Merge commit '4baba6c813b7a1f27370e20fb1a87b05fcb39208'

* commit '4baba6c813b7a1f27370e20fb1a87b05fcb39208':
  h264_parser: Fix POC parsing for the case where MMCO_RESET is present.

Conflicts:
	libavcodec/h264.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer
2013-10-16 12:51:26 +02:00
3 changed files with 154 additions and 45 deletions

View File

@@ -2602,7 +2602,7 @@ void ff_h264_hl_decode_mb(H264Context *h)
hl_decode_mb_simple_8(h);
}
static int pred_weight_table(H264Context *h)
int ff_pred_weight_table(H264Context *h)
{
int list, i;
int luma_def, chroma_def;
@@ -3310,6 +3310,49 @@ static int h264_slice_header_init(H264Context *h, int reinit)
return 0;
}
int ff_set_ref_count(H264Context *h)
{
int num_ref_idx_active_override_flag;
// set defaults, might be overridden a few lines later
h->ref_count[0] = h->pps.ref_count[0];
h->ref_count[1] = h->pps.ref_count[1];
if (h->slice_type_nos != AV_PICTURE_TYPE_I) {
unsigned max[2];
max[0] = max[1] = h->picture_structure == PICT_FRAME ? 15 : 31;
if (h->slice_type_nos == AV_PICTURE_TYPE_B)
h->direct_spatial_mv_pred = get_bits1(&h->gb);
num_ref_idx_active_override_flag = get_bits1(&h->gb);
if (num_ref_idx_active_override_flag) {
h->ref_count[0] = get_ue_golomb(&h->gb) + 1;
if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
h->ref_count[1] = get_ue_golomb(&h->gb) + 1;
} else
// full range is spec-ok in this case, even for frames
h->ref_count[1] = 1;
}
if (h->ref_count[0]-1 > max[0] || h->ref_count[1]-1 > max[1]){
av_log(h->avctx, AV_LOG_ERROR, "reference overflow %u > %u or %u > %u\n", h->ref_count[0]-1, max[0], h->ref_count[1]-1, max[1]);
h->ref_count[0] = h->ref_count[1] = 0;
return AVERROR_INVALIDDATA;
}
if (h->slice_type_nos == AV_PICTURE_TYPE_B)
h->list_count = 2;
else
h->list_count = 1;
} else {
h->list_count = 0;
h->ref_count[0] = h->ref_count[1] = 0;
}
return 0;
}
/**
* Decode a slice header.
* This will also call ff_MPV_common_init() and frame_start() as needed.
@@ -3324,7 +3367,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
{
unsigned int first_mb_in_slice;
unsigned int pps_id;
int num_ref_idx_active_override_flag, ret;
int ret;
unsigned int slice_type, tmp, i, j;
int last_pic_structure, last_pic_droppable;
int must_reinit;
@@ -3777,45 +3820,15 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
if (h->pps.redundant_pic_cnt_present)
h->redundant_pic_count = get_ue_golomb(&h->gb);
// set defaults, might be overridden a few lines later
h->ref_count[0] = h->pps.ref_count[0];
h->ref_count[1] = h->pps.ref_count[1];
ret = ff_set_ref_count(h);
if (ret < 0)
return ret;
if (h->slice_type_nos != AV_PICTURE_TYPE_I) {
unsigned max[2];
max[0] = max[1] = h->picture_structure == PICT_FRAME ? 15 : 31;
if (h->slice_type_nos == AV_PICTURE_TYPE_B)
h->direct_spatial_mv_pred = get_bits1(&h->gb);
num_ref_idx_active_override_flag = get_bits1(&h->gb);
if (num_ref_idx_active_override_flag) {
h->ref_count[0] = get_ue_golomb(&h->gb) + 1;
if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
h->ref_count[1] = get_ue_golomb(&h->gb) + 1;
} else
// full range is spec-ok in this case, even for frames
h->ref_count[1] = 1;
}
if (h->ref_count[0]-1 > max[0] || h->ref_count[1]-1 > max[1]){
av_log(h->avctx, AV_LOG_ERROR, "reference overflow %u > %u or %u > %u\n", h->ref_count[0]-1, max[0], h->ref_count[1]-1, max[1]);
h->ref_count[0] = h->ref_count[1] = 0;
return AVERROR_INVALIDDATA;
}
if (h->slice_type_nos == AV_PICTURE_TYPE_B)
h->list_count = 2;
else
h->list_count = 1;
} else {
h->list_count = 0;
h->ref_count[0] = h->ref_count[1] = 0;
}
if (slice_type != AV_PICTURE_TYPE_I &&
(h0->current_slice == 0 ||
slice_type != h0->last_slice_type ||
memcmp(h0->last_ref_count, h0->ref_count, sizeof(h0->ref_count)))) {
ff_h264_fill_default_ref_list(h);
}
@@ -3830,7 +3843,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
if ((h->pps.weighted_pred && h->slice_type_nos == AV_PICTURE_TYPE_P) ||
(h->pps.weighted_bipred_idc == 1 &&
h->slice_type_nos == AV_PICTURE_TYPE_B))
pred_weight_table(h);
ff_pred_weight_table(h);
else if (h->pps.weighted_bipred_idc == 2 &&
h->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(h, -1);