From 5b170c0bea06c5556fe5a74f436c46a88e69e8fc Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 18 Aug 2012 20:22:10 +0100 Subject: x86: remove FASTDIV inline asm GCC 4.3 and later do the right thing with the plain C code. Earlier versions in 32-bit mode generate one extra instruction, needlessly zeroing what would be the high half of the shifted value. At least two gcc configurations miscompile the inline asm in some situations. In 64-bit mode, all gcc versions generate imul r64, r64 followed by shr. On Intel i7 and later, this imul is faster 32-bit mul. On older Intel and all AMD, it is slightly slower. On Atom it is much slower. Considering where the FASTDIV macro is used, any overall negative performance impact of this change should be negligible. If anyone cares, they should file a bug against gcc and get the instruction selection fixed. Signed-off-by: Mans Rullgard --- libavutil/intmath.h | 2 -- libavutil/x86/intmath.h | 37 ------------------------------------- 2 files changed, 39 deletions(-) delete mode 100644 libavutil/x86/intmath.h diff --git a/libavutil/intmath.h b/libavutil/intmath.h index 1be96da..ba198c9 100644 --- a/libavutil/intmath.h +++ b/libavutil/intmath.h @@ -34,8 +34,6 @@ extern const uint32_t ff_inverse[257]; #if ARCH_ARM # include "arm/intmath.h" -#elif ARCH_X86 -# include "x86/intmath.h" #endif #if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4) diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h deleted file mode 100644 index b23c0f1..0000000 --- a/libavutil/x86/intmath.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2010 Mans Rullgard - * - * 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 AVUTIL_X86_INTMATH_H -#define AVUTIL_X86_INTMATH_H - -#if HAVE_INLINE_ASM -#define FASTDIV(a,b) \ - ({\ - int ret, dmy;\ - __asm__ volatile(\ - "mull %3"\ - :"=d"(ret), "=a"(dmy)\ - :"1"(a), "g"(ff_inverse[b])\ - );\ - ret;\ - }) -#endif - -#endif /* AVUTIL_X86_INTMATH_H */ -- cgit v1.1 From ac330161584b69c766d955d6ee3ee045cca31030 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 10 Aug 2012 15:47:07 +0200 Subject: mjpegdec: support AVRn interlaced Signed-off-by: Luca Barbato --- libavcodec/mjpegdec.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 81aa36a..f79eabe 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -1051,9 +1051,6 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, prev_shift = get_bits(&s->gb, 4); /* Ah */ point_transform = get_bits(&s->gb, 4); /* Al */ - for (i = 0; i < nb_components; i++) - s->last_dc[i] = 1024; - if (nb_components > 1) { /* interleaved stream */ s->mb_width = (s->width + s->h_max * block_size - 1) / (s->h_max * block_size); @@ -1079,6 +1076,10 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, for (i = s->mjpb_skiptosod; i > 0; i--) skip_bits(&s->gb, 8); +next_field: + for (i = 0; i < nb_components; i++) + s->last_dc[i] = 1024; + if (s->lossless) { if (CONFIG_JPEGLS_DECODER && s->ls) { // for () { @@ -1113,6 +1114,22 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, return ret; } } + + if (s->interlaced && + get_bits_left(&s->gb) > 32 && + show_bits(&s->gb, 8) == 0xFF) { + GetBitContext bak = s->gb; + align_get_bits(&bak); + if (show_bits(&bak, 16) == 0xFFD1) { + av_dlog(s->avctx, "AVRn interlaced picture marker found\n"); + s->gb = bak; + skip_bits(&s->gb, 16); + s->bottom_field ^= 1; + + goto next_field; + } + } + emms_c(); return 0; out_of_range: -- cgit v1.1 From 7011a42b1abbf39ee02d50f5e4b2a10552d92ae2 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Sun, 19 Aug 2012 13:02:23 +0200 Subject: rtmp: support strict rtmp servers In order to send or receive a stream FCPublish, FCSubscribe and _checkbw are completely optional and often not implemented. releaseStream over a non-existen stream might report an error instead of being silent. Signed-off-by: Luca Barbato --- libavformat/rtmpproto.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 6205cd2..f3ba1e3 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -549,7 +549,7 @@ static int gen_release_stream(URLContext *s, RTMPContext *rt) ff_amf_write_null(&p); ff_amf_write_string(&p, rt->playpath); - return rtmp_send_packet(rt, &pkt, 0); + return rtmp_send_packet(rt, &pkt, 1); } /** @@ -573,7 +573,7 @@ static int gen_fcpublish_stream(URLContext *s, RTMPContext *rt) ff_amf_write_null(&p); ff_amf_write_string(&p, rt->playpath); - return rtmp_send_packet(rt, &pkt, 0); + return rtmp_send_packet(rt, &pkt, 1); } /** @@ -1525,8 +1525,11 @@ static int handle_invoke_error(URLContext *s, RTMPPacket *pkt) if (!ff_amf_get_field_value(pkt->data + 9, data_end, "description", tmpstr, sizeof(tmpstr))) { - if (tracked_method && !strcmp(tracked_method, "_checkbw")) { - /* Ignore _checkbw errors. */ + if (tracked_method && (!strcmp(tracked_method, "_checkbw") || + !strcmp(tracked_method, "releaseStream") || + !strcmp(tracked_method, "FCSubscribe") || + !strcmp(tracked_method, "FCPublish"))) { + /* Gracefully ignore Adobe-specific historical artifact errors. */ level = AV_LOG_WARNING; ret = 0; } else -- cgit v1.1 From 5d4ef004bfe85a006501d21373cce86c9bf32401 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 20 Aug 2012 12:18:58 -0400 Subject: adpcm_swf: Use correct sample offsets when using trellis. Fixes invalid reads when encoding mono streams when trellis is used. --- libavcodec/adpcmenc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c index 038dbf1..843b32f 100644 --- a/libavcodec/adpcmenc.c +++ b/libavcodec/adpcmenc.c @@ -615,10 +615,11 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, if (avctx->trellis > 0) { FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error); - adpcm_compress_trellis(avctx, samples + 2, buf, &c->status[0], n); + adpcm_compress_trellis(avctx, samples + avctx->channels, buf, + &c->status[0], n); if (avctx->channels == 2) - adpcm_compress_trellis(avctx, samples + 3, buf + n, - &c->status[1], n); + adpcm_compress_trellis(avctx, samples + avctx->channels + 1, + buf + n, &c->status[1], n); for (i = 0; i < n; i++) { put_bits(&pb, 4, buf[i]); if (avctx->channels == 2) -- cgit v1.1 From ec7a212f9f3659181040d40f95a0358f8c8b48e9 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 21 Aug 2012 11:29:37 -0400 Subject: alacenc: fix max_frame_size calculation for the final frame --- libavcodec/alacenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index 70f4bba..5b00a7a 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -546,7 +546,7 @@ static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, s->frame_size = frame->nb_samples; - if (avctx->frame_size < DEFAULT_FRAME_SIZE) + if (frame->nb_samples < DEFAULT_FRAME_SIZE) max_frame_size = get_max_frame_size(s->frame_size, avctx->channels, DEFAULT_SAMPLE_SIZE); else -- cgit v1.1 From 358078d9bb89d6266e274720eba8582ec7b1c6b7 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 21 Aug 2012 11:27:34 -0400 Subject: alacenc: remove unneeded sample_fmt check --- libavcodec/alacenc.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index 5b00a7a..d337e40 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -426,11 +426,6 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) avctx->frame_size = s->frame_size = DEFAULT_FRAME_SIZE; - if (avctx->sample_fmt != AV_SAMPLE_FMT_S16) { - av_log(avctx, AV_LOG_ERROR, "only pcm_s16 input samples are supported\n"); - return -1; - } - /* TODO: Correctly implement multi-channel ALAC. It is similar to multi-channel AAC, in that it has a series of single-channel (SCE), channel-pair (CPE), and LFE elements. */ -- cgit v1.1 From f24cc1b2f1b5d9a1fd91340cc9f7b97dda9dc3b1 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 21 Aug 2012 09:21:56 -0400 Subject: alacenc: use s16p sample format as input --- libavcodec/alacenc.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index d337e40..6b5c4f0 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -78,17 +78,15 @@ typedef struct AlacEncodeContext { } AlacEncodeContext; -static void init_sample_buffers(AlacEncodeContext *s, - const int16_t *input_samples) +static void init_sample_buffers(AlacEncodeContext *s, int16_t **input_samples) { int ch, i; for (ch = 0; ch < s->avctx->channels; ch++) { - const int16_t *sptr = input_samples + ch; - for (i = 0; i < s->frame_size; i++) { - s->sample_buf[ch][i] = *sptr; - sptr += s->avctx->channels; - } + int32_t *bptr = s->sample_buf[ch]; + const int16_t *sptr = input_samples[ch]; + for (i = 0; i < s->frame_size; i++) + bptr[i] = sptr[i]; } } @@ -347,8 +345,7 @@ static void alac_entropy_coder(AlacEncodeContext *s) } } -static int write_frame(AlacEncodeContext *s, AVPacket *avpkt, - const int16_t *samples) +static int write_frame(AlacEncodeContext *s, AVPacket *avpkt, int16_t **samples) { int i, j; int prediction_type = 0; @@ -358,8 +355,10 @@ static int write_frame(AlacEncodeContext *s, AVPacket *avpkt, if (s->verbatim) { write_frame_header(s); - for (i = 0; i < s->frame_size * s->avctx->channels; i++) - put_sbits(pb, 16, *samples++); + /* samples are channel-interleaved in verbatim mode */ + for (i = 0; i < s->frame_size; i++) + for (j = 0; j < s->avctx->channels; j++) + put_sbits(pb, 16, samples[j][i]); } else { init_sample_buffers(s, samples); write_frame_header(s); @@ -537,7 +536,7 @@ static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, { AlacEncodeContext *s = avctx->priv_data; int out_bytes, max_frame_size, ret; - const int16_t *samples = (const int16_t *)frame->data[0]; + int16_t **samples = (int16_t **)frame->extended_data; s->frame_size = frame->nb_samples; @@ -577,7 +576,7 @@ AVCodec ff_alac_encoder = { .encode2 = alac_encode_frame, .close = alac_encode_close, .capabilities = CODEC_CAP_SMALL_LAST_FRAME, - .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, + .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), }; -- cgit v1.1 From 4b0e0f31bf0f618a634dcfdca45e72cdfb0b48b5 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 21 Aug 2012 12:29:11 -0400 Subject: lpc: fix alignment of windowed samples for odd maximum LPC order Fixes crash on x86 due to alignment requirements for w_data in lpc_apply_welch_window_sse2(). --- libavcodec/lpc.c | 15 +++++++-------- libavcodec/lpc.h | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c index 6ce5dde..cc3ce44 100644 --- a/libavcodec/lpc.c +++ b/libavcodec/lpc.c @@ -178,11 +178,9 @@ int ff_lpc_calc_coefs(LPCContext *s, } if (lpc_type == FF_LPC_TYPE_LEVINSON) { - double *windowed_samples = s->windowed_samples + max_order; + s->lpc_apply_welch_window(samples, blocksize, s->windowed_samples); - s->lpc_apply_welch_window(samples, blocksize, windowed_samples); - - s->lpc_compute_autocorr(windowed_samples, blocksize, max_order, autoc); + s->lpc_compute_autocorr(s->windowed_samples, blocksize, max_order, autoc); compute_lpc_coefs(autoc, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1); @@ -248,10 +246,11 @@ av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order, s->lpc_type = lpc_type; if (lpc_type == FF_LPC_TYPE_LEVINSON) { - s->windowed_samples = av_mallocz((blocksize + max_order + 2) * - sizeof(*s->windowed_samples)); - if (!s->windowed_samples) + s->windowed_buffer = av_mallocz((blocksize + 2 + FFALIGN(max_order, 4)) * + sizeof(*s->windowed_samples)); + if (!s->windowed_buffer) return AVERROR(ENOMEM); + s->windowed_samples = s->windowed_buffer + FFALIGN(max_order, 4); } else { s->windowed_samples = NULL; } @@ -267,5 +266,5 @@ av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order, av_cold void ff_lpc_end(LPCContext *s) { - av_freep(&s->windowed_samples); + av_freep(&s->windowed_buffer); } diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h index 1775374..cbee46f 100644 --- a/libavcodec/lpc.h +++ b/libavcodec/lpc.h @@ -51,6 +51,7 @@ typedef struct LPCContext { int blocksize; int max_order; enum FFLPCType lpc_type; + double *windowed_buffer; double *windowed_samples; /** -- cgit v1.1 From e981215944876333d6da2a029e4b697e4831048b Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 21 Aug 2012 12:48:23 -0400 Subject: FATE: add ALAC encoding tests --- tests/Makefile | 1 + tests/fate/alac.mak | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/fate/alac.mak diff --git a/tests/Makefile b/tests/Makefile index 0b11102..2af9a91 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -26,6 +26,7 @@ include $(SRC_PATH)/tests/fate/vcodec.mak include $(SRC_PATH)/tests/fate/aac.mak include $(SRC_PATH)/tests/fate/ac3.mak include $(SRC_PATH)/tests/fate/adpcm.mak +include $(SRC_PATH)/tests/fate/alac.mak include $(SRC_PATH)/tests/fate/als.mak include $(SRC_PATH)/tests/fate/amrnb.mak include $(SRC_PATH)/tests/fate/amrwb.mak diff --git a/tests/fate/alac.mak b/tests/fate/alac.mak new file mode 100644 index 0000000..b55b594 --- /dev/null +++ b/tests/fate/alac.mak @@ -0,0 +1,15 @@ +FATE_ALAC += fate-alac-level-0 \ + fate-alac-level-1 \ + fate-alac-level-2 \ + fate-alac-lpc-orders \ + +fate-alac-level-%: OPTS = -compression_level $(@:fate-alac-level-%=%) +fate-alac-lpc-orders: OPTS = -min_prediction_order 1 -max_prediction_order 30 + +fate-alac-%: REF = $(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav +fate-alac-%: CMD = enc_dec_pcm mov wav s16le $(REF) -c alac $(OPTS) +fate-alac-%: CMP = oneoff +fate-alac-%: FUZZ = 0 + +FATE_SAMPLES_AVCONV += $(FATE_ALAC) +fate-alac: $(FATE_ALAC) -- cgit v1.1 From 890fddd0ea16aa8fe423820ae83ae1f67978921b Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 20 Aug 2012 13:30:44 -0400 Subject: vorbisenc: fix quality parameter This generates output with bitrates similar to libvorbis for a given quality value. --- libavcodec/vorbisenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c index 4fd8c32..cdb3af0 100644 --- a/libavcodec/vorbisenc.c +++ b/libavcodec/vorbisenc.c @@ -1181,9 +1181,9 @@ static av_cold int vorbis_encode_init(AVCodecContext *avccontext) goto error; if (avccontext->flags & CODEC_FLAG_QSCALE) - venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.; + venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA; else - venc->quality = 0.03; + venc->quality = 3.0; venc->quality *= venc->quality; if ((ret = put_main_header(venc, (uint8_t**)&avccontext->extradata)) < 0) -- cgit v1.1 From a0a5fed908a2f36d64e2b99673475d85b4c49430 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 20 Aug 2012 13:35:48 -0400 Subject: vorbisenc: set AVCodecContext.bit_rate to 0 The Vorbis encoder is always VBR. --- libavcodec/vorbisenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c index cdb3af0..b0e0e68 100644 --- a/libavcodec/vorbisenc.c +++ b/libavcodec/vorbisenc.c @@ -1180,6 +1180,7 @@ static av_cold int vorbis_encode_init(AVCodecContext *avccontext) if ((ret = create_vorbis_context(venc, avccontext)) < 0) goto error; + avccontext->bit_rate = 0; if (avccontext->flags & CODEC_FLAG_QSCALE) venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA; else -- cgit v1.1 From 7b44061f4be1075eefbc2eec649f38dd0dbfcc82 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 22 Aug 2012 10:37:35 +0200 Subject: doc/APIchanges: add an entry for codec descriptors. Also fill in missing dates and hashes. --- doc/APIchanges | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 5e67e0d..f919e53 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,28 +13,38 @@ libavutil: 2011-04-18 API changes, most recent first: -2012-08-08 - xxxxxxx - lavu 51.39 - avutil.h +2012-08-18 - lavc 54.26 - avcodec.h + Add codec descriptors for accessing codec properties without having + to refer to a specific decoder or encoder. + + c223d79 - Add an AVCodecDescriptor struct and functions + avcodec_descriptor_get() and avcodec_descriptor_next(). + 51efed1 - Add AVCodecDescriptor.props and AV_CODEC_PROP_INTRA_ONLY. + 91e59fe - Add avcodec_descriptor_get_by_name(). + + +2012-08-08 - 1d9c2dc - lavu 51.39 - avutil.h Don't implicitly include libavutil/common.h in avutil.h -2012-08-08 - xxxxxxx - lavu 51.38 - dict.h +2012-08-08 - 987170c - lavu 51.38 - dict.h Add av_dict_count(). -2012-08-xx - xxxxxxx - lavc 54.25 - avcodec.h +2012-08-07 - 104e10f - lavc 54.25 - avcodec.h Rename CodecID to AVCodecID and all CODEC_ID_* to AV_CODEC_ID_*. To provide backwards compatibility, CodecID is now #defined as AVCodecID. Note that this can break user code that includes avcodec.h and uses the 'CodecID' identifier. Such code should either #undef CodecID or stop using the CodecID name. -2012-08-03 - xxxxxxx - lavu 51.37.1 - cpu.h +2012-08-03 - 239fdf1 - lavu 51.37.1 - cpu.h lsws 2.1.1 - swscale.h Rename AV_CPU_FLAG_MMX2 ---> AV_CPU_FLAG_MMXEXT. Rename SWS_CPU_CAPS_MMX2 ---> SWS_CPU_CAPS_MMXEXT. -2012-07-xx - xxxxxxx - lavf 54.13.0 - avformat.h +2012-07-29 - 681ed00 - lavf 54.13.0 - avformat.h Add AVFMT_FLAG_NOBUFFER for low latency use cases. -2012-07-xx - xxxxxxx - lavfi 3.0.0 - avfilter.h +2012-07-20 - b70d89a - lavfi 3.0.0 - avfilter.h Add avfilter_unref_bufferp(). 2012-07-10 - 5fade8a - lavu 51.37.0 -- cgit v1.1