summaryrefslogtreecommitdiff
path: root/libavcodec/h264_refs.c
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2016-06-12 13:24:27 +0200
committerClément Bœsch <u@pkh.me>2016-06-12 13:26:52 +0200
commit1534ef87c74cc66a117bf61c467641c2129bc964 (patch)
tree68e36bf8432b8a5bd1cd9cc6187d874e0978b1a4 /libavcodec/h264_refs.c
parent1a57b464cf1687d4571a075c99b6ac36a60f4480 (diff)
parent3176217c60ca7828712985092d9102d331ea4f3d (diff)
Merge commit '3176217c60ca7828712985092d9102d331ea4f3d'
* commit '3176217c60ca7828712985092d9102d331ea4f3d': h264: decouple h264_ps from the h264 decoder Main changes: - a local GetBitContext is created for the various ff_h264_decode_seq_parameter_set() attempts - just like the old code, remove_sps() is adjusted so it doesn't remove the pps. Fixes decode with Ticket #631 http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20111108/dae58f17/attachment.mp4 but see next point as well. - ff_h264_update_thread_context() is updated to work even when SPS isn't set as it breaks current skip_frame code. This makes sure we can still decode the sample from ticket #631 without the need for -flags2 +chunks. (Thanks to Michael) - keep {sps,pps}_ref pointers that stay alive even when the active pps/sps get removed from the available lists (patch by michaelni with additionnal frees in ff_h264_free_context() from mateo) - added a check on sps in avpriv_h264_has_num_reorder_frames() to fix crashes with mpegts_with_dvbsubs.ts from Ticket #4074 http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4074/mpegts_with_dvbsubs.ts - in h264_parser.c:h264_parse(), after the ff_h264_decode_extradata() is called, the pps and sps from the local parser context are updated with the pps and sps from the used h264context. This fixes fate-flv-demux. - in h264_slice.c, "PPS changed between slices" error is not triggered anymore in one condition as it makes fate-h264-xavc-4389 fails with THREADS=N (Thanks to Michael) Merged-by: Clément Bœsch <clement@stupeflix.com> Merged-by: Michael Niedermayer <michael@niedermayer.cc> Merged-by: Matthieu Bouron <matthieu.bouron@stupeflix.com>
Diffstat (limited to 'libavcodec/h264_refs.c')
-rw-r--r--libavcodec/h264_refs.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 279dbcf06d..02c7867abc 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -592,7 +592,7 @@ int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
int mmco_index = 0, i = 0;
if (h->short_ref_count &&
- h->long_ref_count + h->short_ref_count >= h->sps.ref_frame_count &&
+ h->long_ref_count + h->short_ref_count >= h->ps.sps->ref_frame_count &&
!(FIELD_PICTURE(h) && !h->first_field && h->cur_pic_ptr->reference)) {
mmco[0].opcode = MMCO_SHORT2UNUSED;
mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;
@@ -768,7 +768,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
}
}
- if (h->long_ref_count + h->short_ref_count > FFMAX(h->sps.ref_frame_count, 1)) {
+ if (h->long_ref_count + h->short_ref_count > FFMAX(h->ps.sps->ref_frame_count, 1)) {
/* We have too many reference frames, probably due to corrupted
* stream. Need to discard one frame. Prevents overrun of the
@@ -777,7 +777,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
av_log(h->avctx, AV_LOG_ERROR,
"number of reference frames (%d+%d) exceeds max (%d; probably "
"corrupt input), discarding one\n",
- h->long_ref_count, h->short_ref_count, h->sps.ref_frame_count);
+ h->long_ref_count, h->short_ref_count, h->ps.sps->ref_frame_count);
err = AVERROR_INVALIDDATA;
if (h->long_ref_count && !h->short_ref_count) {
@@ -796,8 +796,8 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
for (i = 0; i<h->short_ref_count; i++) {
pic = h->short_ref[i];
if (pic->invalid_gap) {
- int d = av_mod_uintp2(h->cur_pic_ptr->frame_num - pic->frame_num, h->sps.log2_max_frame_num);
- if (d > h->sps.ref_frame_count)
+ int d = av_mod_uintp2(h->cur_pic_ptr->frame_num - pic->frame_num, h->ps.sps->log2_max_frame_num);
+ if (d > h->ps.sps->ref_frame_count)
remove_short(h, pic->frame_num, 0);
}
}
@@ -805,10 +805,11 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
print_short_term(h);
print_long_term(h);
- for (i = 0; i < FF_ARRAY_ELEMS(h->pps_buffers); i++) {
- if (h->pps_buffers[i]) {
- pps_ref_count[0] = FFMAX(pps_ref_count[0], h->pps_buffers[i]->ref_count[0]);
- pps_ref_count[1] = FFMAX(pps_ref_count[1], h->pps_buffers[i]->ref_count[1]);
+ for (i = 0; i < FF_ARRAY_ELEMS(h->ps.pps_list); i++) {
+ if (h->ps.pps_list[i]) {
+ const PPS *pps = (const PPS *)h->ps.pps_list[i]->data;
+ pps_ref_count[0] = FFMAX(pps_ref_count[0], pps->ref_count[0]);
+ pps_ref_count[1] = FFMAX(pps_ref_count[1], pps->ref_count[1]);
}
}