Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2016-06-29 21:04:23 +0300
committerClément Bœsch <u@pkh.me>2016-06-29 21:04:23 +0300
commitc28aecc56ace7a6f5f21c1484d00932d4777f4e8 (patch)
treead2d3fd01575a10d26fbaa02c3715c9d4361af03 /libavcodec/h264_slice.c
parent2b1995e3eeb377a8408b14bdbf381abb2233b975 (diff)
parent7ab5d577a9affe3397c08b032f983f9bf7101865 (diff)
Merge commit '7ab5d577a9affe3397c08b032f983f9bf7101865'
* commit '7ab5d577a9affe3397c08b032f983f9bf7101865': h264: move initializing the slice start out of h264_slice_header_parse() Merged-by: Clément Bœsch <u@pkh.me>
Diffstat (limited to 'libavcodec/h264_slice.c')
-rw-r--r--libavcodec/h264_slice.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 0e09ee2134..e5fb64fc22 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1024,7 +1024,6 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl)
{
const SPS *sps;
const PPS *pps;
- unsigned int first_mb_in_slice;
unsigned int pps_id;
int ret;
unsigned int slice_type, tmp, i;
@@ -1039,9 +1038,9 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl)
if (first_slice)
av_assert0(!h->setup_finished);
- first_mb_in_slice = get_ue_golomb_long(&sl->gb);
+ sl->first_mb_addr = get_ue_golomb_long(&sl->gb);
- if (first_mb_in_slice == 0) { // FIXME better field boundary detection
+ if (sl->first_mb_addr == 0) { // FIXME better field boundary detection
if (h->current_slice) {
if (h->setup_finished) {
av_log(h->avctx, AV_LOG_ERROR, "Too many fields\n");
@@ -1090,7 +1089,7 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl)
if (slice_type > 9) {
av_log(h->avctx, AV_LOG_ERROR,
"slice type %d too large at %d\n",
- slice_type, first_mb_in_slice);
+ slice_type, sl->first_mb_addr);
return AVERROR_INVALIDDATA;
}
if (slice_type > 4) {
@@ -1524,19 +1523,6 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl)
}
}
- av_assert1(h->mb_num == h->mb_width * h->mb_height);
- if (first_mb_in_slice << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
- first_mb_in_slice >= h->mb_num) {
- av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
- return AVERROR_INVALIDDATA;
- }
- sl->resync_mb_x = sl->mb_x = first_mb_in_slice % h->mb_width;
- sl->resync_mb_y = sl->mb_y = (first_mb_in_slice / h->mb_width) <<
- FIELD_OR_MBAFF_PICTURE(h);
- if (h->picture_structure == PICT_BOTTOM_FIELD)
- sl->resync_mb_y = sl->mb_y = sl->mb_y + 1;
- av_assert1(sl->mb_y < h->mb_height);
-
if (h->picture_structure == PICT_FRAME) {
h->curr_pic_num = h->poc.frame_num;
h->max_pic_num = 1 << sps->log2_max_frame_num;
@@ -1692,6 +1678,19 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
if (ret) // can not be ret<0 because of SLICE_SKIPED, SLICE_SINGLETHREAD, ...
return ret;
+ av_assert1(h->mb_num == h->mb_width * h->mb_height);
+ if (sl->first_mb_addr << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
+ sl->first_mb_addr >= h->mb_num) {
+ av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
+ return AVERROR_INVALIDDATA;
+ }
+ sl->resync_mb_x = sl->mb_x = sl->first_mb_addr % h->mb_width;
+ sl->resync_mb_y = sl->mb_y = (sl->first_mb_addr / h->mb_width) <<
+ FIELD_OR_MBAFF_PICTURE(h);
+ if (h->picture_structure == PICT_BOTTOM_FIELD)
+ sl->resync_mb_y = sl->mb_y = sl->mb_y + 1;
+ av_assert1(sl->mb_y < h->mb_height);
+
if (!h->setup_finished)
ff_h264_init_poc(h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc,
h->ps.sps, &h->poc, h->picture_structure, h->nal_ref_idc);