* commit '95eb35f30513e335990ad0d5dca6ddc318477291': h264: move the ref lists variables into the per-slice context Conflicts: libavcodec/h264.c libavcodec/h264.h libavcodec/h264_cabac.c libavcodec/h264_cavlc.c libavcodec/h264_direct.c libavcodec/h264_mb.c libavcodec/h264_picture.c libavcodec/h264_refs.c libavcodec/h264_slice.c Merged-by: Michael Niedermayer <michaelni@gmx.at>tags/n2.7
| @@ -228,10 +228,10 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice, | |||
| slice->slice_type += 5; | |||
| slice->luma_log2_weight_denom = sl->luma_log2_weight_denom; | |||
| slice->chroma_log2_weight_denom = sl->chroma_log2_weight_denom; | |||
| if (h->list_count > 0) | |||
| slice->num_ref_idx_l0_active_minus1 = h->ref_count[0] - 1; | |||
| if (h->list_count > 1) | |||
| slice->num_ref_idx_l1_active_minus1 = h->ref_count[1] - 1; | |||
| if (sl->list_count > 0) | |||
| slice->num_ref_idx_l0_active_minus1 = sl->ref_count[0] - 1; | |||
| if (sl->list_count > 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_beta_offset_div2 = h->slice_beta_offset / 2; | |||
| slice->Reserved8Bits = 0; | |||
| @@ -239,8 +239,8 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice, | |||
| for (list = 0; list < 2; list++) { | |||
| unsigned i; | |||
| for (i = 0; i < FF_ARRAY_ELEMS(slice->RefPicList[list]); i++) { | |||
| if (list < h->list_count && i < h->ref_count[list]) { | |||
| const H264Picture *r = &h->ref_list[list][i]; | |||
| if (list < sl->list_count && i < sl->ref_count[list]) { | |||
| const H264Picture *r = &sl->ref_list[list][i]; | |||
| unsigned plane; | |||
| unsigned index; | |||
| if (ctx->workaround & FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO) | |||
| @@ -447,6 +447,7 @@ static int dxva2_h264_decode_slice(AVCodecContext *avctx, | |||
| static int dxva2_h264_end_frame(AVCodecContext *avctx) | |||
| { | |||
| H264Context *h = avctx->priv_data; | |||
| H264SliceContext *sl = &h->slice_ctx[0]; | |||
| struct dxva2_picture_context *ctx_pic = | |||
| h->cur_pic_ptr->hwaccel_picture_private; | |||
| int ret; | |||
| @@ -458,7 +459,7 @@ static int dxva2_h264_end_frame(AVCodecContext *avctx) | |||
| &ctx_pic->qm, sizeof(ctx_pic->qm), | |||
| commit_bitstream_and_slice_buffer); | |||
| 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; | |||
| } | |||
| @@ -75,13 +75,13 @@ 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 | |||
| * it for now. If this turns out to have any relevance in | |||
| * practice then correct remapping should be added. */ | |||
| if (ref >= h->ref_count[0]) | |||
| if (ref >= sl->ref_count[0]) | |||
| ref = 0; | |||
| if (!h->ref_list[0][ref].f.data[0]) { | |||
| if (!sl->ref_list[0][ref].f.data[0]) { | |||
| av_log(h->avctx, AV_LOG_DEBUG, "Reference not available for error concealing\n"); | |||
| ref = 0; | |||
| } | |||
| if ((h->ref_list[0][ref].reference&3) != 3) { | |||
| if ((sl->ref_list[0][ref].reference&3) != 3) { | |||
| av_log(h->avctx, AV_LOG_DEBUG, "Reference invalid\n"); | |||
| return; | |||
| } | |||
| @@ -95,11 +95,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]); | |||
| } | |||
| 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; | |||
| 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); | |||
| int vshift = desc->log2_chroma_h; | |||
| const int field_pic = h->picture_structure != PICT_FRAME; | |||
| @@ -1033,7 +1034,7 @@ int ff_pred_weight_table(H264Context *h, H264SliceContext *sl) | |||
| for (list = 0; list < 2; list++) { | |||
| sl->luma_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; | |||
| luma_weight_flag = get_bits1(&h->gb); | |||
| @@ -1117,9 +1118,10 @@ void ff_h264_flush_change(H264Context *h) | |||
| ff_h264_reset_sei(h); | |||
| h->recovery_frame = -1; | |||
| h->frame_recovered = 0; | |||
| h->list_count = 0; | |||
| h->current_slice = 0; | |||
| h->mmco_reset = 1; | |||
| for (i = 0; i < h->nb_slice_ctx; i++) | |||
| h->slice_ctx[i].list_count = 0; | |||
| } | |||
| /* forget old pics after a seek */ | |||
| @@ -1324,8 +1326,8 @@ int ff_set_ref_count(H264Context *h, H264SliceContext *sl) | |||
| if (ref_count[0]-1 > max[0] || ref_count[1]-1 > max[1]){ | |||
| av_log(h->avctx, AV_LOG_ERROR, "reference overflow %u > %u or %u > %u\n", ref_count[0]-1, max[0], ref_count[1]-1, max[1]); | |||
| h->ref_count[0] = h->ref_count[1] = 0; | |||
| h->list_count = 0; | |||
| sl->ref_count[0] = sl->ref_count[1] = 0; | |||
| sl->list_count = 0; | |||
| return AVERROR_INVALIDDATA; | |||
| } | |||
| @@ -1338,12 +1340,12 @@ int ff_set_ref_count(H264Context *h, H264SliceContext *sl) | |||
| ref_count[0] = ref_count[1] = 0; | |||
| } | |||
| if (list_count != h->list_count || | |||
| ref_count[0] != h->ref_count[0] || | |||
| ref_count[1] != h->ref_count[1]) { | |||
| h->ref_count[0] = ref_count[0]; | |||
| h->ref_count[1] = ref_count[1]; | |||
| h->list_count = list_count; | |||
| if (list_count != sl->list_count || | |||
| ref_count[0] != sl->ref_count[0] || | |||
| ref_count[1] != sl->ref_count[1]) { | |||
| sl->ref_count[0] = ref_count[0]; | |||
| sl->ref_count[1] = ref_count[1]; | |||
| sl->list_count = list_count; | |||
| return 1; | |||
| } | |||
| @@ -1701,7 +1703,7 @@ again: | |||
| if (err < 0 || err == SLICE_SKIPED) { | |||
| if (err < 0) | |||
| 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 == SLICE_SINGLETHREAD) { | |||
| /* Slice could not be decoded in parallel mode, copy down | |||
| * NAL unit stuff to context 0 and restart. Note that | |||
| @@ -1875,7 +1877,7 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data, | |||
| if (avctx->flags2 & CODEC_FLAG2_CHUNKS) | |||
| decode_postinit(h, 1); | |||
| ff_h264_field_end(h, 0); | |||
| ff_h264_field_end(h, &h->slice_ctx[0], 0); | |||
| /* Wait for second field. */ | |||
| *got_frame = 0; | |||
| @@ -401,6 +401,17 @@ typedef struct H264SliceContext { | |||
| int map_col_to_list0[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. | |||
| * is 64 if not available. | |||
| @@ -492,16 +503,7 @@ typedef struct H264Context { | |||
| int picture_structure; | |||
| 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 | |||
| 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 | |||
| GetBitContext intra_gb; | |||
| @@ -834,7 +836,7 @@ int ff_h264_alloc_tables(H264Context *h); | |||
| */ | |||
| 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_remove_all_refs(H264Context *h); | |||
| @@ -1148,7 +1150,7 @@ static inline int get_avc_nalsize(H264Context *h, const uint8_t *buf, | |||
| return nalsize; | |||
| } | |||
| 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); | |||
| void ff_h264_unref_picture(H264Context *h, H264Picture *pic); | |||
| @@ -1156,7 +1158,7 @@ void ff_h264_unref_picture(H264Context *h, H264Picture *pic); | |||
| int ff_h264_context_init(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_pred_weight_table(H264Context *h, H264SliceContext *sl); | |||
| int ff_set_ref_count(H264Context *h, H264SliceContext *sl); | |||
| @@ -2051,8 +2051,8 @@ decode_intra_mb: | |||
| return 0; | |||
| } | |||
| local_ref_count[0] = h->ref_count[0] << MB_MBAFF(h); | |||
| local_ref_count[1] = h->ref_count[1] << MB_MBAFF(h); | |||
| local_ref_count[0] = sl->ref_count[0] << MB_MBAFF(h); | |||
| local_ref_count[1] = sl->ref_count[1] << MB_MBAFF(h); | |||
| fill_decode_caches(h, sl, mb_type); | |||
| @@ -2118,7 +2118,7 @@ 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++ ) { | |||
| if(IS_DIRECT(sl->sub_mb_type[i])) continue; | |||
| if(IS_DIR(sl->sub_mb_type[i], 0, list)){ | |||
| @@ -2141,7 +2141,7 @@ decode_intra_mb: | |||
| if(dct8x8_allowed) | |||
| 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++){ | |||
| sl->ref_cache[list][scan8[4 * i]] = sl->ref_cache[list][scan8[4 * i] + 1]; | |||
| if(IS_DIRECT(sl->sub_mb_type[i])){ | |||
| @@ -2205,7 +2205,7 @@ decode_intra_mb: | |||
| } else { | |||
| int list, i; | |||
| 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)){ | |||
| int ref; | |||
| if (local_ref_count[list] > 1) { | |||
| @@ -2219,7 +2219,7 @@ decode_intra_mb: | |||
| 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)){ | |||
| int mx,my,mpx,mpy; | |||
| pred_motion(h, sl, 0, 4, list, sl->ref_cache[list][ scan8[0] ], &mx, &my); | |||
| @@ -2232,7 +2232,7 @@ decode_intra_mb: | |||
| } | |||
| } | |||
| 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++){ | |||
| if(IS_DIR(mb_type, i, list)){ | |||
| int ref; | |||
| @@ -2249,7 +2249,7 @@ decode_intra_mb: | |||
| 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++){ | |||
| if(IS_DIR(mb_type, i, list)){ | |||
| int mx,my,mpx,mpy; | |||
| @@ -2267,7 +2267,7 @@ decode_intra_mb: | |||
| } | |||
| }else{ | |||
| av_assert2(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++){ | |||
| if(IS_DIR(mb_type, i, list)){ //FIXME optimize | |||
| int ref; | |||
| @@ -2284,7 +2284,7 @@ decode_intra_mb: | |||
| 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++){ | |||
| if(IS_DIR(mb_type, i, list)){ | |||
| int mx,my,mpx,mpy; | |||
| @@ -794,8 +794,8 @@ decode_intra_mb: | |||
| return 0; | |||
| } | |||
| local_ref_count[0] = h->ref_count[0] << MB_MBAFF(h); | |||
| local_ref_count[1] = h->ref_count[1] << MB_MBAFF(h); | |||
| local_ref_count[0] = sl->ref_count[0] << MB_MBAFF(h); | |||
| local_ref_count[1] = sl->ref_count[1] << MB_MBAFF(h); | |||
| fill_decode_neighbors(h, sl, mb_type); | |||
| fill_decode_caches(h, sl, mb_type); | |||
| @@ -875,7 +875,7 @@ 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 : local_ref_count[list]; | |||
| for(i=0; i<4; i++){ | |||
| if(IS_DIRECT(sl->sub_mb_type[i])) continue; | |||
| @@ -903,7 +903,7 @@ decode_intra_mb: | |||
| if(dct8x8_allowed) | |||
| 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++){ | |||
| if(IS_DIRECT(sl->sub_mb_type[i])) { | |||
| sl->ref_cache[list][ scan8[4*i] ] = sl->ref_cache[list][ scan8[4*i]+1 ]; | |||
| @@ -953,7 +953,7 @@ decode_intra_mb: | |||
| int list, mx, my, i; | |||
| //FIXME we should set ref_idx_l? to 0 if we use that later ... | |||
| if(IS_16X16(mb_type)){ | |||
| for(list=0; list<h->list_count; list++){ | |||
| for (list = 0; list < sl->list_count; list++) { | |||
| unsigned int val; | |||
| if(IS_DIR(mb_type, 0, list)){ | |||
| if(local_ref_count[list]==1){ | |||
| @@ -970,7 +970,7 @@ decode_intra_mb: | |||
| 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)){ | |||
| pred_motion(h, sl, 0, 4, list, sl->ref_cache[list][ scan8[0] ], &mx, &my); | |||
| mx += get_se_golomb(&h->gb); | |||
| @@ -982,7 +982,7 @@ decode_intra_mb: | |||
| } | |||
| } | |||
| 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++){ | |||
| unsigned int val; | |||
| if(IS_DIR(mb_type, i, list)){ | |||
| @@ -1002,7 +1002,7 @@ decode_intra_mb: | |||
| 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++){ | |||
| unsigned int val; | |||
| if(IS_DIR(mb_type, i, list)){ | |||
| @@ -1019,7 +1019,7 @@ decode_intra_mb: | |||
| } | |||
| }else{ | |||
| av_assert2(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++){ | |||
| unsigned int val; | |||
| if(IS_DIR(mb_type, i, list)){ //FIXME optimize | |||
| @@ -1039,7 +1039,7 @@ decode_intra_mb: | |||
| 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++){ | |||
| unsigned int val; | |||
| if(IS_DIR(mb_type, i, list)){ | |||
| @@ -34,11 +34,12 @@ | |||
| #include <assert.h> | |||
| static int get_scale_factor(H264Context *const h, int poc, int poc1, int i) | |||
| static int get_scale_factor(H264Context *const h, H264SliceContext *sl, | |||
| int poc, int poc1, int i) | |||
| { | |||
| int poc0 = h->ref_list[0][i].poc; | |||
| int poc0 = sl->ref_list[0][i].poc; | |||
| int td = av_clip_int8(poc1 - poc0); | |||
| if (td == 0 || h->ref_list[0][i].long_ref) { | |||
| if (td == 0 || sl->ref_list[0][i].long_ref) { | |||
| return 256; | |||
| } else { | |||
| int tb = av_clip_int8(poc - poc0); | |||
| @@ -52,29 +53,30 @@ void ff_h264_direct_dist_scale_factor(H264Context *const h, | |||
| { | |||
| const int poc = FIELD_PICTURE(h) ? h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD] | |||
| : h->cur_pic_ptr->poc; | |||
| const int poc1 = h->ref_list[1][0].poc; | |||
| const int poc1 = sl->ref_list[1][0].poc; | |||
| int i, field; | |||
| if (FRAME_MBAFF(h)) | |||
| for (field = 0; field < 2; field++) { | |||
| const int poc = h->cur_pic_ptr->field_poc[field]; | |||
| const int poc1 = h->ref_list[1][0].field_poc[field]; | |||
| for (i = 0; i < 2 * h->ref_count[0]; i++) | |||
| const int poc1 = sl->ref_list[1][0].field_poc[field]; | |||
| for (i = 0; i < 2 * sl->ref_count[0]; i++) | |||
| sl->dist_scale_factor_field[field][i ^ field] = | |||
| get_scale_factor(h, poc, poc1, i + 16); | |||
| get_scale_factor(h, sl, poc, poc1, i + 16); | |||
| } | |||
| for (i = 0; i < h->ref_count[0]; i++) | |||
| sl->dist_scale_factor[i] = get_scale_factor(h, poc, poc1, i); | |||
| for (i = 0; i < sl->ref_count[0]; i++) | |||
| sl->dist_scale_factor[i] = get_scale_factor(h, sl, poc, poc1, i); | |||
| } | |||
| static void fill_colmap(H264Context *h, int map[2][16 + 32], int list, | |||
| static void fill_colmap(H264Context *h, H264SliceContext *sl, | |||
| int map[2][16 + 32], int list, | |||
| int field, int colfield, int mbafi) | |||
| { | |||
| H264Picture *const ref1 = &h->ref_list[1][0]; | |||
| H264Picture *const ref1 = &sl->ref_list[1][0]; | |||
| int j, old_ref, rfield; | |||
| int start = mbafi ? 16 : 0; | |||
| int end = mbafi ? 16 + 2 * h->ref_count[0] : h->ref_count[0]; | |||
| int end = mbafi ? 16 + 2 * sl->ref_count[0] : sl->ref_count[0]; | |||
| int interl = mbafi || h->picture_structure != PICT_FRAME; | |||
| /* bogus; fills in for missing frames */ | |||
| @@ -91,8 +93,8 @@ static void fill_colmap(H264Context *h, int map[2][16 + 32], int list, | |||
| poc = (poc & ~3) + rfield + 1; | |||
| for (j = start; j < end; j++) { | |||
| if (4 * h->ref_list[0][j].frame_num + | |||
| (h->ref_list[0][j].reference & 3) == poc) { | |||
| if (4 * sl->ref_list[0][j].frame_num + | |||
| (sl->ref_list[0][j].reference & 3) == poc) { | |||
| int cur_ref = mbafi ? (j - 16) ^ field : j; | |||
| if (ref1->mbaff) | |||
| map[list][2 * old_ref + (rfield ^ field) + 16] = cur_ref; | |||
| @@ -107,17 +109,17 @@ static void fill_colmap(H264Context *h, int map[2][16 + 32], int list, | |||
| void ff_h264_direct_ref_list_init(H264Context *const h, H264SliceContext *sl) | |||
| { | |||
| H264Picture *const ref1 = &h->ref_list[1][0]; | |||
| H264Picture *const ref1 = &sl->ref_list[1][0]; | |||
| H264Picture *const cur = h->cur_pic_ptr; | |||
| int list, j, field; | |||
| int sidx = (h->picture_structure & 1) ^ 1; | |||
| int ref1sidx = (ref1->reference & 1) ^ 1; | |||
| for (list = 0; list < 2; list++) { | |||
| cur->ref_count[sidx][list] = h->ref_count[list]; | |||
| for (j = 0; j < h->ref_count[list]; j++) | |||
| cur->ref_poc[sidx][list][j] = 4 * h->ref_list[list][j].frame_num + | |||
| (h->ref_list[list][j].reference & 3); | |||
| cur->ref_count[sidx][list] = sl->ref_count[list]; | |||
| for (j = 0; j < sl->ref_count[list]; j++) | |||
| cur->ref_poc[sidx][list][j] = 4 * sl->ref_list[list][j].frame_num + | |||
| (sl->ref_list[list][j].reference & 3); | |||
| } | |||
| if (h->picture_structure == PICT_FRAME) { | |||
| @@ -130,25 +132,25 @@ void ff_h264_direct_ref_list_init(H264Context *const h, H264SliceContext *sl) | |||
| sl->col_fieldoff = 0; | |||
| if (h->picture_structure == PICT_FRAME) { | |||
| int cur_poc = h->cur_pic_ptr->poc; | |||
| int *col_poc = h->ref_list[1]->field_poc; | |||
| int *col_poc = sl->ref_list[1]->field_poc; | |||
| sl->col_parity = (FFABS(col_poc[0] - cur_poc) >= | |||
| FFABS(col_poc[1] - cur_poc)); | |||
| ref1sidx = | |||
| sidx = sl->col_parity; | |||
| // FL -> FL & differ parity | |||
| } else if (!(h->picture_structure & h->ref_list[1][0].reference) && | |||
| !h->ref_list[1][0].mbaff) { | |||
| sl->col_fieldoff = 2 * h->ref_list[1][0].reference - 3; | |||
| } else if (!(h->picture_structure & sl->ref_list[1][0].reference) && | |||
| !sl->ref_list[1][0].mbaff) { | |||
| sl->col_fieldoff = 2 * sl->ref_list[1][0].reference - 3; | |||
| } | |||
| if (sl->slice_type_nos != AV_PICTURE_TYPE_B || sl->direct_spatial_mv_pred) | |||
| return; | |||
| for (list = 0; list < 2; list++) { | |||
| fill_colmap(h, sl->map_col_to_list0, list, sidx, ref1sidx, 0); | |||
| fill_colmap(h, sl, sl->map_col_to_list0, list, sidx, ref1sidx, 0); | |||
| if (FRAME_MBAFF(h)) | |||
| for (field = 0; field < 2; field++) | |||
| fill_colmap(h, sl->map_col_to_list0_field[field], list, field, | |||
| fill_colmap(h, sl, sl->map_col_to_list0_field[field], list, field, | |||
| field, 1); | |||
| } | |||
| } | |||
| @@ -188,9 +190,9 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s | |||
| int mv[2]; | |||
| int list; | |||
| assert(h->ref_list[1][0].reference & 3); | |||
| assert(sl->ref_list[1][0].reference & 3); | |||
| await_reference_mb_row(h, &h->ref_list[1][0], | |||
| await_reference_mb_row(h, &sl->ref_list[1][0], | |||
| h->mb_y + !!IS_INTERLACED(*mb_type)); | |||
| #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \ | |||
| @@ -231,7 +233,7 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s | |||
| else | |||
| mv[list] = AV_RN32A(C); | |||
| } | |||
| av_assert2(ref[list] < (h->ref_count[list] << !!FRAME_MBAFF(h))); | |||
| av_assert2(ref[list] < (sl->ref_count[list] << !!FRAME_MBAFF(h))); | |||
| } else { | |||
| int mask = ~(MB_TYPE_L0 << (2 * list)); | |||
| mv[list] = 0; | |||
| @@ -259,7 +261,7 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s | |||
| return; | |||
| } | |||
| if (IS_INTERLACED(h->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 | |||
| mb_y = (h->mb_y & ~1) + sl->col_parity; | |||
| mb_xy = h->mb_x + | |||
| @@ -274,8 +276,8 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s | |||
| if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR | |||
| mb_y = h->mb_y & ~1; | |||
| mb_xy = (h->mb_y & ~1) * h->mb_stride + h->mb_x; | |||
| mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy]; | |||
| mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + h->mb_stride]; | |||
| 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]; | |||
| b8_stride = 2 + 4 * h->mb_stride; | |||
| b4_stride *= 6; | |||
| if (IS_INTERLACED(mb_type_col[0]) != | |||
| @@ -295,7 +297,7 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s | |||
| } else { // AFR/FR -> AFR/FR | |||
| single_col: | |||
| mb_type_col[0] = | |||
| mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy]; | |||
| mb_type_col[1] = sl->ref_list[1][0].mb_type[mb_xy]; | |||
| sub_mb_type |= MB_TYPE_16x16 | MB_TYPE_DIRECT2; /* B_SUB_8x8 */ | |||
| if (!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)) { | |||
| @@ -315,12 +317,12 @@ single_col: | |||
| } | |||
| } | |||
| await_reference_mb_row(h, &h->ref_list[1][0], mb_y); | |||
| await_reference_mb_row(h, &sl->ref_list[1][0], mb_y); | |||
| l1mv0 = (void*)&h->ref_list[1][0].motion_val[0][h->mb2b_xy[mb_xy]]; | |||
| l1mv1 = (void*)&h->ref_list[1][0].motion_val[1][h->mb2b_xy[mb_xy]]; | |||
| l1ref0 = &h->ref_list[1][0].ref_index[0][4 * mb_xy]; | |||
| l1ref1 = &h->ref_list[1][0].ref_index[1][4 * mb_xy]; | |||
| l1mv0 = (void*)&sl->ref_list[1][0].motion_val[0][h->mb2b_xy[mb_xy]]; | |||
| l1mv1 = (void*)&sl->ref_list[1][0].motion_val[1][h->mb2b_xy[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]; | |||
| if (!b8_stride) { | |||
| if (h->mb_y & 1) { | |||
| l1ref0 += 2; | |||
| @@ -347,7 +349,7 @@ single_col: | |||
| (uint8_t)ref[0], 1); | |||
| fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8, | |||
| (uint8_t)ref[1], 1); | |||
| if (!IS_INTRA(mb_type_col[y8]) && !h->ref_list[1][0].long_ref && | |||
| if (!IS_INTRA(mb_type_col[y8]) && !sl->ref_list[1][0].long_ref && | |||
| ((l1ref0[xy8] == 0 && | |||
| FFABS(l1mv0[xy4][0]) <= 1 && | |||
| FFABS(l1mv0[xy4][1]) <= 1) || | |||
| @@ -378,7 +380,7 @@ single_col: | |||
| fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1); | |||
| fill_rectangle(&sl->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1); | |||
| if (!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref && | |||
| if (!IS_INTRA(mb_type_col[0]) && !sl->ref_list[1][0].long_ref && | |||
| ((l1ref0[0] == 0 && | |||
| FFABS(l1mv0[0][0]) <= 1 && | |||
| FFABS(l1mv0[0][1]) <= 1) || | |||
| @@ -416,7 +418,7 @@ single_col: | |||
| assert(b8_stride == 2); | |||
| /* col_zero_flag */ | |||
| if (!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref && | |||
| if (!IS_INTRA(mb_type_col[0]) && !sl->ref_list[1][0].long_ref && | |||
| (l1ref0[i8] == 0 || | |||
| (l1ref0[i8] < 0 && | |||
| l1ref1[i8] == 0 && | |||
| @@ -472,12 +474,12 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl, | |||
| unsigned int sub_mb_type; | |||
| int i8, i4; | |||
| assert(h->ref_list[1][0].reference & 3); | |||
| assert(sl->ref_list[1][0].reference & 3); | |||
| await_reference_mb_row(h, &h->ref_list[1][0], | |||
| await_reference_mb_row(h, &sl->ref_list[1][0], | |||
| h->mb_y + !!IS_INTERLACED(*mb_type)); | |||
| if (IS_INTERLACED(h->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 | |||
| mb_y = (h->mb_y & ~1) + sl->col_parity; | |||
| mb_xy = h->mb_x + | |||
| @@ -492,8 +494,8 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl, | |||
| if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR | |||
| mb_y = h->mb_y & ~1; | |||
| mb_xy = h->mb_x + (h->mb_y & ~1) * h->mb_stride; | |||
| mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy]; | |||
| mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + h->mb_stride]; | |||
| 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]; | |||
| b8_stride = 2 + 4 * h->mb_stride; | |||
| b4_stride *= 6; | |||
| if (IS_INTERLACED(mb_type_col[0]) != | |||
| @@ -516,7 +518,7 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl, | |||
| } else { // AFR/FR -> AFR/FR | |||
| single_col: | |||
| mb_type_col[0] = | |||
| mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy]; | |||
| mb_type_col[1] = sl->ref_list[1][0].mb_type[mb_xy]; | |||
| sub_mb_type = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | | |||
| MB_TYPE_DIRECT2; /* B_SUB_8x8 */ | |||
| @@ -539,12 +541,12 @@ single_col: | |||
| } | |||
| } | |||
| await_reference_mb_row(h, &h->ref_list[1][0], mb_y); | |||
| await_reference_mb_row(h, &sl->ref_list[1][0], mb_y); | |||
| l1mv0 = (void*)&h->ref_list[1][0].motion_val[0][h->mb2b_xy[mb_xy]]; | |||
| l1mv1 = (void*)&h->ref_list[1][0].motion_val[1][h->mb2b_xy[mb_xy]]; | |||
| l1ref0 = &h->ref_list[1][0].ref_index[0][4 * mb_xy]; | |||
| l1ref1 = &h->ref_list[1][0].ref_index[1][4 * mb_xy]; | |||
| l1mv0 = (void*)&sl->ref_list[1][0].motion_val[0][h->mb2b_xy[mb_xy]]; | |||
| l1mv1 = (void*)&sl->ref_list[1][0].motion_val[1][h->mb2b_xy[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]; | |||
| if (!b8_stride) { | |||
| if (h->mb_y & 1) { | |||
| l1ref0 += 2; | |||
| @@ -565,7 +567,7 @@ single_col: | |||
| map_col_to_list0[1] = sl->map_col_to_list0_field[h->mb_y & 1][1]; | |||
| dist_scale_factor = sl->dist_scale_factor_field[h->mb_y & 1]; | |||
| } | |||
| ref_offset = (h->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); | |||
| if (IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])) { | |||
| int y_shift = 2 * !IS_INTERLACED(*mb_type); | |||
| @@ -370,7 +370,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; | |||
| 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->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) ) | |||
| AV_WN64A(bS[0][0], 0x0004000400040004ULL); | |||
| @@ -445,7 +445,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 | | |||
| 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) | |||
| 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 | | |||
| @@ -61,7 +61,7 @@ static inline void get_lowest_part_y(H264Context *h, H264SliceContext *sl, | |||
| if (list0) { | |||
| 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. | |||
| // 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, | |||
| if (list1) { | |||
| 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 || | |||
| (ref->reference & 3) != h->picture_structure) { | |||
| @@ -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++) { | |||
| int row = refs[list][ref]; | |||
| 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_picture = ref_pic->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, | |||
| y_offset += 8 * (h->mb_y >> MB_FIELD(h)); | |||
| 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, | |||
| dest_y, dest_cb, dest_cr, x_offset, y_offset, | |||
| qpix_op, chroma_op, pixel_shift, chroma_idc); | |||
| @@ -359,7 +359,7 @@ static av_always_inline void mc_part_std(H264Context *h, H264SliceContext *sl, | |||
| } | |||
| 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, | |||
| dest_y, dest_cb, dest_cr, x_offset, y_offset, | |||
| qpix_op, chroma_op, pixel_shift, chroma_idc); | |||
| @@ -411,11 +411,11 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext * | |||
| int refn0 = sl->ref_cache[0][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, | |||
| x_offset, y_offset, qpix_put, chroma_put, | |||
| 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, | |||
| x_offset, y_offset, qpix_put, chroma_put, | |||
| pixel_shift, chroma_idc); | |||
| @@ -456,7 +456,7 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext * | |||
| } else { | |||
| int list = list1 ? 1 : 0; | |||
| 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, | |||
| dest_y, dest_cb, dest_cr, x_offset, y_offset, | |||
| qpix_put, chroma_put, pixel_shift, chroma_idc); | |||
| @@ -490,7 +490,7 @@ static av_always_inline void prefetch_motion(H264Context *h, H264SliceContext *s | |||
| if (refn >= 0) { | |||
| 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; | |||
| uint8_t **src = h->ref_list[list][refn].f.data; | |||
| uint8_t **src = sl->ref_list[list][refn].f.data; | |||
| int off = mx * (1<< pixel_shift) + | |||
| (my + (h->mb_x & 3) * 4) * sl->mb_linesize + | |||
| (64 << pixel_shift); | |||
| @@ -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_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)) { | |||
| linesize = sl->mb_linesize = h->linesize * 2; | |||
| @@ -77,7 +77,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) | |||
| } | |||
| if (FRAME_MBAFF(h)) { | |||
| int list; | |||
| for (list = 0; list < h->list_count; list++) { | |||
| for (list = 0; list < sl->list_count; list++) { | |||
| if (!USES_LIST(mb_type, list)) | |||
| continue; | |||
| if (IS_16X16(mb_type)) { | |||
| @@ -289,7 +289,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext | |||
| h->linesize, 4); | |||
| } | |||
| h->list_counts[mb_xy] = h->list_count; | |||
| h->list_counts[mb_xy] = sl->list_count; | |||
| if (!SIMPLE && MB_FIELD(h)) { | |||
| linesize = sl->mb_linesize = sl->mb_uvlinesize = h->linesize * 2; | |||
| @@ -299,7 +299,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext | |||
| dest[p] -= h->linesize * 15; | |||
| if (FRAME_MBAFF(h)) { | |||
| int list; | |||
| for (list = 0; list < h->list_count; list++) { | |||
| for (list = 0; list < sl->list_count; list++) { | |||
| if (!USES_LIST(mb_type, list)) | |||
| continue; | |||
| if (IS_16X16(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)) { | |||
| int list; | |||
| 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 = h->cur_pic.ref_index[list]; | |||
| int16_t(*mv_cache)[2] = &sl->mv_cache[list][scan8[0]]; | |||
| @@ -145,7 +145,7 @@ static int scan_mmco_reset(AVCodecParserContext *s) | |||
| if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { | |||
| int list; | |||
| for (list = 0; list < h->list_count; list++) { | |||
| for (list = 0; list < sl->list_count; list++) { | |||
| if (get_bits1(&h->gb)) { | |||
| int index; | |||
| for (index = 0; ; index++) { | |||
| @@ -161,7 +161,7 @@ static int scan_mmco_reset(AVCodecParserContext *s) | |||
| } else | |||
| break; | |||
| if (index >= h->ref_count[list]) { | |||
| if (index >= sl->ref_count[list]) { | |||
| av_log(h->avctx, AV_LOG_ERROR, | |||
| "reference count %d overflow\n", index); | |||
| return AVERROR_INVALIDDATA; | |||
| @@ -152,7 +152,7 @@ void ff_h264_set_erpic(ERPicture *dst, H264Picture *src) | |||
| #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; | |||
| int err = 0; | |||
| @@ -197,26 +197,26 @@ int ff_h264_field_end(H264Context *h, int in_setup) | |||
| * causes problems for the first MB line, too. | |||
| */ | |||
| if (!FIELD_PICTURE(h) && h->current_slice && !h->sps.new) { | |||
| int use_last_pic = h->last_pic_for_ec.f.buf[0] && !h->ref_count[0]; | |||
| int use_last_pic = h->last_pic_for_ec.f.buf[0] && !sl->ref_count[0]; | |||
| ff_h264_set_erpic(&h->er.cur_pic, h->cur_pic_ptr); | |||
| if (use_last_pic) { | |||
| ff_h264_set_erpic(&h->er.last_pic, &h->last_pic_for_ec); | |||
| COPY_PICTURE(&h->ref_list[0][0], &h->last_pic_for_ec); | |||
| } else if (h->ref_count[0]) { | |||
| ff_h264_set_erpic(&h->er.last_pic, &h->ref_list[0][0]); | |||
| COPY_PICTURE(&sl->ref_list[0][0], &h->last_pic_for_ec); | |||
| } else if (sl->ref_count[0]) { | |||
| ff_h264_set_erpic(&h->er.last_pic, &sl->ref_list[0][0]); | |||
| } else | |||
| ff_h264_set_erpic(&h->er.last_pic, NULL); | |||
| if (h->ref_count[1]) | |||
| ff_h264_set_erpic(&h->er.next_pic, &h->ref_list[1][0]); | |||
| if (sl->ref_count[1]) | |||
| ff_h264_set_erpic(&h->er.next_pic, &sl->ref_list[1][0]); | |||
| h->er.ref_count = h->ref_count[0]; | |||
| h->er.ref_count = sl->ref_count[0]; | |||
| ff_er_frame_end(&h->er); | |||
| if (use_last_pic) | |||
| memset(&h->ref_list[0][0], 0, sizeof(h->last_pic_for_ec)); | |||
| memset(&sl->ref_list[0][0], 0, sizeof(h->last_pic_for_ec)); | |||
| } | |||
| #endif /* CONFIG_ERROR_RESILIENCE */ | |||
| @@ -138,8 +138,8 @@ int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl) | |||
| h->long_ref, 16, 1, h->picture_structure); | |||
| av_assert0(len <= 32); | |||
| if (len < h->ref_count[list]) | |||
| memset(&h->default_ref_list[list][len], 0, sizeof(H264Picture) * (h->ref_count[list] - len)); | |||
| if (len < sl->ref_count[list]) | |||
| memset(&h->default_ref_list[list][len], 0, sizeof(H264Picture) * (sl->ref_count[list] - len)); | |||
| lens[list] = len; | |||
| } | |||
| @@ -162,18 +162,18 @@ int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl) | |||
| h-> long_ref, 16, 1, h->picture_structure); | |||
| av_assert0(len <= 32); | |||
| if (len < h->ref_count[0]) | |||
| memset(&h->default_ref_list[0][len], 0, sizeof(H264Picture) * (h->ref_count[0] - len)); | |||
| if (len < sl->ref_count[0]) | |||
| memset(&h->default_ref_list[0][len], 0, sizeof(H264Picture) * (sl->ref_count[0] - len)); | |||
| } | |||
| #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", | |||
| (h->default_ref_list[0][i].long_ref ? "LT" : "ST"), | |||
| h->default_ref_list[0][i].pic_id, | |||
| h->default_ref_list[0][i].f.data[0]); | |||
| } | |||
| 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", | |||
| (h->default_ref_list[1][i].long_ref ? "LT" : "ST"), | |||
| h->default_ref_list[1][i].pic_id, | |||
| @@ -210,16 +210,16 @@ static int pic_num_extract(H264Context *h, int pic_num, int *structure) | |||
| 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; | |||
| print_short_term(h); | |||
| print_long_term(h); | |||
| for (list = 0; list < h->list_count; list++) { | |||
| for (i = 0; i < h->ref_count[list]; i++) | |||
| COPY_PICTURE(&h->ref_list[list][i], &h->default_ref_list[list][i]); | |||
| for (list = 0; list < sl->list_count; list++) { | |||
| for (i = 0; i < sl->ref_count[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] | |||
| int pred = h->curr_pic_num; | |||
| @@ -233,7 +233,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h) | |||
| if (modification_of_pic_nums_idc == 3) | |||
| break; | |||
| if (index >= h->ref_count[list]) { | |||
| if (index >= sl->ref_count[list]) { | |||
| av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n"); | |||
| return -1; | |||
| } | |||
| @@ -302,39 +302,39 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h) | |||
| if (i < 0) { | |||
| av_log(h->avctx, AV_LOG_ERROR, | |||
| "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 { | |||
| for (i = index; i + 1 < h->ref_count[list]; i++) { | |||
| if (ref->long_ref == h->ref_list[list][i].long_ref && | |||
| ref->pic_id == h->ref_list[list][i].pic_id) | |||
| for (i = index; i + 1 < sl->ref_count[list]; i++) { | |||
| if (ref->long_ref == sl->ref_list[list][i].long_ref && | |||
| ref->pic_id == sl->ref_list[list][i].pic_id) | |||
| break; | |||
| } | |||
| 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)) { | |||
| 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 (index = 0; index < h->ref_count[list]; index++) { | |||
| if ( !h->ref_list[list][index].f.buf[0] | |||
| || (!FIELD_PICTURE(h) && (h->ref_list[list][index].reference&3) != 3)) { | |||
| for (list = 0; list < sl->list_count; list++) { | |||
| for (index = 0; index < sl->ref_count[list]; index++) { | |||
| if ( !sl->ref_list[list][index].f.buf[0] | |||
| || (!FIELD_PICTURE(h) && (sl->ref_list[list][index].reference&3) != 3)) { | |||
| int i; | |||
| av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc); | |||
| for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++) | |||
| h->last_pocs[i] = INT_MIN; | |||
| if (h->default_ref_list[list][0].f.buf[0] | |||
| && !(!FIELD_PICTURE(h) && (h->default_ref_list[list][0].reference&3) != 3)) | |||
| 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 | |||
| return -1; | |||
| } | |||
| av_assert0(av_buffer_get_ref_count(h->ref_list[list][index].f.buf[0]) > 0); | |||
| av_assert0(av_buffer_get_ref_count(sl->ref_list[list][index].f.buf[0]) > 0); | |||
| } | |||
| } | |||
| @@ -344,10 +344,10 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h) | |||
| void ff_h264_fill_mbaff_ref_list(H264Context *h, H264SliceContext *sl) | |||
| { | |||
| int list, i, j; | |||
| for (list = 0; list < h->list_count; list++) { | |||
| for (i = 0; i < h->ref_count[list]; i++) { | |||
| H264Picture *frame = &h->ref_list[list][i]; | |||
| H264Picture *field = &h->ref_list[list][16 + 2 * i]; | |||
| for (list = 0; list < sl->list_count; list++) { | |||
| for (i = 0; i < sl->ref_count[list]; i++) { | |||
| H264Picture *frame = &sl->ref_list[list][i]; | |||
| H264Picture *field = &sl->ref_list[list][16 + 2 * i]; | |||
| COPY_PICTURE(field, frame); | |||
| for (j = 0; j < 3; j++) | |||
| field[0].f.linesize[j] <<= 1; | |||
| @@ -498,7 +498,8 @@ void ff_h264_remove_all_refs(H264Context *h) | |||
| h->short_ref_count = 0; | |||
| memset(h->default_ref_list, 0, sizeof(h->default_ref_list)); | |||
| memset(h->ref_list, 0, sizeof(h->ref_list)); | |||
| for (i = 0; i < h->nb_slice_ctx; i++) | |||
| memset(h->slice_ctx[i].ref_list, 0, sizeof(h->slice_ctx[i].ref_list)); | |||
| } | |||
| /** | |||
| @@ -897,20 +897,20 @@ static void implicit_weight_table(H264Context *h, H264SliceContext *sl, int fiel | |||
| } else { | |||
| cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure - 1]; | |||
| } | |||
| if (h->ref_count[0] == 1 && h->ref_count[1] == 1 && !FRAME_MBAFF(h) && | |||
| h->ref_list[0][0].poc + h->ref_list[1][0].poc == 2 * cur_poc) { | |||
| if (sl->ref_count[0] == 1 && sl->ref_count[1] == 1 && !FRAME_MBAFF(h) && | |||
| sl->ref_list[0][0].poc + sl->ref_list[1][0].poc == 2 * cur_poc) { | |||
| sl->use_weight = 0; | |||
| sl->use_weight_chroma = 0; | |||
| return; | |||
| } | |||
| ref_start = 0; | |||
| ref_count0 = h->ref_count[0]; | |||
| ref_count1 = h->ref_count[1]; | |||
| ref_count0 = sl->ref_count[0]; | |||
| ref_count1 = sl->ref_count[1]; | |||
| } else { | |||
| cur_poc = h->cur_pic_ptr->field_poc[field]; | |||
| ref_start = 16; | |||
| ref_count0 = 16 + 2 * h->ref_count[0]; | |||
| ref_count1 = 16 + 2 * h->ref_count[1]; | |||
| ref_count0 = 16 + 2 * sl->ref_count[0]; | |||
| ref_count1 = 16 + 2 * sl->ref_count[1]; | |||
| } | |||
| sl->use_weight = 2; | |||
| @@ -919,11 +919,11 @@ static void implicit_weight_table(H264Context *h, H264SliceContext *sl, int fiel | |||
| sl->chroma_log2_weight_denom = 5; | |||
| for (ref0 = ref_start; ref0 < ref_count0; ref0++) { | |||
| int poc0 = h->ref_list[0][ref0].poc; | |||
| int poc0 = sl->ref_list[0][ref0].poc; | |||
| for (ref1 = ref_start; ref1 < ref_count1; ref1++) { | |||
| int w = 32; | |||
| if (!h->ref_list[0][ref0].long_ref && !h->ref_list[1][ref1].long_ref) { | |||
| int poc1 = h->ref_list[1][ref1].poc; | |||
| if (!sl->ref_list[0][ref0].long_ref && !sl->ref_list[1][ref1].long_ref) { | |||
| int poc1 = sl->ref_list[1][ref1].poc; | |||
| int td = av_clip_int8(poc1 - poc0); | |||
| if (td) { | |||
| int tb = av_clip_int8(cur_poc - poc0); | |||
| @@ -1304,7 +1304,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex | |||
| if (first_mb_in_slice == 0) { // FIXME better field boundary detection | |||
| if (h0->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) { | |||
| ff_h264_field_end(h, 1); | |||
| ff_h264_field_end(h, sl, 1); | |||
| } | |||
| h0->current_slice = 0; | |||
| @@ -1801,15 +1801,15 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex | |||
| if (slice_type != AV_PICTURE_TYPE_I && | |||
| (h0->current_slice == 0 || | |||
| slice_type != h0->last_slice_type || | |||
| memcmp(h0->last_ref_count, h0->ref_count, sizeof(h0->ref_count)))) { | |||
| memcmp(h0->last_ref_count, sl->ref_count, sizeof(sl->ref_count)))) { | |||
| ff_h264_fill_default_ref_list(h, sl); | |||
| } | |||
| if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { | |||
| ret = ff_h264_decode_ref_pic_list_reordering(h); | |||
| ret = ff_h264_decode_ref_pic_list_reordering(h, sl); | |||
| if (ret < 0) { | |||
| h->ref_count[1] = h->ref_count[0] = 0; | |||
| sl->ref_count[1] = sl->ref_count[0] = 0; | |||
| return ret; | |||
| } | |||
| } | |||
| @@ -1950,7 +1950,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex | |||
| 6 * (h->sps.bit_depth_luma - 8); | |||
| h0->last_slice_type = slice_type; | |||
| memcpy(h0->last_ref_count, h0->ref_count, sizeof(h0->last_ref_count)); | |||
| memcpy(h0->last_ref_count, sl->ref_count, sizeof(h0->last_ref_count)); | |||
| sl->slice_num = ++h0->current_slice; | |||
| if (sl->slice_num) | |||
| @@ -1964,13 +1964,13 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex | |||
| for (j = 0; j < 2; j++) { | |||
| int id_list[16]; | |||
| int *ref2frm = h->ref2frm[sl->slice_num & (MAX_SLICES - 1)][j]; | |||
| int *ref2frm = sl->ref2frm[sl->slice_num & (MAX_SLICES - 1)][j]; | |||
| for (i = 0; i < 16; i++) { | |||
| id_list[i] = 60; | |||
| if (j < h->list_count && i < h->ref_count[j] && | |||
| h->ref_list[j][i].f.buf[0]) { | |||
| if (j < sl->list_count && i < sl->ref_count[j] && | |||
| sl->ref_list[j][i].f.buf[0]) { | |||
| int k; | |||
| AVBuffer *buf = h->ref_list[j][i].f.buf[0]->buffer; | |||
| AVBuffer *buf = sl->ref_list[j][i].f.buf[0]->buffer; | |||
| for (k = 0; k < h->short_ref_count; k++) | |||
| if (h->short_ref[k]->f.buf[0]->buffer == buf) { | |||
| id_list[i] = k; | |||
| @@ -1987,12 +1987,12 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex | |||
| ref2frm[0] = | |||
| ref2frm[1] = -1; | |||
| for (i = 0; i < 16; i++) | |||
| ref2frm[i + 2] = 4 * id_list[i] + (h->ref_list[j][i].reference & 3); | |||
| ref2frm[i + 2] = 4 * id_list[i] + (sl->ref_list[j][i].reference & 3); | |||
| ref2frm[18 + 0] = | |||
| ref2frm[18 + 1] = -1; | |||
| for (i = 16; i < 48; i++) | |||
| ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1] + | |||
| (h->ref_list[j][i].reference & 3); | |||
| (sl->ref_list[j][i].reference & 3); | |||
| } | |||
| h0->au_pps_id = pps_id; | |||
| @@ -2012,7 +2012,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex | |||
| pps_id, h->frame_num, | |||
| h->cur_pic_ptr->field_poc[0], | |||
| h->cur_pic_ptr->field_poc[1], | |||
| h->ref_count[0], h->ref_count[1], | |||
| sl->ref_count[0], sl->ref_count[1], | |||
| sl->qscale, | |||
| h->deblocking_filter, | |||
| h->slice_alpha_c0_offset, h->slice_beta_offset, | |||
| @@ -2057,7 +2057,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, | |||
| if (USES_LIST(top_type, list)) { | |||
| const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride; | |||
| const int b8_xy = 4 * top_xy + 2; | |||
| int (*ref2frm)[64] = (void*)(h->ref2frm[h->slice_table[top_xy] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2)); | |||
| int (*ref2frm)[64] = (void*)(sl->ref2frm[h->slice_table[top_xy] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2)); | |||
| AV_COPY128(mv_dst - 1 * 8, h->cur_pic.motion_val[list][b_xy + 0]); | |||
| ref_cache[0 - 1 * 8] = | |||
| ref_cache[1 - 1 * 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 0]]; | |||
| @@ -2072,7 +2072,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, | |||
| if (USES_LIST(left_type[LTOP], list)) { | |||
| const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3; | |||
| const int b8_xy = 4 * left_xy[LTOP] + 1; | |||
| int (*ref2frm)[64] =(void*)( h->ref2frm[h->slice_table[left_xy[LTOP]] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2)); | |||
| int (*ref2frm)[64] =(void*)( sl->ref2frm[h->slice_table[left_xy[LTOP]] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2)); | |||
| AV_COPY32(mv_dst - 1 + 0, h->cur_pic.motion_val[list][b_xy + b_stride * 0]); | |||
| AV_COPY32(mv_dst - 1 + 8, h->cur_pic.motion_val[list][b_xy + b_stride * 1]); | |||
| AV_COPY32(mv_dst - 1 + 16, h->cur_pic.motion_val[list][b_xy + b_stride * 2]); | |||
| @@ -2105,7 +2105,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, | |||
| { | |||
| int8_t *ref = &h->cur_pic.ref_index[list][4 * mb_xy]; | |||
| int (*ref2frm)[64] = (void*)(h->ref2frm[sl->slice_num & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2)); | |||
| int (*ref2frm)[64] = (void*)(sl->ref2frm[sl->slice_num & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2)); | |||
| uint32_t ref01 = (pack16to32(ref2frm[list][ref[0]], ref2frm[list][ref[1]]) & 0x00FF00FF) * 0x0101; | |||
| uint32_t ref23 = (pack16to32(ref2frm[list][ref[2]], ref2frm[list][ref[3]]) & 0x00FF00FF) * 0x0101; | |||
| AV_WN32A(&ref_cache[0 * 8], ref01); | |||
| @@ -2203,7 +2203,7 @@ static int fill_filter_caches(H264Context *h, H264SliceContext *sl, int mb_type) | |||
| fill_filter_caches_inter(h, sl, mb_type, top_xy, left_xy, | |||
| top_type, left_type, mb_xy, 0); | |||
| if (h->list_count == 2) | |||
| if (sl->list_count == 2) | |||
| fill_filter_caches_inter(h, sl, mb_type, top_xy, left_xy, | |||
| top_type, left_type, mb_xy, 1); | |||
| @@ -2288,7 +2288,7 @@ static void loop_filter(H264Context *h, H264SliceContext *sl, int start_x, int e | |||
| mb_xy = h->mb_xy = mb_x + mb_y * h->mb_stride; | |||
| sl->slice_num = h->slice_table[mb_xy]; | |||
| mb_type = h->cur_pic.mb_type[mb_xy]; | |||
| h->list_count = h->list_counts[mb_xy]; | |||
| sl->list_count = h->list_counts[mb_xy]; | |||
| if (FRAME_MBAFF(h)) | |||
| h->mb_mbaff = | |||
| @@ -2354,7 +2354,7 @@ static void predict_field_decoding_flag(H264Context *h, H264SliceContext *sl) | |||
| /** | |||
| * Draw edges and report progress for the last MB row. | |||
| */ | |||
| static void decode_finish_row(H264Context *h) | |||
| static void decode_finish_row(H264Context *h, H264SliceContext *sl) | |||
| { | |||
| int top = 16 * (h->mb_y >> FIELD_PICTURE(h)); | |||
| int pic_height = 16 * h->mb_height >> FIELD_PICTURE(h); | |||
| @@ -2376,7 +2376,7 @@ static void decode_finish_row(H264Context *h) | |||
| top = 0; | |||
| } | |||
| ff_h264_draw_horiz_band(h, top, height); | |||
| ff_h264_draw_horiz_band(h, sl, top, height); | |||
| if (h->droppable || h->er.error_occurred) | |||
| return; | |||
| @@ -2385,7 +2385,8 @@ static void decode_finish_row(H264Context *h) | |||
| h->picture_structure == PICT_BOTTOM_FIELD); | |||
| } | |||
| static void er_add_slice(H264Context *h, int startx, int starty, | |||
| static void er_add_slice(H264Context *h, H264SliceContext *sl, | |||
| int startx, int starty, | |||
| int endx, int endy, int status) | |||
| { | |||
| if (CONFIG_ERROR_RESILIENCE) { | |||
| @@ -2453,7 +2454,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) | |||
| if ((h->workaround_bugs & FF_BUG_TRUNCATED) && | |||
| h->cabac.bytestream > h->cabac.bytestream_end + 2) { | |||
| er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x - 1, | |||
| er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, h->mb_x - 1, | |||
| h->mb_y, ER_MB_END); | |||
| if (h->mb_x >= lf_x_start) | |||
| loop_filter(h, sl, lf_x_start, h->mb_x + 1); | |||
| @@ -2466,7 +2467,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) | |||
| "error while decoding MB %d %d, bytestream %"PTRDIFF_SPECIFIER"\n", | |||
| h->mb_x, h->mb_y, | |||
| h->cabac.bytestream_end - h->cabac.bytestream); | |||
| er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x, | |||
| er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, h->mb_x, | |||
| h->mb_y, ER_MB_ERROR); | |||
| return AVERROR_INVALIDDATA; | |||
| } | |||
| @@ -2474,7 +2475,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) | |||
| if (++h->mb_x >= h->mb_width) { | |||
| loop_filter(h, sl, lf_x_start, h->mb_x); | |||
| h->mb_x = lf_x_start = 0; | |||
| decode_finish_row(h); | |||
| decode_finish_row(h, sl); | |||
| ++h->mb_y; | |||
| if (FIELD_OR_MBAFF_PICTURE(h)) { | |||
| ++h->mb_y; | |||
| @@ -2486,7 +2487,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) | |||
| if (eos || h->mb_y >= h->mb_height) { | |||
| tprintf(h->avctx, "slice end %d %d\n", | |||
| get_bits_count(&h->gb), h->gb.size_in_bits); | |||
| er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x - 1, | |||
| er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, h->mb_x - 1, | |||
| h->mb_y, ER_MB_END); | |||
| if (h->mb_x > lf_x_start) | |||
| loop_filter(h, sl, lf_x_start, h->mb_x); | |||
| @@ -2513,7 +2514,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) | |||
| if (ret < 0) { | |||
| av_log(h->avctx, AV_LOG_ERROR, | |||
| "error while decoding MB %d %d\n", h->mb_x, h->mb_y); | |||
| er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x, | |||
| er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, h->mb_x, | |||
| h->mb_y, ER_MB_ERROR); | |||
| return ret; | |||
| } | |||
| @@ -2521,7 +2522,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) | |||
| if (++h->mb_x >= h->mb_width) { | |||
| loop_filter(h, sl, lf_x_start, h->mb_x); | |||
| h->mb_x = lf_x_start = 0; | |||
| decode_finish_row(h); | |||
| decode_finish_row(h, sl); | |||
| ++h->mb_y; | |||
| if (FIELD_OR_MBAFF_PICTURE(h)) { | |||
| ++h->mb_y; | |||
| @@ -2534,12 +2535,12 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) | |||
| if ( get_bits_left(&h->gb) == 0 | |||
| || get_bits_left(&h->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) { | |||
| er_add_slice(h, h->resync_mb_x, h->resync_mb_y, | |||
| er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, | |||
| h->mb_x - 1, h->mb_y, ER_MB_END); | |||
| return 0; | |||
| } else { | |||
| er_add_slice(h, h->resync_mb_x, h->resync_mb_y, | |||
| er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, | |||
| h->mb_x, h->mb_y, ER_MB_END); | |||
| return AVERROR_INVALIDDATA; | |||
| @@ -2552,14 +2553,14 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) | |||
| get_bits_count(&h->gb), h->gb.size_in_bits); | |||
| if (get_bits_left(&h->gb) == 0) { | |||
| er_add_slice(h, h->resync_mb_x, h->resync_mb_y, | |||
| er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, | |||
| h->mb_x - 1, h->mb_y, ER_MB_END); | |||
| if (h->mb_x > lf_x_start) | |||
| loop_filter(h, sl, lf_x_start, h->mb_x); | |||
| return 0; | |||
| } else { | |||
| er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x, | |||
| er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, h->mb_x, | |||
| h->mb_y, ER_MB_ERROR); | |||
| return AVERROR_INVALIDDATA; | |||
| @@ -198,7 +198,7 @@ static void fill_vaapi_plain_pred_weight_table(H264Context *h, | |||
| *luma_weight_flag = sl->luma_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 | |||
| only what is available in the bitstream (7.4.3.2). */ | |||
| if (sl->luma_weight_flag[list]) { | |||
| @@ -293,6 +293,7 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx) | |||
| { | |||
| struct vaapi_context * const vactx = avctx->hwaccel_context; | |||
| H264Context * const h = avctx->priv_data; | |||
| H264SliceContext *sl = &h->slice_ctx[0]; | |||
| int ret; | |||
| av_dlog(avctx, "vaapi_h264_end_frame()\n"); | |||
| @@ -304,7 +305,7 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx) | |||
| if (ret < 0) | |||
| goto finish; | |||
| ff_h264_draw_horiz_band(h, 0, h->avctx->height); | |||
| ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height); | |||
| finish: | |||
| ff_vaapi_common_end_frame(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->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->num_ref_idx_l0_active_minus1 = h->list_count > 0 ? h->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_l0_active_minus1 = sl->list_count > 0 ? sl->ref_count[0] - 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->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; | |||
| @@ -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->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->RefPicList1, h->ref_list[1], h->list_count > 1 ? h->ref_count[1] : 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, sl->ref_list[1], sl->list_count > 1 ? sl->ref_count[1] : 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, | |||
| @@ -500,7 +500,7 @@ void ff_vdpau_h264_picture_complete(H264Context *h) | |||
| memcpy(render->info.h264.scaling_lists_8x8[0], h->pps.scaling_matrix8[0], sizeof(render->info.h264.scaling_lists_8x8[0])); | |||
| memcpy(render->info.h264.scaling_lists_8x8[1], h->pps.scaling_matrix8[3], sizeof(render->info.h264.scaling_lists_8x8[0])); | |||
| ff_h264_draw_horiz_band(h, 0, h->avctx->height); | |||
| ff_h264_draw_horiz_band(h, &h->slice_ctx[0], 0, h->avctx->height); | |||
| render->bitstream_buffers_used = 0; | |||
| } | |||
| #endif /* CONFIG_H264_VDPAU_DECODER */ | |||
| @@ -198,6 +198,7 @@ static int vdpau_h264_decode_slice(AVCodecContext *avctx, | |||
| static int vdpau_h264_end_frame(AVCodecContext *avctx) | |||
| { | |||
| H264Context *h = avctx->priv_data; | |||
| H264SliceContext *sl = &h->slice_ctx[0]; | |||
| H264Picture *pic = h->cur_pic_ptr; | |||
| struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; | |||
| int val; | |||
| @@ -206,7 +207,7 @@ static int vdpau_h264_end_frame(AVCodecContext *avctx) | |||
| if (val < 0) | |||
| 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; | |||
| } | |||