]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/lagarithrac.c
lavc: add libdcadec decoder
[ffmpeg] / libavcodec / lagarithrac.c
index f1ffbf0a9b90c7519171c56011a9513c1cd7b835..edfb18fb746851f4c7dc83ee937976ef6de48535 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 /**
- * @file libavcodec/lagarithrac.c
+ * @file
  * Lagarith range decoder
  * @author Nathan Caldwell
  * @author David Conrad
 #include "get_bits.h"
 #include "lagarithrac.h"
 
-void lag_rac_init(lag_rac *l, GetBitContext *gb, int length)
+void ff_lag_rac_init(lag_rac *l, GetBitContext *gb, int length)
 {
-    int i, j;
+    int i, j, left;
 
     /* According to reference decoder "1st byte is garbage",
      * however, it gets skipped by the call to align_get_bits()
      */
     align_get_bits(gb);
+    left                = get_bits_left(gb) >> 3;
     l->bytestream_start =
     l->bytestream       = gb->buffer + get_bits_count(gb) / 8;
-    l->bytestream_end   = l->bytestream_start + length;
+    l->bytestream_end   = l->bytestream_start + FFMIN(length, left);
 
     l->range        = 0x80;
     l->low          = *l->bytestream >> 1;