summaryrefslogtreecommitdiffstats
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorMatthieu Bouron <matthieu.bouron@stupeflix.com>2015-12-14 17:49:48 +0100
committerMatthieu Bouron <matthieu.bouron@stupeflix.com>2015-12-15 10:35:47 +0100
commitae1c750cb49ff5d6641a11cd9765da1150e6a9bd (patch)
tree7350454e52562b772663de3fbd03327817752e21 /libavcodec/utils.c
parent0c59d40ae06b680de366663d77b4124947813367 (diff)
downloadffmpeg-streaming-ae1c750cb49ff5d6641a11cd9765da1150e6a9bd.zip
ffmpeg-streaming-ae1c750cb49ff5d6641a11cd9765da1150e6a9bd.tar.gz
lavc/utils: use AVPixFmtDescriptor to probe palette formats
Also use the input frame format instead of the AVCodecContext one according to the documentation of AVCodecContext.get_buffer2().
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 9a7ffde..94ec2f6 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -646,6 +646,7 @@ fail:
static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
{
FramePool *pool = s->internal->pool;
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pic->format);
int i;
if (pic->data[0]) {
@@ -653,6 +654,13 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
return -1;
}
+ if (!desc) {
+ av_log(s, AV_LOG_ERROR,
+ "Unable to get pixel format descriptor for format %s\n",
+ av_get_pix_fmt_name(pic->format));
+ return AVERROR(EINVAL);
+ }
+
memset(pic->data, 0, sizeof(pic->data));
pic->extended_data = pic->data;
@@ -669,8 +677,9 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
pic->data[i] = NULL;
pic->linesize[i] = 0;
}
- if (pic->data[1] && !pic->data[2])
- avpriv_set_systematic_pal2((uint32_t *)pic->data[1], s->pix_fmt);
+ if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
+ desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
+ avpriv_set_systematic_pal2((uint32_t *)pic->data[1], pic->format);
if (s->debug & FF_DEBUG_BUFFERS)
av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p\n", pic);
OpenPOWER on IntegriCloud