annotate apiexample.c @ 4340:268811f3f1ef libavcodec

Optimization of 'dct_unquantize_h263_intra' for ARM (armv5te) patch by Siarhei Siamashka % siarhei P siamashka A gmail P com % Original thread: Date: Jan 6, 2007 5:07 PM Subject: [Ffmpeg-devel] [PATCH] Optimization of 'dct_unquantize_h263_intra' for ARM (armv5te) (try2) and Date: Jan 2, 2007 6:13 PM Subject: [Ffmpeg-devel] [PATCH] Optimization of 'dct_unquantize_h263_intra' for ARM (armv5te)
author gpoirier
date Sun, 07 Jan 2007 23:24:14 +0000
parents c8c591fe26f8
children 219255141aa1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
1 /*
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
2 * copyright (c) 2001 Fabrice Bellard
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
3 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
4 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
5 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
6 * FFmpeg is free software; you can redistribute it and/or
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
8 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
9 * version 2.1 of the License, or (at your option) any later version.
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
10 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
11 * FFmpeg is distributed in the hope that it will be useful,
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
14 * Lesser General Public License for more details.
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
15 *
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
17 * License along with FFmpeg; if not, write to the Free Software
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
19 */
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
20
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
21 /**
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
22 * @file apiexample.c
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
23 * avcodec API use example.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
24 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
25 * Note that this library only handles codecs (mpeg, mpeg4, etc...),
1427
3a6d613c88d8 spelling fix
bellard
parents: 1394
diff changeset
26 * not file formats (avi, vob, etc...). See library 'libavformat' for the
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
27 * format handling
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
28 */
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
29
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
30 #include <stdlib.h>
986e461dc072 Initial revision
glantau
parents:
diff changeset
31 #include <stdio.h>
986e461dc072 Initial revision
glantau
parents:
diff changeset
32 #include <string.h>
986e461dc072 Initial revision
glantau
parents:
diff changeset
33 #include <math.h>
986e461dc072 Initial revision
glantau
parents:
diff changeset
34
1059
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
35 #ifdef HAVE_AV_CONFIG_H
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
36 #undef HAVE_AV_CONFIG_H
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
37 #endif
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
38
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
39 #include "avcodec.h"
986e461dc072 Initial revision
glantau
parents:
diff changeset
40
986e461dc072 Initial revision
glantau
parents:
diff changeset
41 #define INBUF_SIZE 4096
986e461dc072 Initial revision
glantau
parents:
diff changeset
42
986e461dc072 Initial revision
glantau
parents:
diff changeset
43 /*
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
44 * Audio encoding example
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
45 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
46 void audio_encode_example(const char *filename)
986e461dc072 Initial revision
glantau
parents:
diff changeset
47 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
48 AVCodec *codec;
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
49 AVCodecContext *c= NULL;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
50 int frame_size, i, j, out_size, outbuf_size;
986e461dc072 Initial revision
glantau
parents:
diff changeset
51 FILE *f;
986e461dc072 Initial revision
glantau
parents:
diff changeset
52 short *samples;
986e461dc072 Initial revision
glantau
parents:
diff changeset
53 float t, tincr;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1059
diff changeset
54 uint8_t *outbuf;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
55
986e461dc072 Initial revision
glantau
parents:
diff changeset
56 printf("Audio encoding\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
57
986e461dc072 Initial revision
glantau
parents:
diff changeset
58 /* find the MP2 encoder */
986e461dc072 Initial revision
glantau
parents:
diff changeset
59 codec = avcodec_find_encoder(CODEC_ID_MP2);
986e461dc072 Initial revision
glantau
parents:
diff changeset
60 if (!codec) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
61 fprintf(stderr, "codec not found\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
62 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
63 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
64
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
65 c= avcodec_alloc_context();
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
66
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
67 /* put sample parameters */
986e461dc072 Initial revision
glantau
parents:
diff changeset
68 c->bit_rate = 64000;
986e461dc072 Initial revision
glantau
parents:
diff changeset
69 c->sample_rate = 44100;
986e461dc072 Initial revision
glantau
parents:
diff changeset
70 c->channels = 2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
71
986e461dc072 Initial revision
glantau
parents:
diff changeset
72 /* open it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
73 if (avcodec_open(c, codec) < 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
74 fprintf(stderr, "could not open codec\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
75 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
76 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
77
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
78 /* the codec gives us the frame size, in samples */
986e461dc072 Initial revision
glantau
parents:
diff changeset
79 frame_size = c->frame_size;
986e461dc072 Initial revision
glantau
parents:
diff changeset
80 samples = malloc(frame_size * 2 * c->channels);
986e461dc072 Initial revision
glantau
parents:
diff changeset
81 outbuf_size = 10000;
986e461dc072 Initial revision
glantau
parents:
diff changeset
82 outbuf = malloc(outbuf_size);
986e461dc072 Initial revision
glantau
parents:
diff changeset
83
1931
902556e6d21d writing corrupt files on MinGW patch by (Matthias Fritschi <choi at netlabs dot org>)
michael
parents: 1427
diff changeset
84 f = fopen(filename, "wb");
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
85 if (!f) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
86 fprintf(stderr, "could not open %s\n", filename);
986e461dc072 Initial revision
glantau
parents:
diff changeset
87 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
88 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
89
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
90 /* encode a single tone sound */
986e461dc072 Initial revision
glantau
parents:
diff changeset
91 t = 0;
986e461dc072 Initial revision
glantau
parents:
diff changeset
92 tincr = 2 * M_PI * 440.0 / c->sample_rate;
986e461dc072 Initial revision
glantau
parents:
diff changeset
93 for(i=0;i<200;i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
94 for(j=0;j<frame_size;j++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
95 samples[2*j] = (int)(sin(t) * 10000);
986e461dc072 Initial revision
glantau
parents:
diff changeset
96 samples[2*j+1] = samples[2*j];
986e461dc072 Initial revision
glantau
parents:
diff changeset
97 t += tincr;
986e461dc072 Initial revision
glantau
parents:
diff changeset
98 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
99 /* encode the samples */
986e461dc072 Initial revision
glantau
parents:
diff changeset
100 out_size = avcodec_encode_audio(c, outbuf, outbuf_size, samples);
986e461dc072 Initial revision
glantau
parents:
diff changeset
101 fwrite(outbuf, 1, out_size, f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
102 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
103 fclose(f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
104 free(outbuf);
986e461dc072 Initial revision
glantau
parents:
diff changeset
105 free(samples);
986e461dc072 Initial revision
glantau
parents:
diff changeset
106
986e461dc072 Initial revision
glantau
parents:
diff changeset
107 avcodec_close(c);
2517
3d8bbb8e7156 use av_free() instead of free() where it's meant to.
mmu_man
parents: 2423
diff changeset
108 av_free(c);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
109 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
110
986e461dc072 Initial revision
glantau
parents:
diff changeset
111 /*
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
112 * Audio decoding.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
113 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
114 void audio_decode_example(const char *outfilename, const char *filename)
986e461dc072 Initial revision
glantau
parents:
diff changeset
115 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
116 AVCodec *codec;
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
117 AVCodecContext *c= NULL;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
118 int out_size, size, len;
986e461dc072 Initial revision
glantau
parents:
diff changeset
119 FILE *f, *outfile;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1059
diff changeset
120 uint8_t *outbuf;
1394
951a4448c05a FF_INPUT_BUFFER_PADDING_SIZE
michaelni
parents: 1373
diff changeset
121 uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE], *inbuf_ptr;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
122
986e461dc072 Initial revision
glantau
parents:
diff changeset
123 printf("Audio decoding\n");
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
124
1394
951a4448c05a FF_INPUT_BUFFER_PADDING_SIZE
michaelni
parents: 1373
diff changeset
125 /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
951a4448c05a FF_INPUT_BUFFER_PADDING_SIZE
michaelni
parents: 1373
diff changeset
126 memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
127
986e461dc072 Initial revision
glantau
parents:
diff changeset
128 /* find the mpeg audio decoder */
986e461dc072 Initial revision
glantau
parents:
diff changeset
129 codec = avcodec_find_decoder(CODEC_ID_MP2);
986e461dc072 Initial revision
glantau
parents:
diff changeset
130 if (!codec) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
131 fprintf(stderr, "codec not found\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
132 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
133 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
134
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
135 c= avcodec_alloc_context();
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
136
986e461dc072 Initial revision
glantau
parents:
diff changeset
137 /* open it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
138 if (avcodec_open(c, codec) < 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
139 fprintf(stderr, "could not open codec\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
140 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
141 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
142
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
143 outbuf = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
986e461dc072 Initial revision
glantau
parents:
diff changeset
144
1931
902556e6d21d writing corrupt files on MinGW patch by (Matthias Fritschi <choi at netlabs dot org>)
michael
parents: 1427
diff changeset
145 f = fopen(filename, "rb");
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
146 if (!f) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
147 fprintf(stderr, "could not open %s\n", filename);
986e461dc072 Initial revision
glantau
parents:
diff changeset
148 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
149 }
1931
902556e6d21d writing corrupt files on MinGW patch by (Matthias Fritschi <choi at netlabs dot org>)
michael
parents: 1427
diff changeset
150 outfile = fopen(outfilename, "wb");
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
151 if (!outfile) {
2517
3d8bbb8e7156 use av_free() instead of free() where it's meant to.
mmu_man
parents: 2423
diff changeset
152 av_free(c);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
153 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
154 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
155
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
156 /* decode until eof */
986e461dc072 Initial revision
glantau
parents:
diff changeset
157 inbuf_ptr = inbuf;
986e461dc072 Initial revision
glantau
parents:
diff changeset
158 for(;;) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
159 size = fread(inbuf, 1, INBUF_SIZE, f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
160 if (size == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
161 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
162
986e461dc072 Initial revision
glantau
parents:
diff changeset
163 inbuf_ptr = inbuf;
986e461dc072 Initial revision
glantau
parents:
diff changeset
164 while (size > 0) {
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
165 len = avcodec_decode_audio(c, (short *)outbuf, &out_size,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
166 inbuf_ptr, size);
986e461dc072 Initial revision
glantau
parents:
diff changeset
167 if (len < 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
168 fprintf(stderr, "Error while decoding\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
169 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
170 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
171 if (out_size > 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
172 /* if a frame has been decoded, output it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
173 fwrite(outbuf, 1, out_size, outfile);
986e461dc072 Initial revision
glantau
parents:
diff changeset
174 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
175 size -= len;
986e461dc072 Initial revision
glantau
parents:
diff changeset
176 inbuf_ptr += len;
986e461dc072 Initial revision
glantau
parents:
diff changeset
177 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
178 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
179
986e461dc072 Initial revision
glantau
parents:
diff changeset
180 fclose(outfile);
986e461dc072 Initial revision
glantau
parents:
diff changeset
181 fclose(f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
182 free(outbuf);
986e461dc072 Initial revision
glantau
parents:
diff changeset
183
986e461dc072 Initial revision
glantau
parents:
diff changeset
184 avcodec_close(c);
2517
3d8bbb8e7156 use av_free() instead of free() where it's meant to.
mmu_man
parents: 2423
diff changeset
185 av_free(c);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
186 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
187
986e461dc072 Initial revision
glantau
parents:
diff changeset
188 /*
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
189 * Video encoding example
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
190 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
191 void video_encode_example(const char *filename)
986e461dc072 Initial revision
glantau
parents:
diff changeset
192 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
193 AVCodec *codec;
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
194 AVCodecContext *c= NULL;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
195 int i, out_size, size, x, y, outbuf_size;
986e461dc072 Initial revision
glantau
parents:
diff changeset
196 FILE *f;
925
7fccaa0d699d AVVideoFrame -> AVFrame
michaelni
parents: 919
diff changeset
197 AVFrame *picture;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1059
diff changeset
198 uint8_t *outbuf, *picture_buf;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
199
986e461dc072 Initial revision
glantau
parents:
diff changeset
200 printf("Video encoding\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
201
986e461dc072 Initial revision
glantau
parents:
diff changeset
202 /* find the mpeg1 video encoder */
986e461dc072 Initial revision
glantau
parents:
diff changeset
203 codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
986e461dc072 Initial revision
glantau
parents:
diff changeset
204 if (!codec) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
205 fprintf(stderr, "codec not found\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
206 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
207 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
208
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
209 c= avcodec_alloc_context();
925
7fccaa0d699d AVVideoFrame -> AVFrame
michaelni
parents: 919
diff changeset
210 picture= avcodec_alloc_frame();
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
211
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
212 /* put sample parameters */
986e461dc072 Initial revision
glantau
parents:
diff changeset
213 c->bit_rate = 400000;
986e461dc072 Initial revision
glantau
parents:
diff changeset
214 /* resolution must be a multiple of two */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
215 c->width = 352;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
216 c->height = 288;
986e461dc072 Initial revision
glantau
parents:
diff changeset
217 /* frames per second */
2637
ef44d24680d1 switch to native time bases
michael
parents: 2552
diff changeset
218 c->time_base= (AVRational){1,25};
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
219 c->gop_size = 10; /* emit one intra frame every ten frames */
1373
b47a402bbe7f last frames & b frames encoding fix
michaelni
parents: 1126
diff changeset
220 c->max_b_frames=1;
2760
dfcfaeed1679 apiexample fix by (Chip: szarlada, freemail hu)
michael
parents: 2637
diff changeset
221 c->pix_fmt = PIX_FMT_YUV420P;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
222
986e461dc072 Initial revision
glantau
parents:
diff changeset
223 /* open it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
224 if (avcodec_open(c, codec) < 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
225 fprintf(stderr, "could not open codec\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
226 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
227 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
228
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
229 /* the codec gives us the frame size, in samples */
986e461dc072 Initial revision
glantau
parents:
diff changeset
230
1931
902556e6d21d writing corrupt files on MinGW patch by (Matthias Fritschi <choi at netlabs dot org>)
michael
parents: 1427
diff changeset
231 f = fopen(filename, "wb");
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
232 if (!f) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
233 fprintf(stderr, "could not open %s\n", filename);
986e461dc072 Initial revision
glantau
parents:
diff changeset
234 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
235 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
236
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
237 /* alloc image and output buffer */
986e461dc072 Initial revision
glantau
parents:
diff changeset
238 outbuf_size = 100000;
986e461dc072 Initial revision
glantau
parents:
diff changeset
239 outbuf = malloc(outbuf_size);
986e461dc072 Initial revision
glantau
parents:
diff changeset
240 size = c->width * c->height;
986e461dc072 Initial revision
glantau
parents:
diff changeset
241 picture_buf = malloc((size * 3) / 2); /* size for YUV 420 */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
242
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
243 picture->data[0] = picture_buf;
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
244 picture->data[1] = picture->data[0] + size;
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
245 picture->data[2] = picture->data[1] + size / 4;
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
246 picture->linesize[0] = c->width;
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
247 picture->linesize[1] = c->width / 2;
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
248 picture->linesize[2] = c->width / 2;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
249
986e461dc072 Initial revision
glantau
parents:
diff changeset
250 /* encode 1 second of video */
986e461dc072 Initial revision
glantau
parents:
diff changeset
251 for(i=0;i<25;i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
252 fflush(stdout);
986e461dc072 Initial revision
glantau
parents:
diff changeset
253 /* prepare a dummy image */
986e461dc072 Initial revision
glantau
parents:
diff changeset
254 /* Y */
986e461dc072 Initial revision
glantau
parents:
diff changeset
255 for(y=0;y<c->height;y++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
256 for(x=0;x<c->width;x++) {
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
257 picture->data[0][y * picture->linesize[0] + x] = x + y + i * 3;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
258 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
259 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
260
986e461dc072 Initial revision
glantau
parents:
diff changeset
261 /* Cb and Cr */
986e461dc072 Initial revision
glantau
parents:
diff changeset
262 for(y=0;y<c->height/2;y++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
263 for(x=0;x<c->width/2;x++) {
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
264 picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2;
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
265 picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
266 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
267 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
268
986e461dc072 Initial revision
glantau
parents:
diff changeset
269 /* encode the image */
919
c87eee6da7b1 fixing api-example
michaelni
parents: 895
diff changeset
270 out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
1373
b47a402bbe7f last frames & b frames encoding fix
michaelni
parents: 1126
diff changeset
271 printf("encoding frame %3d (size=%5d)\n", i, out_size);
b47a402bbe7f last frames & b frames encoding fix
michaelni
parents: 1126
diff changeset
272 fwrite(outbuf, 1, out_size, f);
b47a402bbe7f last frames & b frames encoding fix
michaelni
parents: 1126
diff changeset
273 }
b47a402bbe7f last frames & b frames encoding fix
michaelni
parents: 1126
diff changeset
274
b47a402bbe7f last frames & b frames encoding fix
michaelni
parents: 1126
diff changeset
275 /* get the delayed frames */
b47a402bbe7f last frames & b frames encoding fix
michaelni
parents: 1126
diff changeset
276 for(; out_size; i++) {
b47a402bbe7f last frames & b frames encoding fix
michaelni
parents: 1126
diff changeset
277 fflush(stdout);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
278
1373
b47a402bbe7f last frames & b frames encoding fix
michaelni
parents: 1126
diff changeset
279 out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
b47a402bbe7f last frames & b frames encoding fix
michaelni
parents: 1126
diff changeset
280 printf("write frame %3d (size=%5d)\n", i, out_size);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
281 fwrite(outbuf, 1, out_size, f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
282 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
283
986e461dc072 Initial revision
glantau
parents:
diff changeset
284 /* add sequence end code to have a real mpeg file */
986e461dc072 Initial revision
glantau
parents:
diff changeset
285 outbuf[0] = 0x00;
986e461dc072 Initial revision
glantau
parents:
diff changeset
286 outbuf[1] = 0x00;
986e461dc072 Initial revision
glantau
parents:
diff changeset
287 outbuf[2] = 0x01;
986e461dc072 Initial revision
glantau
parents:
diff changeset
288 outbuf[3] = 0xb7;
986e461dc072 Initial revision
glantau
parents:
diff changeset
289 fwrite(outbuf, 1, 4, f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
290 fclose(f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
291 free(picture_buf);
986e461dc072 Initial revision
glantau
parents:
diff changeset
292 free(outbuf);
986e461dc072 Initial revision
glantau
parents:
diff changeset
293
986e461dc072 Initial revision
glantau
parents:
diff changeset
294 avcodec_close(c);
2517
3d8bbb8e7156 use av_free() instead of free() where it's meant to.
mmu_man
parents: 2423
diff changeset
295 av_free(c);
3d8bbb8e7156 use av_free() instead of free() where it's meant to.
mmu_man
parents: 2423
diff changeset
296 av_free(picture);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
297 printf("\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
298 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
299
986e461dc072 Initial revision
glantau
parents:
diff changeset
300 /*
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
301 * Video decoding example
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
302 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
303
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
304 void pgm_save(unsigned char *buf,int wrap, int xsize,int ysize,char *filename)
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
305 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
306 FILE *f;
986e461dc072 Initial revision
glantau
parents:
diff changeset
307 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
308
986e461dc072 Initial revision
glantau
parents:
diff changeset
309 f=fopen(filename,"w");
986e461dc072 Initial revision
glantau
parents:
diff changeset
310 fprintf(f,"P5\n%d %d\n%d\n",xsize,ysize,255);
986e461dc072 Initial revision
glantau
parents:
diff changeset
311 for(i=0;i<ysize;i++)
986e461dc072 Initial revision
glantau
parents:
diff changeset
312 fwrite(buf + i * wrap,1,xsize,f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
313 fclose(f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
314 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
315
986e461dc072 Initial revision
glantau
parents:
diff changeset
316 void video_decode_example(const char *outfilename, const char *filename)
986e461dc072 Initial revision
glantau
parents:
diff changeset
317 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
318 AVCodec *codec;
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
319 AVCodecContext *c= NULL;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
320 int frame, size, got_picture, len;
986e461dc072 Initial revision
glantau
parents:
diff changeset
321 FILE *f;
925
7fccaa0d699d AVVideoFrame -> AVFrame
michaelni
parents: 919
diff changeset
322 AVFrame *picture;
1394
951a4448c05a FF_INPUT_BUFFER_PADDING_SIZE
michaelni
parents: 1373
diff changeset
323 uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE], *inbuf_ptr;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
324 char buf[1024];
986e461dc072 Initial revision
glantau
parents:
diff changeset
325
1394
951a4448c05a FF_INPUT_BUFFER_PADDING_SIZE
michaelni
parents: 1373
diff changeset
326 /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
951a4448c05a FF_INPUT_BUFFER_PADDING_SIZE
michaelni
parents: 1373
diff changeset
327 memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
951a4448c05a FF_INPUT_BUFFER_PADDING_SIZE
michaelni
parents: 1373
diff changeset
328
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
329 printf("Video decoding\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
330
986e461dc072 Initial revision
glantau
parents:
diff changeset
331 /* find the mpeg1 video decoder */
986e461dc072 Initial revision
glantau
parents:
diff changeset
332 codec = avcodec_find_decoder(CODEC_ID_MPEG1VIDEO);
986e461dc072 Initial revision
glantau
parents:
diff changeset
333 if (!codec) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
334 fprintf(stderr, "codec not found\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
335 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
336 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
337
685
44a1dab0205c fixing apiexample
michaelni
parents: 71
diff changeset
338 c= avcodec_alloc_context();
925
7fccaa0d699d AVVideoFrame -> AVFrame
michaelni
parents: 919
diff changeset
339 picture= avcodec_alloc_frame();
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
340
895
1a5926aeed5f apiexample doesnt send complete frames to the codec
michaelni
parents: 685
diff changeset
341 if(codec->capabilities&CODEC_CAP_TRUNCATED)
1a5926aeed5f apiexample doesnt send complete frames to the codec
michaelni
parents: 685
diff changeset
342 c->flags|= CODEC_FLAG_TRUNCATED; /* we dont send complete frames */
1a5926aeed5f apiexample doesnt send complete frames to the codec
michaelni
parents: 685
diff changeset
343
71
79be2c581c01 changed opendivx to mpeg4
glantau
parents: 0
diff changeset
344 /* for some codecs, such as msmpeg4 and mpeg4, width and height
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
345 MUST be initialized there because these info are not available
986e461dc072 Initial revision
glantau
parents:
diff changeset
346 in the bitstream */
986e461dc072 Initial revision
glantau
parents:
diff changeset
347
986e461dc072 Initial revision
glantau
parents:
diff changeset
348 /* open it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
349 if (avcodec_open(c, codec) < 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
350 fprintf(stderr, "could not open codec\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
351 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
352 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
353
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
354 /* the codec gives us the frame size, in samples */
986e461dc072 Initial revision
glantau
parents:
diff changeset
355
1931
902556e6d21d writing corrupt files on MinGW patch by (Matthias Fritschi <choi at netlabs dot org>)
michael
parents: 1427
diff changeset
356 f = fopen(filename, "rb");
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
357 if (!f) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
358 fprintf(stderr, "could not open %s\n", filename);
986e461dc072 Initial revision
glantau
parents:
diff changeset
359 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
360 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
361
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
362 frame = 0;
986e461dc072 Initial revision
glantau
parents:
diff changeset
363 for(;;) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
364 size = fread(inbuf, 1, INBUF_SIZE, f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
365 if (size == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
366 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
367
986e461dc072 Initial revision
glantau
parents:
diff changeset
368 /* NOTE1: some codecs are stream based (mpegvideo, mpegaudio)
986e461dc072 Initial revision
glantau
parents:
diff changeset
369 and this is the only method to use them because you cannot
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
370 know the compressed data size before analysing it.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
371
71
79be2c581c01 changed opendivx to mpeg4
glantau
parents: 0
diff changeset
372 BUT some other codecs (msmpeg4, mpeg4) are inherently frame
79be2c581c01 changed opendivx to mpeg4
glantau
parents: 0
diff changeset
373 based, so you must call them with all the data for one
79be2c581c01 changed opendivx to mpeg4
glantau
parents: 0
diff changeset
374 frame exactly. You must also initialize 'width' and
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
375 'height' before initializing them. */
986e461dc072 Initial revision
glantau
parents:
diff changeset
376
986e461dc072 Initial revision
glantau
parents:
diff changeset
377 /* NOTE2: some codecs allow the raw parameters (frame size,
986e461dc072 Initial revision
glantau
parents:
diff changeset
378 sample rate) to be changed at any frame. We handle this, so
986e461dc072 Initial revision
glantau
parents:
diff changeset
379 you should also take care of it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
380
986e461dc072 Initial revision
glantau
parents:
diff changeset
381 /* here, we use a stream based decoder (mpeg1video), so we
986e461dc072 Initial revision
glantau
parents:
diff changeset
382 feed decoder and see if it could decode a frame */
986e461dc072 Initial revision
glantau
parents:
diff changeset
383 inbuf_ptr = inbuf;
986e461dc072 Initial revision
glantau
parents:
diff changeset
384 while (size > 0) {
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
385 len = avcodec_decode_video(c, picture, &got_picture,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
386 inbuf_ptr, size);
986e461dc072 Initial revision
glantau
parents:
diff changeset
387 if (len < 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
388 fprintf(stderr, "Error while decoding frame %d\n", frame);
986e461dc072 Initial revision
glantau
parents:
diff changeset
389 exit(1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
390 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
391 if (got_picture) {
1373
b47a402bbe7f last frames & b frames encoding fix
michaelni
parents: 1126
diff changeset
392 printf("saving frame %3d\n", frame);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
393 fflush(stdout);
986e461dc072 Initial revision
glantau
parents:
diff changeset
394
986e461dc072 Initial revision
glantau
parents:
diff changeset
395 /* the picture is allocated by the decoder. no need to
986e461dc072 Initial revision
glantau
parents:
diff changeset
396 free it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
397 snprintf(buf, sizeof(buf), outfilename, frame);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
398 pgm_save(picture->data[0], picture->linesize[0],
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
399 c->width, c->height, buf);
986e461dc072 Initial revision
glantau
parents:
diff changeset
400 frame++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
401 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
402 size -= len;
986e461dc072 Initial revision
glantau
parents:
diff changeset
403 inbuf_ptr += len;
986e461dc072 Initial revision
glantau
parents:
diff changeset
404 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
405 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
406
986e461dc072 Initial revision
glantau
parents:
diff changeset
407 /* some codecs, such as MPEG, transmit the I and P frame with a
986e461dc072 Initial revision
glantau
parents:
diff changeset
408 latency of one frame. You must do the following to have a
986e461dc072 Initial revision
glantau
parents:
diff changeset
409 chance to get the last frame of the video */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
410 len = avcodec_decode_video(c, picture, &got_picture,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
411 NULL, 0);
986e461dc072 Initial revision
glantau
parents:
diff changeset
412 if (got_picture) {
1373
b47a402bbe7f last frames & b frames encoding fix
michaelni
parents: 1126
diff changeset
413 printf("saving last frame %3d\n", frame);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
414 fflush(stdout);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
415
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
416 /* the picture is allocated by the decoder. no need to
986e461dc072 Initial revision
glantau
parents:
diff changeset
417 free it */
986e461dc072 Initial revision
glantau
parents:
diff changeset
418 snprintf(buf, sizeof(buf), outfilename, frame);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
419 pgm_save(picture->data[0], picture->linesize[0],
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
420 c->width, c->height, buf);
986e461dc072 Initial revision
glantau
parents:
diff changeset
421 frame++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
422 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2760
diff changeset
423
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
424 fclose(f);
986e461dc072 Initial revision
glantau
parents:
diff changeset
425
986e461dc072 Initial revision
glantau
parents:
diff changeset
426 avcodec_close(c);
2517
3d8bbb8e7156 use av_free() instead of free() where it's meant to.
mmu_man
parents: 2423
diff changeset
427 av_free(c);
3d8bbb8e7156 use av_free() instead of free() where it's meant to.
mmu_man
parents: 2423
diff changeset
428 av_free(picture);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
429 printf("\n");
986e461dc072 Initial revision
glantau
parents:
diff changeset
430 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
431
986e461dc072 Initial revision
glantau
parents:
diff changeset
432 int main(int argc, char **argv)
986e461dc072 Initial revision
glantau
parents:
diff changeset
433 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
434 const char *filename;
986e461dc072 Initial revision
glantau
parents:
diff changeset
435
986e461dc072 Initial revision
glantau
parents:
diff changeset
436 /* must be called before using avcodec lib */
986e461dc072 Initial revision
glantau
parents:
diff changeset
437 avcodec_init();
986e461dc072 Initial revision
glantau
parents:
diff changeset
438
986e461dc072 Initial revision
glantau
parents:
diff changeset
439 /* register all the codecs (you can also register only the codec
986e461dc072 Initial revision
glantau
parents:
diff changeset
440 you wish to have smaller code */
986e461dc072 Initial revision
glantau
parents:
diff changeset
441 avcodec_register_all();
1059
890b9fb44e84 * still unfinished code for Options
kabi
parents: 925
diff changeset
442
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
443 if (argc <= 1) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
444 audio_encode_example("/tmp/test.mp2");
986e461dc072 Initial revision
glantau
parents:
diff changeset
445 audio_decode_example("/tmp/test.sw", "/tmp/test.mp2");
986e461dc072 Initial revision
glantau
parents:
diff changeset
446
986e461dc072 Initial revision
glantau
parents:
diff changeset
447 video_encode_example("/tmp/test.mpg");
986e461dc072 Initial revision
glantau
parents:
diff changeset
448 filename = "/tmp/test.mpg";
986e461dc072 Initial revision
glantau
parents:
diff changeset
449 } else {
986e461dc072 Initial revision
glantau
parents:
diff changeset
450 filename = argv[1];
986e461dc072 Initial revision
glantau
parents:
diff changeset
451 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
452
986e461dc072 Initial revision
glantau
parents:
diff changeset
453 // audio_decode_example("/tmp/test.sw", filename);
986e461dc072 Initial revision
glantau
parents:
diff changeset
454 video_decode_example("/tmp/test%d.pgm", filename);
986e461dc072 Initial revision
glantau
parents:
diff changeset
455
986e461dc072 Initial revision
glantau
parents:
diff changeset
456 return 0;
986e461dc072 Initial revision
glantau
parents:
diff changeset
457 }