Browse code

sink_buffer: implement fixed frame size.

Nicolas George authored on 2012/06/25 07:30:15
Showing 2 changed files
... ...
@@ -56,6 +56,15 @@ typedef struct {
56 56
 AVABufferSinkParams *av_abuffersink_params_alloc(void);
57 57
 
58 58
 /**
59
+ * Set the frame size for an audio buffer sink.
60
+ *
61
+ * All calls to av_buffersink_get_buffer_ref will return a buffer with
62
+ * exactly the specified number of samples, or AVERROR(EAGAIN) if there is
63
+ * not enough. The last buffer at EOF will be padded with 0.
64
+ */
65
+void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size);
66
+
67
+/**
59 68
  * Tell av_buffersink_get_buffer_ref() to read video/samples buffer
60 69
  * reference, but not remove it from the buffer. This is useful if you
61 70
  * need only to read a video/samples buffer, without to fetch it.
... ...
@@ -125,6 +125,14 @@ static void end_frame(AVFilterLink *inlink)
125 125
     }
126 126
 }
127 127
 
128
+void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size)
129
+{
130
+    AVFilterLink *inlink = ctx->inputs[0];
131
+
132
+    inlink->min_samples = inlink->max_samples =
133
+    inlink->partial_buf_size = frame_size;
134
+}
135
+
128 136
 int av_buffersink_get_buffer_ref(AVFilterContext *ctx,
129 137
                                   AVFilterBufferRef **bufref, int flags)
130 138
 {