Fix a segmentation fault on some samples when the memory type is 3 (OUT_SURFACE_MEM_NOT_MAPPED) and attempting to save the output (which is not supported) (#239)
* Fix a segmentation fault on some samples when the memory type is 3 (OUT_SURFACE_MEM_NOT_MAPPED) and attempting to save the output (which is not supported)
* update the videoDecodeMultiFiles sample
* update the readme for videoDecodeMultiFiles
* add comments
* use OUT_SURFACE_MEM_NOT_MAPPED instead of integer number 3
[ROCm/rocdecode commit: 31c7c7c104]
This commit is contained in:
committed by
GitHub
orang tua
18e32ff6c8
melakukan
bc48060ff0
@@ -35,5 +35,5 @@ make -j
|
||||
-md5 <generate MD5 message digest on the decoded YUV image sequence [optional]>
|
||||
-md5_check MD5_File_Path <generate MD5 message digest on the decoded YUV image sequence and compare to the reference MD5 string in a file [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]>
|
||||
-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/3 : OUT_SURFACE_MEM_NOT_MAPPED]>
|
||||
```
|
||||
@@ -51,7 +51,7 @@ void ShowHelpAndExit(const char *option = NULL) {
|
||||
<< "-md5_check MD5 File Path - generate MD5 message digest on the decoded YUV image sequence and compare to the reference MD5 string in a file; optional;" << 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;
|
||||
<< " [0 : OUT_SURFACE_MEM_DEV_INTERNAL/ 1 : OUT_SURFACE_MEM_DEV_COPIED/ 2 : OUT_SURFACE_MEM_HOST_COPIED/ 3 : OUT_SURFACE_MEM_NOT_MAPPED]" << std::endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ int main(int argc, char **argv) {
|
||||
if (b_generate_md5) {
|
||||
viddec.UpdateMd5ForFrame(pframe, surf_info);
|
||||
}
|
||||
if (dump_output_frames) {
|
||||
if (dump_output_frames && mem_type != OUT_SURFACE_MEM_NOT_MAPPED) {
|
||||
viddec.SaveFrameToFile(output_file_path, pframe, surf_info);
|
||||
}
|
||||
// release frame
|
||||
@@ -238,6 +238,12 @@ int main(int argc, char **argv) {
|
||||
if (!dump_output_frames) {
|
||||
std::cout << "info: avg decoding time per frame: " << total_dec_time / n_frame << " ms" <<std::endl;
|
||||
std::cout << "info: avg FPS: " << (n_frame / total_dec_time) * 1000 << std::endl;
|
||||
} else {
|
||||
if (mem_type == OUT_SURFACE_MEM_NOT_MAPPED) {
|
||||
std::cout << "info: saving frames with -m 3 option is not supported!" << std::endl;
|
||||
} else {
|
||||
std::cout << "info: saved frames into " << output_file_path << std::endl;
|
||||
}
|
||||
}
|
||||
if (b_generate_md5) {
|
||||
uint8_t *digest;
|
||||
|
||||
@@ -35,5 +35,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]>
|
||||
-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/ 3 : OUT_SURFACE_MEM_NOT_MAPPED]>
|
||||
```
|
||||
@@ -76,7 +76,7 @@ void ShowHelpAndExit(const char *option = NULL) {
|
||||
<< "-sei extract SEI messages; optional;" << 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;
|
||||
<< " [0 : OUT_SURFACE_MEM_DEV_INTERNAL/ 1 : OUT_SURFACE_MEM_DEV_COPIED/ 2 : OUT_SURFACE_MEM_HOST_COPIED/ 3 : OUT_SURFACE_MEM_NOT_MAPPED]" << std::endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
for (int i = 0; i < n_frame_returned; i++) {
|
||||
pframe = viddec.GetFrame(&pts);
|
||||
if (dump_output_frames) {
|
||||
if (dump_output_frames && mem_type != OUT_SURFACE_MEM_NOT_MAPPED) {
|
||||
viddec.SaveFrameToFile(output_file_path, pframe, surf_info);
|
||||
}
|
||||
// release frame
|
||||
@@ -208,6 +208,13 @@ int main(int argc, char **argv) {
|
||||
if (!dump_output_frames) {
|
||||
std::cout << "info: avg decoding time per frame (ms): " << total_dec_time / n_frame << std::endl;
|
||||
std::cout << "info: avg FPS: " << (n_frame / total_dec_time) * 1000 << std::endl;
|
||||
} else {
|
||||
if (mem_type == OUT_SURFACE_MEM_NOT_MAPPED) {
|
||||
std::cout << "info: saving frames with -m 3 option is not supported!" << std::endl;
|
||||
} else {
|
||||
std::cout << "info: saved frames into " << output_file_path << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (const std::exception &ex) {
|
||||
std::cout << ex.what() << std::endl;
|
||||
|
||||
@@ -41,7 +41,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]
|
||||
m 0 [optional] [0 : OUT_SURFACE_MEM_DEV_INTERNAL/ 1 : OUT_SURFACE_MEM_DEV_COPIED/ 2 : OUT_SURFACE_MEM_HOST_COPIED/ 3 : OUT_SURFACE_MEM_NOT_MAPPED]
|
||||
infile input2.[mp4/mov...] [optional]
|
||||
outfile output2.yuv [optional]
|
||||
...
|
||||
|
||||
@@ -61,7 +61,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
|
||||
<< "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/ 3 : OUT_SURFACE_MEM_NOT_MAPPED]" << std::endl
|
||||
<< "flush 1 flush last frames during reconfig; optional; default - 1 [1 : Flush last frames during reconfig 0 : Discard last frames during reconfigure ]" << std::endl
|
||||
<< "infile input2.[mp4/mov...]" << std::endl
|
||||
<< "outfile output2.yuv" << std::endl
|
||||
@@ -230,7 +230,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
for (int i = 0; i < n_frame_returned; i++) {
|
||||
pframe = viddec->GetFrame(&pts);
|
||||
if (file_data.dump_output_frames) {
|
||||
if (file_data.dump_output_frames && file_data.mem_type != OUT_SURFACE_MEM_NOT_MAPPED) {
|
||||
viddec->SaveFrameToFile(file_data.out_file, pframe, surf_info);
|
||||
}
|
||||
// release frame
|
||||
@@ -244,6 +244,13 @@ int main(int argc, char **argv) {
|
||||
if (!file_data.dump_output_frames) {
|
||||
std::cout << "info: avg decoding time per frame (ms): " << total_dec_time / n_frame << std::endl;
|
||||
std::cout << "info: avg FPS: " << (n_frame / total_dec_time) * 1000 << std::endl;
|
||||
} else {
|
||||
if (file_data.mem_type == OUT_SURFACE_MEM_NOT_MAPPED) {
|
||||
std::cout << "info: saving frames with -m 3 option is not supported!" << std::endl;
|
||||
} else {
|
||||
std::cout << "info: saved frames into " << file_data.out_file << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
if (!use_reconfigure) {
|
||||
delete viddec;
|
||||
|
||||
@@ -33,5 +33,4 @@ 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]>
|
||||
```
|
||||
@@ -53,8 +53,7 @@ void ShowHelpAndExit(const char *option = NULL) {
|
||||
<< "-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
|
||||
<< "-of Output Format name - (native, bgr, bgr48, rgb, rgb48, bgra, bgra64, rgba, rgba64; converts native YUV frame to RGB image format; 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" << std::endl;
|
||||
<< "-crop crop rectangle for output (not used when using interopped decoded frame); optional; default: 0" << std::endl;
|
||||
|
||||
exit(0);
|
||||
}
|
||||
@@ -259,13 +258,6 @@ int main(int argc, char **argv) {
|
||||
device_id = atoi(argv[i]);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-m")) {
|
||||
if (++i == argc) {
|
||||
ShowHelpAndExit("-m");
|
||||
}
|
||||
mem_type = static_cast<OutputSurfaceMemoryType>(atoi(argv[i]));
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user