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
332332 AVCodecContext *c= NULL;
333333 int i, ret, x, y, got_output;
334334 FILE *f;
335− AVFrame *picture;
335+ AVFrame *frame;
336336 AVPacket pkt;
337337 uint8_t endcode[] = { 0, 0, 1, 0xb7 };
338338
@@ -373,18 +373,18 @@ static void video_encode_example(const char *filename, int codec_id) · 34 unmodified lines
373373 exit(1);
374374 }
375375
376− picture = avcodec_alloc_frame();
377− if (!picture) {
376+ frame = avcodec_alloc_frame();
377+ if (!frame) {
378378 fprintf(stderr, "Could not allocate video frame\n");
379379 exit(1);
380380 }
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;
384384
385385 /* the image can be allocated by any means and av_image_alloc() is
386386 * 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,
388388 c->pix_fmt, 32);
389389 if (ret < 0) {
390390 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
402402 /* Y */
403403 for(y=0;y<c->height;y++) {
404404 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;
406406 }
407407 }
408408
409409 /* Cb and Cr */
410410 for(y=0;y<c->height/2;y++) {
411411 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;
414414 }
415415 }
416416
417− picture->pts = i;
417+ frame->pts = i;
418418
419419 /* encode the image */
420− ret = avcodec_encode_video2(c, &pkt, picture, &got_output);
420+ ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
421421 if (ret < 0) {
422422 fprintf(stderr, "Error encoding frame\n");
423423 exit(1);
@@ -453,8 +453,8 @@ static void video_encode_example(const char *filename, int codec_id) · 29 unmodified lines
453453
454454 avcodec_close(c);
455455 av_free(c);
456− av_freep(&picture->data[0]);
457− av_free(picture);
456+ av_freep(&frame->data[0]);
457+ av_free(frame);
458458 printf("\n");
459459 }
460460

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