From 7bece9b22f75289d84ac71c1c7b79851274e723e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 Mar 2013 20:37:11 +0100 Subject: [PATCH 1/2] h264: add a parameter to the FRAME_MBAFF macro. This way it does not look like a constant. --- libavcodec/h264.c | 38 +++++++++++++++++------------------ libavcodec/h264.h | 6 +++--- libavcodec/h264_cabac.c | 8 ++++---- libavcodec/h264_cavlc.c | 4 ++-- libavcodec/h264_direct.c | 8 ++++---- libavcodec/h264_loopfilter.c | 10 ++++----- libavcodec/h264_mb_template.c | 4 ++-- libavcodec/h264_mvpred.h | 10 ++++----- 8 files changed, 44 insertions(+), 44 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 37b3337e55..d52349a3b6 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -118,7 +118,7 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1); fill_rectangle(h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32((*mv)[0][0][0], (*mv)[0][0][1]), 4); - assert(!FRAME_MBAFF); + assert(!FRAME_MBAFF(h)); ff_h264_hl_decode_mb(h); } @@ -2048,7 +2048,7 @@ static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y, src_cb -= uvlinesize; src_cr -= uvlinesize; - if (!simple && FRAME_MBAFF) { + if (!simple && FRAME_MBAFF(h)) { if (h->mb_y & 1) { if (!MB_MBAFF(h)) { top_border = h->top_borders[0][h->mb_x]; @@ -2141,7 +2141,7 @@ static av_always_inline void xchg_mb_border(H264Context *h, uint8_t *src_y, uint8_t *top_border_m1; uint8_t *top_border; - if (!simple && FRAME_MBAFF) { + if (!simple && FRAME_MBAFF(h)) { if (h->mb_y & 1) { if (!MB_MBAFF(h)) return; @@ -2533,7 +2533,7 @@ static void implicit_weight_table(H264Context *h, int field) } else { cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure - 1]; } - if (h->ref_count[0] == 1 && h->ref_count[1] == 1 && !FRAME_MBAFF && + if (h->ref_count[0] == 1 && h->ref_count[1] == 1 && !FRAME_MBAFF(h) && h->ref_list[0][0].poc + h->ref_list[1][0].poc == 2 * cur_poc) { h->use_weight = 0; h->use_weight_chroma = 0; @@ -3563,7 +3563,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) (h->avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; - if (FRAME_MBAFF) { + if (FRAME_MBAFF(h)) { ff_h264_fill_mbaff_ref_list(h); if (h->pps.weighted_bipred_idc == 2 && h->slice_type_nos == AV_PICTURE_TYPE_B) { @@ -3843,7 +3843,7 @@ static int fill_filter_caches(H264Context *h, int mb_type) * stuff, I can't imagine that these complex rules are worth it. */ left_xy[LBOT] = left_xy[LTOP] = mb_xy - 1; - if (FRAME_MBAFF) { + if (FRAME_MBAFF(h)) { const int left_mb_field_flag = IS_INTERLACED(h->cur_pic.mb_type[mb_xy - 1]); const int curr_mb_field_flag = IS_INTERLACED(mb_type); if (h->mb_y & 1) { @@ -3872,7 +3872,7 @@ static int fill_filter_caches(H264Context *h, int mb_type) ((qp + h->cur_pic.qscale_table[left_xy[LTOP]] + 1) >> 1) <= qp_thresh) && (top_xy < 0 || ((qp + h->cur_pic.qscale_table[top_xy] + 1) >> 1) <= qp_thresh)) { - if (!FRAME_MBAFF) + if (!FRAME_MBAFF(h)) return 1; if ((left_xy[LTOP] < 0 || ((qp + h->cur_pic.qscale_table[left_xy[LBOT]] + 1) >> 1) <= qp_thresh) && @@ -3978,21 +3978,21 @@ static void loop_filter(H264Context *h, int start_x, int end_x) { uint8_t *dest_y, *dest_cb, *dest_cr; int linesize, uvlinesize, mb_x, mb_y; - const int end_mb_y = h->mb_y + FRAME_MBAFF; + const int end_mb_y = h->mb_y + FRAME_MBAFF(h); const int old_slice_type = h->slice_type; const int pixel_shift = h->pixel_shift; const int block_h = 16 >> h->chroma_y_shift; if (h->deblocking_filter) { for (mb_x = start_x; mb_x < end_x; mb_x++) - for (mb_y = end_mb_y - FRAME_MBAFF; mb_y <= end_mb_y; mb_y++) { + for (mb_y = end_mb_y - FRAME_MBAFF(h); mb_y <= end_mb_y; mb_y++) { int mb_xy, mb_type; mb_xy = h->mb_xy = mb_x + mb_y * h->mb_stride; h->slice_num = h->slice_table[mb_xy]; mb_type = h->cur_pic.mb_type[mb_xy]; h->list_count = h->list_counts[mb_xy]; - if (FRAME_MBAFF) + if (FRAME_MBAFF(h)) h->mb_mbaff = h->mb_field_decoding_flag = !!IS_INTERLACED(mb_type); @@ -4027,7 +4027,7 @@ static void loop_filter(H264Context *h, int start_x, int end_x) h->chroma_qp[0] = get_chroma_qp(h, 0, h->cur_pic.qscale_table[mb_xy]); h->chroma_qp[1] = get_chroma_qp(h, 1, h->cur_pic.qscale_table[mb_xy]); - if (FRAME_MBAFF) { + if (FRAME_MBAFF(h)) { ff_h264_filter_mb(h, mb_x, mb_y, dest_y, dest_cb, dest_cr, linesize, uvlinesize); } else { @@ -4038,7 +4038,7 @@ static void loop_filter(H264Context *h, int start_x, int end_x) } h->slice_type = old_slice_type; h->mb_x = end_x; - h->mb_y = end_mb_y - FRAME_MBAFF; + h->mb_y = end_mb_y - FRAME_MBAFF(h); h->chroma_qp[0] = get_chroma_qp(h, 0, h->qscale); h->chroma_qp[1] = get_chroma_qp(h, 1, h->qscale); } @@ -4060,8 +4060,8 @@ static void decode_finish_row(H264Context *h) { int top = 16 * (h->mb_y >> FIELD_PICTURE); int pic_height = 16 * h->mb_height >> FIELD_PICTURE; - int height = 16 << FRAME_MBAFF; - int deblock_border = (16 + 4) << FRAME_MBAFF; + int height = 16 << FRAME_MBAFF(h); + int deblock_border = (16 + 4) << FRAME_MBAFF(h); if (h->deblocking_filter) { if ((top + height) >= pic_height) @@ -4103,7 +4103,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) h->mb_skip_run = -1; - h->is_complex = FRAME_MBAFF || h->picture_structure != PICT_FRAME || + h->is_complex = FRAME_MBAFF(h) || h->picture_structure != PICT_FRAME || avctx->codec_id != AV_CODEC_ID_H264 || (CONFIG_GRAY && (h->flags & CODEC_FLAG_GRAY)); @@ -4129,7 +4129,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ff_h264_hl_decode_mb(h); // FIXME optimal? or let mb_decode decode 16x32 ? - if (ret >= 0 && FRAME_MBAFF) { + if (ret >= 0 && FRAME_MBAFF(h)) { h->mb_y++; ret = ff_h264_decode_mb_cabac(h); @@ -4165,7 +4165,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ++h->mb_y; if (FIELD_OR_MBAFF_PICTURE) { ++h->mb_y; - if (FRAME_MBAFF && h->mb_y < h->mb_height) + if (FRAME_MBAFF(h) && h->mb_y < h->mb_height) predict_field_decoding_flag(h); } } @@ -4188,7 +4188,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ff_h264_hl_decode_mb(h); // FIXME optimal? or let mb_decode decode 16x32 ? - if (ret >= 0 && FRAME_MBAFF) { + if (ret >= 0 && FRAME_MBAFF(h)) { h->mb_y++; ret = ff_h264_decode_mb_cavlc(h); @@ -4212,7 +4212,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ++h->mb_y; if (FIELD_OR_MBAFF_PICTURE) { ++h->mb_y; - if (FRAME_MBAFF && h->mb_y < h->mb_height) + if (FRAME_MBAFF(h) && h->mb_y < h->mb_height) predict_field_decoding_flag(h); } if (h->mb_y >= h->mb_height) { diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 9d2a1c5756..077202dd9d 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -61,7 +61,7 @@ #ifdef ALLOW_INTERLACE #define MB_MBAFF(h) h->mb_mbaff #define MB_FIELD(h) h->mb_field_decoding_flag -#define FRAME_MBAFF h->mb_aff_frame +#define FRAME_MBAFF(h) h->mb_aff_frame #define FIELD_PICTURE (h->picture_structure != PICT_FRAME) #define LEFT_MBS 2 #define LTOP 0 @@ -70,7 +70,7 @@ #else #define MB_MBAFF(h) 0 #define MB_FIELD(h) 0 -#define FRAME_MBAFF 0 +#define FRAME_MBAFF(h) 0 #define FIELD_PICTURE 0 #undef IS_INTERLACED #define IS_INTERLACED(mb_type) 0 @@ -79,7 +79,7 @@ #define LBOT 0 #define LEFT(i) 0 #endif -#define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF || FIELD_PICTURE) +#define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF(h) || FIELD_PICTURE) #ifndef CABAC #define CABAC h->pps.cabac diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index 2d3717bec2..258e9ee7e6 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1323,7 +1323,7 @@ static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) { int mba_xy, mbb_xy; int ctx = 0; - if(FRAME_MBAFF){ //FIXME merge with the stuff in fill_caches? + if (FRAME_MBAFF(h)) { //FIXME merge with the stuff in fill_caches? int mb_xy = mb_x + (mb_y&~1)*h->mb_stride; mba_xy = mb_xy - 1; if( (mb_y&1) @@ -1886,13 +1886,13 @@ int ff_h264_decode_mb_cabac(H264Context *h) { if( h->slice_type_nos != AV_PICTURE_TYPE_I ) { int skip; /* a skipped mb needs the aff flag from the following mb */ - if( FRAME_MBAFF && (h->mb_y&1)==1 && h->prev_mb_skipped ) + if (FRAME_MBAFF(h) && (h->mb_y & 1) == 1 && h->prev_mb_skipped) skip = h->next_mb_skipped; else skip = decode_cabac_mb_skip( h, h->mb_x, h->mb_y ); /* read skip flags */ if( skip ) { - if( FRAME_MBAFF && (h->mb_y&1)==0 ){ + if (FRAME_MBAFF(h) && (h->mb_y & 1) == 0) { h->cur_pic.mb_type[mb_xy] = MB_TYPE_SKIP; h->next_mb_skipped = decode_cabac_mb_skip( h, h->mb_x, h->mb_y+1 ); if(!h->next_mb_skipped) @@ -1909,7 +1909,7 @@ int ff_h264_decode_mb_cabac(H264Context *h) { } } - if(FRAME_MBAFF){ + if (FRAME_MBAFF(h)) { if( (h->mb_y&1) == 0 ) h->mb_mbaff = h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h); diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c index b66ce9a0b1..b18c54eed1 100644 --- a/libavcodec/h264_cavlc.c +++ b/libavcodec/h264_cavlc.c @@ -708,7 +708,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h){ h->mb_skip_run= get_ue_golomb(&h->gb); if (h->mb_skip_run--) { - if(FRAME_MBAFF && (h->mb_y&1) == 0){ + if(FRAME_MBAFF(h) && (h->mb_y&1) == 0){ if(h->mb_skip_run==0) h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&h->gb); } @@ -716,7 +716,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h){ return 0; } } - if(FRAME_MBAFF){ + if (FRAME_MBAFF(h)) { if( (h->mb_y&1) == 0 ) h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&h->gb); } diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c index 0e81280612..719ebee511 100644 --- a/libavcodec/h264_direct.c +++ b/libavcodec/h264_direct.c @@ -53,7 +53,7 @@ void ff_h264_direct_dist_scale_factor(H264Context * const h){ const int poc1 = h->ref_list[1][0].poc; int i, field; - if (FRAME_MBAFF) + if (FRAME_MBAFF(h)) for (field = 0; field < 2; field++){ const int poc = h->cur_pic_ptr->field_poc[field]; const int poc1 = h->ref_list[1][0].field_poc[field]; @@ -118,7 +118,7 @@ void ff_h264_direct_ref_list_init(H264Context * const h){ memcpy(cur->ref_poc [1], cur->ref_poc [0], sizeof(cur->ref_poc [0])); } - cur->mbaff= FRAME_MBAFF; + cur->mbaff = FRAME_MBAFF(h); h->col_fieldoff= 0; if(h->picture_structure == PICT_FRAME){ @@ -135,7 +135,7 @@ void ff_h264_direct_ref_list_init(H264Context * const h){ for(list=0; list<2; list++){ fill_colmap(h, h->map_col_to_list0, list, sidx, ref1sidx, 0); - if(FRAME_MBAFF) + if (FRAME_MBAFF(h)) for(field=0; field<2; field++) fill_colmap(h, h->map_col_to_list0_field[field], list, field, field, 1); } @@ -496,7 +496,7 @@ single_col: const int *dist_scale_factor = h->dist_scale_factor; int ref_offset; - if(FRAME_MBAFF && IS_INTERLACED(*mb_type)){ + if (FRAME_MBAFF(h) && IS_INTERLACED(*mb_type)) { map_col_to_list0[0] = h->map_col_to_list0_field[h->mb_y&1][0]; map_col_to_list0[1] = h->map_col_to_list0_field[h->mb_y&1][1]; dist_scale_factor =h->dist_scale_factor_field[h->mb_y&1]; diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index 424c598dcf..87566192d3 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -417,7 +417,7 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h, } void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) { - assert(!FRAME_MBAFF); + assert(!FRAME_MBAFF(h)); if(!h->h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff) { ff_h264_filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize); return; @@ -482,7 +482,7 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u if(mbm_type && !first_vertical_edge_done){ - if (FRAME_MBAFF && (dir == 1) && ((mb_y&1) == 0) + if (FRAME_MBAFF(h) && (dir == 1) && ((mb_y&1) == 0) && IS_INTERLACED(mbm_type&~mb_type) ) { // This is a special case in the norm where the filtering must @@ -538,14 +538,14 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u if( IS_INTRA(mb_type|mbm_type)) { AV_WN64A(bS, 0x0003000300030003ULL); if ( (!IS_INTERLACED(mb_type|mbm_type)) - || ((FRAME_MBAFF || (h->picture_structure != PICT_FRAME)) && (dir == 0)) + || ((FRAME_MBAFF(h) || (h->picture_structure != PICT_FRAME)) && (dir == 0)) ) AV_WN64A(bS, 0x0004000400040004ULL); } else { int i; int mv_done; - if( dir && FRAME_MBAFF && IS_INTERLACED(mb_type ^ mbm_type)) { + if( dir && FRAME_MBAFF(h) && IS_INTERLACED(mb_type ^ mbm_type)) { AV_WN64A(bS, 0x0001000100010001ULL); mv_done = 1; } @@ -711,7 +711,7 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint int a = h->slice_alpha_c0_offset - qp_bd_offset; int b = h->slice_beta_offset - qp_bd_offset; - if (FRAME_MBAFF + if (FRAME_MBAFF(h) // and current and left pair do not have the same interlaced type && IS_INTERLACED(mb_type^h->left_type[LTOP]) // and left mb is in available to us diff --git a/libavcodec/h264_mb_template.c b/libavcodec/h264_mb_template.c index 5c1121f735..769ac94d3d 100644 --- a/libavcodec/h264_mb_template.c +++ b/libavcodec/h264_mb_template.c @@ -73,7 +73,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h) dest_cb -= h->uvlinesize * (block_h - 1); dest_cr -= h->uvlinesize * (block_h - 1); } - if (FRAME_MBAFF) { + if (FRAME_MBAFF(h)) { int list; for (list = 0; list < h->list_count; list++) { if (!USES_LIST(mb_type, list)) @@ -302,7 +302,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h) if (mb_y & 1) // FIXME move out of this function? for (p = 0; p < 3; p++) dest[p] -= h->linesize * 15; - if (FRAME_MBAFF) { + if (FRAME_MBAFF(h)) { int list; for (list = 0; list < h->list_count; list++) { if (!USES_LIST(mb_type, list)) diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h index b0f60343f6..e87340c142 100644 --- a/libavcodec/h264_mvpred.h +++ b/libavcodec/h264_mvpred.h @@ -42,7 +42,7 @@ static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, /* there is no consistent mapping of mvs to neighboring locations that will * make mbaff happy, so we can't move all this logic to fill_caches */ - if (FRAME_MBAFF) { + if (FRAME_MBAFF(h)) { #define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4) \ const int xy = XY, y4 = Y4; \ const int mb_type = mb_types[xy + (y4 >> 2) * h->mb_stride]; \ @@ -231,7 +231,7 @@ static av_always_inline void pred_8x16_motion(H264Context *const h, } #define FIX_MV_MBAFF(type, refn, mvn, idx) \ - if (FRAME_MBAFF) { \ + if (FRAME_MBAFF(h)) { \ if (MB_FIELD(h)) { \ if (!IS_INTERLACED(type)) { \ refn <<= 1; \ @@ -369,7 +369,7 @@ static void fill_decode_neighbors(H264Context *h, int mb_type) topright_xy = top_xy + 1; left_xy[LBOT] = left_xy[LTOP] = mb_xy - 1; h->left_block = left_block_options[0]; - if (FRAME_MBAFF) { + if (FRAME_MBAFF(h)) { const int left_mb_field_flag = IS_INTERLACED(h->cur_pic.mb_type[mb_xy - 1]); const int curr_mb_field_flag = IS_INTERLACED(mb_type); if (h->mb_y & 1) { @@ -678,7 +678,7 @@ static void fill_decode_caches(H264Context *h, int mb_type) } } - if ((mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2)) && !FRAME_MBAFF) + if ((mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2)) && !FRAME_MBAFF(h)) continue; if (!(mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2))) { @@ -760,7 +760,7 @@ static void fill_decode_caches(H264Context *h, int mb_type) MAP_F2F(scan8[0] - 1 + 2 * 8, left_type[LBOT]) \ MAP_F2F(scan8[0] - 1 + 3 * 8, left_type[LBOT]) - if (FRAME_MBAFF) { + if (FRAME_MBAFF(h)) { if (MB_FIELD(h)) { #define MAP_F2F(idx, mb_type) \ From 7fa00653a550c0d24b3951c0f9fed6350ecf5ce4 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 Mar 2013 20:37:11 +0100 Subject: [PATCH 2/2] h264: add a parameter to the FIELD_PICTURE macro. This way it does not look like a constant. --- libavcodec/h264.c | 24 ++++++++++++------------ libavcodec/h264.h | 6 +++--- libavcodec/h264_cabac.c | 2 +- libavcodec/h264_loopfilter.c | 6 +++--- libavcodec/h264_refs.c | 12 ++++++------ 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index d52349a3b6..14369ac70c 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -751,7 +751,7 @@ static void await_references(H264Context *h) row <<= MB_MBAFF(h); nrefs[list]--; - if (!FIELD_PICTURE && ref_field_picture) { // frame referencing two fields + if (!FIELD_PICTURE(h) && ref_field_picture) { // frame referencing two fields ff_thread_await_progress(&ref_pic->tf, FFMIN((row >> 1) - !(row & 1), pic_height - 1), @@ -759,12 +759,12 @@ static void await_references(H264Context *h) ff_thread_await_progress(&ref_pic->tf, FFMIN((row >> 1), pic_height - 1), 0); - } else if (FIELD_PICTURE && !ref_field_picture) { // field referencing one field of a frame + } else if (FIELD_PICTURE(h) && !ref_field_picture) { // field referencing one field of a frame ff_thread_await_progress(&ref_pic->tf, FFMIN(row * 2 + ref_field, pic_height - 1), 0); - } else if (FIELD_PICTURE) { + } else if (FIELD_PICTURE(h)) { ff_thread_await_progress(&ref_pic->tf, FFMIN(row, pic_height - 1), ref_field); @@ -2801,7 +2801,7 @@ static int field_end(H264Context *h, int in_setup) * past end by one (callers fault) and resync_mb_y != 0 * causes problems for the first MB line, too. */ - if (!FIELD_PICTURE) { + if (!FIELD_PICTURE(h)) { h->er.cur_pic = h->cur_pic_ptr; h->er.last_pic = h->ref_count[0] ? &h->ref_list[0][0] : NULL; h->er.next_pic = h->ref_count[1] ? &h->ref_list[1][0] : NULL; @@ -3098,7 +3098,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) first_mb_in_slice = get_ue_golomb(&h->gb); if (first_mb_in_slice == 0) { // FIXME better field boundary detection - if (h0->current_slice && FIELD_PICTURE) { + if (h0->current_slice && FIELD_PICTURE(h)) { field_end(h, 1); } @@ -3327,7 +3327,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF); /* figure out if we have a complementary field pair */ - if (!FIELD_PICTURE || h->picture_structure == last_pic_structure) { + if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) { /* Previous field is unmatched. Don't display it, but let it * remain for reference if marked as such. */ if (!last_pic_droppable && last_pic_structure != PICT_FRAME) { @@ -3411,11 +3411,11 @@ static int decode_slice_header(H264Context *h, H264Context *h0) assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF); /* figure out if we have a complementary field pair */ - if (!FIELD_PICTURE || h->picture_structure == last_pic_structure) { + if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) { /* Previous field is unmatched. Don't display it, but let it * remain for reference if marked as such. */ h0->cur_pic_ptr = NULL; - h0->first_field = FIELD_PICTURE; + h0->first_field = FIELD_PICTURE(h); } else { if (h0->cur_pic_ptr->frame_num != h->frame_num) { /* This and the previous field had different frame_nums. @@ -3430,10 +3430,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0) } } else { /* Frame or first field in a potentially complementary pair */ - h0->first_field = FIELD_PICTURE; + h0->first_field = FIELD_PICTURE(h); } - if (!FIELD_PICTURE || h0->first_field) { + if (!FIELD_PICTURE(h) || h0->first_field) { if (h264_frame_start(h) < 0) { h0->first_field = 0; return -1; @@ -4058,8 +4058,8 @@ static void predict_field_decoding_flag(H264Context *h) */ static void decode_finish_row(H264Context *h) { - int top = 16 * (h->mb_y >> FIELD_PICTURE); - int pic_height = 16 * h->mb_height >> FIELD_PICTURE; + int top = 16 * (h->mb_y >> FIELD_PICTURE(h)); + int pic_height = 16 * h->mb_height >> FIELD_PICTURE(h); int height = 16 << FRAME_MBAFF(h); int deblock_border = (16 + 4) << FRAME_MBAFF(h); diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 077202dd9d..66708c04c6 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -62,7 +62,7 @@ #define MB_MBAFF(h) h->mb_mbaff #define MB_FIELD(h) h->mb_field_decoding_flag #define FRAME_MBAFF(h) h->mb_aff_frame -#define FIELD_PICTURE (h->picture_structure != PICT_FRAME) +#define FIELD_PICTURE(h) (h->picture_structure != PICT_FRAME) #define LEFT_MBS 2 #define LTOP 0 #define LBOT 1 @@ -71,7 +71,7 @@ #define MB_MBAFF(h) 0 #define MB_FIELD(h) 0 #define FRAME_MBAFF(h) 0 -#define FIELD_PICTURE 0 +#define FIELD_PICTURE(h) 0 #undef IS_INTERLACED #define IS_INTERLACED(mb_type) 0 #define LEFT_MBS 1 @@ -79,7 +79,7 @@ #define LBOT 0 #define LEFT(i) 0 #endif -#define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF(h) || FIELD_PICTURE) +#define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF(h) || FIELD_PICTURE(h)) #ifndef CABAC #define CABAC h->pps.cabac diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index 258e9ee7e6..8cd60dcf23 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1341,7 +1341,7 @@ static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) { }else{ int mb_xy = h->mb_xy; mba_xy = mb_xy - 1; - mbb_xy = mb_xy - (h->mb_stride << FIELD_PICTURE); + mbb_xy = mb_xy - (h->mb_stride << FIELD_PICTURE(h)); } if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP(h->cur_pic.mb_type[mba_xy] )) diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index 87566192d3..bd1cf9c0d6 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -271,7 +271,7 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h, if( IS_INTRA(mb_type) ) { static const int16_t bS4[4] = {4,4,4,4}; static const int16_t bS3[4] = {3,3,3,3}; - const int16_t *bSH = FIELD_PICTURE ? bS3 : bS4; + const int16_t *bSH = FIELD_PICTURE(h) ? bS3 : bS4; if(left_type) filter_mb_edgev( &img_y[4*0<>24); //IS_8x8DCT(mb_type) ? 2 : 1; edges = 4 - 3*((mb_type>>3) & !(h->cbp & 15)); //(mb_type & MB_TYPE_16x16) && !(h->cbp & 15) ? 1 : 4; h->h264dsp.h264_loop_filter_strength( bS, h->non_zero_count_cache, h->ref_cache, h->mv_cache, - h->list_count==2, edges, step, mask_edge0, mask_edge1, FIELD_PICTURE); + h->list_count==2, edges, step, mask_edge0, mask_edge1, FIELD_PICTURE(h)); } if( IS_INTRA(left_type) ) AV_WN64A(bS[0][0], 0x0004000400040004ULL); if( IS_INTRA(top_type) ) - AV_WN64A(bS[1][0], FIELD_PICTURE ? 0x0003000300030003ULL : 0x0004000400040004ULL); + AV_WN64A(bS[1][0], FIELD_PICTURE(h) ? 0x0003000300030003ULL : 0x0004000400040004ULL); #define FILTER(hv,dir,edge,intra)\ if(AV_RN64A(bS[dir][edge])) { \ diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index 796f8295ed..c96503343b 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -122,7 +122,7 @@ int ff_h264_fill_default_ref_list(H264Context *h) int cur_poc, list; int lens[2]; - if (FIELD_PICTURE) + if (FIELD_PICTURE(h)) cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD]; else cur_poc = h->cur_pic_ptr->poc; @@ -191,7 +191,7 @@ static void print_long_term(H264Context *h); static int pic_num_extract(H264Context *h, int pic_num, int *structure) { *structure = h->picture_structure; - if (FIELD_PICTURE) { + if (FIELD_PICTURE(h)) { if (!(pic_num & 1)) /* opposite field */ *structure ^= PICT_FRAME; @@ -291,7 +291,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h) COPY_PICTURE(&h->ref_list[list][i], &h->ref_list[list][i - 1]); } COPY_PICTURE(&h->ref_list[list][index], ref); - if (FIELD_PICTURE) { + if (FIELD_PICTURE(h)) { pic_as_field(&h->ref_list[list][index], pic_structure); } } @@ -524,11 +524,11 @@ int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice) if (h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count && - !(FIELD_PICTURE && !h->first_field && h->cur_pic_ptr->reference)) { + !(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; mmco_index = 1; - if (FIELD_PICTURE) { + if (FIELD_PICTURE(h)) { mmco[0].short_pic_num *= 2; mmco[1].opcode = MMCO_SHORT2UNUSED; mmco[1].short_pic_num = mmco[0].short_pic_num + 1; @@ -751,7 +751,7 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb, if (long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG && long_arg == 16) && - !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))) { + !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE(h)))) { av_log(h->avctx, AV_LOG_ERROR, "illegal long ref in memory management control " "operation %d\n", opcode);