ffmpeg patches for TERMUX from Andrew + mpeg formats
[goodguy/cinelerra.git] / cinelerra-5.1 / thirdparty / src / ffmpeg-4.4.patch_3
1 --- ffmpeg-4.4/libavcodec/opus_pvq.c.orig       2021-05-08 12:19:49.996985421 +0300
2 +++ ffmpeg-4.4/libavcodec/opus_pvq.c    2021-05-08 12:21:12.440985425 +0300
3 @@ -495,12 +495,12 @@
4      uint32_t N0 = N;
5      int N_B = N / blocks;
6      int N_B0 = N_B;
7 -    int B0 = blocks;
8 +    int B0_ = blocks;
9      int time_divide = 0;
10      int recombine = 0;
11      int inv = 0;
12      float mid = 0, side = 0;
13 -    int longblocks = (B0 == 1);
14 +    int longblocks = (B0_ == 1);
15      uint32_t cm = 0;
16
17      if (N == 1) {
18 @@ -532,7 +532,7 @@
19          /* Band recombining to increase frequency resolution */
20
21          if (lowband &&
22 -            (recombine || ((N_B & 1) == 0 && tf_change < 0) || B0 > 1)) {
23 +            (recombine || ((N_B & 1) == 0 && tf_change < 0) || B0_ > 1)) {
24              for (i = 0; i < N; i++)
25                  lowband_scratch[i] = lowband[i];
26              lowband = lowband_scratch;
27 @@ -556,13 +556,13 @@
28              time_divide++;
29              tf_change++;
30          }
31 -        B0 = blocks;
32 +        B0_ = blocks;
33          N_B0 = N_B;
34
35          /* Reorganize the samples in time order instead of frequency order */
36 -        if (B0 > 1 && (quant || lowband))
37 +        if (B0_ > 1 && (quant || lowband))
38              celt_deinterleave_hadamard(pvq->hadamard_tmp, quant ? X : lowband,
39 -                                       N_B >> recombine, B0 << recombine,
40 +                                       N_B >> recombine, B0_ << recombine,
41                                         longblocks);
42      }
43
44 @@ -604,7 +604,7 @@
45              if (quant) {
46                  if (stereo && N > 2)
47                      ff_opus_rc_enc_uint_step(rc, itheta, qn / 2);
48 -                else if (stereo || B0 > 1)
49 +                else if (stereo || B0_ > 1)
50                      ff_opus_rc_enc_uint(rc, itheta, qn + 1);
51                  else
52                      ff_opus_rc_enc_uint_tri(rc, itheta, qn);
53 @@ -619,7 +619,7 @@
54              } else {
55                  if (stereo && N > 2)
56                      itheta = ff_opus_rc_dec_uint_step(rc, qn / 2);
57 -                else if (stereo || B0 > 1)
58 +                else if (stereo || B0_ > 1)
59                      itheta = ff_opus_rc_dec_uint(rc, qn+1);
60                  else
61                      itheta = ff_opus_rc_dec_uint_tri(rc, qn);
62 @@ -725,7 +725,7 @@
63
64              /* Give more bits to low-energy MDCTs than they would
65               * otherwise deserve */
66 -            if (B0 > 1 && !stereo && (itheta & 0x3fff)) {
67 +            if (B0_ > 1 && !stereo && (itheta & 0x3fff)) {
68                  if (itheta > 8192)
69                      /* Rough approximation for pre-echo masking */
70                      delta -= delta >> (4 - duration);
71 @@ -764,14 +764,14 @@
72                  cmt = pvq->quant_band(pvq, f, rc, band, Y, NULL, N, sbits, blocks,
73                                        next_lowband2, duration, NULL, next_level,
74                                        gain * side, NULL, fill >> blocks);
75 -                cm |= cmt << ((B0 >> 1) & (stereo - 1));
76 +                cm |= cmt << ((B0_ >> 1) & (stereo - 1));
77              } else {
78                  /* For a stereo split, the high bits of fill are always zero,
79                   * so no folding will be done to the side. */
80                  cm = pvq->quant_band(pvq, f, rc, band, Y, NULL, N, sbits, blocks,
81                                       next_lowband2, duration, NULL, next_level,
82                                       gain * side, NULL, fill >> blocks);
83 -                cm <<= ((B0 >> 1) & (stereo - 1));
84 +                cm <<= ((B0_ >> 1) & (stereo - 1));
85                  rebalance = sbits - (rebalance - f->remaining2);
86                  if (rebalance > 3 << 3 && itheta != 16384)
87                      mbits += rebalance - (3 << 3);
88 @@ -842,13 +842,13 @@
89          int k;
90
91          /* Undo the sample reorganization going from time order to frequency order */
92 -        if (B0 > 1)
93 +        if (B0_ > 1)
94              celt_interleave_hadamard(pvq->hadamard_tmp, X, N_B >> recombine,
95 -                                     B0 << recombine, longblocks);
96 +                                     B0_ << recombine, longblocks);
97
98          /* Undo time-freq changes that we did earlier */
99          N_B = N_B0;
100 -        blocks = B0;
101 +        blocks = B0_;
102          for (k = 0; k < time_divide; k++) {
103              blocks >>= 1;
104              N_B <<= 1;