Commit d76559fb authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'd4d9068c'

* commit 'd4d9068c':
  h264: move mb_{x,y} into the per-slice context

Conflicts:
	libavcodec/h264.c
	libavcodec/h264_cavlc.c
	libavcodec/h264_mb.c
	libavcodec/h264_slice.c
	libavcodec/svq3.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 668c65e7 d4d9068c
...@@ -220,7 +220,7 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice, ...@@ -220,7 +220,7 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
slice->SliceBytesInBuffer = size; slice->SliceBytesInBuffer = size;
slice->wBadSliceChopping = 0; slice->wBadSliceChopping = 0;
slice->first_mb_in_slice = (h->mb_y >> FIELD_OR_MBAFF_PICTURE(h)) * h->mb_width + h->mb_x; slice->first_mb_in_slice = (sl->mb_y >> FIELD_OR_MBAFF_PICTURE(h)) * h->mb_width + sl->mb_x;
slice->NumMbsForSlice = 0; /* XXX it is set once we have all slices */ slice->NumMbsForSlice = 0; /* XXX it is set once we have all slices */
slice->BitOffsetToSliceData = get_bits_count(&h->gb); slice->BitOffsetToSliceData = get_bits_count(&h->gb);
slice->slice_type = ff_h264_get_slice_type(sl); slice->slice_type = ff_h264_get_slice_type(sl);
......
...@@ -66,8 +66,8 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, ...@@ -66,8 +66,8 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
H264Context *h = opaque; H264Context *h = opaque;
H264SliceContext *sl = &h->slice_ctx[0]; H264SliceContext *sl = &h->slice_ctx[0];
h->mb_x = mb_x; sl->mb_x = mb_x;
h->mb_y = mb_y; sl->mb_y = mb_y;
sl->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));
av_assert1(ref >= 0); av_assert1(ref >= 0);
...@@ -160,7 +160,7 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h, H264SliceContext *sl) ...@@ -160,7 +160,7 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h, H264SliceContext *sl)
if (status < 0) { if (status < 0) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"top block unavailable for requested intra4x4 mode %d at %d %d\n", "top block unavailable for requested intra4x4 mode %d at %d %d\n",
status, h->mb_x, h->mb_y); status, sl->mb_x, sl->mb_y);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} else if (status) { } else if (status) {
sl->intra4x4_pred_mode_cache[scan8[0] + i] = status; sl->intra4x4_pred_mode_cache[scan8[0] + i] = status;
...@@ -176,7 +176,7 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h, H264SliceContext *sl) ...@@ -176,7 +176,7 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h, H264SliceContext *sl)
if (status < 0) { if (status < 0) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"left block unavailable for requested intra4x4 mode %d at %d %d\n", "left block unavailable for requested intra4x4 mode %d at %d %d\n",
status, h->mb_x, h->mb_y); status, sl->mb_x, sl->mb_y);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} else if (status) { } else if (status) {
sl->intra4x4_pred_mode_cache[scan8[0] + 8 * i] = status; sl->intra4x4_pred_mode_cache[scan8[0] + 8 * i] = status;
...@@ -200,7 +200,7 @@ int ff_h264_check_intra_pred_mode(H264Context *h, H264SliceContext *sl, ...@@ -200,7 +200,7 @@ int ff_h264_check_intra_pred_mode(H264Context *h, H264SliceContext *sl,
if (mode > 3U) { if (mode > 3U) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"out of range intra chroma pred mode at %d %d\n", "out of range intra chroma pred mode at %d %d\n",
h->mb_x, h->mb_y); sl->mb_x, sl->mb_y);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
...@@ -209,7 +209,7 @@ int ff_h264_check_intra_pred_mode(H264Context *h, H264SliceContext *sl, ...@@ -209,7 +209,7 @@ int ff_h264_check_intra_pred_mode(H264Context *h, H264SliceContext *sl,
if (mode < 0) { if (mode < 0) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"top block unavailable for requested intra mode at %d %d\n", "top block unavailable for requested intra mode at %d %d\n",
h->mb_x, h->mb_y); sl->mb_x, sl->mb_y);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
} }
...@@ -219,7 +219,7 @@ int ff_h264_check_intra_pred_mode(H264Context *h, H264SliceContext *sl, ...@@ -219,7 +219,7 @@ int ff_h264_check_intra_pred_mode(H264Context *h, H264SliceContext *sl,
if (mode < 0) { if (mode < 0) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"left block unavailable for requested intra mode at %d %d\n", "left block unavailable for requested intra mode at %d %d\n",
h->mb_x, h->mb_y); sl->mb_x, sl->mb_y);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (is_chroma && (sl->left_samples_available & 0x8080)) { if (is_chroma && (sl->left_samples_available & 0x8080)) {
...@@ -1143,7 +1143,7 @@ static void flush_dpb(AVCodecContext *avctx) ...@@ -1143,7 +1143,7 @@ static void flush_dpb(AVCodecContext *avctx)
h->cur_pic_ptr = NULL; h->cur_pic_ptr = NULL;
ff_h264_unref_picture(h, &h->cur_pic); ff_h264_unref_picture(h, &h->cur_pic);
h->mb_x = h->mb_y = 0; h->mb_y = 0;
ff_h264_free_tables(h, 1); ff_h264_free_tables(h, 1);
h->context_initialized = 0; h->context_initialized = 0;
......
...@@ -393,6 +393,7 @@ typedef struct H264SliceContext { ...@@ -393,6 +393,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_x, mb_y;
int mb_xy; int mb_xy;
int mb_skip_run; int mb_skip_run;
int is_complex; int is_complex;
...@@ -569,7 +570,7 @@ typedef struct H264Context { ...@@ -569,7 +570,7 @@ typedef struct H264Context {
int x264_build; int x264_build;
int mb_x, mb_y; int mb_y;
int resync_mb_x; int resync_mb_x;
int resync_mb_y; int resync_mb_y;
int mb_height, mb_width; int mb_height, mb_width;
...@@ -1094,7 +1095,7 @@ static av_always_inline void write_back_motion(H264Context *h, ...@@ -1094,7 +1095,7 @@ static av_always_inline void write_back_motion(H264Context *h,
int mb_type) int mb_type)
{ {
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 * sl->mb_x + 4 * sl->mb_y * h->b_stride; // try mb2b(8)_xy
const int b8_xy = 4 * sl->mb_xy; const int b8_xy = 4 * sl->mb_xy;
if (USES_LIST(mb_type, 0)) { if (USES_LIST(mb_type, 0)) {
......
...@@ -1288,7 +1288,7 @@ static int decode_cabac_field_decoding_flag(H264Context *h, H264SliceContext *sl ...@@ -1288,7 +1288,7 @@ static int decode_cabac_field_decoding_flag(H264Context *h, H264SliceContext *sl
unsigned long ctx = 0; unsigned long ctx = 0;
ctx += h->mb_field_decoding_flag & !!h->mb_x; //for FMO:(s->current_picture.mb_type[mba_xy] >> 7) & (h->slice_table[mba_xy] == h->slice_num); ctx += h->mb_field_decoding_flag & !!sl->mb_x; //for FMO:(s->current_picture.mb_type[mba_xy] >> 7) & (h->slice_table[mba_xy] == h->slice_num);
ctx += (h->cur_pic.mb_type[mbb_xy] >> 7) & (h->slice_table[mbb_xy] == sl->slice_num); ctx += (h->cur_pic.mb_type[mbb_xy] >> 7) & (h->slice_table[mbb_xy] == sl->slice_num);
return get_cabac_noinline( &sl->cabac, &(sl->cabac_state+70)[ctx] ); return get_cabac_noinline( &sl->cabac, &(sl->cabac_state+70)[ctx] );
...@@ -1917,21 +1917,21 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl) ...@@ -1917,21 +1917,21 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl)
const int pixel_shift = h->pixel_shift; const int pixel_shift = h->pixel_shift;
unsigned local_ref_count[2]; unsigned local_ref_count[2];
mb_xy = sl->mb_xy = h->mb_x + h->mb_y*h->mb_stride; mb_xy = sl->mb_xy = sl->mb_x + sl->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, sl->mb_x, sl->mb_y);
if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
int skip; int skip;
/* a skipped mb needs the aff flag from the following mb */ /* a skipped mb needs the aff flag from the following mb */
if (FRAME_MBAFF(h) && (h->mb_y & 1) == 1 && sl->prev_mb_skipped) if (FRAME_MBAFF(h) && (sl->mb_y & 1) == 1 && sl->prev_mb_skipped)
skip = sl->next_mb_skipped; skip = sl->next_mb_skipped;
else else
skip = decode_cabac_mb_skip(h, sl, h->mb_x, h->mb_y ); skip = decode_cabac_mb_skip(h, sl, sl->mb_x, sl->mb_y );
/* read skip flags */ /* read skip flags */
if( skip ) { if( skip ) {
if (FRAME_MBAFF(h) && (h->mb_y & 1) == 0) { if (FRAME_MBAFF(h) && (sl->mb_y & 1) == 0) {
h->cur_pic.mb_type[mb_xy] = MB_TYPE_SKIP; h->cur_pic.mb_type[mb_xy] = MB_TYPE_SKIP;
sl->next_mb_skipped = decode_cabac_mb_skip(h, sl, h->mb_x, h->mb_y+1 ); sl->next_mb_skipped = decode_cabac_mb_skip(h, sl, sl->mb_x, sl->mb_y+1 );
if(!sl->next_mb_skipped) if(!sl->next_mb_skipped)
h->mb_mbaff = h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h, sl); h->mb_mbaff = h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h, sl);
} }
...@@ -1947,7 +1947,7 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl) ...@@ -1947,7 +1947,7 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl)
} }
} }
if (FRAME_MBAFF(h)) { if (FRAME_MBAFF(h)) {
if( (h->mb_y&1) == 0 ) if ((sl->mb_y & 1) == 0)
h->mb_mbaff = h->mb_mbaff =
h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h, sl); h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h, sl);
} }
...@@ -2377,7 +2377,7 @@ decode_intra_mb: ...@@ -2377,7 +2377,7 @@ decode_intra_mb:
ctx= 3; ctx= 3;
val++; val++;
if(val > 2*max_qp){ //prevent infinite loop if(val > 2*max_qp){ //prevent infinite loop
av_log(h->avctx, AV_LOG_ERROR, "cabac decode of qscale diff failed at %d %d\n", h->mb_x, h->mb_y); av_log(h->avctx, AV_LOG_ERROR, "cabac decode of qscale diff failed at %d %d\n", sl->mb_x, sl->mb_y);
return -1; return -1;
} }
} }
......
...@@ -478,7 +478,7 @@ static int decode_residual(H264Context *h, H264SliceContext *sl, ...@@ -478,7 +478,7 @@ static int decode_residual(H264Context *h, H264SliceContext *sl,
if(total_coeff==0) if(total_coeff==0)
return 0; return 0;
if(total_coeff > (unsigned)max_coeff) { if(total_coeff > (unsigned)max_coeff) {
av_log(h->avctx, AV_LOG_ERROR, "corrupted macroblock %d %d (total_coeff=%d)\n", h->mb_x, h->mb_y, total_coeff); av_log(h->avctx, AV_LOG_ERROR, "corrupted macroblock %d %d (total_coeff=%d)\n", sl->mb_x, sl->mb_y, total_coeff);
return -1; return -1;
} }
...@@ -628,7 +628,7 @@ static int decode_residual(H264Context *h, H264SliceContext *sl, ...@@ -628,7 +628,7 @@ static int decode_residual(H264Context *h, H264SliceContext *sl,
} }
if(zeros_left<0){ if(zeros_left<0){
av_log(h->avctx, AV_LOG_ERROR, "negative number of zero coeffs at %d %d\n", h->mb_x, h->mb_y); av_log(h->avctx, AV_LOG_ERROR, "negative number of zero coeffs at %d %d\n", sl->mb_x, sl->mb_y);
return -1; return -1;
} }
...@@ -711,9 +711,9 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl) ...@@ -711,9 +711,9 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl)
const int pixel_shift = h->pixel_shift; const int pixel_shift = h->pixel_shift;
unsigned local_ref_count[2]; unsigned local_ref_count[2];
mb_xy = sl->mb_xy = h->mb_x + h->mb_y*h->mb_stride; mb_xy = sl->mb_xy = sl->mb_x + sl->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, sl->mb_x, sl->mb_y);
cbp = 0; /* avoid warning. FIXME: find a solution without slowing cbp = 0; /* avoid warning. FIXME: find a solution without slowing
down the code */ down the code */
if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
...@@ -721,7 +721,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl) ...@@ -721,7 +721,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl)
sl->mb_skip_run = get_ue_golomb_long(&h->gb); sl->mb_skip_run = get_ue_golomb_long(&h->gb);
if (sl->mb_skip_run--) { if (sl->mb_skip_run--) {
if(FRAME_MBAFF(h) && (h->mb_y&1) == 0){ if (FRAME_MBAFF(h) && (sl->mb_y & 1) == 0) {
if (sl->mb_skip_run == 0) if (sl->mb_skip_run == 0)
h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&h->gb); h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&h->gb);
} }
...@@ -730,7 +730,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl) ...@@ -730,7 +730,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl)
} }
} }
if (FRAME_MBAFF(h)) { if (FRAME_MBAFF(h)) {
if( (h->mb_y&1) == 0 ) if ((sl->mb_y & 1) == 0)
h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&h->gb); h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&h->gb);
} }
...@@ -759,7 +759,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl) ...@@ -759,7 +759,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl)
mb_type--; mb_type--;
decode_intra_mb: decode_intra_mb:
if(mb_type > 25){ if(mb_type > 25){
av_log(h->avctx, AV_LOG_ERROR, "mb_type %d in %c slice too large at %d %d\n", mb_type, av_get_picture_type_char(sl->slice_type), h->mb_x, h->mb_y); av_log(h->avctx, AV_LOG_ERROR, "mb_type %d in %c slice too large at %d %d\n", mb_type, av_get_picture_type_char(sl->slice_type), sl->mb_x, sl->mb_y);
return -1; return -1;
} }
partition_count=0; partition_count=0;
...@@ -849,7 +849,7 @@ decode_intra_mb: ...@@ -849,7 +849,7 @@ decode_intra_mb:
for(i=0; i<4; i++){ for(i=0; i<4; i++){
sl->sub_mb_type[i]= get_ue_golomb_31(&h->gb); sl->sub_mb_type[i]= get_ue_golomb_31(&h->gb);
if(sl->sub_mb_type[i] >=13){ if(sl->sub_mb_type[i] >=13){
av_log(h->avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], h->mb_x, h->mb_y); av_log(h->avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], sl->mb_x, sl->mb_y);
return -1; return -1;
} }
sub_partition_count[i]= b_sub_mb_type_info[ sl->sub_mb_type[i] ].partition_count; sub_partition_count[i]= b_sub_mb_type_info[ sl->sub_mb_type[i] ].partition_count;
...@@ -867,7 +867,7 @@ decode_intra_mb: ...@@ -867,7 +867,7 @@ decode_intra_mb:
for(i=0; i<4; i++){ for(i=0; i<4; i++){
sl->sub_mb_type[i]= get_ue_golomb_31(&h->gb); sl->sub_mb_type[i]= get_ue_golomb_31(&h->gb);
if(sl->sub_mb_type[i] >=4){ if(sl->sub_mb_type[i] >=4){
av_log(h->avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], h->mb_x, h->mb_y); av_log(h->avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], sl->mb_x, sl->mb_y);
return -1; return -1;
} }
sub_partition_count[i]= p_sub_mb_type_info[ sl->sub_mb_type[i] ].partition_count; sub_partition_count[i]= p_sub_mb_type_info[ sl->sub_mb_type[i] ].partition_count;
...@@ -1065,14 +1065,14 @@ decode_intra_mb: ...@@ -1065,14 +1065,14 @@ decode_intra_mb:
if(decode_chroma){ if(decode_chroma){
if(cbp > 47){ if(cbp > 47){
av_log(h->avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, h->mb_x, h->mb_y); av_log(h->avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, sl->mb_x, sl->mb_y);
return -1; return -1;
} }
if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp[cbp]; if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp[cbp];
else cbp= golomb_to_inter_cbp [cbp]; else cbp= golomb_to_inter_cbp [cbp];
}else{ }else{
if(cbp > 15){ if(cbp > 15){
av_log(h->avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, h->mb_x, h->mb_y); av_log(h->avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, sl->mb_x, sl->mb_y);
return -1; return -1;
} }
if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp_gray[cbp]; if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp_gray[cbp];
...@@ -1116,7 +1116,7 @@ decode_intra_mb: ...@@ -1116,7 +1116,7 @@ decode_intra_mb:
if (sl->qscale < 0) sl->qscale += max_qp + 1; if (sl->qscale < 0) sl->qscale += max_qp + 1;
else sl->qscale -= max_qp+1; else sl->qscale -= max_qp+1;
if (((unsigned)sl->qscale) > max_qp){ if (((unsigned)sl->qscale) > max_qp){
av_log(h->avctx, AV_LOG_ERROR, "dquant out of range (%d) at %d %d\n", dquant, h->mb_x, h->mb_y); av_log(h->avctx, AV_LOG_ERROR, "dquant out of range (%d) at %d %d\n", dquant, sl->mb_x, sl->mb_y);
return -1; return -1;
} }
} }
......
...@@ -179,7 +179,7 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s ...@@ -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 = sl->mb_xy, mb_y = h->mb_y; int mb_xy = sl->mb_xy, mb_y = sl->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;
...@@ -193,7 +193,7 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s ...@@ -193,7 +193,7 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s
assert(sl->ref_list[1][0].reference & 3); assert(sl->ref_list[1][0].reference & 3);
await_reference_mb_row(h, &sl->ref_list[1][0], await_reference_mb_row(h, &sl->ref_list[1][0],
h->mb_y + !!IS_INTERLACED(*mb_type)); sl->mb_y + !!IS_INTERLACED(*mb_type));
#define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \ #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \
MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM) MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM)
...@@ -263,9 +263,9 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s ...@@ -263,9 +263,9 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s
if (IS_INTERLACED(sl->ref_list[1][0].mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL if (IS_INTERLACED(sl->ref_list[1][0].mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL
mb_y = (h->mb_y & ~1) + sl->col_parity; mb_y = (sl->mb_y & ~1) + sl->col_parity;
mb_xy = h->mb_x + mb_xy = sl->mb_x +
((h->mb_y & ~1) + sl->col_parity) * h->mb_stride; ((sl->mb_y & ~1) + sl->col_parity) * h->mb_stride;
b8_stride = 0; b8_stride = 0;
} else { } else {
mb_y += sl->col_fieldoff; mb_y += sl->col_fieldoff;
...@@ -274,8 +274,8 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s ...@@ -274,8 +274,8 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s
goto single_col; goto single_col;
} else { // AFL/AFR/FR/FL -> AFR/FR } else { // AFL/AFR/FR/FL -> AFR/FR
if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR
mb_y = h->mb_y & ~1; mb_y = sl->mb_y & ~1;
mb_xy = (h->mb_y & ~1) * h->mb_stride + h->mb_x; mb_xy = (sl->mb_y & ~1) * h->mb_stride + sl->mb_x;
mb_type_col[0] = sl->ref_list[1][0].mb_type[mb_xy]; mb_type_col[0] = sl->ref_list[1][0].mb_type[mb_xy];
mb_type_col[1] = sl->ref_list[1][0].mb_type[mb_xy + h->mb_stride]; mb_type_col[1] = sl->ref_list[1][0].mb_type[mb_xy + h->mb_stride];
b8_stride = 2 + 4 * h->mb_stride; b8_stride = 2 + 4 * h->mb_stride;
...@@ -324,7 +324,7 @@ single_col: ...@@ -324,7 +324,7 @@ single_col:
l1ref0 = &sl->ref_list[1][0].ref_index[0][4 * mb_xy]; l1ref0 = &sl->ref_list[1][0].ref_index[0][4 * mb_xy];
l1ref1 = &sl->ref_list[1][0].ref_index[1][4 * mb_xy]; l1ref1 = &sl->ref_list[1][0].ref_index[1][4 * mb_xy];
if (!b8_stride) { if (!b8_stride) {
if (h->mb_y & 1) { if (sl->mb_y & 1) {
l1ref0 += 2; l1ref0 += 2;
l1ref1 += 2; l1ref1 += 2;
l1mv0 += 2 * b4_stride; l1mv0 += 2 * b4_stride;
...@@ -466,7 +466,7 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl, ...@@ -466,7 +466,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 = sl->mb_xy, mb_y = h->mb_y; int mb_xy = sl->mb_xy, mb_y = sl->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;
...@@ -477,13 +477,13 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl, ...@@ -477,13 +477,13 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl,
assert(sl->ref_list[1][0].reference & 3); assert(sl->ref_list[1][0].reference & 3);
await_reference_mb_row(h, &sl->ref_list[1][0], await_reference_mb_row(h, &sl->ref_list[1][0],
h->mb_y + !!IS_INTERLACED(*mb_type)); sl->mb_y + !!IS_INTERLACED(*mb_type));
if (IS_INTERLACED(sl->ref_list[1][0].mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL if (IS_INTERLACED(sl->ref_list[1][0].mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL
mb_y = (h->mb_y & ~1) + sl->col_parity; mb_y = (sl->mb_y & ~1) + sl->col_parity;
mb_xy = h->mb_x + mb_xy = sl->mb_x +
((h->mb_y & ~1) + sl->col_parity) * h->mb_stride; ((sl->mb_y & ~1) + sl->col_parity) * h->mb_stride;
b8_stride = 0; b8_stride = 0;
} else { } else {
mb_y += sl->col_fieldoff; mb_y += sl->col_fieldoff;
...@@ -492,8 +492,8 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl, ...@@ -492,8 +492,8 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl,
goto single_col; goto single_col;
} else { // AFL/AFR/FR/FL -> AFR/FR } else { // AFL/AFR/FR/FL -> AFR/FR
if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR
mb_y = h->mb_y & ~1; mb_y = sl->mb_y & ~1;
mb_xy = h->mb_x + (h->mb_y & ~1) * h->mb_stride; mb_xy = sl->mb_x + (sl->mb_y & ~1) * h->mb_stride;
mb_type_col[0] = sl->ref_list[1][0].mb_type[mb_xy]; mb_type_col[0] = sl->ref_list[1][0].mb_type[mb_xy];
mb_type_col[1] = sl->ref_list[1][0].mb_type[mb_xy + h->mb_stride]; mb_type_col[1] = sl->ref_list[1][0].mb_type[mb_xy + h->mb_stride];
b8_stride = 2 + 4 * h->mb_stride; b8_stride = 2 + 4 * h->mb_stride;
...@@ -548,7 +548,7 @@ single_col: ...@@ -548,7 +548,7 @@ single_col:
l1ref0 = &sl->ref_list[1][0].ref_index[0][4 * mb_xy]; l1ref0 = &sl->ref_list[1][0].ref_index[0][4 * mb_xy];
l1ref1 = &sl->ref_list[1][0].ref_index[1][4 * mb_xy]; l1ref1 = &sl->ref_list[1][0].ref_index[1][4 * mb_xy];
if (!b8_stride) { if (!b8_stride) {
if (h->mb_y & 1) { if (sl->mb_y & 1) {
l1ref0 += 2; l1ref0 += 2;
l1ref1 += 2; l1ref1 += 2;
l1mv0 += 2 * b4_stride; l1mv0 += 2 * b4_stride;
...@@ -563,9 +563,9 @@ single_col: ...@@ -563,9 +563,9 @@ single_col:
int ref_offset; int ref_offset;
if (FRAME_MBAFF(h) && IS_INTERLACED(*mb_type)) { if (FRAME_MBAFF(h) && IS_INTERLACED(*mb_type)) {
map_col_to_list0[0] = sl->map_col_to_list0_field[h->mb_y & 1][0]; map_col_to_list0[0] = sl->map_col_to_list0_field[sl->mb_y & 1][0];
map_col_to_list0[1] = sl->map_col_to_list0_field[h->mb_y & 1][1]; map_col_to_list0[1] = sl->map_col_to_list0_field[sl->mb_y & 1][1];
dist_scale_factor = sl->dist_scale_factor_field[h->mb_y & 1]; dist_scale_factor = sl->dist_scale_factor_field[sl->mb_y & 1];
} }
ref_offset = (sl->ref_list[1][0].mbaff << 4) & (mb_type_col[0] >> 3); ref_offset = (sl->ref_list[1][0].mbaff << 4) & (mb_type_col[0] >> 3);
......
...@@ -57,7 +57,7 @@ static inline void get_lowest_part_y(H264Context *h, H264SliceContext *sl, ...@@ -57,7 +57,7 @@ static inline void get_lowest_part_y(H264Context *h, H264SliceContext *sl,
{ {
int my; int my;
y_offset += 16 * (h->mb_y >> MB_FIELD(h)); y_offset += 16 * (sl->mb_y >> MB_FIELD(h));
if (list0) { if (list0) {
int ref_n = sl->ref_cache[0][scan8[n]]; int ref_n = sl->ref_cache[0][scan8[n]];
...@@ -287,7 +287,7 @@ static av_always_inline void mc_dir_part(H264Context *h, H264SliceContext *sl, ...@@ -287,7 +287,7 @@ static av_always_inline void mc_dir_part(H264Context *h, H264SliceContext *sl,
ysh = 3 - (chroma_idc == 2 /* yuv422 */); ysh = 3 - (chroma_idc == 2 /* yuv422 */);
if (chroma_idc == 1 /* yuv420 */ && MB_FIELD(h)) { if (chroma_idc == 1 /* yuv420 */ && MB_FIELD(h)) {
// chroma offset when predicting from a field of opposite parity // chroma offset when predicting from a field of opposite parity
my += 2 * ((h->mb_y & 1) - (pic->reference - 1)); my += 2 * ((sl->mb_y & 1) - (pic->reference - 1));
emu |= (my >> 3) < 0 || (my >> 3) + 8 >= (pic_height >> 1); emu |= (my >> 3) < 0 || (my >> 3) + 8 >= (pic_height >> 1);
} }
...@@ -345,8 +345,8 @@ static av_always_inline void mc_part_std(H264Context *h, H264SliceContext *sl, ...@@ -345,8 +345,8 @@ static av_always_inline void mc_part_std(H264Context *h, H264SliceContext *sl,
dest_cb += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize; dest_cb += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize;
dest_cr += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize; dest_cr += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize;
} }
x_offset += 8 * h->mb_x; x_offset += 8 * sl->mb_x;
y_offset += 8 * (h->mb_y >> MB_FIELD(h)); y_offset += 8 * (sl->mb_y >> MB_FIELD(h));
if (list0) { if (list0) {
H264Picture *ref = &sl->ref_list[0][sl->ref_cache[0][scan8[n]]]; H264Picture *ref = &sl->ref_list[0][sl->ref_cache[0][scan8[n]]];
...@@ -399,8 +399,8 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext * ...@@ -399,8 +399,8 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext *
dest_cb += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize; dest_cb += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize;
dest_cr += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize; dest_cr += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize;
} }
x_offset += 8 * h->mb_x; x_offset += 8 * sl->mb_x;
y_offset += 8 * (h->mb_y >> MB_FIELD(h)); y_offset += 8 * (sl->mb_y >> MB_FIELD(h));
if (list0 && list1) { if (list0 && list1) {
/* don't optimize for luma-only case, since B-frames usually /* don't optimize for luma-only case, since B-frames usually
...@@ -421,7 +421,7 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext * ...@@ -421,7 +421,7 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext *
pixel_shift, chroma_idc); pixel_shift, chroma_idc);
if (sl->use_weight == 2) { if (sl->use_weight == 2) {
int weight0 = sl->implicit_weight[refn0][refn1][h->mb_y & 1]; int weight0 = sl->implicit_weight[refn0][refn1][sl->mb_y & 1];
int weight1 = 64 - weight0; int weight1 = 64 - weight0;
luma_weight_avg(dest_y, tmp_y, sl->mb_linesize, luma_weight_avg(dest_y, tmp_y, sl->mb_linesize,
height, 5, weight0, weight1, 0); height, 5, weight0, weight1, 0);
...@@ -488,18 +488,18 @@ static av_always_inline void prefetch_motion(H264Context *h, H264SliceContext *s ...@@ -488,18 +488,18 @@ static av_always_inline void prefetch_motion(H264Context *h, H264SliceContext *s
* optimized for 64byte cache lines */ * optimized for 64byte cache lines */
const int refn = sl->ref_cache[list][scan8[0]]; const int refn = sl->ref_cache[list][scan8[0]];
if (refn >= 0) { if (refn >= 0) {
const int mx = (sl->mv_cache[list][scan8[0]][0] >> 2) + 16 * h->mb_x + 8; const int mx = (sl->mv_cache[list][scan8[0]][0] >> 2) + 16 * sl->mb_x + 8;
const int my = (sl->mv_cache[list][scan8[0]][1] >> 2) + 16 * h->mb_y; const int my = (sl->mv_cache[list][scan8[0]][1] >> 2) + 16 * sl->mb_y;
uint8_t **src = sl->ref_list[list][refn].f.data; uint8_t **src = sl->ref_list[list][refn].f.data;
int off = mx * (1<< pixel_shift) + int off = mx * (1<< pixel_shift) +
(my + (h->mb_x & 3) * 4) * sl->mb_linesize + (my + (sl->mb_x & 3) * 4) * sl->mb_linesize +
(64 << pixel_shift); (64 << pixel_shift);
h->vdsp.prefetch(src[0] + off, h->linesize, 4); h->vdsp.prefetch(src[0] + off, h->linesize, 4);
if (chroma_idc == 3 /* yuv444 */) { if (chroma_idc == 3 /* yuv444 */) {
h->vdsp.prefetch(src[1] + off, h->linesize, 4); h->vdsp.prefetch(src[1] + off, h->linesize, 4);
h->vdsp.prefetch(src[2] + off, h->linesize, 4); h->vdsp.prefetch(src[2] + off, h->linesize, 4);
} else { } else {
off= ((mx>>1)+64) * (1<<pixel_shift) + ((my>>1) + (h->mb_x&7))*h->uvlinesize; off= ((mx>>1)+64) * (1<<pixel_shift) + ((my>>1) + (sl->mb_x&7))*h->uvlinesize;
h->vdsp.prefetch(src[1] + off, src[2] - src[1], 2); h->vdsp.prefetch(src[1] + off, src[2] - src[1], 2);
} }
} }
...@@ -519,7 +519,7 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl ...@@ -519,7 +519,7 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl
uint8_t *top_border; uint8_t *top_border;
if (!simple && FRAME_MBAFF(h)) { if (!simple && FRAME_MBAFF(h)) {
if (h->mb_y & 1) { if (sl->mb_y & 1) {
if (!MB_MBAFF(h)) if (!MB_MBAFF(h))
return; return;
} else { } else {
...@@ -531,16 +531,16 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl ...@@ -531,16 +531,16 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl
deblock_topleft = h->slice_table[sl->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 = (sl->mb_x > 0);
deblock_top = (h->mb_y > !!MB_FIELD(h)); deblock_top = (sl->mb_y > !!MB_FIELD(h));
} }
src_y -= linesize + 1 + pixel_shift; src_y -= linesize + 1 + pixel_shift;
src_cb -= uvlinesize + 1 + pixel_shift; src_cb -= uvlinesize + 1 + pixel_shift;
src_cr -= uvlinesize + 1 + pixel_shift; src_cr -= uvlinesize + 1 + pixel_shift;
top_border_m1 = h->top_borders[top_idx][h->mb_x - 1]; top_border_m1 = h->top_borders[top_idx][sl->mb_x - 1];
top_border = h->top_borders[top_idx][h->mb_x]; top_border = h->top_borders[top_idx][sl->mb_x];
#define XCHG(a, b, xchg) \ #define XCHG(a, b, xchg) \
if (pixel_shift) { \ if (pixel_shift) { \
...@@ -562,8 +562,8 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl ...@@ -562,8 +562,8 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl
} }
XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg); XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);
XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1); XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);
if (h->mb_x + 1 < h->mb_width) { if (sl->mb_x + 1 < h->mb_width) {
XCHG(h->top_borders[top_idx][h->mb_x + 1], XCHG(h->top_borders[top_idx][sl->mb_x + 1],
src_y + (17 << pixel_shift), 1); src_y + (17 << pixel_shift), 1);
} }
if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) {
...@@ -576,9 +576,9 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl ...@@ -576,9 +576,9 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl
XCHG(top_border + (24 << pixel_shift), src_cb + (9 << pixel_shift), 1); XCHG(top_border + (24 << pixel_shift), src_cb + (9 << pixel_shift), 1);
XCHG(top_border + (32 << pixel_shift), src_cr + (1 << pixel_shift), xchg); XCHG(top_border + (32 << pixel_shift), src_cr + (1 << pixel_shift), xchg);
XCHG(top_border + (40 << pixel_shift), src_cr + (9 << pixel_shift), 1); XCHG(top_border + (40 << pixel_shift), src_cr + (9 << pixel_shift), 1);
if (h->mb_x + 1 < h->mb_width) { if (sl->mb_x + 1 < h->mb_width) {
XCHG(h->top_borders[top_idx][h->mb_x + 1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1); XCHG(h->top_borders[top_idx][sl->mb_x + 1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1);
XCHG(h->top_borders[top_idx][h->mb_x + 1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1); XCHG(h->top_borders[top_idx][sl->mb_x + 1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1);
} }
} else { } else {
if (deblock_topleft) { if (deblock_topleft) {
...@@ -676,7 +676,7 @@ static av_always_inline void hl_decode_mb_predict_luma(H264Context *h, ...@@ -676,7 +676,7 @@ static av_always_inline void hl_decode_mb_predict_luma(H264Context *h,
uint64_t tr_high; uint64_t tr_high;
if (dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED) { if (dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED) {
const int topright_avail = (sl->topright_samples_available << i) & 0x8000; const int topright_avail = (sl->topright_samples_available << i) & 0x8000;
av_assert2(h->mb_y || linesize <= block_offset[i]); av_assert2(sl->mb_y || linesize <= block_offset[i]);
if (!topright_avail) { if (!topright_avail) {
if (pixel_shift) { if (pixel_shift) {
tr_high = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL; tr_high = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL;
......
...@@ -42,8 +42,8 @@ ...@@ -42,8 +42,8 @@
static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
{ {
const int mb_x = h->mb_x; const int mb_x = sl->mb_x;
const int mb_y = h->mb_y; const int mb_y = sl->mb_y;
const int mb_xy = sl->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;
...@@ -61,8 +61,8 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) ...@@ -61,8 +61,8 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
dest_cb = h->cur_pic.f.data[1] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * h->uvlinesize * block_h; dest_cb = h->cur_pic.f.data[1] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * h->uvlinesize * block_h;
dest_cr = h->cur_pic.f.data[2] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * h->uvlinesize * block_h; dest_cr = h->cur_pic.f.data[2] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * h->uvlinesize * block_h;
h->vdsp.prefetch(dest_y + (h->mb_x & 3) * 4 * h->linesize + (64 << PIXEL_SHIFT), h->linesize, 4); h->vdsp.prefetch(dest_y + (sl->mb_x & 3) * 4 * h->linesize + (64 << PIXEL_SHIFT), h->linesize, 4);
h->vdsp.prefetch(dest_cb + (h->mb_x & 7) * h->uvlinesize + (64 << PIXEL_SHIFT), dest_cr - dest_cb, 2); h->vdsp.prefetch(dest_cb + (sl->mb_x & 7) * h->uvlinesize + (64 << PIXEL_SHIFT), dest_cr - dest_cb, 2);
h->list_counts[mb_xy] = sl->list_count; h->list_counts[mb_xy] = sl->list_count;
...@@ -82,13 +82,13 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) ...@@ -82,13 +82,13 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
continue; continue;
if (IS_16X16(mb_type)) { if (IS_16X16(mb_type)) {
int8_t *ref = &sl->ref_cache[list][scan8[0]]; int8_t *ref = &sl->ref_cache[list][scan8[0]];
fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (h->mb_y & 1), 1); fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (sl->mb_y & 1), 1);
} else { } else {
for (i = 0; i < 16; i += 4) { for (i = 0; i < 16; i += 4) {
int ref = sl->ref_cache[list][scan8[i]]; int ref = sl->ref_cache[list][scan8[i]];
if (ref >= 0) if (ref >= 0)
fill_rectangle(&sl->ref_cache[list][scan8[i]], 2, 2, fill_rectangle(&sl->ref_cache[list][scan8[i]], 2, 2,
8, (16 + ref) ^ (h->mb_y & 1), 1); 8, (16 + ref) ^ (sl->mb_y & 1), 1);
} }
} }
} }
...@@ -271,8 +271,8 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) ...@@ -271,8 +271,8 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext *sl) static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext *sl)
{ {
const int mb_x = h->mb_x; const int mb_x = sl->mb_x;
const int mb_y = h->mb_y; const int mb_y = sl->mb_y;
const int mb_xy = sl->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];
...@@ -285,7 +285,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext ...@@ -285,7 +285,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext
for (p = 0; p < plane_count; p++) { for (p = 0; p < plane_count; p++) {
dest[p] = h->cur_pic.f.data[p] + dest[p] = h->cur_pic.f.data[p] +
((mb_x << PIXEL_SHIFT) + mb_y * h->linesize) * 16; ((mb_x << PIXEL_SHIFT) + mb_y * h->linesize) * 16;
h->vdsp.prefetch(dest[p] + (h->mb_x & 3) * 4 * h->linesize + (64 << PIXEL_SHIFT), h->vdsp.prefetch(dest[p] + (sl->mb_x & 3) * 4 * h->linesize + (64 << PIXEL_SHIFT),
h->linesize, 4); h->linesize, 4);
} }
...@@ -304,13 +304,13 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext ...@@ -304,13 +304,13 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext
continue; continue;
if (IS_16X16(mb_type)) { if (IS_16X16(mb_type)) {
int8_t *ref = &sl->ref_cache[list][scan8[0]]; int8_t *ref = &sl->ref_cache[list][scan8[0]];
fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (h->mb_y & 1), 1); fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (sl->mb_y & 1), 1);
} else { } else {
for (i = 0; i < 16; i += 4) { for (i = 0; i < 16; i += 4) {
int ref = sl->ref_cache[list][scan8[i]]; int ref = sl->ref_cache[list][scan8[i]];
if (ref >= 0) if (ref >= 0)
fill_rectangle(&sl->ref_cache[list][scan8[i]], 2, 2, fill_rectangle(&sl->ref_cache[list][scan8[i]], 2, 2,
8, (16 + ref) ^ (h->mb_y & 1), 1); 8, (16 + ref) ^ (sl->mb_y & 1), 1);
} }
} }
} }
......
...@@ -49,7 +49,7 @@ static void mc_part(H264Context *h, H264SliceContext *sl, ...@@ -49,7 +49,7 @@ static void mc_part(H264Context *h, H264SliceContext *sl,
int list0, int list1) int list0, int list1)
{ {
if ((sl->use_weight == 2 && list0 && list1 && if ((sl->use_weight == 2 && list0 && list1 &&
(sl->implicit_weight[sl->ref_cache[0][scan8[n]]][sl->ref_cache[1][scan8[n]]][h->mb_y & 1] != 32)) || (sl->implicit_weight[sl->ref_cache[0][scan8[n]]][sl->ref_cache[1][scan8[n]]][sl->mb_y & 1] != 32)) ||
sl->use_weight == 1) sl->use_weight == 1)
mc_part_weighted(h, sl, n, square, height, delta, dest_y, dest_cb, dest_cr, mc_part_weighted(h, sl, n, square, height, delta, dest_y, dest_cb, dest_cr,
x_offset, y_offset, qpix_put, chroma_put, x_offset, y_offset, qpix_put, chroma_put,
......
...@@ -64,7 +64,7 @@ static av_always_inline int fetch_diagonal_mv(H264Context *h, H264SliceContext * ...@@ -64,7 +64,7 @@ static av_always_inline int fetch_diagonal_mv(H264Context *h, H264SliceContext *
if (!MB_FIELD(h) && IS_INTERLACED(sl->left_type[0])) { if (!MB_FIELD(h) && IS_INTERLACED(sl->left_type[0])) {
SET_DIAG_MV(* 2, >> 1, sl->left_mb_xy[0] + h->mb_stride, SET_DIAG_MV(* 2, >> 1, sl->left_mb_xy[0] + h->mb_stride,
(h->mb_y & 1) * 2 + (i >> 5)); (sl->mb_y & 1) * 2 + (i >> 5));
} }
if (MB_FIELD(h) && !IS_INTERLACED(sl->left_type[0])) { if (MB_FIELD(h) && !IS_INTERLACED(sl->left_type[0])) {
// left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's OK. // left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's OK.
...@@ -148,7 +148,7 @@ static av_always_inline void pred_motion(H264Context *const h, ...@@ -148,7 +148,7 @@ static av_always_inline void pred_motion(H264Context *const h,
tprintf(h->avctx, tprintf(h->avctx,
"pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n", "pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n",
top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref, top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref,
A[0], A[1], ref, *mx, *my, h->mb_x, h->mb_y, n, list); A[0], A[1], ref, *mx, *my, sl->mb_x, sl->mb_y, n, list);
} }
/** /**
...@@ -167,7 +167,7 @@ static av_always_inline void pred_16x8_motion(H264Context *const h, ...@@ -167,7 +167,7 @@ static av_always_inline void pred_16x8_motion(H264Context *const h,
const int16_t *const B = sl->mv_cache[list][scan8[0] - 8]; const int16_t *const B = sl->mv_cache[list][scan8[0] - 8];
tprintf(h->avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", tprintf(h->avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n",
top_ref, B[0], B[1], h->mb_x, h->mb_y, n, list); top_ref, B[0], B[1], sl->mb_x, sl->mb_y, n, list);
if (top_ref == ref) { if (top_ref == ref) {
*mx = B[0]; *mx = B[0];
...@@ -179,7 +179,7 @@ static av_always_inline void pred_16x8_motion(H264Context *const h, ...@@ -179,7 +179,7 @@ static av_always_inline void pred_16x8_motion(H264Context *const h,
const int16_t *const A = sl->mv_cache[list][scan8[8] - 1]; const int16_t *const A = sl->mv_cache[list][scan8[8] - 1];
tprintf(h->avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", tprintf(h->avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n",
left_ref, A[0], A[1], h->mb_x, h->mb_y, n, list); left_ref, A[0], A[1], sl->mb_x, sl->mb_y, n, list);
if (left_ref == ref) { if (left_ref == ref) {
*mx = A[0]; *mx = A[0];
...@@ -208,7 +208,7 @@ static av_always_inline void pred_8x16_motion(H264Context *const h, ...@@ -208,7 +208,7 @@ static av_always_inline void pred_8x16_motion(H264Context *const h,
const int16_t *const A = sl->mv_cache[list][scan8[0] - 1]; const int16_t *const A = sl->mv_cache[list][scan8[0] - 1];
tprintf(h->avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", tprintf(h->avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n",
left_ref, A[0], A[1], h->mb_x, h->mb_y, n, list); left_ref, A[0], A[1], sl->mb_x, sl->mb_y, n, list);
if (left_ref == ref) { if (left_ref == ref) {
*mx = A[0]; *mx = A[0];
...@@ -222,7 +222,7 @@ static av_always_inline void pred_8x16_motion(H264Context *const h, ...@@ -222,7 +222,7 @@ static av_always_inline void pred_8x16_motion(H264Context *const h,
diagonal_ref = fetch_diagonal_mv(h, sl, &C, scan8[4], list, 2); diagonal_ref = fetch_diagonal_mv(h, sl, &C, scan8[4], list, 2);
tprintf(h->avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", tprintf(h->avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n",
diagonal_ref, C[0], C[1], h->mb_x, h->mb_y, n, list); diagonal_ref, C[0], C[1], sl->mb_x, sl->mb_y, n, list);
if (diagonal_ref == ref) { if (diagonal_ref == ref) {
*mx = C[0]; *mx = C[0];
...@@ -299,7 +299,7 @@ static av_always_inline void pred_pskip_motion(H264Context *const h, ...@@ -299,7 +299,7 @@ static av_always_inline void pred_pskip_motion(H264Context *const h,
} }
tprintf(h->avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", tprintf(h->avctx, "pred_pskip: (%d) (%d) at %2d %2d\n",
top_ref, left_ref, h->mb_x, h->mb_y); top_ref, left_ref, sl->mb_x, sl->mb_y);
if (USES_LIST(sl->topright_type, 0)) { if (USES_LIST(sl->topright_type, 0)) {
diagonal_ref = ref[4 * sl->topright_mb_xy + 2]; diagonal_ref = ref[4 * sl->topright_mb_xy + 2];
...@@ -378,7 +378,7 @@ static void fill_decode_neighbors(H264Context *h, H264SliceContext *sl, int mb_t ...@@ -378,7 +378,7 @@ static void fill_decode_neighbors(H264Context *h, H264SliceContext *sl, int mb_t
if (FRAME_MBAFF(h)) { if (FRAME_MBAFF(h)) {
const int left_mb_field_flag = IS_INTERLACED(h->cur_pic.mb_type[mb_xy - 1]); 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); const int curr_mb_field_flag = IS_INTERLACED(mb_type);
if (h->mb_y & 1) { if (sl->mb_y & 1) {
if (left_mb_field_flag != curr_mb_field_flag) { if (left_mb_field_flag != curr_mb_field_flag) {
left_xy[LBOT] = left_xy[LTOP] = mb_xy - h->mb_stride - 1; left_xy[LBOT] = left_xy[LTOP] = mb_xy - h->mb_stride - 1;
if (curr_mb_field_flag) { if (curr_mb_field_flag) {
......
This diff is collapsed.
...@@ -385,11 +385,11 @@ static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode, ...@@ -385,11 +385,11 @@ static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode,
for (i = 0; i < 16; i += part_height) for (i = 0; i < 16; i += part_height)
for (j = 0; j < 16; j += part_width) { for (j = 0; j < 16; j += part_width) {
const int b_xy = (4 * h->mb_x + (j >> 2)) + const int b_xy = (4 * sl->mb_x + (j >> 2)) +
(4 * h->mb_y + (i >> 2)) * h->b_stride; (4 * sl->mb_y + (i >> 2)) * h->b_stride;
int dxy; int dxy;
x = 16 * h->mb_x + j; x = 16 * sl->mb_x + j;
y = 16 * h->mb_y + i; y = 16 * sl->mb_y + i;
k = (j >> 2 & 1) + (i >> 1 & 2) + k = (j >> 2 & 1) + (i >> 1 & 2) +
(j >> 1 & 4) + (i & 8); (j >> 1 & 4) + (i & 8);
...@@ -495,20 +495,20 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) ...@@ -495,20 +495,20 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
uint32_t vlc; uint32_t vlc;
int8_t *top, *left; int8_t *top, *left;
const int mb_xy = sl->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 * sl->mb_x + 4 * sl->mb_y * h->b_stride;
sl->top_samples_available = (h->mb_y == 0) ? 0x33FF : 0xFFFF; sl->top_samples_available = (sl->mb_y == 0) ? 0x33FF : 0xFFFF;
sl->left_samples_available = (h->mb_x == 0) ? 0x5F5F : 0xFFFF; sl->left_samples_available = (sl->mb_x == 0) ? 0x5F5F : 0xFFFF;
sl->topright_samples_available = 0xFFFF; sl->topright_samples_available = 0xFFFF;
if (mb_type == 0) { /* SKIP */ if (mb_type == 0) { /* SKIP */
if (h->pict_type == AV_PICTURE_TYPE_P || if (h->pict_type == AV_PICTURE_TYPE_P ||
s->next_pic->mb_type[mb_xy] == -1) { s->next_pic->mb_type[mb_xy] == -1) {
svq3_mc_dir_part(s, 16 * h->mb_x, 16 * h->mb_y, 16, 16, svq3_mc_dir_part(s, 16 * sl->mb_x, 16 * sl->mb_y, 16, 16,
0, 0, 0, 0, 0, 0); 0, 0, 0, 0, 0, 0);
if (h->pict_type == AV_PICTURE_TYPE_B) if (h->pict_type == AV_PICTURE_TYPE_B)
svq3_mc_dir_part(s, 16 * h->mb_x, 16 * h->mb_y, 16, 16, svq3_mc_dir_part(s, 16 * sl->mb_x, 16 * sl->mb_y, 16, 16,
0, 0, 0, 0, 1, 1); 0, 0, 0, 0, 1, 1);
mb_type = MB_TYPE_SKIP; mb_type = MB_TYPE_SKIP;
...@@ -540,7 +540,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) ...@@ -540,7 +540,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
*/ */
for (m = 0; m < 2; m++) { for (m = 0; m < 2; m++) {
if (h->mb_x > 0 && sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1] + 6] != -1) { if (sl->mb_x > 0 && sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1] + 6] != -1) {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
AV_COPY32(sl->mv_cache[m][scan8[0] - 1 + i * 8], AV_COPY32(sl->mv_cache[m][scan8[0] - 1 + i * 8],
h->cur_pic.motion_val[m][b_xy - 1 + i * h->b_stride]); h->cur_pic.motion_val[m][b_xy - 1 + i * h->b_stride]);
...@@ -548,14 +548,14 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) ...@@ -548,14 +548,14 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
AV_ZERO32(sl->mv_cache[m][scan8[0] - 1 + i * 8]); AV_ZERO32(sl->mv_cache[m][scan8[0] - 1 + i * 8]);
} }
if (h->mb_y > 0) { if (sl->mb_y > 0) {
memcpy(sl->mv_cache[m][scan8[0] - 1 * 8], memcpy(sl->mv_cache[m][scan8[0] - 1 * 8],
h->cur_pic.motion_val[m][b_xy - h->b_stride], h->cur_pic.motion_val[m][b_xy - h->b_stride],
4 * 2 * sizeof(int16_t)); 4 * 2 * sizeof(int16_t));
memset(&sl->ref_cache[m][scan8[0] - 1 * 8], memset(&sl->ref_cache[m][scan8[0] - 1 * 8],
(sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4); (sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4);
if (h->mb_x < h->mb_width - 1) { if (sl->mb_x < h->mb_width - 1) {
AV_COPY32(sl->mv_cache[m][scan8[0] + 4 - 1 * 8], AV_COPY32(sl->mv_cache[m][scan8[0] + 4 - 1 * 8],
h->cur_pic.motion_val[m][b_xy - h->b_stride + 4]); h->cur_pic.motion_val[m][b_xy - h->b_stride + 4]);
sl->ref_cache[m][scan8[0] + 4 - 1 * 8] = sl->ref_cache[m][scan8[0] + 4 - 1 * 8] =
...@@ -563,7 +563,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) ...@@ -563,7 +563,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1; sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1;
} else } else
sl->ref_cache[m][scan8[0] + 4 - 1 * 8] = PART_NOT_AVAILABLE; sl->ref_cache[m][scan8[0] + 4 - 1 * 8] = PART_NOT_AVAILABLE;
if (h->mb_x > 0) { if (sl->mb_x > 0) {
AV_COPY32(sl->mv_cache[m][scan8[0] - 1 - 1 * 8], AV_COPY32(sl->mv_cache[m][scan8[0] - 1 - 1 * 8],
h->cur_pic.motion_val[m][b_xy - h->b_stride - 1]); h->cur_pic.motion_val[m][b_xy - h->b_stride - 1]);
sl->ref_cache[m][scan8[0] - 1 - 1 * 8] = sl->ref_cache[m][scan8[0] - 1 - 1 * 8] =
...@@ -606,13 +606,13 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) ...@@ -606,13 +606,13 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
memset(sl->intra4x4_pred_mode_cache, -1, 8 * 5 * sizeof(int8_t)); memset(sl->intra4x4_pred_mode_cache, -1, 8 * 5 * sizeof(int8_t));
if (mb_type == 8) { if (mb_type == 8) {
if (h->mb_x > 0) { if (sl->mb_x > 0) {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
sl->intra4x4_pred_mode_cache[scan8[0] - 1 + i * 8] = sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1] + 6 - i]; sl->intra4x4_pred_mode_cache[scan8[0] - 1 + i * 8] = sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1] + 6 - i];
if (sl->intra4x4_pred_mode_cache[scan8[0] - 1] == -1) if (sl->intra4x4_pred_mode_cache[scan8[0] - 1] == -1)
sl->left_samples_available = 0x5F5F; sl->left_samples_available = 0x5F5F;
} }
if (h->mb_y > 0) { if (sl->mb_y > 0) {
sl->intra4x4_pred_mode_cache[4 + 8 * 0] = sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 0]; sl->intra4x4_pred_mode_cache[4 + 8 * 0] = sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 0];
sl->intra4x4_pred_mode_cache[5 + 8 * 0] = sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 1]; sl->intra4x4_pred_mode_cache[5 + 8 * 0] = sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 1];
sl->intra4x4_pred_mode_cache[6 + 8 * 0] = sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 2]; sl->intra4x4_pred_mode_cache[6 + 8 * 0] = sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 2];
...@@ -653,8 +653,8 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) ...@@ -653,8 +653,8 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
if (mb_type == 8) { if (mb_type == 8) {
ff_h264_check_intra4x4_pred_mode(h, sl); ff_h264_check_intra4x4_pred_mode(h, sl);
sl->top_samples_available = (h->mb_y == 0) ? 0x33FF : 0xFFFF; sl->top_samples_available = (sl->mb_y == 0) ? 0x33FF : 0xFFFF;
sl->left_samples_available = (h->mb_x == 0) ? 0x5F5F : 0xFFFF; sl->left_samples_available = (sl->mb_x == 0) ? 0x5F5F : 0xFFFF;
} else { } else {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
memset(&sl->intra4x4_pred_mode_cache[scan8[0] + 8 * i], DC_128_PRED, 4); memset(&sl->intra4x4_pred_mode_cache[scan8[0] + 8 * i], DC_128_PRED, 4);
...@@ -829,7 +829,7 @@ static int svq3_decode_slice_header(AVCodecContext *avctx) ...@@ -829,7 +829,7 @@ static int svq3_decode_slice_header(AVCodecContext *avctx)
if ((header & 0x9F) == 2) { if ((header & 0x9F) == 2) {
i = (h->mb_num < 64) ? 6 : (1 + av_log2(h->mb_num - 1)); i = (h->mb_num < 64) ? 6 : (1 + av_log2(h->mb_num - 1));
sl->mb_skip_run = get_bits(&h->gb, i) - sl->mb_skip_run = get_bits(&h->gb, i) -
(h->mb_y * h->mb_width + h->mb_x); (sl->mb_y * h->mb_width + sl->mb_x);
} else { } else {
skip_bits1(&h->gb); skip_bits1(&h->gb);
sl->mb_skip_run = 0; sl->mb_skip_run = 0;
...@@ -852,17 +852,17 @@ static int svq3_decode_slice_header(AVCodecContext *avctx) ...@@ -852,17 +852,17 @@ static int svq3_decode_slice_header(AVCodecContext *avctx)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
/* reset intra predictors and invalidate motion vector references */ /* reset intra predictors and invalidate motion vector references */
if (h->mb_x > 0) { if (sl->mb_x > 0) {
memset(sl->intra4x4_pred_mode + h->mb2br_xy[mb_xy - 1] + 3, memset(sl->intra4x4_pred_mode + h->mb2br_xy[mb_xy - 1] + 3,
-1, 4 * sizeof(int8_t)); -1, 4 * sizeof(int8_t));
memset(sl->intra4x4_pred_mode + h->mb2br_xy[mb_xy - h->mb_x], memset(sl->intra4x4_pred_mode + h->mb2br_xy[mb_xy - sl->mb_x],
-1, 8 * sizeof(int8_t) * h->mb_x); -1, 8 * sizeof(int8_t) * sl->mb_x);
} }
if (h->mb_y > 0) { if (sl->mb_y > 0) {
memset(sl->intra4x4_pred_mode + h->mb2br_xy[mb_xy - h->mb_stride], memset(sl->intra4x4_pred_mode + h->mb2br_xy[mb_xy - h->mb_stride],
-1, 8 * sizeof(int8_t) * (h->mb_width - h->mb_x)); -1, 8 * sizeof(int8_t) * (h->mb_width - sl->mb_x));
if (h->mb_x > 0) if (sl->mb_x > 0)
sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride - 1] + 3] = -1; sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride - 1] + 3] = -1;
} }
...@@ -1153,7 +1153,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data, ...@@ -1153,7 +1153,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
return 0; return 0;
} }
h->mb_x = h->mb_y = sl->mb_xy = 0; sl->mb_x = sl->mb_y = sl->mb_xy = 0;
if (s->watermark_key) { if (s->watermark_key) {
av_fast_padded_malloc(&s->buf, &s->buf_size, buf_size); av_fast_padded_malloc(&s->buf, &s->buf_size, buf_size);
...@@ -1280,10 +1280,10 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data, ...@@ -1280,10 +1280,10 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
} }
} }
for (h->mb_y = 0; h->mb_y < h->mb_height; h->mb_y++) { for (sl->mb_y = 0; sl->mb_y < h->mb_height; sl->mb_y++) {
for (h->mb_x = 0; h->mb_x < h->mb_width; h->mb_x++) { for (sl->mb_x = 0; sl->mb_x < h->mb_width; sl->mb_x++) {
unsigned mb_type; unsigned mb_type;
sl->mb_xy = h->mb_x + h->mb_y * h->mb_stride; sl->mb_xy = sl->mb_x + sl->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 ||
...@@ -1305,7 +1305,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data, ...@@ -1305,7 +1305,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
mb_type += 4; mb_type += 4;
if (mb_type > 33 || svq3_decode_mb(s, mb_type)) { if (mb_type > 33 || svq3_decode_mb(s, mb_type)) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"error while decoding MB %d %d\n", h->mb_x, h->mb_y); "error while decoding MB %d %d\n", sl->mb_x, sl->mb_y);
return -1; return -1;
} }
...@@ -1313,20 +1313,20 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data, ...@@ -1313,20 +1313,20 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
ff_h264_hl_decode_mb(h, &h->slice_ctx[0]); ff_h264_hl_decode_mb(h, &h->slice_ctx[0]);
if (h->pict_type != AV_PICTURE_TYPE_B && !h->low_delay) if (h->pict_type != AV_PICTURE_TYPE_B && !h->low_delay)
h->cur_pic.mb_type[h->mb_x + h->mb_y * h->mb_stride] = h->cur_pic.mb_type[sl->mb_x + sl->mb_y * h->mb_stride] =
(h->pict_type == AV_PICTURE_TYPE_P && mb_type < 8) ? (mb_type - 1) : -1; (h->pict_type == AV_PICTURE_TYPE_P && mb_type < 8) ? (mb_type - 1) : -1;
} }
ff_draw_horiz_band(avctx, &s->cur_pic->f, ff_draw_horiz_band(avctx, &s->cur_pic->f,
s->last_pic->f.data[0] ? &s->last_pic->f : NULL, s->last_pic->f.data[0] ? &s->last_pic->f : NULL,
16 * h->mb_y, 16, h->picture_structure, 0, 16 * sl->mb_y, 16, h->picture_structure, 0,
h->low_delay); h->low_delay);
} }
left = buf_size*8 - get_bits_count(&h->gb); left = buf_size*8 - get_bits_count(&h->gb);
if (h->mb_y != h->mb_height || h->mb_x != h->mb_width) { if (sl->mb_y != h->mb_height || sl->mb_x != h->mb_width) {
av_log(avctx, AV_LOG_INFO, "frame num %d incomplete pic x %d y %d left %d\n", avctx->frame_number, h->mb_y, h->mb_x, left); av_log(avctx, AV_LOG_INFO, "frame num %d incomplete pic x %d y %d left %d\n", avctx->frame_number, sl->mb_y, sl->mb_x, left);
//av_hex_dump(stderr, buf+buf_size-8, 8); //av_hex_dump(stderr, buf+buf_size-8, 8);
} }
......
...@@ -329,7 +329,7 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx, ...@@ -329,7 +329,7 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
if (!slice_param) if (!slice_param)
return -1; return -1;
slice_param->slice_data_bit_offset = get_bits_count(&h->gb) + 8; /* bit buffer started beyond nal_unit_type */ slice_param->slice_data_bit_offset = get_bits_count(&h->gb) + 8; /* bit buffer started beyond nal_unit_type */
slice_param->first_mb_in_slice = (h->mb_y >> FIELD_OR_MBAFF_PICTURE(h)) * h->mb_width + h->mb_x; slice_param->first_mb_in_slice = (sl->mb_y >> FIELD_OR_MBAFF_PICTURE(h)) * h->mb_width + sl->mb_x;
slice_param->slice_type = ff_h264_get_slice_type(sl); slice_param->slice_type = ff_h264_get_slice_type(sl);
slice_param->direct_spatial_mv_pred_flag = sl->slice_type == AV_PICTURE_TYPE_B ? sl->direct_spatial_mv_pred : 0; slice_param->direct_spatial_mv_pred_flag = sl->slice_type == AV_PICTURE_TYPE_B ? sl->direct_spatial_mv_pred : 0;
slice_param->num_ref_idx_l0_active_minus1 = sl->list_count > 0 ? sl->ref_count[0] - 1 : 0; slice_param->num_ref_idx_l0_active_minus1 = sl->list_count > 0 ? sl->ref_count[0] - 1 : 0;
......
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