]> git.sesse.net Git - vlc/blobdiff - include/vlc_bits.h
Remove SUBCAT_VIDEO_VFILTER2
[vlc] / include / vlc_bits.h
index 774d9558059189e3e5877025b07cfdbeee1bf2f9..6c2915138c768d9c49b6646dde6c711acf6eabef 100644 (file)
@@ -1,24 +1,24 @@
 /*****************************************************************************
- * bits.h : Bit handling helpers
+ * vlc_bits.h : Bit handling helpers
  *****************************************************************************
- * Copyright (C) 2003 the VideoLAN team
+ * Copyright (C) 2003 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program 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.
  *
  * This program 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 General Public License for more details.
+ * 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 General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifndef VLC_BITS_H
  */
 
 typedef struct bs_s
-{
-    const uint8_t *p_start;
-    const uint8_t *p;
-    const uint8_t *p_end;
-
-    unsigned     i_left;    /* i_count number of available bits */
-} bs_t;
-
-typedef struct bs_writable_s
 {
     uint8_t *p_start;
     uint8_t *p;
     uint8_t *p_end;
-    
-    unsigned     i_left;    /* i_count number of available bits */
-} bsw_t;
 
+    ssize_t  i_left;    /* i_count number of available bits */
+} bs_t;
 
-static inline void bs_init( bs_t *s, const void *p_data, unsigned i_data )
+static inline void bs_init( bs_t *s, const void *p_data, size_t i_data )
 {
-    s->p_start = p_data;
-    s->p       = p_data;
-    s->p_end   = s->p + i_data;
+    s->p_start = (void *)p_data;
+    s->p       = s->p_start;
+    s->p_end   = s->p_start + i_data;
     s->i_left  = 8;
 }
 
-static inline int bs_pos( bs_t *s )
+static inline int bs_pos( const bs_t *s )
 {
     return( 8 * ( s->p - s->p_start ) + 8 - s->i_left );
 }
 
-static inline int bs_eof( bs_t *s )
+static inline int bs_eof( const bs_t *s )
 {
     return( s->p >= s->p_end ? 1: 0 );
 }
@@ -138,7 +128,7 @@ static inline uint32_t bs_show( bs_t *s, int i_count )
     return bs_read( &s_tmp, i_count );
 }
 
-static inline void bs_skip( bs_t *s, int i_count )
+static inline void bs_skip( bs_t *s, ssize_t i_count )
 {
     s->i_left -= i_count;
 
@@ -151,67 +141,25 @@ static inline void bs_skip( bs_t *s, int i_count )
     }
 }
 
-/*
- * Writable bits stream
- */
-static inline void bsw_init_writable( bsw_t *s, void *p_data, unsigned i_data )
-{
-    s->p_start = p_data;
-    s->p       = p_data;
-    s->p_end   = s->p + i_data;
-    s->i_left  = 8;
-}
-
-static inline bs_t * bs_from_writable( bsw_t *s )
-{
-    return (bs_t *)s;
-}
-
-static inline void bsw_skip( bsw_t *s, int count )
-{
-    return bs_skip(bs_from_writable(s), count);
-}
-
-static inline uint32_t bsw_show( bsw_t *s, int count )
-{
-    return bs_show(bs_from_writable(s), count);
-}
-
-static inline uint32_t bsw_read1( bsw_t *s )
-{
-    return bs_read1(bs_from_writable(s));
-}
-
-static inline uint32_t bsw_read( bsw_t *s, int count )
-{
-    return bs_read(bs_from_writable(s), count);
-}
-
-static inline int bsw_pos( bsw_t *s )
-{
-    return bs_pos(bs_from_writable(s));
-}
-
-static inline int bsw_eof( bsw_t *s )
-{
-    return bs_eof(bs_from_writable(s));
-}
-
-
-static inline void bsw_write( bsw_t *s, int i_count, uint32_t i_bits )
+static inline void bs_write( bs_t *s, int i_count, uint32_t i_bits )
 {
     while( i_count > 0 )
     {
         if( s->p >= s->p_end )
+        {
             break;
+        }
 
         i_count--;
 
         if( ( i_bits >> i_count )&0x01 )
+        {
             *s->p |= 1 << ( s->i_left - 1 );
+        }
         else
+        {
             *s->p &= ~( 1 << ( s->i_left - 1 ) );
-
+        }
         s->i_left--;
         if( s->i_left == 0 )
         {
@@ -221,7 +169,7 @@ static inline void bsw_write( bsw_t *s, int i_count, uint32_t i_bits )
     }
 }
 
-static inline void bsw_align( bsw_t *s )
+static inline void bs_align( bs_t *s )
 {
     if( s->i_left != 8 )
     {
@@ -230,16 +178,20 @@ static inline void bsw_align( bsw_t *s )
     }
 }
 
-static inline void bsw_align_0( bsw_t *s )
+static inline void bs_align_0( bs_t *s )
 {
     if( s->i_left != 8 )
-        bsw_write( s, s->i_left, 0 );
+    {
+        bs_write( s, s->i_left, 0 );
+    }
 }
 
-static inline void bsw_align_1( bsw_t *s )
+static inline void bs_align_1( bs_t *s )
 {
     while( s->i_left != 8 )
-        bsw_write( s, 1, 1 );
+    {
+        bs_write( s, 1, 1 );
+    }
 }
 
 #endif