Browse code

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

Clément Bœsch authored on 2012/02/15 01:00:53
Showing 4 changed files
... ...
@@ -13,6 +13,9 @@ libavutil:   2011-04-18
13 13
 
14 14
 API changes, most recent first:
15 15
 
16
+2012-03-26 - xxxxxxx - lavfi 2.66.100
17
+  Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions.
18
+
16 19
 2012-03-21 - xxxxxxx - lavu 51.43.100
17 20
   Add bprint.h for bprint API.
18 21
 
... ...
@@ -56,6 +56,20 @@ AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame
56 56
     return picref;
57 57
 }
58 58
 
59
+int avfilter_fill_frame_from_audio_buffer_ref(AVFrame *frame,
60
+                                              const AVFilterBufferRef *samplesref)
61
+{
62
+    if (!samplesref || !samplesref->audio || !frame)
63
+        return AVERROR(EINVAL);
64
+
65
+    memcpy(frame->data, samplesref->data, sizeof(frame->data));
66
+    frame->pkt_pos    = samplesref->pos;
67
+    frame->format     = samplesref->format;
68
+    frame->nb_samples = samplesref->audio->nb_samples;
69
+
70
+    return 0;
71
+}
72
+
59 73
 int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
60 74
                                               const AVFilterBufferRef *picref)
61 75
 {
... ...
@@ -73,3 +87,12 @@ int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
73 73
 
74 74
     return 0;
75 75
 }
76
+
77
+int avfilter_fill_frame_from_buffer_ref(AVFrame *frame,
78
+                                        const AVFilterBufferRef *ref)
79
+{
80
+    if (!ref)
81
+        return AVERROR(EINVAL);
82
+    return ref->video ? avfilter_fill_frame_from_video_buffer_ref(frame, ref)
83
+                      : avfilter_fill_frame_from_audio_buffer_ref(frame, ref);
84
+}
... ...
@@ -47,6 +47,17 @@ int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
47 47
 AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame, int perms);
48 48
 
49 49
 /**
50
+ * Fill an AVFrame with the information stored in samplesref.
51
+ *
52
+ * @param frame an already allocated AVFrame
53
+ * @param samplesref an audio buffer reference
54
+ * @return 0 in case of success, a negative AVERROR code in case of
55
+ * failure
56
+ */
57
+int avfilter_fill_frame_from_audio_buffer_ref(AVFrame *frame,
58
+                                              const AVFilterBufferRef *samplesref);
59
+
60
+/**
50 61
  * Fill an AVFrame with the information stored in picref.
51 62
  *
52 63
  * @param frame an already allocated AVFrame
... ...
@@ -58,6 +69,17 @@ int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
58 58
                                               const AVFilterBufferRef *picref);
59 59
 
60 60
 /**
61
+ * Fill an AVFrame with information stored in ref.
62
+ *
63
+ * @param frame an already allocated AVFrame
64
+ * @param ref a video or audio buffer reference
65
+ * @return 0 in case of success, a negative AVERROR code in case of
66
+ * failure
67
+ */
68
+int avfilter_fill_frame_from_buffer_ref(AVFrame *frame,
69
+                                        const AVFilterBufferRef *ref);
70
+
71
+/**
61 72
  * Add frame data to buffer_src.
62 73
  *
63 74
  * @param buffer_src pointer to a buffer source context
... ...
@@ -29,8 +29,8 @@
29 29
 #include "libavutil/avutil.h"
30 30
 
31 31
 #define LIBAVFILTER_VERSION_MAJOR  2
32
-#define LIBAVFILTER_VERSION_MINOR 65
33
-#define LIBAVFILTER_VERSION_MICRO 102
32
+#define LIBAVFILTER_VERSION_MINOR 66
33
+#define LIBAVFILTER_VERSION_MICRO 100
34 34
 
35 35
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
36 36
                                                LIBAVFILTER_VERSION_MINOR, \