annotate utils.c @ 3:1bdbd869c1f0 libavcodec

added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
author glantau
date Mon, 23 Jul 2001 20:58:31 +0000
parents 986e461dc072
children 08265a63313e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1 /*
986e461dc072 Initial revision
glantau
parents:
diff changeset
2 * utils for libavcodec
986e461dc072 Initial revision
glantau
parents:
diff changeset
3 * Copyright (c) 2001 Gerard Lantau.
986e461dc072 Initial revision
glantau
parents:
diff changeset
4 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
986e461dc072 Initial revision
glantau
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
986e461dc072 Initial revision
glantau
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
986e461dc072 Initial revision
glantau
parents:
diff changeset
8 * (at your option) any later version.
986e461dc072 Initial revision
glantau
parents:
diff changeset
9 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
986e461dc072 Initial revision
glantau
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
986e461dc072 Initial revision
glantau
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
986e461dc072 Initial revision
glantau
parents:
diff changeset
13 * GNU General Public License for more details.
986e461dc072 Initial revision
glantau
parents:
diff changeset
14 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
986e461dc072 Initial revision
glantau
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
986e461dc072 Initial revision
glantau
parents:
diff changeset
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
986e461dc072 Initial revision
glantau
parents:
diff changeset
18 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
19 #include <stdlib.h>
986e461dc072 Initial revision
glantau
parents:
diff changeset
20 #include <stdio.h>
986e461dc072 Initial revision
glantau
parents:
diff changeset
21 #include <string.h>
986e461dc072 Initial revision
glantau
parents:
diff changeset
22 #include <errno.h>
986e461dc072 Initial revision
glantau
parents:
diff changeset
23 #include "common.h"
986e461dc072 Initial revision
glantau
parents:
diff changeset
24 #include "dsputil.h"
986e461dc072 Initial revision
glantau
parents:
diff changeset
25 #include "avcodec.h"
986e461dc072 Initial revision
glantau
parents:
diff changeset
26
986e461dc072 Initial revision
glantau
parents:
diff changeset
27 /* memory alloc */
986e461dc072 Initial revision
glantau
parents:
diff changeset
28 void *av_mallocz(int size)
986e461dc072 Initial revision
glantau
parents:
diff changeset
29 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
30 void *ptr;
986e461dc072 Initial revision
glantau
parents:
diff changeset
31 ptr = malloc(size);
986e461dc072 Initial revision
glantau
parents:
diff changeset
32 if (!ptr)
986e461dc072 Initial revision
glantau
parents:
diff changeset
33 return NULL;
986e461dc072 Initial revision
glantau
parents:
diff changeset
34 memset(ptr, 0, size);
986e461dc072 Initial revision
glantau
parents:
diff changeset
35 return ptr;
986e461dc072 Initial revision
glantau
parents:
diff changeset
36 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
37
986e461dc072 Initial revision
glantau
parents:
diff changeset
38 /* encoder management */
986e461dc072 Initial revision
glantau
parents:
diff changeset
39 AVCodec *first_avcodec;
986e461dc072 Initial revision
glantau
parents:
diff changeset
40
986e461dc072 Initial revision
glantau
parents:
diff changeset
41 void register_avcodec(AVCodec *format)
986e461dc072 Initial revision
glantau
parents:
diff changeset
42 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
43 AVCodec **p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
44 p = &first_avcodec;
986e461dc072 Initial revision
glantau
parents:
diff changeset
45 while (*p != NULL) p = &(*p)->next;
986e461dc072 Initial revision
glantau
parents:
diff changeset
46 *p = format;
986e461dc072 Initial revision
glantau
parents:
diff changeset
47 format->next = NULL;
986e461dc072 Initial revision
glantau
parents:
diff changeset
48 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
49
986e461dc072 Initial revision
glantau
parents:
diff changeset
50 int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
986e461dc072 Initial revision
glantau
parents:
diff changeset
51 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
52 int ret;
986e461dc072 Initial revision
glantau
parents:
diff changeset
53
986e461dc072 Initial revision
glantau
parents:
diff changeset
54 avctx->codec = codec;
986e461dc072 Initial revision
glantau
parents:
diff changeset
55 avctx->frame_number = 0;
986e461dc072 Initial revision
glantau
parents:
diff changeset
56 avctx->priv_data = av_mallocz(codec->priv_data_size);
986e461dc072 Initial revision
glantau
parents:
diff changeset
57 if (!avctx->priv_data)
986e461dc072 Initial revision
glantau
parents:
diff changeset
58 return -ENOMEM;
986e461dc072 Initial revision
glantau
parents:
diff changeset
59 ret = avctx->codec->init(avctx);
986e461dc072 Initial revision
glantau
parents:
diff changeset
60 if (ret < 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
61 free(avctx->priv_data);
986e461dc072 Initial revision
glantau
parents:
diff changeset
62 avctx->priv_data = NULL;
986e461dc072 Initial revision
glantau
parents:
diff changeset
63 return ret;
986e461dc072 Initial revision
glantau
parents:
diff changeset
64 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
65 return 0;
986e461dc072 Initial revision
glantau
parents:
diff changeset
66 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
67
986e461dc072 Initial revision
glantau
parents:
diff changeset
68 int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
986e461dc072 Initial revision
glantau
parents:
diff changeset
69 const short *samples)
986e461dc072 Initial revision
glantau
parents:
diff changeset
70 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
71 int ret;
986e461dc072 Initial revision
glantau
parents:
diff changeset
72
986e461dc072 Initial revision
glantau
parents:
diff changeset
73 ret = avctx->codec->encode(avctx, buf, buf_size, (void *)samples);
986e461dc072 Initial revision
glantau
parents:
diff changeset
74 avctx->frame_number++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
75 return ret;
986e461dc072 Initial revision
glantau
parents:
diff changeset
76 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
77
986e461dc072 Initial revision
glantau
parents:
diff changeset
78 int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
986e461dc072 Initial revision
glantau
parents:
diff changeset
79 const AVPicture *pict)
986e461dc072 Initial revision
glantau
parents:
diff changeset
80 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
81 int ret;
986e461dc072 Initial revision
glantau
parents:
diff changeset
82
986e461dc072 Initial revision
glantau
parents:
diff changeset
83 ret = avctx->codec->encode(avctx, buf, buf_size, (void *)pict);
986e461dc072 Initial revision
glantau
parents:
diff changeset
84 avctx->frame_number++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
85 return ret;
986e461dc072 Initial revision
glantau
parents:
diff changeset
86 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
87
986e461dc072 Initial revision
glantau
parents:
diff changeset
88 /* decode a frame. return -1 if error, otherwise return the number of
986e461dc072 Initial revision
glantau
parents:
diff changeset
89 bytes used. If no frame could be decompressed, *got_picture_ptr is
986e461dc072 Initial revision
glantau
parents:
diff changeset
90 zero. Otherwise, it is non zero */
986e461dc072 Initial revision
glantau
parents:
diff changeset
91 int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
986e461dc072 Initial revision
glantau
parents:
diff changeset
92 int *got_picture_ptr,
986e461dc072 Initial revision
glantau
parents:
diff changeset
93 UINT8 *buf, int buf_size)
986e461dc072 Initial revision
glantau
parents:
diff changeset
94 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
95 int ret;
986e461dc072 Initial revision
glantau
parents:
diff changeset
96
986e461dc072 Initial revision
glantau
parents:
diff changeset
97 ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
986e461dc072 Initial revision
glantau
parents:
diff changeset
98 buf, buf_size);
986e461dc072 Initial revision
glantau
parents:
diff changeset
99 avctx->frame_number++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
100 return ret;
986e461dc072 Initial revision
glantau
parents:
diff changeset
101 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
102
986e461dc072 Initial revision
glantau
parents:
diff changeset
103 /* decode an audio frame. return -1 if error, otherwise return the
986e461dc072 Initial revision
glantau
parents:
diff changeset
104 *number of bytes used. If no frame could be decompressed,
986e461dc072 Initial revision
glantau
parents:
diff changeset
105 *frame_size_ptr is zero. Otherwise, it is the decompressed frame
986e461dc072 Initial revision
glantau
parents:
diff changeset
106 *size in BYTES. */
986e461dc072 Initial revision
glantau
parents:
diff changeset
107 int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
986e461dc072 Initial revision
glantau
parents:
diff changeset
108 int *frame_size_ptr,
986e461dc072 Initial revision
glantau
parents:
diff changeset
109 UINT8 *buf, int buf_size)
986e461dc072 Initial revision
glantau
parents:
diff changeset
110 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
111 int ret;
986e461dc072 Initial revision
glantau
parents:
diff changeset
112
986e461dc072 Initial revision
glantau
parents:
diff changeset
113 ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
986e461dc072 Initial revision
glantau
parents:
diff changeset
114 buf, buf_size);
986e461dc072 Initial revision
glantau
parents:
diff changeset
115 avctx->frame_number++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
116 return ret;
986e461dc072 Initial revision
glantau
parents:
diff changeset
117 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
118
986e461dc072 Initial revision
glantau
parents:
diff changeset
119 int avcodec_close(AVCodecContext *avctx)
986e461dc072 Initial revision
glantau
parents:
diff changeset
120 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
121 if (avctx->codec->close)
986e461dc072 Initial revision
glantau
parents:
diff changeset
122 avctx->codec->close(avctx);
986e461dc072 Initial revision
glantau
parents:
diff changeset
123 free(avctx->priv_data);
986e461dc072 Initial revision
glantau
parents:
diff changeset
124 avctx->priv_data = NULL;
986e461dc072 Initial revision
glantau
parents:
diff changeset
125 avctx->codec = NULL;
986e461dc072 Initial revision
glantau
parents:
diff changeset
126 return 0;
986e461dc072 Initial revision
glantau
parents:
diff changeset
127 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
128
986e461dc072 Initial revision
glantau
parents:
diff changeset
129 AVCodec *avcodec_find_encoder(enum CodecID id)
986e461dc072 Initial revision
glantau
parents:
diff changeset
130 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
131 AVCodec *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
132 p = first_avcodec;
986e461dc072 Initial revision
glantau
parents:
diff changeset
133 while (p) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
134 if (p->encode != NULL && p->id == id)
986e461dc072 Initial revision
glantau
parents:
diff changeset
135 return p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
136 p = p->next;
986e461dc072 Initial revision
glantau
parents:
diff changeset
137 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
138 return NULL;
986e461dc072 Initial revision
glantau
parents:
diff changeset
139 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
140
986e461dc072 Initial revision
glantau
parents:
diff changeset
141 AVCodec *avcodec_find_decoder(enum CodecID id)
986e461dc072 Initial revision
glantau
parents:
diff changeset
142 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
143 AVCodec *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
144 p = first_avcodec;
986e461dc072 Initial revision
glantau
parents:
diff changeset
145 while (p) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
146 if (p->decode != NULL && p->id == id)
986e461dc072 Initial revision
glantau
parents:
diff changeset
147 return p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
148 p = p->next;
986e461dc072 Initial revision
glantau
parents:
diff changeset
149 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
150 return NULL;
986e461dc072 Initial revision
glantau
parents:
diff changeset
151 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
152
986e461dc072 Initial revision
glantau
parents:
diff changeset
153 AVCodec *avcodec_find_decoder_by_name(const char *name)
986e461dc072 Initial revision
glantau
parents:
diff changeset
154 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
155 AVCodec *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
156 p = first_avcodec;
986e461dc072 Initial revision
glantau
parents:
diff changeset
157 while (p) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
158 if (p->decode != NULL && strcmp(name,p->name) == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
159 return p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
160 p = p->next;
986e461dc072 Initial revision
glantau
parents:
diff changeset
161 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
162 return NULL;
986e461dc072 Initial revision
glantau
parents:
diff changeset
163 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
164
986e461dc072 Initial revision
glantau
parents:
diff changeset
165 AVCodec *avcodec_find(enum CodecID id)
986e461dc072 Initial revision
glantau
parents:
diff changeset
166 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
167 AVCodec *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
168 p = first_avcodec;
986e461dc072 Initial revision
glantau
parents:
diff changeset
169 while (p) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
170 if (p->id == id)
986e461dc072 Initial revision
glantau
parents:
diff changeset
171 return p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
172 p = p->next;
986e461dc072 Initial revision
glantau
parents:
diff changeset
173 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
174 return NULL;
986e461dc072 Initial revision
glantau
parents:
diff changeset
175 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
176
986e461dc072 Initial revision
glantau
parents:
diff changeset
177 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
986e461dc072 Initial revision
glantau
parents:
diff changeset
178 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
179 const char *codec_name;
986e461dc072 Initial revision
glantau
parents:
diff changeset
180 AVCodec *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
181 char buf1[32];
986e461dc072 Initial revision
glantau
parents:
diff changeset
182
986e461dc072 Initial revision
glantau
parents:
diff changeset
183 if (encode)
986e461dc072 Initial revision
glantau
parents:
diff changeset
184 p = avcodec_find_encoder(enc->codec_id);
986e461dc072 Initial revision
glantau
parents:
diff changeset
185 else
986e461dc072 Initial revision
glantau
parents:
diff changeset
186 p = avcodec_find_decoder(enc->codec_id);
986e461dc072 Initial revision
glantau
parents:
diff changeset
187
986e461dc072 Initial revision
glantau
parents:
diff changeset
188 if (p) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
189 codec_name = p->name;
986e461dc072 Initial revision
glantau
parents:
diff changeset
190 } else if (enc->codec_name[0] != '\0') {
986e461dc072 Initial revision
glantau
parents:
diff changeset
191 codec_name = enc->codec_name;
986e461dc072 Initial revision
glantau
parents:
diff changeset
192 } else {
986e461dc072 Initial revision
glantau
parents:
diff changeset
193 /* output avi tags */
986e461dc072 Initial revision
glantau
parents:
diff changeset
194 if (enc->codec_type == CODEC_TYPE_VIDEO) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
195 snprintf(buf1, sizeof(buf1), "%c%c%c%c",
986e461dc072 Initial revision
glantau
parents:
diff changeset
196 enc->codec_tag & 0xff,
986e461dc072 Initial revision
glantau
parents:
diff changeset
197 (enc->codec_tag >> 8) & 0xff,
986e461dc072 Initial revision
glantau
parents:
diff changeset
198 (enc->codec_tag >> 16) & 0xff,
986e461dc072 Initial revision
glantau
parents:
diff changeset
199 (enc->codec_tag >> 24) & 0xff);
986e461dc072 Initial revision
glantau
parents:
diff changeset
200 } else {
986e461dc072 Initial revision
glantau
parents:
diff changeset
201 snprintf(buf1, sizeof(buf1), "0x%04x", enc->codec_tag);
986e461dc072 Initial revision
glantau
parents:
diff changeset
202 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
203 codec_name = buf1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
204 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
205
986e461dc072 Initial revision
glantau
parents:
diff changeset
206 switch(enc->codec_type) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
207 case CODEC_TYPE_VIDEO:
986e461dc072 Initial revision
glantau
parents:
diff changeset
208 snprintf(buf, buf_size,
986e461dc072 Initial revision
glantau
parents:
diff changeset
209 "Video: %s%s",
986e461dc072 Initial revision
glantau
parents:
diff changeset
210 codec_name, enc->flags & CODEC_FLAG_HQ ? " (hq)" : "");
986e461dc072 Initial revision
glantau
parents:
diff changeset
211 if (enc->width) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
212 snprintf(buf + strlen(buf), buf_size - strlen(buf),
986e461dc072 Initial revision
glantau
parents:
diff changeset
213 ", %dx%d, %0.2f fps",
986e461dc072 Initial revision
glantau
parents:
diff changeset
214 enc->width, enc->height,
986e461dc072 Initial revision
glantau
parents:
diff changeset
215 (float)enc->frame_rate / FRAME_RATE_BASE);
986e461dc072 Initial revision
glantau
parents:
diff changeset
216 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
217 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
218 case CODEC_TYPE_AUDIO:
986e461dc072 Initial revision
glantau
parents:
diff changeset
219 snprintf(buf, buf_size,
986e461dc072 Initial revision
glantau
parents:
diff changeset
220 "Audio: %s",
986e461dc072 Initial revision
glantau
parents:
diff changeset
221 codec_name);
986e461dc072 Initial revision
glantau
parents:
diff changeset
222 if (enc->sample_rate) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
223 snprintf(buf + strlen(buf), buf_size - strlen(buf),
986e461dc072 Initial revision
glantau
parents:
diff changeset
224 ", %d Hz, %s",
986e461dc072 Initial revision
glantau
parents:
diff changeset
225 enc->sample_rate,
986e461dc072 Initial revision
glantau
parents:
diff changeset
226 enc->channels == 2 ? "stereo" : "mono");
986e461dc072 Initial revision
glantau
parents:
diff changeset
227 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
228 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
229 default:
986e461dc072 Initial revision
glantau
parents:
diff changeset
230 abort();
986e461dc072 Initial revision
glantau
parents:
diff changeset
231 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
232 if (enc->bit_rate != 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
233 snprintf(buf + strlen(buf), buf_size - strlen(buf),
986e461dc072 Initial revision
glantau
parents:
diff changeset
234 ", %d kb/s", enc->bit_rate / 1000);
986e461dc072 Initial revision
glantau
parents:
diff changeset
235 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
236 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
237
986e461dc072 Initial revision
glantau
parents:
diff changeset
238 /* must be called before any other functions */
986e461dc072 Initial revision
glantau
parents:
diff changeset
239 void avcodec_init(void)
986e461dc072 Initial revision
glantau
parents:
diff changeset
240 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
241 dsputil_init();
986e461dc072 Initial revision
glantau
parents:
diff changeset
242 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
243
986e461dc072 Initial revision
glantau
parents:
diff changeset
244 /* simple call to use all the codecs */
986e461dc072 Initial revision
glantau
parents:
diff changeset
245 void avcodec_register_all(void)
986e461dc072 Initial revision
glantau
parents:
diff changeset
246 {
3
1bdbd869c1f0 added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents: 0
diff changeset
247 /* encoders */
1bdbd869c1f0 added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents: 0
diff changeset
248 #ifdef CONFIG_ENCODERS
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
249 register_avcodec(&ac3_encoder);
986e461dc072 Initial revision
glantau
parents:
diff changeset
250 register_avcodec(&mp2_encoder);
986e461dc072 Initial revision
glantau
parents:
diff changeset
251 register_avcodec(&mpeg1video_encoder);
986e461dc072 Initial revision
glantau
parents:
diff changeset
252 register_avcodec(&h263_encoder);
986e461dc072 Initial revision
glantau
parents:
diff changeset
253 register_avcodec(&h263p_encoder);
986e461dc072 Initial revision
glantau
parents:
diff changeset
254 register_avcodec(&rv10_encoder);
986e461dc072 Initial revision
glantau
parents:
diff changeset
255 register_avcodec(&mjpeg_encoder);
986e461dc072 Initial revision
glantau
parents:
diff changeset
256 register_avcodec(&opendivx_encoder);
986e461dc072 Initial revision
glantau
parents:
diff changeset
257 register_avcodec(&msmpeg4_encoder);
3
1bdbd869c1f0 added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents: 0
diff changeset
258 #endif /* CONFIG_ENCODERS */
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
259 register_avcodec(&pcm_codec);
986e461dc072 Initial revision
glantau
parents:
diff changeset
260 register_avcodec(&rawvideo_codec);
3
1bdbd869c1f0 added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents: 0
diff changeset
261
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
262 /* decoders */
3
1bdbd869c1f0 added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents: 0
diff changeset
263 #ifdef CONFIG_DECODERS
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
264 register_avcodec(&h263_decoder);
986e461dc072 Initial revision
glantau
parents:
diff changeset
265 register_avcodec(&opendivx_decoder);
986e461dc072 Initial revision
glantau
parents:
diff changeset
266 register_avcodec(&msmpeg4_decoder);
986e461dc072 Initial revision
glantau
parents:
diff changeset
267 register_avcodec(&mpeg_decoder);
986e461dc072 Initial revision
glantau
parents:
diff changeset
268 register_avcodec(&h263i_decoder);
986e461dc072 Initial revision
glantau
parents:
diff changeset
269 register_avcodec(&rv10_decoder);
3
1bdbd869c1f0 added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents: 0
diff changeset
270 #ifdef CONFIG_MPGLIB
1bdbd869c1f0 added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents: 0
diff changeset
271 register_avcodec(&mp3_decoder);
1bdbd869c1f0 added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents: 0
diff changeset
272 #endif
1bdbd869c1f0 added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents: 0
diff changeset
273 #ifdef CONFIG_AC3
1bdbd869c1f0 added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents: 0
diff changeset
274 register_avcodec(&ac3_decoder);
1bdbd869c1f0 added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents: 0
diff changeset
275 #endif
1bdbd869c1f0 added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents: 0
diff changeset
276 #endif /* CONFIG_DECODERS */
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
277 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
278
986e461dc072 Initial revision
glantau
parents:
diff changeset
279 static int encode_init(AVCodecContext *s)
986e461dc072 Initial revision
glantau
parents:
diff changeset
280 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
281 return 0;
986e461dc072 Initial revision
glantau
parents:
diff changeset
282 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
283
986e461dc072 Initial revision
glantau
parents:
diff changeset
284 static int decode_frame(AVCodecContext *avctx,
986e461dc072 Initial revision
glantau
parents:
diff changeset
285 void *data, int *data_size,
986e461dc072 Initial revision
glantau
parents:
diff changeset
286 UINT8 *buf, int buf_size)
986e461dc072 Initial revision
glantau
parents:
diff changeset
287 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
288 return -1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
289 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
290
986e461dc072 Initial revision
glantau
parents:
diff changeset
291 static int encode_frame(AVCodecContext *avctx,
986e461dc072 Initial revision
glantau
parents:
diff changeset
292 unsigned char *frame, int buf_size, void *data)
986e461dc072 Initial revision
glantau
parents:
diff changeset
293 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
294 return -1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
295 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
296
986e461dc072 Initial revision
glantau
parents:
diff changeset
297 /* dummy pcm codec */
986e461dc072 Initial revision
glantau
parents:
diff changeset
298 AVCodec pcm_codec = {
986e461dc072 Initial revision
glantau
parents:
diff changeset
299 "pcm",
986e461dc072 Initial revision
glantau
parents:
diff changeset
300 CODEC_TYPE_AUDIO,
986e461dc072 Initial revision
glantau
parents:
diff changeset
301 CODEC_ID_PCM,
986e461dc072 Initial revision
glantau
parents:
diff changeset
302 0,
986e461dc072 Initial revision
glantau
parents:
diff changeset
303 encode_init,
986e461dc072 Initial revision
glantau
parents:
diff changeset
304 encode_frame,
986e461dc072 Initial revision
glantau
parents:
diff changeset
305 NULL,
986e461dc072 Initial revision
glantau
parents:
diff changeset
306 decode_frame,
986e461dc072 Initial revision
glantau
parents:
diff changeset
307 };
986e461dc072 Initial revision
glantau
parents:
diff changeset
308
986e461dc072 Initial revision
glantau
parents:
diff changeset
309 AVCodec rawvideo_codec = {
986e461dc072 Initial revision
glantau
parents:
diff changeset
310 "rawvideo",
986e461dc072 Initial revision
glantau
parents:
diff changeset
311 CODEC_TYPE_VIDEO,
986e461dc072 Initial revision
glantau
parents:
diff changeset
312 CODEC_ID_RAWVIDEO,
986e461dc072 Initial revision
glantau
parents:
diff changeset
313 0,
986e461dc072 Initial revision
glantau
parents:
diff changeset
314 encode_init,
986e461dc072 Initial revision
glantau
parents:
diff changeset
315 encode_frame,
986e461dc072 Initial revision
glantau
parents:
diff changeset
316 NULL,
986e461dc072 Initial revision
glantau
parents:
diff changeset
317 decode_frame,
986e461dc072 Initial revision
glantau
parents:
diff changeset
318 };