Browse code

Merge commit '831018b0bbe26a603802a9022472f714a59293be'

* commit '831018b0bbe26a603802a9022472f714a59293be':
mpeg4audio: Make avpriv_copy_pce_data() inline

Merged-by: James Almer <jamrial@gmail.com>

James Almer authored on 2017/10/31 05:47:21
Showing 5 changed files
... ...
@@ -91,7 +91,7 @@ static int aac_adtstoasc_filter(AVBSFContext *bsfc, AVPacket *out)
91 91
                 goto fail;
92 92
             }
93 93
             init_put_bits(&pb, pce_data, MAX_PCE_SIZE);
94
-            pce_size = avpriv_copy_pce_data(&pb, &gb)/8;
94
+            pce_size = ff_copy_pce_data(&pb, &gb) / 8;
95 95
             flush_put_bits(&pb);
96 96
             in->size -= get_bits_count(&gb)/8;
97 97
             in->data += get_bits_count(&gb)/8;
... ...
@@ -167,43 +167,3 @@ int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
167 167
 
168 168
     return ff_mpeg4audio_get_config_gb(c, &gb, sync_extension);
169 169
 }
170
-
171
-static av_always_inline unsigned int copy_bits(PutBitContext *pb,
172
-                                               GetBitContext *gb,
173
-                                               int bits)
174
-{
175
-    unsigned int el = get_bits(gb, bits);
176
-    put_bits(pb, bits, el);
177
-    return el;
178
-}
179
-
180
-int avpriv_copy_pce_data(PutBitContext *pb, GetBitContext *gb)
181
-{
182
-    int five_bit_ch, four_bit_ch, comment_size, bits;
183
-    int offset = put_bits_count(pb);
184
-
185
-    copy_bits(pb, gb, 10);                  //Tag, Object Type, Frequency
186
-    five_bit_ch  = copy_bits(pb, gb, 4);    //Front
187
-    five_bit_ch += copy_bits(pb, gb, 4);    //Side
188
-    five_bit_ch += copy_bits(pb, gb, 4);    //Back
189
-    four_bit_ch  = copy_bits(pb, gb, 2);    //LFE
190
-    four_bit_ch += copy_bits(pb, gb, 3);    //Data
191
-    five_bit_ch += copy_bits(pb, gb, 4);    //Coupling
192
-    if (copy_bits(pb, gb, 1))               //Mono Mixdown
193
-        copy_bits(pb, gb, 4);
194
-    if (copy_bits(pb, gb, 1))               //Stereo Mixdown
195
-        copy_bits(pb, gb, 4);
196
-    if (copy_bits(pb, gb, 1))               //Matrix Mixdown
197
-        copy_bits(pb, gb, 3);
198
-    for (bits = five_bit_ch*5+four_bit_ch*4; bits > 16; bits -= 16)
199
-        copy_bits(pb, gb, 16);
200
-    if (bits)
201
-        copy_bits(pb, gb, bits);
202
-    avpriv_align_put_bits(pb);
203
-    align_get_bits(gb);
204
-    comment_size = copy_bits(pb, gb, 8);
205
-    for (; comment_size > 0; comment_size--)
206
-        copy_bits(pb, gb, 8);
207
-
208
-    return put_bits_count(pb) - offset;
209
-}
... ...
@@ -23,6 +23,9 @@
23 23
 #define AVCODEC_MPEG4AUDIO_H
24 24
 
25 25
 #include <stdint.h>
26
+
27
+#include "libavutil/attributes.h"
28
+
26 29
 #include "get_bits.h"
27 30
 #include "put_bits.h"
28 31
 
... ...
@@ -115,6 +118,44 @@ enum AudioObjectType {
115 115
 #define MAX_PCE_SIZE 320 ///<Maximum size of a PCE including the 3-bit ID_PCE
116 116
                          ///<marker and the comment
117 117
 
118
-int avpriv_copy_pce_data(PutBitContext *pb, GetBitContext *gb);
118
+static av_always_inline unsigned int ff_pce_copy_bits(PutBitContext *pb,
119
+                                                      GetBitContext *gb,
120
+                                                      int bits)
121
+{
122
+    unsigned int el = get_bits(gb, bits);
123
+    put_bits(pb, bits, el);
124
+    return el;
125
+}
126
+
127
+static inline int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb)
128
+{
129
+    int five_bit_ch, four_bit_ch, comment_size, bits;
130
+    int offset = put_bits_count(pb);
131
+
132
+    ff_pce_copy_bits(pb, gb, 10);               // Tag, Object Type, Frequency
133
+    five_bit_ch  = ff_pce_copy_bits(pb, gb, 4); // Front
134
+    five_bit_ch += ff_pce_copy_bits(pb, gb, 4); // Side
135
+    five_bit_ch += ff_pce_copy_bits(pb, gb, 4); // Back
136
+    four_bit_ch  = ff_pce_copy_bits(pb, gb, 2); // LFE
137
+    four_bit_ch += ff_pce_copy_bits(pb, gb, 3); // Data
138
+    five_bit_ch += ff_pce_copy_bits(pb, gb, 4); // Coupling
139
+    if (ff_pce_copy_bits(pb, gb, 1))            // Mono Mixdown
140
+        ff_pce_copy_bits(pb, gb, 4);
141
+    if (ff_pce_copy_bits(pb, gb, 1))            // Stereo Mixdown
142
+        ff_pce_copy_bits(pb, gb, 4);
143
+    if (ff_pce_copy_bits(pb, gb, 1))            // Matrix Mixdown
144
+        ff_pce_copy_bits(pb, gb, 3);
145
+    for (bits = five_bit_ch*5+four_bit_ch*4; bits > 16; bits -= 16)
146
+        ff_pce_copy_bits(pb, gb, 16);
147
+    if (bits)
148
+        ff_pce_copy_bits(pb, gb, bits);
149
+    avpriv_align_put_bits(pb);
150
+    align_get_bits(gb);
151
+    comment_size = ff_pce_copy_bits(pb, gb, 8);
152
+    for (; comment_size > 0; comment_size--)
153
+        ff_pce_copy_bits(pb, gb, 8);
154
+
155
+    return put_bits_count(pb) - offset;
156
+}
119 157
 
120 158
 #endif /* AVCODEC_MPEG4AUDIO_H */
... ...
@@ -85,7 +85,7 @@ static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, const ui
85 85
         init_put_bits(&pb, adts->pce_data, MAX_PCE_SIZE);
86 86
 
87 87
         put_bits(&pb, 3, 5); //ID_PCE
88
-        adts->pce_size = (avpriv_copy_pce_data(&pb, &gb) + 3) / 8;
88
+        adts->pce_size = (ff_copy_pce_data(&pb, &gb) + 3) / 8;
89 89
         flush_put_bits(&pb);
90 90
     }
91 91
 
... ...
@@ -128,7 +128,7 @@ static void latm_write_frame_header(AVFormatContext *s, PutBitContext *bs)
128 128
                 int ret = init_get_bits8(&gb, par->extradata, par->extradata_size);
129 129
                 av_assert0(ret >= 0); // extradata size has been checked already, so this should not fail
130 130
                 skip_bits_long(&gb, ctx->off + 3);
131
-                avpriv_copy_pce_data(bs, &gb);
131
+                ff_copy_pce_data(bs, &gb);
132 132
             }
133 133
         }
134 134