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 AVCodecContext* m_avctx;
501 int m_getBufferError;
511 static bool m_capGeneral;
512 static bool m_capDeepColor;
515 struct AVBufferRefDeleter
517 void operator()(AVBufferRef* p)
const;
520 std::unique_ptr<AVBufferRef, AVBufferRefDeleter> m_deviceRef;
536 virtual bool Init(EINTERLACEMETHOD method) = 0;
540 virtual void Flush() = 0;
541 virtual bool UpdateDeintMethod(EINTERLACEMETHOD method) = 0;
542 virtual bool DoesSync() = 0;
543 virtual bool WantsPic() {
return true;}
544 virtual bool UseVideoSurface() = 0;
545 virtual void Discard(
COutput* output, ReadyToDispose cb) { (output->*cb)(
this); }
559 bool Init(EINTERLACEMETHOD method)
override;
563 void Flush()
override;
564 bool UpdateDeintMethod(EINTERLACEMETHOD method)
override;
565 bool DoesSync()
override;
566 bool UseVideoSurface()
override;
567 void Discard(
COutput *output, ReadyToDispose cb)
override;
570 ReadyToDispose m_cbDispose =
nullptr;
572 int m_refsToSurfaces = 0;
584 bool Init(EINTERLACEMETHOD method)
override;
588 void Flush()
override;
589 bool UpdateDeintMethod(EINTERLACEMETHOD method)
override;
590 bool DoesSync()
override;
591 bool WantsPic()
override;
592 bool UseVideoSurface()
override;
593 void Discard(
COutput *output, ReadyToDispose cb)
override;
595 bool CheckSuccess(VAStatus status,
const std::string&
function);
598 VAConfigID m_configId = VA_INVALID_ID;
599 VAContextID m_contextId = VA_INVALID_ID;
601 std::deque<CVaapiDecodedPicture> m_decodedPics;
602 VABufferID m_filter = VA_INVALID_ID;
603 int m_forwardRefs, m_backwardRefs;
606 EINTERLACEMETHOD m_vppMethod;
607 ReadyToDispose m_cbDispose =
nullptr;
620 bool Init(EINTERLACEMETHOD method)
override;
624 void Flush()
override;
625 bool UpdateDeintMethod(EINTERLACEMETHOD method)
override;
626 bool DoesSync()
override;
627 bool UseVideoSurface()
override;
628 void Discard(
COutput *output, ReadyToDispose cb)
override;
630 bool CheckSuccess(VAStatus status,
const std::string&
function);
634 AVFilterGraph* m_pFilterGraph;
635 AVFilterContext* m_pFilterIn;
636 AVFilterContext* m_pFilterOut;
637 AVFrame *m_pFilterFrameIn;
638 AVFrame *m_pFilterFrameOut;
639 EINTERLACEMETHOD m_diMethod;
643 ReadyToDispose m_cbDispose =
nullptr;
645 int m_refsToPics = 0;
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
Definition: DVDStreamInfo.h:23
Definition: VideoBuffer.h:85
Definition: deflate.c:123
Definition: ActorProtocol.h:73
Definition: DVDVideoCodec.h:245
skip post processing
Definition: VAAPI.h:555
ffmpeg filter
Definition: VAAPI.h:614
Definition: ActorProtocol.h:21
Definition: ActorProtocol.h:45
Buffer pool holds allocated vaapi and gl resources Embedded in COutput.
Definition: VAAPI.cpp:1318
VAAPI post processing.
Definition: VAAPI.h:578
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