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) {
700 int segments = offset_len >> 4;
701 int rest = (offset_len & 15);
715 for (j = 0; j < segments; j++) {
740 for (i = 0; i <
length; i++)
749 "The slice_qp %d is outside the valid range "
781 #define CTB(tab, x, y) ((tab)[(y) * s->sps->ctb_width + (x)])
783 #define SET_SAO(elem, value) \
785 if (!sao_merge_up_flag && !sao_merge_left_flag) \
787 else if (sao_merge_left_flag) \
788 sao->elem = CTB(s->sao, rx-1, ry).elem; \
789 else if (sao_merge_up_flag) \
790 sao->elem = CTB(s->sao, rx, ry-1).elem; \
798 int sao_merge_left_flag = 0;
799 int sao_merge_up_flag = 0;
809 if (ry > 0 && !sao_merge_left_flag) {
834 for (i = 0; i < 4; i++)
838 for (i = 0; i < 4; i++) {
847 }
else if (c_idx != 2) {
853 for (i = 0; i < 4; i++) {
861 sao->
offset_val[c_idx][i + 1] <<= log2_sao_offset_scale;
873 if (log2_res_scale_abs_plus1 != 0) {
876 (1 - 2 * res_scale_sign_flag);
886 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
887 int log2_cb_size,
int log2_trafo_size,
888 int blk_idx,
int cbf_luma,
int *cbf_cb,
int *cbf_cr)
891 const int log2_trafo_size_c = log2_trafo_size - s->
sps->
hshift[1];
895 int trafo_size = 1 << log2_trafo_size;
901 if (cbf_luma || cbf_cb[0] || cbf_cr[0] ||
905 int cbf_chroma = cbf_cb[0] || cbf_cr[0] ||
907 (cbf_cb[1] || cbf_cr[1]));
919 "The cu_qp_delta %d is outside the valid range "
933 if (cu_chroma_qp_offset_flag) {
934 int cu_chroma_qp_offset_idx = 0;
938 "cu_chroma_qp_offset_idx not yet tested.\n");
972 int trafo_size_h = 1 << (log2_trafo_size_c + s->
sps->
hshift[1]);
973 int trafo_size_v = 1 << (log2_trafo_size_c + s->
sps->
vshift[1]);
984 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (i << log2_trafo_size_c), 1);
988 log2_trafo_size_c, scan_idx_c, 1);
996 int size = 1 << log2_trafo_size_c;
1000 for (i = 0; i < (size *
size); i++) {
1013 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (i << log2_trafo_size_c), 2);
1017 log2_trafo_size_c, scan_idx_c, 2);
1025 int size = 1 << log2_trafo_size_c;
1029 for (i = 0; i < (size *
size); i++) {
1036 int trafo_size_h = 1 << (log2_trafo_size + 1);
1037 int trafo_size_v = 1 << (log2_trafo_size + s->
sps->
vshift[1]);
1041 trafo_size_h, trafo_size_v);
1042 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (i << log2_trafo_size), 1);
1046 log2_trafo_size, scan_idx_c, 1);
1051 trafo_size_h, trafo_size_v);
1052 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (i << log2_trafo_size), 2);
1056 log2_trafo_size, scan_idx_c, 2);
1061 int trafo_size_h = 1 << (log2_trafo_size_c + s->
sps->
hshift[1]);
1062 int trafo_size_v = 1 << (log2_trafo_size_c + s->
sps->
vshift[1]);
1068 trafo_size_h, trafo_size_v);
1069 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (1 << log2_trafo_size_c), 1);
1070 s->
hpc.
intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (1 << log2_trafo_size_c), 2);
1072 }
else if (blk_idx == 3) {
1073 int trafo_size_h = 1 << (log2_trafo_size + 1);
1074 int trafo_size_v = 1 << (log2_trafo_size + s->
sps->
vshift[1]);
1076 trafo_size_h, trafo_size_v);
1081 trafo_size_h, trafo_size_v);
1082 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (1 << (log2_trafo_size)), 1);
1083 s->
hpc.
intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (1 << (log2_trafo_size)), 2);
1093 int cb_size = 1 << log2_cb_size;
1101 for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
1102 for (i = (x0 >> log2_min_pu_size); i < (x_end >> log2_min_pu_size); i++)
1103 s->
is_pcm[i + j * min_pu_width] = 2;
1107 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1108 int log2_cb_size,
int log2_trafo_size,
1109 int trafo_depth,
int blk_idx,
1110 const int *base_cbf_cb,
const int *base_cbf_cr)
1118 cbf_cb[0] = base_cbf_cb[0];
1119 cbf_cb[1] = base_cbf_cb[1];
1120 cbf_cr[0] = base_cbf_cr[0];
1121 cbf_cr[1] = base_cbf_cr[1];
1124 if (trafo_depth == 1) {
1140 if (log2_trafo_size <= s->sps->log2_max_trafo_size &&
1142 trafo_depth < lc->cu.max_trafo_depth &&
1157 if (trafo_depth == 0 || cbf_cb[0]) {
1164 if (trafo_depth == 0 || cbf_cr[0]) {
1172 if (split_transform_flag) {
1173 const int trafo_size_split = 1 << (log2_trafo_size - 1);
1174 const int x1 = x0 + trafo_size_split;
1175 const int y1 = y0 + trafo_size_split;
1177 #define SUBDIVIDE(x, y, idx) \
1179 ret = hls_transform_tree(s, x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size, \
1180 log2_trafo_size - 1, trafo_depth + 1, idx, \
1199 cbf_cb[0] || cbf_cr[0] ||
1205 log2_cb_size, log2_trafo_size,
1206 blk_idx, cbf_luma, cbf_cb, cbf_cr);
1212 for (i = 0; i < (1 << log2_trafo_size); i += min_tu_size)
1213 for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) {
1214 int x_tu = (x0 + j) >> log2_min_tu_size;
1215 int y_tu = (y0 + i) >> log2_min_tu_size;
1216 s->
cbf_luma[y_tu * min_tu_width + x_tu] = 1;
1233 int cb_size = 1 << log2_cb_size;
1288 int block_w,
int block_h,
int luma_weight,
int luma_offset)
1292 ptrdiff_t srcstride = ref->
linesize[0];
1301 x_off += mv->
x >> 2;
1302 y_off += mv->
y >> 2;
1313 edge_emu_stride, srcstride,
1317 pic_width, pic_height);
1319 srcstride = edge_emu_stride;
1324 block_h, mx, my, block_w);
1328 luma_weight, luma_offset, mx, my, block_w);
1348 AVFrame *ref0,
const Mv *mv0,
int x_off,
int y_off,
1349 int block_w,
int block_h,
AVFrame *ref1,
const Mv *mv1,
struct MvField *current_mv)
1352 ptrdiff_t src0stride = ref0->
linesize[0];
1353 ptrdiff_t src1stride = ref1->
linesize[0];
1356 int mx0 = mv0->
x & 3;
1357 int my0 = mv0->
y & 3;
1358 int mx1 = mv1->
x & 3;
1359 int my1 = mv1->
y & 3;
1362 int x_off0 = x_off + (mv0->
x >> 2);
1363 int y_off0 = y_off + (mv0->
y >> 2);
1364 int x_off1 = x_off + (mv1->
x >> 2);
1365 int y_off1 = y_off + (mv1->
y >> 2);
1379 edge_emu_stride, src0stride,
1383 pic_width, pic_height);
1385 src0stride = edge_emu_stride;
1396 edge_emu_stride, src1stride,
1400 pic_width, pic_height);
1402 src1stride = edge_emu_stride;
1406 block_h, mx0, my0, block_w);
1409 block_h, mx1, my1, block_w);
1439 ptrdiff_t dststride,
uint8_t *src0, ptrdiff_t srcstride,
int reflist,
1440 int x_off,
int y_off,
int block_w,
int block_h,
struct MvField *current_mv,
int chroma_weight,
int chroma_offset)
1445 const Mv *
mv = ¤t_mv->
mv[reflist];
1451 intptr_t mx = mv->
x & ((1 << (2 + hshift)) - 1);
1452 intptr_t my = mv->
y & ((1 << (2 + vshift)) - 1);
1453 intptr_t _mx = mx << (1 - hshift);
1454 intptr_t _my = my << (1 - vshift);
1456 x_off += mv->
x >> (2 + hshift);
1457 y_off += mv->
y >> (2 + vshift);
1468 edge_emu_stride, srcstride,
1472 pic_width, pic_height);
1475 srcstride = edge_emu_stride;
1479 block_h, _mx, _my, block_w);
1483 chroma_weight, chroma_offset, _mx, _my, block_w);
1504 int x_off,
int y_off,
int block_w,
int block_h,
struct MvField *current_mv,
int cidx)
1509 ptrdiff_t src1stride = ref0->
linesize[cidx+1];
1510 ptrdiff_t src2stride = ref1->
linesize[cidx+1];
1515 Mv *mv0 = ¤t_mv->
mv[0];
1516 Mv *mv1 = ¤t_mv->
mv[1];
1520 intptr_t mx0 = mv0->
x & ((1 << (2 + hshift)) - 1);
1521 intptr_t my0 = mv0->
y & ((1 << (2 + vshift)) - 1);
1522 intptr_t mx1 = mv1->
x & ((1 << (2 + hshift)) - 1);
1523 intptr_t my1 = mv1->
y & ((1 << (2 + vshift)) - 1);
1524 intptr_t _mx0 = mx0 << (1 - hshift);
1525 intptr_t _my0 = my0 << (1 - vshift);
1526 intptr_t _mx1 = mx1 << (1 - hshift);
1527 intptr_t _my1 = my1 << (1 - vshift);
1529 int x_off0 = x_off + (mv0->
x >> (2 + hshift));
1530 int y_off0 = y_off + (mv0->
y >> (2 + vshift));
1531 int x_off1 = x_off + (mv1->
x >> (2 + hshift));
1532 int y_off1 = y_off + (mv1->
y >> (2 + vshift));
1534 src1 += y_off0 * src1stride + (int)((
unsigned)x_off0 << s->
sps->
pixel_shift);
1535 src2 += y_off1 * src2stride + (int)((
unsigned)x_off1 << s->
sps->
pixel_shift);
1546 edge_emu_stride, src1stride,
1550 pic_width, pic_height);
1553 src1stride = edge_emu_stride;
1565 edge_emu_stride, src2stride,
1569 pic_width, pic_height);
1572 src2stride = edge_emu_stride;
1576 block_h, _mx0, _my0, block_w);
1579 src2, src2stride, lc->
tmp,
1580 block_h, _mx1, _my1, block_w);
1583 src2, src2stride, lc->
tmp,
1590 _mx1, _my1, block_w);
1596 int y =
FFMAX(0, (mv->
y >> 2) + y0 + height + 9);
1603 int nPbH,
int log2_cb_size,
int part_idx,
1615 if (inter_pred_idc !=
PRED_L1) {
1623 part_idx, merge_idx, mv, mvp_flag, 0);
1628 if (inter_pred_idc !=
PRED_L0) {
1641 part_idx, merge_idx, mv, mvp_flag, 1);
1649 int log2_cb_size,
int partIdx,
int idx)
1651 #define POS(c_idx, x, y) \
1652 &s->frame->data[c_idx][((y) >> s->sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \
1653 (((x) >> s->sps->hshift[c_idx]) << s->sps->pixel_shift)]
1656 struct MvField current_mv = {{{ 0 }}};
1668 int x_cb = x0 >> log2_min_cb_size;
1669 int y_cb = y0 >> log2_min_cb_size;
1685 partIdx, merge_idx, ¤t_mv);
1688 partIdx, merge_idx, ¤t_mv);
1696 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
1699 ref0 = refPicList[0].
ref[current_mv.
ref_idx[0]];
1705 ref1 = refPicList[1].
ref[current_mv.
ref_idx[1]];
1718 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
1724 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1727 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1737 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH,
1743 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1747 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1757 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
1758 ref1->frame, ¤t_mv.
mv[1], ¤t_mv);
1762 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0);
1765 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 1);
1774 int prev_intra_luma_pred_flag)
1792 int intra_pred_mode;
1797 if ((y0 - 1) < y_ctb)
1800 if (cand_left == cand_up) {
1801 if (cand_left < 2) {
1806 candidate[0] = cand_left;
1807 candidate[1] = 2 + ((cand_left - 2 - 1 + 32) & 31);
1808 candidate[2] = 2 + ((cand_left - 2 + 1) & 31);
1811 candidate[0] = cand_left;
1812 candidate[1] = cand_up;
1822 if (prev_intra_luma_pred_flag) {
1823 intra_pred_mode = candidate[lc->
pu.
mpm_idx];
1825 if (candidate[0] > candidate[1])
1827 if (candidate[0] > candidate[2])
1829 if (candidate[1] > candidate[2])
1833 for (i = 0; i < 3; i++)
1834 if (intra_pred_mode >= candidate[i])
1841 for (i = 0; i < size_in_pus; i++) {
1842 memset(&s->
tab_ipm[(y_pu + i) * min_pu_width + x_pu],
1843 intra_pred_mode, size_in_pus);
1845 for (j = 0; j < size_in_pus; j++) {
1850 return intra_pred_mode;
1854 int log2_cb_size,
int ct_depth)
1867 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20,
1868 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31};
1874 static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 };
1875 uint8_t prev_intra_luma_pred_flag[4];
1877 int pb_size = (1 << log2_cb_size) >> split;
1878 int side = split + 1;
1882 for (i = 0; i < side; i++)
1883 for (j = 0; j < side; j++)
1886 for (i = 0; i < side; i++) {
1887 for (j = 0; j < side; j++) {
1888 if (prev_intra_luma_pred_flag[2 * i + j])
1895 prev_intra_luma_pred_flag[2 * i + j]);
1900 for (i = 0; i < side; i++) {
1901 for (j = 0; j < side; j++) {
1903 if (chroma_mode != 4) {
1916 if (chroma_mode != 4) {
1920 mode_idx = intra_chroma_table[chroma_mode];
1927 if (chroma_mode != 4) {
1943 int pb_size = 1 << log2_cb_size;
1951 if (size_in_pus == 0)
1953 for (j = 0; j < size_in_pus; j++)
1954 memset(&s->
tab_ipm[(y_pu + j) * min_pu_width + x_pu],
INTRA_DC, size_in_pus);
1956 for (j = 0; j < size_in_pus; j++)
1957 for (k = 0; k < size_in_pus; k++)
1963 int cb_size = 1 << log2_cb_size;
1966 int length = cb_size >> log2_min_cb_size;
1968 int x_cb = x0 >> log2_min_cb_size;
1969 int y_cb = y0 >> log2_min_cb_size;
1970 int idx = log2_cb_size - 2;
1981 for (x = 0; x < 4; x++)
1993 x = y_cb * min_cb_width + x_cb;
1994 for (y = 0; y <
length; y++) {
1995 memset(&s->
skip_flag[x], skip_flag, length);
2000 x = y_cb * min_cb_width + x_cb;
2001 for (y = 0; y <
length; y++) {
2028 log2_cb_size <= s->sps->pcm.log2_max_pcm_cb_size) {
2054 hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
2058 hls_prediction_unit(s, x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
2062 hls_prediction_unit(s, x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);
2066 hls_prediction_unit(s, x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
2070 hls_prediction_unit(s, x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
2074 hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
2075 hls_prediction_unit(s, x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
2076 hls_prediction_unit(s, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
2082 int rqt_root_cbf = 1;
2089 const static int cbf[2] = { 0 };
2095 log2_cb_size, 0, 0, cbf, cbf);
2108 x = y_cb * min_cb_width + x_cb;
2109 for (y = 0; y <
length; y++) {
2114 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2115 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0) {
2125 int log2_cb_size,
int cb_depth)
2128 const int cb_size = 1 << log2_cb_size;
2133 if (x0 + cb_size <= s->sps->width &&
2134 y0 + cb_size <= s->sps->height &&
2153 const int cb_size_split = cb_size >> 1;
2154 const int x1 = x0 + cb_size_split;
2155 const int y1 = y0 + cb_size_split;
2163 if (more_data && x1 < s->sps->width) {
2168 if (more_data && y1 < s->sps->height) {
2173 if (more_data && x1 < s->sps->width &&
2174 y1 < s->sps->height) {
2180 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2181 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0)
2185 return ((x1 + cb_size_split) < s->
sps->
width ||
2193 if ((!((x0 + cb_size) %
2195 (x0 + cb_size >= s->
sps->
width)) &&
2200 return !end_of_slice_flag;
2215 int ctb_addr_in_slice = ctb_addr_rs - s->
sh.
slice_addr;
2220 if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
2246 if (!ctb_addr_in_slice > 0)
2248 if (ctb_addr_in_slice < s->sps->ctb_width)
2280 while (more_data && ctb_addr_ts < s->sps->ctb_size) {
2296 if (more_data < 0) {
2307 if (x_ctb + ctb_size >= s->
sps->
width &&
2331 int *ctb_row_p = input_ctb_row;
2332 int ctb_row = ctb_row_p[job];
2342 ret =
init_get_bits8(&lc->
gb,
s->data +
s->sh.offset[ctb_row - 1],
s->sh.size[ctb_row - 1]);
2349 while(more_data && ctb_addr_ts < s->sps->ctb_size) {
2350 int x_ctb = (ctb_addr_rs %
s->sps->ctb_width) <<
s->sps->log2_ctb_size;
2351 int y_ctb = (ctb_addr_rs /
s->sps->ctb_width) <<
s->sps->log2_ctb_size;
2363 hls_sao_param(
s, x_ctb >>
s->sps->log2_ctb_size, y_ctb >>
s->sps->log2_ctb_size);
2366 if (more_data < 0) {
2367 s->tab_slice_address[ctb_addr_rs] = -1;
2377 if (!more_data && (x_ctb+ctb_size) <
s->sps->width && ctb_row !=
s->sh.num_entry_point_offsets) {
2383 if ((x_ctb+ctb_size) >=
s->sps->width && (y_ctb+ctb_size) >=
s->sps->height ) {
2388 ctb_addr_rs =
s->pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2391 if(x_ctb >=
s->sps->width) {
2406 int startheader, cmpt = 0;
2430 for (j = 0, cmpt = 0, startheader = offset + s->
sh.
entry_point_offset[0]; j < s->skipped_bytes; j++) {
2439 for (j = 0, cmpt = 0, startheader = offset
2503 "nal_unit_type: %d, nuh_layer_id: %d, temporal_id: %d\n",
2506 return nuh_layer_id == 0;
2618 int ctb_addr_ts,
ret;
2674 if (s->
max_ra == INT_MAX) {
2696 }
else if (!s->
ref) {
2703 "Non-matching NAL types of the VCL NALUs: %d %d\n",
2713 "Error constructing the reference lists for the current slice.\n");
2737 if (ctb_addr_ts < 0) {
2772 #define STARTCODE_TEST \
2773 if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
2774 if (src[i + 2] != 3) { \
2780 #if HAVE_FAST_UNALIGNED
2781 #define FIND_FIRST_ZERO \
2782 if (i > 0 && !src[i]) \
2787 for (i = 0; i + 1 <
length; i += 9) {
2789 (
AV_RN64A(src + i) - 0x0100010001000101ULL)) &
2790 0x8000800080008080ULL))
2797 for (i = 0; i + 1 <
length; i += 5) {
2799 (
AV_RN32A(src + i) - 0x01000101U)) &
2808 for (i = 0; i + 1 <
length; i += 2) {
2811 if (i > 0 && src[i - 1] == 0)
2817 if (i >= length - 1) {
2832 memcpy(dst, src, i);
2834 while (si + 2 < length) {
2836 if (src[si + 2] > 3) {
2837 dst[di++] = src[si++];
2838 dst[di++] = src[si++];
2839 }
else if (src[si] == 0 && src[si + 1] == 0) {
2840 if (src[si + 2] == 3) {
2861 dst[di++] = src[si++];
2864 dst[di++] = src[si++];
2878 int i, consumed,
ret = 0;
2887 while (length >= 4) {
2889 int extract_length = 0;
2894 extract_length = (extract_length << 8) | buf[i];
2898 if (extract_length > length) {
2905 while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
2984 for (i = 0; i < s->
nb_nals; i++) {
2992 "Error parsing NAL unit #%d.\n", i);
3007 for (i = 0; i < 16; i++)
3008 av_log(log_ctx, level,
"%02"PRIx8, md5[i]);
3037 for (i = 0; frame->
data[i]; i++) {
3045 for (j = 0; j < h; j++) {
3050 (
const uint16_t *) src, w);
3058 if (!memcmp(md5, s->
md5[i], 16)) {
3100 "hardware accelerator failed to decode picture\n");
3186 for (i = 0; i < 3; i++) {
3375 int i, j, num_arrays, nal_len_size;
3380 nal_len_size = (bytestream2_get_byte(&gb) & 3) + 1;
3381 num_arrays = bytestream2_get_byte(&gb);
3388 for (i = 0; i < num_arrays; i++) {
3389 int type = bytestream2_get_byte(&gb) & 0x3f;
3390 int cnt = bytestream2_get_be16(&gb);
3392 for (j = 0; j < cnt; j++) {
3394 int nalsize = bytestream2_peek_be16(&gb) + 2;
3397 "Invalid NAL unit size in extradata.\n");
3404 "Decoding nal unit %d %d from hvcC failed\n",
3466 memset(s, 0,
sizeof(*s));
3482 #define OFFSET(x) offsetof(HEVCContext, x)
3483 #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
3494 {
"apply_defdispwin",
"Apply default display window from VUI",
OFFSET(apply_defdispwin),
3496 {
"strict-displaywin",
"stricly apply default display window size",
OFFSET(apply_defdispwin),
3514 .priv_class = &hevc_decoder_class,