ffmpeg patches for TERMUX from Andrew + mpeg formats
[goodguy/cinelerra.git] / cinelerra-5.1 / thirdparty / src / ffmpeg-4.4.patch_3
diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg-4.4.patch_3 b/cinelerra-5.1/thirdparty/src/ffmpeg-4.4.patch_3
new file mode 100644 (file)
index 0000000..5e42b66
--- /dev/null
@@ -0,0 +1,104 @@
+--- ffmpeg-4.4/libavcodec/opus_pvq.c.orig      2021-05-08 12:19:49.996985421 +0300
++++ ffmpeg-4.4/libavcodec/opus_pvq.c   2021-05-08 12:21:12.440985425 +0300
+@@ -495,12 +495,12 @@
+     uint32_t N0 = N;
+     int N_B = N / blocks;
+     int N_B0 = N_B;
+-    int B0 = blocks;
++    int B0_ = blocks;
+     int time_divide = 0;
+     int recombine = 0;
+     int inv = 0;
+     float mid = 0, side = 0;
+-    int longblocks = (B0 == 1);
++    int longblocks = (B0_ == 1);
+     uint32_t cm = 0;
+
+     if (N == 1) {
+@@ -532,7 +532,7 @@
+         /* Band recombining to increase frequency resolution */
+
+         if (lowband &&
+-            (recombine || ((N_B & 1) == 0 && tf_change < 0) || B0 > 1)) {
++            (recombine || ((N_B & 1) == 0 && tf_change < 0) || B0_ > 1)) {
+             for (i = 0; i < N; i++)
+                 lowband_scratch[i] = lowband[i];
+             lowband = lowband_scratch;
+@@ -556,13 +556,13 @@
+             time_divide++;
+             tf_change++;
+         }
+-        B0 = blocks;
++        B0_ = blocks;
+         N_B0 = N_B;
+
+         /* Reorganize the samples in time order instead of frequency order */
+-        if (B0 > 1 && (quant || lowband))
++        if (B0_ > 1 && (quant || lowband))
+             celt_deinterleave_hadamard(pvq->hadamard_tmp, quant ? X : lowband,
+-                                       N_B >> recombine, B0 << recombine,
++                                       N_B >> recombine, B0_ << recombine,
+                                        longblocks);
+     }
+
+@@ -604,7 +604,7 @@
+             if (quant) {
+                 if (stereo && N > 2)
+                     ff_opus_rc_enc_uint_step(rc, itheta, qn / 2);
+-                else if (stereo || B0 > 1)
++                else if (stereo || B0_ > 1)
+                     ff_opus_rc_enc_uint(rc, itheta, qn + 1);
+                 else
+                     ff_opus_rc_enc_uint_tri(rc, itheta, qn);
+@@ -619,7 +619,7 @@
+             } else {
+                 if (stereo && N > 2)
+                     itheta = ff_opus_rc_dec_uint_step(rc, qn / 2);
+-                else if (stereo || B0 > 1)
++                else if (stereo || B0_ > 1)
+                     itheta = ff_opus_rc_dec_uint(rc, qn+1);
+                 else
+                     itheta = ff_opus_rc_dec_uint_tri(rc, qn);
+@@ -725,7 +725,7 @@
+
+             /* Give more bits to low-energy MDCTs than they would
+              * otherwise deserve */
+-            if (B0 > 1 && !stereo && (itheta & 0x3fff)) {
++            if (B0_ > 1 && !stereo && (itheta & 0x3fff)) {
+                 if (itheta > 8192)
+                     /* Rough approximation for pre-echo masking */
+                     delta -= delta >> (4 - duration);
+@@ -764,14 +764,14 @@
+                 cmt = pvq->quant_band(pvq, f, rc, band, Y, NULL, N, sbits, blocks,
+                                       next_lowband2, duration, NULL, next_level,
+                                       gain * side, NULL, fill >> blocks);
+-                cm |= cmt << ((B0 >> 1) & (stereo - 1));
++                cm |= cmt << ((B0_ >> 1) & (stereo - 1));
+             } else {
+                 /* For a stereo split, the high bits of fill are always zero,
+                  * so no folding will be done to the side. */
+                 cm = pvq->quant_band(pvq, f, rc, band, Y, NULL, N, sbits, blocks,
+                                      next_lowband2, duration, NULL, next_level,
+                                      gain * side, NULL, fill >> blocks);
+-                cm <<= ((B0 >> 1) & (stereo - 1));
++                cm <<= ((B0_ >> 1) & (stereo - 1));
+                 rebalance = sbits - (rebalance - f->remaining2);
+                 if (rebalance > 3 << 3 && itheta != 16384)
+                     mbits += rebalance - (3 << 3);
+@@ -842,13 +842,13 @@
+         int k;
+
+         /* Undo the sample reorganization going from time order to frequency order */
+-        if (B0 > 1)
++        if (B0_ > 1)
+             celt_interleave_hadamard(pvq->hadamard_tmp, X, N_B >> recombine,
+-                                     B0 << recombine, longblocks);
++                                     B0_ << recombine, longblocks);
+
+         /* Undo time-freq changes that we did earlier */
+         N_B = N_B0;
+-        blocks = B0;
++        blocks = B0_;
+         for (k = 0; k < time_divide; k++) {
+             blocks >>= 1;
+             N_B <<= 1;