Commit 61635c7a authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '8b00f4df'

* commit '8b00f4df':
  h264: move some neighbour information into the per-slice context

Conflicts:
	libavcodec/h264_cabac.c
	libavcodec/h264_cavlc.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents a2740a06 8b00f4df
...@@ -357,6 +357,19 @@ typedef struct H264SliceContext { ...@@ -357,6 +357,19 @@ typedef struct H264SliceContext {
int chroma_pred_mode; int chroma_pred_mode;
int intra16x16_pred_mode; int intra16x16_pred_mode;
int topleft_mb_xy;
int top_mb_xy;
int topright_mb_xy;
int left_mb_xy[LEFT_MBS];
int topleft_type;
int top_type;
int topright_type;
int left_type[LEFT_MBS];
const uint8_t *left_block;
int topleft_partition;
} H264SliceContext; } H264SliceContext;
/** /**
...@@ -396,19 +409,6 @@ typedef struct H264Context { ...@@ -396,19 +409,6 @@ typedef struct H264Context {
int workaround_bugs; int workaround_bugs;
// prediction stuff // prediction stuff
int topleft_mb_xy;
int top_mb_xy;
int topright_mb_xy;
int left_mb_xy[LEFT_MBS];
int topleft_type;
int top_type;
int topright_type;
int left_type[LEFT_MBS];
const uint8_t *left_block;
int topleft_partition;
int8_t intra4x4_pred_mode_cache[5 * 8]; int8_t intra4x4_pred_mode_cache[5 * 8];
int8_t(*intra4x4_pred_mode); int8_t(*intra4x4_pred_mode);
H264PredContext hpc; H264PredContext hpc;
......
...@@ -1293,15 +1293,17 @@ static int decode_cabac_field_decoding_flag(H264Context *h) { ...@@ -1293,15 +1293,17 @@ static int decode_cabac_field_decoding_flag(H264Context *h) {
return get_cabac_noinline( &h->cabac, &(h->cabac_state+70)[ctx] ); return get_cabac_noinline( &h->cabac, &(h->cabac_state+70)[ctx] );
} }
static int decode_cabac_intra_mb_type(H264Context *h, int ctx_base, int intra_slice) { static int decode_cabac_intra_mb_type(H264Context *h, H264SliceContext *sl,
int ctx_base, int intra_slice)
{
uint8_t *state= &h->cabac_state[ctx_base]; uint8_t *state= &h->cabac_state[ctx_base];
int mb_type; int mb_type;
if(intra_slice){ if(intra_slice){
int ctx=0; int ctx=0;
if( h->left_type[LTOP] & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)) if (sl->left_type[LTOP] & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM))
ctx++; ctx++;
if( h->top_type & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)) if (sl->top_type & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM))
ctx++; ctx++;
if( get_cabac_noinline( &h->cabac, &state[ctx] ) == 0 ) if( get_cabac_noinline( &h->cabac, &state[ctx] ) == 0 )
return 0; /* I4x4 */ return 0; /* I4x4 */
...@@ -1371,17 +1373,18 @@ static int decode_cabac_mb_intra4x4_pred_mode( H264Context *h, int pred_mode ) { ...@@ -1371,17 +1373,18 @@ static int decode_cabac_mb_intra4x4_pred_mode( H264Context *h, int pred_mode ) {
return mode + ( mode >= pred_mode ); return mode + ( mode >= pred_mode );
} }
static int decode_cabac_mb_chroma_pre_mode( H264Context *h) { static int decode_cabac_mb_chroma_pre_mode(H264Context *h, H264SliceContext *sl)
const int mba_xy = h->left_mb_xy[0]; {
const int mbb_xy = h->top_mb_xy; const int mba_xy = sl->left_mb_xy[0];
const int mbb_xy = sl->top_mb_xy;
int ctx = 0; int ctx = 0;
/* No need to test for IS_INTRA4x4 and IS_INTRA16x16, as we set chroma_pred_mode_table to 0 */ /* No need to test for IS_INTRA4x4 and IS_INTRA16x16, as we set chroma_pred_mode_table to 0 */
if( h->left_type[LTOP] && h->chroma_pred_mode_table[mba_xy] != 0 ) if (sl->left_type[LTOP] && h->chroma_pred_mode_table[mba_xy] != 0)
ctx++; ctx++;
if( h->top_type && h->chroma_pred_mode_table[mbb_xy] != 0 ) if (sl->top_type && h->chroma_pred_mode_table[mbb_xy] != 0)
ctx++; ctx++;
if( get_cabac_noinline( &h->cabac, &h->cabac_state[64+ctx] ) == 0 ) if( get_cabac_noinline( &h->cabac, &h->cabac_state[64+ctx] ) == 0 )
...@@ -1931,15 +1934,15 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl) ...@@ -1931,15 +1934,15 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl)
sl->prev_mb_skipped = 0; sl->prev_mb_skipped = 0;
fill_decode_neighbors(h, -(MB_FIELD(h))); fill_decode_neighbors(h, sl, -(MB_FIELD(h)));
if( h->slice_type_nos == AV_PICTURE_TYPE_B ) { if( h->slice_type_nos == AV_PICTURE_TYPE_B ) {
int ctx = 0; int ctx = 0;
av_assert2(h->slice_type_nos == AV_PICTURE_TYPE_B); av_assert2(h->slice_type_nos == AV_PICTURE_TYPE_B);
if( !IS_DIRECT( h->left_type[LTOP]-1 ) ) if (!IS_DIRECT(sl->left_type[LTOP] - 1))
ctx++; ctx++;
if( !IS_DIRECT( h->top_type-1 ) ) if (!IS_DIRECT(sl->top_type - 1))
ctx++; ctx++;
if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+ctx] ) ){ if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+ctx] ) ){
...@@ -1955,7 +1958,7 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl) ...@@ -1955,7 +1958,7 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl)
if( bits < 8 ){ if( bits < 8 ){
mb_type= bits + 3; /* B_Bi_16x16 through B_L1_L0_16x8 */ mb_type= bits + 3; /* B_Bi_16x16 through B_L1_L0_16x8 */
}else if( bits == 13 ){ }else if( bits == 13 ){
mb_type= decode_cabac_intra_mb_type(h, 32, 0); mb_type = decode_cabac_intra_mb_type(h, sl, 32, 0);
goto decode_intra_mb; goto decode_intra_mb;
}else if( bits == 14 ){ }else if( bits == 14 ){
mb_type= 11; /* B_L1_L0_8x16 */ mb_type= 11; /* B_L1_L0_8x16 */
...@@ -1981,11 +1984,11 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl) ...@@ -1981,11 +1984,11 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl)
partition_count= p_mb_type_info[mb_type].partition_count; partition_count= p_mb_type_info[mb_type].partition_count;
mb_type= p_mb_type_info[mb_type].type; mb_type= p_mb_type_info[mb_type].type;
} else { } else {
mb_type= decode_cabac_intra_mb_type(h, 17, 0); mb_type = decode_cabac_intra_mb_type(h, sl, 17, 0);
goto decode_intra_mb; goto decode_intra_mb;
} }
} else { } else {
mb_type= decode_cabac_intra_mb_type(h, 3, 1); mb_type = decode_cabac_intra_mb_type(h, sl, 3, 1);
if(h->slice_type == AV_PICTURE_TYPE_SI && mb_type) if(h->slice_type == AV_PICTURE_TYPE_SI && mb_type)
mb_type--; mb_type--;
av_assert2(h->slice_type_nos == AV_PICTURE_TYPE_I); av_assert2(h->slice_type_nos == AV_PICTURE_TYPE_I);
...@@ -2037,7 +2040,7 @@ decode_intra_mb: ...@@ -2037,7 +2040,7 @@ decode_intra_mb:
local_ref_count[0] = h->ref_count[0] << MB_MBAFF(h); local_ref_count[0] = h->ref_count[0] << MB_MBAFF(h);
local_ref_count[1] = h->ref_count[1] << MB_MBAFF(h); local_ref_count[1] = h->ref_count[1] << MB_MBAFF(h);
fill_decode_caches(h, mb_type); fill_decode_caches(h, sl, mb_type);
if( IS_INTRA( mb_type ) ) { if( IS_INTRA( mb_type ) ) {
int i, pred_mode; int i, pred_mode;
...@@ -2066,7 +2069,7 @@ decode_intra_mb: ...@@ -2066,7 +2069,7 @@ decode_intra_mb:
} }
if(decode_chroma){ if(decode_chroma){
h->chroma_pred_mode_table[mb_xy] = h->chroma_pred_mode_table[mb_xy] =
pred_mode = decode_cabac_mb_chroma_pre_mode( h ); pred_mode = decode_cabac_mb_chroma_pre_mode(h, sl);
pred_mode= ff_h264_check_intra_pred_mode( h, pred_mode, 1 ); pred_mode= ff_h264_check_intra_pred_mode( h, pred_mode, 1 );
if( pred_mode < 0 ) return -1; if( pred_mode < 0 ) return -1;
...@@ -2141,7 +2144,7 @@ decode_intra_mb: ...@@ -2141,7 +2144,7 @@ decode_intra_mb:
const int index= 4*i + block_width*j; const int index= 4*i + block_width*j;
int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ]; int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ];
uint8_t (* mvd_cache)[2]= &h->mvd_cache[list][ scan8[index] ]; uint8_t (* mvd_cache)[2]= &h->mvd_cache[list][ scan8[index] ];
pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mx, &my); pred_motion(h, sl, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mx, &my);
DECODE_CABAC_MB_MVD( h, list, index) DECODE_CABAC_MB_MVD( h, list, index)
tprintf(h->avctx, "final mv:%d %d\n", mx, my); tprintf(h->avctx, "final mv:%d %d\n", mx, my);
...@@ -2205,7 +2208,7 @@ decode_intra_mb: ...@@ -2205,7 +2208,7 @@ decode_intra_mb:
for(list=0; list<h->list_count; list++){ for(list=0; list<h->list_count; list++){
if(IS_DIR(mb_type, 0, list)){ if(IS_DIR(mb_type, 0, list)){
int mx,my,mpx,mpy; int mx,my,mpx,mpy;
pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mx, &my); pred_motion(h, sl, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mx, &my);
DECODE_CABAC_MB_MVD( h, list, 0) DECODE_CABAC_MB_MVD( h, list, 0)
tprintf(h->avctx, "final mv:%d %d\n", mx, my); tprintf(h->avctx, "final mv:%d %d\n", mx, my);
...@@ -2236,7 +2239,7 @@ decode_intra_mb: ...@@ -2236,7 +2239,7 @@ decode_intra_mb:
for(i=0; i<2; i++){ for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){ if(IS_DIR(mb_type, i, list)){
int mx,my,mpx,mpy; int mx,my,mpx,mpy;
pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mx, &my); pred_16x8_motion(h, sl, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mx, &my);
DECODE_CABAC_MB_MVD( h, list, 8*i) DECODE_CABAC_MB_MVD( h, list, 8*i)
tprintf(h->avctx, "final mv:%d %d\n", mx, my); tprintf(h->avctx, "final mv:%d %d\n", mx, my);
...@@ -2271,7 +2274,7 @@ decode_intra_mb: ...@@ -2271,7 +2274,7 @@ decode_intra_mb:
for(i=0; i<2; i++){ for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){ if(IS_DIR(mb_type, i, list)){
int mx,my,mpx,mpy; int mx,my,mpx,mpy;
pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mx, &my); pred_8x16_motion(h, sl, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mx, &my);
DECODE_CABAC_MB_MVD( h, list, 4*i) DECODE_CABAC_MB_MVD( h, list, 4*i)
tprintf(h->avctx, "final mv:%d %d\n", mx, my); tprintf(h->avctx, "final mv:%d %d\n", mx, my);
...@@ -2314,7 +2317,7 @@ decode_intra_mb: ...@@ -2314,7 +2317,7 @@ decode_intra_mb:
int i; int i;
uint8_t *nnz_cache = h->non_zero_count_cache; uint8_t *nnz_cache = h->non_zero_count_cache;
for (i = 0; i < 2; i++){ for (i = 0; i < 2; i++){
if (h->left_type[LEFT(i)] && !IS_8x8DCT(h->left_type[LEFT(i)])){ if (sl->left_type[LEFT(i)] && !IS_8x8DCT(sl->left_type[LEFT(i)])) {
nnz_cache[3+8* 1 + 2*8*i]= nnz_cache[3+8* 1 + 2*8*i]=
nnz_cache[3+8* 2 + 2*8*i]= nnz_cache[3+8* 2 + 2*8*i]=
nnz_cache[3+8* 6 + 2*8*i]= nnz_cache[3+8* 6 + 2*8*i]=
...@@ -2323,7 +2326,7 @@ decode_intra_mb: ...@@ -2323,7 +2326,7 @@ decode_intra_mb:
nnz_cache[3+8*12 + 2*8*i]= IS_INTRA(mb_type) ? 64 : 0; nnz_cache[3+8*12 + 2*8*i]= IS_INTRA(mb_type) ? 64 : 0;
} }
} }
if (h->top_type && !IS_8x8DCT(h->top_type)){ if (sl->top_type && !IS_8x8DCT(sl->top_type)){
uint32_t top_empty = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 0x40404040; uint32_t top_empty = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 0x40404040;
AV_WN32A(&nnz_cache[4+8* 0], top_empty); AV_WN32A(&nnz_cache[4+8* 0], top_empty);
AV_WN32A(&nnz_cache[4+8* 5], top_empty); AV_WN32A(&nnz_cache[4+8* 5], top_empty);
......
...@@ -792,8 +792,8 @@ decode_intra_mb: ...@@ -792,8 +792,8 @@ decode_intra_mb:
local_ref_count[0] = h->ref_count[0] << MB_MBAFF(h); local_ref_count[0] = h->ref_count[0] << MB_MBAFF(h);
local_ref_count[1] = h->ref_count[1] << MB_MBAFF(h); local_ref_count[1] = h->ref_count[1] << MB_MBAFF(h);
fill_decode_neighbors(h, mb_type); fill_decode_neighbors(h, sl, mb_type);
fill_decode_caches(h, mb_type); fill_decode_caches(h, sl, mb_type);
//mb_pred //mb_pred
if(IS_INTRA(mb_type)){ if(IS_INTRA(mb_type)){
...@@ -914,7 +914,7 @@ decode_intra_mb: ...@@ -914,7 +914,7 @@ decode_intra_mb:
int mx, my; int mx, my;
const int index= 4*i + block_width*j; const int index= 4*i + block_width*j;
int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ]; int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ];
pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mx, &my); pred_motion(h, sl, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mx, &my);
mx += get_se_golomb(&h->gb); mx += get_se_golomb(&h->gb);
my += get_se_golomb(&h->gb); my += get_se_golomb(&h->gb);
tprintf(h->avctx, "final mv:%d %d\n", mx, my); tprintf(h->avctx, "final mv:%d %d\n", mx, my);
...@@ -967,7 +967,7 @@ decode_intra_mb: ...@@ -967,7 +967,7 @@ decode_intra_mb:
} }
for(list=0; list<h->list_count; list++){ for(list=0; list<h->list_count; list++){
if(IS_DIR(mb_type, 0, list)){ if(IS_DIR(mb_type, 0, list)){
pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mx, &my); pred_motion(h, sl, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mx, &my);
mx += get_se_golomb(&h->gb); mx += get_se_golomb(&h->gb);
my += get_se_golomb(&h->gb); my += get_se_golomb(&h->gb);
tprintf(h->avctx, "final mv:%d %d\n", mx, my); tprintf(h->avctx, "final mv:%d %d\n", mx, my);
...@@ -1001,7 +1001,7 @@ decode_intra_mb: ...@@ -1001,7 +1001,7 @@ decode_intra_mb:
for(i=0; i<2; i++){ for(i=0; i<2; i++){
unsigned int val; unsigned int val;
if(IS_DIR(mb_type, i, list)){ if(IS_DIR(mb_type, i, list)){
pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mx, &my); pred_16x8_motion(h, sl, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mx, &my);
mx += get_se_golomb(&h->gb); mx += get_se_golomb(&h->gb);
my += get_se_golomb(&h->gb); my += get_se_golomb(&h->gb);
tprintf(h->avctx, "final mv:%d %d\n", mx, my); tprintf(h->avctx, "final mv:%d %d\n", mx, my);
...@@ -1038,7 +1038,7 @@ decode_intra_mb: ...@@ -1038,7 +1038,7 @@ decode_intra_mb:
for(i=0; i<2; i++){ for(i=0; i<2; i++){
unsigned int val; unsigned int val;
if(IS_DIR(mb_type, i, list)){ if(IS_DIR(mb_type, i, list)){
pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mx, &my); pred_8x16_motion(h, sl, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mx, &my);
mx += get_se_golomb(&h->gb); mx += get_se_golomb(&h->gb);
my += get_se_golomb(&h->gb); my += get_se_golomb(&h->gb);
tprintf(h->avctx, "final mv:%d %d\n", mx, my); tprintf(h->avctx, "final mv:%d %d\n", mx, my);
......
...@@ -233,6 +233,7 @@ static av_always_inline void filter_mb_edgech(uint8_t *pix, int stride, ...@@ -233,6 +233,7 @@ static av_always_inline void filter_mb_edgech(uint8_t *pix, int stride,
} }
static av_always_inline void h264_filter_mb_fast_internal(H264Context *h, static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
H264SliceContext *sl,
int mb_x, int mb_y, int mb_x, int mb_y,
uint8_t *img_y, uint8_t *img_y,
uint8_t *img_cb, uint8_t *img_cb,
...@@ -246,8 +247,8 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h, ...@@ -246,8 +247,8 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
int chroma422 = CHROMA422(h); int chroma422 = CHROMA422(h);
int mb_xy = h->mb_xy; int mb_xy = h->mb_xy;
int left_type= h->left_type[LTOP]; int left_type = sl->left_type[LTOP];
int top_type= h->top_type; int top_type = sl->top_type;
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset; int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
...@@ -256,7 +257,7 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h, ...@@ -256,7 +257,7 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
int mb_type = h->cur_pic.mb_type[mb_xy]; int mb_type = h->cur_pic.mb_type[mb_xy];
int qp = h->cur_pic.qscale_table[mb_xy]; int qp = h->cur_pic.qscale_table[mb_xy];
int qp0 = h->cur_pic.qscale_table[mb_xy - 1]; int qp0 = h->cur_pic.qscale_table[mb_xy - 1];
int qp1 = h->cur_pic.qscale_table[h->top_mb_xy]; int qp1 = h->cur_pic.qscale_table[sl->top_mb_xy];
int qpc = get_chroma_qp( h, 0, qp ); int qpc = get_chroma_qp( h, 0, qp );
int qpc0 = get_chroma_qp( h, 0, qp0 ); int qpc0 = get_chroma_qp( h, 0, qp0 );
int qpc1 = get_chroma_qp( h, 0, qp1 ); int qpc1 = get_chroma_qp( h, 0, qp1 );
...@@ -425,12 +426,12 @@ void ff_h264_filter_mb_fast(H264Context *h, H264SliceContext *sl, ...@@ -425,12 +426,12 @@ void ff_h264_filter_mb_fast(H264Context *h, H264SliceContext *sl,
} }
#if CONFIG_SMALL #if CONFIG_SMALL
h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, h->pixel_shift); h264_filter_mb_fast_internal(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, h->pixel_shift);
#else #else
if(h->pixel_shift){ if(h->pixel_shift){
h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, 1); h264_filter_mb_fast_internal(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, 1);
}else{ }else{
h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, 0); h264_filter_mb_fast_internal(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, 0);
} }
#endif #endif
} }
...@@ -476,8 +477,8 @@ static av_always_inline void filter_mb_dir(H264Context *h, H264SliceContext *sl, ...@@ -476,8 +477,8 @@ static av_always_inline void filter_mb_dir(H264Context *h, H264SliceContext *sl,
int chroma_qp_avg[2]; int chroma_qp_avg[2];
int chroma444 = CHROMA444(h); int chroma444 = CHROMA444(h);
int chroma422 = CHROMA422(h); int chroma422 = CHROMA422(h);
const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy; const int mbm_xy = dir == 0 ? mb_xy -1 : sl->top_mb_xy;
const int mbm_type = dir == 0 ? h->left_type[LTOP] : h->top_type; const int mbm_type = dir == 0 ? sl->left_type[LTOP] : sl->top_type;
// how often to recheck mv-based bS when iterating between edges // how often to recheck mv-based bS when iterating between edges
static const uint8_t mask_edge_tab[2][8]={{0,3,3,3,1,1,1,1}, static const uint8_t mask_edge_tab[2][8]={{0,3,3,3,1,1,1,1},
...@@ -728,9 +729,9 @@ void ff_h264_filter_mb(H264Context *h, H264SliceContext *sl, ...@@ -728,9 +729,9 @@ void ff_h264_filter_mb(H264Context *h, H264SliceContext *sl,
if (FRAME_MBAFF(h) if (FRAME_MBAFF(h)
// and current and left pair do not have the same interlaced type // and current and left pair do not have the same interlaced type
&& IS_INTERLACED(mb_type^h->left_type[LTOP]) && IS_INTERLACED(mb_type ^ sl->left_type[LTOP])
// and left mb is in available to us // and left mb is in available to us
&& h->left_type[LTOP]) { && sl->left_type[LTOP]) {
/* First vertical edge is different in MBAFF frames /* First vertical edge is different in MBAFF frames
* There are 8 different bS to compute and 2 different Qp * There are 8 different bS to compute and 2 different Qp
*/ */
...@@ -758,8 +759,8 @@ void ff_h264_filter_mb(H264Context *h, H264SliceContext *sl, ...@@ -758,8 +759,8 @@ void ff_h264_filter_mb(H264Context *h, H264SliceContext *sl,
const uint8_t *off= offset[MB_FIELD(h)][mb_y&1]; const uint8_t *off= offset[MB_FIELD(h)][mb_y&1];
for( i = 0; i < 8; i++ ) { for( i = 0; i < 8; i++ ) {
int j= MB_FIELD(h) ? i>>2 : i&1; int j= MB_FIELD(h) ? i>>2 : i&1;
int mbn_xy = h->left_mb_xy[LEFT(j)]; int mbn_xy = sl->left_mb_xy[LEFT(j)];
int mbn_type= h->left_type[LEFT(j)]; int mbn_type = sl->left_type[LEFT(j)];
if( IS_INTRA( mbn_type ) ) if( IS_INTRA( mbn_type ) )
bS[i] = 4; bS[i] = 4;
...@@ -774,8 +775,8 @@ void ff_h264_filter_mb(H264Context *h, H264SliceContext *sl, ...@@ -774,8 +775,8 @@ void ff_h264_filter_mb(H264Context *h, H264SliceContext *sl,
} }
mb_qp = h->cur_pic.qscale_table[mb_xy]; mb_qp = h->cur_pic.qscale_table[mb_xy];
mbn0_qp = h->cur_pic.qscale_table[h->left_mb_xy[0]]; mbn0_qp = h->cur_pic.qscale_table[sl->left_mb_xy[0]];
mbn1_qp = h->cur_pic.qscale_table[h->left_mb_xy[1]]; mbn1_qp = h->cur_pic.qscale_table[sl->left_mb_xy[1]];
qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1; qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) + bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1; get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1;
......
...@@ -500,7 +500,8 @@ static av_always_inline void prefetch_motion(H264Context *h, int list, ...@@ -500,7 +500,8 @@ static av_always_inline void prefetch_motion(H264Context *h, int list,
} }
} }
static av_always_inline void xchg_mb_border(H264Context *h, uint8_t *src_y, static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl,
uint8_t *src_y,
uint8_t *src_cb, uint8_t *src_cr, uint8_t *src_cb, uint8_t *src_cr,
int linesize, int uvlinesize, int linesize, int uvlinesize,
int xchg, int chroma444, int xchg, int chroma444,
...@@ -523,7 +524,7 @@ static av_always_inline void xchg_mb_border(H264Context *h, uint8_t *src_y, ...@@ -523,7 +524,7 @@ static av_always_inline void xchg_mb_border(H264Context *h, uint8_t *src_y,
if (h->deblocking_filter == 2) { if (h->deblocking_filter == 2) {
deblock_topleft = h->slice_table[h->mb_xy - 1 - h->mb_stride] == h->slice_num; deblock_topleft = h->slice_table[h->mb_xy - 1 - h->mb_stride] == h->slice_num;
deblock_top = h->top_type; deblock_top = sl->top_type;
} else { } else {
deblock_topleft = (h->mb_x > 0); deblock_topleft = (h->mb_x > 0);
deblock_top = (h->mb_y > !!MB_FIELD(h)); deblock_top = (h->mb_y > !!MB_FIELD(h));
......
...@@ -156,7 +156,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) ...@@ -156,7 +156,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
} else { } else {
if (IS_INTRA(mb_type)) { if (IS_INTRA(mb_type)) {
if (h->deblocking_filter) if (h->deblocking_filter)
xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, xchg_mb_border(h, sl, dest_y, dest_cb, dest_cr, linesize,
uvlinesize, 1, 0, SIMPLE, PIXEL_SHIFT); uvlinesize, 1, 0, SIMPLE, PIXEL_SHIFT);
if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) {
...@@ -169,7 +169,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) ...@@ -169,7 +169,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
block_offset, linesize, dest_y, 0); block_offset, linesize, dest_y, 0);
if (h->deblocking_filter) if (h->deblocking_filter)
xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, xchg_mb_border(h, sl, dest_y, dest_cb, dest_cr, linesize,
uvlinesize, 0, 0, SIMPLE, PIXEL_SHIFT); uvlinesize, 0, 0, SIMPLE, PIXEL_SHIFT);
} else if (is_h264) { } else if (is_h264) {
if (chroma422) { if (chroma422) {
...@@ -340,7 +340,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext ...@@ -340,7 +340,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext
} else { } else {
if (IS_INTRA(mb_type)) { if (IS_INTRA(mb_type)) {
if (h->deblocking_filter) if (h->deblocking_filter)
xchg_mb_border(h, dest[0], dest[1], dest[2], linesize, xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize,
linesize, 1, 1, SIMPLE, PIXEL_SHIFT); linesize, 1, 1, SIMPLE, PIXEL_SHIFT);
for (p = 0; p < plane_count; p++) for (p = 0; p < plane_count; p++)
...@@ -349,7 +349,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext ...@@ -349,7 +349,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext
block_offset, linesize, dest[p], p); block_offset, linesize, dest[p], p);
if (h->deblocking_filter) if (h->deblocking_filter)
xchg_mb_border(h, dest[0], dest[1], dest[2], linesize, xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize,
linesize, 0, 1, SIMPLE, PIXEL_SHIFT); linesize, 0, 1, SIMPLE, PIXEL_SHIFT);
} else { } else {
FUNC(hl_motion_444)(h, sl, dest[0], dest[1], dest[2], FUNC(hl_motion_444)(h, sl, dest[0], dest[1], dest[2],
......
This diff is collapsed.
...@@ -2153,9 +2153,9 @@ static int fill_filter_caches(H264Context *h, H264SliceContext *sl, int mb_type) ...@@ -2153,9 +2153,9 @@ static int fill_filter_caches(H264Context *h, H264SliceContext *sl, int mb_type)
} }
} }
h->top_mb_xy = top_xy; sl->top_mb_xy = top_xy;
h->left_mb_xy[LTOP] = left_xy[LTOP]; sl->left_mb_xy[LTOP] = left_xy[LTOP];
h->left_mb_xy[LBOT] = left_xy[LBOT]; sl->left_mb_xy[LBOT] = left_xy[LBOT];
{ {
/* For sufficiently low qp, filtering wouldn't do anything. /* For sufficiently low qp, filtering wouldn't do anything.
* This is a conservative estimate: could also check beta_offset * This is a conservative estimate: could also check beta_offset
...@@ -2191,9 +2191,9 @@ static int fill_filter_caches(H264Context *h, H264SliceContext *sl, int mb_type) ...@@ -2191,9 +2191,9 @@ static int fill_filter_caches(H264Context *h, H264SliceContext *sl, int mb_type)
if (h->slice_table[left_xy[LBOT]] == 0xFFFF) if (h->slice_table[left_xy[LBOT]] == 0xFFFF)
left_type[LTOP] = left_type[LBOT] = 0; left_type[LTOP] = left_type[LBOT] = 0;
} }
h->top_type = top_type; sl->top_type = top_type;
h->left_type[LTOP] = left_type[LTOP]; sl->left_type[LTOP] = left_type[LTOP];
h->left_type[LBOT] = left_type[LBOT]; sl->left_type[LBOT] = left_type[LBOT];
if (IS_INTRA(mb_type)) if (IS_INTRA(mb_type))
return 0; return 0;
......
...@@ -376,6 +376,7 @@ static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode, ...@@ -376,6 +376,7 @@ static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode,
{ {
int i, j, k, mx, my, dx, dy, x, y; int i, j, k, mx, my, dx, dy, x, y;
H264Context *h = &s->h; H264Context *h = &s->h;
H264SliceContext *sl = &h->slice_ctx[0];
const int part_width = ((size & 5) == 4) ? 4 : 16 >> (size & 1); const int part_width = ((size & 5) == 4) ? 4 : 16 >> (size & 1);
const int part_height = 16 >> ((unsigned)(size + 1) / 3); const int part_height = 16 >> ((unsigned)(size + 1) / 3);
const int extra_width = (mode == PREDICT_MODE) ? -16 * 6 : 0; const int extra_width = (mode == PREDICT_MODE) ? -16 * 6 : 0;
...@@ -393,7 +394,7 @@ static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode, ...@@ -393,7 +394,7 @@ static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode,
(j >> 1 & 4) + (i & 8); (j >> 1 & 4) + (i & 8);
if (mode != PREDICT_MODE) { if (mode != PREDICT_MODE) {
pred_motion(h, k, part_width >> 2, dir, 1, &mx, &my); pred_motion(h, sl, k, part_width >> 2, dir, 1, &mx, &my);
} else { } else {
mx = s->next_pic->motion_val[0][b_xy][0] << 1; mx = s->next_pic->motion_val[0][b_xy][0] << 1;
my = s->next_pic->motion_val[0][b_xy][1] << 1; my = s->next_pic->motion_val[0][b_xy][1] << 1;
......
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