[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / cores / dvdplayer / DVDCodecs / Video / DVDVideoCodecVDA.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2013 Team XBMC
4  *      http://www.xbmc.org
5  *
6  *  This Program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This Program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with XBMC; see the file COPYING.  If not, see
18  *  <http://www.gnu.org/licenses/>.
19  *
20  */
21
22 #if defined(HAVE_LIBVDADECODER)
23
24 #include "DVDVideoCodec.h"
25 #include <CoreVideo/CoreVideo.h>
26
27 // tracks a frame in and output queue in display order
28 typedef struct frame_queue {
29   double              dts;
30   double              pts;
31   double              sort_time;
32   FourCharCode        pixel_buffer_format;
33   CVBufferRef         pixel_buffer_ref;
34   struct frame_queue  *nextframe;
35 } frame_queue;
36
37 class DllAvUtil;
38 class DllSwScale;
39 class DllAvFormat;
40 class DllLibVDADecoder;
41 class CDVDVideoCodecVDA : public CDVDVideoCodec
42 {
43 public:
44   CDVDVideoCodecVDA();
45   virtual ~CDVDVideoCodecVDA();
46
47   // Required overrides
48   virtual bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options);
49   virtual void Dispose(void);
50   virtual int  Decode(BYTE *pData, int iSize, double dts, double pts);
51   virtual void Reset(void);
52   virtual bool GetPicture(DVDVideoPicture *pDvdVideoPicture);
53   virtual bool ClearPicture(DVDVideoPicture* pDvdVideoPicture);
54   virtual void SetDropState(bool bDrop);
55   virtual const char* GetName(void) { return (const char*)m_pFormatName; }
56   
57 protected:
58   void DisplayQueuePop(void);
59   void UYVY422_to_YUV420P(uint8_t *yuv422_ptr, int yuv422_stride, DVDVideoPicture *picture);
60   void BGRA_to_YUV420P(uint8_t *bgra_ptr, int bgra_stride, DVDVideoPicture *picture);
61
62   static void VDADecoderCallback(
63     void *decompressionOutputRefCon, CFDictionaryRef frameInfo,
64     OSStatus status, uint32_t infoFlags, CVImageBufferRef imageBuffer);
65
66   DllLibVDADecoder  *m_dll;
67   void              *m_vda_decoder;   // opaque vdadecoder reference
68   int32_t           m_format;
69   const char        *m_pFormatName;
70   bool              m_DropPictures;
71
72   double            m_sort_time_offset;
73   pthread_mutex_t   m_queue_mutex;    // mutex protecting queue manipulation
74   frame_queue       *m_display_queue; // display-order queue - next display frame is always at the queue head
75   int32_t           m_queue_depth;    // we will try to keep the queue depth around 16+1 frames
76   int32_t           m_max_ref_frames;
77   bool              m_use_cvBufferRef;
78   
79   bool              m_convert_bytestream;
80   bool              m_convert_3byteTo4byteNALSize;
81   DllAvUtil         *m_dllAvUtil;
82   DllAvFormat       *m_dllAvFormat;
83
84   DllSwScale        *m_dllSwScale;
85   DVDVideoPicture   m_videobuffer;
86 };
87
88 #endif