History

examples/decoding_encoding: prefer 'frame' over 'picture' for an AVFrame

Decrease confusion.

Stefano Sabatini committed 14 years ago

Commit d3b8d561 parent dd84efe1 file · +19 −19Browse files

Showing the changes to doc/examples/decoding_encoding.c (1 of 1 file). Show all

Unified · Split

doc/examples/decoding_encoding.c+19−19
@@ -491,9 +491,9 @@ static void video_decode_example(const char *outfilename, const char *filename) · 490 unmodified lines
491491 {
492492 AVCodec *codec;
493493 AVCodecContext *c= NULL;
494− int frame, got_picture, len;
494+ int frame_count, got_frame, len;
495495 FILE *f;
496− AVFrame *picture;
496+ AVFrame *frame;
497497 uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
498498 char buf[1024];
499499 AVPacket avpkt;
@@ -537,13 +537,13 @@ static void video_decode_example(const char *outfilename, const char *filename) · 37 unmodified lines
537537 exit(1);
538538 }
539539
540− picture = avcodec_alloc_frame();
541− if (!picture) {
540+ frame = avcodec_alloc_frame();
541+ if (!frame) {
542542 fprintf(stderr, "Could not allocate video frame\n");
543543 exit(1);
544544 }
545545
546− frame = 0;
546+ frame_count = 0;
547547 for(;;) {
548548 avpkt.size = fread(inbuf, 1, INBUF_SIZE, f);
549549 if (avpkt.size == 0)
@@ -566,21 +566,21 @@ static void video_decode_example(const char *outfilename, const char *filename) · 16 unmodified lines
566566 feed decoder and see if it could decode a frame */
567567 avpkt.data = inbuf;
568568 while (avpkt.size > 0) {
569− len = avcodec_decode_video2(c, picture, &got_picture, &avpkt);
569+ len = avcodec_decode_video2(c, frame, &got_frame, &avpkt);
570570 if (len < 0) {
571− fprintf(stderr, "Error while decoding frame %d\n", frame);
571+ fprintf(stderr, "Error while decoding frame %d\n", frame_count);
572572 exit(1);
573573 }
574− if (got_picture) {
575− printf("Saving frame %3d\n", frame);
574+ if (got_frame) {
575+ printf("Saving frame %3d\n", frame_count);
576576 fflush(stdout);
577577
578578 /* the picture is allocated by the decoder. no need to
579579 free it */
580− snprintf(buf, sizeof(buf), outfilename, frame);
581− pgm_save(picture->data[0], picture->linesize[0],
580+ snprintf(buf, sizeof(buf), outfilename, frame_count);
581+ pgm_save(frame->data[0], frame->linesize[0],
582582 c->width, c->height, buf);
583− frame++;
583+ frame_count++;
584584 }
585585 avpkt.size -= len;
586586 avpkt.data += len;
@@ -592,24 +592,24 @@ static void video_decode_example(const char *outfilename, const char *filename) · 5 unmodified lines
592592 chance to get the last frame of the video */
593593 avpkt.data = NULL;
594594 avpkt.size = 0;
595− len = avcodec_decode_video2(c, picture, &got_picture, &avpkt);
596− if (got_picture) {
597− printf("Saving last frame %3d\n", frame);
595+ len = avcodec_decode_video2(c, frame, &got_frame, &avpkt);
596+ if (got_frame) {
597+ printf("Saving last frame %3d\n", frame_count);
598598 fflush(stdout);
599599
600600 /* the picture is allocated by the decoder. no need to
601601 free it */
602− snprintf(buf, sizeof(buf), outfilename, frame);
603− pgm_save(picture->data[0], picture->linesize[0],
602+ snprintf(buf, sizeof(buf), outfilename, frame_count);
603+ pgm_save(frame->data[0], frame->linesize[0],
604604 c->width, c->height, buf);
605− frame++;
605+ frame_count++;
606606 }
607607
608608 fclose(f);
609609
610610 avcodec_close(c);
611611 av_free(c);
612− avcodec_free_frame(&picture);
612+ avcodec_free_frame(&frame);
613613 printf("\n");
614614 }
615615

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