aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/h264_slice.c
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2016-06-12 16:06:58 +0200
committerClément Bœsch <u@pkh.me>2016-06-12 19:01:43 +0200
commitbd3fd467febe92300e0ebf8ff13c193f9236479a (patch)
treee2a4382598405ce35492ec3c69e007e36f9b5e6c /libavcodec/h264_slice.c
parent65d5f32fd7d234a9b08e3743593de0a72af7c03c (diff)
parentc8dcff0cdb17d0aa03ac729eba12d1a20f1f59c8 (diff)
downloadffmpeg-bd3fd467febe92300e0ebf8ff13c193f9236479a.tar.gz
Merge commit 'c8dcff0cdb17d0aa03ac729eba12d1a20f1f59c8'
* commit 'c8dcff0cdb17d0aa03ac729eba12d1a20f1f59c8': h264: factor out calculating the POC count into a separate file Merged-by: Clément Bœsch <u@pkh.me>
Diffstat (limited to 'libavcodec/h264_slice.c')
-rw-r--r--libavcodec/h264_slice.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 394a0c4b88..6c097075d4 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -421,7 +421,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
h->x264_build = h1->x264_build;
// POC timing
- copy_fields(h, h1, poc_lsb, current_slice);
+ copy_fields(h, h1, poc, current_slice);
copy_picture_range(h->short_ref, h1->short_ref, 32, h, h1);
copy_picture_range(h->long_ref, h1->long_ref, 32, h, h1);
@@ -435,11 +435,11 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
if (!h->droppable) {
err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
- h->prev_poc_msb = h->poc_msb;
- h->prev_poc_lsb = h->poc_lsb;
+ h->poc.prev_poc_msb = h->poc.poc_msb;
+ h->poc.prev_poc_lsb = h->poc.poc_lsb;
}
- h->prev_frame_num_offset = h->frame_num_offset;
- h->prev_frame_num = h->frame_num;
+ h->poc.prev_frame_num_offset = h->poc.frame_num_offset;
+ h->poc.prev_frame_num = h->poc.frame_num;
h->recovery_frame = h1->recovery_frame;
@@ -476,8 +476,7 @@ static int h264_frame_start(H264Context *h)
pic->reference = h->droppable ? 0 : h->picture_structure;
pic->f->coded_picture_number = h->coded_picture_number++;
pic->field_picture = h->picture_structure != PICT_FRAME;
- pic->frame_num = h->frame_num;
-
+ pic->frame_num = h->poc.frame_num;
/*
* Zero key_frame here; IDR markings per slice in frame or fields are ORed
* in later.
@@ -1324,15 +1323,15 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
frame_num = get_bits(&sl->gb, sps->log2_max_frame_num);
if (!first_slice) {
- if (h->frame_num != frame_num) {
+ if (h->poc.frame_num != frame_num) {
av_log(h->avctx, AV_LOG_ERROR, "Frame num change from %d to %d\n",
- h->frame_num, frame_num);
+ h->poc.frame_num, frame_num);
return AVERROR_INVALIDDATA;
}
}
if (!h->setup_finished)
- h->frame_num = frame_num;
+ h->poc.frame_num = frame_num;
sl->mb_mbaff = 0;
mb_aff_frame = 0;
@@ -1385,19 +1384,19 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
if (h->current_slice == 0) {
/* Shorten frame num gaps so we don't have to allocate reference
* frames just to throw them away */
- if (h->frame_num != h->prev_frame_num) {
- int unwrap_prev_frame_num = h->prev_frame_num;
+ if (h->poc.frame_num != h->poc.prev_frame_num) {
+ int unwrap_prev_frame_num = h->poc.prev_frame_num;
int max_frame_num = 1 << sps->log2_max_frame_num;
- if (unwrap_prev_frame_num > h->frame_num)
+ if (unwrap_prev_frame_num > h->poc.frame_num)
unwrap_prev_frame_num -= max_frame_num;
- if ((h->frame_num - unwrap_prev_frame_num) > sps->ref_frame_count) {
- unwrap_prev_frame_num = (h->frame_num - sps->ref_frame_count) - 1;
+ if ((h->poc.frame_num - unwrap_prev_frame_num) > sps->ref_frame_count) {
+ unwrap_prev_frame_num = (h->poc.frame_num - sps->ref_frame_count) - 1;
if (unwrap_prev_frame_num < 0)
unwrap_prev_frame_num += max_frame_num;
- h->prev_frame_num = unwrap_prev_frame_num;
+ h->poc.prev_frame_num = unwrap_prev_frame_num;
}
}
@@ -1426,7 +1425,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
last_pic_structure == PICT_TOP_FIELD);
}
} else {
- if (h->cur_pic_ptr->frame_num != h->frame_num) {
+ if (h->cur_pic_ptr->frame_num != h->poc.frame_num) {
/* This and previous field were reference, but had
* different frame_nums. Consider this field first in
* pair. Throw away previous field except for reference
@@ -1458,11 +1457,11 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
}
}
- while (h->frame_num != h->prev_frame_num && !h->first_field &&
- h->frame_num != (h->prev_frame_num + 1) % (1 << sps->log2_max_frame_num)) {
+ while (h->poc.frame_num != h->poc.prev_frame_num && !h->first_field &&
+ h->poc.frame_num != (h->poc.prev_frame_num + 1) % (1 << sps->log2_max_frame_num)) {
H264Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
- h->frame_num, h->prev_frame_num);
+ h->poc.frame_num, h->poc.prev_frame_num);
if (!sps->gaps_in_frame_num_allowed_flag)
for(i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN;
@@ -1472,9 +1471,9 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
return ret;
}
- h->prev_frame_num++;
- h->prev_frame_num %= 1 << sps->log2_max_frame_num;
- h->cur_pic_ptr->frame_num = h->prev_frame_num;
+ h->poc.prev_frame_num++;
+ h->poc.prev_frame_num %= 1 << sps->log2_max_frame_num;
+ h->cur_pic_ptr->frame_num = h->poc.prev_frame_num;
h->cur_pic_ptr->invalid_gap = !sps->gaps_in_frame_num_allowed_flag;
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1);
@@ -1505,7 +1504,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
prev->f->height);
h->short_ref[0]->poc = prev->poc + 2;
}
- h->short_ref[0]->frame_num = h->prev_frame_num;
+ h->short_ref[0]->frame_num = h->poc.prev_frame_num;
}
}
@@ -1526,7 +1525,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
h->first_field = FIELD_PICTURE(h);
} else {
h->missing_fields = 0;
- if (h->cur_pic_ptr->frame_num != h->frame_num) {
+ if (h->cur_pic_ptr->frame_num != h->poc.frame_num) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
h->picture_structure==PICT_BOTTOM_FIELD);
/* This and the previous field had different frame_nums.
@@ -1577,10 +1576,10 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
av_assert1(sl->mb_y < h->mb_height);
if (h->picture_structure == PICT_FRAME) {
- h->curr_pic_num = h->frame_num;
+ h->curr_pic_num = h->poc.frame_num;
h->max_pic_num = 1 << sps->log2_max_frame_num;
} else {
- h->curr_pic_num = 2 * h->frame_num + 1;
+ h->curr_pic_num = 2 * h->poc.frame_num + 1;
h->max_pic_num = 1 << (sps->log2_max_frame_num + 1);
}
@@ -1591,12 +1590,12 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
int poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb);
if (!h->setup_finished)
- h->poc_lsb = poc_lsb;
+ h->poc.poc_lsb = poc_lsb;
if (pps->pic_order_present == 1 && h->picture_structure == PICT_FRAME) {
int delta_poc_bottom = get_se_golomb(&sl->gb);
if (!h->setup_finished)
- h->delta_poc_bottom = delta_poc_bottom;
+ h->poc.delta_poc_bottom = delta_poc_bottom;
}
}
@@ -1604,18 +1603,19 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
int delta_poc = get_se_golomb(&sl->gb);
if (!h->setup_finished)
- h->delta_poc[0] = delta_poc;
+ h->poc.delta_poc[0] = delta_poc;
if (pps->pic_order_present == 1 && h->picture_structure == PICT_FRAME) {
delta_poc = get_se_golomb(&sl->gb);
if (!h->setup_finished)
- h->delta_poc[1] = delta_poc;
+ h->poc.delta_poc[1] = delta_poc;
}
}
if (!h->setup_finished)
- ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc);
+ ff_h264_init_poc(h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc,
+ sps, &h->poc, h->picture_structure, h->nal_ref_idc);
if (pps->redundant_pic_cnt_present)
sl->redundant_pic_count = get_ue_golomb(&sl->gb);
@@ -1829,7 +1829,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
av_get_picture_type_char(sl->slice_type),
sl->slice_type_fixed ? " fix" : "",
h->nal_unit_type == NAL_IDR_SLICE ? " IDR" : "",
- pps_id, h->frame_num,
+ pps_id, h->poc.frame_num,
h->cur_pic_ptr->field_poc[0],
h->cur_pic_ptr->field_poc[1],
sl->ref_count[0], sl->ref_count[1],