Commit 7fa00653 authored by Anton Khirnov's avatar Anton Khirnov

h264: add a parameter to the FIELD_PICTURE macro.

This way it does not look like a constant.
parent 7bece9b2
...@@ -751,7 +751,7 @@ static void await_references(H264Context *h) ...@@ -751,7 +751,7 @@ static void await_references(H264Context *h)
row <<= MB_MBAFF(h); row <<= MB_MBAFF(h);
nrefs[list]--; 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, ff_thread_await_progress(&ref_pic->tf,
FFMIN((row >> 1) - !(row & 1), FFMIN((row >> 1) - !(row & 1),
pic_height - 1), pic_height - 1),
...@@ -759,12 +759,12 @@ static void await_references(H264Context *h) ...@@ -759,12 +759,12 @@ static void await_references(H264Context *h)
ff_thread_await_progress(&ref_pic->tf, ff_thread_await_progress(&ref_pic->tf,
FFMIN((row >> 1), pic_height - 1), FFMIN((row >> 1), pic_height - 1),
0); 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, ff_thread_await_progress(&ref_pic->tf,
FFMIN(row * 2 + ref_field, FFMIN(row * 2 + ref_field,
pic_height - 1), pic_height - 1),
0); 0);
} else if (FIELD_PICTURE) { } else if (FIELD_PICTURE(h)) {
ff_thread_await_progress(&ref_pic->tf, ff_thread_await_progress(&ref_pic->tf,
FFMIN(row, pic_height - 1), FFMIN(row, pic_height - 1),
ref_field); ref_field);
...@@ -2801,7 +2801,7 @@ static int field_end(H264Context *h, int in_setup) ...@@ -2801,7 +2801,7 @@ static int field_end(H264Context *h, int in_setup)
* past end by one (callers fault) and resync_mb_y != 0 * past end by one (callers fault) and resync_mb_y != 0
* causes problems for the first MB line, too. * 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.cur_pic = h->cur_pic_ptr;
h->er.last_pic = h->ref_count[0] ? &h->ref_list[0][0] : NULL; 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; 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) ...@@ -3098,7 +3098,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
first_mb_in_slice = get_ue_golomb(&h->gb); first_mb_in_slice = get_ue_golomb(&h->gb);
if (first_mb_in_slice == 0) { // FIXME better field boundary detection 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); field_end(h, 1);
} }
...@@ -3327,7 +3327,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -3327,7 +3327,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF); assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
/* figure out if we have a complementary field pair */ /* 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 /* Previous field is unmatched. Don't display it, but let it
* remain for reference if marked as such. */ * remain for reference if marked as such. */
if (!last_pic_droppable && last_pic_structure != PICT_FRAME) { if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
...@@ -3411,11 +3411,11 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -3411,11 +3411,11 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF); assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
/* figure out if we have a complementary field pair */ /* 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 /* Previous field is unmatched. Don't display it, but let it
* remain for reference if marked as such. */ * remain for reference if marked as such. */
h0->cur_pic_ptr = NULL; h0->cur_pic_ptr = NULL;
h0->first_field = FIELD_PICTURE; h0->first_field = FIELD_PICTURE(h);
} else { } else {
if (h0->cur_pic_ptr->frame_num != h->frame_num) { if (h0->cur_pic_ptr->frame_num != h->frame_num) {
/* This and the previous field had different frame_nums. /* This and the previous field had different frame_nums.
...@@ -3430,10 +3430,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -3430,10 +3430,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
} }
} else { } else {
/* Frame or first field in a potentially complementary pair */ /* 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) { if (h264_frame_start(h) < 0) {
h0->first_field = 0; h0->first_field = 0;
return -1; return -1;
...@@ -4058,8 +4058,8 @@ static void predict_field_decoding_flag(H264Context *h) ...@@ -4058,8 +4058,8 @@ static void predict_field_decoding_flag(H264Context *h)
*/ */
static void decode_finish_row(H264Context *h) static void decode_finish_row(H264Context *h)
{ {
int top = 16 * (h->mb_y >> FIELD_PICTURE); int top = 16 * (h->mb_y >> FIELD_PICTURE(h));
int pic_height = 16 * h->mb_height >> FIELD_PICTURE; int pic_height = 16 * h->mb_height >> FIELD_PICTURE(h);
int height = 16 << FRAME_MBAFF(h); int height = 16 << FRAME_MBAFF(h);
int deblock_border = (16 + 4) << FRAME_MBAFF(h); int deblock_border = (16 + 4) << FRAME_MBAFF(h);
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
#define MB_MBAFF(h) h->mb_mbaff #define MB_MBAFF(h) h->mb_mbaff
#define MB_FIELD(h) h->mb_field_decoding_flag #define MB_FIELD(h) h->mb_field_decoding_flag
#define FRAME_MBAFF(h) h->mb_aff_frame #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 LEFT_MBS 2
#define LTOP 0 #define LTOP 0
#define LBOT 1 #define LBOT 1
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
#define MB_MBAFF(h) 0 #define MB_MBAFF(h) 0
#define MB_FIELD(h) 0 #define MB_FIELD(h) 0
#define FRAME_MBAFF(h) 0 #define FRAME_MBAFF(h) 0
#define FIELD_PICTURE 0 #define FIELD_PICTURE(h) 0
#undef IS_INTERLACED #undef IS_INTERLACED
#define IS_INTERLACED(mb_type) 0 #define IS_INTERLACED(mb_type) 0
#define LEFT_MBS 1 #define LEFT_MBS 1
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
#define LBOT 0 #define LBOT 0
#define LEFT(i) 0 #define LEFT(i) 0
#endif #endif
#define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF(h) || FIELD_PICTURE) #define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF(h) || FIELD_PICTURE(h))
#ifndef CABAC #ifndef CABAC
#define CABAC h->pps.cabac #define CABAC h->pps.cabac
......
...@@ -1341,7 +1341,7 @@ static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) { ...@@ -1341,7 +1341,7 @@ static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) {
}else{ }else{
int mb_xy = h->mb_xy; int mb_xy = h->mb_xy;
mba_xy = mb_xy - 1; 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] )) if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP(h->cur_pic.mb_type[mba_xy] ))
......
...@@ -271,7 +271,7 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h, ...@@ -271,7 +271,7 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
if( IS_INTRA(mb_type) ) { if( IS_INTRA(mb_type) ) {
static const int16_t bS4[4] = {4,4,4,4}; static const int16_t bS4[4] = {4,4,4,4};
static const int16_t bS3[4] = {3,3,3,3}; 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) if(left_type)
filter_mb_edgev( &img_y[4*0<<pixel_shift], linesize, bS4, qp0, a, b, h, 1); filter_mb_edgev( &img_y[4*0<<pixel_shift], linesize, bS4, qp0, a, b, h, 1);
if( IS_8x8DCT(mb_type) ) { if( IS_8x8DCT(mb_type) ) {
...@@ -372,12 +372,12 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h, ...@@ -372,12 +372,12 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
int step = 1+(mb_type>>24); //IS_8x8DCT(mb_type) ? 2 : 1; int step = 1+(mb_type>>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; 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->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) ) if( IS_INTRA(left_type) )
AV_WN64A(bS[0][0], 0x0004000400040004ULL); AV_WN64A(bS[0][0], 0x0004000400040004ULL);
if( IS_INTRA(top_type) ) 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)\ #define FILTER(hv,dir,edge,intra)\
if(AV_RN64A(bS[dir][edge])) { \ if(AV_RN64A(bS[dir][edge])) { \
......
...@@ -122,7 +122,7 @@ int ff_h264_fill_default_ref_list(H264Context *h) ...@@ -122,7 +122,7 @@ int ff_h264_fill_default_ref_list(H264Context *h)
int cur_poc, list; int cur_poc, list;
int lens[2]; int lens[2];
if (FIELD_PICTURE) if (FIELD_PICTURE(h))
cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD]; cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD];
else else
cur_poc = h->cur_pic_ptr->poc; cur_poc = h->cur_pic_ptr->poc;
...@@ -191,7 +191,7 @@ static void print_long_term(H264Context *h); ...@@ -191,7 +191,7 @@ static void print_long_term(H264Context *h);
static int pic_num_extract(H264Context *h, int pic_num, int *structure) static int pic_num_extract(H264Context *h, int pic_num, int *structure)
{ {
*structure = h->picture_structure; *structure = h->picture_structure;
if (FIELD_PICTURE) { if (FIELD_PICTURE(h)) {
if (!(pic_num & 1)) if (!(pic_num & 1))
/* opposite field */ /* opposite field */
*structure ^= PICT_FRAME; *structure ^= PICT_FRAME;
...@@ -291,7 +291,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h) ...@@ -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][i], &h->ref_list[list][i - 1]);
} }
COPY_PICTURE(&h->ref_list[list][index], ref); 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); 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) ...@@ -524,11 +524,11 @@ int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
if (h->short_ref_count && if (h->short_ref_count &&
h->long_ref_count + h->short_ref_count == h->sps.ref_frame_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].opcode = MMCO_SHORT2UNUSED;
mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num; mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;
mmco_index = 1; mmco_index = 1;
if (FIELD_PICTURE) { if (FIELD_PICTURE(h)) {
mmco[0].short_pic_num *= 2; mmco[0].short_pic_num *= 2;
mmco[1].opcode = MMCO_SHORT2UNUSED; mmco[1].opcode = MMCO_SHORT2UNUSED;
mmco[1].short_pic_num = mmco[0].short_pic_num + 1; 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, ...@@ -751,7 +751,7 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb,
if (long_arg >= 32 || if (long_arg >= 32 ||
(long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG && (long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG &&
long_arg == 16) && long_arg == 16) &&
!(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))) { !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE(h)))) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"illegal long ref in memory management control " "illegal long ref in memory management control "
"operation %d\n", opcode); "operation %d\n", opcode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment