Decrease confusion.
Showing the changes to doc/examples/decoding_encoding.c (1 of 1 file). Show all
Unified · Split
| @@ -491,9 +491,9 @@ static void video_decode_example(const char *outfilename, const char *filename) · 490 unmodified lines | ||
| 491 | 491 | { |
| 492 | 492 | AVCodec *codec; |
| 493 | 493 | AVCodecContext *c= NULL; |
| 494 | − int frame, got_picture, len; | |
| 494 | + int frame_count, got_frame, len; | |
| 495 | 495 | FILE *f; |
| 496 | − AVFrame *picture; | |
| 496 | + AVFrame *frame; | |
| 497 | 497 | uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; |
| 498 | 498 | char buf[1024]; |
| 499 | 499 | AVPacket avpkt; |
| @@ -537,13 +537,13 @@ static void video_decode_example(const char *outfilename, const char *filename) · 37 unmodified lines | ||
| 537 | 537 | exit(1); |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | − picture = avcodec_alloc_frame(); | |
| 541 | − if (!picture) { | |
| 540 | + frame = avcodec_alloc_frame(); | |
| 541 | + if (!frame) { | |
| 542 | 542 | fprintf(stderr, "Could not allocate video frame\n"); |
| 543 | 543 | exit(1); |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | − frame = 0; | |
| 546 | + frame_count = 0; | |
| 547 | 547 | for(;;) { |
| 548 | 548 | avpkt.size = fread(inbuf, 1, INBUF_SIZE, f); |
| 549 | 549 | if (avpkt.size == 0) |
| @@ -566,21 +566,21 @@ static void video_decode_example(const char *outfilename, const char *filename) · 16 unmodified lines | ||
| 566 | 566 | feed decoder and see if it could decode a frame */ |
| 567 | 567 | avpkt.data = inbuf; |
| 568 | 568 | while (avpkt.size > 0) { |
| 569 | − len = avcodec_decode_video2(c, picture, &got_picture, &avpkt); | |
| 569 | + len = avcodec_decode_video2(c, frame, &got_frame, &avpkt); | |
| 570 | 570 | if (len < 0) { |
| 571 | − fprintf(stderr, "Error while decoding frame %d\n", frame); | |
| 571 | + fprintf(stderr, "Error while decoding frame %d\n", frame_count); | |
| 572 | 572 | exit(1); |
| 573 | 573 | } |
| 574 | − if (got_picture) { | |
| 575 | − printf("Saving frame %3d\n", frame); | |
| 574 | + if (got_frame) { | |
| 575 | + printf("Saving frame %3d\n", frame_count); | |
| 576 | 576 | fflush(stdout); |
| 577 | 577 | |
| 578 | 578 | /* the picture is allocated by the decoder. no need to |
| 579 | 579 | 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], | |
| 582 | 582 | c->width, c->height, buf); |
| 583 | − frame++; | |
| 583 | + frame_count++; | |
| 584 | 584 | } |
| 585 | 585 | avpkt.size -= len; |
| 586 | 586 | avpkt.data += len; |
| @@ -592,24 +592,24 @@ static void video_decode_example(const char *outfilename, const char *filename) · 5 unmodified lines | ||
| 592 | 592 | chance to get the last frame of the video */ |
| 593 | 593 | avpkt.data = NULL; |
| 594 | 594 | 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); | |
| 598 | 598 | fflush(stdout); |
| 599 | 599 | |
| 600 | 600 | /* the picture is allocated by the decoder. no need to |
| 601 | 601 | 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], | |
| 604 | 604 | c->width, c->height, buf); |
| 605 | − frame++; | |
| 605 | + frame_count++; | |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | fclose(f); |
| 609 | 609 | |
| 610 | 610 | avcodec_close(c); |
| 611 | 611 | av_free(c); |
| 612 | − avcodec_free_frame(&picture); | |
| 612 | + avcodec_free_frame(&frame); | |
| 613 | 613 | printf("\n"); |
| 614 | 614 | } |
| 615 | 615 | |