History

avcodec/mpegvideo, mpegpicture: Add buffer pool

This avoids constant allocations+frees and will also allow to simply switch to the RefStruct API, thereby avoiding the overhead of the AVBuffer API. It also simplifies the code, because it removes the "needs_realloc" field: It was added in 435c0b87d28b48dc2e0360adc404a0e2d66d16a0, before the introduction of the AVBuffer API: given that these buffers may be used by different threads, they were not freed immediately and instead were marked as being freed later by setting needs_realloc.

Andreas Rheinhardt committed 4 years ago

Commit 788892d1 parent a95591d6 files · +112 −157Browse files

Showing the changes to libavcodec (6 of 6 files). Show all

Unified · Split

6 files
  1. libavcodec/mpegpicture.c +32 −123
  2. libavcodec/mpegpicture.h +18 −9
  3. libavcodec/mpegvideo.c +37 −0
  4. libavcodec/mpegvideo.h +2 −0
  5. libavcodec/mpegvideo_dec.c +16 −19
  6. libavcodec/mpegvideo_enc.c +7 −6
libavcodec/mpegpicture.c+32−123
@@ -29,15 +29,11 @@ · 28 unmodified lines
2929 #include "avcodec.h"
3030 #include "motion_est.h"
3131 #include "mpegpicture.h"
32−#include "mpegvideo.h"
3332 #include "refstruct.h"
3433 #include "threadframe.h"
3534
3635 static void av_noinline free_picture_tables(Picture *pic)
3736 {
38− pic->alloc_mb_width =
39− pic->alloc_mb_height = 0;
40−
4137 av_buffer_unref(&pic->mbskip_table_buf);
4238 av_buffer_unref(&pic->qscale_table_buf);
4339 av_buffer_unref(&pic->mb_type_buf);
@@ -46,43 +42,9 @@ static void av_noinline free_picture_tables(Picture *pic) · 2 unmodified lines
4642 av_buffer_unref(&pic->motion_val_buf[i]);
4743 av_buffer_unref(&pic->ref_index_buf[i]);
4844 }
49−}
50−
51−static int make_table_writable(AVBufferRef **ref)
52−{
53− AVBufferRef *old = *ref, *new;
54−
55− if (av_buffer_is_writable(old))
56− return 0;
57− new = av_buffer_allocz(old->size);
58− if (!new)
59− return AVERROR(ENOMEM);
60− av_buffer_unref(ref);
61− *ref = new;
62− return 0;
63−}
64−
65−static int make_tables_writable(Picture *pic)
66−{
67−#define MAKE_WRITABLE(table) \
68−do {\
69− int ret = make_table_writable(&pic->table); \
70− if (ret < 0) \
71− return ret; \
72−} while (0)
73−
74− MAKE_WRITABLE(mbskip_table_buf);
75− MAKE_WRITABLE(qscale_table_buf);
76− MAKE_WRITABLE(mb_type_buf);
77−
78− if (pic->motion_val_buf[0]) {
79− for (int i = 0; i < 2; i++) {
80− MAKE_WRITABLE(motion_val_buf[i]);
81− MAKE_WRITABLE(ref_index_buf[i]);
82− }
83− }
8445
85− return 0;
46+ pic->mb_width =
47+ pic->mb_height = 0;
8648 }
8749
8850 int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
@@ -170,38 +132,28 @@ static int handle_pic_linesizes(AVCodecContext *avctx, Picture *pic, · 81 unmodified lines
170132 return 0;
171133 }
172134
173−static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encoding, int out_format,
174− int mb_stride, int mb_width, int mb_height, int b8_stride)
135+static int alloc_picture_tables(BufferPoolContext *pools, Picture *pic,
136+ int mb_height)
175137 {
176− const int big_mb_num = mb_stride * (mb_height + 1) + 1;
177− const int mb_array_size = mb_stride * mb_height;
178− const int b8_array_size = b8_stride * mb_height * 2;
179− int i;
180−
181−
182− pic->mbskip_table_buf = av_buffer_allocz(mb_array_size + 2);
183− pic->qscale_table_buf = av_buffer_allocz(big_mb_num + mb_stride);
184− pic->mb_type_buf = av_buffer_allocz((big_mb_num + mb_stride) *
185− sizeof(uint32_t));
186− if (!pic->mbskip_table_buf || !pic->qscale_table_buf || !pic->mb_type_buf)
187− return AVERROR(ENOMEM);
188−
189− if (out_format == FMT_H263 || encoding ||
190− (avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS)) {
191− int mv_size = 2 * (b8_array_size + 4) * sizeof(int16_t);
192− int ref_index_size = 4 * mb_array_size;
193−
194− for (i = 0; mv_size && i < 2; i++) {
195− pic->motion_val_buf[i] = av_buffer_allocz(mv_size);
196− pic->ref_index_buf[i] = av_buffer_allocz(ref_index_size);
197− if (!pic->motion_val_buf[i] || !pic->ref_index_buf[i])
198− return AVERROR(ENOMEM);
138+#define GET_BUFFER(name, idx_suffix) do { \
139+ pic->name ## _buf idx_suffix = av_buffer_pool_get(pools->name ## _pool); \
140+ if (!pic->name ## _buf idx_suffix) \
141+ return AVERROR(ENOMEM); \
142+} while (0)
143+ GET_BUFFER(mbskip_table,);
144+ GET_BUFFER(qscale_table,);
145+ GET_BUFFER(mb_type,);
146+ if (pools->motion_val_pool) {
147+ for (int i = 0; i < 2; i++) {
148+ GET_BUFFER(motion_val, [i]);
149+ GET_BUFFER(ref_index, [i]);
199150 }
200151 }
152+#undef GET_BUFFER
201153
202− pic->alloc_mb_width = mb_width;
203− pic->alloc_mb_height = mb_height;
204− pic->alloc_mb_stride = mb_stride;
154+ pic->mb_width = pools->alloc_mb_width;
155+ pic->mb_height = mb_height;
156+ pic->mb_stride = pools->alloc_mb_stride;
205157
206158 return 0;
207159 }
@@ -211,17 +163,11 @@ static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encodin · 3 unmodified lines
211163 * The pixels are allocated/set by calling get_buffer() if shared = 0
212164 */
213165 int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me,
214− ScratchpadContext *sc, int encoding, int out_format,
215− int mb_stride, int mb_width, int mb_height, int b8_stride,
216− ptrdiff_t *linesize, ptrdiff_t *uvlinesize)
166+ ScratchpadContext *sc, BufferPoolContext *pools,
167+ int mb_height, ptrdiff_t *linesize, ptrdiff_t *uvlinesize)
217168 {
218169 int i, ret;
219170
220− if (pic->qscale_table_buf)
221− if ( pic->alloc_mb_width != mb_width
222− || pic->alloc_mb_height != mb_height)
223− free_picture_tables(pic);
224−
225171 if (handle_pic_linesizes(avctx, pic, me, sc,
226172 *linesize, *uvlinesize) < 0)
227173 return -1;
@@ -229,18 +175,14 @@ int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me, · 1 unmodified line
229175 *linesize = pic->f->linesize[0];
230176 *uvlinesize = pic->f->linesize[1];
231177
232− if (!pic->qscale_table_buf)
233− ret = alloc_picture_tables(avctx, pic, encoding, out_format,
234− mb_stride, mb_width, mb_height, b8_stride);
235− else
236− ret = make_tables_writable(pic);
178+ ret = alloc_picture_tables(pools, pic, mb_height);
237179 if (ret < 0)
238180 goto fail;
239181
240182 pic->mbskip_table = pic->mbskip_table_buf->data;
241183 memset(pic->mbskip_table, 0, pic->mbskip_table_buf->size);
242− pic->qscale_table = pic->qscale_table_buf->data + 2 * mb_stride + 1;
243− pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * mb_stride + 1;
184+ pic->qscale_table = pic->qscale_table_buf->data + 2 * pic->mb_stride + 1;
185+ pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * pic->mb_stride + 1;
244186
245187 if (pic->motion_val_buf[0]) {
246188 for (i = 0; i < 2; i++) {
@@ -257,7 +199,6 @@ int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me, · 10 unmodified lines
257199 fail:
258200 av_log(avctx, AV_LOG_ERROR, "Error allocating a picture.\n");
259201 ff_mpeg_unref_picture(pic);
260− free_picture_tables(pic);
261202 return AVERROR(ENOMEM);
262203 }
263204
@@ -272,20 +213,18 @@ void ff_mpeg_unref_picture(Picture *pic) · 8 unmodified lines
272213
273214 ff_refstruct_unref(&pic->hwaccel_picture_private);
274215
275− if (pic->needs_realloc)
276− free_picture_tables(pic);
216+ free_picture_tables(pic);
277217
278218 pic->dummy = 0;
279219 pic->field_picture = 0;
280220 pic->b_frame_score = 0;
281− pic->needs_realloc = 0;
282221 pic->reference = 0;
283222 pic->shared = 0;
284223 pic->display_picture_number = 0;
285224 pic->coded_picture_number = 0;
286225 }
287226
288−int ff_update_picture_tables(Picture *dst, const Picture *src)
227+static int update_picture_tables(Picture *dst, const Picture *src)
289228 {
290229 int i, ret;
291230
@@ -310,9 +249,9 @@ int ff_update_picture_tables(Picture *dst, const Picture *src) · 18 unmodified lines
310249 dst->ref_index[i] = src->ref_index[i];
311250 }
312251
313− dst->alloc_mb_width = src->alloc_mb_width;
314− dst->alloc_mb_height = src->alloc_mb_height;
315− dst->alloc_mb_stride = src->alloc_mb_stride;
252+ dst->mb_width = src->mb_width;
253+ dst->mb_height = src->mb_height;
254+ dst->mb_stride = src->mb_stride;
316255
317256 return 0;
318257 }
@@ -330,7 +269,7 @@ int ff_mpeg_ref_picture(Picture *dst, Picture *src) · 11 unmodified lines
330269 if (ret < 0)
331270 goto fail;
332271
333− ret = ff_update_picture_tables(dst, src);
272+ ret = update_picture_tables(dst, src);
334273 if (ret < 0)
335274 goto fail;
336275
@@ -340,7 +279,6 @@ int ff_mpeg_ref_picture(Picture *dst, Picture *src) · 3 unmodified lines
340279 dst->dummy = src->dummy;
341280 dst->field_picture = src->field_picture;
342281 dst->b_frame_score = src->b_frame_score;
343− dst->needs_realloc = src->needs_realloc;
344282 dst->reference = src->reference;
345283 dst->shared = src->shared;
346284 dst->display_picture_number = src->display_picture_number;
@@ -352,30 +290,14 @@ fail: · 5 unmodified lines
352290 return ret;
353291 }
354292
355−static inline int pic_is_unused(Picture *pic)
356−{
357− if (!pic->f->buf[0])
358− return 1;
359− if (pic->needs_realloc)
360− return 1;
361− return 0;
362−}
363−
364−static int find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
293+int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
365294 {
366295 int i;
367296
368− if (shared) {
369297 for (i = 0; i < MAX_PICTURE_COUNT; i++) {
370298 if (!picture[i].f->buf[0])
371299 return i;
372300 }
373− } else {
374− for (i = 0; i < MAX_PICTURE_COUNT; i++) {
375− if (pic_is_unused(&picture[i]))
376− return i;
377− }
378− }
379301
380302 av_log(avctx, AV_LOG_FATAL,
381303 "Internal error, picture buffer overflow\n");
@@ -394,21 +316,8 @@ static int find_unused_picture(AVCodecContext *avctx, Picture *picture, int shar · 12 unmodified lines
394316 return -1;
395317 }
396318
397−int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
398−{
399− int ret = find_unused_picture(avctx, picture, shared);
400−
401− if (ret >= 0 && ret < MAX_PICTURE_COUNT) {
402− if (picture[ret].needs_realloc) {
403− ff_mpeg_unref_picture(&picture[ret]);
404− }
405− }
406− return ret;
407−}
408−
409319 void av_cold ff_mpv_picture_free(Picture *pic)
410320 {
411− free_picture_tables(pic);
412321 ff_mpeg_unref_picture(pic);
413322 av_frame_free(&pic->f);
414323 }
libavcodec/mpegpicture.h+18−9
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323
2424 #include <stdint.h>
2525
26+#include "libavutil/buffer.h"
2627 #include "libavutil/frame.h"
2728
2829 #include "avcodec.h"
@@ -41,6 +42,17 @@ typedef struct ScratchpadContext { · 12 unmodified lines
4142 int linesize; ///< linesize that the buffers in this context have been allocated for
4243 } ScratchpadContext;
4344
45+typedef struct BufferPoolContext {
46+ AVBufferPool *mbskip_table_pool;
47+ AVBufferPool *qscale_table_pool;
48+ AVBufferPool *mb_type_pool;
49+ AVBufferPool *motion_val_pool;
50+ AVBufferPool *ref_index_pool;
51+ int alloc_mb_width; ///< mb_width used to allocate tables
52+ int alloc_mb_height; ///< mb_height used to allocate tables
53+ int alloc_mb_stride; ///< mb_stride used to allocate tables
54+} BufferPoolContext;
55+
4456 /**
4557 * Picture.
4658 */
@@ -63,18 +75,17 @@ typedef struct Picture { · 16 unmodified lines
6375 AVBufferRef *ref_index_buf[2];
6476 int8_t *ref_index[2];
6577
66− int alloc_mb_width; ///< mb_width used to allocate tables
67− int alloc_mb_height; ///< mb_height used to allocate tables
68− int alloc_mb_stride; ///< mb_stride used to allocate tables
69−
7078 /// RefStruct reference for hardware accelerator private data
7179 void *hwaccel_picture_private;
7280
81+ int mb_width; ///< mb_width of the tables
82+ int mb_height; ///< mb_height of the tables
83+ int mb_stride; ///< mb_stride of the tables
84+
7385 int dummy; ///< Picture is a dummy and should not be output
7486 int field_picture; ///< whether or not the picture was encoded in separate fields
7587
7688 int b_frame_score;
77− int needs_realloc; ///< Picture needs to be reallocated (eg due to a frame size change)
7889
7990 int reference;
8091 int shared;
@@ -87,9 +98,8 @@ typedef struct Picture { · 6 unmodified lines
8798 * Allocate a Picture's accessories, but not the AVFrame's buffer itself.
8899 */
89100 int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me,
90− ScratchpadContext *sc, int encoding, int out_format,
91− int mb_stride, int mb_width, int mb_height, int b8_stride,
92− ptrdiff_t *linesize, ptrdiff_t *uvlinesize);
101+ ScratchpadContext *sc, BufferPoolContext *pools,
102+ int mb_height, ptrdiff_t *linesize, ptrdiff_t *uvlinesize);
93103
94104 int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
95105 ScratchpadContext *sc, int linesize);
@@ -98,7 +108,6 @@ int ff_mpeg_ref_picture(Picture *dst, Picture *src); · 2 unmodified lines
98108 void ff_mpeg_unref_picture(Picture *picture);
99109
100110 void ff_mpv_picture_free(Picture *pic);
101−int ff_update_picture_tables(Picture *dst, const Picture *src);
102111
103112 int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared);
104113
libavcodec/mpegvideo.c+37−0
@@ -534,8 +534,19 @@ void ff_mpv_common_defaults(MpegEncContext *s) · 533 unmodified lines
534534 s->slice_context_count = 1;
535535 }
536536
537+static void free_buffer_pools(BufferPoolContext *pools)
538+{
539+ av_buffer_pool_uninit(&pools->mbskip_table_pool);
540+ av_buffer_pool_uninit(&pools->qscale_table_pool);
541+ av_buffer_pool_uninit(&pools->mb_type_pool);
542+ av_buffer_pool_uninit(&pools->motion_val_pool);
543+ av_buffer_pool_uninit(&pools->ref_index_pool);
544+ pools->alloc_mb_height = pools->alloc_mb_width = pools->alloc_mb_stride = 0;
545+}
546+
537547 int ff_mpv_init_context_frame(MpegEncContext *s)
538548 {
549+ BufferPoolContext *const pools = &s->buffer_pools;
539550 int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;
540551 int mb_height;
541552
@@ -630,11 +641,36 @@ int ff_mpv_init_context_frame(MpegEncContext *s) · 88 unmodified lines
630641 return AVERROR(ENOMEM);
631642 memset(s->mbintra_table, 1, mb_array_size);
632643
644+#define ALLOC_POOL(name, size) do { \
645+ pools->name ##_pool = av_buffer_pool_init((size), av_buffer_allocz); \
646+ if (!pools->name ##_pool) \
647+ return AVERROR(ENOMEM); \
648+} while (0)
649+
650+ ALLOC_POOL(mbskip_table, mb_array_size + 2);
651+ ALLOC_POOL(qscale_table, mv_table_size);
652+ ALLOC_POOL(mb_type, mv_table_size * sizeof(uint32_t));
653+
654+ if (s->out_format == FMT_H263 || s->encoding ||
655+ (s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS)) {
656+ const int b8_array_size = s->b8_stride * mb_height * 2;
657+ int mv_size = 2 * (b8_array_size + 4) * sizeof(int16_t);
658+ int ref_index_size = 4 * mb_array_size;
659+
660+ ALLOC_POOL(motion_val, mv_size);
661+ ALLOC_POOL(ref_index, ref_index_size);
662+ }
663+#undef ALLOC_POOL
664+ pools->alloc_mb_width = s->mb_width;
665+ pools->alloc_mb_height = mb_height;
666+ pools->alloc_mb_stride = s->mb_stride;
667+
633668 return !CONFIG_MPEGVIDEODEC || s->encoding ? 0 : ff_mpeg_er_init(s);
634669 }
635670
636671 static void clear_context(MpegEncContext *s)
637672 {
673+ memset(&s->buffer_pools, 0, sizeof(s->buffer_pools));
638674 memset(&s->next_picture, 0, sizeof(s->next_picture));
639675 memset(&s->last_picture, 0, sizeof(s->last_picture));
640676 memset(&s->current_picture, 0, sizeof(s->current_picture));
@@ -762,6 +798,7 @@ void ff_mpv_free_context_frame(MpegEncContext *s) · 121 unmodified lines
762798 {
763799 free_duplicate_contexts(s);
764800
801+ free_buffer_pools(&s->buffer_pools);
765802 av_freep(&s->p_field_mv_table_base);
766803 for (int i = 0; i < 2; i++)
767804 for (int j = 0; j < 2; j++)
libavcodec/mpegvideo.h+2−0
@@ -132,6 +132,8 @@ typedef struct MpegEncContext { · 131 unmodified lines
132132 Picture **input_picture; ///< next pictures on display order for encoding
133133 Picture **reordered_input_picture; ///< pointer to the next pictures in coded order for encoding
134134
135+ BufferPoolContext buffer_pools;
136+
135137 int64_t user_specified_pts; ///< last non-zero pts from AVFrame which was passed into avcodec_send_frame()
136138 /**
137139 * pts difference between the first and second input frame, used for
libavcodec/mpegvideo_dec.c+16−19
@@ -115,12 +115,11 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, · 114 unmodified lines
115115 #define UPDATE_PICTURE(pic)\
116116 do {\
117117 ff_mpeg_unref_picture(&s->pic);\
118− if (s1->pic.f && s1->pic.f->buf[0])\
118+ if (s1->pic.f && s1->pic.f->buf[0]) {\
119119 ret = ff_mpeg_ref_picture(&s->pic, &s1->pic);\
120− else\
121− ret = ff_update_picture_tables(&s->pic, &s1->pic);\
122− if (ret < 0)\
123− return ret;\
120+ if (ret < 0)\
121+ return ret;\
122+ }\
124123 } while (0)
125124
126125 UPDATE_PICTURE(current_picture);
@@ -194,10 +193,6 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s) · 67 unmodified lines
194193
195194 ff_mpv_free_context_frame(s);
196195
197− if (s->picture)
198− for (int i = 0; i < MAX_PICTURE_COUNT; i++)
199− s->picture[i].needs_realloc = 1;
200−
201196 s->last_picture_ptr =
202197 s->next_picture_ptr =
203198 s->current_picture_ptr = NULL;
@@ -268,9 +263,12 @@ static int alloc_picture(MpegEncContext *s, Picture **picp, int reference) · 64 unmodified lines
268263 if (ret < 0)
269264 goto fail;
270265
271− ret = ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, 0, s->out_format,
272− s->mb_stride, s->mb_width, s->mb_height, s->b8_stride,
273− &s->linesize, &s->uvlinesize);
266+ av_assert1(s->mb_width == s->buffer_pools.alloc_mb_width);
267+ av_assert1(s->mb_height == s->buffer_pools.alloc_mb_height ||
268+ FFALIGN(s->mb_height, 2) == s->buffer_pools.alloc_mb_height);
269+ av_assert1(s->mb_stride == s->buffer_pools.alloc_mb_stride);
270+ ret = ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, &s->buffer_pools,
271+ s->mb_height, &s->linesize, &s->uvlinesize);
274272 if (ret < 0)
275273 goto fail;
276274 *picp = pic;
@@ -388,8 +386,7 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) · 111 unmodified lines
388386 for (int i = 0; i < MAX_PICTURE_COUNT; i++) {
389387 if (!s->picture[i].reference ||
390388 (&s->picture[i] != s->last_picture_ptr &&
391− &s->picture[i] != s->next_picture_ptr &&
392− !s->picture[i].needs_realloc)) {
389+ &s->picture[i] != s->next_picture_ptr)) {
393390 ff_mpeg_unref_picture(&s->picture[i]);
394391 }
395392 }
@@ -487,7 +484,7 @@ int ff_mpv_export_qp_table(const MpegEncContext *s, AVFrame *f, const Picture *p · 91 unmodified lines
487484 {
488485 AVVideoEncParams *par;
489486 int mult = (qp_type == FF_MPV_QSCALE_TYPE_MPEG1) ? 2 : 1;
490− unsigned int nb_mb = p->alloc_mb_height * p->alloc_mb_width;
487+ unsigned int nb_mb = p->mb_height * p->mb_width;
491488
492489 if (!(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS))
493490 return 0;
@@ -496,10 +493,10 @@ int ff_mpv_export_qp_table(const MpegEncContext *s, AVFrame *f, const Picture *p · 2 unmodified lines
496493 if (!par)
497494 return AVERROR(ENOMEM);
498495
499− for (unsigned y = 0; y < p->alloc_mb_height; y++)
500− for (unsigned x = 0; x < p->alloc_mb_width; x++) {
501− const unsigned int block_idx = y * p->alloc_mb_width + x;
502− const unsigned int mb_xy = y * p->alloc_mb_stride + x;
496+ for (unsigned y = 0; y < p->mb_height; y++)
497+ for (unsigned x = 0; x < p->mb_width; x++) {
498+ const unsigned int block_idx = y * p->mb_width + x;
499+ const unsigned int mb_xy = y * p->mb_stride + x;
503500 AVVideoBlockParams *const b = av_video_enc_params_block(par, block_idx);
504501
505502 b->src_x = x * 16;
libavcodec/mpegvideo_enc.c+7−6
@@ -1112,9 +1112,11 @@ static int alloc_picture(MpegEncContext *s, Picture *pic) · 1111 unmodified lines
11121112 pic->f->width = avctx->width;
11131113 pic->f->height = avctx->height;
11141114
1115− return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, 1, s->out_format,
1116− s->mb_stride, s->mb_width, s->mb_height, s->b8_stride,
1117− &s->linesize, &s->uvlinesize);
1115+ av_assert1(s->mb_width == s->buffer_pools.alloc_mb_width);
1116+ av_assert1(s->mb_height == s->buffer_pools.alloc_mb_height);
1117+ av_assert1(s->mb_stride == s->buffer_pools.alloc_mb_stride);
1118+ return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, &s->buffer_pools,
1119+ s->mb_height, &s->linesize, &s->uvlinesize);
11181120 }
11191121
11201122 static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
@@ -1480,7 +1482,7 @@ static int select_input_picture(MpegEncContext *s) · 359 unmodified lines
14801482 s->next_picture_ptr &&
14811483 skip_check(s, s->input_picture[0], s->next_picture_ptr)) {
14821484 // FIXME check that the gop check above is +-1 correct
1483− av_frame_unref(s->input_picture[0]->f);
1485+ ff_mpeg_unref_picture(s->input_picture[0]);
14841486
14851487 ff_vbv_update(s, 0);
14861488
@@ -1627,8 +1629,7 @@ no_output_pic: · 140 unmodified lines
16271629 pic->display_picture_number = s->reordered_input_picture[0]->display_picture_number;
16281630
16291631 /* mark us unused / free shared pic */
1630− av_frame_unref(s->reordered_input_picture[0]->f);
1631− s->reordered_input_picture[0]->shared = 0;
1632+ ff_mpeg_unref_picture(s->reordered_input_picture[0]);
16321633
16331634 s->current_picture_ptr = pic;
16341635 } 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