You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
Move get_buffer() calls from decode_init() to decode_frame(). Anything else is
unsupported and causes crashes when libavfilter is enabled. Patch by Sebastian Vater <cdgs basty googlemail com>. Originally committed as revision 23411 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
committed by
Ronald S. Bultje
parent
54b11f1743
commit
522d3930ff
@@ -34,6 +34,7 @@ typedef struct {
|
|||||||
AVFrame frame;
|
AVFrame frame;
|
||||||
int planesize;
|
int planesize;
|
||||||
uint8_t * planebuf;
|
uint8_t * planebuf;
|
||||||
|
int init; // 1 if buffer and palette data already initialized, 0 otherwise
|
||||||
} IffContext;
|
} IffContext;
|
||||||
|
|
||||||
#define LUT8_PART(plane, v) \
|
#define LUT8_PART(plane, v) \
|
||||||
@@ -167,14 +168,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
s->frame.reference = 1;
|
s->frame.reference = 1;
|
||||||
if ((err = avctx->get_buffer(avctx, &s->frame) < 0)) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (avctx->bits_per_coded_sample <= 8 &&
|
return 0;
|
||||||
avctx->pix_fmt != PIX_FMT_GRAY8) ?
|
|
||||||
ff_cmap_read_palette(avctx, (uint32_t*)s->frame.data[1]) : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -258,12 +253,21 @@ static int decode_frame_ilbm(AVCodecContext *avctx,
|
|||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
const uint8_t *buf_end = buf+buf_size;
|
const uint8_t *buf_end = buf+buf_size;
|
||||||
int y, plane;
|
int y, plane, res;
|
||||||
|
|
||||||
if (avctx->reget_buffer(avctx, &s->frame) < 0){
|
if (s->init) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
if ((res = avctx->reget_buffer(avctx, &s->frame)) < 0) {
|
||||||
return -1;
|
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
} else if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||||
|
return res;
|
||||||
|
} else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt != PIX_FMT_GRAY8) {
|
||||||
|
if ((res = ff_cmap_read_palette(avctx, (uint32_t*)s->frame.data[1])) < 0)
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
s->init = 1;
|
||||||
|
|
||||||
if (avctx->codec_tag == MKTAG('I','L','B','M')) { // interleaved
|
if (avctx->codec_tag == MKTAG('I','L','B','M')) { // interleaved
|
||||||
if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) {
|
if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) {
|
||||||
@@ -306,12 +310,21 @@ static int decode_frame_byterun1(AVCodecContext *avctx,
|
|||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
const uint8_t *buf_end = buf+buf_size;
|
const uint8_t *buf_end = buf+buf_size;
|
||||||
int y, plane;
|
int y, plane, res;
|
||||||
|
|
||||||
if (avctx->reget_buffer(avctx, &s->frame) < 0){
|
if (s->init) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
if ((res = avctx->reget_buffer(avctx, &s->frame)) < 0) {
|
||||||
return -1;
|
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
} else if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||||
|
return res;
|
||||||
|
} else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt != PIX_FMT_GRAY8) {
|
||||||
|
if ((res = ff_cmap_read_palette(avctx, (uint32_t*)s->frame.data[1])) < 0)
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
s->init = 1;
|
||||||
|
|
||||||
if (avctx->codec_tag == MKTAG('I','L','B','M')) { //interleaved
|
if (avctx->codec_tag == MKTAG('I','L','B','M')) { //interleaved
|
||||||
if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) {
|
if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) {
|
||||||
|
Reference in New Issue
Block a user