History

examples/decoding_encoding: apply various message log fixes

Stefano Sabatini committed 14 years ago

Commit 70b671a1 parent 8ad54a41 file · +26 −26Browse files

Unified · Split

doc/examples/decoding_encoding.c+26−26
@@ -116,7 +116,7 @@ static void audio_encode_example(const char *filename) · 115 unmodified lines
116 /* find the MP2 encoder */116 /* find the MP2 encoder */
117 codec = avcodec_find_encoder(AV_CODEC_ID_MP2);117 codec = avcodec_find_encoder(AV_CODEC_ID_MP2);
118 if (!codec) {118 if (!codec) {
119 fprintf(stderr, "codec not found\n");119 fprintf(stderr, "Codec not found\n");
120 exit(1);120 exit(1);
121 }121 }
122 122
@@ -128,7 +128,7 @@ static void audio_encode_example(const char *filename) · 5 unmodified lines
128 /* check that the encoder supports s16 pcm input */128 /* check that the encoder supports s16 pcm input */
129 c->sample_fmt = AV_SAMPLE_FMT_S16;129 c->sample_fmt = AV_SAMPLE_FMT_S16;
130 if (!check_sample_fmt(codec, c->sample_fmt)) {130 if (!check_sample_fmt(codec, c->sample_fmt)) {
131 fprintf(stderr, "encoder does not support %s",131 fprintf(stderr, "Encoder does not support sample format %s",
132 av_get_sample_fmt_name(c->sample_fmt));132 av_get_sample_fmt_name(c->sample_fmt));
133 exit(1);133 exit(1);
134 }134 }
@@ -140,20 +140,20 @@ static void audio_encode_example(const char *filename) · 5 unmodified lines
140 140
141 /* open it */141 /* open it */
142 if (avcodec_open2(c, codec, NULL) < 0) {142 if (avcodec_open2(c, codec, NULL) < 0) {
143 fprintf(stderr, "could not open codec\n");143 fprintf(stderr, "Could not open codec\n");
144 exit(1);144 exit(1);
145 }145 }
146 146
147 f = fopen(filename, "wb");147 f = fopen(filename, "wb");
148 if (!f) {148 if (!f) {
149 fprintf(stderr, "could not open %s\n", filename);149 fprintf(stderr, "Could not open %s\n", filename);
150 exit(1);150 exit(1);
151 }151 }
152 152
153 /* frame containing input raw audio */153 /* frame containing input raw audio */
154 frame = avcodec_alloc_frame();154 frame = avcodec_alloc_frame();
155 if (!frame) {155 if (!frame) {
156 fprintf(stderr, "could not allocate audio frame\n");156 fprintf(stderr, "Could not allocate audio frame\n");
157 exit(1);157 exit(1);
158 }158 }
159 159
@@ -167,7 +167,7 @@ static void audio_encode_example(const char *filename) · 7 unmodified lines
167 c->sample_fmt, 0);167 c->sample_fmt, 0);
168 samples = av_malloc(buffer_size);168 samples = av_malloc(buffer_size);
169 if (!samples) {169 if (!samples) {
170 fprintf(stderr, "could not allocate %d bytes for samples buffer\n",170 fprintf(stderr, "Could not allocate %d bytes for samples buffer\n",
171 buffer_size);171 buffer_size);
172 exit(1);172 exit(1);
173 }173 }
@@ -175,7 +175,7 @@ static void audio_encode_example(const char *filename) · 1 unmodified line
175 ret = avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,175 ret = avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,
176 (const uint8_t*)samples, buffer_size, 0);176 (const uint8_t*)samples, buffer_size, 0);
177 if (ret < 0) {177 if (ret < 0) {
178 fprintf(stderr, "could not setup audio frame\n");178 fprintf(stderr, "Could not setup audio frame\n");
179 exit(1);179 exit(1);
180 }180 }
181 181
@@ -197,7 +197,7 @@ static void audio_encode_example(const char *filename) · 15 unmodified lines
197 /* encode the samples */197 /* encode the samples */
198 ret = avcodec_encode_audio2(c, &pkt, frame, &got_output);198 ret = avcodec_encode_audio2(c, &pkt, frame, &got_output);
199 if (ret < 0) {199 if (ret < 0) {
200 fprintf(stderr, "error encoding audio frame\n");200 fprintf(stderr, "Error encoding audio frame\n");
201 exit(1);201 exit(1);
202 }202 }
203 if (got_output) {203 if (got_output) {
@@ -210,7 +210,7 @@ static void audio_encode_example(const char *filename) · 6 unmodified lines
210 for (got_output = 1; got_output; i++) {210 for (got_output = 1; got_output; i++) {
211 ret = avcodec_encode_audio2(c, &pkt, NULL, &got_output);211 ret = avcodec_encode_audio2(c, &pkt, NULL, &got_output);
212 if (ret < 0) {212 if (ret < 0) {
213 fprintf(stderr, "error encoding frame\n");213 fprintf(stderr, "Error encoding frame\n");
214 exit(1);214 exit(1);
215 }215 }
216 216
@@ -247,7 +247,7 @@ static void audio_decode_example(const char *outfilename, const char *filename) · 30 unmodified lines
247 /* find the mpeg audio decoder */247 /* find the mpeg audio decoder */
248 codec = avcodec_find_decoder(AV_CODEC_ID_MP2);248 codec = avcodec_find_decoder(AV_CODEC_ID_MP2);
249 if (!codec) {249 if (!codec) {
250 fprintf(stderr, "codec not found\n");250 fprintf(stderr, "Codec not found\n");
251 exit(1);251 exit(1);
252 }252 }
253 253
@@ -255,13 +255,13 @@ static void audio_decode_example(const char *outfilename, const char *filename) · 1 unmodified line
255 255
256 /* open it */256 /* open it */
257 if (avcodec_open2(c, codec, NULL) < 0) {257 if (avcodec_open2(c, codec, NULL) < 0) {
258 fprintf(stderr, "could not open codec\n");258 fprintf(stderr, "Could not open codec\n");
259 exit(1);259 exit(1);
260 }260 }
261 261
262 f = fopen(filename, "rb");262 f = fopen(filename, "rb");
263 if (!f) {263 if (!f) {
264 fprintf(stderr, "could not open %s\n", filename);264 fprintf(stderr, "Could not open %s\n", filename);
265 exit(1);265 exit(1);
266 }266 }
267 outfile = fopen(outfilename, "wb");267 outfile = fopen(outfilename, "wb");
@@ -279,7 +279,7 @@ static void audio_decode_example(const char *outfilename, const char *filename) · 11 unmodified lines
279 279
280 if (!decoded_frame) {280 if (!decoded_frame) {
281 if (!(decoded_frame = avcodec_alloc_frame())) {281 if (!(decoded_frame = avcodec_alloc_frame())) {
282 fprintf(stderr, "out of memory\n");282 fprintf(stderr, "Could not allocate audio frame\n");
283 exit(1);283 exit(1);
284 }284 }
285 } else285 } else
@@ -341,7 +341,7 @@ static void video_encode_example(const char *filename, int codec_id) · 55 unmodified lines
341 /* find the mpeg1 video encoder */341 /* find the mpeg1 video encoder */
342 codec = avcodec_find_encoder(codec_id);342 codec = avcodec_find_encoder(codec_id);
343 if (!codec) {343 if (!codec) {
344 fprintf(stderr, "codec not found\n");344 fprintf(stderr, "Codec not found\n");
345 exit(1);345 exit(1);
346 }346 }
347 347
@@ -363,13 +363,13 @@ static void video_encode_example(const char *filename, int codec_id) · 15 unmodified lines
363 363
364 /* open it */364 /* open it */
365 if (avcodec_open2(c, codec, NULL) < 0) {365 if (avcodec_open2(c, codec, NULL) < 0) {
366 fprintf(stderr, "could not open codec\n");366 fprintf(stderr, "Could not open codec\n");
367 exit(1);367 exit(1);
368 }368 }
369 369
370 f = fopen(filename, "wb");370 f = fopen(filename, "wb");
371 if (!f) {371 if (!f) {
372 fprintf(stderr, "could not open %s\n", filename);372 fprintf(stderr, "Could not open %s\n", filename);
373 exit(1);373 exit(1);
374 }374 }
375 375
@@ -387,7 +387,7 @@ static void video_encode_example(const char *filename, int codec_id) · 11 unmodified lines
387 ret = av_image_alloc(picture->data, picture->linesize, c->width, c->height,387 ret = av_image_alloc(picture->data, picture->linesize, c->width, c->height,
388 c->pix_fmt, 32);388 c->pix_fmt, 32);
389 if (ret < 0) {389 if (ret < 0) {
390 fprintf(stderr, "could not alloc raw picture buffer\n");390 fprintf(stderr, "Could not allocate raw picture buffer\n");
391 exit(1);391 exit(1);
392 }392 }
393 393
@@ -419,12 +419,12 @@ static void video_encode_example(const char *filename, int codec_id) · 25 unmodified lines
419 /* encode the image */419 /* encode the image */
420 ret = avcodec_encode_video2(c, &pkt, picture, &got_output);420 ret = avcodec_encode_video2(c, &pkt, picture, &got_output);
421 if (ret < 0) {421 if (ret < 0) {
422 fprintf(stderr, "error encoding frame\n");422 fprintf(stderr, "Error encoding frame\n");
423 exit(1);423 exit(1);
424 }424 }
425 425
426 if (got_output) {426 if (got_output) {
427 printf("encoding frame %3d (size=%5d)\n", i, pkt.size);427 printf("Write frame %3d (size=%5d)\n", i, pkt.size);
428 fwrite(pkt.data, 1, pkt.size, f);428 fwrite(pkt.data, 1, pkt.size, f);
429 av_free_packet(&pkt);429 av_free_packet(&pkt);
430 }430 }
@@ -436,12 +436,12 @@ static void video_encode_example(const char *filename, int codec_id) · 5 unmodified lines
436 436
437 ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);437 ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
438 if (ret < 0) {438 if (ret < 0) {
439 fprintf(stderr, "error encoding frame\n");439 fprintf(stderr, "Error encoding frame\n");
440 exit(1);440 exit(1);
441 }441 }
442 442
443 if (got_output) {443 if (got_output) {
444 printf("write frame %3d (size=%5d)\n", i, pkt.size);444 printf("Write frame %3d (size=%5d)\n", i, pkt.size);
445 fwrite(pkt.data, 1, pkt.size, f);445 fwrite(pkt.data, 1, pkt.size, f);
446 av_free_packet(&pkt);446 av_free_packet(&pkt);
447 }447 }
@@ -496,7 +496,7 @@ static void video_decode_example(const char *outfilename, const char *filename) · 48 unmodified lines
496 /* find the mpeg1 video decoder */496 /* find the mpeg1 video decoder */
497 codec = avcodec_find_decoder(AV_CODEC_ID_MPEG1VIDEO);497 codec = avcodec_find_decoder(AV_CODEC_ID_MPEG1VIDEO);
498 if (!codec) {498 if (!codec) {
499 fprintf(stderr, "codec not found\n");499 fprintf(stderr, "Codec not found\n");
500 exit(1);500 exit(1);
501 }501 }
502 502
@@ -510,7 +510,7 @@ static void video_decode_example(const char *outfilename, const char *filename) · 7 unmodified lines
510 510
511 /* open it */511 /* open it */
512 if (avcodec_open2(c, codec, NULL) < 0) {512 if (avcodec_open2(c, codec, NULL) < 0) {
513 fprintf(stderr, "could not open codec\n");513 fprintf(stderr, "Could not open codec\n");
514 exit(1);514 exit(1);
515 }515 }
516 516
@@ -518,7 +518,7 @@ static void video_decode_example(const char *outfilename, const char *filename) · 1 unmodified line
518 518
519 f = fopen(filename, "rb");519 f = fopen(filename, "rb");
520 if (!f) {520 if (!f) {
521 fprintf(stderr, "could not open %s\n", filename);521 fprintf(stderr, "Could not open %s\n", filename);
522 exit(1);522 exit(1);
523 }523 }
524 524
@@ -557,7 +557,7 @@ static void video_decode_example(const char *outfilename, const char *filename) · 32 unmodified lines
557 exit(1);557 exit(1);
558 }558 }
559 if (got_picture) {559 if (got_picture) {
560 printf("saving frame %3d\n", frame);560 printf("Saving frame %3d\n", frame);
561 fflush(stdout);561 fflush(stdout);
562 562
563 /* the picture is allocated by the decoder. no need to563 /* the picture is allocated by the decoder. no need to
@@ -579,7 +579,7 @@ static void video_decode_example(const char *outfilename, const char *filename) · 15 unmodified lines
579 avpkt.size = 0;579 avpkt.size = 0;
580 len = avcodec_decode_video2(c, picture, &got_picture, &avpkt);580 len = avcodec_decode_video2(c, picture, &got_picture, &avpkt);
581 if (got_picture) {581 if (got_picture) {
582 printf("saving last frame %3d\n", frame);582 printf("Saving last frame %3d\n", frame);
583 fflush(stdout);583 fflush(stdout);
584 584
585 /* the picture is allocated by the decoder. no need to585 /* the picture is allocated by the decoder. no need to

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t