Mar 15, 2021, 16:09 by [email protected]:

> Signed-off-by: Florian Nouwt <[email protected]>
> ---
>  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
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to