From c44cef978bd5c2692606a7a4ef4a7da393147ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 24 Oct 2012 01:05:12 +0300 Subject: smoothstreamingenc: Don't assume streams start from timestamp 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also use dts instead of pts for deciding where to split fragments. Signed-off-by: Martin Storsjö --- libavformat/smoothstreamingenc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index 69d555f9ec..1ed675a272 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -559,12 +559,15 @@ static int ism_write_packet(AVFormatContext *s, AVPacket *pkt) SmoothStreamingContext *c = s->priv_data; AVStream *st = s->streams[pkt->stream_index]; OutputStream *os = &c->streams[pkt->stream_index]; - int64_t end_pts = (c->nb_fragments + 1) * c->min_frag_duration; + int64_t end_dts = (c->nb_fragments + 1) * c->min_frag_duration; int ret; + if (st->first_dts == AV_NOPTS_VALUE) + st->first_dts = pkt->dts; + if ((!c->has_video || st->codec->codec_type == AVMEDIA_TYPE_VIDEO) && - av_compare_ts(pkt->pts, st->time_base, - end_pts, AV_TIME_BASE_Q) >= 0 && + av_compare_ts(pkt->dts - st->first_dts, st->time_base, + end_dts, AV_TIME_BASE_Q) >= 0 && pkt->flags & AV_PKT_FLAG_KEY && os->packets_written) { if ((ret = ism_flush(s, 0)) < 0) -- cgit v1.2.3 From d4c99513f41272b9753e59642724717b834710a0 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 23 Oct 2012 23:33:44 +0100 Subject: configure: generalise 64-bit test Signed-off-by: Mans Rullgard --- configure | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 37cdf1e096..b1c6d4511c 100755 --- a/configure +++ b/configure @@ -2668,13 +2668,20 @@ EOF check_host_cflags -std=c99 check_host_cflags -Wall +check_64bit(){ + arch32=$1 + arch64=$2 + expr=$3 + check_code cc "" "int test[2*($expr) - 1]" && + subarch=$arch64 || subarch=$arch32 +} + case "$arch" in alpha|ia64|mips|parisc|sparc) spic=$shared ;; x86) - subarch="x86_32" - check_code cc "" "int test[(int)sizeof(char*) - 7]" && subarch="x86_64" + check_64bit x86_32 x86_64 'sizeof(void *) > 4' if test "$subarch" = "x86_64"; then spic=$shared fi -- cgit v1.2.3 From 2acda282eb8efac556cb351e91c557e580406294 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 23 Oct 2012 23:34:35 +0100 Subject: configure: detect mips64 automatically Signed-off-by: Mans Rullgard --- configure | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/configure b/configure index b1c6d4511c..9f6eda51d0 100755 --- a/configure +++ b/configure @@ -2453,13 +2453,9 @@ case "$arch" in arm*) arch="arm" ;; - mips|mipsel|IP*) + mips*|IP*) arch="mips" ;; - mips64*) - arch="mips" - subarch="mips64" - ;; parisc|hppa) arch="parisc" ;; @@ -2677,7 +2673,11 @@ check_64bit(){ } case "$arch" in - alpha|ia64|mips|parisc|sparc) + alpha|ia64|parisc|sparc) + spic=$shared + ;; + mips) + check_64bit mips mips64 '_MIPS_SIM > 1' spic=$shared ;; x86) -- cgit v1.2.3 From 56203596aea365387917c40964c03b5156b15e22 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 23 Oct 2012 23:39:40 +0100 Subject: configure: detect ppc64 automatically Signed-off-by: Mans Rullgard --- configure | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 9f6eda51d0..1f48fbeb9c 100755 --- a/configure +++ b/configure @@ -2463,13 +2463,9 @@ case "$arch" in arch="parisc" subarch="parisc64" ;; - "Power Macintosh"|ppc|powerpc) + "Power Macintosh"|ppc*|powerpc*) arch="ppc" ;; - ppc64|powerpc64) - arch="ppc" - subarch="ppc64" - ;; s390|s390x) arch="s390" ;; @@ -2680,6 +2676,9 @@ case "$arch" in check_64bit mips mips64 '_MIPS_SIM > 1' spic=$shared ;; + ppc) + check_64bit ppc ppc64 'sizeof(void *) > 4' + ;; x86) check_64bit x86_32 x86_64 'sizeof(void *) > 4' if test "$subarch" = "x86_64"; then -- cgit v1.2.3 From a6e9d6497739b7b60e3284f03b27883514bbc94a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 24 Oct 2012 00:21:15 +0100 Subject: configure: detect parisc64 automatically Signed-off-by: Mans Rullgard --- configure | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 1f48fbeb9c..079e6dbc00 100755 --- a/configure +++ b/configure @@ -2456,13 +2456,9 @@ case "$arch" in mips*|IP*) arch="mips" ;; - parisc|hppa) + parisc*|hppa*) arch="parisc" ;; - parisc64|hppa64) - arch="parisc" - subarch="parisc64" - ;; "Power Macintosh"|ppc*|powerpc*) arch="ppc" ;; @@ -2669,13 +2665,17 @@ check_64bit(){ } case "$arch" in - alpha|ia64|parisc|sparc) + alpha|ia64|sparc) spic=$shared ;; mips) check_64bit mips mips64 '_MIPS_SIM > 1' spic=$shared ;; + parisc) + check_64bit parisc parisc64 'sizeof(void *) > 4' + spic=$shared + ;; ppc) check_64bit ppc ppc64 'sizeof(void *) > 4' ;; -- cgit v1.2.3 From 5bac2d0c3020587a03cb14e8b6a664a0b92f26c2 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 18 Oct 2012 19:27:51 +0200 Subject: avutil: Move memcpy_backptr() to mem.c The function is used elsewhere and does not belong with the LZO code. --- libavcodec/dfa.c | 2 +- libavcodec/eatgv.c | 2 +- libavcodec/g723_1.c | 2 +- libavcodec/lcldec.c | 2 +- libavcodec/wmavoice.c | 2 +- libavcodec/xan.c | 3 +-- libavcodec/xxan.c | 3 +-- libavutil/lzo.c | 44 +------------------------------------------- libavutil/lzo.h | 11 ----------- libavutil/mem.c | 37 +++++++++++++++++++++++++++++++++++++ libavutil/mem.h | 12 ++++++++++++ 11 files changed, 57 insertions(+), 63 deletions(-) diff --git a/libavcodec/dfa.c b/libavcodec/dfa.c index ae184d7b5f..1598f47c6c 100644 --- a/libavcodec/dfa.c +++ b/libavcodec/dfa.c @@ -24,7 +24,7 @@ #include "bytestream.h" #include "libavutil/imgutils.h" -#include "libavutil/lzo.h" // for av_memcpy_backptr +#include "libavutil/mem.h" typedef struct DfaContext { AVFrame pic; diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c index 404238b6ef..170eeb10d5 100644 --- a/libavcodec/eatgv.c +++ b/libavcodec/eatgv.c @@ -31,8 +31,8 @@ #include "avcodec.h" #define BITSTREAM_READER_LE #include "get_bits.h" -#include "libavutil/lzo.h" #include "libavutil/imgutils.h" +#include "libavutil/mem.h" #define EA_PREAMBLE_SIZE 8 #define kVGT_TAG MKTAG('k', 'V', 'G', 'T') diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c index 5c213da64c..342c63473d 100644 --- a/libavcodec/g723_1.c +++ b/libavcodec/g723_1.c @@ -27,7 +27,7 @@ #define BITSTREAM_READER_LE #include "libavutil/audioconvert.h" -#include "libavutil/lzo.h" +#include "libavutil/mem.h" #include "libavutil/opt.h" #include "avcodec.h" #include "get_bits.h" diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c index 6b101ae6d1..c80d0fe30e 100644 --- a/libavcodec/lcldec.c +++ b/libavcodec/lcldec.c @@ -41,10 +41,10 @@ #include #include +#include "libavutil/mem.h" #include "avcodec.h" #include "bytestream.h" #include "lcl.h" -#include "libavutil/lzo.h" #if CONFIG_ZLIB_DECODER #include diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 63caad2440..466d1ec495 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -29,6 +29,7 @@ #include +#include "libavutil/mem.h" #include "dsputil.h" #include "avcodec.h" #include "get_bits.h" @@ -38,7 +39,6 @@ #include "acelp_vectors.h" #include "acelp_filters.h" #include "lsp.h" -#include "libavutil/lzo.h" #include "dct.h" #include "rdft.h" #include "sinewin.h" diff --git a/libavcodec/xan.c b/libavcodec/xan.c index 586320b55e..e6bfc0da06 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -33,12 +33,11 @@ #include #include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" #include "avcodec.h" #include "bytestream.h" #define BITSTREAM_READER_LE #include "get_bits.h" -// for av_memcpy_backptr -#include "libavutil/lzo.h" #define RUNTIME_GAMMA 0 diff --git a/libavcodec/xxan.c b/libavcodec/xxan.c index b06d314d0f..2a5a8ca631 100644 --- a/libavcodec/xxan.c +++ b/libavcodec/xxan.c @@ -22,11 +22,10 @@ #include "avcodec.h" #include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" #include "bytestream.h" #define BITSTREAM_READER_LE #include "get_bits.h" -// for av_memcpy_backptr -#include "libavutil/lzo.h" typedef struct XanContext { AVCodecContext *avctx; diff --git a/libavutil/lzo.c b/libavutil/lzo.c index c17d32f362..eff3cd2333 100644 --- a/libavutil/lzo.c +++ b/libavutil/lzo.c @@ -100,8 +100,6 @@ static inline void copy(LZOContext *c, int cnt) c->out = dst + cnt; } -static inline void memcpy_backptr(uint8_t *dst, int back, int cnt); - /** * @brief Copies previously decoded bytes to current position. * @param back how many bytes back we start @@ -122,50 +120,10 @@ static inline void copy_backptr(LZOContext *c, int back, int cnt) cnt = FFMAX(c->out_end - dst, 0); c->error |= AV_LZO_OUTPUT_FULL; } - memcpy_backptr(dst, back, cnt); + av_memcpy_backptr(dst, back, cnt); c->out = dst + cnt; } -static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) -{ - const uint8_t *src = &dst[-back]; - if (back == 1) { - memset(dst, *src, cnt); - } else { - if (cnt >= 4) { - AV_COPY16U(dst, src); - AV_COPY16U(dst + 2, src + 2); - src += 4; - dst += 4; - cnt -= 4; - } - if (cnt >= 8) { - AV_COPY16U(dst, src); - AV_COPY16U(dst + 2, src + 2); - AV_COPY16U(dst + 4, src + 4); - AV_COPY16U(dst + 6, src + 6); - src += 8; - dst += 8; - cnt -= 8; - } - if (cnt > 0) { - int blocklen = back; - while (cnt > blocklen) { - memcpy(dst, src, blocklen); - dst += blocklen; - cnt -= blocklen; - blocklen <<= 1; - } - memcpy(dst, src, cnt); - } - } -} - -void av_memcpy_backptr(uint8_t *dst, int back, int cnt) -{ - memcpy_backptr(dst, back, cnt); -} - int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { int state = 0; diff --git a/libavutil/lzo.h b/libavutil/lzo.h index a84b9bd15d..9d7e8f1dc1 100644 --- a/libavutil/lzo.h +++ b/libavutil/lzo.h @@ -59,17 +59,6 @@ */ int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); -/** - * @brief deliberately overlapping memcpy implementation - * @param dst destination buffer - * @param back how many bytes back we start (the initial size of the overlapping window) - * @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. - */ -void av_memcpy_backptr(uint8_t *dst, int back, int cnt); - /** * @} */ diff --git a/libavutil/mem.c b/libavutil/mem.c index 16c1adb014..feba3163b0 100644 --- a/libavutil/mem.c +++ b/libavutil/mem.c @@ -27,6 +27,7 @@ #include "config.h" #include +#include #include #include #if HAVE_MALLOC_H @@ -34,6 +35,7 @@ #endif #include "avutil.h" +#include "intreadwrite.h" #include "mem.h" /* here we can use OS-dependent allocation functions */ @@ -177,3 +179,38 @@ char *av_strdup(const char *s) } return ptr; } + +void av_memcpy_backptr(uint8_t *dst, int back, int cnt) +{ + const uint8_t *src = &dst[-back]; + if (back == 1) { + memset(dst, *src, cnt); + } else { + if (cnt >= 4) { + AV_COPY16U(dst, src); + AV_COPY16U(dst + 2, src + 2); + src += 4; + dst += 4; + cnt -= 4; + } + if (cnt >= 8) { + AV_COPY16U(dst, src); + AV_COPY16U(dst + 2, src + 2); + AV_COPY16U(dst + 4, src + 4); + AV_COPY16U(dst + 6, src + 6); + src += 8; + dst += 8; + cnt -= 8; + } + if (cnt > 0) { + int blocklen = back; + while (cnt > blocklen) { + memcpy(dst, src, blocklen); + dst += blocklen; + cnt -= blocklen; + blocklen <<= 1; + } + memcpy(dst, src, cnt); + } + } +} diff --git a/libavutil/mem.h b/libavutil/mem.h index 4f14f27a91..8f4722447d 100644 --- a/libavutil/mem.h +++ b/libavutil/mem.h @@ -27,6 +27,7 @@ #define AVUTIL_MEM_H #include +#include #include "attributes.h" #include "avutil.h" @@ -164,6 +165,17 @@ char *av_strdup(const char *s) av_malloc_attrib; */ void av_freep(void *ptr); +/** + * @brief deliberately overlapping memcpy implementation + * @param dst destination buffer + * @param back how many bytes back we start (the initial size of the overlapping window) + * @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. + */ +void av_memcpy_backptr(uint8_t *dst, int back, int cnt); + /** * @} */ -- cgit v1.2.3 From 2a91ada8282f18d2807abee5188225bba1b19bda Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 18 Oct 2012 19:48:27 +0200 Subject: avutil: Make LZO decoder code configure-time selectable --- configure | 6 +++++- libavformat/matroskadec.c | 9 +++++++-- libavutil/Makefile | 6 ++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 079e6dbc00..df07a6f4fb 100755 --- a/configure +++ b/configure @@ -120,6 +120,7 @@ Component options: --disable-dct disable DCT code --disable-dwt disable DWT code --disable-lsp disable LSP code + --disable-lzo disable LZO decoder code --disable-mdct disable MDCT code --disable-rdft disable RDFT code --disable-fft disable FFT code @@ -1029,6 +1030,7 @@ CONFIG_LIST=" libxavs libxvid lsp + lzo mdct memalign_hack network @@ -1437,6 +1439,7 @@ binkaudio_dct_decoder_select="mdct rdft dct sinewin" binkaudio_rdft_decoder_select="mdct rdft sinewin" cavs_decoder_select="golomb mpegvideo" cook_decoder_select="mdct sinewin" +cscd_decoder_select="lzo" cscd_decoder_suggest="zlib" dca_decoder_select="mdct" dnxhd_encoder_select="aandcttables mpegvideoenc" @@ -1516,6 +1519,7 @@ msmpeg4v3_encoder_select="h263_encoder" mss2_decoder_select="vc1_decoder" nellymoser_decoder_select="mdct sinewin" nellymoser_encoder_select="mdct sinewin" +nuv_decoder_select="lzo" png_decoder_select="zlib" png_encoder_select="zlib" qcelp_decoder_select="lsp" @@ -1628,7 +1632,7 @@ eac3_demuxer_select="ac3_parser" flac_demuxer_select="flac_parser" ipod_muxer_select="mov_muxer" matroska_audio_muxer_select="matroska_muxer" -matroska_demuxer_suggest="zlib bzlib" +matroska_demuxer_suggest="bzlib lzo zlib" mov_demuxer_suggest="zlib" mp3_demuxer_select="mpegaudio_parser" mp4_muxer_select="mov_muxer" diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 68c936c15a..26f8707e83 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1011,6 +1011,7 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size, memcpy(pkt_data + header_size, data, isize); break; } +#if CONFIG_LZO case MATROSKA_TRACK_ENCODING_COMP_LZO: do { olen = pkt_size *= 3; @@ -1028,6 +1029,7 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size, } pkt_size -= olen; break; +#endif #if CONFIG_ZLIB case MATROSKA_TRACK_ENCODING_COMP_ZLIB: { z_stream zstream = {0}; @@ -1436,14 +1438,17 @@ static int matroska_read_header(AVFormatContext *s) "Multiple combined encodings not supported"); } else if (encodings_list->nb_elem == 1) { if (encodings[0].type || - (encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP && + ( #if CONFIG_ZLIB encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_ZLIB && #endif #if CONFIG_BZLIB encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_BZLIB && #endif - encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO)) { +#if CONFIG_LZO + encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO && +#endif + encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP)) { encodings[0].scope = 0; av_log(matroska->ctx, AV_LOG_ERROR, "Unsupported encoding type"); diff --git a/libavutil/Makefile b/libavutil/Makefile index 227a57efc2..45f8e9076c 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -24,7 +24,6 @@ HEADERS = adler32.h \ intreadwrite.h \ lfg.h \ log.h \ - lzo.h \ mathematics.h \ md5.h \ mem.h \ @@ -42,6 +41,8 @@ HEADERS = adler32.h \ version.h \ xtea.h \ +HEADERS-$(CONFIG_LZO) += lzo.h + ARCH_HEADERS = bswap.h \ intmath.h \ intreadwrite.h \ @@ -71,7 +72,6 @@ OBJS = adler32.o \ log.o \ log2.o \ log2_tab.o \ - lzo.o \ mathematics.o \ md5.o \ mem.o \ @@ -89,6 +89,8 @@ OBJS = adler32.o \ utils.o \ xtea.o \ +OBJS-$(CONFIG_LZO) += lzo.o + OBJS += $(COMPAT_OBJS:%=../compat/%) SKIPHEADERS = old_pix_fmts.h -- cgit v1.2.3