4 * Copyright (C) 2005-2013 Team XBMC
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with XBMC; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
26 #include "cores/VideoRenderers/RenderFormats.h"
28 // when modifying these structures, make sure you update all codecs accordingly
29 #define FRAME_TYPE_UNDEF 0
30 #define FRAME_TYPE_I 1
31 #define FRAME_TYPE_P 2
32 #define FRAME_TYPE_B 3
33 #define FRAME_TYPE_D 4
35 namespace DXVA { class CSurfaceContext; }
36 namespace VAAPI { struct CHolder; }
40 struct OpenMaxVideoBuffer;
41 class CStageFrightVideo;
42 typedef void* EGLImageKHR;
44 // should be entirely filled by all codecs
45 struct DVDVideoPicture
47 double pts; // timestamp in seconds, used in the CDVDPlayer class to keep track of pts
53 uint8_t* data[4]; // [4] = alpha channel, currently not used
54 int iLineSize[4]; // [4] = alpha channel, currently not used
57 DXVA::CSurfaceContext* context;
63 VAAPI::CHolder* vaapi;
68 OpenMaxVideoBuffer *openMaxBuffer;
72 struct __CVBuffer *cvBufferRef;
76 CStageFrightVideo* stf;
83 double iRepeatPicture;
85 unsigned int iFrameType : 4; // see defines above // 1->I, 2->P, 3->B, 0->Undef
86 unsigned int color_matrix : 4;
87 unsigned int color_range : 1; // 1 indicate if we have a full range of color
88 unsigned int chroma_position;
89 unsigned int color_primaries;
90 unsigned int color_transfer;
91 unsigned int extended_format;
93 int8_t* qscale_table; // Quantization parameters, primarily used by filters
99 unsigned int iDisplayWidth; // width of the picture without black bars
100 unsigned int iDisplayHeight; // height of the picture without black bars
102 ERenderFormat format;
105 struct DVDVideoUserData
111 #define DVP_FLAG_TOP_FIELD_FIRST 0x00000001
112 #define DVP_FLAG_REPEAT_TOP_FIELD 0x00000002 //Set to indicate that the top field should be repeated
113 #define DVP_FLAG_ALLOCATED 0x00000004 //Set to indicate that this has allocated data
114 #define DVP_FLAG_INTERLACED 0x00000008 //Set to indicate that this frame is interlaced
116 #define DVP_FLAG_NOSKIP 0x00000010 // indicate this picture should never be dropped
117 #define DVP_FLAG_DROPPED 0x00000020 // indicate that this picture has been dropped in decoder stage, will have no data
119 // DVP_FLAG 0x00000100 - 0x00000f00 is in use by libmpeg2!
121 #define DVP_QSCALE_UNKNOWN 0
122 #define DVP_QSCALE_MPEG1 1
123 #define DVP_QSCALE_MPEG2 2
124 #define DVP_QSCALE_H264 3
126 class CDVDStreamInfo;
127 class CDVDCodecOption;
128 class CDVDCodecOptions;
130 // VC_ messages, messages can be combined
131 #define VC_ERROR 0x00000001 // an error occured, no other messages will be returned
132 #define VC_BUFFER 0x00000002 // the decoder needs more data
133 #define VC_PICTURE 0x00000004 // the decoder got a picture, call Decode(NULL, 0) again to parse the rest of the data
134 #define VC_USERDATA 0x00000008 // the decoder found some userdata, call Decode(NULL, 0) again to parse the rest of the data
135 #define VC_FLUSHED 0x00000010 // the decoder lost it's state, we need to restart decoding again
141 virtual ~CDVDVideoCodec() {}
144 * Open the decoder, returns true on success
146 virtual bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) = 0;
149 * Dispose, Free all resources
151 virtual void Dispose() = 0;
154 * returns one or a combination of VC_ messages
155 * pData and iSize can be NULL, this means we should flush the rest of the data.
157 virtual int Decode(uint8_t* pData, int iSize, double dts, double pts) = 0;
161 * Should be the same as calling Dispose and Open after each other
163 virtual void Reset() = 0;
166 * returns true if successfull
167 * the data is valid until the next Decode call
169 virtual bool GetPicture(DVDVideoPicture* pDvdVideoPicture) = 0;
173 * returns true if successfull
174 * the data is cleared to zero
176 virtual bool ClearPicture(DVDVideoPicture* pDvdVideoPicture)
178 memset(pDvdVideoPicture, 0, sizeof(DVDVideoPicture));
183 * returns true if successfull
184 * the data is valid until the next Decode call
185 * userdata can be anything, for now we use it for closed captioning
187 virtual bool GetUserData(DVDVideoUserData* pDvdVideoUserData)
189 pDvdVideoUserData->data = NULL;
190 pDvdVideoUserData->size = 0;
195 * will be called by video player indicating if a frame will eventually be dropped
196 * codec can then skip actually decoding the data, just consume the data set picture headers
198 virtual void SetDropState(bool bDrop) = 0;
201 * will be called by video player indicating the playback speed. see DVD_PLAYSPEED_NORMAL,
202 * DVD_PLAYSPEED_PAUSE and friends.
204 virtual void SetSpeed(int iSpeed) {};
207 * returns the number of demuxer bytes in any internal buffers
209 virtual int GetDataSize(void)
215 * returns the time in seconds for demuxer bytes in any internal buffers
217 virtual double GetTimeSize(void)
224 FILTER_DEINTERLACE_YADIF = 0x1, /* use first deinterlace mode */
225 FILTER_DEINTERLACE_ANY = 0xf, /* use any deinterlace mode */
226 FILTER_DEINTERLACE_FLAGGED = 0x10, /* only deinterlace flagged frames */
227 FILTER_DEINTERLACE_HALFED = 0x20, /* do half rate deinterlacing */
228 FILTER_ROTATE = 0x40, /* rotate image according to the codec hints */
232 * set the type of filters that should be applied at decoding stage if possible
234 virtual unsigned int SetFilters(unsigned int filters) { return 0u; }
238 * should return codecs name
240 virtual const char* GetName() = 0;
244 * How many packets should player remember, so codec
245 * can recover should something cause it to flush
246 * outside of players control
248 virtual unsigned GetConvergeCount()
255 * Number of references to old pictures that are allowed to
256 * be retained when calling decode on the next demux packet
258 virtual unsigned GetAllowedReferences() { return 0; }