From 7e68c91e247ba20fc8a08cf5a6cf2b75984f1aeb Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 14 Oct 2012 23:41:12 +0200 Subject: [PATCH 1/3] rmdec: Move SIPR code shared with Matroska demuxer to a separate file --- libavformat/Makefile | 6 ++-- libavformat/matroskadec.c | 2 +- libavformat/rm.h | 8 ----- libavformat/rmdec.c | 42 +-------------------------- libavformat/rmsipr.c | 61 +++++++++++++++++++++++++++++++++++++++ libavformat/rmsipr.h | 35 ++++++++++++++++++++++ 6 files changed, 101 insertions(+), 53 deletions(-) create mode 100644 libavformat/rmsipr.c create mode 100644 libavformat/rmsipr.h diff --git a/libavformat/Makefile b/libavformat/Makefile index 5d89a2e3da..26c9803add 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -135,8 +135,8 @@ OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o OBJS-$(CONFIG_LXF_DEMUXER) += lxfdec.o OBJS-$(CONFIG_M4V_DEMUXER) += m4vdec.o rawdec.o OBJS-$(CONFIG_M4V_MUXER) += rawenc.o -OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \ - isom.o rmdec.o rm.o +OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \ + isom.o rmsipr.o OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o matroska.o \ isom.o avc.o \ flacenc_header.o avlanguage.o @@ -242,7 +242,7 @@ OBJS-$(CONFIG_R3D_DEMUXER) += r3d.o OBJS-$(CONFIG_RAWVIDEO_DEMUXER) += rawvideodec.o rawdec.o OBJS-$(CONFIG_RAWVIDEO_MUXER) += rawenc.o OBJS-$(CONFIG_RL2_DEMUXER) += rl2.o -OBJS-$(CONFIG_RM_DEMUXER) += rmdec.o rm.o +OBJS-$(CONFIG_RM_DEMUXER) += rmdec.o rm.o rmsipr.o OBJS-$(CONFIG_RM_MUXER) += rmenc.o rm.o OBJS-$(CONFIG_ROQ_DEMUXER) += idroqdec.o OBJS-$(CONFIG_ROQ_MUXER) += idroqenc.o rawenc.o diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 094b0558f7..68c936c15a 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -35,7 +35,7 @@ /* For ff_codec_get_id(). */ #include "riff.h" #include "isom.h" -#include "rm.h" +#include "rmsipr.h" #include "matroska.h" #include "libavcodec/bytestream.h" #include "libavcodec/mpeg4audio.h" diff --git a/libavformat/rm.h b/libavformat/rm.h index 9d104ad74c..a06ea01a5a 100644 --- a/libavformat/rm.h +++ b/libavformat/rm.h @@ -26,7 +26,6 @@ #include "internal.h" extern const char * const ff_rm_metadata[4]; -extern const unsigned char ff_sipr_subpk_size[4]; extern const AVCodecTag ff_rm_codec_tags[]; typedef struct RMStream RMStream; @@ -93,11 +92,4 @@ int ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb, int ff_rm_retrieve_cache (AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *rst, AVPacket *pkt); -/** - * Perform 4-bit block reordering for SIPR data. - * - * @param buf SIPR data - */ -void ff_rm_reorder_sipr_data(uint8_t *buf, int sub_packet_h, int framesize); - #endif /* AVFORMAT_RM_H */ diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index eefd2c5082..07d218e311 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -25,6 +25,7 @@ #include "avformat.h" #include "internal.h" #include "riff.h" +#include "rmsipr.h" #include "rm.h" #define DEINT_ID_GENR MKTAG('g', 'e', 'n', 'r') ///< interleaving for Cooker/Atrac @@ -59,21 +60,6 @@ typedef struct { int audio_pkt_cnt; ///< Output packet counter } RMDemuxContext; -static const unsigned char sipr_swaps[38][2] = { - { 0, 63 }, { 1, 22 }, { 2, 44 }, { 3, 90 }, - { 5, 81 }, { 7, 31 }, { 8, 86 }, { 9, 58 }, - { 10, 36 }, { 12, 68 }, { 13, 39 }, { 14, 73 }, - { 15, 53 }, { 16, 69 }, { 17, 57 }, { 19, 88 }, - { 20, 34 }, { 21, 71 }, { 24, 46 }, { 25, 94 }, - { 26, 54 }, { 28, 75 }, { 29, 50 }, { 32, 70 }, - { 33, 92 }, { 35, 74 }, { 38, 85 }, { 40, 56 }, - { 42, 87 }, { 43, 65 }, { 45, 59 }, { 48, 79 }, - { 49, 93 }, { 51, 89 }, { 55, 95 }, { 61, 76 }, - { 67, 83 }, { 77, 80 } -}; - -const unsigned char ff_sipr_subpk_size[4] = { 29, 19, 37, 20 }; - static inline void get_strl(AVIOContext *pb, char *buf, int buf_size, int len) { int i; @@ -719,32 +705,6 @@ rm_ac3_swap_bytes (AVStream *st, AVPacket *pkt) } } -/** - * Perform 4-bit block reordering for SIPR data. - * @todo This can be optimized, e.g. use memcpy() if data blocks are aligned - */ -void ff_rm_reorder_sipr_data(uint8_t *buf, int sub_packet_h, int framesize) -{ - int n, bs = sub_packet_h * framesize * 2 / 96; // nibbles per subpacket - - for (n = 0; n < 38; n++) { - int j; - int i = bs * sipr_swaps[n][0]; - int o = bs * sipr_swaps[n][1]; - - /* swap 4bit-nibbles of block 'i' with 'o' */ - for (j = 0; j < bs; j++, i++, o++) { - int x = (buf[i >> 1] >> (4 * (i & 1))) & 0xF, - y = (buf[o >> 1] >> (4 * (o & 1))) & 0xF; - - buf[o >> 1] = (x << (4 * (o & 1))) | - (buf[o >> 1] & (0xF << (4 * !(o & 1)))); - buf[i >> 1] = (y << (4 * (i & 1))) | - (buf[i >> 1] & (0xF << (4 * !(i & 1)))); - } - } -} - int ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *ast, int len, AVPacket *pkt, diff --git a/libavformat/rmsipr.c b/libavformat/rmsipr.c new file mode 100644 index 0000000000..89fbd0e398 --- /dev/null +++ b/libavformat/rmsipr.c @@ -0,0 +1,61 @@ +/* + * tables and functions for demuxing SIPR audio muxed RealMedia style + * + * This file is part of Libav. + * + * 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. + * + * 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "rmsipr.h" + +const unsigned char ff_sipr_subpk_size[4] = { 29, 19, 37, 20 }; + +static const unsigned char sipr_swaps[38][2] = { + { 0, 63 }, { 1, 22 }, { 2, 44 }, { 3, 90 }, + { 5, 81 }, { 7, 31 }, { 8, 86 }, { 9, 58 }, + { 10, 36 }, { 12, 68 }, { 13, 39 }, { 14, 73 }, + { 15, 53 }, { 16, 69 }, { 17, 57 }, { 19, 88 }, + { 20, 34 }, { 21, 71 }, { 24, 46 }, { 25, 94 }, + { 26, 54 }, { 28, 75 }, { 29, 50 }, { 32, 70 }, + { 33, 92 }, { 35, 74 }, { 38, 85 }, { 40, 56 }, + { 42, 87 }, { 43, 65 }, { 45, 59 }, { 48, 79 }, + { 49, 93 }, { 51, 89 }, { 55, 95 }, { 61, 76 }, + { 67, 83 }, { 77, 80 } +}; + +/* This can be optimized, e.g. use memcpy() if data blocks are aligned. */ +void ff_rm_reorder_sipr_data(uint8_t *buf, int sub_packet_h, int framesize) +{ + int n, bs = sub_packet_h * framesize * 2 / 96; // nibbles per subpacket + + for (n = 0; n < 38; n++) { + int j; + int i = bs * sipr_swaps[n][0]; + int o = bs * sipr_swaps[n][1]; + + /* swap 4bit-nibbles of block 'i' with 'o' */ + for (j = 0; j < bs; j++, i++, o++) { + int x = (buf[i >> 1] >> (4 * (i & 1))) & 0xF, + y = (buf[o >> 1] >> (4 * (o & 1))) & 0xF; + + buf[o >> 1] = (x << (4 * (o & 1))) | + (buf[o >> 1] & (0xF << (4 * !(o & 1)))); + buf[i >> 1] = (y << (4 * (i & 1))) | + (buf[i >> 1] & (0xF << (4 * !(i & 1)))); + } + } +} diff --git a/libavformat/rmsipr.h b/libavformat/rmsipr.h new file mode 100644 index 0000000000..c8d3d0a236 --- /dev/null +++ b/libavformat/rmsipr.h @@ -0,0 +1,35 @@ +/* + * tables and functions for demuxing SIPR audio muxed RealMedia style + * + * This file is part of Libav. + * + * 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. + * + * 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_RMSIPR_H +#define AVFORMAT_RMSIPR_H + +#include + +extern const unsigned char ff_sipr_subpk_size[4]; + +/** + * Perform 4-bit block reordering for SIPR data. + * + * @param buf SIPR data + */ +void ff_rm_reorder_sipr_data(uint8_t *buf, int sub_packet_h, int framesize); + +#endif /* AVFORMAT_RMSIPR_H */ From 0fbb62a8e6c6f0b431f736eed1da2cc649253f27 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sun, 14 Oct 2012 07:54:22 +0200 Subject: [PATCH 2/3] build: support asan and tsan toolchain shortcuts --- configure | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/configure b/configure index 86526393a5..870b6ad625 100755 --- a/configure +++ b/configure @@ -2048,6 +2048,16 @@ ranlib="${cross_prefix}${ranlib}" sysinclude_default="${sysroot}/usr/include" case "$toolchain" in + clang-asan) + cc_default="clang" + add_cflags -faddress-sanitizer + add_ldflags -faddress-sanitizer + ;; + clang-tsan) + cc_default="clang" + add_cflags -fthread-sanitizer + add_ldflags -fthread-sanitizer + ;; msvc) cc_default="c99wrap cl" ld_default="c99wrap link" From 4c995fafd861f537360b3717901cdbed6a6844e7 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 13 Oct 2012 22:56:25 +0100 Subject: [PATCH 3/3] configure: simplify get_version() function awk alone can do this, no need for grep. Signed-off-by: Mans Rullgard --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 870b6ad625..a054830d0d 100755 --- a/configure +++ b/configure @@ -3774,7 +3774,7 @@ get_version(){ lcname=$1 name=$(toupper $lcname) file=$source_path/$lcname/version.h - eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }') + eval $(awk "/#define ${name}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file") eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak