< From: Ferdinand Oeinck <[email protected]>
> Date: Mon, 6 Apr 2015 15:47:14 +0200
> Subject: [PATCH] hqx: Implement multithread slice decoding
>
> ---
>  libavcodec/hqx.c | 142 
> +++++++++++++++++++++++++++++++++++--------------------
>  libavcodec/hqx.h |   9 +++-
>  2 files changed, 99 insertions(+), 52 deletions(-)
>
> +typedef struct
> +{
> +    AVFrame *pic;
> +    uint8_t *src;
> +    GetBitContext gb[17];
> +    unsigned data_size;
> +    mb_decode_func decode_func;
> +    uint32_t slice_off[17];
> +} data_t;

I would recommend a more appropriate name, such as HQXThreadData,
which is similarly used in other codecs.

> +
> +static int decode_slice_thread(AVCodecContext *avctx, void *arg, int slice, 
> int threadnr)
> +{
> +    DECLARE_ALIGNED(16, int16_t, block)[16][64];
> +
> +    data_t * data = (data_t*) arg;
> +    uint32_t * slice_off = data->slice_off;
> +    unsigned data_size = data->data_size;
> +    if (slice_off[slice] < HQX_HEADER_SIZE ||
> +        slice_off[slice] >= slice_off[slice + 1] ||
> +        slice_off[slice + 1] > data_size) {
> +        av_log(avctx, AV_LOG_ERROR, "Invalid slice size.\n");
> +        return AVERROR_INVALIDDATA;
> +    }
> +    int ret = init_get_bits8(&data->gb[slice], data->src + slice_off[slice],
> +        slice_off[slice + 1] - slice_off[slice]);
> +    if (ret < 0)
> +        return ret;
> +    HQXContext *ctx = avctx->priv_data;

This won't compile, all variables need to be declared at the very top
of the function.

> +    ret = decode_slice(ctx, data->pic, &data->gb[slice], slice, 
> data->decode_func);
> +    if (ret < 0) {
> +        av_log(avctx, AV_LOG_ERROR, "Error decoding slice %d.\n", slice);
> +    }
> +    return ret;
> +}
> +
>  static int hqx_decode_frame(AVCodecContext *avctx, void *data,
>                              int *got_picture_ptr, AVPacket *avpkt)
>  {
> @@ -583,6 +619,10 @@ static int hqx_decode_frame(AVCodecContext *avctx, void 
> *data,
>      if (ret < 0)
>          return ret;
>
> +
> +    avctx->execute2(avctx, decode_slice_thread, &arg_data, NULL, 16);
> +
> +#if 0
>      for (slice = 0; slice < 16; slice++) {
>          if (slice_off[slice] < HQX_HEADER_SIZE ||
>              slice_off[slice] >= slice_off[slice + 1] ||
> @@ -599,7 +639,7 @@ static int hqx_decode_frame(AVCodecContext *avctx, void 
> *data,
>              av_log(avctx, AV_LOG_ERROR, "Error decoding slice %d.\n", slice);
>          }
>      }
> -
> +#endif

There is no need to keep this block of code in a #if 0 statement,
after all changes will be stored by git.
Just remove it if it is no longer needed.

> @@ -46,11 +46,18 @@ typedef struct HQXAC {
>      const HQXLUT *lut;
>  } HQXAC;
>
> +
> +typedef struct slice_data_t
> +{
> +    DECLARE_ALIGNED(16, int16_t, block)[16][64];
> +
> +}slice_data_t;
> +

Similarly to above, a more appropriate name would be HQXSliceCOntext.

>  typedef struct HQXContext {
>      int format, dcb, width, height;
>      int interlaced;
>
> -    DECLARE_ALIGNED(16, int16_t, block)[16][64];
> +    slice_data_t slice[17];


Patch 2 wrt clipping should be fine, thank you.
Vittorio
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to