MythTV  master
nuppeldecoder.h
Go to the documentation of this file.
1 #ifndef NUPPELDECODER_H_
2 #define NUPPELDECODER_H_
3 
4 #include "config.h"
5 
6 #include <list>
7 using namespace std;
8 
9 #include <QString>
10 
11 #include "format.h"
12 #include "decoderbase.h"
13 #include "mythframe.h"
14 
15 #include "RTjpegN.h"
16 
17 extern "C" {
18 #include "libavcodec/avcodec.h"
19 }
20 
21 class ProgramInfo;
23 {
24  public:
25  RawDataList(struct rtframeheader frameh, unsigned char *data) :
26  frameheader(frameh), packet(data) {}
27  ~RawDataList() { if (packet) delete [] packet; }
28 
29  struct rtframeheader frameheader;
30  unsigned char *packet;
31 };
32 
33 class NuppelDecoder : public DecoderBase
34 {
35  public:
36  NuppelDecoder(MythPlayer *parent, const ProgramInfo &pginfo);
37  ~NuppelDecoder();
38 
39  static bool CanHandle(char testbuf[kDecoderProbeBufferSize],
40  int testbufsize = kDecoderProbeBufferSize);
41 
42  int OpenFile(RingBuffer *rbuffer, bool novideo,
43  char testbuf[kDecoderProbeBufferSize],
44  int testbufsize = kDecoderProbeBufferSize) override; // DecoderBase
45 
46  bool GetFrame(DecodeType) override; // DecoderBase
47 
48  // lastFrame is really (m_framesPlayed - 1) since we increment after getting
49  bool IsLastFrameKey(void) const override // DecoderBase
50  { return (m_lastKey == m_framesPlayed); }
51  void WriteStoredData(RingBuffer *rb, bool storevid,
52  long timecodeOffset) override; // DecoderBase
53  void ClearStoredData(void) override; // DecoderBase
54 
55  long UpdateStoredFrameNum(long framenumber) override; // DecoderBase
56 
57  QString GetCodecDecoderName(void) const override // DecoderBase
58  { return "nuppel"; }
59  QString GetRawEncodingType(void) override; // DecoderBase
60  MythCodecID GetVideoCodecID(void) const override; // DecoderBase
61 
62  private:
63  NuppelDecoder(const NuppelDecoder &) = delete; // not copyable
64  NuppelDecoder &operator=(const NuppelDecoder &) = delete; // not copyable
65 
66  inline bool ReadFileheader(struct rtfileheader *fh);
67  inline bool ReadFrameheader(struct rtframeheader *fh);
68 
69  bool DecodeFrame(struct rtframeheader *frameheader,
70  unsigned char *lstrm, VideoFrame *frame);
71  bool isValidFrametype(char type);
72 
73  bool InitAVCodecVideo(int codec);
74  void CloseAVCodecVideo(void);
75  bool InitAVCodecAudio(int codec);
76  void CloseAVCodecAudio(void);
77  void StoreRawData(unsigned char *strm);
78 
79  void SeekReset(long long newKey = 0, uint skipFrames = 0,
80  bool doFlush = false, bool discardFrames = false) override; // DecoderBase
81 
82  friend int get_nuppel_buffer(struct AVCodecContext *c, AVFrame *pic, int flags);
83  friend void release_nuppel_buffer(void *opaque, uint8_t *data);
84 
85  struct rtfileheader m_fileheader;
86  struct rtframeheader m_frameheader;
87 
88  RTjpeg *m_rtjd {nullptr};
89 
90  int m_video_width {0};
91  int m_video_height {0};
92  int m_video_size {0};
93  double m_video_frame_rate {0.0};
94  int m_audio_samplerate {44100};
95 #if HAVE_BIGENDIAN
96  int m_audio_bits_per_sample {0};
97 #endif
98 
99  int m_ffmpeg_extradatasize {0};
100  uint8_t *m_ffmpeg_extradata {nullptr};
101 
102  struct extendeddata m_extradata;
103  bool m_usingextradata {false};
104 
105  bool m_disablevideo {false};
106 
107  int m_totalLength {0};
108  long long m_totalFrames {0};
109 
110  int m_effdsp {0};
111 
112  VideoFrame *m_directframe {nullptr};
113  VideoFrame *m_decoded_video_frame {nullptr};
114 
115  AVCodec *m_mpa_vidcodec {nullptr};
116  AVCodecContext *m_mpa_vidctx {nullptr};
117  AVCodec *m_mpa_audcodec {nullptr};
118  AVCodecContext *m_mpa_audctx {nullptr};
119  uint8_t *m_audioSamples {nullptr};
120 
121  bool m_directrendering {false};
122 
123  char m_lastct {'1'};
124 
125  unsigned char *m_strm {nullptr};
126  unsigned char *m_buf {nullptr};
127  unsigned char *m_buf2 {nullptr};
128  unsigned char *m_planes[3];
129 
130  list<RawDataList*> m_storedData;
131 
132  int m_videosizetotal {0};
133  int m_videoframesread {0};
134  bool m_setreadahead {false};
135 };
136 
137 #endif
138 
139 /* vim: set expandtab tabstop=4 shiftwidth=4: */
RawDataList(struct rtframeheader frameh, unsigned char *data)
Definition: nuppeldecoder.h:25
MythCodecID
Definition: mythcodecid.h:10
struct AVFrame AVFrame
void release_nuppel_buffer(void *opaque, uint8_t *data)
int get_nuppel_buffer(struct AVCodecContext *c, AVFrame *pic, int)
unsigned int uint
Definition: compat.h:140
Holds information on recordings and videos.
Definition: programinfo.h:66
const int kDecoderProbeBufferSize
Definition: decoderbase.h:23
unsigned char * packet
Definition: nuppeldecoder.h:30
bool IsLastFrameKey(void) const override
Definition: nuppeldecoder.h:49
enum DecodeTypes DecodeType
Definition: RTjpegN.h:64
list< RawDataList * > m_storedData
Implements a file/stream reader/writer.
QString GetCodecDecoderName(void) const override
Definition: nuppeldecoder.h:57