Commit 95eb35f3 authored by Anton Khirnov's avatar Anton Khirnov

h264: move the ref lists variables into the per-slice context

parent 77477266
...@@ -228,10 +228,10 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice, ...@@ -228,10 +228,10 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
slice->slice_type += 5; slice->slice_type += 5;
slice->luma_log2_weight_denom = sl->luma_log2_weight_denom; slice->luma_log2_weight_denom = sl->luma_log2_weight_denom;
slice->chroma_log2_weight_denom = sl->chroma_log2_weight_denom; slice->chroma_log2_weight_denom = sl->chroma_log2_weight_denom;
if (h->list_count > 0) if (sl->list_count > 0)
slice->num_ref_idx_l0_active_minus1 = h->ref_count[0] - 1; slice->num_ref_idx_l0_active_minus1 = sl->ref_count[0] - 1;
if (h->list_count > 1) if (sl->list_count > 1)
slice->num_ref_idx_l1_active_minus1 = h->ref_count[1] - 1; slice->num_ref_idx_l1_active_minus1 = sl->ref_count[1] - 1;
slice->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2; slice->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2;
slice->slice_beta_offset_div2 = h->slice_beta_offset / 2; slice->slice_beta_offset_div2 = h->slice_beta_offset / 2;
slice->Reserved8Bits = 0; slice->Reserved8Bits = 0;
...@@ -239,8 +239,8 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice, ...@@ -239,8 +239,8 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
for (list = 0; list < 2; list++) { for (list = 0; list < 2; list++) {
unsigned i; unsigned i;
for (i = 0; i < FF_ARRAY_ELEMS(slice->RefPicList[list]); i++) { for (i = 0; i < FF_ARRAY_ELEMS(slice->RefPicList[list]); i++) {
if (list < h->list_count && i < h->ref_count[list]) { if (list < sl->list_count && i < sl->ref_count[list]) {
const H264Picture *r = &h->ref_list[list][i]; const H264Picture *r = &sl->ref_list[list][i];
unsigned plane; unsigned plane;
unsigned index; unsigned index;
if (ctx->workaround & FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO) if (ctx->workaround & FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO)
...@@ -447,6 +447,7 @@ static int dxva2_h264_decode_slice(AVCodecContext *avctx, ...@@ -447,6 +447,7 @@ static int dxva2_h264_decode_slice(AVCodecContext *avctx,
static int dxva2_h264_end_frame(AVCodecContext *avctx) static int dxva2_h264_end_frame(AVCodecContext *avctx)
{ {
H264Context *h = avctx->priv_data; H264Context *h = avctx->priv_data;
H264SliceContext *sl = &h->slice_ctx[0];
struct dxva2_picture_context *ctx_pic = struct dxva2_picture_context *ctx_pic =
h->cur_pic_ptr->hwaccel_picture_private; h->cur_pic_ptr->hwaccel_picture_private;
int ret; int ret;
...@@ -458,7 +459,7 @@ static int dxva2_h264_end_frame(AVCodecContext *avctx) ...@@ -458,7 +459,7 @@ static int dxva2_h264_end_frame(AVCodecContext *avctx)
&ctx_pic->qm, sizeof(ctx_pic->qm), &ctx_pic->qm, sizeof(ctx_pic->qm),
commit_bitstream_and_slice_buffer); commit_bitstream_and_slice_buffer);
if (!ret) if (!ret)
ff_h264_draw_horiz_band(h, 0, h->avctx->height); ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
return ret; return ret;
} }
......
...@@ -67,7 +67,7 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, ...@@ -67,7 +67,7 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
* differ between slices. We take the easy approach and ignore * differ between slices. We take the easy approach and ignore
* it for now. If this turns out to have any relevance in * it for now. If this turns out to have any relevance in
* practice then correct remapping should be added. */ * practice then correct remapping should be added. */
if (ref >= h->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 * h->mb_xy],
2, 2, 2, ref, 1); 2, 2, 2, ref, 1);
...@@ -78,11 +78,12 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, ...@@ -78,11 +78,12 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
ff_h264_hl_decode_mb(h, &h->slice_ctx[0]); ff_h264_hl_decode_mb(h, &h->slice_ctx[0]);
} }
void ff_h264_draw_horiz_band(H264Context *h, int y, int height) void ff_h264_draw_horiz_band(H264Context *h, H264SliceContext *sl,
int y, int height)
{ {
AVCodecContext *avctx = h->avctx; AVCodecContext *avctx = h->avctx;
AVFrame *cur = &h->cur_pic.f; AVFrame *cur = &h->cur_pic.f;
AVFrame *last = h->ref_list[0][0].f.data[0] ? &h->ref_list[0][0].f : NULL; AVFrame *last = sl->ref_list[0][0].f.data[0] ? &sl->ref_list[0][0].f : NULL;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
int vshift = desc->log2_chroma_h; int vshift = desc->log2_chroma_h;
const int field_pic = h->picture_structure != PICT_FRAME; const int field_pic = h->picture_structure != PICT_FRAME;
...@@ -1019,7 +1020,7 @@ int ff_pred_weight_table(H264Context *h, H264SliceContext *sl) ...@@ -1019,7 +1020,7 @@ int ff_pred_weight_table(H264Context *h, H264SliceContext *sl)
for (list = 0; list < 2; list++) { for (list = 0; list < 2; list++) {
sl->luma_weight_flag[list] = 0; sl->luma_weight_flag[list] = 0;
sl->chroma_weight_flag[list] = 0; sl->chroma_weight_flag[list] = 0;
for (i = 0; i < h->ref_count[list]; i++) { for (i = 0; i < sl->ref_count[list]; i++) {
int luma_weight_flag, chroma_weight_flag; int luma_weight_flag, chroma_weight_flag;
luma_weight_flag = get_bits1(&h->gb); luma_weight_flag = get_bits1(&h->gb);
...@@ -1297,16 +1298,16 @@ int ff_set_ref_count(H264Context *h, H264SliceContext *sl) ...@@ -1297,16 +1298,16 @@ int ff_set_ref_count(H264Context *h, H264SliceContext *sl)
if (ref_count[0] > max_refs || ref_count[1] > max_refs) { if (ref_count[0] > max_refs || ref_count[1] > max_refs) {
av_log(h->avctx, AV_LOG_ERROR, "reference overflow\n"); av_log(h->avctx, AV_LOG_ERROR, "reference overflow\n");
h->ref_count[0] = h->ref_count[1] = 0; sl->ref_count[0] = sl->ref_count[1] = 0;
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (list_count != h->list_count || if (list_count != sl->list_count ||
ref_count[0] != h->ref_count[0] || ref_count[0] != sl->ref_count[0] ||
ref_count[1] != h->ref_count[1]) { ref_count[1] != sl->ref_count[1]) {
h->ref_count[0] = ref_count[0]; sl->ref_count[0] = ref_count[0];
h->ref_count[1] = ref_count[1]; sl->ref_count[1] = ref_count[1];
h->list_count = list_count; sl->list_count = list_count;
return 1; return 1;
} }
...@@ -1642,7 +1643,7 @@ again: ...@@ -1642,7 +1643,7 @@ again:
if (err < 0) { if (err < 0) {
av_log(h->avctx, AV_LOG_ERROR, "decode_slice_header error\n"); av_log(h->avctx, AV_LOG_ERROR, "decode_slice_header error\n");
h->ref_count[0] = h->ref_count[1] = h->list_count = 0; sl->ref_count[0] = sl->ref_count[1] = sl->list_count = 0;
} else if (err == 1) { } else if (err == 1) {
/* Slice could not be decoded in parallel mode, copy down /* Slice could not be decoded in parallel mode, copy down
* NAL unit stuff to context 0 and restart. Note that * NAL unit stuff to context 0 and restart. Note that
...@@ -1773,7 +1774,7 @@ out: ...@@ -1773,7 +1774,7 @@ out:
if (avctx->flags2 & CODEC_FLAG2_CHUNKS) if (avctx->flags2 & CODEC_FLAG2_CHUNKS)
decode_postinit(h, 1); decode_postinit(h, 1);
ff_h264_field_end(h, 0); ff_h264_field_end(h, &h->slice_ctx[0], 0);
*got_frame = 0; *got_frame = 0;
if (h->next_output_pic && ((avctx->flags & CODEC_FLAG_OUTPUT_CORRUPT) || if (h->next_output_pic && ((avctx->flags & CODEC_FLAG_OUTPUT_CORRUPT) ||
......
...@@ -364,6 +364,17 @@ typedef struct H264SliceContext { ...@@ -364,6 +364,17 @@ typedef struct H264SliceContext {
int map_col_to_list0[2][16 + 32]; int map_col_to_list0[2][16 + 32];
int map_col_to_list0_field[2][2][16 + 32]; int map_col_to_list0_field[2][2][16 + 32];
/**
* num_ref_idx_l0/1_active_minus1 + 1
*/
unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode
unsigned int list_count;
H264Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs.
* Reordered version of default_ref_list
* according to picture reordering in slice header */
int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1
/** /**
* non zero coeff count cache. * non zero coeff count cache.
* is 64 if not available. * is 64 if not available.
...@@ -449,16 +460,7 @@ typedef struct H264Context { ...@@ -449,16 +460,7 @@ typedef struct H264Context {
int picture_structure; int picture_structure;
int first_field; int first_field;
/**
* num_ref_idx_l0/1_active_minus1 + 1
*/
unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode
unsigned int list_count;
uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type
H264Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs.
* Reordered version of default_ref_list
* according to picture reordering in slice header */
int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1
// data partitioning // data partitioning
GetBitContext intra_gb; GetBitContext intra_gb;
...@@ -773,7 +775,7 @@ int ff_h264_alloc_tables(H264Context *h); ...@@ -773,7 +775,7 @@ int ff_h264_alloc_tables(H264Context *h);
*/ */
int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl); int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl);
int ff_h264_decode_ref_pic_list_reordering(H264Context *h); int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl);
void ff_h264_fill_mbaff_ref_list(H264Context *h, H264SliceContext *sl); void ff_h264_fill_mbaff_ref_list(H264Context *h, H264SliceContext *sl);
void ff_h264_remove_all_refs(H264Context *h); void ff_h264_remove_all_refs(H264Context *h);
...@@ -1046,7 +1048,7 @@ static av_always_inline int get_dct8x8_allowed(H264Context *h, H264SliceContext ...@@ -1046,7 +1048,7 @@ static av_always_inline int get_dct8x8_allowed(H264Context *h, H264SliceContext
0x0001000100010001ULL)); 0x0001000100010001ULL));
} }
int ff_h264_field_end(H264Context *h, int in_setup); int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup);
int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src); int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src);
void ff_h264_unref_picture(H264Context *h, H264Picture *pic); void ff_h264_unref_picture(H264Context *h, H264Picture *pic);
...@@ -1054,7 +1056,7 @@ void ff_h264_unref_picture(H264Context *h, H264Picture *pic); ...@@ -1054,7 +1056,7 @@ void ff_h264_unref_picture(H264Context *h, H264Picture *pic);
int ff_h264_context_init(H264Context *h); int ff_h264_context_init(H264Context *h);
int ff_h264_set_parameter_from_sps(H264Context *h); int ff_h264_set_parameter_from_sps(H264Context *h);
void ff_h264_draw_horiz_band(H264Context *h, int y, int height); void ff_h264_draw_horiz_band(H264Context *h, H264SliceContext *sl, int y, int height);
int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc); int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc);
int ff_pred_weight_table(H264Context *h, H264SliceContext *sl); int ff_pred_weight_table(H264Context *h, H264SliceContext *sl);
int ff_set_ref_count(H264Context *h, H264SliceContext *sl); int ff_set_ref_count(H264Context *h, H264SliceContext *sl);
......
...@@ -2112,11 +2112,11 @@ decode_intra_mb: ...@@ -2112,11 +2112,11 @@ decode_intra_mb:
} }
} }
for( list = 0; list < h->list_count; list++ ) { for( list = 0; list < sl->list_count; list++ ) {
for( i = 0; i < 4; i++ ) { for( i = 0; i < 4; i++ ) {
if(IS_DIRECT(sl->sub_mb_type[i])) continue; if(IS_DIRECT(sl->sub_mb_type[i])) continue;
if(IS_DIR(sl->sub_mb_type[i], 0, list)){ if(IS_DIR(sl->sub_mb_type[i], 0, list)){
int rc = h->ref_count[list] << MB_MBAFF(h); int rc = sl->ref_count[list] << MB_MBAFF(h);
if (rc > 1) { if (rc > 1) {
ref[list][i] = decode_cabac_mb_ref(h, sl, list, 4 * i); ref[list][i] = decode_cabac_mb_ref(h, sl, list, 4 * i);
if (ref[list][i] >= (unsigned) rc) { if (ref[list][i] >= (unsigned) rc) {
...@@ -2136,7 +2136,7 @@ decode_intra_mb: ...@@ -2136,7 +2136,7 @@ decode_intra_mb:
if(dct8x8_allowed) if(dct8x8_allowed)
dct8x8_allowed = get_dct8x8_allowed(h, sl); dct8x8_allowed = get_dct8x8_allowed(h, sl);
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
for(i=0; i<4; i++){ for(i=0; i<4; i++){
sl->ref_cache[list][scan8[4 * i]] = sl->ref_cache[list][scan8[4 * i] + 1]; sl->ref_cache[list][scan8[4 * i]] = sl->ref_cache[list][scan8[4 * i] + 1];
if(IS_DIRECT(sl->sub_mb_type[i])){ if(IS_DIRECT(sl->sub_mb_type[i])){
...@@ -2200,9 +2200,9 @@ decode_intra_mb: ...@@ -2200,9 +2200,9 @@ decode_intra_mb:
} else { } else {
int list, i; int list, i;
if(IS_16X16(mb_type)){ if(IS_16X16(mb_type)){
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
if(IS_DIR(mb_type, 0, list)){ if(IS_DIR(mb_type, 0, list)){
int ref, rc = h->ref_count[list] << MB_MBAFF(h); int ref, rc = sl->ref_count[list] << MB_MBAFF(h);
if (rc > 1) { if (rc > 1) {
ref= decode_cabac_mb_ref(h, sl, list, 0); ref= decode_cabac_mb_ref(h, sl, list, 0);
if (ref >= (unsigned) rc) { if (ref >= (unsigned) rc) {
...@@ -2214,7 +2214,7 @@ decode_intra_mb: ...@@ -2214,7 +2214,7 @@ decode_intra_mb:
fill_rectangle(&sl->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1); fill_rectangle(&sl->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1);
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->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, sl, 0, 4, list, sl->ref_cache[list][ scan8[0] ], &mx, &my); pred_motion(h, sl, 0, 4, list, sl->ref_cache[list][ scan8[0] ], &mx, &my);
...@@ -2227,10 +2227,10 @@ decode_intra_mb: ...@@ -2227,10 +2227,10 @@ decode_intra_mb:
} }
} }
else if(IS_16X8(mb_type)){ else if(IS_16X8(mb_type)){
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
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 ref, rc = h->ref_count[list] << MB_MBAFF(h); int ref, rc = sl->ref_count[list] << MB_MBAFF(h);
if (rc > 1) { if (rc > 1) {
ref= decode_cabac_mb_ref(h, sl, list, 8 * i); ref= decode_cabac_mb_ref(h, sl, list, 8 * i);
if (ref >= (unsigned) rc) { if (ref >= (unsigned) rc) {
...@@ -2244,7 +2244,7 @@ decode_intra_mb: ...@@ -2244,7 +2244,7 @@ decode_intra_mb:
fill_rectangle(&sl->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1); fill_rectangle(&sl->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
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;
...@@ -2262,10 +2262,10 @@ decode_intra_mb: ...@@ -2262,10 +2262,10 @@ decode_intra_mb:
} }
}else{ }else{
assert(IS_8X16(mb_type)); assert(IS_8X16(mb_type));
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
for(i=0; i<2; i++){ for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){ //FIXME optimize if(IS_DIR(mb_type, i, list)){ //FIXME optimize
int ref, rc = h->ref_count[list] << MB_MBAFF(h); int ref, rc = sl->ref_count[list] << MB_MBAFF(h);
if (rc > 1) { if (rc > 1) {
ref= decode_cabac_mb_ref(h, sl, list, 4 * i); ref= decode_cabac_mb_ref(h, sl, list, 4 * i);
if (ref >= (unsigned) rc) { if (ref >= (unsigned) rc) {
...@@ -2279,7 +2279,7 @@ decode_intra_mb: ...@@ -2279,7 +2279,7 @@ decode_intra_mb:
fill_rectangle(&sl->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1); fill_rectangle(&sl->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
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;
......
...@@ -864,8 +864,8 @@ decode_intra_mb: ...@@ -864,8 +864,8 @@ decode_intra_mb:
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
int ref_count = IS_REF0(mb_type) ? 1 : h->ref_count[list] << MB_MBAFF(h); int ref_count = IS_REF0(mb_type) ? 1 : sl->ref_count[list] << MB_MBAFF(h);
for(i=0; i<4; i++){ for(i=0; i<4; i++){
if(IS_DIRECT(sl->sub_mb_type[i])) continue; if(IS_DIRECT(sl->sub_mb_type[i])) continue;
if(IS_DIR(sl->sub_mb_type[i], 0, list)){ if(IS_DIR(sl->sub_mb_type[i], 0, list)){
...@@ -892,7 +892,7 @@ decode_intra_mb: ...@@ -892,7 +892,7 @@ decode_intra_mb:
if(dct8x8_allowed) if(dct8x8_allowed)
dct8x8_allowed = get_dct8x8_allowed(h, sl); dct8x8_allowed = get_dct8x8_allowed(h, sl);
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
for(i=0; i<4; i++){ for(i=0; i<4; i++){
if(IS_DIRECT(sl->sub_mb_type[i])) { if(IS_DIRECT(sl->sub_mb_type[i])) {
sl->ref_cache[list][ scan8[4*i] ] = sl->ref_cache[list][ scan8[4*i]+1 ]; sl->ref_cache[list][ scan8[4*i] ] = sl->ref_cache[list][ scan8[4*i]+1 ];
...@@ -942,10 +942,10 @@ decode_intra_mb: ...@@ -942,10 +942,10 @@ decode_intra_mb:
int list, mx, my, i; int list, mx, my, i;
//FIXME we should set ref_idx_l? to 0 if we use that later ... //FIXME we should set ref_idx_l? to 0 if we use that later ...
if(IS_16X16(mb_type)){ if(IS_16X16(mb_type)){
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
unsigned int val; unsigned int val;
if(IS_DIR(mb_type, 0, list)){ if(IS_DIR(mb_type, 0, list)){
int rc = h->ref_count[list] << MB_MBAFF(h); int rc = sl->ref_count[list] << MB_MBAFF(h);
if (rc == 1) { if (rc == 1) {
val= 0; val= 0;
} else if (rc == 2) { } else if (rc == 2) {
...@@ -960,7 +960,7 @@ decode_intra_mb: ...@@ -960,7 +960,7 @@ decode_intra_mb:
fill_rectangle(&sl->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1); fill_rectangle(&sl->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1);
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
if(IS_DIR(mb_type, 0, list)){ if(IS_DIR(mb_type, 0, list)){
pred_motion(h, sl, 0, 4, list, sl->ref_cache[list][ scan8[0] ], &mx, &my); pred_motion(h, sl, 0, 4, list, sl->ref_cache[list][ scan8[0] ], &mx, &my);
mx += get_se_golomb(&h->gb); mx += get_se_golomb(&h->gb);
...@@ -972,11 +972,11 @@ decode_intra_mb: ...@@ -972,11 +972,11 @@ decode_intra_mb:
} }
} }
else if(IS_16X8(mb_type)){ else if(IS_16X8(mb_type)){
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
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)){
int rc = h->ref_count[list] << MB_MBAFF(h); int rc = sl->ref_count[list] << MB_MBAFF(h);
if (rc == 1) { if (rc == 1) {
val= 0; val= 0;
} else if (rc == 2) { } else if (rc == 2) {
...@@ -993,7 +993,7 @@ decode_intra_mb: ...@@ -993,7 +993,7 @@ decode_intra_mb:
fill_rectangle(&sl->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1); fill_rectangle(&sl->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1);
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
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)){
...@@ -1010,11 +1010,11 @@ decode_intra_mb: ...@@ -1010,11 +1010,11 @@ decode_intra_mb:
} }
}else{ }else{
assert(IS_8X16(mb_type)); assert(IS_8X16(mb_type));
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
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)){ //FIXME optimize if(IS_DIR(mb_type, i, list)){ //FIXME optimize
int rc = h->ref_count[list] << MB_MBAFF(h); int rc = sl->ref_count[list] << MB_MBAFF(h);
if (rc == 1) { if (rc == 1) {
val= 0; val= 0;
} else if (rc == 2) { } else if (rc == 2) {
...@@ -1031,7 +1031,7 @@ decode_intra_mb: ...@@ -1031,7 +1031,7 @@ decode_intra_mb:
fill_rectangle(&sl->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1); fill_rectangle(&sl->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1);
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
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)){
......
This diff is collapsed.
...@@ -372,7 +372,7 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h, ...@@ -372,7 +372,7 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
int step = 1+(mb_type>>24); //IS_8x8DCT(mb_type) ? 2 : 1; int step = 1+(mb_type>>24); //IS_8x8DCT(mb_type) ? 2 : 1;
edges = 4 - 3*((mb_type>>3) & !(h->cbp & 15)); //(mb_type & MB_TYPE_16x16) && !(h->cbp & 15) ? 1 : 4; edges = 4 - 3*((mb_type>>3) & !(h->cbp & 15)); //(mb_type & MB_TYPE_16x16) && !(h->cbp & 15) ? 1 : 4;
h->h264dsp.h264_loop_filter_strength(bS, sl->non_zero_count_cache, sl->ref_cache, sl->mv_cache, h->h264dsp.h264_loop_filter_strength(bS, sl->non_zero_count_cache, sl->ref_cache, sl->mv_cache,
h->list_count==2, edges, step, mask_edge0, mask_edge1, FIELD_PICTURE(h)); sl->list_count==2, edges, step, mask_edge0, mask_edge1, FIELD_PICTURE(h));
} }
if( IS_INTRA(left_type) ) if( IS_INTRA(left_type) )
AV_WN64A(bS[0][0], 0x0004000400040004ULL); AV_WN64A(bS[0][0], 0x0004000400040004ULL);
...@@ -447,7 +447,7 @@ static int check_mv(H264Context *h, H264SliceContext *sl, long b_idx, long bn_id ...@@ -447,7 +447,7 @@ static int check_mv(H264Context *h, H264SliceContext *sl, long b_idx, long bn_id
v = sl->mv_cache[0][b_idx][0] - sl->mv_cache[0][bn_idx][0] + 3 >= 7U | v = sl->mv_cache[0][b_idx][0] - sl->mv_cache[0][bn_idx][0] + 3 >= 7U |
FFABS(sl->mv_cache[0][b_idx][1] - sl->mv_cache[0][bn_idx][1]) >= mvy_limit; FFABS(sl->mv_cache[0][b_idx][1] - sl->mv_cache[0][bn_idx][1]) >= mvy_limit;
if(h->list_count==2){ if (sl->list_count == 2) {
if(!v) if(!v)
v = sl->ref_cache[1][b_idx] != sl->ref_cache[1][bn_idx] | v = sl->ref_cache[1][b_idx] != sl->ref_cache[1][bn_idx] |
sl->mv_cache[1][b_idx][0] - sl->mv_cache[1][bn_idx][0] + 3 >= 7U | sl->mv_cache[1][b_idx][0] - sl->mv_cache[1][bn_idx][0] + 3 >= 7U |
......
...@@ -61,7 +61,7 @@ static inline void get_lowest_part_y(H264Context *h, H264SliceContext *sl, ...@@ -61,7 +61,7 @@ static inline void get_lowest_part_y(H264Context *h, H264SliceContext *sl,
if (list0) { if (list0) {
int ref_n = sl->ref_cache[0][scan8[n]]; int ref_n = sl->ref_cache[0][scan8[n]];
H264Picture *ref = &h->ref_list[0][ref_n]; H264Picture *ref = &sl->ref_list[0][ref_n];
// Error resilience puts the current picture in the ref list. // Error resilience puts the current picture in the ref list.
// Don't try to wait on these as it will cause a deadlock. // Don't try to wait on these as it will cause a deadlock.
...@@ -77,7 +77,7 @@ static inline void get_lowest_part_y(H264Context *h, H264SliceContext *sl, ...@@ -77,7 +77,7 @@ static inline void get_lowest_part_y(H264Context *h, H264SliceContext *sl,
if (list1) { if (list1) {
int ref_n = sl->ref_cache[1][scan8[n]]; int ref_n = sl->ref_cache[1][scan8[n]];
H264Picture *ref = &h->ref_list[1][ref_n]; H264Picture *ref = &sl->ref_list[1][ref_n];
if (ref->tf.progress->data != h->cur_pic.tf.progress->data || if (ref->tf.progress->data != h->cur_pic.tf.progress->data ||
(ref->reference & 3) != h->picture_structure) { (ref->reference & 3) != h->picture_structure) {
...@@ -164,11 +164,11 @@ static void await_references(H264Context *h, H264SliceContext *sl) ...@@ -164,11 +164,11 @@ static void await_references(H264Context *h, H264SliceContext *sl)
} }
} }
for (list = h->list_count - 1; list >= 0; list--) for (list = sl->list_count - 1; list >= 0; list--)
for (ref = 0; ref < 48 && nrefs[list]; ref++) { for (ref = 0; ref < 48 && nrefs[list]; ref++) {
int row = refs[list][ref]; int row = refs[list][ref];
if (row >= 0) { if (row >= 0) {
H264Picture *ref_pic = &h->ref_list[list][ref]; H264Picture *ref_pic = &sl->ref_list[list][ref];
int ref_field = ref_pic->reference - 1; int ref_field = ref_pic->reference - 1;
int ref_field_picture = ref_pic->field_picture; int ref_field_picture = ref_pic->field_picture;
int pic_height = 16 * h->mb_height >> ref_field_picture; int pic_height = 16 * h->mb_height >> ref_field_picture;
...@@ -349,7 +349,7 @@ static av_always_inline void mc_part_std(H264Context *h, H264SliceContext *sl, ...@@ -349,7 +349,7 @@ static av_always_inline void mc_part_std(H264Context *h, H264SliceContext *sl,
y_offset += 8 * (h->mb_y >> MB_FIELD(h)); y_offset += 8 * (h->mb_y >> MB_FIELD(h));
if (list0) { if (list0) {
H264Picture *ref = &h->ref_list[0][sl->ref_cache[0][scan8[n]]]; H264Picture *ref = &sl->ref_list[0][sl->ref_cache[0][scan8[n]]];
mc_dir_part(h, sl, ref, n, square, height, delta, 0, mc_dir_part(h, sl, ref, n, square, height, delta, 0,
dest_y, dest_cb, dest_cr, x_offset, y_offset, dest_y, dest_cb, dest_cr, x_offset, y_offset,
qpix_op, chroma_op, pixel_shift, chroma_idc); qpix_op, chroma_op, pixel_shift, chroma_idc);
...@@ -359,7 +359,7 @@ static av_always_inline void mc_part_std(H264Context *h, H264SliceContext *sl, ...@@ -359,7 +359,7 @@ static av_always_inline void mc_part_std(H264Context *h, H264SliceContext *sl,
} }
if (list1) { if (list1) {
H264Picture *ref = &h->ref_list[1][sl->ref_cache[1][scan8[n]]]; H264Picture *ref = &sl->ref_list[1][sl->ref_cache[1][scan8[n]]];
mc_dir_part(h, sl, ref, n, square, height, delta, 1, mc_dir_part(h, sl, ref, n, square, height, delta, 1,
dest_y, dest_cb, dest_cr, x_offset, y_offset, dest_y, dest_cb, dest_cr, x_offset, y_offset,
qpix_op, chroma_op, pixel_shift, chroma_idc); qpix_op, chroma_op, pixel_shift, chroma_idc);
...@@ -411,11 +411,11 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext * ...@@ -411,11 +411,11 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext *
int refn0 = sl->ref_cache[0][scan8[n]]; int refn0 = sl->ref_cache[0][scan8[n]];
int refn1 = sl->ref_cache[1][scan8[n]]; int refn1 = sl->ref_cache[1][scan8[n]];
mc_dir_part(h, sl, &h->ref_list[0][refn0], n, square, height, delta, 0, mc_dir_part(h, sl, &sl->ref_list[0][refn0], n, square, height, delta, 0,
dest_y, dest_cb, dest_cr, dest_y, dest_cb, dest_cr,
x_offset, y_offset, qpix_put, chroma_put, x_offset, y_offset, qpix_put, chroma_put,
pixel_shift, chroma_idc); pixel_shift, chroma_idc);
mc_dir_part(h, sl, &h->ref_list[1][refn1], n, square, height, delta, 1, mc_dir_part(h, sl, &sl->ref_list[1][refn1], n, square, height, delta, 1,
tmp_y, tmp_cb, tmp_cr, tmp_y, tmp_cb, tmp_cr,
x_offset, y_offset, qpix_put, chroma_put, x_offset, y_offset, qpix_put, chroma_put,
pixel_shift, chroma_idc); pixel_shift, chroma_idc);
...@@ -452,7 +452,7 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext * ...@@ -452,7 +452,7 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext *
} else { } else {
int list = list1 ? 1 : 0; int list = list1 ? 1 : 0;
int refn = sl->ref_cache[list][scan8[n]]; int refn = sl->ref_cache[list][scan8[n]];
H264Picture *ref = &h->ref_list[list][refn]; H264Picture *ref = &sl->ref_list[list][refn];
mc_dir_part(h, sl, ref, n, square, height, delta, list, mc_dir_part(h, sl, ref, n, square, height, delta, list,
dest_y, dest_cb, dest_cr, x_offset, y_offset, dest_y, dest_cb, dest_cr, x_offset, y_offset,
qpix_put, chroma_put, pixel_shift, chroma_idc); qpix_put, chroma_put, pixel_shift, chroma_idc);
...@@ -484,7 +484,7 @@ static av_always_inline void prefetch_motion(H264Context *h, H264SliceContext *s ...@@ -484,7 +484,7 @@ static av_always_inline void prefetch_motion(H264Context *h, H264SliceContext *s
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 * h->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 * h->mb_y;
uint8_t **src = h->ref_list[list][refn].f.data; uint8_t **src = sl->ref_list[list][refn].f.data;
int off = (mx << pixel_shift) + int off = (mx << pixel_shift) +
(my + (h->mb_x & 3) * 4) * sl->mb_linesize + (my + (h->mb_x & 3) * 4) * sl->mb_linesize +
(64 << pixel_shift); (64 << pixel_shift);
......
...@@ -64,7 +64,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) ...@@ -64,7 +64,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
h->vdsp.prefetch(dest_y + (h->mb_x & 3) * 4 * h->linesize + (64 << PIXEL_SHIFT), h->linesize, 4); h->vdsp.prefetch(dest_y + (h->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 + (h->mb_x & 7) * h->uvlinesize + (64 << PIXEL_SHIFT), dest_cr - dest_cb, 2);
h->list_counts[mb_xy] = h->list_count; h->list_counts[mb_xy] = sl->list_count;
if (!SIMPLE && MB_FIELD(h)) { if (!SIMPLE && MB_FIELD(h)) {
linesize = sl->mb_linesize = h->linesize * 2; linesize = sl->mb_linesize = h->linesize * 2;
...@@ -77,7 +77,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) ...@@ -77,7 +77,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
} }
if (FRAME_MBAFF(h)) { if (FRAME_MBAFF(h)) {
int list; int list;
for (list = 0; list < h->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
if (!USES_LIST(mb_type, list)) if (!USES_LIST(mb_type, list))
continue; continue;
if (IS_16X16(mb_type)) { if (IS_16X16(mb_type)) {
...@@ -292,7 +292,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext ...@@ -292,7 +292,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext
h->linesize, 4); h->linesize, 4);
} }
h->list_counts[mb_xy] = h->list_count; h->list_counts[mb_xy] = sl->list_count;
if (!SIMPLE && MB_FIELD(h)) { if (!SIMPLE && MB_FIELD(h)) {
linesize = sl->mb_linesize = sl->mb_uvlinesize = h->linesize * 2; linesize = sl->mb_linesize = sl->mb_uvlinesize = h->linesize * 2;
...@@ -302,7 +302,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext ...@@ -302,7 +302,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext
dest[p] -= h->linesize * 15; dest[p] -= h->linesize * 15;
if (FRAME_MBAFF(h)) { if (FRAME_MBAFF(h)) {
int list; int list;
for (list = 0; list < h->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
if (!USES_LIST(mb_type, list)) if (!USES_LIST(mb_type, list))
continue; continue;
if (IS_16X16(mb_type)) { if (IS_16X16(mb_type)) {
......
...@@ -606,7 +606,7 @@ static void fill_decode_caches(H264Context *h, H264SliceContext *sl, int mb_type ...@@ -606,7 +606,7 @@ static void fill_decode_caches(H264Context *h, H264SliceContext *sl, int mb_type
if (IS_INTER(mb_type) || (IS_DIRECT(mb_type) && sl->direct_spatial_mv_pred)) { if (IS_INTER(mb_type) || (IS_DIRECT(mb_type) && sl->direct_spatial_mv_pred)) {
int list; int list;
int b_stride = h->b_stride; int b_stride = h->b_stride;
for (list = 0; list < h->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
int8_t *ref_cache = &sl->ref_cache[list][scan8[0]]; int8_t *ref_cache = &sl->ref_cache[list][scan8[0]];
int8_t *ref = h->cur_pic.ref_index[list]; int8_t *ref = h->cur_pic.ref_index[list];
int16_t(*mv_cache)[2] = &sl->mv_cache[list][scan8[0]]; int16_t(*mv_cache)[2] = &sl->mv_cache[list][scan8[0]];
......
...@@ -114,7 +114,7 @@ static int scan_mmco_reset(AVCodecParserContext *s) ...@@ -114,7 +114,7 @@ static int scan_mmco_reset(AVCodecParserContext *s)
if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
int list; int list;
for (list = 0; list < h->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
if (get_bits1(&h->gb)) { if (get_bits1(&h->gb)) {
int index; int index;
for (index = 0; ; index++) { for (index = 0; ; index++) {
...@@ -130,7 +130,7 @@ static int scan_mmco_reset(AVCodecParserContext *s) ...@@ -130,7 +130,7 @@ static int scan_mmco_reset(AVCodecParserContext *s)
} else } else
break; break;
if (index >= h->ref_count[list]) { if (index >= sl->ref_count[list]) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"reference count %d overflow\n", index); "reference count %d overflow\n", index);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
......
...@@ -144,7 +144,7 @@ static void h264_set_erpic(ERPicture *dst, H264Picture *src) ...@@ -144,7 +144,7 @@ static void h264_set_erpic(ERPicture *dst, H264Picture *src)
} }
#endif /* CONFIG_ERROR_RESILIENCE */ #endif /* CONFIG_ERROR_RESILIENCE */
int ff_h264_field_end(H264Context *h, int in_setup) int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
{ {
AVCodecContext *const avctx = h->avctx; AVCodecContext *const avctx = h->avctx;
int err = 0; int err = 0;
...@@ -187,9 +187,9 @@ int ff_h264_field_end(H264Context *h, int in_setup) ...@@ -187,9 +187,9 @@ int ff_h264_field_end(H264Context *h, int in_setup)
if (!FIELD_PICTURE(h)) { if (!FIELD_PICTURE(h)) {
h264_set_erpic(&h->er.cur_pic, h->cur_pic_ptr); h264_set_erpic(&h->er.cur_pic, h->cur_pic_ptr);
h264_set_erpic(&h->er.last_pic, h264_set_erpic(&h->er.last_pic,
h->ref_count[0] ? &h->ref_list[0][0] : NULL); sl->ref_count[0] ? &sl->ref_list[0][0] : NULL);
h264_set_erpic(&h->er.next_pic, h264_set_erpic(&h->er.next_pic,
h->ref_count[1] ? &h->ref_list[1][0] : NULL); sl->ref_count[1] ? &sl->ref_list[1][0] : NULL);
ff_er_frame_end(&h->er); ff_er_frame_end(&h->er);
} }
#endif /* CONFIG_ERROR_RESILIENCE */ #endif /* CONFIG_ERROR_RESILIENCE */
......
...@@ -141,8 +141,8 @@ int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl) ...@@ -141,8 +141,8 @@ int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl)
FF_ARRAY_ELEMS(h->default_ref_list[0]) - len, FF_ARRAY_ELEMS(h->default_ref_list[0]) - len,
h->long_ref, 16, 1, h->picture_structure); h->long_ref, 16, 1, h->picture_structure);
if (len < h->ref_count[list]) if (len < sl->ref_count[list])
memset(&h->default_ref_list[list][len], 0, sizeof(H264Picture) * (h->ref_count[list] - len)); memset(&h->default_ref_list[list][len], 0, sizeof(H264Picture) * (sl->ref_count[list] - len));
lens[list] = len; lens[list] = len;
} }
...@@ -164,18 +164,18 @@ int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl) ...@@ -164,18 +164,18 @@ int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl)
FF_ARRAY_ELEMS(h->default_ref_list[0]) - len, FF_ARRAY_ELEMS(h->default_ref_list[0]) - len,
h-> long_ref, 16, 1, h->picture_structure); h-> long_ref, 16, 1, h->picture_structure);
if (len < h->ref_count[0]) if (len < sl->ref_count[0])
memset(&h->default_ref_list[0][len], 0, sizeof(H264Picture) * (h->ref_count[0] - len)); memset(&h->default_ref_list[0][len], 0, sizeof(H264Picture) * (sl->ref_count[0] - len));
} }
#ifdef TRACE #ifdef TRACE
for (i = 0; i < h->ref_count[0]; i++) { for (i = 0; i < sl->ref_count[0]; i++) {
tprintf(h->avctx, "List0: %s fn:%d 0x%p\n", tprintf(h->avctx, "List0: %s fn:%d 0x%p\n",
(h->default_ref_list[0][i].long_ref ? "LT" : "ST"), (h->default_ref_list[0][i].long_ref ? "LT" : "ST"),
h->default_ref_list[0][i].pic_id, h->default_ref_list[0][i].pic_id,
h->default_ref_list[0][i].f.data[0]); h->default_ref_list[0][i].f.data[0]);
} }
if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
for (i = 0; i < h->ref_count[1]; i++) { for (i = 0; i < sl->ref_count[1]; i++) {
tprintf(h->avctx, "List1: %s fn:%d 0x%p\n", tprintf(h->avctx, "List1: %s fn:%d 0x%p\n",
(h->default_ref_list[1][i].long_ref ? "LT" : "ST"), (h->default_ref_list[1][i].long_ref ? "LT" : "ST"),
h->default_ref_list[1][i].pic_id, h->default_ref_list[1][i].pic_id,
...@@ -212,16 +212,16 @@ static int pic_num_extract(H264Context *h, int pic_num, int *structure) ...@@ -212,16 +212,16 @@ static int pic_num_extract(H264Context *h, int pic_num, int *structure)
return pic_num; return pic_num;
} }
int ff_h264_decode_ref_pic_list_reordering(H264Context *h) int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl)
{ {
int list, index, pic_structure, i; int list, index, pic_structure, i;
print_short_term(h); print_short_term(h);
print_long_term(h); print_long_term(h);
for (list = 0; list < h->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
for (i = 0; i < h->ref_count[list]; i++) for (i = 0; i < sl->ref_count[list]; i++)
COPY_PICTURE(&h->ref_list[list][i], &h->default_ref_list[list][i]); COPY_PICTURE(&sl->ref_list[list][i], &h->default_ref_list[list][i]);
if (get_bits1(&h->gb)) { // ref_pic_list_modification_flag_l[01] if (get_bits1(&h->gb)) { // ref_pic_list_modification_flag_l[01]
int pred = h->curr_pic_num; int pred = h->curr_pic_num;
...@@ -235,7 +235,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h) ...@@ -235,7 +235,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
if (modification_of_pic_nums_idc == 3) if (modification_of_pic_nums_idc == 3)
break; break;
if (index >= h->ref_count[list]) { if (index >= sl->ref_count[list]) {
av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n"); av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n");
return -1; return -1;
} }
...@@ -304,30 +304,30 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h) ...@@ -304,30 +304,30 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
if (i < 0) { if (i < 0) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"reference picture missing during reorder\n"); "reference picture missing during reorder\n");
memset(&h->ref_list[list][index], 0, sizeof(H264Picture)); // FIXME memset(&sl->ref_list[list][index], 0, sizeof(H264Picture)); // FIXME
} else { } else {
for (i = index; i + 1 < h->ref_count[list]; i++) { for (i = index; i + 1 < sl->ref_count[list]; i++) {
if (ref->long_ref == h->ref_list[list][i].long_ref && if (ref->long_ref == sl->ref_list[list][i].long_ref &&
ref->pic_id == h->ref_list[list][i].pic_id) ref->pic_id == sl->ref_list[list][i].pic_id)
break; break;
} }
for (; i > index; i--) { for (; i > index; i--) {
COPY_PICTURE(&h->ref_list[list][i], &h->ref_list[list][i - 1]); COPY_PICTURE(&sl->ref_list[list][i], &sl->ref_list[list][i - 1]);
} }
COPY_PICTURE(&h->ref_list[list][index], ref); COPY_PICTURE(&sl->ref_list[list][index], ref);
if (FIELD_PICTURE(h)) { if (FIELD_PICTURE(h)) {
pic_as_field(&h->ref_list[list][index], pic_structure); pic_as_field(&sl->ref_list[list][index], pic_structure);
} }
} }
} }
} }
} }
for (list = 0; list < h->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
for (index = 0; index < h->ref_count[list]; index++) { for (index = 0; index < sl->ref_count[list]; index++) {
if (!h->ref_list[list][index].f.buf[0]) { if (!sl->ref_list[list][index].f.buf[0]) {
av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture\n"); av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture\n");
if (h->default_ref_list[list][0].f.buf[0]) if (h->default_ref_list[list][0].f.buf[0])
COPY_PICTURE(&h->ref_list[list][index], &h->default_ref_list[list][0]); COPY_PICTURE(&sl->ref_list[list][index], &h->default_ref_list[list][0]);
else else
return -1; return -1;
} }
...@@ -341,9 +341,9 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h, H264SliceContext *sl) ...@@ -341,9 +341,9 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h, H264SliceContext *sl)
{ {
int list, i, j; int list, i, j;
for (list = 0; list < 2; list++) { //FIXME try list_count for (list = 0; list < 2; list++) { //FIXME try list_count
for (i = 0; i < h->ref_count[list]; i++) { for (i = 0; i < sl->ref_count[list]; i++) {
H264Picture *frame = &h->ref_list[list][i]; H264Picture *frame = &sl->ref_list[list][i];
H264Picture *field = &h->ref_list[list][16 + 2 * i]; H264Picture *field = &sl->ref_list[list][16 + 2 * i];
COPY_PICTURE(field, frame); COPY_PICTURE(field, frame);
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
field[0].f.linesize[j] <<= 1; field[0].f.linesize[j] <<= 1;
......
This diff is collapsed.
...@@ -198,7 +198,7 @@ static void fill_vaapi_plain_pred_weight_table(H264Context *h, ...@@ -198,7 +198,7 @@ static void fill_vaapi_plain_pred_weight_table(H264Context *h,
*luma_weight_flag = sl->luma_weight_flag[list]; *luma_weight_flag = sl->luma_weight_flag[list];
*chroma_weight_flag = sl->chroma_weight_flag[list]; *chroma_weight_flag = sl->chroma_weight_flag[list];
for (i = 0; i < h->ref_count[list]; i++) { for (i = 0; i < sl->ref_count[list]; i++) {
/* VA API also wants the inferred (default) values, not /* VA API also wants the inferred (default) values, not
only what is available in the bitstream (7.4.3.2). */ only what is available in the bitstream (7.4.3.2). */
if (sl->luma_weight_flag[list]) { if (sl->luma_weight_flag[list]) {
...@@ -293,6 +293,7 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx) ...@@ -293,6 +293,7 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
{ {
struct vaapi_context * const vactx = avctx->hwaccel_context; struct vaapi_context * const vactx = avctx->hwaccel_context;
H264Context * const h = avctx->priv_data; H264Context * const h = avctx->priv_data;
H264SliceContext *sl = &h->slice_ctx[0];
int ret; int ret;
av_dlog(avctx, "vaapi_h264_end_frame()\n"); av_dlog(avctx, "vaapi_h264_end_frame()\n");
...@@ -304,7 +305,7 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx) ...@@ -304,7 +305,7 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
if (ret < 0) if (ret < 0)
goto finish; goto finish;
ff_h264_draw_horiz_band(h, 0, h->avctx->height); ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
finish: finish:
ff_vaapi_common_end_frame(avctx); ff_vaapi_common_end_frame(avctx);
...@@ -331,8 +332,8 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx, ...@@ -331,8 +332,8 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
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 = (h->mb_y >> FIELD_OR_MBAFF_PICTURE(h)) * h->mb_width + h->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 = h->list_count > 0 ? h->ref_count[0] - 1 : 0; slice_param->num_ref_idx_l0_active_minus1 = sl->list_count > 0 ? sl->ref_count[0] - 1 : 0;
slice_param->num_ref_idx_l1_active_minus1 = h->list_count > 1 ? h->ref_count[1] - 1 : 0; slice_param->num_ref_idx_l1_active_minus1 = sl->list_count > 1 ? sl->ref_count[1] - 1 : 0;
slice_param->cabac_init_idc = h->cabac_init_idc; slice_param->cabac_init_idc = h->cabac_init_idc;
slice_param->slice_qp_delta = sl->qscale - h->pps.init_qp; slice_param->slice_qp_delta = sl->qscale - h->pps.init_qp;
slice_param->disable_deblocking_filter_idc = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter; slice_param->disable_deblocking_filter_idc = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter;
...@@ -341,8 +342,8 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx, ...@@ -341,8 +342,8 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
slice_param->luma_log2_weight_denom = sl->luma_log2_weight_denom; slice_param->luma_log2_weight_denom = sl->luma_log2_weight_denom;
slice_param->chroma_log2_weight_denom = sl->chroma_log2_weight_denom; slice_param->chroma_log2_weight_denom = sl->chroma_log2_weight_denom;
fill_vaapi_RefPicList(slice_param->RefPicList0, h->ref_list[0], h->list_count > 0 ? h->ref_count[0] : 0); fill_vaapi_RefPicList(slice_param->RefPicList0, sl->ref_list[0], sl->list_count > 0 ? sl->ref_count[0] : 0);
fill_vaapi_RefPicList(slice_param->RefPicList1, h->ref_list[1], h->list_count > 1 ? h->ref_count[1] : 0); fill_vaapi_RefPicList(slice_param->RefPicList1, sl->ref_list[1], sl->list_count > 1 ? sl->ref_count[1] : 0);
fill_vaapi_plain_pred_weight_table(h, 0, fill_vaapi_plain_pred_weight_table(h, 0,
&slice_param->luma_weight_l0_flag, slice_param->luma_weight_l0, slice_param->luma_offset_l0, &slice_param->luma_weight_l0_flag, slice_param->luma_weight_l0, slice_param->luma_offset_l0,
......
...@@ -198,6 +198,7 @@ static int vdpau_h264_decode_slice(AVCodecContext *avctx, ...@@ -198,6 +198,7 @@ static int vdpau_h264_decode_slice(AVCodecContext *avctx,
static int vdpau_h264_end_frame(AVCodecContext *avctx) static int vdpau_h264_end_frame(AVCodecContext *avctx)
{ {
H264Context *h = avctx->priv_data; H264Context *h = avctx->priv_data;
H264SliceContext *sl = &h->slice_ctx[0];
H264Picture *pic = h->cur_pic_ptr; H264Picture *pic = h->cur_pic_ptr;
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
int val; int val;
...@@ -206,7 +207,7 @@ static int vdpau_h264_end_frame(AVCodecContext *avctx) ...@@ -206,7 +207,7 @@ static int vdpau_h264_end_frame(AVCodecContext *avctx)
if (val < 0) if (val < 0)
return val; return val;
ff_h264_draw_horiz_band(h, 0, h->avctx->height); ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
return 0; return 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