]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/bitstream.c
LPCM 24 bits support, patch by Lars Täuber, lars.taeuber gmx net
[ffmpeg] / libavcodec / bitstream.c
index 8e5d15acebf0eb707195a6a511926f5d03ae20a0..f02c9c7e12e1d4cc20d9ddaea34fde987ba723a0 100644 (file)
  * @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);
+attribute_deprecated av_alloc_size(2)
+void *ff_realloc_static(void *ptr, unsigned int size);
 
 void align_put_bits(PutBitContext *s)
 {
@@ -50,7 +51,7 @@ void align_put_bits(PutBitContext *s)
 #endif
 }
 
-void ff_put_string(PutBitContext * pbc, char *s, int put_zero)
+void ff_put_string(PutBitContext * pbc, const char *s, int put_zero)
 {
     while(*s){
         put_bits(pbc, 8, *s);
@@ -60,6 +61,28 @@ void ff_put_string(PutBitContext * pbc, char *s, int put_zero)
         put_bits(pbc, 8, 0);
 }
 
+void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
+{
+    const uint16_t *srcw= (const 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