diff --git a/libavcodec/h264.c b/libavcodec/h264.c index a53be146e7..c3f2f2e4a5 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -90,7 +90,7 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1); fill_rectangle(sl->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32((*mv)[0][0][0], (*mv)[0][0][1]), 4); - h->mb_mbaff = + sl->mb_mbaff = sl->mb_field_decoding_flag = 0; ff_h264_hl_decode_mb(h, &h->slice_ctx[0]); } diff --git a/libavcodec/h264.h b/libavcodec/h264.h index e5a6a17c50..45545b6cdb 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -402,6 +402,7 @@ typedef struct H264SliceContext { int is_complex; int mb_field_decoding_flag; + int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag int redundant_pic_count; @@ -539,7 +540,6 @@ typedef struct H264Context { // interlacing specific flags int mb_aff_frame; - int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag int picture_structure; int first_field; diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index 90dd9f9641..ec9167efbe 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1933,7 +1933,7 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl) h->cur_pic.mb_type[mb_xy] = MB_TYPE_SKIP; sl->next_mb_skipped = decode_cabac_mb_skip(h, sl, sl->mb_x, sl->mb_y+1 ); if(!sl->next_mb_skipped) - h->mb_mbaff = sl->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h, sl); + sl->mb_mbaff = sl->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h, sl); } decode_mb_skip(h, sl); @@ -1948,7 +1948,7 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl) } if (FRAME_MBAFF(h)) { if ((sl->mb_y & 1) == 0) - h->mb_mbaff = + sl->mb_mbaff = sl->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h, sl); } @@ -2057,8 +2057,8 @@ decode_intra_mb: return 0; } - local_ref_count[0] = sl->ref_count[0] << MB_MBAFF(h); - local_ref_count[1] = sl->ref_count[1] << MB_MBAFF(h); + local_ref_count[0] = sl->ref_count[0] << MB_MBAFF(sl); + local_ref_count[1] = sl->ref_count[1] << MB_MBAFF(sl); fill_decode_caches(h, sl, mb_type); diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c index 45e2096849..0e26ff22ae 100644 --- a/libavcodec/h264_cavlc.c +++ b/libavcodec/h264_cavlc.c @@ -723,7 +723,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl) if (sl->mb_skip_run--) { if (FRAME_MBAFF(h) && (sl->mb_y & 1) == 0) { if (sl->mb_skip_run == 0) - h->mb_mbaff = sl->mb_field_decoding_flag = get_bits1(&sl->gb); + sl->mb_mbaff = sl->mb_field_decoding_flag = get_bits1(&sl->gb); } decode_mb_skip(h, sl); return 0; @@ -731,7 +731,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl) } if (FRAME_MBAFF(h)) { if ((sl->mb_y & 1) == 0) - h->mb_mbaff = sl->mb_field_decoding_flag = get_bits1(&sl->gb); + sl->mb_mbaff = sl->mb_field_decoding_flag = get_bits1(&sl->gb); } sl->prev_mb_skipped = 0; @@ -794,8 +794,8 @@ decode_intra_mb: return 0; } - local_ref_count[0] = sl->ref_count[0] << MB_MBAFF(h); - local_ref_count[1] = sl->ref_count[1] << MB_MBAFF(h); + local_ref_count[0] = sl->ref_count[0] << MB_MBAFF(sl); + local_ref_count[1] = sl->ref_count[1] << MB_MBAFF(sl); fill_decode_neighbors(h, sl, mb_type); fill_decode_caches(h, sl, mb_type); diff --git a/libavcodec/h264_mb.c b/libavcodec/h264_mb.c index dcd65a9464..b33c63c130 100644 --- a/libavcodec/h264_mb.c +++ b/libavcodec/h264_mb.c @@ -173,7 +173,7 @@ static void await_references(const H264Context *h, H264SliceContext *sl) int ref_field_picture = ref_pic->field_picture; int pic_height = 16 * h->mb_height >> ref_field_picture; - row <<= MB_MBAFF(h); + row <<= MB_MBAFF(sl); nrefs[list]--; if (!FIELD_PICTURE(h) && ref_field_picture) { // frame referencing two fields @@ -520,10 +520,10 @@ static av_always_inline void xchg_mb_border(const H264Context *h, H264SliceConte if (!simple && FRAME_MBAFF(h)) { if (sl->mb_y & 1) { - if (!MB_MBAFF(h)) + if (!MB_MBAFF(sl)) return; } else { - top_idx = MB_MBAFF(h) ? 0 : 1; + top_idx = MB_MBAFF(sl) ? 0 : 1; } } diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index d81dd9077b..0e72a81a53 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -794,7 +794,7 @@ static av_always_inline void backup_mb_border(H264Context *h, H264SliceContext * if (!simple && FRAME_MBAFF(h)) { if (sl->mb_y & 1) { - if (!MB_MBAFF(h)) { + if (!MB_MBAFF(sl)) { top_border = h->top_borders[0][sl->mb_x]; AV_COPY128(top_border, src_y + 15 * linesize); if (pixel_shift) @@ -829,7 +829,7 @@ static av_always_inline void backup_mb_border(H264Context *h, H264SliceContext * } } } - } else if (MB_MBAFF(h)) { + } else if (MB_MBAFF(sl)) { top_idx = 0; } else return; @@ -1513,7 +1513,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex } } - h->mb_mbaff = 0; + sl->mb_mbaff = 0; h->mb_aff_frame = 0; last_pic_structure = h0->picture_structure; last_pic_droppable = h0->droppable; @@ -2053,7 +2053,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, if (USES_LIST(top_type, list)) { const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride; const int b8_xy = 4 * top_xy + 2; - int (*ref2frm)[64] = (void*)(sl->ref2frm[h->slice_table[top_xy] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2)); + int (*ref2frm)[64] = (void*)(sl->ref2frm[h->slice_table[top_xy] & (MAX_SLICES - 1)][0] + (MB_MBAFF(sl) ? 20 : 2)); AV_COPY128(mv_dst - 1 * 8, h->cur_pic.motion_val[list][b_xy + 0]); ref_cache[0 - 1 * 8] = ref_cache[1 - 1 * 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 0]]; @@ -2068,7 +2068,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, if (USES_LIST(left_type[LTOP], list)) { const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3; const int b8_xy = 4 * left_xy[LTOP] + 1; - int (*ref2frm)[64] =(void*)( sl->ref2frm[h->slice_table[left_xy[LTOP]] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2)); + int (*ref2frm)[64] =(void*)( sl->ref2frm[h->slice_table[left_xy[LTOP]] & (MAX_SLICES - 1)][0] + (MB_MBAFF(sl) ? 20 : 2)); AV_COPY32(mv_dst - 1 + 0, h->cur_pic.motion_val[list][b_xy + b_stride * 0]); AV_COPY32(mv_dst - 1 + 8, h->cur_pic.motion_val[list][b_xy + b_stride * 1]); AV_COPY32(mv_dst - 1 + 16, h->cur_pic.motion_val[list][b_xy + b_stride * 2]); @@ -2101,7 +2101,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, { int8_t *ref = &h->cur_pic.ref_index[list][4 * mb_xy]; - int (*ref2frm)[64] = (void*)(sl->ref2frm[sl->slice_num & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2)); + int (*ref2frm)[64] = (void*)(sl->ref2frm[sl->slice_num & (MAX_SLICES - 1)][0] + (MB_MBAFF(sl) ? 20 : 2)); uint32_t ref01 = (pack16to32(ref2frm[list][ref[0]], ref2frm[list][ref[1]]) & 0x00FF00FF) * 0x0101; uint32_t ref23 = (pack16to32(ref2frm[list][ref[2]], ref2frm[list][ref[3]]) & 0x00FF00FF) * 0x0101; AV_WN32A(&ref_cache[0 * 8], ref01); @@ -2287,7 +2287,7 @@ static void loop_filter(H264Context *h, H264SliceContext *sl, int start_x, int e sl->list_count = h->list_counts[mb_xy]; if (FRAME_MBAFF(h)) - h->mb_mbaff = + sl->mb_mbaff = sl->mb_field_decoding_flag = !!IS_INTERLACED(mb_type); sl->mb_x = mb_x; @@ -2344,7 +2344,7 @@ static void predict_field_decoding_flag(H264Context *h, H264SliceContext *sl) h->cur_pic.mb_type[mb_xy - 1] : (h->slice_table[mb_xy - h->mb_stride] == sl->slice_num) ? h->cur_pic.mb_type[mb_xy - h->mb_stride] : 0; - h->mb_mbaff = sl->mb_field_decoding_flag = IS_INTERLACED(mb_type) ? 1 : 0; + sl->mb_mbaff = sl->mb_field_decoding_flag = IS_INTERLACED(mb_type) ? 1 : 0; } /**