Mercurial > libavcodec.hg
comparison api-example.c @ 11766:01408f7d629c libavcodec
Cosmetics: reindent after the previous commit
author | mstorsjo |
---|---|
date | Tue, 25 May 2010 19:16:15 +0000 |
parents | c96e649c4e0a |
children |
comparison
equal
deleted
inserted
replaced
11765:c96e649c4e0a | 11766:01408f7d629c |
---|---|
155 exit(1); | 155 exit(1); |
156 } | 156 } |
157 | 157 |
158 /* decode until eof */ | 158 /* decode until eof */ |
159 avpkt.data = inbuf; | 159 avpkt.data = inbuf; |
160 avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f); | 160 avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f); |
161 | 161 |
162 while (avpkt.size > 0) { | 162 while (avpkt.size > 0) { |
163 out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; | 163 out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; |
164 len = avcodec_decode_audio3(c, (short *)outbuf, &out_size, &avpkt); | 164 len = avcodec_decode_audio3(c, (short *)outbuf, &out_size, &avpkt); |
165 if (len < 0) { | 165 if (len < 0) { |
166 fprintf(stderr, "Error while decoding\n"); | 166 fprintf(stderr, "Error while decoding\n"); |
167 exit(1); | 167 exit(1); |
168 } | 168 } |
169 if (out_size > 0) { | 169 if (out_size > 0) { |
170 /* if a frame has been decoded, output it */ | 170 /* if a frame has been decoded, output it */ |
171 fwrite(outbuf, 1, out_size, outfile); | 171 fwrite(outbuf, 1, out_size, outfile); |
172 } | 172 } |
173 avpkt.size -= len; | 173 avpkt.size -= len; |
174 avpkt.data += len; | 174 avpkt.data += len; |
175 if (avpkt.size < AUDIO_REFILL_THRESH) { | 175 if (avpkt.size < AUDIO_REFILL_THRESH) { |
176 /* Refill the input buffer, to avoid trying to decode | 176 /* Refill the input buffer, to avoid trying to decode |
177 * incomplete frames. Instead of this, one could also use | 177 * incomplete frames. Instead of this, one could also use |
178 * a parser, or use a proper container format through | 178 * a parser, or use a proper container format through |
179 * libavformat. */ | 179 * libavformat. */ |
180 memmove(inbuf, avpkt.data, avpkt.size); | 180 memmove(inbuf, avpkt.data, avpkt.size); |
181 avpkt.data = inbuf; | 181 avpkt.data = inbuf; |
182 len = fread(avpkt.data + avpkt.size, 1, | 182 len = fread(avpkt.data + avpkt.size, 1, |
183 AUDIO_INBUF_SIZE - avpkt.size, f); | 183 AUDIO_INBUF_SIZE - avpkt.size, f); |
184 if (len > 0) | 184 if (len > 0) |
185 avpkt.size += len; | 185 avpkt.size += len; |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 fclose(outfile); | 189 fclose(outfile); |
190 fclose(f); | 190 fclose(f); |
191 free(outbuf); | 191 free(outbuf); |
192 | 192 |