Revision d38c340f libavfilter/avfilter.c

View differences:

libavfilter/avfilter.c
267 267
    return ret;
268 268
}
269 269

  
270
AVFilterBufferRef *
271
avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms,
272
                                          int w, int h, enum PixelFormat format)
273
{
274
    AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer));
275
    AVFilterBufferRef *picref = av_mallocz(sizeof(AVFilterBufferRef));
276

  
277
    if (!pic || !picref)
278
        goto fail;
279

  
280
    picref->buf = pic;
281
    picref->buf->free = ff_avfilter_default_free_buffer;
282
    if (!(picref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps))))
283
        goto fail;
284

  
285
    picref->video->w = w;
286
    picref->video->h = h;
287

  
288
    /* make sure the buffer gets read permission or it's useless for output */
289
    picref->perms = perms | AV_PERM_READ;
290

  
291
    pic->refcount = 1;
292
    picref->type = AVMEDIA_TYPE_VIDEO;
293
    picref->format = format;
294

  
295
    memcpy(pic->data,        data,          sizeof(pic->data));
296
    memcpy(pic->linesize,    linesize,      sizeof(pic->linesize));
297
    memcpy(picref->data,     pic->data,     sizeof(picref->data));
298
    memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize));
299

  
300
    return picref;
301

  
302
fail:
303
    if (picref && picref->video)
304
        av_free(picref->video);
305
    av_free(picref);
306
    av_free(pic);
307
    return NULL;
308
}
309

  
270 310
AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
271 311
                                             enum AVSampleFormat sample_fmt, int size,
272 312
                                             int64_t channel_layout, int planar)

Also available in: Unified diff