| 1 |
/* |
| 2 |
* Copyright (c) 2022-2023, Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included |
| 12 |
* in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
|
| 23 |
//! |
| 24 |
//! \file ddi_decode_mpeg2_specific.h |
| 25 |
//! \brief Defines class for DDI media MPEG2 decode |
| 26 |
//! |
| 27 |
|
| 28 |
#ifndef __DDI_DECODE_MPEG2_SPECIFIC_H__ |
| 29 |
#define __DDI_DECODE_MPEG2_SPECIFIC_H__ |
| 30 |
|
| 31 |
#include "ddi_decode_base_specific.h" |
| 32 |
|
| 33 |
namespace decode |
| 34 |
{ |
| 35 |
|
| 36 |
//! |
| 37 |
//! \class DdiDecodeMpeg2 |
| 38 |
//! \brief Ddi Decode MPEG2 |
| 39 |
//! |
| 40 |
class DdiDecodeMpeg2 : public DdiDecodeBase |
| 41 |
{ |
| 42 |
public: |
| 43 |
//! |
| 44 |
//! \brief Constructor |
| 45 |
//! |
| 46 |
DdiDecodeMpeg2() : DdiDecodeBase() {m_withDpb = false;}; |
| 47 |
|
| 48 |
//! |
| 49 |
//! \brief Destructor |
| 50 |
//! |
| 51 |
virtual ~DdiDecodeMpeg2(){}; |
| 52 |
|
| 53 |
// inherited virtual functions |
| 54 |
virtual void DestroyContext( |
| 55 |
VADriverContextP ctx) override; |
| 56 |
|
| 57 |
virtual VAStatus RenderPicture( |
| 58 |
VADriverContextP ctx, |
| 59 |
VAContextID context, |
| 60 |
VABufferID *buffers, |
| 61 |
int32_t num_buffers) override; |
| 62 |
|
| 63 |
virtual VAStatus SetDecodeParams() override; |
| 64 |
|
| 65 |
virtual void ContextInit( |
| 66 |
int32_t picWidth, |
| 67 |
int32_t picHeight) override; |
| 68 |
|
| 69 |
virtual VAStatus CodecHalInit( |
| 70 |
DDI_MEDIA_CONTEXT *mediaCtx, |
| 71 |
void *ptr) override; |
| 72 |
|
| 73 |
virtual VAStatus AllocSliceControlBuffer( |
| 74 |
DDI_MEDIA_BUFFER *buf) override; |
| 75 |
|
| 76 |
virtual uint8_t *GetPicParamBuf( |
| 77 |
DDI_CODEC_COM_BUFFER_MGR *bufMgr) override; |
| 78 |
|
| 79 |
private: |
| 80 |
//! |
| 81 |
//! \brief ParaSliceParam for MPEG2 |
| 82 |
//! \details parse the sliceParam info required by MPEG2 decoding for |
| 83 |
//! each slice |
| 84 |
//! |
| 85 |
//! \param [in] *mediaCtx |
| 86 |
//! DDI_MEDIA_CONTEXT |
| 87 |
//! \param [in] *slcParam |
| 88 |
//! VASliceParameterBufferMPEG2 |
| 89 |
//! \param [in] numSlices |
| 90 |
//! uint32_t |
| 91 |
//! |
| 92 |
//! \return VA_STATUS_SUCCESS is returned if it is parsed successfully. |
| 93 |
//! else fail reason |
| 94 |
VAStatus ParseSliceParams( |
| 95 |
DDI_MEDIA_CONTEXT *mediaCtx, |
| 96 |
VASliceParameterBufferMPEG2 *slcParam, |
| 97 |
uint32_t numSlices); |
| 98 |
|
| 99 |
//! |
| 100 |
//! \brief ParseIQMatrixParam for MPEG2 |
| 101 |
//! \details parse the QMatrix info required by MPEG2 decoding |
| 102 |
//! |
| 103 |
//! \param [in] *mediaCtx |
| 104 |
//! DDI_MEDIA_CONTEXT |
| 105 |
//! \param [in] *qMatrix |
| 106 |
//! VAIQMatrixBufferMPEG2 |
| 107 |
//! |
| 108 |
//! \return VA_STATUS_SUCCESS is returned if it is parsed successfully. |
| 109 |
//! else fail reason |
| 110 |
VAStatus ParseIQMatrix( |
| 111 |
DDI_MEDIA_CONTEXT *mediaCtx, |
| 112 |
VAIQMatrixBufferMPEG2 *matrix); |
| 113 |
|
| 114 |
//! \brief ParsePicParam for MPEG2 |
| 115 |
//! \details parse the PicParam info required by MPEG2 decoding |
| 116 |
//! |
| 117 |
//! \param [in] *mediaCtx |
| 118 |
//! DDI_MEDIA_CONTEXT |
| 119 |
//! \param [in] *qMatrix |
| 120 |
//! VAIQMatrixBufferH264 |
| 121 |
//! |
| 122 |
//! \return VA_STATUS_SUCCESS is returned if it is parsed successfully. |
| 123 |
//! else fail reason |
| 124 |
VAStatus ParsePicParams( |
| 125 |
DDI_MEDIA_CONTEXT *mediaCtx, |
| 126 |
VAPictureParameterBufferMPEG2 *picParam); |
| 127 |
|
| 128 |
//! \brief Alloc SliceParam content for MPEG2 |
| 129 |
//! \details Alloc/resize SlicePram content for MPEG2 decoding |
| 130 |
//! |
| 131 |
//! \param [in] numSlices |
| 132 |
//! uint32_t the required number of slices |
| 133 |
//! |
| 134 |
//! \return VA_STATUS_SUCCESS is returned if it is parsed successfully. |
| 135 |
//! else fail reason |
| 136 |
VAStatus AllocSliceParamContext( |
| 137 |
uint32_t numSlices); |
| 138 |
|
| 139 |
//! |
| 140 |
//! \brief Parse and Refine the number of MBs for MPEG2 |
| 141 |
//! \details parse and Refine the number of MBs for each slices |
| 142 |
//! This helps to fix the issue passed from upper middleware. |
| 143 |
//! |
| 144 |
//! \param [in] numSlices |
| 145 |
//! int32_t |
| 146 |
void ParseNumMbsForSlice(int32_t numSlices); |
| 147 |
|
| 148 |
//! \brief Init Resource buffer for MPEG2 |
| 149 |
//! \details Initialize and allocate the Resource buffer for MPEG2 |
| 150 |
//! |
| 151 |
//! \return VA_STATUS_SUCCESS is returned if it is parsed successfully. |
| 152 |
//! else fail reason |
| 153 |
VAStatus InitResourceBuffer(); |
| 154 |
|
| 155 |
void FreeResource(); |
| 156 |
|
| 157 |
//! \brief Free Resource buffer for MPEG2 |
| 158 |
//! |
| 159 |
void FreeResourceBuffer(); |
| 160 |
|
| 161 |
MEDIA_CLASS_DEFINE_END(decode__DdiDecodeMpeg2) |
| 162 |
}; |
| 163 |
|
| 164 |
} // namespace decode |
| 165 |
#endif /* __DDI_DECODE_MPEG2_SPECIFIC_H__ */ |