annotate apiexample.c @ 1194:432d9a42a244 libavcodec

Compile a52 util functions too
author arpi_esp
date Wed, 16 Apr 2003 20:04:20 +0000
parents 77ccf7fe3bd0
children b47a402bbe7f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
1 /**
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
2 * @file apiexample.c
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
3 * avcodec API use example.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
4 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
5 * Note that this library only handles codecs (mpeg, mpeg4, etc...),
986e461dc072 Initial revision
glantau
parents:
diff changeset
6 * not file formats (avi, vob, etc...). See library 'libav' for the
986e461dc072 Initial revision
glantau
parents:
diff changeset
7 * format handling
986e461dc072 Initial revision
glantau
parents:
diff changeset
8 */
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
9
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
10 #include <stdlib.h>
986e461dc072 Initial revision
glantau
parents:
diff changeset
11 #include <stdio.h>
986e461dc072 Initial revision
glantau
parents:
diff changeset
12 #include <string.h>
986e461dc072 Initial revision
glantau
parents:
diff changeset
13 #include <math.h>
986e461dc072 Initial revision
glantau
parents:
diff changeset
14
1059
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
15 #ifdef HAVE_AV_CONFIG_H
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
16 #undef HAVE_AV_CONFIG_H
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
17 #endif
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
18
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
19 #include "avcodec.h"
986e461dc072 Initial revision
glantau
parents:
diff changeset
20
986e461dc072 Initial revision
glantau
parents:
diff changeset
21 #define INBUF_SIZE 4096
986e461dc072 Initial revision
glantau
parents:
diff changeset
22
986e461dc072 Initial revision
glantau
parents:
diff changeset
23 /*
986e461dc072 Initial revision
glantau
parents:
diff changeset
24 * Audio encoding example
986e461dc072 Initial revision
glantau
parents:
diff changeset
25 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
26 void audio_encode_example(const char *filename)
986e461dc072 Initial revision
glantau
parents:
diff changeset
27 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
28 AVCodec *codec;
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
29 AVCodecContext *c= NULL;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
30 int frame_size, i, j, out_size, outbuf_size;
986e461dc072 Initial revision
glantau
parents:
diff changeset
31 FILE *f;
986e461dc072 Initial revision
glantau
parents:
diff changeset
32 short *samples;
986e461dc072 Initial revision
glantau
parents:
diff changeset
33 float t, tincr;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1059
diff changeset
34 uint8_t *outbuf;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
35
986e461dc072 Initial revision
glantau
parents:
diff changeset
36 printf("Audio encoding\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
37
986e461dc072 Initial revision
glantau
parents:
diff changeset
38 /* find the MP2 encoder */
986e461dc072 Initial revision
glantau
parents:
diff changeset
39 codec = avcodec_find_encoder(CODEC_ID_MP2);
986e461dc072 Initial revision
glantau
parents:
diff changeset
40 if (!codec) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
41 fprintf(stderr, "codec not found\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
42 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
43 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
44
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
45 c= avcodec_alloc_context();
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
46
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
47 /* put sample parameters */
986e461dc072 Initial revision
glantau
parents:
diff changeset
48 c->bit_rate = 64000;
986e461dc072 Initial revision
glantau
parents:
diff changeset
49 c->sample_rate = 44100;
986e461dc072 Initial revision
glantau
parents:
diff changeset
50 c->channels = 2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
51
986e461dc072 Initial revision
glantau
parents:
diff changeset
52 /* open it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
53 if (avcodec_open(c, codec) < 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
54 fprintf(stderr, "could not open codec\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
55 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
56 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
57
986e461dc072 Initial revision
glantau
parents:
diff changeset
58 /* the codec gives us the frame size, in samples */
986e461dc072 Initial revision
glantau
parents:
diff changeset
59 frame_size = c->frame_size;
986e461dc072 Initial revision
glantau
parents:
diff changeset
60 samples = malloc(frame_size * 2 * c->channels);
986e461dc072 Initial revision
glantau
parents:
diff changeset
61 outbuf_size = 10000;
986e461dc072 Initial revision
glantau
parents:
diff changeset
62 outbuf = malloc(outbuf_size);
986e461dc072 Initial revision
glantau
parents:
diff changeset
63
986e461dc072 Initial revision
glantau
parents:
diff changeset
64 f = fopen(filename, "w");
986e461dc072 Initial revision
glantau
parents:
diff changeset
65 if (!f) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
66 fprintf(stderr, "could not open %s\n", filename);
986e461dc072 Initial revision
glantau
parents:
diff changeset
67 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
68 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
69
986e461dc072 Initial revision
glantau
parents:
diff changeset
70 /* encode a single tone sound */
986e461dc072 Initial revision
glantau
parents:
diff changeset
71 t = 0;
986e461dc072 Initial revision
glantau
parents:
diff changeset
72 tincr = 2 * M_PI * 440.0 / c->sample_rate;
986e461dc072 Initial revision
glantau
parents:
diff changeset
73 for(i=0;i<200;i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
74 for(j=0;j<frame_size;j++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
75 samples[2*j] = (int)(sin(t) * 10000);
986e461dc072 Initial revision
glantau
parents:
diff changeset
76 samples[2*j+1] = samples[2*j];
986e461dc072 Initial revision
glantau
parents:
diff changeset
77 t += tincr;
986e461dc072 Initial revision
glantau
parents:
diff changeset
78 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
79 /* encode the samples */
986e461dc072 Initial revision
glantau
parents:
diff changeset
80 out_size = avcodec_encode_audio(c, outbuf, outbuf_size, samples);
986e461dc072 Initial revision
glantau
parents:
diff changeset
81 fwrite(outbuf, 1, out_size, f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
82 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
83 fclose(f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
84 free(outbuf);
986e461dc072 Initial revision
glantau
parents:
diff changeset
85 free(samples);
986e461dc072 Initial revision
glantau
parents:
diff changeset
86
986e461dc072 Initial revision
glantau
parents:
diff changeset
87 avcodec_close(c);
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
88 free(c);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
89 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
90
986e461dc072 Initial revision
glantau
parents:
diff changeset
91 /*
986e461dc072 Initial revision
glantau
parents:
diff changeset
92 * Audio decoding.
986e461dc072 Initial revision
glantau
parents:
diff changeset
93 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
94 void audio_decode_example(const char *outfilename, const char *filename)
986e461dc072 Initial revision
glantau
parents:
diff changeset
95 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
96 AVCodec *codec;
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
97 AVCodecContext *c= NULL;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
98 int out_size, size, len;
986e461dc072 Initial revision
glantau
parents:
diff changeset
99 FILE *f, *outfile;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1059
diff changeset
100 uint8_t *outbuf;
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1059
diff changeset
101 uint8_t inbuf[INBUF_SIZE], *inbuf_ptr;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
102
986e461dc072 Initial revision
glantau
parents:
diff changeset
103 printf("Audio decoding\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
104
986e461dc072 Initial revision
glantau
parents:
diff changeset
105 /* find the mpeg audio decoder */
986e461dc072 Initial revision
glantau
parents:
diff changeset
106 codec = avcodec_find_decoder(CODEC_ID_MP2);
986e461dc072 Initial revision
glantau
parents:
diff changeset
107 if (!codec) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
108 fprintf(stderr, "codec not found\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
109 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
110 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
111
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
112 c= avcodec_alloc_context();
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
113
986e461dc072 Initial revision
glantau
parents:
diff changeset
114 /* open it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
115 if (avcodec_open(c, codec) < 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
116 fprintf(stderr, "could not open codec\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
117 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
118 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
119
986e461dc072 Initial revision
glantau
parents:
diff changeset
120 outbuf = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
986e461dc072 Initial revision
glantau
parents:
diff changeset
121
986e461dc072 Initial revision
glantau
parents:
diff changeset
122 f = fopen(filename, "r");
986e461dc072 Initial revision
glantau
parents:
diff changeset
123 if (!f) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
124 fprintf(stderr, "could not open %s\n", filename);
986e461dc072 Initial revision
glantau
parents:
diff changeset
125 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
126 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
127 outfile = fopen(outfilename, "w");
986e461dc072 Initial revision
glantau
parents:
diff changeset
128 if (!outfile) {
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
129 free(c);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
130 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
131 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
132
986e461dc072 Initial revision
glantau
parents:
diff changeset
133 /* decode until eof */
986e461dc072 Initial revision
glantau
parents:
diff changeset
134 inbuf_ptr = inbuf;
986e461dc072 Initial revision
glantau
parents:
diff changeset
135 for(;;) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
136 size = fread(inbuf, 1, INBUF_SIZE, f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
137 if (size == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
138 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
139
986e461dc072 Initial revision
glantau
parents:
diff changeset
140 inbuf_ptr = inbuf;
986e461dc072 Initial revision
glantau
parents:
diff changeset
141 while (size > 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
142 len = avcodec_decode_audio(c, (short *)outbuf, &out_size,
986e461dc072 Initial revision
glantau
parents:
diff changeset
143 inbuf_ptr, size);
986e461dc072 Initial revision
glantau
parents:
diff changeset
144 if (len < 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
145 fprintf(stderr, "Error while decoding\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
146 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
147 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
148 if (out_size > 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
149 /* if a frame has been decoded, output it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
150 fwrite(outbuf, 1, out_size, outfile);
986e461dc072 Initial revision
glantau
parents:
diff changeset
151 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
152 size -= len;
986e461dc072 Initial revision
glantau
parents:
diff changeset
153 inbuf_ptr += len;
986e461dc072 Initial revision
glantau
parents:
diff changeset
154 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
155 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
156
986e461dc072 Initial revision
glantau
parents:
diff changeset
157 fclose(outfile);
986e461dc072 Initial revision
glantau
parents:
diff changeset
158 fclose(f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
159 free(outbuf);
986e461dc072 Initial revision
glantau
parents:
diff changeset
160
986e461dc072 Initial revision
glantau
parents:
diff changeset
161 avcodec_close(c);
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
162 free(c);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
163 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
164
986e461dc072 Initial revision
glantau
parents:
diff changeset
165 /*
986e461dc072 Initial revision
glantau
parents:
diff changeset
166 * Video encoding example
986e461dc072 Initial revision
glantau
parents:
diff changeset
167 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
168 void video_encode_example(const char *filename)
986e461dc072 Initial revision
glantau
parents:
diff changeset
169 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
170 AVCodec *codec;
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
171 AVCodecContext *c= NULL;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
172 int i, out_size, size, x, y, outbuf_size;
986e461dc072 Initial revision
glantau
parents:
diff changeset
173 FILE *f;
925
7fccaa0d699d AVVideoFrame -> AVFrame
michaelni
parents: 919
diff changeset
174 AVFrame *picture;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1059
diff changeset
175 uint8_t *outbuf, *picture_buf;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
176
986e461dc072 Initial revision
glantau
parents:
diff changeset
177 printf("Video encoding\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
178
986e461dc072 Initial revision
glantau
parents:
diff changeset
179 /* find the mpeg1 video encoder */
986e461dc072 Initial revision
glantau
parents:
diff changeset
180 codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
986e461dc072 Initial revision
glantau
parents:
diff changeset
181 if (!codec) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
182 fprintf(stderr, "codec not found\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
183 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
184 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
185
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
186 c= avcodec_alloc_context();
925
7fccaa0d699d AVVideoFrame -> AVFrame
michaelni
parents: 919
diff changeset
187 picture= avcodec_alloc_frame();
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
188
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
189 /* put sample parameters */
986e461dc072 Initial revision
glantau
parents:
diff changeset
190 c->bit_rate = 400000;
986e461dc072 Initial revision
glantau
parents:
diff changeset
191 /* resolution must be a multiple of two */
986e461dc072 Initial revision
glantau
parents:
diff changeset
192 c->width = 352;
986e461dc072 Initial revision
glantau
parents:
diff changeset
193 c->height = 288;
986e461dc072 Initial revision
glantau
parents:
diff changeset
194 /* frames per second */
1126
77ccf7fe3bd0 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 1114
diff changeset
195 c->frame_rate = 25;
77ccf7fe3bd0 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 1114
diff changeset
196 c->frame_rate_base= 1;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
197 c->gop_size = 10; /* emit one intra frame every ten frames */
986e461dc072 Initial revision
glantau
parents:
diff changeset
198
986e461dc072 Initial revision
glantau
parents:
diff changeset
199 /* open it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
200 if (avcodec_open(c, codec) < 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
201 fprintf(stderr, "could not open codec\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
202 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
203 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
204
986e461dc072 Initial revision
glantau
parents:
diff changeset
205 /* the codec gives us the frame size, in samples */
986e461dc072 Initial revision
glantau
parents:
diff changeset
206
986e461dc072 Initial revision
glantau
parents:
diff changeset
207 f = fopen(filename, "w");
986e461dc072 Initial revision
glantau
parents:
diff changeset
208 if (!f) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
209 fprintf(stderr, "could not open %s\n", filename);
986e461dc072 Initial revision
glantau
parents:
diff changeset
210 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
211 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
212
986e461dc072 Initial revision
glantau
parents:
diff changeset
213 /* alloc image and output buffer */
986e461dc072 Initial revision
glantau
parents:
diff changeset
214 outbuf_size = 100000;
986e461dc072 Initial revision
glantau
parents:
diff changeset
215 outbuf = malloc(outbuf_size);
986e461dc072 Initial revision
glantau
parents:
diff changeset
216 size = c->width * c->height;
986e461dc072 Initial revision
glantau
parents:
diff changeset
217 picture_buf = malloc((size * 3) / 2); /* size for YUV 420 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
218
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
219 picture->data[0] = picture_buf;
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
220 picture->data[1] = picture->data[0] + size;
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
221 picture->data[2] = picture->data[1] + size / 4;
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
222 picture->linesize[0] = c->width;
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
223 picture->linesize[1] = c->width / 2;
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
224 picture->linesize[2] = c->width / 2;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
225
986e461dc072 Initial revision
glantau
parents:
diff changeset
226 /* encode 1 second of video */
986e461dc072 Initial revision
glantau
parents:
diff changeset
227 for(i=0;i<25;i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
228 printf("encoding frame %3d\r", i);
986e461dc072 Initial revision
glantau
parents:
diff changeset
229 fflush(stdout);
986e461dc072 Initial revision
glantau
parents:
diff changeset
230 /* prepare a dummy image */
986e461dc072 Initial revision
glantau
parents:
diff changeset
231 /* Y */
986e461dc072 Initial revision
glantau
parents:
diff changeset
232 for(y=0;y<c->height;y++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
233 for(x=0;x<c->width;x++) {
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
234 picture->data[0][y * picture->linesize[0] + x] = x + y + i * 3;
0
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 /* Cb and Cr */
986e461dc072 Initial revision
glantau
parents:
diff changeset
239 for(y=0;y<c->height/2;y++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
240 for(x=0;x<c->width/2;x++) {
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
241 picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2;
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
242 picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
243 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
244 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
245
986e461dc072 Initial revision
glantau
parents:
diff changeset
246 /* encode the image */
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
247 out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
248 fwrite(outbuf, 1, out_size, f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
249 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
250
986e461dc072 Initial revision
glantau
parents:
diff changeset
251 /* add sequence end code to have a real mpeg file */
986e461dc072 Initial revision
glantau
parents:
diff changeset
252 outbuf[0] = 0x00;
986e461dc072 Initial revision
glantau
parents:
diff changeset
253 outbuf[1] = 0x00;
986e461dc072 Initial revision
glantau
parents:
diff changeset
254 outbuf[2] = 0x01;
986e461dc072 Initial revision
glantau
parents:
diff changeset
255 outbuf[3] = 0xb7;
986e461dc072 Initial revision
glantau
parents:
diff changeset
256 fwrite(outbuf, 1, 4, f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
257 fclose(f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
258 free(picture_buf);
986e461dc072 Initial revision
glantau
parents:
diff changeset
259 free(outbuf);
986e461dc072 Initial revision
glantau
parents:
diff changeset
260
986e461dc072 Initial revision
glantau
parents:
diff changeset
261 avcodec_close(c);
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
262 free(c);
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
263 free(picture);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
264 printf("\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
265 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
266
986e461dc072 Initial revision
glantau
parents:
diff changeset
267 /*
986e461dc072 Initial revision
glantau
parents:
diff changeset
268 * Video decoding example
986e461dc072 Initial revision
glantau
parents:
diff changeset
269 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
270
986e461dc072 Initial revision
glantau
parents:
diff changeset
271 void pgm_save(unsigned char *buf,int wrap, int xsize,int ysize,char *filename)
986e461dc072 Initial revision
glantau
parents:
diff changeset
272 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
273 FILE *f;
986e461dc072 Initial revision
glantau
parents:
diff changeset
274 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
275
986e461dc072 Initial revision
glantau
parents:
diff changeset
276 f=fopen(filename,"w");
986e461dc072 Initial revision
glantau
parents:
diff changeset
277 fprintf(f,"P5\n%d %d\n%d\n",xsize,ysize,255);
986e461dc072 Initial revision
glantau
parents:
diff changeset
278 for(i=0;i<ysize;i++)
986e461dc072 Initial revision
glantau
parents:
diff changeset
279 fwrite(buf + i * wrap,1,xsize,f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
280 fclose(f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
281 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
282
986e461dc072 Initial revision
glantau
parents:
diff changeset
283 void video_decode_example(const char *outfilename, const char *filename)
986e461dc072 Initial revision
glantau
parents:
diff changeset
284 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
285 AVCodec *codec;
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
286 AVCodecContext *c= NULL;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
287 int frame, size, got_picture, len;
986e461dc072 Initial revision
glantau
parents:
diff changeset
288 FILE *f;
925
7fccaa0d699d AVVideoFrame -> AVFrame
michaelni
parents: 919
diff changeset
289 AVFrame *picture;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1059
diff changeset
290 uint8_t inbuf[INBUF_SIZE], *inbuf_ptr;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
291 char buf[1024];
986e461dc072 Initial revision
glantau
parents:
diff changeset
292
986e461dc072 Initial revision
glantau
parents:
diff changeset
293 printf("Video decoding\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
294
986e461dc072 Initial revision
glantau
parents:
diff changeset
295 /* find the mpeg1 video decoder */
986e461dc072 Initial revision
glantau
parents:
diff changeset
296 codec = avcodec_find_decoder(CODEC_ID_MPEG1VIDEO);
986e461dc072 Initial revision
glantau
parents:
diff changeset
297 if (!codec) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
298 fprintf(stderr, "codec not found\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
299 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
300 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
301
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
302 c= avcodec_alloc_context();
925
7fccaa0d699d AVVideoFrame -> AVFrame
michaelni
parents: 919
diff changeset
303 picture= avcodec_alloc_frame();
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
304
895
1a5926aeed5f apiexample doesnt send complete frames to the codec
michaelni
parents: 685
diff changeset
305 if(codec->capabilities&CODEC_CAP_TRUNCATED)
1a5926aeed5f apiexample doesnt send complete frames to the codec
michaelni
parents: 685
diff changeset
306 c->flags|= CODEC_FLAG_TRUNCATED; /* we dont send complete frames */
1a5926aeed5f apiexample doesnt send complete frames to the codec
michaelni
parents: 685
diff changeset
307
71
79be2c581c01 changed opendivx to mpeg4
glantau
parents: 0
diff changeset
308 /* for some codecs, such as msmpeg4 and mpeg4, width and height
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
309 MUST be initialized there because these info are not available
986e461dc072 Initial revision
glantau
parents:
diff changeset
310 in the bitstream */
986e461dc072 Initial revision
glantau
parents:
diff changeset
311
986e461dc072 Initial revision
glantau
parents:
diff changeset
312 /* open it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
313 if (avcodec_open(c, codec) < 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
314 fprintf(stderr, "could not open codec\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
315 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
316 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
317
986e461dc072 Initial revision
glantau
parents:
diff changeset
318 /* the codec gives us the frame size, in samples */
986e461dc072 Initial revision
glantau
parents:
diff changeset
319
986e461dc072 Initial revision
glantau
parents:
diff changeset
320 f = fopen(filename, "r");
986e461dc072 Initial revision
glantau
parents:
diff changeset
321 if (!f) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
322 fprintf(stderr, "could not open %s\n", filename);
986e461dc072 Initial revision
glantau
parents:
diff changeset
323 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
324 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
325
986e461dc072 Initial revision
glantau
parents:
diff changeset
326 frame = 0;
986e461dc072 Initial revision
glantau
parents:
diff changeset
327 for(;;) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
328 size = fread(inbuf, 1, INBUF_SIZE, f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
329 if (size == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
330 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
331
986e461dc072 Initial revision
glantau
parents:
diff changeset
332 /* NOTE1: some codecs are stream based (mpegvideo, mpegaudio)
986e461dc072 Initial revision
glantau
parents:
diff changeset
333 and this is the only method to use them because you cannot
986e461dc072 Initial revision
glantau
parents:
diff changeset
334 know the compressed data size before analysing it.
986e461dc072 Initial revision
glantau
parents:
diff changeset
335
71
79be2c581c01 changed opendivx to mpeg4
glantau
parents: 0
diff changeset
336 BUT some other codecs (msmpeg4, mpeg4) are inherently frame
79be2c581c01 changed opendivx to mpeg4
glantau
parents: 0
diff changeset
337 based, so you must call them with all the data for one
79be2c581c01 changed opendivx to mpeg4
glantau
parents: 0
diff changeset
338 frame exactly. You must also initialize 'width' and
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
339 'height' before initializing them. */
986e461dc072 Initial revision
glantau
parents:
diff changeset
340
986e461dc072 Initial revision
glantau
parents:
diff changeset
341 /* NOTE2: some codecs allow the raw parameters (frame size,
986e461dc072 Initial revision
glantau
parents:
diff changeset
342 sample rate) to be changed at any frame. We handle this, so
986e461dc072 Initial revision
glantau
parents:
diff changeset
343 you should also take care of it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
344
986e461dc072 Initial revision
glantau
parents:
diff changeset
345 /* here, we use a stream based decoder (mpeg1video), so we
986e461dc072 Initial revision
glantau
parents:
diff changeset
346 feed decoder and see if it could decode a frame */
986e461dc072 Initial revision
glantau
parents:
diff changeset
347 inbuf_ptr = inbuf;
986e461dc072 Initial revision
glantau
parents:
diff changeset
348 while (size > 0) {
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
349 len = avcodec_decode_video(c, picture, &got_picture,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
350 inbuf_ptr, size);
986e461dc072 Initial revision
glantau
parents:
diff changeset
351 if (len < 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
352 fprintf(stderr, "Error while decoding frame %d\n", frame);
986e461dc072 Initial revision
glantau
parents:
diff changeset
353 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
354 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
355 if (got_picture) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
356 printf("saving frame %3d\r", frame);
986e461dc072 Initial revision
glantau
parents:
diff changeset
357 fflush(stdout);
986e461dc072 Initial revision
glantau
parents:
diff changeset
358
986e461dc072 Initial revision
glantau
parents:
diff changeset
359 /* the picture is allocated by the decoder. no need to
986e461dc072 Initial revision
glantau
parents:
diff changeset
360 free it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
361 snprintf(buf, sizeof(buf), outfilename, frame);
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
362 pgm_save(picture->data[0], picture->linesize[0],
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
363 c->width, c->height, buf);
986e461dc072 Initial revision
glantau
parents:
diff changeset
364 frame++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
365 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
366 size -= len;
986e461dc072 Initial revision
glantau
parents:
diff changeset
367 inbuf_ptr += len;
986e461dc072 Initial revision
glantau
parents:
diff changeset
368 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
369 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
370
986e461dc072 Initial revision
glantau
parents:
diff changeset
371 /* some codecs, such as MPEG, transmit the I and P frame with a
986e461dc072 Initial revision
glantau
parents:
diff changeset
372 latency of one frame. You must do the following to have a
986e461dc072 Initial revision
glantau
parents:
diff changeset
373 chance to get the last frame of the video */
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
374 len = avcodec_decode_video(c, picture, &got_picture,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
375 NULL, 0);
986e461dc072 Initial revision
glantau
parents:
diff changeset
376 if (got_picture) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
377 printf("saving frame %3d\r", frame);
986e461dc072 Initial revision
glantau
parents:
diff changeset
378 fflush(stdout);
986e461dc072 Initial revision
glantau
parents:
diff changeset
379
986e461dc072 Initial revision
glantau
parents:
diff changeset
380 /* the picture is allocated by the decoder. no need to
986e461dc072 Initial revision
glantau
parents:
diff changeset
381 free it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
382 snprintf(buf, sizeof(buf), outfilename, frame);
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
383 pgm_save(picture->data[0], picture->linesize[0],
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
384 c->width, c->height, buf);
986e461dc072 Initial revision
glantau
parents:
diff changeset
385 frame++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
386 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
387
986e461dc072 Initial revision
glantau
parents:
diff changeset
388 fclose(f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
389
986e461dc072 Initial revision
glantau
parents:
diff changeset
390 avcodec_close(c);
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
391 free(c);
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
392 free(picture);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
393 printf("\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
394 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
395
1059
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
396 // simple example how the options could be used
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
397 int options_example(int argc, char* argv[])
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
398 {
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
399 AVCodec* codec = avcodec_find_encoder_by_name((argc > 1) ? argv[2] : "mpeg4");
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
400 const AVOption* c;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
401 AVCodecContext* avctx;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
402 char* def = av_malloc(5000);
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
403 const char* col = "";
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
404 int i = 0;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
405
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
406 if (!codec)
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
407 return -1;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
408 c = codec->options;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
409 avctx = avcodec_alloc_context();
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
410 *def = 0;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
411
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
412 if (c) {
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
413 const AVOption *stack[FF_OPT_MAX_DEPTH];
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
414 int depth = 0;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
415 for (;;) {
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
416 if (!c->name) {
1114
e4762efc3617 * more generic avoption_parse
kabi
parents: 1106
diff changeset
417 if (c->help) {
1059
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
418 stack[depth++] = c;
1114
e4762efc3617 * more generic avoption_parse
kabi
parents: 1106
diff changeset
419 c = (const AVOption*)c->help;
1059
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
420 } else {
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
421 if (depth == 0)
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
422 break; // finished
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
423 c = stack[--depth];
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
424 c++;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
425 }
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
426 } else {
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
427 int t = c->type & FF_OPT_TYPE_MASK;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
428 printf("Config %s %s\n",
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
429 t == FF_OPT_TYPE_BOOL ? "bool " :
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
430 t == FF_OPT_TYPE_DOUBLE ? "double " :
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
431 t == FF_OPT_TYPE_INT ? "integer" :
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
432 t == FF_OPT_TYPE_STRING ? "string " :
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
433 "unknown??", c->name);
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
434 switch (t) {
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
435 case FF_OPT_TYPE_BOOL:
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
436 i += sprintf(def + i, "%s%s=%s",
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
437 col, c->name,
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
438 c->defval != 0. ? "on" : "off");
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
439 break;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
440 case FF_OPT_TYPE_DOUBLE:
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
441 i += sprintf(def + i, "%s%s=%f",
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
442 col, c->name, c->defval);
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
443 break;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
444 case FF_OPT_TYPE_INT:
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
445 i += sprintf(def + i, "%s%s=%d",
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
446 col, c->name, (int) c->defval);
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
447 break;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
448 case FF_OPT_TYPE_STRING:
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
449 if (c->defstr) {
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
450 char* d = av_strdup(c->defstr);
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
451 char* f = strchr(d, ',');
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
452 if (f)
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
453 *f = 0;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
454 i += sprintf(def + i, "%s%s=%s",
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
455 col, c->name, d);
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
456 av_free(d);
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
457 }
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
458 break;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
459 }
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
460 col = ":";
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
461 c++;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
462 }
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
463 }
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
464 }
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
465 printf("Default Options: %s\n", def);
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
466 av_free(def);
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
467 return 0;
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
468 }
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
469
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
470
986e461dc072 Initial revision
glantau
parents:
diff changeset
471 int main(int argc, char **argv)
986e461dc072 Initial revision
glantau
parents:
diff changeset
472 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
473 const char *filename;
986e461dc072 Initial revision
glantau
parents:
diff changeset
474
986e461dc072 Initial revision
glantau
parents:
diff changeset
475 /* must be called before using avcodec lib */
986e461dc072 Initial revision
glantau
parents:
diff changeset
476 avcodec_init();
986e461dc072 Initial revision
glantau
parents:
diff changeset
477
986e461dc072 Initial revision
glantau
parents:
diff changeset
478 /* register all the codecs (you can also register only the codec
986e461dc072 Initial revision
glantau
parents:
diff changeset
479 you wish to have smaller code */
986e461dc072 Initial revision
glantau
parents:
diff changeset
480 avcodec_register_all();
1059
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
481
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
482 #ifdef OPT_TEST
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
483 options_example(argc, argv);
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
484 #else
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
485 if (argc <= 1) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
486 audio_encode_example("/tmp/test.mp2");
986e461dc072 Initial revision
glantau
parents:
diff changeset
487 audio_decode_example("/tmp/test.sw", "/tmp/test.mp2");
986e461dc072 Initial revision
glantau
parents:
diff changeset
488
986e461dc072 Initial revision
glantau
parents:
diff changeset
489 video_encode_example("/tmp/test.mpg");
986e461dc072 Initial revision
glantau
parents:
diff changeset
490 filename = "/tmp/test.mpg";
986e461dc072 Initial revision
glantau
parents:
diff changeset
491 } else {
986e461dc072 Initial revision
glantau
parents:
diff changeset
492 filename = argv[1];
986e461dc072 Initial revision
glantau
parents:
diff changeset
493 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
494
986e461dc072 Initial revision
glantau
parents:
diff changeset
495 // audio_decode_example("/tmp/test.sw", filename);
986e461dc072 Initial revision
glantau
parents:
diff changeset
496 video_decode_example("/tmp/test%d.pgm", filename);
1059
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
497 #endif
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
498
986e461dc072 Initial revision
glantau
parents:
diff changeset
499 return 0;
986e461dc072 Initial revision
glantau
parents:
diff changeset
500 }