* adds av1 to ctest

* add av1 support for batch sample

* add test to make test also

* path update for make test

* add function for codec support check

* add changes to batch sample

* addressign review comment

* modify all apps to check codec support
This commit is contained in:
Lakshmi Kumar
2024-07-26 14:09:58 -07:00
zatwierdzone przez GitHub
rodzic d0924490a8
commit e3b3fe9e8e
13 zmienionych plików z 173 dodań i 17 usunięć
+1 -1
Wyświetl plik
@@ -147,7 +147,7 @@ if(HIP_FOUND AND Libva_FOUND)
install(FILES utils/resize_kernels.cpp DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/utils COMPONENT dev)
install(FILES utils/resize_kernels.h DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/utils COMPONENT dev)
install(FILES utils/video_post_process.h DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/utils COMPONENT dev)
install(FILES data/videos/AMD_driving_virtual_20-H265.mp4 data/videos/AMD_driving_virtual_20-H264.mp4 DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/video COMPONENT dev)
install(FILES data/videos/AMD_driving_virtual_20-H265.mp4 data/videos/AMD_driving_virtual_20-H264.mp4 data/videos/AMD_driving_virtual_20-AV1.mp4 DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/video COMPONENT dev)
# install license information - {ROCM_PATH}/share/doc/rocdecode
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
install(FILES ${CPACK_RESOURCE_FILE_LICENSE} DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT runtime)
Plik binarny nie jest wyświetlany.
+78
Wyświetl plik
@@ -34,4 +34,82 @@ add_test(
--build-generator "${CMAKE_GENERATOR}"
--test-command "videodecode"
-i ${CMAKE_SOURCE_DIR}/data/videos/AMD_driving_virtual_20-H265.mp4
)
# videoDecodeMem
add_test(
NAME
video_decodeMem-H265
COMMAND
"${CMAKE_CTEST_COMMAND}"
--build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/videoDecodeMem"
"${CMAKE_CURRENT_SOURCE_DIR}/videoDecodeMem"
--build-generator "${CMAKE_GENERATOR}"
--test-command "videodecodemem"
-i ${CMAKE_SOURCE_DIR}/data/videos/AMD_driving_virtual_20-H265.mp4
)
# videoDecodePerf
add_test(
NAME
video_decodePerf-H265
COMMAND
"${CMAKE_CTEST_COMMAND}"
--build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/videoDecodePerf"
"${CMAKE_CURRENT_SOURCE_DIR}/videoDecodePerf"
--build-generator "${CMAKE_GENERATOR}"
--test-command "videodecodeperf"
-i ${CMAKE_SOURCE_DIR}/data/videos/AMD_driving_virtual_20-H265.mp4
)
# videoDecodeRGB
add_test(
NAME
video_decodeRGB-H265
COMMAND
"${CMAKE_CTEST_COMMAND}"
--build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/videoDecodeRGB"
"${CMAKE_CURRENT_SOURCE_DIR}/videoDecodeRGB"
--build-generator "${CMAKE_GENERATOR}"
--test-command "videodecodergb"
-i ${CMAKE_SOURCE_DIR}/data/videos/AMD_driving_virtual_20-H265.mp4 -of rgb
)
# videoDecode H264
add_test(
NAME
video_decode-H264
COMMAND
"${CMAKE_CTEST_COMMAND}"
--build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/videoDecode"
"${CMAKE_CURRENT_SOURCE_DIR}/videoDecode"
--build-generator "${CMAKE_GENERATOR}"
--test-command "videodecode"
-i ${CMAKE_SOURCE_DIR}/data/videos/AMD_driving_virtual_20-H264.mp4
)
# videoDecodeBatch
add_test(
NAME
video_decodeBatch
COMMAND
"${CMAKE_CTEST_COMMAND}"
--build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/videoDecodeBatch"
"${CMAKE_CURRENT_BINARY_DIR}/videoDecodeBatch"
--build-generator "${CMAKE_GENERATOR}"
--test-command "videodecodebatch"
-i ${CMAKE_SOURCE_DIR}/data/videos/ -t 2
)
# videoDecode AV1
add_test(
NAME
video_decode-AV1
COMMAND
"${CMAKE_CTEST_COMMAND}"
--build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/videoDecode"
"${CMAKE_CURRENT_BINARY_DIR}/videoDecode"
--build-generator "${CMAKE_GENERATOR}"
--test-command "videodecode"
-i ${CMAKE_SOURCE_DIR}/data/videos/AMD_driving_virtual_20-AV1.mp4
)
+4 -1
Wyświetl plik
@@ -207,7 +207,10 @@ int main(int argc, char **argv) {
VideoSeekContext video_seek_ctx;
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, disp_delay);
if(!viddec.CodecSupported(device_id, rocdec_codec_id, demuxer.GetBitDepth())) {
std::cerr << "GPU doesn't support codec!" << std::endl;
return 0;
}
std::string device_name, gcn_arch_name;
int pci_bus_id, pci_domain_id, pci_device_id;
@@ -296,7 +296,7 @@ int main(int argc, char **argv) {
std::cout << "info: Number of threads: " << n_thread << std::endl;
std::vector<std::unique_ptr<VideoDemuxer>> v_demuxer(num_files);
std::unique_ptr<RocVideoDecoder> dec_8bit_avc(nullptr), dec_8bit_hevc(nullptr), dec_10bit_hevc(nullptr);
std::unique_ptr<RocVideoDecoder> dec_8bit_avc(nullptr), dec_8bit_hevc(nullptr), dec_10bit_hevc(nullptr), dec_8bit_av1(nullptr), dec_10bit_av1(nullptr);
std::vector<std::unique_ptr<DecoderInfo>> v_dec_info;
ThreadPool thread_pool(n_thread);
@@ -342,13 +342,21 @@ int main(int argc, char **argv) {
if (v_dec_info[i]->rocdec_codec_id == rocDecVideoCodec_AVC) {
std::unique_ptr<RocVideoDecoder> dec_8bit_avc(new RocVideoDecoder(v_dec_info[i]->dec_device_id, mem_type, v_dec_info[i]->rocdec_codec_id, b_force_zero_latency, p_crop_rect));
v_dec_info[i]->viddec = std::move(dec_8bit_avc);
} else if (v_dec_info[i]->rocdec_codec_id == rocDecVideoCodec_HEVC){
} else if (v_dec_info[i]->rocdec_codec_id == rocDecVideoCodec_HEVC) {
std::unique_ptr<RocVideoDecoder> dec_8bit_hevc(new RocVideoDecoder(v_dec_info[i]->dec_device_id, mem_type, v_dec_info[i]->rocdec_codec_id, b_force_zero_latency, p_crop_rect));
v_dec_info[i]->viddec = std::move(dec_8bit_hevc);
} else if (v_dec_info[i]->rocdec_codec_id == rocDecVideoCodec_AV1) {
std::unique_ptr<RocVideoDecoder> dec_8bit_av1(new RocVideoDecoder(v_dec_info[i]->dec_device_id, mem_type, v_dec_info[i]->rocdec_codec_id, b_force_zero_latency, p_crop_rect));
v_dec_info[i]->viddec = std::move(dec_8bit_av1);
}
} else { //bit depth = 10bit
if (v_dec_info[i]->rocdec_codec_id == rocDecVideoCodec_HEVC) {
std::unique_ptr<RocVideoDecoder> dec_10bit_hevc(new RocVideoDecoder(v_dec_info[i]->dec_device_id, mem_type, v_dec_info[i]->rocdec_codec_id, b_force_zero_latency, p_crop_rect));
v_dec_info[i]->viddec = std::move(dec_10bit_hevc);
} else if (v_dec_info[i]->rocdec_codec_id == rocDecVideoCodec_AV1) {
std::unique_ptr<RocVideoDecoder> dec_10bit_av1(new RocVideoDecoder(v_dec_info[i]->dec_device_id, mem_type, v_dec_info[i]->rocdec_codec_id, b_force_zero_latency, p_crop_rect));
v_dec_info[i]->viddec = std::move(dec_10bit_av1);
}
} else {
std::unique_ptr<RocVideoDecoder> dec_10bit_hevc(new RocVideoDecoder(v_dec_info[i]->dec_device_id, mem_type, v_dec_info[i]->rocdec_codec_id, b_force_zero_latency, p_crop_rect));
v_dec_info[i]->viddec = std::move(dec_10bit_hevc);
}
v_dec_info[i]->viddec->GetDeviceinfo(device_name, gcn_arch_name, pci_bus_id, pci_domain_id, pci_device_id);
@@ -370,28 +378,40 @@ int main(int argc, char **argv) {
uint32_t bit_depth = v_demuxer[j]->GetBitDepth();
rocDecVideoCodec codec_id = AVCodec2RocDecVideoCodec(v_demuxer[j]->GetCodecID());
if (v_dec_info[thread_idx]->bit_depth != bit_depth || v_dec_info[thread_idx]->rocdec_codec_id != codec_id) {
if (bit_depth == 8) { // can be HEVC or H.264
if (bit_depth == 8) { // can be HEVC or H.264 or AV1
if (dec_8bit_avc == nullptr && codec_id == rocDecVideoCodec_AVC) {
std::unique_ptr<RocVideoDecoder> dec_8bit_avc(new RocVideoDecoder(v_dec_info[thread_idx]->dec_device_id, mem_type, codec_id, b_force_zero_latency, p_crop_rect));
v_dec_info[thread_idx]->viddec = std::move(dec_8bit_avc);
} else if (dec_8bit_hevc == nullptr && codec_id == rocDecVideoCodec_HEVC) {
std::unique_ptr<RocVideoDecoder> dec_8bit_hevc(new RocVideoDecoder(v_dec_info[thread_idx]->dec_device_id, mem_type, codec_id, b_force_zero_latency, p_crop_rect));
v_dec_info[thread_idx]->viddec = std::move(dec_8bit_hevc);
} else if (dec_8bit_av1 == nullptr && codec_id == rocDecVideoCodec_AV1) {
std::unique_ptr<RocVideoDecoder> dec_8bit_av1(new RocVideoDecoder(v_dec_info[thread_idx]->dec_device_id, mem_type, codec_id, b_force_zero_latency, p_crop_rect));
v_dec_info[thread_idx]->viddec = std::move(dec_8bit_av1);
} else {
if (codec_id == rocDecVideoCodec_AVC) {
v_dec_info[thread_idx]->viddec.swap(dec_8bit_avc);
} else {
} else if (codec_id == rocDecVideoCodec_HEVC) {
v_dec_info[thread_idx]->viddec.swap(dec_8bit_hevc);
} else {
v_dec_info[thread_idx]->viddec.swap(dec_8bit_av1);
}
}
v_dec_info[thread_idx]->bit_depth = bit_depth;
v_dec_info[thread_idx]->rocdec_codec_id = codec_id;
} else { // bit_depth = 10bit; only HEVC
if (dec_10bit_hevc == nullptr) {
} else { // bit_depth = 10bit; HEVC or AV1
if (dec_10bit_hevc == nullptr && codec_id == rocDecVideoCodec_HEVC) {
std::unique_ptr<RocVideoDecoder> dec_10bit_hevc(new RocVideoDecoder(v_dec_info[thread_idx]->dec_device_id, mem_type, codec_id, b_force_zero_latency, p_crop_rect));
v_dec_info[thread_idx]->viddec = std::move(dec_10bit_hevc);
} else if (dec_10bit_av1 == nullptr && codec_id == rocDecVideoCodec_AV1) {
std::unique_ptr<RocVideoDecoder> dec_10bit_av1(new RocVideoDecoder(v_dec_info[thread_idx]->dec_device_id, mem_type, codec_id, b_force_zero_latency, p_crop_rect));
v_dec_info[thread_idx]->viddec = std::move(dec_10bit_av1);
} else {
v_dec_info[thread_idx]->viddec.swap(dec_10bit_hevc);
if (codec_id == rocDecVideoCodec_HEVC) {
v_dec_info[thread_idx]->viddec.swap(dec_10bit_hevc);
} else {
v_dec_info[thread_idx]->viddec.swap(dec_10bit_av1);
}
}
v_dec_info[thread_idx]->bit_depth = bit_depth;
v_dec_info[thread_idx]->rocdec_codec_id = codec_id;
@@ -402,6 +422,10 @@ int main(int argc, char **argv) {
std::setfill('0') << std::setw(2) << std::right << std::hex << pci_bus_id << ":" << std::setfill('0') << std::setw(2) <<
std::right << std::hex << pci_domain_id << "." << pci_device_id << std::dec << std::endl;
}
if (!v_dec_info[thread_idx]->viddec->CodecSupported(v_dec_info[thread_idx]->dec_device_id, v_dec_info[thread_idx]->rocdec_codec_id, v_dec_info[thread_idx]->bit_depth)) {
std::cerr << "Codec not supported on GPU, skipping this file!" << std::endl;
continue;
}
thread_pool.ExecuteJob(std::bind(DecProc, v_dec_info[thread_idx]->viddec.get(), v_demuxer[j].get(), &v_frame[j], &v_fps[j], std::ref(v_dec_info[thread_idx]->decoding_complete), b_dump_output_frames, output_file_names[j], mem_type));
}
@@ -426,8 +450,8 @@ int main(int argc, char **argv) {
} catch (const std::exception &ex) {
std::cout << ex.what() << std::endl;
exit(1);
}
return 0;
}
@@ -179,6 +179,10 @@ int main(int argc, char **argv) {
VideoDemuxer demuxer(&stream_provider);
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);
if(!viddec.CodecSupported(device_id, rocdec_codec_id, demuxer.GetBitDepth())) {
std::cerr << "GPU doesn't support codec!" << std::endl;
return 0;
}
std::string device_name, gcn_arch_name;
int pci_bus_id, pci_domain_id, pci_device_id;
@@ -185,13 +185,16 @@ int main(int argc, char **argv) {
reconfig_params.p_reconfig_user_struct = &reconfig_user_struct;
}
if (use_reconfigure) {
if (!viddec) {
viddec = new RocVideoDecoder(device_id, file_data.mem_type, rocdec_codec_id, file_data.b_force_zero_latency, file_data.p_crop_rect, file_data.b_extract_sei_messages);
}
} else {
viddec = new RocVideoDecoder(device_id, file_data.mem_type, rocdec_codec_id, file_data.b_force_zero_latency, file_data.p_crop_rect, file_data.b_extract_sei_messages);
}
if(!viddec->CodecSupported(device_id, rocdec_codec_id, demuxer.GetBitDepth())) {
std::cerr << "Codec not supported on GPU, skipping this file!" << std::endl;
continue;
}
if (viddec && file_data.b_flush_last_frames) viddec->SetReconfigParams(&reconfig_params);
std::string device_name, gcn_arch_name;
int pci_bus_id, pci_domain_id, pci_device_id;
@@ -178,6 +178,10 @@ int main(int argc, char **argv) {
v_device_id[i] = i % hip_vis_dev_count;
}
std::unique_ptr<RocVideoDecoder> dec(new RocVideoDecoder(v_device_id[i], mem_type, rocdec_codec_id, b_force_zero_latency, p_crop_rect));
if (!dec->CodecSupported(v_device_id[i], rocdec_codec_id, demuxer->GetBitDepth())) {
std::cerr << "Codec not supported on GPU, skipping this file!" << std::endl;
continue;
}
v_demuxer.push_back(std::move(demuxer));
v_viddec.push_back(std::move(dec));
}
@@ -255,6 +255,10 @@ int main(int argc, char **argv) {
VideoDemuxer demuxer(input_file_path.c_str());
rocDecVideoCodec rocdec_codec_id = AVCodec2RocDecVideoCodec(demuxer.GetCodecID());
RocVideoDecoder viddec(device_id, mem_type, rocdec_codec_id, false, p_crop_rect);
if(!viddec.CodecSupported(device_id, rocdec_codec_id, demuxer.GetBitDepth())) {
std::cerr << "GPU doesn't support codec!" << std::endl;
return 0;
}
VideoPostProcess post_process;
std::string device_name, gcn_arch_name;
@@ -468,6 +468,10 @@ int main(int argc, char **argv) {
std::setfill('0') << std::setw(2) << std::right << std::hex << pci_bus_id << ":" << std::setfill('0') << std::setw(2) <<
std::right << std::hex << pci_domain_id << "." << pci_device_id << std::dec << std::endl;
}
if (!v_dec_info[thread_idx]->viddec->CodecSupported(v_dec_info[thread_idx]->dec_device_id, v_dec_info[thread_idx]->rocdec_codec_id, v_dec_info[thread_idx]->bit_depth)) {
std::cerr << "Codec not supported on GPU, skipping this file!" << std::endl;
continue;
}
thread_pool.ExecuteJob(std::bind(DecProc, v_dec_info[thread_idx]->viddec.get(), v_demuxer[j].get(), &v_frame[j], &v_fps[j], std::ref(v_dec_info[thread_idx]->decoding_complete),
seek_mode, b_dump_output_frames, seq_info, &output_seq_file_names[j*seq_info.batch_size], mem_type));
}
+14 -1
Wyświetl plik
@@ -76,7 +76,7 @@ add_test(
-i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4
)
# videoDecodeMem
# videoDecodePerf
add_test(
NAME
video_decodePerf-H265
@@ -127,3 +127,16 @@ add_test(
--test-command "videodecodebatch"
-i ${ROCM_PATH}/share/rocdecode/video/ -t 2
)
# videoDecode AV1
add_test(
NAME
video_decode-AV1
COMMAND
"${CMAKE_CTEST_COMMAND}"
--build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecode"
"${CMAKE_CURRENT_BINARY_DIR}/videoDecode"
--build-generator "${CMAKE_GENERATOR}"
--test-command "videodecode"
-i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-AV1.mp4
)
+14 -2
Wyświetl plik
@@ -285,9 +285,9 @@ int RocVideoDecoder::HandleVideoSequence(RocdecVideoFormat *p_video_format) {
decode_caps.chroma_format = p_video_format->chroma_format;
decode_caps.bit_depth_minus_8 = p_video_format->bit_depth_luma_minus8;
ROCDEC_API_CALL(rocDecGetDecoderCaps(&decode_caps));
rocDecGetDecoderCaps(&decode_caps);
if(!decode_caps.is_supported) {
ROCDEC_THROW("Rocdec:: Codec not supported on this GPU: ", ROCDEC_NOT_SUPPORTED);
ROCDEC_THROW("rocDecode:: Codec not supported on this GPU ", ROCDEC_NOT_SUPPORTED);
return 0;
}
if ((p_video_format->coded_width > decode_caps.max_width) || (p_video_format->coded_height > decode_caps.max_height)) {
@@ -1173,3 +1173,15 @@ std::chrono::_V2::system_clock::time_point RocVideoDecoder::StartTimer() {
double RocVideoDecoder::StopTimer(const std::chrono::_V2::system_clock::time_point &start_time) {
return std::chrono::duration<double, std::milli>(std::chrono::_V2::system_clock::now() - start_time).count();
}
bool RocVideoDecoder::CodecSupported(int device_id, rocDecVideoCodec codec_id, uint32_t bit_depth) {
RocdecDecodeCaps decode_caps;
decode_caps.device_id = device_id;
decode_caps.codec_type = codec_id;
decode_caps.chroma_format = rocDecVideoChromaFormat_420;
decode_caps.bit_depth_minus_8 = bit_depth - 8;
if(rocDecGetDecoderCaps(&decode_caps) != ROCDEC_SUCCESS) {
return false;
}
return true;
}
@@ -375,6 +375,13 @@ class RocVideoDecoder {
}
}
/**
* @brief Check if the given Video Codec is supported on the given GPU
*
* @return rocDecStatus
*/
bool CodecSupported(int device_id, rocDecVideoCodec codec_id, uint32_t bit_depth);
private:
/**
* @brief Callback function to be registered for getting a callback when decoding of sequence starts