Revision a7c6e117

View differences:

libavcodec/ac3enc.c
36 36
    int nb_channels;
37 37
    int nb_all_channels;
38 38
    int lfe_channel;
39
    const uint8_t *channel_map;
39 40
    int bit_rate;
40 41
    unsigned int sample_rate;
41 42
    unsigned int bitstream_id;
......
638 639
    s->nb_all_channels = channels;
639 640
    s->nb_channels = channels > 5 ? 5 : channels;
640 641
    s->lfe_channel = s->lfe ? 5 : -1;
642
    s->channel_map = ff_ac3_enc_channel_map[s->channel_mode][s->lfe];
641 643

  
642 644
    /* frequency */
643 645
    for(i=0;i<3;i++) {
......
1158 1160

  
1159 1161
    frame_bits = 0;
1160 1162
    for(ch=0;ch<s->nb_all_channels;ch++) {
1163
        int ich = s->channel_map[ch];
1161 1164
        /* fixed mdct to the six sub blocks & exponent computation */
1162 1165
        for(i=0;i<NB_BLOCKS;i++) {
1163 1166
            int16_t *sptr;
1164 1167
            int sinc;
1165 1168

  
1166 1169
            /* compute input samples */
1167
            memcpy(input_samples, s->last_samples[ch], N/2 * sizeof(int16_t));
1170
            memcpy(input_samples, s->last_samples[ich], N/2 * sizeof(int16_t));
1168 1171
            sinc = s->nb_all_channels;
1169
            sptr = samples + (sinc * (N/2) * i) + ch;
1172
            sptr = samples + (sinc * (N/2) * i) + ich;
1170 1173
            for(j=0;j<N/2;j++) {
1171 1174
                v = *sptr;
1172 1175
                input_samples[j + N/2] = v;
1173
                s->last_samples[ch][j] = v;
1176
                s->last_samples[ich][j] = v;
1174 1177
                sptr += sinc;
1175 1178
            }
1176 1179

  
libavcodec/ac3tab.c
79 79
    2, 1, 2, 3, 3, 4, 4, 5
80 80
};
81 81

  
82
/**
83
 * Table to remap channels from SMPTE order to AC-3 order.
84
 * [channel_mode][lfe][ch]
85
 */
86
const uint8_t ff_ac3_enc_channel_map[8][2][6] = {
87
    { { 0, 1,          }, { 0, 1, 2,         } },
88
    { { 0,             }, { 0, 1,            } },
89
    { { 0, 1,          }, { 0, 1, 2,         } },
90
    { { 0, 2, 1,       }, { 0, 2, 1, 3,      } },
91
    { { 0, 1, 2,       }, { 0, 1, 3, 2,      } },
92
    { { 0, 2, 1, 3,    }, { 0, 2, 1, 4, 3,   } },
93
    { { 0, 1, 2, 3, 4, }, { 0, 1, 3, 4, 2,   } },
94
    { { 0, 2, 1, 3, 4, }, { 0, 2, 1, 4, 5, 3 } },
95
};
96

  
82 97
/* possible frequencies */
83 98
const uint16_t ff_ac3_sample_rate_tab[3] = { 48000, 44100, 32000 };
84 99

  
libavcodec/ac3tab.h
26 26

  
27 27
extern const uint16_t ff_ac3_frame_size_tab[38][3];
28 28
extern const uint8_t  ff_ac3_channels_tab[8];
29
extern const uint8_t  ff_ac3_enc_channel_map[8][2][6];
29 30
extern const uint16_t ff_ac3_sample_rate_tab[3];
30 31
extern const uint16_t ff_ac3_bitrate_tab[19];
31 32
extern const int16_t  ff_ac3_window[256];

Also available in: Unified diff