* rocDecode: Added a command option to limit the number of decoded frames to a user set value to the video decoder app. (#252)

This commit is contained in:
jeffqjiangNew
2024-02-16 08:44:03 -05:00
committed by GitHub
parent 9b006616ed
commit ad31866ee0
2 changed files with 13 additions and 0 deletions
+1
View File
@@ -30,6 +30,7 @@ make -j
./videodecode -i <input video file [required]>
-o <output path to save decoded YUV frames [optional]>
-d <GPU device ID - 0:device 0 / 1:device 1/ ... [optional - default:0]>
-f <Number of decoded frames - specify the number of pictures to be decoded [optional]>
-z <force_zero_latency - Decoded frames will be flushed out for display immediately [optional]>
-sei <extract SEI messages [optional]>
-md5 <generate MD5 message digest on the decoded YUV image sequence [optional]>
+12
View File
@@ -45,6 +45,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
<< "-f Number of decoded frames - specify the number of pictures to be decoded; optional" << std::endl
<< "-z force_zero_latency (force_zero_latency, Decoded frames will be flushed out for display immediately); optional;" << std::endl
<< "-sei extract SEI messages; optional;" << std::endl
<< "-md5 generate MD5 message digest on the decoded YUV image sequence; optional;" << std::endl
@@ -71,6 +72,7 @@ int main(int argc, char **argv) {
OutputSurfaceMemoryType mem_type = OUT_SURFACE_MEM_DEV_INTERNAL; // set to internal
ReconfigParams reconfig_params = { 0 };
ReconfigDumpFileStruct reconfig_user_struct = { 0 };
uint32_t num_decoded_frames = 0; // default value is 0, meaning decode the entire stream
// Parse command-line arguments
if(argc <= 1) {
@@ -102,6 +104,13 @@ int main(int argc, char **argv) {
device_id = atoi(argv[i]);
continue;
}
if (!strcmp(argv[i], "-f")) {
if (++i == argc) {
ShowHelpAndExit("-d");
}
num_decoded_frames = atoi(argv[i]);
continue;
}
if (!strcmp(argv[i], "-z")) {
if (i == argc) {
ShowHelpAndExit("-z");
@@ -231,6 +240,9 @@ int main(int argc, char **argv) {
auto time_per_decode = std::chrono::duration<double, std::milli>(end_time - start_time).count();
total_dec_time += time_per_decode;
n_frame += n_frame_returned;
if (num_decoded_frames && num_decoded_frames == n_frame) {
break;
}
} while (n_video_bytes);
n_frame += viddec.GetNumOfFlushedFrames();