11 #include "DVDVideoCodec.h"    12 #include "cores/VideoPlayer/Buffers/VideoBuffer.h"    13 #include "cores/VideoSettings.h"    14 #include "threads/CriticalSection.h"    15 #include "threads/Event.h"    16 #include "threads/SharedSection.h"    17 #include "threads/Thread.h"    18 #include "utils/ActorProtocol.h"    19 #include "utils/Geometry.h"    21 #include "platform/linux/sse4/DllLibSSE4.h"    33 #include <libavutil/avutil.h>    34 #include <libavfilter/avfilter.h>    37 using namespace Actor;
    41 #define FULLHD_WIDTH                       1920    46 void VaErrorCallback(
void *user_context, 
const char *message);
    47 void VaInfoCallback(
void *user_context, 
const char *message);
    63   uint16_t processedPics;
    73     std::unique_lock<CCriticalSection> l(m_sec);
    78     std::unique_lock<CCriticalSection> l(m_sec);
    83     std::unique_lock<CCriticalSection> l(m_sec);
    88     std::unique_lock<CCriticalSection> l(m_sec);
    93     std::unique_lock<CCriticalSection> l(m_sec);
    98     std::unique_lock<CCriticalSection> l(m_sec);
   103     std::unique_lock<CCriticalSection> l(m_sec);
   110   void Get(uint16_t& decoded, uint16_t& processed, uint16_t& render, 
bool& vpp)
   112     std::unique_lock<CCriticalSection> l(m_sec);
   113     decoded = decodedPics, processed = processedPics, render = renderPics;
   116   void SetParams(uint64_t time, 
int flags)
   118     std::unique_lock<CCriticalSection> l(m_sec);
   122   void GetParams(uint64_t& lat, 
int& flags)
   124     std::unique_lock<CCriticalSection> l(m_sec);
   130     std::unique_lock<CCriticalSection> l(m_sec);
   133   void GetCmd(
int& cmd)
   135     std::unique_lock<CCriticalSection> l(m_sec);
   139   void SetCanSkipDeint(
bool canSkip)
   141     std::unique_lock<CCriticalSection> l(m_sec);
   142     canSkipDeint = canSkip;
   146     std::unique_lock<CCriticalSection> l(m_sec);
   152   void SetVpp(
bool vpp)
   154     std::unique_lock<CCriticalSection> l(m_sec);
   159   CCriticalSection m_sec;
   184   uint32_t maxReferences;
   188   VAConfigAttrib attrib;
   207     DVDPic.SetParams(rhs.DVDPic);
   208     videoSurface = rhs.videoSurface;
   213   VASurfaceID videoSurface;
   230     DVDPic.SetParams(rhs.DVDPic);
   231     videoSurface = rhs.videoSurface;
   240   VASurfaceID videoSurface;
   251   void GetPlanes(uint8_t*(&planes)[YuvImage::MAX_PLANES]) 
override;
   252   void GetStrides(
int(&strides)[YuvImage::MAX_PLANES]) 
override;
   255   AVFrame *avFrame = 
nullptr;
   269     : 
Protocol(std::move(name), inEvent, outEvent)
   291     : 
Protocol(std::move(name), inEvent, outEvent)
   308   EINTERLACEMETHOD diMethods[8];
   333   void OnStartup() 
override;
   334   void OnExit() 
override;
   335   void Process() 
override;
   343   void ProcessReturnProcPicture(
int id);
   344   void ProcessSyncPicture();
   349   void EnsureBufferPool();
   350   void ReleaseBufferPool(
bool precleanup = 
false);
   355   bool m_bStateMachineSelfTrigger;
   359   std::chrono::milliseconds m_extTimeout = std::chrono::milliseconds::zero();
   363   std::shared_ptr<CVaapiBufferPool> m_bufferPool;
   366   std::list<std::shared_ptr<CPostproc>> m_discardedPostprocs;
   377   void AddSurface(VASurfaceID surf);
   378   void ClearReference(VASurfaceID surf);
   379   bool MarkRender(VASurfaceID surf);
   380   void ClearRender(VASurfaceID surf);
   381   bool IsValid(VASurfaceID surf);
   382   VASurfaceID GetFree(VASurfaceID surf);
   383   VASurfaceID GetAtIndex(
int idx);
   384   VASurfaceID RemoveNext(
bool skiprender = 
false);
   391   std::map<VASurfaceID, int> m_state;
   392   std::list<VASurfaceID> m_freeSurfaces;
   393   CCriticalSection m_section;
   405   VADisplay GetDisplay();
   406   bool SupportsProfile(VAProfile profile);
   407   VAConfigAttrib GetAttrib(VAProfile profile);
   408   VAConfigID CreateConfig(VAProfile profile, VAConfigAttrib attrib);
   409   static void FFReleaseBuffer(
void *opaque, uint8_t *data);
   413   void SetVaDisplayForSystem();
   414   bool CreateContext();
   415   void DestroyContext();
   417   bool CheckSuccess(VAStatus status, 
const std::string& 
function);
   418   bool IsValidDecoder(
CDecoder *decoder);
   419   void SetValidDRMVaDisplayFromRenderNode();
   421   static CCriticalSection m_section;
   422   VADisplay m_display = NULL;
   425   VAProfile *m_profiles;
   426   std::vector<CDecoder*> m_decoders;
   427   int m_renderNodeFD{-1};
   439   virtual VADisplay GetVADisplay() = 0;
   440   virtual void* GetEGLDisplay() { 
return nullptr; }
   457   bool Open (AVCodecContext* avctx, AVCodecContext* mainctx, 
const enum AVPixelFormat) 
override;
   458   CDVDVideoCodec::VCReturn Decode (AVCodecContext* avctx, AVFrame* frame) 
override;
   459   bool GetPicture(AVCodecContext* avctx, 
VideoPicture* picture) 
override;
   460   void Reset() 
override;
   461   virtual void Close();
   462   long Release() 
override;
   463   bool CanSkipDeint() 
override;
   464   unsigned GetAllowedReferences()
 override { 
return 4; }
   466   CDVDVideoCodec::VCReturn Check(AVCodecContext* avctx) 
override;
   467   const std::string Name()
 override { 
return "vaapi"; }
   468   void SetCodecControl(
int flags) 
override;
   470   void FFReleaseBuffer(uint8_t *data);
   471   static int FFGetBuffer(AVCodecContext *avctx, AVFrame *pic, 
int flags);
   479   void SetWidthHeight(
int width, 
int height);
   481   bool CheckStatus(VAStatus vdp_st, 
int line);
   482   void FiniVAAPIOutput();
   484   long ReleasePicReference();
   485   bool CheckSuccess(VAStatus status, 
const std::string& 
function);
   493   CCriticalSection m_DecoderSection;
   497   bool m_vaapiConfigured;
   500   int m_getBufferError;
   510   static bool m_capGeneral;
   511   static bool m_capDeepColor;
   514   struct AVBufferRefDeleter
   516     void operator()(AVBufferRef* p) 
const;
   519   std::unique_ptr<AVBufferRef, AVBufferRefDeleter> m_deviceRef;
   535   virtual bool Init(EINTERLACEMETHOD method) = 0;
   539   virtual void Flush() = 0;
   540   virtual bool UpdateDeintMethod(EINTERLACEMETHOD method) = 0;
   541   virtual bool DoesSync() = 0;
   542   virtual bool WantsPic() {
return true;}
   543   virtual bool UseVideoSurface() = 0;
   544   virtual void Discard(
COutput* output, ReadyToDispose cb) { (output->*cb)(
this); }
   558   bool Init(EINTERLACEMETHOD method) 
override;
   562   void Flush() 
override;
   563   bool UpdateDeintMethod(EINTERLACEMETHOD method) 
override;
   564   bool DoesSync() 
override;
   565   bool UseVideoSurface() 
override;
   566   void Discard(
COutput *output, ReadyToDispose cb) 
override;
   569   ReadyToDispose m_cbDispose = 
nullptr;
   571   int m_refsToSurfaces = 0;
   583   bool Init(EINTERLACEMETHOD method) 
override;
   587   void Flush() 
override;
   588   bool UpdateDeintMethod(EINTERLACEMETHOD method) 
override;
   589   bool DoesSync() 
override;
   590   bool WantsPic() 
override;
   591   bool UseVideoSurface() 
override;
   592   void Discard(
COutput *output, ReadyToDispose cb) 
override;
   594   bool CheckSuccess(VAStatus status, 
const std::string& 
function);
   597   VAConfigID m_configId = VA_INVALID_ID;
   598   VAContextID m_contextId = VA_INVALID_ID;
   600   std::deque<CVaapiDecodedPicture> m_decodedPics;
   601   VABufferID m_filter = VA_INVALID_ID;
   602   int m_forwardRefs, m_backwardRefs;
   605   EINTERLACEMETHOD m_vppMethod;
   606   ReadyToDispose m_cbDispose = 
nullptr;
   619   bool Init(EINTERLACEMETHOD method) 
override;
   623   void Flush() 
override;
   624   bool UpdateDeintMethod(EINTERLACEMETHOD method) 
override;
   625   bool DoesSync() 
override;
   626   bool UseVideoSurface() 
override;
   627   void Discard(
COutput *output, ReadyToDispose cb) 
override;
   629   bool CheckSuccess(VAStatus status, 
const std::string& 
function);
   633   AVFilterGraph* m_pFilterGraph;
   634   AVFilterContext* m_pFilterIn;
   635   AVFilterContext* m_pFilterOut;
   636   AVFrame *m_pFilterFrameIn;
   637   AVFrame *m_pFilterFrameOut;
   638   EINTERLACEMETHOD m_diMethod;
   642   ReadyToDispose m_cbDispose = 
nullptr;
   644   int m_refsToPics = 0;
 This is an Event class built from a ConditionVariable. 
Definition: Event.h:35
Definition: DVDStreamInfo.h:25
Definition: VideoBuffer.h:85
Definition: deflate.c:123
Definition: ActorProtocol.h:73
Definition: DVDVideoCodec.h:248
skip post processing 
Definition: VAAPI.h:554
ffmpeg filter 
Definition: VAAPI.h:613
Definition: ActorProtocol.h:21
Definition: ActorProtocol.h:45
Buffer pool holds allocated vaapi and gl resources Embedded in COutput. 
Definition: VAAPI.cpp:1313
VAAPI post processing. 
Definition: VAAPI.h:577
Holds a decoded frame Input to COutput for further processing. 
Definition: VAAPI.h:198
Definition: ProcessInfo.h:26
Definition: DllLibSSE4.h:24
Definition: DVDVideoCodec.h:36
Buffer statistics used to control number of frames in queue. 
Definition: VAAPI.h:59
bool m_seenInterlaced
Whether at least one interlaced frame was encountered in the video stream (indicating that more inter...
Definition: VAAPI.h:361