[FFmpeg-devel] [PATCH] MOV: support stz2 "Compact Sample Size Box"

Michael Niedermayer michaelni
Fri Mar 6 21:42:36 CET 2009


On Fri, Mar 06, 2009 at 03:07:03PM -0500, Alex Converse wrote:
> 2009/3/3 Michael Niedermayer <michaelni at gmx.at>:
> > On Tue, Mar 03, 2009 at 02:45:15AM -0500, Alex Converse wrote:
> > [...]
> >> @@ -1143,8 +1150,33 @@ static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
> >> ? ? ?if (!sc->sample_sizes)
> >> ? ? ? ? ?return AVERROR(ENOMEM);
> >>
> >> + ? ?switch(field_size) {
> >> + ? ?case 4:
> >> + ? ? ? ?for(i=0; i<entries-1; i+=2) {
> >> + ? ? ? ? ? ?int field = get_byte(pb);
> >> + ? ? ? ? ? ?sc->sample_sizes[i ?] = field >> 4;
> >> + ? ? ? ? ? ?sc->sample_sizes[i+1] = field & 0xF;
> >> + ? ? ? ?}
> >> + ? ? ? ?if(entries&1) {
> >> + ? ? ? ? ? ?sc->sample_sizes[entries-1] = get_byte(pb) >> 4;
> >> + ? ? ? ?}
> >> + ? ? ? ?break;
> >> + ? ?case 8:
> >> + ? ? ? ?for(i=0; i<entries; i++)
> >> + ? ? ? ? ? ?sc->sample_sizes[i] = get_byte(pb);
> >> + ? ? ? ?break;
> >> + ? ?case 16:
> >> + ? ? ? ?for(i=0; i<entries; i++)
> >> + ? ? ? ? ? ?sc->sample_sizes[i] = get_be16(pb);
> >> + ? ? ? ?break;
> >> + ? ?case 32:
> >> ? ? ?for(i=0; i<entries; i++)
> >> ? ? ? ? ?sc->sample_sizes[i] = get_be32(pb);
> >> + ? ? ? ?break;
> >> + ? ?default:
> >> + ? ? ? ?av_log(c->fc, AV_LOG_ERROR, "Invalid sample field size %d\n", field_size);
> >> + ? ? ? ?return -1;
> >> + ? ?}
> >
> > I think that should be using GetBitContext
> >
> 
> Are you sure that's the best approach? 

no, but iam fairly sure above is worse ;)
this code isnt speed critical, theres no sense in bloating the
loops up like that ...


> The only thing that doesn't use
> whole multiples bytes are half bytes and they are required to begin
> and are padded to byte alignment. (And obviously 2 of them fit very
> nicely into a byte.) Right now the mov demuxer doesn't use a
> GetBitContext at all.
> 
> If you do think it's the way to go can you point me to somewhere that
> switches back and forth between ByteIOContext to GetBitContext to use
> as an example?

grep GetBitCo libavformat/*c

and iam not saying GetBitContext is pretty when used with ByteIOContext,
maybe theres a better choice ...

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090306/bc3f6063/attachment.pgp>



More information about the ffmpeg-devel mailing list