aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/pcxenc.c
diff options
context:
space:
mode:
authorFrank Vernaillen <fr_ve@hotmail.com>2011-12-27 20:47:49 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-12-27 23:51:02 +0100
commitad1c50255735c20bd86572d3e8b3c88a5ca6c8f1 (patch)
treef9e9406ec9cec9c3f63f5fde38229200fdea06b8 /libavcodec/pcxenc.c
parent29c1b258abac40c43783477af9852830868c14c8 (diff)
downloadffmpeg-ad1c50255735c20bd86572d3e8b3c88a5ca6c8f1.tar.gz
Fixed crash in palette handling when converting certain .png images to .pcx or .bmp.
The existing code expected a palette buffer holding 256 uint32_t's allocated in the data[1] field of the AVFrame structure, but data[1] was NULL. The bug is fixed by using a fixed local array (palette256) to hold the palette instead. This solves http://ffmpeg.org/trac/ffmpeg/ticket/833 Signed-off-by: Frank Vernaillen <fr_ve@hotmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pcxenc.c')
-rw-r--r--libavcodec/pcxenc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c
index 816223e736..a39e221805 100644
--- a/libavcodec/pcxenc.c
+++ b/libavcodec/pcxenc.c
@@ -28,6 +28,7 @@
#include "avcodec.h"
#include "bytestream.h"
+#include "libavutil/imgutils.h"
typedef struct PCXContext {
AVFrame picture;
@@ -105,6 +106,7 @@ static int pcx_encode_frame(AVCodecContext *avctx,
int bpp, nplanes, i, y, line_bytes, written;
const uint32_t *pal = NULL;
+ uint32_t palette256[256];
const uint8_t *src;
*pict = *(AVFrame *)data;
@@ -126,6 +128,11 @@ static int pcx_encode_frame(AVCodecContext *avctx,
case PIX_FMT_RGB4_BYTE:
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_GRAY8:
+ bpp = 8;
+ nplanes = 1;
+ ff_set_systematic_pal2(palette256, avctx->pix_fmt);
+ pal = palette256;
+ break;
case PIX_FMT_PAL8:
bpp = 8;
nplanes = 1;