00001 #ifndef PRIVATEDECODER_VDA_H
00002 #define PRIVATEDECODER_VDA_H
00003
00004 #include <QSize>
00005 #include <QLibrary>
00006 #include <QList>
00007
00008 #import "CoreFoundation/CoreFoundation.h"
00009 #ifdef USING_QUARTZ_VIDEO
00010 #import "QuartzCore/CoreVideo.h"
00011 #else
00012 #import "CoreVideo/CoreVideo.h"
00013 #endif
00014 #include "privatedecoder_vda_defs.h"
00015 #include "privatedecoder.h"
00016
00017 class VDALibrary
00018 {
00019 public:
00020 static MTV_PUBLIC VDALibrary* GetVDALibrary(void);
00021 VDALibrary();
00022 bool IsValid(void) const { return m_valid; }
00023
00024 MYTH_VDADECODERCREATE decoderCreate;
00025 MYTH_VDADECODERDECODE decoderDecode;
00026 MYTH_VDADECODERFLUSH decoderFlush;
00027 MYTH_VDADECODERDESTROY decoderDestroy;
00028 CFStringRef *decoderConfigWidth;
00029 CFStringRef *decoderConfigHeight;
00030 CFStringRef *decoderConfigSourceFmt;
00031 CFStringRef *decoderConfigAVCCData;
00032 QLibrary *m_lib;
00033 bool m_valid;
00034 };
00035
00036 class VDAFrame
00037 {
00038 public:
00039 VDAFrame(CVPixelBufferRef buf, FourCharCode fmt, int64_t pres,
00040 int8_t interlaced, int8_t top_field, int8_t repeat)
00041 : buffer(buf), format(fmt), pts(pres),
00042 interlaced_frame(interlaced), top_field_first(top_field),
00043 repeat_pict(repeat) { }
00044
00045 CVPixelBufferRef buffer;
00046 FourCharCode format;
00047 int64_t pts;
00048 int8_t interlaced_frame;
00049 int8_t top_field_first;
00050 int8_t repeat_pict;
00051 };
00052
00053 class PrivateDecoderVDA : public PrivateDecoder
00054 {
00055 public:
00056 static void GetDecoders(render_opts &opts);
00057 PrivateDecoderVDA();
00058 virtual ~PrivateDecoderVDA();
00059 virtual QString GetName(void) { return "vda"; }
00060 virtual bool Init(const QString &decoder,
00061 PlayerFlags flags,
00062 AVCodecContext *avctx);
00063 virtual bool Reset(void);
00064 virtual int GetFrame(AVStream *stream,
00065 AVFrame *picture,
00066 int *got_picture_ptr,
00067 AVPacket *pkt);
00068 virtual bool HasBufferedFrames(void);
00069 virtual bool NeedsReorderedPTS(void) { return true; }
00070
00071 static void VDADecoderCallback(void *decompressionOutputRefCon,
00072 CFDictionaryRef frameInfo,
00073 OSStatus status,
00074 uint32_t infoFlags,
00075 CVImageBufferRef imageBuffer);
00076
00077 protected:
00078 void PopDecodedFrame(void);
00079 bool RewriteAvcc(uint8_t **data, int &len, CFDataRef &data_out);
00080 bool RewritePacket(uint8_t *data, int len, CFDataRef &data_out);
00081
00082 VDALibrary *m_lib;
00083 VDADecoder *m_decoder;
00084 QSize m_size;
00085 QMutex m_frame_lock;
00086 int32_t m_frames_decoded;
00087 QList<VDAFrame> m_decoded_frames;
00088 bool m_annexb;
00089 uint32_t m_slice_count;
00090 bool m_convert_3byteTo4byteNALSize;
00091 int32_t m_max_ref_frames;
00092 };
00093
00094 #endif // PRIVATEDECODER_VDA_H