/* * LZO 1x decompression * Copyright (c) 2006 Reimar Doeffinger * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <limits.h> #include <stdint.h> #include <string.h> #include "avassert.h" #include "intreadwrite.h" #include "lzo.h" #include "macros.h" #include "mem.h" /// Define if we may write up to 12 bytes beyond the output buffer. #define OUTBUF_PADDED … /// Define if we may read up to 8 bytes beyond the input buffer. #define INBUF_PADDED … LZOContext; /** * @brief Reads one byte from the input buffer, avoiding an overrun. * @return byte read */ static inline int get_byte(LZOContext *c) { … } #ifdef INBUF_PADDED #define GETB(c) … #else #define GETB … #endif /** * @brief Decodes a length value in the coding used by lzo. * @param x previous byte value * @param mask bits used from x * @return decoded length value */ static inline int get_len(LZOContext *c, int x, int mask) { … } /** * @brief Copies bytes from input to output buffer with checking. * @param cnt number of bytes to copy, must be >= 0 */ static inline void copy(LZOContext *c, int cnt) { … } /** * @brief Copies previously decoded bytes to current position. * @param back how many bytes back we start, must be > 0 * @param cnt number of bytes to copy, must be > 0 * * cnt > back is valid, this will copy the bytes we just copied, * thus creating a repeating pattern with a period length of back. */ static inline void copy_backptr(LZOContext *c, int back, int cnt) { … } int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { … }