Keep lzo1x_decode until the next major version bump for binary compatibility. Originally committed as revision 16946 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
| @@ -158,7 +158,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, | |||||
| switch ((buf[0] >> 1) & 7) { | switch ((buf[0] >> 1) & 7) { | ||||
| case 0: { // lzo compression | case 0: { // lzo compression | ||||
| int outlen = c->decomp_size, inlen = buf_size - 2; | int outlen = c->decomp_size, inlen = buf_size - 2; | ||||
| if (lzo1x_decode(c->decomp_buf, &outlen, &buf[2], &inlen)) | |||||
| if (av_lzo1x_decode(c->decomp_buf, &outlen, &buf[2], &inlen)) | |||||
| av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n"); | av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n"); | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -232,7 +232,7 @@ static av_cold int decode_init(AVCodecContext *avctx) { | |||||
| c->linelen = avctx->width * avctx->bits_per_coded_sample / 8; | c->linelen = avctx->width * avctx->bits_per_coded_sample / 8; | ||||
| c->height = avctx->height; | c->height = avctx->height; | ||||
| c->decomp_size = c->height * c->linelen; | c->decomp_size = c->height * c->linelen; | ||||
| c->decomp_buf = av_malloc(c->decomp_size + LZO_OUTPUT_PADDING); | |||||
| c->decomp_buf = av_malloc(c->decomp_size + AV_LZO_OUTPUT_PADDING); | |||||
| if (!c->decomp_buf) { | if (!c->decomp_buf) { | ||||
| av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); | av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); | ||||
| return 1; | return 1; | ||||
| @@ -116,7 +116,7 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height, int qualit | |||||
| avctx->width = c->width = width; | avctx->width = c->width = width; | ||||
| avctx->height = c->height = height; | avctx->height = c->height = height; | ||||
| c->decomp_size = c->height * c->width * 3 / 2; | c->decomp_size = c->height * c->width * 3 / 2; | ||||
| c->decomp_buf = av_realloc(c->decomp_buf, c->decomp_size + LZO_OUTPUT_PADDING); | |||||
| c->decomp_buf = av_realloc(c->decomp_buf, c->decomp_size + AV_LZO_OUTPUT_PADDING); | |||||
| if (!c->decomp_buf) { | if (!c->decomp_buf) { | ||||
| av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); | av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); | ||||
| return 0; | return 0; | ||||
| @@ -175,7 +175,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, | |||||
| buf_size -= 12; | buf_size -= 12; | ||||
| if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) { | if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) { | ||||
| int outlen = c->decomp_size, inlen = buf_size; | int outlen = c->decomp_size, inlen = buf_size; | ||||
| if (lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen)) | |||||
| if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen)) | |||||
| av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n"); | av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n"); | ||||
| buf = c->decomp_buf; | buf = c->decomp_buf; | ||||
| buf_size = c->decomp_size; | buf_size = c->decomp_size; | ||||
| @@ -872,9 +872,9 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size, | |||||
| do { | do { | ||||
| olen = pkt_size *= 3; | olen = pkt_size *= 3; | ||||
| pkt_data = av_realloc(pkt_data, | pkt_data = av_realloc(pkt_data, | ||||
| pkt_size+LZO_OUTPUT_PADDING); | |||||
| result = lzo1x_decode(pkt_data, &olen, data, &isize); | |||||
| } while (result==LZO_OUTPUT_FULL && pkt_size<10000000); | |||||
| pkt_size+AV_LZO_OUTPUT_PADDING); | |||||
| result = av_lzo1x_decode(pkt_data, &olen, data, &isize); | |||||
| } while (result==AV_LZO_OUTPUT_FULL && pkt_size<10000000); | |||||
| if (result) | if (result) | ||||
| goto failed; | goto failed; | ||||
| pkt_size -= olen; | pkt_size -= olen; | ||||
| @@ -41,7 +41,7 @@ typedef struct LZOContext { | |||||
| static inline int get_byte(LZOContext *c) { | static inline int get_byte(LZOContext *c) { | ||||
| if (c->in < c->in_end) | if (c->in < c->in_end) | ||||
| return *c->in++; | return *c->in++; | ||||
| c->error |= LZO_INPUT_DEPLETED; | |||||
| c->error |= AV_LZO_INPUT_DEPLETED; | |||||
| return 1; | return 1; | ||||
| } | } | ||||
| @@ -88,11 +88,11 @@ static inline void copy(LZOContext *c, int cnt) { | |||||
| register uint8_t *dst = c->out; | register uint8_t *dst = c->out; | ||||
| if (cnt > c->in_end - src) { | if (cnt > c->in_end - src) { | ||||
| cnt = FFMAX(c->in_end - src, 0); | cnt = FFMAX(c->in_end - src, 0); | ||||
| c->error |= LZO_INPUT_DEPLETED; | |||||
| c->error |= AV_LZO_INPUT_DEPLETED; | |||||
| } | } | ||||
| if (cnt > c->out_end - dst) { | if (cnt > c->out_end - dst) { | ||||
| cnt = FFMAX(c->out_end - dst, 0); | cnt = FFMAX(c->out_end - dst, 0); | ||||
| c->error |= LZO_OUTPUT_FULL; | |||||
| c->error |= AV_LZO_OUTPUT_FULL; | |||||
| } | } | ||||
| #if defined(INBUF_PADDED) && defined(OUTBUF_PADDED) | #if defined(INBUF_PADDED) && defined(OUTBUF_PADDED) | ||||
| COPY4(dst, src); | COPY4(dst, src); | ||||
| @@ -120,12 +120,12 @@ static inline void copy_backptr(LZOContext *c, int back, int cnt) { | |||||
| register const uint8_t *src = &c->out[-back]; | register const uint8_t *src = &c->out[-back]; | ||||
| register uint8_t *dst = c->out; | register uint8_t *dst = c->out; | ||||
| if (src < c->out_start || src > dst) { | if (src < c->out_start || src > dst) { | ||||
| c->error |= LZO_INVALID_BACKPTR; | |||||
| c->error |= AV_LZO_INVALID_BACKPTR; | |||||
| return; | return; | ||||
| } | } | ||||
| if (cnt > c->out_end - dst) { | if (cnt > c->out_end - dst) { | ||||
| cnt = FFMAX(c->out_end - dst, 0); | cnt = FFMAX(c->out_end - dst, 0); | ||||
| c->error |= LZO_OUTPUT_FULL; | |||||
| c->error |= AV_LZO_OUTPUT_FULL; | |||||
| } | } | ||||
| memcpy_backptr(dst, back, cnt); | memcpy_backptr(dst, back, cnt); | ||||
| c->out = dst + cnt; | c->out = dst + cnt; | ||||
| @@ -187,9 +187,9 @@ void av_memcpy_backptr(uint8_t *dst, int back, int cnt) { | |||||
| * \return 0 on success, otherwise error flags, see lzo.h | * \return 0 on success, otherwise error flags, see lzo.h | ||||
| * | * | ||||
| * Make sure all buffers are appropriately padded, in must provide | * Make sure all buffers are appropriately padded, in must provide | ||||
| * LZO_INPUT_PADDING, out must provide LZO_OUTPUT_PADDING additional bytes. | |||||
| * AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes. | |||||
| */ | */ | ||||
| int lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { | |||||
| int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { | |||||
| int state= 0; | int state= 0; | ||||
| int x; | int x; | ||||
| LZOContext c; | LZOContext c; | ||||
| @@ -202,10 +202,10 @@ int lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { | |||||
| if (x > 17) { | if (x > 17) { | ||||
| copy(&c, x - 17); | copy(&c, x - 17); | ||||
| x = GETB(c); | x = GETB(c); | ||||
| if (x < 16) c.error |= LZO_ERROR; | |||||
| if (x < 16) c.error |= AV_LZO_ERROR; | |||||
| } | } | ||||
| if (c.in > c.in_end) | if (c.in > c.in_end) | ||||
| c.error |= LZO_INPUT_DEPLETED; | |||||
| c.error |= AV_LZO_INPUT_DEPLETED; | |||||
| while (!c.error) { | while (!c.error) { | ||||
| int cnt, back; | int cnt, back; | ||||
| if (x > 15) { | if (x > 15) { | ||||
| @@ -223,7 +223,7 @@ int lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { | |||||
| back += (GETB(c) << 6) + (x >> 2); | back += (GETB(c) << 6) + (x >> 2); | ||||
| if (back == (1 << 14)) { | if (back == (1 << 14)) { | ||||
| if (cnt != 1) | if (cnt != 1) | ||||
| c.error |= LZO_ERROR; | |||||
| c.error |= AV_LZO_ERROR; | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| @@ -252,6 +252,12 @@ int lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { | |||||
| return c.error; | return c.error; | ||||
| } | } | ||||
| #if LIBAVUTIL_VERSION_MAJOR < 50 | |||||
| int lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { | |||||
| return av_lzo1x_decode(out, outlen, in, inlen); | |||||
| } | |||||
| #endif | |||||
| #ifdef TEST | #ifdef TEST | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <lzo/lzo1x.h> | #include <lzo/lzo1x.h> | ||||
| @@ -277,7 +283,7 @@ START_TIMER | |||||
| #elif defined(LIBLZO_UNSAFE) | #elif defined(LIBLZO_UNSAFE) | ||||
| if (lzo1x_decompress(comp, inlen, decomp, &outlen, NULL)) | if (lzo1x_decompress(comp, inlen, decomp, &outlen, NULL)) | ||||
| #else | #else | ||||
| if (lzo1x_decode(decomp, &outlen, comp, &inlen)) | |||||
| if (av_lzo1x_decode(decomp, &outlen, comp, &inlen)) | |||||
| #endif | #endif | ||||
| av_log(NULL, AV_LOG_ERROR, "decompression error\n"); | av_log(NULL, AV_LOG_ERROR, "decompression error\n"); | ||||
| STOP_TIMER("lzod") | STOP_TIMER("lzod") | ||||
| @@ -24,15 +24,15 @@ | |||||
| #include <stdint.h> | #include <stdint.h> | ||||
| #define LZO_INPUT_DEPLETED 1 | |||||
| #define LZO_OUTPUT_FULL 2 | |||||
| #define LZO_INVALID_BACKPTR 4 | |||||
| #define LZO_ERROR 8 | |||||
| #define AV_LZO_INPUT_DEPLETED 1 | |||||
| #define AV_LZO_OUTPUT_FULL 2 | |||||
| #define AV_LZO_INVALID_BACKPTR 4 | |||||
| #define AV_LZO_ERROR 8 | |||||
| #define LZO_INPUT_PADDING 8 | |||||
| #define LZO_OUTPUT_PADDING 12 | |||||
| #define AV_LZO_INPUT_PADDING 8 | |||||
| #define AV_LZO_OUTPUT_PADDING 12 | |||||
| int lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); | |||||
| int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); | |||||
| void av_memcpy_backptr(uint8_t *dst, int back, int cnt); | void av_memcpy_backptr(uint8_t *dst, int back, int cnt); | ||||