42 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 };
87 int pic_size_in_ctb = ((width >> log2_min_cb_size) + 1) *
88 ((height >> log2_min_cb_size) + 1);
142 uint8_t luma_weight_l0_flag[16];
143 uint8_t chroma_weight_l0_flag[16];
144 uint8_t luma_weight_l1_flag[16];
145 uint8_t chroma_weight_l1_flag[16];
146 int luma_log2_weight_denom;
149 if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7)
159 if (!luma_weight_l0_flag[i]) {
166 chroma_weight_l0_flag[i] =
get_bits1(gb);
169 chroma_weight_l0_flag[i] = 0;
172 if (luma_weight_l0_flag[i]) {
177 if (chroma_weight_l0_flag[i]) {
178 for (j = 0; j < 2; j++) {
195 if (!luma_weight_l1_flag[i]) {
202 chroma_weight_l1_flag[i] =
get_bits1(gb);
205 chroma_weight_l1_flag[i] = 0;
208 if (luma_weight_l1_flag[i]) {
213 if (chroma_weight_l1_flag[i]) {
214 for (j = 0; j < 2; j++) {
235 int prev_delta_msb = 0;
236 unsigned int nb_sps = 0, nb_sh;
252 for (i = 0; i < rps->
nb_refs; i++) {
269 if (delta_poc_msb_present) {
272 if (i && i != nb_sps)
273 delta += prev_delta_msb;
276 prev_delta_msb =
delta;
285 #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL)
288 unsigned int num = 0, den = 0;
302 #if CONFIG_HEVC_DXVA2_HWACCEL
337 for (i = 0; i < 3; i++) {
346 for(c_idx = 0; c_idx < c_count; c_idx++) {
369 if (num != 0 && den != 0)
436 int slice_address_length;
446 "Invalid slice segment address: %u.\n",
495 "Ignoring POC change between slices: %d -> %d\n", s->
poc, poc);
512 int numbits, rps_idx;
520 rps_idx = numbits > 0 ?
get_bits(gb, numbits) : 0;
623 "Invalid collocated_ref_idx: %d.\n",
638 "Invalid number of merging MVP candidates: %d.\n",
660 int deblocking_filter_override_flag = 0;
663 deblocking_filter_override_flag =
get_bits1(gb);
665 if (deblocking_filter_override_flag) {
707 int segments = offset_len >> 4;
708 int rest = (offset_len & 15);
710 if (offset_len < 1 || offset_len > 32) {
729 for (j = 0; j < segments; j++) {
754 for (i = 0; i <
length; i++)
763 "The slice_qp %d is outside the valid range "
797 #define CTB(tab, x, y) ((tab)[(y) * s->sps->ctb_width + (x)])
799 #define SET_SAO(elem, value) \
801 if (!sao_merge_up_flag && !sao_merge_left_flag) \
803 else if (sao_merge_left_flag) \
804 sao->elem = CTB(s->sao, rx-1, ry).elem; \
805 else if (sao_merge_up_flag) \
806 sao->elem = CTB(s->sao, rx, ry-1).elem; \
814 int sao_merge_left_flag = 0;
815 int sao_merge_up_flag = 0;
825 if (ry > 0 && !sao_merge_left_flag) {
850 for (i = 0; i < 4; i++)
854 for (i = 0; i < 4; i++) {
863 }
else if (c_idx != 2) {
869 for (i = 0; i < 4; i++) {
877 sao->
offset_val[c_idx][i + 1] <<= log2_sao_offset_scale;
889 if (log2_res_scale_abs_plus1 != 0) {
892 (1 - 2 * res_scale_sign_flag);
902 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
903 int log2_cb_size,
int log2_trafo_size,
904 int blk_idx,
int cbf_luma,
int *cbf_cb,
int *cbf_cr)
907 const int log2_trafo_size_c = log2_trafo_size - s->
sps->
hshift[1];
911 int trafo_size = 1 << log2_trafo_size;
917 if (cbf_luma || cbf_cb[0] || cbf_cr[0] ||
921 int cbf_chroma = cbf_cb[0] || cbf_cr[0] ||
923 (cbf_cb[1] || cbf_cr[1]));
935 "The cu_qp_delta %d is outside the valid range "
949 if (cu_chroma_qp_offset_flag) {
950 int cu_chroma_qp_offset_idx = 0;
954 "cu_chroma_qp_offset_idx not yet tested.\n");
988 int trafo_size_h = 1 << (log2_trafo_size_c + s->
sps->
hshift[1]);
989 int trafo_size_v = 1 << (log2_trafo_size_c + s->
sps->
vshift[1]);
1000 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (i << log2_trafo_size_c), 1);
1004 log2_trafo_size_c, scan_idx_c, 1);
1012 int size = 1 << log2_trafo_size_c;
1016 for (i = 0; i < (size *
size); i++) {
1029 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (i << log2_trafo_size_c), 2);
1033 log2_trafo_size_c, scan_idx_c, 2);
1041 int size = 1 << log2_trafo_size_c;
1045 for (i = 0; i < (size *
size); i++) {
1052 int trafo_size_h = 1 << (log2_trafo_size + 1);
1053 int trafo_size_v = 1 << (log2_trafo_size + s->
sps->
vshift[1]);
1057 trafo_size_h, trafo_size_v);
1058 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (i << log2_trafo_size), 1);
1062 log2_trafo_size, scan_idx_c, 1);
1067 trafo_size_h, trafo_size_v);
1068 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (i << log2_trafo_size), 2);
1072 log2_trafo_size, scan_idx_c, 2);
1077 int trafo_size_h = 1 << (log2_trafo_size_c + s->
sps->
hshift[1]);
1078 int trafo_size_v = 1 << (log2_trafo_size_c + s->
sps->
vshift[1]);
1084 trafo_size_h, trafo_size_v);
1085 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (1 << log2_trafo_size_c), 1);
1086 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (1 << log2_trafo_size_c), 2);
1088 }
else if (blk_idx == 3) {
1089 int trafo_size_h = 1 << (log2_trafo_size + 1);
1090 int trafo_size_v = 1 << (log2_trafo_size + s->
sps->
vshift[1]);
1092 trafo_size_h, trafo_size_v);
1097 trafo_size_h, trafo_size_v);
1098 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (1 << (log2_trafo_size)), 1);
1099 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (1 << (log2_trafo_size)), 2);
1109 int cb_size = 1 << log2_cb_size;
1117 for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
1118 for (i = (x0 >> log2_min_pu_size); i < (x_end >> log2_min_pu_size); i++)
1119 s->
is_pcm[i + j * min_pu_width] = 2;
1123 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1124 int log2_cb_size,
int log2_trafo_size,
1125 int trafo_depth,
int blk_idx,
1126 const int *base_cbf_cb,
const int *base_cbf_cr)
1134 cbf_cb[0] = base_cbf_cb[0];
1135 cbf_cb[1] = base_cbf_cb[1];
1136 cbf_cr[0] = base_cbf_cr[0];
1137 cbf_cr[1] = base_cbf_cr[1];
1140 if (trafo_depth == 1) {
1156 if (log2_trafo_size <= s->sps->log2_max_trafo_size &&
1158 trafo_depth < lc->cu.max_trafo_depth &&
1173 if (trafo_depth == 0 || cbf_cb[0]) {
1180 if (trafo_depth == 0 || cbf_cr[0]) {
1188 if (split_transform_flag) {
1189 const int trafo_size_split = 1 << (log2_trafo_size - 1);
1190 const int x1 = x0 + trafo_size_split;
1191 const int y1 = y0 + trafo_size_split;
1193 #define SUBDIVIDE(x, y, idx) \
1195 ret = hls_transform_tree(s, x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size, \
1196 log2_trafo_size - 1, trafo_depth + 1, idx, \
1215 cbf_cb[0] || cbf_cr[0] ||
1221 log2_cb_size, log2_trafo_size,
1222 blk_idx, cbf_luma, cbf_cb, cbf_cr);
1228 for (i = 0; i < (1 << log2_trafo_size); i += min_tu_size)
1229 for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) {
1230 int x_tu = (x0 + j) >> log2_min_tu_size;
1231 int y_tu = (y0 + i) >> log2_min_tu_size;
1232 s->
cbf_luma[y_tu * min_tu_width + x_tu] = 1;
1249 int cb_size = 1 << log2_cb_size;
1304 int block_w,
int block_h,
int luma_weight,
int luma_offset)
1308 ptrdiff_t srcstride = ref->
linesize[0];
1317 x_off += mv->
x >> 2;
1318 y_off += mv->
y >> 2;
1329 edge_emu_stride, srcstride,
1333 pic_width, pic_height);
1335 srcstride = edge_emu_stride;
1340 block_h, mx, my, block_w);
1344 luma_weight, luma_offset, mx, my, block_w);
1364 AVFrame *ref0,
const Mv *mv0,
int x_off,
int y_off,
1365 int block_w,
int block_h,
AVFrame *ref1,
const Mv *mv1,
struct MvField *current_mv)
1368 ptrdiff_t src0stride = ref0->
linesize[0];
1369 ptrdiff_t src1stride = ref1->
linesize[0];
1372 int mx0 = mv0->
x & 3;
1373 int my0 = mv0->
y & 3;
1374 int mx1 = mv1->
x & 3;
1375 int my1 = mv1->
y & 3;
1378 int x_off0 = x_off + (mv0->
x >> 2);
1379 int y_off0 = y_off + (mv0->
y >> 2);
1380 int x_off1 = x_off + (mv1->
x >> 2);
1381 int y_off1 = y_off + (mv1->
y >> 2);
1395 edge_emu_stride, src0stride,
1399 pic_width, pic_height);
1401 src0stride = edge_emu_stride;
1412 edge_emu_stride, src1stride,
1416 pic_width, pic_height);
1418 src1stride = edge_emu_stride;
1422 block_h, mx0, my0, block_w);
1425 block_h, mx1, my1, block_w);
1455 ptrdiff_t dststride,
uint8_t *src0, ptrdiff_t srcstride,
int reflist,
1456 int x_off,
int y_off,
int block_w,
int block_h,
struct MvField *current_mv,
int chroma_weight,
int chroma_offset)
1461 const Mv *
mv = ¤t_mv->
mv[reflist];
1467 intptr_t mx = mv->
x & ((1 << (2 + hshift)) - 1);
1468 intptr_t my = mv->
y & ((1 << (2 + vshift)) - 1);
1469 intptr_t _mx = mx << (1 - hshift);
1470 intptr_t _my = my << (1 - vshift);
1472 x_off += mv->
x >> (2 + hshift);
1473 y_off += mv->
y >> (2 + vshift);
1484 edge_emu_stride, srcstride,
1488 pic_width, pic_height);
1491 srcstride = edge_emu_stride;
1495 block_h, _mx, _my, block_w);
1499 chroma_weight, chroma_offset, _mx, _my, block_w);
1520 int x_off,
int y_off,
int block_w,
int block_h,
struct MvField *current_mv,
int cidx)
1525 ptrdiff_t src1stride = ref0->
linesize[cidx+1];
1526 ptrdiff_t src2stride = ref1->
linesize[cidx+1];
1531 Mv *mv0 = ¤t_mv->
mv[0];
1532 Mv *mv1 = ¤t_mv->
mv[1];
1536 intptr_t mx0 = mv0->
x & ((1 << (2 + hshift)) - 1);
1537 intptr_t my0 = mv0->
y & ((1 << (2 + vshift)) - 1);
1538 intptr_t mx1 = mv1->
x & ((1 << (2 + hshift)) - 1);
1539 intptr_t my1 = mv1->
y & ((1 << (2 + vshift)) - 1);
1540 intptr_t _mx0 = mx0 << (1 - hshift);
1541 intptr_t _my0 = my0 << (1 - vshift);
1542 intptr_t _mx1 = mx1 << (1 - hshift);
1543 intptr_t _my1 = my1 << (1 - vshift);
1545 int x_off0 = x_off + (mv0->
x >> (2 + hshift));
1546 int y_off0 = y_off + (mv0->
y >> (2 + vshift));
1547 int x_off1 = x_off + (mv1->
x >> (2 + hshift));
1548 int y_off1 = y_off + (mv1->
y >> (2 + vshift));
1550 src1 += y_off0 * src1stride + (int)((
unsigned)x_off0 << s->
sps->
pixel_shift);
1551 src2 += y_off1 * src2stride + (int)((
unsigned)x_off1 << s->
sps->
pixel_shift);
1562 edge_emu_stride, src1stride,
1566 pic_width, pic_height);
1569 src1stride = edge_emu_stride;
1581 edge_emu_stride, src2stride,
1585 pic_width, pic_height);
1588 src2stride = edge_emu_stride;
1592 block_h, _mx0, _my0, block_w);
1595 src2, src2stride, lc->
tmp,
1596 block_h, _mx1, _my1, block_w);
1599 src2, src2stride, lc->
tmp,
1606 _mx1, _my1, block_w);
1612 int y =
FFMAX(0, (mv->
y >> 2) + y0 + height + 9);
1619 int nPbH,
int log2_cb_size,
int part_idx,
1631 if (inter_pred_idc !=
PRED_L1) {
1639 part_idx, merge_idx, mv, mvp_flag, 0);
1644 if (inter_pred_idc !=
PRED_L0) {
1657 part_idx, merge_idx, mv, mvp_flag, 1);
1665 int log2_cb_size,
int partIdx,
int idx)
1667 #define POS(c_idx, x, y) \
1668 &s->frame->data[c_idx][((y) >> s->sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \
1669 (((x) >> s->sps->hshift[c_idx]) << s->sps->pixel_shift)]
1672 struct MvField current_mv = {{{ 0 }}};
1684 int x_cb = x0 >> log2_min_cb_size;
1685 int y_cb = y0 >> log2_min_cb_size;
1701 partIdx, merge_idx, ¤t_mv);
1704 partIdx, merge_idx, ¤t_mv);
1712 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
1715 ref0 = refPicList[0].
ref[current_mv.
ref_idx[0]];
1721 ref1 = refPicList[1].
ref[current_mv.
ref_idx[1]];
1734 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
1740 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1743 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1753 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH,
1759 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1763 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1773 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
1774 ref1->frame, ¤t_mv.
mv[1], ¤t_mv);
1778 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0);
1781 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 1);
1790 int prev_intra_luma_pred_flag)
1808 int intra_pred_mode;
1813 if ((y0 - 1) < y_ctb)
1816 if (cand_left == cand_up) {
1817 if (cand_left < 2) {
1822 candidate[0] = cand_left;
1823 candidate[1] = 2 + ((cand_left - 2 - 1 + 32) & 31);
1824 candidate[2] = 2 + ((cand_left - 2 + 1) & 31);
1827 candidate[0] = cand_left;
1828 candidate[1] = cand_up;
1838 if (prev_intra_luma_pred_flag) {
1839 intra_pred_mode = candidate[lc->
pu.
mpm_idx];
1841 if (candidate[0] > candidate[1])
1843 if (candidate[0] > candidate[2])
1845 if (candidate[1] > candidate[2])
1849 for (i = 0; i < 3; i++)
1850 if (intra_pred_mode >= candidate[i])
1857 for (i = 0; i < size_in_pus; i++) {
1858 memset(&s->
tab_ipm[(y_pu + i) * min_pu_width + x_pu],
1859 intra_pred_mode, size_in_pus);
1861 for (j = 0; j < size_in_pus; j++) {
1866 return intra_pred_mode;
1870 int log2_cb_size,
int ct_depth)
1883 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20,
1884 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31};
1890 static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 };
1891 uint8_t prev_intra_luma_pred_flag[4];
1893 int pb_size = (1 << log2_cb_size) >> split;
1894 int side = split + 1;
1898 for (i = 0; i < side; i++)
1899 for (j = 0; j < side; j++)
1902 for (i = 0; i < side; i++) {
1903 for (j = 0; j < side; j++) {
1904 if (prev_intra_luma_pred_flag[2 * i + j])
1911 prev_intra_luma_pred_flag[2 * i + j]);
1916 for (i = 0; i < side; i++) {
1917 for (j = 0; j < side; j++) {
1919 if (chroma_mode != 4) {
1932 if (chroma_mode != 4) {
1936 mode_idx = intra_chroma_table[chroma_mode];
1943 if (chroma_mode != 4) {
1959 int pb_size = 1 << log2_cb_size;
1967 if (size_in_pus == 0)
1969 for (j = 0; j < size_in_pus; j++)
1970 memset(&s->
tab_ipm[(y_pu + j) * min_pu_width + x_pu],
INTRA_DC, size_in_pus);
1972 for (j = 0; j < size_in_pus; j++)
1973 for (k = 0; k < size_in_pus; k++)
1979 int cb_size = 1 << log2_cb_size;
1982 int length = cb_size >> log2_min_cb_size;
1984 int x_cb = x0 >> log2_min_cb_size;
1985 int y_cb = y0 >> log2_min_cb_size;
1986 int idx = log2_cb_size - 2;
1997 for (x = 0; x < 4; x++)
2009 x = y_cb * min_cb_width + x_cb;
2010 for (y = 0; y <
length; y++) {
2011 memset(&s->
skip_flag[x], skip_flag, length);
2016 x = y_cb * min_cb_width + x_cb;
2017 for (y = 0; y <
length; y++) {
2044 log2_cb_size <= s->sps->pcm.log2_max_pcm_cb_size) {
2070 hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
2074 hls_prediction_unit(s, x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
2078 hls_prediction_unit(s, x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);
2082 hls_prediction_unit(s, x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
2086 hls_prediction_unit(s, x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
2090 hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
2091 hls_prediction_unit(s, x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
2092 hls_prediction_unit(s, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
2098 int rqt_root_cbf = 1;
2105 const static int cbf[2] = { 0 };
2111 log2_cb_size, 0, 0, cbf, cbf);
2124 x = y_cb * min_cb_width + x_cb;
2125 for (y = 0; y <
length; y++) {
2130 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2131 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0) {
2141 int log2_cb_size,
int cb_depth)
2144 const int cb_size = 1 << log2_cb_size;
2149 if (x0 + cb_size <= s->sps->width &&
2150 y0 + cb_size <= s->sps->height &&
2169 const int cb_size_split = cb_size >> 1;
2170 const int x1 = x0 + cb_size_split;
2171 const int y1 = y0 + cb_size_split;
2179 if (more_data && x1 < s->sps->width) {
2184 if (more_data && y1 < s->sps->height) {
2189 if (more_data && x1 < s->sps->width &&
2190 y1 < s->sps->height) {
2196 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2197 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0)
2201 return ((x1 + cb_size_split) < s->
sps->
width ||
2209 if ((!((x0 + cb_size) %
2211 (x0 + cb_size >= s->
sps->
width)) &&
2216 return !end_of_slice_flag;
2231 int ctb_addr_in_slice = ctb_addr_rs - s->
sh.
slice_addr;
2236 if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
2262 if (!ctb_addr_in_slice > 0)
2264 if (ctb_addr_in_slice < s->sps->ctb_width)
2296 while (more_data && ctb_addr_ts < s->sps->ctb_size) {
2312 if (more_data < 0) {
2323 if (x_ctb + ctb_size >= s->
sps->
width &&
2347 int *ctb_row_p = input_ctb_row;
2348 int ctb_row = ctb_row_p[job];
2358 ret =
init_get_bits8(&lc->
gb,
s->data +
s->sh.offset[ctb_row - 1],
s->sh.size[ctb_row - 1]);
2365 while(more_data && ctb_addr_ts < s->sps->ctb_size) {
2366 int x_ctb = (ctb_addr_rs %
s->sps->ctb_width) <<
s->sps->log2_ctb_size;
2367 int y_ctb = (ctb_addr_rs /
s->sps->ctb_width) <<
s->sps->log2_ctb_size;
2379 hls_sao_param(
s, x_ctb >>
s->sps->log2_ctb_size, y_ctb >>
s->sps->log2_ctb_size);
2382 if (more_data < 0) {
2383 s->tab_slice_address[ctb_addr_rs] = -1;
2395 if (!more_data && (x_ctb+ctb_size) <
s->sps->width && ctb_row !=
s->sh.num_entry_point_offsets) {
2401 if ((x_ctb+ctb_size) >=
s->sps->width && (y_ctb+ctb_size) >=
s->sps->height ) {
2406 ctb_addr_rs =
s->pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2409 if(x_ctb >=
s->sps->width) {
2424 int64_t startheader, cmpt = 0;
2455 for (j = 0, cmpt = 0, startheader = offset + s->
sh.
entry_point_offset[0]; j < s->skipped_bytes; j++) {
2464 for (j = 0, cmpt = 0, startheader = offset
2477 if (length < offset) {
2534 "nal_unit_type: %d, nuh_layer_id: %d, temporal_id: %d\n",
2537 return nuh_layer_id == 0;
2650 int ctb_addr_ts,
ret;
2706 if (s->
max_ra == INT_MAX) {
2728 }
else if (!s->
ref) {
2735 "Non-matching NAL types of the VCL NALUs: %d %d\n",
2745 "Error constructing the reference lists for the current slice.\n");
2769 if (ctb_addr_ts < 0) {
2804 #define STARTCODE_TEST \
2805 if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
2806 if (src[i + 2] != 3) { \
2812 #if HAVE_FAST_UNALIGNED
2813 #define FIND_FIRST_ZERO \
2814 if (i > 0 && !src[i]) \
2819 for (i = 0; i + 1 <
length; i += 9) {
2821 (
AV_RN64A(src + i) - 0x0100010001000101ULL)) &
2822 0x8000800080008080ULL))
2829 for (i = 0; i + 1 <
length; i += 5) {
2831 (
AV_RN32A(src + i) - 0x01000101U)) &
2840 for (i = 0; i + 1 <
length; i += 2) {
2843 if (i > 0 && src[i - 1] == 0)
2849 if (i >= length - 1) {
2864 memcpy(dst, src, i);
2866 while (si + 2 < length) {
2868 if (src[si + 2] > 3) {
2869 dst[di++] = src[si++];
2870 dst[di++] = src[si++];
2871 }
else if (src[si] == 0 && src[si + 1] == 0) {
2872 if (src[si + 2] == 3) {
2893 dst[di++] = src[si++];
2896 dst[di++] = src[si++];
2910 int i, consumed,
ret = 0;
2919 while (length >= 4) {
2921 int extract_length = 0;
2926 extract_length = (extract_length << 8) | buf[i];
2930 if (extract_length > length) {
2937 while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
3016 for (i = 0; i < s->
nb_nals; i++) {
3023 "Error parsing NAL unit #%d.\n", i);
3038 for (i = 0; i < 16; i++)
3039 av_log(log_ctx, level,
"%02"PRIx8, md5[i]);
3068 for (i = 0; frame->
data[i]; i++) {
3076 for (j = 0; j < h; j++) {
3081 (
const uint16_t *) src, w);
3089 if (!memcmp(md5, s->
md5[i], 16)) {
3131 "hardware accelerator failed to decode picture\n");
3217 for (i = 0; i < 3; i++) {
3407 int i, j, num_arrays, nal_len_size;
3412 nal_len_size = (bytestream2_get_byte(&gb) & 3) + 1;
3413 num_arrays = bytestream2_get_byte(&gb);
3420 for (i = 0; i < num_arrays; i++) {
3421 int type = bytestream2_get_byte(&gb) & 0x3f;
3422 int cnt = bytestream2_get_be16(&gb);
3424 for (j = 0; j < cnt; j++) {
3426 int nalsize = bytestream2_peek_be16(&gb) + 2;
3429 "Invalid NAL unit size in extradata.\n");
3436 "Decoding nal unit %d %d from hvcC failed\n",
3499 memset(s, 0,
sizeof(*s));
3516 #define OFFSET(x) offsetof(HEVCContext, x)
3517 #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
3528 {
"apply_defdispwin",
"Apply default display window from VUI",
OFFSET(apply_defdispwin),
3530 {
"strict-displaywin",
"stricly apply default display window size",
OFFSET(apply_defdispwin),
3548 .priv_class = &hevc_decoder_class,
#define EDGE_EMU_BUFFER_STRIDE
const uint8_t ff_hevc_pel_weight[65]
int frame_packing_arrangement_type
unsigned int log2_min_cb_size
int sei_frame_packing_present
frame packing arrangement variables
const char const char void * val
int(* start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Called at the beginning of each frame or field picture.
uint8_t log2_sao_offset_scale_luma
int ff_hevc_merge_idx_decode(HEVCContext *s)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
int ff_hevc_frame_nb_refs(HEVCContext *s)
Get the number of candidate references for the current frame.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
Views are alternated temporally.
uint8_t diff_cu_chroma_qp_offset_depth
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
int ff_hevc_merge_flag_decode(HEVCContext *s)
int ff_hevc_sao_band_position_decode(HEVCContext *s)
int coded_width
Bitstream width / height, may be different from width/height e.g.
int max_dec_pic_buffering
void ff_hevc_pred_init(HEVCPredContext *hpc, int bit_depth)
uint8_t edge_emu_buffer[(MAX_PB_SIZE+7)*EDGE_EMU_BUFFER_STRIDE *2]
static void hevc_await_progress(HEVCContext *s, HEVCFrame *ref, const Mv *mv, int y0, int height)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
int ff_hevc_decode_nal_sps(HEVCContext *s)
Views are next to each other, but when upscaling apply a checkerboard pattern.
#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)
int content_interpretation_type
int ff_hevc_cbf_luma_decode(HEVCContext *s, int trafo_depth)
int8_t cb_qp_offset_list[5]
#define LIBAVUTIL_VERSION_INT
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int16_t x
horizontal component of motion vector
void(* bswap16_buf)(uint16_t *dst, const uint16_t *src, int len)
static av_cold int init(AVCodecContext *avctx)
#define FF_PROFILE_HEVC_MAIN_STILL_PICTURE
void * hwaccel_picture_private
static int hevc_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
static int set_sps(HEVCContext *s, const HEVCSPS *sps)
int ff_hevc_end_of_slice_flag_decode(HEVCContext *s)
uint8_t intra_split_flag
IntraSplitFlag.
int rem_intra_luma_pred_mode
enum AVColorRange color_range
MPEG vs JPEG YUV range.
void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv)
uint8_t weighted_bipred_flag
void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header)
int ff_hevc_rem_intra_luma_pred_mode_decode(HEVCContext *s)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static void intra_prediction_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
uint8_t seq_loop_filter_across_slices_enabled_flag
uint8_t cabac_init_present_flag
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everythnig 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)
int ff_hevc_frame_rps(HEVCContext *s)
Construct the reference picture sets for the current frame.
#define FF_ARRAY_ELEMS(a)
int * ctb_addr_ts_to_rs
CtbAddrTSToRS.
int num_ref_idx_l0_default_active
num_ref_idx_l0_default_active_minus1 + 1
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
struct HEVCFrame * ref[MAX_REFS]
ShortTermRPS st_rps[MAX_SHORT_TERM_RPS_COUNT]
void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
int ff_hevc_sao_type_idx_decode(HEVCContext *s)
uint16_t seq_decode
Sequence counters for decoded and output frames, so that old frames are output first after a POC rese...
void av_md5_update(AVMD5 *ctx, const uint8_t *src, int len)
Update hash value.
enum NALUnitType first_nal_type
Macro definitions for various function/variable attributes.
uint8_t entropy_coding_sync_enabled_flag
int ff_hevc_cu_transquant_bypass_flag_decode(HEVCContext *s)
static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread)
static int hls_slice_data(HEVCContext *s)
static void hls_sao_param(HEVCContext *s, int rx, int ry)
AVBufferPool * rpl_tab_pool
candidate references for the current frame
uint8_t log2_sao_offset_scale_chroma
struct AVHWAccel * hwaccel
Hardware accelerator in use.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
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)
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...
unsigned int log2_max_trafo_size
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)
struct AVMD5 * av_md5_alloc(void)
Allocate an AVMD5 context.
int ff_hevc_mpm_idx_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.
int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0, int x_cb, int y_cb)
Stereo 3D type: this structure describes how two videos are packed within a single video surface...
static int set_side_data(HEVCContext *s)
uint8_t ctb_up_right_flag
uint8_t vps_timing_info_present_flag
static int hls_slice_header(HEVCContext *s)
#define FF_PROFILE_UNKNOWN
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.
unsigned int log2_min_pcm_cb_size
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
#define avpriv_atomic_int_set
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
int ff_hevc_decode_nal_sei(HEVCContext *s)
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)
#define EPEL_EXTRA_BEFORE
uint8_t loop_filter_disable_flag
static void print_md5(void *log_ctx, int level, uint8_t md5[16])
int sei_anticlockwise_rotation
void ff_hevc_flush_dpb(HEVCContext *s)
Drop all frames currently in DPB.
static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
uint8_t cu_transquant_bypass_flag
int16_t tmp[MAX_PB_SIZE *MAX_PB_SIZE]
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
int * skipped_bytes_pos_size_nal
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 blk_idx, int cbf_luma, int *cbf_cb, int *cbf_cr)
void(* put_hevc_qpel[10][2][2])(int16_t *dst, uint8_t *src, ptrdiff_t srcstride, int height, intptr_t mx, intptr_t my, int width)
static av_unused const uint8_t * skip_bytes(CABACContext *c, int n)
Skip n bytes and reset the decoder.
uint8_t transquant_bypass_enable_flag
int ff_hevc_sao_offset_sign_decode(HEVCContext *s)
int temporal_id
temporal_id_plus1 - 1
#define SET_SAO(elem, value)
HEVCLocalContext * HEVClcList[MAX_NB_THREADS]
static void hevc_decode_flush(AVCodecContext *avctx)
static void luma_mc_bi(HEVCContext *s, uint8_t *dst, ptrdiff_t dststride, AVFrame *ref0, const Mv *mv0, int x_off, int y_off, int block_w, int block_h, AVFrame *ref1, const Mv *mv1, struct MvField *current_mv)
8.5.3.2.2.1 Luma sample bidirectional interpolation process
int8_t cr_qp_offset_list[5]
int slice_idx
number of the slice being currently decoded
#define BOUNDARY_UPPER_SLICE
static int get_bits_left(GetBitContext *gb)
uint8_t intra_pred_mode[4]
uint16_t depth_minus1
Number of bits in the component minus 1.
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int has_b_frames
Size of the frame reordering buffer in the decoder.
int flags
Additional information about the frame packing.
static av_cold int hevc_init_thread_copy(AVCodecContext *avctx)
int ff_hevc_cu_chroma_qp_offset_flag(HEVCContext *s)
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int log2_trafo_size)
uint8_t slice_initialized
1 if the independent slice segment header was successfully parsed
unsigned int log2_max_poc_lsb
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
AVBufferRef * vps_list[MAX_VPS_COUNT]
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
AVBufferRef * rpl_tab_buf
#define avpriv_atomic_int_get
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int vui_timing_info_present_flag
AVBufferRef * current_sps
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
struct HEVCSPS::@51 temporal_layer[MAX_SUB_LAYERS]
int active_thread_type
Which multithreading methods are in use by the codec.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void(* intra_pred[4])(struct HEVCContext *s, int x0, int y0, int c_idx)
int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb)
Compute POC of the current frame and return it.
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
unsigned int log2_ctb_size
void(* transform_add[4])(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride)
int ** skipped_bytes_pos_nal
uint8_t * sao_pixel_buffer_h[3]
const char * name
Name of the codec implementation.
void ff_init_cabac_states(void)
static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
void ff_hevc_save_states(HEVCContext *s, int ctb_addr_ts)
static const uint8_t offset[127][2]
static int verify_md5(HEVCContext *s, AVFrame *frame)
int ff_hevc_cu_chroma_qp_offset_idx(HEVCContext *s)
static const AVClass hevc_decoder_class
uint8_t max_trafo_depth
MaxTrafoDepth.
uint8_t edge_emu_buffer2[(MAX_PB_SIZE+7)*EDGE_EMU_BUFFER_STRIDE *2]
uint16_t sequence
A sequence counter, so that old frames are output first after a POC reset.
static char * split(char *message, char delim)
uint8_t tiles_enabled_flag
int ff_hevc_decode_nal_vps(HEVCContext *s)
int ff_alloc_entries(AVCodecContext *avctx, int count)
int eo_class[3]
sao_eo_class
uint32_t vps_num_units_in_tick
static av_cold int hevc_init_context(AVCodecContext *avctx)
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
struct HEVCContext * sList[MAX_NB_THREADS]
common internal API header
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int ff_hevc_mvp_lx_flag_decode(HEVCContext *s)
uint8_t lists_modification_present_flag
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
AVBufferRef * tab_mvf_buf
uint8_t type_idx[3]
sao_type_idx
enum AVPictureType pict_type
Picture type of the frame.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
int max_transform_hierarchy_depth_inter
static const AVOption options[]
uint8_t * sao_pixel_buffer_v[3]
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
int offset_abs[3][4]
sao_offset_abs
int num_tile_columns
num_tile_columns_minus1 + 1
int width
picture width / height.
int ff_hevc_output_frame(HEVCContext *s, AVFrame *frame, int flush)
Find next frame in output order and put a reference to it in frame.
#define FF_PROFILE_HEVC_MAIN_10
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
static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size)
static int luma_intra_pred_mode(HEVCContext *s, int x0, int y0, int pu_size, int prev_intra_luma_pred_flag)
8.4.1
int ff_hevc_part_mode_decode(HEVCContext *s, int log2_cb_size)
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
AVBufferRef * sps_list[MAX_SPS_COUNT]
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
int ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size)
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
uint8_t cu_qp_delta_enabled_flag
uint8_t used_by_curr_pic_lt_sps_flag[32]
static int hls_pcm_sample(HEVCContext *s, int x0, int y0, int log2_cb_size)
Context Adaptive Binary Arithmetic Coder inline functions.
void ff_hevc_set_neighbour_available(HEVCContext *s, int x0, int y0, int nPbW, int nPbH)
void(* put_hevc_qpel_bi[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width)
uint8_t output_flag_present_flag
void ff_hevc_set_qPy(HEVCContext *s, int xBase, int yBase, int log2_cb_size)
void av_display_rotation_set(int32_t matrix[9], double angle)
Initialize a transformation matrix describing a pure rotation by the specified angle (in degrees)...
static int hevc_frame_start(HEVCContext *s)
AVBufferRef * pps_list[MAX_PPS_COUNT]
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
static void flush(AVCodecContext *avctx)
the normal 2^n-1 "JPEG" YUV ranges
uint8_t pic_slice_level_chroma_qp_offsets_present_flag
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
int ff_hevc_split_coding_unit_flag_decode(HEVCContext *s, int ct_depth, int x0, int y0)
void ff_reset_entries(AVCodecContext *avctx)
int colour_description_present_flag
static const int8_t mv[256][2]
static void chroma_mc_uni(HEVCContext *s, uint8_t *dst0, ptrdiff_t dststride, uint8_t *src0, ptrdiff_t srcstride, int reflist, int x_off, int y_off, int block_w, int block_h, struct MvField *current_mv, int chroma_weight, int chroma_offset)
8.5.3.2.2.2 Chroma sample uniprediction interpolation process
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
enum AVPixelFormat pix_fmt
void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size)
int sei_display_orientation_present
display orientation
int ff_hevc_res_scale_sign_flag(HEVCContext *s, int idx)
void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
enum AVStereo3DType type
How views are packed within the video.
#define AV_LOG_INFO
Standard information.
static int pic_arrays_init(HEVCContext *s, const HEVCSPS *sps)
static void pic_arrays_free(HEVCContext *s)
NOTE: Each function hls_foo correspond to the function foo in the specification (HLS stands for High ...
static av_cold int hevc_decode_init(AVCodecContext *avctx)
void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n)
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
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
uint8_t is_nalff
this flag is != 0 if bitstream is encapsulated as a format defined in 14496-15
int * ctb_addr_rs_to_ts
CtbAddrRSToTS.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
unsigned int log2_min_pu_size
int ff_hevc_decode_nal_pps(HEVCContext *s)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
unsigned int sps_id
seq_parameter_set_id
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
main external API structure.
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip)
Flip the input matrix horizontally and/or vertically.
static int hevc_decode_extradata(HEVCContext *s)
enum PredMode pred_mode
PredMode.
AVBufferRef * hwaccel_priv_buf
int num_extra_slice_header_bits
uint8_t * data
The data buffer.
int16_t y
vertical component of motion vector
void ff_hevc_clear_refs(HEVCContext *s)
Mark all frames in DPB as unused for reference.
uint8_t num_long_term_ref_pics_sps
void av_md5_init(AVMD5 *ctx)
Initialize MD5 hashing.
static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb, int ctb_addr_ts)
uint8_t cross_component_prediction_enabled_flag
uint32_t vui_num_units_in_tick
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
uint8_t deblocking_filter_control_present_flag
static unsigned int get_bits1(GetBitContext *s)
BYTE int const BYTE int int int height
uint8_t * checksum_buf
used on BE to byteswap the lines for checksumming
static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal)
uint8_t sps_temporal_mvp_enabled_flag
#define FF_THREAD_FRAME
Decode more than one frame at once.
Describe the class of an AVClass context structure.
int num_tile_rows
num_tile_rows_minus1 + 1
int ff_hevc_log2_res_scale_abs(HEVCContext *s, int idx)
static void skip_bits(GetBitContext *s, int n)
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
uint8_t chroma_qp_offset_list_enabled_flag
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
static av_always_inline void set_ct_depth(HEVCContext *s, int x0, int y0, int log2_cb_size, int ct_depth)
enum AVColorSpace colorspace
YUV colorspace type.
static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
void(* put_pcm)(uint8_t *_dst, ptrdiff_t _stride, int width, int height, struct GetBitContext *gb, int pcm_bit_depth)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int enable_parallel_tiles
int ff_hevc_sao_eo_class_decode(HEVCContext *s)
int last_eos
last packet contains an EOS/EOB NAL
#define FF_PROFILE_HEVC_REXT
unsigned int log2_min_tb_size
enum PartMode part_mode
PartMode.
uint16_t lt_ref_pic_poc_lsb_sps[32]
enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Wrapper around get_format() for frame-multithreaded codecs.
int ff_hevc_slice_rpl(HEVCContext *s)
Construct the reference picture list(s) for the current slice.
uint8_t intra_pred_mode_c[4]
static int hls_nal_unit(HEVCContext *s)
void(* put_hevc_qpel_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)
enum NALUnitType nal_unit_type
void av_md5_final(AVMD5 *ctx, uint8_t *dst)
Finish hashing and output digest value.
int allocate_progress
Whether to allocate progress for frame threading.
static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_size)
int tc_offset
tc_offset_div2 * 2
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer. ...
uint8_t transfer_characteristic
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
HEVCLocalContext * HEVClc
Views are on top of each other.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int ff_hevc_inter_pred_idc_decode(HEVCContext *s, int nPbW, int nPbH)
int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length, HEVCNAL *nal)
int ff_hevc_cbf_cb_cr_decode(HEVCContext *s, int trafo_depth)
AVStereo3D * av_stereo3d_create_side_data(AVFrame *frame)
Allocate a complete AVFrameSideData and add it to the frame.
void ff_hevc_bump_frame(HEVCContext *s)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int ff_hevc_ref_idx_lx_decode(HEVCContext *s, int num_ref_idx_lx)
static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int log2_cb_size, int cb_depth)
void ff_hevc_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size)
the normal 219*2^(n-8) "MPEG" YUV ranges
int eos
current packet contains an EOS/EOB NAL
Views are next to each other.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
int skipped_bytes_pos_size
int ff_hevc_intra_chroma_pred_mode_decode(HEVCContext *s)
int max_transform_hierarchy_depth_intra
int ff_hevc_no_residual_syntax_flag_decode(HEVCContext *s)
GLint GLenum GLboolean GLsizei stride
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
common internal and external API header
AVBufferPool * av_buffer_pool_init(int size, AVBufferRef *(*alloc)(int size))
Allocate and initialize a buffer pool.
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
uint8_t weighted_pred_flag
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)
#define BOUNDARY_LEFT_SLICE
int32_t * tab_slice_address
int16_t offset_val[3][5]
SaoOffsetVal.
static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output, AVPacket *avpkt)
unsigned int * column_width
ColumnWidth.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int partIdx, int idx)
uint8_t * filter_slice_edges
uint8_t slice_header_extension_present_flag
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
int nal_length_size
Number of bytes used for nal length (1, 2 or 4)
void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv, int mvp_lx_flag, int LX)
AVBufferPool * tab_mvf_pool
int video_full_range_flag
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data...
int ff_hevc_cu_qp_delta_abs(HEVCContext *s)
#define FF_PROFILE_HEVC_MAIN
uint8_t chroma_qp_offset_list_len_minus1
static const uint8_t tab_mode_idx[]
void ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts)
#define SUBDIVIDE(x, y, idx)
int ff_hevc_split_transform_flag_decode(HEVCContext *s, int log2_trafo_size)
int(* execute)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size)
The codec may call this to execute several independent things.
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
#define QPEL_EXTRA_BEFORE
int ff_hevc_pred_mode_decode(HEVCContext *s)
struct AVCodecInternal * internal
Private context used for internal data.
int ff_hevc_cu_qp_delta_sign_flag(HEVCContext *s)
void(* put_hevc_epel_bi[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width)
int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCContext *s)
int key_frame
1 -> keyframe, 0-> not
uint8_t long_term_ref_pics_present_flag
static void * av_mallocz_array(size_t nmemb, size_t size)
int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
void(* put_hevc_epel_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)
static int hls_cross_component_pred(HEVCContext *s, int idx)
int diff_cu_qp_delta_depth
int ff_hevc_sao_offset_abs_decode(HEVCContext *s)
int ff_hevc_pcm_flag_decode(HEVCContext *s)
static int init_thread_copy(AVCodecContext *avctx)
#define av_malloc_array(a, b)
uint8_t context_initialized
static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int job, int self_id)
int video_signal_type_present_flag
#define FFSWAP(type, a, b)
uint8_t deblocking_filter_override_enabled_flag
int beta_offset
beta_offset_div2 * 2
int(* decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Callback for each slice.
#define BOUNDARY_LEFT_TILE
int ff_hevc_sao_merge_flag_decode(HEVCContext *s)
int(* end_frame)(AVCodecContext *avctx)
Called at the end of each frame or field picture.
void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0, int log2_trafo_size, enum ScanType scan_idx, int c_idx)
AVPixelFormat
Pixel format.
static av_cold int hevc_decode_free(AVCodecContext *avctx)
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int hevc_ref_frame(HEVCContext *s, HEVCFrame *dst, HEVCFrame *src)
uint8_t separate_colour_plane_flag
output (i.e. cropped) values
static const AVProfile profiles[]
static void intra_prediction_unit_default_value(HEVCContext *s, int x0, int y0, int log2_cb_size)
#define SAMPLE_CTB(tab, x, y)
uint8_t dependent_slice_segments_enabled_flag
int offset_sign[3][4]
sao_offset_sign
#define BOUNDARY_UPPER_TILE
void(* put_hevc_epel_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 ox0, int wx1, int ox1, intptr_t mx, intptr_t my, int width)