00001 #ifndef NUPPELDECODER_H_
00002 #define NUPPELDECODER_H_
00003
00004 #include "config.h"
00005
00006 #include <list>
00007 using namespace std;
00008
00009 #include <QString>
00010
00011 #include "format.h"
00012 #include "decoderbase.h"
00013
00014 #include "RTjpegN.h"
00015
00016 extern "C" {
00017 #include "frame.h"
00018 #include "libavcodec/avcodec.h"
00019 }
00020
00021 class ProgramInfo;
00022 class RawDataList
00023 {
00024 public:
00025 RawDataList(struct rtframeheader frameh, unsigned char *data)
00026 { frameheader = frameh; packet = data; }
00027 ~RawDataList() { if (packet) delete [] packet; }
00028
00029 struct rtframeheader frameheader;
00030 unsigned char *packet;
00031 };
00032
00033 class NuppelDecoder : public DecoderBase
00034 {
00035 public:
00036 NuppelDecoder(MythPlayer *parent, const ProgramInfo &pginfo);
00037 ~NuppelDecoder();
00038
00039 static bool CanHandle(char testbuf[kDecoderProbeBufferSize],
00040 int testbufsize = kDecoderProbeBufferSize);
00041
00042 int OpenFile(RingBuffer *rbuffer, bool novideo,
00043 char testbuf[kDecoderProbeBufferSize],
00044 int testbufsize = kDecoderProbeBufferSize);
00045
00046 virtual bool GetFrame(DecodeType);
00047
00048
00049 virtual bool IsLastFrameKey(void) const
00050 { return (lastKey == framesPlayed); }
00051 void WriteStoredData(RingBuffer *rb, bool writevid, long timecodeOffset);
00052 void ClearStoredData(void);
00053
00054 long UpdateStoredFrameNum(long framenumber);
00055
00056 QString GetCodecDecoderName(void) const { return "nuppel"; }
00057 QString GetRawEncodingType(void);
00058 MythCodecID GetVideoCodecID(void) const;
00059
00060 private:
00061 inline bool ReadFileheader(struct rtfileheader *fileheader);
00062 inline bool ReadFrameheader(struct rtframeheader *frameheader);
00063
00064 bool DecodeFrame(struct rtframeheader *frameheader,
00065 unsigned char *lstrm, VideoFrame *frame);
00066 bool isValidFrametype(char type);
00067
00068 bool InitAVCodecVideo(int codec);
00069 void CloseAVCodecVideo(void);
00070 bool InitAVCodecAudio(int codec);
00071 void CloseAVCodecAudio(void);
00072 void StoreRawData(unsigned char *strm);
00073
00074 void SeekReset(long long newKey = 0, uint skipFrames = 0,
00075 bool needFlush = false, bool discardFrames = false);
00076
00077 friend int get_nuppel_buffer(struct AVCodecContext *c, AVFrame *pic);
00078 friend void release_nuppel_buffer(struct AVCodecContext *c, AVFrame *pic);
00079
00080 struct rtfileheader fileheader;
00081 struct rtframeheader frameheader;
00082
00083 RTjpeg *rtjd;
00084
00085 int video_width, video_height, video_size;
00086 double video_frame_rate;
00087 int audio_samplerate;
00088 #if HAVE_BIGENDIAN
00089 int audio_bits_per_sample;
00090 #endif
00091
00092 int ffmpeg_extradatasize;
00093 uint8_t *ffmpeg_extradata;
00094
00095 struct extendeddata extradata;
00096 bool usingextradata;
00097
00098 bool disablevideo;
00099
00100 int totalLength;
00101 long long totalFrames;
00102
00103 int effdsp;
00104
00105 VideoFrame *directframe;
00106 VideoFrame *decoded_video_frame;
00107
00108 AVCodec *mpa_vidcodec;
00109 AVCodecContext *mpa_vidctx;
00110 AVCodec *mpa_audcodec;
00111 AVCodecContext *mpa_audctx;
00112 AVPicture tmppicture;
00113 AVFrame *m_audioFrame;
00114
00115 bool directrendering;
00116
00117 char lastct;
00118
00119 unsigned char *strm_buf;
00120 unsigned char *strm;
00121 unsigned char *buf;
00122 unsigned char *buf2;
00123 unsigned char *planes[3];
00124
00125 list<RawDataList*> StoredData;
00126
00127 int videosizetotal;
00128 int videoframesread;
00129 bool setreadahead;
00130 };
00131
00132 #endif
00133
00134