rocDecode API Tracing Support (#49)
* rocDecode API Tracing support * Test bin file added to rocdecode. Need to add validate python methods * Added option to not make rocDecode tests * Added rocdecode and rocprofv3 tests * Added csv test * Address PR comments. Changed tests to use built-in rocstreambit decoder to remove ffmpeg dependancy. Changed cmake option to disbale tests rather than not build them. Tests work locally, but will fail until rocDecode is built with tracing enabled on CI * Add option to avoid building rocdecode tests * Added option to avoid building rocdecode bin file * Merge conflict error * CMake files changed in response to review comments. Attempting to implement callbacks. * Turned off test building for rocdecode * Minor fixes for review comments * Review comments * Updated formatting * Document changes and format.hpp reversion. Need to remove iterate args support for now for later update. * Remove iterate args support * Remove iterate-args * enforce abi versioning in macro if * Fix doc error * removed spaces to fix indentation error --------- Co-authored-by: Madsen, Jonathan <Jonathan.Madsen@amd.com>
This commit is contained in:
@@ -31,6 +31,7 @@ set(ROCPROFILER_HEADER_FILES
|
||||
profile_config.h
|
||||
registration.h
|
||||
rccl.h
|
||||
rocdecode.h
|
||||
spm.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||
|
||||
@@ -44,6 +45,7 @@ add_subdirectory(hsa)
|
||||
add_subdirectory(marker)
|
||||
add_subdirectory(ompt)
|
||||
add_subdirectory(rccl)
|
||||
add_subdirectory(rocdecode)
|
||||
add_subdirectory(cxx)
|
||||
add_subdirectory(kfd)
|
||||
add_subdirectory(amd_detail)
|
||||
|
||||
@@ -182,6 +182,25 @@ typedef struct
|
||||
/// @brief Specification of the API function, e.g., ::rocprofiler_rccl_api_id_t
|
||||
} rocprofiler_buffer_tracing_rccl_api_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Buffer ROCDecode API Record.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t size; ///< size of this struct
|
||||
rocprofiler_buffer_tracing_kind_t kind;
|
||||
rocprofiler_tracing_operation_t operation;
|
||||
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
|
||||
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
|
||||
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
|
||||
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
|
||||
|
||||
/// @var kind
|
||||
/// @brief ::ROCPROFILER_CALLBACK_TRACING_ROCDECODE_API
|
||||
/// @var operation
|
||||
/// @brief Specification of the API function, e.g., ::rocprofiler_rocdecode_api_id_t
|
||||
} rocprofiler_buffer_tracing_rocdecode_api_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Buffer Memory Copy Tracer Record.
|
||||
*/
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <rocprofiler-sdk/marker.h>
|
||||
#include <rocprofiler-sdk/ompt.h>
|
||||
#include <rocprofiler-sdk/rccl.h>
|
||||
#include <rocprofiler-sdk/rocdecode.h>
|
||||
|
||||
#include <hsa/hsa.h>
|
||||
#include <hsa/hsa_amd_tool.h>
|
||||
@@ -108,6 +109,16 @@ typedef struct
|
||||
rocprofiler_rccl_api_retval_t retval;
|
||||
} rocprofiler_callback_tracing_rccl_api_data_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler ROCDecode API Callback Data.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t size; ///< size of this struct
|
||||
rocprofiler_rocdecode_api_args_t args;
|
||||
rocprofiler_rocdecode_api_retval_t retval;
|
||||
} rocprofiler_callback_tracing_rocdecode_api_data_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Code Object Load Tracer Callback Record.
|
||||
*/
|
||||
|
||||
@@ -82,6 +82,7 @@ ROCPROFILER_DEFINE_CATEGORY(category, openmp, "OpenMP")
|
||||
ROCPROFILER_DEFINE_CATEGORY(category, kernel_dispatch, "GPU kernel dispatch")
|
||||
ROCPROFILER_DEFINE_CATEGORY(category, memory_copy, "Async memory copy")
|
||||
ROCPROFILER_DEFINE_CATEGORY(category, memory_allocation, "Memory Allocation")
|
||||
ROCPROFILER_DEFINE_CATEGORY(category, rocdecode_api, "ROCDecode API function")
|
||||
|
||||
#define ROCPROFILER_PERFETTO_CATEGORIES \
|
||||
ROCPROFILER_PERFETTO_CATEGORY(category::hsa_api), \
|
||||
@@ -91,7 +92,8 @@ ROCPROFILER_DEFINE_CATEGORY(category, memory_allocation, "Memory Allocation")
|
||||
ROCPROFILER_PERFETTO_CATEGORY(category::openmp), \
|
||||
ROCPROFILER_PERFETTO_CATEGORY(category::kernel_dispatch), \
|
||||
ROCPROFILER_PERFETTO_CATEGORY(category::memory_copy), \
|
||||
ROCPROFILER_PERFETTO_CATEGORY(category::memory_allocation)
|
||||
ROCPROFILER_PERFETTO_CATEGORY(category::memory_allocation), \
|
||||
ROCPROFILER_PERFETTO_CATEGORY(category::rocdecode_api)
|
||||
|
||||
#include <perfetto.h>
|
||||
|
||||
|
||||
@@ -386,6 +386,21 @@ save(ArchiveT& ar, rocprofiler_callback_tracing_rccl_api_data_t data)
|
||||
ROCP_SDK_SAVE_DATA_FIELD(retval);
|
||||
}
|
||||
|
||||
template <typename ArchiveT>
|
||||
void
|
||||
save(ArchiveT& ar, rocprofiler_rocdecode_api_retval_t data)
|
||||
{
|
||||
ROCP_SDK_SAVE_DATA_FIELD(rocDecStatus_retval);
|
||||
}
|
||||
|
||||
template <typename ArchiveT>
|
||||
void
|
||||
save(ArchiveT& ar, rocprofiler_callback_tracing_rocdecode_api_data_t data)
|
||||
{
|
||||
ROCP_SDK_SAVE_DATA_FIELD(size);
|
||||
ROCP_SDK_SAVE_DATA_FIELD(retval);
|
||||
}
|
||||
|
||||
template <typename ArchiveT>
|
||||
void
|
||||
save(ArchiveT& ar, rocprofiler_callback_tracing_ompt_data_t data)
|
||||
@@ -479,6 +494,13 @@ save(ArchiveT& ar, rocprofiler_buffer_tracing_rccl_api_record_t data)
|
||||
save_buffer_tracing_api_record(ar, data);
|
||||
}
|
||||
|
||||
template <typename ArchiveT>
|
||||
void
|
||||
save(ArchiveT& ar, rocprofiler_buffer_tracing_rocdecode_api_record_t data)
|
||||
{
|
||||
save_buffer_tracing_api_record(ar, data);
|
||||
}
|
||||
|
||||
template <typename ArchiveT>
|
||||
void
|
||||
save(ArchiveT& ar, rocprofiler_buffer_tracing_ompt_target_t data)
|
||||
|
||||
@@ -69,6 +69,7 @@ typedef enum // NOLINT(performance-enum-size)
|
||||
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_RCCL_API, ///<
|
||||
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_OMPT, ///<
|
||||
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_MEMORY_ALLOCATION, ///<
|
||||
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_ROCDECODE_API, ///<
|
||||
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_LAST,
|
||||
} rocprofiler_external_correlation_id_request_kind_t;
|
||||
|
||||
|
||||
@@ -176,6 +176,7 @@ typedef enum // NOLINT(performance-enum-size)
|
||||
///< ::rocprofiler_memory_allocation_operation_t
|
||||
ROCPROFILER_CALLBACK_TRACING_RUNTIME_INITIALIZATION, ///< Callback notifying that a runtime
|
||||
///< library has been initialized
|
||||
ROCPROFILER_CALLBACK_TRACING_ROCDECODE_API, ///< rocDecode API Tracing
|
||||
ROCPROFILER_CALLBACK_TRACING_LAST,
|
||||
} rocprofiler_callback_tracing_kind_t;
|
||||
|
||||
@@ -207,6 +208,7 @@ typedef enum // NOLINT(performance-enum-size)
|
||||
ROCPROFILER_BUFFER_TRACING_RUNTIME_INITIALIZATION, ///< Record indicating a runtime library has
|
||||
///< been initialized. @see
|
||||
///< ::rocprofiler_runtime_initialization_operation_t
|
||||
ROCPROFILER_BUFFER_TRACING_ROCDECODE_API, ///< rocDecode tracing
|
||||
ROCPROFILER_BUFFER_TRACING_LAST,
|
||||
} rocprofiler_buffer_tracing_kind_t;
|
||||
|
||||
@@ -363,12 +365,13 @@ typedef enum
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ROCPROFILER_LIBRARY = (1 << 0),
|
||||
ROCPROFILER_HSA_LIBRARY = (1 << 1),
|
||||
ROCPROFILER_HIP_LIBRARY = (1 << 2),
|
||||
ROCPROFILER_MARKER_LIBRARY = (1 << 3),
|
||||
ROCPROFILER_RCCL_LIBRARY = (1 << 4),
|
||||
ROCPROFILER_LIBRARY_LAST = ROCPROFILER_RCCL_LIBRARY,
|
||||
ROCPROFILER_LIBRARY = (1 << 0),
|
||||
ROCPROFILER_HSA_LIBRARY = (1 << 1),
|
||||
ROCPROFILER_HIP_LIBRARY = (1 << 2),
|
||||
ROCPROFILER_MARKER_LIBRARY = (1 << 3),
|
||||
ROCPROFILER_RCCL_LIBRARY = (1 << 4),
|
||||
ROCPROFILER_ROCDECODE_LIBRARY = (1 << 5),
|
||||
ROCPROFILER_LIBRARY_LAST = ROCPROFILER_ROCDECODE_LIBRARY,
|
||||
} rocprofiler_runtime_library_t;
|
||||
|
||||
/**
|
||||
@@ -384,7 +387,8 @@ typedef enum
|
||||
ROCPROFILER_MARKER_CONTROL_TABLE = (1 << 4),
|
||||
ROCPROFILER_MARKER_NAME_TABLE = (1 << 5),
|
||||
ROCPROFILER_RCCL_TABLE = (1 << 6),
|
||||
ROCPROFILER_TABLE_LAST = ROCPROFILER_RCCL_TABLE,
|
||||
ROCPROFILER_ROCDECODE_TABLE = (1 << 7),
|
||||
ROCPROFILER_TABLE_LAST = ROCPROFILER_ROCDECODE_TABLE,
|
||||
} rocprofiler_intercept_table_t;
|
||||
|
||||
/**
|
||||
@@ -392,11 +396,12 @@ typedef enum
|
||||
*/
|
||||
typedef enum // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCPROFILER_RUNTIME_INITIALIZATION_NONE = 0, ///< Unknown runtime initialization
|
||||
ROCPROFILER_RUNTIME_INITIALIZATION_HSA, ///< Application loaded HSA runtime
|
||||
ROCPROFILER_RUNTIME_INITIALIZATION_HIP, ///< Application loaded HIP runtime
|
||||
ROCPROFILER_RUNTIME_INITIALIZATION_MARKER, ///< Application loaded Marker (ROCTx) runtime
|
||||
ROCPROFILER_RUNTIME_INITIALIZATION_RCCL, ///< Application loaded RCCL runtime
|
||||
ROCPROFILER_RUNTIME_INITIALIZATION_NONE = 0, ///< Unknown runtime initialization
|
||||
ROCPROFILER_RUNTIME_INITIALIZATION_HSA, ///< Application loaded HSA runtime
|
||||
ROCPROFILER_RUNTIME_INITIALIZATION_HIP, ///< Application loaded HIP runtime
|
||||
ROCPROFILER_RUNTIME_INITIALIZATION_MARKER, ///< Application loaded Marker (ROCTx) runtime
|
||||
ROCPROFILER_RUNTIME_INITIALIZATION_RCCL, ///< Application loaded RCCL runtime
|
||||
ROCPROFILER_RUNTIME_INITIALIZATION_ROCDECODE, ///< Application loaded rocDecode runtime
|
||||
ROCPROFILER_RUNTIME_INITIALIZATION_LAST,
|
||||
} rocprofiler_runtime_initialization_operation_t;
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2025 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 <rocprofiler-sdk/rocdecode/api_args.h>
|
||||
#include <rocprofiler-sdk/rocdecode/api_id.h>
|
||||
#include <rocprofiler-sdk/rocdecode/table_id.h>
|
||||
@@ -0,0 +1,13 @@
|
||||
#
|
||||
#
|
||||
# Installation of public rocDecode headers
|
||||
#
|
||||
#
|
||||
set(ROCPROFILER_ROCDECODE_HEADER_FILES api_args.h api_id.h table_id.h)
|
||||
|
||||
install(
|
||||
FILES ${ROCPROFILER_ROCDECODE_HEADER_FILES}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/rocdecode
|
||||
COMPONENT development)
|
||||
|
||||
add_subdirectory(details)
|
||||
@@ -0,0 +1,165 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2025 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 <rocprofiler-sdk/defines.h>
|
||||
#include <rocprofiler-sdk/version.h>
|
||||
|
||||
#if !defined(ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE)
|
||||
# if defined __has_include
|
||||
# if __has_include(<rocdecode/rocparser.h>) && __has_include(<rocdecode/rocdecode.h>) && __has_include(<rocdecode/roc_bitstream_reader.h>)
|
||||
# define ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE 1
|
||||
# else
|
||||
# define ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE 0
|
||||
# endif
|
||||
# else
|
||||
# define ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE > 0
|
||||
# include <rocdecode/roc_bitstream_reader.h>
|
||||
# include <rocdecode/rocdecode.h>
|
||||
# include <rocdecode/rocparser.h>
|
||||
#else
|
||||
# include <rocprofiler-sdk/rocdecode/details/roc_bitstream_reader.h>
|
||||
# include <rocprofiler-sdk/rocdecode/details/rocdecode.h>
|
||||
# include <rocprofiler-sdk/rocdecode/details/rocparser.h>
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
// Empty struct has a size of 0 in C but size of 1 in C++.
|
||||
// This struct is added to the union members which represent
|
||||
// functions with no arguments to ensure ABI compatibility
|
||||
typedef struct rocprofiler_rocdecode_api_no_args
|
||||
{
|
||||
char empty;
|
||||
} rocprofiler_rocdecode_api_no_args;
|
||||
|
||||
typedef union rocprofiler_rocdecode_api_retval_t
|
||||
{
|
||||
int32_t rocDecStatus_retval;
|
||||
const char* const_charp_retval;
|
||||
} rocprofiler_rocdecode_api_retval_t;
|
||||
|
||||
typedef union rocprofiler_rocdecode_api_args_t
|
||||
{
|
||||
struct
|
||||
{
|
||||
RocdecVideoParser* parser_handle;
|
||||
RocdecParserParams* params;
|
||||
} rocDecCreateVideoParser;
|
||||
|
||||
struct
|
||||
{
|
||||
RocdecVideoParser parser_handle;
|
||||
RocdecSourceDataPacket* packet;
|
||||
} rocDecParseVideoData;
|
||||
|
||||
struct
|
||||
{
|
||||
RocdecVideoParser parser_handle;
|
||||
} rocDecDestroyVideoParser;
|
||||
|
||||
struct
|
||||
{
|
||||
rocDecDecoderHandle* decoder_handle;
|
||||
RocDecoderCreateInfo* decoder_create_info;
|
||||
} rocDecCreateDecoder;
|
||||
|
||||
struct
|
||||
{
|
||||
rocDecDecoderHandle decoder_handle;
|
||||
} rocDecDestroyDecoder;
|
||||
|
||||
struct
|
||||
{
|
||||
RocdecDecodeCaps* decode_caps;
|
||||
} rocDecGetDecoderCaps;
|
||||
|
||||
struct
|
||||
{
|
||||
rocDecDecoderHandle decoder_handle;
|
||||
RocdecPicParams* pic_params;
|
||||
} rocDecDecodeFrame;
|
||||
|
||||
struct
|
||||
{
|
||||
rocDecDecoderHandle decoder_handle;
|
||||
int pic_idx;
|
||||
RocdecDecodeStatus* decode_status;
|
||||
} rocDecGetDecodeStatus;
|
||||
|
||||
struct
|
||||
{
|
||||
rocDecDecoderHandle decoder_handle;
|
||||
RocdecReconfigureDecoderInfo* reconfig_params;
|
||||
} rocDecReconfigureDecoder;
|
||||
|
||||
struct
|
||||
{
|
||||
rocDecDecoderHandle decoder_handle;
|
||||
int pic_idx;
|
||||
void** dev_mem_ptr;
|
||||
uint32_t* horizontal_pitch;
|
||||
RocdecProcParams* vid_postproc_params;
|
||||
} rocDecGetVideoFrame;
|
||||
struct
|
||||
{
|
||||
rocDecStatus rocdec_status;
|
||||
} rocDecGetErrorName;
|
||||
|
||||
#if ROCDECODE_RUNTIME_API_TABLE_STEP_VERSION >= 1
|
||||
struct
|
||||
{
|
||||
RocdecBitstreamReader* bs_reader_handle;
|
||||
const char* input_file_path;
|
||||
} rocDecCreateBitstreamReader;
|
||||
struct
|
||||
{
|
||||
RocdecBitstreamReader bs_reader_handle;
|
||||
rocDecVideoCodec* codec_type;
|
||||
} rocDecGetBitstreamCodecType;
|
||||
struct
|
||||
{
|
||||
RocdecBitstreamReader bs_reader_handle;
|
||||
int* bit_depth;
|
||||
} rocDecGetBitstreamBitDepth;
|
||||
struct
|
||||
{
|
||||
RocdecBitstreamReader bs_reader_handle;
|
||||
uint8_t** pic_data;
|
||||
int* pic_size;
|
||||
int64_t* pts;
|
||||
} rocDecGetBitstreamPicData;
|
||||
struct
|
||||
{
|
||||
RocdecBitstreamReader bs_reader_handle;
|
||||
} rocDecDestroyBitstreamReader;
|
||||
#endif
|
||||
} rocprofiler_rocdecode_api_args_t;
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -0,0 +1,56 @@
|
||||
|
||||
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2025 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 <rocprofiler-sdk/version.h>
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler enumeration of HSA Core API tracing operations
|
||||
*/
|
||||
typedef enum // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCPROFILER_ROCDECODE_API_ID_NONE = -1,
|
||||
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecCreateVideoParser = 0,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecParseVideoData,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecDestroyVideoParser,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecCreateDecoder,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecDestroyDecoder,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecGetDecoderCaps,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecDecodeFrame,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecGetDecodeStatus,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecReconfigureDecoder,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecGetVideoFrame,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecGetErrorName,
|
||||
|
||||
#if ROCDECODE_RUNTIME_API_TABLE_STEP_VERSION >= 1
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecCreateBitstreamReader,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecGetBitstreamCodecType,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecGetBitstreamBitDepth,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecGetBitstreamPicData,
|
||||
ROCPROFILER_ROCDECODE_API_ID_rocDecDestroyBitstreamReader,
|
||||
#endif
|
||||
ROCPROFILER_ROCDECODE_API_ID_LAST,
|
||||
} rocprofiler_rocdecode_api_id_t;
|
||||
@@ -0,0 +1,13 @@
|
||||
#
|
||||
#
|
||||
# Installation of public ROCDecode headers
|
||||
#
|
||||
#
|
||||
set(ROCPROFILER_ROCDECODE_DETAILS_HEADER_FILES
|
||||
rocdecode_api_trace.h rocdecode.h rocparser.h rocdecode_version.h
|
||||
roc_bitstream_reader.h)
|
||||
|
||||
install(
|
||||
FILES ${ROCPROFILER_ROCDECODE_DETAILS_HEADER_FILES}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/rocdecode/details
|
||||
COMPONENT development)
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
Copyright (c) 2024 - 2025 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
|
||||
|
||||
#if !defined(ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE)
|
||||
# if defined __has_include
|
||||
# if __has_include(<rocdecode/rocdecode.h>)
|
||||
# define ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE 1
|
||||
# else
|
||||
# define ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE 0
|
||||
# endif
|
||||
# else
|
||||
# define ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE > 0
|
||||
# include <rocdecode/rocdecode.h>
|
||||
#else
|
||||
# include <rocprofiler-sdk/rocdecode/details/rocdecode.h>
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \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 AMD’s 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 */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
Copyright (c) 2024 - 2025 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
|
||||
|
||||
#if !defined(ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE)
|
||||
# if defined __has_include
|
||||
# if __has_include(<rocdecode/rocparser.h>) && __has_include(<rocdecode/rocdecode.h>) && __has_include(<rocdecode/roc_bitstream_reader.h>)
|
||||
# define ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE 1
|
||||
# else
|
||||
# define ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE 0
|
||||
# endif
|
||||
# else
|
||||
# define ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE > 0
|
||||
# include <rocdecode/roc_bitstream_reader.h>
|
||||
# include <rocdecode/rocdecode.h>
|
||||
# include <rocdecode/rocparser.h>
|
||||
#else
|
||||
# include <rocprofiler-sdk/rocdecode/details/roc_bitstream_reader.h>
|
||||
# include <rocprofiler-sdk/rocdecode/details/rocdecode.h>
|
||||
# include <rocprofiler-sdk/rocdecode/details/rocparser.h>
|
||||
#endif
|
||||
|
||||
// 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.
|
||||
// *******************************************************************************************
|
||||
// //
|
||||
};
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (c) 2024 - 2024 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
|
||||
/* NOTE: Match version with CMakeLists.txt */
|
||||
#define ROCDECODE_MAJOR_VERSION 0
|
||||
#define ROCDECODE_MINOR_VERSION 10
|
||||
#define ROCDECODE_MICRO_VERSION 0
|
||||
|
||||
/**
|
||||
* ROCDECODE_CHECK_VERSION:
|
||||
* @major: major version, like 1 in 1.2.3
|
||||
* @minor: minor version, like 2 in 1.2.3
|
||||
* @micro: micro version, like 3 in 1.2.3
|
||||
*
|
||||
* Evaluates to %TRUE if the version of rocDecode is greater than
|
||||
* @major, @minor and @micro
|
||||
*/
|
||||
#define ROCDECODE_CHECK_VERSION(major, minor, micro) \
|
||||
(ROCDECODE_MAJOR_VERSION > (major) || \
|
||||
(ROCDECODE_MAJOR_VERSION == (major) && ROCDECODE_MINOR_VERSION > (minor)) || \
|
||||
(ROCDECODE_MAJOR_VERSION == (major) && ROCDECODE_MINOR_VERSION == (minor) && \
|
||||
ROCDECODE_MICRO_VERSION >= (micro)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
Copyright (c) 2024 - 2025 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
|
||||
|
||||
#if !defined(ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE)
|
||||
# if defined __has_include
|
||||
# if __has_include(<rocdecode/rocdecode.h>)
|
||||
# define ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE 1
|
||||
# else
|
||||
# define ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE 0
|
||||
# endif
|
||||
# else
|
||||
# define ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ROCPROFILER_SDK_USE_SYSTEM_ROCDECODE > 0
|
||||
# include <rocdecode/rocdecode.h>
|
||||
#else
|
||||
# include <rocprofiler-sdk/rocdecode/details/rocdecode.h>
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \file
|
||||
* \brief The AMD rocParser Library.
|
||||
*
|
||||
* \defgroup group_rocparser rocDecode Parser: AMD ROCm Video Parser API
|
||||
* \brief AMD The rocDecode video parser for AMD’s 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;
|
||||
|
||||
/**
|
||||
* @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) */
|
||||
} 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 rocDecParserMarkFrameForReuse(RocdecVideoParser parser_handle, int
|
||||
//! pic_idx) Mark frame with index pic_idx in parser's buffer pool for reuse (means the frame has
|
||||
//! been consumed)
|
||||
/************************************************************************************************/
|
||||
extern rocDecStatus ROCDECAPI
|
||||
rocDecParserMarkFrameForReuse(RocdecVideoParser parser_handle, int pic_idx);
|
||||
|
||||
/************************************************************************************************/
|
||||
//! \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 */
|
||||
@@ -0,0 +1,31 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2025 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
|
||||
|
||||
// NOLINTNEXTLINE(performance-enum-size)
|
||||
typedef enum
|
||||
{
|
||||
ROCPROFILER_ROCDECODE_TABLE_ID_NONE = -1,
|
||||
ROCPROFILER_ROCDECODE_TABLE_ID = 0,
|
||||
ROCPROFILER_ROCDECODE_TABLE_ID_LAST,
|
||||
} rocprofiler_rocdecode_table_id_t;
|
||||
Reference in New Issue
Block a user