29 #include "cores/VideoPlayer/Buffers/VideoBuffer.h" 30 #include "cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h" 31 #include "cores/VideoSettings.h" 32 #include "guilib/DispResource.h" 33 #include "threads/CriticalSection.h" 34 #include "threads/Event.h" 35 #include "threads/SharedSection.h" 36 #include "threads/Thread.h" 37 #include "utils/ActorProtocol.h" 38 #include "utils/Geometry.h" 48 #include <X11/Xutil.h> 51 #include <libavutil/avutil.h> 52 #include <libavcodec/vdpau.h> 66 VdpGetProcAddress*vdp_get_proc_address;
67 VdpDeviceDestroy* vdp_device_destroy;
69 VdpVideoSurfaceCreate* vdp_video_surface_create;
70 VdpVideoSurfaceDestroy* vdp_video_surface_destroy;
71 VdpVideoSurfacePutBitsYCbCr* vdp_video_surface_put_bits_y_cb_cr;
72 VdpVideoSurfaceGetBitsYCbCr* vdp_video_surface_get_bits_y_cb_cr;
74 VdpOutputSurfacePutBitsYCbCr* vdp_output_surface_put_bits_y_cb_cr;
75 VdpOutputSurfacePutBitsNative* vdp_output_surface_put_bits_native;
76 VdpOutputSurfaceCreate* vdp_output_surface_create;
77 VdpOutputSurfaceDestroy* vdp_output_surface_destroy;
78 VdpOutputSurfaceGetBitsNative* vdp_output_surface_get_bits_native;
79 VdpOutputSurfaceRenderOutputSurface* vdp_output_surface_render_output_surface;
80 VdpOutputSurfacePutBitsIndexed* vdp_output_surface_put_bits_indexed;
82 VdpVideoMixerCreate* vdp_video_mixer_create;
83 VdpVideoMixerSetFeatureEnables* vdp_video_mixer_set_feature_enables;
84 VdpVideoMixerQueryParameterSupport* vdp_video_mixer_query_parameter_support;
85 VdpVideoMixerQueryFeatureSupport* vdp_video_mixer_query_feature_support;
86 VdpVideoMixerDestroy* vdp_video_mixer_destroy;
87 VdpVideoMixerRender* vdp_video_mixer_render;
88 VdpVideoMixerSetAttributeValues* vdp_video_mixer_set_attribute_values;
90 VdpGenerateCSCMatrix* vdp_generate_csc_matrix;
92 VdpGetErrorString* vdp_get_error_string;
94 VdpDecoderCreate* vdp_decoder_create;
95 VdpDecoderDestroy* vdp_decoder_destroy;
96 VdpDecoderRender* vdp_decoder_render;
97 VdpDecoderQueryCapabilities* vdp_decoder_query_caps;
99 VdpPreemptionCallbackRegister* vdp_preemption_callback_register;
115 uint16_t decodedPics;
116 uint16_t processedPics;
125 std::unique_lock<CCriticalSection> l(m_sec);
130 std::unique_lock<CCriticalSection> l(m_sec);
135 std::unique_lock<CCriticalSection> l(m_sec);
140 std::unique_lock<CCriticalSection> l(m_sec);
145 std::unique_lock<CCriticalSection> l(m_sec);
150 std::unique_lock<CCriticalSection> l(m_sec);
155 std::unique_lock<CCriticalSection> l(m_sec);
161 void Get(uint16_t& decoded, uint16_t& processed, uint16_t& render)
163 std::unique_lock<CCriticalSection> l(m_sec);
164 decoded = decodedPics, processed = processedPics, render = renderPics;
166 void SetParams(uint64_t time,
int flags)
168 std::unique_lock<CCriticalSection> l(m_sec);
172 void GetParams(uint64_t& lat,
int& flags)
174 std::unique_lock<CCriticalSection> l(m_sec);
178 void SetCanSkipDeint(
bool canSkip)
180 std::unique_lock<CCriticalSection> l(m_sec);
181 canSkipDeint = canSkip;
185 std::unique_lock<CCriticalSection> l(m_sec);
191 void SetDraining(
bool drain)
193 std::unique_lock<CCriticalSection> l(m_sec);
198 std::unique_lock<CCriticalSection> l(m_sec);
206 CCriticalSection m_sec;
226 VdpDecoder vdpDecoder;
227 VdpChromaType vdpChromaType;
232 int numRenderBuffers;
233 uint32_t maxReferences;
254 DVDPic.SetParams(rhs.DVDPic);
255 videoSurface = rhs.videoSurface;
260 VdpVideoSurface videoSurface;
276 DVDPic.SetParams(rhs.DVDPic);
277 videoSurface = rhs.videoSurface;
278 outputSurface = rhs.outputSurface;
286 VdpVideoSurface videoSurface = VDP_INVALID_HANDLE;
287 VdpOutputSurface outputSurface = VDP_INVALID_HANDLE;
315 : Protocol(std::move(name), inEvent, outEvent)
335 : Protocol(std::move(name), inEvent, outEvent)
365 void OnStartup()
override;
366 void OnExit()
override;
367 void Process()
override;
372 void CreateVdpauMixer();
373 void ProcessPicture();
376 void CheckFeatures();
377 void SetPostProcFeatures(
bool postProcEnabled);
379 void InitCSCMatrix(
int Width);
380 bool GenerateStudioCSCMatrix(VdpColorStandard colorStandard, VdpCSCMatrix &studioCSCMatrix);
382 void SetNoiseReduction();
384 void SetDeintSkipChroma();
385 void SetDeinterlacing();
386 void SetHWUpscaling();
387 void DisableHQScaling();
388 std::string GetDeintStrFromInterlaceMethod(EINTERLACEMETHOD method);
389 bool CheckStatus(VdpStatus vdp_st,
int line);
393 bool m_bStateMachineSelfTrigger;
399 VdpVideoMixer m_videoMixer;
400 VdpProcamp m_Procamp;
401 VdpCSCMatrix m_CSCMatrix;
405 float m_NoiseReduction;
409 bool m_SeenInterlaceFlag;
410 unsigned int m_ColorMatrix : 4;
411 VdpVideoMixerPictureStructure m_mixerfield;
415 std::queue<VdpOutputSurface> m_outputSurfaces;
416 std::queue<CVdpauDecodedPicture> m_decodedPics;
417 std::deque<CVdpauDecodedPicture> m_mixerInput;
482 void OnStartup()
override;
483 void OnExit()
override;
484 void Process()
override;
490 void ProcessSyncPicture();
494 bool EnsureBufferPool();
495 void ReleaseBufferPool();
498 bool CheckStatus(VdpStatus vdp_st,
int line);
502 bool m_bStateMachineSelfTrigger;
509 std::shared_ptr<CVdpauBufferPool> m_bufferPool;
520 void AddSurface(VdpVideoSurface surf);
521 void ClearReference(VdpVideoSurface surf);
522 bool MarkRender(VdpVideoSurface surf);
523 void ClearRender(VdpVideoSurface surf);
524 bool IsValid(VdpVideoSurface surf);
525 VdpVideoSurface GetFree(VdpVideoSurface surf);
526 VdpVideoSurface RemoveNext(
bool skiprender =
false);
531 std::map<VdpVideoSurface, int> m_state;
532 std::list<VdpVideoSurface> m_freeSurfaces;
533 CCriticalSection m_section;
546 VdpDevice GetDevice();
547 bool Supports(VdpVideoMixerFeature feature);
548 VdpVideoMixerFeature* GetFeatures();
549 int GetFeatureCount();
554 bool CreateContext();
555 void DestroyContext();
557 void SpewHardwareAvailable();
559 static CCriticalSection m_section;
560 static Display *m_display;
562 VdpVideoMixerFeature m_vdpFeatures[14];
564 static void *m_dlHandle;
565 VdpDevice m_vdpDevice;
567 VdpStatus (*dl_vdp_device_create_x11)(Display* display,
int screen, VdpDevice* device, VdpGetProcAddress **get_proc_address);
591 bool Open (AVCodecContext* avctx, AVCodecContext* mainctx,
const enum AVPixelFormat)
override;
592 CDVDVideoCodec::VCReturn Decode (AVCodecContext* avctx, AVFrame* frame)
override;
593 bool GetPicture(AVCodecContext* avctx,
VideoPicture* picture)
override;
594 void Reset()
override;
595 virtual void Close();
596 long Release()
override;
597 bool CanSkipDeint()
override;
598 unsigned GetAllowedReferences()
override {
return 5; }
600 CDVDVideoCodec::VCReturn Check(AVCodecContext* avctx)
override;
601 const std::string Name()
override {
return "vdpau"; }
602 void SetCodecControl(
int flags)
override;
604 bool Supports(VdpVideoMixerFeature feature);
605 static bool IsVDPAUFormat(AVPixelFormat
fmt);
607 static void FFReleaseBuffer(
void *opaque, uint8_t *data);
608 static int FFGetBuffer(AVCodecContext *avctx, AVFrame *pic,
int flags);
609 static int Render(
struct AVCodecContext *s,
struct AVFrame *src,
610 const VdpPictureInfo *info, uint32_t buffers_used,
611 const VdpBitstreamBuffer *buffers);
613 void OnLostDisplay()
override;
614 void OnResetDisplay()
override;
617 static void Register();
620 void SetWidthHeight(
int width,
int height);
621 bool ConfigVDPAU(AVCodecContext *avctx,
int ref_frames);
622 bool CheckStatus(VdpStatus vdp_st,
int line);
623 void FiniVDPAUOutput();
625 long ReleasePicReference();
627 static void ReadFormatOf( AVCodecID codec
628 , VdpDecoderProfile &decoder_profile
629 , VdpChromaType &chroma_type);
640 CCriticalSection m_DecoderSection;
644 bool m_vdpauConfigured;
647 AVVDPAUContext m_hwContext;
648 AVCodecContext* m_avctx =
nullptr;
658 static bool m_capGeneral;
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
Definition: DVDStreamInfo.h:23
Definition: VideoBuffer.h:85
Buffer statistics used to control number of frames in queue.
Definition: VDPAU.h:112
Definition: ActorProtocol.h:73
Embeds the vdpau video mixer Embedded by COutput class, gets decoded frames from COutput, processes them in mixer ands sends processed frames back to COutput.
Definition: VDPAU.h:354
Definition: DVDVideoCodec.h:245
Definition: ActorProtocol.h:45
VDPAU main class.
Definition: VDPAU.h:573
Definition: DispResource.h:14
Holds a decoded frame Input to COutput for further processing.
Definition: VDPAU.h:245
Definition: ProcessInfo.h:26
Definition: VDPAU.cpp:1393
Definition: DVDVideoCodec.h:36
Frame after having been processed by vdpau mixer.
Definition: VDPAU.h:267
VDPAU interface to driver.
Definition: VDPAU.h:64