mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/dpx: fix reading 12bit dpx images, which have non zero padding bits
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
e1f8184a1a
commit
8cb7d20567
|
@ -25,6 +25,18 @@
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "internal.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)
|
static unsigned int read32(const uint8_t **ptr, int is_big)
|
||||||
{
|
{
|
||||||
unsigned int temp;
|
unsigned int temp;
|
||||||
|
@ -159,11 +171,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||||
av_log(avctx, AV_LOG_ERROR, "Packing to 16bit required\n");
|
av_log(avctx, AV_LOG_ERROR, "Packing to 16bit required\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (endian) {
|
avctx->pix_fmt = AV_PIX_FMT_GBRP12;
|
||||||
avctx->pix_fmt = AV_PIX_FMT_GBRP12BE;
|
|
||||||
} else {
|
|
||||||
avctx->pix_fmt = AV_PIX_FMT_GBRP12LE;
|
|
||||||
}
|
|
||||||
total_size = 2 * avctx->width * avctx->height * elements;
|
total_size = 2 * avctx->width * avctx->height * elements;
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
|
@ -221,18 +229,12 @@ static int decode_frame(AVCodecContext *avctx,
|
||||||
(uint16_t*)ptr[1],
|
(uint16_t*)ptr[1],
|
||||||
(uint16_t*)ptr[2]};
|
(uint16_t*)ptr[2]};
|
||||||
for (y = 0; y < avctx->width; y++) {
|
for (y = 0; y < avctx->width; y++) {
|
||||||
*dst[2] = *((uint16_t*)buf);
|
*dst[2] = read16(&buf, endian) >> 4;
|
||||||
*dst[2] = (*dst[2] >> 4) | (*dst[2] << 12);
|
|
||||||
dst[2]++;
|
dst[2]++;
|
||||||
buf += 2;
|
*dst[0] = read16(&buf, endian) >> 4;
|
||||||
*dst[0] = *((uint16_t*)buf);
|
|
||||||
*dst[0] = (*dst[0] >> 4) | (*dst[0] << 12);
|
|
||||||
dst[0]++;
|
dst[0]++;
|
||||||
buf += 2;
|
*dst[1] = read16(&buf, endian) >> 4;
|
||||||
*dst[1] = *((uint16_t*)buf);
|
|
||||||
*dst[1] = (*dst[1] >> 4) | (*dst[1] << 12);
|
|
||||||
dst[1]++;
|
dst[1]++;
|
||||||
buf += 2;
|
|
||||||
// For 12 bit, ignore alpha
|
// For 12 bit, ignore alpha
|
||||||
if (elements == 4)
|
if (elements == 4)
|
||||||
buf += 2;
|
buf += 2;
|
||||||
|
|
Loading…
Reference in New Issue