3 * Copyright (C) 2005-2013 Team XBMC
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)
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.
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/>.
22 #if defined(HAVE_LIBVDADECODER)
24 #include "DVDVideoCodec.h"
25 #include <CoreVideo/CoreVideo.h>
27 // tracks a frame in and output queue in display order
28 typedef struct frame_queue {
32 FourCharCode pixel_buffer_format;
33 CVBufferRef pixel_buffer_ref;
34 struct frame_queue *nextframe;
40 class DllLibVDADecoder;
41 class CDVDVideoCodecVDA : public CDVDVideoCodec
45 virtual ~CDVDVideoCodecVDA();
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; }
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);
62 static void VDADecoderCallback(
63 void *decompressionOutputRefCon, CFDictionaryRef frameInfo,
64 OSStatus status, uint32_t infoFlags, CVImageBufferRef imageBuffer);
66 DllLibVDADecoder *m_dll;
67 void *m_vda_decoder; // opaque vdadecoder reference
69 const char *m_pFormatName;
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;
79 bool m_convert_bytestream;
80 bool m_convert_3byteTo4byteNALSize;
81 DllAvUtil *m_dllAvUtil;
82 DllAvFormat *m_dllAvFormat;
84 DllSwScale *m_dllSwScale;
85 DVDVideoPicture m_videobuffer;