summaryrefslogtreecommitdiff
path: root/src/video_decode.h
blob: 9da7f636142dbd1d021d9db2d4999ae9cb652240 (plain)
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
#ifndef _VIDEO_DECODE_H_
#define _VIDEO_DECODE_H_

#include <stdint.h>
#include <libavutil/avutil.h>
#include <libavutil/error.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>

struct video_decode;
struct video_frame {
	uint8_t *data;
	int width, height, stride;
};

struct video_decode {
	AVFormatContext *fmt_ctx;
	AVCodecContext *codec_ctx;
	AVCodec *codec;
	int stream;
};

int
video_decode_init(struct video_decode **vd, char *file, int64_t timestamp);

void
video_decode_uninit(struct video_decode **vd);

/*
 * Returns number of decoded frames:
 *   1 - One frame decoded
 *   0 - Zero frames decoded - EOF
 * < 0 - Zero frames decoded - Error
 */
int
video_decode_get_frame(struct video_decode *vd, struct video_frame **frame);

void
video_decode_free_frame(struct video_frame **frame);

#endif /* _VIDEO_DECODE_H_ */