diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-11-25 20:50:28 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-11-25 20:50:28 +0000 |
commit | d38c340fdc970c913866f5e8461cf33ab200a51b (patch) | |
tree | 52a0e1f03ba1c0a4062ef9fc19298efbd2489d5f /libavfilter/avfilter.c | |
parent | 4723bc286812ded7150cd543e6348d04683ce997 (diff) | |
download | ffmpeg-d38c340fdc970c913866f5e8461cf33ab200a51b.tar.gz |
Implement avfilter_get_video_buffer_ref_from_arrays().
Originally committed as revision 25827 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r-- | libavfilter/avfilter.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index a761c81cfc..6146a3a06a 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -267,6 +267,46 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int return ret; } +AVFilterBufferRef * +avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms, + int w, int h, enum PixelFormat format) +{ + AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer)); + AVFilterBufferRef *picref = av_mallocz(sizeof(AVFilterBufferRef)); + + if (!pic || !picref) + goto fail; + + picref->buf = pic; + picref->buf->free = ff_avfilter_default_free_buffer; + if (!(picref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps)))) + goto fail; + + picref->video->w = w; + picref->video->h = h; + + /* make sure the buffer gets read permission or it's useless for output */ + picref->perms = perms | AV_PERM_READ; + + pic->refcount = 1; + picref->type = AVMEDIA_TYPE_VIDEO; + picref->format = format; + + memcpy(pic->data, data, sizeof(pic->data)); + memcpy(pic->linesize, linesize, sizeof(pic->linesize)); + memcpy(picref->data, pic->data, sizeof(picref->data)); + memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize)); + + return picref; + +fail: + if (picref && picref->video) + av_free(picref->video); + av_free(picref); + av_free(pic); + return NULL; +} + AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, enum AVSampleFormat sample_fmt, int size, int64_t channel_layout, int planar) |