diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ba3e23df5..973fcdb4bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,8 +48,9 @@ find_package(Libva QUIET) if(HIP_FOUND AND Libva_FOUND) include_directories(api - src - src/vaapi + src/rocdecode + src/parser + src/rocdecode/vaapi ) file(GLOB_RECURSE SOURCES "./src/*.cpp") add_library(${PROJECT_NAME} SHARED ${SOURCES}) diff --git a/api/rocdecode.h b/api/rocdecode.h index 5f13c3c3b0..b57374b474 100644 --- a/api/rocdecode.h +++ b/api/rocdecode.h @@ -62,6 +62,7 @@ typedef enum rocDecStatus_enum{ ROCDEC_OUTOF_MEMORY = -4, ROCDEC_INVALID_PARAMETER = -5, ROCDEC_NOT_IMPLEMENTED = -6, + ROCDEC_NOT_SUPPORTED = -7, ROCDEC_SUCCESS = 0, }rocDecStatus; @@ -92,7 +93,7 @@ typedef enum rocDecVideoCodec_enum { /*********************************************************************************/ //! \enum rocDecVideoSurfaceFormat //! Video surface format enums used for output format of decoded output -//! These enums are used in rocDecDECODECREATEINFO structure +//! These enums are used in RocdecDecoderCreateInfo structure /*********************************************************************************/ typedef enum rocDecVideoSurfaceFormat_enum { rocDecVideoSurfaceFormat_NV12=0, /**< Semi-Planar YUV [Y plane followed by interleaved UV plane] */ @@ -106,7 +107,7 @@ typedef enum rocDecVideoSurfaceFormat_enum { /**************************************************************************************************************/ //! \enum rocDecVideoChromaFormat //! Chroma format enums -//! These enums are used in ROCDCODECREATEINFO and ROCDECDECODECAPS structures +//! These enums are used in ROCDCODECREATEINFO and RocdecDecodeCaps structures /**************************************************************************************************************/ typedef enum rocDecVideoChromaFormat_enum { rocDecVideoChromaFormat_Monochrome=0, /**< MonoChrome */ @@ -118,7 +119,7 @@ typedef enum rocDecVideoChromaFormat_enum { /*************************************************************************/ //! \enum rocDecDecodeStatus //! Decode status enums -//! These enums are used in ROCDECGETDECODESTATUS structure +//! These enums are used in RocdecGetDecodeStatus structure /*************************************************************************/ typedef enum rocDecodeStatus_enum { rocDecodeStatus_Invalid = 0, // Decode status is not valid @@ -130,171 +131,489 @@ typedef enum rocDecodeStatus_enum { } rocDecDecodeStatus; /**************************************************************************************************************/ -//! \struct rocDecDECODECAPS; +//! \struct RocdecDecodeCaps; //! This structure is used in rocDecGetDecoderCaps API /**************************************************************************************************************/ -typedef struct _ROCDECDECODECAPS { +typedef struct _RocdecDecodeCaps { rocDecVideoCodec eCodecType; /**< IN: rocDecVideoCodec_XXX */ rocDecVideoChromaFormat eChromaFormat; /**< IN: rocDecVideoChromaFormat_XXX */ - unsigned int nBitDepthMinus8; /**< IN: The Value "BitDepth minus 8" */ - unsigned int reserved1[3]; /**< Reserved for future use - set to zero */ + uint32_t nBitDepthMinus8; /**< IN: The Value "BitDepth minus 8" */ + uint32_t reserved1[3]; /**< Reserved for future use - set to zero */ - unsigned char bIsSupported; /**< OUT: 1 if codec supported, 0 if not supported */ - unsigned char nNumDecoders; /**< OUT: Number of Decoders that can support IN params */ - unsigned short nOutputFormatMask; /**< OUT: each bit represents corresponding rocDecVideoSurfaceFormat enum */ - unsigned int nMaxWidth; /**< OUT: Max supported coded width in pixels */ - unsigned int nMaxHeight; /**< OUT: Max supported coded height in pixels */ - unsigned short nMinWidth; /**< OUT: Min supported coded width in pixels */ - unsigned short nMinHeight; /**< OUT: Min supported coded height in pixels */ - unsigned int reserved2[6]; /**< Reserved for future use - set to zero */ -} ROCDECDECODECAPS; + uint8_t bIsSupported; /**< OUT: 1 if codec supported, 0 if not supported */ + uint8_t nNumDecoders; /**< OUT: Number of Decoders that can support IN params */ + uint16_t nOutputFormatMask; /**< OUT: each bit represents corresponding rocDecVideoSurfaceFormat enum */ + uint32_t nMaxWidth; /**< OUT: Max supported coded width in pixels */ + uint32_t nMaxHeight; /**< OUT: Max supported coded height in pixels */ + uint16_t nMinWidth; /**< OUT: Min supported coded width in pixels */ + uint16_t nMinHeight; /**< OUT: Min supported coded height in pixels */ + uint32_t reserved2[6]; /**< Reserved for future use - set to zero */ +} RocdecDecodeCaps; /**************************************************************************************************************/ -//! \struct ROCDECDECODECREATEINFO +//! \struct RocdecDecoderCreateInfo //! This structure is used in rocDecCreateDecoder API /**************************************************************************************************************/ -typedef struct _ROCDECDECODECREATEINFO { - unsigned long ulWidth; /**< IN: Coded sequence width in pixels */ - unsigned long ulHeight; /**< IN: Coded sequence height in pixels */ - unsigned long ulNumDecodeSurfaces; /**< IN: Maximum number of internal decode surfaces */ +typedef struct _RocdecDecoderCreateInfo { + uint32_t ulWidth; /**< IN: Coded sequence width in pixels */ + uint32_t ulHeight; /**< IN: Coded sequence height in pixels */ + uint32_t ulNumDecodeSurfaces; /**< IN: Maximum number of internal decode surfaces */ rocDecVideoCodec CodecType; /**< IN: rocDecVideoCodec_XXX */ rocDecVideoChromaFormat ChromaFormat; /**< IN: rocDecVideoChromaFormat_XXX */ - unsigned long bitDepthMinus8; /**< IN: The value "BitDepth minus 8" */ - unsigned long ulIntraDecodeOnly; /**< IN: Set 1 only if video has all intra frames (default value is 0). This will + uint32_t bitDepthMinus8; /**< IN: The value "BitDepth minus 8" */ + uint32_t ulIntraDecodeOnly; /**< IN: Set 1 only if video has all intra frames (default value is 0). This will optimize video memory for Intra frames only decoding. The support is limited to specific codecs - H264, HEVC, VP9, the flag will be ignored for codecs which are not supported. However decoding might fail if the flag is enabled in case of supported codecs for regular bit streams having P and/or B frames. */ - unsigned long ulMaxWidth; /**< IN: Coded sequence max width in pixels used with reconfigure Decoder */ - unsigned long ulMaxHeight; /**< IN: Coded sequence max height in pixels used with reconfigure Decoder */ - + uint32_t ulMaxWidth; /**< IN: Coded sequence max width in pixels used with reconfigure Decoder */ + uint32_t ulMaxHeight; /**< IN: Coded sequence max height in pixels used with reconfigure Decoder */ /** * IN: area of the frame that should be copied */ struct { - short left; - short top; - short right; - short bottom; + int16_t left; + int16_t top; + int16_t right; + int16_t bottom; } roi_area; rocDecVideoSurfaceFormat OutputFormat; /**< IN: rocDecVideoSurfaceFormat_XXX */ - unsigned long ulTargetWidth; /**< IN: Post-processed output width (Should be aligned to 2) */ - unsigned long ulTargetHeight; /**< IN: Post-processed output height (Should be aligned to 2) */ - unsigned long ulNumOutputSurfaces; /**< IN: Maximum number of output surfaces simultaneously mapped */ + uint32_t ulTargetWidth; /**< IN: Post-processed output width (Should be aligned to 2) */ + uint32_t ulTargetHeight; /**< IN: Post-processed output height (Should be aligned to 2) */ + uint32_t ulNumOutputSurfaces; /**< IN: Maximum number of output surfaces simultaneously mapped */ /** * IN: target rectangle in the output frame (for aspect ratio conversion) * if a null rectangle is specified, {0,0,ulTargetWidth,ulTargetHeight} will be used */ struct { - short left; - short top; - short right; - short bottom; + int16_t left; + int16_t top; + int16_t right; + int16_t bottom; } target_rect; - unsigned long enableHistogram; /**< IN: enable histogram output, if supported */ - unsigned long Reserved2[4]; /**< Reserved for future use - set to zero */ -} ROCDECDECODECREATEINFO; + uint32_t enableHistogram; /**< IN: enable histogram output, if supported */ + uint32_t Reserved2[4]; /**< Reserved for future use - set to zero */ +} RocdecDecoderCreateInfo; /*********************************************************************************************************/ -//! \struct ROCDECGETDECODESTATUS +//! \struct RocdecDecodeStatus //! Struct for reporting decode status. -//! This structure is used in rocDecGetDecodeStatus API. +//! This structure is used in RocdecGetDecodeStatus API. /*********************************************************************************************************/ -typedef struct _ROCDECGETDECODESTATUS { +typedef struct _RocdecDecodeStatus { rocDecDecodeStatus decodeStatus; - unsigned int reserved[31]; + uint32_t reserved[31]; void *pReserved[8]; -} ROCDECGETDECODESTATUS; +} RocdecDecodeStatus; /****************************************************/ -//! \struct rocDecRECONFIGUREDECODERINFO +//! \struct RocdecReconfigureDecoderInfo //! Struct for decoder reset //! This structure is used in rocDecReconfigureDecoder() API /****************************************************/ -typedef struct _ROCDECRECONFIGUREDECODERINFO { - unsigned int ulWidth; /**< IN: Coded sequence width in pixels, MUST be < = ulMaxWidth defined at ROCDECDECODECREATEINFO */ - unsigned int ulHeight; /**< IN: Coded sequence height in pixels, MUST be < = ulMaxHeight defined at ROCDECDECODECREATEINFO */ - unsigned int ulTargetWidth; /**< IN: Post processed output width */ - unsigned int ulTargetHeight; /**< IN: Post Processed output height */ - unsigned int ulNumDecodeSurfaces; /**< IN: Maximum number of internal decode surfaces */ - unsigned int reserved1[12]; /**< Reserved for future use. Set to Zero */ +typedef struct _RocdecReconfigureDecoderInfo { + uint32_t ulWidth; /**< IN: Coded sequence width in pixels, MUST be < = ulMaxWidth defined at RocdecDecoderCreateInfo */ + uint32_t ulHeight; /**< IN: Coded sequence height in pixels, MUST be < = ulMaxHeight defined at RocdecDecoderCreateInfo */ + uint32_t ulTargetWidth; /**< IN: Post processed output width */ + uint32_t ulTargetHeight; /**< IN: Post Processed output height */ + uint32_t ulNumDecodeSurfaces; /**< IN: Maximum number of internal decode surfaces */ + uint32_t reserved1[12]; /**< Reserved for future use. Set to Zero */ /** * IN: Area of frame to be displayed. Use-case : Source Cropping */ struct { - short left; - short top; - short right; - short bottom; + int16_t left; + int16_t top; + int16_t right; + int16_t bottom; } roi_area; /** * IN: Target Rectangle in the OutputFrame. Use-case : Aspect ratio Conversion */ struct { - short left; - short top; - short right; - short bottom; + int16_t left; + int16_t top; + int16_t right; + int16_t bottom; } target_rect; - unsigned int reserved2[11]; /**< Reserved for future use. Set to Zero */ -} ROCDECRECONFIGUREDECODERINFO; + uint32_t reserved2[11]; /**< Reserved for future use. Set to Zero */ +} RocdecReconfigureDecoderInfo; + +/*********************************************************/ +//! \struct RocdecH264Picture +//! H.264 Picture Entry +//! This structure is used in RocdecH264PicParams structure +/*********************************************************/ +typedef struct _RocdecH264Picture { + int PicIdx; /**< picture index of reference frame */ + int FrameIdx; /**< frame_num(int16_t-term) or LongTermFrameIdx(long-term) */ + uint32_t RefFlags; /**< See below for definitions */ + int TopFieldOrderCnt; /**< field order count of top field */ + int BottomFieldOrderCnt; /**< field order count of bottom field */ +} RocdecH264Picture; + +/* flags in RocdecH264Picture could be OR of the following */ +#define RocdecH264Picture_FLAGS_INVALID 0x00000001 +#define RocdecH264Picture_FLAGS_TOP_FIELD 0x00000002 +#define RocdecH264Picture_FLAGS_BOTTOM_FIELD 0x00000004 +#define RocdecH264Picture_FLAGS_SHORT_TERM_REFERENCE 0x00000008 +#define RocdecH264Picture_FLAGS_LONG_TERM_REFERENCE 0x00000010 +#define RocdecH264Picture_FLAGS_NON_EXISTING 0x00000020 + +/*********************************************************/ +//! \struct RocdecHEVCPicture +//! HEVC Picture Entry +//! This structure is used in RocdecHevcPicParams structure +/*********************************************************/ +typedef struct _RocdecHEVCPicture { + int PicIdx; /**< reconstructed picture surface ID */ + /** \brief picture order count. + * in HEVC, POCs for top and bottom fields of same picture should + * take different values. + */ + int POC; + uint32_t Flags; /**< See below for definitions */ + uint32_t Reserved[4]; /**< reserved for future; must be zero */ +} RocdecHEVCPicture; + +/* flags in RocdecHEVCPicture could be OR of the following */ +#define RocdecHEVCPicture_INVALID 0x00000001 +/** \brief indication of interlace scan picture. + * should take same value for all the pictures in sequence. + */ +#define RocdecHEVCPicture_FIELD_PIC 0x00000002 +/** \brief polarity of the field picture. + * top field takes even lines of buffer surface. + * bottom field takes odd lines of buffer surface. + */ +#define RocdecHEVCPicture_BOTTOM_FIELD 0x00000004 +/** \brief Long term reference picture */ +#define RocdecHEVCPicture_LONG_TERM_REFERENCE 0x00000008 +/** + * RocdecHEVCPicture_ST_CURR_BEFORE, RocdecHEVCPicture_RPS_ST_CURR_AFTER + * and RocdecHEVCPicture_RPS_LT_CURR of any picture in ReferenceFrames[] should + * be exclusive. No more than one of them can be set for any picture. + * Sum of NumPocStCurrBefore, NumPocStCurrAfter and NumPocLtCurr + * equals NumPocTotalCurr, which should be equal to or smaller than 8. + * Application should provide valid values for both int16_t format and long format. + * The pictures in DPB with any of these three flags turned on are referred by + * the current picture. + */ +/** \brief RefPicSetStCurrBefore of HEVC spec variable + * Number of ReferenceFrames[] entries with this bit set equals + * NumPocStCurrBefore. + */ +#define RocdecHEVCPicture_RPS_ST_CURR_BEFORE 0x00000010 +/** \brief RefPicSetStCurrAfter of HEVC spec variable + * Number of ReferenceFrames[] entries with this bit set equals + * NumPocStCurrAfter. + */ +#define RocdecHEVCPicture_RPS_ST_CURR_AFTER 0x00000020 +/** \brief RefPicSetLtCurr of HEVC spec variable + * Number of ReferenceFrames[] entries with this bit set equals + * NumPocLtCurr. + */ +#define RocdecHEVCPicture_RPS_LT_CURR 0x00000040 /***********************************************************/ -//! \struct ROCDECJPEGPICPARAMS placeholder +//! \struct RocdecJPEGPicParams placeholder //! JPEG picture parameters -//! This structure is used in ROCDECPICPARAMS structure +//! This structure is used in RocdecPicParams structure /***********************************************************/ -typedef struct _ROCDECJPEGPICPARAMS { +typedef struct _RocdecJPEGPicParams { int Reserved; -} ROCDECJPEGPICPARAMS; +} RocdecJPEGPicParams; /***********************************************************/ -//! \struct ROCDECMPEG2PICPARAMS placeholder -//! JPEG picture parameters -//! This structure is used in ROCDECMPEG2PICPARAMS structure +//! \struct RocdecMpeg2QMatrix +//! MPEG2 QMatrix +//! This structure is used in _RocdecMpeg2PicParams structure /***********************************************************/ -typedef struct _ROCDECMPEG2PICPARAMS { - int Reserved; -} ROCDECMPEG2PICPARAMS; +typedef struct _RocdecMpeg2QMatrix { + int32_t load_intra_quantiser_matrix; + int32_t load_non_intra_quantiser_matrix; + int32_t load_chroma_intra_quantiser_matrix; + int32_t load_chroma_non_intra_quantiser_matrix; + uint8_t intra_quantiser_matrix[64]; + uint8_t non_intra_quantiser_matrix[64]; + uint8_t chroma_intra_quantiser_matrix[64]; + uint8_t chroma_non_intra_quantiser_matrix[64]; +} RocdecMpeg2QMatrix; + /***********************************************************/ -//! \struct ROCDECH264PICPARAMS placeholder -//! JPEG picture parameters -//! This structure is used in ROCDECH264PICPARAMS structure +//! \struct RocdecMpeg2PicParams +//! MPEG2 picture parameters +//! This structure is used in RocdecMpeg2PicParams structure /***********************************************************/ -typedef struct _ROCDECH264PICPARAMS { - int Reserved; -} ROCDECH264PICPARAMS; +typedef struct _RocdecMpeg2PicParams { + uint16_t horizontal_size; + uint16_t vertical_size; + uint32_t forward_reference_pic; // surface_id for forward reference + uint32_t backward_reference_picture; // surface_id for backward reference + /* meanings of the following fields are the same as in the standard */ + int32_t picture_coding_type; + int32_t f_code; /* pack all four fcode into this */ + union { + struct { + uint32_t intra_dc_precision : 2; + uint32_t picture_structure : 2; + uint32_t top_field_first : 1; + uint32_t frame_pred_frame_dct : 1; + uint32_t concealment_motion_vectors : 1; + uint32_t q_scale_type : 1; + uint32_t intra_vlc_format : 1; + uint32_t alternate_scan : 1; + uint32_t repeat_first_field : 1; + uint32_t progressive_frame : 1; + uint32_t is_first_field : 1; // indicate whether the current field is the first field for field picture + } bits; + uint32_t value; + } picture_coding_extension; + + RocdecMpeg2QMatrix q_matrix; + uint32_t Reserved[4]; +} RocdecMpeg2PicParams; /***********************************************************/ -//! \struct ROCDECHEVCPICPARAMS placeholder -//! JPEG picture parameters -//! This structure is used in ROCDECHEVCPICPARAMS structure +//! \struct RocdecH264PicParams placeholder +//! H.264 picture parameters +//! This structure is used in RocdecH264PicParams structure +//! This structure is configured similar to VA-API VAPictureParameterBufferH264 structure /***********************************************************/ -typedef struct _ROCDECHEVCPICPARAMS { - int Reserved; -} ROCDECHEVCPICPARAMS; +typedef struct _RocdecH264PicParams { + RocdecH264Picture cur_pic; + RocdecH264Picture dpb[16]; /* in DPB */ + uint16_t picture_width_in_mbs_minus1; + uint16_t picture_height_in_mbs_minus1; + uint8_t bit_depth_luma_minus8; + uint8_t bit_depth_chroma_minus8; + uint8_t num_ref_frames; + union { + struct { + uint32_t chroma_format_idc : 2; + uint32_t residual_colour_transform_flag : 1; + uint32_t gaps_in_frame_num_value_allowed_flag : 1; + uint32_t frame_mbs_only_flag : 1; + uint32_t mb_adaptive_frame_field_flag : 1; + uint32_t direct_8x8_inference_flag : 1; + uint32_t MinLumaBiPredSize8x8 : 1; /* see A.3.3.2 */ + uint32_t log2_max_frame_num_minus4 : 4; + uint32_t pic_order_cnt_type : 2; + uint32_t log2_max_pic_order_cnt_lsb_minus4 : 4; + uint32_t delta_pic_order_always_zero_flag : 1; + } bits; + uint32_t value; + } sps_fields; + union { + struct { + uint32_t entropy_coding_mode_flag : 1; + uint32_t weighted_pred_flag : 1; + uint32_t weighted_bipred_idc : 2; + uint32_t transform_8x8_mode_flag : 1; + uint32_t field_pic_flag : 1; + uint32_t constrained_intra_pred_flag : 1; + uint32_t pic_order_present_flag : 1; + uint32_t deblocking_filter_control_present_flag : 1; + uint32_t redundant_pic_cnt_present_flag : 1; + uint32_t reference_pic_flag : 1; /* nal_ref_idc != 0 */ + } bits; + uint32_t value; + } pps_fields; + + // FMO/ASO + uint8_t num_slice_groups_minus1; + uint8_t slice_group_map_type; + uint16_t slice_group_change_rate_minus1; + int8_t pic_init_qp_minus26; + int8_t pic_init_qs_minus26; + int8_t chroma_qp_index_offset; + int8_t second_chroma_qp_index_offset; + + uint16_t frame_num; + uint8_t num_ref_idx_l0_default_active_minus1; + uint8_t num_ref_idx_l1_default_active_minus1; + + // Quantization Matrices (raster-order) + uint8_t scaling_list_4x4[6][16]; + uint8_t scaling_list_8x8[2][64]; + // SVC/MVC : Not supported in this version + // union + // { + // ROCDECH264MVCEXT mvcext; + // ROCDECH264SVCEXT svcext; + // }; + uint32_t Reserved[12]; +} RocdecH264PicParams; + /***********************************************************/ -//! \struct ROCDECVC1PICPARAMS placeholder -//! JPEG picture parameters -//! This structure is used in ROCDECVC1PICPARAMS structure +//! \struct RocdecHevcQMatrix +//! HEVC QMatrix +//! This structure is sent once per frame, +//! and only when scaling_list_enabled_flag = 1. +//! When sps_scaling_list_data_present_flag = 0, app still +//! needs to send in this structure with default matrix values. +//! This structure is used in RocdecHevcQMatrix structure /***********************************************************/ -typedef struct _ROCDECVC1PICPARAMS { +typedef struct _RocdecHevcQMatrix { + /** + * \brief 4x4 scaling, + * correspongs i = 0, MatrixID is in the range of 0 to 5, + * inclusive. And j is in the range of 0 to 15, inclusive. + */ + uint8_t ScalingList4x4[6][16]; + /** + * \brief 8x8 scaling, + * correspongs i = 1, MatrixID is in the range of 0 to 5, + * inclusive. And j is in the range of 0 to 63, inclusive. + */ + uint8_t ScalingList8x8[6][64]; + /** + * \brief 16x16 scaling, + * correspongs i = 2, MatrixID is in the range of 0 to 5, + * inclusive. And j is in the range of 0 to 63, inclusive. + */ + uint8_t ScalingList16x16[6][64]; + /** + * \brief 32x32 scaling, + * correspongs i = 3, MatrixID is in the range of 0 to 1, + * inclusive. And j is in the range of 0 to 63, inclusive. + */ + uint8_t ScalingList32x32[2][64]; + /** + * \brief DC values of the 16x16 scaling lists, + * corresponds to HEVC spec syntax + * scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8 + * with sizeID = 2 and matrixID in the range of 0 to 5, inclusive. + */ + uint8_t ScalingListDC16x16[6]; + /** + * \brief DC values of the 32x32 scaling lists, + * corresponds to HEVC spec syntax + * scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8 + * with sizeID = 3 and matrixID in the range of 0 to 1, inclusive. + */ + uint8_t ScalingListDC32x32[2]; + +} RocdecHevcQMatrix; + +/***********************************************************/ +//! \struct RocdecHevcPicParams +//! HEVC picture parameters +//! This structure is used in RocdecHevcPicParams structure +/***********************************************************/ +typedef struct _RocdecHevcPicParams { + RocdecHEVCPicture cur_pic; + RocdecHEVCPicture dpb[15]; /* in DPB */ + uint16_t picture_width_in_luma_samples; + uint16_t picture_height_in_luma_samples; + union { + struct { + /** following flags have same syntax and semantic as those in HEVC spec */ + uint32_t chroma_format_idc : 2; + uint32_t separate_colour_plane_flag : 1; + uint32_t pcm_enabled_flag : 1; + uint32_t scaling_list_enabled_flag : 1; + uint32_t transform_skip_enabled_flag : 1; + uint32_t amp_enabled_flag : 1; + uint32_t strong_intra_smoothing_enabled_flag : 1; + uint32_t sign_data_hiding_enabled_flag : 1; + uint32_t constrained_intra_pred_flag : 1; + uint32_t cu_qp_delta_enabled_flag : 1; + uint32_t weighted_pred_flag : 1; + uint32_t weighted_bipred_flag : 1; + uint32_t transquant_bypass_enabled_flag : 1; + uint32_t tiles_enabled_flag : 1; + uint32_t entropy_coding_sync_enabled_flag : 1; + uint32_t pps_loop_filter_across_slices_enabled_flag : 1; + uint32_t loop_filter_across_tiles_enabled_flag : 1; + uint32_t pcm_loop_filter_disabled_flag : 1; + /** set based on sps_max_num_reorder_pics of current temporal layer. */ + uint32_t NoPicReorderingFlag : 1; + /** picture has no B slices */ + uint32_t NoBiPredFlag : 1; + + uint32_t ReservedBits : 11; + } bits; + uint32_t value; + } pps_fields; + + /** SPS fields: the following parameters have same syntax with those in HEVC spec */ + uint8_t sps_max_dec_pic_buffering_minus1; /**< IN: DPB size for current temporal layer */ + uint8_t bit_depth_luma_minus8; + uint8_t bit_depth_chroma_minus8; + uint8_t pcm_sample_bit_depth_luma_minus1; + uint8_t pcm_sample_bit_depth_chroma_minus1; + uint8_t log2_min_luma_coding_block_size_minus3; + uint8_t log2_diff_max_min_luma_coding_block_size; + uint8_t log2_min_transform_block_size_minus2; + uint8_t log2_diff_max_min_transform_block_size; + uint8_t log2_min_pcm_luma_coding_block_size_minus3; + uint8_t log2_diff_max_min_pcm_luma_coding_block_size; + uint8_t max_transform_hierarchy_depth_intra; + uint8_t max_transform_hierarchy_depth_inter; + int8_t init_qp_minus26; + uint8_t diff_cu_qp_delta_depth; + int8_t pps_cb_qp_offset; + int8_t pps_cr_qp_offset; + uint8_t log2_parallel_merge_level_minus2; + uint8_t num_tile_columns_minus1; + uint8_t num_tile_rows_minus1; + /** + * when uniform_spacing_flag equals 1, application should populate + * column_width_minus[], and row_height_minus1[] with approperiate values. + */ + uint16_t column_width_minus1[19]; + uint16_t row_height_minus1[21]; + + uint32_t slice_parsing_fields; /**< IN: Needed only for Short Slice Format */ + + /** following parameters have same syntax with those in HEVC spec */ + uint8_t log2_max_pic_order_cnt_lsb_minus4; + uint8_t num_int16_t_term_ref_pic_sets; + uint8_t num_long_term_ref_pic_sps; + uint8_t num_ref_idx_l0_default_active_minus1; + uint8_t num_ref_idx_l1_default_active_minus1; + int8_t pps_beta_offset_div2; + int8_t pps_tc_offset_div2; + uint8_t num_extra_slice_header_bits; + /** + * \brief number of bits that structure + * int16_t_term_ref_pic_set( num_int16_t_term_ref_pic_sets ) takes in slice + * segment header when int16_t_term_ref_pic_set_sps_flag equals 0. + * if int16_t_term_ref_pic_set_sps_flag equals 1, the value should be 0. + * the bit count is calculated after emulation prevention bytes are removed + * from bit streams. + * This variable is used for accelorater to skip parsing the + * int16_t_term_ref_pic_set( num_int16_t_term_ref_pic_sets ) structure. + */ + uint32_t st_rps_bits; + + RocdecHevcQMatrix q_matrix; + uint32_t Reserved[16]; +} RocdecHevcPicParams; + +/***********************************************************/ +//! \struct RocdecVc1PicParams placeholder +//! JPEG picture parameters +//! This structure is used in RocdecVc1PicParams structure +/***********************************************************/ +typedef struct _RocdecVc1PicParams { int Reserved; -} ROCDECVC1PICPARAMS; +} RocdecVc1PicParams; /******************************************************************************************/ -//! \struct _ROCDECPICPARAMS +//! \struct _RocdecPicParams //! Picture parameters for decoding //! This structure is used in rocDecDecodePicture API //! IN for rocDecDecodePicture /******************************************************************************************/ -typedef struct _ROCDECPICPARAMS { +typedef struct _RocdecPicParams { int PicWidth; /**< IN: Coded frame width */ int PicHeight; /**< IN: Coded frame height */ int CurrPicIdx; /**< IN: Output index of the current picture */ @@ -302,47 +621,47 @@ typedef struct _ROCDECPICPARAMS { int bottom_field_flag; /**< IN: 0=top field, 1=bottom field (ignored if field_pic_flag=0) */ int second_field; /**< IN: Second field of a complementary field pair */ // Bitstream data - unsigned int nBitstreamDataLen; /**< IN: Number of bytes in bitstream data buffer */ - const unsigned char *pBitstreamData; /**< IN: Ptr to bitstream data for this picture (slice-layer) */ - unsigned int nNumSlices; /**< IN: Number of slices in this picture */ - const unsigned int *pSliceDataOffsets; /**< IN: nNumSlices entries, contains offset of each slice within + uint32_t nBitstreamDataLen; /**< IN: Number of bytes in bitstream data buffer */ + const uint8_t *pBitstreamData; /**< IN: Ptr to bitstream data for this picture (slice-layer) */ + uint32_t nNumSlices; /**< IN: Number of slices in this picture */ + const uint32_t *pSliceDataOffsets; /**< IN: nNumSlices entries, contains offset of each slice within the bitstream data buffer */ int ref_pic_flag; /**< IN: This picture is a reference picture */ int intra_pic_flag; /**< IN: This picture is entirely intra coded */ - unsigned int Reserved[30]; /**< Reserved for future use */ + uint32_t Reserved[30]; /**< Reserved for future use */ // IN: Codec-specific data union { - ROCDECMPEG2PICPARAMS mpeg2; /**< Also used for MPEG-1 */ - ROCDECH264PICPARAMS h264; - ROCDECHEVCPICPARAMS hevc; - ROCDECVC1PICPARAMS vc1; - ROCDECJPEGPICPARAMS jpeg; - unsigned int CodecReserved[256]; + RocdecMpeg2PicParams mpeg2; /**< Also used for MPEG-1 */ + RocdecH264PicParams h264; + RocdecHevcPicParams hevc; + RocdecVc1PicParams vc1; + RocdecJPEGPicParams jpeg; + uint32_t CodecReserved[256]; } CodecSpecific; -} ROCDECPICPARAMS; + +} RocdecPicParams; /******************************************************/ -//! \struct ROCDECPROCPARAMS +//! \struct RocdecProcParams //! Picture parameters for postprocessing //! This structure is used in rocDecMapVideoFrame API /******************************************************/ -typedef struct _ROCDECPROCPARAMS +typedef struct _RocdecProcParams { int progressive_frame; /**< IN: Input is progressive (deinterlace_mode will be ignored) */ int top_field_first; /**< IN: Input frame is top field first (1st field is top, 2nd field is bottom) */ - unsigned int reserved_flags[2]; /**< Reserved for future use (set to zero) */ + uint32_t reserved_flags[2]; /**< Reserved for future use (set to zero) */ // The fields below are used for raw YUV input - unsigned long long raw_input_dptr; /**< IN: Input HIP device ptr for raw YUV extensions */ - unsigned int raw_input_pitch; /**< IN: pitch in bytes of raw YUV input (should be aligned appropriately) */ - unsigned int raw_input_format; /**< IN: Input YUV format (rocDecVideoCodec_enum) */ - unsigned long long raw_output_dptr; /**< IN: Output HIP device mem ptr for raw YUV extensions */ - unsigned int raw_output_pitch; /**< IN: pitch in bytes of raw YUV output (should be aligned appropriately) */ - unsigned int raw_output_format; /**< IN: Output YUV format (rocDecVideoCodec_enum) */ - hipStream_t output_hstream; /**< IN: stream object used by rocDecMapVideoFrame */ - unsigned int Reserved[16]; /**< Reserved for future use (set to zero) */ -} ROCDECPROCPARAMS; - + uint64_t raw_input_dptr; /**< IN: Input HIP device ptr for raw YUV extensions */ + uint32_t raw_input_pitch; /**< IN: pitch in bytes of raw YUV input (should be aligned appropriately) */ + uint32_t raw_input_format; /**< IN: Input YUV format (rocDecVideoCodec_enum) */ + uint64_t raw_output_dptr; /**< IN: Output HIP device mem ptr for raw YUV extensions */ + uint32_t raw_output_pitch; /**< IN: pitch in bytes of raw YUV output (should be aligned appropriately) */ + uint32_t raw_output_format; /**< IN: Output YUV format (rocDecVideoCodec_enum) */ + hipStream_t output_hstream; /**< IN: stream object used by rocDecMapVideoFrame */ + uint32_t Reserved[16]; /**< Reserved for future use (set to zero) */ +} RocdecProcParams; /***********************************************************************************************************/ @@ -371,10 +690,10 @@ typedef struct _ROCDECPROCPARAMS /***********************************************************************************************************/ /*****************************************************************************************************/ -//! \fn rocDecStatus ROCDECAPI rocDecCreateDecoder(rocDecDecoderHandle *phDecoder, ROCDECDECODECREATEINFO *pdci) +//! \fn rocDecStatus ROCDECAPI rocDecCreateDecoder(rocDecDecoderHandle *phDecoder, RocdecDecoderCreateInfo *pdci) //! Create the decoder object based on pdci. A handle to the created decoder is returned /*****************************************************************************************************/ -extern rocDecStatus ROCDECAPI rocDecCreateDecoder(rocDecDecoderHandle *phDecoder, ROCDECDECODECREATEINFO *pdci); +extern rocDecStatus ROCDECAPI rocDecCreateDecoder(rocDecDecoderHandle *phDecoder, RocdecDecoderCreateInfo *pdci); /*****************************************************************************************************/ //! \fn rocDecStatus ROCDECAPI rocDecDestroyDecoder(rocDecDecoderHandle hDecoder) @@ -383,46 +702,46 @@ extern rocDecStatus ROCDECAPI rocDecCreateDecoder(rocDecDecoderHandle *phDecoder extern rocDecStatus ROCDECAPI rocDecDestroyDecoder(rocDecDecoderHandle hDecoder); /**********************************************************************************************************************/ -//! \fn rocDecStatus ROCDECAPI rocdecGetDecoderCaps(ROCDECDECODECAPS *pdc) +//! \fn rocDecStatus ROCDECAPI rocdecGetDecoderCaps(RocdecDecodeCaps *pdc) //! Queries decode capabilities of AMD's VCN decoder based on CodecType, ChromaFormat and BitDepthMinus8 parameters. -//! 1. Application fills IN parameters CodecType, ChromaFormat and BitDepthMinus8 of ROCDECDECODECAPS structure +//! 1. Application fills IN parameters CodecType, ChromaFormat and BitDepthMinus8 of RocdecDecodeCaps structure //! 2. On calling rocdecGetDecoderCaps, driver fills OUT parameters if the IN parameters are supported //! If IN parameters passed to the driver are not supported by AMD-VCN-HW, then all OUT params are set to 0. /**********************************************************************************************************************/ -extern rocDecStatus ROCDECAPI rocDecGetDecoderCaps(rocDecDecoderHandle hDecoder, ROCDECDECODECAPS *pdc); +extern rocDecStatus ROCDECAPI rocDecGetDecoderCaps(rocDecDecoderHandle hDecoder, RocdecDecodeCaps *pdc); /*****************************************************************************************************/ -//! \fn rocDecStatus ROCDECAPI rocDecDecodeFrame(rocDecDecoderHandle hDecoder, ROCDECPICPARAMS *pPicParams) +//! \fn rocDecStatus ROCDECAPI rocDecDecodeFrame(rocDecDecoderHandle hDecoder, RocdecPicParams *pPicParams) //! Decodes a single picture //! Submits the frame for HW decoding /*****************************************************************************************************/ -extern rocDecStatus ROCDECAPI rocDecDecodeFrame(rocDecDecoderHandle hDecoder, ROCDECPICPARAMS *pPicParams); +extern rocDecStatus ROCDECAPI rocDecDecodeFrame(rocDecDecoderHandle hDecoder, RocdecPicParams *pPicParams); /************************************************************************************************************/ -//! \fn rocDecStatus ROCDECAPI rocDecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, ROCDECGETDECODESTATUS* pDecodeStatus); +//! \fn rocDecStatus ROCDECAPI rocDecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, RocdecDecodeStatus* pDecodeStatus); //! Get the decode status for frame corresponding to nPicIdx //! API is currently supported for HEVC, H264 and JPEG codecs. -//! API returns CUDA_ERROR_NOT_SUPPORTED error code for unsupported GPU or codec. +//! API returns ROCDEC_NOT_SUPPORTED error code for unsupported GPU or codec. /************************************************************************************************************/ -extern rocDecStatus ROCDECAPI rocDecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, ROCDECGETDECODESTATUS* pDecodeStatus); +extern rocDecStatus ROCDECAPI rocDecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, RocdecDecodeStatus* pDecodeStatus); /*********************************************************************************************************/ -//! \fn rocDecStatus ROCDECAPI rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, ROCDECRECONFIGUREDECODERINFO *pDecReconfigParams) +//! \fn rocDecStatus ROCDECAPI rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, RocdecReconfigureDecoderInfo *pDecReconfigParams) //! 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::pfnSequenceCallback +//! params, target area params change for same codec. Must be called during RocdecParserParams::pfnSequenceCallback /*********************************************************************************************************/ -extern rocDecStatus ROCDECAPI rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, ROCDECRECONFIGUREDECODERINFO *pDecReconfigParams); +extern rocDecStatus ROCDECAPI rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, RocdecReconfigureDecoderInfo *pDecReconfigParams); /************************************************************************************************************************/ //! \fn extern rocDecStatus ROCDECAPI rocDecMapVideoFrame(rocDecDecoderHandle hDecoder, int nPicIdx, -//! unsigned int *pDevMemPtr, unsigned int *pHorizontalPitch, -//! ROCDECPROCPARAMS *pVidPostprocParams); +//! uint32_t *pDevMemPtr, uint32_t *pHorizontalPitch, +//! RocdecProcParams *pVidPostprocParams); //! Post-process and map video frame corresponding to nPicIdx for use in HIP. Returns HIP device pointer and associated //! pitch(horizontal stride) of the video frame. Returns device memory pointers for each plane (Y, U and V) seperately /************************************************************************************************************************/ extern rocDecStatus ROCDECAPI rocDecMapVideoFrame(rocDecDecoderHandle hDecoder, int nPicIdx, - void *pDevMemPtr[3], unsigned int *pHorizontalPitch[3], - ROCDECPROCPARAMS *pVidPostprocParams); + void *pDevMemPtr[3], uint32_t *pHorizontalPitch[3], + RocdecProcParams *pVidPostprocParams); /*****************************************************************************************************/ //! \fn rocDecStatus ROCDECAPI rocDecUnMapVideoFrame(rocDecDecoderHandle hDecoder, void *pMappedDevPtr) diff --git a/api/rocparser.h b/api/rocparser.h new file mode 100644 index 0000000000..1cb51d95b9 --- /dev/null +++ b/api/rocparser.h @@ -0,0 +1,270 @@ +/* +Copyright (c) 2023 - 2023 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.h" + +#if defined(__cplusplus) +extern "C" { +#endif /* __cplusplus */ +/*! + * \file + * \brief The AMD rocDecode library. + * + * \defgroup group_rocparser API: APIs for Video Parser + * \defgroup group_rocdec_struct + */ +/*********************************************************************************/ +//! 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 ulNumDecodeSurfaces. + 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 ulNumDecodeSurfaces 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; + +/*****************************************************************************/ +//! \ingroup STRUCTS +//! \struct RocdecSourceDataPacket +//! Data Packet +//! Used in rocDecParseVideoData API +//! IN for rocDecParseVideoData +/*****************************************************************************/ +typedef struct _RocdecSourceDataPacket { + uint32_t flags; /**< IN: Combination of CUVID_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 + CUVID_PKT_TIMESTAMP flag is set */ +} RocdecSourceDataPacket; + + +/**********************************************************************************/ +/*! \brief Timing Info struct + * \ingroup group_rocdec_struct + * \struct RocdecParserDispInfo + * \Used in rocdecParseVideoData API with PFNVIDDISPLAYCALLBACK pfnDisplayPicture + */ +/**********************************************************************************/ +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 CodecReserved[1024]; + }; +} RocdecOperatingPointInfo; + + +/**********************************************************************************/ +//! \ingroup STRUCTS +//! \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 STRUCTS +//! \struct RocdecSeiMessageInfo +//! Used in rocDecParseVideoData API with PFNVIDSEIMSGCALLBACK pfnGetSEIMsg +/**********************************************************************************/ +typedef struct _RocdecSeiMessageInfo { + void *pSEIData; /**< OUT: SEI Message Data */ + RocdecSeiMessage *pSEIMessage; /**< 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::ulMaxNumDecodeSurfaces + * \ 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 CodecType; /**< IN: rocDecVideoCodec_XXX */ + uint32_t ulMaxNumDecodeSurfaces; /**< IN: Max # of decode surfaces (parser will cycle through these) */ + uint32_t ulClockRate; /**< IN: Timestamp units in Hz (0=default=10000000Hz) */ + uint32_t ulErrorThreshold; /**< IN: % Error threshold (0-100) for calling pfnDecodePicture (100=always + IN: call pfnDecodePicture even if picture bitstream is fully corrupted) */ + uint32_t ulMaxDisplayDelay; /**< IN: Max display queue delay (improves pipelining of decode with display) + 0=no delay (recommended values: 2..4) */ + uint32_t bAnnexb : 1; /**< IN: AV1 annexB stream */ + uint32_t uReserved : 31; /**< Reserved for future use - set to zero */ + uint32_t uReserved1[4]; /**< IN: Reserved for future use - set to 0 */ + void *pUserData; /**< IN: User data for callbacks */ + PFNVIDSEQUENCECALLBACK pfnSequenceCallback; /**< IN: Called before decoding frames and/or whenever there is a fmt change */ + PFNVIDDECODECALLBACK pfnDecodePicture; /**< IN: Called when a picture is ready to be decoded (decode order) */ + PFNVIDDISPLAYCALLBACK pfnDisplayPicture; /**< IN: Called whenever a picture is ready to be displayed (display order) */ + PFNVIDOPPOINTCALLBACK pfnGetOperatingPoint; /**< IN: Called from AV1 sequence header to get operating point of a AV1 + scalable bitstream */ + PFNVIDSEIMSGCALLBACK pfnGetSEIMsg; /**< IN: Called when all SEI messages are parsed for particular frame */ + void *pvReserved2[5]; /**< Reserved for future use - set to NULL */ + RocdecVideoFormatEx *pExtVideoInfo; /**< IN: [Optional] sequence header data from system layer */ +} RocdecParserParams; + +/************************************************************************************************/ +//! \ingroup FUNCTS +//! \fn rocDecodeStatus ROCDECAPI rocDecCreateVideoParser(RocdecVideoParser *pHandle, RocdecParserParams *pParams) +//! Create video parser object and initialize +/************************************************************************************************/ +extern rocDecStatus ROCDECAPI rocDecCreateVideoParser(RocdecVideoParser *pHandle, RocdecParserParams *pParams); + +/************************************************************************************************/ +//! \ingroup FUNCTS +//! \fn rocDecodeStatus ROCDECAPI rocDecParseVideoData(RocdecVideoParser handle, RocdecSourceDataPacket *pPacket) +//! Parse the video data from source data packet in pPacket +//! Extracts parameter sets like SPS, PPS, bitstream etc. from pPacket and +//! calls back pfnDecodePicture with RocdecPicParams data for kicking of HW decoding +//! calls back pfnSequenceCallback with RocdecVideoFormat data for initial sequence header or when +//! the decoder encounters a video format change +//! calls back pfnDisplayPicture with RocdecParserDispInfo data to display a video frame +/************************************************************************************************/ +extern rocDecStatus ROCDECAPI rocDecParseVideoData(RocdecVideoParser handle, RocdecSourceDataPacket *pPacket); + +#if defined(__cplusplus) +} +#endif /* __cplusplus */ diff --git a/src/parser/parser_handle.h b/src/parser/parser_handle.h new file mode 100644 index 0000000000..f028fa8873 --- /dev/null +++ b/src/parser/parser_handle.h @@ -0,0 +1,61 @@ +/* +Copyright (c) 2023 - 2023 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 +#include +#include "rocparser.h" + +class RocVideoParser { +public: + RocVideoParser() {}; // default constructor + RocVideoParser(RocdecParserParams *pParams): parser_params_(*pParams) {}; + ~RocVideoParser(); + void SetParserParams(RocdecParserParams *pParams) { parser_params_ = *pParams; }; + RocdecParserParams *GetParserParams() {return &parser_params_;}; + rocDecStatus ParseVideoData(RocdecSourceDataPacket *pData); + +private: + RocdecParserParams parser_params_; +}; + +struct RocParserHandle { +public: + explicit RocParserHandle() {}; // default constructor + ~RocParserHandle() { clear_errors(); } + std::shared_ptr roc_parser; // class instantiation + bool no_error() { return error.empty(); } + const char* error_msg() { return error.c_str(); } + void capture_error(const std::string& err_msg) { error = err_msg; } + bool set_parser_params(RocdecParserParams *pParams) { + if(roc_parser) { + roc_parser->SetParserParams(pParams); + return true; + } else { + return false; + } + } + +private: + void clear_errors() { error = "";} + std::string error; +}; \ No newline at end of file diff --git a/src/parser/roc_video_parser.cpp b/src/parser/roc_video_parser.cpp new file mode 100644 index 0000000000..bc81e60b80 --- /dev/null +++ b/src/parser/roc_video_parser.cpp @@ -0,0 +1,36 @@ +/* +Copyright (c) 2023 - 2023 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. +*/ +#include "rocparser.h" +#include "parser_handle.h" + + + +/** + * @brief + * + * @param pData + * @return rocDecodeStatus + */ +rocDecStatus RocVideoParser::ParseVideoData(RocdecSourceDataPacket *pData) { + // todo: + return ROCDEC_SUCCESS; +} diff --git a/src/parser/rocparser_api.cpp b/src/parser/rocparser_api.cpp new file mode 100644 index 0000000000..6535322828 --- /dev/null +++ b/src/parser/rocparser_api.cpp @@ -0,0 +1,71 @@ +/* +Copyright (c) 2023 - 2023 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. +*/ +#include "parser_handle.h" +#include "../commons.h" + + +/************************************************************************************************/ +//! \ingroup FUNCTS +//! \fn rocParserStatus ROCDECAPI rocDecCreateVideoParser(RocdecVideoParser *pHandle, RocdecParserParams *pParams) +//! Create video parser object and initialize +/************************************************************************************************/ +rocDecStatus ROCDECAPI +rocDecCreateVideoParser(RocdecVideoParser *pHandle, RocdecParserParams *pParams) { + RocdecVideoParser handle = nullptr; + try { + handle = new RocParserHandle(); + } + catch(const std::exception& e) { + ERR( STR("Failed to init the rocDecode handle, ") + STR(e.what())) + } + //set params for the handle + auto parser_handle = static_cast (handle); + if (!parser_handle->set_parser_params(pParams)) + return ROCDEC_INVALID_PARAMETER; + *pHandle = handle; + return rocDecStatus::ROCDEC_SUCCESS; +} + +/************************************************************************************************/ +//! \ingroup FUNCTS +//! \fn rocParserStatus ROCDECAPI rocDecParseVideoData(RocdecVideoParser handle, RocdecSourceDataPacket *pPacket) +//! Parse the video data from source data packet in pPacket +//! Extracts parameter sets like SPS, PPS, bitstream etc. from pPacket and +//! calls back pfnDecodePicture with RocdecPicParams data for kicking of HW decoding +//! calls back pfnSequenceCallback with RocdecVideoFormat data for initial sequence header or when +//! the decoder encounters a video format change +//! calls back pfnDisplayPicture with ROCDECPARSERDISPINFO data to display a video frame +/************************************************************************************************/ +rocDecStatus ROCDECAPI +rocDecParseVideoData(RocdecVideoParser handle, RocdecSourceDataPacket *pPacket) { + auto parser_hdl = static_cast (handle); + rocDecStatus ret; + try { + ret = parser_hdl->roc_parser->ParseVideoData(pPacket); + } + catch(const std::exception& e) { + parser_hdl->capture_error(e.what()); + ERR(e.what()) + return ROCDEC_RUNTIME_ERROR; + } + return ret; +} diff --git a/src/dec_handle.h b/src/rocdecode/dec_handle.h similarity index 97% rename from src/dec_handle.h rename to src/rocdecode/dec_handle.h index 150c1cb1cf..c787ea8943 100644 --- a/src/dec_handle.h +++ b/src/rocdecode/dec_handle.h @@ -26,6 +26,10 @@ THE SOFTWARE. #include "roc_decoder.h" +/** + * @brief DecHandle structure + * + */ struct DecHandle { explicit DecHandle() {}; //constructor diff --git a/src/roc_decoder.cpp b/src/rocdecode/roc_decoder.cpp similarity index 91% rename from src/roc_decoder.cpp rename to src/rocdecode/roc_decoder.cpp index 9b71b937e3..3f3b86e397 100644 --- a/src/roc_decoder.cpp +++ b/src/rocdecode/roc_decoder.cpp @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "commons.h" +#include "../commons.h" #include "roc_decoder.h" RocDecoder::RocDecoder(int device_id, int num_devices):device_id_ {device_id}, num_devices_{num_devices} { @@ -32,29 +32,29 @@ RocDecoder::RocDecoder(int device_id, int num_devices):device_id_ {device_id}, n } -rocDecStatus RocDecoder::getDecoderCaps(ROCDECDECODECAPS *pdc) { +rocDecStatus RocDecoder::getDecoderCaps(RocdecDecodeCaps *pdc) { // todo:: return appropriate decStatus if fails //vaQueryConfigProfiles - // fill the ROCDECDECODECAPS struct + // fill the RocdecDecodeCaps struct // return status return ROCDEC_NOT_IMPLEMENTED; } -rocDecStatus RocDecoder::decodeFrame(ROCDECPICPARAMS *pPicParams) { +rocDecStatus RocDecoder::decodeFrame(RocdecPicParams *pPicParams) { // todo:: return appropriate decStatus if fails // call funsction to do va-api decoding using the picture parameters structure // return status return ROCDEC_NOT_IMPLEMENTED; } -rocDecStatus RocDecoder::getDecodeStatus(int nPicIdx, ROCDECGETDECODESTATUS* pDecodeStatus) { +rocDecStatus RocDecoder::getDecodeStatus(int nPicIdx, RocdecDecodeStatus* pDecodeStatus) { // todo:: return appropriate decStatus // init vaapi decoder to get the decoding status of the picture specified by nPicIndex // return status return ROCDEC_NOT_IMPLEMENTED; } -rocDecStatus RocDecoder::reconfigureDecoder(ROCDECRECONFIGUREDECODERINFO *pDecReconfigParams) { +rocDecStatus RocDecoder::reconfigureDecoder(RocdecReconfigureDecoderInfo *pDecReconfigParams) { // todo:: return appropriate decStatus // this will be called when the current configuration is changed during decoding // release the current va-api decoder instance and create a new one with the new parameters (or reinit if available) @@ -63,7 +63,7 @@ rocDecStatus RocDecoder::reconfigureDecoder(ROCDECRECONFIGUREDECODERINFO *pDecRe } rocDecStatus RocDecoder::mapVideoFrame(int nPicIdx, void *pDevMemPtr[3], - unsigned int *pHorizontalPitch[3], ROCDECPROCPARAMS *pVidPostprocParams) { + unsigned int *pHorizontalPitch[3], RocdecProcParams *pVidPostprocParams) { // todo:: return appropriate decStatus // Post-process and map video frame corresponding to nPicIdx for use in HIP. Returns HIP device pointer and associated // pitch(horizontal stride) of the video frame. Returns device memory pointers for each plane (Y, U and V) seperately diff --git a/src/roc_decoder.h b/src/rocdecode/roc_decoder.h similarity index 84% rename from src/roc_decoder.h rename to src/rocdecode/roc_decoder.h index 76b8db4e61..73f8d1b95b 100644 --- a/src/roc_decoder.h +++ b/src/rocdecode/roc_decoder.h @@ -38,11 +38,11 @@ class RocDecoder { public: RocDecoder(int device_id, int num_devices); ~RocDecoder(); - rocDecStatus getDecoderCaps(ROCDECDECODECAPS *pdc); - rocDecStatus decodeFrame(ROCDECPICPARAMS *pPicParams); - rocDecStatus getDecodeStatus(int nPicIdx, ROCDECGETDECODESTATUS* pDecodeStatus); - rocDecStatus reconfigureDecoder(ROCDECRECONFIGUREDECODERINFO *pDecReconfigParams); - rocDecStatus mapVideoFrame(int nPicIdx, void *pDevMemPtr[3], unsigned int *pHorizontalPitch[3], ROCDECPROCPARAMS *pVidPostprocParams); + rocDecStatus getDecoderCaps(RocdecDecodeCaps *pdc); + rocDecStatus decodeFrame(RocdecPicParams *pPicParams); + rocDecStatus getDecodeStatus(int nPicIdx, RocdecDecodeStatus* pDecodeStatus); + rocDecStatus reconfigureDecoder(RocdecReconfigureDecoderInfo *pDecReconfigParams); + rocDecStatus mapVideoFrame(int nPicIdx, void *pDevMemPtr[3], unsigned int *pHorizontalPitch[3], RocdecProcParams *pVidPostprocParams); rocDecStatus unMapVideoFrame(void *pMappedDevPtr); private: @@ -54,4 +54,4 @@ private: hipDeviceProp_t hip_dev_prop_; hipStream_t hip_stream_; std::vector drm_nodes_; -}; \ No newline at end of file +}; diff --git a/src/rocdecode_api.cpp b/src/rocdecode/rocdecode_api.cpp similarity index 88% rename from src/rocdecode_api.cpp rename to src/rocdecode/rocdecode_api.cpp index 0197102ffd..ed5c738acb 100644 --- a/src/rocdecode_api.cpp +++ b/src/rocdecode/rocdecode_api.cpp @@ -21,14 +21,14 @@ THE SOFTWARE. */ #include "dec_handle.h" #include "rocdecode.h" -#include "commons.h" +#include "../commons.h" /*****************************************************************************************************/ -//! \fn rocDecStatus ROCDECAPI rocDecCreateDecoder(rocDecDecoderHandle *phDecoder, ROCDECDECODECREATEINFO *pdci) +//! \fn rocDecStatus ROCDECAPI rocDecCreateDecoder(rocDecDecoderHandle *phDecoder, RocdecDecoderCreateInfo *pdci) //! Create the decoder object based on pdci. A handle to the created decoder is returned /*****************************************************************************************************/ rocDecStatus ROCDECAPI -rocDecCreateDecoder(rocDecDecoderHandle *phDecoder, ROCDECDECODECREATEINFO *pdci) { +rocDecCreateDecoder(rocDecDecoderHandle *phDecoder, RocdecDecoderCreateInfo *pdci) { rocDecDecoderHandle handle = nullptr; try { handle = new DecHandle(); @@ -52,14 +52,14 @@ rocDecDestroyDecoder(rocDecDecoderHandle hDecoder) { } /**********************************************************************************************************************/ -//! \fn rocDecStatus ROCDECAPI rocdecGetDecoderCaps(rocDecDecoderHandle hDecoder, ROCDECDECODECAPS *pdc) +//! \fn rocDecStatus ROCDECAPI rocdecGetDecoderCaps(rocDecDecoderHandle hDecoder, RocdecDecodeCaps *pdc) //! Queries decode capabilities of AMD's VCN decoder based on CodecType, ChromaFormat and BitDepthMinus8 parameters. -//! 1. Application fills IN parameters CodecType, ChromaFormat and BitDepthMinus8 of ROCDECDECODECAPS structure +//! 1. Application fills IN parameters CodecType, ChromaFormat and BitDepthMinus8 of RocdecDecodeCaps structure //! 2. On calling rocdecGetDecoderCaps, driver fills OUT parameters if the IN parameters are supported //! If IN parameters passed to the driver are not supported by AMD-VCN-HW, then all OUT params are set to 0. /**********************************************************************************************************************/ rocDecStatus ROCDECAPI -rocDecGetDecoderCaps(rocDecDecoderHandle hDecoder, ROCDECDECODECAPS *pdc) { +rocDecGetDecoderCaps(rocDecDecoderHandle hDecoder, RocdecDecodeCaps *pdc) { auto handle = static_cast (hDecoder); rocDecStatus ret; try { @@ -74,12 +74,12 @@ rocDecGetDecoderCaps(rocDecDecoderHandle hDecoder, ROCDECDECODECAPS *pdc) { } /*****************************************************************************************************/ -//! \fn rocDecStatus ROCDECAPI rocDecDecodeFrame(rocDecDecoderHandle hDecoder, ROCDECPICPARAMS *pPicParams) +//! \fn rocDecStatus ROCDECAPI rocDecDecodeFrame(rocDecDecoderHandle hDecoder, RocdecPicParams *pPicParams) //! Decodes a single picture //! Submits the frame for HW decoding /*****************************************************************************************************/ rocDecStatus ROCDECAPI -rocDecDecodeFrame(rocDecDecoderHandle hDecoder, ROCDECPICPARAMS *pPicParams) { +rocDecDecodeFrame(rocDecDecoderHandle hDecoder, RocdecPicParams *pPicParams) { auto handle = static_cast (hDecoder); rocDecStatus ret; try { @@ -94,13 +94,13 @@ rocDecDecodeFrame(rocDecDecoderHandle hDecoder, ROCDECPICPARAMS *pPicParams) { } /************************************************************************************************************/ -//! \fn rocDecStatus ROCDECAPI rocDecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, ROCDECGETDECODESTATUS* pDecodeStatus); +//! \fn rocDecStatus ROCDECAPI RocdecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, RocdecDecodeStatus* pDecodeStatus); //! Get the decode status for frame corresponding to nPicIdx //! API is currently supported for HEVC, H264 and JPEG codecs. //! API returns CUDA_ERROR_NOT_SUPPORTED error code for unsupported GPU or codec. /************************************************************************************************************/ rocDecStatus ROCDECAPI -rocDecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, ROCDECGETDECODESTATUS* pDecodeStatus) { +RocdecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, RocdecDecodeStatus* pDecodeStatus) { auto handle = static_cast (hDecoder); rocDecStatus ret; try { @@ -115,12 +115,12 @@ rocDecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, ROCDECGETDECODE } /*********************************************************************************************************/ -//! \fn rocDecStatus ROCDECAPI rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, ROCDECRECONFIGUREDECODERINFO *pDecReconfigParams) +//! \fn rocDecStatus ROCDECAPI rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, RocdecReconfigureDecoderInfo *pDecReconfigParams) //! 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::pfnSequenceCallback +//! params, target area params change for same codec. Must be called during RocdecParserParams::pfnSequenceCallback /*********************************************************************************************************/ rocDecStatus ROCDECAPI -rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, ROCDECRECONFIGUREDECODERINFO *pDecReconfigParams) { +rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, RocdecReconfigureDecoderInfo *pDecReconfigParams) { auto handle = static_cast (hDecoder); rocDecStatus ret; try { @@ -137,13 +137,13 @@ rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, ROCDECRECONFIGUREDECODERI /************************************************************************************************************************/ //! \fn extern rocDecStatus ROCDECAPI rocDecMapVideoFrame(rocDecDecoderHandle hDecoder, int nPicIdx, //! unsigned int *pDevMemPtr, unsigned int *pHorizontalPitch, -//! ROCDECPROCPARAMS *pVidPostprocParams); +//! RocdecProcParams *pVidPostprocParams); //! Post-process and map video frame corresponding to nPicIdx for use in HIP. Returns HIP device pointer and associated //! pitch(horizontal stride) of the video frame. Returns device memory pointers for each plane (Y, U and V) seperately /************************************************************************************************************************/ rocDecStatus ROCDECAPI rocDecMapVideoFrame(rocDecDecoderHandle hDecoder, int nPicIdx, - void *pDevMemPtr[3], unsigned int *pHorizontalPitch[3], ROCDECPROCPARAMS *pVidPostprocParams) { + void *pDevMemPtr[3], unsigned int *pHorizontalPitch[3], RocdecProcParams *pVidPostprocParams) { auto handle = static_cast (hDecoder); rocDecStatus ret; try { diff --git a/src/vaapi/vaapi_videodecoder.cpp b/src/rocdecode/vaapi/vaapi_videodecoder.cpp similarity index 98% rename from src/vaapi/vaapi_videodecoder.cpp rename to src/rocdecode/vaapi/vaapi_videodecoder.cpp index 9f526fbecf..af761397bd 100644 --- a/src/vaapi/vaapi_videodecoder.cpp +++ b/src/rocdecode/vaapi/vaapi_videodecoder.cpp @@ -28,5 +28,5 @@ THE SOFTWARE. #include #include -#include "commons.h" +#include "../commons.h" #include "vaapi_videodecoder.h" diff --git a/src/vaapi/vaapi_videodecoder.h b/src/rocdecode/vaapi/vaapi_videodecoder.h similarity index 100% rename from src/vaapi/vaapi_videodecoder.h rename to src/rocdecode/vaapi/vaapi_videodecoder.h