 |
libxcoder
5.2.0
|
Go to the documentation of this file.
35 #elif __linux__ || __APPLE__
39 static void print_usage(
void)
42 "Video decoding demo application directly using Netint Libxcoder version %s\n"
43 "Usage: ni_xcoder_decode [options]\n"
46 "-h | --help Show this message.\n"
47 "-v | --version Print version info.\n"
48 "-i | --input (Required) Input file path.\n"
49 "-o | --output (Required) Output file path.\n"
50 "-m | --dec-codec (Required) Decoder codec format. Must match the codec of input file.\n"
51 " [a|avc, h|hevc, v|vp9]\n"
52 "-l | --loglevel Set loglevel of this application and libxcoder API.\n"
53 " [none, fatal, error, info, debug, trace]\n"
55 "-c | --card Set card index to use.\n"
56 " See `ni_rsrc_mon` for info of cards on system.\n"
58 "-r | --repeat To loop input X times. Must be a positive integer\n"
60 "-d | --decoder-params Decoding params. See \"Decoding Parameters\" chapter in\n"
61 " QuadraIntegration&ProgrammingGuide*.pdf for help.\n"
66 int main(
int argc,
char *argv[])
72 FILE *output_fp = NULL;
73 int video_width, video_height, bit_depth;
74 int dec_codec_format = -1;
78 char dec_conf_params[2048] = {0};
87 void *p_stream_info = NULL;
94 const char *opt_string =
"hvi:o:m:l:c:r:d:";
95 static struct option long_options[] = {
108 while ((opt =
getopt_long(argc, argv, opt_string, long_options, &opt_index)) != -1)
121 strcpy(in_filename,
optarg);
124 strcpy(out_filename,
optarg);
128 for (i = 0; i < strlen(
optarg); i++)
132 if (strcmp(
optarg,
"a") == 0 || strcmp(
optarg,
"avc") == 0)
136 else if (strcmp(
optarg,
"h") == 0 || strcmp(
optarg,
"hevc") == 0)
140 else if (strcmp(
optarg,
"v") == 0 || strcmp(
optarg,
"vp9") == 0)
147 "Must be one of [a|avc, h|hevc, v|vp9]\n",
optarg);
161 "Must be one of [none, fatal, error, info, debug, trace]\n",
optarg);
167 xcoderGUID = (int)strtol(
optarg, &n, 10);
168 if (n ==
optarg || *n !=
'\0' || xcoderGUID < 0)
171 "Must be a non-negative integer\n",
optarg);
181 "Must be a positive integer\n",
optarg);
187 strcpy(dec_conf_params,
optarg);
196 if (!in_filename[0]) {
202 if (!out_filename[0]) {
208 if (dec_codec_format == -1) {
215 if (!p_dec_api_param)
229 if (strcmp(out_filename,
"null") != 0 &&
230 strcmp(out_filename,
"/dev/null") != 0)
232 output_fp = fopen(out_filename,
"wb");
243 ni_log(
NI_LOG_INFO,
"Note: Requested NULL output, no output file will be generated\n");
252 "ERROR: Failed to probe input file as H.264, file format not supported!\n");
257 video_width = avc_sps.
width;
258 video_height = avc_sps.
height;
260 bit_depth, video_width, video_height);
267 "ERROR: Failed to probe input file as H.265, file format not supported!\n");
271 video_width = (int)(hevc_sps.
width -
274 video_height = (int)(hevc_sps.
height -
277 ni_log(
NI_LOG_INFO,
"Using probed H.265 source info: %d bits, resolution %dx%d\n",
278 bit_depth, video_width, video_height);
285 "ERROR: Failed to probe input file as VP9, file format not supported!\n");
288 bit_depth = vp9_info.
profile ? 10 : 8;
289 video_width = vp9_info.
width;
290 video_height = vp9_info.
height;
292 "Using probed VP9 source info: %d bits, resolution %dx%d, timebase %u/%u\n",
293 bit_depth, video_width, video_height,
339 p_stream_info = &avc_sps;
341 p_stream_info = &hevc_sps;
343 p_stream_info = &vp9_info;
353 video_height, p_stream_info);
357 "Error: decoder_send_data() failed, rc: %d\n",
367 output_fp, 1, &rx_size);
395 ni_log(
NI_LOG_INFO,
"Decoder stats: received %u frames, fps %.2f, total bytes %u\n",
425 free(p_dec_api_param);
427 if (output_fp != NULL)
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 probe_h264_stream_info(ni_demo_context_t *p_ctx, ni_h264_sps_t *sps)
struct timeval current_time
void ni_log_set_level(ni_log_level_t level)
Set ni_log_level.
uint64_t ni_gettime_ns(void)
unsigned int bottom_offset
#define required_argument
#define NI_XCODER_REVISION
int probe_h265_stream_info(ni_demo_context_t *p_ctx, ni_h265_sps_t *sps)
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 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.
struct timeval previous_time
int probe_vp9_stream_info(ni_demo_context_t *p_ctx, ni_vp9_header_info_t *vp9_info)
ni_log_level_t arg_to_ni_log_level(const char *arg_str)
Convert terminal arg string to ni_log_level_t.
void decoder_stat_report_and_close(ni_demo_context_t *p_ctx, ni_session_context_t *p_dec_ctx)
#define NI_TEST_RETCODE_END_OF_STREAM
int read_and_cache_file(ni_demo_context_t *ctx, char *filename)
uint64_t num_frames_received
#define NI_TEST_RETCODE_EAGAIN
int decoder_open_session(ni_session_context_t *p_dec_ctx, int iXcoderGUID, ni_xcoder_params_t *p_dec_params)
decoder session open
ni_h265_window_t pic_conf_win
unsigned int right_offset
void ni_log(ni_log_level_t level, const char *fmt,...)
print log message using ni_log_callback
#define NI_TEST_RETCODE_SUCCESS
int getopt_long(int argc, char *argv[], const char *optstring, const struct option *longopts, int *longindex)
int bit_depth_luma
bit_depth_luma_minus8 + 8
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.
void ni_device_session_context_clear(ni_session_context_t *p_ctx)
Clear already allocated session context.
uint8_t * p_data[NI_MAX_NUM_DATA_POINTERS]
ni_retcode_t ni_hwframe_buffer_recycle2(niFrameSurface1_t *surface)
Recycle a frame buffer on card, only hwframe descriptor is needed.
ni_retcode_t ni_decoder_init_default_params(ni_xcoder_params_t *p_param, int fps_num, int fps_denom, long bit_rate, int width, int height)
Initialize default decoder parameters.
union _ni_session_data_io::@19 data
uint64_t dec_total_bytes_received
ni_retcode_t ni_device_session_context_init(ni_session_context_t *p_ctx)
Initialize already allocated session context to a known state.
int ni_retrieve_decoder_params(char xcoderParams[], ni_xcoder_params_t *params, ni_session_context_t *ctx)
retrieve decoder config parameter values from –decoder-params
int main(int argc, char *argv[])
Implementation of getopt() and getopt_long() for Windows environment.
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,...