26 #include "libavutil/attributes.h"
27 #include "libavutil/common.h"
28 #include "libavutil/display.h"
30 #include "libavutil/md5.h"
31 #include "libavutil/opt.h"
32 #include "libavutil/pixdesc.h"
33 #include "libavutil/stereo3d.h"
66 { 0, 1, 2, 3, 16, 17, 18, 19, },
67 { 4, 5, 6, 7, 20, 21, 22, 23, },
68 { 8, 9, 10, 11, 24, 25, 26, 27, },
69 { 12, 13, 14, 15, 28, 29, 30, 31, },
70 { 32, 33, 34, 35, 48, 49, 50, 51, },
71 { 36, 37, 38, 39, 52, 53, 54, 55, },
72 { 40, 41, 42, 43, 56, 57, 58, 59, },
73 { 44, 45, 46, 47, 60, 61, 62, 63, },
145 { 0, 2, 5, 9, 14, 20, 27, 35, },
146 { 1, 4, 8, 13, 19, 26, 34, 42, },
147 { 3, 7, 12, 18, 25, 33, 41, 48, },
148 { 6, 11, 17, 24, 32, 40, 47, 53, },
149 { 10, 16, 23, 31, 39, 46, 52, 57, },
150 { 15, 22, 30, 38, 45, 51, 56, 60, },
151 { 21, 29, 37, 44, 50, 55, 59, 62, },
152 { 28, 36, 43, 49, 54, 58, 61, 63, },
194 int pic_size_in_ctb = ((width >> log2_min_cb_size) + 1) *
195 ((height >> log2_min_cb_size) + 1);
249 uint8_t luma_weight_l0_flag[16];
250 uint8_t chroma_weight_l0_flag[16];
251 uint8_t luma_weight_l1_flag[16];
252 uint8_t chroma_weight_l1_flag[16];
262 if (!luma_weight_l0_flag[i]) {
269 chroma_weight_l0_flag[i] =
get_bits1(gb);
272 chroma_weight_l0_flag[i] = 0;
275 if (luma_weight_l0_flag[i]) {
280 if (chroma_weight_l0_flag[i]) {
281 for (j = 0; j < 2; j++) {
298 if (!luma_weight_l1_flag[i]) {
305 chroma_weight_l1_flag[i] =
get_bits1(gb);
308 chroma_weight_l1_flag[i] = 0;
311 if (luma_weight_l1_flag[i]) {
316 if (chroma_weight_l1_flag[i]) {
317 for (j = 0; j < 2; j++) {
338 int prev_delta_msb = 0;
339 unsigned int nb_sps = 0, nb_sh;
355 for (i = 0; i < rps->
nb_refs; i++) {
372 if (delta_poc_msb_present) {
375 if (i && i != nb_sps)
376 delta += prev_delta_msb;
379 prev_delta_msb =
delta;
389 unsigned int num = 0, den = 0;
444 if (num != 0 && den != 0)
502 int slice_address_length;
512 "Invalid slice segment address: %u.\n",
555 int short_term_ref_pic_set_sps_flag, poc;
561 "Ignoring POC change between slices: %d -> %d\n", s->
poc, poc);
568 short_term_ref_pic_set_sps_flag =
get_bits1(gb);
569 if (!short_term_ref_pic_set_sps_flag) {
576 int numbits, rps_idx;
584 rps_idx = numbits > 0 ?
get_bits(gb, numbits) : 0;
685 "Invalid collocated_ref_idx: %d.\n",
700 "Invalid number of merging MVP candidates: %d.\n",
717 int deblocking_filter_override_flag = 0;
720 deblocking_filter_override_flag =
get_bits1(gb);
722 if (deblocking_filter_override_flag) {
765 for (i = 0; i < length; i++)
774 "The slice_qp %d is outside the valid range "
799 #define CTB(tab, x, y) ((tab)[(y) * s->sps->ctb_width + (x)])
801 #define SET_SAO(elem, value) \
803 if (!sao_merge_up_flag && !sao_merge_left_flag) \
805 else if (sao_merge_left_flag) \
806 sao->elem = CTB(s->sao, rx-1, ry).elem; \
807 else if (sao_merge_up_flag) \
808 sao->elem = CTB(s->sao, rx, ry-1).elem; \
816 int sao_merge_left_flag = 0;
817 int sao_merge_up_flag = 0;
828 if (ry > 0 && !sao_merge_left_flag) {
834 for (c_idx = 0; c_idx < 3; c_idx++) {
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++) {
885 int log2_trafo_size,
enum ScanType scan_idx,
888 #define GET_COORD(offset, n) \
890 x_c = (scan_x_cg[offset >> 4] << 2) + scan_x_off[n]; \
891 y_c = (scan_y_cg[offset >> 4] << 2) + scan_y_off[n]; \
894 int transform_skip_flag = 0;
896 int last_significant_coeff_x, last_significant_coeff_y;
900 int greater1_ctx = 1;
903 int x_cg_last_sig, y_cg_last_sig;
905 const uint8_t *scan_x_cg, *scan_y_cg, *scan_x_off, *scan_y_off;
915 int trafo_size = 1 << log2_trafo_size;
916 int i, qp, shift, add, scale, scale_m;
917 const uint8_t level_scale[] = { 40, 45, 51, 57, 64, 72 };
923 static const int qp_c[] = {
924 29, 30, 31, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37
928 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2,
929 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
930 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3,
934 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3,
935 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6,
936 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10,
956 qp = qp_c[qp_i - 30];
962 add = 1 << (shift - 1);
963 scale = level_scale[rem6[qp]] << (div6[qp]);
972 if (log2_trafo_size != 5)
973 matrix_id = 3 * matrix_id + c_idx;
975 scale_matrix = sl->
sl[log2_trafo_size - 2][matrix_id];
976 if (log2_trafo_size >= 4)
977 dc_scale = sl->
sl_dc[log2_trafo_size - 4][matrix_id];
983 log2_trafo_size == 2) {
987 last_significant_coeff_x =
989 last_significant_coeff_y =
992 if (last_significant_coeff_x > 3) {
994 last_significant_coeff_x = (1 << ((last_significant_coeff_x >> 1) - 1)) *
995 (2 + (last_significant_coeff_x & 1)) +
999 if (last_significant_coeff_y > 3) {
1001 last_significant_coeff_y = (1 << ((last_significant_coeff_y >> 1) - 1)) *
1002 (2 + (last_significant_coeff_y & 1)) +
1007 FFSWAP(
int, last_significant_coeff_x, last_significant_coeff_y);
1009 x_cg_last_sig = last_significant_coeff_x >> 2;
1010 y_cg_last_sig = last_significant_coeff_y >> 2;
1014 int last_x_c = last_significant_coeff_x & 3;
1015 int last_y_c = last_significant_coeff_y & 3;
1020 if (trafo_size == 4) {
1023 }
else if (trafo_size == 8) {
1027 }
else if (trafo_size == 16) {
1043 num_coeff =
horiz_scan8x8_inv[last_significant_coeff_y][last_significant_coeff_x];
1050 num_coeff =
horiz_scan8x8_inv[last_significant_coeff_x][last_significant_coeff_y];
1054 num_last_subset = (num_coeff - 1) >> 4;
1056 for (i = num_last_subset; i >= 0; i--) {
1058 int x_cg, y_cg, x_c, y_c;
1059 int implicit_non_zero_coeff = 0;
1060 int64_t trans_coeff_level;
1062 int offset = i << 4;
1064 uint8_t significant_coeff_flag_idx[16];
1065 uint8_t nb_significant_coeff_flag = 0;
1067 x_cg = scan_x_cg[i];
1068 y_cg = scan_y_cg[i];
1070 if (i < num_last_subset && i > 0) {
1072 if (x_cg < (1 << (log2_trafo_size - 2)) - 1)
1073 ctx_cg += significant_coeff_group_flag[x_cg + 1][y_cg];
1074 if (y_cg < (1 << (log2_trafo_size - 2)) - 1)
1075 ctx_cg += significant_coeff_group_flag[x_cg][y_cg + 1];
1077 significant_coeff_group_flag[x_cg][y_cg] =
1079 implicit_non_zero_coeff = 1;
1081 significant_coeff_group_flag[x_cg][y_cg] =
1082 ((x_cg == x_cg_last_sig && y_cg == y_cg_last_sig) ||
1083 (x_cg == 0 && y_cg == 0));
1086 last_scan_pos = num_coeff - offset - 1;
1088 if (i == num_last_subset) {
1089 n_end = last_scan_pos - 1;
1090 significant_coeff_flag_idx[0] = last_scan_pos;
1091 nb_significant_coeff_flag = 1;
1096 if (x_cg < ((1 << log2_trafo_size) - 1) >> 2)
1097 prev_sig = significant_coeff_group_flag[x_cg + 1][y_cg];
1098 if (y_cg < ((1 << log2_trafo_size) - 1) >> 2)
1099 prev_sig += significant_coeff_group_flag[x_cg][y_cg + 1] << 1;
1101 for (n = n_end; n >= 0; n--) {
1104 if (significant_coeff_group_flag[x_cg][y_cg] &&
1105 (n > 0 || implicit_non_zero_coeff == 0)) {
1110 significant_coeff_flag_idx[nb_significant_coeff_flag] = n;
1111 nb_significant_coeff_flag++;
1112 implicit_non_zero_coeff = 0;
1115 int last_cg = (x_c == (x_cg << 2) && y_c == (y_cg << 2));
1116 if (last_cg && implicit_non_zero_coeff && significant_coeff_group_flag[x_cg][y_cg]) {
1117 significant_coeff_flag_idx[nb_significant_coeff_flag] = n;
1118 nb_significant_coeff_flag++;
1123 n_end = nb_significant_coeff_flag;
1126 int first_nz_pos_in_cg = 16;
1127 int last_nz_pos_in_cg = -1;
1128 int c_rice_param = 0;
1129 int first_greater1_coeff_idx = -1;
1130 uint8_t coeff_abs_level_greater1_flag[16] = { 0 };
1131 uint16_t coeff_sign_flag;
1133 int sign_hidden = 0;
1136 int ctx_set = (i > 0 && c_idx == 0) ? 2 : 0;
1138 if (!(i == num_last_subset) && greater1_ctx == 0)
1141 last_nz_pos_in_cg = significant_coeff_flag_idx[0];
1143 for (m = 0; m < (n_end > 8 ? 8 : n_end); m++) {
1144 int n_idx = significant_coeff_flag_idx[m];
1145 int inc = (ctx_set << 2) + greater1_ctx;
1146 coeff_abs_level_greater1_flag[n_idx] =
1148 if (coeff_abs_level_greater1_flag[n_idx]) {
1150 }
else if (greater1_ctx > 0 && greater1_ctx < 3) {
1154 if (coeff_abs_level_greater1_flag[n_idx] &&
1155 first_greater1_coeff_idx == -1)
1156 first_greater1_coeff_idx = n_idx;
1158 first_nz_pos_in_cg = significant_coeff_flag_idx[n_end - 1];
1159 sign_hidden = last_nz_pos_in_cg - first_nz_pos_in_cg >= 4 &&
1162 if (first_greater1_coeff_idx != -1) {
1168 coeff_sign_flag =
ff_hevc_coeff_sign_flag(s, nb_significant_coeff_flag - 1) << (16 - (nb_significant_coeff_flag - 1));
1171 for (m = 0; m < n_end; m++) {
1172 n = significant_coeff_flag_idx[m];
1174 trans_coeff_level = 1 + coeff_abs_level_greater1_flag[n];
1175 if (trans_coeff_level == ((m < 8) ?
1176 ((n == first_greater1_coeff_idx) ? 3 : 2) : 1)) {
1179 trans_coeff_level += last_coeff_abs_level_remaining;
1180 if ((trans_coeff_level) > (3 * (1 << c_rice_param)))
1181 c_rice_param =
FFMIN(c_rice_param + 1, 4);
1184 sum_abs += trans_coeff_level;
1185 if (n == first_nz_pos_in_cg && ((sum_abs & 1) == 1))
1186 trans_coeff_level = -trans_coeff_level;
1188 if (coeff_sign_flag >> 15)
1189 trans_coeff_level = -trans_coeff_level;
1190 coeff_sign_flag <<= 1;
1193 if (y_c || x_c || log2_trafo_size < 4) {
1195 switch (log2_trafo_size) {
1196 case 3: pos = (y_c << 3) + x_c;
break;
1197 case 4: pos = ((y_c >> 1) << 3) + (x_c >> 1);
break;
1198 case 5: pos = ((y_c >> 2) << 3) + (x_c >> 2);
break;
1199 default: pos = (y_c << 2) + x_c;
1201 scale_m = scale_matrix[pos];
1206 trans_coeff_level = (trans_coeff_level * (int64_t)scale * (int64_t)scale_m + add) >> shift;
1207 if(trans_coeff_level < 0) {
1208 if((~trans_coeff_level) & 0xFffffffffff8000)
1209 trans_coeff_level = -32768;
1211 if (trans_coeff_level & 0xffffffffffff8000)
1212 trans_coeff_level = 32767;
1215 coeffs[y_c * trafo_size + x_c] = trans_coeff_level;
1223 if (transform_skip_flag)
1226 log2_trafo_size == 2)
1234 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1235 int log2_cb_size,
int log2_trafo_size,
1236 int trafo_depth,
int blk_idx,
1237 int cbf_luma,
int cbf_cb,
int cbf_cr)
1242 int trafo_size = 1 << log2_trafo_size;
1246 if (log2_trafo_size > 2) {
1247 trafo_size = trafo_size << (s->
sps->
hshift[1] - 1);
1251 }
else if (blk_idx == 3) {
1252 trafo_size = trafo_size << s->
sps->
hshift[1];
1254 trafo_size, trafo_size);
1260 if (cbf_luma || cbf_cb || cbf_cr) {
1274 "The cu_qp_delta %d is outside the valid range "
1305 if (log2_trafo_size > 2) {
1310 }
else if (blk_idx == 3) {
1322 int cb_size = 1 << log2_cb_size;
1330 for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
1331 for (i = (x0 >> log2_min_pu_size); i < (x_end >> log2_min_pu_size); i++)
1332 s->
is_pcm[i + j * min_pu_width] = 2;
1336 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1337 int log2_cb_size,
int log2_trafo_size,
1338 int trafo_depth,
int blk_idx,
1339 int cbf_cb,
int cbf_cr)
1346 if (trafo_depth == 1)
1352 if (log2_trafo_size <= s->sps->log2_max_trafo_size &&
1354 trafo_depth < lc->cu.max_trafo_depth &&
1368 if (log2_trafo_size > 2 && (trafo_depth == 0 || cbf_cb))
1370 else if (log2_trafo_size > 2 || trafo_depth == 0)
1372 if (log2_trafo_size > 2 && (trafo_depth == 0 || cbf_cr))
1374 else if (log2_trafo_size > 2 || trafo_depth == 0)
1377 if (split_transform_flag) {
1378 const int trafo_size_split = 1 << (log2_trafo_size - 1);
1379 const int x1 = x0 + trafo_size_split;
1380 const int y1 = y0 + trafo_size_split;
1382 #define SUBDIVIDE(x, y, idx) \
1384 ret = hls_transform_tree(s, x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size, \
1385 log2_trafo_size - 1, trafo_depth + 1, idx, \
1408 log2_cb_size, log2_trafo_size, trafo_depth,
1409 blk_idx, cbf_luma, cbf_cb, cbf_cr);
1415 for (i = 0; i < (1 << log2_trafo_size); i += min_tu_size)
1416 for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) {
1417 int x_tu = (x0 + j) >> log2_min_tu_size;
1418 int y_tu = (y0 + i) >> log2_min_tu_size;
1419 s->
cbf_luma[y_tu * min_tu_width + x_tu] = 1;
1437 int cb_size = 1 << log2_cb_size;
1476 case 0: lc->
pu.
mvd.
x = 0;
break;
1482 case 0: lc->
pu.
mvd.
y = 0;
break;
1501 int block_w,
int block_h)
1505 ptrdiff_t srcstride = ref->
linesize[0];
1514 x_off += mv->
x >> 2;
1515 y_off += mv->
y >> 2;
1518 if (x_off < extra_left || y_off < extra_top ||
1522 int offset = extra_top * srcstride + (extra_left << s->
sps->
pixel_shift);
1523 int buf_offset = extra_top *
1527 edge_emu_stride, srcstride,
1530 x_off - extra_left, y_off - extra_top,
1531 pic_width, pic_height);
1533 srcstride = edge_emu_stride;
1555 int x_off,
int y_off,
int block_w,
int block_h)
1560 ptrdiff_t src1stride = ref->
linesize[1];
1561 ptrdiff_t src2stride = ref->
linesize[2];
1562 int pic_width = s->
sps->
width >> 1;
1568 x_off += mv->
x >> 3;
1569 y_off += mv->
y >> 3;
1585 edge_emu_stride, src1stride,
1589 pic_width, pic_height);
1592 src1stride = edge_emu_stride;
1594 block_w, block_h, mx, my, lc->
mc_buffer);
1597 edge_emu_stride, src2stride,
1601 pic_width, pic_height);
1603 src2stride = edge_emu_stride;
1606 block_w, block_h, mx, my,
1610 block_w, block_h, mx, my,
1613 block_w, block_h, mx, my,
1621 int y = (mv->
y >> 2) + y0 + height + 9;
1627 int log2_cb_size,
int partIdx)
1629 #define POS(c_idx, x, y) \
1630 &s->frame->data[c_idx][((y) >> s->sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \
1631 (((x) >> s->sps->hshift[c_idx]) << s->sps->pixel_shift)]
1634 struct MvField current_mv = {{{ 0 }}};
1649 int x_cb = x0 >> log2_min_cb_size;
1650 int y_cb = y0 >> log2_min_cb_size;
1665 log2_cb_size, partIdx,
1666 merge_idx, ¤t_mv);
1672 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
1682 partIdx, merge_idx, ¤t_mv);
1688 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
1695 if (inter_pred_idc !=
PRED_L1) {
1698 current_mv.
ref_idx[0] = ref_idx[0];
1704 partIdx, merge_idx, ¤t_mv,
1710 if (inter_pred_idc !=
PRED_L0) {
1713 current_mv.
ref_idx[1] = ref_idx[1];
1725 partIdx, merge_idx, ¤t_mv,
1736 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
1741 ref0 = refPicList[0].
ref[current_mv.
ref_idx[0]];
1747 ref1 = refPicList[1].
ref[current_mv.
ref_idx[1]];
1758 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH);
1766 tmpstride, nPbW, nPbH);
1771 ¤t_mv.
mv[0], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2);
1779 nPbW / 2, nPbH / 2);
1784 nPbW / 2, nPbH / 2);
1797 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH);
1811 ¤t_mv.
mv[1], x0/2, y0/2, nPbW/2, nPbH/2);
1818 dst1, s->
frame->
linesize[1], tmp, tmpstride, nPbW/2, nPbH/2);
1822 dst2, s->
frame->
linesize[2], tmp2, tmpstride, nPbW/2, nPbH/2);
1839 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH);
1841 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH);
1851 tmp, tmp2, tmpstride, nPbW, nPbH);
1854 tmp, tmp2, tmpstride, nPbW, nPbH);
1858 ¤t_mv.
mv[0], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2);
1860 ¤t_mv.
mv[1], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2);
1870 tmpstride, nPbW / 2, nPbH / 2);
1877 tmpstride, nPbW / 2, nPbH / 2);
1889 int prev_intra_luma_pred_flag)
1907 int intra_pred_mode;
1912 if ((y0 - 1) < y_ctb)
1915 if (cand_left == cand_up) {
1916 if (cand_left < 2) {
1921 candidate[0] = cand_left;
1922 candidate[1] = 2 + ((cand_left - 2 - 1 + 32) & 31);
1923 candidate[2] = 2 + ((cand_left - 2 + 1) & 31);
1926 candidate[0] = cand_left;
1927 candidate[1] = cand_up;
1937 if (prev_intra_luma_pred_flag) {
1938 intra_pred_mode = candidate[lc->
pu.
mpm_idx];
1940 if (candidate[0] > candidate[1])
1942 if (candidate[0] > candidate[2])
1944 if (candidate[1] > candidate[2])
1948 for (i = 0; i < 3; i++)
1949 if (intra_pred_mode >= candidate[i])
1956 for (i = 0; i < size_in_pus; i++) {
1957 memset(&s->
tab_ipm[(y_pu + i) * min_pu_width + x_pu],
1958 intra_pred_mode, size_in_pus);
1960 for (j = 0; j < size_in_pus; j++) {
1961 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
is_intra = 1;
1962 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
pred_flag[0] = 0;
1963 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
pred_flag[1] = 0;
1964 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
ref_idx[0] = 0;
1965 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
ref_idx[1] = 0;
1966 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
mv[0].x = 0;
1967 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
mv[0].y = 0;
1968 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
mv[1].x = 0;
1969 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
mv[1].y = 0;
1973 return intra_pred_mode;
1977 int log2_cb_size,
int ct_depth)
1984 for (y = 0; y < length; y++)
1993 static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 };
1994 uint8_t prev_intra_luma_pred_flag[4];
1996 int pb_size = (1 << log2_cb_size) >> split;
1997 int side = split + 1;
2001 for (i = 0; i < side; i++)
2002 for (j = 0; j < side; j++)
2005 for (i = 0; i < side; i++) {
2006 for (j = 0; j < side; j++) {
2007 if (prev_intra_luma_pred_flag[2 * i + j])
2014 prev_intra_luma_pred_flag[2 * i + j]);
2019 if (chroma_mode != 4) {
2034 int pb_size = 1 << log2_cb_size;
2042 if (size_in_pus == 0)
2044 for (j = 0; j < size_in_pus; j++) {
2045 memset(&s->
tab_ipm[(y_pu + j) * min_pu_width + x_pu],
INTRA_DC, size_in_pus);
2046 for (k = 0; k < size_in_pus; k++)
2053 int cb_size = 1 << log2_cb_size;
2056 int length = cb_size >> log2_min_cb_size;
2058 int x_cb = x0 >> log2_min_cb_size;
2059 int y_cb = y0 >> log2_min_cb_size;
2071 for (x = 0; x < 4; x++)
2084 x = y_cb * min_cb_width + x_cb;
2085 for (y = 0; y < length; y++) {
2086 memset(&s->
skip_flag[x], skip_flag, length);
2111 log2_cb_size <= s->sps->pcm.log2_max_pcm_cb_size) {
2159 hls_prediction_unit(s, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3);
2175 log2_cb_size, 0, 0, 0, 0);
2188 x = y_cb * min_cb_width + x_cb;
2189 for (y = 0; y < length; y++) {
2200 int log2_cb_size,
int cb_depth)
2203 const int cb_size = 1 << log2_cb_size;
2207 if (x0 + cb_size <= s->sps->width &&
2208 y0 + cb_size <= s->sps->height &&
2221 const int cb_size_split = cb_size >> 1;
2222 const int x1 = x0 + cb_size_split;
2223 const int y1 = y0 + cb_size_split;
2228 #define SUBDIVIDE(x, y) \
2230 if (x < s->sps->width && y < s->sps->height) { \
2231 int ret = hls_coding_quadtree(s, x, y, log2_cb_size, cb_depth);\
2256 int ctb_addr_in_slice = ctb_addr_rs - s->
sh.
slice_addr;
2261 if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
2288 if (!ctb_addr_in_slice > 0)
2290 if (ctb_addr_in_slice < s->sps->ctb_width)
2309 while (more_data && ctb_addr_ts < s->sps->ctb_size) {
2334 if (x_ctb + ctb_size >= s->
sps->
width &&
2361 "nal_unit_type: %d, nuh_layer_id: %dtemporal_id: %d\n",
2364 return nuh_layer_id == 0;
2372 for (c_idx = 0; c_idx < 3; c_idx++) {
2380 int len = min_pu_size >> hshift;
2383 for (n = 0; n < (min_pu_size >> vshift); n++) {
2384 memcpy(dst, src, len);
2497 int ctb_addr_ts, ret;
2553 if (s->
max_ra == INT_MAX) {
2575 }
else if (!s->
ref) {
2582 "Non-matching NAL types of the VCL NALUs: %d %d\n",
2592 "Error constructing the reference lists for the current slice.\n");
2606 if (ctb_addr_ts < 0) {
2639 #define STARTCODE_TEST \
2640 if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
2641 if (src[i + 2] != 3) { \
2647 #if HAVE_FAST_UNALIGNED
2648 #define FIND_FIRST_ZERO \
2649 if (i > 0 && !src[i]) \
2654 for (i = 0; i + 1 < length; i += 9) {
2656 (
AV_RN64A(src + i) - 0x0100010001000101ULL)) &
2657 0x8000800080008080ULL))
2664 for (i = 0; i + 1 < length; i += 5) {
2666 (
AV_RN32A(src + i) - 0x01000101U)) &
2675 for (i = 0; i + 1 < length; i += 2) {
2678 if (i > 0 && src[i - 1] == 0)
2684 if (i >= length - 1) {
2697 memcpy(dst, src, i);
2699 while (si + 2 < length) {
2701 if (src[si + 2] > 3) {
2702 dst[di++] = src[si++];
2703 dst[di++] = src[si++];
2704 }
else if (src[si] == 0 && src[si + 1] == 0) {
2705 if (src[si + 2] == 3) {
2715 dst[di++] = src[si++];
2718 dst[di++] = src[si++];
2730 int i, consumed, ret = 0;
2738 while (length >= 4) {
2740 int extract_length = 0;
2745 extract_length = (extract_length << 8) | buf[i];
2749 if (extract_length > length) {
2760 if (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
2767 extract_length = length;
2804 for (i = 0; i < s->
nb_nals; i++) {
2808 "Error parsing NAL unit #%d.\n", i);
2823 for (i = 0; i < 16; i++)
2824 av_log(log_ctx, level,
"%02"PRIx8, md5[i]);
2853 for (i = 0; frame->
data[i]; i++) {
2861 for (j = 0; j < h; j++) {
2866 (
const uint16_t *) src, w);
2874 if (!memcmp(md5, s->
md5[i], 16)) {
3123 int i, j, num_arrays, nal_len_size;
3128 nal_len_size = (bytestream2_get_byte(&gb) & 3) + 1;
3129 num_arrays = bytestream2_get_byte(&gb);
3136 for (i = 0; i < num_arrays; i++) {
3137 int type = bytestream2_get_byte(&gb) & 0x3f;
3138 int cnt = bytestream2_get_be16(&gb);
3140 for (j = 0; j < cnt; j++) {
3142 int nalsize = bytestream2_peek_be16(&gb) + 2;
3145 "Invalid NAL unit size in extradata.\n");
3152 "Decoding nal unit %d %d from hvcC failed\n",
3201 memset(s, 0,
sizeof(*s));
3217 #define OFFSET(x) offsetof(HEVCContext, x)
3218 #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
3228 {
"apply_defdispwin",
"Apply default display window from VUI",
OFFSET(apply_defdispwin),
3246 .priv_class = &hevc_decoder_class,
#define EDGE_EMU_BUFFER_STRIDE
static const uint8_t horiz_scan2x2_x[4]
int frame_packing_arrangement_type
unsigned int log2_min_cb_size
int sei_frame_packing_present
frame packing arrangement variables
int ff_hevc_merge_idx_decode(HEVCContext *s)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
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.
This structure describes decoded (raw) audio or video data.
static void restore_tqb_pixels(HEVCContext *s)
void(* bswap16_buf)(uint16_t *dst, const uint16_t *src, int len)
void(* put_hevc_epel[2][2])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int width, int height, int mx, int my, int16_t *mcbuffer)
void(* put_unweighted_pred)(uint8_t *dst, ptrdiff_t dststride, int16_t *src, ptrdiff_t srcstride, int width, int height)
static void hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size)
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.
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)
#define AV_LOG_WARNING
Something somehow does not look correct.
int content_interpretation_type
int ff_hevc_cbf_luma_decode(HEVCContext *s, int trafo_depth)
int16_t x
horizontal component of motion vector
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.
static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
Clip a signed integer value into the amin-amax range.
void(* put_hevc_qpel[4][4])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int width, int height, int16_t *mcbuffer)
#define FF_PROFILE_HEVC_MAIN
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)
int ff_hevc_significant_coeff_group_flag_decode(HEVCContext *s, int c_idx, int ctx_cg)
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)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
#define DECLARE_ALIGNED(n, t, v)
int ff_hevc_rem_intra_luma_pred_mode_decode(HEVCContext *s)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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 ff_hevc_hls_filter(HEVCContext *s, int x, int y)
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everythnig contained in src to dst and reset src.
int ff_hevc_frame_rps(HEVCContext *s)
Construct the reference picture sets for the current frame.
int ff_hevc_coeff_abs_level_greater2_flag_decode(HEVCContext *s, int c_idx, int inc)
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]
the normal 219*2^(n-8) "MPEG" YUV ranges
ShortTermRPS st_rps[MAX_SHORT_TERM_RPS_COUNT]
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...
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
enum NALUnitType first_nal_type
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
uint8_t entropy_coding_sync_enabled_flag
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
int ff_hevc_cu_transquant_bypass_flag_decode(HEVCContext *s)
static int hls_slice_data(HEVCContext *s)
const uint8_t ff_hevc_qpel_extra_before[4]
static void hls_sao_param(HEVCContext *s, int rx, int ry)
AVBufferPool * rpl_tab_pool
candidate references for the current frame
int ff_hevc_last_significant_coeff_y_prefix_decode(HEVCContext *s, int c_idx, int log2_size)
unsigned int log2_max_trafo_size
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
int ff_hevc_mpm_idx_decode(HEVCContext *s)
int ff_hevc_coeff_abs_level_greater1_flag_decode(HEVCContext *s, int c_idx, int ctx_set)
Views are next to each other.
int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0, int x_cb, int y_cb)
void(* weighted_pred_avg)(uint8_t denom, int16_t wl0Flag, int16_t wl1Flag, int16_t ol0Flag, int16_t ol1Flag, uint8_t *dst, ptrdiff_t dststride, int16_t *src1, int16_t *src2, ptrdiff_t srcstride, int width, int height)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
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
int ff_hevc_abs_mvd_greater0_flag_decode(HEVCContext *s)
static int hls_slice_header(HEVCContext *s)
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
int num_ref_idx_l1_default_active
num_ref_idx_l1_default_active_minus1 + 1
const char * name
Name of the codec implementation.
unsigned int log2_min_pcm_cb_size
static void luma_mc(HEVCContext *s, int16_t *dst, ptrdiff_t dststride, AVFrame *ref, const Mv *mv, int x_off, int y_off, int block_w, int block_h)
8.5.3.2.2.1 Luma sample interpolation process
#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)
uint8_t scaling_list_data_present_flag
struct AVCodecInternal * internal
Private context used for internal data.
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.
#define EPEL_EXTRA_BEFORE
uint8_t loop_filter_disable_flag
int ff_hevc_mvd_decode(HEVCContext *s)
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
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...
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
void(* put_weighted_pred_avg)(uint8_t *dst, ptrdiff_t dststride, int16_t *src1, int16_t *src2, ptrdiff_t srcstride, int width, int height)
int ff_hevc_sao_offset_sign_decode(HEVCContext *s)
int temporal_id
temporal_id_plus1 - 1
#define SET_SAO(elem, value)
static void hevc_decode_flush(AVCodecContext *avctx)
int slice_idx
number of the slice being currently decoded
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)...
#define BOUNDARY_UPPER_SLICE
uint8_t intra_pred_mode[4]
uint16_t depth_minus1
Number of bits in the component minus 1.
void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len)
#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)
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
static int extract_rbsp(const uint8_t *src, int length, HEVCNAL *nal)
unsigned int log2_max_poc_lsb
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
void(* transform_add[4])(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
AVBufferRef * vps_list[MAX_VPS_COUNT]
static void chroma_mc(HEVCContext *s, int16_t *dst1, int16_t *dst2, ptrdiff_t dststride, AVFrame *ref, const Mv *mv, int x_off, int y_off, int block_w, int block_h)
8.5.3.2.2.2 Chroma sample interpolation process
#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
struct AVMD5 * av_md5_alloc(void)
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
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#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 ff_init_cabac_states(void)
void(* transquant_bypass[4])(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
void ff_hevc_save_states(HEVCContext *s, int ctb_addr_ts)
Views are next to each other, but when upscaling apply a checkerboard pattern.
static int verify_md5(HEVCContext *s, AVFrame *frame)
static const AVClass hevc_decoder_class
uint8_t max_trafo_depth
MaxTrafoDepth.
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 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)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
int ff_hevc_mvd_sign_flag_decode(HEVCContext *s)
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
int ff_hevc_coeff_abs_level_remaining(HEVCContext *s, int base_level, int rc_rice_param)
uint8_t type_idx[3]
sao_type_idx
const uint8_t ff_hevc_qpel_extra[4]
int ff_hevc_transform_skip_flag_decode(HEVCContext *s, int c_idx)
const uint8_t ff_hevc_qpel_extra_after[4]
uint8_t * data
The data buffer.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
int max_transform_hierarchy_depth_inter
int16_t mc_buffer[(64+7)*64]
static const AVOption options[]
the normal 2^n-1 "JPEG" YUV ranges
int offset_abs[3][4]
sao_offset_abs
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.
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)
void(* transform_skip)(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
static int luma_intra_pred_mode(HEVCContext *s, int x0, int y0, int pu_size, int prev_intra_luma_pred_flag)
8.4.1
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
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.
void(* emulated_edge_mc)(uint8_t *buf, const uint8_t *src, ptrdiff_t buf_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...
AVBufferRef * sps_list[MAX_SPS_COUNT]
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
uint8_t cu_qp_delta_enabled_flag
#define FF_ARRAY_ELEMS(a)
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(* put_pcm)(uint8_t *dst, ptrdiff_t stride, int size, GetBitContext *gb, int pcm_bit_depth)
void ff_hevc_set_neighbour_available(HEVCContext *s, int x0, int y0, int nPbW, int nPbH)
uint8_t sign_data_hiding_flag
uint8_t output_flag_present_flag
#define FF_PROFILE_UNKNOWN
const uint8_t ff_hevc_diag_scan4x4_y[16]
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
int offset_val[3][5]
SaoOffsetVal.
static int hevc_frame_start(HEVCContext *s)
AVBufferRef * pps_list[MAX_PPS_COUNT]
if(ac->has_optimized_func)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
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)
int colour_description_present_flag
static const int8_t mv[256][2]
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int partIdx)
enum AVPixelFormat pix_fmt
static int hls_transform_unit(HEVCContext *s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, int trafo_depth, int blk_idx, int cbf_luma, int cbf_cb, int cbf_cr)
int sei_display_orientation_present
display orientation
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 ...
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
uint8_t transform_skip_enabled_flag
static av_cold int hevc_decode_init(AVCodecContext *avctx)
int ff_hevc_significant_coeff_flag_decode(HEVCContext *s, int c_idx, int x_c, int y_c, int log2_trafo_size, int scan_idx, int prev_sig)
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.
unsigned int log2_min_pu_size
int ff_hevc_decode_nal_pps(HEVCContext *s)
int ff_hevc_abs_mvd_greater1_flag_decode(HEVCContext *s)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
struct HEVCSPS::@25 temporal_layer[MAX_SUB_LAYERS]
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.
static void close(AVCodecParserContext *s)
static int hevc_decode_extradata(HEVCContext *s)
enum PredMode pred_mode
PredMode.
int num_extra_slice_header_bits
int16_t y
vertical component of motion vector
void ff_hevc_clear_refs(HEVCContext *s)
Mark all frames in DPB as unused for reference.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
uint8_t num_long_term_ref_pics_sps
void av_md5_init(struct AVMD5 *ctx)
static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb, int ctb_addr_ts)
uint32_t vui_num_units_in_tick
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
uint8_t deblocking_filter_control_present_flag
static unsigned int get_bits1(GetBitContext *s)
void ff_hevc_pred_init(HEVCPredContext *hpc, int bit_depth)
uint8_t * checksum_buf
used on BE to byteswap the lines for checksumming
uint8_t sps_temporal_mvp_enabled_flag
Describe the class of an AVClass context structure.
static void skip_bits(GetBitContext *s, int n)
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
void av_buffer_pool_uninit(AVBufferPool **pool)
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.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int ff_hevc_sao_eo_class_decode(HEVCContext *s)
static const uint8_t rem6[QP_MAX_NUM+1]
static const uint8_t diag_scan2x2_inv[2][2]
unsigned int log2_min_tb_size
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
enum PartMode part_mode
PartMode.
uint16_t lt_ref_pic_poc_lsb_sps[32]
int ff_hevc_slice_rpl(HEVCContext *s)
Construct the reference picture list(s) for the current slice.
static int hls_nal_unit(HEVCContext *s)
static const uint8_t horiz_scan4x4_x[16]
enum NALUnitType nal_unit_type
void av_md5_final(struct AVMD5 *ctx, uint8_t *dst)
int allocate_progress
Whether to allocate progress for frame threading.
uint8_t scaling_list_enable_flag
static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_size)
static const uint8_t horiz_scan4x4_y[16]
int tc_offset
tc_offset_div2 * 2
uint8_t transfer_characteristic
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip)
Flip the input matrix horizontally and/or vertically.
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_cbf_cb_cr_decode(HEVCContext *s, int trafo_depth)
int ff_hevc_ref_idx_lx_decode(HEVCContext *s, int num_ref_idx_lx)
uint8_t intra_pred_mode_c
static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int log2_cb_size, int cb_depth)
int eos
current packet contains an EOS/EOB NAL
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
const uint8_t ff_hevc_diag_scan8x8_x[64]
int ff_hevc_intra_chroma_pred_mode_decode(HEVCContext *s)
int max_transform_hierarchy_depth_intra
coded frame dimension in various units
int ff_hevc_no_residual_syntax_flag_decode(HEVCContext *s)
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
#define FFSWAP(type, a, b)
static void hls_residual_coding(HEVCContext *s, int x0, int y0, int log2_trafo_size, enum ScanType scan_idx, int c_idx)
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
#define BOUNDARY_LEFT_SLICE
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
int32_t * tab_slice_address
static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output, AVPacket *avpkt)
unsigned int * column_width
ColumnWidth.
static const uint8_t diag_scan2x2_x[4]
Views are alternated temporally.
uint8_t * filter_slice_edges
uint8_t slice_header_extension_present_flag
static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
int ff_hevc_coeff_sign_flag(HEVCContext *s, uint8_t nb)
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
static av_cold int init(AVCodecParserContext *s)
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, int cbf_cb, int cbf_cr)
int video_full_range_flag
int ff_hevc_cu_qp_delta_abs(HEVCContext *s)
static const uint8_t div6[QP_MAX_NUM+1]
void ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts)
#define SUBDIVIDE(x, y, idx)
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
int ff_hevc_split_transform_flag_decode(HEVCContext *s, int log2_trafo_size)
#define GET_COORD(offset, n)
static const uint8_t horiz_scan8x8_inv[8][8]
int ff_hevc_pred_mode_decode(HEVCContext *s)
int ff_hevc_cu_qp_delta_sign_flag(HEVCContext *s)
const uint8_t ff_hevc_diag_scan4x4_x[16]
int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCContext *s)
int key_frame
1 -> keyframe, 0-> not
void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size)
Views are on top of each other.
static const uint8_t diag_scan4x4_inv[4][4]
int ff_hevc_last_significant_coeff_suffix_decode(HEVCContext *s, int last_significant_coeff_prefix)
uint8_t long_term_ref_pics_present_flag
void(* transform_4x4_luma_add)(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
#define FF_PROFILE_HEVC_MAIN_STILL_PICTURE
static void * av_mallocz_array(size_t nmemb, size_t size)
int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
static const uint8_t scan_1x1[1]
int ff_hevc_last_significant_coeff_x_prefix_decode(HEVCContext *s, int c_idx, int log2_size)
void(* weighted_pred)(uint8_t denom, int16_t wlxFlag, int16_t olxFlag, uint8_t *dst, ptrdiff_t dststride, int16_t *src, ptrdiff_t srcstride, int width, int height)
int diff_cu_qp_delta_depth
int ff_hevc_sao_offset_abs_decode(HEVCContext *s)
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data...
int ff_hevc_pcm_flag_decode(HEVCContext *s)
const uint8_t ff_hevc_diag_scan8x8_y[64]
uint8_t context_initialized
int video_signal_type_present_flag
uint8_t deblocking_filter_override_enabled_flag
int beta_offset
beta_offset_div2 * 2
av_default_item_name
Return the context name.
static const uint8_t horiz_scan2x2_y[4]
#define BOUNDARY_LEFT_TILE
static const uint8_t diag_scan2x2_y[4]
int ff_hevc_sao_merge_flag_decode(HEVCContext *s)
AVStereo3D * av_stereo3d_create_side_data(AVFrame *frame)
Allocate a complete AVFrameSideData and add it to the frame.
static av_cold int hevc_decode_free(AVCodecContext *avctx)
This structure stores compressed data.
#define FF_PROFILE_HEVC_MAIN_10
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int hevc_ref_frame(HEVCContext *s, HEVCFrame *dst, HEVCFrame *src)
static const uint8_t diag_scan8x8_inv[8][8]
uint8_t separate_colour_plane_flag
output (i.e. cropped) values
static const AVProfile profiles[]
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
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