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