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

Showing the changes to libavcodec (1 of 1 file). Show all

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
1091 return acc;1091 return acc;
1092}1092}
1093 1093
1094static int alloc_picture(MpegEncContext *s, AVFrame *f)1094/**
1095 * Allocates new buffers for an AVFrame and copies the properties
1096 * from another AVFrame.
1097 */
1098static int prepare_picture(MpegEncContext *s, AVFrame *f, const AVFrame *props_frame)
1095{1099{
1096 AVCodecContext *avctx = s->avctx;1100 AVCodecContext *avctx = s->avctx;
1097 int ret;1101 int ret;
@@ -1116,6 +1120,10 @@ static int alloc_picture(MpegEncContext *s, AVFrame *f) · 18 unmodified lines
1116 f->width = avctx->width;1120 f->width = avctx->width;
1117 f->height = avctx->height;1121 f->height = avctx->height;
1118 1122
1123 ret = av_frame_copy_props(f, props_frame);
1124 if (ret < 0)
1125 return ret;
1126
1119 return 0;1127 return 0;
1120}1128}
1121 1129
@@ -1186,14 +1194,9 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) · 64 unmodified lines
1186 return ret;1194 return ret;
1187 pic->shared = 1;1195 pic->shared = 1;
1188 } else {1196 } else {
1189 ret = alloc_picture(s, pic->f);1197 ret = prepare_picture(s, pic->f, pic_arg);
1190 if (ret < 0)1198 if (ret < 0)
1191 goto fail;1199 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 }
1197 1200
1198 for (int i = 0; i < 3; i++) {1201 for (int i = 0; i < 3; i++) {
1199 ptrdiff_t src_stride = pic_arg->linesize[i];1202 ptrdiff_t src_stride = pic_arg->linesize[i];
@@ -1607,11 +1610,8 @@ no_output_pic: · 407 unmodified lines
1607 // input is a shared pix, so we can't modify it -> allocate a new1610 // input is a shared pix, so we can't modify it -> allocate a new
1608 // one & ensure that the shared one is reuseable1611 // one & ensure that the shared one is reuseable
1609 av_frame_move_ref(s->new_pic, s->reordered_input_picture[0]->f);1612 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;
1613 1613
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);
1615 if (ret < 0)1615 if (ret < 0)
1616 goto fail;1616 goto fail;
1617 } else {1617 } 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