1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

h264: move mb_xy into the per-slice context

This commit is contained in:
Anton Khirnov 2015-01-17 22:28:46 +01:00
parent 07c5ca551b
commit 0edbe6faa7
12 changed files with 32 additions and 32 deletions

View File

@ -60,7 +60,7 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
h->mb_x = mb_x; h->mb_x = mb_x;
h->mb_y = mb_y; h->mb_y = mb_y;
h->mb_xy = mb_x + mb_y * h->mb_stride; sl->mb_xy = mb_x + mb_y * h->mb_stride;
memset(sl->non_zero_count_cache, 0, sizeof(sl->non_zero_count_cache)); memset(sl->non_zero_count_cache, 0, sizeof(sl->non_zero_count_cache));
assert(ref >= 0); assert(ref >= 0);
/* FIXME: It is possible albeit uncommon that slice references /* FIXME: It is possible albeit uncommon that slice references
@ -69,7 +69,7 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
* practice then correct remapping should be added. */ * practice then correct remapping should be added. */
if (ref >= sl->ref_count[0]) if (ref >= sl->ref_count[0])
ref = 0; ref = 0;
fill_rectangle(&h->cur_pic.ref_index[0][4 * h->mb_xy], fill_rectangle(&h->cur_pic.ref_index[0][4 * sl->mb_xy],
2, 2, 2, ref, 1); 2, 2, 2, ref, 1);
fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1); fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
fill_rectangle(sl->mv_cache[0][scan8[0]], 4, 4, 8, fill_rectangle(sl->mv_cache[0][scan8[0]], 4, 4, 8,

View File

@ -356,6 +356,7 @@ typedef struct H264SliceContext {
ptrdiff_t mb_linesize; ///< may be equal to s->linesize or s->linesize * 2, for mbaff ptrdiff_t mb_linesize; ///< may be equal to s->linesize or s->linesize * 2, for mbaff
ptrdiff_t mb_uvlinesize; ptrdiff_t mb_uvlinesize;
int mb_xy;
int mb_skip_run; int mb_skip_run;
int is_complex; int is_complex;
@ -531,7 +532,6 @@ typedef struct H264Context {
int mb_height, mb_width; int mb_height, mb_width;
int mb_stride; int mb_stride;
int mb_num; int mb_num;
int mb_xy;
// ============================================================= // =============================================================
// Things below are not used in the MB or more inner code // Things below are not used in the MB or more inner code
@ -946,7 +946,7 @@ static av_always_inline int pred_intra_mode(H264Context *h,
static av_always_inline void write_back_intra_pred_mode(H264Context *h, static av_always_inline void write_back_intra_pred_mode(H264Context *h,
H264SliceContext *sl) H264SliceContext *sl)
{ {
int8_t *i4x4 = sl->intra4x4_pred_mode + h->mb2br_xy[h->mb_xy]; int8_t *i4x4 = sl->intra4x4_pred_mode + h->mb2br_xy[sl->mb_xy];
int8_t *i4x4_cache = sl->intra4x4_pred_mode_cache; int8_t *i4x4_cache = sl->intra4x4_pred_mode_cache;
AV_COPY32(i4x4, i4x4_cache + 4 + 8 * 4); AV_COPY32(i4x4, i4x4_cache + 4 + 8 * 4);
@ -958,7 +958,7 @@ static av_always_inline void write_back_intra_pred_mode(H264Context *h,
static av_always_inline void write_back_non_zero_count(H264Context *h, static av_always_inline void write_back_non_zero_count(H264Context *h,
H264SliceContext *sl) H264SliceContext *sl)
{ {
const int mb_xy = h->mb_xy; const int mb_xy = sl->mb_xy;
uint8_t *nnz = h->non_zero_count[mb_xy]; uint8_t *nnz = h->non_zero_count[mb_xy];
uint8_t *nnz_cache = sl->non_zero_count_cache; uint8_t *nnz_cache = sl->non_zero_count_cache;
@ -992,8 +992,8 @@ static av_always_inline void write_back_motion_list(H264Context *h,
AV_COPY128(mv_dst + 2 * b_stride, mv_src + 8 * 2); AV_COPY128(mv_dst + 2 * b_stride, mv_src + 8 * 2);
AV_COPY128(mv_dst + 3 * b_stride, mv_src + 8 * 3); AV_COPY128(mv_dst + 3 * b_stride, mv_src + 8 * 3);
if (CABAC(h)) { if (CABAC(h)) {
uint8_t (*mvd_dst)[2] = &sl->mvd_table[list][FMO ? 8 * h->mb_xy uint8_t (*mvd_dst)[2] = &sl->mvd_table[list][FMO ? 8 * sl->mb_xy
: h->mb2br_xy[h->mb_xy]]; : h->mb2br_xy[sl->mb_xy]];
uint8_t(*mvd_src)[2] = &sl->mvd_cache[list][scan8[0]]; uint8_t(*mvd_src)[2] = &sl->mvd_cache[list][scan8[0]];
if (IS_SKIP(mb_type)) { if (IS_SKIP(mb_type)) {
AV_ZERO128(mvd_dst); AV_ZERO128(mvd_dst);
@ -1021,7 +1021,7 @@ static av_always_inline void write_back_motion(H264Context *h,
{ {
const int b_stride = h->b_stride; const int b_stride = h->b_stride;
const int b_xy = 4 * h->mb_x + 4 * h->mb_y * h->b_stride; // try mb2b(8)_xy const int b_xy = 4 * h->mb_x + 4 * h->mb_y * h->b_stride; // try mb2b(8)_xy
const int b8_xy = 4 * h->mb_xy; const int b8_xy = 4 * sl->mb_xy;
if (USES_LIST(mb_type, 0)) { if (USES_LIST(mb_type, 0)) {
write_back_motion_list(h, sl, b_stride, b_xy, b8_xy, mb_type, 0); write_back_motion_list(h, sl, b_stride, b_xy, b8_xy, mb_type, 0);
@ -1034,7 +1034,7 @@ static av_always_inline void write_back_motion(H264Context *h,
if (sl->slice_type_nos == AV_PICTURE_TYPE_B && CABAC(h)) { if (sl->slice_type_nos == AV_PICTURE_TYPE_B && CABAC(h)) {
if (IS_8X8(mb_type)) { if (IS_8X8(mb_type)) {
uint8_t *direct_table = &h->direct_table[4 * h->mb_xy]; uint8_t *direct_table = &h->direct_table[4 * sl->mb_xy];
direct_table[1] = sl->sub_mb_type[1] >> 1; direct_table[1] = sl->sub_mb_type[1] >> 1;
direct_table[2] = sl->sub_mb_type[2] >> 1; direct_table[2] = sl->sub_mb_type[2] >> 1;
direct_table[3] = sl->sub_mb_type[3] >> 1; direct_table[3] = sl->sub_mb_type[3] >> 1;

View File

@ -1284,7 +1284,7 @@ void ff_h264_init_cabac_states(H264Context *h, H264SliceContext *sl)
static int decode_cabac_field_decoding_flag(H264Context *h, H264SliceContext *sl) static int decode_cabac_field_decoding_flag(H264Context *h, H264SliceContext *sl)
{ {
const long mbb_xy = h->mb_xy - 2L*h->mb_stride; const long mbb_xy = sl->mb_xy - 2L*h->mb_stride;
unsigned long ctx = 0; unsigned long ctx = 0;
@ -1348,7 +1348,7 @@ static int decode_cabac_mb_skip(H264Context *h, H264SliceContext *sl,
}else }else
mbb_xy = mb_x + (mb_y-1)*h->mb_stride; mbb_xy = mb_x + (mb_y-1)*h->mb_stride;
}else{ }else{
int mb_xy = h->mb_xy; int mb_xy = sl->mb_xy;
mba_xy = mb_xy - 1; mba_xy = mb_xy - 1;
mbb_xy = mb_xy - (h->mb_stride << FIELD_PICTURE(h)); mbb_xy = mb_xy - (h->mb_stride << FIELD_PICTURE(h));
} }
@ -1693,9 +1693,9 @@ decode_cabac_residual_internal(H264Context *h, H264SliceContext *sl,
if( is_dc ) { if( is_dc ) {
if( cat == 3 ) if( cat == 3 )
h->cbp_table[h->mb_xy] |= 0x40 << (n - CHROMA_DC_BLOCK_INDEX); h->cbp_table[sl->mb_xy] |= 0x40 << (n - CHROMA_DC_BLOCK_INDEX);
else else
h->cbp_table[h->mb_xy] |= 0x100 << (n - LUMA_DC_BLOCK_INDEX); h->cbp_table[sl->mb_xy] |= 0x100 << (n - LUMA_DC_BLOCK_INDEX);
sl->non_zero_count_cache[scan8[n]] = coeff_count; sl->non_zero_count_cache[scan8[n]] = coeff_count;
} else { } else {
if( max_coeff == 64 ) if( max_coeff == 64 )
@ -1914,7 +1914,7 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl)
int decode_chroma = h->sps.chroma_format_idc == 1 || h->sps.chroma_format_idc == 2; int decode_chroma = h->sps.chroma_format_idc == 1 || h->sps.chroma_format_idc == 2;
const int pixel_shift = h->pixel_shift; const int pixel_shift = h->pixel_shift;
mb_xy = h->mb_xy = h->mb_x + h->mb_y*h->mb_stride; mb_xy = sl->mb_xy = h->mb_x + h->mb_y*h->mb_stride;
tprintf(h->avctx, "pic:%d mb:%d/%d\n", h->frame_num, h->mb_x, h->mb_y); tprintf(h->avctx, "pic:%d mb:%d/%d\n", h->frame_num, h->mb_x, h->mb_y);
if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {

View File

@ -703,7 +703,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl)
int decode_chroma = h->sps.chroma_format_idc == 1 || h->sps.chroma_format_idc == 2; int decode_chroma = h->sps.chroma_format_idc == 1 || h->sps.chroma_format_idc == 2;
const int pixel_shift = h->pixel_shift; const int pixel_shift = h->pixel_shift;
mb_xy = h->mb_xy = h->mb_x + h->mb_y*h->mb_stride; mb_xy = sl->mb_xy = h->mb_x + h->mb_y*h->mb_stride;
tprintf(h->avctx, "pic:%d mb:%d/%d\n", h->frame_num, h->mb_x, h->mb_y); tprintf(h->avctx, "pic:%d mb:%d/%d\n", h->frame_num, h->mb_x, h->mb_y);
cbp = 0; /* avoid warning. FIXME: find a solution without slowing cbp = 0; /* avoid warning. FIXME: find a solution without slowing

View File

@ -179,7 +179,7 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s
{ {
int b8_stride = 2; int b8_stride = 2;
int b4_stride = h->b_stride; int b4_stride = h->b_stride;
int mb_xy = h->mb_xy, mb_y = h->mb_y; int mb_xy = sl->mb_xy, mb_y = h->mb_y;
int mb_type_col[2]; int mb_type_col[2];
const int16_t (*l1mv0)[2], (*l1mv1)[2]; const int16_t (*l1mv0)[2], (*l1mv1)[2];
const int8_t *l1ref0, *l1ref1; const int8_t *l1ref0, *l1ref1;
@ -465,7 +465,7 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl,
{ {
int b8_stride = 2; int b8_stride = 2;
int b4_stride = h->b_stride; int b4_stride = h->b_stride;
int mb_xy = h->mb_xy, mb_y = h->mb_y; int mb_xy = sl->mb_xy, mb_y = h->mb_y;
int mb_type_col[2]; int mb_type_col[2];
const int16_t (*l1mv0)[2], (*l1mv1)[2]; const int16_t (*l1mv0)[2], (*l1mv1)[2];
const int8_t *l1ref0, *l1ref1; const int8_t *l1ref0, *l1ref1;

View File

@ -248,7 +248,7 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
int chroma444 = CHROMA444(h); int chroma444 = CHROMA444(h);
int chroma422 = CHROMA422(h); int chroma422 = CHROMA422(h);
int mb_xy = h->mb_xy; int mb_xy = sl->mb_xy;
int left_type = sl->left_type[LTOP]; int left_type = sl->left_type[LTOP];
int top_type = sl->top_type; int top_type = sl->top_type;

View File

@ -96,7 +96,7 @@ static inline void get_lowest_part_y(H264Context *h, H264SliceContext *sl,
*/ */
static void await_references(H264Context *h, H264SliceContext *sl) static void await_references(H264Context *h, H264SliceContext *sl)
{ {
const int mb_xy = h->mb_xy; const int mb_xy = sl->mb_xy;
const int mb_type = h->cur_pic.mb_type[mb_xy]; const int mb_type = h->cur_pic.mb_type[mb_xy];
int refs[2][48]; int refs[2][48];
int nrefs[2] = { 0 }; int nrefs[2] = { 0 };
@ -524,7 +524,7 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl
} }
if (sl->deblocking_filter == 2) { if (sl->deblocking_filter == 2) {
deblock_topleft = h->slice_table[h->mb_xy - 1 - h->mb_stride] == sl->slice_num; deblock_topleft = h->slice_table[sl->mb_xy - 1 - h->mb_stride] == sl->slice_num;
deblock_top = sl->top_type; deblock_top = sl->top_type;
} else { } else {
deblock_topleft = (h->mb_x > 0); deblock_topleft = (h->mb_x > 0);
@ -812,7 +812,7 @@ static av_always_inline void hl_decode_mb_idct_luma(H264Context *h, H264SliceCon
void ff_h264_hl_decode_mb(H264Context *h, H264SliceContext *sl) void ff_h264_hl_decode_mb(H264Context *h, H264SliceContext *sl)
{ {
const int mb_xy = h->mb_xy; const int mb_xy = sl->mb_xy;
const int mb_type = h->cur_pic.mb_type[mb_xy]; const int mb_type = h->cur_pic.mb_type[mb_xy];
int is_complex = CONFIG_SMALL || sl->is_complex || int is_complex = CONFIG_SMALL || sl->is_complex ||
IS_INTRA_PCM(mb_type) || sl->qscale == 0; IS_INTRA_PCM(mb_type) || sl->qscale == 0;

View File

@ -44,7 +44,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
{ {
const int mb_x = h->mb_x; const int mb_x = h->mb_x;
const int mb_y = h->mb_y; const int mb_y = h->mb_y;
const int mb_xy = h->mb_xy; const int mb_xy = sl->mb_xy;
const int mb_type = h->cur_pic.mb_type[mb_xy]; const int mb_type = h->cur_pic.mb_type[mb_xy];
uint8_t *dest_y, *dest_cb, *dest_cr; uint8_t *dest_y, *dest_cb, *dest_cr;
int linesize, uvlinesize /*dct_offset*/; int linesize, uvlinesize /*dct_offset*/;
@ -276,7 +276,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext
{ {
const int mb_x = h->mb_x; const int mb_x = h->mb_x;
const int mb_y = h->mb_y; const int mb_y = h->mb_y;
const int mb_xy = h->mb_xy; const int mb_xy = sl->mb_xy;
const int mb_type = h->cur_pic.mb_type[mb_xy]; const int mb_type = h->cur_pic.mb_type[mb_xy];
uint8_t *dest[3]; uint8_t *dest[3];
int linesize; int linesize;

View File

@ -71,7 +71,7 @@ static void MCFUNC(hl_motion)(H264Context *h, H264SliceContext *sl,
h264_weight_func *weight_op, h264_weight_func *weight_op,
h264_biweight_func *weight_avg) h264_biweight_func *weight_avg)
{ {
const int mb_xy = h->mb_xy; const int mb_xy = sl->mb_xy;
const int mb_type = h->cur_pic.mb_type[mb_xy]; const int mb_type = h->cur_pic.mb_type[mb_xy];
assert(IS_INTER(mb_type)); assert(IS_INTER(mb_type));

View File

@ -355,7 +355,7 @@ zeromv:
static void fill_decode_neighbors(H264Context *h, H264SliceContext *sl, int mb_type) static void fill_decode_neighbors(H264Context *h, H264SliceContext *sl, int mb_type)
{ {
const int mb_xy = h->mb_xy; const int mb_xy = sl->mb_xy;
int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS];
static const uint8_t left_block_options[4][32] = { static const uint8_t left_block_options[4][32] = {
{ 0, 1, 2, 3, 7, 10, 8, 11, 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 5 * 4, 1 + 9 * 4 }, { 0, 1, 2, 3, 7, 10, 8, 11, 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 5 * 4, 1 + 9 * 4 },
@ -802,7 +802,7 @@ static void fill_decode_caches(H264Context *h, H264SliceContext *sl, int mb_type
*/ */
static void av_unused decode_mb_skip(H264Context *h, H264SliceContext *sl) static void av_unused decode_mb_skip(H264Context *h, H264SliceContext *sl)
{ {
const int mb_xy = h->mb_xy; const int mb_xy = sl->mb_xy;
int mb_type = 0; int mb_type = 0;
memset(h->non_zero_count[mb_xy], 0, 48); memset(h->non_zero_count[mb_xy], 0, 48);

View File

@ -1909,7 +1909,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h,
*/ */
static int fill_filter_caches(H264Context *h, H264SliceContext *sl, int mb_type) static int fill_filter_caches(H264Context *h, H264SliceContext *sl, int mb_type)
{ {
const int mb_xy = h->mb_xy; const int mb_xy = sl->mb_xy;
int top_xy, left_xy[LEFT_MBS]; int top_xy, left_xy[LEFT_MBS];
int top_type, left_type[LEFT_MBS]; int top_type, left_type[LEFT_MBS];
uint8_t *nnz; uint8_t *nnz;
@ -2065,7 +2065,7 @@ static void loop_filter(H264Context *h, H264SliceContext *sl, int start_x, int e
for (mb_x = start_x; mb_x < end_x; mb_x++) for (mb_x = start_x; mb_x < end_x; mb_x++)
for (mb_y = end_mb_y - FRAME_MBAFF(h); 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; int mb_xy, mb_type;
mb_xy = h->mb_xy = mb_x + mb_y * h->mb_stride; mb_xy = sl->mb_xy = mb_x + mb_y * h->mb_stride;
sl->slice_num = h->slice_table[mb_xy]; sl->slice_num = h->slice_table[mb_xy];
mb_type = h->cur_pic.mb_type[mb_xy]; mb_type = h->cur_pic.mb_type[mb_xy];
sl->list_count = h->list_counts[mb_xy]; sl->list_count = h->list_counts[mb_xy];

View File

@ -487,7 +487,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
int cbp = 0; int cbp = 0;
uint32_t vlc; uint32_t vlc;
int8_t *top, *left; int8_t *top, *left;
const int mb_xy = h->mb_xy; const int mb_xy = sl->mb_xy;
const int b_xy = 4 * h->mb_x + 4 * h->mb_y * h->b_stride; const int b_xy = 4 * h->mb_x + 4 * h->mb_y * h->b_stride;
sl->top_samples_available = (h->mb_y == 0) ? 0x33FF : 0xFFFF; sl->top_samples_available = (h->mb_y == 0) ? 0x33FF : 0xFFFF;
@ -775,7 +775,7 @@ static int svq3_decode_slice_header(AVCodecContext *avctx)
SVQ3Context *s = avctx->priv_data; SVQ3Context *s = avctx->priv_data;
H264Context *h = &s->h; H264Context *h = &s->h;
H264SliceContext *sl = &h->slice_ctx[0]; H264SliceContext *sl = &h->slice_ctx[0];
const int mb_xy = h->mb_xy; const int mb_xy = sl->mb_xy;
int i, header; int i, header;
unsigned slice_id; unsigned slice_id;
@ -1132,7 +1132,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
init_get_bits(&h->gb, buf, 8 * buf_size); init_get_bits(&h->gb, buf, 8 * buf_size);
h->mb_x = h->mb_y = h->mb_xy = 0; h->mb_x = h->mb_y = sl->mb_xy = 0;
if (svq3_decode_slice_header(avctx)) if (svq3_decode_slice_header(avctx))
return -1; return -1;
@ -1248,7 +1248,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
for (h->mb_y = 0; h->mb_y < h->mb_height; h->mb_y++) { for (h->mb_y = 0; h->mb_y < h->mb_height; h->mb_y++) {
for (h->mb_x = 0; h->mb_x < h->mb_width; h->mb_x++) { for (h->mb_x = 0; h->mb_x < h->mb_width; h->mb_x++) {
unsigned mb_type; unsigned mb_type;
h->mb_xy = h->mb_x + h->mb_y * h->mb_stride; sl->mb_xy = h->mb_x + h->mb_y * h->mb_stride;
if ((get_bits_count(&h->gb) + 7) >= h->gb.size_in_bits && if ((get_bits_count(&h->gb) + 7) >= h->gb.size_in_bits &&
((get_bits_count(&h->gb) & 7) == 0 || ((get_bits_count(&h->gb) & 7) == 0 ||