diff --git a/projects/rocdecode/samples/videoDecode/videodecode.cpp b/projects/rocdecode/samples/videoDecode/videodecode.cpp index 79118e1e5b..c28b733043 100644 --- a/projects/rocdecode/samples/videoDecode/videodecode.cpp +++ b/projects/rocdecode/samples/videoDecode/videodecode.cpp @@ -41,6 +41,7 @@ void ShowHelpAndExit(const char *option = NULL) { << "-i Input File Path - required" << std::endl << "-o Output File Path - dumps output if requested; optional" << std::endl << "-d GPU device ID (0 for the first device, 1 for the second, etc.); optional; default: 0" << std::endl + << "-z force_zero_latency (force_zero_latency, Decoded frames will be flushed out for display immediately); optional;" << std::endl << "-crop crop rectangle for output (not used when using interopped decoded frame); optional; default: 0" << std::endl; exit(0); } @@ -51,6 +52,7 @@ int main(int argc, char **argv) { int dumpOutputFrames = 0; int isOutputRGB = 0; int deviceId = 0; + bool b_force_zero_latency = false; // false by default: enabling this option might affect decoding performance Rect crop_rect = {}; Rect *p_crop_rect = nullptr; OUTPUT_SURF_MEMORY_TYPE mem_type = OUT_SURFACE_MEM_DEV_INTERNAL; // set to internal @@ -84,6 +86,13 @@ int main(int argc, char **argv) { deviceId = atoi(argv[i]); continue; } + if (!strcmp(argv[i], "-z")) { + if (i == argc) { + ShowHelpAndExit("-z"); + } + b_force_zero_latency = true; + continue; + } if (!strcmp(argv[i], "-crop")) { if (++i == argc || 4 != sscanf(argv[i], "%d,%d,%d,%d", &crop_rect.l, &crop_rect.t, &crop_rect.r, &crop_rect.b)) { ShowHelpAndExit("-crop"); @@ -100,7 +109,7 @@ int main(int argc, char **argv) { try { VideoDemuxer demuxer(inputFilePath.c_str()); rocDecVideoCodec rocdec_codec_id = AVCodec2RocDecVideoCodec(demuxer.GetCodecID()); - RocVideoDecoder viddec(deviceId, mem_type, rocdec_codec_id, false, true, p_crop_rect); + RocVideoDecoder viddec(deviceId, mem_type, rocdec_codec_id, false, b_force_zero_latency, p_crop_rect); std::string deviceName, gcnArchName, drmNode; int pciBusID, pciDomainID, pciDeviceID; diff --git a/projects/rocdecode/utils/rocvideodecode/roc_video_dec.cpp b/projects/rocdecode/utils/rocvideodecode/roc_video_dec.cpp index 8dc600ed48..2ae1cb49a6 100644 --- a/projects/rocdecode/utils/rocvideodecode/roc_video_dec.cpp +++ b/projects/rocdecode/utils/rocvideodecode/roc_video_dec.cpp @@ -22,11 +22,11 @@ THE SOFTWARE. #include "roc_video_dec.h" -RocVideoDecoder::RocVideoDecoder(int device_id, OUTPUT_SURF_MEMORY_TYPE out_mem_type, rocDecVideoCodec codec, bool b_low_latency, bool device_frame_pitched, - const Rect *p_crop_rect, bool extract_user_SEI_Message, int max_width, int max_height, - uint32_t clk_rate, bool force_zero_latency) : device_id_{device_id}, out_mem_type_(out_mem_type), codec_id_(codec), - b_low_latency_(b_low_latency), b_device_frame_pitched_(device_frame_pitched), b_extract_sei_message_(extract_user_SEI_Message), - max_width_ (max_width), max_height_(max_height), b_force_zero_latency_(force_zero_latency) { +RocVideoDecoder::RocVideoDecoder(int device_id, OUTPUT_SURF_MEMORY_TYPE out_mem_type, rocDecVideoCodec codec, bool b_low_latency, bool force_zero_latency, + bool device_frame_pitched, const Rect *p_crop_rect, bool extract_user_SEI_Message, int max_width, int max_height, + uint32_t clk_rate) : device_id_{device_id}, out_mem_type_(out_mem_type), codec_id_(codec), b_low_latency_(b_low_latency), + b_force_zero_latency_(force_zero_latency), b_device_frame_pitched_(device_frame_pitched), b_extract_sei_message_(extract_user_SEI_Message), + max_width_ (max_width), max_height_(max_height) { if (!InitHIP(device_id_)) { THROW("Failed to initilize the HIP"); diff --git a/projects/rocdecode/utils/rocvideodecode/roc_video_dec.h b/projects/rocdecode/utils/rocvideodecode/roc_video_dec.h index 1bdce4d57a..6e72103b54 100644 --- a/projects/rocdecode/utils/rocvideodecode/roc_video_dec.h +++ b/projects/rocdecode/utils/rocvideodecode/roc_video_dec.h @@ -148,9 +148,9 @@ class RocVideoDecoder { * @param clk_rate * @param force_zero_latency */ - RocVideoDecoder(int device_id, OUTPUT_SURF_MEMORY_TYPE out_mem_type, rocDecVideoCodec codec, bool b_low_latency, bool device_frame_pitched, - const Rect *p_crop_rect, bool extract_user_SEI_Message = false, int max_width = 0, int max_height = 0, - uint32_t clk_rate = 1000, bool force_zero_latency = false); + RocVideoDecoder(int device_id, OUTPUT_SURF_MEMORY_TYPE out_mem_type, rocDecVideoCodec codec, bool b_low_latency, bool force_zero_latency = false, + bool device_frame_pitched = true, const Rect *p_crop_rect = nullptr, bool extract_user_SEI_Message = false, int max_width = 0, int max_height = 0, + uint32_t clk_rate = 1000); ~RocVideoDecoder(); rocDecVideoCodec GetCodecId() { return codec_id_; }