mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-27 18:02:11 +00:00
h264: move mb_mbaff into the per-slice context
This commit is contained in:
parent
bc98e8c0e0
commit
e9b2383bf8
@ -365,6 +365,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;
|
||||
|
||||
@ -496,7 +497,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;
|
||||
|
||||
|
@ -1930,7 +1930,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);
|
||||
@ -1945,7 +1945,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);
|
||||
}
|
||||
|
||||
@ -2122,7 +2122,7 @@ decode_intra_mb:
|
||||
for( i = 0; i < 4; i++ ) {
|
||||
if(IS_DIRECT(sl->sub_mb_type[i])) continue;
|
||||
if(IS_DIR(sl->sub_mb_type[i], 0, list)){
|
||||
int rc = sl->ref_count[list] << MB_MBAFF(h);
|
||||
int rc = sl->ref_count[list] << MB_MBAFF(sl);
|
||||
if (rc > 1) {
|
||||
ref[list][i] = decode_cabac_mb_ref(h, sl, list, 4 * i);
|
||||
if (ref[list][i] >= (unsigned) rc) {
|
||||
@ -2208,7 +2208,7 @@ decode_intra_mb:
|
||||
if(IS_16X16(mb_type)){
|
||||
for (list = 0; list < sl->list_count; list++) {
|
||||
if(IS_DIR(mb_type, 0, list)){
|
||||
int ref, rc = sl->ref_count[list] << MB_MBAFF(h);
|
||||
int ref, rc = sl->ref_count[list] << MB_MBAFF(sl);
|
||||
if (rc > 1) {
|
||||
ref= decode_cabac_mb_ref(h, sl, list, 0);
|
||||
if (ref >= (unsigned) rc) {
|
||||
@ -2236,7 +2236,7 @@ decode_intra_mb:
|
||||
for (list = 0; list < sl->list_count; list++) {
|
||||
for(i=0; i<2; i++){
|
||||
if(IS_DIR(mb_type, i, list)){
|
||||
int ref, rc = sl->ref_count[list] << MB_MBAFF(h);
|
||||
int ref, rc = sl->ref_count[list] << MB_MBAFF(sl);
|
||||
if (rc > 1) {
|
||||
ref= decode_cabac_mb_ref(h, sl, list, 8 * i);
|
||||
if (ref >= (unsigned) rc) {
|
||||
@ -2271,7 +2271,7 @@ decode_intra_mb:
|
||||
for (list = 0; list < sl->list_count; list++) {
|
||||
for(i=0; i<2; i++){
|
||||
if(IS_DIR(mb_type, i, list)){ //FIXME optimize
|
||||
int ref, rc = sl->ref_count[list] << MB_MBAFF(h);
|
||||
int ref, rc = sl->ref_count[list] << MB_MBAFF(sl);
|
||||
if (rc > 1) {
|
||||
ref= decode_cabac_mb_ref(h, sl, list, 4 * i);
|
||||
if (ref >= (unsigned) rc) {
|
||||
|
@ -715,7 +715,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;
|
||||
@ -723,7 +723,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;
|
||||
@ -865,7 +865,7 @@ decode_intra_mb:
|
||||
}
|
||||
|
||||
for (list = 0; list < sl->list_count; list++) {
|
||||
int ref_count = IS_REF0(mb_type) ? 1 : sl->ref_count[list] << MB_MBAFF(h);
|
||||
int ref_count = IS_REF0(mb_type) ? 1 : sl->ref_count[list] << MB_MBAFF(sl);
|
||||
for(i=0; i<4; i++){
|
||||
if(IS_DIRECT(sl->sub_mb_type[i])) continue;
|
||||
if(IS_DIR(sl->sub_mb_type[i], 0, list)){
|
||||
@ -945,7 +945,7 @@ decode_intra_mb:
|
||||
for (list = 0; list < sl->list_count; list++) {
|
||||
unsigned int val;
|
||||
if(IS_DIR(mb_type, 0, list)){
|
||||
int rc = sl->ref_count[list] << MB_MBAFF(h);
|
||||
int rc = sl->ref_count[list] << MB_MBAFF(sl);
|
||||
if (rc == 1) {
|
||||
val= 0;
|
||||
} else if (rc == 2) {
|
||||
@ -976,7 +976,7 @@ decode_intra_mb:
|
||||
for(i=0; i<2; i++){
|
||||
unsigned int val;
|
||||
if(IS_DIR(mb_type, i, list)){
|
||||
int rc = sl->ref_count[list] << MB_MBAFF(h);
|
||||
int rc = sl->ref_count[list] << MB_MBAFF(sl);
|
||||
if (rc == 1) {
|
||||
val= 0;
|
||||
} else if (rc == 2) {
|
||||
@ -1014,7 +1014,7 @@ decode_intra_mb:
|
||||
for(i=0; i<2; i++){
|
||||
unsigned int val;
|
||||
if(IS_DIR(mb_type, i, list)){ //FIXME optimize
|
||||
int rc = sl->ref_count[list] << MB_MBAFF(h);
|
||||
int rc = sl->ref_count[list] << MB_MBAFF(sl);
|
||||
if (rc == 1) {
|
||||
val= 0;
|
||||
} else if (rc == 2) {
|
||||
|
@ -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
|
||||
@ -516,10 +516,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -735,7 +735,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)
|
||||
@ -770,7 +770,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;
|
||||
@ -1356,7 +1356,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
|
||||
|
||||
h->frame_num = get_bits(&sl->gb, h->sps.log2_max_frame_num);
|
||||
|
||||
h->mb_mbaff = 0;
|
||||
sl->mb_mbaff = 0;
|
||||
h->mb_aff_frame = 0;
|
||||
last_pic_structure = h0->picture_structure;
|
||||
last_pic_droppable = h0->droppable;
|
||||
@ -1836,7 +1836,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] = sl->ref2frm[h->slice_table[top_xy] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2);
|
||||
int (*ref2frm)[64] = 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]];
|
||||
@ -1851,7 +1851,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] = sl->ref2frm[h->slice_table[left_xy[LTOP]] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2);
|
||||
int (*ref2frm)[64] = 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]);
|
||||
@ -1884,7 +1884,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] = sl->ref2frm[sl->slice_num & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2);
|
||||
int (*ref2frm)[64] = 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);
|
||||
@ -2070,7 +2070,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;
|
||||
@ -2127,7 +2127,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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user