On Tue, Mar 31, 2015 at 4:31 PM, Diego Biurrun <[email protected]> wrote:
> From: Kostya Shishkov <[email protected]>
>
> ELS and ePIC decoder courtesy of Maxim Poliakovski,
> cleanup and integration by Diego Biurrun.
>
> Signed-off-by: Diego Biurrun <[email protected]>
> ---
>
> Now states Go2Meeting support prominently in the file header,
> as requested by Kostya.
>
>  Changelog            |   1 +
>  doc/general.texi     |   2 +
>  libavcodec/Makefile  |   2 +-
>  libavcodec/elsdec.c  | 411 ++++++++++++++++++++++++++++
>  libavcodec/elsdec.h  |  60 ++++
>  libavcodec/g2meet.c  | 757 
> +++++++++++++++++++++++++++++++++++++++++++++++++--
>  libavcodec/version.h |   2 +-
>  7 files changed, 1209 insertions(+), 26 deletions(-)
>  create mode 100644 libavcodec/elsdec.c
>  create mode 100644 libavcodec/elsdec.h
> --- /dev/null
> +++ b/libavcodec/elsdec.c
> +    { -1,  -72, 169, 145 },
> +    { -6,   -5, 168,  49 },
> +    {  0, -108, 171, 171 },
> +    {  0, -108, 172, 172 },
> +    { -6,   -5, 173, 173 }

nit: comma at the end

> +};
> +
> +static int els_exp_tab[ELS_JOTS_PER_BYTE * 4 + 1];
> +static const int *pAllowable = &els_exp_tab[ELS_JOTS_PER_BYTE * 3];

Is there no way to avoid the static variables here? Maybe the could be
members of ElsDecCtx.

> +av_cold void ff_els_generate_exp_table(void)
> +{
> +    int i;
> +    float jot_size = 8.0f / ELS_JOTS_PER_BYTE;
> +
> +    for (i = 0; i < ELS_JOTS_PER_BYTE; i++) {
> +        els_exp_tab[i]                         = 0;
> +        els_exp_tab[i + ELS_JOTS_PER_BYTE * 2] = floor(pow(2.0f, (i + 
> ELS_JOTS_PER_BYTE) * jot_size));
> +        els_exp_tab[i + ELS_JOTS_PER_BYTE]     = els_exp_tab[i + 
> ELS_JOTS_PER_BYTE * 2] >> 8;
> +        els_exp_tab[i + ELS_JOTS_PER_BYTE * 3] = els_exp_tab[i + 
> ELS_JOTS_PER_BYTE * 2] << 8;
> +    }
> +
> +    els_exp_tab[ELS_JOTS_PER_BYTE * 4] = ELS_MAX;
> +}
> diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
> index 475c244..8880268 100644
> --- a/libavcodec/g2meet.c
> +++ b/libavcodec/g2meet.c
>  typedef struct G2MContext {
> -    JPGContext jc;
> +    ePICContext ec;
> +    JPGContext  jc;

imho needless whitespace

>      int        version;
>
>      int        compression;
> @@ -101,8 +144,9 @@ typedef struct G2MContext {
>      uint8_t    *framebuf;
>      int        framebuf_stride, old_width, old_height;
>
> -    uint8_t    *synth_tile, *jpeg_tile;
> -    int        tile_stride, old_tile_w, old_tile_h;
> +    uint8_t    *synth_tile, *jpeg_tile, *epic_buf, *epic_buf_base;
> +    int        tile_stride, epic_buf_stride, old_tile_w, old_tile_h;
> +    int        swapuv;
>
>      uint8_t    *kempf_buf, *kempf_flags;
>
> @@ -179,7 +223,7 @@ static void jpg_unescape(const uint8_t *src, int src_size,
>                           uint8_t *dst, int *dst_size)
>  {
>      const uint8_t *src_end = src + src_size;
> -    uint8_t *dst_start = dst;
> +    uint8_t *dst_start     = dst;

unrelated?

>      while (src < src_end) {
>          uint8_t x = *src++;
> @@ -229,11 +273,11 @@ static int jpg_decode_block(JPGContext *c, 
> GetBitContext *gb,
>      return 0;
>  }
>
> @@ -663,7 +1372,7 @@ static int g2m_decode_frame(AVCodecContext *avctx, void 
> *data,
>                              int *got_picture_ptr, AVPacket *avpkt)
>  {
>      const uint8_t *buf = avpkt->data;
> -    int buf_size = avpkt->size;
> +    int buf_size       = avpkt->size;

unrelated?

>      G2MContext *c = avctx->priv_data;
>      AVFrame *pic = data;
>      GetByteContext bc, tbc;
> @@ -874,6 +1580,8 @@ static av_cold int g2m_decode_init(AVCodecContext *avctx)
>      G2MContext *const c = avctx->priv_data;
>      int ret;
>
> +    ff_els_generate_exp_table();
> +
>      if ((ret = jpg_init(avctx, &c->jc)) != 0) {
>          av_log(avctx, AV_LOG_ERROR, "Cannot initialise VLCs\n");
>          jpg_free_context(&c->jc);
> @@ -895,6 +1603,7 @@ static av_cold int g2m_decode_end(AVCodecContext *avctx)
>
>      jpg_free_context(&c->jc);
>
> +    av_freep(&c->epic_buf_base);
>      av_freep(&c->kempf_buf);
>      av_freep(&c->kempf_flags);
>      av_freep(&c->synth_tile);

If you get to remove the static variable you could mark this decoder
as FF_CODEC_CAP_INIT_THREADSAFE,
and if you remove "jpg_free_context(&c->jc);" you may mark this
decoder as FF_CODEC_CAP_INIT_CLEANUP too.

Looks very nice otherwise.
-- 
Vittorio
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to