Add 'projects/rocdecode/' from commit 'b0bab079403eda171f9056409fa96b0908f61073'

git-subtree-dir: projects/rocdecode
git-subtree-mainline: 5d609c1e57
git-subtree-split: b0bab07940
Этот коммит содержится в:
Ameya Keshava Mallya
2026-01-30 20:33:26 +00:00
родитель 5d609c1e57 b0bab07940
Коммит d0396f30b3
208 изменённых файлов: 43533 добавлений и 0 удалений
+106
Просмотреть файл
@@ -0,0 +1,106 @@
/*
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.
*/
#pragma once
#include "rocdecode/rocdecode.h"
#include "rocdecode/rocparser.h"
#include "rocdecode/roc_bitstream_reader.h"
// Define version macros for the rocDecode API dispatch table, specifying the MAJOR and STEP versions.
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// 1. When adding new functions to the rocDecode API dispatch table, always append the new function pointer
// to the end of the table and increment the dispatch table's version number. Never rearrange the order of
// the member variables in the dispatch table, as doing so will break the Application Binary Interface (ABI).
// 2. In critical situations where the type of an existing member variable in a dispatch table has been changed
// or removed due to a data type modification, it is important to increment the major version number of the
// rocDecode API dispatch table. If the function pointer type can no longer be declared, do not remove it.
// Instead, change the function pointer type to `void*` and ensure it is always initialized to `nullptr`.
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// The major version number should ideally remain unchanged. Increment the ROCDECODE_RUNTIME_API_TABLE_MAJOR_VERSION only
// for fundamental changes to the rocDecodeDispatchTable struct, such as altering the type or name of an existing member variable.
// Please DO NOT REMOVE it.
#define ROCDECODE_RUNTIME_API_TABLE_MAJOR_VERSION 0
// Increment the ROCDECODE_RUNTIME_API_TABLE_STEP_VERSION when new runtime API functions are added.
// If the corresponding ROCDECODE_RUNTIME_API_TABLE_MAJOR_VERSION increases reset the ROCDECODE_RUNTIME_API_TABLE_STEP_VERSION to zero.
#define ROCDECODE_RUNTIME_API_TABLE_STEP_VERSION 1
// rocDecode API interface
typedef rocDecStatus (ROCDECAPI *PfnRocDecCreateVideoParser)(RocdecVideoParser *parser_handle, RocdecParserParams *params);
typedef rocDecStatus (ROCDECAPI *PfnRocDecParseVideoData)(RocdecVideoParser parser_handle, RocdecSourceDataPacket *packet);
typedef rocDecStatus (ROCDECAPI *PfnRocDecDestroyVideoParser)(RocdecVideoParser parser_handle);
typedef rocDecStatus (ROCDECAPI *PfnRocDecCreateDecoder)(rocDecDecoderHandle *decoder_handle, RocDecoderCreateInfo *decoder_create_info);
typedef rocDecStatus (ROCDECAPI *PfnRocDecDestroyDecoder)(rocDecDecoderHandle decoder_handle);
typedef rocDecStatus (ROCDECAPI *PfnRocDecGetDecoderCaps)(RocdecDecodeCaps *decode_caps);
typedef rocDecStatus (ROCDECAPI *PfnRocDecDecodeFrame)(rocDecDecoderHandle decoder_handle, RocdecPicParams *pic_params);
typedef rocDecStatus (ROCDECAPI *PfnRocDecGetDecodeStatus)(rocDecDecoderHandle decoder_handle, int pic_idx, RocdecDecodeStatus *decode_status);
typedef rocDecStatus (ROCDECAPI *PfnRocDecReconfigureDecoder)(rocDecDecoderHandle decoder_handle, RocdecReconfigureDecoderInfo *reconfig_params);
typedef rocDecStatus (ROCDECAPI *PfnRocDecGetVideoFrame)(rocDecDecoderHandle decoder_handle, int pic_idx, void *dev_mem_ptr[3], uint32_t *horizontal_pitch, RocdecProcParams *vid_postproc_params);
typedef const char* (ROCDECAPI *PfnRocDecGetErrorName)(rocDecStatus rocdec_status);
typedef rocDecStatus (ROCDECAPI *PfnRocDecCreateBitstreamReader)(RocdecBitstreamReader *bs_reader_handle, const char *input_file_path);
typedef rocDecStatus (ROCDECAPI *PfnRocDecGetBitstreamCodecType)(RocdecBitstreamReader bs_reader_handle, rocDecVideoCodec *codec_type);
typedef rocDecStatus (ROCDECAPI *PfnRocDecGetBitstreamBitDepth)(RocdecBitstreamReader bs_reader_handle, int *bit_depth);
typedef rocDecStatus (ROCDECAPI *PfnRocDecGetBitstreamPicData)(RocdecBitstreamReader bs_reader_handle, uint8_t **pic_data, int *pic_size, int64_t *pts);
typedef rocDecStatus (ROCDECAPI *PfnRocDecDestroyBitstreamReader)(RocdecBitstreamReader bs_reader_handle);
// rocDecode API dispatch table
struct RocDecodeDispatchTable {
// ROCDECODE_RUNTIME_API_TABLE_STEP_VERSION == 0
size_t size;
PfnRocDecCreateVideoParser pfn_rocdec_create_video_parser;
PfnRocDecParseVideoData pfn_rocdec_parse_video_data;
PfnRocDecDestroyVideoParser pfn_rocdec_destroy_video_parser;
PfnRocDecCreateDecoder pfn_rocdec_create_decoder;
PfnRocDecDestroyDecoder pfn_rocdec_destroy_decoder;
PfnRocDecGetDecoderCaps pfn_rocdec_get_gecoder_caps;
PfnRocDecDecodeFrame pfn_rocdec_decode_frame;
PfnRocDecGetDecodeStatus pfn_rocdec_get_decode_status;
PfnRocDecReconfigureDecoder pfn_rocdec_reconfigure_decoder;
PfnRocDecGetVideoFrame pfn_rocdec_get_video_frame;
PfnRocDecGetErrorName pfn_rocdec_get_error_name;
// PLEASE DO NOT EDIT ABOVE!
// ROCDECODE_RUNTIME_API_TABLE_STEP_VERSION == 1
PfnRocDecCreateBitstreamReader pfn_rocdec_create_bitstream_reader;
PfnRocDecGetBitstreamCodecType pfn_rocdec_get_bitstream_codec_type;
PfnRocDecGetBitstreamBitDepth pfn_rocdec_get_bitstream_bit_depth;
PfnRocDecGetBitstreamPicData pfn_rocdec_get_bitstream_pic_data;
PfnRocDecDestroyBitstreamReader pfn_rocdec_destroy_bitstream_reader;
// PLEASE DO NOT EDIT ABOVE!
// ROCDECODE_RUNTIME_API_TABLE_STEP_VERSION == 2
// ******************************************************************************************* //
// READ BELOW
// ******************************************************************************************* //
// Please keep this text at the end of the structure:
// 1. Do not reorder any existing members.
// 2. Increase the step version definition before adding new members.
// 3. Insert new members under the appropriate step version comment.
// 4. Generate a comment for the next step version.
// 5. Add a "PLEASE DO NOT EDIT ABOVE!" comment.
// ******************************************************************************************* //
};
+59
Просмотреть файл
@@ -0,0 +1,59 @@
/*
Copyright (c) 2024 - 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.
*/
#ifndef _ROCDECODE_HOST_VERSION_H_
#define _ROCDECODE_HOST_VERSION_H_
/*!
* \file
* \brief rocDecode host version
* \defgroup group_rocdecode_host_version rocdecode-host Version
* \brief rocdecode-host version
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define ROCDECODE_HOST_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define ROCDECODE_HOST_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define ROCDECODE_HOST_VERSION_PATCH @PROJECT_VERSION_PATCH@
/**
* ROCDECODE_HOST_CHECK_VERSION:
* @major: major version, like 1 in 1.2.3
* @minor: minor version, like 2 in 1.2.3
* @patch: patch version, like 3 in 1.2.3
*
* Evaluates to %TRUE if the version of ROCDECODE HOST is greater than
* @major, @minor and @patch
*/
#define ROCDECODE_HOST_CHECK_VERSION(major, minor, patch) \
(ROCDECODE_HOST_VERSION_MAJOR > (major) || \
(ROCDECODE_HOST_VERSION_MAJOR == (major) && ROCDECODE_HOST_VERSION_MINOR > (minor)) || \
(ROCDECODE_HOST_VERSION_MAJOR == (major) && ROCDECODE_HOST_VERSION_MINOR == (minor) && ROCDECODE_HOST_VERSION_PATCH >= (patch)))
#ifdef __cplusplus
} // end extern "C" block
#endif
#endif //_ROCDECODE_HOST_VERSION_H_ header guard
+85
Просмотреть файл
@@ -0,0 +1,85 @@
/*
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.
*/
#pragma once
#include "rocdecode/rocdecode.h"
/*!
* \file
* \brief The AMD rocBitstreamReader Library.
*
* \defgroup group_roc_bitstream_reader rocDecode Parser: AMD ROCm Video Bitstream Reader API
* \brief AMD The rocBitstreamReader is a toolkit to read picture data from bitstream files for decoding on AMDs GPUs.
*/
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
/*********************************************************************************/
//! HANDLE of rocBitstreamReader
//! Used in subsequent API calls after rocDecCreateBitstreamReader
/*********************************************************************************/
typedef void *RocdecBitstreamReader;
/************************************************************************************************/
//! \ingroup group_roc_bitstream_reader
//! \fn rocDecStatus ROCDECAPI rocDecCreateBitstreamReader(RocdecBitstreamReader *bs_reader_handle, const char *input_file_path)
//! Create video bitstream reader object and initialize
/************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecCreateBitstreamReader(RocdecBitstreamReader *bs_reader_handle, const char *input_file_path);
/************************************************************************************************/
//! \ingroup group_roc_bitstream_reader
//! \fn rocDecStatus ROCDECAPI rocDecGetBitstreamCodecType(RocdecBitstreamReader bs_reader_handle, rocDecVideoCodec *codec_type)
//! Get the codec type of the bitstream
/************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecGetBitstreamCodecType(RocdecBitstreamReader bs_reader_handle, rocDecVideoCodec *codec_type);
/************************************************************************************************/
//! \ingroup group_roc_bitstream_reader
//! \fn rocDecStatus ROCDECAPI rocDecGetBitstreamBitDepth(RocdecBitstreamReader bs_reader_handle, int *bit_depth)
//! Get the bit depth of the bitstream
/************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecGetBitstreamBitDepth(RocdecBitstreamReader bs_reader_handle, int *bit_depth);
/************************************************************************************************/
//! \ingroup group_roc_bitstream_reader
//! \fn rocDecStatus ROCDECAPI rocDecGetBitstreamPicData(RocdecBitstreamReader bs_reader_handle, uint8_t **pic_data, int *pic_size, int64_t *pts)
//! Read one unit of picture data from the bitstream. The unit can be a frame or field for AVC/HEVC,
//! a temporal unit for AV1, or a frame (including superframe) for VP9. The picture data unit is pointed
//! by pic_data. The size of the unit is specified by pic_size. The presentation time stamp, if available,
//! is given by pts.
/************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecGetBitstreamPicData(RocdecBitstreamReader bs_reader_handle, uint8_t **pic_data, int *pic_size, int64_t *pts);
/************************************************************************************************/
//! \ingroup group_roc_bitstream_reader
//! \fn rocDecStatus ROCDECAPI rocDecDestroyBitstreamReader(RocdecBitstreamReader bs_reader_handle)
//! Destroy the video parser object
/************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecDestroyBitstreamReader(RocdecBitstreamReader bs_reader_handle);
#if defined(__cplusplus)
}
#endif /* __cplusplus */
Разница между файлами не показана из-за своего большого размера Загрузить разницу
+190
Просмотреть файл
@@ -0,0 +1,190 @@
/*
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.
*/
#ifndef ROCDECAPI
#if defined(_WIN32)
#define ROCDECAPI __stdcall // for future: only linux is supported in this version
#else
#define ROCDECAPI
#endif
#endif
#pragma once
#include "hip/hip_runtime.h"
#include "rocdecode.h"
#include "rocparser.h"
/*!
* \file
* \brief The AMD rocDecode Library.
*
* \defgroup group_amd_rocdecode rocDecode: AMD ROCm Software Decode API
* \brief The rocDecodeHost is a part of rocDecode toolkit to decode videos and images using a avcodec based video decoder on ROCm.
*/
#if defined(__cplusplus)
extern "C" {
#endif // __cplusplus
/****************************************************************/
//! \ingroup group_rocdec_struct
//! \struct RocdecVideoFormatHost
//! Video format including raw sequence header information
//! Used in rocDecCreateVideoParser API
/****************************************************************/
typedef struct {
RocdecVideoFormat video_format; /**< OUT: RocdecVideoFormat structure */
rocDecVideoSurfaceFormat video_surface_format; /**< OUT: output surface format */
uint32_t reserved[16]; // reserved for future
} RocdecVideoFormatHost;
typedef int(ROCDECAPI *PFNVIDSEQUENCECHOSTALLBACK)(void *, RocdecVideoFormatHost *);
typedef int(ROCDECAPI *PFNVIDDISPLAYHOSTCALLBACK)(void *, void *);
/******************************************************************************************/
//! \struct _RocdecPicParamsHost
//! \ingroup group_amd_rocdecode
//! Picture parameters for decoding
//! This structure is used in rocDecDecodePictureHost API
//! IN for rocDecDecodePictureHost
/******************************************************************************************/
typedef struct _RocdecPicParamsHost {
// Bitstream data
uint32_t bitstream_data_len; /**< IN: Number of bytes in bitstream data buffer */
const uint8_t *bitstream_data; /**< IN: Ptr to bitstream data for this picture (slice-layer) */
uint32_t flags; /**< IN: Combination of ROCDEC_PKT_XXX flags */
RocdecTimeStamp pts; /**< IN: Presentation time stamp (10MHz clock), only valid if ROCDEC_PKT_TIMESTAMP flag is set */
} RocdecPicParamsHost;
/**************************************************************************************************************/
//! \struct RocDecoderHostCreateInfo
//! \ingroup group_amd_rocdecode
//! This structure is used in rocDecCreateDecoderHost API
/**************************************************************************************************************/
typedef struct _RocDecoderHostCreateInfo {
uint32_t width; /**< IN: Coded sequence width in pixels */
uint32_t height; /**< IN: Coded sequence height in pixels */
uint32_t num_decode_threads; /**< IN: Maximum number of internal decode threads for multi-threading <default value 0: threading will be chosen as appropriate to get the max performace> */
rocDecVideoCodec codec_type; /**< IN: rocDecVideoCodec_XXX */
rocDecVideoChromaFormat chroma_format; /**< IN: rocDecVideoChromaFormat_XXX */
uint32_t bit_depth_minus_8; /**< IN: The value "BitDepth minus 8" */
uint32_t intra_decode_only; /**< IN: not used for avcodec based decoding (default value is 0). */
uint32_t max_width; /**< IN: Coded sequence max width in pixels used with reconfigure Decoder */
uint32_t max_height; /**< IN: Coded sequence max height in pixels used with reconfigure Decoder */
struct {
int16_t left;
int16_t top;
int16_t right;
int16_t bottom;
} display_rect; /**< IN: area of the frame that should be displayed */
rocDecVideoSurfaceFormat output_format; /**< IN: rocDecVideoSurfaceFormat_XXX */
uint32_t target_width; /**< IN: Post-processed output width (Should be aligned to 2) */
uint32_t target_height; /**< IN: Post-processed output height (Should be aligned to 2) */
uint32_t num_output_surfaces; /**< IN: Maximum number of output surfaces simultaneously mapped */
struct {
int16_t left;
int16_t top;
int16_t right;
int16_t bottom;
} target_rect; /**< IN: (for future use) target rectangle in the output frame (for aspect ratio conversion)
if a null rectangle is specified, {0,0,target_width,target_height} will be used*/
void *user_data; /**< IN: User data for callbacks */
// callback functions to enable users to consume decoded data
PFNVIDSEQUENCECHOSTALLBACK pfn_sequence_callback; /**< IN: Called before decoding frames and/or whenever there is a fmt change */
PFNVIDDISPLAYCALLBACK pfn_display_picture; /**< IN: Called whenever a picture is ready to be displayed (display order) */
PFNVIDSEIMSGCALLBACK pfn_get_sei_msg; /**< IN: Called when all SEI messages are parsed for particular frame */
uint32_t reserved[4]; /**< Reserved for future use - set to zero */
} RocDecoderHostCreateInfo;
/*****************************************************************************************************/
//! \fn rocDecStatus ROCDECAPI rocDecCreateDecoderHost(rocDecDecoderHandle *decoder_handle, RocDecoderHostCreateInfo *decoder_create_info)
//! \ingroup group_amd_rocdecode
//! Create the decoder object based on decoder_create_info. A handle to the created decoder is returned
/*****************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecCreateDecoderHost(rocDecDecoderHandle *decoder_handle, RocDecoderHostCreateInfo *decoder_create_info);
/*****************************************************************************************************/
//! \fn rocDecStatus ROCDECAPI rocDecDestroyDecoderHost(rocDecDecoderHandle decoder_handle)
//! \ingroup group_amd_rocdecode
//! Destroy the decoder object
/*****************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecDestroyDecoderHost(rocDecDecoderHandle decoder_handle);
/**********************************************************************************************************************/
//! \fn rocDecStatus ROCDECAPI rocDecGetDecoderCapsHost(RocdecDecodeCaps *decode_caps)
//! \ingroup group_amd_rocdecode
//! Queries decode capabilities of host based decoder based on codec type, chroma_format and BitDepthMinus8 parameters.
//! 1. Application fills IN parameters codec_type, chroma_format and BitDepthMinus8 of RocdecDecodeCaps structure
//! 2. For FFMpeg avcodec based decoder, this call returns success
/**********************************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecGetDecoderCapsHost(RocdecDecodeCaps *decode_caps);
/*****************************************************************************************************/
//! \fn rocDecStatus ROCDECAPI rocDecDecodeFrameHost(rocDecDecoderHandle decoder_handle, RocdecPicParamsHost *pic_params)
//! \ingroup group_amd_rocdecode
//! Decodes a single picture
//! Submits the frame for host based decoding
/*****************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecDecodeFrameHost(rocDecDecoderHandle decoder_handle, RocdecPicParamsHost *pic_params);
/************************************************************************************************************/
//! \fn rocDecStatus ROCDECAPI rocDecGetDecodeStatusHost(rocDecDecoderHandle decoder_handle, int pic_idx, RocdecDecodeStatus* decode_status);
//! \ingroup group_amd_rocdecode
//! Get the decode status for frame corresponding to nPicIdx
//! API is currently supported for HEVC, AVC/H264 and JPEG codecs.
//! API returns ROCDEC_NOT_SUPPORTED error code for unsupported codec.
/************************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecGetDecodeStatusHost(rocDecDecoderHandle decoder_handle, int pic_idx, RocdecDecodeStatus *decode_status);
/*********************************************************************************************************/
//! \fn rocDecStatus ROCDECAPI rocDecReconfigureDecoderHost(rocDecDecoderHandle decoder_handle, RocdecReconfigureDecoderInfo *reconfig_params)
//! \ingroup group_amd_rocdecode
//! Used to reuse single decoder for multiple clips. Currently supports resolution change, resize params
//! params, target area params change for same codec. Must be called during RocdecParserParams::pfn_sequence_callback
/*********************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecReconfigureDecoderHost(rocDecDecoderHandle decoder_handle, RocdecReconfigureDecoderInfo *reconfig_params);
/************************************************************************************************************************/
//! \fn extern rocDecStatus ROCDECAPI rocDecGetVideoFrameHost(rocDecDecoderHandle decoder_handle, int pic_idx,
//! uint32_t *frame_data, uint32_t *line_size,
//! RocdecProcParams *vid_postproc_params);
//! \ingroup group_amd_rocdecode
//! Post-process and map video frame corresponding to pic_idx for use in HIP. Returns HIP device pointer and associated
//! line_size of the video frame. Returns host memory pointers and pitch for each plane (Y, U and V) seperately
//! line_size is a pointer to an unsigned 32-bit integer array of size 3.
/************************************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecGetVideoFrameHost(rocDecDecoderHandle decoder_handle, int pic_idx,
void **frame_data, uint32_t *line_size,
RocdecProcParams *vid_postproc_params);
/*****************************************************************************************************/
//! \fn const char* ROCDECAPI rocDecGetErrorNameHost(rocDecStatus rocdec_status)
//! \ingroup group_amd_rocdecode
//! Return name of the specified error code in text form.
/*****************************************************************************************************/
extern const char *ROCDECAPI rocDecGetErrorNameHost(rocDecStatus rocdec_status);
#ifdef __cplusplus
}
#endif
+297
Просмотреть файл
@@ -0,0 +1,297 @@
/*
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.
*/
#pragma once
#include "rocdecode/rocdecode.h"
/*!
* \file
* \brief The AMD rocParser Library.
*
* \defgroup group_rocparser rocDecode Parser: AMD ROCm Video Parser API
* \brief AMD The rocDecode video parser for AMDs GPUs.
* \defgroup group_rocdec_struct rocDecode Parser Structs: AMD ROCm Video Parser Structs
* \brief AMD The rocDecode video parser struct
*/
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
/*********************************************************************************/
//! HANDLE pf rocDecDecoder
//! Used in subsequent API calls after rocDecCreateDecoder
/*********************************************************************************/
typedef void *RocdecVideoParser;
typedef uint64_t RocdecTimeStamp;
/***************************************************************/
//! \enum RocdecReconfigOptions
//! Decoder reconfigure options for VP9 decode
//! Used in RocdecVideoFormat structure
/***************************************************************/
typedef enum {
ROCDEC_RECONFIG_NEW_SURFACES = 0, /**< Allocate new surfaces during decoder reconfig */
ROCDEC_RECONFIG_KEEP_SURFACES = 1, /**< Keep existing surfaces during decoder reconfig */
} RocdecReconfigOptions;
/**
* @brief ROCDEC_VIDEO_FORMAT struct
* @ingroup group_rocdec_struct
* Used in Parser callback API
*/
typedef struct {
rocDecVideoCodec codec; /**< OUT: Compression format */
/**
* OUT: frame rate = numerator / denominator (for example: 30000/1001)
*/
struct {
/**< OUT: frame rate numerator (0 = unspecified or variable frame rate) */
uint32_t numerator;
/**< OUT: frame rate denominator (0 = unspecified or variable frame rate) */
uint32_t denominator;
} frame_rate;
uint8_t progressive_sequence; /**< OUT: 0=interlaced, 1=progressive */
uint8_t bit_depth_luma_minus8; /**< OUT: high bit depth luma. E.g, 2 for 10-bitdepth, 4 for 12-bitdepth */
uint8_t bit_depth_chroma_minus8; /**< OUT: high bit depth chroma. E.g, 2 for 10-bitdepth, 4 for 12-bitdepth */
uint8_t min_num_decode_surfaces; /**< OUT: Minimum number of decode surfaces to be allocated for correct
decoding. The client can send this value in num_decode_surfaces.
This guarantees correct functionality and optimal video memory
usage but not necessarily the best performance, which depends on
the design of the overall application. The optimal number of
decode surfaces (in terms of performance and memory utilization)
should be decided by experimentation for each application, but it
cannot go below min_num_decode_surfaces.
If this value is used for num_decode_surfaces then it must be
returned to parser during sequence callback. */
uint32_t coded_width; /**< OUT: coded frame width in pixels */
uint32_t coded_height; /**< OUT: coded frame height in pixels */
/**
* area of the frame that should be displayed
* typical example:
* coded_width = 1920, coded_height = 1088
* display_area = { 0,0,1920,1080 }
*/
struct {
int left; /**< OUT: left position of display rect */
int top; /**< OUT: top position of display rect */
int right; /**< OUT: right position of display rect */
int bottom; /**< OUT: bottom position of display rect */
} display_area;
rocDecVideoChromaFormat chroma_format; /**< OUT: Chroma format */
uint32_t bitrate; /**< OUT: video bitrate (bps, 0=unknown) */
/**
* OUT: Display Aspect Ratio = x:y (4:3, 16:9, etc)
*/
struct {
int x;
int y;
} display_aspect_ratio;
/**
* Video Signal Description
* Refer section E.2.1 (VUI parameters semantics) of H264 spec file
*/
struct {
uint8_t video_format : 3; /**< OUT: 0-Component, 1-PAL, 2-NTSC, 3-SECAM, 4-MAC, 5-Unspecified */
uint8_t video_full_range_flag : 1; /**< OUT: indicates the black level and luma and chroma range */
uint8_t reserved_zero_bits : 4; /**< Reserved bits */
uint8_t color_primaries; /**< OUT: chromaticity coordinates of source primaries */
uint8_t transfer_characteristics; /**< OUT: opto-electronic transfer characteristic of the source picture */
uint8_t matrix_coefficients; /**< OUT: used in deriving luma and chroma signals from RGB primaries */
} video_signal_description;
uint32_t seqhdr_data_length; /**< OUT: Additional bytes following (RocdecVideoFormatEx) */
uint32_t reconfig_options; /**< OUT: Refer to RocdecReconfigOptions */
} RocdecVideoFormat;
/****************************************************************/
//! \ingroup group_rocdec_struct
//! \struct RocdecVideoFormat
//! Video format including raw sequence header information
//! Used in rocDecCreateVideoParser API
/****************************************************************/
typedef struct {
RocdecVideoFormat format; /**< OUT: RocdecVideoFormat structure */
uint32_t max_width;
uint32_t max_height;
uint8_t raw_seqhdr_data[1024]; /**< OUT: Sequence header data */
} RocdecVideoFormatEx;
/***************************************************************/
//! \enum RocdecVideoPacketFlags
//! Data packet flags
//! Used in RocdecSourceDataPacket structure
/***************************************************************/
typedef enum {
ROCDEC_PKT_ENDOFSTREAM = 0x01, /**< Set when this is the last packet for this stream */
ROCDEC_PKT_TIMESTAMP = 0x02, /**< Timestamp is valid */
ROCDEC_PKT_DISCONTINUITY = 0x04, /**< Set when a discontinuity has to be signalled */
ROCDEC_PKT_ENDOFPICTURE = 0x08, /**< Set when the packet contains exactly one frame or one field */
ROCDEC_PKT_NOTIFY_EOS = 0x10, /**< If this flag is set along with ROCDEC_PKT_ENDOFSTREAM, an additional (dummy)
display callback will be invoked with null value of ROCDECPARSERDISPINFO which
should be interpreted as end of the stream. */
} RocdecVideoPacketFlags;
/*****************************************************************************/
//! \ingroup group_rocdec_struct
//! \struct RocdecSourceDataPacket
//! Data Packet
//! Used in rocDecParseVideoData API
//! IN for rocDecParseVideoData
/*****************************************************************************/
typedef struct _RocdecSourceDataPacket {
uint32_t flags; /**< IN: Combination of ROCDEC_PKT_XXX flags */
uint32_t payload_size; /**< IN: number of bytes in the payload (may be zero if EOS flag is set) */
const uint8_t *payload; /**< IN: Pointer to packet payload data (may be NULL if EOS flag is set) */
RocdecTimeStamp pts; /**< IN: Presentation time stamp (10MHz clock), only valid if ROCDEC_PKT_TIMESTAMP flag is set */
} RocdecSourceDataPacket;
/**********************************************************************************/
/*! \brief Timing Info struct
* \ingroup group_rocdec_struct
* \struct RocdecParserDispInfo
* \Used in rocdecParseVideoData API with PFNVIDDISPLAYCALLBACK pfn_display_picture
*/
/**********************************************************************************/
typedef struct _RocdecParserDispInfo {
int picture_index; /**< OUT: Index of the current picture */
int progressive_frame; /**< OUT: 1 if progressive frame; 0 otherwise */
int top_field_first; /**< OUT: 1 if top field is displayed first; 0 otherwise */
int repeat_first_field; /**< OUT: Number of additional fields (1=ivtc, 2=frame doubling, 4=frame tripling, -1=unpaired field) */
RocdecTimeStamp pts; /**< OUT: Presentation time stamp */
} RocdecParserDispInfo;
/**
* @brief RocdecOperatingPointInfo struct
* @ingroup group_rocdec_struct
* Operating point information of scalable bitstream
*/
typedef struct _RocdecOperatingPointInfo {
rocDecVideoCodec codec;
union {
struct
{
uint8_t operating_points_cnt;
uint8_t reserved24_bits[3];
uint16_t operating_points_idc[32];
} av1;
uint8_t codec_reserved[1024];
};
} RocdecOperatingPointInfo;
/**********************************************************************************/
//! \ingroup group_rocdec_struct
//! \struct RocdecSeiMessage;
//! Used in RocdecSeiMessageInfo structure
/**********************************************************************************/
typedef struct _RocdecSeiMessage {
uint8_t sei_message_type; /**< OUT: SEI Message Type */
uint8_t reserved[3];
uint32_t sei_message_size; /**< OUT: SEI Message Size */
} RocdecSeiMessage;
/**********************************************************************************/
//! \ingroup group_rocdec_struct
//! \struct RocdecSeiMessageInfo
//! Used in rocDecParseVideoData API with PFNVIDSEIMSGCALLBACK pfn_get_sei_msg
/**********************************************************************************/
typedef struct _RocdecSeiMessageInfo {
void *sei_data; /**< OUT: SEI Message Data */
RocdecSeiMessage *sei_message; /**< OUT: SEI Message Info */
uint32_t sei_message_count; /**< OUT: SEI Message Count */
uint32_t picIdx; /**< OUT: SEI Message Pic Index */
} RocdecSeiMessageInfo;
/**
* @brief Parser callbacks
* \ The parser will call these synchronously from within rocDecParseVideoData(), whenever there is sequence change or a picture
* \ is ready to be decoded and/or displayed.
* \ Return values from these callbacks are interpreted as below. If the callbacks return failure, it will be propagated by
* \ rocDecParseVideoData() to the application.
* \ Parser picks default operating point as 0 and outputAllLayers flag as 0 if PFNVIDOPPOINTCALLBACK is not set or return value is
* \ -1 or invalid operating point.
* \ PFNVIDSEQUENCECALLBACK : 0: fail, 1: succeeded, > 1: override dpb size of parser (set by RocdecParserParams::max_num_decode_surfaces
* \ while creating parser)
* \ PFNVIDDECODECALLBACK : 0: fail, >=1: succeeded
* \ PFNVIDDISPLAYCALLBACK : 0: fail, >=1: succeeded
* \ PFNVIDOPPOINTCALLBACK : <0: fail, >=0: succeeded (bit 0-9: OperatingPoint, bit 10-10: outputAllLayers, bit 11-30: reserved)
* \ PFNVIDSEIMSGCALLBACK : 0: fail, >=1: succeeded
*/
typedef int(ROCDECAPI *PFNVIDSEQUENCECALLBACK)(void *, RocdecVideoFormat *);
typedef int(ROCDECAPI *PFNVIDDECODECALLBACK)(void *, RocdecPicParams *);
typedef int(ROCDECAPI *PFNVIDDISPLAYCALLBACK)(void *, RocdecParserDispInfo *);
// typedef int (ROCDECAPI *PFNVIDOPPOINTCALLBACK)(void *, RocdecOperatingPointInfo*); // reserved for future (AV1 specific)
typedef int(ROCDECAPI *PFNVIDSEIMSGCALLBACK)(void *, RocdecSeiMessageInfo *);
/**
* \brief The AMD rocDecode library.
* \ingroup group_rocdec_struct
* \Used in rocDecCreateVideoParser API
*/
typedef struct _RocdecParserParams {
rocDecVideoCodec codec_type; /**< IN: rocDecVideoCodec_XXX */
uint32_t max_num_decode_surfaces; /**< IN: Max # of decode surfaces (parser will cycle through these) */
uint32_t clock_rate; /**< IN: Timestamp units in Hz (0=default=10000000Hz) */
uint32_t error_threshold; /**< IN: % Error threshold (0-100) for calling pfn_decode_picture (100=always IN: call pfn_decode_picture even if picture bitstream is fully corrupted) */
uint32_t max_display_delay; /**< IN: Max display queue delay (improves pipelining of decode with display) 0 = no delay (recommended values: 2..4) */
uint32_t annex_b : 1; /**< IN: AV1 annexB stream */
uint32_t reserved : 31; /**< Reserved for future use - set to zero */
uint32_t reserved_1[4]; /**< IN: Reserved for future use - set to 0 */
void *user_data; /**< IN: User data for callbacks */
PFNVIDSEQUENCECALLBACK pfn_sequence_callback; /**< IN: Called before decoding frames and/or whenever there is a fmt change */
PFNVIDDECODECALLBACK pfn_decode_picture; /**< IN: Called when a picture is ready to be decoded (decode order) */
PFNVIDDISPLAYCALLBACK pfn_display_picture; /**< IN: Called whenever a picture is ready to be displayed (display order) */
PFNVIDSEIMSGCALLBACK pfn_get_sei_msg; /**< IN: Called when all SEI messages are parsed for particular frame */
void *reserved_2[5]; /**< Reserved for future use - set to NULL */
RocdecVideoFormatEx *ext_video_info; /**< IN: [Optional] sequence header data from system layer */
} RocdecParserParams;
/************************************************************************************************/
//! \ingroup group_rocparser
//! \fn rocDecodeStatus ROCDECAPI rocDecCreateVideoParser(RocdecVideoParser *parser_handle, RocdecParserParams *params)
//! Create video parser object and initialize
/************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecCreateVideoParser(RocdecVideoParser *parser_handle, RocdecParserParams *params);
/************************************************************************************************/
//! \ingroup group_rocparser
//! \fn rocDecodeStatus ROCDECAPI rocDecParseVideoData(RocdecVideoParser parser_handle, RocdecSourceDataPacket *packet)
//! Parse the video data from source data packet in pPacket
//! Extracts parameter sets like SPS, PPS, bitstream etc. from pPacket and
//! calls back pfn_decode_picture with RocdecPicParams data for kicking of HW decoding
//! calls back pfn_sequence_callback with RocdecVideoFormat data for initial sequence header or when
//! the decoder encounters a video format change
//! calls back pfn_display_picture with RocdecParserDispInfo data to display a video frame
/************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecParseVideoData(RocdecVideoParser parser_handle, RocdecSourceDataPacket *packet);
/************************************************************************************************/
//! \ingroup group_rocparser
//! \fn rocDecStatus ROCDECAPI rocDecDestroyVideoParser(RocdecVideoParser parser_handle)
//! Destroy the video parser object
/************************************************************************************************/
extern rocDecStatus ROCDECAPI rocDecDestroyVideoParser(RocdecVideoParser parser_handle);
#if defined(__cplusplus)
}
#endif /* __cplusplus */
+59
Просмотреть файл
@@ -0,0 +1,59 @@
/*
Copyright (c) 2024 - 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.
*/
#ifndef _ROCDECODE_VERSION_H_
#define _ROCDECODE_VERSION_H_
/*!
* \file
* \brief rocDecode version
* \defgroup group_rocdecode_version rocDecode Version
* \brief rocDecode version
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define ROCDECODE_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define ROCDECODE_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define ROCDECODE_VERSION_PATCH @PROJECT_VERSION_PATCH@
/**
* ROCDECODE_CHECK_VERSION:
* @major: major version, like 1 in 1.2.3
* @minor: minor version, like 2 in 1.2.3
* @patch: patch version, like 3 in 1.2.3
*
* Evaluates to %TRUE if the version of ROCDECODE is greater than
* @major, @minor and @patch
*/
#define ROCDECODE_CHECK_VERSION(major, minor, patch) \
(ROCDECODE_VERSION_MAJOR > (major) || \
(ROCDECODE_VERSION_MAJOR == (major) && ROCDECODE_VERSION_MINOR > (minor)) || \
(ROCDECODE_VERSION_MAJOR == (major) && ROCDECODE_VERSION_MINOR == (minor) && ROCDECODE_VERSION_PATCH >= (patch)))
#ifdef __cplusplus
} // end extern "C" block
#endif
#endif //_ROCDECODE_VERSION_H_ header guard