Browse code

lavfi: add audio channel packing negotiation fields

Signed-off-by: Stefano Sabatini <stefano.sabatini-lala@poste.it>

Mina Nagy Zaki authored on 2011/06/28 14:56:19
Showing 6 changed files
... ...
@@ -13,6 +13,14 @@ libavutil:   2011-04-18
13 13
 
14 14
 API changes, most recent first:
15 15
 
16
+2011-07-16 - xxxxxx - lavfi 2.27.0
17
+  Add audio packing negotiation fields and helper functions.
18
+
19
+  In particular, add AVFilterPacking enum, planar, in_packings and
20
+  out_packings fields to AVFilterLink, and the functions:
21
+  avfilter_set_common_packing_formats()
22
+  avfilter_all_packing_formats()
23
+
16 24
 2011-07-10 - a67c061 - lavf 53.3.0
17 25
   Add avformat_find_stream_info(), deprecate av_find_stream_info().
18 26
 
... ...
@@ -221,6 +221,9 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
221 221
     if (link->out_chlayouts)
222 222
         avfilter_formats_changeref(&link->out_chlayouts,
223 223
                                    &filt->outputs[filt_dstpad_idx]->out_chlayouts);
224
+    if (link->out_packing)
225
+        avfilter_formats_changeref(&link->out_packing,
226
+                                   &filt->outputs[filt_dstpad_idx]->out_packing);
224 227
 
225 228
     return 0;
226 229
 }
... ...
@@ -29,7 +29,7 @@
29 29
 #include "libavutil/rational.h"
30 30
 
31 31
 #define LIBAVFILTER_VERSION_MAJOR  2
32
-#define LIBAVFILTER_VERSION_MINOR 26
32
+#define LIBAVFILTER_VERSION_MINOR 27
33 33
 #define LIBAVFILTER_VERSION_MICRO  0
34 34
 
35 35
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
... ...
@@ -265,6 +265,11 @@ AVFilterFormats *avfilter_all_formats(enum AVMediaType type);
265 265
 AVFilterFormats *avfilter_all_channel_layouts(void);
266 266
 
267 267
 /**
268
+ * Return a list of all audio packing formats.
269
+ */
270
+AVFilterFormats *avfilter_all_packing_formats(void);
271
+
272
+/**
268 273
  * Return a format list which contains the intersection of the formats of
269 274
  * a and b. Also, all the references of a, all the references of b, and
270 275
  * a and b themselves will be deallocated.
... ...
@@ -482,6 +487,7 @@ AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int per
482 482
 void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats);
483 483
 void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats);
484 484
 void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats);
485
+void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats);
485 486
 
486 487
 /** Default handler for query_formats() */
487 488
 int avfilter_default_query_formats(AVFilterContext *ctx);
... ...
@@ -570,6 +576,11 @@ struct AVFilterContext {
570 570
     void *priv;                     ///< private data for use by the filter
571 571
 };
572 572
 
573
+enum AVFilterPacking {
574
+    AVFILTER_PACKED = 0,
575
+    AVFILTER_PLANAR,
576
+};
577
+
573 578
 /**
574 579
  * A link between two filters. This contains pointers to the source and
575 580
  * destination filters between which this link exists, and the indexes of
... ...
@@ -597,9 +608,10 @@ struct AVFilterLink {
597 597
     int w;                      ///< agreed upon image width
598 598
     int h;                      ///< agreed upon image height
599 599
     AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
600
-    /* These two parameters apply only to audio */
600
+    /* These parameters apply only to audio */
601 601
     int64_t channel_layout;     ///< channel layout of current buffer (see libavutil/audioconvert.h)
602 602
     int64_t sample_rate;        ///< samples per second
603
+    int planar;                 ///< agreed upon packing mode of audio buffers. true if planar.
603 604
 
604 605
     int format;                 ///< agreed upon media format
605 606
 
... ...
@@ -615,6 +627,8 @@ struct AVFilterLink {
615 615
 
616 616
     AVFilterFormats *in_chlayouts;
617 617
     AVFilterFormats *out_chlayouts;
618
+    AVFilterFormats *in_packing;
619
+    AVFilterFormats *out_packing;
618 620
 
619 621
     /**
620 622
      * The buffer reference currently being sent across the link by the source
... ...
@@ -203,8 +203,12 @@ static void pick_format(AVFilterLink *link)
203 203
         link->channel_layout = link->in_chlayouts->formats[0];
204 204
         avfilter_formats_unref(&link->in_chlayouts);
205 205
         avfilter_formats_unref(&link->out_chlayouts);
206
-    }
207 206
 
207
+        link->in_packing->format_count = 1;
208
+        link->planar = link->in_packing->formats[0] == AVFILTER_PLANAR;
209
+        avfilter_formats_unref(&link->in_packing);
210
+        avfilter_formats_unref(&link->out_packing);
211
+    }
208 212
 }
209 213
 
210 214
 static void pick_formats(AVFilterGraph *graph)
... ...
@@ -239,11 +239,19 @@ void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *
239 239
                        offsetof(AVFilterLink, out_chlayouts));
240 240
 }
241 241
 
242
+void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats)
243
+{
244
+    set_common_formats(ctx, formats, AVMEDIA_TYPE_AUDIO,
245
+                       offsetof(AVFilterLink, in_packing),
246
+                       offsetof(AVFilterLink, out_packing));
247
+}
248
+
242 249
 int avfilter_default_query_formats(AVFilterContext *ctx)
243 250
 {
244 251
     avfilter_set_common_pixel_formats(ctx, avfilter_all_formats(AVMEDIA_TYPE_VIDEO));
245 252
     avfilter_set_common_sample_formats(ctx, avfilter_all_formats(AVMEDIA_TYPE_AUDIO));
246 253
     avfilter_set_common_channel_layouts(ctx, avfilter_all_channel_layouts());
254
+    avfilter_set_common_packing_formats(ctx, avfilter_all_packing_formats());
247 255
 
248 256
     return 0;
249 257
 }
... ...
@@ -173,6 +173,17 @@ AVFilterFormats *avfilter_all_channel_layouts(void)
173 173
     return avfilter_make_format64_list(chlayouts);
174 174
 }
175 175
 
176
+AVFilterFormats *avfilter_all_packing_formats(void)
177
+{
178
+    static int packing[] = {
179
+        AVFILTER_PACKED,
180
+        AVFILTER_PLANAR,
181
+        -1,
182
+    };
183
+
184
+    return avfilter_make_format_list(packing);
185
+}
186
+
176 187
 void avfilter_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
177 188
 {
178 189
     *ref = f;