1 // Copyright (c) 2008-2019 Intel Corporation
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in all
11 // copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #ifndef __MFX_COMMON_DECODE_INT_H__
22 #define __MFX_COMMON_DECODE_INT_H__
23 
24 #include <vector>
25 #include "mfx_common.h"
26 #include "mfx_common_int.h"
27 #include "umc_video_decoder.h"
28 
29 class MFXMediaDataAdapter : public UMC::MediaData
30 {
31 public:
32     MFXMediaDataAdapter(mfxBitstream *pBitstream = 0);
33 
34     void Load(mfxBitstream *pBitstream);
35     void Save(mfxBitstream *pBitstream);
36 
37     void SetExtBuffer(mfxExtBuffer*);
38 };
39 
40 mfxStatus ConvertUMCStatusToMfx(UMC::Status status);
41 
42 void ConvertMFXParamsToUMC(mfxVideoParam const* par, UMC::VideoStreamInfo* umcVideoParams);
43 void ConvertMFXParamsToUMC(mfxVideoParam const* par, UMC::VideoDecoderParams* umcVideoParams);
44 
45 UMC::ColorFormat ConvertFOURCCToUMCColorFormat(mfxU32);
46 mfxU32 ConvertUMCColorFormatToFOURCC(UMC::ColorFormat);
47 void ConvertUMCParamsToMFX(UMC::VideoStreamInfo const*, mfxVideoParam*);
48 void ConvertUMCParamsToMFX(UMC::VideoDecoderParams const*, mfxVideoParam*);
49 
50 bool IsNeedChangeVideoParam(mfxVideoParam *par);
51 
52 mfxU16 FourCcBitDepth(mfxU32 fourCC);
53 bool InitBitDepthFields(mfxFrameInfo *info);
54 
ExtractProfile(mfxU32 profile)55 inline mfxU32 ExtractProfile(mfxU32 profile)
56 {
57     return profile & 0xFF;
58 }
59 
IsMVCProfile(mfxU32 profile)60 inline bool IsMVCProfile(mfxU32 profile)
61 {
62     profile = ExtractProfile(profile);
63     return (profile == MFX_PROFILE_AVC_MULTIVIEW_HIGH || profile == MFX_PROFILE_AVC_STEREO_HIGH);
64 }
65 
66 
67 
68 inline
MoveBitstreamData(mfxBitstream & bs,mfxU32 offset)69 void MoveBitstreamData(mfxBitstream& bs, mfxU32 offset)
70 {
71     VM_ASSERT(offset <= bs.DataLength);
72     bs.DataOffset += offset;
73     bs.DataLength -= offset;
74 }
75 
76 // Memory reference counting base class
77 class RefCounter
78 {
79 public:
80 
RefCounter()81     RefCounter() : m_refCounter(0)
82     {
83     }
84 
85     void IncrementReference() const;
86 
87     void DecrementReference();
88 
ResetRefCounter()89     void ResetRefCounter() { m_refCounter = 0; }
90 
GetRefCounter()91     uint32_t GetRefCounter() const { return m_refCounter; }
92 
93 protected:
94     mutable int32_t m_refCounter;
95 
~RefCounter()96     virtual ~RefCounter()
97     {
98     }
99 
Free()100     virtual void Free()
101     {
102     }
103 };
104 
105 #endif
106