[Ffmpeg-cvslog] r6475 - trunk/libavcodec/vorbis_enc.c

ods15 subversion
Mon Oct 2 08:08:10 CEST 2006


Author: ods15
Date: Mon Oct  2 08:08:09 2006
New Revision: 6475

Modified:
   trunk/libavcodec/vorbis_enc.c

Log:
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines

channel coupling

Modified: trunk/libavcodec/vorbis_enc.c
==============================================================================
--- trunk/libavcodec/vorbis_enc.c	(original)
+++ trunk/libavcodec/vorbis_enc.c	Mon Oct  2 08:08:09 2006
@@ -92,6 +92,9 @@
     int * mux;
     int * floor;
     int * residue;
+    int coupling_steps;
+    int * magnitude;
+    int * angle;
 } mapping_t;
 
 typedef struct {
@@ -389,6 +392,13 @@
         mc->floor[i] = 0;
         mc->residue[i] = 0;
     }
+    mc->coupling_steps = venc->channels == 2 ? 1 : 0;
+    mc->magnitude = av_malloc(sizeof(int) * mc->coupling_steps);
+    mc->angle = av_malloc(sizeof(int) * mc->coupling_steps);
+    if (mc->coupling_steps) {
+        mc->magnitude[0] = 0;
+        mc->angle[0] = 1;
+    }
 
     venc->nmodes = 1;
     venc->modes = av_malloc(sizeof(vorbis_mode_t) * venc->nmodes);
@@ -602,7 +612,15 @@
         put_bits(&pb, 1, mc->submaps > 1);
         if (mc->submaps > 1) put_bits(&pb, 4, mc->submaps - 1);
 
-        put_bits(&pb, 1, 0); // channel coupling
+        put_bits(&pb, 1, !!mc->coupling_steps);
+        if (mc->coupling_steps) {
+            put_bits(&pb, 8, mc->coupling_steps - 1);
+            for (j = 0; j < mc->coupling_steps; j++) {
+                av_log(NULL, AV_LOG_ERROR, "%d %d %d %d\n", venc->channels, ilog(venc->channels - 1), mc->magnitude[j], mc->angle[j]);
+                put_bits(&pb, ilog(venc->channels - 1), mc->magnitude[j]);
+                put_bits(&pb, ilog(venc->channels - 1), mc->angle[j]);
+            }
+        }
 
         put_bits(&pb, 2, 0); // reserved
 
@@ -932,6 +950,25 @@
         }
     }
 
+    for (i = 0; i < mapping->coupling_steps; i++) {
+        float * mag = venc->coeffs + mapping->magnitude[i] * samples;
+        float * ang = venc->coeffs + mapping->angle[i] * samples;
+        int j;
+        for (j = 0; j < samples; j++) {
+            float m = mag[j];
+            float a = ang[j];
+            if (m > 0) {
+                ang[j] = m - a;
+                if (a > m) mag[j] = a;
+                else mag[j] = m;
+            } else {
+                ang[j] = a - m;
+                if (a > m) mag[j] = m;
+                else mag[j] = a;
+            }
+        }
+    }
+
     residue_encode(venc, &venc->residues[mapping->residue[mapping->mux[0]]], &pb, venc->coeffs, samples, venc->channels);
 
     return (put_bits_count(&pb) + 7) / 8;




More information about the ffmpeg-cvslog mailing list