[FFmpeg-devel] [PATCH 1/2] Fix DPX decoder

Michael Niedermayer michaelni at gmx.at
Sat Oct 6 00:11:42 CEST 2012


On Fri, Oct 05, 2012 at 10:42:17PM +0200, Georg Lippitsch wrote:
> Rewrite the DPX decoder to work with provided sample DPXs at
> http://samples.ffmpeg.org/image-samples/dpx_samples.zip
> 
> The decoder could only decode 8 and 10 bit without alpha correctly,
> failing or even crashing at other flavors. This patch aims to fix
> these issues, properly decoding all variants of DPX provided in the
> referenced DPX sample zip. For 10 and 12 bit, the alpha channel
> is ignored, but decoding is still possible.
> ---
>  libavcodec/dpx.c |  157 +++++++++++++++++++++++++++++-------------------------
>  1 files changed, 84 insertions(+), 73 deletions(-)
> 
> diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
> index 71cf439..5d0ac2a 100644
> --- a/libavcodec/dpx.c
> +++ b/libavcodec/dpx.c
> @@ -41,6 +41,19 @@ static unsigned int read32(const uint8_t **ptr, int is_big)
>      return temp;
>  }
>  
> +static uint16_t read10in32(const uint8_t **ptr, uint32_t * lbuf,
> +                                  int * n_datum, int is_big)
> +{
> +    if (*n_datum)
> +        (*n_datum)--;
> +    else {
> +        *lbuf = read32(ptr, is_big);
> +        *n_datum = 2;
> +    }
> +
> +    return ((*lbuf) >> (*n_datum * 10 + 2)) & 0x3FF;
> +}

i suspect this is quite slow and its used per sample


[...]
> @@ -180,68 +191,68 @@ static int decode_frame(AVCodecContext *avctx,
>  
>      for (i=0; i<AV_NUM_DATA_POINTERS; i++)
>          ptr[i] = p->data[i];
> -    stride = p->linesize[0];
>  
> -    if (source_packet_size*avctx->width*avctx->height > buf_end - buf) {
> +    if (elements * avctx->width * avctx->height > buf_end - buf) {
>          av_log(avctx, AV_LOG_ERROR, "Overread buffer. Invalid header?\n");
>          return -1;
>      }

this looks wrong for >8bit

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

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121006/7defa1b5/attachment.asc>


More information about the ffmpeg-devel mailing list