|
Packit |
1244b8 |
/*
|
|
Packit |
1244b8 |
* Copyright (C) 2013-2016 Intel Corporation. All rights reserved.
|
|
Packit |
1244b8 |
*
|
|
Packit |
1244b8 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
Packit |
1244b8 |
* you may not use this file except in compliance with the License.
|
|
Packit |
1244b8 |
* You may obtain a copy of the License at
|
|
Packit |
1244b8 |
*
|
|
Packit |
1244b8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
1244b8 |
*
|
|
Packit |
1244b8 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
1244b8 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
1244b8 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
1244b8 |
* See the License for the specific language governing permissions and
|
|
Packit |
1244b8 |
* limitations under the License.
|
|
Packit |
1244b8 |
*/
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
#ifndef vaapidecoder_h265_h
|
|
Packit |
1244b8 |
#define vaapidecoder_h265_h
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
#include "common/Functional.h"
|
|
Packit |
1244b8 |
#include "vaapidecoder_base.h"
|
|
Packit |
1244b8 |
#include "vaapidecpicture.h"
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
#include <set>
|
|
Packit |
1244b8 |
#include <map>
|
|
Packit |
1244b8 |
#include <va/va_dec_hevc.h>
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
namespace YamiParser {
|
|
Packit |
1244b8 |
namespace H265 {
|
|
Packit |
1244b8 |
struct SPS;
|
|
Packit |
1244b8 |
struct SliceHeader;
|
|
Packit |
1244b8 |
struct NalUnit;
|
|
Packit |
1244b8 |
class Parser;
|
|
Packit |
1244b8 |
};
|
|
Packit |
1244b8 |
};
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
namespace YamiMediaCodec {
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
class VaapiDecPictureH265;
|
|
Packit |
1244b8 |
class VaapiDecoderH265:public VaapiDecoderBase {
|
|
Packit |
1244b8 |
typedef YamiParser::H265::SPS SPS;
|
|
Packit |
1244b8 |
typedef YamiParser::H265::SliceHeader SliceHeader;
|
|
Packit |
1244b8 |
typedef YamiParser::H265::NalUnit NalUnit;
|
|
Packit |
1244b8 |
typedef YamiParser::H265::Parser Parser;
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
public:
|
|
Packit |
1244b8 |
typedef SharedPtr<VaapiDecPictureH265> PicturePtr;
|
|
Packit |
1244b8 |
typedef std::vector<VaapiDecPictureH265*> RefSet;
|
|
Packit |
1244b8 |
VaapiDecoderH265();
|
|
Packit |
1244b8 |
virtual ~VaapiDecoderH265();
|
|
Packit |
1244b8 |
virtual YamiStatus start(VideoConfigBuffer*);
|
|
Packit |
1244b8 |
virtual YamiStatus decode(VideoDecodeBuffer*);
|
|
Packit |
1244b8 |
virtual void flush(void);
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
private:
|
|
Packit |
1244b8 |
friend class FactoryTest<IVideoDecoder, VaapiDecoderH265>;
|
|
Packit |
1244b8 |
friend class VaapiDecoderH265Test;
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
class DPB {
|
|
Packit |
1244b8 |
typedef VaapiDecoderH265::RefSet RefSet;
|
|
Packit |
1244b8 |
typedef std::function<YamiStatus(const PicturePtr&)> OutputCallback;
|
|
Packit |
1244b8 |
typedef std::function<void (const PicturePtr&)> ForEachFunction;
|
|
Packit |
1244b8 |
public:
|
|
Packit |
1244b8 |
typedef VaapiDecoderH265::PicturePtr PicturePtr;
|
|
Packit |
1244b8 |
DPB(OutputCallback output);
|
|
Packit |
1244b8 |
bool init(const PicturePtr&,
|
|
Packit |
1244b8 |
const SliceHeader *const,
|
|
Packit |
1244b8 |
const NalUnit *const,
|
|
Packit |
1244b8 |
bool newStream);
|
|
Packit |
1244b8 |
bool add(const PicturePtr&, const SliceHeader* const lastSlice);
|
|
Packit |
1244b8 |
void flush();
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
RefSet m_stCurrBefore;
|
|
Packit |
1244b8 |
RefSet m_stCurrAfter;
|
|
Packit |
1244b8 |
RefSet m_stFoll;
|
|
Packit |
1244b8 |
RefSet m_ltCurr;
|
|
Packit |
1244b8 |
RefSet m_ltFoll;
|
|
Packit |
1244b8 |
private:
|
|
Packit |
1244b8 |
void forEach(ForEachFunction);
|
|
Packit |
1244b8 |
bool initReference(const PicturePtr&,
|
|
Packit |
1244b8 |
const SliceHeader *const,
|
|
Packit |
1244b8 |
const NalUnit *const,
|
|
Packit |
1244b8 |
bool newStream);
|
|
Packit |
1244b8 |
bool initShortTermRef(const PicturePtr& picture,
|
|
Packit |
1244b8 |
const SliceHeader* const);
|
|
Packit |
1244b8 |
bool initShortTermRef(RefSet& ref,int32_t currPoc,
|
|
Packit |
1244b8 |
const int32_t* const delta,
|
|
Packit |
1244b8 |
const uint8_t* const used,
|
|
Packit |
1244b8 |
uint8_t num);
|
|
Packit |
1244b8 |
bool initLongTermRef(const PicturePtr&,
|
|
Packit |
1244b8 |
const SliceHeader *const);
|
|
Packit |
1244b8 |
VaapiDecPictureH265* getPic(int32_t poc, bool hasMsb = true);
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
//for C.5.2.2
|
|
Packit |
1244b8 |
bool checkReorderPics(const SPS* const sps);
|
|
Packit |
1244b8 |
bool checkDpbSize(const SPS* const);
|
|
Packit |
1244b8 |
bool checkLatency(const SPS* const);
|
|
Packit |
1244b8 |
void removeUnused();
|
|
Packit |
1244b8 |
void clearRefSet();
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
void bumpAll();
|
|
Packit |
1244b8 |
bool bump();
|
|
Packit |
1244b8 |
bool output(const PicturePtr& picture);
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
struct PocLess
|
|
Packit |
1244b8 |
{
|
|
Packit |
1244b8 |
inline bool operator()(const PicturePtr& left, const PicturePtr& right) const;
|
|
Packit |
1244b8 |
};
|
|
Packit |
1244b8 |
typedef std::set<PicturePtr, PocLess> PictureList;
|
|
Packit |
1244b8 |
PictureList m_pictures;
|
|
Packit |
1244b8 |
OutputCallback m_output;
|
|
Packit |
1244b8 |
PicturePtr m_dummy;
|
|
Packit |
1244b8 |
};
|
|
Packit |
1244b8 |
YamiStatus decodeNalu(NalUnit*);
|
|
Packit |
1244b8 |
YamiStatus decodeParamSet(NalUnit*);
|
|
Packit |
1244b8 |
YamiStatus decodeSlice(NalUnit*);
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
static VAProfile getVaProfile(const SPS* const sps);
|
|
Packit |
1244b8 |
YamiStatus ensureContext(const SPS* const);
|
|
Packit |
1244b8 |
bool fillPicture(const PicturePtr& , const SliceHeader* const );
|
|
Packit |
1244b8 |
bool fillSlice(const PicturePtr&, const SliceHeader* const, const NalUnit* const );
|
|
Packit |
1244b8 |
bool fillIqMatrix(const PicturePtr&, const SliceHeader* const);
|
|
Packit |
1244b8 |
bool fillPredWeightTable(VASliceParameterBufferHEVC*, const SliceHeader* const);
|
|
Packit |
1244b8 |
bool fillReference(const PicturePtr&,
|
|
Packit |
1244b8 |
VASliceParameterBufferHEVC*, const SliceHeader* const);
|
|
Packit |
1244b8 |
void fillReference(VAPictureHEVC* refs, int32_t size);
|
|
Packit |
1244b8 |
void fillReference(VAPictureHEVC* refs, int32_t& n, const RefSet& refset, uint32_t flags);
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
bool fillReferenceIndex(VASliceParameterBufferHEVC*, const SliceHeader* const);
|
|
Packit |
1244b8 |
void fillReferenceIndexForList(VASliceParameterBufferHEVC*, const RefSet&, bool isList0);
|
|
Packit |
1244b8 |
bool getRefPicList(RefSet& refset, const RefSet& stCurr0, const RefSet& stCurr1,
|
|
Packit |
1244b8 |
uint8_t numActive, bool modify, const uint32_t* modiList);
|
|
Packit |
1244b8 |
uint8_t getIndex(int32_t poc);
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
bool decodeHevcRecordData(uint8_t* buf, int32_t bufSize);
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
SurfacePtr createSurface(const SliceHeader* const);
|
|
Packit |
1244b8 |
YamiStatus createPicture(PicturePtr& picture, const SliceHeader* const, const NalUnit* const nalu);
|
|
Packit |
1244b8 |
void getPoc(const PicturePtr&, const SliceHeader* const,
|
|
Packit |
1244b8 |
const NalUnit* const);
|
|
Packit |
1244b8 |
YamiStatus decodeCurrent();
|
|
Packit |
1244b8 |
YamiStatus outputPicture(const PicturePtr&);
|
|
Packit |
1244b8 |
void flush(bool discardOutput);
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
SharedPtr<Parser> m_parser;
|
|
Packit |
1244b8 |
PicturePtr m_current;
|
|
Packit |
1244b8 |
int32_t m_prevPicOrderCntMsb;
|
|
Packit |
1244b8 |
int32_t m_prevPicOrderCntLsb;
|
|
Packit |
1244b8 |
int32_t m_nalLengthSize;
|
|
Packit |
1244b8 |
bool m_associatedIrapNoRaslOutputFlag;
|
|
Packit |
1244b8 |
bool m_noRaslOutputFlag;
|
|
Packit |
1244b8 |
bool m_newStream;
|
|
Packit |
1244b8 |
bool m_endOfSequence;
|
|
Packit |
1244b8 |
DPB m_dpb;
|
|
Packit |
1244b8 |
std::map<int32_t, uint8_t> m_pocToIndex;
|
|
Packit |
1244b8 |
SharedPtr<SliceHeader> m_prevSlice;
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
/**
|
|
Packit |
1244b8 |
* VaapiDecoderFactory registration result. This decoder is registered in
|
|
Packit |
1244b8 |
* vaapidecoder_host.cpp
|
|
Packit |
1244b8 |
*/
|
|
Packit |
1244b8 |
static const bool s_registered;
|
|
Packit |
1244b8 |
};
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
} // namespace YamiMediaCodec
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
#endif
|
|
Packit |
1244b8 |
|