1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-2021 Ricardo Villalba <ricardo@smplayer.info> 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 19 #ifndef VIDEOLAYERRENDER_H 20 #define VIDEOLAYERRENDER_H 21 22 #include "videolayer.h" 23 #include <QList> 24 #include <QMap> 25 #include <stdint.h> 26 27 #define USE_YUV 28 29 #ifdef USE_GL_WINDOW 30 #include <QOpenGLFunctions> 31 class OpenGLRenderer; 32 #endif 33 34 class QTimer; 35 class ConnectionBase; 36 37 //#define COUNT_FPS 38 39 class VideoLayerRender : public VideoLayer 40 #ifdef USE_GL_WINDOW 41 , protected QOpenGLFunctions 42 #endif 43 { 44 Q_OBJECT 45 46 public: 47 VideoLayerRender(QWidget* parent = 0, Qt::WindowFlags f = QFlag(0)); 48 ~VideoLayerRender(); 49 50 void init(int width, int height, int bytes_per_pixel, uint32_t format, unsigned char* buffer); setImageBuffer(unsigned char * buffer)51 void setImageBuffer(unsigned char* buffer) { image_buffer = buffer; } 52 isFormatSupported(uint32_t format)53 bool isFormatSupported(uint32_t format) { 54 return supported_formats.contains(format); 55 } 56 57 public slots: 58 virtual void playingStarted(); 59 virtual void playingStopped(); 60 virtual void gotVO(QString); 61 62 virtual void render(); 63 64 protected: 65 QList<ConnectionBase *> connections; 66 QList<uint32_t> supported_formats; 67 bool is_vo_to_render; 68 69 int image_width; 70 int image_height; 71 int image_bytes; 72 uint32_t image_format; 73 unsigned char* image_buffer; 74 #if !defined(USE_GL_WINDOW) && defined(USE_YUV) 75 unsigned char* conv_buffer; 76 #endif 77 78 protected: 79 #ifdef USE_GL_WINDOW 80 virtual void initializeGL(); 81 virtual void paintGL(); 82 virtual void resizeGL(int w, int h); 83 84 OpenGLRenderer * renderer; 85 #else 86 virtual void paintEvent(QPaintEvent *event); 87 #ifdef USE_YUV 88 void YUV420PtoRGB24(unsigned char* yuv_src, unsigned char* rgb_dst, int w, int h); 89 void YUY2toRGB24(unsigned char* yuv_src, unsigned char* rgb_dst, int w, int h); 90 #endif 91 QPixmap frame; 92 QMap<uint32_t, int> format_to_image; 93 #endif 94 95 #ifdef COUNT_FPS 96 signals: 97 void renderedFps(int); 98 99 protected slots: 100 void updateFps(); 101 102 protected: 103 QTimer * fps_timer; 104 int current_fps; 105 #endif 106 }; 107 108 #endif 109