[FFmpeg-devel] [PATCH 1/2] Fix DPX decoder Rewrite the DPX decoder to work with provided sample DPXs

Michael Niedermayer michaelni at gmx.at
Fri Oct 5 00:07:53 CEST 2012


On Thu, Oct 04, 2012 at 07:48:48PM +0200, Georg Lippitsch wrote:
> ---
>  libavcodec/dpx.c |  157 +++++++++++++++++++++++++++++-------------------------
>  1 files changed, 84 insertions(+), 73 deletions(-)
> 
> diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
> index 71cf439..45cd1fc 100644
> --- a/libavcodec/dpx.c
> +++ b/libavcodec/dpx.c
> @@ -41,6 +41,22 @@ 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)
> +{
> +    uint16_t temp;
> +
> +    if (!(*n_datum % 3)) {
> +         *lbuf = read32(ptr, is_big);
> +    }

modulo (%) is slow, please avoid it in the inner loops


> +
> +    temp = ((*lbuf) >> ((2 - *n_datum % 3) * 10 + 2)) & 0x3FF;
> +
> +    (*n_datum)++;
> +
> +    return temp;
> +}
> +
>  static int decode_frame(AVCodecContext *avctx,
>                          void *data,
>                          int *data_size,
> @@ -57,10 +73,10 @@ static int decode_frame(AVCodecContext *avctx,
>      unsigned int offset;
>      int magic_num, endian;
>      int x, y, i;
> -    int w, h, stride, bits_per_color, descriptor, elements, target_packet_size, source_packet_size;
> -    int planar;
> +    int w, h, bits_per_color, descriptor, elements, packing;
>  
> -    unsigned int rgbBuffer;
> +    unsigned int rgbBuffer = 0;
> +    int n_datum = 0;
>  
>      if (avpkt->size <= 1634) {
>          av_log(avctx, AV_LOG_ERROR, "Packet too small for DPX header\n");
> @@ -99,8 +115,10 @@ static int decode_frame(AVCodecContext *avctx,
>      buf += 3;
>      avctx->bits_per_raw_sample =
>      bits_per_color = buf[0];
> +    buf++;
> +    packing = *((uint16_t*)buf);
[...]
> +    case 12:
> +        for (x = 0; x < avctx->height; x++) {
> +            uint16_t *dst[3] = {(uint16_t*)ptr[0],
> +                                (uint16_t*)ptr[1],
> +                                (uint16_t*)ptr[2]};
> +            for (y = 0; y < avctx->width; y++) {
> +                *dst[2] = *((uint16_t*)buf) >> 4;
> +                dst[2]++;
> +                buf += 2;
> +                *dst[0] = *((uint16_t*)buf) >> 4;

all this cast and dereference code doesnt look endian safe

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

There seems to be only one solution to NIH syndrom, ... a shooting squad
-------------- 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/20121005/fb5d81d1/attachment.asc>


More information about the ffmpeg-devel mailing list