summaryrefslogtreecommitdiff
path: root/libavfilter/avcodec.c
diff options
context:
space:
mode:
authorClément Bœsch <clement.boesch@smartjog.com>2012-02-14 17:00:53 +0100
committerClément Bœsch <ubitux@gmail.com>2012-03-26 22:46:40 +0200
commita67d9cfa58c61c8da7f8fdf4285db6ec208a8766 (patch)
tree07d4145627d25c158bcf2362acabe934b7214499 /libavfilter/avcodec.c
parenta84851bef8b7c99708ac5c7d0cddd6f8a7ee4d9e (diff)
downloadffmpeg-a67d9cfa58c61c8da7f8fdf4285db6ec208a8766.tar.gz
lavfi: add avfilter_fill_frame_from_{audio_,}buffer_ref().
Diffstat (limited to 'libavfilter/avcodec.c')
-rw-r--r--libavfilter/avcodec.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c
index 2850c4daa5..455ef9283a 100644
--- a/libavfilter/avcodec.c
+++ b/libavfilter/avcodec.c
@@ -56,6 +56,20 @@ AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame
return picref;
}
+int avfilter_fill_frame_from_audio_buffer_ref(AVFrame *frame,
+ const AVFilterBufferRef *samplesref)
+{
+ if (!samplesref || !samplesref->audio || !frame)
+ return AVERROR(EINVAL);
+
+ memcpy(frame->data, samplesref->data, sizeof(frame->data));
+ frame->pkt_pos = samplesref->pos;
+ frame->format = samplesref->format;
+ frame->nb_samples = samplesref->audio->nb_samples;
+
+ return 0;
+}
+
int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
const AVFilterBufferRef *picref)
{
@@ -73,3 +87,12 @@ int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
return 0;
}
+
+int avfilter_fill_frame_from_buffer_ref(AVFrame *frame,
+ const AVFilterBufferRef *ref)
+{
+ if (!ref)
+ return AVERROR(EINVAL);
+ return ref->video ? avfilter_fill_frame_from_video_buffer_ref(frame, ref)
+ : avfilter_fill_frame_from_audio_buffer_ref(frame, ref);
+}