lavfi: add avfilter_fill_frame_from_{audio_,}buffer_ref().

This commit is contained in:
Clément Bœsch
2012-02-14 17:00:53 +01:00
committed by Clément Bœsch
parent a84851bef8
commit a67d9cfa58
4 changed files with 50 additions and 2 deletions

View File

@@ -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);
}