aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/dpx.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-10-05 01:31:15 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-10-05 01:31:15 +0200
commit8cb7d20567052e205406cee5efe98c7269184942 (patch)
treecad08229e23e2cdad810ef88a47c70393869deba /libavcodec/dpx.c
parente1f8184a1a973fd7de1bf53578d09661ec7bad75 (diff)
downloadandroid_external_ffmpeg-8cb7d20567052e205406cee5efe98c7269184942.tar.gz
android_external_ffmpeg-8cb7d20567052e205406cee5efe98c7269184942.tar.bz2
android_external_ffmpeg-8cb7d20567052e205406cee5efe98c7269184942.zip
avcodec/dpx: fix reading 12bit dpx images, which have non zero padding bits
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/dpx.c')
-rw-r--r--libavcodec/dpx.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index 6c3d53604a..11f692fea4 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -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;