Skip to content

Commit

Permalink
Merge commit '7fa00653a550c0d24b3951c0f9fed6350ecf5ce4'
Browse files Browse the repository at this point in the history
* commit '7fa00653a550c0d24b3951c0f9fed6350ecf5ce4':
  h264: add a parameter to the FIELD_PICTURE macro.
  h264: add a parameter to the FRAME_MBAFF macro.

Conflicts:
	libavcodec/h264.c
	libavcodec/h264_loopfilter.c
	libavcodec/h264_refs.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
  • Loading branch information
michaelni committed Mar 21, 2013
2 parents e168b50 + 7fa0065 commit bf4d0f8
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 69 deletions.
60 changes: 30 additions & 30 deletions libavcodec/h264.c
Expand Up @@ -786,20 +786,20 @@ 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),
1);
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);
Expand Down Expand Up @@ -2096,7 +2096,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];
Expand Down Expand Up @@ -2189,7 +2189,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;
Expand Down Expand Up @@ -2581,7 +2581,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;
Expand Down Expand Up @@ -2863,7 +2863,7 @@ static int field_end(H264Context *h, int in_setup)
* causes problems for the first MB line, too.
*/
if (CONFIG_ERROR_RESILIENCE &&
!FIELD_PICTURE && h->current_slice && !h->sps.new) {
!FIELD_PICTURE(h) && h->current_slice && !h->sps.new) {
h->er.cur_pic = h->cur_pic_ptr;
ff_er_frame_end(&h->er);
}
Expand Down Expand Up @@ -3208,7 +3208,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
first_mb_in_slice = get_ue_golomb_long(&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);
}

Expand Down Expand Up @@ -3452,7 +3452,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
}

/* 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) {
Expand Down Expand Up @@ -3539,11 +3539,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) {
ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
Expand All @@ -3560,10 +3560,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;
Expand Down Expand Up @@ -3700,7 +3700,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) {
Expand Down Expand Up @@ -3989,7 +3989,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) {
Expand Down Expand Up @@ -4018,7 +4018,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) &&
Expand Down Expand Up @@ -4124,21 +4124,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);

Expand Down Expand Up @@ -4173,7 +4173,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 {
Expand All @@ -4184,7 +4184,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);
}
Expand All @@ -4204,10 +4204,10 @@ 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 height = 16 << FRAME_MBAFF;
int deblock_border = (16 + 4) << FRAME_MBAFF;
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);

if (h->deblocking_filter) {
if ((top + height) >= pic_height)
Expand Down Expand Up @@ -4253,7 +4253,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)

av_assert0(h->block_offset[15] == (4 * ((scan8[15] - scan8[0]) & 7) << h->pixel_shift) + 4 * h->linesize * ((scan8[15] - scan8[0]) >> 3));

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));

Expand All @@ -4278,7 +4278,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);
Expand Down Expand Up @@ -4316,7 +4316,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);
}
}
Expand All @@ -4339,7 +4339,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);

Expand All @@ -4363,7 +4363,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) {
Expand Down
10 changes: 5 additions & 5 deletions libavcodec/h264.h
Expand Up @@ -63,25 +63,25 @@
#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 FIELD_PICTURE (h->picture_structure != PICT_FRAME)
#define FRAME_MBAFF(h) h->mb_aff_frame
#define FIELD_PICTURE(h) (h->picture_structure != PICT_FRAME)
#define LEFT_MBS 2
#define LTOP 0
#define LBOT 1
#define LEFT(i) (i)
#else
#define MB_MBAFF(h) 0
#define MB_FIELD(h) 0
#define FRAME_MBAFF 0
#define FIELD_PICTURE 0
#define FRAME_MBAFF(h) 0
#define FIELD_PICTURE(h) 0
#undef IS_INTERLACED
#define IS_INTERLACED(mb_type) 0
#define LEFT_MBS 1
#define LTOP 0
#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(h))

#ifndef CABAC
#define CABAC h->pps.cabac
Expand Down
10 changes: 5 additions & 5 deletions libavcodec/h264_cabac.c
Expand Up @@ -1322,7 +1322,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)
Expand All @@ -1340,7 +1340,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] ))
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions libavcodec/h264_cavlc.c
Expand Up @@ -709,15 +709,15 @@ 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);
}
decode_mb_skip(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);
}
Expand Down
8 changes: 4 additions & 4 deletions libavcodec/h264_direct.c
Expand Up @@ -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];
Expand Down Expand Up @@ -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){
Expand All @@ -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);
}
Expand Down Expand Up @@ -496,7 +496,7 @@ static void pred_temp_direct_motion(H264Context * const h, int *mb_type){
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];
Expand Down

0 comments on commit bf4d0f8

Please sign in to comment.