X-Git-Url: https://git.piment-noir.org/?p=deb_ffmpeg.git;a=blobdiff_plain;f=ffmpeg%2Flibavcodec%2Fhevc.c;h=d4dc52c9dd837eda39332ad7a989e290eed4a051;hp=309b3854e92226789486d6fd326a37d9ccf29ffe;hb=f6fa7814ccfe3e76514b36cf04f5cd3cb657c8cf;hpb=2ba45a602cbfa7b771effba9b11bb4245c21bc00 diff --git a/ffmpeg/libavcodec/hevc.c b/ffmpeg/libavcodec/hevc.c index 309b385..d4dc52c 100644 --- a/ffmpeg/libavcodec/hevc.c +++ b/ffmpeg/libavcodec/hevc.c @@ -351,7 +351,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps) } if (num != 0 && den != 0) - av_reduce(&s->avctx->time_base.num, &s->avctx->time_base.den, + av_reduce(&s->avctx->framerate.den, &s->avctx->framerate.num, num, den, 1 << 30); return 0; @@ -865,8 +865,7 @@ static int hls_cross_component_pred(HEVCContext *s, int idx) { static int hls_transform_unit(HEVCContext *s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, - int trafo_depth, int blk_idx, - int cbf_luma, int *cbf_cb, int *cbf_cr) + int blk_idx, int cbf_luma, int *cbf_cb, int *cbf_cr) { HEVCLocalContext *lc = s->HEVClc; const int log2_trafo_size_c = log2_trafo_size - s->sps->hshift[1]; @@ -972,8 +971,8 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, ptrdiff_t stride = s->frame->linesize[1]; int hshift = s->sps->hshift[1]; int vshift = s->sps->vshift[1]; - int16_t *coeffs_y = lc->tu.coeffs[0]; - int16_t *coeffs = lc->tu.coeffs[1]; + int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer; + int16_t *coeffs = (int16_t*)lc->edge_emu_buffer2; int size = 1 << log2_trafo_size_c; uint8_t *dst = &s->frame->data[1][(y0 >> vshift) * stride + @@ -1001,8 +1000,8 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, ptrdiff_t stride = s->frame->linesize[2]; int hshift = s->sps->hshift[2]; int vshift = s->sps->vshift[2]; - int16_t *coeffs_y = lc->tu.coeffs[0]; - int16_t *coeffs = lc->tu.coeffs[1]; + int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer; + int16_t *coeffs = (int16_t*)lc->edge_emu_buffer2; int size = 1 << log2_trafo_size_c; uint8_t *dst = &s->frame->data[2][(y0 >> vshift) * stride + @@ -1183,7 +1182,7 @@ do { } ret = hls_transform_unit(s, x0, y0, xBase, yBase, cb_xBase, cb_yBase, - log2_cb_size, log2_trafo_size, trafo_depth, + log2_cb_size, log2_trafo_size, blk_idx, cbf_luma, cbf_cb, cbf_cr); if (ret < 0) return ret; @@ -1327,7 +1326,6 @@ static void luma_mc_uni(HEVCContext *s, uint8_t *dst, ptrdiff_t dststride, int block_w, int block_h, AVFrame *ref1, const Mv *mv1, struct MvField *current_mv) { HEVCLocalContext *lc = s->HEVClc; - DECLARE_ALIGNED(16, int16_t, tmp[MAX_PB_SIZE * MAX_PB_SIZE]); ptrdiff_t src0stride = ref0->linesize[0]; ptrdiff_t src1stride = ref1->linesize[0]; int pic_width = s->sps->width; @@ -1381,13 +1379,13 @@ static void luma_mc_uni(HEVCContext *s, uint8_t *dst, ptrdiff_t dststride, src1stride = edge_emu_stride; } - s->hevcdsp.put_hevc_qpel[idx][!!my0][!!mx0](tmp, src0, src0stride, + s->hevcdsp.put_hevc_qpel[idx][!!my0][!!mx0](lc->tmp, src0, src0stride, block_h, mx0, my0, block_w); if (!weight_flag) - s->hevcdsp.put_hevc_qpel_bi[idx][!!my1][!!mx1](dst, dststride, src1, src1stride, tmp, + s->hevcdsp.put_hevc_qpel_bi[idx][!!my1][!!mx1](dst, dststride, src1, src1stride, lc->tmp, block_h, mx1, my1, block_w); else - s->hevcdsp.put_hevc_qpel_bi_w[idx][!!my1][!!mx1](dst, dststride, src1, src1stride, tmp, + s->hevcdsp.put_hevc_qpel_bi_w[idx][!!my1][!!mx1](dst, dststride, src1, src1stride, lc->tmp, block_h, s->sh.luma_log2_weight_denom, s->sh.luma_weight_l0[current_mv->ref_idx[0]], s->sh.luma_weight_l1[current_mv->ref_idx[1]], @@ -1482,7 +1480,6 @@ static void chroma_mc_uni(HEVCContext *s, uint8_t *dst0, static void chroma_mc_bi(HEVCContext *s, uint8_t *dst0, ptrdiff_t dststride, AVFrame *ref0, AVFrame *ref1, int x_off, int y_off, int block_w, int block_h, struct MvField *current_mv, int cidx) { - DECLARE_ALIGNED(16, int16_t, tmp [MAX_PB_SIZE * MAX_PB_SIZE]); HEVCLocalContext *lc = s->HEVClc; uint8_t *src1 = ref0->data[cidx+1]; uint8_t *src2 = ref1->data[cidx+1]; @@ -1552,15 +1549,15 @@ static void chroma_mc_bi(HEVCContext *s, uint8_t *dst0, ptrdiff_t dststride, AVF src2stride = edge_emu_stride; } - s->hevcdsp.put_hevc_epel[idx][!!my0][!!mx0](tmp, src1, src1stride, + s->hevcdsp.put_hevc_epel[idx][!!my0][!!mx0](lc->tmp, src1, src1stride, block_h, _mx0, _my0, block_w); if (!weight_flag) s->hevcdsp.put_hevc_epel_bi[idx][!!my1][!!mx1](dst0, s->frame->linesize[cidx+1], - src2, src2stride, tmp, + src2, src2stride, lc->tmp, block_h, _mx1, _my1, block_w); else s->hevcdsp.put_hevc_epel_bi_w[idx][!!my1][!!mx1](dst0, s->frame->linesize[cidx+1], - src2, src2stride, tmp, + src2, src2stride, lc->tmp, block_h, s->sh.chroma_log2_weight_denom, s->sh.chroma_weight_l0[current_mv->ref_idx[0]][cidx], @@ -1573,12 +1570,57 @@ static void chroma_mc_bi(HEVCContext *s, uint8_t *dst0, ptrdiff_t dststride, AVF static void hevc_await_progress(HEVCContext *s, HEVCFrame *ref, const Mv *mv, int y0, int height) { - int y = (mv->y >> 2) + y0 + height + 9; + int y = FFMAX(0, (mv->y >> 2) + y0 + height + 9); if (s->threads_type == FF_THREAD_FRAME ) ff_thread_await_progress(&ref->tf, y, 0); } +static void hevc_luma_mv_mpv_mode(HEVCContext *s, int x0, int y0, int nPbW, + int nPbH, int log2_cb_size, int part_idx, + int merge_idx, MvField *mv) +{ + HEVCLocalContext *lc = s->HEVClc; + enum InterPredIdc inter_pred_idc = PRED_L0; + int mvp_flag; + + ff_hevc_set_neighbour_available(s, x0, y0, nPbW, nPbH); + mv->pred_flag = 0; + if (s->sh.slice_type == B_SLICE) + inter_pred_idc = ff_hevc_inter_pred_idc_decode(s, nPbW, nPbH); + + if (inter_pred_idc != PRED_L1) { + if (s->sh.nb_refs[L0]) + mv->ref_idx[0]= ff_hevc_ref_idx_lx_decode(s, s->sh.nb_refs[L0]); + + mv->pred_flag = PF_L0; + ff_hevc_hls_mvd_coding(s, x0, y0, 0); + mvp_flag = ff_hevc_mvp_lx_flag_decode(s); + ff_hevc_luma_mv_mvp_mode(s, x0, y0, nPbW, nPbH, log2_cb_size, + part_idx, merge_idx, mv, mvp_flag, 0); + mv->mv[0].x += lc->pu.mvd.x; + mv->mv[0].y += lc->pu.mvd.y; + } + + if (inter_pred_idc != PRED_L0) { + if (s->sh.nb_refs[L1]) + mv->ref_idx[1]= ff_hevc_ref_idx_lx_decode(s, s->sh.nb_refs[L1]); + + if (s->sh.mvd_l1_zero_flag == 1 && inter_pred_idc == PRED_BI) { + AV_ZERO32(&lc->pu.mvd); + } else { + ff_hevc_hls_mvd_coding(s, x0, y0, 1); + } + + mv->pred_flag += PF_L1; + mvp_flag = ff_hevc_mvp_lx_flag_decode(s); + ff_hevc_luma_mv_mvp_mode(s, x0, y0, nPbW, nPbH, log2_cb_size, + part_idx, merge_idx, mv, mvp_flag, 1); + mv->mv[1].x += lc->pu.mvd.x; + mv->mv[1].y += lc->pu.mvd.y; + } +} + static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int partIdx, int idx) @@ -1602,95 +1644,33 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int min_cb_width = s->sps->min_cb_width; int x_cb = x0 >> log2_min_cb_size; int y_cb = y0 >> log2_min_cb_size; - int ref_idx[2]; - int mvp_flag[2]; int x_pu, y_pu; int i, j; - if (SAMPLE_CTB(s->skip_flag, x_cb, y_cb)) { + int skip_flag = SAMPLE_CTB(s->skip_flag, x_cb, y_cb); + + if (!skip_flag) + lc->pu.merge_flag = ff_hevc_merge_flag_decode(s); + + if (skip_flag || lc->pu.merge_flag) { if (s->sh.max_num_merge_cand > 1) merge_idx = ff_hevc_merge_idx_decode(s); else merge_idx = 0; - ff_hevc_luma_mv_merge_mode(s, x0, y0, - 1 << log2_cb_size, - 1 << log2_cb_size, - log2_cb_size, partIdx, - merge_idx, ¤t_mv); - x_pu = x0 >> s->sps->log2_min_pu_size; - y_pu = y0 >> s->sps->log2_min_pu_size; - - for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++) - for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++) - tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv; - } else { /* MODE_INTER */ - lc->pu.merge_flag = ff_hevc_merge_flag_decode(s); - if (lc->pu.merge_flag) { - if (s->sh.max_num_merge_cand > 1) - merge_idx = ff_hevc_merge_idx_decode(s); - else - merge_idx = 0; - - ff_hevc_luma_mv_merge_mode(s, x0, y0, nPbW, nPbH, log2_cb_size, - partIdx, merge_idx, ¤t_mv); - x_pu = x0 >> s->sps->log2_min_pu_size; - y_pu = y0 >> s->sps->log2_min_pu_size; - - for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++) - for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++) - tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv; - } else { - enum InterPredIdc inter_pred_idc = PRED_L0; - ff_hevc_set_neighbour_available(s, x0, y0, nPbW, nPbH); - current_mv.pred_flag = 0; - if (s->sh.slice_type == B_SLICE) - inter_pred_idc = ff_hevc_inter_pred_idc_decode(s, nPbW, nPbH); - - if (inter_pred_idc != PRED_L1) { - if (s->sh.nb_refs[L0]) { - ref_idx[0] = ff_hevc_ref_idx_lx_decode(s, s->sh.nb_refs[L0]); - current_mv.ref_idx[0] = ref_idx[0]; - } - current_mv.pred_flag = PF_L0; - ff_hevc_hls_mvd_coding(s, x0, y0, 0); - mvp_flag[0] = ff_hevc_mvp_lx_flag_decode(s); - ff_hevc_luma_mv_mvp_mode(s, x0, y0, nPbW, nPbH, log2_cb_size, - partIdx, merge_idx, ¤t_mv, - mvp_flag[0], 0); - current_mv.mv[0].x += lc->pu.mvd.x; - current_mv.mv[0].y += lc->pu.mvd.y; - } - - if (inter_pred_idc != PRED_L0) { - if (s->sh.nb_refs[L1]) { - ref_idx[1] = ff_hevc_ref_idx_lx_decode(s, s->sh.nb_refs[L1]); - current_mv.ref_idx[1] = ref_idx[1]; - } - - if (s->sh.mvd_l1_zero_flag == 1 && inter_pred_idc == PRED_BI) { - AV_ZERO32(&lc->pu.mvd); - } else { - ff_hevc_hls_mvd_coding(s, x0, y0, 1); - } + ff_hevc_luma_mv_merge_mode(s, x0, y0, nPbW, nPbH, log2_cb_size, + partIdx, merge_idx, ¤t_mv); + } else { + hevc_luma_mv_mpv_mode(s, x0, y0, nPbW, nPbH, log2_cb_size, + partIdx, merge_idx, ¤t_mv); + } - current_mv.pred_flag += PF_L1; - mvp_flag[1] = ff_hevc_mvp_lx_flag_decode(s); - ff_hevc_luma_mv_mvp_mode(s, x0, y0, nPbW, nPbH, log2_cb_size, - partIdx, merge_idx, ¤t_mv, - mvp_flag[1], 1); - current_mv.mv[1].x += lc->pu.mvd.x; - current_mv.mv[1].y += lc->pu.mvd.y; - } + x_pu = x0 >> s->sps->log2_min_pu_size; + y_pu = y0 >> s->sps->log2_min_pu_size; - x_pu = x0 >> s->sps->log2_min_pu_size; - y_pu = y0 >> s->sps->log2_min_pu_size; - - for(j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++) - for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++) - tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv; - } - } + for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++) + for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++) + tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv; if (current_mv.pred_flag & PF_L0) { ref0 = refPicList[0].ref[current_mv.ref_idx[0]]; @@ -1964,11 +1944,9 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) lc->cu.x = x0; lc->cu.y = y0; - lc->cu.rqt_root_cbf = 1; lc->cu.pred_mode = MODE_INTRA; lc->cu.part_mode = PART_2Nx2N; lc->cu.intra_split_flag = 0; - lc->cu.pcm_flag = 0; SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0; for (x = 0; x < 4; x++) @@ -2004,6 +1982,8 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) if (!s->sh.disable_deblocking_filter_flag) ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size); } else { + int pcm_flag = 0; + if (s->sh.slice_type != I_SLICE) lc->cu.pred_mode = ff_hevc_pred_mode_decode(s); if (lc->cu.pred_mode != MODE_INTRA || @@ -2017,9 +1997,9 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) if (lc->cu.part_mode == PART_2Nx2N && s->sps->pcm_enabled_flag && log2_cb_size >= s->sps->pcm.log2_min_pcm_cb_size && log2_cb_size <= s->sps->pcm.log2_max_pcm_cb_size) { - lc->cu.pcm_flag = ff_hevc_pcm_flag_decode(s); + pcm_flag = ff_hevc_pcm_flag_decode(s); } - if (lc->cu.pcm_flag) { + if (pcm_flag) { intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); ret = hls_pcm_sample(s, x0, y0, log2_cb_size); if (s->sps->pcm.loop_filter_disable_flag) @@ -2069,12 +2049,14 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) } } - if (!lc->cu.pcm_flag) { + if (!pcm_flag) { + int rqt_root_cbf = 1; + if (lc->cu.pred_mode != MODE_INTRA && !(lc->cu.part_mode == PART_2Nx2N && lc->pu.merge_flag)) { - lc->cu.rqt_root_cbf = ff_hevc_no_residual_syntax_flag_decode(s); + rqt_root_cbf = ff_hevc_no_residual_syntax_flag_decode(s); } - if (lc->cu.rqt_root_cbf) { + if (rqt_root_cbf) { const static int cbf[2] = { 0 }; lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ? s->sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag : @@ -2105,7 +2087,7 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) lc->qPy_pred = lc->qp_y; } - set_ct_depth(s, x0, y0, log2_cb_size, lc->ct.depth); + set_ct_depth(s, x0, y0, log2_cb_size, lc->ct_depth); return 0; } @@ -2119,7 +2101,7 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int qp_block_mask = (1<<(s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1; int split_cu; - lc->ct.depth = cb_depth; + lc->ct_depth = cb_depth; if (x0 + cb_size <= s->sps->width && y0 + cb_size <= s->sps->height && log2_cb_size > s->sps->log2_min_cb_size) { @@ -2532,7 +2514,7 @@ static int set_side_data(HEVCContext *s) av_display_rotation_set((int32_t *)rotation->data, angle); av_display_matrix_flip((int32_t *)rotation->data, - s->sei_vflip, s->sei_hflip); + s->sei_hflip, s->sei_vflip); } return 0;