X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmlp.c;h=9615b66ee18635e4726b65230d5f3516193f9252;hb=0c71cc65266469253d531e8101a211ce8f26387c;hp=7ef7f975265e2b41717938909ea3c239f2b46b17;hpb=7a2efd2e447d5e7c7c0af61417a838b042fb7d0a;p=ffmpeg diff --git a/libavcodec/mlp.c b/libavcodec/mlp.c index 7ef7f975265..9615b66ee18 100644 --- a/libavcodec/mlp.c +++ b/libavcodec/mlp.c @@ -2,26 +2,27 @@ * MLP codec common code * Copyright (c) 2007-2008 Ian Caulfield * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include "libavutil/crc.h" +#include "libavutil/intreadwrite.h" #include "mlp.h" const uint8_t ff_mlp_huffman_tables[3][18][2] = { @@ -41,11 +42,16 @@ const uint8_t ff_mlp_huffman_tables[3][18][2] = { }; static int crc_init = 0; -static AVCRC crc_63[1024]; -static AVCRC crc_1D[1024]; -static AVCRC crc_2D[1024]; - -void av_cold ff_mlp_init_crc() +#if CONFIG_SMALL +#define CRC_TABLE_SIZE 257 +#else +#define CRC_TABLE_SIZE 1024 +#endif +static AVCRC crc_63[CRC_TABLE_SIZE]; +static AVCRC crc_1D[CRC_TABLE_SIZE]; +static AVCRC crc_2D[CRC_TABLE_SIZE]; + +av_cold void ff_mlp_init_crc(void) { if (!crc_init) { av_crc_init(crc_63, 0, 8, 0x63, sizeof(crc_63)); @@ -95,6 +101,8 @@ uint8_t ff_mlp_calculate_parity(const uint8_t *buf, unsigned int buf_size) uint32_t scratch = 0; const uint8_t *buf_end = buf + buf_size; + for (; ((intptr_t) buf & 3) && buf < buf_end; buf++) + scratch ^= *buf; for (; buf < buf_end - 3; buf += 4) scratch ^= *((const uint32_t*)buf);