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: 449572f9bf]
This commit is contained in:
Lakshmi Kumar
2023-11-30 05:31:37 -08:00
committed by GitHub
orang tua 372ab1219a
melakukan 55193f5165
10 mengubah file dengan 51 tambahan dan 6 penghapusan
@@ -34,4 +34,5 @@ make -j
-z <force_zero_latency - Decoded frames will be flushed out for display immediately [optional]>
-sei <extract SEI messages [optional]>
-crop <crop rectangle for output (not used when using interopped decoded frame) [optional - default: 0,0,0,0]>
-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]>
```
@@ -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<OutputSurfaceMemoryType>(atoi(argv[i]));
continue;
}
ShowHelpAndExit(argv[i]);
}
try {
@@ -34,4 +34,5 @@ make -j
-f <Number of forks ( >= 1) [optional; default:4]>
-d <Device ID (>= 0) [optional - default:0]>
-z <force_zero_latency - Decoded frames will be flushed out for display immediately [optional]>
-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]>
```
@@ -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<OutputSurfaceMemoryType>(atoi(argv[i]));
continue;
}
ShowHelpAndExit(argv[i]);
}
@@ -34,4 +34,5 @@ make -j
-z <force_zero_latency - Decoded frames will be flushed out for display immediately [optional]>
-sei <extract SEI messages [optional]>
-crop <crop rectangle for output (not used when using interopped decoded frame) [optional - default: 0,0,0,0]>
-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]>
```
@@ -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<OutputSurfaceMemoryType>(atoi(argv[i]));
continue;
}
ShowHelpAndExit(argv[i]);
}
try {
@@ -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]
...
@@ -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<FileInfo> *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<FileInfo> *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<OutputSurfaceMemoryType>(atoi(value));
}
}
if (file_idx > 0) {
@@ -144,7 +149,6 @@ int main(int argc, char **argv) {
std::deque<FileInfo> 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;
@@ -34,4 +34,5 @@ make -j
-t <number of threads [optional - default:4]>
-d <Device ID (>= 0) [optional - default:0]>
-z <force_zero_latency - Decoded frames will be flushed out for display immediately [optional]>
-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]>
```
@@ -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<OutputSurfaceMemoryType>(atoi(argv[i]));
continue;
}
ShowHelpAndExit(argv[i]);
}