]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/bitstream.c
fix adpcm swf decoding
[ffmpeg] / libavcodec / bitstream.c
index fcd4fd9cb24922926ca43232885955c4d65e8d95..35f775437df8e791589a6dd941fa3cc224604dc2 100644 (file)
@@ -3,19 +3,21 @@
  * Copyright (c) 2000, 2001 Fabrice Bellard.
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  *
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  *
  * alternative bitstream reader & writer by Michael Niedermayer <michaelni@gmx.at>
  */
  * @file bitstream.c
  * bitstream api.
  */
+
 #include "avcodec.h"
 #include "bitstream.h"
 
+/**
+ * Same as av_mallocz_static(), but does a realloc.
+ *
+ * @param[in] ptr The block of memory to reallocate.
+ * @param[in] size The requested size.
+ * @return Block of memory of requested size.
+ */
+void *ff_realloc_static(void *ptr, unsigned int size);
+
 void align_put_bits(PutBitContext *s)
 {
 #ifdef ALT_BITSTREAM_WRITER
@@ -37,7 +48,7 @@ void align_put_bits(PutBitContext *s)
 #endif
 }
 
-void put_string(PutBitContext * pbc, char *s, int put_zero)
+void ff_put_string(PutBitContext * pbc, char *s, int put_zero)
 {
     while(*s){
         put_bits(pbc, 8, *s);
@@ -47,47 +58,6 @@ void put_string(PutBitContext * pbc, char *s, int put_zero)
         put_bits(pbc, 8, 0);
 }
 
-/* bit input functions */
-
-/** 
- * reads 0-32 bits.
- */
-unsigned int get_bits_long(GetBitContext *s, int n){
-    if(n<=17) return get_bits(s, n);
-    else{
-        int ret= get_bits(s, 16) << (n-16);
-        return ret | get_bits(s, n-16);
-    }
-}
-
-/** 
- * shows 0-32 bits.
- */
-unsigned int show_bits_long(GetBitContext *s, int n){
-    if(n<=17) return show_bits(s, n);
-    else{
-        GetBitContext gb= *s;
-        int ret= get_bits_long(s, n);
-        *s= gb;
-        return ret;
-    }
-}
-
-void align_get_bits(GetBitContext *s)
-{
-    int n= (-get_bits_count(s)) & 7;
-    if(n) skip_bits(s, n);
-}
-
-int check_marker(GetBitContext *s, const char *msg)
-{
-    int bit= get_bits1(s);
-    if(!bit)
-           av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg);
-
-    return bit;
-}
-
 /* VLC decoding */
 
 //#define DEBUG_VLC
@@ -117,7 +87,7 @@ static int alloc_table(VLC *vlc, int size, int use_static)
     if (vlc->table_size > vlc->table_allocated) {
         vlc->table_allocated += (1 << vlc->bits);
         if(use_static)
-            vlc->table = av_realloc_static(vlc->table,
+            vlc->table = ff_realloc_static(vlc->table,
                                            sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
         else
             vlc->table = av_realloc(vlc->table,
@@ -235,7 +205,7 @@ static int build_table(VLC *vlc, int table_nb_bits,
    'nb_bits' set thee decoding table size (2^nb_bits) entries. The
    bigger it is, the faster is the decoding. But it should not be too
    big to save memory and L1 cache. '9' is a good compromise.
-   
+
    'nb_codes' : number of vlcs codes
 
    'bits' : table which gives the size (in bits) of each vlc code.
@@ -249,7 +219,7 @@ static int build_table(VLC *vlc, int table_nb_bits,
    or 'codes' tables.
 
    'wrap' and 'size' allows to use any memory configuration and types
-   (byte/word/long) to store the 'bits' and 'codes' tables.  
+   (byte/word/long) to store the 'bits' and 'codes' tables.
 
    'use_static' should be set to 1 for tables, which should be freed
    with av_free_static(), 0 if free_vlc() will be used.