Hi, the attached patch improves the decoding of ticket #3692 by following S268M-2003.
Unfortunately, that probably means ffmpeg's dpx encoder is not compliant to these specifications. -- Christophe
From 4ba2ec15c9a111fb4e20523d5a8fa337bedee92d Mon Sep 17 00:00:00 2001 From: Christophe Gisquet <christophe.gisq...@gmail.com> Date: Wed, 13 Aug 2014 00:37:00 +0200 Subject: [PATCH 1/3] dpx: use aligned line starts SMPTE 268M-2003 specifies that each line starts at a 4-bytes boundary. Therefore, modify correspondingly the input buffer strides and size. Partially fixes ticket #3692: DLAD_8b_3c_big.dpx still has inverted colors, which might be related to endianness. --- libavcodec/dpx.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 5f05cd8..2fa549c 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -77,7 +77,7 @@ static int decode_frame(AVCodecContext *avctx, unsigned int offset; int magic_num, endian; - int x, y, i, ret; + int x, y, stride, i, ret; int w, h, bits_per_color, descriptor, elements, packing, total_size; int encoding; @@ -175,24 +175,24 @@ static int decode_frame(AVCodecContext *avctx, switch (bits_per_color) { case 8: - total_size = avctx->width * avctx->height * elements; + stride = avctx->width * elements; break; case 10: if (!packing) { av_log(avctx, AV_LOG_ERROR, "Packing to 32bit required\n"); return -1; } - total_size = (avctx->width * elements + 2) / 3 * 4 * avctx->height; + stride = (avctx->width * elements + 2) / 3 * 4; break; case 12: if (!packing) { av_log(avctx, AV_LOG_ERROR, "Packing to 16bit required\n"); return -1; } - total_size = 2 * avctx->width * avctx->height * elements; + stride = 2 * avctx->width * elements; break; case 16: - total_size = 2 * avctx->width * avctx->height * elements; + stride = 2 * avctx->width * elements; break; case 1: case 32: @@ -203,6 +203,11 @@ static int decode_frame(AVCodecContext *avctx, return AVERROR_INVALIDDATA; } + // Table 3c: Runs will always break at scan line boundaries. Packing + // will always break to the next 32-bit word at scan-line boundaries. + stride = FFALIGN(stride, 4); + total_size = stride*avctx->height; + switch (1000 * descriptor + 10 * bits_per_color + endian) { case 6081: case 6080: @@ -308,6 +313,8 @@ static int decode_frame(AVCodecContext *avctx, // For 12 bit, ignore alpha if (elements == 4) buf += 2; + // Jump to next aligned position + buf += stride - 6*avctx->width; } for (i = 0; i < 3; i++) ptr[i] += p->linesize[i]; @@ -317,7 +324,7 @@ static int decode_frame(AVCodecContext *avctx, elements *= 2; case 8: av_image_copy_plane(ptr[0], p->linesize[0], - buf, elements * avctx->width, + buf, stride, elements * avctx->width, avctx->height); break; } -- 1.9.2.msysgit.0
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel