[FFmpeg-devel] [PATCH] avcodec: add Actimagine VX video decoder

Florian Nouwt fnouwt2 at gmail.com
Mon Mar 15 20:37:03 EET 2021


I'll have a look if functions can be reused. If it's the case, the same
could likely be done to the mobiclip decoder too since that one does a lot
of stuff in a similar way.
The "idct" looks very similar to "ff_h264_idct_add" in h264idct_template.c.
Which would make sense since the codec is largely based on techniques used
in h264. In that function the order seems to be reversed though
(column->row, row->row instead of row->column, row->row) and I wonder if
that can have any impact on the output? (Rounding errors or so)
I think there's a good chance that h264 prediction functions can also be
used. I will check if they are 100% equal.

I have a question about the color space btw. This format uses a yuv
approximation based on bit shifting as I described in the init function.
Currently it is not supported by ffmpeg. Would there be a way to add it or
so? The regular yuv coefficients do look alright, but it is not correct.
Everything is a bit less saturated or so.

Op ma 15 mrt. 2021 18:34 schreef Lynne <dev at lynne.ee>:

> Mar 15, 2021, 16:09 by fnouwt2 at gmail.com:
>
> > Signed-off-by: Florian Nouwt <fnouwt2 at gmail.com>
> > ---
> >  Changelog                    |    1 +
> >  configure                    |    1 +
> >  doc/general_contents.texi    |    2 +
> >  libavcodec/Makefile          |    3 +-
> >  libavcodec/actimagine.c      | 1523 ++++++++++++++++++++++++++++++++++
> >  libavcodec/allcodecs.c       |    1 +
> >  libavcodec/codec_desc.c      |    7 +
> >  libavcodec/codec_id.h        |    1 +
> >  libavcodec/h264_cavlc.c      |  135 +--
> >  libavcodec/h264_cavlc_data.c |  140 ++++
> >  libavcodec/h264_cavlc_data.h |   33 +
> >  libavcodec/version.h         |    2 +-
> >  libavformat/riff.c           |    2 +
> >  13 files changed, 1723 insertions(+), 128 deletions(-)
> >  create mode 100644 libavcodec/actimagine.c
> >  create mode 100644 libavcodec/h264_cavlc_data.c
> >  create mode 100644 libavcodec/h264_cavlc_data.h
> >
> > +static void decode_dct(AVCodecContext *avctx, int x, int y, int plane,
> > +                       const int* level)
> > +{
> > +    int a, b, c, d, e, f;
> > +    int dct[16];
> > +    int tmp[16];
> > +    ActimagineContext *s = avctx->priv_data;
> > +
> > +    // dezigzag
> > +    for (int i = 0; i < 16; i++)
> > +        dct[zigzag4x4_tab[i]] = level[i];
> > +
> > +    // dequantize
> > +    for (int i = 0; i < 2; i++) {
> > +        for (int j = 0; j < 4; j++) {
> > +            dct[4 * j + i]     *= s->qtab[i][j];
> > +            dct[4 * j + i + 2] *= s->qtab[i][j];
> > +        }
> > +    }
> > +
> > +    dct[0] += 32;// rounding
> > +
> > +    for (int i = 0; i < 4; i++) {
> > +        a = dct[i * 4 + 0];
> > +        b = dct[i * 4 + 1];
> > +        c = dct[i * 4 + 2];
> > +        d = dct[i * 4 + 3];
> > +        a += c;
> > +        c = a - c * 2;
> > +        e = (b >> 1) - d;
> > +        f = b + (d >> 1);
> > +        tmp[ 0 + i] = a + f;
> > +        tmp[ 4 + i] = c + e;
> > +        tmp[ 8 + i] = c - e;
> > +        tmp[12 + i] = a - f;
> > +    }
> > +
> > +    for (int i = 0; i < 4; i++) {
> > +        a = tmp[i * 4 + 0];
> > +        b = tmp[i * 4 + 1];
> > +        c = tmp[i * 4 + 2];
> > +        d = tmp[i * 4 + 3];
> > +        a += c;
> > +        c =  a - c * 2;
> > +        e  = (b >> 1) - d;
> > +        f = b + (d >> 1);
> > +        PIXEL_CUR(s, plane, x + 0, y + i)
> > +            = av_clip_uint8(PIXEL_CUR(s, plane, x + 0, y + i) + ((a +
> f) >> 6));
> > +        PIXEL_CUR(s, plane, x + 1, y + i)
> > +            = av_clip_uint8(PIXEL_CUR(s, plane, x + 1, y + i) + ((c +
> e) >> 6));
> > +        PIXEL_CUR(s, plane, x + 2, y + i)
> > +            = av_clip_uint8(PIXEL_CUR(s, plane, x + 2, y + i) + ((c -
> e) >> 6));
> > +        PIXEL_CUR(s, plane, x + 3, y + i)
> > +            = av_clip_uint8(PIXEL_CUR(s, plane, x + 3, y + i) + ((a -
> f) >> 6));
> > +    }
> > +}
> >
>
> This isn't really a DCT but a WHT approximation of one. We have some
> DSP functions with assembly written for this. Some have suggested that
> it's similar to H264's. The predictors also look similiar to it.
> Could you take a look whether you can reuse them (iwht4_1d in
> libavcodec/vp9dsp_template.c), or if not, maybe rename the function
> to decode_wht?
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list