Samples - Clean up and bug fixes (#203)
* clean up samples * fixes error seen in videoDecodeMem app with big files
Cette révision appartient à :
@@ -159,6 +159,8 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
try {
|
||||
std::size_t found_file = input_file_path.find_last_of('/');
|
||||
std::cout << "info: Input file: " << input_file_path.substr(found_file + 1) << std::endl;
|
||||
VideoDemuxer demuxer(input_file_path.c_str());
|
||||
rocDecVideoCodec rocdec_codec_id = AVCodec2RocDecVideoCodec(demuxer.GetCodecID());
|
||||
RocVideoDecoder viddec(device_id, mem_type, rocdec_codec_id, b_force_zero_latency, p_crop_rect, b_extract_sei_messages);
|
||||
@@ -166,8 +168,6 @@ int main(int argc, char **argv) {
|
||||
std::string device_name, gcn_arch_name;
|
||||
int pci_bus_id, pci_domain_id, pci_device_id;
|
||||
|
||||
std::size_t found_file = input_file_path.find_last_of('/');
|
||||
std::cout << "info: Input file: " << input_file_path.substr(found_file + 1) << std::endl;
|
||||
viddec.GetDeviceinfo(device_name, gcn_arch_name, pci_bus_id, pci_domain_id, pci_device_id);
|
||||
std::cout << "info: Using GPU device " << device_id << " - " << device_name << "[" << gcn_arch_name << "] on PCI bus " <<
|
||||
std::setfill('0') << std::setw(2) << std::right << std::hex << pci_bus_id << ":" << std::setfill('0') << std::setw(2) <<
|
||||
@@ -211,9 +211,7 @@ int main(int argc, char **argv) {
|
||||
pkg_flags |= ROCDEC_PKT_ENDOFSTREAM;
|
||||
}
|
||||
n_frame_returned = viddec.DecodeFrame(pvideo, n_video_bytes, pkg_flags, pts);
|
||||
auto end_time = std::chrono::high_resolution_clock::now();
|
||||
auto time_per_frame = std::chrono::duration<double, std::milli>(end_time - start_time).count();
|
||||
total_dec_time += time_per_frame;
|
||||
|
||||
if (!n_frame && !viddec.GetOutputSurfaceInfo(&surf_info)) {
|
||||
std::cerr << "Error: Failed to get Output Surface Info!" << std::endl;
|
||||
break;
|
||||
@@ -229,6 +227,9 @@ int main(int argc, char **argv) {
|
||||
// release frame
|
||||
viddec.ReleaseFrame(pts);
|
||||
}
|
||||
auto end_time = std::chrono::high_resolution_clock::now();
|
||||
auto time_per_decode = std::chrono::duration<double, std::milli>(end_time - start_time).count();
|
||||
total_dec_time += time_per_decode;
|
||||
n_frame += n_frame_returned;
|
||||
} while (n_video_bytes);
|
||||
|
||||
|
||||
@@ -42,9 +42,17 @@ public:
|
||||
FileStreamProvider(const char *input_file_path) {
|
||||
fp_in_.open(input_file_path, std::ifstream::in | std::ifstream::binary);
|
||||
if (!fp_in_) {
|
||||
std::cout << "Unable to open input file: " << input_file_path << std::endl;
|
||||
return;
|
||||
std::cerr << "Unable to open input file: " << input_file_path << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
fp_in_.seekg (0, fp_in_.end);
|
||||
int length = fp_in_.tellg();
|
||||
fp_in_.seekg (0, fp_in_.beg);
|
||||
if (length > (100 * 1024 * 1024)) { // avioc_buffer_size = 100 * 1024 * 1024 in video_demuxer.h
|
||||
std::cerr << "This app supports only file sizes upto 100MB! Please use a smaller file." << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
}
|
||||
~FileStreamProvider() {
|
||||
fp_in_.close();
|
||||
|
||||
@@ -50,10 +50,10 @@ void DecProc(RocVideoDecoder *p_dec, VideoDemuxer *demuxer, int *pn_frame, doubl
|
||||
} while (n_video_bytes);
|
||||
|
||||
auto end_time = std::chrono::high_resolution_clock::now();
|
||||
auto time_per_frame = std::chrono::duration<double, std::milli>(end_time - start_time).count();
|
||||
auto time_per_decode = std::chrono::duration<double, std::milli>(end_time - start_time).count();
|
||||
|
||||
// Calculate average decoding time
|
||||
total_dec_time = time_per_frame;
|
||||
total_dec_time = time_per_decode;
|
||||
double average_decoding_time = total_dec_time / n_frame;
|
||||
double n_fps = 1000 / average_decoding_time;
|
||||
*pn_fps = n_fps;
|
||||
@@ -161,6 +161,10 @@ int main(int argc, char **argv) {
|
||||
int hip_vis_dev_count = 0;
|
||||
GetEnvVar("HIP_VISIBLE_DEVICES", hip_vis_dev_count);
|
||||
|
||||
std::size_t found_file = input_file_path.find_last_of('/');
|
||||
std::cout << "info: Input file: " << input_file_path.substr(found_file + 1) << std::endl;
|
||||
std::cout << "info: Number of threads: " << n_thread << std::endl;
|
||||
|
||||
for (int i = 0; i < n_thread; i++) {
|
||||
std::unique_ptr<VideoDemuxer> demuxer(new VideoDemuxer(input_file_path.c_str()));
|
||||
rocDecVideoCodec rocdec_codec_id = AVCodec2RocDecVideoCodec(demuxer->GetCodecID());
|
||||
@@ -189,9 +193,6 @@ int main(int argc, char **argv) {
|
||||
std::string device_name;
|
||||
int pci_bus_id, pci_domain_id, pci_device_id;
|
||||
|
||||
std::size_t found_file = input_file_path.find_last_of('/');
|
||||
std::cout << "info: Input file: " << input_file_path.substr(found_file + 1) << std::endl;
|
||||
std::cout << "info: Number of threads: " << n_thread << std::endl;
|
||||
for (int i = 0; i < n_thread; i++) {
|
||||
v_viddec[i]->GetDeviceinfo(device_name, gcn_arch_name, pci_bus_id, pci_domain_id, pci_device_id);
|
||||
std::cout << "info: stream " << i << " using GPU device " << v_device_id[i] << " - " << device_name << "[" << gcn_arch_name << "] on PCI bus " <<
|
||||
|
||||
@@ -233,7 +233,7 @@ AVFormatContext *VideoDemuxer::CreateFmtContextUtil(StreamProvider *stream_provi
|
||||
return nullptr;
|
||||
}
|
||||
uint8_t *avioc_buffer = nullptr;
|
||||
int avioc_buffer_size = 10 * 1024 * 1024;
|
||||
int avioc_buffer_size = 100 * 1024 * 1024;
|
||||
avioc_buffer = (uint8_t *)av_malloc(avioc_buffer_size);
|
||||
if (!avioc_buffer) {
|
||||
std::cerr << "ERROR: av_malloc failed!" << std::endl;
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur