Go to the documentation of this file.
31 #define OUTBUF_PADDED 1
33 #define INBUF_PADDED 1
47 if (
c->in <
c->in_end)
54 #define GETB(c) (*(c).in++)
56 #define GETB(c) get_byte(&(c))
70 if (cnt >= INT_MAX - 1000) {
87 register const uint8_t *
src =
c->in;
88 register uint8_t *dst =
c->out;
90 if (cnt >
c->in_end -
src) {
94 if (cnt >
c->out_end - dst) {
95 cnt =
FFMAX(
c->out_end - dst, 0);
98 #if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
105 memcpy(dst,
src, cnt);
120 register uint8_t *dst =
c->out;
122 if (dst -
c->out_start < back) {
126 if (cnt >
c->out_end - dst) {
127 cnt =
FFMAX(
c->out_end - dst, 0);
139 if (*outlen <= 0 || *inlen <= 0) {
148 c.in_end = (
const uint8_t *)in + *inlen;
149 c.out =
c.out_start =
out;
150 c.out_end = (uint8_t *)
out + *outlen;
166 back = (
GETB(
c) << 3) + ((x >> 2) & 7) + 1;
170 back = (
GETB(
c) << 6) + (x >> 2) + 1;
173 back = (1 << 14) + ((x & 8) << 11);
175 back += (
GETB(
c) << 6) + (x >> 2);
176 if (back == (1 << 14)) {
189 back = (1 << 11) + (
GETB(
c) << 2) + (x >> 2) + 1;
192 back = (
GETB(
c) << 2) + (x >> 2) + 1;
200 *inlen =
c.in_end -
c.in;
203 *outlen =
c.out_end -
c.out;
static void copy(LZOContext *c, int cnt)
Copies bytes from input to output buffer with checking.
#define AV_LZO_INPUT_DEPLETED
end of the input buffer reached before decoding finished
static const uint16_t mask[17]
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
Overlapping memcpy() implementation.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int get_len(LZOContext *c, int x, int mask)
Decodes a length value in the coding used by lzo.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen)
Decodes LZO 1x compressed data.
#define AV_LZO_INVALID_BACKPTR
a reference to previously decoded data was wrong
#define AV_LZO_ERROR
a non-specific error in the compressed bitstream
static int get_byte(LZOContext *c)
Reads one byte from the input buffer, avoiding an overrun.
static void copy_backptr(LZOContext *c, int back, int cnt)
Copies previously decoded bytes to current position.
#define AV_LZO_OUTPUT_FULL
decoded data did not fit into output buffer