lavfi: implement avfilter_get_audio_buffer_ref_from_frame.
authorNicolas George <nicolas.george@normalesup.org>
Sat, 28 Apr 2012 11:05:09 +0000 (13:05 +0200)
committerNicolas George <nicolas.george@normalesup.org>
Fri, 4 May 2012 21:26:40 +0000 (23:26 +0200)
libavfilter/avcodec.c
libavfilter/avcodec.h

index 3581aef..e5f2bc3 100644 (file)
@@ -56,6 +56,20 @@ AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame
     return picref;
 }
 
+AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame,
+                                                            int perms)
+{
+    AVFilterBufferRef *picref =
+        avfilter_get_audio_buffer_ref_from_arrays((uint8_t **)frame->data, (int *)frame->linesize, perms,
+                                                  frame->nb_samples, frame->format,
+                                                  av_frame_get_channel_layout(frame),
+                                                  av_sample_fmt_is_planar(frame->format));
+    if (!picref)
+        return NULL;
+    avfilter_copy_frame_props(picref, frame);
+    return picref;
+}
+
 int avfilter_fill_frame_from_audio_buffer_ref(AVFrame *frame,
                                               const AVFilterBufferRef *samplesref)
 {
index 64773a6..1aa8b9c 100644 (file)
@@ -46,6 +46,16 @@ int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
  */
 AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame, int perms);
 
+
+/**
+ * Create and return a picref reference from the data and properties
+ * contained in frame.
+ *
+ * @param perms permissions to assign to the new buffer reference
+ */
+AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame,
+                                                            int perms);
+
 /**
  * Fill an AVFrame with the information stored in samplesref.
  *