History

examples/decoding_encoding: replace "picture" with "frame" in encode_example()

The use of "picture" in place of "frame" is confusing.

Stefano Sabatini committed 14 years ago

Commit bcf93f71 parent 70b671a1 file · +14 −14Browse files

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

Unified · Split

doc/examples/decoding_encoding.c+14−14
@@ -332,7 +332,7 @@ static void video_encode_example(const char *filename, int codec_id) · 331 unmodified lines
332 AVCodecContext *c= NULL;332 AVCodecContext *c= NULL;
333 int i, ret, x, y, got_output;333 int i, ret, x, y, got_output;
334 FILE *f;334 FILE *f;
335 AVFrame *picture;335 AVFrame *frame;
336 AVPacket pkt;336 AVPacket pkt;
337 uint8_t endcode[] = { 0, 0, 1, 0xb7 };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 exit(1);373 exit(1);
374 }374 }
375 375
376 picture = avcodec_alloc_frame();376 frame = avcodec_alloc_frame();
377 if (!picture) {377 if (!frame) {
378 fprintf(stderr, "Could not allocate video frame\n");378 fprintf(stderr, "Could not allocate video frame\n");
379 exit(1);379 exit(1);
380 }380 }
381 picture->format = c->pix_fmt;381 frame->format = c->pix_fmt;
382 picture->width = c->width;382 frame->width = c->width;
383 picture->height = c->height;383 frame->height = c->height;
384 384
385 /* the image can be allocated by any means and av_image_alloc() is385 /* the image can be allocated by any means and av_image_alloc() is
386 * just the most convenient way if av_malloc() is to be used */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 c->pix_fmt, 32);388 c->pix_fmt, 32);
389 if (ret < 0) {389 if (ret < 0) {
390 fprintf(stderr, "Could not allocate raw picture buffer\n");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 /* Y */402 /* Y */
403 for(y=0;y<c->height;y++) {403 for(y=0;y<c->height;y++) {
404 for(x=0;x<c->width;x++) {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 /* Cb and Cr */409 /* Cb and Cr */
410 for(y=0;y<c->height/2;y++) {410 for(y=0;y<c->height/2;y++) {
411 for(x=0;x<c->width/2;x++) {411 for(x=0;x<c->width/2;x++) {
412 picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2;412 frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
413 picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5;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 /* encode the image */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 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);
@@ -453,8 +453,8 @@ static void video_encode_example(const char *filename, int codec_id) · 29 unmodified lines
453 453
454 avcodec_close(c);454 avcodec_close(c);
455 av_free(c);455 av_free(c);
456 av_freep(&picture->data[0]);456 av_freep(&frame->data[0]);
457 av_free(picture);457 av_free(frame);
458 printf("\n");458 printf("\n");
459}459}
460 460

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