comparison lcldec.c @ 9767:99d5a25c5895 libavcodec

Use bytestream_get_le16 to simplify offset/count calculation for mszh decompression.
author reimar
date Sun, 31 May 2009 10:35:39 +0000
parents ff036b7cab79
children c0af0d67bb8f
comparison
equal deleted inserted replaced
9766:ff036b7cab79 9767:99d5a25c5895
41 #include <stdio.h> 41 #include <stdio.h>
42 #include <stdlib.h> 42 #include <stdlib.h>
43 43
44 #include "avcodec.h" 44 #include "avcodec.h"
45 #include "get_bits.h" 45 #include "get_bits.h"
46 #include "bytestream.h"
46 #include "lcl.h" 47 #include "lcl.h"
47 48
48 #if CONFIG_ZLIB_DECODER 49 #if CONFIG_ZLIB_DECODER
49 #include <zlib.h> 50 #include <zlib.h>
50 #endif 51 #endif
94 break; 95 break;
95 memcpy(destptr, srcptr, 4); 96 memcpy(destptr, srcptr, 4);
96 destptr += 4; 97 destptr += 4;
97 srcptr += 4; 98 srcptr += 4;
98 } else { 99 } else {
99 ofs = *srcptr++; 100 ofs = bytestream_get_le16(&srcptr);
100 cnt = *srcptr++; 101 cnt = (ofs >> 11) + 1;
101 ofs += cnt * 256;
102 cnt = (cnt >> 3) + 1;
103 ofs &= 0x7ff; 102 ofs &= 0x7ff;
104 cnt *= 4; 103 cnt *= 4;
105 if (destptr_end - destptr < cnt) { 104 if (destptr_end - destptr < cnt) {
106 cnt = destptr_end - destptr; 105 cnt = destptr_end - destptr;
107 } 106 }