[FFmpeg-devel] [PATCH 1/2] avcodec: add HCOM decoder

Michael Niedermayer michael at niedermayer.cc
Sun Jan 20 01:09:23 EET 2019


On Wed, Jan 02, 2019 at 06:12:08PM -0300, James Almer wrote:
> On 1/2/2019 3:53 PM, Paul B Mahol wrote:
> > +static int hcom_decode(AVCodecContext *avctx, void *data,
> > +                       int *got_frame, AVPacket *pkt)
> > +{
> > +    HCOMContext *s = avctx->priv_data;
> > +    AVFrame *frame = data;
> > +    GetByteContext gb;
> > +    uint32_t current;
> > +    int ret, n = 0;
> > +
> > +    if (pkt->size > INT16_MAX)
> > +        return AVERROR_INVALIDDATA;
> > +
> > +    frame->nb_samples = pkt->size * 8;
> > +    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
> > +        return ret;
> > +
> > +    bytestream2_init(&gb, pkt->data, pkt->size);
> > +    while (bytestream2_get_bytes_left(&gb) >= 4) {
> > +        int bits = 32;
> > +
> > +        current = bytestream2_get_be32(&gb);
> > +
> > +        while (bits-- > 0) {
> > +
> > +            if (current & 0x80000000) {
> > +                s->dict_entry = s->dict[s->dict_entry].r;
> > +            } else {
> > +                s->dict_entry = s->dict[s->dict_entry].l;
> > +            }
> > +
> > +            current = current << 1;
> 
> This sounds like get_bits is a better fit than bytestream2 for this decoder.

this looks like a standard vlc/huffman reader
and could be using the existing vlc code (init_vlc / get_vlc2 / ...)

thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190120/64362d83/attachment.sig>


More information about the ffmpeg-devel mailing list