comparison lzo.c @ 633:8c48a1b999a3 libavutil

spelling/grammar/consistency review part I
author diego
date Wed, 28 Jan 2009 00:16:05 +0000
parents b8574db98875
children c04808220c83
comparison
equal deleted inserted replaced
632:f9884e1112d0 633:8c48a1b999a3
17 * You should have received a copy of the GNU Lesser General Public 17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software 18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */ 20 */
21 #include "common.h" 21 #include "common.h"
22 //! avoid e.g. MPlayers fast_memcpy, it slows things down here 22 //! Avoid e.g. MPlayers fast_memcpy, it slows things down here.
23 #undef memcpy 23 #undef memcpy
24 #include <string.h> 24 #include <string.h>
25 #include "lzo.h" 25 #include "lzo.h"
26 26
27 //! define if we may write up to 12 bytes beyond the output buffer 27 //! Define if we may write up to 12 bytes beyond the output buffer.
28 #define OUTBUF_PADDED 1 28 #define OUTBUF_PADDED 1
29 //! define if we may read up to 8 bytes beyond the input buffer 29 //! Define if we may read up to 8 bytes beyond the input buffer.
30 #define INBUF_PADDED 1 30 #define INBUF_PADDED 1
31 typedef struct LZOContext { 31 typedef struct LZOContext {
32 const uint8_t *in, *in_end; 32 const uint8_t *in, *in_end;
33 uint8_t *out_start, *out, *out_end; 33 uint8_t *out_start, *out, *out_end;
34 int error; 34 int error;
50 #else 50 #else
51 #define GETB(c) get_byte(&(c)) 51 #define GETB(c) get_byte(&(c))
52 #endif 52 #endif
53 53
54 /** 54 /**
55 * \brief decode a length value in the coding used by lzo 55 * \brief Decodes a length value in the coding used by lzo.
56 * \param x previous byte value 56 * \param x previous byte value
57 * \param mask bits used from x 57 * \param mask bits used from x
58 * \return decoded length value 58 * \return decoded length value
59 */ 59 */
60 static inline int get_len(LZOContext *c, int x, int mask) { 60 static inline int get_len(LZOContext *c, int x, int mask) {
78 #define COPY2(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; 78 #define COPY2(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1];
79 #define COPY4(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; (d)[2] = (s)[2]; (d)[3] = (s)[3]; 79 #define COPY4(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; (d)[2] = (s)[2]; (d)[3] = (s)[3];
80 #endif 80 #endif
81 81
82 /** 82 /**
83 * \brief copy bytes from input to output buffer with checking 83 * \brief Copies bytes from input to output buffer with checking.
84 * \param cnt number of bytes to copy, must be >= 0 84 * \param cnt number of bytes to copy, must be >= 0
85 */ 85 */
86 static inline void copy(LZOContext *c, int cnt) { 86 static inline void copy(LZOContext *c, int cnt) {
87 register const uint8_t *src = c->in; 87 register const uint8_t *src = c->in;
88 register uint8_t *dst = c->out; 88 register uint8_t *dst = c->out;
107 } 107 }
108 108
109 static inline void memcpy_backptr(uint8_t *dst, int back, int cnt); 109 static inline void memcpy_backptr(uint8_t *dst, int back, int cnt);
110 110
111 /** 111 /**
112 * \brief copy previously decoded bytes to current position 112 * \brief Copies previously decoded bytes to current position.
113 * \param back how many bytes back we start 113 * \param back how many bytes back we start
114 * \param cnt number of bytes to copy, must be >= 0 114 * \param cnt number of bytes to copy, must be >= 0
115 * 115 *
116 * cnt > back is valid, this will copy the bytes we just copied, 116 * cnt > back is valid, this will copy the bytes we just copied,
117 * thus creating a repeating pattern with a period length of back. 117 * thus creating a repeating pattern with a period length of back.
177 void av_memcpy_backptr(uint8_t *dst, int back, int cnt) { 177 void av_memcpy_backptr(uint8_t *dst, int back, int cnt) {
178 memcpy_backptr(dst, back, cnt); 178 memcpy_backptr(dst, back, cnt);
179 } 179 }
180 180
181 /** 181 /**
182 * \brief decode LZO 1x compressed data 182 * \brief Decodes LZO 1x compressed data.
183 * \param out output buffer 183 * \param out output buffer
184 * \param outlen size of output buffer, number of bytes left are returned here 184 * \param outlen size of output buffer, number of bytes left are returned here
185 * \param in input buffer 185 * \param in input buffer
186 * \param inlen size of input buffer, number of bytes left are returned here 186 * \param inlen size of input buffer, number of bytes left are returned here
187 * \return 0 on success, otherwise error flags, see lzo.h 187 * \return 0 on success, otherwise error flags, see lzo.h
188 * 188 *
189 * make sure all buffers are appropriately padded, in must provide 189 * Make sure all buffers are appropriately padded, in must provide
190 * LZO_INPUT_PADDING, out must provide LZO_OUTPUT_PADDING additional bytes 190 * LZO_INPUT_PADDING, out must provide LZO_OUTPUT_PADDING additional bytes.
191 */ 191 */
192 int lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { 192 int lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) {
193 int state= 0; 193 int state= 0;
194 int x; 194 int x;
195 LZOContext c; 195 LZOContext c;
283 STOP_TIMER("lzod") 283 STOP_TIMER("lzod")
284 } 284 }
285 if (memcmp(orig, decomp, s)) 285 if (memcmp(orig, decomp, s))
286 av_log(NULL, AV_LOG_ERROR, "decompression incorrect\n"); 286 av_log(NULL, AV_LOG_ERROR, "decompression incorrect\n");
287 else 287 else
288 av_log(NULL, AV_LOG_ERROR, "decompression ok\n"); 288 av_log(NULL, AV_LOG_ERROR, "decompression OK\n");
289 return 0; 289 return 0;
290 } 290 }
291 #endif 291 #endif