Revision 9d9b9d32

View differences:

libavcodec/audioconvert.c
89 89
int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name)
90 90
{
91 91
    switch(nb_channels) {
92
    case 1: return CHANNEL_LAYOUT_MONO;
93
    case 2: return CHANNEL_LAYOUT_STEREO;
94
    case 3: return CHANNEL_LAYOUT_SURROUND;
95
    case 4: return CHANNEL_LAYOUT_QUAD;
96
    case 5: return CHANNEL_LAYOUT_5POINT0;
97
    case 6: return CHANNEL_LAYOUT_5POINT1;
98
    case 8: return CHANNEL_LAYOUT_7POINT1;
92
    case 1: return CH_LAYOUT_MONO;
93
    case 2: return CH_LAYOUT_STEREO;
94
    case 3: return CH_LAYOUT_SURROUND;
95
    case 4: return CH_LAYOUT_QUAD;
96
    case 5: return CH_LAYOUT_5POINT0;
97
    case 6: return CH_LAYOUT_5POINT1;
98
    case 8: return CH_LAYOUT_7POINT1;
99 99
    default: return 0;
100 100
    }
101 101
}
......
105 105
    int         nb_channels;
106 106
    int64_t     layout;
107 107
} const channel_layout_map[] = {
108
    { "mono",        1,  CHANNEL_LAYOUT_MONO },
109
    { "stereo",      2,  CHANNEL_LAYOUT_STEREO },
110
    { "surround",    3,  CHANNEL_LAYOUT_SURROUND },
111
    { "quad",        4,  CHANNEL_LAYOUT_QUAD },
112
    { "5.0",         5,  CHANNEL_LAYOUT_5POINT0 },
113
    { "5.1",         6,  CHANNEL_LAYOUT_5POINT1 },
114
    { "5.1+downmix", 8,  CHANNEL_LAYOUT_5POINT1|CHANNEL_LAYOUT_STEREO_DOWNMIX, },
115
    { "7.1",         8,  CHANNEL_LAYOUT_7POINT1 },
116
    { "7.1(wide)",   8,  CHANNEL_LAYOUT_7POINT1_WIDE },
117
    { "7.1+downmix", 10, CHANNEL_LAYOUT_7POINT1|CHANNEL_LAYOUT_STEREO_DOWNMIX, },
108
    { "mono",        1,  CH_LAYOUT_MONO },
109
    { "stereo",      2,  CH_LAYOUT_STEREO },
110
    { "surround",    3,  CH_LAYOUT_SURROUND },
111
    { "quad",        4,  CH_LAYOUT_QUAD },
112
    { "5.0",         5,  CH_LAYOUT_5POINT0 },
113
    { "5.1",         6,  CH_LAYOUT_5POINT1 },
114
    { "5.1+downmix", 8,  CH_LAYOUT_5POINT1|CH_LAYOUT_STEREO_DOWNMIX, },
115
    { "7.1",         8,  CH_LAYOUT_7POINT1 },
116
    { "7.1(wide)",   8,  CH_LAYOUT_7POINT1_WIDE },
117
    { "7.1+downmix", 10, CH_LAYOUT_7POINT1|CH_LAYOUT_STEREO_DOWNMIX, },
118 118
    { 0 }
119 119
};
120 120

  
libavcodec/avcodec.h
347 347
};
348 348

  
349 349
/* Audio channel masks */
350
#define CHANNEL_FRONT_LEFT             0x00000001
351
#define CHANNEL_FRONT_RIGHT            0x00000002
352
#define CHANNEL_FRONT_CENTER           0x00000004
353
#define CHANNEL_LOW_FREQUENCY          0x00000008
354
#define CHANNEL_BACK_LEFT              0x00000010
355
#define CHANNEL_BACK_RIGHT             0x00000020
356
#define CHANNEL_FRONT_LEFT_OF_CENTER   0x00000040
357
#define CHANNEL_FRONT_RIGHT_OF_CENTER  0x00000080
358
#define CHANNEL_BACK_CENTER            0x00000100
359
#define CHANNEL_SIDE_LEFT              0x00000200
360
#define CHANNEL_SIDE_RIGHT             0x00000400
361
#define CHANNEL_TOP_CENTER             0x00000800
362
#define CHANNEL_TOP_FRONT_LEFT         0x00001000
363
#define CHANNEL_TOP_FRONT_CENTER       0x00002000
364
#define CHANNEL_TOP_FRONT_RIGHT        0x00004000
365
#define CHANNEL_TOP_BACK_LEFT          0x00008000
366
#define CHANNEL_TOP_BACK_CENTER        0x00010000
367
#define CHANNEL_TOP_BACK_RIGHT         0x00020000
368
#define CHANNEL_STEREO_LEFT            0x20000000  ///< Stereo downmix.
369
#define CHANNEL_STEREO_RIGHT           0x40000000  ///< See CHANNEL_STEREO_LEFT.
350
#define CH_FRONT_LEFT             0x00000001
351
#define CH_FRONT_RIGHT            0x00000002
352
#define CH_FRONT_CENTER           0x00000004
353
#define CH_LOW_FREQUENCY          0x00000008
354
#define CH_BACK_LEFT              0x00000010
355
#define CH_BACK_RIGHT             0x00000020
356
#define CH_FRONT_LEFT_OF_CENTER   0x00000040
357
#define CH_FRONT_RIGHT_OF_CENTER  0x00000080
358
#define CH_BACK_CENTER            0x00000100
359
#define CH_SIDE_LEFT              0x00000200
360
#define CH_SIDE_RIGHT             0x00000400
361
#define CH_TOP_CENTER             0x00000800
362
#define CH_TOP_FRONT_LEFT         0x00001000
363
#define CH_TOP_FRONT_CENTER       0x00002000
364
#define CH_TOP_FRONT_RIGHT        0x00004000
365
#define CH_TOP_BACK_LEFT          0x00008000
366
#define CH_TOP_BACK_CENTER        0x00010000
367
#define CH_TOP_BACK_RIGHT         0x00020000
368
#define CH_STEREO_LEFT            0x20000000  ///< Stereo downmix.
369
#define CH_STEREO_RIGHT           0x40000000  ///< See CH_STEREO_LEFT.
370 370

  
371 371
/* Audio channel convenience macros */
372
#define CHANNEL_LAYOUT_MONO              (CHANNEL_FRONT_CENTER)
373
#define CHANNEL_LAYOUT_STEREO            (CHANNEL_FRONT_LEFT|CHANNEL_FRONT_RIGHT)
374
#define CHANNEL_LAYOUT_SURROUND          (CHANNEL_LAYOUT_STEREO|CHANNEL_FRONT_CENTER)
375
#define CHANNEL_LAYOUT_QUAD              (CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT)
376
#define CHANNEL_LAYOUT_5POINT0           (CHANNEL_LAYOUT_SURROUND|CHANNEL_SIDE_LEFT|CHANNEL_SIDE_RIGHT)
377
#define CHANNEL_LAYOUT_5POINT1           (CHANNEL_LAYOUT_5POINT0|CHANNEL_LOW_FREQUENCY)
378
#define CHANNEL_LAYOUT_7POINT1           (CHANNEL_LAYOUT_5POINT1|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT)
379
#define CHANNEL_LAYOUT_7POINT1_WIDE      (CHANNEL_LAYOUT_SURROUND|CHANNEL_LOW_FREQUENCY|\
380
                                          CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT|\
381
                                          CHANNEL_FRONT_LEFT_OF_CENTER|CHANNEL_FRONT_RIGHT_OF_CENTER)
382
#define CHANNEL_LAYOUT_STEREO_DOWNMIX    (CHANNEL_STEREO_LEFT|CHANNEL_STEREO_RIGHT)
372
#define CH_LAYOUT_MONO              (CH_FRONT_CENTER)
373
#define CH_LAYOUT_STEREO            (CH_FRONT_LEFT|CH_FRONT_RIGHT)
374
#define CH_LAYOUT_SURROUND          (CH_LAYOUT_STEREO|CH_FRONT_CENTER)
375
#define CH_LAYOUT_QUAD              (CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT)
376
#define CH_LAYOUT_5POINT0           (CH_LAYOUT_SURROUND|CH_SIDE_LEFT|CH_SIDE_RIGHT)
377
#define CH_LAYOUT_5POINT1           (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY)
378
#define CH_LAYOUT_7POINT1           (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT)
379
#define CH_LAYOUT_7POINT1_WIDE      (CH_LAYOUT_SURROUND|CH_LOW_FREQUENCY|\
380
                                          CH_BACK_LEFT|CH_BACK_RIGHT|\
381
                                          CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER)
382
#define CH_LAYOUT_STEREO_DOWNMIX    (CH_STEREO_LEFT|CH_STEREO_RIGHT)
383 383

  
384 384
/* in bytes */
385 385
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
libavcodec/dca.c
66 66
 * L = left, R = right, C = center, S = surround, F = front, R = rear, T = total, OV = overhead.
67 67
 * S  -> back, when both rear and back are configured move one of them to the side channel
68 68
 * OV -> center back
69
 * All 2 channel configurations -> CHANNEL_LAYOUT_STEREO
69
 * All 2 channel configurations -> CH_LAYOUT_STEREO
70 70
 */
71 71

  
72 72
static const int64_t dca_core_channel_layout[] = {
73
    CHANNEL_FRONT_CENTER,                                               ///< 1, A
74
    CHANNEL_LAYOUT_STEREO,                                              ///< 2, A + B (dual mono)
75
    CHANNEL_LAYOUT_STEREO,                                              ///< 2, L + R (stereo)
76
    CHANNEL_LAYOUT_STEREO,                                              ///< 2, (L+R) + (L-R) (sum-difference)
77
    CHANNEL_LAYOUT_STEREO,                                              ///< 2, LT +RT (left and right total)
78
    CHANNEL_LAYOUT_STEREO|CHANNEL_FRONT_CENTER,                         ///< 3, C+L+R
79
    CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_CENTER,                          ///< 3, L+R+S
80
    CHANNEL_LAYOUT_STEREO|CHANNEL_FRONT_CENTER|CHANNEL_BACK_CENTER,     ///< 4, C + L + R+ S
81
    CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT,         ///< 4, L + R+ SL+SR
82
    CHANNEL_LAYOUT_STEREO|CHANNEL_FRONT_CENTER|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT,                                       ///< 5, C + L + R+ SL+SR
83
    CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT|CHANNEL_FRONT_LEFT_OF_CENTER|CHANNEL_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR
84
    CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT|CHANNEL_FRONT_CENTER|CHANNEL_BACK_CENTER,                   ///< 6, C + L + R+ LR + RR + OV
85
    CHANNEL_FRONT_CENTER|CHANNEL_FRONT_RIGHT_OF_CENTER|CHANNEL_FRONT_LEFT_OF_CENTER|CHANNEL_BACK_CENTER|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT,  ///< 6, CF+ CR+LF+ RF+LR + RR
86
    CHANNEL_FRONT_LEFT_OF_CENTER|CHANNEL_FRONT_CENTER|CHANNEL_FRONT_RIGHT_OF_CENTER|CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT, ///< 7, CL + C + CR + L + R + SL + SR
87
    CHANNEL_FRONT_LEFT_OF_CENTER|CHANNEL_FRONT_RIGHT_OF_CENTER|CHANNEL_LAYOUT_STEREO|CHANNEL_SIDE_LEFT|CHANNEL_SIDE_RIGHT|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT, ///< 8, CL + CR + L + R + SL1 + SL2+ SR1 + SR2
88
    CHANNEL_FRONT_LEFT_OF_CENTER|CHANNEL_FRONT_CENTER|CHANNEL_FRONT_RIGHT_OF_CENTER|CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_LEFT|CHANNEL_BACK_CENTER|CHANNEL_BACK_RIGHT, ///< 8, CL + C+ CR + L + R + SL + S+ SR
73
    CH_FRONT_CENTER,                                               ///< 1, A
74
    CH_LAYOUT_STEREO,                                              ///< 2, A + B (dual mono)
75
    CH_LAYOUT_STEREO,                                              ///< 2, L + R (stereo)
76
    CH_LAYOUT_STEREO,                                              ///< 2, (L+R) + (L-R) (sum-difference)
77
    CH_LAYOUT_STEREO,                                              ///< 2, LT +RT (left and right total)
78
    CH_LAYOUT_STEREO|CH_FRONT_CENTER,                         ///< 3, C+L+R
79
    CH_LAYOUT_STEREO|CH_BACK_CENTER,                          ///< 3, L+R+S
80
    CH_LAYOUT_STEREO|CH_FRONT_CENTER|CH_BACK_CENTER,     ///< 4, C + L + R+ S
81
    CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT,         ///< 4, L + R+ SL+SR
82
    CH_LAYOUT_STEREO|CH_FRONT_CENTER|CH_BACK_LEFT|CH_BACK_RIGHT,                                       ///< 5, C + L + R+ SL+SR
83
    CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT|CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR
84
    CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT|CH_FRONT_CENTER|CH_BACK_CENTER,                   ///< 6, C + L + R+ LR + RR + OV
85
    CH_FRONT_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_FRONT_LEFT_OF_CENTER|CH_BACK_CENTER|CH_BACK_LEFT|CH_BACK_RIGHT,  ///< 6, CF+ CR+LF+ RF+LR + RR
86
    CH_FRONT_LEFT_OF_CENTER|CH_FRONT_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT, ///< 7, CL + C + CR + L + R + SL + SR
87
    CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT|CH_BACK_LEFT|CH_BACK_RIGHT, ///< 8, CL + CR + L + R + SL1 + SL2+ SR1 + SR2
88
    CH_FRONT_LEFT_OF_CENTER|CH_FRONT_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_CENTER|CH_BACK_RIGHT, ///< 8, CL + C+ CR + L + R + SL + S+ SR
89 89

  
90 90
    /* The following entries adds the LFE layouts, this way we can reuse the table for the AVCodec channel_layouts member*/
91
    CHANNEL_FRONT_CENTER|CHANNEL_LOW_FREQUENCY,
92
    CHANNEL_LAYOUT_STEREO|CHANNEL_LOW_FREQUENCY,
93
    CHANNEL_LAYOUT_STEREO|CHANNEL_FRONT_CENTER|CHANNEL_LOW_FREQUENCY,
94
    CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_CENTER|CHANNEL_LOW_FREQUENCY,
95
    CHANNEL_LAYOUT_STEREO|CHANNEL_FRONT_CENTER|CHANNEL_BACK_CENTER|CHANNEL_LOW_FREQUENCY,
96
    CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT|CHANNEL_LOW_FREQUENCY,
97
    CHANNEL_LAYOUT_STEREO|CHANNEL_FRONT_CENTER|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT|CHANNEL_LOW_FREQUENCY,
98
    CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT|CHANNEL_FRONT_LEFT_OF_CENTER|CHANNEL_FRONT_RIGHT_OF_CENTER|CHANNEL_LOW_FREQUENCY,
99
    CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT|CHANNEL_FRONT_CENTER|CHANNEL_BACK_CENTER|CHANNEL_LOW_FREQUENCY,
100
    CHANNEL_FRONT_CENTER|CHANNEL_FRONT_RIGHT_OF_CENTER|CHANNEL_FRONT_LEFT_OF_CENTER|CHANNEL_BACK_CENTER|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT|CHANNEL_LOW_FREQUENCY,
101
    CHANNEL_FRONT_LEFT_OF_CENTER|CHANNEL_FRONT_CENTER|CHANNEL_FRONT_RIGHT_OF_CENTER|CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT|CHANNEL_LOW_FREQUENCY,
102
    CHANNEL_FRONT_LEFT_OF_CENTER|CHANNEL_FRONT_RIGHT_OF_CENTER|CHANNEL_LAYOUT_STEREO|CHANNEL_SIDE_LEFT|CHANNEL_SIDE_RIGHT|CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT|CHANNEL_LOW_FREQUENCY,
103
    CHANNEL_FRONT_LEFT_OF_CENTER|CHANNEL_FRONT_CENTER|CHANNEL_FRONT_RIGHT_OF_CENTER|CHANNEL_LAYOUT_STEREO|CHANNEL_BACK_LEFT|CHANNEL_BACK_CENTER|CHANNEL_BACK_RIGHT|CHANNEL_LOW_FREQUENCY,
91
    CH_FRONT_CENTER|CH_LOW_FREQUENCY,
92
    CH_LAYOUT_STEREO|CH_LOW_FREQUENCY,
93
    CH_LAYOUT_STEREO|CH_FRONT_CENTER|CH_LOW_FREQUENCY,
94
    CH_LAYOUT_STEREO|CH_BACK_CENTER|CH_LOW_FREQUENCY,
95
    CH_LAYOUT_STEREO|CH_FRONT_CENTER|CH_BACK_CENTER|CH_LOW_FREQUENCY,
96
    CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT|CH_LOW_FREQUENCY,
97
    CH_LAYOUT_STEREO|CH_FRONT_CENTER|CH_BACK_LEFT|CH_BACK_RIGHT|CH_LOW_FREQUENCY,
98
    CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT|CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_LOW_FREQUENCY,
99
    CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT|CH_FRONT_CENTER|CH_BACK_CENTER|CH_LOW_FREQUENCY,
100
    CH_FRONT_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_FRONT_LEFT_OF_CENTER|CH_BACK_CENTER|CH_BACK_LEFT|CH_BACK_RIGHT|CH_LOW_FREQUENCY,
101
    CH_FRONT_LEFT_OF_CENTER|CH_FRONT_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT|CH_LOW_FREQUENCY,
102
    CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT|CH_BACK_LEFT|CH_BACK_RIGHT|CH_LOW_FREQUENCY,
103
    CH_FRONT_LEFT_OF_CENTER|CH_FRONT_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_CENTER|CH_BACK_RIGHT|CH_LOW_FREQUENCY,
104 104
    0,
105 105
};
106 106

  
......
1211 1211
    if(avctx->request_channels == 2 && s->prim_channels > 2) {
1212 1212
        channels = 2;
1213 1213
        s->output = DCA_STEREO;
1214
        avctx->channel_layout = CHANNEL_LAYOUT_STEREO;
1214
        avctx->channel_layout = CH_LAYOUT_STEREO;
1215 1215
    }
1216 1216
    if (s->amode<16)
1217 1217
        avctx->channel_layout = dca_core_channel_layout[s->amode];
1218 1218

  
1219
    if (s->lfe) avctx->channel_layout |= CHANNEL_LOW_FREQUENCY;
1219
    if (s->lfe) avctx->channel_layout |= CH_LOW_FREQUENCY;
1220 1220

  
1221 1221
    /* There is nothing that prevents a dts frame to change channel configuration
1222 1222
       but FFmpeg doesn't support that so only set the channels if it is previously

Also available in: Unified diff