From 686998704ac4698570b3707e87c327cb697f8548 Mon Sep 17 00:00:00 2001 From: jeffqjiangNew <142832361+jeffqjiangNew@users.noreply.github.com> Date: Tue, 27 Aug 2024 21:39:43 -0400 Subject: [PATCH] * rocDecode/Perf: Added resolution and bit rate info into csv output, to speed up performance data post-processing. (#412) [ROCm/rocdecode commit: fbec8fd3f503816b022097402d2e12ac2648ed9b] --- .../test/testScripts/run_rocDecodeSamples.py | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/projects/rocdecode/test/testScripts/run_rocDecodeSamples.py b/projects/rocdecode/test/testScripts/run_rocDecodeSamples.py index 5cfd9748fc..ea1fee0f0e 100644 --- a/projects/rocdecode/test/testScripts/run_rocDecodeSamples.py +++ b/projects/rocdecode/test/testScripts/run_rocDecodeSamples.py @@ -56,6 +56,22 @@ def iter_files(path): if item.is_file(): yield item +def print_bitrate(current_file): + file_name = str(current_file) + mbps_pos = file_name.find("mbps") + if (mbps_pos != -1): + fps_pos = file_name.find("fps_") + if (fps_pos != -1): + bit_rate = file_name[fps_pos + 4 : mbps_pos] + else: + bit_rate = "n/a" + else: + bit_rate = "n/a" + orig_stdout = sys.stdout + sys.stdout = open(resultsPath+'/rocDecode_output.log', 'a') + print("Bitrate: ", bit_rate) + sys.stdout = orig_stdout + # Import arguments parser = argparse.ArgumentParser() parser.add_argument('--rocDecode_directory', type=str, default='', @@ -118,16 +134,19 @@ if os.path.exists(resultsPath+'/rocDecode_test_results.csv'): if sampleMode == 0: for current_file in iter_files(filesDirPath): + print_bitrate(current_file) + os.system(run_rocDecode_app+' -i '+str(current_file)+' -d '+str(gpuDeviceID)+' -f '+str(maxNumFrames)+' | tee -a '+resultsPath+'/rocDecode_output.log') print("\n\n") orig_stdout = sys.stdout sys.stdout = open(resultsPath+'/rocDecode_test_results.csv', 'a') - echo_1 = 'File Name, Codec, Bit Depth, Total Frames, Average decoding time per frame (ms), Avg FPS' + echo_1 = 'File Name, Codec, Video Size, Bit Depth, Bit rate, Total Frames, Average decoding time per frame (ms), Avg FPS' print(echo_1) sys.stdout = orig_stdout - runAwk_csv = r'''awk '/info: Input file: / {filename=$4; next} + runAwk_csv = r'''awk '/Bitrate: / {bitRate=$2; next} + /info: Input file: / {filename=$4; next} /info: Using GPU device 0 - AMD Radeon Graphics[gfx1030] on PCI bus 0d:00.0/{next} /info: decoding started, please wait!/{next} /Input Video Information/{next} @@ -140,24 +159,27 @@ if sampleMode == 0: /Video Decoding Params:/{next} /\tNum Surfaces : /{next} /\tCrop : /{next} - /\tResize : /{next} + /\tResize : /{videoSize=$3; next} /^$/{next} /info: Total pictures decoded: / {totalFrames=$5; next} /info: avg decoding time per picture: /{timePerFrame=$7; next} - /info: avg decode FPS: / { printf("%s, %s, %d, %d, %f, %f\n", filename, codec, bitDepth, totalFrames, timePerFrame, $5) }' rocDecode_videoDecode_results/rocDecode_output.log >> rocDecode_videoDecode_results/rocDecode_test_results.csv''' + /info: avg decode FPS: / { printf("%s, %s, %s, %d, %s, %d, %f, %f\n", filename, codec, videoSize, bitDepth, bitRate, totalFrames, timePerFrame, $5) }' rocDecode_videoDecode_results/rocDecode_output.log >> rocDecode_videoDecode_results/rocDecode_test_results.csv''' os.system(runAwk_csv) elif sampleMode == 1: for current_file in iter_files(filesDirPath): + print_bitrate(current_file) + os.system(run_rocDecode_app+' -i '+str(current_file)+' -t '+str(numThreads)+' -f '+str(maxNumFrames)+' | tee -a '+resultsPath+'/rocDecode_output.log') print("\n\n") orig_stdout = sys.stdout sys.stdout = open(resultsPath+'/rocDecode_test_results.csv', 'a') - echo_1 = 'File Name, Num Threads, Codec, Bit Depth, Total Frames, Average decoding time per frame (ms), Avg FPS' + echo_1 = 'File Name, Num Threads, Codec, Video Size, Bit Depth, Bit rate, Total Frames, Average decoding time per frame (ms), Avg FPS' print(echo_1) sys.stdout = orig_stdout - runAwk_csv = r'''awk '/info: Input file: / {filename=$4; next} + runAwk_csv = r'''awk '/Bitrate: / {bitRate=$2; next} + /info: Input file: / {filename=$4; next} /info: Number of threads: / {numThreads=$5; next} /info: Using GPU device 0 - AMD Radeon Graphics[gfx1030] on PCI bus 0d:00.0/{next} /info: decoding started, please wait!/{next} @@ -171,11 +193,11 @@ elif sampleMode == 1: /Video Decoding Params:/{next} /\tNum Surfaces : /{next} /\tCrop : /{next} - /\tResize : /{next} + /\tResize : /{videoSize=$3; next} /^$/{next} /info: Total pictures decoded: / {totalFrames=$5; next} /info: avg decoding time per picture: /{timePerFrame=$7; next} - /info: avg decode FPS: / { printf("%s, %d, %s, %d, %d, %f, %f\n", filename, numThreads, codec, bitDepth, totalFrames, timePerFrame, $5) }' rocDecode_videoDecodePerf_results/rocDecode_output.log >> rocDecode_videoDecodePerf_results/rocDecode_test_results.csv''' + /info: avg decode FPS: / { printf("%s, %d, %s, %s, %d, %s, %d, %f, %f\n", filename, numThreads, codec, videoSize, bitDepth, bitRate, totalFrames, timePerFrame, $5) }' rocDecode_videoDecodePerf_results/rocDecode_output.log >> rocDecode_videoDecodePerf_results/rocDecode_test_results.csv''' sys.stdout = orig_stdout os.system(runAwk_csv)