Add audio channel layout API to libavcodec.
[ffmpeg.git] / libavcodec / avcodec.h
index 3be9402..cf6385f 100644 (file)
@@ -30,7 +30,7 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 52
-#define LIBAVCODEC_VERSION_MINOR  1
+#define LIBAVCODEC_VERSION_MINOR  2
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -346,6 +346,41 @@ enum SampleFormat {
     SAMPLE_FMT_NB               ///< Number of sample formats. DO NOT USE if dynamically linking to libavcodec
 };
 
+/* Audio channel masks */
+#define CHANNEL_FRONT_LEFT             0x00000001
+#define CHANNEL_FRONT_RIGHT            0x00000002
+#define CHANNEL_FRONT_CENTER           0x00000004
+#define CHANNEL_LOW_FREQUENCY          0x00000008
+#define CHANNEL_BACK_LEFT              0x00000010
+#define CHANNEL_BACK_RIGHT             0x00000020
+#define CHANNEL_FRONT_LEFT_OF_CENTER   0x00000040
+#define CHANNEL_FRONT_RIGHT_OF_CENTER  0x00000080
+#define CHANNEL_BACK_CENTER            0x00000100
+#define CHANNEL_SIDE_LEFT              0x00000200
+#define CHANNEL_SIDE_RIGHT             0x00000400
+#define CHANNEL_TOP_CENTER             0x00000800
+#define CHANNEL_TOP_FRONT_LEFT         0x00001000
+#define CHANNEL_TOP_FRONT_CENTER       0x00002000
+#define CHANNEL_TOP_FRONT_RIGHT        0x00004000
+#define CHANNEL_TOP_BACK_LEFT          0x00008000
+#define CHANNEL_TOP_BACK_CENTER        0x00010000
+#define CHANNEL_TOP_BACK_RIGHT         0x00020000
+#define CHANNEL_STEREO_LEFT            0x20000000  ///< Stereo downmix.
+#define CHANNEL_STEREO_RIGHT           0x40000000  ///< See CHANNEL_STEREO_LEFT.
+
+/* Audio channel convenience macros */
+#define CHANNEL_LAYOUT_MONO              (CHANNEL_FRONT_CENTER)
+#define CHANNEL_LAYOUT_STEREO            (CHANNEL_FRONT_LEFT|CHANNEL_FRONT_RIGHT)
+#define CHANNEL_LAYOUT_SURROUND          (CHANNEL_LAYOUT_STEREO|CHANNEL_FRONT_CENTER)
+#define CHANNEL_LAYOUT_QUAD              (CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT)
+#define CHANNEL_LAYOUT_5POINT0           (CHANNEL_LAYOUT_SURROUND|CHANNEL_SIDE_LEFT|CHANNEL_SIDE_RIGHT)
+#define CHANNEL_LAYOUT_5POINT1           (CHANNEL_LAYOUT_5POINT0|CHANNEL_LOW_FREQUENCY)
+#define CHANNEL_LAYOUT_7POINT1           (CHANNEL_LAYOUT_5POINT1|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT)
+#define CHANNEL_LAYOUT_7POINT1_WIDE      (CHANNEL_LAYOUT_SURROUND|CHANNEL_LOW_FREQUENCY|\
+                                          CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT|\
+                                          CHANNEL_FRONT_LEFT_OF_CENTER|CHANNEL_FRONT_RIGHT_OF_CENTER)
+#define CHANNEL_LAYOUT_STEREO_DOWNMIX    (CHANNEL_STEREO_LEFT|CHANNEL_STEREO_RIGHT)
+
 /* in bytes */
 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
 
@@ -2198,12 +2233,15 @@ typedef struct AVCodecContext {
      */
     int64_t timecode_frame_start;
 
+#if LIBAVCODEC_VERSION_MAJOR < 53
     /**
      * Decoder should decode to this many channels if it can (0 for default)
      * - encoding: unused
      * - decoding: Set by user.
+     * @deprecated Deprecated in favor of request_channel_layout.
      */
     int request_channels;
+#endif
 
     /**
      * Percentage of dynamic range compression to be applied by the decoder.
@@ -2228,6 +2266,20 @@ typedef struct AVCodecContext {
      * - decoding: set by libavcodec.
      */
     int bits_per_raw_sample;
+
+    /**
+     * Audio channel layout.
+     * - encoding: set by user.
+     * - decoding: set by libavcodec.
+     */
+    int64_t channel_layout;
+
+    /**
+     * Request decoder to use this channel layout if it can (0 for default)
+     * - encoding: unused
+     * - decoding: Set by user.
+     */
+    int64_t request_channel_layout;
 } AVCodecContext;
 
 /**
@@ -2269,6 +2321,7 @@ typedef struct AVCodec {
     const char *long_name;
     const int *supported_samplerates;       ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
     const enum SampleFormat *sample_fmts;   ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
+    const int64_t *channel_layouts;         ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
 } AVCodec;
 
 /**