Added real decode speed report to set it apart from the current output speed report in sample apps (#409)

* * rocDecode: Added real decode speed report.
 - The current decode speed report is actually output/display speed report.
 - Due to AV1's extensive use of alternate reference frames that are not display, AV1 decoded frame count and output/displayed frame count can be quite different, making the current speed report not an accurate decode speed measurement.
 - We now added the actual decode speed report, besides the existing speed report, now called output/display FPS.

* * rocDecode: Added real decode speed report.
 - The current decode speed report is actually output/display speed report.
 - Due to AV1's extensive use of alternate reference frames that are not display, AV1 decoded frame count and output/displayed frame count can be quite different, making the current speed report not an accurate decode speed measurement.
 - We now added the actual decode speed report, besides the existing speed report, now called output/display FPS.

* * rocDecode/Sample script: Added missing changes for sample_mode 0 case.

[ROCm/rocdecode commit: 6253248188]
このコミットが含まれているのは:
jeffqjiangNew
2024-08-20 17:43:33 -04:00
committed by GitHub
コミット 29cfd4a541
6個のファイルの変更、65行の追加、40行の削除
+28 -13
ファイルの表示
@@ -37,8 +37,9 @@ THE SOFTWARE.
#include "roc_video_dec.h"
#include "common.h"
void DecProc(RocVideoDecoder *p_dec, VideoDemuxer *demuxer, int *pn_frame, double *pn_fps, int num_decoded_frames) {
void DecProc(RocVideoDecoder *p_dec, VideoDemuxer *demuxer, int *pn_frame, int *pn_pic_dec, double *pn_fps, double *pn_fps_dec, int max_num_frames) {
int n_video_bytes = 0, n_frame_returned = 0, n_frame = 0;
int n_pic_decoded = 0, decoded_pics = 0;
uint8_t *p_video = nullptr;
int64_t pts = 0;
double total_dec_time = 0.0;
@@ -46,9 +47,10 @@ void DecProc(RocVideoDecoder *p_dec, VideoDemuxer *demuxer, int *pn_frame, doubl
do {
demuxer->Demux(&p_video, &n_video_bytes, &pts);
n_frame_returned = p_dec->DecodeFrame(p_video, n_video_bytes, 0, pts);
n_frame_returned = p_dec->DecodeFrame(p_video, n_video_bytes, 0, pts, &decoded_pics);
n_frame += n_frame_returned;
if (num_decoded_frames && num_decoded_frames <= n_frame) {
n_pic_decoded += decoded_pics;
if (max_num_frames && max_num_frames <= n_frame) {
break;
}
} while (n_video_bytes);
@@ -58,10 +60,14 @@ void DecProc(RocVideoDecoder *p_dec, VideoDemuxer *demuxer, int *pn_frame, doubl
auto session_overhead = p_dec->GetDecoderSessionOverHead(std::this_thread::get_id());
// Calculate average decoding time
total_dec_time = time_per_decode - session_overhead;
double average_decoding_time = total_dec_time / n_frame;
double n_fps = 1000 / average_decoding_time;
double average_output_time = total_dec_time / n_frame;
double average_decoding_time = total_dec_time / n_pic_decoded;
double n_fps = 1000 / average_output_time;
double n_fps_dec = 1000 / average_decoding_time;
*pn_fps = n_fps;
*pn_fps_dec = n_fps_dec;
*pn_frame = n_frame;
*pn_pic_dec = n_pic_decoded;
}
void ShowHelpAndExit(const char *option = NULL) {
@@ -81,7 +87,7 @@ int main(int argc, char **argv) {
Rect *p_crop_rect = nullptr;
OutputSurfaceMemoryType mem_type = OUT_SURFACE_MEM_NOT_MAPPED; // set to decode only for performance
bool b_force_zero_latency = false;
uint32_t num_decoded_frames = 0; // default value is 0, meaning decode the entire stream
uint32_t max_num_frames = 0; // max number of frames to be decoded. default value is 0, meaning decode the entire stream
int disp_delay = 0;
// Parse command-line arguments
@@ -130,7 +136,7 @@ int main(int argc, char **argv) {
if (++i == argc) {
ShowHelpAndExit("-d");
}
num_decoded_frames = atoi(argv[i]);
max_num_frames = atoi(argv[i]);
continue;
}
if (!strcmp(argv[i], "-z")) {
@@ -207,12 +213,16 @@ int main(int argc, char **argv) {
}
float total_fps = 0;
float total_fps_dec = 0;
std::vector<std::thread> v_thread;
std::vector<double> v_fps;
std::vector<int> v_frame;
std::vector<double> v_fps, v_fps_dec;
std::vector<int> v_frame, v_frame_dec;
v_fps.resize(n_thread, 0);
v_fps_dec.resize(n_thread, 0);
v_frame.resize(n_thread, 0);
v_frame_dec.resize(n_thread, 0);
int n_total = 0;
int n_total_dec = 0;
OutputSurfaceInfo *p_surf_info;
std::string device_name;
@@ -227,18 +237,23 @@ int main(int argc, char **argv) {
}
for (int i = 0; i < n_thread; i++) {
v_thread.push_back(std::thread(DecProc, v_viddec[i].get(), v_demuxer[i].get(), &v_frame[i], &v_fps[i], num_decoded_frames));
v_thread.push_back(std::thread(DecProc, v_viddec[i].get(), v_demuxer[i].get(), &v_frame[i], &v_frame_dec[i], &v_fps[i], &v_fps_dec[i], max_num_frames));
}
for (int i = 0; i < n_thread; i++) {
v_thread[i].join();
total_fps += v_fps[i];
total_fps_dec += v_fps_dec[i];
n_total += v_frame[i];
n_total_dec += v_frame_dec[i];
}
std::cout << "info: Total frame decoded: " << n_total << std::endl;
std::cout << "info: avg decoding time per frame: " << 1000 / total_fps << " ms" << std::endl;
std::cout << "info: avg FPS: " << total_fps << std::endl;
std::cout << "info: Total pictures decoded: " << n_total_dec << std::endl;
std::cout << "info: Total frames output/displayed: " << n_total << std::endl;
std::cout << "info: avg decoding time per picture: " << 1000 / total_fps_dec << " ms" << std::endl;
std::cout << "info: avg decode FPS: " << total_fps_dec << std::endl;
std::cout << "info: avg output/display time per frame: " << 1000 / total_fps << " ms" << std::endl;
std::cout << "info: avg output/display FPS: " << total_fps << std::endl;
} catch (const std::exception &ex) {
std::cout << ex.what() << std::endl;
exit(1);