summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorJanne Grunau <janne-libav@jannau.net>2013-01-02 02:28:34 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-02 02:28:57 +0100
commite9fd51b0d6dc65bdfcd702531c400ae9ee50a67d (patch)
tree9c9374a0911e6d2dfc546910011733e6d53356db /libavcodec
parent341e40f1e1eeba1a2952c26363630596193e887b (diff)
h264: check SPS entries directly to detect pixel format changes
Comparing AVCodecContext.pix_fmt against the get_pixel_format() return value has the side effect of calling the get_format() callback on each slice. Users of the callback will probably handle hardware accelerator initialization in the callback. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/h264.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 81d6d012a2..bbb9606648 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -2656,7 +2656,6 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
int last_pic_structure, last_pic_droppable;
int must_reinit;
int needs_reinit = 0;
- enum AVPixelFormat pix_fmt;
/* FIXME: 2tap qpel isn't implemented for high bit depth. */
if ((s->avctx->flags2 & CODEC_FLAG2_FAST) &&
@@ -2733,8 +2732,14 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
if (h->pps.sps_id != h->current_sps_id ||
h->context_reinitialized ||
h0->sps_buffers[h->pps.sps_id]->new) {
+ SPS *new_sps = h0->sps_buffers[h->pps.sps_id];
+
h0->sps_buffers[h->pps.sps_id]->new = 0;
+ if (h->sps.chroma_format_idc != new_sps->chroma_format_idc ||
+ h->sps.bit_depth_luma != new_sps->bit_depth_luma)
+ needs_reinit = 1;
+
h->current_sps_id = h->pps.sps_id;
h->sps = *h0->sps_buffers[h->pps.sps_id];
@@ -2775,6 +2780,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
s->avctx->color_range = h->sps.full_range>0 ? AVCOL_RANGE_JPEG
: AVCOL_RANGE_MPEG;
if (h->sps.colour_description_present_flag) {
+ if (s->avctx->colorspace != h->sps.colorspace)
+ needs_reinit = 1;
s->avctx->color_primaries = h->sps.color_primaries;
s->avctx->color_trc = h->sps.color_trc;
s->avctx->colorspace = h->sps.colorspace;
@@ -2782,14 +2789,6 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
}
- ret = get_pixel_format(h);
- if (ret < 0)
- return ret;
- else
- pix_fmt = ret;
- if (s->avctx->pix_fmt == PIX_FMT_NONE)
- s->avctx->pix_fmt = pix_fmt;
-
if (s->context_initialized &&
(
needs_reinit ||
@@ -2801,12 +2800,14 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
return AVERROR_INVALIDDATA;
}
- av_log(h->s.avctx, AV_LOG_INFO, "Reinit context to %dx%d, "
- "pix_fmt: %d\n", s->width, s->height, pix_fmt);
-
flush_change(h);
- s->avctx->pix_fmt = pix_fmt;
+ if ((ret = get_pixel_format(h)) < 0)
+ return ret;
+ s->avctx->pix_fmt = ret;
+
+ av_log(h->s.avctx, AV_LOG_INFO, "Reinit context to %dx%d, "
+ "pix_fmt: %d\n", s->width, s->height, s->avctx->pix_fmt);
if ((ret = h264_slice_header_init(h, 1)) < 0) {
av_log(h->s.avctx, AV_LOG_ERROR,
@@ -2821,6 +2822,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
"Cannot (re-)initialize context during parallel decoding.\n");
return -1;
}
+ if ((ret = get_pixel_format(h)) < 0)
+ return ret;
+ s->avctx->pix_fmt = ret;
+
if ((ret = h264_slice_header_init(h, 0)) < 0) {
av_log(h->s.avctx, AV_LOG_ERROR,
"h264_slice_header_init() failed\n");