MD5 digest generation support (#109)
* * rocDecode/HEVC: Added support for MD5 message digest generation.
- Command option "-md5" triggers MD5 calculation and output.
* * rocDecode/HEVC: Changed C type casting to C++ type casting.
[ROCm/rocdecode commit: ad20961c4a]
This commit is contained in:
@@ -43,6 +43,7 @@ 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
|
||||
<< "-md5 generate MD5 message digest on the decoded YUV image sequence; 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;
|
||||
@@ -56,6 +57,7 @@ int main(int argc, char **argv) {
|
||||
int device_id = 0;
|
||||
bool b_force_zero_latency = false; // false by default: enabling this option might affect decoding performance
|
||||
bool b_extract_sei_messages = false;
|
||||
bool b_generate_md5 = false;
|
||||
Rect crop_rect = {};
|
||||
Rect *p_crop_rect = nullptr;
|
||||
OutputSurfaceMemoryType mem_type = OUT_SURFACE_MEM_DEV_INTERNAL; // set to internal
|
||||
@@ -103,6 +105,13 @@ int main(int argc, char **argv) {
|
||||
b_extract_sei_messages = true;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-md5")) {
|
||||
if (i == argc) {
|
||||
ShowHelpAndExit("-md5");
|
||||
}
|
||||
b_generate_md5 = 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");
|
||||
@@ -146,6 +155,10 @@ int main(int argc, char **argv) {
|
||||
uint32_t width, height;
|
||||
double total_dec_time = 0;
|
||||
|
||||
if (b_generate_md5) {
|
||||
viddec.InitMd5();
|
||||
}
|
||||
|
||||
do {
|
||||
auto start_time = std::chrono::high_resolution_clock::now();
|
||||
demuxer.Demux(&pvideo, &n_video_bytes, &pts);
|
||||
@@ -163,6 +176,9 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
for (int i = 0; i < n_frame_returned; i++) {
|
||||
pframe = viddec.GetFrame(&pts);
|
||||
if (b_generate_md5) {
|
||||
viddec.UpdateMd5ForFrame(pframe, surf_info);
|
||||
}
|
||||
if (dump_output_frames) {
|
||||
viddec.SaveFrameToFile(output_file_path, pframe, surf_info);
|
||||
}
|
||||
@@ -177,6 +193,15 @@ int main(int argc, char **argv) {
|
||||
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;
|
||||
}
|
||||
if (b_generate_md5) {
|
||||
uint8_t *digest;
|
||||
viddec.FinalizeMd5(&digest);
|
||||
std::cout << "MD5 message digest: ";
|
||||
for (int i = 0; i < 16; i++) {
|
||||
std::cout << std::hex << static_cast<int>(digest[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
} catch (const std::exception &ex) {
|
||||
std::cout << ex.what() << std::endl;
|
||||
exit(1);
|
||||
|
||||
Reference in New Issue
Block a user