From 55193f516595dfa60f9824f633bf9bea7fa2ea45 Mon Sep 17 00:00:00 2001 From: Lakshmi Kumar Date: Thu, 30 Nov 2023 05:31:37 -0800 Subject: [PATCH] Samples - adds surface memory option to user (#104) * adding surface mem type as user arg * adding mem type user arg for all apps * readme update * readme updates on all apps [ROCm/rocdecode commit: 449572f9bf62c9e7b05439c7397bf3c329aec937] --- projects/rocdecode/samples/videoDecode/README.md | 1 + .../rocdecode/samples/videoDecode/videodecode.cpp | 11 ++++++++++- projects/rocdecode/samples/videoDecodeFork/README.md | 1 + .../samples/videoDecodeFork/videodecodefork.cpp | 11 ++++++++++- projects/rocdecode/samples/videoDecodeMem/README.md | 1 + .../samples/videoDecodeMem/videodecodemem.cpp | 11 ++++++++++- .../rocdecode/samples/videoDecodeMultiFiles/README.md | 1 + .../videoDecodeMultiFiles/videodecodemultifiles.cpp | 8 ++++++-- projects/rocdecode/samples/videoDecodePerf/README.md | 1 + .../samples/videoDecodePerf/videodecodeperf.cpp | 11 ++++++++++- 10 files changed, 51 insertions(+), 6 deletions(-) diff --git a/projects/rocdecode/samples/videoDecode/README.md b/projects/rocdecode/samples/videoDecode/README.md index fac58244cb..5b11c85c9f 100644 --- a/projects/rocdecode/samples/videoDecode/README.md +++ b/projects/rocdecode/samples/videoDecode/README.md @@ -34,4 +34,5 @@ make -j -z -sei -crop + -m ``` \ No newline at end of file diff --git a/projects/rocdecode/samples/videoDecode/videodecode.cpp b/projects/rocdecode/samples/videoDecode/videodecode.cpp index 6aa5d59c3d..54b14a30c2 100644 --- a/projects/rocdecode/samples/videoDecode/videodecode.cpp +++ b/projects/rocdecode/samples/videoDecode/videodecode.cpp @@ -43,7 +43,9 @@ void ShowHelpAndExit(const char *option = NULL) { << "-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 << "-sei extract SEI messages; optional;" << std::endl - << "-crop crop rectangle for output (not used when using interopped decoded frame); optional; default: 0" << std::endl; + << "-crop crop rectangle for output (not used when using interopped decoded frame); optional; default: 0" << std::endl + << "-m output_surface_memory_type - decoded surface memory; optional; default - 0" + << " [0 : OUT_SURFACE_MEM_DEV_INTERNAL/ 1 : OUT_SURFACE_MEM_DEV_COPIED/ 2 : OUT_SURFACE_MEM_HOST_COPIED]" << std::endl; exit(0); } @@ -112,6 +114,13 @@ int main(int argc, char **argv) { p_crop_rect = &crop_rect; continue; } + if (!strcmp(argv[i], "-m")) { + if (++i == argc) { + ShowHelpAndExit("-m"); + } + mem_type = static_cast(atoi(argv[i])); + continue; + } ShowHelpAndExit(argv[i]); } try { diff --git a/projects/rocdecode/samples/videoDecodeFork/README.md b/projects/rocdecode/samples/videoDecodeFork/README.md index d1adc7a3f4..f3a95d5cbf 100644 --- a/projects/rocdecode/samples/videoDecodeFork/README.md +++ b/projects/rocdecode/samples/videoDecodeFork/README.md @@ -34,4 +34,5 @@ make -j -f = 1) [optional; default:4]> -d = 0) [optional - default:0]> -z + -m ``` \ No newline at end of file diff --git a/projects/rocdecode/samples/videoDecodeFork/videodecodefork.cpp b/projects/rocdecode/samples/videoDecodeFork/videodecodefork.cpp index 5e2840ef60..819a0c35ff 100644 --- a/projects/rocdecode/samples/videoDecodeFork/videodecodefork.cpp +++ b/projects/rocdecode/samples/videoDecodeFork/videodecodefork.cpp @@ -58,7 +58,9 @@ void ShowHelpAndExit(const char *option = NULL) { << "-i Input File Path - required" << std::endl << "-f Number of forks (>= 1) - optional; default: 4" << std::endl << "-d Device ID (>= 0) - optional; default: 0" << std::endl - << "-z force_zero_latency (force_zero_latency, Decoded frames will be flushed out for display immediately); optional;" << std::endl; + << "-z force_zero_latency (force_zero_latency, Decoded frames will be flushed out for display immediately); optional;" << std::endl + << "-m output_surface_memory_type - decoded surface memory; optional; default - 0" + << " [0 : OUT_SURFACE_MEM_DEV_INTERNAL/ 1 : OUT_SURFACE_MEM_DEV_COPIED/ 2 : OUT_SURFACE_MEM_HOST_COPIED]" << std::endl; exit(0); } @@ -112,6 +114,13 @@ int main(int argc, char **argv) { b_force_zero_latency = true; continue; } + if (!strcmp(argv[i], "-m")) { + if (++i == argc) { + ShowHelpAndExit("-m"); + } + mem_type = static_cast(atoi(argv[i])); + continue; + } ShowHelpAndExit(argv[i]); } diff --git a/projects/rocdecode/samples/videoDecodeMem/README.md b/projects/rocdecode/samples/videoDecodeMem/README.md index c6ab369bb5..fa3377659b 100644 --- a/projects/rocdecode/samples/videoDecodeMem/README.md +++ b/projects/rocdecode/samples/videoDecodeMem/README.md @@ -34,4 +34,5 @@ make -j -z -sei -crop + -m ``` \ No newline at end of file diff --git a/projects/rocdecode/samples/videoDecodeMem/videodecodemem.cpp b/projects/rocdecode/samples/videoDecodeMem/videodecodemem.cpp index 04084d9548..8f7b46e263 100644 --- a/projects/rocdecode/samples/videoDecodeMem/videodecodemem.cpp +++ b/projects/rocdecode/samples/videoDecodeMem/videodecodemem.cpp @@ -66,7 +66,9 @@ void ShowHelpAndExit(const char *option = NULL) { << "-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 << "-sei extract SEI messages; optional;" << std::endl - << "-crop crop rectangle for output (not used when using interopped decoded frame); optional; default: 0" << std::endl; + << "-crop crop rectangle for output (not used when using interopped decoded frame); optional; default: 0" << std::endl + << "-m output_surface_memory_type - decoded surface memory; optional; default - 0" + << " [0 : OUT_SURFACE_MEM_DEV_INTERNAL/ 1 : OUT_SURFACE_MEM_DEV_COPIED/ 2 : OUT_SURFACE_MEM_HOST_COPIED]" << std::endl; exit(0); } @@ -135,6 +137,13 @@ int main(int argc, char **argv) { p_crop_rect = &crop_rect; continue; } + if (!strcmp(argv[i], "-m")) { + if (++i == argc) { + ShowHelpAndExit("-m"); + } + mem_type = static_cast(atoi(argv[i])); + continue; + } ShowHelpAndExit(argv[i]); } try { diff --git a/projects/rocdecode/samples/videoDecodeMultiFiles/README.md b/projects/rocdecode/samples/videoDecodeMultiFiles/README.md index 35089eb21c..19356753dc 100644 --- a/projects/rocdecode/samples/videoDecodeMultiFiles/README.md +++ b/projects/rocdecode/samples/videoDecodeMultiFiles/README.md @@ -38,6 +38,7 @@ outfile output1.yuv [optional] z 0 [optional] sei 0 [optional] crop l,t,r,b [optional] +m 0 [optional] [0 : OUT_SURFACE_MEM_DEV_INTERNAL/ 1 : OUT_SURFACE_MEM_DEV_COPIED/ 2 : OUT_SURFACE_MEM_HOST_COPIED] infile input2.[mp4/mov...] [optional] outfile output2.yuv [optional] ... diff --git a/projects/rocdecode/samples/videoDecodeMultiFiles/videodecodemultifiles.cpp b/projects/rocdecode/samples/videoDecodeMultiFiles/videodecodemultifiles.cpp index 00dd6c6473..391f1c8928 100644 --- a/projects/rocdecode/samples/videoDecodeMultiFiles/videodecodemultifiles.cpp +++ b/projects/rocdecode/samples/videoDecodeMultiFiles/videodecodemultifiles.cpp @@ -47,6 +47,7 @@ typedef struct { Rect crop_rect; Rect *p_crop_rect; int dump_output_frames; + OutputSurfaceMemoryType mem_type; // set to internal } FileInfo; void ShowHelpAndExit(const char *option = NULL) { @@ -58,6 +59,7 @@ void ShowHelpAndExit(const char *option = NULL) { << "z 0 (force_zero_latency - Decoded frames will be flushed out for display immediately; default: 0)" << std::endl << "sei 0 (extract SEI messages; default: 0)" << std::endl << "crop l,t,r,b (crop rectangle for output (not used when using interopped decoded frame); default: 0)" << std::endl + << "m 0 decoded surface memory; optional; default - 0 [0 : OUT_SURFACE_MEM_DEV_INTERNAL/ 1 : OUT_SURFACE_MEM_DEV_COPIED/ 2 : OUT_SURFACE_MEM_HOST_COPIED]" << std::endl << "infile input2.[mp4/mov...]" << std::endl << "outfile output2.yuv" << std::endl << "...." << std::endl @@ -118,6 +120,7 @@ void ParseCommandLine(std::deque *multi_file_data, int &device_id, int file_data.dump_output_frames = 0; file_data.crop_rect = {0, 0, 0, 0}; file_data.p_crop_rect = nullptr; + file_data.mem_type = OUT_SURFACE_MEM_DEV_INTERNAL; } else if (!strcmp(param, "outfile")) { file_data.out_file = value; file_data.dump_output_frames = 1; @@ -132,6 +135,8 @@ void ParseCommandLine(std::deque *multi_file_data, int &device_id, int exit(1); } file_data.p_crop_rect = &file_data.crop_rect; + } else if (!strcmp(param, "m")) { + file_data.mem_type = static_cast(atoi(value)); } } if (file_idx > 0) { @@ -144,7 +149,6 @@ int main(int argc, char **argv) { std::deque multi_file_data; FileInfo file_data; int device_id = 0; - OutputSurfaceMemoryType mem_type = OUT_SURFACE_MEM_DEV_INTERNAL; // set to internal ParseCommandLine (&multi_file_data, device_id, argc, argv); @@ -154,7 +158,7 @@ int main(int argc, char **argv) { multi_file_data.pop_front(); VideoDemuxer demuxer(file_data.in_file.c_str()); rocDecVideoCodec rocdec_codec_id = AVCodec2RocDecVideoCodec(demuxer.GetCodecID()); - RocVideoDecoder viddec(device_id, mem_type, rocdec_codec_id, false, file_data.b_force_zero_latency, file_data.p_crop_rect, file_data.b_extract_sei_messages); + RocVideoDecoder viddec(device_id, file_data.mem_type, rocdec_codec_id, false, file_data.b_force_zero_latency, file_data.p_crop_rect, file_data.b_extract_sei_messages); std::string device_name, gcn_arch_name; int pci_bus_id, pci_domain_id, pci_device_id; diff --git a/projects/rocdecode/samples/videoDecodePerf/README.md b/projects/rocdecode/samples/videoDecodePerf/README.md index 33b26e08bc..40ec20364b 100644 --- a/projects/rocdecode/samples/videoDecodePerf/README.md +++ b/projects/rocdecode/samples/videoDecodePerf/README.md @@ -34,4 +34,5 @@ make -j -t -d = 0) [optional - default:0]> -z + -m ``` \ No newline at end of file diff --git a/projects/rocdecode/samples/videoDecodePerf/videodecodeperf.cpp b/projects/rocdecode/samples/videoDecodePerf/videodecodeperf.cpp index 551dc58fc5..247e91d9b1 100644 --- a/projects/rocdecode/samples/videoDecodePerf/videodecodeperf.cpp +++ b/projects/rocdecode/samples/videoDecodePerf/videodecodeperf.cpp @@ -65,7 +65,9 @@ void ShowHelpAndExit(const char *option = NULL) { << "-i Input File Path - required" << std::endl << "-t Number of threads (>= 1) - optional; default: 4" << std::endl << "-d Device ID (>= 0) - optional; default: 0" << std::endl - << "-z force_zero_latency (force_zero_latency, Decoded frames will be flushed out for display immediately); optional;" << std::endl; + << "-z force_zero_latency (force_zero_latency, Decoded frames will be flushed out for display immediately); optional;" << std::endl + << "-m output_surface_memory_type - decoded surface memory; optional; default - 0" + << " [0 : OUT_SURFACE_MEM_DEV_INTERNAL/ 1 : OUT_SURFACE_MEM_DEV_COPIED/ 2 : OUT_SURFACE_MEM_HOST_COPIED]" << std::endl; exit(0); } @@ -119,6 +121,13 @@ int main(int argc, char **argv) { b_force_zero_latency = true; continue; } + if (!strcmp(argv[i], "-m")) { + if (++i == argc) { + ShowHelpAndExit("-m"); + } + mem_type = static_cast(atoi(argv[i])); + continue; + } ShowHelpAndExit(argv[i]); }