-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathzh264decoder.h
55 lines (40 loc) · 1.23 KB
/
zh264decoder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef ZH264DECODER_H
#define ZH264DECODER_H
#include "zfile.h"
#include "zimage.h"
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
}
#define ZH264_READ_CHUNK_SIZE 16384
namespace LibChaos {
class ZH264Decoder {
public:
typedef void (*decoderCallback)(zu32 number, AVFrame* frame, AVPacket* pkt, const ZH264Decoder *decodeFrame, void* user);
public:
ZH264Decoder();
ZH264Decoder(ZPath file, decoderCallback callback, void *userptr);
~ZH264Decoder();
bool open(ZPath path, decoderCallback framecallback, void *userptr);
bool isOk() const { return ok; }
void forceFPS(float fps);
double getFPS() const;
bool readFrame();
private:
void readData();
void decodeFrame(zbyte *data, zu64 size);
public:
AVCodec *codec; // h264 decoder
AVCodecContext *context; // Decoder state
AVCodecParserContext *parser; // h264 bitstream parser
AVFrame *frame; // Current decoded frame
zu32 framecount;
ZFile file; // File with h264 data
ZArray<zbyte> buffer; // Buffered file data
bool ok;
decoderCallback callback;
void *user;
float forcefps;
};
}
#endif // ZH264DECODER_H