History

avcodec/mpegvideo_enc: Move copying properties to alloc_picture()

This way said function sets everything (except for the actual contents of the frame's data). Also rename it to prepare_picture() given its new role.

Andreas Rheinhardt committed 3 years ago

Commit 2dfe7c11 parent 8225d2d1 file · +11 −11Browse files

Unified · Split

libavcodec/mpegvideo_enc.c+11−11
@@ -1091,7 +1091,11 @@ static int get_intra_count(MpegEncContext *s, const uint8_t *src, · 1090 unmodified lines
10911091 return acc;
10921092 }
10931093
1094−static int alloc_picture(MpegEncContext *s, AVFrame *f)
1094+/**
1095+ * Allocates new buffers for an AVFrame and copies the properties
1096+ * from another AVFrame.
1097+ */
1098+static int prepare_picture(MpegEncContext *s, AVFrame *f, const AVFrame *props_frame)
10951099 {
10961100 AVCodecContext *avctx = s->avctx;
10971101 int ret;
@@ -1116,6 +1120,10 @@ static int alloc_picture(MpegEncContext *s, AVFrame *f) · 18 unmodified lines
11161120 f->width = avctx->width;
11171121 f->height = avctx->height;
11181122
1123+ ret = av_frame_copy_props(f, props_frame);
1124+ if (ret < 0)
1125+ return ret;
1126+
11191127 return 0;
11201128 }
11211129
@@ -1186,14 +1194,9 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) · 64 unmodified lines
11861194 return ret;
11871195 pic->shared = 1;
11881196 } else {
1189− ret = alloc_picture(s, pic->f);
1197+ ret = prepare_picture(s, pic->f, pic_arg);
11901198 if (ret < 0)
11911199 goto fail;
1192− ret = av_frame_copy_props(pic->f, pic_arg);
1193− if (ret < 0) {
1194− ff_mpeg_unref_picture(pic);
1195− return ret;
1196− }
11971200
11981201 for (int i = 0; i < 3; i++) {
11991202 ptrdiff_t src_stride = pic_arg->linesize[i];
@@ -1607,11 +1610,8 @@ no_output_pic: · 407 unmodified lines
16071610 // input is a shared pix, so we can't modify it -> allocate a new
16081611 // one & ensure that the shared one is reuseable
16091612 av_frame_move_ref(s->new_pic, s->reordered_input_picture[0]->f);
1610− ret = alloc_picture(s, s->reordered_input_picture[0]->f);
1611− if (ret < 0)
1612− goto fail;
16131613
1614− ret = av_frame_copy_props(s->reordered_input_picture[0]->f, s->new_pic);
1614+ ret = prepare_picture(s, s->reordered_input_picture[0]->f, s->new_pic);
16151615 if (ret < 0)
16161616 goto fail;
16171617 } else {

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