The use of "picture" in place of "frame" is confusing.
Showing the changes to doc/examples/decoding_encoding.c (1 of 1 file). Show all
Unified · Split
| @@ -332,7 +332,7 @@ static void video_encode_example(const char *filename, int codec_id) · 331 unmodified lines | ||
| 332 | 332 | AVCodecContext *c= NULL; |
| 333 | 333 | int i, ret, x, y, got_output; |
| 334 | 334 | FILE *f; |
| 335 | − AVFrame *picture; | |
| 335 | + AVFrame *frame; | |
| 336 | 336 | AVPacket pkt; |
| 337 | 337 | uint8_t endcode[] = { 0, 0, 1, 0xb7 }; |
| 338 | 338 | |
| @@ -373,18 +373,18 @@ static void video_encode_example(const char *filename, int codec_id) · 34 unmodified lines | ||
| 373 | 373 | exit(1); |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | − picture = avcodec_alloc_frame(); | |
| 377 | − if (!picture) { | |
| 376 | + frame = avcodec_alloc_frame(); | |
| 377 | + if (!frame) { | |
| 378 | 378 | fprintf(stderr, "Could not allocate video frame\n"); |
| 379 | 379 | exit(1); |
| 380 | 380 | } |
| 381 | − picture->format = c->pix_fmt; | |
| 382 | − picture->width = c->width; | |
| 383 | − picture->height = c->height; | |
| 381 | + frame->format = c->pix_fmt; | |
| 382 | + frame->width = c->width; | |
| 383 | + frame->height = c->height; | |
| 384 | 384 | |
| 385 | 385 | /* the image can be allocated by any means and av_image_alloc() is |
| 386 | 386 | * just the most convenient way if av_malloc() is to be used */ |
| 387 | − ret = av_image_alloc(picture->data, picture->linesize, c->width, c->height, | |
| 387 | + ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height, | |
| 388 | 388 | c->pix_fmt, 32); |
| 389 | 389 | if (ret < 0) { |
| 390 | 390 | fprintf(stderr, "Could not allocate raw picture buffer\n"); |
| @@ -402,22 +402,22 @@ static void video_encode_example(const char *filename, int codec_id) · 11 unmodified lines | ||
| 402 | 402 | /* Y */ |
| 403 | 403 | for(y=0;y<c->height;y++) { |
| 404 | 404 | for(x=0;x<c->width;x++) { |
| 405 | − picture->data[0][y * picture->linesize[0] + x] = x + y + i * 3; | |
| 405 | + frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3; | |
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /* Cb and Cr */ |
| 410 | 410 | for(y=0;y<c->height/2;y++) { |
| 411 | 411 | for(x=0;x<c->width/2;x++) { |
| 412 | − picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2; | |
| 413 | − picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5; | |
| 412 | + frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2; | |
| 413 | + frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5; | |
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | − picture->pts = i; | |
| 417 | + frame->pts = i; | |
| 418 | 418 | |
| 419 | 419 | /* encode the image */ |
| 420 | − ret = avcodec_encode_video2(c, &pkt, picture, &got_output); | |
| 420 | + ret = avcodec_encode_video2(c, &pkt, frame, &got_output); | |
| 421 | 421 | if (ret < 0) { |
| 422 | 422 | fprintf(stderr, "Error encoding frame\n"); |
| 423 | 423 | exit(1); |
| @@ -453,8 +453,8 @@ static void video_encode_example(const char *filename, int codec_id) · 29 unmodified lines | ||
| 453 | 453 | |
| 454 | 454 | avcodec_close(c); |
| 455 | 455 | av_free(c); |
| 456 | − av_freep(&picture->data[0]); | |
| 457 | − av_free(picture); | |
| 456 | + av_freep(&frame->data[0]); | |
| 457 | + av_free(frame); | |
| 458 | 458 | printf("\n"); |
| 459 | 459 | } |
| 460 | 460 | |