Commit 83bf40f3 authored by Carl Eugen Hoyos's avatar Carl Eugen Hoyos

lavc/8bps: Fix 32bit output of 24bit video.

Regression since / partial revert of ba3bb53b
parent 58776ccb
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
static const enum AVPixelFormat pixfmt_rgb24[] = { static const enum AVPixelFormat pixfmt_rgb24[] = {
AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE }; AV_PIX_FMT_BGR24, AV_PIX_FMT_0RGB32, AV_PIX_FMT_NONE };
typedef struct EightBpsContext { typedef struct EightBpsContext {
AVCodecContext *avctx; AVCodecContext *avctx;
...@@ -65,6 +65,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, ...@@ -65,6 +65,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
unsigned int dlen, p, row; unsigned int dlen, p, row;
const unsigned char *lp, *dp, *ep; const unsigned char *lp, *dp, *ep;
unsigned char count; unsigned char count;
unsigned int px_inc;
unsigned int planes = c->planes; unsigned int planes = c->planes;
unsigned char *planemap = c->planemap; unsigned char *planemap = c->planemap;
int ret; int ret;
...@@ -77,6 +78,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, ...@@ -77,6 +78,8 @@ static int decode_frame(AVCodecContext *avctx, void *data,
/* Set data pointer after line lengths */ /* Set data pointer after line lengths */
dp = encoded + planes * (height << 1); dp = encoded + planes * (height << 1);
px_inc = planes + (avctx->pix_fmt == AV_PIX_FMT_0RGB32);
for (p = 0; p < planes; p++) { for (p = 0; p < planes; p++) {
/* Lines length pointer for this plane */ /* Lines length pointer for this plane */
lp = encoded + p * (height << 1); lp = encoded + p * (height << 1);
...@@ -95,21 +98,21 @@ static int decode_frame(AVCodecContext *avctx, void *data, ...@@ -95,21 +98,21 @@ static int decode_frame(AVCodecContext *avctx, void *data,
if ((count = *dp++) <= 127) { if ((count = *dp++) <= 127) {
count++; count++;
dlen -= count + 1; dlen -= count + 1;
if (pixptr_end - pixptr < count * planes) if (pixptr_end - pixptr < count * px_inc)
break; break;
if (ep - dp < count) if (ep - dp < count)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
while (count--) { while (count--) {
*pixptr = *dp++; *pixptr = *dp++;
pixptr += planes; pixptr += px_inc;
} }
} else { } else {
count = 257 - count; count = 257 - count;
if (pixptr_end - pixptr < count * planes) if (pixptr_end - pixptr < count * px_inc)
break; break;
while (count--) { while (count--) {
*pixptr = *dp; *pixptr = *dp;
pixptr += planes; pixptr += px_inc;
} }
dp++; dp++;
dlen -= 2; dlen -= 2;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#define LIBAVCODEC_VERSION_MAJOR 57 #define LIBAVCODEC_VERSION_MAJOR 57
#define LIBAVCODEC_VERSION_MINOR 58 #define LIBAVCODEC_VERSION_MINOR 58
#define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_MICRO 102
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \
......
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