]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/aacdec.c
v210enc: Add SIMD optimised 8-bit and 10-bit encoders
[ffmpeg] / libavcodec / aacdec.c
index e25838fca06ad523d94b10a108e7e89c73223904..9c0a46d0d5e6f08761c6b52fbd2edea20c41af93 100644 (file)
@@ -143,8 +143,6 @@ static av_cold int che_configure(AACContext *ac,
                                  enum ChannelPosition che_pos,
                                  int type, int id, int *channels)
 {
-    if (*channels >= MAX_CHANNELS)
-        return AVERROR_INVALIDDATA;
     if (che_pos) {
         if (!ac->che[type][id]) {
             if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
@@ -152,6 +150,8 @@ static av_cold int che_configure(AACContext *ac,
             ff_aac_sbr_ctx_init(ac, &ac->che[type][id]->sbr);
         }
         if (type != TYPE_CCE) {
+            if (*channels >= MAX_CHANNELS - 2)
+                return AVERROR_INVALIDDATA;
             ac->output_element[(*channels)++] = &ac->che[type][id]->ch[0];
             if (type == TYPE_CPE ||
                 (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1)) {
@@ -624,6 +624,9 @@ static void decode_channel_map(uint8_t layout_map[][3],
         case AAC_CHANNEL_LFE:
             syn_ele = TYPE_LFE;
             break;
+        default:
+            // AAC_CHANNEL_OFF has no channel map
+            return;
         }
         layout_map[0][0] = syn_ele;
         layout_map[0][1] = get_bits(gb, 4);
@@ -1416,13 +1419,12 @@ static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb,
                                    int ms_present)
 {
     int idx;
+    int max_idx = cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb;
     if (ms_present == 1) {
-        for (idx = 0;
-             idx < cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb;
-             idx++)
+        for (idx = 0; idx < max_idx; idx++)
             cpe->ms_mask[idx] = get_bits1(gb);
     } else if (ms_present == 2) {
-        memset(cpe->ms_mask, 1, cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb * sizeof(cpe->ms_mask[0]));
+        memset(cpe->ms_mask, 1, max_idx * sizeof(cpe->ms_mask[0]));
     }
 }
 
@@ -2529,7 +2531,7 @@ static void apply_dependent_coupling(AACContext *ac,
                 const float gain = cce->coup.gain[index][idx];
                 for (group = 0; group < ics->group_len[g]; group++) {
                     for (k = offsets[i]; k < offsets[i + 1]; k++) {
-                        // XXX dsputil-ize
+                        // FIXME: SIMDify
                         dest[group * 128 + k] += gain * src[group * 128 + k];
                     }
                 }