Browse code

lavfi: remove some audio-related function from public API.

Those functions are only useful inside filters. It is better to not
support user filters until the API is more stable.

This breaks audio filtering API and ABI in theory, but since it's
unusable right now this shouldn't be a problem.

Anton Khirnov authored on 2012/05/07 17:51:23
Showing 5 changed files
... ...
@@ -21,6 +21,7 @@
21 21
  * null audio filter
22 22
  */
23 23
 
24
+#include "audio.h"
24 25
 #include "avfilter.h"
25 26
 
26 27
 AVFilter avfilter_af_anull = {
... ...
@@ -31,8 +32,8 @@ AVFilter avfilter_af_anull = {
31 31
 
32 32
     .inputs    = (AVFilterPad[]) {{ .name             = "default",
33 33
                                     .type             = AVMEDIA_TYPE_AUDIO,
34
-                                    .get_audio_buffer = avfilter_null_get_audio_buffer,
35
-                                    .filter_samples   = avfilter_null_filter_samples },
34
+                                    .get_audio_buffer = ff_null_get_audio_buffer,
35
+                                    .filter_samples   = ff_null_filter_samples },
36 36
                                   { .name = NULL}},
37 37
 
38 38
     .outputs   = (AVFilterPad[]) {{ .name             = "default",
39 39
new file mode 100644
... ...
@@ -0,0 +1,61 @@
0
+/*
1
+ * This file is part of Libav.
2
+ *
3
+ * Libav is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * Libav is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with Libav; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#ifndef AVFILTER_AUDIO_H
19
+#define AVFILTER_AUDIO_H
20
+
21
+#include "avfilter.h"
22
+
23
+/** default handler for get_audio_buffer() for audio inputs */
24
+AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms,
25
+                                                     int nb_samples);
26
+
27
+/** get_audio_buffer() handler for filters which simply pass audio along */
28
+AVFilterBufferRef *ff_null_get_audio_buffer(AVFilterLink *link, int perms,
29
+                                                  int nb_samples);
30
+
31
+/**
32
+ * Request an audio samples buffer with a specific set of permissions.
33
+ *
34
+ * @param link           the output link to the filter from which the buffer will
35
+ *                       be requested
36
+ * @param perms          the required access permissions
37
+ * @param nb_samples     the number of samples per channel
38
+ * @return               A reference to the samples. This must be unreferenced with
39
+ *                       avfilter_unref_buffer when you are finished with it.
40
+ */
41
+AVFilterBufferRef *ff_get_audio_buffer(AVFilterLink *link, int perms,
42
+                                             int nb_samples);
43
+
44
+/** default handler for filter_samples() for audio inputs */
45
+void ff_default_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
46
+
47
+/** filter_samples() handler for filters which simply pass audio along */
48
+void ff_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
49
+
50
+/**
51
+ * Send a buffer of audio samples to the next filter.
52
+ *
53
+ * @param link       the output link over which the audio samples are being sent
54
+ * @param samplesref a reference to the buffer of audio samples being sent. The
55
+ *                   receiving filter will free this reference when it no longer
56
+ *                   needs it or pass it on to the next filter.
57
+ */
58
+void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
59
+
60
+#endif /* AVFILTER_AUDIO_H */
... ...
@@ -26,6 +26,8 @@
26 26
 #include "libavutil/audioconvert.h"
27 27
 #include "libavutil/imgutils.h"
28 28
 #include "libavcodec/avcodec.h"
29
+
30
+#include "audio.h"
29 31
 #include "avfilter.h"
30 32
 #include "internal.h"
31 33
 
... ...
@@ -366,8 +368,8 @@ fail:
366 366
     return NULL;
367 367
 }
368 368
 
369
-AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
370
-                                             int nb_samples)
369
+AVFilterBufferRef *ff_get_audio_buffer(AVFilterLink *link, int perms,
370
+                                       int nb_samples)
371 371
 {
372 372
     AVFilterBufferRef *ret = NULL;
373 373
 
... ...
@@ -375,7 +377,7 @@ AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
375 375
         ret = link->dstpad->get_audio_buffer(link, perms, nb_samples);
376 376
 
377 377
     if (!ret)
378
-        ret = avfilter_default_get_audio_buffer(link, perms, nb_samples);
378
+        ret = ff_default_get_audio_buffer(link, perms, nb_samples);
379 379
 
380 380
     if (ret)
381 381
         ret->type = AVMEDIA_TYPE_AUDIO;
... ...
@@ -570,7 +572,7 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
570 570
     draw_slice(link, y, h, slice_dir);
571 571
 }
572 572
 
573
-void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
573
+void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
574 574
 {
575 575
     void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *);
576 576
     AVFilterPad *dst = link->dstpad;
... ...
@@ -578,7 +580,7 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
578 578
     FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1);
579 579
 
580 580
     if (!(filter_samples = dst->filter_samples))
581
-        filter_samples = avfilter_default_filter_samples;
581
+        filter_samples = ff_default_filter_samples;
582 582
 
583 583
     /* prepare to copy the samples if the buffer has insufficient permissions */
584 584
     if ((dst->min_perms & samplesref->perms) != dst->min_perms ||
... ...
@@ -591,8 +593,8 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
591 591
                "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n",
592 592
                samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms);
593 593
 
594
-        link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms,
595
-                                                          samplesref->audio->nb_samples);
594
+        link->cur_buf = ff_default_get_audio_buffer(link, dst->min_perms,
595
+                                                    samplesref->audio->nb_samples);
596 596
         link->cur_buf->pts                = samplesref->pts;
597 597
         link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate;
598 598
 
... ...
@@ -460,9 +460,6 @@ void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir
460 460
 /** default handler for end_frame() for video inputs */
461 461
 void avfilter_default_end_frame(AVFilterLink *link);
462 462
 
463
-/** default handler for filter_samples() for audio inputs */
464
-void avfilter_default_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
465
-
466 463
 /** default handler for config_props() for audio/video outputs */
467 464
 int avfilter_default_config_output_link(AVFilterLink *link);
468 465
 
... ...
@@ -470,10 +467,6 @@ int avfilter_default_config_output_link(AVFilterLink *link);
470 470
 AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
471 471
                                                      int perms, int w, int h);
472 472
 
473
-/** default handler for get_audio_buffer() for audio inputs */
474
-AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
475
-                                                     int nb_samples);
476
-
477 473
 /**
478 474
  * A helper for query_formats() which sets all links to the same list of
479 475
  * formats. If there are no links hooked to this filter, the list of formats is
... ...
@@ -493,17 +486,10 @@ void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
493 493
 /** end_frame() handler for filters which simply pass video along */
494 494
 void avfilter_null_end_frame(AVFilterLink *link);
495 495
 
496
-/** filter_samples() handler for filters which simply pass audio along */
497
-void avfilter_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
498
-
499 496
 /** get_video_buffer() handler for filters which simply pass video along */
500 497
 AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link,
501 498
                                                   int perms, int w, int h);
502 499
 
503
-/** get_audio_buffer() handler for filters which simply pass audio along */
504
-AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms,
505
-                                                  int nb_samples);
506
-
507 500
 /**
508 501
  * Filter definition. This defines the pads a filter contains, and all the
509 502
  * callback functions used to interact with the filter.
... ...
@@ -684,19 +670,6 @@ avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int
684 684
                                           int w, int h, enum PixelFormat format);
685 685
 
686 686
 /**
687
- * Request an audio samples buffer with a specific set of permissions.
688
- *
689
- * @param link           the output link to the filter from which the buffer will
690
- *                       be requested
691
- * @param perms          the required access permissions
692
- * @param nb_samples     the number of samples per channel
693
- * @return               A reference to the samples. This must be unreferenced with
694
- *                       avfilter_unref_buffer when you are finished with it.
695
- */
696
-AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
697
-                                             int nb_samples);
698
-
699
-/**
700 687
  * Create an audio buffer reference wrapped around an already
701 688
  * allocated samples buffer.
702 689
  *
... ...
@@ -766,16 +739,6 @@ void avfilter_end_frame(AVFilterLink *link);
766 766
  */
767 767
 void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
768 768
 
769
-/**
770
- * Send a buffer of audio samples to the next filter.
771
- *
772
- * @param link       the output link over which the audio samples are being sent
773
- * @param samplesref a reference to the buffer of audio samples being sent. The
774
- *                   receiving filter will free this reference when it no longer
775
- *                   needs it or pass it on to the next filter.
776
- */
777
-void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
778
-
779 769
 /** Initialize the filter system. Register all builtin filters. */
780 770
 void avfilter_register_all(void);
781 771
 
... ...
@@ -22,6 +22,8 @@
22 22
 #include "libavutil/audioconvert.h"
23 23
 #include "libavutil/imgutils.h"
24 24
 #include "libavutil/samplefmt.h"
25
+
26
+#include "audio.h"
25 27
 #include "avfilter.h"
26 28
 #include "internal.h"
27 29
 
... ...
@@ -57,8 +59,8 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per
57 57
     return picref;
58 58
 }
59 59
 
60
-AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
61
-                                                     int nb_samples)
60
+AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms,
61
+                                               int nb_samples)
62 62
 {
63 63
     AVFilterBufferRef *samplesref = NULL;
64 64
     uint8_t **data;
... ...
@@ -133,7 +135,7 @@ void avfilter_default_end_frame(AVFilterLink *inlink)
133 133
 }
134 134
 
135 135
 /* FIXME: samplesref is same as link->cur_buf. Need to consider removing the redundant parameter. */
136
-void avfilter_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
136
+void ff_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
137 137
 {
138 138
     AVFilterLink *outlink = NULL;
139 139
 
... ...
@@ -141,11 +143,11 @@ void avfilter_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *sa
141 141
         outlink = inlink->dst->outputs[0];
142 142
 
143 143
     if (outlink) {
144
-        outlink->out_buf = avfilter_default_get_audio_buffer(inlink, AV_PERM_WRITE,
145
-                                                             samplesref->audio->nb_samples);
144
+        outlink->out_buf = ff_default_get_audio_buffer(inlink, AV_PERM_WRITE,
145
+                                                       samplesref->audio->nb_samples);
146 146
         outlink->out_buf->pts                = samplesref->pts;
147 147
         outlink->out_buf->audio->sample_rate = samplesref->audio->sample_rate;
148
-        avfilter_filter_samples(outlink, avfilter_ref_buffer(outlink->out_buf, ~0));
148
+        ff_filter_samples(outlink, avfilter_ref_buffer(outlink->out_buf, ~0));
149 149
         avfilter_unref_buffer(outlink->out_buf);
150 150
         outlink->out_buf = NULL;
151 151
     }
... ...
@@ -233,9 +235,9 @@ void avfilter_null_end_frame(AVFilterLink *link)
233 233
     avfilter_end_frame(link->dst->outputs[0]);
234 234
 }
235 235
 
236
-void avfilter_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
236
+void ff_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
237 237
 {
238
-    avfilter_filter_samples(link->dst->outputs[0], samplesref);
238
+    ff_filter_samples(link->dst->outputs[0], samplesref);
239 239
 }
240 240
 
241 241
 AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
... ...
@@ -243,8 +245,8 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms,
243 243
     return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h);
244 244
 }
245 245
 
246
-AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms,
247
-                                                  int nb_samples)
246
+AVFilterBufferRef *ff_null_get_audio_buffer(AVFilterLink *link, int perms,
247
+                                            int nb_samples)
248 248
 {
249
-    return avfilter_get_audio_buffer(link->dst->outputs[0], perms, nb_samples);
249
+    return ff_get_audio_buffer(link->dst->outputs[0], perms, nb_samples);
250 250
 }