00001 #ifndef VIDEOOUT_XV_H_
00002 #define VIDEOOUT_XV_H_
00003
00004 #include <qwindowdefs.h>
00005
00006 #include "videooutbase.h"
00007
00008 #include "mythxdisplay.h"
00009 #include <X11/Xatom.h>
00010 #include <X11/Xutil.h>
00011 #include <X11/extensions/XShm.h>
00012 #include <X11/extensions/Xvlib.h>
00013 #include <X11/extensions/Xv.h>
00014
00015 #undef HAVE_AV_CONFIG_H
00016 extern "C" {
00017 #include "libavcodec/avcodec.h"
00018 }
00019
00020 class MythPlayer;
00021 class ChromaKeyOSD;
00022
00023 typedef enum VideoOutputSubType
00024 {
00025 XVUnknown = 0, Xlib, XShm, XVideo,
00026 } VOSType;
00027
00028 class VideoOutputXv : public VideoOutput
00029 {
00030 friend class ChromaKeyOSD;
00031 public:
00032 static void GetRenderOptions(render_opts &opts, QStringList &cpudeints);
00033 VideoOutputXv();
00034 ~VideoOutputXv();
00035
00036 bool Init(int width, int height, float aspect,
00037 WId winid, const QRect &win_rect, MythCodecID codec_id);
00038
00039 bool SetDeinterlacingEnabled(bool);
00040 bool SetupDeinterlace(bool interlaced, const QString& ovrf="");
00041 bool ApproveDeintFilter(const QString& filtername) const;
00042
00043 void ProcessFrame(VideoFrame *frame, OSD *osd,
00044 FilterChain *filterList,
00045 const PIPMap &pipPlayers,
00046 FrameScanType scan);
00047
00048 void PrepareFrame(VideoFrame*, FrameScanType, OSD *osd);
00049 void Show(FrameScanType);
00050
00051 void ClearAfterSeek(void);
00052
00053 void WindowResized(const QSize &new_size);
00054
00055 void MoveResize(void);
00056 bool InputChanged(const QSize &input_size,
00057 float aspect,
00058 MythCodecID av_codec_id,
00059 void *codec_private,
00060 bool &aspect_only);
00061 void Zoom(ZoomDirection direction);
00062 void VideoAspectRatioChanged(float aspect);
00063 void EmbedInWidget(const QRect &rect);
00064 void StopEmbedding(void);
00065 void MoveResizeWindow(QRect new_rect);
00066 void DrawUnusedRects(bool sync = true);
00067 virtual void UpdatePauseFrame(int64_t &default_tc);
00068 int SetPictureAttribute(PictureAttribute attribute, int newValue);
00069 void InitPictureAttributes(void);
00070
00071 virtual bool IsPIPSupported(void) const
00072 { return XVideo == VideoOutputSubType(); }
00073 virtual bool IsPBPSupported(void) const
00074 { return XVideo == VideoOutputSubType(); }
00075 virtual bool NeedExtraAudioDecode(void) const { return false; }
00076
00077 virtual QRect GetPIPRect(PIPLocation location,
00078 MythPlayer *pipplayer = NULL,
00079 bool do_pixel_adj = true) const;
00080
00081 static MythCodecID GetBestSupportedCodec(uint stream_type);
00082
00083 static int GrabSuitableXvPort(MythXDisplay* disp, Window root,
00084 MythCodecID type,
00085 uint width, uint height,
00086 bool &xvsetdefaults,
00087 QString *adaptor_name = NULL);
00088 static void UngrabXvPort(MythXDisplay* disp, int port);
00089
00090 static QStringList GetAllowedRenderers(MythCodecID myth_codec_id,
00091 const QSize &video_dim);
00092
00093 VOSType VideoOutputSubType() const { return video_output_subtype; }
00094 virtual MythPainter* GetOSDPainter(void);
00095
00096 private:
00097 virtual bool hasFullScreenOSD(void) const { return chroma_osd; }
00098 void DiscardFrame(VideoFrame*);
00099 void DiscardFrames(bool next_frame_keyframe);
00100
00101 void PrepareFrameXv(VideoFrame *);
00102 void PrepareFrameMem(VideoFrame *, FrameScanType);
00103
00104 void ShowXVideo(FrameScanType scan);
00105
00106 int SetXVPictureAttribute(PictureAttribute attribute, int newValue);
00107 void InitColorKey(bool turnoffautopaint);
00108
00109 bool InitVideoBuffers(bool use_xv, bool use_shm);
00110
00111 bool InitXVideo(void);
00112 bool InitXShm(void);
00113 bool InitXlib(void);
00114 bool InitOSD(void);
00115
00116 bool CreateBuffers(VOSType subtype);
00117 vector<unsigned char*> CreateShmImages(uint num, bool use_xv);
00118 void CreatePauseFrame(VOSType subtype);
00119
00120 void DeleteBuffers(VOSType subtype, bool delete_pause_frame);
00121
00122 bool InitSetupBuffers(void);
00123
00124
00125 VOSType video_output_subtype;
00126 QMutex global_lock;
00127
00128
00129 Window XJ_win;
00130 Window XJ_curwin;
00131 MythXDisplay *disp;
00132 unsigned long XJ_letterbox_colour;
00133 bool XJ_started;
00134
00135 VideoFrame av_pause_frame;
00136 vector<XShmSegmentInfo*> XJ_shm_infos;
00137 vector<YUVInfo> XJ_yuv_infos;
00138
00139
00140 XImage *XJ_non_xv_image;
00141 long long non_xv_frames_shown;
00142 int non_xv_show_frame;
00143 int non_xv_fps;
00144 PixelFormat non_xv_av_format;
00145 time_t non_xv_stop_time;
00146
00147
00148 int xv_port;
00149 int xv_hue_base;
00150 int xv_colorkey;
00151 bool xv_draw_colorkey;
00152 int xv_chroma;
00153 bool xv_set_defaults;
00154 buffer_map_t xv_buffers;
00155 bool xv_need_bobdeint_repaint;
00156 bool xv_use_picture_controls;
00157 QMap<PictureAttribute,int> xv_attribute_min;
00158 QMap<PictureAttribute,int> xv_attribute_max;
00159 QMap<PictureAttribute,int> xv_attribute_def;
00160
00161
00162 ChromaKeyOSD *chroma_osd;
00163 };
00164
00165 #endif // VIDEOOUT_XV_H_