From 9dd94f8379a0f7b3c820bf73c45fa888971c7432 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Mon, 28 Mar 2011 13:54:18 -0700 Subject: [PATCH 1/7] mov: Add support for zero-sized stsc runs. A zero sized stsc run doesn't make a lot of sense but the spec does not prohibit them and MPlayer VLC demuxers support them. Signed-off-by: Anton Khirnov --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 94f19a684a..b57c1aab1c 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1553,7 +1553,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st) for (i = 0; i < sc->chunk_count; i++) { current_offset = sc->chunk_offsets[i]; - if (stsc_index + 1 < sc->stsc_count && + while (stsc_index + 1 < sc->stsc_count && i + 1 == sc->stsc_data[stsc_index + 1].first) stsc_index++; for (j = 0; j < sc->stsc_data[stsc_index].count; j++) { From cb7e2c1ca864a2ff44c851689ba8a2d4a81dfd27 Mon Sep 17 00:00:00 2001 From: Kharkov Alexander Date: Fri, 18 Mar 2011 08:26:51 +0100 Subject: [PATCH 2/7] flvdec: read index stored in the 'keyframes' tag. 'keyframes' metatag is not part of the standard, it is just convention to use such kind of metatag information for indexing. Structure is following, it allows to have it inconsistent: keyframes: times (array): time0 (num) time1 (num) time2 (num) filepositions (array) position0 (num) position1 (num) Signed-off-by: Anton Khirnov --- libavformat/flvdec.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 2152f7d55a..972b4d95dd 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -31,6 +31,10 @@ #include "avio_internal.h" #include "flv.h" +#define KEYFRAMES_TAG "keyframes" +#define KEYFRAMES_TIMESTAMP_TAG "times" +#define KEYFRAMES_BYTEOFFSET_TAG "filepositions" + typedef struct { int wrong_dts; ///< wrong dts due to negative cts } FLVContext; @@ -125,6 +129,64 @@ static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize) { return length; } +static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream *vstream, int64_t max_pos) { + unsigned int arraylen = 0, timeslen = 0, fileposlen = 0, i; + double num_val; + char str_val[256]; + int64_t *times = NULL; + int64_t *filepositions = NULL; + int ret = 0; + + while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) { + int64_t* current_array; + + // Expect array object in context + if (avio_r8(ioc) != AMF_DATA_TYPE_ARRAY) + break; + + arraylen = avio_rb32(ioc); + /* + * Expect only 'times' or 'filepositions' sub-arrays in other case refuse to use such metadata + * for indexing + */ + if (!strcmp(KEYFRAMES_TIMESTAMP_TAG, str_val) && !times) { + if (!(times = av_mallocz(sizeof(*times) * arraylen))) { + ret = AVERROR(ENOMEM); + goto finish; + } + timeslen = arraylen; + current_array = times; + } else if (!strcmp(KEYFRAMES_BYTEOFFSET_TAG, str_val) && !filepositions) { + if (!(filepositions = av_mallocz(sizeof(*filepositions) * arraylen))) { + ret = AVERROR(ENOMEM); + goto finish; + } + fileposlen = arraylen; + current_array = filepositions; + } else // unexpected metatag inside keyframes, will not use such metadata for indexing + break; + + for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++) { + if (avio_r8(ioc) != AMF_DATA_TYPE_NUMBER) + goto finish; + num_val = av_int2dbl(avio_rb64(ioc)); + current_array[i] = num_val; + } + } + + if (timeslen == fileposlen) + for(i = 0; i < arraylen; i++) + av_add_index_entry(vstream, filepositions[i], times[i]*1000, 0, 0, AVINDEX_KEYFRAME); + else + av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n"); + +finish: + av_freep(×); + av_freep(&filepositions); + avio_seek(ioc, max_pos, SEEK_SET); + return ret; +} + static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, int64_t max_pos, int depth) { AVCodecContext *acodec, *vcodec; AVIOContext *ioc; @@ -149,6 +211,10 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst case AMF_DATA_TYPE_OBJECT: { unsigned int keylen; + if (!strcmp(KEYFRAMES_TAG, key) && depth == 1) + if (parse_keyframes_index(s, ioc, vstream, max_pos) < 0) + return -1; + while(avio_tell(ioc) < max_pos - 2 && (keylen = avio_rb16(ioc))) { avio_skip(ioc, keylen); //skip key string if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0) From 7f6e05cdfd1242a6774e89283b6e2cefde191590 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 31 Mar 2011 01:28:08 +0100 Subject: [PATCH 3/7] ac3enc: simplify sym_quant() These expressions are equivalent since levels is always odd, and overflow is impossible due to the constraints set by the assert(). Signed-off-by: Mans Rullgard --- libavcodec/ac3enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 18e4dae26a..a869d7de9d 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1192,7 +1192,7 @@ static int compute_bit_allocation(AC3EncodeContext *s) */ static inline int sym_quant(int c, int e, int levels) { - int v = ((((levels * c) >> (24 - e)) + 1) >> 1) + (levels >> 1); + int v = (((levels * c) >> (24 - e)) + levels) >> 1; av_assert2(v >= 0 && v < levels); return v; } From 2f97b12eaf8ada30b3884604d66dbdf51e727b67 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 30 Mar 2011 21:23:04 +0100 Subject: [PATCH 4/7] Include dependencies for test programs This makes sure the various *-test programs are correctly rebuilt when necessary. Signed-off-by: Mans Rullgard --- common.mak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common.mak b/common.mak index 6daf77cc07..03fae6f805 100644 --- a/common.mak +++ b/common.mak @@ -89,7 +89,7 @@ FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS) EXAMPLES := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES))) OBJS := $(addprefix $(SUBDIR),$(sort $(OBJS))) -TESTOBJS := $(addprefix $(SUBDIR),$(TESTOBJS)) +TESTOBJS := $(addprefix $(SUBDIR),$(TESTOBJS) $(TESTPROGS:%=%-test.o)) TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS))) HOSTOBJS := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS))) HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS))) @@ -111,4 +111,4 @@ CLEANSUFFIXES = *.d *.o *~ *.ho *.map *.ver DISTCLEANSUFFIXES = *.pc LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp --include $(wildcard $(OBJS:.o=.d)) +-include $(wildcard $(OBJS:.o=.d) $(TESTOBJS:.o=.d)) From 7087ce08c84dd20404ba258096530cc547d25c15 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 26 Mar 2011 15:20:30 +0000 Subject: [PATCH 5/7] Fixed-point FFT and MDCT --- libavcodec/Makefile | 10 ++++-- libavcodec/costablegen.c | 26 +++++++++++++-- libavcodec/fft-internal.h | 67 +++++++++++++++++++++++++++++++++++++++ libavcodec/fft.c | 53 +++++++++++++++++-------------- libavcodec/fft.h | 41 +++++++++++++++++++++--- libavcodec/fft_fixed.c | 20 ++++++++++++ libavcodec/fft_float.c | 20 ++++++++++++ libavcodec/mdct.c | 32 ++++++++----------- libavcodec/mdct_fixed.c | 20 ++++++++++++ libavcodec/mdct_float.c | 20 ++++++++++++ 10 files changed, 257 insertions(+), 52 deletions(-) create mode 100644 libavcodec/fft-internal.h create mode 100644 libavcodec/fft_fixed.c create mode 100644 libavcodec/fft_float.c create mode 100644 libavcodec/mdct_fixed.c create mode 100644 libavcodec/mdct_float.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 2dea2036ad..4f3392fcf5 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -31,15 +31,16 @@ OBJS-$(CONFIG_ENCODERS) += faandct.o jfdctfst.o jfdctint.o OBJS-$(CONFIG_DCT) += dct.o OBJS-$(CONFIG_DWT) += dwt.o OBJS-$(CONFIG_DXVA2) += dxva2.o -FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o -OBJS-$(CONFIG_FFT) += avfft.o fft.o $(FFT-OBJS-yes) +FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o cos_fixed_tables.o +OBJS-$(CONFIG_FFT) += avfft.o fft_fixed.o fft_float.o \ + $(FFT-OBJS-yes) OBJS-$(CONFIG_GOLOMB) += golomb.o OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o OBJS-$(CONFIG_H264PRED) += h264pred.o OBJS-$(CONFIG_HUFFMAN) += huffman.o OBJS-$(CONFIG_LPC) += lpc.o OBJS-$(CONFIG_LSP) += lsp.o -OBJS-$(CONFIG_MDCT) += mdct.o +OBJS-$(CONFIG_MDCT) += mdct_fixed.o mdct_float.o RDFT-OBJS-$(CONFIG_HARDCODED_TABLES) += sin_tables.o OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes) OBJS-$(CONFIG_SINEWIN) += sinewin.o @@ -672,6 +673,9 @@ $(SUBDIR)dct-test$(EXESUF): $(SUBDIR)dctref.o $(SUBDIR)cos_tables.c: $(SUBDIR)costablegen$(HOSTEXESUF) $(M)./$< > $@ +$(SUBDIR)cos_fixed_tables.c: $(SUBDIR)costablegen$(HOSTEXESUF) + $(M)./$< cos fixed > $@ + $(SUBDIR)sin_tables.c: $(SUBDIR)costablegen$(HOSTEXESUF) $(M)./$< sin > $@ diff --git a/libavcodec/costablegen.c b/libavcodec/costablegen.c index 33afd8de2d..65c492696b 100644 --- a/libavcodec/costablegen.c +++ b/libavcodec/costablegen.c @@ -29,14 +29,33 @@ #endif #define BITS 16 #define FLOATFMT "%.18e" +#define FIXEDFMT "%6d" + +static int clip_f15(int v) +{ + return v < -32767 ? -32767 : + v > 32767 ? 32767 : + v; +} + +static void printval(double val, int fixed) +{ + if (fixed) + printf(" "FIXEDFMT",", clip_f15(lrint(val * (double)(1<<15)))); + else + printf(" "FLOATFMT",", val); + +} int main(int argc, char *argv[]) { int i, j; - int do_sin = argc == 2 && !strcmp(argv[1], "sin"); + int do_sin = argc > 1 && !strcmp(argv[1], "sin"); + int fixed = argc > 2 && !strcmp(argv[2], "fixed"); double (*func)(double) = do_sin ? sin : cos; printf("/* This file was generated by libavcodec/costablegen */\n"); + printf("#define CONFIG_FFT_FLOAT %d\n", !fixed); printf("#include \"libavcodec/%s\"\n", do_sin ? "rdft.h" : "fft.h"); for (i = 4; i <= BITS; i++) { int m = 1 << i; @@ -46,11 +65,12 @@ int main(int argc, char *argv[]) int idx = j > m/4 ? m/2 - j : j; if (do_sin && j >= m/4) idx = m/4 - j; - printf(" "FLOATFMT",", func(idx*freq)); + printval(func(idx*freq), fixed); if ((j & 3) == 3) printf("\n "); } - printf(" "FLOATFMT"\n};\n", func(do_sin ? -(m/4 - 1)*freq : freq)); + printval(func(do_sin ? -(m/4 - 1)*freq : freq), fixed); + printf("\n};\n"); } return 0; } diff --git a/libavcodec/fft-internal.h b/libavcodec/fft-internal.h new file mode 100644 index 0000000000..1f240dbd18 --- /dev/null +++ b/libavcodec/fft-internal.h @@ -0,0 +1,67 @@ +/* + * 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 AVCODEC_FFT_INTERNAL_H +#define AVCODEC_FFT_INTERNAL_H + +#if CONFIG_FFT_FLOAT + +#define FIX15(v) (v) +#define sqrthalf (float)M_SQRT1_2 + +#define BF(x, y, a, b) do { \ + x = a - b; \ + y = a + b; \ + } while (0) + +#define CMUL(dre, dim, are, aim, bre, bim) do { \ + (dre) = (are) * (bre) - (aim) * (bim); \ + (dim) = (are) * (bim) + (aim) * (bre); \ + } while (0) + +#else + +#include "libavutil/intmath.h" +#include "mathops.h" + +#define SCALE_FLOAT(a, bits) lrint((a) * (double)(1 << (bits))) +#define FIX15(a) av_clip(SCALE_FLOAT(a, 15), -32767, 32767) + +#define sqrthalf ((int16_t)((1<<15)*M_SQRT1_2)) + +#define BF(x, y, a, b) do { \ + x = (a - b) >> 1; \ + y = (a + b) >> 1; \ + } while (0) + +#define CMUL(dre, dim, are, aim, bre, bim) do { \ + (dre) = (MUL16(are, bre) - MUL16(aim, bim)) >> 15; \ + (dim) = (MUL16(are, bim) + MUL16(aim, bre)) >> 15; \ + } while (0) + +#endif /* CONFIG_FFT_FLOAT */ + +#define ff_imdct_calc_c FFT_NAME(ff_imdct_calc_c) +#define ff_imdct_half_c FFT_NAME(ff_imdct_half_c) +#define ff_mdct_calc_c FFT_NAME(ff_mdct_calc_c) + +void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); +void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input); +void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); + +#endif /* AVCODEC_FFT_INTERNAL_H */ diff --git a/libavcodec/fft.c b/libavcodec/fft.c index 76e9c4139e..2da5b43d5f 100644 --- a/libavcodec/fft.c +++ b/libavcodec/fft.c @@ -30,6 +30,7 @@ #include #include "libavutil/mathematics.h" #include "fft.h" +#include "fft-internal.h" /* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */ #if !CONFIG_HARDCODED_TABLES @@ -47,10 +48,21 @@ COSTABLE(16384); COSTABLE(32768); COSTABLE(65536); #endif -COSTABLE_CONST FFTSample * const ff_cos_tabs[] = { +COSTABLE_CONST FFTSample * const FFT_NAME(ff_cos_tabs)[] = { NULL, NULL, NULL, NULL, - ff_cos_16, ff_cos_32, ff_cos_64, ff_cos_128, ff_cos_256, ff_cos_512, ff_cos_1024, - ff_cos_2048, ff_cos_4096, ff_cos_8192, ff_cos_16384, ff_cos_32768, ff_cos_65536, + FFT_NAME(ff_cos_16), + FFT_NAME(ff_cos_32), + FFT_NAME(ff_cos_64), + FFT_NAME(ff_cos_128), + FFT_NAME(ff_cos_256), + FFT_NAME(ff_cos_512), + FFT_NAME(ff_cos_1024), + FFT_NAME(ff_cos_2048), + FFT_NAME(ff_cos_4096), + FFT_NAME(ff_cos_8192), + FFT_NAME(ff_cos_16384), + FFT_NAME(ff_cos_32768), + FFT_NAME(ff_cos_65536), }; static void ff_fft_permute_c(FFTContext *s, FFTComplex *z); @@ -73,9 +85,9 @@ av_cold void ff_init_ff_cos_tabs(int index) int i; int m = 1<mdct_calc = ff_mdct_calc_c; #endif +#if CONFIG_FFT_FLOAT if (ARCH_ARM) ff_fft_init_arm(s); if (HAVE_ALTIVEC) ff_fft_init_altivec(s); if (HAVE_MMX) ff_fft_init_mmx(s); +#endif for(j=4; j<=nbits; j++) { ff_init_ff_cos_tabs(j); @@ -144,13 +158,6 @@ av_cold void ff_fft_end(FFTContext *s) av_freep(&s->tmp_buf); } -#define sqrthalf (float)M_SQRT1_2 - -#define BF(x,y,a,b) {\ - x = a - b;\ - y = a + b;\ -} - #define BUTTERFLIES(a0,a1,a2,a3) {\ BF(t3, t5, t5, t1);\ BF(a2.re, a0.re, a0.re, t5);\ @@ -174,10 +181,8 @@ av_cold void ff_fft_end(FFTContext *s) } #define TRANSFORM(a0,a1,a2,a3,wre,wim) {\ - t1 = a2.re * wre + a2.im * wim;\ - t2 = a2.im * wre - a2.re * wim;\ - t5 = a3.re * wre - a3.im * wim;\ - t6 = a3.im * wre + a3.re * wim;\ + CMUL(t1, t2, a2.re, a2.im, wre, -wim);\ + CMUL(t5, t6, a3.re, a3.im, wre, wim);\ BUTTERFLIES(a0,a1,a2,a3)\ } @@ -193,7 +198,7 @@ av_cold void ff_fft_end(FFTContext *s) #define PASS(name)\ static void name(FFTComplex *z, const FFTSample *wre, unsigned int n)\ {\ - FFTSample t1, t2, t3, t4, t5, t6;\ + FFTDouble t1, t2, t3, t4, t5, t6;\ int o1 = 2*n;\ int o2 = 4*n;\ int o3 = 6*n;\ @@ -222,12 +227,12 @@ static void fft##n(FFTComplex *z)\ fft##n2(z);\ fft##n4(z+n4*2);\ fft##n4(z+n4*3);\ - pass(z,ff_cos_##n,n4/2);\ + pass(z,FFT_NAME(ff_cos_##n),n4/2);\ } static void fft4(FFTComplex *z) { - FFTSample t1, t2, t3, t4, t5, t6, t7, t8; + FFTDouble t1, t2, t3, t4, t5, t6, t7, t8; BF(t3, t1, z[0].re, z[1].re); BF(t8, t6, z[3].re, z[2].re); @@ -241,7 +246,7 @@ static void fft4(FFTComplex *z) static void fft8(FFTComplex *z) { - FFTSample t1, t2, t3, t4, t5, t6, t7, t8; + FFTDouble t1, t2, t3, t4, t5, t6, t7, t8; fft4(z); @@ -262,7 +267,9 @@ static void fft8(FFTComplex *z) #if !CONFIG_SMALL static void fft16(FFTComplex *z) { - FFTSample t1, t2, t3, t4, t5, t6; + FFTDouble t1, t2, t3, t4, t5, t6; + FFTSample cos_16_1 = FFT_NAME(ff_cos_16)[1]; + FFTSample cos_16_3 = FFT_NAME(ff_cos_16)[3]; fft8(z); fft4(z+8); @@ -270,8 +277,8 @@ static void fft16(FFTComplex *z) TRANSFORM_ZERO(z[0],z[4],z[8],z[12]); TRANSFORM(z[2],z[6],z[10],z[14],sqrthalf,sqrthalf); - TRANSFORM(z[1],z[5],z[9],z[13],ff_cos_16[1],ff_cos_16[3]); - TRANSFORM(z[3],z[7],z[11],z[15],ff_cos_16[3],ff_cos_16[1]); + TRANSFORM(z[1],z[5],z[9],z[13],cos_16_1,cos_16_3); + TRANSFORM(z[3],z[7],z[11],z[15],cos_16_3,cos_16_1); } #else DECL_FFT(16,8,4) diff --git a/libavcodec/fft.h b/libavcodec/fft.h index 36be9962ad..2f13e5fdb3 100644 --- a/libavcodec/fft.h +++ b/libavcodec/fft.h @@ -22,11 +22,37 @@ #ifndef AVCODEC_FFT_H #define AVCODEC_FFT_H +#ifndef CONFIG_FFT_FLOAT +#define CONFIG_FFT_FLOAT 1 +#endif + #include #include "config.h" #include "libavutil/mem.h" + +#if CONFIG_FFT_FLOAT + #include "avfft.h" +#define FFT_NAME(x) x + +typedef float FFTDouble; + +#else + +#define FFT_NAME(x) x ## _fixed + +typedef int16_t FFTSample; +typedef int FFTDouble; + +typedef struct FFTComplex { + int16_t re, im; +} FFTComplex; + +typedef struct FFTContext FFTContext; + +#endif /* CONFIG_FFT_FLOAT */ + /* FFT computation */ struct FFTContext { @@ -66,7 +92,7 @@ struct FFTContext { #endif #define COSTABLE(size) \ - COSTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_cos_##size)[size/2] + COSTABLE_CONST DECLARE_ALIGNED(16, FFTSample, FFT_NAME(ff_cos_##size))[size/2] extern COSTABLE(16); extern COSTABLE(32); @@ -81,7 +107,9 @@ extern COSTABLE(8192); extern COSTABLE(16384); extern COSTABLE(32768); extern COSTABLE(65536); -extern COSTABLE_CONST FFTSample* const ff_cos_tabs[17]; +extern COSTABLE_CONST FFTSample* const FFT_NAME(ff_cos_tabs)[17]; + +#define ff_init_ff_cos_tabs FFT_NAME(ff_init_ff_cos_tabs) /** * Initialize the cosine table in ff_cos_tabs[index] @@ -89,6 +117,9 @@ extern COSTABLE_CONST FFTSample* const ff_cos_tabs[17]; */ void ff_init_ff_cos_tabs(int index); +#define ff_fft_init FFT_NAME(ff_fft_init) +#define ff_fft_end FFT_NAME(ff_fft_end) + /** * Set up a complex FFT. * @param nbits log2 of the length of the input array @@ -102,10 +133,10 @@ void ff_fft_init_arm(FFTContext *s); void ff_fft_end(FFTContext *s); +#define ff_mdct_init FFT_NAME(ff_mdct_init) +#define ff_mdct_end FFT_NAME(ff_mdct_end) + int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale); -void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); -void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input); -void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); void ff_mdct_end(FFTContext *s); #endif /* AVCODEC_FFT_H */ diff --git a/libavcodec/fft_fixed.c b/libavcodec/fft_fixed.c new file mode 100644 index 0000000000..b28091d35c --- /dev/null +++ b/libavcodec/fft_fixed.c @@ -0,0 +1,20 @@ +/* + * 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 + */ + +#define CONFIG_FFT_FLOAT 0 +#include "fft.c" diff --git a/libavcodec/fft_float.c b/libavcodec/fft_float.c new file mode 100644 index 0000000000..24c9fdb366 --- /dev/null +++ b/libavcodec/fft_float.c @@ -0,0 +1,20 @@ +/* + * 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 + */ + +#define CONFIG_FFT_FLOAT 1 +#include "fft.c" diff --git a/libavcodec/mdct.c b/libavcodec/mdct.c index 9edb57760e..6f64534273 100644 --- a/libavcodec/mdct.c +++ b/libavcodec/mdct.c @@ -24,12 +24,19 @@ #include "libavutil/common.h" #include "libavutil/mathematics.h" #include "fft.h" +#include "fft-internal.h" /** * @file * MDCT/IMDCT transforms. */ +#if CONFIG_FFT_FLOAT +# define RSCALE(x) (x) +#else +# define RSCALE(x) ((x) >> 1) +#endif + /** * init MDCT or IMDCT computation. */ @@ -70,8 +77,8 @@ av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale) scale = sqrt(fabs(scale)); for(i=0;itcos[i*tstep] = -cos(alpha) * scale; - s->tsin[i*tstep] = -sin(alpha) * scale; + s->tcos[i*tstep] = FIX15(-cos(alpha) * scale); + s->tsin[i*tstep] = FIX15(-sin(alpha) * scale); } return 0; fail: @@ -79,17 +86,6 @@ av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale) return -1; } -/* complex multiplication: p = a * b */ -#define CMUL(pre, pim, are, aim, bre, bim) \ -{\ - FFTSample _are = (are);\ - FFTSample _aim = (aim);\ - FFTSample _bre = (bre);\ - FFTSample _bim = (bim);\ - (pre) = _are * _bre - _aim * _bim;\ - (pim) = _are * _bim + _aim * _bre;\ -} - /** * Compute the middle half of the inverse MDCT of size N = 2^nbits, * thus excluding the parts that can be derived by symmetry @@ -161,7 +157,7 @@ void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input) void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input) { int i, j, n, n8, n4, n2, n3; - FFTSample re, im; + FFTDouble re, im; const uint16_t *revtab = s->revtab; const FFTSample *tcos = s->tcos; const FFTSample *tsin = s->tsin; @@ -175,13 +171,13 @@ void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input) /* pre rotation */ for(i=0;i Date: Tue, 25 Jan 2011 10:48:38 +0200 Subject: [PATCH 6/7] configure: Initial support for --target-os=symbian MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- configure | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure b/configure index fab4f2b2fc..dbcada5385 100755 --- a/configure +++ b/configure @@ -1822,7 +1822,7 @@ set_default host_cc exesuf() { case $1 in - mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;; + mingw32*|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;; esac } @@ -2480,6 +2480,11 @@ case $target_os in add_cppflags -D_QNX_SOURCE network_extralibs="-lsocket" ;; + symbian) + SLIBSUF=".dll" + enable dos_paths + add_cflags --include=$sysinclude/gcce/gcce.h + ;; none) ;; *) From e006d71fa849542eb27146efac629288703b3d75 Mon Sep 17 00:00:00 2001 From: Jindrich Makovicka Date: Thu, 31 Mar 2011 16:58:50 +0200 Subject: [PATCH 7/7] mpegts: propagate avio EOF in read_packet() Allows distinguishing between EOF and IO error in read_packet return code. Signed-off-by: Jindrich Makovicka Signed-off-by: Anton Khirnov --- libavformat/mpegts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index abdb000445..62e9dcbbd9 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1350,7 +1350,7 @@ static int read_packet(AVFormatContext *s, uint8_t *buf, int raw_packet_size) for(;;) { len = avio_read(pb, buf, TS_PACKET_SIZE); if (len != TS_PACKET_SIZE) - return AVERROR(EIO); + return len < 0 ? len : AVERROR_EOF; /* check paquet sync byte */ if (buf[0] != 0x47) { /* find a new packet start */