Add 'projects/rocdecode/' from commit 'b0bab079403eda171f9056409fa96b0908f61073'
git-subtree-dir: projects/rocdecode git-subtree-mainline:5d609c1e57git-subtree-split:b0bab07940
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
_build/
|
||||
_doxygen/
|
||||
@@ -0,0 +1,24 @@
|
||||
.. meta::
|
||||
:description: rocDecode memory types
|
||||
:keywords: parse video, parse, decode, video decoder, video decoding, rocDecode, AMD, ROCm, memory types
|
||||
|
||||
********************************************************************
|
||||
rocDecode surface data memory locations
|
||||
********************************************************************
|
||||
|
||||
Surface data memory refers to the memory used by rocDecode for decoded frames and processing results. There are three locations where surface data memory can be stored: device memory, host memory, and internal memory.
|
||||
|
||||
Device memory refers to GPU memory. It's optimized for operations performed by the GPU, avoiding unnecessary memory transfers between the device and the host. It's used for standalone GPU processing and high-performance computing tasks where multiple operations are performed on the same data.
|
||||
|
||||
|
||||
Host memory refers to CPU memory. It's suitable for when the memory needs to be accessed or manipulated by CPU-side applications or when data needs to be transferred between systems.
|
||||
|
||||
Internal memory refers to intermediate GPU memory that is shared between operators. It's optimized for operator chaining within GPU workflows. It keeps data localized on the GPU so it can be accessed by subsequent operations, reducing latency and improving throughput. For example, in image processing pipelines, the results of a resizing operator can directly feed into a filtering operator without needing to copy data to the host between each step. This optimization is especially useful for large datasets and real-time applications.
|
||||
|
||||
|
||||
The ``OutputSurfaceMemoryType_enum`` enum type defines ``OUT_SURFACE_MEM_DEV_COPIED``, ``OUT_SURFACE_MEM_HOST_COPIED``, and ``OUT_SURFACE_MEM_DEV_INTERNAL``, for the three different types of memory locations. ``OUT_SURFACE_MEM_DEV_COPIED`` indicates device, or GPU, memory. ``OUT_SURFACE_MEM_HOST_COPIED`` indicates host, or CPU, memory. And ``OUT_SURFACE_MEM_DEV_INTERNAL`` indicates intermediate GPU memory.
|
||||
|
||||
``OUT_SURFACE_MEM_DEV_COPIED`` is not supported when the FFmpeg decoder is used.
|
||||
|
||||
A fourth enum, ``OUT_SURFACE_MEM_NOT_MAPPED``, is used only for performance purposes. The decoded frames are not available when this memory type is used.
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
.. meta::
|
||||
:description: Video decoding pipeline
|
||||
:keywords: video decoder, video decoding, rocDecode, AMD, ROCm
|
||||
|
||||
********************************************************************
|
||||
Video decoding pipeline
|
||||
********************************************************************
|
||||
|
||||
.. image:: ../data/VideoDecoderPipelinetest.png
|
||||
:alt: Video decoder pipeline test
|
||||
|
||||
There are three main components in rocDecode:
|
||||
|
||||
* Demuxer: Our demuxer is based on FFmpeg, a leading multimedia framework. For more information,
|
||||
refer to the `FFmpeg website <https://ffmpeg.org/about.html>`_.
|
||||
* Video parser APIs
|
||||
* Video decoder APIs
|
||||
|
||||
rocDecode follows this workflow:
|
||||
|
||||
1. The demuxer extracts a segment of video data and sends it to the video parser.
|
||||
2. The video parser extracts crucial information, such as picture and slice parameters, and sends it to
|
||||
the decoder APIs.
|
||||
3. The hardware receives the picture and slice parameters, then decodes a frame using Video
|
||||
Acceleration API (VA-API).
|
||||
4. This process repeats in a loop until all frames have been decoded.
|
||||
|
||||
Steps in decoding video content for applications (available in the rocDecode Toolkit):
|
||||
|
||||
1. Demultiplex the content into elementary stream packets (FFmpeg)
|
||||
2. Parse the demultiplexed packets into video frames for the decoder provided by rocDecode API.
|
||||
3. Decode compressed video frames into YUV frames using rocDecode API.
|
||||
4. Wait for the decoding to finish.
|
||||
5. Get the decoded YUV frame from amd-gpu context to HIP (using VAAPI-HIP interoperability under
|
||||
ROCm).
|
||||
6. Run HIP kernels in the mapped YUV frame. For example, format conversion, scaling, object detection,
|
||||
classification, and others.
|
||||
7. Release the decoded frame.
|
||||
|
||||
.. note::
|
||||
YUV is a color space that represents images using luminance (Y) for brightness and two chrominance
|
||||
components (U and V) for color information.
|
||||
|
||||
The preceding steps are demonstrated in the sample applications located in our
|
||||
`GitHub repository <https://github.com/ROCm/rocDecode/tree/develop/samples>`_ directory.
|
||||
@@ -0,0 +1,57 @@
|
||||
# MIT License
|
||||
|
||||
# Copyright (c) 2023 - 2026 Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file only contains a selection of the most common options. For a full
|
||||
# list see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
import re
|
||||
|
||||
from rocm_docs import ROCmDocs
|
||||
|
||||
with open('../CMakeLists.txt', encoding='utf-8') as f:
|
||||
match = re.search(r'.*\bset\(VERSION\s+\"?([0-9.]+)[^0-9.]+', f.read())
|
||||
if not match:
|
||||
raise ValueError("VERSION not found!")
|
||||
version_number = match[1]
|
||||
left_nav_title = f"rocDecode {version_number} documentation"
|
||||
|
||||
# for PDF output on Read the Docs
|
||||
project = "rocDecode documentation"
|
||||
author = "Advanced Micro Devices, Inc."
|
||||
copyright = "Copyright (c) 2024 - 2026 Advanced Micro Devices, Inc. All rights reserved."
|
||||
version = version_number
|
||||
release = version_number
|
||||
|
||||
external_toc_path = "./sphinx/_toc.yml"
|
||||
|
||||
docs_core = ROCmDocs(left_nav_title)
|
||||
docs_core.run_doxygen(doxygen_root="doxygen", doxygen_path="doxygen/xml")
|
||||
docs_core.enable_api_reference()
|
||||
docs_core.setup()
|
||||
|
||||
external_projects_current_project = "rocdecode"
|
||||
|
||||
for sphinx_var in ROCmDocs.SPHINX_VARS:
|
||||
globals()[sphinx_var] = getattr(docs_core, sphinx_var)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
@@ -0,0 +1,3 @@
|
||||
html/
|
||||
latex/
|
||||
xml/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,238 @@
|
||||
<doxygenlayout version="1.0">
|
||||
<!-- Generated by doxygen 1.9.7 -->
|
||||
<!-- Navigation index tabs for HTML output -->
|
||||
<navindex>
|
||||
<tab type="mainpage" visible="yes" title="Introduction"/>
|
||||
<tab type="pages" visible="yes" title="" intro=""/>
|
||||
<tab type="topics" visible="yes" title="rocDecode APIs" intro=""/>
|
||||
<tab type="namespaces" visible="yes" title="">
|
||||
<tab type="namespacelist" visible="yes" title="" intro=""/>
|
||||
<tab type="namespacemembers" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="concepts" visible="yes" title="">
|
||||
</tab>
|
||||
<tab type="interfaces" visible="yes" title="">
|
||||
<tab type="interfacelist" visible="yes" title="" intro=""/>
|
||||
<tab type="interfaceindex" visible="$ALPHABETICAL_INDEX" title=""/>
|
||||
<tab type="interfacehierarchy" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="classes" visible="no" title="">
|
||||
<tab type="classlist" visible="no" title="" intro=""/>
|
||||
<tab type="hierarchy" visible="no" title="" intro=""/>
|
||||
<tab type="classmembers" visible="no" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="structs" visible="no" title="">
|
||||
<tab type="structlist" visible="no" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="exceptions" visible="yes" title="">
|
||||
<tab type="exceptionlist" visible="yes" title="" intro=""/>
|
||||
<tab type="exceptionindex" visible="$ALPHABETICAL_INDEX" title=""/>
|
||||
<tab type="exceptionhierarchy" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="files" visible="yes" title="rocDecode Header Files">
|
||||
<tab type="filelist" visible="no" title="" intro=""/>
|
||||
<tab type="globals" visible="no" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="examples" visible="yes" title="" intro=""/>
|
||||
</navindex>
|
||||
|
||||
<!-- Layout definition for a class page -->
|
||||
<class>
|
||||
<briefdescription visible="yes"/>
|
||||
<includes visible="$SHOW_HEADERFILE"/>
|
||||
<inheritancegraph visible="$CLASS_GRAPH"/>
|
||||
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
|
||||
<memberdecl>
|
||||
<nestedclasses visible="yes" title=""/>
|
||||
<publictypes title=""/>
|
||||
<services title=""/>
|
||||
<interfaces title=""/>
|
||||
<publicslots title=""/>
|
||||
<signals title=""/>
|
||||
<publicmethods title=""/>
|
||||
<publicstaticmethods title=""/>
|
||||
<publicattributes title=""/>
|
||||
<publicstaticattributes title=""/>
|
||||
<protectedtypes title=""/>
|
||||
<protectedslots title=""/>
|
||||
<protectedmethods title=""/>
|
||||
<protectedstaticmethods title=""/>
|
||||
<protectedattributes title=""/>
|
||||
<protectedstaticattributes title=""/>
|
||||
<packagetypes title=""/>
|
||||
<packagemethods title=""/>
|
||||
<packagestaticmethods title=""/>
|
||||
<packageattributes title=""/>
|
||||
<packagestaticattributes title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
<privatetypes title=""/>
|
||||
<privateslots title=""/>
|
||||
<privatemethods title=""/>
|
||||
<privatestaticmethods title=""/>
|
||||
<privateattributes title=""/>
|
||||
<privatestaticattributes title=""/>
|
||||
<friends title=""/>
|
||||
<related title="" subtitle=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<services title=""/>
|
||||
<interfaces title=""/>
|
||||
<constructors title=""/>
|
||||
<functions title=""/>
|
||||
<related title=""/>
|
||||
<variables title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
</memberdef>
|
||||
<allmemberslink visible="yes"/>
|
||||
<usedfiles visible="$SHOW_USED_FILES"/>
|
||||
<authorsection visible="yes"/>
|
||||
</class>
|
||||
|
||||
<!-- Layout definition for a namespace page -->
|
||||
<namespace>
|
||||
<briefdescription visible="yes"/>
|
||||
<memberdecl>
|
||||
<nestednamespaces visible="yes" title=""/>
|
||||
<constantgroups visible="yes" title=""/>
|
||||
<interfaces visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<concepts visible="yes" title=""/>
|
||||
<structs visible="yes" title=""/>
|
||||
<exceptions visible="yes" title=""/>
|
||||
<typedefs title=""/>
|
||||
<sequences title=""/>
|
||||
<dictionaries title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<sequences title=""/>
|
||||
<dictionaries title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</namespace>
|
||||
|
||||
<!-- Layout definition for a concept page -->
|
||||
<concept>
|
||||
<briefdescription visible="yes"/>
|
||||
<includes visible="$SHOW_HEADERFILE"/>
|
||||
<definition visible="yes" title=""/>
|
||||
<detaileddescription title=""/>
|
||||
<authorsection visible="yes"/>
|
||||
</concept>
|
||||
|
||||
<!-- Layout definition for a file page -->
|
||||
<file>
|
||||
<briefdescription visible="yes"/>
|
||||
<includes visible="$SHOW_INCLUDE_FILES"/>
|
||||
<includegraph visible="$INCLUDE_GRAPH"/>
|
||||
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
|
||||
<sourcelink visible="yes"/>
|
||||
<memberdecl>
|
||||
<interfaces visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<structs visible="yes" title=""/>
|
||||
<exceptions visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<concepts visible="yes" title=""/>
|
||||
<constantgroups visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<sequences title=""/>
|
||||
<dictionaries title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<sequences title=""/>
|
||||
<dictionaries title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<authorsection/>
|
||||
</file>
|
||||
|
||||
<!-- Layout definition for a group page -->
|
||||
<group>
|
||||
<briefdescription visible="yes"/>
|
||||
<groupgraph visible="$GROUP_GRAPHS"/>
|
||||
<memberdecl>
|
||||
<nestedgroups visible="yes" title=""/>
|
||||
<dirs visible="yes" title=""/>
|
||||
<files visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<concepts visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<sequences title=""/>
|
||||
<dictionaries title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<pagedocs/>
|
||||
<inlineclasses title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<sequences title=""/>
|
||||
<dictionaries title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</group>
|
||||
|
||||
<!-- Layout definition for a directory page -->
|
||||
<directory>
|
||||
<briefdescription visible="yes"/>
|
||||
<directorygraph visible="yes"/>
|
||||
<memberdecl>
|
||||
<dirs visible="yes"/>
|
||||
<files visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
</directory>
|
||||
</doxygenlayout>
|
||||
@@ -0,0 +1,76 @@
|
||||
.. meta::
|
||||
:description: Using the rocDecode bitstream reader API
|
||||
:keywords: rocDecode, AMD, ROCm, bitstream decoder
|
||||
|
||||
********************************************************************
|
||||
Using the rocDecode bitstream reader APIs
|
||||
********************************************************************
|
||||
|
||||
The rocDecode bitstream reader APIs are a simplified set of APIs that provide a way to use and test the decoder without relying on FFMpeg. The bitstream reader APIs can be used to extract and parse coded picture data from an elementary video stream for the decoder to consume.
|
||||
|
||||
.. note::
|
||||
|
||||
The bitstream reader APIs can only be used with elementary video streams and IVF container files.
|
||||
|
||||
|
||||
The |videodecoderaw|_ sample demonstrates how to use the bitstream reader APIs, including how to create a bitstream reader and use it to extract picture data and pass it to the decoder:
|
||||
|
||||
.. code:: C++
|
||||
|
||||
RocdecBitstreamReader bs_reader = nullptr;
|
||||
rocDecVideoCodec rocdec_codec_id;
|
||||
int bit_depth;
|
||||
if (rocDecCreateBitstreamReader(&bs_reader, input_file_path.c_str()) != ROCDEC_SUCCESS) {
|
||||
std::cerr << "Failed to create the bitstream reader." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
[...]
|
||||
# Decode loop:
|
||||
do {
|
||||
if (rocDecGetBitstreamPicData(bs_reader, &pvideo, &n_video_bytes, &pts) != ROCDEC_SUCCESS) {
|
||||
std::cerr << "Failed to get picture data." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
[...]
|
||||
n_frame_returned = viddec.DecodeFrame(pvideo, n_video_bytes, pkg_flags, pts, &decoded_pics);
|
||||
}
|
||||
|
||||
|
||||
The ``videodecoderaw.cpp`` example also demonstrates how to use the bitstream reader APIs to obtain the bit depth and codec of a stream:
|
||||
|
||||
.. code:: C++
|
||||
|
||||
if (rocDecGetBitstreamCodecType(bs_reader, &rocdec_codec_id) != ROCDEC_SUCCESS) {
|
||||
std::cerr << "Failed to get stream codec type." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
[...]
|
||||
if (rocDecGetBitstreamBitDepth(bs_reader, &bit_depth) != ROCDEC_SUCCESS) {
|
||||
std::cerr << "Failed to get stream bit depth." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
``rocDecDestroyBitstreamReader`` must always be called to destroy the bitstream reader once processing is complete.
|
||||
|
||||
|
||||
.. |videodecode| replace:: ``videodecode.cpp``
|
||||
.. _videodecode: https://github.com/ROCm/rocDecode/tree/develop/samples/videoDecode/videodecode.cpp
|
||||
|
||||
.. |videodecoderaw| replace:: ``videodecoderaw.cpp``
|
||||
.. _videodecoderaw: https://github.com/ROCm/rocDecode/tree/develop/samples/videoDecodeRaw
|
||||
|
||||
.. |common| replace:: ``common.h``
|
||||
.. _common: https://github.com/ROCm/rocDecode/blob/develop/samples/common.h
|
||||
|
||||
.. |apifolder| replace:: ``api`` folder
|
||||
.. _apifolder: https://github.com/ROCm/rocDecode/tree/develop/api
|
||||
|
||||
.. |utilsfolder| replace:: ``utils`` folder
|
||||
.. _utilsfolder: https://github.com/ROCm/rocDecode/tree/develop/utils
|
||||
|
||||
|
||||
.. |reconfig_struct| replace:: ``ReconfigParams_t``
|
||||
.. _reconfig_struct: https://rocm.docs.amd.com/projects/rocDecode/en/latest/doxygen/html/structReconfigParams__t.html
|
||||
@@ -0,0 +1,96 @@
|
||||
.. meta::
|
||||
:description: Using rocDecode with the FFMpeg demultiplexer
|
||||
:keywords: parse video, parse, rocDecode, AMD, ROCm, FFmpeg demuxer
|
||||
|
||||
********************************************************************
|
||||
Using the rocDecode FFmpeg demultiplexer
|
||||
********************************************************************
|
||||
|
||||
The rocDecode FFmpeg demultiplexer (demuxer) extracts coded picture data from digital media files.
|
||||
|
||||
To use the rocDecode FFmpeg demuxer , import the ``video_demuxer.h`` header file.
|
||||
|
||||
.. code:: C++
|
||||
|
||||
#include "video_demuxer.h"
|
||||
|
||||
Instantiate a ``VideoDemuxer`` with the path to the video file. The ``GetCodecId`` and ``GetBitDepth`` functions can be used to obtain the video stream's codec ID and bit depth. The ``AVCodec2RocDecVideoCodec`` utility function converts the codec ID returned from the demuxer to its corresponding ``rocDecVideoCodec_enum`` value.
|
||||
|
||||
.. code:: C++
|
||||
|
||||
VideoDemuxer *demuxer;
|
||||
demuxer = new VideoDemuxer(input_file_path.c_str());
|
||||
rocdec_codec_id = AVCodec2RocDecVideoCodec(demuxer->GetCodecID());
|
||||
bit_depth = demuxer->GetBitDepth();
|
||||
|
||||
Call ``Demux`` to extract frame data from the stream:
|
||||
|
||||
.. code:: C++
|
||||
|
||||
demuxer->Demux(&pvideo, &n_video_bytes, &pts);
|
||||
|
||||
The demuxer will demultiplex frames sequentially starting at the beginning of the stream. To start the demultiplexing and decoding process from a different frame, create a seek context that specifies a seek criteria and a seek mode.
|
||||
|
||||
The seek criteria describes whether the demuxer needs to seek to a specific frame or seek to a specific timestamp. The seek mode indicates whether the demuxer should seek to the exact frame or to the previous keyframe.
|
||||
|
||||
The seek criteria is defined by the ``SeekCriteriaEnum`` enum and the seek mode is defined by the ``SeekModeEnum`` enum. Both the ``SeekCriteriaEnum`` and the ``SeekModeEnum`` are defined in ``video_demuxer.h``.
|
||||
|
||||
Set the seek criteria to ``SEEK_CRITERIA_FRAME_NUM`` to seek to a frame or to ``SEEK_CRITERIA_TIME_STAMP`` to seek to a timestamp. Set the seek mode to ``SEEK_MODE_EXACT_FRAME`` to seek to the exact frame or to ``SEEK_MODE_PREV_KEY_FRAME`` to seek to the previous keyframe.
|
||||
|
||||
From |videodecode|_:
|
||||
|
||||
.. code:: C++
|
||||
|
||||
VideoSeekContext video_seek_ctx;
|
||||
[...]
|
||||
do {
|
||||
[...]
|
||||
if (seek_criteria == 1 && first_frame) {
|
||||
// use VideoSeekContext class to seek to given frame number
|
||||
video_seek_ctx.seek_frame_ = seek_to_frame;
|
||||
video_seek_ctx.seek_crit_ = SEEK_CRITERIA_FRAME_NUM;
|
||||
video_seek_ctx.seek_mode_ = (seek_mode ? SEEK_MODE_EXACT_FRAME : SEEK_MODE_PREV_KEY_FRAME);
|
||||
demuxer->Seek(video_seek_ctx, &pvideo, &n_video_bytes);
|
||||
pts = video_seek_ctx.out_frame_pts_;
|
||||
std::cout << "info: Number of frames that were decoded during seek - " << video_seek_ctx.num_frames_decoded_ << std::endl;
|
||||
first_frame = false;
|
||||
} else if (seek_criteria == 2 && first_frame) {
|
||||
// use VideoSeekContext class to seek to given timestamp
|
||||
video_seek_ctx.seek_frame_ = seek_to_frame;
|
||||
video_seek_ctx.seek_crit_ = SEEK_CRITERIA_TIME_STAMP;
|
||||
video_seek_ctx.seek_mode_ = (seek_mode ? SEEK_MODE_EXACT_FRAME : SEEK_MODE_PREV_KEY_FRAME);
|
||||
demuxer->Seek(video_seek_ctx, &pvideo, &n_video_bytes);
|
||||
pts = video_seek_ctx.out_frame_pts_;
|
||||
std::cout << "info: Duration of frame found after seek - " << video_seek_ctx.out_frame_duration_ << " ms" << std::endl;
|
||||
first_frame = false;
|
||||
} else {
|
||||
demuxer->Demux(&pvideo, &n_video_bytes, &pts);
|
||||
}
|
||||
[...]
|
||||
} while (n_video_bytes);
|
||||
|
||||
Delete the demuxer once demultiplexing is complete.
|
||||
|
||||
.. code:: C++
|
||||
|
||||
delete demuxer;
|
||||
|
||||
.. |videodecode| replace:: ``videodecode.cpp``
|
||||
.. _videodecode: https://github.com/ROCm/rocDecode/tree/develop/samples/videoDecode/videodecode.cpp
|
||||
|
||||
.. |videodecoderaw| replace:: ``videodecoderaw.cpp``
|
||||
.. _videodecoderaw: https://github.com/ROCm/rocDecode/tree/develop/samples/videoDecodeRaw
|
||||
|
||||
.. |common| replace:: ``common.h``
|
||||
.. _common: https://github.com/ROCm/rocDecode/blob/develop/samples/common.h
|
||||
|
||||
.. |apifolder| replace:: ``api`` folder
|
||||
.. _apifolder: https://github.com/ROCm/rocDecode/tree/develop/api
|
||||
|
||||
.. |utilsfolder| replace:: ``utils`` folder
|
||||
.. _utilsfolder: https://github.com/ROCm/rocDecode/tree/develop/utils
|
||||
|
||||
|
||||
.. |reconfig_struct| replace:: ``ReconfigParams_t``
|
||||
.. _reconfig_struct: https://rocm.docs.amd.com/projects/rocDecode/en/latest/doxygen/html/structReconfigParams__t.html
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
.. meta::
|
||||
:description: Using the rocDecode core API
|
||||
:keywords: rocDecode, AMD, ROCm, core API
|
||||
|
||||
********************************************************************
|
||||
Using the rocdecdecode example
|
||||
********************************************************************
|
||||
|
||||
rocDecode provides four core APIs exposed in the header files in the |apifolder|_ directory:
|
||||
|
||||
| The rocDecode parser API, exposed in ``rocparser.h``.
|
||||
| The hardware decoder API, exposed in ``rocdecode.h``.
|
||||
| The software decoder API, exposed in ``rocdecode_host.h``.
|
||||
| The bitstream reader API, exposed in ``roc_bitstream_reader.h``.
|
||||
|
||||
The |rocdecdecode|_ sample demonstrates how to use the rocDecode core APIs in an application. It shows how to use the parser and both the hardware and software decoders. For information on how to use the bitstream reader API, see :doc:`Using the rocDecode bitstream reader API <./using-rocDecode-bitstream>`.
|
||||
|
||||
The sample decodes raw elementary video frame files as input and produces individually decoded frames in YUV format as output. The input can be one individual frame file or multiple frames from one or more video files. The individual frame files must be numbered in ascending order of frames.
|
||||
|
||||
``rocdecdecode.cpp`` takes the following arguments:
|
||||
|
||||
.. list-table::
|
||||
:widths: 10 60 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Argument
|
||||
- Description
|
||||
- Note
|
||||
|
||||
* - ``-i``
|
||||
- Path to the input video frame file or to frame folder.
|
||||
- Required.
|
||||
|
||||
* - ``-o``
|
||||
- Output path. Saves the decoded YUV frames to this folder.
|
||||
- Optional. Decoded frames aren't saved by default.
|
||||
|
||||
* - ``-d``
|
||||
- GPU device ID. Set it to 0 for the first device, 1 for the second device, 2 for the third device, and so on for each subsequent device.
|
||||
- Optional. Set to 0 by default.
|
||||
|
||||
* - ``-b``
|
||||
- Backend. Set it to 0 to use the hardware decoder on the GPU or to 1 to use the software decoder on the CPU.
|
||||
- Optional. Set to 0 by default.
|
||||
|
||||
|
||||
* - ``-c``
|
||||
- Codec. Set to 0 for HEVC, 1 for H264, 2 for AV1, 4 for VP9, 5 for VP8, or 6 for MJPEG.
|
||||
- Optional. Set to 0 by default.
|
||||
|
||||
* - ``-n``
|
||||
- Number of iterations for performance evaluation.
|
||||
- Optional. Set to 1 by default.
|
||||
|
||||
* - ``-m``
|
||||
- The output surface memory type. The memory type where the surface data, such as the decoded frames, resides. Set this to 0 for intermediate GPU memory, to 1 for GPU memory, and to 2 for CPU memory. See :doc:`Surface data memory locations <../conceptual/rocDecode-memory-types>` for more information.
|
||||
- Optional. Set to 0 by default.
|
||||
|
||||
The ``DecoderInfo`` struct defined in the sample is used to store user-supplied parameters as well as the decoder and parser handles.
|
||||
|
||||
The memory type and the type of decoder is set by the specified backend. If the GPU (device) backend is selected, both a parser and a hardware decoder are created. If the CPU (host) backend is selected, only a software decoder is created:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
DecoderInfo dec_info;
|
||||
[...]
|
||||
int main(int argc, char** argv) {
|
||||
[...]
|
||||
dec_info.rocdec_codec_id = CodecTypeToRocDecVideoCodec(codec_type);
|
||||
dec_info.dec_device_id = device_id;
|
||||
dec_info.mem_type = (!backend) ? OUT_SURFACE_MEM_DEV_INTERNAL : OUT_SURFACE_MEM_HOST;
|
||||
init();
|
||||
if (backend == DECODER_BACKEND_DEVICE) {
|
||||
create_parser(dec_info);
|
||||
create_decoder(dec_info);
|
||||
} else {
|
||||
create_decoder_host(dec_info);
|
||||
}
|
||||
[...]
|
||||
}
|
||||
|
||||
All applications need to register the ``pfn_sequence_callback`` and ``pfn_display_picture`` callbacks. Applications that use the parser must also register the ``pfn_decode_picture`` callback.
|
||||
|
||||
When the GPU backend is selected, these callbacks are registered in the ``create_parser()`` function. ``create_parser`` also creates the parser using ``rocDecCreateVideoParser()``:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
void create_parser(DecoderInfo& dec_info) {
|
||||
RocdecParserParams params = {};
|
||||
params.codec_type = dec_info.rocdec_codec_id;
|
||||
params.max_num_decode_surfaces = 6;
|
||||
params.max_display_delay = 1;
|
||||
params.user_data = &dec_info;
|
||||
params.pfn_sequence_callback = handle_video_sequence;
|
||||
params.pfn_decode_picture = handle_picture_decode;
|
||||
params.pfn_display_picture = handle_picture_display;
|
||||
CHECK(rocDecCreateVideoParser(&dec_info.parser, ¶ms));
|
||||
}
|
||||
|
||||
The ``create_decoder()`` function sets the decoder parameters and passes them to ``rocDecCreateDecoder()`` to create the hardware decoder:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
void create_decoder(DecoderInfo& dec_info) {
|
||||
RocDecoderCreateInfo create_info = {};
|
||||
create_info.codec_type = dec_info.rocdec_codec_id; // user specified codec_type for raw files
|
||||
[...]
|
||||
CHECK(rocDecCreateDecoder(&dec_info.decoder, &create_info));
|
||||
}
|
||||
|
||||
The ``create_decoder_host()`` function performs the same actions as ``create_decoder()``, but uses ``rocDecCreateDecoderHost()`` to create a software decoder. Because the parser isn't used with the software decoder, and because the software decoder uses different function calls, the callbacks for the software decoder are registered in ``create_decoder_host()``:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
void create_decoder_host(DecoderInfo& dec_info) {
|
||||
RocDecoderHostCreateInfo create_info = {};
|
||||
create_info.codec_type = dec_info.rocdec_codec_id;
|
||||
[...]
|
||||
create_info.pfn_sequence_callback = handle_video_sequence_host;
|
||||
create_info.pfn_display_picture = handle_picture_display_host;
|
||||
CHECK(rocDecCreateDecoderHost(&dec_info.decoder, &create_info));
|
||||
dec_info.backend = DECODER_BACKEND_HOST;
|
||||
}
|
||||
|
||||
After the decoder and parser have been created, ``decode_frames`` is called.
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
[...]
|
||||
dec_info.dump_decoded_frames = dump_output_frames;
|
||||
auto input_frames = read_frames(input_file_names);
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
for (int i = 0; i < num_iterations; i++) {
|
||||
decode_frames(dec_info, input_frames);
|
||||
}
|
||||
[...]
|
||||
}
|
||||
|
||||
``decode_frames`` calls ``rocDecParseVideoData()`` or ``rocDecDecodeFrameHost()``, depending on the backend, to parse and decode the frames:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
void decode_frames(DecoderInfo& dec_info, const std::vector<std::vector<uint8_t>>& frames) {
|
||||
// gpu backend using VCN
|
||||
if (dec_info.backend == DECODER_BACKEND_DEVICE) {
|
||||
for (int i=0; i < static_cast<int>(frames.size()); ++i) {
|
||||
RocdecSourceDataPacket packet = {};
|
||||
packet.payload_size = frames[i].size();
|
||||
packet.payload = frames[i].data();
|
||||
if (i == static_cast<int>(frames.size() - 1)) {
|
||||
packet.flags = ROCDEC_PKT_ENDOFPICTURE; // mark end_of_picture flag for last frame
|
||||
}
|
||||
CHECK(rocDecParseVideoData(dec_info.parser, &packet));
|
||||
}
|
||||
} else if (dec_info.backend == DECODER_BACKEND_HOST) {
|
||||
for (int i=0; i < static_cast<int>(frames.size()); ++i) {
|
||||
RocdecPicParamsHost pic_params = {};
|
||||
pic_params.bitstream_data_len = frames[i].size();
|
||||
pic_params.bitstream_data = frames[i].data();
|
||||
if (i == static_cast<int>(frames.size() - 1)) {
|
||||
pic_params.flags = ROCDEC_PKT_ENDOFPICTURE; // mark end_of_picture flag for last frame
|
||||
}
|
||||
CHECK(rocDecDecodeFrameHost(dec_info.decoder, &pic_params));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
The registered callbacks are triggered during the calls to ``rocDecParseVideoData()`` and ``rocDecDecodeFrameHost()``.
|
||||
|
||||
``pfn_decode_picture`` is triggered when a new frame is ready to be decoded, ``pfn_sequence_callback`` is triggered when a new sequence header is encountered, and ``pfn_display_picture`` is triggered when a frame has finished being decoded.
|
||||
|
||||
``pfn_decode_picture`` needs to call ``rocDecDecodeFrame()`` or ``rocDecodeFrameHost()``, depending on the specified backend, to decode a frame.
|
||||
|
||||
In ``rocdecdecode.cpp``, ``pfn_decode_picture`` calls ``handle_picture_decode()`` or ``handle_picture_decode_host()``, depending on the specified backend:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
int ROCDECAPI handle_picture_decode(void* user_data, RocdecPicParams* params) {
|
||||
DecoderInfo *p_dec_info = static_cast<DecoderInfo *>(user_data);
|
||||
CHECK(rocDecDecodeFrame(p_dec_info->decoder, params));
|
||||
return 1;
|
||||
}
|
||||
|
||||
``pfn_sequence_callback`` is triggered when a format change occurs or when a new sequence header is encountered. When this happens, the decoder is reconfigured to handle the new sequence or format.
|
||||
|
||||
``pfn_sequence_callback`` needs to call ``rocDecReconfigureDecoder()`` or ``rocDecReconfigureDecoderHost()`` depending on the backend, to reconfigure the decoder.
|
||||
|
||||
In the ``rocdecdecode.cpp`` sample, ``pfn_sequence_callback`` calls ``handle_video_sequence()`` or ``handle_video_sequence_host()``, depending on the specified backend:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
int ROCDECAPI handle_video_sequence(void* user_data, RocdecVideoFormat* format) {
|
||||
DecoderInfo *p_dec_info = static_cast<DecoderInfo *>(user_data);
|
||||
[...]
|
||||
RocdecReconfigureDecoderInfo reconfig_params = {};
|
||||
reconfig_params.width = format->coded_width;
|
||||
reconfig_params.height = format->coded_height;
|
||||
reconfig_params.bit_depth_minus_8 = bitdepth_minus_8;
|
||||
reconfig_params.num_decode_surfaces = format->min_num_decode_surfaces;
|
||||
reconfig_params.target_width = target_width;
|
||||
reconfig_params.target_height = target_height;
|
||||
reconfig_params.display_rect.left = format->display_area.left;
|
||||
reconfig_params.display_rect.right = format->display_area.right;
|
||||
reconfig_params.display_rect.top = format->display_area.top;
|
||||
reconfig_params.display_rect.bottom = format->display_area.bottom;
|
||||
CHECK(rocDecReconfigureDecoder(p_dec_info->decoder, &reconfig_params));
|
||||
[...]
|
||||
return 1;
|
||||
}
|
||||
|
||||
``pfn_display_picture`` is triggered when a frame has been decoded. It needs to call ``rocDecGetVideoFrame()`` or ``rocDecGetVideoFrameHost()``, depending on the specified backend.
|
||||
|
||||
``rocDecGetVideoFrame()`` and ``rocDecGetVideoFrameHost()`` map the video ID of the decoded frame to HIP. Calls to both these functions block until the frame is decoded and the memory mapping is complete. They return the HIP device pointer or the host memory pointer, depending on the backend specified, as well as information about the :doc:`output surface <../conceptual/rocDecode-memory-types>`.
|
||||
|
||||
``pfn_display_picture`` calls ``handle_picture_display()`` or ``handle_handle_picture_display_host()``, depending on the specified backend, and saves the frames to file if the ``rocdecdecode`` was run with the ``-o`` option:
|
||||
|
||||
From the ``rocdecdecode.cpp`` sample:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
int ROCDECAPI handle_picture_display(void* user_data, RocdecParserDispInfo* disp_info) {
|
||||
DecoderInfo *p_dec_info = static_cast<DecoderInfo *>(user_data);
|
||||
RocdecProcParams params = {};
|
||||
params.progressive_frame = disp_info->progressive_frame;
|
||||
params.top_field_first = disp_info->top_field_first;
|
||||
void* dev_mem_ptr[3] = { 0 };
|
||||
uint32_t pitch[3] = { 0 };
|
||||
CHECK(rocDecGetVideoFrame(p_dec_info->decoder, disp_info->picture_index, dev_mem_ptr, pitch, ¶ms));
|
||||
if (p_dec_info->dump_decoded_frames) {
|
||||
save_frame_to_file(p_dec_info, dev_mem_ptr, pitch);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Once decoding is complete, ``rocDecDestroyVideoParser()`` needs to be called to destroy the parser, and either ``rocDecDestroyDecoderHost()`` or ``rocDecDestroyDecoder()`` needs to be called to destroy the decoder.
|
||||
|
||||
.. |rocdecdecode| replace:: ``rocdecdecode``
|
||||
.. _rocdecdecode: https://github.com/ROCm/rocDecode/tree/develop/samples/rocdecDecode/README.md
|
||||
|
||||
.. |apifolder| replace:: ``api/rocdecode/``
|
||||
.. _apifolder: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode
|
||||
|
||||
.. |utilsfolder| replace:: ``utils`` folder
|
||||
.. _utilsfolder: https://github.com/ROCm/rocDecode/tree/develop/utils
|
||||
@@ -0,0 +1,146 @@
|
||||
.. meta::
|
||||
:description: UUsing the rocDecode RocVideoDecoder
|
||||
:keywords: parse video, parse, decode, video decoder, video decoding, rocDecode, AMD, ROCm, RocVideoDecoder
|
||||
|
||||
********************************************************************
|
||||
Using the rocDecode RocVideoDecoder
|
||||
********************************************************************
|
||||
|
||||
rocDecode provides two methods fpr decoding a video stream: using the rocDecode RocVideoDecoder on the GPU or using the FFmpeg decoder on the CPU.
|
||||
|
||||
|
||||
This topic covers how to decode a video stream using the RocVideoDecoder class in |roc_video_dec|_. The RocVideoDecode class provides high-level calls to the core APIs in the |apifolder|_ of the rocDecode GitHub repository. For information about the core APIs, see :doc:`Using the rocDecode core APIs <../reference/rocDecode-core-APIs>`.
|
||||
|
||||
The RocVideoDecoder takes a demultiplexed coded picture as input. The picture can be demultiplexed from a video stream using the :doc:`FFmpeg demultiplexer <./using-rocDecode-ffmpeg>`.
|
||||
|
||||
To use the rocDecode video decoder, import the ``roc_video_dec.h`` header file and instantiate ``RocVideoDecoder``.
|
||||
|
||||
The ``RocVideoDecoder`` constructor takes the following parameters:
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 70 15
|
||||
:header-rows: 1
|
||||
|
||||
* - Parameter
|
||||
- Description
|
||||
- Default
|
||||
|
||||
* - ``device_id``
|
||||
- ``int`` |br| |br| The GPU device ID. |br| |br| Set it to 0 for the first device, 1 for the second device, 2 for the third device, and so on for each subsequent device.
|
||||
- 0
|
||||
|
||||
* - ``out_mem_type``
|
||||
- |OutputSurfaceMemoryType|_ |br| |br| The memory type where the surface data, such as the decoded frames, resides. |br| |br| 0: ``OUT_SURFACE_MEM_DEV_INTERNAL``. The surface data is stored internally on memory shared by the GPU and CPU. |br| |br| 1: ``OUT_SURFACE_MEM_DEV_COPIED``. The surface data resides on the GPU. |br| |br| 2: ``OUT_SURFACE_MEM_HOST_COPIED``. The surface data resides on the CPU. |br| |br| See :doc:`Surface data memory locations <../conceptual/rocDecode-memory-types>` for more information.
|
||||
- 0, OUT_SURFACE_MEM_DEV_INTERNAL
|
||||
|
||||
* - ``codec``
|
||||
- |rocDecVideoCodec|_ |br| |br| The video file's codec ID converted to ``rocDecVideoCodec`` using ``AVCodec2RocDecVideoCodec``.
|
||||
- No default, a value must be provided
|
||||
|
||||
* - ``force_zero_latency``
|
||||
- ``bool`` |br| |br| Set to ``true`` to flush decoded frames for immediate display.
|
||||
- ``false``
|
||||
|
||||
* - ``p_crop_rect``
|
||||
- ``const Rect *`` |br| |br| The rectangle to use for cropping.
|
||||
- No cropping
|
||||
|
||||
* - ``extract_user_SEI_Message``
|
||||
- ``bool`` |br| |br| Set to ``true`` to extract Supplemental Enhancement Information (SEI) from the video stream.
|
||||
- ``false``, no SEI will be extracted
|
||||
|
||||
* - ``disp_delay``
|
||||
- ``uint32_t`` |br| |br| Delay the display by this number of frames.
|
||||
- 0, no delay in displaying the frames
|
||||
|
||||
* - ``max_width``
|
||||
- ``int`` |br| |br| Max width.
|
||||
- 0
|
||||
|
||||
* - ``max_height``
|
||||
- ``int`` |br| |br| Max height.
|
||||
- 0
|
||||
|
||||
* - ``clk_rate``
|
||||
- ``uint32_t`` |br| |br| Clock rate.
|
||||
- 1000
|
||||
|
||||
|
||||
.. |br| raw:: html
|
||||
|
||||
</br>
|
||||
|
||||
|
||||
For example, from |videodecode|_:
|
||||
|
||||
.. code:: C++
|
||||
|
||||
RocVideoDecoder viddec(device_id, mem_type, rocdec_codec_id, b_force_zero_latency, p_crop_rect, b_extract_sei_messages, disp_delay);
|
||||
|
||||
``RocVideoDecoder`` will create a parser and a decoder, and initialize HIP on the device.
|
||||
|
||||
The same decoder instance is reused when there's a change to the video resolution without a change in the codec.
|
||||
|
||||
The decoder maintains a pool of frame buffers for decoded images that haven't yet been displayed or processed. When the video stream resolution changes, the existing frame buffers in the buffer pool are deleted. The decoder is then reconfigured for the new resolution and new buffers are created.
|
||||
|
||||
To prevent the remaining frames in the buffers from being deleted along with the buffers, a callback function can be defined to consume the remaining frames.
|
||||
|
||||
The |reconfig_struct|_ struct stores information on how to handle the reconfiguration. A callback, a user-defined flush mode, and a user-defined struct are passed to ``ReconfigParams_t``. The reconfiguration parameters are then passed to the decoder using ``SetReconfigParams``.
|
||||
|
||||
The reconfiguration parameters need to be defined prior to entering the decoding loop. For example, the reconfiguration structs are defined in |common|_ in the rocDecode samples and then used in ``videodecode.cpp``
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
typedef enum ReconfigFlushMode_enum {
|
||||
RECONFIG_FLUSH_MODE_NONE = 0x0, /**< Just flush to get the frame count */
|
||||
RECONFIG_FLUSH_MODE_DUMP_TO_FILE = 0x1, /**< The remaining frames will be dumped to file in this mode */
|
||||
RECONFIG_FLUSH_MODE_CALCULATE_MD5 = (0x1 << 1), /**< Calculate the MD5 of the flushed frames */
|
||||
} ReconfigFlushMode;
|
||||
|
||||
typedef struct ReconfigDumpFileStruct_t {
|
||||
bool b_dump_frames_to_file;
|
||||
std::string output_file_name;
|
||||
void *md5_generator_handle;
|
||||
} ReconfigDumpFileStruct;
|
||||
|
||||
reconfig_params.p_fn_reconfigure_flush = ReconfigureFlushCallback;
|
||||
reconfig_user_struct.b_dump_frames_to_file = dump_output_frames;
|
||||
reconfig_user_struct.output_file_name = output_file_path;
|
||||
reconfig_params.reconfig_flush_mode = RECONFIG_FLUSH_MODE_NONE;
|
||||
if (dump_output_frames) {
|
||||
reconfig_params.reconfig_flush_mode |= RECONFIG_FLUSH_MODE_DUMP_TO_FILE;
|
||||
}
|
||||
if (b_generate_md5) {
|
||||
reconfig_params.reconfig_flush_mode |= RECONFIG_FLUSH_MODE_CALCULATE_MD5;
|
||||
}
|
||||
reconfig_params.p_reconfig_user_struct = &reconfig_user_struct;
|
||||
viddec.SetReconfigParams(&reconfig_params);
|
||||
|
||||
In the decode loop, the demultiplexed coded picture is passed to ``DecodeFrame``. Once the frame is decoded and processed, it is released with ``ReleaseFrame``.
|
||||
|
||||
.. |videodecode| replace:: ``videodecode.cpp``
|
||||
.. _videodecode: https://github.com/ROCm/rocDecode/tree/develop/samples/videoDecode/videodecode.cpp
|
||||
|
||||
.. |videodecoderaw| replace:: ``videodecoderaw.cpp``
|
||||
.. _videodecoderaw: https://github.com/ROCm/rocDecode/tree/develop/samples/videoDecodeRaw
|
||||
|
||||
.. |common| replace:: ``common.h``
|
||||
.. _common: https://github.com/ROCm/rocDecode/blob/develop/samples/common.h
|
||||
|
||||
.. |apifolder| replace:: ``api`` folder
|
||||
.. _apifolder: https://github.com/ROCm/rocDecode/tree/develop/api
|
||||
|
||||
.. |utilsfolder| replace:: ``utils`` folder
|
||||
.. _utilsfolder: https://github.com/ROCm/rocDecode/tree/develop/utils
|
||||
|
||||
.. |roc_video_dec| replace:: ``roc_video_dec.h``
|
||||
.. _roc_video_dec: https://github.com/ROCm/rocDecode/tree/develop/utils/rocvideodecode/roc_video_dec.h
|
||||
|
||||
.. |reconfig_struct| replace:: ``ReconfigParams_t``
|
||||
.. _reconfig_struct: https://rocm.docs.amd.com/projects/rocDecode/en/latest/doxygen/html/structReconfigParams__t.html
|
||||
|
||||
.. |OutputSurfaceMemoryType| replace:: ``OutputSurfaceMemoryType``
|
||||
.. _OutputSurfaceMemoryType: https://rocm.docs.amd.com/projects/rocDecode/en/latest/doxygen/html/roc__video__dec_8h.html
|
||||
|
||||
.. |rocDecVideoCodec| replace:: ``rocDecVideoCodec``
|
||||
.. _rocDecVideoCodec: https://rocm.docs.amd.com/projects/rocDecode/en/latest/doxygen/html/rocdecode_8h.html
|
||||
@@ -0,0 +1,257 @@
|
||||
.. meta::
|
||||
:description: Understanding the rocDecode videodecode sample
|
||||
:keywords: parse video, parse, decode, video decoder, video decoding, rocDecode, AMD, ROCm, sample, walkthrough
|
||||
|
||||
********************************************************************
|
||||
Understanding the rocDecode videodecode sample
|
||||
********************************************************************
|
||||
|
||||
The |videodecode|_ sample in the rocDecode GitHub repository |samplefolder|_ demonstrates how to decode a video stream.
|
||||
|
||||
As with the other rocDecode samples, ``videodecode.cpp`` uses the utility classes in the rocDecode repository's |utilsfolder|_.
|
||||
|
||||
rocDecode provides two ways to decode a video stream: using the rocDecode RocVideoDecoder on GPU or using the FFMpeg video decoder on CPU.
|
||||
|
||||
The ``videodecode.cpp`` sample lets the user choose which method to use through the ``--backend`` argument.
|
||||
|
||||
``videodecode.cpp`` takes the following arguments:
|
||||
|
||||
.. list-table::
|
||||
:widths: 10 30 60
|
||||
:header-rows: 1
|
||||
|
||||
* - Argument
|
||||
- Description
|
||||
- Note
|
||||
|
||||
* - ``-i``
|
||||
- Input file path
|
||||
- Required. The path to the input video stream.
|
||||
|
||||
* - ``-o``
|
||||
- Output file path
|
||||
- Optional. The file to which to write the decoded frames, including those that remain in the decoded frame buffer pool when the RocVideoDecoder is being reconfigured.
|
||||
|
||||
* - ``-d``
|
||||
- GPU device ID
|
||||
- Optional. Set it to 0 for the first device, 1 for the second device, 2 for the third device, and so on for each subsequent device. Set to 0 by default.
|
||||
|
||||
* - ``-backend``
|
||||
- The backend to use for decoding
|
||||
- Optional. Set it to 0 to use RocVideoDecode on GPU, 1 to use the FFMpeg decoder on CPU, or 2 to use the FFMpeg decoder with no multithreading on CPU. Uses RocVideoDecode on GPU by default.
|
||||
|
||||
* - ``-f``
|
||||
- Number of frames to decode
|
||||
- Optional. Decodes the entire stream by default.
|
||||
|
||||
* - ``-z``
|
||||
- Force zero latency
|
||||
- Optional. When set to ``true`` forces decoded frames to be flushed out for display immediately. ``false`` by default.
|
||||
|
||||
* - ``-disp_delay``
|
||||
- Display delay
|
||||
- Optional. The number of frames to decode before displaying the results. Set to 1 by default.
|
||||
|
||||
* - ``-sei``
|
||||
- Extract Supplemental Enhancement Information (SEI)
|
||||
- Optional. Set to ``true`` to extract SEI. ``false`` by default.
|
||||
|
||||
* - ``-md5``
|
||||
- Generate MD5 message digest
|
||||
- Optional. Set to ``true`` to generate the MD5 message digest for the decoded YUV image sequence. ``false`` by default.
|
||||
|
||||
* - ``-md5_check``
|
||||
- Compare the generated MD5 with a provided MD5 string
|
||||
- Optional. When a file containing an MD5 string is passed to this argument, the MD5 message is compared to the string in the file.
|
||||
|
||||
* - ``-crop``
|
||||
- Crop rectangle
|
||||
- Optional. Takes four integers defining the crop rectangle to use with the output. This argument is ignored when using interopped decoded frame. See the documentation for the `Rect struct <https://rocm.docs.amd.com/projects/rocDecode/en/latest/doxygen/html/structRect.html>`_ for more information. There is no cropping by default.
|
||||
|
||||
* - ``-m``
|
||||
- The output surface memory type
|
||||
- Optional. The memory type where the surface data, such as the decoded frames, resides. Set this to 0 for intermediate GPU memory, to 1 for GPU memory, and to 2 for CPU memory. See :doc:`Surface data memory locations <../conceptual/rocDecode-memory-types>` for more information. Uses intermediate GPU memory by default.
|
||||
|
||||
* - ``-seek_criteria``
|
||||
- Seek criteria and seek starting point
|
||||
- Optional. Set to 1 and the frame number to start demultiplexing from that specific frame. Set to 2 and the timestamp to start demultiplexing from that specific timestamp. The seek criteria and starting point must be comma-separated (``,``). Demultiplexing begins at the first frame by default.
|
||||
|
||||
* - ``-seek_mode``
|
||||
- Seek mode
|
||||
- Optional. Set to 0 to seek to the previous keyframe. Set to 1 to seek to the exact frame. Seeks to previous keyframe by default.
|
||||
|
||||
* - ``-no_ffmpeg_demux``
|
||||
- Don't use the FFMpeg demultiplexer
|
||||
- Optional. Set to ``true`` to use the RocDecode bitstream reader to obtain picture data. The bitstream reader can only be used with an elementary stream. The FFmpeg demultiplexer is used by default.
|
||||
|
||||
Because the ``videodecode.cpp`` example can use the RocDecode RocVideoDecoder, the FFMpeg decoder, the FFmpeg demultiplexer (demuxer), or the RocDecode bitstream reader, it imports the ``roc_video_dec.h``, ``video_demuxer.h``, and ``ffmpeg_video_dec.h`` header files. These headers contain the convenience classes and functions for decoding and demultiplexing video.
|
||||
|
||||
|
||||
The FFMpeg demuxer is used to demultiplex the input stream unless the ``-no_ffmpeg_demux`` argument was set to ``true``.
|
||||
|
||||
.. code:: C++
|
||||
|
||||
VideoDemuxer *demuxer;
|
||||
demuxer = new VideoDemuxer(input_file_path.c_str());
|
||||
|
||||
The ``GetCodecId`` and ``GetBitDepth`` functions are used to obtain the video stream's codec and bit depth. The ``AVCodec2RocDecVideoCodec`` utility function converts the codec returned from the demuxer to its corresponding ``rocDecVideoCodec_enum`` value.
|
||||
|
||||
.. code:: C++
|
||||
|
||||
rocdec_codec_id = AVCodec2RocDecVideoCodec(demuxer->GetCodecID());
|
||||
bit_depth = demuxer->GetBitDepth();
|
||||
|
||||
The codec ID and bit depth are used to instantiate the video decoder. If the GPU backend was selected, the RocVideoDecoder is instantiated:
|
||||
|
||||
.. code:: C++
|
||||
|
||||
RocVideoDecoder *viddec;
|
||||
viddec = new RocVideoDecoder(device_id, mem_type, rocdec_codec_id, b_force_zero_latency, p_crop_rect, b_extract_sei_messages, disp_delay);
|
||||
|
||||
For more information about the rocDecode RocVideoDecoder, see :doc:`Using the rocDecode RocVideoDecoder <./using-rocDecode-video-decoder>`.
|
||||
|
||||
If the CPU backend was selected, the FFMpeg decoder is instantiated:
|
||||
|
||||
.. code:: C++
|
||||
|
||||
viddec = new FFMpegVideoDecoder(device_id, mem_type, rocdec_codec_id, b_force_zero_latency, p_crop_rect, b_extract_sei_messages, disp_delay);
|
||||
|
||||
The decoder instance is reused when there is a change to the video resolution without a change in the codec. When the video stream resolution changes, the decoder is reconfigured for the new resolution and the pool of frame buffers that the decoder maintains is deleted.
|
||||
|
||||
The |reconfig_struct|_ struct is used to store information on how to handle the frames that remain in the buffers at the time of reconfiguration. A callback, a user-defined flush mode, and a user-defined struct are passed to ``ReconfigParams_t``. The reconfiguration parameters are then passed to the decoder using ``SetReconfigParams``.
|
||||
|
||||
The reconfiguration structs are defined in |common|_ in the rocDecode samples. Three possibilities for the remaining frames in the decoded frame buffer pool are provided:
|
||||
|
||||
* ``RECONFIG_FLUSH_MODE_NONE``: delete the frames along with the buffers.
|
||||
* ``RECONFIG_FLUSH_MODE_DUMP_TO_FILE``: write the frames to the specified output file before deleting the buffers.
|
||||
* ``RECONFIG_FLUSH_MODE_CALCULATE_MD5``: calculate the MD5 of the frames before deleting the buffers.
|
||||
|
||||
.. code:: C++
|
||||
|
||||
typedef enum ReconfigFlushMode_enum {
|
||||
RECONFIG_FLUSH_MODE_NONE = 0x0, /**< Just flush to get the frame count */
|
||||
RECONFIG_FLUSH_MODE_DUMP_TO_FILE = 0x1, /**< The remaining frames will be dumped to file in this mode */
|
||||
RECONFIG_FLUSH_MODE_CALCULATE_MD5 = (0x1 << 1), /**< Calculate the MD5 of the flushed frames */
|
||||
} ReconfigFlushMode;
|
||||
|
||||
typedef struct ReconfigDumpFileStruct_t {
|
||||
bool b_dump_frames_to_file;
|
||||
std::string output_file_name;
|
||||
void *md5_generator_handle;
|
||||
} ReconfigDumpFileStruct;
|
||||
|
||||
|
||||
If the ``-o`` output file path argument was set, the remaining frames in the decoded frame buffer pool will be written to the output file upon reconfiguration. If the ``-md5`` argument was set to ``true``, the MD5 of the frames in the decoded frame buffer pool will be calculated before they're flushed or written to file. If neither option was selected, the frames in the decoded frame buffer pool will be deleted along with the buffers without being saved or processed.
|
||||
|
||||
.. code:: C++
|
||||
|
||||
reconfig_params.p_fn_reconfigure_flush = ReconfigureFlushCallback;
|
||||
reconfig_user_struct.b_dump_frames_to_file = dump_output_frames;
|
||||
reconfig_user_struct.output_file_name = output_file_path;
|
||||
reconfig_params.reconfig_flush_mode = RECONFIG_FLUSH_MODE_NONE;
|
||||
if (dump_output_frames) {
|
||||
reconfig_params.reconfig_flush_mode |= RECONFIG_FLUSH_MODE_DUMP_TO_FILE;
|
||||
}
|
||||
if (b_generate_md5) {
|
||||
reconfig_params.reconfig_flush_mode |= RECONFIG_FLUSH_MODE_CALCULATE_MD5;
|
||||
}
|
||||
reconfig_params.p_reconfig_user_struct = &reconfig_user_struct;
|
||||
|
||||
The reconfiguration parameters need to be defined prior to entering the decoding loop.
|
||||
|
||||
In the decode loop, the video stream is demultiplexed before being decoded.
|
||||
|
||||
The demuxer will demultiplex frames sequentially starting at the beginning of the stream unless ``-seek_criteria`` was set to either 1 or 2.
|
||||
|
||||
If the ``-seek_criteria`` argument was set to 1 and ``-seek_mode`` was set to 1, the demuxer will start demultiplexing the video at the frame provided.
|
||||
|
||||
If the ``-seek_criteria`` argument was set to 1 and ``-seek_mode`` wasn't set or was set to 0, the demuxer will start demultiplexing the video at the first keyframe before the frame provided.
|
||||
|
||||
If the ``-seek_criteria`` argument was set to 2 the demuxer will start demultiplexing the video at the timestamp provided.
|
||||
|
||||
The seek criteria is defined by the ``SeekCriteriaEnum`` enum and the seek mode is defined by the ``SeekModeEnum`` enum. Both the ``SeekCriteriaEnum`` and the ``SeekModeEnum`` are defined in ``video_demuxer.h``.
|
||||
|
||||
From ``videodecode.cpp``:
|
||||
|
||||
.. code:: C++
|
||||
|
||||
VideoSeekContext video_seek_ctx;
|
||||
[...]
|
||||
do {
|
||||
[...]
|
||||
if (seek_criteria == 1 && first_frame) {
|
||||
// use VideoSeekContext class to seek to given frame number
|
||||
video_seek_ctx.seek_frame_ = seek_to_frame;
|
||||
video_seek_ctx.seek_crit_ = SEEK_CRITERIA_FRAME_NUM;
|
||||
video_seek_ctx.seek_mode_ = (seek_mode ? SEEK_MODE_EXACT_FRAME : SEEK_MODE_PREV_KEY_FRAME);
|
||||
demuxer->Seek(video_seek_ctx, &pvideo, &n_video_bytes);
|
||||
pts = video_seek_ctx.out_frame_pts_;
|
||||
std::cout << "info: Number of frames that were decoded during seek - " << video_seek_ctx.num_frames_decoded_ << std::endl;
|
||||
first_frame = false;
|
||||
} else if (seek_criteria == 2 && first_frame) {
|
||||
// use VideoSeekContext class to seek to given timestamp
|
||||
video_seek_ctx.seek_frame_ = seek_to_frame;
|
||||
video_seek_ctx.seek_crit_ = SEEK_CRITERIA_TIME_STAMP;
|
||||
video_seek_ctx.seek_mode_ = (seek_mode ? SEEK_MODE_EXACT_FRAME : SEEK_MODE_PREV_KEY_FRAME);
|
||||
demuxer->Seek(video_seek_ctx, &pvideo, &n_video_bytes);
|
||||
pts = video_seek_ctx.out_frame_pts_;
|
||||
std::cout << "info: Duration of frame found after seek - " << video_seek_ctx.out_frame_duration_ << " ms" << std::endl;
|
||||
first_frame = false;
|
||||
} else {
|
||||
demuxer->Demux(&pvideo, &n_video_bytes, &pts);
|
||||
}
|
||||
|
||||
The video can now be decoded using the ``DecodeFrame`` function.
|
||||
|
||||
If the ``-md5`` argument was set to ``true``, MD5 is calculated for the file. If an output file path was provided, the decoded frames will be written to file.
|
||||
|
||||
The frame is released with ``ReleaseFrame`` once processing is complete.
|
||||
|
||||
.. code:: C++
|
||||
|
||||
n_frame_returned = viddec->DecodeFrame(pvideo, n_video_bytes, pkg_flags, pts, &decoded_pics);
|
||||
|
||||
[...]
|
||||
|
||||
for (int i = 0; i < n_frame_returned; i++) {
|
||||
pframe = viddec->GetFrame(&pts);
|
||||
if (b_generate_md5) {
|
||||
md5_generator->UpdateMd5ForFrame(pframe, surf_info);
|
||||
}
|
||||
if (dump_output_frames && mem_type != OUT_SURFACE_MEM_NOT_MAPPED) {
|
||||
viddec->SaveFrameToFile(output_file_path, pframe, surf_info);
|
||||
}
|
||||
|
||||
viddec->ReleaseFrame(pts);
|
||||
|
||||
|
||||
The demuxer is deleted once decoding is done.
|
||||
|
||||
.. code:: C++
|
||||
|
||||
delete demuxer;
|
||||
|
||||
.. |videodecode| replace:: ``videodecode.cpp``
|
||||
.. _videodecode: https://github.com/ROCm/rocDecode/tree/develop/samples/videoDecode/videodecode.cpp
|
||||
|
||||
.. |videodecoderaw| replace:: ``videodecoderaw.cpp``
|
||||
.. _videodecoderaw: https://github.com/ROCm/rocDecode/tree/develop/samples/videoDecodeRaw
|
||||
|
||||
.. |common| replace:: ``common.h``
|
||||
.. _common: https://github.com/ROCm/rocDecode/blob/develop/samples/common.h
|
||||
|
||||
.. |apifolder| replace:: ``api`` folder
|
||||
.. _apifolder: https://github.com/ROCm/rocDecode/tree/develop/api
|
||||
|
||||
.. |utilsfolder| replace:: ``utils`` folder
|
||||
.. _utilsfolder: https://github.com/ROCm/rocDecode/tree/develop/utils
|
||||
|
||||
.. |samplefolder| replace:: ``samples`` folder
|
||||
.. _samplefolder: https://github.com/ROCm/rocDecode/tree/develop/samples
|
||||
|
||||
.. |reconfig_struct| replace:: ``ReconfigParams_t``
|
||||
.. _reconfig_struct: https://rocm.docs.amd.com/projects/rocDecode/en/latest/doxygen/html/structReconfigParams__t.html
|
||||
|
||||
.. |br| raw:: html
|
||||
|
||||
</br>
|
||||
@@ -0,0 +1,64 @@
|
||||
.. meta::
|
||||
:description: rocDecode documentation and API reference library
|
||||
:keywords: rocDecode, ROCm, API, documentation, video, decode, decoding, acceleration
|
||||
|
||||
********************************************************************
|
||||
rocDecode documentation
|
||||
********************************************************************
|
||||
|
||||
rocDecode provides APIs, utilities, and samples that you can use to easily access the video decoding
|
||||
features of your media engines (VCNs). It also allows interoperability with other compute engines on
|
||||
the GPU using Video Acceleration API (VA-API)/HIP. To learn more, see :doc:`what-is-rocDecode`
|
||||
|
||||
The rocDecode public repository is located at `https://github.com/ROCm/rocDecode <https://github.com/ROCm/rocDecode>`_.
|
||||
|
||||
.. grid:: 2
|
||||
:gutter: 3
|
||||
|
||||
.. grid-item-card:: Install
|
||||
|
||||
* :doc:`rocDecode prerequisites <./install/rocDecode-prerequisites>`
|
||||
* :doc:`Installing rocDecode with the package installer <./install/rocDecode-package-install>`
|
||||
* :doc:`Building and installing rocDecode from source code <./install/rocDecode-build-and-install>`
|
||||
* `rocDecode Docker containers <https://github.com/ROCm/rocDecode/tree/develop/docker>`_
|
||||
|
||||
.. grid:: 2
|
||||
:gutter: 3
|
||||
|
||||
.. grid-item-card:: Conceptual
|
||||
|
||||
* :doc:`Video decoding pipeline <./conceptual/video-decoding-pipeline>`
|
||||
* :doc:`rocDecode surface memory locations <./conceptual/rocDecode-memory-types>`
|
||||
|
||||
.. grid-item-card:: How to
|
||||
|
||||
* :doc:`Understand the rocDecode videodecode.cpp sample <./how-to/using-rocDecode-videodecode-sample>`
|
||||
* :doc:`Understand the rocDecode rocdecdecode.cpp sample <./how-to/using-rocDecode-rocdecdecoder>`
|
||||
* :doc:`Use the rocDecode RocVideoDecoder <./how-to/using-rocDecode-video-decoder>`
|
||||
* :doc:`Use the rocDecode FFmpeg demultiplexer <./how-to/using-rocDecode-ffmpeg>`
|
||||
* :doc:`Use the rocDecode bitstream reader APIs <./how-to/using-rocDecode-bitstream>`
|
||||
|
||||
|
||||
.. grid-item-card:: Samples
|
||||
|
||||
* :doc:`rocDecode samples <./tutorials/rocDecode-samples>`
|
||||
|
||||
.. grid-item-card:: Reference
|
||||
|
||||
* :doc:`The rocDecode core APIs <./reference/rocDecode-core-APIs>`
|
||||
|
||||
* :doc:`The rocDecode parser API <./reference/rocDecode-parser>`
|
||||
* :doc:`The rocDecode hardware decoder API <./reference/rocDecode-hw-decoder>`
|
||||
* :doc:`The rocDecode software decoder API <./reference/rocDecode-sw-decoder>`
|
||||
|
||||
* :doc:`rocDecode logging levels <./reference/rocDecode-logging-control>`
|
||||
* :doc:`rocDecode codec support and hardware capabilities <./reference/rocDecode-formats-and-architectures>`
|
||||
* :doc:`API library <../doxygen/html/files>`
|
||||
* :doc:`Functions <../doxygen/html/globals>`
|
||||
* :doc:`Data structures <../doxygen/html/annotated>`
|
||||
|
||||
To contribute to the documentation, refer to
|
||||
`Contributing to ROCm <https://rocm.docs.amd.com/en/latest/contribute/contributing.html>`_.
|
||||
|
||||
You can find licensing information on the
|
||||
`Licensing <https://rocm.docs.amd.com/en/latest/about/license.html>`_ page.
|
||||
@@ -0,0 +1,55 @@
|
||||
.. meta::
|
||||
:description: Build and install rocDecode with the source code
|
||||
:keywords: install, building, rocDecode, AMD, ROCm, source code, developer
|
||||
|
||||
********************************************************************
|
||||
Building and installing rocDecode from source code
|
||||
********************************************************************
|
||||
|
||||
If you will be contributing to the rocDecode code base, or if you want to preview new features, build rocDecode from its source code.
|
||||
|
||||
If you will not be previewing features or contributing to the code base, use the :doc:`package installers <./rocDecode-package-install>` to install rocDecode.
|
||||
|
||||
Before building rocDecode, use `rocDecode-setup.py <https://github.com/ROCm/rocDecode/blob/develop/rocDecode-setup.py>`_ to install all the required prerequisites:
|
||||
|
||||
.. code:: shell
|
||||
|
||||
python3 rocDecode-setup.py [--rocm_path ROCM_INSTALLATION_PATH; default=/opt/rocm]
|
||||
[--runtime {ON|OFF}; default=ON]
|
||||
[--developer {ON|OFF}; default=OFF]
|
||||
|
||||
.. note::
|
||||
|
||||
Never run ``rocDecode-setup.py`` with ``--runtime OFF``.
|
||||
|
||||
``--developer ON`` is required to use the code samples.
|
||||
|
||||
Build and install rocDecode using the following commands:
|
||||
|
||||
.. code:: shell
|
||||
|
||||
git clone https://github.com/ROCm/rocDecode.git
|
||||
cd rocDecode
|
||||
mkdir build && cd build
|
||||
cmake ../
|
||||
make -j8
|
||||
sudo make install
|
||||
|
||||
After installation, the rocDecode libraries will be copied to ``/opt/rocm/lib`` and the rocDecode header files will be copied to ``/opt/rocm/include/rocdecode``.
|
||||
|
||||
Build and install the rocDecode test module. This module is required if you'll be using the rocDecode samples, and can only be installed if ``rocDecode-setup.py`` was run with ``--developer ON``.
|
||||
|
||||
.. code:: shell
|
||||
|
||||
mkdir rocdecode-test && cd rocdecode-test
|
||||
cmake /opt/rocm/share/rocdecode/test/
|
||||
ctest -VV
|
||||
|
||||
Run ``make test`` to test your build. To run the test with the verbose option, run ``make test ARGS="-VV"``.
|
||||
|
||||
To create a package installer for rocDecode, run:
|
||||
|
||||
.. code:: shell
|
||||
|
||||
sudo make package
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
.. meta::
|
||||
:description: Installing rocDecode with the package installer
|
||||
:keywords: install, rocDecode, AMD, ROCm, basic, development, package
|
||||
|
||||
********************************************************************
|
||||
Installing rocDecode with the package installer
|
||||
********************************************************************
|
||||
|
||||
Three rocDecode packages are available:
|
||||
|
||||
* ``rocdecode``: The rocDecode runtime package. This is the basic rocDecode package. It must always be installed.
|
||||
* ``rocdecode-host``: The rocDecode software decoding package. This package must be installed to use the FFmpeg software decoder.
|
||||
* ``rocdecode-dev``: The rocDecode development package. This package installs a full suite of libraries, header files, and samples. This package must be installed to use the rocDecode samples.
|
||||
* ``rocdecode-test``: A test package that provides a CTest to verify the installation. This package must be installed to use the rocDecode samples.
|
||||
|
||||
All the required prerequisites are installed when the package installation method is used.
|
||||
|
||||
|
||||
Basic installation without software decoding
|
||||
==============================================
|
||||
|
||||
Use the following commands to install only the rocDecode runtime package:
|
||||
|
||||
.. tab-set::
|
||||
|
||||
.. tab-item:: Ubuntu
|
||||
|
||||
.. code:: shell
|
||||
|
||||
sudo apt install rocdecode
|
||||
|
||||
.. tab-item:: RHEL
|
||||
|
||||
.. code:: shell
|
||||
|
||||
sudo yum install rocdecode
|
||||
|
||||
.. tab-item:: SLES
|
||||
|
||||
.. code:: shell
|
||||
|
||||
sudo zypper install rocdecode
|
||||
|
||||
|
||||
Basic installation with software decoding
|
||||
==============================================
|
||||
|
||||
Use the following commands to install the rocDecode runtime package and the host decoding package:
|
||||
|
||||
.. tab-set::
|
||||
|
||||
.. tab-item:: Ubuntu
|
||||
|
||||
.. code:: shell
|
||||
|
||||
sudo apt install rocdecode rocdecode-host
|
||||
|
||||
.. tab-item:: RHEL
|
||||
|
||||
.. code:: shell
|
||||
|
||||
sudo yum install rocdecode rocdecode-host
|
||||
|
||||
.. tab-item:: SLES
|
||||
|
||||
.. code:: shell
|
||||
|
||||
sudo zypper install rocdecode rocdecode-host
|
||||
|
||||
|
||||
Complete installation
|
||||
========================================
|
||||
|
||||
Use the following commands to install ``rocdecode``, ``rocdecode-host``, ``rocdecode-dev``, and ``rocdecode-test``:
|
||||
|
||||
.. tab-set::
|
||||
|
||||
.. tab-item:: Ubuntu
|
||||
|
||||
.. code:: shell
|
||||
|
||||
sudo apt install rocdecode rocdecode-host rocdecode-dev rocdecode-test
|
||||
|
||||
.. tab-item:: RHEL
|
||||
|
||||
.. code:: shell
|
||||
|
||||
sudo yum install rocdecode rocdecode-host rocdecode-devel rocdecode-test
|
||||
.. tab-item:: SLES
|
||||
|
||||
.. code:: shell
|
||||
|
||||
sudo zypper install rocdecode rocdecode-host rocdecode-devel rocdecode-test
|
||||
@@ -0,0 +1,41 @@
|
||||
.. meta::
|
||||
:description: rocDecode Installation Prerequisites
|
||||
:keywords: install, rocDecode, AMD, ROCm, prerequisites, dependencies, requirements
|
||||
|
||||
********************************************************************
|
||||
rocDecode prerequisites
|
||||
********************************************************************
|
||||
|
||||
rocDecode requires ROCm running on `GPUs based on the CDNA architecture <https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html>`_.
|
||||
|
||||
ROCm must be installed using the AMDGPU installer with the ``rocm`` usecase:
|
||||
|
||||
.. code:: shell
|
||||
|
||||
sudo amdgpu-install --usecase=rocm
|
||||
|
||||
rocDecode has been tested on the following Linux environments:
|
||||
|
||||
* Ubuntu 22.04 and 24.04
|
||||
* RHEL 8 and 9
|
||||
* SLES 15 SP7
|
||||
|
||||
See `Supported operating systems <https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html#supported-operating-systems>`_ for the complete list of ROCm supported Linux environments.
|
||||
|
||||
The following prerequisites are installed by the package installer. If you are building and installing using the source code, use the `rocDecode-setup.py <https://github.com/ROCm/rocDecode/blob/develop/rocDecode-setup.py>`_ to install these prerequisites.
|
||||
|
||||
.. note::
|
||||
|
||||
To use the rocDecode samples, the ``rocdecode``, ``rocdecode-dev``, ``rocdecode-host``, and ``rocdecode-test`` packages need to be installed.
|
||||
|
||||
If you're installing using the rocDecode source code, the ``rocDecode-setup.py`` script must be run with ``--developer`` set to ``ON``.
|
||||
|
||||
* Libva-amdgpu-dev, an AMD implementation for Video Acceleration API (VA-API)
|
||||
* AMD VA Drivers
|
||||
* CMake version 3.10 or later
|
||||
* AMD Clang++ Version 18.0.0 or later
|
||||
* pkg-config
|
||||
* FFmpeg runtime and headers
|
||||
* libstdc++-12-dev for installations on Ubuntu 22.04
|
||||
* HIP, specifically the ``hip-dev`` package
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# License
|
||||
|
||||
```{include} ../LICENSE
|
||||
```
|
||||
@@ -0,0 +1,37 @@
|
||||
.. meta::
|
||||
:description: Using rocDecode
|
||||
:keywords: parse video, parse, decode, video decoder, video decoding, rocDecode, core APIs, AMD, ROCm
|
||||
|
||||
********************************************************************
|
||||
The rocDecode core APIs
|
||||
********************************************************************
|
||||
|
||||
The rocDecode core APIs are intended for users who want to have full control of the decoding pipeline and interact with the core components instead of the utility classes. The :doc:`Using the rocDecode videodecode sample <../how-to/using-rocDecode-videodecode-sample>` provides an introduction to using the utility classes.
|
||||
|
||||
The rocDecode core APIs are exposed in header files in the |apifolder|_ folder of the `rocDecode GitHub repository <https://github.com/ROCm/rocDecode>`_.
|
||||
|
||||
:doc:`The rocDecode parser API <./rocDecode-parser>` is exposed in |rocparser|_. It contains functions that create and destroy the parser, as well as functions that parse the bitstream.
|
||||
|
||||
:doc:`The hardware decoder API <./rocDecode-hw-decoder>` is exposed in |rocdecode|_. It contains functions that create, control, and destroy the decoder, as well as functions that decode the parsed frames on the GPU.
|
||||
|
||||
:doc:`The software decoder API <./rocDecode-sw-decoder>` is exposed in |rocdecodehost|_. It contains the same functionality as ``rocdecode.h``, but all the operations are run on the host rather than the GPU.
|
||||
|
||||
:doc:`The bitstream reader API <../how-to/using-rocDecode-bitstream>` is exposed in |bitstreamreader|_. It provides an alternative to the FFMpeg demuxer and contains a simple stream file parser that can read elementary files and IVF container files.
|
||||
|
||||
.. |apifolder| replace:: ``api/rocdecode``
|
||||
.. _apifolder: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode
|
||||
|
||||
.. |rocparser| replace:: ``api/rocdecode/rocparser.h``
|
||||
.. _rocparser: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/rocparser.h
|
||||
|
||||
.. |rocdecode| replace:: ``api/rocDecode/rocdecode.h``
|
||||
.. _rocdecode: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/rocdecode.h
|
||||
|
||||
.. |rocdecodehost| replace:: ``api/rocDecode/rocdecode_host.h``
|
||||
.. _rocdecodehost: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/rocdecode_host.h
|
||||
|
||||
.. |bitstreamreader| replace:: ``api/rocDecode/roc_bitstream_reader.h``
|
||||
.. _bitstreamreader: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/roc_bitstream_reader.h
|
||||
|
||||
.. |utilsfolder| replace:: ``utils`` folder
|
||||
.. _utilsfolder: https://github.com/ROCm/rocDecode/tree/develop/utils
|
||||
@@ -0,0 +1,27 @@
|
||||
.. meta::
|
||||
:description: rocDecode supported codex and hardware capabilities
|
||||
:keywords: install, rocDecode, AMD, ROCm, GPU, codec, VCN
|
||||
|
||||
********************************************************************
|
||||
rocDecode supported codecs and hardware capabilities
|
||||
********************************************************************
|
||||
|
||||
rocDecode supports the following codecs:
|
||||
|
||||
* H.265 (HEVC): 8 bit and 10 bit
|
||||
* H.264 (AVC): 8 bit
|
||||
* AV1: 8 bit and 10 bit
|
||||
* VP9: 8 bit and 10 bit
|
||||
|
||||
The following table shows the codec support and capabilities of the VCN for each supported GPU
|
||||
architecture:
|
||||
|
||||
.. csv-table::
|
||||
:header: "GPU Architecture", "VCN Generation", "Number of VCNs", "H.265/HEVC", "Max width, Max height - H.265", "H.264/AVC", "Max width, Max height - H.264", "AV1", "Max width, Max height - AV1", "VP9", "Max width, Max height - VP9"
|
||||
|
||||
"gfx908 - MI1xx", "VCN 2.5.0", "2", "Yes", "7680, 4320", "Yes", "4096, 2160", "No", "N/A, N/A", "Yes", "7680, 4320"
|
||||
"gfx90a - MI2xx", "VCN 2.6.0", "2", "Yes", "7680, 4320", "Yes", "4096, 2160", "No", "N/A, N/A", "Yes", "7680, 4320"
|
||||
"gfx942 - MI3xx", "VCN 4.0", "3/4", "Yes", "7680, 4320", "Yes", "4096, 2176", "Yes", "8192, 4352", "Yes", "7680, 4320"
|
||||
"gfx1030, gfx1031, gfx1032 - Navi2x", "VCN 3.x", "2", "Yes", "7680, 4320", "Yes", "4096, 2176", "Yes", "8192, 4352", "Yes", "7680, 4320"
|
||||
"gfx1100, gfx1102 - Navi3x", "VCN 4.0", "2", "Yes", "7680, 4320", "Yes", "4096, 2176", "Yes", "8192, 4352", "Yes", "7680, 4320"
|
||||
"gfx1101 - Navi3x", "VCN 4.0", "1", "Yes", "7680, 4320", "Yes", "4096, 2176", "Yes", "8192, 4352", "Yes", "7680, 4320"
|
||||
@@ -0,0 +1,62 @@
|
||||
.. meta::
|
||||
:description: The rocDecode hardware decoder
|
||||
:keywords: decode, video decoder, video decoding, rocDecode, core APIs, AMD, ROCm
|
||||
|
||||
********************************************************************
|
||||
The rocDecode hardware decoder API
|
||||
********************************************************************
|
||||
|
||||
The rocDecode hardware decoder API exposed in |rocdecode|_ is used to decode frames that were parsed by :doc:`the rocDecode parser <./rocDecode-parser>`.
|
||||
|
||||
Parsing parameters are stored in the ``RocDecoderCreateInfo`` struct and passed to ``rocDecCreateDecoder()`` to create a new decoder. ``rocDecCreateDecoder()`` returns a handle to the decoder. For example:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
RocDecoderCreateInfo create_info = {};
|
||||
create_info.codec_type = dec_info.rocdec_codec_id; // user specified codec_type for raw files
|
||||
create_info.max_width = DEFAULT_WIDTH;
|
||||
create_info.max_height = DEFAULT_HEIGHT;
|
||||
create_info.width = DEFAULT_WIDTH;
|
||||
create_info.height = DEFAULT_HEIGHT;
|
||||
create_info.num_decode_surfaces = 6;
|
||||
create_info.num_output_surfaces = 1;
|
||||
rocDecCreateDecoder(&decoder_handle, &create_info);
|
||||
|
||||
|
||||
``rocDecGetDecoderCaps()`` queries the capabilities of the underlying hardware video decoder. Decoder capabilities usually include supported codecs, maximum resolution, and
|
||||
bit depth.
|
||||
|
||||
``rocDecDecodeFrame()`` is used to submit frames for hardware decoding. This function must be called when the ``pfn_decode_picture`` callback is triggered in the ``rocDecParseVideoData()`` call. See :doc:`The rocDecode parser API <./rocDecode-parser>` for details about this call.
|
||||
|
||||
``rocDecDecodeFrame()`` takes the decoder handle and the pointer to the ``RocdecPicParams()`` struct and initiates the video decoding using VA-API. ``RocdecPicParams`` is populated with the decoded frame information.
|
||||
|
||||
The ``pfn_sequence_callback`` callback is triggered when a format change occurs or when a new sequence header is encountered. The implementation of ``pfn_sequence_callback`` must call ``rocDecReconfigureDecoder()`` to reconfigure the decoder to handle the new sequence or format. See :doc:`The rocDecode parser API <./rocDecode-parser>` for details about this callback.
|
||||
|
||||
``rocDecGetDecodeStatus()`` can be called to query the decoding status of a frame. The result of the query is either ``rocDecodeStatus_Success``, if decoding is complete, or ``rocDecodeStatus_InProgress``, if decoding is still in progress.
|
||||
|
||||
The ``pfn_display_picture`` callback is triggered when a frame has been decoded. The decoded frame can then be further processed in device memory. The implementation for this callback must call ``rocDecGetVideoFrame()`` to obtain the decoded frame's HIP device pointer.
|
||||
|
||||
``rocDecGetVideoFrame()`` provides a way to access the decoded frame in HIP. This is a blocking call that only returns once frame decoding and memory mapping is complete. It returns the HIP device pointer as well as information about the :doc:`output surface type <../conceptual/rocDecode-memory-types>`.
|
||||
|
||||
If the output surface type is ``OUT_SURFACE_MEM_DEV_INTERNAL``, meaning intermediate GPU memory, the direct pointer to the decoded surface is provided. If the requested surface
|
||||
type is ``OUT_SURFACE_MEM_DEV_COPIED`` or ``OUT_SURFACE_MEM_HOST_COPIED``, the internal decoded frame is copied to another buffer, either in device memory or host memory.
|
||||
|
||||
Once decoding is complete, ``rocDecDestroyVideoParser()`` and ``rocDecDestroyDecoder()`` must be called to destroy the parser and the decoding session, and free resources.
|
||||
|
||||
.. |apifolder| replace:: ``api/rocdecode``
|
||||
.. _apifolder: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode
|
||||
|
||||
.. |rocparser| replace:: ``api/rocdecode/rocparser.h``
|
||||
.. _rocparser: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/rocparser.h
|
||||
|
||||
.. |rocdecode| replace:: ``api/rocDecode/rocdecode.h``
|
||||
.. _rocdecode: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/rocdecode.h
|
||||
|
||||
.. |rocdecodehost| replace:: ``api/rocDecode/rocdecode_host.h``
|
||||
.. _rocdecodehost: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/rocdecode_host.h
|
||||
|
||||
.. |bitstreamreader| replace:: ``api/rocDecode/roc_bitstream_reader.h``
|
||||
.. _bitstreamreader: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/roc_bitstream_reader.h
|
||||
|
||||
.. |utilsfolder| replace:: ``utils`` folder
|
||||
.. _utilsfolder: https://github.com/ROCm/rocDecode/tree/develop/utils
|
||||
@@ -0,0 +1,53 @@
|
||||
.. meta::
|
||||
:description: rocDecode logging controls
|
||||
:keywords: rocDecode, core APIs, logging, AMD, ROCm
|
||||
|
||||
********************************************************************
|
||||
rocDecode logging control
|
||||
********************************************************************
|
||||
|
||||
rocDecode core components can be configured to output different levels of log messages during decoding.
|
||||
|
||||
The log level can be changed by either setting the log level through the ``ROCDEC_LOG_LEVEL`` environment variable, or by calling the ``RocDecLogger::SetLogLevel()`` function in |commons|_.
|
||||
|
||||
The logging levels are:
|
||||
|
||||
| 0: Critical (Default level)
|
||||
| 1: Error
|
||||
| 2: Warning
|
||||
| 3: Info
|
||||
| 4: Debug
|
||||
|
||||
The log level defines the maximum severity of log messages to output. For example, to output warning and error messages as well as critical messages, ``ROCDEC_LOG_LEVEL`` would need to be set to 2:
|
||||
|
||||
.. code:: shell
|
||||
|
||||
ROCDEC_LOG_LEVEL = 2
|
||||
|
||||
or
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
SetLogLevel(2);
|
||||
|
||||
|
||||
.. |apifolder| replace:: ``api/rocdecode``
|
||||
.. _apifolder: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode
|
||||
|
||||
.. |rocparser| replace:: ``api/rocdecode/rocparser.h``
|
||||
.. _rocparser: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/rocparser.h
|
||||
|
||||
.. |rocdecode| replace:: ``api/rocDecode/rocdecode.h``
|
||||
.. _rocdecode: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/rocdecode.h
|
||||
|
||||
.. |rocdecodehost| replace:: ``api/rocDecode/rocdecode_host.h``
|
||||
.. _rocdecodehost: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/rocdecode_host.h
|
||||
|
||||
.. |bitstreamreader| replace:: ``api/rocDecode/roc_bitstream_reader.h``
|
||||
.. _bitstreamreader: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/roc_bitstream_reader.h
|
||||
|
||||
.. |utilsfolder| replace:: ``utils`` folder
|
||||
.. _utilsfolder: https://github.com/ROCm/rocDecode/tree/develop/utils
|
||||
|
||||
.. |commons| replace:: ``commons.h``
|
||||
.. _commons: https://github.com/ROCm/rocDecode/tree/develop/src/commons.h
|
||||
@@ -0,0 +1,54 @@
|
||||
.. meta::
|
||||
:description: The rocDecode parser API
|
||||
:keywords: parse video, parser, decode, video decoder, video decoding, rocDecode, core APIs, AMD, ROCm
|
||||
|
||||
********************************************************************
|
||||
The rocDecode parser API
|
||||
********************************************************************
|
||||
|
||||
The rocDecode parser API, exposed in |rocparser|_, is used to decode bitstreams and organize them in a structured format that can be consumed by the hardware decoder.
|
||||
|
||||
The parser parameters are stored in the ``RocdecParserParams`` struct and passed to ``rocDecCreateVideoParser()`` to create a new parser. ``rocDecCreateVideoParser()`` returns a handle to the parser. For example:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
RocdecParserParams params = {};
|
||||
params.codec_type = rocdec_codec_id;
|
||||
params.max_num_decode_surfaces = 6;
|
||||
params.max_display_delay = 1;
|
||||
params.user_data = &dec_info;
|
||||
rocDecCreateVideoParser(&parser_handle, ¶ms);
|
||||
|
||||
Elementary stream video packets extracted from the demultiplexer (demuxer) are passed to the parser using the ``RocdecSourceDataPacket`` struct. Packet information in ``RocdecSourceDataPacket`` is passed to ``rocDecParseVideoData()``. For example:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
RocdecSourceDataPacket packet = {};
|
||||
packet.payload_size = frames[i].size();
|
||||
packet.payload = frames[i].data();
|
||||
rocDecParseVideoData(parser_handle, &packet);
|
||||
|
||||
Three callbacks must be registered when the parser is used: ``pfn_decode_picture``, ``pfn_sequence_callback``, and ``pfn_display_picture``. These callbacks are triggered in the ``rocDecParseVideoData()`` call.
|
||||
|
||||
``pfn_decode_picture`` is triggered when a picture is ready for decoding. Its implementation must call ``rocDecDecodeFrame()`` from the hardware decoder API.
|
||||
|
||||
``pfn_sequence_callback`` is triggered when a new sequence header is encountered or when there's a format change. Its implementation handles reconfiguring the decoder to handle the new frame format. Its implementation must call ``rocDecReconfigureDecoder()`` from the hardware decoder API.
|
||||
|
||||
``pfn_display_picture`` is triggered when a frame has been decoded. Its implementation must call ``rocDecGetVideoFrame()`` from the hardware decoder API.
|
||||
|
||||
A fourth callback, ``pfn_get_sei_msg``, is optional. ``pfn_get_sei_msg`` is triggered when a Supplementation Enhancement Information (SEI) message is parsed and returned to the caller.
|
||||
|
||||
If any of the callbacks return an error, the error is propagated back to the application.
|
||||
|
||||
Once the stream is fully decoded, ``rocDecDestroyVideoParser()`` must be called to destroy the parser object and free all allocated resources.
|
||||
|
||||
|
||||
|
||||
.. |rocparser| replace:: ``rocparser.h``
|
||||
.. _rocparser: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/rocparser.h
|
||||
|
||||
.. |utilsfolder| replace:: ``utils`` folder
|
||||
.. _utilsfolder: https://github.com/ROCm/rocDecode/tree/develop/utils
|
||||
|
||||
.. |rocdecdecode| replace:: ``rocdecdecode.cpp``
|
||||
.. _rocdecdecode: https://github.com/ROCm/rocDecode/tree/develop/samples/rocdecDecode/rocdecdecode.cpp
|
||||
@@ -0,0 +1,61 @@
|
||||
.. meta::
|
||||
:description: The rocDecode software decoder
|
||||
:keywords: decode, video decoder, video decoding, rocDecode, core APIs, AMD, ROCm
|
||||
|
||||
********************************************************************
|
||||
The rocDecode software decoder API
|
||||
********************************************************************
|
||||
|
||||
The rocDecode software decoder API exposed in |rocdecodehost|_ is used to decode frames that have been demultiplexed (demuxed) by :doc:`the FFmpeg demuxer <../how-to/using-rocDecode-ffmpeg>`.
|
||||
|
||||
Decoding parameters are stored in the ``RocDecoderHostCreateInfo`` struct and passed to ``rocDecCreateDecoderHost()`` to create a new software decoder. ``rocDecCreateDecoderHost()`` returns a handle to the decoder. For example:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
RocDecoderHostCreateInfo create_info = {};
|
||||
create_info.codec_type = rocdec_codec_id;
|
||||
create_info.num_decode_threads = 0; // default
|
||||
create_info.max_width = DEFAULT_WIDTH;
|
||||
create_info.max_height = DEFAULT_HEIGHT;
|
||||
create_info.chroma_format = rocDecVideoChromaFormat_420;
|
||||
create_info.output_format = rocDecVideoSurfaceFormat_P016;
|
||||
create_info.bit_depth_minus_8 = 2;
|
||||
create_info.num_output_surfaces = 1;
|
||||
create_info.user_data = &dec_info;
|
||||
rocDecCreateDecoderHost(&dec_info.decoder, &create_info);
|
||||
|
||||
``rocDecGetDecoderCapsHost()`` queries the capabilities of the underlying software video decoder. Decoder capabilities usually include supported codecs, maximum resolution, and
|
||||
bit depth.
|
||||
|
||||
``rocDecDecodeFrameHost()`` is used to submit frames for software decoding. ``rocDecDecodeFrameHost()`` takes the decoder handle and the pointer to the ``RocdecPicParamsHost`` struct and initiates the video decoding. ``RocdecPicParamsHost`` is populated with the decoded frame information.
|
||||
|
||||
The ``pfn_sequence_callback`` callback is triggered when a format change occurs or when a new sequence header is encountered. This callback must be registered in any application that uses the software decoder and its implementation must call ``rocDecReconfigureDecoderHost()`` to reconfigure the decoder to handle the new sequence or format.
|
||||
|
||||
``rocDecGetDecodeStatusHost()`` can be called to query the decoding status of a frame. The result of the query is either ``rocDecodeStatus_Success``, if decoding is complete, or ``rocDecodeStatus_InProgress``, if decoding is still in progress.
|
||||
|
||||
The ``pfn_display_picture`` callback is triggered when a frame has been decoded. This callback must be registered by any application that uses the software decoder and its implementation must call ``rocDecGetVideoFrameHost()``. ``rocDecGetVideoFrameHost()`` returns the decoded frame's host memory pointer. The decoded frame can then be further processed using this pointer.
|
||||
|
||||
``rocDecGetVideoFrameHost()`` provides a way to access the decoded frame in host memory. This is a blocking call that only returns once both frame decoding and memory mapping are done. It returns the host memory pointer as well as information about the :doc:`output surface type <../conceptual/rocDecode-memory-types>`.
|
||||
|
||||
If the output surface type is ``OUT_SURFACE_MEM_DEV_INTERNAL``, meaning intermediate GPU memory, the direct pointer to the decoded surface is provided. If the requested surface
|
||||
type is ``OUT_SURFACE_MEM_DEV_COPIED`` or ``OUT_SURFACE_MEM_HOST_COPIED``, the internal decoded frame is copied to another buffer, either in device memory or host memory.
|
||||
|
||||
Once decoding is complete, ``rocDecDestroyDecoderHost()`` must be called to destroy the decoder and free resources.
|
||||
|
||||
.. |apifolder| replace:: ``api/rocdecode``
|
||||
.. _apifolder: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode
|
||||
|
||||
.. |rocparser| replace:: ``api/rocdecode/rocparser.h``
|
||||
.. _rocparser: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/rocparser.h
|
||||
|
||||
.. |rocdecode| replace:: ``api/rocDecode/rocdecode.h``
|
||||
.. _rocdecode: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/rocdecode.h
|
||||
|
||||
.. |rocdecodehost| replace:: ``api/rocDecode/rocdecode_host.h``
|
||||
.. _rocdecodehost: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/rocdecode_host.h
|
||||
|
||||
.. |bitstreamreader| replace:: ``api/rocDecode/roc_bitstream_reader.h``
|
||||
.. _bitstreamreader: https://github.com/ROCm/rocDecode/tree/develop/api/rocdecode/roc_bitstream_reader.h
|
||||
|
||||
.. |utilsfolder| replace:: ``utils`` folder
|
||||
.. _utilsfolder: https://github.com/ROCm/rocDecode/tree/develop/utils
|
||||
@@ -0,0 +1 @@
|
||||
_toc.yml
|
||||
@@ -0,0 +1,70 @@
|
||||
defaults:
|
||||
numbered: False
|
||||
root: index
|
||||
subtrees:
|
||||
- entries:
|
||||
- file: what-is-rocDecode.rst
|
||||
title: What is rocDecode?
|
||||
|
||||
- caption: Install
|
||||
entries:
|
||||
- file: install/rocDecode-prerequisites.rst
|
||||
title: rocDecode prerequisites
|
||||
- file: install/rocDecode-package-install.rst
|
||||
title: Installing rocDecode with the package installer
|
||||
- file: install/rocDecode-build-and-install.rst
|
||||
title: Installing rocDecode from its source code
|
||||
- url: https://github.com/ROCm/rocDecode/tree/develop/docker
|
||||
title: rocDecode Docker containers
|
||||
|
||||
- caption: Conceptual
|
||||
entries:
|
||||
- file: conceptual/video-decoding-pipeline.rst
|
||||
title: Video decoding pipeline
|
||||
- file: conceptual/rocDecode-memory-types.rst
|
||||
title: rocDecode surface memory locations
|
||||
|
||||
- caption: Samples
|
||||
entries:
|
||||
- file: tutorials/rocDecode-samples.rst
|
||||
title: rocDecode samples
|
||||
|
||||
- caption: How to
|
||||
entries:
|
||||
- file: how-to/using-rocDecode-videodecode-sample.rst
|
||||
title: Understand the videodecode sample
|
||||
- file: how-to/using-rocDecode-rocdecdecoder.rst
|
||||
title: Understand the rocdecdecode.cpp sample
|
||||
- file: how-to/using-rocDecode-video-decoder.rst
|
||||
title: Use RocVideoDecoder
|
||||
- file: how-to/using-rocDecode-ffmpeg.rst
|
||||
title: Use the FFmpeg demultiplexer
|
||||
- file: how-to/using-rocDecode-bitstream.rst
|
||||
title: Use the bitstream reader APIs
|
||||
|
||||
- caption: Reference
|
||||
entries:
|
||||
- file: reference/rocDecode-core-APIs.rst
|
||||
title: Core APIs
|
||||
subtrees:
|
||||
- entries:
|
||||
- file: reference/rocDecode-parser.rst
|
||||
title: Parser API
|
||||
- file: reference/rocDecode-hw-decoder.rst
|
||||
title: Hardware decoder API
|
||||
- file: reference/rocDecode-sw-decoder.rst
|
||||
title: Software decoder API
|
||||
- file: reference/rocDecode-logging-control.rst
|
||||
title: Logging levels
|
||||
- file: reference/rocDecode-formats-and-architectures.rst
|
||||
title: rocDecode supported codecs and architectures
|
||||
- file: doxygen/html/files
|
||||
title: rocDecode API library
|
||||
- file: doxygen/html/globals
|
||||
title: rocDecode functions
|
||||
- file: doxygen/html/annotated
|
||||
title: rocDecode data structures
|
||||
|
||||
- caption: About
|
||||
entries:
|
||||
- file: license.md
|
||||
@@ -0,0 +1 @@
|
||||
rocm-docs-core[api_reference]==1.31.2
|
||||
@@ -0,0 +1,294 @@
|
||||
#
|
||||
# This file is autogenerated by pip-compile with Python 3.10
|
||||
# by the following command:
|
||||
#
|
||||
# pip-compile requirements.in
|
||||
#
|
||||
accessible-pygments==0.0.5
|
||||
# via pydata-sphinx-theme
|
||||
alabaster==1.0.0
|
||||
# via sphinx
|
||||
asttokens==3.0.1
|
||||
# via stack-data
|
||||
attrs==25.4.0
|
||||
# via
|
||||
# jsonschema
|
||||
# jupyter-cache
|
||||
# referencing
|
||||
babel==2.17.0
|
||||
# via
|
||||
# pydata-sphinx-theme
|
||||
# sphinx
|
||||
beautifulsoup4==4.14.3
|
||||
# via pydata-sphinx-theme
|
||||
breathe==4.36.0
|
||||
# via rocm-docs-core
|
||||
certifi==2026.1.4
|
||||
# via requests
|
||||
cffi==2.0.0
|
||||
# via
|
||||
# cryptography
|
||||
# pynacl
|
||||
charset-normalizer==3.4.4
|
||||
# via requests
|
||||
click==8.3.1
|
||||
# via
|
||||
# click-log
|
||||
# doxysphinx
|
||||
# jupyter-cache
|
||||
# sphinx-external-toc
|
||||
click-log==0.4.0
|
||||
# via doxysphinx
|
||||
comm==0.2.3
|
||||
# via ipykernel
|
||||
cryptography==46.0.3
|
||||
# via pyjwt
|
||||
debugpy==1.8.19
|
||||
# via ipykernel
|
||||
decorator==5.2.1
|
||||
# via ipython
|
||||
docutils==0.21.2
|
||||
# via
|
||||
# myst-parser
|
||||
# pydata-sphinx-theme
|
||||
# sphinx
|
||||
doxysphinx==3.3.14
|
||||
# via rocm-docs-core
|
||||
exceptiongroup==1.3.1
|
||||
# via ipython
|
||||
executing==2.2.1
|
||||
# via stack-data
|
||||
fastjsonschema==2.21.2
|
||||
# via
|
||||
# nbformat
|
||||
# rocm-docs-core
|
||||
gitdb==4.0.12
|
||||
# via gitpython
|
||||
gitpython==3.1.46
|
||||
# via rocm-docs-core
|
||||
greenlet==3.3.0
|
||||
# via sqlalchemy
|
||||
idna==3.11
|
||||
# via requests
|
||||
imagesize==1.4.1
|
||||
# via sphinx
|
||||
importlib-metadata==8.7.1
|
||||
# via
|
||||
# jupyter-cache
|
||||
# myst-nb
|
||||
ipykernel==7.1.0
|
||||
# via myst-nb
|
||||
ipython==8.38.0
|
||||
# via
|
||||
# ipykernel
|
||||
# myst-nb
|
||||
jedi==0.19.2
|
||||
# via ipython
|
||||
jinja2==3.1.6
|
||||
# via
|
||||
# myst-parser
|
||||
# sphinx
|
||||
jsonschema==4.26.0
|
||||
# via nbformat
|
||||
jsonschema-specifications==2025.9.1
|
||||
# via jsonschema
|
||||
jupyter-cache==1.0.1
|
||||
# via myst-nb
|
||||
jupyter-client==8.8.0
|
||||
# via
|
||||
# ipykernel
|
||||
# nbclient
|
||||
jupyter-core==5.9.1
|
||||
# via
|
||||
# ipykernel
|
||||
# jupyter-client
|
||||
# nbclient
|
||||
# nbformat
|
||||
libsass==0.22.0
|
||||
# via doxysphinx
|
||||
lxml==5.2.1
|
||||
# via doxysphinx
|
||||
markdown-it-py==3.0.0
|
||||
# via
|
||||
# mdit-py-plugins
|
||||
# myst-parser
|
||||
markupsafe==3.0.3
|
||||
# via jinja2
|
||||
matplotlib-inline==0.2.1
|
||||
# via
|
||||
# ipykernel
|
||||
# ipython
|
||||
mdit-py-plugins==0.5.0
|
||||
# via myst-parser
|
||||
mdurl==0.1.2
|
||||
# via markdown-it-py
|
||||
mpire==2.10.2
|
||||
# via doxysphinx
|
||||
myst-nb==1.3.0
|
||||
# via rocm-docs-core
|
||||
myst-parser==4.0.1
|
||||
# via myst-nb
|
||||
nbclient==0.10.4
|
||||
# via
|
||||
# jupyter-cache
|
||||
# myst-nb
|
||||
nbformat==5.10.4
|
||||
# via
|
||||
# jupyter-cache
|
||||
# myst-nb
|
||||
# nbclient
|
||||
nest-asyncio==1.6.0
|
||||
# via ipykernel
|
||||
packaging==25.0
|
||||
# via
|
||||
# ipykernel
|
||||
# pydata-sphinx-theme
|
||||
# sphinx
|
||||
parso==0.8.5
|
||||
# via jedi
|
||||
pexpect==4.9.0
|
||||
# via ipython
|
||||
platformdirs==4.5.1
|
||||
# via jupyter-core
|
||||
prompt-toolkit==3.0.52
|
||||
# via ipython
|
||||
psutil==7.2.1
|
||||
# via ipykernel
|
||||
ptyprocess==0.7.0
|
||||
# via pexpect
|
||||
pure-eval==0.2.3
|
||||
# via stack-data
|
||||
pycparser==2.23
|
||||
# via cffi
|
||||
pydata-sphinx-theme==0.15.4
|
||||
# via
|
||||
# rocm-docs-core
|
||||
# sphinx-book-theme
|
||||
pygithub==2.8.1
|
||||
# via rocm-docs-core
|
||||
pygments==2.19.2
|
||||
# via
|
||||
# accessible-pygments
|
||||
# ipython
|
||||
# mpire
|
||||
# pydata-sphinx-theme
|
||||
# sphinx
|
||||
pyjson5==1.6.9
|
||||
# via doxysphinx
|
||||
pyjwt[crypto]==2.10.1
|
||||
# via pygithub
|
||||
pynacl==1.6.2
|
||||
# via pygithub
|
||||
pyparsing==3.3.1
|
||||
# via doxysphinx
|
||||
python-dateutil==2.9.0.post0
|
||||
# via jupyter-client
|
||||
pyyaml==6.0.3
|
||||
# via
|
||||
# jupyter-cache
|
||||
# myst-nb
|
||||
# myst-parser
|
||||
# rocm-docs-core
|
||||
# sphinx-external-toc
|
||||
pyzmq==27.1.0
|
||||
# via
|
||||
# ipykernel
|
||||
# jupyter-client
|
||||
referencing==0.37.0
|
||||
# via
|
||||
# jsonschema
|
||||
# jsonschema-specifications
|
||||
requests==2.32.5
|
||||
# via
|
||||
# pygithub
|
||||
# sphinx
|
||||
rocm-docs-core[api-reference]==1.31.2
|
||||
# via -r requirements.in
|
||||
rpds-py==0.30.0
|
||||
# via
|
||||
# jsonschema
|
||||
# referencing
|
||||
six==1.17.0
|
||||
# via python-dateutil
|
||||
smmap==5.0.2
|
||||
# via gitdb
|
||||
snowballstemmer==3.0.1
|
||||
# via sphinx
|
||||
soupsieve==2.8.1
|
||||
# via beautifulsoup4
|
||||
sphinx==8.1.3
|
||||
# via
|
||||
# breathe
|
||||
# myst-nb
|
||||
# myst-parser
|
||||
# pydata-sphinx-theme
|
||||
# rocm-docs-core
|
||||
# sphinx-book-theme
|
||||
# sphinx-copybutton
|
||||
# sphinx-design
|
||||
# sphinx-external-toc
|
||||
# sphinx-notfound-page
|
||||
sphinx-book-theme==1.1.4
|
||||
# via rocm-docs-core
|
||||
sphinx-copybutton==0.5.2
|
||||
# via rocm-docs-core
|
||||
sphinx-design==0.6.1
|
||||
# via rocm-docs-core
|
||||
sphinx-external-toc==1.0.1
|
||||
# via rocm-docs-core
|
||||
sphinx-notfound-page==1.1.0
|
||||
# via rocm-docs-core
|
||||
sphinxcontrib-applehelp==2.0.0
|
||||
# via sphinx
|
||||
sphinxcontrib-devhelp==2.0.0
|
||||
# via sphinx
|
||||
sphinxcontrib-htmlhelp==2.1.0
|
||||
# via sphinx
|
||||
sphinxcontrib-jsmath==1.0.1
|
||||
# via sphinx
|
||||
sphinxcontrib-qthelp==2.0.0
|
||||
# via sphinx
|
||||
sphinxcontrib-serializinghtml==2.0.0
|
||||
# via sphinx
|
||||
sqlalchemy==2.0.45
|
||||
# via jupyter-cache
|
||||
stack-data==0.6.3
|
||||
# via ipython
|
||||
tabulate==0.9.0
|
||||
# via jupyter-cache
|
||||
tomli==2.4.0
|
||||
# via sphinx
|
||||
tornado==6.5.4
|
||||
# via
|
||||
# ipykernel
|
||||
# jupyter-client
|
||||
tqdm==4.67.1
|
||||
# via mpire
|
||||
traitlets==5.14.3
|
||||
# via
|
||||
# ipykernel
|
||||
# ipython
|
||||
# jupyter-client
|
||||
# jupyter-core
|
||||
# matplotlib-inline
|
||||
# nbclient
|
||||
# nbformat
|
||||
typing-extensions==4.15.0
|
||||
# via
|
||||
# beautifulsoup4
|
||||
# cryptography
|
||||
# exceptiongroup
|
||||
# ipython
|
||||
# myst-nb
|
||||
# pydata-sphinx-theme
|
||||
# pygithub
|
||||
# referencing
|
||||
# sqlalchemy
|
||||
urllib3==2.6.3
|
||||
# via
|
||||
# pygithub
|
||||
# requests
|
||||
wcwidth==0.2.14
|
||||
# via prompt-toolkit
|
||||
zipp==3.23.0
|
||||
# via importlib-metadata
|
||||
@@ -0,0 +1,32 @@
|
||||
.. meta::
|
||||
:description: rocDecode Sample Prerequisites
|
||||
:keywords: install, rocDecode, AMD, ROCm, samples, prerequisites, dependencies, requirements
|
||||
|
||||
********************************************************************
|
||||
rocDecode samples
|
||||
********************************************************************
|
||||
|
||||
rocDecode samples are available in the `rocDecode GitHub repository <https://github.com/ROCm/rocDecode/tree/develop/samples>`_.
|
||||
|
||||
You can find a walkthrough of the ``videodecode.cpp`` sample at :doc:`Understanding the videodecode.cpp sample <../how-to/using-rocDecode-videodecode-sample>`.
|
||||
|
||||
All rocDecode packages, ``rocDecode``, ``rocdecode-dev``, ``rocdecode-host``, and ``rocdecode-test``, must be installed to use the rocDecode samples.
|
||||
|
||||
If you're using a :doc:`package installer <../install/rocDecode-package-install>`, install ``rocdecode``, ``rocdecode-dev``, ``rocdecode-host``, and ``rocdecode-test``.
|
||||
|
||||
If you're building and installing rocDecode from its :doc:`source code <../install/rocDecode-build-and-install>`, ``rocDecode-setup.py`` needs to be run with ``--developer`` set to ``ON``:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
python3 rocDecode-setup.py --developer ON
|
||||
|
||||
The ``rocDecode-test`` package needs to be built and installed as well:
|
||||
|
||||
.. code:: shell
|
||||
|
||||
mkdir rocdecode-test && cd rocdecode-test
|
||||
cmake /opt/rocm/share/rocdecode/test/
|
||||
ctest -VV
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
.. meta::
|
||||
:description: What is rocDecode?
|
||||
:keywords: video decoding, rocDecode, AMD, ROCm
|
||||
|
||||
********************************************************************
|
||||
What is rocDecode?
|
||||
********************************************************************
|
||||
|
||||
AMD GPUs contain one or more media engines (VCNs) that provide fully accelerated, hardware-based
|
||||
video decoding. Hardware decoders consume lower power than CPU-based decoders. Dedicated
|
||||
hardware decoders offload decoding tasks from the CPU, boosting overall decoding throughput. With
|
||||
proper power management, decoding on hardware decoders can lower the overall system power
|
||||
consumption and improve decoding performance.
|
||||
|
||||
Using the rocDecode API, you can decode compressed video streams while keeping the resulting YUV
|
||||
frames in video memory. With decoded frames in video memory, you can run video post-processing
|
||||
using ROCm HIP, thereby avoiding unnecessary data copies via the PCIe bus. You can post-process video
|
||||
frames using scaling or color conversion and augmentation kernels (on a GPU or host) in a format for
|
||||
GPU/CPU-accelerated inferencing and training.
|
||||
|
||||
In addition, you can use the rocDecode API to create multiple instances of video decoders based on the number of available VCNs on a GPU device. By configuring the decoder for a device, all available VCNs can be used seamlessly to decode a batch of video streams in parallel.
|
||||
|
||||
For more information, refer to the
|
||||
:doc:`Video decoding pipeline <./conceptual/video-decoding-pipeline>`.
|
||||
Reference in New Issue
Block a user