]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/bitstream.c
Proper check for --help and -h parameters
[ffmpeg] / libavcodec / bitstream.c
index 271a393b22eb120db02e463e14d78edf9fd82794..5c50120460fa4b6e4a32b03d8c153ce92f3e01e5 100644 (file)
@@ -3,6 +3,8 @@
  * Copyright (c) 2000, 2001 Fabrice Bellard.
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  *
+ * alternative bitstream reader & writer by Michael Niedermayer <michaelni@gmx.at>
+ *
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
@@ -18,8 +20,6 @@
  * You should have received a copy of the GNU Lesser General Public
  * 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>
  */
 
 /**
@@ -36,7 +36,7 @@
  * @param[in] ptr The block of memory to reallocate.
  * @param[in] size The requested size.
  * @return Block of memory of requested size.
- * @deprecated. Code which uses ff_realloc_static is broken/missdesigned
+ * @deprecated. Code which uses ff_realloc_static is broken/misdesigned
  * and should correctly use static arrays
  */
 attribute_deprecated void *ff_realloc_static(void *ptr, unsigned int size);
@@ -60,6 +60,28 @@ void ff_put_string(PutBitContext * pbc, char *s, int put_zero)
         put_bits(pbc, 8, 0);
 }
 
+void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length)
+{
+    const uint16_t *srcw= (uint16_t*)src;
+    int words= length>>4;
+    int bits= length&15;
+    int i;
+
+    if(length==0) return;
+
+    if(ENABLE_SMALL || words < 16 || put_bits_count(pb)&7){
+        for(i=0; i<words; i++) put_bits(pb, 16, be2me_16(srcw[i]));
+    }else{
+        for(i=0; put_bits_count(pb)&31; i++)
+            put_bits(pb, 8, src[i]);
+        flush_put_bits(pb);
+        memcpy(pbBufPtr(pb), src+i, 2*words-i);
+        skip_put_bytes(pb, 2*words-i);
+    }
+
+    put_bits(pb, bits, be2me_16(srcw[words])>>(16-bits));
+}
+
 /* VLC decoding */
 
 //#define DEBUG_VLC