X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Favcodec.c;h=f452303bb4e4b55dafbc4df330181b14d1473d4e;hb=7d1918affee4bc70fb8ac139ba9235e7fed2979b;hp=c50cd18f0bc5c2ababb1c521d50c84d605a2dff6;hpb=39afcf1d7eba8f2f3d59c973aa57df714e679629;p=ffmpeg diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c index c50cd18f0bc..f452303bb4e 100644 --- a/libavfilter/avcodec.c +++ b/libavfilter/avcodec.c @@ -70,14 +70,28 @@ AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame, int perms) { - AVFilterBufferRef *picref = + AVFilterBufferRef *samplesref = avfilter_get_audio_buffer_ref_from_arrays((uint8_t **)frame->data, frame->linesize[0], perms, frame->nb_samples, frame->format, av_frame_get_channel_layout(frame)); - if (!picref) + if (!samplesref) return NULL; - avfilter_copy_frame_props(picref, frame); - return picref; + avfilter_copy_frame_props(samplesref, frame); + return samplesref; +} + +AVFilterBufferRef *avfilter_get_buffer_ref_from_frame(enum AVMediaType type, + const AVFrame *frame, + int perms) +{ + switch (type) { + case AVMEDIA_TYPE_VIDEO: + return avfilter_get_video_buffer_ref_from_frame(frame, perms); + case AVMEDIA_TYPE_AUDIO: + return avfilter_get_audio_buffer_ref_from_frame(frame, perms); + default: + return NULL; + } } int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)