MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / alloc_frame_buffer

Function alloc_frame_buffer

libavcodec/mpegvideo.c:213–249  ·  view source on GitHub ↗

* Allocates a frame buffer */

Source from the content-addressed store, hash-verified

211 * Allocates a frame buffer
212 */
213static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
214{
215 int r;
216
217 if (s->avctx->hwaccel) {
218 assert(!pic->hwaccel_picture_private);
219 if (s->avctx->hwaccel->priv_data_size) {
220 pic->hwaccel_picture_private = av_mallocz(s->avctx->hwaccel->priv_data_size);
221 if (!pic->hwaccel_picture_private) {
222 av_log(s->avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
223 return -1;
224 }
225 }
226 }
227
228 r = s->avctx->get_buffer(s->avctx, (AVFrame*)pic);
229
230 if (r<0 || !pic->age || !pic->type || !pic->data[0]) {
231 av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]);
232 av_freep(&pic->hwaccel_picture_private);
233 return -1;
234 }
235
236 if (s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1])) {
237 av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n");
238 free_frame_buffer(s, pic);
239 return -1;
240 }
241
242 if (pic->linesize[1] != pic->linesize[2]) {
243 av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride mismatch)\n");
244 free_frame_buffer(s, pic);
245 return -1;
246 }
247
248 return 0;
249}
250
251/**
252 * allocates a Picture

Callers 1

ff_alloc_pictureFunction · 0.85

Calls 4

av_malloczFunction · 0.85
av_logFunction · 0.85
av_freepFunction · 0.85
free_frame_bufferFunction · 0.85

Tested by

no test coverage detected