]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/bitstream.c
ac3enc: Add codec-specific options for writing AC-3 metadata.
[ffmpeg] / libavcodec / bitstream.c
index 1e24099cc8b7bf1f359a5e224223f4edd3a810da..329ec9527e42dcf41a1d1e3217db051b3904191c 100644 (file)
@@ -6,25 +6,25 @@
  *
  * alternative bitstream reader & writer by Michael Niedermayer <michaelni@gmx.at>
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /**
- * @file libavcodec/bitstream.c
+ * @file
  * bitstream api.
  */
 
@@ -275,8 +275,8 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
              const void *symbols, int symbols_wrap, int symbols_size,
              int flags)
 {
-    VLCcode buf[nb_codes];
-    int i, j;
+    VLCcode *buf;
+    int i, j, ret;
 
     vlc->bits = nb_bits;
     if(flags & INIT_VLC_USE_NEW_STATIC){
@@ -295,6 +295,8 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
     av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes);
 #endif
 
+    buf = av_malloc((nb_codes+1)*sizeof(VLCcode));
+
     assert(symbols_size <= 2 || !symbols);
     j = 0;
 #define COPY(condition)\
@@ -319,7 +321,10 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
     COPY(buf[j].bits && buf[j].bits <= nb_bits);
     nb_codes = j;
 
-    if (build_table(vlc, nb_bits, nb_codes, buf, flags) < 0) {
+    ret = build_table(vlc, nb_bits, nb_codes, buf, flags);
+
+    av_free(buf);
+    if (ret < 0) {
         av_freep(&vlc->table);
         return -1;
     }