FFMPEG - Updates (#33)

* FFMPEG - Updates

* Readme - Updates

* Sample - Install

* Install Sample Deps

* Samples - Updates

* Sample - Added missing header

[ROCm/rocdecode commit: d34d85027c]
This commit is contained in:
Kiriti Gowda
2023-11-06 08:51:47 -08:00
کامیت شده توسط GitHub
والد 295091beb8
کامیت 7f64bb0b61
5فایلهای تغییر یافته به همراه104 افزوده شده و 42 حذف شده
@@ -21,34 +21,61 @@
#
################################################################################
cmake_minimum_required (VERSION 3.0)
cmake_minimum_required (VERSION 3.5)
project(videodecode)
set(CMAKE_CXX_STANDARD 17)
set(ROCM_PATH /opt/rocm CACHE PATH "default ROCm installation path")
# ROCM Path
if(DEFINED ENV{ROCM_PATH})
set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Default ROCm installation path")
elseif(ROCM_PATH)
message("-- INFO:ROCM_PATH Set -- ${ROCM_PATH}")
else()
set(ROCM_PATH /opt/rocm CACHE PATH "Default ROCm installation path")
endif()
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH})
set(CMAKE_CXX_COMPILER ${ROCM_PATH}/llvm/bin/clang++)
set(DEFAULT_AMDGPU_TARGETS "gfx803;gfx900;gfx906;gfx908;gfx90a;gfx940;gfx1030;gfx1031;gfx1032;gfx1100")
set(AMDGPU_TARGETS "${DEFAULT_AMDGPU_TARGETS}" CACHE STRING "List of specific machine types for library to target")
find_package(HIP QUIET)
find_package(FFmpeg QUIET)
message("-- ${CMAKE_CURRENT_SOURCE_DIR}")
if(HIP_FOUND AND FFMPEG_FOUND)
include_directories (${ROCM_PATH}/include/rocdecode)
# find rocDecode
find_library(ROCDECODE_LIBRARY NAMES rocdecode HINTS {ROCM_PATH}/lib)
find_path(ROCDECODE_INCLUDE_DIR NAMES rocdecode.h PATHS /opt/rocm/include/rocdecode {ROCM_PATH}/include/rocdecode)
if(ROCDECODE_LIBRARY AND ROCDECODE_INCLUDE_DIR)
set(ROCDECODE_FOUND TRUE)
message("-- ${White}Using rocDecode -- \n\tLibraries:${ROCDECODE_LIBRARY} \n\tIncludes:${ROCDECODE_INCLUDE_DIR}${ColourReset}")
endif()
if(HIP_FOUND AND FFMPEG_FOUND AND ROCDECODE_FOUND)
# HIP
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} hip::device)
# FFMPEG
include_directories(${AVUTIL_INCLUDE_DIR} ${AVCODEC_INCLUDE_DIR}
${SWSCALE_INCLUDE_DIR} ${AVFORMAT_INCLUDE_DIR})
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} ${FFMPEG_LIBRARIES})
# rocDecode
include_directories (${ROCDECODE_INCLUDE_DIR})
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} ${ROCDECODE_LIBRARY})
list(APPEND SOURCES ${PROJECT_SOURCE_DIR} videodecode.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../../utils/rocvideodecode/roc_video_dec.cpp)
add_executable(${PROJECT_NAME} ${SOURCES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17")
target_link_libraries(${PROJECT_NAME} ${AVUTIL_LIBRARY} ${AVCODEC_LIBRARY} ${AVFORMAT_LIBRARY} hip::device rocdecode)
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 insatll FFMPEG!")
message(FATAL_ERROR "-- ERROR!: FFMPEG Not Found! - please install FFMPEG!")
endif()
if (NOT Libva_FOUND)
message(FATAL_ERROR "-- ERROR!: libva-dev Not Found - please install libva-dev!")
if (NOT ROCDECODE_FOUND)
message(FATAL_ERROR "-- ERROR!: rocDecode Not Found! - please install rocDecode!")
endif()
message("-- ERROR!: ${PROJECT_NAME} excluded! please install all the dependencies and try again!")
endif()
@@ -1,11 +1,36 @@
# Video Decode Sample
This sample illustrates the FFMPEG demuxer to get the individual frames which are then decoded on AMD hardware using VAAPI. This sample supports both YUV420 8-bit and 10-bit streams.
This sample illustrates the FFMPEG demuxer to get the individual frames which are then decoded on AMD hardware using VAAPI.
## Build and run the sample:
This sample supports both YUV420 8-bit and 10-bit streams.
## Prerequisites:
* Linux distribution
+ Ubuntu - `20.04` / `22.04`
* [ROCm supported hardware](https://rocm.docs.amd.com/en/latest/release/gpu_os_support.html)
* Install [ROCm 5.5 or later](https://rocmdocs.amd.com/en/latest/deploy/linux/installer/install.html) with `--usecase=graphics,rocm --no-32`
* rocDecode
* CMake `3.5` or later
* [FFMPEG](https://ffmpeg.org/about.html)
```
sudo apt install ffmpeg libavcodec-dev libavformat-dev libswscale-dev
```
## Build
```
mkdir build
cd build
cmake ..
cmake ../
make -j
./videodecode -i <input video file - required> -o <optional; output path to save decoded YUV frames> -d <GPU device ID, 0 for the first device, 1 for the second device, etc>
```
# Run
```
./videodecode -i <input video file [required]>
-o <output path to save decoded YUV frames [optional]>
-d <GPU device ID - 0:device 0 / 1:device 1/ ... [optional - default:0]>
```
@@ -21,6 +21,7 @@ THE SOFTWARE.
*/
#include <iostream>
#include <iomanip>
#include <unistd.h>
#include <vector>
#include <string>