34static const uint8_t default_scaling_list_inter[] = {
35 16, 16, 16, 16, 17, 18, 20, 24, 16, 16, 16, 17, 18, 20, 24, 25,
36 16, 16, 17, 18, 20, 24, 25, 28, 16, 17, 18, 20, 24, 25, 28, 33,
37 17, 18, 20, 24, 25, 28, 33, 41, 18, 20, 24, 25, 28, 33, 41, 54,
38 20, 24, 25, 28, 33, 41, 54, 71, 24, 25, 28, 33, 41, 54, 71, 91};
40static const uint8_t default_scaling_list_intra[] = {
41 16, 16, 16, 16, 17, 18, 21, 24, 16, 16, 16, 16, 17, 19, 22, 25,
42 16, 16, 17, 18, 20, 22, 25, 29, 16, 16, 18, 21, 24, 27, 31, 36,
43 17, 17, 20, 24, 30, 35, 41, 47, 18, 19, 22, 27, 35, 44, 54, 65,
44 21, 22, 25, 31, 41, 54, 70, 88, 24, 25, 29, 36, 47, 65, 88, 115};
46static const uint8_t default_scaling4[2][16] = {
47 {6, 13, 20, 28, 13, 20, 28, 32, 20, 28, 32, 37, 28, 32, 37, 42},
48 {10, 14, 20, 24, 14, 20, 24, 27, 20, 24, 27, 30, 24, 27, 30, 34}};
50static const uint8_t default_scaling8[2][64] = {
51 {6, 10, 13, 16, 18, 23, 25, 27, 10, 11, 16, 18, 23, 25, 27, 29,
52 13, 16, 18, 23, 25, 27, 29, 31, 16, 18, 23, 25, 27, 29, 31, 33,
53 18, 23, 25, 27, 29, 31, 33, 36, 23, 25, 27, 29, 31, 33, 36, 38,
54 25, 27, 29, 31, 33, 36, 38, 40, 27, 29, 31, 33, 36, 38, 40, 42},
55 {9, 13, 15, 17, 19, 21, 22, 24, 13, 13, 17, 19, 21, 22, 24, 25,
56 15, 17, 19, 21, 22, 24, 25, 27, 17, 19, 21, 22, 24, 25, 27, 28,
57 19, 21, 22, 24, 25, 27, 28, 30, 21, 22, 24, 25, 27, 28, 30, 32,
58 22, 24, 25, 27, 28, 30, 32, 33, 24, 25, 27, 28, 30, 32, 33, 35}};
60static const uint8_t ni_zigzag_direct[64] = {
61 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
62 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
63 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
64 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63};
66static const uint8_t ni_zigzag_scan[16 + 1] = {
67 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4, 1 + 1 * 4, 2 + 0 * 4,
68 3 + 0 * 4, 2 + 1 * 4, 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4,
69 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4,
73 {0, 1}, {1, 1}, {12, 11}, {10, 11}, {16, 11}, {40, 33},
74 {24, 11}, {20, 11}, {32, 11}, {80, 33}, {18, 11}, {15, 11},
75 {64, 33}, {160, 99}, {4, 3}, {3, 2}, {2, 1},
78static const uint8_t hevc_sub_width_c[] = {1, 2, 2, 1};
80static const uint8_t hevc_sub_height_c[] = {1, 2, 1, 1};
82static const uint8_t hevc_diag_scan4x4_x[16] = {
83 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 1, 2, 3, 2, 3, 3,
86static const uint8_t hevc_diag_scan4x4_y[16] = {
87 0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 3, 2, 3,
90static const uint8_t hevc_diag_scan8x8_x[64] = {
91 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0,
92 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 2,
93 3, 4, 5, 6, 7, 3, 4, 5, 6, 7, 4, 5, 6, 7, 5, 6, 7, 6, 7, 7,
96static const uint8_t hevc_diag_scan8x8_y[64] = {
97 0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 6,
98 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 7,
99 6, 5, 4, 3, 2, 7, 6, 5, 4, 3, 7, 6, 5, 4, 7, 6, 5, 7, 6, 7,
187 for (i = 0; i < cpb_count; i++)
205 int ret = -1, aspect_ratio_info_present_flag;
206 unsigned int aspect_ratio_idc;
209 if (aspect_ratio_info_present_flag)
218 sps->
sar = ni_h264_pixel_aspect_list[aspect_ratio_idc];
276 if (!num_units_in_tick || !time_scale)
280 num_units_in_tick, time_scale);
339 const uint8_t *jvt_list,
const uint8_t *fallback_list)
341 int i, last = 8, next = 8;
342 const uint8_t *scan = (size == 16 ? ni_zigzag_scan : ni_zigzag_direct);
347 memcpy(factors, fallback_list, size *
sizeof(uint8_t));
350 for (i = 0; i < size; i++)
355 if (v < -128 || v > 127)
360 next = (last + v) & 0xff;
364 memcpy(factors, jvt_list, size *
sizeof(uint8_t));
367 last = (factors[scan[i]] = next ? next : last);
375 uint8_t (*scaling_matrix4)[16], uint8_t (*scaling_matrix8)[64])
378 const uint8_t *fallback[4] = {default_scaling4[0], default_scaling4[1],
379 default_scaling8[0], default_scaling8[1]};
385 default_scaling4[0], fallback[0]);
387 default_scaling4[0], scaling_matrix4[0]);
389 default_scaling4[0], scaling_matrix4[1]);
391 default_scaling4[1], fallback[1]);
393 default_scaling4[1], scaling_matrix4[3]);
395 default_scaling4[1], scaling_matrix4[4]);
397 default_scaling8[0], fallback[2]);
399 default_scaling8[1], fallback[3]);
403 default_scaling8[0], scaling_matrix8[0]);
405 default_scaling8[1], scaling_matrix8[3]);
407 default_scaling8[0], scaling_matrix8[1]);
409 default_scaling8[1], scaling_matrix8[4]);
424 int profile_idc, level_idc, constraint_set_flags = 0;
426 int i, log2_max_frame_num_minus4;
455 if (100 == profile_idc || 110 == profile_idc || 122 == profile_idc ||
456 244 == profile_idc || 44 == profile_idc || 83 == profile_idc ||
457 86 == profile_idc || 118 == profile_idc || 128 == profile_idc ||
458 138 == profile_idc || 139 == profile_idc || 134 == profile_idc ||
459 135 == profile_idc || 144 == profile_idc )
516 log2_max_frame_num_minus4);
587 int step_x = 1 << hsub;
624 int *sei_type,
int *is_interlaced)
640 unsigned type = 0, tmp;
651 }
while (tmp == 0xFF);
653 *sei_type = (int)type;
663 }
while (tmp == 0xFF);
676 if (cpb_dpb_delays_present_flag)
688 "parse_sei pic_timing SEI invalid pic_struct: "
720 uint32_t nal_size, ep3_removed = 0, vcl_nal_count = 0;
721 int nal_type = -1, sei_type = -1;
722 int sps_parsed = 0, is_interlaced = 0;
732 while ((!sps_parsed || !is_interlaced) && vcl_nal_count < 100 &&
739 while (!(p_buf[0] == 0x00 && p_buf[1] == 0x00 && p_buf[2] == 0x01) &&
755 nal_size -= ep3_removed;
759 if (vcl_nal_count > 0)
762 "Warning: %s has %d slice NAL units ahead of SPS!\n",
763 __func__, vcl_nal_count);
787 "probe_h264_stream_info interlaced NOT supported!\n");
795 vcl_nal_count, sps_parsed ?
"Yes" :
"No",
796 is_interlaced ?
"Yes" :
"No");
797 if (sps_parsed && !is_interlaced)
803 "probing failed.\n");
806 static const char csp[4][5] = {
"Gray",
"420",
"422",
"444"};
808 "H.264 stream probed %d VCL NAL units, sps:%u "
809 "profile:%d/%d poc %d ref:%d %dx%d [SAR: %d:%d] %s %s "
810 "%" PRId32
"/%" PRId32
" %d bits max_reord:%d max_dec_buf:"
832 int32_t *frame_num,
unsigned int *first_mb_in_slice)
835 uint8_t *p_buf = buf;
836 unsigned int slice_type, pps_id;
839 while (!(p_buf[0] == 0x00 && p_buf[1] == 0x00 && p_buf[2] == 0x01) &&
865 slice_type, *first_mb_in_slice);
872 "pps_id %u size %d first_mb %u\n",
873 slice_type, *frame_num, pps_id, size_bytes,
927 *nal_type = (p_ctx->
file_cache[i] & 0x7E) >> 1;
953 int subpic_params_present)
957 for (i = 0; i < nb_cpb; i++)
962 if (subpic_params_present)
982 for (i = 0; i < 32; i++)
995#define check_profile_idc(idc) \
996 ptl->profile_idc == (idc) || ptl->profile_compatibility_flag[idc]
1036#undef check_profile_idc
1046 8 + (8 * 2 * (max_num_sub_layers - 1 > 0)))
1058 for (i = 0; i < max_num_sub_layers - 1; i++)
1064 if (max_num_sub_layers - 1 > 0)
1065 for (i = max_num_sub_layers - 1; i < 8; i++)
1067 for (i = 0; i < max_num_sub_layers - 1; i++)
1081 "Not enough data for sublayer %i level_idc\n", i);
1093 int nal_params_present = 0, vcl_params_present = 0;
1094 int subpic_params_present = 0;
1097 if (common_inf_present)
1102 if (nal_params_present || vcl_params_present)
1106 if (subpic_params_present)
1120 if (subpic_params_present)
1131 for (i = 0; i < max_sublayers; i++)
1134 unsigned int nb_cpb = 1;
1148 if (nb_cpb < 1 || nb_cpb > 32)
1155 if (nal_params_present)
1157 if (vcl_params_present)
1167 for (matrixId = 0; matrixId < 6; matrixId++)
1170 memset(sl->
sl[0][matrixId], 16, 16);
1171 sl->
sl_dc[0][matrixId] = 16;
1172 sl->
sl_dc[1][matrixId] = 16;
1174 memcpy(sl->
sl[1][0], default_scaling_list_intra, 64);
1175 memcpy(sl->
sl[1][1], default_scaling_list_intra, 64);
1176 memcpy(sl->
sl[1][2], default_scaling_list_intra, 64);
1177 memcpy(sl->
sl[1][3], default_scaling_list_inter, 64);
1178 memcpy(sl->
sl[1][4], default_scaling_list_inter, 64);
1179 memcpy(sl->
sl[1][5], default_scaling_list_inter, 64);
1180 memcpy(sl->
sl[2][0], default_scaling_list_intra, 64);
1181 memcpy(sl->
sl[2][1], default_scaling_list_intra, 64);
1182 memcpy(sl->
sl[2][2], default_scaling_list_intra, 64);
1183 memcpy(sl->
sl[2][3], default_scaling_list_inter, 64);
1184 memcpy(sl->
sl[2][4], default_scaling_list_inter, 64);
1185 memcpy(sl->
sl[2][5], default_scaling_list_inter, 64);
1186 memcpy(sl->
sl[3][0], default_scaling_list_intra, 64);
1187 memcpy(sl->
sl[3][1], default_scaling_list_intra, 64);
1188 memcpy(sl->
sl[3][2], default_scaling_list_intra, 64);
1189 memcpy(sl->
sl[3][3], default_scaling_list_inter, 64);
1190 memcpy(sl->
sl[3][4], default_scaling_list_inter, 64);
1191 memcpy(sl->
sl[3][5], default_scaling_list_inter, 64);
1196 uint8_t scaling_list_pred_mode_flag;
1197 int32_t scaling_list_dc_coef[2][6];
1198 int size_id, matrix_id, pos;
1201 for (size_id = 0; size_id < 4; size_id++)
1202 for (matrix_id = 0; matrix_id < 6;
1203 matrix_id += ((size_id == 3) ? 3 : 1))
1206 if (!scaling_list_pred_mode_flag)
1214 delta *= (size_id == 3) ? 3 : 1;
1215 if (matrix_id < delta)
1218 "Invalid delta in scaling list data: %d.\n",
1223 memcpy(sl->
sl[size_id][matrix_id],
1224 sl->
sl[size_id][matrix_id - delta],
1225 size_id > 0 ? 64 : 16);
1227 sl->
sl_dc[size_id - 2][matrix_id] =
1228 sl->
sl_dc[size_id - 2][matrix_id - delta];
1232 int32_t next_coef, coef_num;
1233 int32_t scaling_list_delta_coef;
1236 coef_num = 1 << (4 + (size_id << 1));
1241 scaling_list_dc_coef[size_id - 2][matrix_id] =
1243 next_coef = scaling_list_dc_coef[size_id - 2][matrix_id];
1244 sl->
sl_dc[size_id - 2][matrix_id] = next_coef;
1246 for (i = 0; i < coef_num; i++)
1250 4 * hevc_diag_scan4x4_y[i] + hevc_diag_scan4x4_x[i];
1253 8 * hevc_diag_scan8x8_y[i] + hevc_diag_scan8x8_x[i];
1257 (next_coef + 256U + scaling_list_delta_coef) % 256;
1258 sl->
sl[size_id][matrix_id][pos] = next_coef;
1265 for (i = 0; i < 64; i++)
1267 sl->
sl[3][1][i] = sl->
sl[2][1][i];
1268 sl->
sl[3][2][i] = sl->
sl[2][2][i];
1269 sl->
sl[3][4][i] = sl->
sl[2][4][i];
1270 sl->
sl[3][5][i] = sl->
sl[2][5][i];
1284 uint8_t rps_predict = 0;
1298 int32_t abs_delta_rps;
1299 uint8_t use_delta_flag = 0;
1300 uint8_t delta_rps_sign;
1302 if (is_slice_header)
1308 "Invalid value of delta_idx in slice header RPS: %d > "
1320 if (abs_delta_rps < 1 || abs_delta_rps > 32768)
1326 delta_rps = (1 - (delta_rps_sign << 1)) * abs_delta_rps;
1334 if (used || use_delta_flag)
1336 if (i < rps_ridx->num_delta_pocs)
1337 delta_poc = delta_rps + rps_ridx->
delta_poc[i];
1339 delta_poc = delta_rps;
1349 if (k >= (
sizeof(rps->
used) /
sizeof(rps->
used[0])))
1364 used = rps->
used[i];
1365 for (k = i - 1; k >= 0; k--)
1368 if (delta_poc < tmp)
1373 rps->
used[k] = used;
1386 used = rps->
used[i];
1390 rps->
used[k] = used;
1396 int prev, nb_positive_pics;
1414 if (delta_poc < 1 || delta_poc > 32768)
1425 for (i = 0; i < nb_positive_pics; i++)
1428 if (delta_poc < 1 || delta_poc > 32768)
1446 VUI backup_vui, *vui = &sps->
vui;
1448 int sar_present, alt = 0;
1454 if (sar_idx < (
sizeof(vui_sar) /
sizeof(vui_sar[0])))
1455 vui->
sar = vui_sar[sar_idx];
1456 else if (sar_idx == 255)
1501 "Invalid format, only support yuv420p\n");
1520 memcpy(&br_backup, br,
sizeof(br_backup));
1521 memcpy(&backup_vui, vui,
sizeof(backup_vui));
1533 if (apply_defdispwin)
1536 "discarding vui default display window, "
1537 "original values are l:%u r:%u t:%u b:%u\n",
1558 "Strange VUI timing information, retrying...\n");
1559 memcpy(vui, &backup_vui,
sizeof(backup_vui));
1560 memcpy(br, &br_backup,
sizeof(br_backup));
1585 "Strange VUI bitstream restriction information, retrying"
1586 " from timing information...\n");
1587 memcpy(vui, &backup_vui,
sizeof(backup_vui));
1588 memcpy(br, &br_backup,
sizeof(br_backup));
1606 "Overread in VUI, retrying from timing information...\n");
1607 memcpy(vui, &backup_vui,
sizeof(backup_vui));
1608 memcpy(br, &br_backup,
sizeof(br_backup));
1619 int log2_diff_max_min_transform_block_size;
1620 int bit_depth_chroma, start, vui_present, sublayer_ordering_info;
1685 "Luma bit depth (%d) is different from chroma bit depth (%d), "
1686 "this is unsupported.\n",
1695 "only support 8bit/10bit yuv420p, bit_depth %d, "
1696 "chroma_format_idc %d\n",
1710 "log2_max_pic_order_cnt_lsb_minus4 out range: %d\n",
1734 if (!sublayer_ordering_info)
1736 for (i = 0; i < start; i++)
1764 "Invalid value %d for log2_diff_max_min_coding_block_size",
1776 if (log2_diff_max_min_transform_block_size < 0 ||
1777 log2_diff_max_min_transform_block_size > 30)
1780 "Invalid value %d for log2_diff_max_min_transform_block_size",
1781 log2_diff_max_min_transform_block_size);
1816 "PCM bit depth (%d, %d) is greater than normal bit depth "
1832 for (i = 0; i < (int)sps->
nb_st_rps; i++)
1885 "extended_precision_processing_flag not yet implemented\n");
1892 "high_precision_offsets_enabled_flag not yet "
1902 "cabac_bypass_alignment_enabled_flag not yet "
1917 memset(ow, 0,
sizeof(*ow));
1936 "log2_ctb_size %d differs from the bounds of any known profile\n",
1968 "max_transform_hierarchy_depth_inter out of range: %d\n",
1976 "max_transform_hierarchy_depth_intra out of range: %d\n",
2001 uint8_t *buf = NULL;
2003 uint32_t nal_size, ep3_removed = 0, vcl_nal_count = 0;
2010 "Error probe_h265_stream_info: allocate stream buf failed\n");
2016 while ((!sps_parsed) && vcl_nal_count < 100 &&
2022 while (!(p_buf[0] == 0x00 && p_buf[1] == 0x00 && p_buf[2] == 0x01) &&
2031 "Error probe_h265_stream_info NAL has no header\n");
2038 nal_size -= ep3_removed;
2043 if (vcl_nal_count > 0)
2046 "Warning: %s has %d slice NAL units ahead of SPS!\n",
2047 __func__, vcl_nal_count);
2053 "probe_h265_stream_info: parse_sps error\n");
2057 }
else if (nal_type < 32)
2111 memcpy(p_dst, &p_ctx->
file_cache[i], data_size);
2116 memcpy(p_dst, &p_ctx->
file_cache[i], data_size);
2172 if ((profile != 0) && (profile != 2))
2176 "Only support profile0(yuv420,8bit) and profile2(yuv420, 10bit)\n");
2187 uint8_t *buf = NULL;
2189 if (NULL == (buf = calloc(1, 64)))
2192 "Error probe_vp9_stream_info: allocate stream buf failed\n");
2197 uint32_t size_bytes = 64;
2234 int input_video_width,
int input_video_height,
2238 uint8_t *tmp_buf_ptr = tmp_buf;
2240 uint32_t frame_pkt_size = 0, nal_size;
2243 uint32_t send_size = 0;
2245 int32_t frame_num = -1, curr_frame_num;
2246 unsigned int first_mb_in_slice = 0;
2269 frame_pkt_size += nal_size;
2270 tmp_buf_ptr += nal_size;
2272 nal_type, nal_size);
2278 nal_size, sps, &curr_frame_num,
2279 &first_mb_in_slice))
2281 if (-1 == frame_num)
2284 frame_num = curr_frame_num;
2285 }
else if (curr_frame_num != frame_num ||
2286 0 == first_mb_in_slice)
2291 frame_pkt_size -= nal_size;
2299 "decoder_send_data: parse_slice_header error "
2300 "NAL type %d size %u, continue\n",
2301 nal_type, nal_size);
2303 }
else if (-1 != frame_num)
2307 frame_pkt_size -= nal_size;
2316 frame_pkt_size += nal_size;
2317 tmp_buf_ptr += nal_size;
2319 nal_type, nal_size);
2321 if (nal_type >= 0 && nal_type <= 23)
2324 __func__, nal_type, nal_size);
2332 frame_pkt_size += packet_size;
2345 send_size = frame_pkt_size + p_dec_ctx->
prev_size;
2422 int output_video_width,
int output_video_height,
2423 FILE *p_file,
int write_to_file,
2428 bool b_is_hwframe = p_dec_ctx->
hw_action;
2439 "===> decoder_receive_data hwframe %d pixel_format %d <===\n",
2455 output_video_height;
2478 &(p_out_data->
data.
frame), width, height,
2508 }
else if (rx_size > 0)
2516 if (p_file && write_to_file) {
2525 output_video_width, output_video_height, p_dec_ctx->
pixel_format,
2531 output_video_width, output_video_height, p_dec_ctx->
pixel_format, p_out_frame);
2555 *p_rx_size = rx_size;
2593 p_dec_ctx->
hw_id = iXcoderGUID;
2611 ni_log(
NI_LOG_INFO,
"Decoder device %d session open successful.\n", iXcoderGUID);
2679 return (
void *)(int64_t)retval;
2712 p_out_frame = &frame_list->
frames[frame_list->
tail];
2715 p_ctx, p_dec_ctx, p_out_frame, p_dec_recv_param->
input_width,
2728 "Error: decoder_receive_thread break in transcode mode!\n");
2760 else if (drawbox_params->
enabled)
2765 p_dec_recv_param->
p_fmt_ctx, p_ni_frame, &filter_out_frame, drawbox_params,
2782 ni_log(
NI_LOG_INFO,
"Decoder stats: received %u frames, fps %.2f, total bytes %u\n",
2799 return (
void *)(int64_t)retval;
void ni_dec_retrieve_aux_data(ni_frame_t *frame)
Retrieve auxiliary data (close caption, various SEI) associated with this frame that is returned by d...
@ NI_COL_PRI_NB
Not part of ABI.
#define NI_NUM_PIXEL_ASPECT_RATIO
@ NI_H264_SEI_PIC_STRUCT_FRAME_TRIPLING
frame tripling
@ NI_H264_SEI_PIC_STRUCT_FRAME
frame
@ NI_H264_SEI_TYPE_PIC_TIMING
int ni_bs_reader_bits_count(ni_bitstream_reader_t *br)
return the number of bits already parsed in stream
uint32_t ni_bs_reader_get_ue(ni_bitstream_reader_t *br)
read an unsigned Exp-Golomb code ue(v)
int32_t ni_bs_reader_get_se(ni_bitstream_reader_t *br)
read a signed Exp-Golomb code se(v)
void ni_bitstream_reader_init(ni_bitstream_reader_t *br, const uint8_t *data, int bit_size)
init a bitstream reader Note: bitstream_reader takes reading ownership of the data
uint32_t ni_bs_reader_get_bits(ni_bitstream_reader_t *br, int n)
read bits (up to 32) from the bitstream reader, after reader init
int ni_bs_reader_get_bits_left(ni_bitstream_reader_t *br)
return the number of bits left to parse in stream
void ni_bs_reader_skip_bits(ni_bitstream_reader_t *br, int n)
skip a number of bits ahead in the bitstream reader
int h265_parse_ptl(ni_bitstream_reader_t *br, PTL *ptl, int max_num_sub_layers)
void decoder_stat_report_and_close(ni_demo_context_t *p_ctx, ni_session_context_t *p_dec_ctx)
int probe_h264_stream_info(ni_demo_context_t *p_ctx, ni_h264_sps_t *sps)
int vp9_parse_header(ni_vp9_header_info_t *vp9_info, uint8_t *buf, int size_bytes)
uint64_t find_h264_next_nalu(ni_demo_context_t *p_ctx, uint8_t *p_dst, int *nal_type)
int h264_parse_sei(uint8_t *buf, int size_bytes, ni_h264_sps_t *sps, int *sei_type, int *is_interlaced)
int h264_parse_hrd(ni_bitstream_reader_t *br, ni_h264_sps_t *sps)
int h265_decode_profile_tier_level(ni_bitstream_reader_t *br, PTLCommon *ptl)
int h265_decode_hrd(ni_bitstream_reader_t *br, int common_inf_present, int max_sublayers)
int h264_parse_scaling_matrices(ni_bitstream_reader_t *br, const ni_h264_sps_t *sps, uint8_t(*scaling_matrix4)[16], uint8_t(*scaling_matrix8)[64])
void * decoder_send_thread(void *args)
int decoder_receive_data(ni_demo_context_t *p_ctx, ni_session_context_t *p_dec_ctx, ni_session_data_io_t *p_out_data, int output_video_width, int output_video_height, FILE *p_file, int write_to_file, int *p_rx_size)
Receive decoded output data from decoder.
int h264_parse_vui(ni_bitstream_reader_t *br, ni_h264_sps_t *sps)
uint64_t find_h265_next_nalu(ni_demo_context_t *p_ctx, uint8_t *p_dst, int *nal_type)
int h264_parse_sps(uint8_t *buf, int size_bytes, ni_h264_sps_t *sps)
int h264_parse_scaling_list(ni_bitstream_reader_t *br, uint8_t *factors, int size, const uint8_t *jvt_list, const uint8_t *fallback_list)
int h265_parse_sps(ni_h265_sps_t *sps, uint8_t *buf, int size_bytes)
int parse_h264_slice_header(uint8_t *buf, int size_bytes, ni_h264_sps_t *sps, int32_t *frame_num, unsigned int *first_mb_in_slice)
int decoder_open_session(ni_session_context_t *p_dec_ctx, int iXcoderGUID, ni_xcoder_params_t *p_dec_params)
decoder session open
int probe_h265_stream_info(ni_demo_context_t *p_ctx, ni_h265_sps_t *sps)
void h265_decode_sublayer_hrd(ni_bitstream_reader_t *br, unsigned int nb_cpb, int subpic_params_present)
void * decoder_receive_thread(void *args)
int h265_scaling_list_data(ni_bitstream_reader_t *br, ScalingList *sl, ni_h265_sps_t *sps)
#define check_profile_idc(idc)
int probe_vp9_stream_info(ni_demo_context_t *p_ctx, ni_vp9_header_info_t *vp9_info)
void h265_set_default_scaling_list_data(ScalingList *sl)
int h265_decode_short_term_rps(ni_bitstream_reader_t *br, ShortTermRPS *rps, const ni_h265_sps_t *sps, int is_slice_header)
int decoder_send_data(ni_demo_context_t *p_ctx, ni_session_context_t *p_dec_ctx, ni_session_data_io_t *p_in_data, int input_video_width, int input_video_height, void *stream_info)
Send decoder input data.
uint64_t find_vp9_next_packet(ni_demo_context_t *p_ctx, uint8_t *p_dst, ni_vp9_header_info_t *vp9_info)
int h265_decode_vui(ni_bitstream_reader_t *br, int apply_defdispwin, ni_h265_sps_t *sps)
Common NETINT definitions used by all modules.
ni_retcode_t ni_frame_buffer_free(ni_frame_t *p_frame)
Free frame buffer that was previously allocated with either ni_frame_buffer_alloc or ni_encoder_frame...
int ni_packet_copy(void *p_destination, const void *const p_source, int cur_size, void *p_leftover, int *p_prev_size)
Copy video packet accounting for alignment.
ni_retcode_t ni_frame_buffer_alloc(ni_frame_t *p_frame, int video_width, int video_height, int alignment, int metadata_flag, int factor, int hw_frame_count, int is_planar)
Allocate preliminary memory for the frame buffer based on provided parameters. Applicable to YUV420 P...
ni_retcode_t ni_device_session_close(ni_session_context_t *p_ctx, int eos_recieved, ni_device_type_t device_type)
Close device session that was previously opened by calling ni_device_session_open() If device_type is...
ni_retcode_t ni_device_session_open(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Open a new device session depending on the device_type parameter If device_type is NI_DEVICE_TYPE_DEC...
ni_retcode_t ni_packet_buffer_free(ni_packet_t *p_packet)
Free packet buffer that was previously allocated with ni_packet_buffer_alloc.
int ni_device_session_read(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data, ni_device_type_t device_type)
Read data from the device If device_type is NI_DEVICE_TYPE_DECODER reads data packet from decoder If ...
ni_retcode_t ni_decoder_frame_buffer_alloc(ni_buf_pool_t *p_pool, ni_frame_t *p_frame, int alloc_mem, int video_width, int video_height, int alignment, int factor, int is_planar)
Allocate memory for decoder frame buffer based on provided parameters; the memory is retrieved from a...
int ni_device_session_read_hwdesc(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data, ni_device_type_t device_type)
Read data from the device If device_type is NI_DEVICE_TYPE_DECODER reads data hwdesc from decoder If ...
ni_retcode_t ni_packet_buffer_alloc(ni_packet_t *p_packet, int packet_size)
Allocate memory for the packet buffer based on provided packet size.
int ni_device_session_write(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data, ni_device_type_t device_type)
Sends data to the device If device_type is NI_DEVICE_TYPE_DECODER sends data packet to decoder If dev...
ni_retcode_t ni_decoder_frame_buffer_free(ni_frame_t *p_frame)
Free decoder frame buffer that was previously allocated with ni_decoder_frame_buffer_alloc,...
@ NI_PIXEL_PLANAR_FORMAT_PLANAR
#define NI_FRAME_LITTLE_ENDIAN
#define NI_INVALID_SESSION_ID
struct _ni_rational ni_rational_t
int scale_filter(ni_session_context_t *p_ctx, ni_frame_t *p_frame_in, ni_session_data_io_t *p_data_out, int iXcoderGUID, int scale_width, int scale_height, int in_format, int out_format)
Do a scale and/or format-change operation.
int drawbox_filter(ni_session_context_t *p_crop_ctx, ni_session_context_t *p_pad_ctx, ni_session_context_t *p_overlay_ctx, ni_session_context_t *p_fmt_ctx, ni_frame_t *p_frame_in, ni_session_data_io_t *p_data_out, ni_drawbox_params_t *p_box_params, int iXcoderGUID, int input_format, int output_format)
Use crop->pad->overlay to simulate a drawbox filter.
void ni_hw_frame_unref(uint16_t hwframe_index)
int ni_to_gc620_pix_fmt(ni_pix_fmt_t pix_fmt)
ni_pixel_planar_format get_pixel_planar(ni_pix_fmt_t pix_fmt)
bool frame_list_is_full(ni_test_frame_list_t *list)
void rewind_data_buf_pos_by(ni_demo_context_t *p_ctx, uint64_t nb_bytes)
int hwdl_frame(ni_session_context_t *p_ctx, ni_session_data_io_t *p_session_data, ni_frame_t *p_src_frame, int output_format)
Download hw frames by HwDesc.
int write_rawvideo_data(FILE *p_file, int input_aligned_width, int input_aligned_height, int output_width, int output_height, int format, ni_frame_t *p_out_frame)
Write hwdl data to files.
void reset_data_buf_pos(ni_demo_context_t *p_ctx)
int frame_list_enqueue(ni_test_frame_list_t *list)
void ni_hw_frame_ref(const niFrameSurface1_t *p_surface)
#define HEVC_MAX_SUB_LAYERS
#define MIN_LOG2_MAX_FRAME_NUM
#define HEVC_MAX_LONG_TERM_REF_PICS
#define HEVC_MAX_SHORT_TERM_REF_PIC_SETS
#define NI_TEST_RETCODE_SUCCESS
#define NI_TEST_RETCODE_EAGAIN
#define NI_TEST_RETCODE_END_OF_STREAM
#define HEVC_MAX_LOG2_CTB_SIZE
#define HEVC_MAX_SPS_COUNT
#define NI_TEST_RETCODE_FAILURE
#define MAX_LOG2_MAX_FRAME_NUM
void ni_log(ni_log_level_t level, const char *fmt,...)
print log message using ni_log_callback
struct timeval current_time
struct timeval previous_time
int ni_remove_emulation_prevent_bytes(uint8_t *buf, int size)
Remove emulation prevention byte(s) as needed from the data buffer.
void ni_usleep(int64_t usec)
uint64_t ni_gettime_ns(void)
uint64_t num_frames_received
uint64_t dec_total_bytes_received
uint64_t dec_total_bytes_sent
uint64_t curr_file_offset
uint8_t * p_data[NI_MAX_NUM_DATA_POINTERS]
int timing_info_present_flag
int pic_struct_present_flag
ni_color_transfer_characteristic_t color_trc
int colour_description_present_flag
ni_color_primaries_t color_primaries
int nal_hrd_parameters_present_flag
int log2_max_frame_num
log2_max_frame_num_minus4 + 4
unsigned int crop_left
frame_cropping_rect_left_offset
int cpb_removal_delay_length
cpb_removal_delay_length_minus1 + 1
int poc_type
pic_order_cnt_type
uint32_t num_units_in_tick
int direct_8x8_inference_flag
int constraint_set_flags
constraint_set[0-3]_flag
int bit_depth_luma
bit_depth_luma_minus8 + 8
int transform_bypass
qpprime_y_zero_transform_bypass_flag
int gaps_in_frame_num_allowed_flag
int bitstream_restriction_flag
uint8_t scaling_matrix8[6][64]
int initial_cpb_removal_delay_length
initial_cpb_removal_delay_length_minus1 + 1
unsigned int max_dec_frame_buffering
int offset_for_non_ref_pic
unsigned int crop_bottom
frame_cropping_rect_bottom_offset
int offset_for_top_to_bottom_field
int vui_parameters_present_flag
int delta_pic_order_always_zero_flag
ni_color_space_t colorspace
uint8_t scaling_matrix4[6][16]
int vcl_hrd_parameters_present_flag
int poc_cycle_length
num_ref_frames_in_pic_order_cnt_cycle
int residual_color_transform_flag
residual_colour_transform_flag
int fixed_frame_rate_flag
int video_signal_type_present_flag
int mb_aff
mb_adaptive_frame_field_flag
short offset_for_ref_frame[256]
int dpb_output_delay_length
dpb_output_delay_length_minus1 + 1
unsigned int crop_right
frame_cropping_rect_right_offset
unsigned int crop_top
frame_cropping_rect_top_offset
int cpb_cnt
See H.264 E.1.2.
int scaling_matrix_present
int crop
frame_cropping_flag
int ref_frame_count
num_ref_frames
int bit_depth_chroma
bit_depth_chroma_minus8 + 8
int log2_max_poc_lsb
log2_max_pic_order_cnt_lsb_minus4
int mb_width
(pic_height_in_map_units_minus1 + 1) * (2 - frame_mbs_only_flag)
unsigned int log2_max_poc_lsb
unsigned int log2_max_trafo_size
int transform_skip_rotation_enabled_flag
unsigned int log2_min_pu_size
int cabac_bypass_alignment_enabled_flag
coded frame dimension in various units
int explicit_rdpcm_enabled_flag
uint8_t num_long_term_ref_pics_sps
int implicit_rdpcm_enabled_flag
unsigned int log2_min_cb_size
struct _ni_h265_sps_t::@1 temporal_layer[HEVC_MAX_SUB_LAYERS]
uint8_t temporal_id_nesting_flag
uint8_t sps_temporal_mvp_enabled_flag
unsigned int log2_max_pcm_cb_size
uint8_t long_term_ref_pics_present_flag
int extended_precision_processing_flag
int sps_range_extension_flag
uint8_t used_by_curr_pic_lt_sps_flag[HEVC_MAX_LONG_TERM_REF_PICS]
int max_transform_hierarchy_depth_inter
ni_h265_window_t pic_conf_win
unsigned int log2_min_tb_size
int intra_smoothing_disabled_flag
ni_h265_window_t output_window
unsigned int log2_min_pcm_cb_size
int transform_skip_context_enabled_flag
uint16_t lt_ref_pic_poc_lsb_sps[HEVC_MAX_LONG_TERM_REF_PICS]
int high_precision_offsets_enabled_flag
unsigned int log2_ctb_size
uint8_t sps_strong_intra_smoothing_enable_flag
unsigned int log2_diff_max_min_coding_block_size
uint8_t loop_filter_disable_flag
uint8_t scaling_list_enable_flag
int max_dec_pic_buffering
int persistent_rice_adaptation_enabled_flag
uint8_t separate_colour_plane_flag
int max_transform_hierarchy_depth_intra
ShortTermRPS st_rps[HEVC_MAX_SHORT_TERM_REF_PIC_SETS]
struct _ni_h265_sps_t::@2 pcm
unsigned int bottom_offset
unsigned int right_offset
ni_device_handle_t device_handle
uint32_t actual_video_width
ni_device_handle_t blk_io_handle
uint32_t active_video_width
uint32_t active_video_height
ni_buf_pool_t * dec_fme_buf_pool
union _ni_session_data_io::@19 data
ni_session_data_io_t frames[NI_MAX_BUFFERED_FRAME]
ni_decoder_input_params_t dec_input_params
uint8_t lower_bit_rate_constraint_flag
uint8_t max_10bit_constraint_flag
uint8_t one_picture_only_constraint_flag
uint8_t max_12bit_constraint_flag
uint8_t max_monochrome_constraint_flag
uint8_t intra_constraint_flag
uint8_t progressive_source_flag
uint8_t max_420chroma_constraint_flag
uint8_t profile_compatibility_flag[32]
uint8_t max_8bit_constraint_flag
uint8_t max_422chroma_constraint_flag
uint8_t frame_only_constraint_flag
uint8_t interlaced_source_flag
uint8_t max_14bit_constraint_flag
uint8_t non_packed_constraint_flag
uint8_t sub_layer_profile_present_flag[HEVC_MAX_SUB_LAYERS]
uint8_t sub_layer_level_present_flag[HEVC_MAX_SUB_LAYERS]
PTLCommon sub_layer_ptl[HEVC_MAX_SUB_LAYERS]
unsigned int num_negative_pics
int rps_idx_num_delta_pocs
int vui_poc_proportional_to_timing_flag
uint8_t transfer_characteristic
int colour_description_present_flag
int chroma_sample_loc_type_top_field
int frame_field_info_present_flag
int overscan_appropriate_flag
int vui_hrd_parameters_present_flag
int default_display_window_flag
int vui_timing_info_present_flag
int log2_max_mv_length_horizontal
int tiles_fixed_structure_flag
uint32_t vui_num_units_in_tick
int max_bits_per_min_cu_denom
int vui_num_ticks_poc_diff_one_minus1
int bitstream_restriction_flag
int motion_vectors_over_pic_boundaries_flag
int min_spatial_segmentation_idc
int max_bytes_per_pic_denom
int log2_max_mv_length_vertical
int neutra_chroma_indication_flag
int chroma_sample_loc_type_bottom_field
int restricted_ref_pic_lists_flag
int video_signal_type_present_flag
int overscan_info_present_flag
int chroma_loc_info_present_flag
ni_h265_window_t def_disp_win
int video_full_range_flag
ni_demo_context_t * p_ctx
ni_drawbox_params_t * drawbox_params
ni_session_context_t * p_sca_ctx
ni_scale_params_t * scale_params
ni_session_context_t * p_pad_ctx
ni_session_context_t * p_dec_ctx
ni_session_context_t * p_ovly_ctx
ni_session_context_t * p_crop_ctx
ni_test_frame_list_t * frame_list
ni_session_context_t * p_fmt_ctx
ni_demo_context_t * p_ctx
ni_session_context_t * p_dec_ctx
ni_test_frame_list_t * frame_list