aboutsummaryrefslogtreecommitdiffstats
path: root/libav/avcodec.h
blob: 299f81ab32d5e64a816424f856d1dc453b6fed9e (plain) (blame)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "common.h"

enum CodecID {
    CODEC_ID_NONE, 
    CODEC_ID_MPEG1VIDEO,
    CODEC_ID_H263,
    CODEC_ID_RV10,
    CODEC_ID_MP2,
    CODEC_ID_AC3,
    CODEC_ID_MJPEG,
};

enum CodecType {
    CODEC_TYPE_VIDEO,
    CODEC_TYPE_AUDIO,
};
    
typedef struct AVEncodeContext {
    int bit_rate;
    int rate; /* frames per sec or samples per sec */

    /* video only */
    int width, height;
    int gop_size; /* 0 = intra only */
    
    /* audio only */
    int channels;

    /* the following data should not be initialized */
    int frame_size; /* in samples, initialized when calling 'init' */
    int frame_number; /* audio or video frame number */
    int key_frame;    /* true if the previous compressed frame was 
                         a key frame (intra, or seekable) */
    struct AVEncoder *codec;
    void *priv_data;
} AVEncodeContext;

typedef struct AVEncoder {
    char *name;
    int type;
    int id;
    int priv_data_size;
    int (*init)(AVEncodeContext *);
    int (*encode)(AVEncodeContext *, UINT8 *buf, int buf_size, void *data);
    int (*close)(AVEncodeContext *);
    struct AVEncoder *next;
} AVEncoder;

extern AVEncoder ac3_encoder;
extern AVEncoder mp2_encoder;
extern AVEncoder mpeg1video_encoder;
extern AVEncoder h263_encoder;
extern AVEncoder rv10_encoder;
extern AVEncoder mjpeg_encoder;

/* resample.c */

typedef struct {
    /* fractional resampling */
    UINT32 incr; /* fractional increment */
    UINT32 frac;
    int last_sample;
    /* integer down sample */
    int iratio;  /* integer divison ratio */
    int icount, isum;
    int inv;
} ReSampleChannelContext;

typedef struct {
    ReSampleChannelContext channel_ctx[2];
    float ratio;
    /* channel convert */
    int input_channels, output_channels;
} ReSampleContext;

int audio_resample_init(ReSampleContext *s, 
                        int output_channels, int input_channels, 
                        int output_rate, int input_rate);
int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);