48 const uint8_t ff_hevc_pel_weight[65] = { [2] = 0, [4] = 1, [6] = 2, [8] = 3, [12] = 4, [16] = 5, [24] = 6, [32] = 7, [48] = 8, [64] = 9 };
93 int pic_size_in_ctb = ((width >> log2_min_cb_size) + 1) *
94 ((height >> log2_min_cb_size) + 1);
148 uint8_t luma_weight_l0_flag[16];
149 uint8_t chroma_weight_l0_flag[16];
150 uint8_t luma_weight_l1_flag[16];
151 uint8_t chroma_weight_l1_flag[16];
152 int luma_log2_weight_denom;
155 if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) {
161 int64_t chroma_log2_weight_denom = luma_log2_weight_denom + (int64_t)
get_se_golomb(gb);
162 if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) {
171 if (!luma_weight_l0_flag[i]) {
178 chroma_weight_l0_flag[i] =
get_bits1(gb);
181 chroma_weight_l0_flag[i] = 0;
184 if (luma_weight_l0_flag[i]) {
186 if ((int8_t)delta_luma_weight_l0 != delta_luma_weight_l0)
191 if (chroma_weight_l0_flag[i]) {
192 for (j = 0; j < 2; j++) {
196 if ( (int8_t)delta_chroma_weight_l0 != delta_chroma_weight_l0
197 || delta_chroma_offset_l0 < -(1<<17) || delta_chroma_offset_l0 > (1<<17)) {
215 if (!luma_weight_l1_flag[i]) {
222 chroma_weight_l1_flag[i] =
get_bits1(gb);
225 chroma_weight_l1_flag[i] = 0;
228 if (luma_weight_l1_flag[i]) {
230 if ((int8_t)delta_luma_weight_l1 != delta_luma_weight_l1)
235 if (chroma_weight_l1_flag[i]) {
236 for (j = 0; j < 2; j++) {
240 if ( (int8_t)delta_chroma_weight_l1 != delta_chroma_weight_l1
241 || delta_chroma_offset_l1 < -(1<<17) || delta_chroma_offset_l1 > (1<<17)) {
264 int prev_delta_msb = 0;
265 unsigned int nb_sps = 0, nb_sh;
283 for (i = 0; i < rps->
nb_refs; i++) {
303 if (i && i != nb_sps)
304 delta += prev_delta_msb;
310 prev_delta_msb =
delta;
323 unsigned int num = 0, den = 0;
328 avctx->
width = sps->
width - ow->left_offset - ow->right_offset;
329 avctx->
height = sps->
height - ow->top_offset - ow->bottom_offset;
369 if (num != 0 && den != 0)
392 #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + \ 393 CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \ 394 CONFIG_HEVC_NVDEC_HWACCEL + \ 395 CONFIG_HEVC_VAAPI_HWACCEL + \ 396 CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + \ 397 CONFIG_HEVC_VDPAU_HWACCEL) 403 #if CONFIG_HEVC_DXVA2_HWACCEL 406 #if CONFIG_HEVC_D3D11VA_HWACCEL 410 #if CONFIG_HEVC_VAAPI_HWACCEL 413 #if CONFIG_HEVC_VDPAU_HWACCEL 416 #if CONFIG_HEVC_NVDEC_HWACCEL 419 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL 424 #if CONFIG_HEVC_DXVA2_HWACCEL 427 #if CONFIG_HEVC_D3D11VA_HWACCEL 431 #if CONFIG_HEVC_VAAPI_HWACCEL 434 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL 437 #if CONFIG_HEVC_VDPAU_HWACCEL 440 #if CONFIG_HEVC_NVDEC_HWACCEL 445 #if CONFIG_HEVC_VDPAU_HWACCEL 448 #if CONFIG_HEVC_NVDEC_HWACCEL 454 #if CONFIG_HEVC_VAAPI_HWACCEL 461 #if CONFIG_HEVC_VDPAU_HWACCEL 464 #if CONFIG_HEVC_NVDEC_HWACCEL 500 for (i = 0; i < 3; i++) {
509 for(c_idx = 0; c_idx < c_count; c_idx++) {
531 for (i = 0; i < 3; i++) {
582 if (sps->
width != last_sps->width || sps->
height != last_sps->height ||
584 last_sps->temporal_layer[last_sps->max_sub_layers - 1].max_dec_pic_buffering)
608 int slice_address_length;
618 "Invalid slice segment address: %u.\n",
667 "Ignoring POC change between slices: %d -> %d\n", s->
poc, poc);
683 int numbits, rps_idx;
691 rps_idx = numbits > 0 ?
get_bits(gb, numbits) : 0;
797 "Invalid collocated_ref_idx: %d.\n",
814 "Invalid number of merging MVP candidates: %d.\n",
841 int deblocking_filter_override_flag = 0;
844 deblocking_filter_override_flag =
get_bits1(gb);
846 if (deblocking_filter_override_flag) {
851 if (beta_offset_div2 < -6 || beta_offset_div2 > 6 ||
852 tc_offset_div2 < -6 || tc_offset_div2 > 6) {
854 "Invalid deblock filter offsets: %d, %d\n",
855 beta_offset_div2, tc_offset_div2);
898 if (offset_len < 1 || offset_len > 32) {
934 for (i = 0; i <
length; i++)
943 "The slice_qp %d is outside the valid range " 975 #define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)]) 977 #define SET_SAO(elem, value) \ 979 if (!sao_merge_up_flag && !sao_merge_left_flag) \ 981 else if (sao_merge_left_flag) \ 982 sao->elem = CTB(s->sao, rx-1, ry).elem; \ 983 else if (sao_merge_up_flag) \ 984 sao->elem = CTB(s->sao, rx, ry-1).elem; \ 992 int sao_merge_left_flag = 0;
993 int sao_merge_up_flag = 0;
1003 if (ry > 0 && !sao_merge_left_flag) {
1028 for (i = 0; i < 4; i++)
1032 for (i = 0; i < 4; i++) {
1034 SET_SAO(offset_sign[c_idx][i],
1041 }
else if (c_idx != 2) {
1047 for (i = 0; i < 4; i++) {
1055 sao->
offset_val[c_idx][i + 1] *= 1 << log2_sao_offset_scale;
1067 if (log2_res_scale_abs_plus1 != 0) {
1070 (1 - 2 * res_scale_sign_flag);
1080 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1081 int log2_cb_size,
int log2_trafo_size,
1082 int blk_idx,
int cbf_luma,
int *cbf_cb,
int *cbf_cr)
1085 const int log2_trafo_size_c = log2_trafo_size - s->
ps.
sps->
hshift[1];
1089 int trafo_size = 1 << log2_trafo_size;
1095 if (cbf_luma || cbf_cb[0] || cbf_cr[0] ||
1099 int cbf_chroma = cbf_cb[0] || cbf_cr[0] ||
1101 (cbf_cb[1] || cbf_cr[1]));
1113 "The cu_qp_delta %d is outside the valid range " 1127 if (cu_chroma_qp_offset_flag) {
1128 int cu_chroma_qp_offset_idx = 0;
1132 "cu_chroma_qp_offset_idx not yet tested.\n");
1166 int trafo_size_h = 1 << (log2_trafo_size_c + s->
ps.
sps->
hshift[1]);
1167 int trafo_size_v = 1 << (log2_trafo_size_c + s->
ps.
sps->
vshift[1]);
1178 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (i << log2_trafo_size_c), 1);
1182 log2_trafo_size_c, scan_idx_c, 1);
1190 int size = 1 << log2_trafo_size_c;
1194 for (i = 0; i < (size *
size); i++) {
1207 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (i << log2_trafo_size_c), 2);
1211 log2_trafo_size_c, scan_idx_c, 2);
1219 int size = 1 << log2_trafo_size_c;
1223 for (i = 0; i < (size *
size); i++) {
1230 int trafo_size_h = 1 << (log2_trafo_size + 1);
1231 int trafo_size_v = 1 << (log2_trafo_size + s->
ps.
sps->
vshift[1]);
1235 trafo_size_h, trafo_size_v);
1236 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (i << log2_trafo_size), 1);
1240 log2_trafo_size, scan_idx_c, 1);
1245 trafo_size_h, trafo_size_v);
1246 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (i << log2_trafo_size), 2);
1250 log2_trafo_size, scan_idx_c, 2);
1255 int trafo_size_h = 1 << (log2_trafo_size_c + s->
ps.
sps->
hshift[1]);
1256 int trafo_size_v = 1 << (log2_trafo_size_c + s->
ps.
sps->
vshift[1]);
1262 trafo_size_h, trafo_size_v);
1263 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (1 << log2_trafo_size_c), 1);
1264 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (1 << log2_trafo_size_c), 2);
1266 }
else if (blk_idx == 3) {
1267 int trafo_size_h = 1 << (log2_trafo_size + 1);
1268 int trafo_size_v = 1 << (log2_trafo_size + s->
ps.
sps->
vshift[1]);
1270 trafo_size_h, trafo_size_v);
1275 trafo_size_h, trafo_size_v);
1276 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (1 << (log2_trafo_size)), 1);
1277 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (1 << (log2_trafo_size)), 2);
1287 int cb_size = 1 << log2_cb_size;
1295 for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
1296 for (i = (x0 >> log2_min_pu_size); i < (x_end >> log2_min_pu_size); i++)
1297 s->
is_pcm[i + j * min_pu_width] = 2;
1301 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1302 int log2_cb_size,
int log2_trafo_size,
1303 int trafo_depth,
int blk_idx,
1304 const int *base_cbf_cb,
const int *base_cbf_cr)
1312 cbf_cb[0] = base_cbf_cb[0];
1313 cbf_cb[1] = base_cbf_cb[1];
1314 cbf_cr[0] = base_cbf_cr[0];
1315 cbf_cr[1] = base_cbf_cr[1];
1318 if (trafo_depth == 1) {
1334 if (log2_trafo_size <= s->ps.sps->log2_max_trafo_size &&
1336 trafo_depth < lc->cu.max_trafo_depth &&
1351 if (trafo_depth == 0 || cbf_cb[0]) {
1358 if (trafo_depth == 0 || cbf_cr[0]) {
1366 if (split_transform_flag) {
1367 const int trafo_size_split = 1 << (log2_trafo_size - 1);
1368 const int x1 = x0 + trafo_size_split;
1369 const int y1 = y0 + trafo_size_split;
1371 #define SUBDIVIDE(x, y, idx) \ 1373 ret = hls_transform_tree(s, x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size, \ 1374 log2_trafo_size - 1, trafo_depth + 1, idx, \ 1393 cbf_cb[0] || cbf_cr[0] ||
1399 log2_cb_size, log2_trafo_size,
1400 blk_idx, cbf_luma, cbf_cb, cbf_cr);
1406 for (i = 0; i < (1 << log2_trafo_size); i += min_tu_size)
1407 for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) {
1408 int x_tu = (x0 + j) >> log2_min_tu_size;
1409 int y_tu = (y0 +
i) >> log2_min_tu_size;
1410 s->
cbf_luma[y_tu * min_tu_width + x_tu] = 1;
1427 int cb_size = 1 << log2_cb_size;
1482 int block_w,
int block_h,
int luma_weight,
int luma_offset)
1486 ptrdiff_t srcstride = ref->
linesize[0];
1495 x_off += mv->
x >> 2;
1496 y_off += mv->
y >> 2;
1507 edge_emu_stride, srcstride,
1511 pic_width, pic_height);
1513 srcstride = edge_emu_stride;
1518 block_h, mx, my, block_w);
1522 luma_weight, luma_offset, mx, my, block_w);
1542 AVFrame *ref0,
const Mv *mv0,
int x_off,
int y_off,
1543 int block_w,
int block_h,
AVFrame *ref1,
const Mv *mv1,
struct MvField *current_mv)
1546 ptrdiff_t src0stride = ref0->
linesize[0];
1547 ptrdiff_t src1stride = ref1->
linesize[0];
1550 int mx0 = mv0->
x & 3;
1551 int my0 = mv0->
y & 3;
1552 int mx1 = mv1->
x & 3;
1553 int my1 = mv1->
y & 3;
1556 int x_off0 = x_off + (mv0->
x >> 2);
1557 int y_off0 = y_off + (mv0->
y >> 2);
1558 int x_off1 = x_off + (mv1->
x >> 2);
1559 int y_off1 = y_off + (mv1->
y >> 2);
1573 edge_emu_stride, src0stride,
1577 pic_width, pic_height);
1579 src0stride = edge_emu_stride;
1590 edge_emu_stride, src1stride,
1594 pic_width, pic_height);
1596 src1stride = edge_emu_stride;
1600 block_h, mx0, my0, block_w);
1603 block_h, mx1, my1, block_w);
1633 ptrdiff_t dststride,
uint8_t *
src0, ptrdiff_t srcstride,
int reflist,
1634 int x_off,
int y_off,
int block_w,
int block_h,
struct MvField *current_mv,
int chroma_weight,
int chroma_offset)
1639 const Mv *
mv = ¤t_mv->
mv[reflist];
1647 intptr_t _mx = mx << (1 - hshift);
1648 intptr_t _my = my << (1 - vshift);
1650 x_off += mv->
x >> (2 + hshift);
1651 y_off += mv->
y >> (2 + vshift);
1662 edge_emu_stride, srcstride,
1666 pic_width, pic_height);
1669 srcstride = edge_emu_stride;
1673 block_h, _mx, _my, block_w);
1677 chroma_weight, chroma_offset, _mx, _my, block_w);
1698 int x_off,
int y_off,
int block_w,
int block_h,
struct MvField *current_mv,
int cidx)
1703 ptrdiff_t src1stride = ref0->
linesize[cidx+1];
1704 ptrdiff_t src2stride = ref1->
linesize[cidx+1];
1709 Mv *mv0 = ¤t_mv->
mv[0];
1710 Mv *mv1 = ¤t_mv->
mv[1];
1718 intptr_t _mx0 = mx0 << (1 - hshift);
1719 intptr_t _my0 = my0 << (1 - vshift);
1720 intptr_t _mx1 = mx1 << (1 - hshift);
1721 intptr_t _my1 = my1 << (1 - vshift);
1723 int x_off0 = x_off + (mv0->
x >> (2 + hshift));
1724 int y_off0 = y_off + (mv0->
y >> (2 + vshift));
1725 int x_off1 = x_off + (mv1->
x >> (2 + hshift));
1726 int y_off1 = y_off + (mv1->
y >> (2 + vshift));
1740 edge_emu_stride, src1stride,
1744 pic_width, pic_height);
1747 src1stride = edge_emu_stride;
1759 edge_emu_stride, src2stride,
1763 pic_width, pic_height);
1766 src2stride = edge_emu_stride;
1770 block_h, _mx0, _my0, block_w);
1773 src2, src2stride, lc->
tmp,
1774 block_h, _mx1, _my1, block_w);
1777 src2, src2stride, lc->
tmp,
1784 _mx1, _my1, block_w);
1791 int y =
FFMAX(0, (mv->
y >> 2) + y0 + height + 9);
1798 int nPbH,
int log2_cb_size,
int part_idx,
1810 if (inter_pred_idc !=
PRED_L1) {
1818 part_idx, merge_idx, mv, mvp_flag, 0);
1823 if (inter_pred_idc !=
PRED_L0) {
1836 part_idx, merge_idx, mv, mvp_flag, 1);
1844 int log2_cb_size,
int partIdx,
int idx)
1846 #define POS(c_idx, x, y) \ 1847 &s->frame->data[c_idx][((y) >> s->ps.sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \ 1848 (((x) >> s->ps.sps->hshift[c_idx]) << s->ps.sps->pixel_shift)] 1851 struct MvField current_mv = {{{ 0 }}};
1863 int x_cb = x0 >> log2_min_cb_size;
1864 int y_cb = y0 >> log2_min_cb_size;
1880 partIdx, merge_idx, ¤t_mv);
1883 partIdx, merge_idx, ¤t_mv);
1891 tab_mvf[(y_pu + j) * min_pu_width + x_pu +
i] = current_mv;
1894 ref0 = refPicList[0].
ref[current_mv.
ref_idx[0]];
1900 ref1 = refPicList[1].
ref[current_mv.
ref_idx[1]];
1913 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
1919 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1922 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1932 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH,
1938 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1942 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1952 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
1953 ref1->frame, ¤t_mv.
mv[1], ¤t_mv);
1957 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0);
1960 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 1);
1969 int prev_intra_luma_pred_flag)
1987 int intra_pred_mode;
1992 if ((y0 - 1) < y_ctb)
1995 if (cand_left == cand_up) {
1996 if (cand_left < 2) {
2001 candidate[0] = cand_left;
2002 candidate[1] = 2 + ((cand_left - 2 - 1 + 32) & 31);
2003 candidate[2] = 2 + ((cand_left - 2 + 1) & 31);
2006 candidate[0] = cand_left;
2007 candidate[1] = cand_up;
2017 if (prev_intra_luma_pred_flag) {
2018 intra_pred_mode = candidate[lc->
pu.
mpm_idx];
2020 if (candidate[0] > candidate[1])
2022 if (candidate[0] > candidate[2])
2024 if (candidate[1] > candidate[2])
2028 for (i = 0; i < 3; i++)
2029 if (intra_pred_mode >= candidate[i])
2036 for (i = 0; i < size_in_pus; i++) {
2037 memset(&s->
tab_ipm[(y_pu + i) * min_pu_width + x_pu],
2038 intra_pred_mode, size_in_pus);
2040 for (j = 0; j < size_in_pus; j++) {
2045 return intra_pred_mode;
2049 int log2_cb_size,
int ct_depth)
2062 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20,
2063 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31};
2069 static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 };
2070 uint8_t prev_intra_luma_pred_flag[4];
2072 int pb_size = (1 << log2_cb_size) >> split;
2073 int side = split + 1;
2077 for (i = 0; i < side; i++)
2078 for (j = 0; j < side; j++)
2081 for (i = 0; i < side; i++) {
2082 for (j = 0; j < side; j++) {
2083 if (prev_intra_luma_pred_flag[2 * i + j])
2090 prev_intra_luma_pred_flag[2 * i + j]);
2095 for (i = 0; i < side; i++) {
2096 for (j = 0; j < side; j++) {
2098 if (chroma_mode != 4) {
2111 if (chroma_mode != 4) {
2115 mode_idx = intra_chroma_table[chroma_mode];
2122 if (chroma_mode != 4) {
2138 int pb_size = 1 << log2_cb_size;
2146 if (size_in_pus == 0)
2148 for (j = 0; j < size_in_pus; j++)
2149 memset(&s->
tab_ipm[(y_pu + j) * min_pu_width + x_pu],
INTRA_DC, size_in_pus);
2151 for (j = 0; j < size_in_pus; j++)
2152 for (k = 0; k < size_in_pus; k++)
2158 int cb_size = 1 << log2_cb_size;
2161 int length = cb_size >> log2_min_cb_size;
2163 int x_cb = x0 >> log2_min_cb_size;
2164 int y_cb = y0 >> log2_min_cb_size;
2165 int idx = log2_cb_size - 2;
2176 for (x = 0; x < 4; x++)
2188 x = y_cb * min_cb_width + x_cb;
2189 for (y = 0; y <
length; y++) {
2190 memset(&s->
skip_flag[x], skip_flag, length);
2195 x = y_cb * min_cb_width + x_cb;
2196 for (y = 0; y <
length; y++) {
2223 log2_cb_size <= s->ps.sps->pcm.log2_max_pcm_cb_size) {
2249 hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
2253 hls_prediction_unit(s, x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
2257 hls_prediction_unit(s, x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);
2261 hls_prediction_unit(s, x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
2265 hls_prediction_unit(s, x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
2269 hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
2270 hls_prediction_unit(s, x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
2271 hls_prediction_unit(s, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
2277 int rqt_root_cbf = 1;
2284 const static int cbf[2] = { 0 };
2290 log2_cb_size, 0, 0, cbf, cbf);
2303 x = y_cb * min_cb_width + x_cb;
2304 for (y = 0; y <
length; y++) {
2309 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2310 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0) {
2320 int log2_cb_size,
int cb_depth)
2323 const int cb_size = 1 << log2_cb_size;
2328 if (x0 + cb_size <= s->ps.sps->width &&
2329 y0 + cb_size <= s->ps.sps->height &&
2348 const int cb_size_split = cb_size >> 1;
2349 const int x1 = x0 + cb_size_split;
2350 const int y1 = y0 + cb_size_split;
2358 if (more_data && x1 < s->ps.sps->width) {
2363 if (more_data && y1 < s->ps.sps->height) {
2368 if (more_data && x1 < s->ps.sps->width &&
2369 y1 < s->ps.sps->height) {
2375 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2376 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0)
2380 return ((x1 + cb_size_split) < s->
ps.
sps->
width ||
2388 if ((!((x0 + cb_size) %
2395 return !end_of_slice_flag;
2410 int ctb_addr_in_slice = ctb_addr_rs - s->
sh.
slice_addr;
2415 if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
2441 if (ctb_addr_in_slice <= 0)
2443 if (ctb_addr_in_slice < s->ps.sps->ctb_width)
2476 while (more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
2496 if (more_data < 0) {
2531 int *ctb_row_p = input_ctb_row;
2532 int ctb_row = ctb_row_p[job];
2542 ret =
init_get_bits8(&lc->
gb,
s->data +
s->sh.offset[ctb_row - 1],
s->sh.size[ctb_row - 1]);
2548 while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
2549 int x_ctb = (ctb_addr_rs %
s->ps.sps->ctb_width) <<
s->ps.sps->log2_ctb_size;
2550 int y_ctb = (ctb_addr_rs /
s->ps.sps->ctb_width) <<
s->ps.sps->log2_ctb_size;
2564 hls_sao_param(
s, x_ctb >>
s->ps.sps->log2_ctb_size, y_ctb >>
s->ps.sps->log2_ctb_size);
2567 if (more_data < 0) {
2578 if (!more_data && (x_ctb+ctb_size) <
s->ps.sps->width && ctb_row !=
s->sh.num_entry_point_offsets) {
2584 if ((x_ctb+ctb_size) >=
s->ps.sps->width && (y_ctb+ctb_size) >=
s->ps.sps->height ) {
2589 ctb_addr_rs =
s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2592 if(x_ctb >=
s->ps.sps->width) {
2600 s->tab_slice_address[ctb_addr_rs] = -1;
2614 int64_t startheader, cmpt = 0;
2651 for (j = 0, cmpt = 0, startheader = offset + s->
sh.
entry_point_offset[0]; j < nal->skipped_bytes; j++) {
2660 for (j = 0, cmpt = 0, startheader = offset
2673 if (length < offset) {
2773 const int mapping[3] = {2, 0, 1};
2774 const int chroma_den = 50000;
2775 const int luma_den = 10000;
2782 for (i = 0; i < 3; i++) {
2783 const int j = mapping[
i];
2803 "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f)\n",
2812 "min_luminance=%f, max_luminance=%f\n",
2861 sizeof(uint32_t) * 4);
2865 tc_sd = (uint32_t*)tcside->
data;
2868 for (
int i = 0;
i < tc_sd[0];
i++) {
2960 int ctb_addr_ts,
ret;
3054 if (s->
max_ra == INT_MAX) {
3076 }
else if (!s->
ref) {
3083 "Non-matching NAL types of the VCL NALUs: %d %d\n",
3093 "Error constructing the reference lists for the current slice.\n");
3117 if (ctb_addr_ts < 0) {
3146 int eos_at_start = 1;
3159 "Error splitting the input into NAL units.\n");
3186 if (ret >= 0 && s->
overlap > 2)
3190 "Error parsing NAL unit #%d.\n", i);
3205 for (i = 0; i < 16; i++)
3206 av_log(log_ctx, level,
"%02"PRIx8, md5[i]);
3235 for (i = 0; frame->
data[
i]; i++) {
3243 for (j = 0; j <
h; j++) {
3248 (
const uint16_t *) src, w);
3320 &new_extradata_size);
3321 if (new_extradata && new_extradata_size > 0) {
3335 "hardware accelerator failed to decode picture\n");
3416 for (i = 0; i < 3; i++) {
3652 #define OFFSET(x) offsetof(HEVCContext, x) 3653 #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM) 3656 {
"apply_defdispwin",
"Apply default display window from VUI",
OFFSET(apply_defdispwin),
3658 {
"strict-displaywin",
"stricly apply default display window size",
OFFSET(apply_defdispwin),
3676 .priv_class = &hevc_decoder_class,
3688 #if CONFIG_HEVC_DXVA2_HWACCEL 3691 #if CONFIG_HEVC_D3D11VA_HWACCEL 3694 #if CONFIG_HEVC_D3D11VA2_HWACCEL 3697 #if CONFIG_HEVC_NVDEC_HWACCEL 3700 #if CONFIG_HEVC_VAAPI_HWACCEL 3703 #if CONFIG_HEVC_VDPAU_HWACCEL 3706 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL #define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static int set_side_data(HEVCContext *s)
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
static void luma_mc_uni(HEVCContext *s, uint8_t *dst, ptrdiff_t dststride, AVFrame *ref, const Mv *mv, int x_off, int y_off, int block_w, int block_h, int luma_weight, int luma_offset)
8.5.3.2.2.1 Luma sample unidirectional interpolation process
static void intra_prediction_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
unsigned int log2_min_cb_size
discard all frames except keyframes
uint8_t log2_sao_offset_scale_luma
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static enum AVPixelFormat pix_fmt
int anticlockwise_rotation
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static int verify_md5(HEVCContext *s, AVFrame *frame)
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
This structure describes decoded (raw) audio or video data.
void(* bswap16_buf)(uint16_t *dst, const uint16_t *src, int len)
int current_frame_is_frame0_flag
unsigned MaxCLL
Max content light level (cd/m^2).
#define atomic_store(object, desired)
AVBufferRef * vps_list[HEVC_MAX_VPS_COUNT]
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
enum AVStereo3DView view
Determines which views are packed.
uint8_t diff_cu_chroma_qp_offset_depth
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
int coded_width
Bitstream width / height, may be different from width/height e.g.
int max_dec_pic_buffering
void(* put_pcm)(uint8_t *_dst, ptrdiff_t _stride, int width, int height, struct GetBitContext *gb, int pcm_bit_depth)
void ff_hevc_pred_init(HEVCPredContext *hpc, int bit_depth)
int ff_hevc_split_coding_unit_flag_decode(HEVCContext *s, int ct_depth, int x0, int y0)
uint8_t edge_emu_buffer[(MAX_PB_SIZE+7)*EDGE_EMU_BUFFER_STRIDE *2]
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
void(* put_hevc_qpel_bi_w[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, int denom, int wx0, int wx1, int ox0, int ox1, intptr_t mx, intptr_t my, int width)
#define LIBAVUTIL_VERSION_INT
int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int16_t x
horizontal component of motion vector
hardware decoding through Videotoolbox
static av_cold int init(AVCodecContext *avctx)
static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
void * hwaccel_picture_private
uint8_t intra_split_flag
IntraSplitFlag.
int rem_intra_luma_pred_mode
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)
8.5.3.2.2.2 Chroma sample bidirectional interpolation process
enum AVColorRange color_range
MPEG vs JPEG YUV range.
static int hls_transform_tree(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, const int *base_cbf_cb, const int *base_cbf_cr)
void ff_hevc_flush_dpb(HEVCContext *s)
Drop all frames currently in DPB.
int ff_hevc_cbf_luma_decode(HEVCContext *s, int trafo_depth)
static const AVClass hevc_decoder_class
Timecode which conforms to SMPTE ST 12-1.
Views are next to each other, but when upscaling apply a checkerboard pattern.
#define HWACCEL_NVDEC(codec)
static void export_stream_params(HEVCContext *s, const HEVCSPS *sps)
Frame contains only the right view.
static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
const char * av_default_item_name(void *ptr)
Return the context name.
uint8_t weighted_bipred_flag
static void hevc_decode_flush(AVCodecContext *avctx)
int ff_hevc_sao_offset_sign_decode(HEVCContext *s)
int ff_hevc_frame_rps(HEVCContext *s)
Construct the reference picture sets for the current frame.
int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
uint8_t seq_loop_filter_across_slices_enabled_flag
uint8_t cabac_init_present_flag
int chroma_loc_info_present_flag
#define AV_PIX_FMT_YUV420P12
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void(* put_hevc_epel_uni[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width)
#define FF_ARRAY_ELEMS(a)
int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps, HEVCSEI *sei, int *is_nalff, int *nal_length_size, int err_recognition, int apply_defdispwin, void *logctx)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
discard all non intra frames
uint8_t used_by_curr_pic_lt_sps_flag[HEVC_MAX_LONG_TERM_REF_PICS]
ShortTermRPS st_rps[HEVC_MAX_SHORT_TERM_REF_PIC_SETS]
Views are next to each other.
int * ctb_addr_ts_to_rs
CtbAddrTSToRS.
int num_ref_idx_l0_default_active
num_ref_idx_l0_default_active_minus1 + 1
static void error(const char *err)
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
int8_t cr_qp_offset_list[6]
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before ff_thread_await_progress() has been called on them.reget_buffer() and buffer age optimizations no longer work.*The contents of buffers must not be written to after ff_thread_report_progress() has been called on them.This includes draw_edges().Porting codecs to frame threading
int ff_hevc_merge_flag_decode(HEVCContext *s)
#define SET_SAO(elem, value)
void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift)
int chroma_sample_loc_type_top_field
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static void hls_sao_param(HEVCContext *s, int rx, int ry)
uint16_t seq_decode
Sequence counters for decoded and output frames, so that old frames are output first after a POC rese...
static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb, int ctb_addr_ts)
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip)
Flip the input matrix horizontally and/or vertically.
void av_md5_update(AVMD5 *ctx, const uint8_t *src, int len)
Update hash value.
Macro definitions for various function/variable attributes.
HEVCSEIMasteringDisplay mastering_display
void av_display_rotation_set(int32_t matrix[9], double angle)
Initialize a transformation matrix describing a pure counterclockwise rotation by the specified angle...
Frame contains only the left view.
uint8_t entropy_coding_sync_enabled_flag
int ff_hevc_no_residual_syntax_flag_decode(HEVCContext *s)
enum AVDiscard skip_frame
Skip decoding for selected frames.
AVBufferPool * rpl_tab_pool
candidate references for the current frame
uint8_t log2_sao_offset_scale_chroma
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
void(* emulated_edge_mc)(uint8_t *dst, const uint8_t *src, ptrdiff_t dst_linesize, ptrdiff_t src_linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
uint8_t cnt_dropped_flag[3]
unsigned int log2_max_trafo_size
void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
void(* put_hevc_epel[10][2][2])(int16_t *dst, uint8_t *src, ptrdiff_t srcstride, int height, intptr_t mx, intptr_t my, int width)
AVBufferRef * sps_list[HEVC_MAX_SPS_COUNT]
int ff_hevc_split_transform_flag_decode(HEVCContext *s, int log2_trafo_size)
struct AVMD5 * av_md5_alloc(void)
Allocate an AVMD5 context.
int ff_hevc_sao_merge_flag_decode(HEVCContext *s)
HEVCSEIContentLight content_light
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
int is_nalff
this flag is != 0 if bitstream is encapsulated as a format defined in 14496-15
int ff_hevc_rem_intra_luma_pred_mode_decode(HEVCContext *s)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
enum HEVCNALUnitType nal_unit_type
#define HWACCEL_VDPAU(codec)
static av_always_inline void set_ct_depth(HEVCContext *s, int x0, int y0, int log2_cb_size, int ct_depth)
int(* decode_params)(AVCodecContext *avctx, int type, const uint8_t *buf, uint32_t buf_size)
Callback for parameter data (SPS/PPS/VPS etc).
static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_size)
Stereo 3D type: this structure describes how two videos are packed within a single video surface...
uint8_t ctb_up_right_flag
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
int ff_hevc_inter_pred_idc_decode(HEVCContext *s, int nPbW, int nPbH)
static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
struct HEVCFrame * ref[HEVC_MAX_REFS]
uint8_t vps_timing_info_present_flag
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int log2_trafo_size)
#define BOUNDARY_LEFT_TILE
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But first
int ff_hevc_part_mode_decode(HEVCContext *s, int log2_cb_size)
int num_ref_idx_l1_default_active
num_ref_idx_l1_default_active_minus1 + 1
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int is_nalff, int nal_length_size, enum AVCodecID codec_id, int small_padding, int use_ref)
Split an input packet into NAL units.
unsigned int log2_min_pcm_cb_size
uint8_t poc_msb_present[32]
HDR dynamic metadata associated with a video frame.
int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCContext *s)
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
#define QPEL_EXTRA_BEFORE
Structure to hold side data for an AVFrame.
int ff_hevc_slice_rpl(HEVCContext *s)
Construct the reference picture list(s) for the current slice.
HEVCSEIUnregistered unregistered
static double av_q2d(AVRational a)
Convert an AVRational to a double.
void ff_hevc_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size)
int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0, int x_cb, int y_cb)
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
void(* put_hevc_qpel_uni_w[10][2][2])(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width)
AVDictionary * metadata
metadata.
AVBufferRef * pps_list[HEVC_MAX_PPS_COUNT]
uint8_t loop_filter_disable_flag
HEVCSEIDynamicHDRPlus dynamic_hdr_plus
int ff_hevc_cbf_cb_cr_decode(HEVCContext *s, int trafo_depth)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
uint8_t cu_transquant_bypass_flag