mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
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().
This commit is contained in:
parent
0c59d40ae0
commit
ae1c750cb4
@ -646,6 +646,7 @@ fail:
|
|||||||
static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
|
static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
|
||||||
{
|
{
|
||||||
FramePool *pool = s->internal->pool;
|
FramePool *pool = s->internal->pool;
|
||||||
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pic->format);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (pic->data[0]) {
|
if (pic->data[0]) {
|
||||||
@ -653,6 +654,13 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
|
|||||||
return -1;
|
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));
|
memset(pic->data, 0, sizeof(pic->data));
|
||||||
pic->extended_data = 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->data[i] = NULL;
|
||||||
pic->linesize[i] = 0;
|
pic->linesize[i] = 0;
|
||||||
}
|
}
|
||||||
if (pic->data[1] && !pic->data[2])
|
if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
|
||||||
avpriv_set_systematic_pal2((uint32_t *)pic->data[1], s->pix_fmt);
|
desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
|
||||||
|
avpriv_set_systematic_pal2((uint32_t *)pic->data[1], pic->format);
|
||||||
|
|
||||||
if (s->debug & FF_DEBUG_BUFFERS)
|
if (s->debug & FF_DEBUG_BUFFERS)
|
||||||
av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p\n", pic);
|
av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p\n", pic);
|
||||||
|
Loading…
Reference in New Issue
Block a user