ffmpeg decode utility class cleanup (#616)

* cleaned up ffmpeg decode utility class to use rocdecode host lib

* added changelog for the PR

* address review comments for FFMPEG dependancy in cmake

* Update CHANGELOG.md

Co-authored-by: spolifroni-amd <Sandra.Polifroni@amd.com>

* addressed review comments

* update version in Cmake

---------

Co-authored-by: spolifroni-amd <Sandra.Polifroni@amd.com>
이 커밋은 다음에 포함됨:
Rajy Rawther
2025-07-28 06:59:47 -07:00
커밋한 사람 GitHub
부모 91044fc832
커밋 3b280ac7c3
7개의 변경된 파일105개의 추가작업 그리고 484개의 파일을 삭제
+11 -5
파일 보기
@@ -82,24 +82,30 @@ if(HIP_FOUND AND FFMPEG_FOUND AND rocdecode_FOUND AND Threads_FOUND AND rocprofi
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} Threads::Threads)
# rocprofiler-register
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} rocprofiler-register::rocprofiler-register)
# sample app exe
# rocdecodehost
find_library(ROCDECODE_HOST_LIBRARY NAMES rocdecodehost HINTS ${ROCM_PATH}/lib)
list(APPEND SOURCES ${PROJECT_SOURCE_DIR} videodecode.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../../utils/rocvideodecode/roc_video_dec.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../../utils/ffmpegvideodecode/ffmpeg_video_dec.cpp)
# sample app exe
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${LINK_LIBRARY_LIST})
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} rocdecode::rocdecode)
if(ROCDECODE_HOST_LIBRARY)
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} ${ROCDECODE_HOST_LIBRARY})
target_compile_definitions(${PROJECT_NAME} PUBLIC ENABLE_HOST_DECODE=1)
else()
target_compile_definitions(${PROJECT_NAME} PUBLIC ENABLE_HOST_DECODE=0)
endif()
# FFMPEG multi-version support
if(_FFMPEG_AVCODEC_VERSION VERSION_LESS_EQUAL 58.134.100)
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_AVCODEC_GREATER_THAN_58_134=0)
else()
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_AVCODEC_GREATER_THAN_58_134=1)
endif()
target_link_libraries(${PROJECT_NAME} ${LINK_LIBRARY_LIST})
else()
message("-- ERROR!: ${PROJECT_NAME} excluded! please install all the dependencies and try again!")
if (NOT HIP_FOUND)
message(FATAL_ERROR "-- ERROR!: HIP Not Found! - please install ROCm and HIP!")
endif()
if (NOT FFMPEG_FOUND)
message(FATAL_ERROR "-- ERROR!: FFMPEG Not Found! - please install FFMPEG!")
endif()
if (NOT rocdecode_FOUND)
message(FATAL_ERROR "-- ERROR!: rocdecode Not Found! - please install rocdecode!")
endif()
+16 -4
파일 보기
@@ -42,6 +42,11 @@ THE SOFTWARE.
#include "ffmpeg_video_dec.h"
#include "common.h"
//hardcoding for host based decoder creation if demux is not available
#define DEFAULT_WIDTH 2912
#define DEFAULT_HEIGHT 1888
void ShowHelpAndExit(const char *option = NULL) {
std::cout << "Options:" << std::endl
<< "-i Input File Path - required" << std::endl
@@ -89,7 +94,7 @@ int main(int argc, char **argv) {
int seek_criteria = 0, seek_mode = 0;
bool b_use_ffmpeg_demuxer = true; // true by default to use FFMPEG demuxer. set to false to use the built-in bitstream reader.
// Parse command-line arguments
// Parse command-line arguments
if(argc <= 1) {
ShowHelpAndExit();
}
@@ -259,10 +264,16 @@ int main(int argc, char **argv) {
if (!backend) // gpu backend
viddec = new RocVideoDecoder(device_id, mem_type, rocdec_codec_id, b_force_zero_latency, p_crop_rect, b_extract_sei_messages, disp_delay);
else {
#if ENABLE_HOST_DECODE
std::cout << "info: RocDecode is using CPU backend!" << std::endl;
bool use_threading = false;
uint32_t max_width = b_use_ffmpeg_demuxer ? demuxer->GetWidth() : DEFAULT_WIDTH;
uint32_t max_height = b_use_ffmpeg_demuxer ? demuxer->GetHeight() : DEFAULT_HEIGHT;
if (mem_type == OUT_SURFACE_MEM_DEV_INTERNAL) mem_type = OUT_SURFACE_MEM_DEV_COPIED; // mem_type internal is not supported in this mode
viddec = new FFMpegVideoDecoder(device_id, mem_type, rocdec_codec_id, b_force_zero_latency, p_crop_rect, b_extract_sei_messages, disp_delay, true);
viddec = new FFMpegVideoDecoder(device_id, mem_type, rocdec_codec_id, b_force_zero_latency, p_crop_rect, b_extract_sei_messages, disp_delay, max_width, max_height);
#else
std::cout << "Error: RocDecode HOST library is not found and backend is not supported!" << std::endl;
return 0;
#endif
}
if(!viddec->CodecSupported(device_id, rocdec_codec_id, bit_depth)) {
@@ -346,7 +357,8 @@ int main(int argc, char **argv) {
}
n_frame_returned = viddec->DecodeFrame(pvideo, n_video_bytes, pkg_flags, pts, &decoded_pics);
if (!n_frame && !viddec->GetOutputSurfaceInfo(&surf_info)) {
// get output surface info after the first decoded frame
if (!n_frame && (n_frame_returned > 0) && !viddec->GetOutputSurfaceInfo(&surf_info)) {
std::cerr << "Error: Failed to get Output Surface Info!" << std::endl;
break;
}