[FFmpeg-devel] [PATCH] Musepack SV8 demuxer and decoder

Kostya kostya.shishkov
Sun Nov 4 13:12:04 CET 2007


On Sun, Nov 04, 2007 at 12:58:22AM +0100, Michael Niedermayer wrote:
> Hi
 
[...]

> > +    int code;
> > +    const uint32_t * C = mpc8_cnk[k-1];
> > +
> > +    code = mpc8_dec_base(gb, k, n);
> 
> int code = mpc8_dec_base(gb, k, n);
 
done
 
> [...]
> > +    if(keyframe){
> > +        c->buf_size = buf_size;
> > +        c->bits = av_realloc(c->bits, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
> > +        memcpy(c->bits, buf, buf_size);
> > +        init_get_bits(gb, c->bits, buf_size * 8);
> > +        memset(c->Q, 0, sizeof(c->Q));
> > +    c->last_bits_used = 0;
> > +    }
> 
> please remove this realloc() and memcpy() mess and decode the individual
> frames which your decoder receives from the parser

I fear it would be overkill as parser needs to effectively duplicate decode_frame().
MPC SV8 stores several frames in one packet, first of them is keyframe, they should
be parsed as single bitstream with no byte paddings. Also there is no way to determine
frame length without decoding it and using correct information from previous frame
to decode current frame.
 
> [...]
> > +                    if(cnt && cnt < SAMPLES_PER_BAND/2)
> > +                        t = mpc8_dec_enum(gb, FFMIN(cnt, 18-cnt), 18);
> > +                    if(cnt > 9) t = ~t;
> 
> the code surrounding mpc8_dec_enum() can be factorized, it occurs several
> times

made it mpc8_get_mask() 
 
> [...]
> > +                    if(bands[i].res[ch] != 9){
> 
> res != 9
 
done
 
> [...]
> > +static const int mpc8_rate[4] = { 44100, 48000, 37800, 32000 };
> 
> too small, index can be up to 7

filled with -1 for now as they might add more samplerates there 
 
> [...]
> > +    int64_t silence;
> 
> unused

dropped 
 
> [...]
> > +    av_set_pts_info(st, 32, 1152 * (1 << (st->codec->extradata[1]&3)*2), st->codec->sample_rate);
> > +    st->duration = c->samples / (1152 * (1 << (st->codec->extradata[1]&3)*2));
> 
> (1152 << (st->codec->extradata[1]&3)*2)

done 
 
> > +    size -= url_ftell(pb) - pos;
> > +    
> > +    return 0;
> 
> useless statement befoe return

dropped 
 
> [...]
> > +AVInputFormat mpc8_demuxer = {
> > +    "mpc8",
> > +    "musepack8",
> > +    sizeof(MPCContext),
> > +    mpc8_probe,
> > +    mpc8_read_header,
> > +    mpc8_read_packet,
> > +    NULL,
> > +    mpc8_read_seek,
> > +    .extensions = "mpc",
> > +};
> 
> if you have a probe function. then you dont really need extensions

dropped 
 
> [...]
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mpc8.patch.gz
Type: application/x-gzip
Size: 11501 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071104/48833e51/attachment.bin>



More information about the ffmpeg-devel mailing list