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];
155 if (!luma_weight_l0_flag[i]) {
162 chroma_weight_l0_flag[i] =
get_bits1(gb);
165 chroma_weight_l0_flag[i] = 0;
168 if (luma_weight_l0_flag[i]) {
173 if (chroma_weight_l0_flag[i]) {
174 for (j = 0; j < 2; j++) {
191 if (!luma_weight_l1_flag[i]) {
198 chroma_weight_l1_flag[i] =
get_bits1(gb);
201 chroma_weight_l1_flag[i] = 0;
204 if (luma_weight_l1_flag[i]) {
209 if (chroma_weight_l1_flag[i]) {
210 for (j = 0; j < 2; j++) {
231 int prev_delta_msb = 0;
232 unsigned int nb_sps = 0, nb_sh;
248 for (i = 0; i < rps->
nb_refs; i++) {
265 if (delta_poc_msb_present) {
268 if (i && i != nb_sps)
269 delta += prev_delta_msb;
272 prev_delta_msb =
delta;
282 unsigned int num = 0, den = 0;
337 if (num != 0 && den != 0)
417 int slice_address_length;
427 "Invalid slice segment address: %u.\n",
470 int short_term_ref_pic_set_sps_flag, poc;
476 "Ignoring POC change between slices: %d -> %d\n", s->
poc, poc);
483 short_term_ref_pic_set_sps_flag =
get_bits1(gb);
484 if (!short_term_ref_pic_set_sps_flag) {
491 int numbits, rps_idx;
499 rps_idx = numbits > 0 ?
get_bits(gb, numbits) : 0;
600 "Invalid collocated_ref_idx: %d.\n",
615 "Invalid number of merging MVP candidates: %d.\n",
637 int deblocking_filter_override_flag = 0;
640 deblocking_filter_override_flag =
get_bits1(gb);
642 if (deblocking_filter_override_flag) {
677 int segments = offset_len >> 4;
678 int rest = (offset_len & 15);
692 for (j = 0; j < segments; j++) {
717 for (i = 0; i <
length; i++)
726 "The slice_qp %d is outside the valid range "
752 #define CTB(tab, x, y) ((tab)[(y) * s->sps->ctb_width + (x)])
754 #define SET_SAO(elem, value) \
756 if (!sao_merge_up_flag && !sao_merge_left_flag) \
758 else if (sao_merge_left_flag) \
759 sao->elem = CTB(s->sao, rx-1, ry).elem; \
760 else if (sao_merge_up_flag) \
761 sao->elem = CTB(s->sao, rx, ry-1).elem; \
769 int sao_merge_left_flag = 0;
770 int sao_merge_up_flag = 0;
780 if (ry > 0 && !sao_merge_left_flag) {
786 for (c_idx = 0; c_idx < 3; c_idx++) {
805 for (i = 0; i < 4; i++)
809 for (i = 0; i < 4; i++) {
818 }
else if (c_idx != 2) {
824 for (i = 0; i < 4; i++) {
832 sao->
offset_val[c_idx][i + 1] <<= log2_sao_offset_scale;
844 if (log2_res_scale_abs_plus1 != 0) {
847 (1 - 2 * res_scale_sign_flag);
857 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
858 int log2_cb_size,
int log2_trafo_size,
859 int trafo_depth,
int blk_idx)
862 const int log2_trafo_size_c = log2_trafo_size - s->
sps->
hshift[1];
866 int trafo_size = 1 << log2_trafo_size;
897 "The cu_qp_delta %d is outside the valid range "
911 if (cu_chroma_qp_offset_flag) {
912 int cu_chroma_qp_offset_idx = 0;
916 "cu_chroma_qp_offset_idx not yet tested.\n");
950 int trafo_size_h = 1 << (log2_trafo_size_c + s->
sps->
hshift[1]);
951 int trafo_size_v = 1 << (log2_trafo_size_c + s->
sps->
vshift[1]);
962 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (i << log2_trafo_size_c), 1);
966 log2_trafo_size_c, scan_idx_c, 1);
972 int16_t *coeffs_y = lc->
tu.
coeffs[0];
974 int size = 1 << log2_trafo_size_c;
978 for (i = 0; i < (size *
size); i++) {
991 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (i << log2_trafo_size_c), 2);
995 log2_trafo_size_c, scan_idx_c, 2);
1001 int16_t *coeffs_y = lc->
tu.
coeffs[0];
1002 int16_t *coeffs = lc->
tu.
coeffs[1];
1003 int size = 1 << log2_trafo_size_c;
1007 for (i = 0; i < (size *
size); i++) {
1013 }
else if (blk_idx == 3) {
1014 int trafo_size_h = 1 << (log2_trafo_size + 1);
1015 int trafo_size_v = 1 << (log2_trafo_size + s->
sps->
vshift[1]);
1019 trafo_size_h, trafo_size_v);
1020 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (i << log2_trafo_size), 1);
1024 log2_trafo_size, scan_idx_c, 1);
1029 trafo_size_h, trafo_size_v);
1030 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (i << log2_trafo_size), 2);
1034 log2_trafo_size, scan_idx_c, 2);
1039 int trafo_size_h = 1 << (log2_trafo_size_c + s->
sps->
hshift[1]);
1040 int trafo_size_v = 1 << (log2_trafo_size_c + s->
sps->
vshift[1]);
1046 trafo_size_h, trafo_size_v);
1047 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (1 << log2_trafo_size_c), 1);
1048 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (1 << log2_trafo_size_c), 2);
1050 }
else if (blk_idx == 3) {
1051 int trafo_size_h = 1 << (log2_trafo_size + 1);
1052 int trafo_size_v = 1 << (log2_trafo_size + s->
sps->
vshift[1]);
1054 trafo_size_h, trafo_size_v);
1059 trafo_size_h, trafo_size_v);
1060 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (1 << (log2_trafo_size)), 1);
1061 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (1 << (log2_trafo_size)), 2);
1071 int cb_size = 1 << log2_cb_size;
1079 for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
1080 for (i = (x0 >> log2_min_pu_size); i < (x_end >> log2_min_pu_size); i++)
1081 s->
is_pcm[i + j * min_pu_width] = 2;
1085 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1086 int log2_cb_size,
int log2_trafo_size,
1087 int trafo_depth,
int blk_idx)
1093 if (trafo_depth > 0 && log2_trafo_size == 2) {
1099 int xBase_cb = xBase & ((1 << log2_trafo_size) - 1);
1100 int yBase_cb = yBase & ((1 << log2_trafo_size) - 1);
1102 SAMPLE_CBF2(lc->
tt.
cbf_cb[trafo_depth - 1], xBase_cb, yBase_cb + (1 << (log2_trafo_size)));
1104 SAMPLE_CBF2(lc->
tt.
cbf_cr[trafo_depth - 1], xBase_cb, yBase_cb + (1 << (log2_trafo_size)));
1116 if (trafo_depth == 1) {
1139 if (log2_trafo_size <= s->sps->log2_max_trafo_size &&
1141 trafo_depth < lc->cu.max_trafo_depth &&
1151 if (trafo_depth == 0 ||
1161 if (trafo_depth == 0 ||
1172 if (split_transform_flag) {
1173 int x1 = x0 + ((1 << log2_trafo_size) >> 1);
1174 int y1 = y0 + ((1 << log2_trafo_size) >> 1);
1177 log2_cb_size, log2_trafo_size - 1,
1178 trafo_depth + 1, 0);
1182 log2_cb_size, log2_trafo_size - 1,
1183 trafo_depth + 1, 1);
1187 log2_cb_size, log2_trafo_size - 1,
1188 trafo_depth + 1, 2);
1192 log2_cb_size, log2_trafo_size - 1,
1193 trafo_depth + 1, 3);
1211 log2_cb_size, log2_trafo_size, trafo_depth,
1218 for (i = 0; i < (1 << log2_trafo_size); i += min_tu_size)
1219 for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) {
1220 int x_tu = (x0 + j) >> log2_min_tu_size;
1221 int y_tu = (y0 + i) >> log2_min_tu_size;
1222 s->
cbf_luma[y_tu * min_tu_width + x_tu] = 1;
1240 int cb_size = 1 << log2_cb_size;
1292 int block_w,
int block_h,
int luma_weight,
int luma_offset)
1296 ptrdiff_t srcstride = ref->
linesize[0];
1305 x_off += mv->
x >> 2;
1306 y_off += mv->
y >> 2;
1317 edge_emu_stride, srcstride,
1321 pic_width, pic_height);
1323 srcstride = edge_emu_stride;
1328 block_h, mx, my, block_w);
1332 luma_weight, luma_offset, mx, my, block_w);
1352 AVFrame *ref0,
const Mv *mv0,
int x_off,
int y_off,
1353 int block_w,
int block_h,
AVFrame *ref1,
const Mv *mv1,
struct MvField *current_mv)
1357 ptrdiff_t src0stride = ref0->
linesize[0];
1358 ptrdiff_t src1stride = ref1->
linesize[0];
1361 int mx0 = mv0->
x & 3;
1362 int my0 = mv0->
y & 3;
1363 int mx1 = mv1->
x & 3;
1364 int my1 = mv1->
y & 3;
1367 int x_off0 = x_off + (mv0->
x >> 2);
1368 int y_off0 = y_off + (mv0->
y >> 2);
1369 int x_off1 = x_off + (mv1->
x >> 2);
1370 int y_off1 = y_off + (mv1->
y >> 2);
1384 edge_emu_stride, src0stride,
1388 pic_width, pic_height);
1390 src0stride = edge_emu_stride;
1401 edge_emu_stride, src1stride,
1405 pic_width, pic_height);
1407 src1stride = edge_emu_stride;
1411 block_h, mx0, my0, block_w);
1414 block_h, mx1, my1, block_w);
1444 ptrdiff_t dststride,
uint8_t *src0, ptrdiff_t srcstride,
int reflist,
1445 int x_off,
int y_off,
int block_w,
int block_h,
struct MvField *current_mv,
int chroma_weight,
int chroma_offset)
1450 const Mv *
mv = ¤t_mv->
mv[reflist];
1456 intptr_t mx = mv->
x & ((1 << (2 + hshift)) - 1);
1457 intptr_t my = mv->
y & ((1 << (2 + vshift)) - 1);
1458 intptr_t _mx = mx << (1 - hshift);
1459 intptr_t _my = my << (1 - vshift);
1461 x_off += mv->
x >> (2 + hshift);
1462 y_off += mv->
y >> (2 + vshift);
1473 edge_emu_stride, srcstride,
1477 pic_width, pic_height);
1480 srcstride = edge_emu_stride;
1484 block_h, _mx, _my, block_w);
1488 chroma_weight, chroma_offset, _mx, _my, block_w);
1509 int x_off,
int y_off,
int block_w,
int block_h,
struct MvField *current_mv,
int cidx)
1516 ptrdiff_t src1stride = ref0->
linesize[cidx+1];
1517 ptrdiff_t src2stride = ref1->
linesize[cidx+1];
1522 Mv *mv0 = ¤t_mv->
mv[0];
1523 Mv *mv1 = ¤t_mv->
mv[1];
1527 intptr_t mx0 = mv0->
x & ((1 << (2 + hshift)) - 1);
1528 intptr_t my0 = mv0->
y & ((1 << (2 + vshift)) - 1);
1529 intptr_t mx1 = mv1->
x & ((1 << (2 + hshift)) - 1);
1530 intptr_t my1 = mv1->
y & ((1 << (2 + vshift)) - 1);
1531 intptr_t _mx0 = mx0 << (1 - hshift);
1532 intptr_t _my0 = my0 << (1 - vshift);
1533 intptr_t _mx1 = mx1 << (1 - hshift);
1534 intptr_t _my1 = my1 << (1 - vshift);
1536 int x_off0 = x_off + (mv0->
x >> (2 + hshift));
1537 int y_off0 = y_off + (mv0->
y >> (2 + vshift));
1538 int x_off1 = x_off + (mv1->
x >> (2 + hshift));
1539 int y_off1 = y_off + (mv1->
y >> (2 + vshift));
1541 src1 += y_off0 * src1stride + (int)((
unsigned)x_off0 << s->
sps->
pixel_shift);
1542 src2 += y_off1 * src2stride + (int)((
unsigned)x_off1 << s->
sps->
pixel_shift);
1553 edge_emu_stride, src1stride,
1557 pic_width, pic_height);
1560 src1stride = edge_emu_stride;
1572 edge_emu_stride, src2stride,
1576 pic_width, pic_height);
1579 src2stride = edge_emu_stride;
1583 block_h, _mx0, _my0, block_w);
1586 src2, src2stride, tmp, tmpstride,
1587 block_h, _mx1, _my1, block_w);
1590 src2, src2stride, tmp, tmpstride,
1597 _mx1, _my1, block_w);
1603 int y = (mv->
y >> 2) + y0 + height + 9;
1611 int log2_cb_size,
int partIdx,
int idx)
1613 #define POS(c_idx, x, y) \
1614 &s->frame->data[c_idx][((y) >> s->sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \
1615 (((x) >> s->sps->hshift[c_idx]) << s->sps->pixel_shift)]
1618 struct MvField current_mv = {{{ 0 }}};
1630 int x_cb = x0 >> log2_min_cb_size;
1631 int y_cb = y0 >> log2_min_cb_size;
1646 log2_cb_size, partIdx,
1647 merge_idx, ¤t_mv);
1653 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
1663 partIdx, merge_idx, ¤t_mv);
1669 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
1677 if (inter_pred_idc !=
PRED_L1) {
1680 current_mv.
ref_idx[0] = ref_idx[0];
1686 partIdx, merge_idx, ¤t_mv,
1692 if (inter_pred_idc !=
PRED_L0) {
1695 current_mv.
ref_idx[1] = ref_idx[1];
1708 partIdx, merge_idx, ¤t_mv,
1719 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
1724 ref0 = refPicList[0].
ref[current_mv.
ref_idx[0]];
1730 ref1 = refPicList[1].
ref[current_mv.
ref_idx[1]];
1743 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
1748 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1751 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1760 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH,
1765 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1769 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1778 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
1779 ref1->
frame, ¤t_mv.
mv[1], ¤t_mv);
1782 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0);
1785 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 1);
1793 int prev_intra_luma_pred_flag)
1811 int intra_pred_mode;
1816 if ((y0 - 1) < y_ctb)
1819 if (cand_left == cand_up) {
1820 if (cand_left < 2) {
1825 candidate[0] = cand_left;
1826 candidate[1] = 2 + ((cand_left - 2 - 1 + 32) & 31);
1827 candidate[2] = 2 + ((cand_left - 2 + 1) & 31);
1830 candidate[0] = cand_left;
1831 candidate[1] = cand_up;
1841 if (prev_intra_luma_pred_flag) {
1842 intra_pred_mode = candidate[lc->
pu.
mpm_idx];
1844 if (candidate[0] > candidate[1])
1846 if (candidate[0] > candidate[2])
1848 if (candidate[1] > candidate[2])
1852 for (i = 0; i < 3; i++)
1853 if (intra_pred_mode >= candidate[i])
1860 for (i = 0; i < size_in_pus; i++) {
1861 memset(&s->
tab_ipm[(y_pu + i) * min_pu_width + x_pu],
1862 intra_pred_mode, size_in_pus);
1864 for (j = 0; j < size_in_pus; j++) {
1869 return intra_pred_mode;
1873 int log2_cb_size,
int ct_depth)
1886 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20,
1887 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31};
1893 static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 };
1894 uint8_t prev_intra_luma_pred_flag[4];
1896 int pb_size = (1 << log2_cb_size) >> split;
1897 int side = split + 1;
1901 for (i = 0; i < side; i++)
1902 for (j = 0; j < side; j++)
1905 for (i = 0; i < side; i++) {
1906 for (j = 0; j < side; j++) {
1907 if (prev_intra_luma_pred_flag[2 * i + j])
1914 prev_intra_luma_pred_flag[2 * i + j]);
1919 for (i = 0; i < side; i++) {
1920 for (j = 0; j < side; j++) {
1922 if (chroma_mode != 4) {
1935 if (chroma_mode != 4) {
1939 mode_idx = intra_chroma_table[chroma_mode];
1946 if (chroma_mode != 4) {
1962 int pb_size = 1 << log2_cb_size;
1970 if (size_in_pus == 0)
1972 for (j = 0; j < size_in_pus; j++)
1973 memset(&s->
tab_ipm[(y_pu + j) * min_pu_width + x_pu],
INTRA_DC, size_in_pus);
1975 for (j = 0; j < size_in_pus; j++)
1976 for (k = 0; k < size_in_pus; k++)
1982 int cb_size = 1 << log2_cb_size;
1985 int length = cb_size >> log2_min_cb_size;
1987 int x_cb = x0 >> log2_min_cb_size;
1988 int y_cb = y0 >> log2_min_cb_size;
1989 int idx = log2_cb_size - 2;
2002 for (x = 0; x < 4; x++)
2014 x = y_cb * min_cb_width + x_cb;
2015 for (y = 0; y <
length; y++) {
2016 memset(&s->
skip_flag[x], skip_flag, length);
2041 log2_cb_size <= s->sps->pcm.log2_max_pcm_cb_size) {
2067 hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
2071 hls_prediction_unit(s, x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
2075 hls_prediction_unit(s, x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);
2079 hls_prediction_unit(s, x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
2083 hls_prediction_unit(s, x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
2087 hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
2088 hls_prediction_unit(s, x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
2089 hls_prediction_unit(s, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
2105 log2_cb_size, 0, 0);
2118 x = y_cb * min_cb_width + x_cb;
2119 for (y = 0; y <
length; y++) {
2124 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2125 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0) {
2135 int log2_cb_size,
int cb_depth)
2138 const int cb_size = 1 << log2_cb_size;
2144 if (x0 + cb_size <= s->sps->width &&
2145 y0 + cb_size <= s->sps->height &&
2162 if (split_cu_flag) {
2163 const int cb_size_split = cb_size >> 1;
2164 const int x1 = x0 + cb_size_split;
2165 const int y1 = y0 + cb_size_split;
2173 if (more_data && x1 < s->sps->width) {
2178 if (more_data && y1 < s->sps->height) {
2183 if (more_data && x1 < s->sps->width &&
2184 y1 < s->sps->height) {
2190 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2191 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0)
2195 return ((x1 + cb_size_split) < s->
sps->
width ||
2203 if ((!((x0 + cb_size) %
2205 (x0 + cb_size >= s->
sps->
width)) &&
2210 return !end_of_slice_flag;
2225 int ctb_addr_in_slice = ctb_addr_rs - s->
sh.
slice_addr;
2227 int tile_left_boundary, tile_up_boundary;
2228 int slice_left_boundary, slice_up_boundary;
2233 if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
2249 tile_left_boundary = x_ctb > 0 &&
2251 slice_left_boundary = x_ctb > 0 &&
2253 tile_up_boundary = y_ctb > 0 &&
2255 slice_up_boundary = y_ctb > 0 &&
2258 tile_left_boundary =
2259 tile_up_boundary = 0;
2260 slice_left_boundary = ctb_addr_in_slice <= 0;
2261 slice_up_boundary = ctb_addr_in_slice < s->
sps->
ctb_width;
2265 lc->
ctb_left_flag = ((x_ctb > 0) && (ctb_addr_in_slice > 0) && !tile_left_boundary);
2293 while (more_data && ctb_addr_ts < s->sps->ctb_size) {
2309 if (more_data < 0) {
2320 if (x_ctb + ctb_size >= s->
sps->
width &&
2344 int *ctb_row_p = input_ctb_row;
2345 int ctb_row = ctb_row_p[job];
2355 ret =
init_get_bits8(&lc->
gb,
s->data +
s->sh.offset[ctb_row - 1],
s->sh.size[ctb_row - 1]);
2362 while(more_data && ctb_addr_ts < s->sps->ctb_size) {
2363 int x_ctb = (ctb_addr_rs %
s->sps->ctb_width) <<
s->sps->log2_ctb_size;
2364 int y_ctb = (ctb_addr_rs /
s->sps->ctb_width) <<
s->sps->log2_ctb_size;
2376 hls_sao_param(
s, x_ctb >>
s->sps->log2_ctb_size, y_ctb >>
s->sps->log2_ctb_size);
2379 if (more_data < 0) {
2380 s->tab_slice_address[ctb_addr_rs] = -1;
2390 if (!more_data && (x_ctb+ctb_size) <
s->sps->width && ctb_row !=
s->sh.num_entry_point_offsets) {
2396 if ((x_ctb+ctb_size) >=
s->sps->width && (y_ctb+ctb_size) >=
s->sps->height ) {
2401 ctb_addr_rs =
s->pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2404 if(x_ctb >=
s->sps->width) {
2419 int startheader, cmpt = 0;
2437 for (j = 0, cmpt = 0, startheader = offset + s->
sh.
entry_point_offset[0]; j < s->skipped_bytes; j++) {
2446 for (j = 0, cmpt = 0, startheader = offset
2510 "nal_unit_type: %d, nuh_layer_id: %dtemporal_id: %d\n",
2513 return nuh_layer_id == 0;
2625 int ctb_addr_ts,
ret;
2681 if (s->
max_ra == INT_MAX) {
2703 }
else if (!s->
ref) {
2710 "Non-matching NAL types of the VCL NALUs: %d %d\n",
2720 "Error constructing the reference lists for the current slice.\n");
2733 if (ctb_addr_ts < 0) {
2767 #define STARTCODE_TEST \
2768 if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
2769 if (src[i + 2] != 3) { \
2775 #if HAVE_FAST_UNALIGNED
2776 #define FIND_FIRST_ZERO \
2777 if (i > 0 && !src[i]) \
2782 for (i = 0; i + 1 <
length; i += 9) {
2784 (
AV_RN64A(src + i) - 0x0100010001000101ULL)) &
2785 0x8000800080008080ULL))
2792 for (i = 0; i + 1 <
length; i += 5) {
2794 (
AV_RN32A(src + i) - 0x01000101U)) &
2803 for (i = 0; i + 1 <
length; i += 2) {
2806 if (i > 0 && src[i - 1] == 0)
2812 if (i >= length - 1) {
2825 memcpy(dst, src, i);
2827 while (si + 2 < length) {
2829 if (src[si + 2] > 3) {
2830 dst[di++] = src[si++];
2831 dst[di++] = src[si++];
2832 }
else if (src[si] == 0 && src[si + 1] == 0) {
2833 if (src[si + 2] == 3) {
2854 dst[di++] = src[si++];
2857 dst[di++] = src[si++];
2869 int i, consumed,
ret = 0;
2878 while (length >= 4) {
2880 int extract_length = 0;
2885 extract_length = (extract_length << 8) | buf[i];
2889 if (extract_length > length) {
2896 while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
2960 for (i = 0; i < s->
nb_nals; i++) {
2968 "Error parsing NAL unit #%d.\n", i);
2983 for (i = 0; i < 16; i++)
2984 av_log(log_ctx, level,
"%02"PRIx8, md5[i]);
3013 for (i = 0; frame->
data[i]; i++) {
3021 for (j = 0; j < h; j++) {
3026 (
const uint16_t *) src, w);
3034 if (!memcmp(md5, s->
md5[i], 16)) {
3339 int i, j, num_arrays, nal_len_size;
3344 nal_len_size = (bytestream2_get_byte(&gb) & 3) + 1;
3345 num_arrays = bytestream2_get_byte(&gb);
3352 for (i = 0; i < num_arrays; i++) {
3353 int type = bytestream2_get_byte(&gb) & 0x3f;
3354 int cnt = bytestream2_get_be16(&gb);
3356 for (j = 0; j < cnt; j++) {
3358 int nalsize = bytestream2_peek_be16(&gb) + 2;
3361 "Invalid NAL unit size in extradata.\n");
3368 "Decoding nal unit %d %d from hvcC failed\n",
3430 memset(s, 0,
sizeof(*s));
3446 #define OFFSET(x) offsetof(HEVCContext, x)
3447 #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
3458 {
"apply_defdispwin",
"Apply default display window from VUI",
OFFSET(apply_defdispwin),
3460 {
"strict-displaywin",
"stricly apply default display window size",
OFFSET(apply_defdispwin),
3478 .priv_class = &hevc_decoder_class,