History

Merge remote-tracking branch 'qatar/master'

* qatar/master: (24 commits) flvdec: remove incomplete, disabled seeking code mem: add support for _aligned_malloc() as found on Windows lavc: Extend the documentation for avcodec_init_packet flvdec: remove incomplete, disabled seeking code http: replace atoll() with strtoll() mpegts: remove unused/incomplete/broken seeking code af_amix: allow float planar sample format as input af_amix: use AVFloatDSPContext.vector_fmac_scalar() float_dsp: add x86-optimized functions for vector_fmac_scalar() float_dsp: Move vector_fmac_scalar() from libavcodec to libavutil lavr: Add x86-optimized function for flt to s32 conversion lavr: Add x86-optimized function for flt to s16 conversion lavr: Add x86-optimized functions for s32 to flt conversion lavr: Add x86-optimized functions for s32 to s16 conversion lavr: Add x86-optimized functions for s16 to flt conversion lavr: Add x86-optimized function for s16 to s32 conversion rtpenc: Support packetizing iLBC rtpdec: Add a depacketizer for iLBC Implement the iLBC storage file format mov: Support muxing/demuxing iLBC ... Conflicts: Changelog configure libavcodec/avcodec.h libavcodec/dsputil.c libavcodec/version.h libavformat/movenc.c libavformat/mpegts.c libavformat/version.h libavutil/mem.c

Michael Niedermayer committed 14 years ago

Commit cabbd272 parents 6b9446e 4cc292044 files · +952 −231Browse files

Unified · Split

44 files
  1. Changelog +1 −0
  2. configure +9 −1
  3. doc/general.texi +14 −0
  4. doc/protocols.texi +4 −0
  5. libavcodec/Makefile +2 −0
  6. libavcodec/allcodecs.c +1 −0
  7. libavcodec/arm/dsputil_init_neon.c +0 −3
  8. libavcodec/arm/dsputil_neon.S +0 −48
  9. libavcodec/avcodec.h +4 −0
  10. libavcodec/dca.c +5 −4
  11. libavcodec/dirac.c +1 −1
  12. libavcodec/dsputil.c +0 −9
  13. libavcodec/dsputil.h +0 −11
  14. libavcodec/libilbc.c +209 −0
  15. libavcodec/ratecontrol.c +0 −12
  16. libavcodec/utils.c +5 −0
  17. libavcodec/version.h +1 −1
  18. libavfilter/af_amix.c +19 −11
  19. libavformat/Makefile +3 −0
  20. libavformat/allformats.c +1 −0
  21. libavformat/flvdec.c +0 −30
  22. libavformat/http.c +3 −3
  23. libavformat/ilbc.c +141 −0
  24. libavformat/isom.c +1 −0
  25. libavformat/mov.c +1 −0
  26. libavformat/movenc.c +2 −1
  27. libavformat/mpegts.c +0 −94
  28. libavformat/rtmpproto.c +8 −0
  29. libavformat/rtpdec.c +1 −0
  30. libavformat/rtpdec_formats.h +1 −0
  31. libavformat/rtpdec_ilbc.c +73 −0
  32. libavformat/rtpenc.c +44 −0
  33. libavformat/rtsp.c +1 −1
  34. libavformat/sdp.c +6 −0
  35. libavformat/version.h +1 −1
  36. libavresample/x86/audio_convert.asm +209 −0
  37. libavresample/x86/audio_convert_init.c +44 −0
  38. libavutil/arm/float_dsp_init_neon.c +4 −0
  39. libavutil/arm/float_dsp_neon.S +48 −0
  40. libavutil/float_dsp.c +9 −0
  41. libavutil/float_dsp.h +16 −0
  42. libavutil/mem.c +6 −0
  43. libavutil/x86/float_dsp.asm +47 −0
  44. libavutil/x86/float_dsp_init.c +7 −0
Changelog+1−0
@@ -10,6 +10,7 @@ version next: · 9 unmodified lines
1010 - atempo filter
1111 - ffprobe -show_data option
1212 - RTMPT protocol support
13+- iLBC encoding/decoding via libilbc
1314
1415
1516 version 0.11:
configure+9−1
@@ -180,6 +180,7 @@ External library support: · 179 unmodified lines
180180 --enable-libfaac enable FAAC support via libfaac [no]
181181 --enable-libfreetype enable libfreetype [no]
182182 --enable-libgsm enable GSM support via libgsm [no]
183+ --enable-libilbc enable iLBC de/encoding via libilbc [no]
183184 --enable-libmodplug enable ModPlug via libmodplug [no]
184185 --enable-libmp3lame enable MP3 encoding via libmp3lame [no]
185186 --enable-libnut enable NUT (de)muxing via libnut,
@@ -1051,6 +1052,7 @@ CONFIG_LIST=" · 865 unmodified lines
10511052 libfaac
10521053 libfreetype
10531054 libgsm
1055+ libilbc
10541056 libmodplug
10551057 libmp3lame
10561058 libnut
@@ -1168,6 +1170,7 @@ HAVE_LIST=" · 111 unmodified lines
11681170 $ARCH_EXT_LIST
11691171 $HAVE_LIST_PUB
11701172 $THREADS_LIST
1173+ aligned_malloc
11711174 aligned_stack
11721175 alsa_asoundlib_h
11731176 altivec_h
@@ -1588,6 +1591,8 @@ libgsm_decoder_deps="libgsm" · 414 unmodified lines
15881591 libgsm_encoder_deps="libgsm"
15891592 libgsm_ms_decoder_deps="libgsm"
15901593 libgsm_ms_encoder_deps="libgsm"
1594+libilbc_decoder_deps="libilbc"
1595+libilbc_encoder_deps="libilbc"
15911596 libmodplug_demuxer_deps="libmodplug"
15921597 libmp3lame_encoder_deps="libmp3lame"
15931598 libopencore_amrnb_decoder_deps="libopencore_amrnb"
@@ -3144,6 +3149,7 @@ check_func ${malloc_prefix}memalign && enable memalign · 1550 unmodified lines
31443149 check_func mkstemp
31453150 check_func mmap
31463151 check_func ${malloc_prefix}posix_memalign && enable posix_memalign
3152+check_func_headers malloc.h _aligned_malloc && enable aligned_malloc
31473153 check_func setrlimit
31483154 check_func strerror_r
31493155 check_func strptime
@@ -3254,6 +3260,7 @@ enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 && · 104 unmodified lines
32543260 enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
32553261 enabled libfreetype && require_pkg_config freetype2 "ft2build.h freetype/freetype.h" FT_Init_FreeType
32563262 enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
3263+enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
32573264 enabled libmodplug && require libmodplug libmodplug/modplug.h ModPlug_Load -lmodplug
32583265 enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
32593266 enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
@@ -3522,7 +3529,7 @@ if test $target_os = "haiku"; then · 262 unmodified lines
35223529 disable posix_memalign
35233530 fi
35243531
3525−! enabled_any memalign posix_memalign &&
3532+! enabled_any memalign posix_memalign aligned_malloc &&
35263533 enabled_any $need_memalign && enable memalign_hack
35273534
35283535 # add_dep lib dep
@@ -3628,6 +3635,7 @@ echo "libcelt enabled ${libcelt-no}" · 99 unmodified lines
36283635 echo "libdc1394 support ${libdc1394-no}"
36293636 echo "libfaac enabled ${libfaac-no}"
36303637 echo "libgsm enabled ${libgsm-no}"
3638+echo "libilbc enabled ${libilbc-no}"
36313639 echo "libmodplug enabled ${libmodplug-no}"
36323640 echo "libmp3lame enabled ${libmp3lame-no}"
36333641 echo "libnut enabled ${libnut-no}"
doc/general.texi+14−0
@@ -93,6 +93,17 @@ x264 is under the GNU Public License Version 2 or later · 92 unmodified lines
9393 details), you must upgrade FFmpeg's license to GPL in order to use it.
9494 @end float
9595
96+@section libilbc
97+
98+iLBC is a narrowband speech codec that has been made freely available
99+by Google as part of the WebRTC project. libilbc is a packaging friendly
100+copy of the iLBC codec. Libav can make use of the libilbc library for
101+iLBC encoding and decoding.
102+
103+Go to @url{https://github.com/dekkers/libilbc} and follow the instructions for
104+installing the library. Then pass @code{--enable-libilbc} to configure to
105+enable it.
106+
96107
97108
98109 @chapter Supported File Formats, Codecs or Features
@@ -191,6 +202,7 @@ library: · 92 unmodified lines
191202 @item IEC61937 encapsulation @tab X @tab X
192203 @item IFF @tab @tab X
193204 @tab Interchange File Format
205+@item iLBC @tab X @tab X
194206 @item Interplay MVE @tab @tab X
195207 @tab Format used in various Interplay computer games.
196208 @item IV8 @tab @tab X
@@ -749,6 +761,8 @@ following image formats are supported: · 552 unmodified lines
749761 @item GSM Microsoft variant @tab E @tab X
750762 @tab encoding supported through external library libgsm
751763 @item IAC (Indeo Audio Coder) @tab @tab X
764+@item iLBC (Internet Low Bitrate Codec) @tab E @tab E
765+ @tab encoding and decoding supported through external library libilbc
752766 @item IMC (Intel Music Coder) @tab @tab X
753767 @item MACE (Macintosh Audio Compression/Expansion) 3:1 @tab @tab X
754768 @item MACE (Macintosh Audio Compression/Expansion) 6:1 @tab @tab X
doc/protocols.texi+4−0
@@ -247,6 +247,10 @@ times to construct arbitrary AMF sequences. · 246 unmodified lines
247247 Version of the Flash plugin used to run the SWF player. The default
248248 is LNX 9,0,124,2.
249249
250+@item rtmp_flush_interval
251+Number of packets flushed in the same request (RTMPT only). The default
252+is 10.
253+
250254 @item rtmp_live
251255 Specify that the media is a live stream. No resuming or seeking in
252256 live streams is possible. The default value is @code{any}, which means the
libavcodec/Makefile+2−0
@@ -659,6 +659,8 @@ OBJS-$(CONFIG_LIBGSM_DECODER) += libgsm.o · 658 unmodified lines
659659 OBJS-$(CONFIG_LIBGSM_ENCODER) += libgsm.o
660660 OBJS-$(CONFIG_LIBGSM_MS_DECODER) += libgsm.o
661661 OBJS-$(CONFIG_LIBGSM_MS_ENCODER) += libgsm.o
662+OBJS-$(CONFIG_LIBILBC_DECODER) += libilbc.o
663+OBJS-$(CONFIG_LIBILBC_ENCODER) += libilbc.o
662664 OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o mpegaudiodecheader.o \
663665 audio_frame_queue.o
664666 OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER) += libopencore-amr.o \
libavcodec/allcodecs.c+1−0
@@ -410,6 +410,7 @@ void avcodec_register_all(void) · 409 unmodified lines
410410 REGISTER_ENCODER (LIBFAAC, libfaac);
411411 REGISTER_ENCDEC (LIBGSM, libgsm);
412412 REGISTER_ENCDEC (LIBGSM_MS, libgsm_ms);
413+ REGISTER_ENCDEC (LIBILBC, libilbc);
413414 REGISTER_ENCODER (LIBMP3LAME, libmp3lame);
414415 REGISTER_ENCDEC (LIBOPENCORE_AMRNB, libopencore_amrnb);
415416 REGISTER_DECODER (LIBOPENCORE_AMRWB, libopencore_amrwb);
libavcodec/arm/dsputil_init_neon.c+0−3
@@ -154,8 +154,6 @@ void ff_vector_fmul_window_neon(float *dst, const float *src0, · 153 unmodified lines
154154 const float *src1, const float *win, int len);
155155 void ff_vector_fmul_scalar_neon(float *dst, const float *src, float mul,
156156 int len);
157−void ff_vector_fmac_scalar_neon(float *dst, const float *src, float mul,
158− int len);
159157 void ff_butterflies_float_neon(float *v1, float *v2, int len);
160158 float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len);
161159 void ff_vector_fmul_reverse_neon(float *dst, const float *src0,
@@ -329,7 +327,6 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) · 167 unmodified lines
329327
330328 c->vector_fmul_window = ff_vector_fmul_window_neon;
331329 c->vector_fmul_scalar = ff_vector_fmul_scalar_neon;
332− c->vector_fmac_scalar = ff_vector_fmac_scalar_neon;
333330 c->butterflies_float = ff_butterflies_float_neon;
334331 c->scalarproduct_float = ff_scalarproduct_float_neon;
335332 c->vector_fmul_reverse = ff_vector_fmul_reverse_neon;
libavcodec/arm/dsputil_neon.S+0−48
@@ -682,54 +682,6 @@ NOVFP vdup.32 q8, r2 · 681 unmodified lines
682682 .unreq len
683683 endfunc
684684
685−function ff_vector_fmac_scalar_neon, export=1
686−VFP len .req r2
687−VFP acc .req r3
688−NOVFP len .req r3
689−NOVFP acc .req r2
690−VFP vdup.32 q15, d0[0]
691−NOVFP vdup.32 q15, r2
692− bics r12, len, #15
693− mov acc, r0
694− beq 3f
695− vld1.32 {q0}, [r1,:128]!
696− vld1.32 {q8}, [acc,:128]!
697− vld1.32 {q1}, [r1,:128]!
698− vld1.32 {q9}, [acc,:128]!
699−1: vmla.f32 q8, q0, q15
700− vld1.32 {q2}, [r1,:128]!
701− vld1.32 {q10}, [acc,:128]!
702− vmla.f32 q9, q1, q15
703− vld1.32 {q3}, [r1,:128]!
704− vld1.32 {q11}, [acc,:128]!
705− vmla.f32 q10, q2, q15
706− vst1.32 {q8}, [r0,:128]!
707− vmla.f32 q11, q3, q15
708− vst1.32 {q9}, [r0,:128]!
709− subs r12, r12, #16
710− beq 2f
711− vld1.32 {q0}, [r1,:128]!
712− vld1.32 {q8}, [acc,:128]!
713− vst1.32 {q10}, [r0,:128]!
714− vld1.32 {q1}, [r1,:128]!
715− vld1.32 {q9}, [acc,:128]!
716− vst1.32 {q11}, [r0,:128]!
717− b 1b
718−2: vst1.32 {q10}, [r0,:128]!
719− vst1.32 {q11}, [r0,:128]!
720− ands len, len, #15
721− it eq
722− bxeq lr
723−3: vld1.32 {q0}, [r1,:128]!
724− vld1.32 {q8}, [acc,:128]!
725− vmla.f32 q8, q0, q15
726− vst1.32 {q8}, [r0,:128]!
727− subs len, len, #4
728− bgt 3b
729− bx lr
730− .unreq len
731−endfunc
732−
733685 function ff_butterflies_float_neon, export=1
734686 1: vld1.32 {q0},[r0,:128]
735687 vld1.32 {q1},[r1,:128]
libavcodec/avcodec.h+4−0
@@ -407,6 +407,7 @@ enum CodecID { · 406 unmodified lines
407407 CODEC_ID_BMV_AUDIO,
408408 CODEC_ID_RALF,
409409 CODEC_ID_IAC,
410+ CODEC_ID_ILBC,
410411 CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
411412 CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'),
412413 CODEC_ID_SONIC = MKBETAG('S','O','N','C'),
@@ -3470,6 +3471,9 @@ void av_destruct_packet(AVPacket *pkt); · 3057 unmodified lines
34703471 /**
34713472 * Initialize optional fields of a packet with default values.
34723473 *
3474+ * Note, this does not touch the data and size members, which have to be
3475+ * initialized separately.
3476+ *
34733477 * @param pkt packet
34743478 */
34753479 void av_init_packet(AVPacket *pkt);
libavcodec/dca.c+5−4
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include <stdio.h>
2828
2929 #include "libavutil/common.h"
30+#include "libavutil/float_dsp.h"
3031 #include "libavutil/intmath.h"
3132 #include "libavutil/intreadwrite.h"
3233 #include "libavutil/mathematics.h"
@@ -384,7 +385,7 @@ typedef struct { · 351 unmodified lines
384385 int profile;
385386
386387 int debug_flag; ///< used for suppressing repeated error messages output
387− DSPContext dsp;
388+ AVFloatDSPContext fdsp;
388389 FFTContext imdct;
389390 SynthFilterContext synth;
390391 DCADSPContext dcadsp;
@@ -2042,8 +2043,8 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 1651 unmodified lines
20422043 float *back_chan = s->samples + s->channel_order_tab[s->xch_base_channel] * 256;
20432044 float *lt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 2] * 256;
20442045 float *rt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 1] * 256;
2045− s->dsp.vector_fmac_scalar(lt_chan, back_chan, -M_SQRT1_2, 256);
2046− s->dsp.vector_fmac_scalar(rt_chan, back_chan, -M_SQRT1_2, 256);
2046+ s->fdsp.vector_fmac_scalar(lt_chan, back_chan, -M_SQRT1_2, 256);
2047+ s->fdsp.vector_fmac_scalar(rt_chan, back_chan, -M_SQRT1_2, 256);
20472048 }
20482049
20492050 if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
@@ -2085,7 +2086,7 @@ static av_cold int dca_decode_init(AVCodecContext *avctx) · 35 unmodified lines
20852086 s->avctx = avctx;
20862087 dca_init_vlcs();
20872088
2088− ff_dsputil_init(&s->dsp, avctx);
2089+ avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
20892090 ff_mdct_init(&s->imdct, 6, 1, 1.0);
20902091 ff_synth_filter_init(&s->synth);
20912092 ff_dcadsp_init(&s->dcadsp);
libavcodec/dirac.c+1−1
@@ -127,7 +127,7 @@ static const enum PixelFormat dirac_pix_fmt[2][3] = { · 126 unmodified lines
127127 static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
128128 dirac_source_params *source)
129129 {
130− AVRational frame_rate = (AVRational){0,0};
130+ AVRational frame_rate = {0,0};
131131 unsigned luma_depth = 8, luma_offset = 16;
132132 int idx;
133133
libavcodec/dsputil.c+0−9
@@ -2509,14 +2509,6 @@ static void vector_fmul_scalar_c(float *dst, const float *src, float mul, · 2508 unmodified lines
25092509 dst[i] = src[i] * mul;
25102510 }
25112511
2512−static void vector_fmac_scalar_c(float *dst, const float *src, float mul,
2513− int len)
2514−{
2515− int i;
2516− for (i = 0; i < len; i++)
2517− dst[i] += src[i] * mul;
2518−}
2519−
25202512 static void butterflies_float_c(float *av_restrict v1, float *av_restrict v2,
25212513 int len)
25222514 {
@@ -3060,7 +3052,6 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) · 537 unmodified lines
30603052 c->butterflies_float = butterflies_float_c;
30613053 c->butterflies_float_interleave = butterflies_float_interleave_c;
30623054 c->vector_fmul_scalar = vector_fmul_scalar_c;
3063− c->vector_fmac_scalar = vector_fmac_scalar_c;
30643055
30653056 c->shrink[0]= av_image_copy_plane;
30663057 c->shrink[1]= ff_shrink22;
libavcodec/dsputil.h+0−11
@@ -420,17 +420,6 @@ typedef struct DSPContext { · 419 unmodified lines
420420 */
421421 void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
422422 int len);
423− /**
424− * Multiply a vector of floats by a scalar float and add to
425− * destination vector. Source and destination vectors must
426− * overlap exactly or not at all.
427− * @param dst result vector, 16-byte aligned
428− * @param src input vector, 16-byte aligned
429− * @param mul scalar value
430− * @param len length of vector, multiple of 4
431− */
432− void (*vector_fmac_scalar)(float *dst, const float *src, float mul,
433− int len);
434423 /**
435424 * Calculate the scalar product of two vectors of floats.
436425 * @param v1 first vector, 16-byte aligned
libavcodec/libilbc.c+209−0
@@ -0,0 +1,209 @@
1+/*
2+ * iLBC decoder/encoder stub
3+ * Copyright (c) 2012 Martin Storsjo
4+ *
5+ * This file is part of FFmpeg.
6+ *
7+ * FFmpeg is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU Lesser General Public
9+ * License as published by the Free Software Foundation; either
10+ * version 2.1 of the License, or (at your option) any later version.
11+ *
12+ * FFmpeg is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+ * Lesser General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU Lesser General Public
18+ * License along with FFmpeg; if not, write to the Free Software
19+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+ */
21+
22+#include <ilbc.h>
23+
24+#include "avcodec.h"
25+#include "libavutil/opt.h"
26+#include "internal.h"
27+
28+static int get_mode(AVCodecContext *avctx)
29+{
30+ if (avctx->block_align == 38)
31+ return 20;
32+ else if (avctx->block_align == 50)
33+ return 30;
34+ else if (avctx->bit_rate > 0)
35+ return avctx->bit_rate <= 14000 ? 30 : 20;
36+ else
37+ return -1;
38+}
39+
40+typedef struct ILBCDecContext {
41+ const AVClass *class;
42+ AVFrame frame;
43+ iLBC_Dec_Inst_t decoder;
44+ int enhance;
45+} ILBCDecContext;
46+
47+static const AVOption ilbc_dec_options[] = {
48+ { "enhance", "Enhance the decoded audio (adds delay)", offsetof(ILBCDecContext, enhance), AV_OPT_TYPE_INT, { 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM },
49+ { NULL }
50+};
51+
52+static const AVClass ilbc_dec_class = {
53+ "libilbc", av_default_item_name, ilbc_dec_options, LIBAVUTIL_VERSION_INT
54+};
55+
56+static av_cold int ilbc_decode_init(AVCodecContext *avctx)
57+{
58+ ILBCDecContext *s = avctx->priv_data;
59+ int mode;
60+
61+ if ((mode = get_mode(avctx)) < 0) {
62+ av_log(avctx, AV_LOG_ERROR, "iLBC frame mode not indicated\n");
63+ return AVERROR(EINVAL);
64+ }
65+
66+ WebRtcIlbcfix_InitDecode(&s->decoder, mode, s->enhance);
67+ avcodec_get_frame_defaults(&s->frame);
68+ avctx->coded_frame = &s->frame;
69+
70+ avctx->channels = 1;
71+ avctx->sample_rate = 8000;
72+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
73+
74+ return 0;
75+}
76+
77+static int ilbc_decode_frame(AVCodecContext *avctx, void *data,
78+ int *got_frame_ptr, AVPacket *avpkt)
79+{
80+ const uint8_t *buf = avpkt->data;
81+ int buf_size = avpkt->size;
82+ ILBCDecContext *s = avctx->priv_data;
83+ int ret;
84+
85+ if (s->decoder.no_of_bytes > buf_size) {
86+ av_log(avctx, AV_LOG_ERROR, "iLBC frame too short (%u, should be %u)\n",
87+ buf_size, s->decoder.no_of_bytes);
88+ return AVERROR_INVALIDDATA;
89+ }
90+
91+ s->frame.nb_samples = s->decoder.blockl;
92+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
93+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
94+ return ret;
95+ }
96+
97+ WebRtcIlbcfix_DecodeImpl((WebRtc_Word16*) s->frame.data[0],
98+ (const WebRtc_UWord16*) buf, &s->decoder, 1);
99+
100+ *got_frame_ptr = 1;
101+ *(AVFrame *)data = s->frame;
102+
103+ return s->decoder.no_of_bytes;
104+}
105+
106+AVCodec ff_libilbc_decoder = {
107+ .name = "libilbc",
108+ .type = AVMEDIA_TYPE_AUDIO,
109+ .id = CODEC_ID_ILBC,
110+ .priv_data_size = sizeof(ILBCDecContext),
111+ .init = ilbc_decode_init,
112+ .decode = ilbc_decode_frame,
113+ .capabilities = CODEC_CAP_DR1,
114+ .long_name = NULL_IF_CONFIG_SMALL("Internet Low Bitrate Codec (iLBC)"),
115+ .priv_class = &ilbc_dec_class,
116+};
117+
118+typedef struct ILBCEncContext {
119+ const AVClass *class;
120+ iLBC_Enc_Inst_t encoder;
121+ int mode;
122+} ILBCEncContext;
123+
124+static const AVOption ilbc_enc_options[] = {
125+ { "mode", "iLBC mode (20 or 30 ms frames)", offsetof(ILBCEncContext, mode), AV_OPT_TYPE_INT, { 20 }, 20, 30, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
126+ { NULL }
127+};
128+
129+static const AVClass ilbc_enc_class = {
130+ "libilbc", av_default_item_name, ilbc_enc_options, LIBAVUTIL_VERSION_INT
131+};
132+
133+static av_cold int ilbc_encode_init(AVCodecContext *avctx)
134+{
135+ ILBCEncContext *s = avctx->priv_data;
136+ int mode;
137+
138+ if (avctx->sample_rate != 8000) {
139+ av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
140+ return AVERROR(EINVAL);
141+ }
142+
143+ if (avctx->channels != 1) {
144+ av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
145+ return AVERROR(EINVAL);
146+ }
147+
148+ if ((mode = get_mode(avctx)) > 0)
149+ s->mode = mode;
150+ else
151+ s->mode = s->mode != 30 ? 20 : 30;
152+ WebRtcIlbcfix_InitEncode(&s->encoder, s->mode);
153+
154+ avctx->block_align = s->encoder.no_of_bytes;
155+ avctx->frame_size = s->encoder.blockl;
156+#if FF_API_OLD_ENCODE_AUDIO
157+ avctx->coded_frame = avcodec_alloc_frame();
158+ if (!avctx->coded_frame)
159+ return AVERROR(ENOMEM);
160+#endif
161+
162+ return 0;
163+}
164+
165+static av_cold int ilbc_encode_close(AVCodecContext *avctx)
166+{
167+#if FF_API_OLD_ENCODE_AUDIO
168+ av_freep(&avctx->coded_frame);
169+#endif
170+ return 0;
171+}
172+
173+static int ilbc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
174+ const AVFrame *frame, int *got_packet_ptr)
175+{
176+ ILBCEncContext *s = avctx->priv_data;
177+ int ret;
178+
179+ if ((ret = ff_alloc_packet(avpkt, 50))) {
180+ av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
181+ return ret;
182+ }
183+
184+ WebRtcIlbcfix_EncodeImpl((WebRtc_UWord16*) avpkt->data, (const WebRtc_Word16*) frame->data[0], &s->encoder);
185+
186+ avpkt->size = s->encoder.no_of_bytes;
187+ *got_packet_ptr = 1;
188+ return 0;
189+}
190+
191+static const AVCodecDefault ilbc_encode_defaults[] = {
192+ { "b", "0" },
193+ { NULL }
194+};
195+
196+AVCodec ff_libilbc_encoder = {
197+ .name = "libilbc",
198+ .type = AVMEDIA_TYPE_AUDIO,
199+ .id = CODEC_ID_ILBC,
200+ .priv_data_size = sizeof(ILBCEncContext),
201+ .init = ilbc_encode_init,
202+ .encode2 = ilbc_encode_frame,
203+ .close = ilbc_encode_close,
204+ .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
205+ AV_SAMPLE_FMT_NONE },
206+ .long_name = NULL_IF_CONFIG_SMALL("Internet Low Bitrate Codec (iLBC)"),
207+ .defaults = ilbc_encode_defaults,
208+ .priv_class = &ilbc_enc_class,
209+};
libavcodec/ratecontrol.c+0−12
@@ -514,14 +514,6 @@ static double predict_size(Predictor *p, double q, double var) · 513 unmodified lines
514514 return p->coeff*var / (q*p->count);
515515 }
516516
517−/*
518−static double predict_qp(Predictor *p, double size, double var)
519−{
520−//printf("coeff:%f, count:%f, var:%f, size:%f//\n", p->coeff, p->count, var, size);
521− return p->coeff*var / (size*p->count);
522−}
523−*/
524−
525517 static void update_predictor(Predictor *p, double q, double var, double size)
526518 {
527519 double new_coeff= size*q / (var + 1);
@@ -561,10 +553,6 @@ static void adaptive_quantization(MpegEncContext *s, double q){ · 33 unmodified lines
561553 int mb_y = mb_xy / s->mb_stride;
562554 int mb_distance;
563555 float mb_factor = 0.0;
564−#if 0
565− if(spat_cplx < q/3) spat_cplx= q/3; //FIXME finetune
566− if(temp_cplx < q/3) temp_cplx= q/3; //FIXME finetune
567−#endif
568556 if(spat_cplx < 4) spat_cplx= 4; //FIXME finetune
569557 if(temp_cplx < 4) temp_cplx= 4; //FIXME finetune
570558
libavcodec/utils.c+5−0
@@ -2138,6 +2138,11 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) · 2137 unmodified lines
21382138 case 29: return 288;
21392139 case 37: return 480;
21402140 }
2141+ } else if (id == CODEC_ID_ILBC) {
2142+ switch (ba) {
2143+ case 38: return 160;
2144+ case 50: return 240;
2145+ }
21412146 }
21422147 }
21432148
libavcodec/version.h+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727 */
2828
2929 #define LIBAVCODEC_VERSION_MAJOR 54
30−#define LIBAVCODEC_VERSION_MINOR 25
30+#define LIBAVCODEC_VERSION_MINOR 26
3131 #define LIBAVCODEC_VERSION_MICRO 100
3232
3333 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
libavfilter/af_amix.c+19−11
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #include "libavutil/audio_fifo.h"
3333 #include "libavutil/avassert.h"
3434 #include "libavutil/avstring.h"
35+#include "libavutil/float_dsp.h"
3536 #include "libavutil/mathematics.h"
3637 #include "libavutil/opt.h"
3738 #include "libavutil/samplefmt.h"
@@ -152,6 +153,7 @@ static int frame_list_add_frame(FrameList *frame_list, int nb_samples, int64_t p · 114 unmodified lines
152153
153154 typedef struct MixContext {
154155 const AVClass *class; /**< class for AVOptions */
156+ AVFloatDSPContext fdsp;
155157
156158 int nb_inputs; /**< number of inputs */
157159 int active_inputs; /**< number of input currently active */
@@ -160,6 +162,7 @@ typedef struct MixContext { · 2 unmodified lines
160162
161163 int nb_channels; /**< number of channels */
162164 int sample_rate; /**< sample rate */
165+ int planar;
163166 AVAudioFifo **fifos; /**< audio fifo for each input */
164167 uint8_t *input_state; /**< current state of each input */
165168 float *input_scale; /**< mixing scale factor for each input */
@@ -224,6 +227,7 @@ static int config_output(AVFilterLink *outlink) · 58 unmodified lines
224227 int i;
225228 char buf[64];
226229
230+ s->planar = av_sample_fmt_is_planar(outlink->format);
227231 s->sample_rate = outlink->sample_rate;
228232 outlink->time_base = (AVRational){ 1, outlink->sample_rate };
229233 s->next_pts = AV_NOPTS_VALUE;
@@ -264,14 +268,6 @@ static int config_output(AVFilterLink *outlink) · 34 unmodified lines
264268 return 0;
265269 }
266270
267−/* TODO: move optimized version from DSPContext to libavutil */
268−static void vector_fmac_scalar(float *dst, const float *src, float mul, int len)
269−{
270− int i;
271− for (i = 0; i < len; i++)
272− dst[i] += src[i] * mul;
273−}
274−
275271 /**
276272 * Read samples from the input FIFOs, mix, and write to the output link.
277273 */
@@ -294,11 +290,20 @@ static int output_frame(AVFilterLink *outlink, int nb_samples) · 16 unmodified lines
294290
295291 for (i = 0; i < s->nb_inputs; i++) {
296292 if (s->input_state[i] == INPUT_ON) {
293+ int planes, plane_size, p;
294+
297295 av_audio_fifo_read(s->fifos[i], (void **)in_buf->extended_data,
298296 nb_samples);
299− vector_fmac_scalar((float *)out_buf->extended_data[0],
300− (float *) in_buf->extended_data[0],
301− s->input_scale[i], nb_samples * s->nb_channels);
297+
298+ planes = s->planar ? s->nb_channels : 1;
299+ plane_size = nb_samples * (s->planar ? 1 : s->nb_channels);
300+ plane_size = FFALIGN(plane_size, 16);
301+
302+ for (p = 0; p < planes; p++) {
303+ s->fdsp.vector_fmac_scalar((float *)out_buf->extended_data[p],
304+ (float *) in_buf->extended_data[p],
305+ s->input_scale[i], plane_size);
306+ }
302307 }
303308 }
304309 avfilter_unref_buffer(in_buf);
@@ -501,6 +506,8 @@ static int init(AVFilterContext *ctx, const char *args, void *opaque) · 196 unmodified lines
501506 ff_insert_inpad(ctx, i, &pad);
502507 }
503508
509+ avpriv_float_dsp_init(&s->fdsp, 0);
510+
504511 return 0;
505512 }
506513
@@ -527,6 +534,7 @@ static int query_formats(AVFilterContext *ctx) · 20 unmodified lines
527534 {
528535 AVFilterFormats *formats = NULL;
529536 ff_add_format(&formats, AV_SAMPLE_FMT_FLT);
537+ ff_add_format(&formats, AV_SAMPLE_FMT_FLTP);
530538 ff_set_common_formats(ctx, formats);
531539 ff_set_common_channel_layouts(ctx, ff_all_channel_layouts());
532540 ff_set_common_samplerates(ctx, ff_all_samplerates());
libavformat/Makefile+3−0
@@ -123,6 +123,8 @@ OBJS-$(CONFIG_ICO_DEMUXER) += icodec.o · 122 unmodified lines
123123 OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
124124 OBJS-$(CONFIG_IDF_DEMUXER) += bintext.o
125125 OBJS-$(CONFIG_IFF_DEMUXER) += iff.o
126+OBJS-$(CONFIG_ILBC_DEMUXER) += ilbc.o
127+OBJS-$(CONFIG_ILBC_MUXER) += ilbc.o
126128 OBJS-$(CONFIG_IMAGE2_DEMUXER) += img2dec.o img2.o
127129 OBJS-$(CONFIG_IMAGE2_MUXER) += img2enc.o img2.o
128130 OBJS-$(CONFIG_IMAGE2PIPE_DEMUXER) += img2dec.o img2.o
@@ -281,6 +283,7 @@ OBJS-$(CONFIG_RTPDEC) += rdt.o \ · 152 unmodified lines
281283 rtpdec_h263.o \
282284 rtpdec_h263_rfc2190.o \
283285 rtpdec_h264.o \
286+ rtpdec_ilbc.o \
284287 rtpdec_latm.o \
285288 rtpdec_mpeg4.o \
286289 rtpdec_qcelp.o \
libavformat/allformats.c+1−0
@@ -116,6 +116,7 @@ void av_register_all(void) · 115 unmodified lines
116116 REGISTER_DEMUXER (IDCIN, idcin);
117117 REGISTER_DEMUXER (IDF, idf);
118118 REGISTER_DEMUXER (IFF, iff);
119+ REGISTER_MUXDEMUX (ILBC, ilbc);
119120 REGISTER_MUXDEMUX (IMAGE2, image2);
120121 REGISTER_MUXDEMUX (IMAGE2PIPE, image2pipe);
121122 REGISTER_DEMUXER (INGENIENT, ingenient);
libavformat/flvdec.c+0−30
@@ -759,33 +759,6 @@ static int flv_read_seek(AVFormatContext *s, int stream_index, · 758 unmodified lines
759759 return avio_seek_time(s->pb, stream_index, ts, flags);
760760 }
761761
762−#if 0 /* don't know enough to implement this */
763−static int flv_read_seek2(AVFormatContext *s, int stream_index,
764− int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
765−{
766− int ret = AVERROR(ENOSYS);
767−
768− if (ts - min_ts > (uint64_t)(max_ts - ts)) flags |= AVSEEK_FLAG_BACKWARD;
769−
770− if (!s->pb->seekable) {
771− if (stream_index < 0) {
772− stream_index = av_find_default_stream_index(s);
773− if (stream_index < 0)
774− return -1;
775−
776− /* timestamp for default must be expressed in AV_TIME_BASE units */
777− ts = av_rescale_rnd(ts, 1000, AV_TIME_BASE,
778− flags & AVSEEK_FLAG_BACKWARD ? AV_ROUND_DOWN : AV_ROUND_UP);
779− }
780− ret = avio_seek_time(s->pb, stream_index, ts, flags);
781− }
782−
783− if (ret == AVERROR(ENOSYS))
784− ret = av_seek_frame(s, stream_index, ts, flags);
785− return ret;
786−}
787−#endif
788−
789762 AVInputFormat ff_flv_demuxer = {
790763 .name = "flv",
791764 .long_name = NULL_IF_CONFIG_SMALL("FLV format"),
@@ -794,9 +767,6 @@ AVInputFormat ff_flv_demuxer = { · 2 unmodified lines
794767 .read_header = flv_read_header,
795768 .read_packet = flv_read_packet,
796769 .read_seek = flv_read_seek,
797−#if 0
798− .read_seek2 = flv_read_seek2,
799−#endif
800770 .read_close = flv_read_close,
801771 .extensions = "flv",
802772 };
libavformat/http.c+3−3
@@ -308,15 +308,15 @@ static int process_line(URLContext *h, char *line, int line_count, · 307 unmodified lines
308308 strcpy(s->location, p);
309309 *new_location = 1;
310310 } else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) {
311− s->filesize = atoll(p);
311+ s->filesize = strtoll(p, NULL, 10);
312312 } else if (!av_strcasecmp (tag, "Content-Range")) {
313313 /* "bytes $from-$to/$document_size" */
314314 const char *slash;
315315 if (!strncmp (p, "bytes ", 6)) {
316316 p += 6;
317− s->off = atoll(p);
317+ s->off = strtoll(p, NULL, 10);
318318 if ((slash = strchr(p, '/')) && strlen(slash) > 0)
319− s->filesize = atoll(slash+1);
319+ s->filesize = strtoll(slash+1, NULL, 10);
320320 }
321321 h->is_streamed = 0; /* we _can_ in fact seek */
322322 } else if (!av_strcasecmp(tag, "Accept-Ranges") && !strncmp(p, "bytes", 5)) {
libavformat/ilbc.c+141−0
@@ -0,0 +1,141 @@
1+/*
2+ * iLBC storage file format
3+ * Copyright (c) 2012 Martin Storsjo
4+ *
5+ * This file is part of FFmpeg.
6+ *
7+ * FFmpeg is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU Lesser General Public
9+ * License as published by the Free Software Foundation; either
10+ * version 2.1 of the License, or (at your option) any later version.
11+ *
12+ * FFmpeg is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+ * Lesser General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU Lesser General Public
18+ * License along with FFmpeg; if not, write to the Free Software
19+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+ */
21+
22+#include "avformat.h"
23+#include "internal.h"
24+
25+static const char mode20_header[] = "#!iLBC20\n";
26+static const char mode30_header[] = "#!iLBC30\n";
27+
28+static int ilbc_write_header(AVFormatContext *s)
29+{
30+ AVIOContext *pb = s->pb;
31+ AVCodecContext *enc;
32+
33+ if (s->nb_streams != 1) {
34+ av_log(s, AV_LOG_ERROR, "Unsupported number of streams\n");
35+ return AVERROR(EINVAL);
36+ }
37+ enc = s->streams[0]->codec;
38+
39+ if (enc->codec_id != CODEC_ID_ILBC) {
40+ av_log(s, AV_LOG_ERROR, "Unsupported codec\n");
41+ return AVERROR(EINVAL);
42+ }
43+
44+ if (enc->block_align == 50) {
45+ avio_write(pb, mode30_header, sizeof(mode30_header) - 1);
46+ } else if (enc->block_align == 38) {
47+ avio_write(pb, mode20_header, sizeof(mode20_header) - 1);
48+ } else {
49+ av_log(s, AV_LOG_ERROR, "Unsupported mode\n");
50+ return AVERROR(EINVAL);
51+ }
52+ avio_flush(pb);
53+ return 0;
54+}
55+
56+static int ilbc_write_packet(AVFormatContext *s, AVPacket *pkt)
57+{
58+ avio_write(s->pb, pkt->data, pkt->size);
59+ avio_flush(s->pb);
60+ return 0;
61+}
62+
63+static int ilbc_probe(AVProbeData *p)
64+{
65+ // Only check for "#!iLBC" which matches both formats
66+ if (!memcmp(p->buf, mode20_header, 6))
67+ return AVPROBE_SCORE_MAX;
68+ else
69+ return 0;
70+}
71+
72+static int ilbc_read_header(AVFormatContext *s)
73+{
74+ AVIOContext *pb = s->pb;
75+ AVStream *st;
76+ uint8_t header[9];
77+
78+ avio_read(pb, header, 9);
79+
80+ st = avformat_new_stream(s, NULL);
81+ if (!st)
82+ return AVERROR(ENOMEM);
83+ st->codec->codec_id = CODEC_ID_ILBC;
84+ st->codec->sample_rate = 8000;
85+ st->codec->channels = 1;
86+ st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
87+ st->start_time = 0;
88+ avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
89+ if (!memcmp(header, mode20_header, sizeof(mode20_header) - 1)) {
90+ st->codec->block_align = 38;
91+ st->codec->bit_rate = 15200;
92+ } else if (!memcmp(header, mode30_header, sizeof(mode30_header) - 1)) {
93+ st->codec->block_align = 50;
94+ st->codec->bit_rate = 13333;
95+ } else {
96+ av_log(s, AV_LOG_ERROR, "Unrecognized iLBC file header\n");
97+ return AVERROR_INVALIDDATA;
98+ }
99+
100+ return 0;
101+}
102+
103+static int ilbc_read_packet(AVFormatContext *s,
104+ AVPacket *pkt)
105+{
106+ AVCodecContext *enc = s->streams[0]->codec;
107+ int ret;
108+
109+ if ((ret = av_new_packet(pkt, enc->block_align)) < 0)
110+ return ret;
111+
112+ pkt->stream_index = 0;
113+ pkt->pos = avio_tell(s->pb);
114+ pkt->duration = enc->block_align == 38 ? 160 : 240;
115+ if ((ret = avio_read(s->pb, pkt->data, enc->block_align)) != enc->block_align) {
116+ av_free_packet(pkt);
117+ return ret < 0 ? ret : AVERROR(EIO);
118+ }
119+
120+ return 0;
121+}
122+
123+AVInputFormat ff_ilbc_demuxer = {
124+ .name = "ilbc",
125+ .long_name = NULL_IF_CONFIG_SMALL("iLBC storage file format"),
126+ .read_probe = ilbc_probe,
127+ .read_header = ilbc_read_header,
128+ .read_packet = ilbc_read_packet,
129+ .flags = AVFMT_GENERIC_INDEX,
130+};
131+
132+AVOutputFormat ff_ilbc_muxer = {
133+ .name = "ilbc",
134+ .long_name = NULL_IF_CONFIG_SMALL("iLBC storage file format"),
135+ .mime_type = "audio/iLBC",
136+ .extensions = "lbc",
137+ .audio_codec = CODEC_ID_ILBC,
138+ .write_header = ilbc_write_header,
139+ .write_packet = ilbc_write_packet,
140+ .flags = AVFMT_NOTIMESTAMPS,
141+};
libavformat/isom.c+1−0
@@ -259,6 +259,7 @@ const AVCodecTag ff_codec_movaudio_tags[] = { · 258 unmodified lines
259259 { CODEC_ID_DVAUDIO, MKTAG('v', 'd', 'v', 'a') },
260260 { CODEC_ID_DVAUDIO, MKTAG('d', 'v', 'c', 'a') },
261261 { CODEC_ID_GSM, MKTAG('a', 'g', 's', 'm') },
262+ { CODEC_ID_ILBC, MKTAG('i', 'l', 'b', 'c') },
262263 { CODEC_ID_MACE3, MKTAG('M', 'A', 'C', '3') },
263264 { CODEC_ID_MACE6, MKTAG('M', 'A', 'C', '6') },
264265 { CODEC_ID_MP1, MKTAG('.', 'm', 'p', '1') },
libavformat/mov.c+1−0
@@ -1540,6 +1540,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) · 1539 unmodified lines
15401540 case CODEC_ID_GSM:
15411541 case CODEC_ID_ADPCM_MS:
15421542 case CODEC_ID_ADPCM_IMA_WAV:
1543+ case CODEC_ID_ILBC:
15431544 st->codec->block_align = sc->bytes_per_frame;
15441545 break;
15451546 case CODEC_ID_ALAC:
libavformat/movenc.c+2−1
@@ -3371,7 +3371,8 @@ static int mov_write_header(AVFormatContext *s) · 3370 unmodified lines
33713371 av_log(s, AV_LOG_WARNING, "track %d: codec frame size is not set\n", i);
33723372 track->audio_vbr = 1;
33733373 }else if(st->codec->codec_id == CODEC_ID_ADPCM_MS ||
3374− st->codec->codec_id == CODEC_ID_ADPCM_IMA_WAV){
3374+ st->codec->codec_id == CODEC_ID_ADPCM_IMA_WAV ||
3375+ st->codec->codec_id == CODEC_ID_ILBC){
33753376 if (!st->codec->block_align) {
33763377 av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i);
33773378 goto error;
libavformat/mpegts.c+0−94
@@ -19,8 +19,6 @@ · 18 unmodified lines
1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020 */
2121
22−//#define USE_SYNCPOINT_SEARCH
23−
2422 #include "libavutil/crc.h"
2523 #include "libavutil/intreadwrite.h"
2624 #include "libavutil/log.h"
@@ -2161,92 +2159,6 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index, · 2134 unmodified lines
21612159 return AV_NOPTS_VALUE;
21622160 }
21632161
2164−#ifdef USE_SYNCPOINT_SEARCH
2165−
2166−static int read_seek2(AVFormatContext *s,
2167− int stream_index,
2168− int64_t min_ts,
2169− int64_t target_ts,
2170− int64_t max_ts,
2171− int flags)
2172−{
2173− int64_t pos;
2174−
2175− int64_t ts_ret, ts_adj;
2176− int stream_index_gen_search;
2177− AVStream *st;
2178− AVParserState *backup;
2179−
2180− backup = ff_store_parser_state(s);
2181−
2182− // detect direction of seeking for search purposes
2183− flags |= (target_ts - min_ts > (uint64_t)(max_ts - target_ts)) ?
2184− AVSEEK_FLAG_BACKWARD : 0;
2185−
2186− if (flags & AVSEEK_FLAG_BYTE) {
2187− // use position directly, we will search starting from it
2188− pos = target_ts;
2189− } else {
2190− // search for some position with good timestamp match
2191− if (stream_index < 0) {
2192− stream_index_gen_search = av_find_default_stream_index(s);
2193− if (stream_index_gen_search < 0) {
2194− ff_restore_parser_state(s, backup);
2195− return -1;
2196− }
2197−
2198− st = s->streams[stream_index_gen_search];
2199− // timestamp for default must be expressed in AV_TIME_BASE units
2200− ts_adj = av_rescale(target_ts,
2201− st->time_base.den,
2202− AV_TIME_BASE * (int64_t)st->time_base.num);
2203− } else {
2204− ts_adj = target_ts;
2205− stream_index_gen_search = stream_index;
2206− }
2207− pos = ff_gen_search(s, stream_index_gen_search, ts_adj,
2208− 0, INT64_MAX, -1,
2209− AV_NOPTS_VALUE,
2210− AV_NOPTS_VALUE,
2211− flags, &ts_ret, mpegts_get_pcr);
2212− if (pos < 0) {
2213− ff_restore_parser_state(s, backup);
2214− return -1;
2215− }
2216− }
2217−
2218− // search for actual matching keyframe/starting position for all streams
2219− if (ff_gen_syncpoint_search(s, stream_index, pos,
2220− min_ts, target_ts, max_ts,
2221− flags) < 0) {
2222− ff_restore_parser_state(s, backup);
2223− return -1;
2224− }
2225−
2226− ff_free_parser_state(s, backup);
2227− return 0;
2228−}
2229−
2230−static int read_seek(AVFormatContext *s, int stream_index, int64_t target_ts, int flags)
2231−{
2232− int ret;
2233− if (flags & AVSEEK_FLAG_BACKWARD) {
2234− flags &= ~AVSEEK_FLAG_BACKWARD;
2235− ret = read_seek2(s, stream_index, INT64_MIN, target_ts, target_ts, flags);
2236− if (ret < 0)
2237− // for compatibility reasons, seek to the best-fitting timestamp
2238− ret = read_seek2(s, stream_index, INT64_MIN, target_ts, INT64_MAX, flags);
2239− } else {
2240− ret = read_seek2(s, stream_index, target_ts, target_ts, INT64_MAX, flags);
2241− if (ret < 0)
2242− // for compatibility reasons, seek to the best-fitting timestamp
2243− ret = read_seek2(s, stream_index, INT64_MIN, target_ts, INT64_MAX, flags);
2244− }
2245− return ret;
2246−}
2247−
2248−#endif
2249−
22502162 /**************************************************************/
22512163 /* parsing functions - called from other demuxers such as RTP */
22522164
@@ -2313,9 +2225,6 @@ AVInputFormat ff_mpegts_demuxer = { · 60 unmodified lines
23132225 .read_close = mpegts_read_close,
23142226 .read_timestamp = mpegts_get_dts,
23152227 .flags = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
2316−#ifdef USE_SYNCPOINT_SEARCH
2317− .read_seek2 = read_seek2,
2318−#endif
23192228 };
23202229
23212230 AVInputFormat ff_mpegtsraw_demuxer = {
@@ -2327,8 +2236,5 @@ AVInputFormat ff_mpegtsraw_demuxer = { · 5 unmodified lines
23272236 .read_close = mpegts_read_close,
23282237 .read_timestamp = mpegts_get_dts,
23292238 .flags = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
2330−#ifdef USE_SYNCPOINT_SEARCH
2331− .read_seek2 = read_seek2,
2332−#endif
23332239 .priv_class = &mpegtsraw_class,
23342240 };
libavformat/rtmpproto.c+8−0
@@ -76,6 +76,7 @@ typedef struct RTMPContext { · 75 unmodified lines
7676 uint8_t* flv_data; ///< buffer with data for demuxer
7777 int flv_size; ///< current buffer size
7878 int flv_off; ///< number of bytes read from current buffer
79+ int flv_nb_packets; ///< number of flv packets published
7980 RTMPPacket out_pkt; ///< rtmp packet, created from flv a/v or metadata (for output)
8081 uint32_t client_report_size; ///< number of bytes after which client should report to server
8182 uint32_t bytes_read; ///< number of bytes read from server
@@ -90,6 +91,7 @@ typedef struct RTMPContext { · 8 unmodified lines
9091 char* swfurl; ///< url of the swf player
9192 int server_bw; ///< server bandwidth
9293 int client_buffer_time; ///< client buffer time in ms
94+ int flush_interval; ///< number of packets flushed in the same request (RTMPT only)
9395 } RTMPContext;
9496
9597 #define PLAYER_KEY_OPEN_PART_LEN 30 ///< length of partial key used for first client digest signing
@@ -1361,9 +1363,14 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size) · 1265 unmodified lines
13611363 rt->flv_size = 0;
13621364 rt->flv_off = 0;
13631365 rt->flv_header_bytes = 0;
1366+ rt->flv_nb_packets++;
13641367 }
13651368 } while (buf_temp - buf < size);
13661369
1370+ if (rt->flv_nb_packets < rt->flush_interval)
1371+ return size;
1372+ rt->flv_nb_packets = 0;
1373+
13671374 /* set stream into nonblocking mode */
13681375 rt->stream->flags |= AVIO_FLAG_NONBLOCK;
13691376
@@ -1404,6 +1411,7 @@ static const AVOption rtmp_options[] = { · 34 unmodified lines
14041411 {"rtmp_buffer", "Set buffer time in milliseconds. The default is 3000.", OFFSET(client_buffer_time), AV_OPT_TYPE_INT, {3000}, 0, INT_MAX, DEC|ENC},
14051412 {"rtmp_conn", "Append arbitrary AMF data to the Connect message", OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
14061413 {"rtmp_flashver", "Version of the Flash plugin used to run the SWF player.", OFFSET(flashver), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
1414+ {"rtmp_flush_interval", "Number of packets flushed in the same request (RTMPT only).", OFFSET(flush_interval), AV_OPT_TYPE_INT, {10}, 0, INT_MAX, ENC},
14071415 {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), AV_OPT_TYPE_INT, {-2}, INT_MIN, INT_MAX, DEC, "rtmp_live"},
14081416 {"any", "both", 0, AV_OPT_TYPE_CONST, {-2}, 0, 0, DEC, "rtmp_live"},
14091417 {"live", "live stream", 0, AV_OPT_TYPE_CONST, {-1}, 0, 0, DEC, "rtmp_live"},
libavformat/rtpdec.c+1−0
@@ -68,6 +68,7 @@ void av_register_rtp_dynamic_payload_handlers(void) · 67 unmodified lines
6868 ff_register_dynamic_payload_handler(&ff_h263_2000_dynamic_handler);
6969 ff_register_dynamic_payload_handler(&ff_h263_rfc2190_dynamic_handler);
7070 ff_register_dynamic_payload_handler(&ff_h264_dynamic_handler);
71+ ff_register_dynamic_payload_handler(&ff_ilbc_dynamic_handler);
7172 ff_register_dynamic_payload_handler(&ff_vorbis_dynamic_handler);
7273 ff_register_dynamic_payload_handler(&ff_theora_dynamic_handler);
7374 ff_register_dynamic_payload_handler(&ff_qdm2_dynamic_handler);
libavformat/rtpdec_formats.h+1−0
@@ -45,6 +45,7 @@ extern RTPDynamicProtocolHandler ff_h263_1998_dynamic_handler; · 44 unmodified lines
4545 extern RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler;
4646 extern RTPDynamicProtocolHandler ff_h263_rfc2190_dynamic_handler;
4747 extern RTPDynamicProtocolHandler ff_h264_dynamic_handler;
48+extern RTPDynamicProtocolHandler ff_ilbc_dynamic_handler;
4849 extern RTPDynamicProtocolHandler ff_mp4a_latm_dynamic_handler;
4950 extern RTPDynamicProtocolHandler ff_mp4v_es_dynamic_handler;
5051 extern RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler;
libavformat/rtpdec_ilbc.c+73−0
@@ -0,0 +1,73 @@
1+/*
2+ * RTP iLBC Depacketizer, RFC 3952
3+ * Copyright (c) 2012 Martin Storsjo
4+ *
5+ * This file is part of FFmpeg.
6+ *
7+ * FFmpeg is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU Lesser General Public
9+ * License as published by the Free Software Foundation; either
10+ * version 2.1 of the License, or (at your option) any later version.
11+ *
12+ * FFmpeg is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+ * Lesser General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU Lesser General Public
18+ * License along with FFmpeg; if not, write to the Free Software
19+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+ */
21+
22+#include "avformat.h"
23+#include "rtpdec_formats.h"
24+#include "libavutil/avstring.h"
25+
26+static int ilbc_parse_fmtp(AVStream *stream, PayloadContext *data,
27+ char *attr, char *value)
28+{
29+ if (!strcmp(attr, "mode")) {
30+ int mode = atoi(value);
31+ switch (mode) {
32+ case 20:
33+ stream->codec->block_align = 38;
34+ break;
35+ case 30:
36+ stream->codec->block_align = 50;
37+ break;
38+ default:
39+ av_log(NULL, AV_LOG_ERROR, "Unsupported iLBC mode %d\n", mode);
40+ return AVERROR(EINVAL);
41+ }
42+ }
43+ return 0;
44+}
45+
46+static int ilbc_parse_sdp_line(AVFormatContext *s, int st_index,
47+ PayloadContext *data, const char *line)
48+{
49+ const char *p;
50+ AVStream *st;
51+
52+ if (st_index < 0)
53+ return 0;
54+ st = s->streams[st_index];
55+
56+ if (av_strstart(line, "fmtp:", &p)) {
57+ int ret = ff_parse_fmtp(st, data, p, ilbc_parse_fmtp);
58+ if (ret < 0)
59+ return ret;
60+ if (!st->codec->block_align) {
61+ av_log(s, AV_LOG_ERROR, "No iLBC mode set\n");
62+ return AVERROR(EINVAL);
63+ }
64+ }
65+ return 0;
66+}
67+
68+RTPDynamicProtocolHandler ff_ilbc_dynamic_handler = {
69+ .enc_name = "iLBC",
70+ .codec_type = AVMEDIA_TYPE_AUDIO,
71+ .codec_id = CODEC_ID_ILBC,
72+ .parse_sdp_a_line = ilbc_parse_sdp_line,
73+};
libavformat/rtpenc.c+44−0
@@ -74,6 +74,7 @@ static int is_supported(enum CodecID id) · 73 unmodified lines
7474 case CODEC_ID_VP8:
7575 case CODEC_ID_ADPCM_G722:
7676 case CODEC_ID_ADPCM_G726:
77+ case CODEC_ID_ILBC:
7778 return 1;
7879 default:
7980 return 0;
@@ -187,6 +188,16 @@ static int rtp_write_header(AVFormatContext *s1) · 107 unmodified lines
187188 * 8000, even if the sample rate is 16000. See RFC 3551. */
188189 avpriv_set_pts_info(st, 32, 1, 8000);
189190 break;
191+ case CODEC_ID_ILBC:
192+ if (st->codec->block_align != 38 && st->codec->block_align != 50) {
193+ av_log(s1, AV_LOG_ERROR, "Incorrect iLBC block size specified\n");
194+ goto fail;
195+ }
196+ if (!s->max_frames_per_packet)
197+ s->max_frames_per_packet = 1;
198+ s->max_frames_per_packet = FFMIN(s->max_frames_per_packet,
199+ s->max_payload_size / st->codec->block_align);
200+ goto defaultcase;
190201 case CODEC_ID_AMR_NB:
191202 case CODEC_ID_AMR_WB:
192203 if (!s->max_frames_per_packet)
@@ -395,6 +406,36 @@ static void rtp_send_mpegts_raw(AVFormatContext *s1, · 202 unmodified lines
395406 }
396407 }
397408
409+static int rtp_send_ilbc(AVFormatContext *s1, const uint8_t *buf, int size)
410+{
411+ RTPMuxContext *s = s1->priv_data;
412+ AVStream *st = s1->streams[0];
413+ int frame_duration = av_get_audio_frame_duration(st->codec, 0);
414+ int frame_size = st->codec->block_align;
415+ int frames = size / frame_size;
416+
417+ while (frames > 0) {
418+ int n = FFMIN(s->max_frames_per_packet - s->num_frames, frames);
419+
420+ if (!s->num_frames) {
421+ s->buf_ptr = s->buf;
422+ s->timestamp = s->cur_timestamp;
423+ }
424+ memcpy(s->buf_ptr, buf, n * frame_size);
425+ frames -= n;
426+ s->num_frames += n;
427+ s->buf_ptr += n * frame_size;
428+ buf += n * frame_size;
429+ s->cur_timestamp += n * frame_duration;
430+
431+ if (s->num_frames == s->max_frames_per_packet) {
432+ ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 1);
433+ s->num_frames = 0;
434+ }
435+ }
436+ return 0;
437+}
438+
398439 static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
399440 {
400441 RTPMuxContext *s = s1->priv_data;
@@ -483,6 +524,9 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) · 82 unmodified lines
483524 case CODEC_ID_VP8:
484525 ff_rtp_send_vp8(s1, pkt->data, size);
485526 break;
527+ case CODEC_ID_ILBC:
528+ rtp_send_ilbc(s1, pkt->data, size);
529+ break;
486530 default:
487531 /* better than nothing : send the codec raw data */
488532 rtp_send_raw(s1, pkt->data, size);
libavformat/rtsp.c+1−1
@@ -1279,7 +1279,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, · 1278 unmodified lines
12791279 "%s/UDP;multicast", trans_pref);
12801280 }
12811281 if (s->oformat) {
1282− av_strlcat(transport, ";mode=receive", sizeof(transport));
1282+ av_strlcat(transport, ";mode=record", sizeof(transport));
12831283 } else if (rt->server_type == RTSP_SERVER_REAL ||
12841284 rt->server_type == RTSP_SERVER_WMS)
12851285 av_strlcat(transport, ";mode=play", sizeof(transport));
libavformat/sdp.c+6−0
@@ -549,6 +549,12 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c, · 548 unmodified lines
549549 c->sample_rate);
550550 break;
551551 }
552+ case CODEC_ID_ILBC:
553+ av_strlcatf(buff, size, "a=rtpmap:%d iLBC/%d\r\n"
554+ "a=fmtp:%d mode=%d\r\n",
555+ payload_type, c->sample_rate,
556+ payload_type, c->block_align == 38 ? 20 : 30);
557+ break;
552558 default:
553559 /* Nothing special to do here... */
554560 break;
libavformat/version.h+1−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
3030 #include "libavutil/avutil.h"
3131
3232 #define LIBAVFORMAT_VERSION_MAJOR 54
33−#define LIBAVFORMAT_VERSION_MINOR 8
33+#define LIBAVFORMAT_VERSION_MINOR 9
3434 #define LIBAVFORMAT_VERSION_MICRO 100
3535
3636 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
libavresample/x86/audio_convert.asm+209−0
@@ -1,6 +1,7 @@
11 ;******************************************************************************
22 ;* x86 optimized Format Conversion Utils
33 ;* Copyright (c) 2008 Loren Merritt
4+;* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
45 ;*
56 ;* This file is part of Libav.
67 ;*
@@ -21,9 +22,217 @@ · 14 unmodified lines
2122
2223 %include "x86inc.asm"
2324 %include "x86util.asm"
25+%include "util.asm"
26+
27+SECTION_RODATA 32
28+
29+pf_s32_inv_scale: times 8 dd 0x30000000
30+pf_s32_scale: times 8 dd 0x4f000000
31+pf_s16_inv_scale: times 4 dd 0x38000000
32+pf_s16_scale: times 4 dd 0x47000000
2433
2534 SECTION_TEXT
2635
36+;------------------------------------------------------------------------------
37+; void ff_conv_s16_to_s32(int32_t *dst, const int16_t *src, int len);
38+;------------------------------------------------------------------------------
39+
40+INIT_XMM sse2
41+cglobal conv_s16_to_s32, 3,3,3, dst, src, len
42+ lea lenq, [2*lend]
43+ lea dstq, [dstq+2*lenq]
44+ add srcq, lenq
45+ neg lenq
46+.loop:
47+ mova m2, [srcq+lenq]
48+ pxor m0, m0
49+ pxor m1, m1
50+ punpcklwd m0, m2
51+ punpckhwd m1, m2
52+ mova [dstq+2*lenq ], m0
53+ mova [dstq+2*lenq+mmsize], m1
54+ add lenq, mmsize
55+ jl .loop
56+ REP_RET
57+
58+;------------------------------------------------------------------------------
59+; void ff_conv_s16_to_flt(float *dst, const int16_t *src, int len);
60+;------------------------------------------------------------------------------
61+
62+%macro CONV_S16_TO_FLT 0
63+cglobal conv_s16_to_flt, 3,3,3, dst, src, len
64+ lea lenq, [2*lend]
65+ add srcq, lenq
66+ lea dstq, [dstq + 2*lenq]
67+ neg lenq
68+ mova m2, [pf_s16_inv_scale]
69+ ALIGN 16
70+.loop:
71+ mova m0, [srcq+lenq]
72+ S16_TO_S32_SX 0, 1
73+ cvtdq2ps m0, m0
74+ cvtdq2ps m1, m1
75+ mulps m0, m2
76+ mulps m1, m2
77+ mova [dstq+2*lenq ], m0
78+ mova [dstq+2*lenq+mmsize], m1
79+ add lenq, mmsize
80+ jl .loop
81+ REP_RET
82+%endmacro
83+
84+INIT_XMM sse2
85+CONV_S16_TO_FLT
86+INIT_XMM sse4
87+CONV_S16_TO_FLT
88+
89+;------------------------------------------------------------------------------
90+; void ff_conv_s32_to_s16(int16_t *dst, const int32_t *src, int len);
91+;------------------------------------------------------------------------------
92+
93+%macro CONV_S32_TO_S16 0
94+cglobal conv_s32_to_s16, 3,3,4, dst, src, len
95+ lea lenq, [2*lend]
96+ lea srcq, [srcq+2*lenq]
97+ add dstq, lenq
98+ neg lenq
99+.loop:
100+ mova m0, [srcq+2*lenq ]
101+ mova m1, [srcq+2*lenq+ mmsize]
102+ mova m2, [srcq+2*lenq+2*mmsize]
103+ mova m3, [srcq+2*lenq+3*mmsize]
104+ psrad m0, 16
105+ psrad m1, 16
106+ psrad m2, 16
107+ psrad m3, 16
108+ packssdw m0, m1
109+ packssdw m2, m3
110+ mova [dstq+lenq ], m0
111+ mova [dstq+lenq+mmsize], m2
112+ add lenq, mmsize*2
113+ jl .loop
114+%if mmsize == 8
115+ emms
116+ RET
117+%else
118+ REP_RET
119+%endif
120+%endmacro
121+
122+INIT_MMX mmx
123+CONV_S32_TO_S16
124+INIT_XMM sse2
125+CONV_S32_TO_S16
126+
127+;------------------------------------------------------------------------------
128+; void ff_conv_s32_to_flt(float *dst, const int32_t *src, int len);
129+;------------------------------------------------------------------------------
130+
131+%macro CONV_S32_TO_FLT 0
132+cglobal conv_s32_to_flt, 3,3,3, dst, src, len
133+ lea lenq, [4*lend]
134+ add srcq, lenq
135+ add dstq, lenq
136+ neg lenq
137+ mova m0, [pf_s32_inv_scale]
138+ ALIGN 16
139+.loop:
140+ cvtdq2ps m1, [srcq+lenq ]
141+ cvtdq2ps m2, [srcq+lenq+mmsize]
142+ mulps m1, m1, m0
143+ mulps m2, m2, m0
144+ mova [dstq+lenq ], m1
145+ mova [dstq+lenq+mmsize], m2
146+ add lenq, mmsize*2
147+ jl .loop
148+%if mmsize == 32
149+ vzeroupper
150+ RET
151+%else
152+ REP_RET
153+%endif
154+%endmacro
155+
156+INIT_XMM sse2
157+CONV_S32_TO_FLT
158+%if HAVE_AVX
159+INIT_YMM avx
160+CONV_S32_TO_FLT
161+%endif
162+
163+;------------------------------------------------------------------------------
164+; void ff_conv_flt_to_s16(int16_t *dst, const float *src, int len);
165+;------------------------------------------------------------------------------
166+
167+INIT_XMM sse2
168+cglobal conv_flt_to_s16, 3,3,5, dst, src, len
169+ lea lenq, [2*lend]
170+ lea srcq, [srcq+2*lenq]
171+ add dstq, lenq
172+ neg lenq
173+ mova m4, [pf_s16_scale]
174+.loop:
175+ mova m0, [srcq+2*lenq ]
176+ mova m1, [srcq+2*lenq+1*mmsize]
177+ mova m2, [srcq+2*lenq+2*mmsize]
178+ mova m3, [srcq+2*lenq+3*mmsize]
179+ mulps m0, m4
180+ mulps m1, m4
181+ mulps m2, m4
182+ mulps m3, m4
183+ cvtps2dq m0, m0
184+ cvtps2dq m1, m1
185+ cvtps2dq m2, m2
186+ cvtps2dq m3, m3
187+ packssdw m0, m1
188+ packssdw m2, m3
189+ mova [dstq+lenq ], m0
190+ mova [dstq+lenq+mmsize], m2
191+ add lenq, mmsize*2
192+ jl .loop
193+ REP_RET
194+
195+;------------------------------------------------------------------------------
196+; void ff_conv_flt_to_s32(int32_t *dst, const float *src, int len);
197+;------------------------------------------------------------------------------
198+
199+%macro CONV_FLT_TO_S32 0
200+cglobal conv_flt_to_s32, 3,3,5, dst, src, len
201+ lea lenq, [lend*4]
202+ add srcq, lenq
203+ add dstq, lenq
204+ neg lenq
205+ mova m4, [pf_s32_scale]
206+.loop:
207+ mulps m0, m4, [srcq+lenq ]
208+ mulps m1, m4, [srcq+lenq+1*mmsize]
209+ mulps m2, m4, [srcq+lenq+2*mmsize]
210+ mulps m3, m4, [srcq+lenq+3*mmsize]
211+ cvtps2dq m0, m0
212+ cvtps2dq m1, m1
213+ cvtps2dq m2, m2
214+ cvtps2dq m3, m3
215+ mova [dstq+lenq ], m0
216+ mova [dstq+lenq+1*mmsize], m1
217+ mova [dstq+lenq+2*mmsize], m2
218+ mova [dstq+lenq+3*mmsize], m3
219+ add lenq, mmsize*4
220+ jl .loop
221+%if mmsize == 32
222+ vzeroupper
223+ RET
224+%else
225+ REP_RET
226+%endif
227+%endmacro
228+
229+INIT_XMM sse2
230+CONV_FLT_TO_S32
231+%if HAVE_AVX
232+INIT_YMM avx
233+CONV_FLT_TO_S32
234+%endif
235+
27236 ;-----------------------------------------------------------------------------
28237 ; void ff_conv_fltp_to_flt_6ch(float *dst, float *const *src, int len,
29238 ; int channels);
libavresample/x86/audio_convert_init.c+44−0
@@ -22,6 +22,22 @@ · 21 unmodified lines
2222 #include "libavutil/cpu.h"
2323 #include "libavresample/audio_convert.h"
2424
25+extern void ff_conv_s16_to_s32_sse2(int16_t *dst, const int32_t *src, int len);
26+
27+extern void ff_conv_s16_to_flt_sse2(float *dst, const int16_t *src, int len);
28+extern void ff_conv_s16_to_flt_sse4(float *dst, const int16_t *src, int len);
29+
30+extern void ff_conv_s32_to_s16_mmx (int16_t *dst, const int32_t *src, int len);
31+extern void ff_conv_s32_to_s16_sse2(int16_t *dst, const int32_t *src, int len);
32+
33+extern void ff_conv_s32_to_flt_sse2(float *dst, const int32_t *src, int len);
34+extern void ff_conv_s32_to_flt_avx (float *dst, const int32_t *src, int len);
35+
36+extern void ff_conv_flt_to_s16_sse2(int16_t *dst, const float *src, int len);
37+
38+extern void ff_conv_flt_to_s32_sse2(int32_t *dst, const float *src, int len);
39+extern void ff_conv_flt_to_s32_avx (int32_t *dst, const float *src, int len);
40+
2541 extern void ff_conv_fltp_to_flt_6ch_mmx (float *dst, float *const *src, int len);
2642 extern void ff_conv_fltp_to_flt_6ch_sse4(float *dst, float *const *src, int len);
2743 extern void ff_conv_fltp_to_flt_6ch_avx (float *dst, float *const *src, int len);
@@ -32,6 +48,8 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac) · 4 unmodified lines
3248 int mm_flags = av_get_cpu_flags();
3349
3450 if (mm_flags & AV_CPU_FLAG_MMX && HAVE_MMX) {
51+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
52+ 0, 1, 8, "MMX", ff_conv_s32_to_s16_mmx);
3553 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
3654 6, 1, 4, "MMX", ff_conv_fltp_to_flt_6ch_mmx);
3755 }
@@ -43,5 +61,31 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac) · 5 unmodified lines
4361 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
4462 6, 16, 4, "AVX", ff_conv_fltp_to_flt_6ch_avx);
4563 }
64+ if (mm_flags & AV_CPU_FLAG_SSE2 && HAVE_SSE) {
65+ if (!(mm_flags & AV_CPU_FLAG_SSE2SLOW)) {
66+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
67+ 0, 16, 16, "SSE2", ff_conv_s32_to_s16_sse2);
68+ }
69+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16,
70+ 0, 16, 8, "SSE2", ff_conv_s16_to_s32_sse2);
71+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16,
72+ 0, 16, 8, "SSE2", ff_conv_s16_to_flt_sse2);
73+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32,
74+ 0, 16, 8, "SSE2", ff_conv_s32_to_flt_sse2);
75+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT,
76+ 0, 16, 16, "SSE2", ff_conv_flt_to_s16_sse2);
77+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT,
78+ 0, 16, 16, "SSE2", ff_conv_flt_to_s32_sse2);
79+ }
80+ if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE) {
81+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16,
82+ 0, 16, 8, "SSE4", ff_conv_s16_to_flt_sse4);
83+ }
84+ if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) {
85+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32,
86+ 0, 32, 16, "AVX", ff_conv_s32_to_flt_avx);
87+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT,
88+ 0, 32, 32, "AVX", ff_conv_flt_to_s32_avx);
89+ }
4690 #endif
4791 }
libavutil/arm/float_dsp_init_neon.c+4−0
@@ -26,7 +26,11 @@ · 25 unmodified lines
2626
2727 void ff_vector_fmul_neon(float *dst, const float *src0, const float *src1, int len);
2828
29+void ff_vector_fmac_scalar_neon(float *dst, const float *src, float mul,
30+ int len);
31+
2932 void ff_float_dsp_init_neon(AVFloatDSPContext *fdsp)
3033 {
3134 fdsp->vector_fmul = ff_vector_fmul_neon;
35+ fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_neon;
3236 }
libavutil/arm/float_dsp_neon.S+48−0
@@ -62,3 +62,51 @@ function ff_vector_fmul_neon, export=1 · 61 unmodified lines
6262 3: vst1.32 {d16-d19},[r0,:128]!
6363 bx lr
6464 endfunc
65+
66+function ff_vector_fmac_scalar_neon, export=1
67+VFP len .req r2
68+VFP acc .req r3
69+NOVFP len .req r3
70+NOVFP acc .req r2
71+VFP vdup.32 q15, d0[0]
72+NOVFP vdup.32 q15, r2
73+ bics r12, len, #15
74+ mov acc, r0
75+ beq 3f
76+ vld1.32 {q0}, [r1,:128]!
77+ vld1.32 {q8}, [acc,:128]!
78+ vld1.32 {q1}, [r1,:128]!
79+ vld1.32 {q9}, [acc,:128]!
80+1: vmla.f32 q8, q0, q15
81+ vld1.32 {q2}, [r1,:128]!
82+ vld1.32 {q10}, [acc,:128]!
83+ vmla.f32 q9, q1, q15
84+ vld1.32 {q3}, [r1,:128]!
85+ vld1.32 {q11}, [acc,:128]!
86+ vmla.f32 q10, q2, q15
87+ vst1.32 {q8}, [r0,:128]!
88+ vmla.f32 q11, q3, q15
89+ vst1.32 {q9}, [r0,:128]!
90+ subs r12, r12, #16
91+ beq 2f
92+ vld1.32 {q0}, [r1,:128]!
93+ vld1.32 {q8}, [acc,:128]!
94+ vst1.32 {q10}, [r0,:128]!
95+ vld1.32 {q1}, [r1,:128]!
96+ vld1.32 {q9}, [acc,:128]!
97+ vst1.32 {q11}, [r0,:128]!
98+ b 1b
99+2: vst1.32 {q10}, [r0,:128]!
100+ vst1.32 {q11}, [r0,:128]!
101+ ands len, len, #15
102+ it eq
103+ bxeq lr
104+3: vld1.32 {q0}, [r1,:128]!
105+ vld1.32 {q8}, [acc,:128]!
106+ vmla.f32 q8, q0, q15
107+ vst1.32 {q8}, [r0,:128]!
108+ subs len, len, #4
109+ bgt 3b
110+ bx lr
111+ .unreq len
112+endfunc
libavutil/float_dsp.c+9−0
@@ -31,9 +31,18 @@ static void vector_fmul_c(float *dst, const float *src0, const float *src1, · 30 unmodified lines
3131 dst[i] = src0[i] * src1[i];
3232 }
3333
34+static void vector_fmac_scalar_c(float *dst, const float *src, float mul,
35+ int len)
36+{
37+ int i;
38+ for (i = 0; i < len; i++)
39+ dst[i] += src[i] * mul;
40+}
41+
3442 void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
3543 {
3644 fdsp->vector_fmul = vector_fmul_c;
45+ fdsp->vector_fmac_scalar = vector_fmac_scalar_c;
3746
3847 #if ARCH_ARM
3948 ff_float_dsp_init_arm(fdsp);
libavutil/float_dsp.h+16−0
@@ -35,6 +35,22 @@ typedef struct AVFloatDSPContext { · 34 unmodified lines
3535 */
3636 void (*vector_fmul)(float *dst, const float *src0, const float *src1,
3737 int len);
38+
39+ /**
40+ * Multiply a vector of floats by a scalar float and add to
41+ * destination vector. Source and destination vectors must
42+ * overlap exactly or not at all.
43+ *
44+ * @param dst result vector
45+ * constraints: 32-byte aligned
46+ * @param src input vector
47+ * constraints: 32-byte aligned
48+ * @param mul scalar value
49+ * @param len length of vector
50+ * constraints: multiple of 16
51+ */
52+ void (*vector_fmac_scalar)(float *dst, const float *src, float mul,
53+ int len);
3854 } AVFloatDSPContext;
3955
4056 /**
libavutil/mem.c+6−0
@@ -94,6 +94,8 @@ void *av_malloc(size_t size) · 93 unmodified lines
9494 if (size) //OS X on SDK 10.6 has a broken posix_memalign implementation
9595 if (posix_memalign(&ptr,ALIGN,size))
9696 ptr = NULL;
97+#elif HAVE_ALIGNED_MALLOC
98+ ptr = _aligned_malloc(size, ALIGN);
9799 #elif HAVE_MEMALIGN
98100 ptr = memalign(ALIGN,size);
99101 /* Why 64?
@@ -145,6 +147,8 @@ void *av_realloc(void *ptr, size_t size) · 45 unmodified lines
145147 ptr= realloc((char*)ptr - diff, size + diff);
146148 if(ptr) ptr = (char*)ptr + diff;
147149 return ptr;
150+#elif HAVE_ALIGNED_MALLOC
151+ return _aligned_realloc(ptr, size + !size, ALIGN);
148152 #else
149153 return realloc(ptr, size + !size);
150154 #endif
@@ -170,6 +174,8 @@ void av_free(void *ptr) · 19 unmodified lines
170174 #if CONFIG_MEMALIGN_HACK
171175 if (ptr)
172176 free((char*)ptr - ((char*)ptr)[-1]);
177+#elif HAVE_ALIGNED_MALLOC
178+ _aligned_free(ptr);
173179 #else
174180 free(ptr);
175181 #endif
libavutil/x86/float_dsp.asm+47−0
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 ;******************************************************************************
2222
2323 %include "x86inc.asm"
24+%include "x86util.asm"
2425
2526 SECTION .text
2627
@@ -55,3 +56,49 @@ VECTOR_FMUL · 28 unmodified lines
5556 INIT_YMM avx
5657 VECTOR_FMUL
5758 %endif
59+
60+;------------------------------------------------------------------------------
61+; void ff_vector_fmac_scalar(float *dst, const float *src, float mul, int len)
62+;------------------------------------------------------------------------------
63+
64+%macro VECTOR_FMAC_SCALAR 0
65+%if UNIX64
66+cglobal vector_fmac_scalar, 3,3,3, dst, src, len
67+%else
68+cglobal vector_fmac_scalar, 4,4,3, dst, src, mul, len
69+%endif
70+%if WIN64
71+ SWAP 0, 2
72+%endif
73+%if ARCH_X86_32
74+ VBROADCASTSS m0, mulm
75+%else
76+ shufps xmm0, xmm0, 0
77+%if cpuflag(avx)
78+ vinsertf128 m0, m0, xmm0, 1
79+%endif
80+%endif
81+ lea lenq, [lend*4-2*mmsize]
82+.loop
83+ mulps m1, m0, [srcq+lenq ]
84+ mulps m2, m0, [srcq+lenq+mmsize]
85+ addps m1, m1, [dstq+lenq ]
86+ addps m2, m2, [dstq+lenq+mmsize]
87+ mova [dstq+lenq ], m1
88+ mova [dstq+lenq+mmsize], m2
89+ sub lenq, 2*mmsize
90+ jge .loop
91+%if mmsize == 32
92+ vzeroupper
93+ RET
94+%else
95+ REP_RET
96+%endif
97+%endmacro
98+
99+INIT_XMM sse
100+VECTOR_FMAC_SCALAR
101+%if HAVE_AVX
102+INIT_YMM avx
103+VECTOR_FMAC_SCALAR
104+%endif
libavutil/x86/float_dsp_init.c+7−0
@@ -26,6 +26,11 @@ extern void ff_vector_fmul_sse(float *dst, const float *src0, const float *src1, · 25 unmodified lines
2626 extern void ff_vector_fmul_avx(float *dst, const float *src0, const float *src1,
2727 int len);
2828
29+extern void ff_vector_fmac_scalar_sse(float *dst, const float *src, float mul,
30+ int len);
31+extern void ff_vector_fmac_scalar_avx(float *dst, const float *src, float mul,
32+ int len);
33+
2934 void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp)
3035 {
3136 #if HAVE_YASM
@@ -33,9 +38,11 @@ void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp) · 1 unmodified line
3338
3439 if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) {
3540 fdsp->vector_fmul = ff_vector_fmul_sse;
41+ fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_sse;
3642 }
3743 if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) {
3844 fdsp->vector_fmul = ff_vector_fmul_avx;
45+ fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_avx;
3946 }
4047 #endif
4148 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t