![]() |
libxcoder
3.4.0
|
Application for performing video processing using libxcoder API and P2P DMA. Its code provides examples on how to programatically use libxcoder API in conjunction with P2P DMA. More...
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <getopt.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/time.h>
#include <time.h>
#include "ni_device_api_logan.h"
#include "ni_util_logan.h"
#include "ni_av_codec_logan.h"
Go to the source code of this file.
Macros | |
#define | _POSIX_C_SOURCE 200809L |
#define | MAX_YUV_FRAME_SIZE (7680 * 4320 * 3 / 2) |
#define | POOL_SIZE 2 |
#define | FILE_NAME_LEN 256 |
Functions | |
void | arg_error_exit (char *arg_name, char *param) |
Exit on argument error. More... | |
int | read_next_chunk_from_file (int fd, uint8_t *p_dst, uint32_t to_read) |
Read the next frame. More... | |
int | load_input_file (const char *filename, unsigned long *bytes_read) |
Load the input file into memory. More... | |
int | p2p_upload_send_data (ni_logan_session_context_t *p_upl_ctx, int fd, uint8_t **p_yuv420p_frame, ni_logan_frame_t *p_in_frame, int input_video_width, int input_video_height, unsigned long *bytes_sent, int *input_exhausted) |
Recycle hw frames back to T408. More... | |
int | p2p_prepare_frames (ni_logan_session_context_t *p_upl_ctx, int input_video_width, int input_video_height, ni_logan_frame_t p2p_frame[]) |
Prepare frames to simulate P2P transfers. More... | |
int | encoder_encode_frame (ni_logan_session_context_t *p_enc_ctx, ni_logan_frame_t *p_in_frame, int input_exhausted, int *need_to_resend) |
Send the Quadra encoder a hardware frame which triggers Quadra to encode the frame. More... | |
int | encoder_receive_data (ni_logan_session_context_t *p_enc_ctx, ni_logan_session_data_io_t *p_out_data, FILE *p_file, unsigned long long *total_bytes_received, int print_time) |
Receive output packet data from the Quadra encoder. More... | |
int | encoder_open_session (ni_logan_session_context_t *p_enc_ctx, int dst_codec_format, int xcoder_id, const char *xcoder_name, ni_logan_encoder_params_t *p_enc_params, int src_bit_depth, int width, int height, ni_color_primaries_t color_primaries, ni_color_transfer_characteristic_t color_trc, ni_color_space_t color_space, int video_full_range_flag, int sar_num, int sar_den, ni_logan_frame_t *p_frame) |
Encoder session open. More... | |
int | uploader_open_session (ni_logan_session_context_t *p_upl_ctx, int *iXcoderGUID, int width, int height) |
Open an upload session to T408. More... | |
void | print_usage (void) |
Print usage information. More... | |
void | parse_arguments (int argc, char *argv[], char *input_filename, char *output_filename, int *iXcoderGUID, int *arg_width, int *arg_height, int *dst_codec_format) |
Parse user command line arguments. More... | |
int | main (int argc, char *argv[]) |
Variables | |
int | send_fin_flag = 0 |
int | receive_fin_flag = 0 |
int | enc_eos_sent = 0 |
uint32_t | number_of_frames = 0 |
uint32_t | number_of_packets = 0 |
uint64_t | data_left_size = 0 |
int | g_repeat = 1 |
struct timeval | start_time |
struct timeval | previous_time |
struct timeval | current_time |
time_t | start_timestamp = 0 |
time_t | previous_timestamp = 0 |
time_t | current_timestamp = 0 |
unsigned long | total_file_size = 0 |
uint8_t * | g_curr_cache_pos = NULL |
uint8_t * | g_yuv_frame [POOL_SIZE] = {NULL, NULL} |
Application for performing video processing using libxcoder API and P2P DMA. Its code provides examples on how to programatically use libxcoder API in conjunction with P2P DMA.
Definition in file ni_p2p_test.c.
#define _POSIX_C_SOURCE 200809L |
Definition at line 35 of file ni_p2p_test.c.
#define FILE_NAME_LEN 256 |
Definition at line 51 of file ni_p2p_test.c.
#define MAX_YUV_FRAME_SIZE (7680 * 4320 * 3 / 2) |
Definition at line 49 of file ni_p2p_test.c.
#define POOL_SIZE 2 |
Definition at line 50 of file ni_p2p_test.c.
void arg_error_exit | ( | char * | arg_name, |
char * | param | ||
) |
Exit on argument error.
[in] | arg_name | pointer to argument name [in] param pointer to provided parameter |
Definition at line 109 of file ni_p2p_test.c.
int encoder_encode_frame | ( | ni_logan_session_context_t * | p_enc_ctx, |
ni_logan_frame_t * | p_in_frame, | ||
int | input_exhausted, | ||
int * | need_to_resend | ||
) |
Send the Quadra encoder a hardware frame which triggers Quadra to encode the frame.
[in] | p_enc_ctx | pointer to encoder context [in] p_in_frame pointer to hw frame [in] input_exhausted flag indicating this is the last frame [in/out] need_to_resend flag indicating need to re-send |
Definition at line 419 of file ni_p2p_test.c.
int encoder_open_session | ( | ni_logan_session_context_t * | p_enc_ctx, |
int | dst_codec_format, | ||
int | xcoder_id, | ||
const char * | xcoder_name, | ||
ni_logan_encoder_params_t * | p_enc_params, | ||
int | src_bit_depth, | ||
int | width, | ||
int | height, | ||
ni_color_primaries_t | color_primaries, | ||
ni_color_transfer_characteristic_t | color_trc, | ||
ni_color_space_t | color_space, | ||
int | video_full_range_flag, | ||
int | sar_num, | ||
int | sar_den, | ||
ni_logan_frame_t * | p_frame | ||
) |
int encoder_receive_data | ( | ni_logan_session_context_t * | p_enc_ctx, |
ni_logan_session_data_io_t * | p_out_data, | ||
FILE * | p_file, | ||
unsigned long long * | total_bytes_received, | ||
int | print_time | ||
) |
Receive output packet data from the Quadra encoder.
[in] | p_enc_ctx | pointer to encoder session context [in] p_out_data pointer to output data session [in] p_file pointer to file to write the packet [out] total_bytes_received running counter of bytes read [in] print_time 1 = print the time |
Definition at line 502 of file ni_p2p_test.c.
int load_input_file | ( | const char * | filename, |
unsigned long * | bytes_read | ||
) |
Load the input file into memory.
[in] | filename | name of input file [out] bytes_read number of bytes read from file |
Definition at line 173 of file ni_p2p_test.c.
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 977 of file ni_p2p_test.c.
int p2p_prepare_frames | ( | ni_logan_session_context_t * | p_upl_ctx, |
int | input_video_width, | ||
int | input_video_height, | ||
ni_logan_frame_t | p2p_frame[] | ||
) |
Prepare frames to simulate P2P transfers.
[in] | p_upl_ctx | pointer to caller allocated uploader session context [in] input_video_width video width [in] input_video_height video height [out] p2p_frame array of hw frames |
Definition at line 352 of file ni_p2p_test.c.
int p2p_upload_send_data | ( | ni_logan_session_context_t * | p_upl_ctx, |
int | fd, | ||
uint8_t ** | p_yuv420p_frame, | ||
ni_logan_frame_t * | p_in_frame, | ||
int | input_video_width, | ||
int | input_video_height, | ||
unsigned long * | bytes_sent, | ||
int * | input_exhausted | ||
) |
Recycle hw frames back to T408.
[in] | p2p_frame | - array of hw frames to recycle |
Reads YUV data from input file then calls a special libxcoder API function to transfer the YUV data into the hardware frame on the Quadra device.
[in] | p_upl_ctx | pointer to upload session context [in] fd file descriptor of input file [in] p_yuv420p_frame address of pointer to YUV data [in] p_in_frame pointer to hardware frame [in] input_video_width video width [in] input_video_height video height [out] bytes_sent updated byte count of total data read [out] input_exhausted set to 1 when we reach end-of-file |
Definition at line 242 of file ni_p2p_test.c.
void parse_arguments | ( | int | argc, |
char * | argv[], | ||
char * | input_filename, | ||
char * | output_filename, | ||
int * | iXcoderGUID, | ||
int * | arg_width, | ||
int * | arg_height, | ||
int * | dst_codec_format | ||
) |
Parse user command line arguments.
[in] | argc | argument count [in] argv argument vector [out] input_filename input filename [out] output_filename output filename [out] iXcoderGUID T408 device [out] arg_width resolution width [out] arg_height resolution height [out] dst_codec_format codec (AVC vs HEVC) |
Definition at line 862 of file ni_p2p_test.c.
void print_usage | ( | void | ) |
int read_next_chunk_from_file | ( | int | fd, |
uint8_t * | p_dst, | ||
uint32_t | to_read | ||
) |
Read the next frame.
[in] | fd | file descriptor of input file |
[out] | p_dst | pointer to place the frame |
[in] | to_read | number of bytes to copy to the pointer |
Definition at line 125 of file ni_p2p_test.c.
int uploader_open_session | ( | ni_logan_session_context_t * | p_upl_ctx, |
int * | iXcoderGUID, | ||
int | width, | ||
int | height | ||
) |
Open an upload session to T408.
[out] | p_upl_ctx | pointer to an upload context of the open session [in] iXcoderGUID pointer to T408 card hw id [in] width width of the frames [in] height height of the frames |
Definition at line 762 of file ni_p2p_test.c.
struct timeval current_time |
Definition at line 60 of file ni_p2p_test.c.
time_t current_timestamp = 0 |
Definition at line 68 of file ni_p2p_test.c.
uint64_t data_left_size = 0 |
Definition at line 59 of file ni_p2p_test.c.
int enc_eos_sent = 0 |
Definition at line 55 of file ni_p2p_test.c.
uint8_t* g_curr_cache_pos = NULL |
Definition at line 72 of file ni_p2p_test.c.
int g_repeat = 1 |
Definition at line 60 of file ni_p2p_test.c.
uint8_t* g_yuv_frame[POOL_SIZE] = {NULL, NULL} |
Definition at line 73 of file ni_p2p_test.c.
uint32_t number_of_frames = 0 |
Definition at line 57 of file ni_p2p_test.c.
uint32_t number_of_packets = 0 |
Definition at line 58 of file ni_p2p_test.c.
struct timeval previous_time |
Definition at line 60 of file ni_p2p_test.c.
time_t previous_timestamp = 0 |
Definition at line 67 of file ni_p2p_test.c.
int receive_fin_flag = 0 |
Definition at line 54 of file ni_p2p_test.c.
int send_fin_flag = 0 |
Definition at line 53 of file ni_p2p_test.c.
struct timeval start_time |
Definition at line 60 of file ni_p2p_test.c.
time_t start_timestamp = 0 |
Definition at line 66 of file ni_p2p_test.c.
unsigned long total_file_size = 0 |
Definition at line 70 of file ni_p2p_test.c.