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/>.
23 #include "DVDVideoCodec.h"
24 #include "DVDResource.h"
25 #include "DllAvCodec.h"
26 #include "DllAvFormat.h"
27 #include "DllAvUtil.h"
28 #include "DllSwScale.h"
29 #include "DllAvFilter.h"
30 #include "DllPostProc.h"
32 class CCriticalSection;
34 class CDVDVideoCodecFFmpeg : public CDVDVideoCodec
37 class IHardwareDecoder : public IDVDResourceCounted<IHardwareDecoder>
41 virtual ~IHardwareDecoder() {};
42 virtual bool Open (AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces) = 0;
43 virtual int Decode (AVCodecContext* avctx, AVFrame* frame) = 0;
44 virtual bool GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture) = 0;
45 virtual int Check (AVCodecContext* avctx) = 0;
46 virtual void Reset () {}
47 virtual unsigned GetAllowedReferences() { return 0; }
48 virtual const std::string Name() = 0;
49 virtual CCriticalSection* Section() { return NULL; }
52 CDVDVideoCodecFFmpeg();
53 virtual ~CDVDVideoCodecFFmpeg();
54 virtual bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options);
55 virtual void Dispose();
56 virtual int Decode(uint8_t* pData, int iSize, double dts, double pts);
58 bool GetPictureCommon(DVDVideoPicture* pDvdVideoPicture);
59 virtual bool GetPicture(DVDVideoPicture* pDvdVideoPicture);
60 virtual void SetDropState(bool bDrop);
61 virtual unsigned int SetFilters(unsigned int filters);
62 virtual const char* GetName() { return m_name.c_str(); }; // m_name is never changed after open
63 virtual unsigned GetConvergeCount();
64 virtual unsigned GetAllowedReferences();
66 bool IsHardwareAllowed() { return !m_bSoftware; }
67 IHardwareDecoder * GetHardware() { return m_pHardware; };
68 void SetHardware(IHardwareDecoder* hardware)
70 SAFE_RELEASE(m_pHardware);
71 m_pHardware = hardware;
76 static enum PixelFormat GetFormat(struct AVCodecContext * avctx, const PixelFormat * fmt);
78 int FilterOpen(const CStdString& filters, bool scale);
80 int FilterProcess(AVFrame* frame);
84 if(m_pCodecContext->codec->name)
85 m_name = CStdString("ff-") + m_pCodecContext->codec->name;
90 m_name += "-" + m_pHardware->Name();
94 AVCodecContext* m_pCodecContext;
97 CStdString m_filters_next;
98 AVFilterGraph* m_pFilterGraph;
99 AVFilterContext* m_pFilterIn;
100 AVFilterContext* m_pFilterOut;
101 #if defined(LIBAVFILTER_AVFRAME_BASED)
102 AVFrame* m_pFilterFrame;
104 AVFilterBufferRef* m_pBufferRef;
108 int m_iPictureHeight;
112 int m_iOrientation;// orientation of the video in degress counter clockwise
114 unsigned int m_uSurfacesCount;
116 DllAvCodec m_dllAvCodec;
117 DllAvUtil m_dllAvUtil;
118 DllSwScale m_dllSwScale;
119 DllAvFilter m_dllAvFilter;
120 DllPostProc m_dllPostProc;
125 IHardwareDecoder *m_pHardware;
129 std::vector<PixelFormat> m_formats;