Commit 8cb7d205 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/dpx: fix reading 12bit dpx images, which have non zero padding bits

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent e1f8184a
......@@ -25,6 +25,18 @@
#include "avcodec.h"
#include "internal.h"
static unsigned int read16(const uint8_t **ptr, int is_big)
{
unsigned int temp;
if (is_big) {
temp = AV_RB16(*ptr);
} else {
temp = AV_RL16(*ptr);
}
*ptr += 2;
return temp;
}
static unsigned int read32(const uint8_t **ptr, int is_big)
{
unsigned int temp;
......@@ -159,11 +171,7 @@ static int decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "Packing to 16bit required\n");
return -1;
}
if (endian) {
avctx->pix_fmt = AV_PIX_FMT_GBRP12BE;
} else {
avctx->pix_fmt = AV_PIX_FMT_GBRP12LE;
}
avctx->pix_fmt = AV_PIX_FMT_GBRP12;
total_size = 2 * avctx->width * avctx->height * elements;
break;
case 16:
......@@ -221,18 +229,12 @@ static int decode_frame(AVCodecContext *avctx,
(uint16_t*)ptr[1],
(uint16_t*)ptr[2]};
for (y = 0; y < avctx->width; y++) {
*dst[2] = *((uint16_t*)buf);
*dst[2] = (*dst[2] >> 4) | (*dst[2] << 12);
*dst[2] = read16(&buf, endian) >> 4;
dst[2]++;
buf += 2;
*dst[0] = *((uint16_t*)buf);
*dst[0] = (*dst[0] >> 4) | (*dst[0] << 12);
*dst[0] = read16(&buf, endian) >> 4;
dst[0]++;
buf += 2;
*dst[1] = *((uint16_t*)buf);
*dst[1] = (*dst[1] >> 4) | (*dst[1] << 12);
*dst[1] = read16(&buf, endian) >> 4;
dst[1]++;
buf += 2;
// For 12 bit, ignore alpha
if (elements == 4)
buf += 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment