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
10- atempo filter10- atempo filter
11- ffprobe -show_data option11- ffprobe -show_data option
12- RTMPT protocol support12- RTMPT protocol support
13- iLBC encoding/decoding via libilbc
13 14
14 15
15version 0.11:16version 0.11:
configure+9−1
@@ -180,6 +180,7 @@ External library support: · 179 unmodified lines
180 --enable-libfaac enable FAAC support via libfaac [no]180 --enable-libfaac enable FAAC support via libfaac [no]
181 --enable-libfreetype enable libfreetype [no]181 --enable-libfreetype enable libfreetype [no]
182 --enable-libgsm enable GSM support via libgsm [no]182 --enable-libgsm enable GSM support via libgsm [no]
183 --enable-libilbc enable iLBC de/encoding via libilbc [no]
183 --enable-libmodplug enable ModPlug via libmodplug [no]184 --enable-libmodplug enable ModPlug via libmodplug [no]
184 --enable-libmp3lame enable MP3 encoding via libmp3lame [no]185 --enable-libmp3lame enable MP3 encoding via libmp3lame [no]
185 --enable-libnut enable NUT (de)muxing via libnut,186 --enable-libnut enable NUT (de)muxing via libnut,
@@ -1051,6 +1052,7 @@ CONFIG_LIST=" · 865 unmodified lines
1051 libfaac1052 libfaac
1052 libfreetype1053 libfreetype
1053 libgsm1054 libgsm
1055 libilbc
1054 libmodplug1056 libmodplug
1055 libmp3lame1057 libmp3lame
1056 libnut1058 libnut
@@ -1168,6 +1170,7 @@ HAVE_LIST=" · 111 unmodified lines
1168 $ARCH_EXT_LIST1170 $ARCH_EXT_LIST
1169 $HAVE_LIST_PUB1171 $HAVE_LIST_PUB
1170 $THREADS_LIST1172 $THREADS_LIST
1173 aligned_malloc
1171 aligned_stack1174 aligned_stack
1172 alsa_asoundlib_h1175 alsa_asoundlib_h
1173 altivec_h1176 altivec_h
@@ -1588,6 +1591,8 @@ libgsm_decoder_deps="libgsm" · 414 unmodified lines
1588libgsm_encoder_deps="libgsm"1591libgsm_encoder_deps="libgsm"
1589libgsm_ms_decoder_deps="libgsm"1592libgsm_ms_decoder_deps="libgsm"
1590libgsm_ms_encoder_deps="libgsm"1593libgsm_ms_encoder_deps="libgsm"
1594libilbc_decoder_deps="libilbc"
1595libilbc_encoder_deps="libilbc"
1591libmodplug_demuxer_deps="libmodplug"1596libmodplug_demuxer_deps="libmodplug"
1592libmp3lame_encoder_deps="libmp3lame"1597libmp3lame_encoder_deps="libmp3lame"
1593libopencore_amrnb_decoder_deps="libopencore_amrnb"1598libopencore_amrnb_decoder_deps="libopencore_amrnb"
@@ -3144,6 +3149,7 @@ check_func ${malloc_prefix}memalign && enable memalign · 1550 unmodified lines
3144check_func mkstemp3149check_func mkstemp
3145check_func mmap3150check_func mmap
3146check_func ${malloc_prefix}posix_memalign && enable posix_memalign3151check_func ${malloc_prefix}posix_memalign && enable posix_memalign
3152check_func_headers malloc.h _aligned_malloc && enable aligned_malloc
3147check_func setrlimit3153check_func setrlimit
3148check_func strerror_r3154check_func strerror_r
3149check_func strptime3155check_func strptime
@@ -3254,6 +3260,7 @@ enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 && · 104 unmodified lines
3254enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac3260enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
3255enabled libfreetype && require_pkg_config freetype2 "ft2build.h freetype/freetype.h" FT_Init_FreeType3261enabled libfreetype && require_pkg_config freetype2 "ft2build.h freetype/freetype.h" FT_Init_FreeType
3256enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm3262enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
3263enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
3257enabled libmodplug && require libmodplug libmodplug/modplug.h ModPlug_Load -lmodplug3264enabled libmodplug && require libmodplug libmodplug/modplug.h ModPlug_Load -lmodplug
3258enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame3265enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
3259enabled libnut && require libnut libnut.h nut_demuxer_init -lnut3266enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
@@ -3522,7 +3529,7 @@ if test $target_os = "haiku"; then · 262 unmodified lines
3522 disable posix_memalign3529 disable posix_memalign
3523fi3530fi
3524 3531
3525! enabled_any memalign posix_memalign &&3532! enabled_any memalign posix_memalign aligned_malloc &&
3526 enabled_any $need_memalign && enable memalign_hack3533 enabled_any $need_memalign && enable memalign_hack
3527 3534
3528# add_dep lib dep3535# add_dep lib dep
@@ -3628,6 +3635,7 @@ echo "libcelt enabled ${libcelt-no}" · 99 unmodified lines
3628echo "libdc1394 support ${libdc1394-no}"3635echo "libdc1394 support ${libdc1394-no}"
3629echo "libfaac enabled ${libfaac-no}"3636echo "libfaac enabled ${libfaac-no}"
3630echo "libgsm enabled ${libgsm-no}"3637echo "libgsm enabled ${libgsm-no}"
3638echo "libilbc enabled ${libilbc-no}"
3631echo "libmodplug enabled ${libmodplug-no}"3639echo "libmodplug enabled ${libmodplug-no}"
3632echo "libmp3lame enabled ${libmp3lame-no}"3640echo "libmp3lame enabled ${libmp3lame-no}"
3633echo "libnut enabled ${libnut-no}"3641echo "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
93details), you must upgrade FFmpeg's license to GPL in order to use it.93details), you must upgrade FFmpeg's license to GPL in order to use it.
94@end float94@end float
95 95
96@section libilbc
97
98iLBC is a narrowband speech codec that has been made freely available
99by Google as part of the WebRTC project. libilbc is a packaging friendly
100copy of the iLBC codec. Libav can make use of the libilbc library for
101iLBC encoding and decoding.
102
103Go to @url{https://github.com/dekkers/libilbc} and follow the instructions for
104installing the library. Then pass @code{--enable-libilbc} to configure to
105enable it.
106
96 107
97 108
98@chapter Supported File Formats, Codecs or Features109@chapter Supported File Formats, Codecs or Features
@@ -191,6 +202,7 @@ library: · 92 unmodified lines
191@item IEC61937 encapsulation @tab X @tab X202@item IEC61937 encapsulation @tab X @tab X
192@item IFF @tab @tab X203@item IFF @tab @tab X
193 @tab Interchange File Format204 @tab Interchange File Format
205@item iLBC @tab X @tab X
194@item Interplay MVE @tab @tab X206@item Interplay MVE @tab @tab X
195 @tab Format used in various Interplay computer games.207 @tab Format used in various Interplay computer games.
196@item IV8 @tab @tab X208@item IV8 @tab @tab X
@@ -749,6 +761,8 @@ following image formats are supported: · 552 unmodified lines
749@item GSM Microsoft variant @tab E @tab X761@item GSM Microsoft variant @tab E @tab X
750 @tab encoding supported through external library libgsm762 @tab encoding supported through external library libgsm
751@item IAC (Indeo Audio Coder) @tab @tab X763@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
752@item IMC (Intel Music Coder) @tab @tab X766@item IMC (Intel Music Coder) @tab @tab X
753@item MACE (Macintosh Audio Compression/Expansion) 3:1 @tab @tab X767@item MACE (Macintosh Audio Compression/Expansion) 3:1 @tab @tab X
754@item MACE (Macintosh Audio Compression/Expansion) 6:1 @tab @tab X768@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
247Version of the Flash plugin used to run the SWF player. The default247Version of the Flash plugin used to run the SWF player. The default
248is LNX 9,0,124,2.248is LNX 9,0,124,2.
249 249
250@item rtmp_flush_interval
251Number of packets flushed in the same request (RTMPT only). The default
252is 10.
253
250@item rtmp_live254@item rtmp_live
251Specify that the media is a live stream. No resuming or seeking in255Specify that the media is a live stream. No resuming or seeking in
252live streams is possible. The default value is @code{any}, which means the256live 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
659OBJS-$(CONFIG_LIBGSM_ENCODER) += libgsm.o659OBJS-$(CONFIG_LIBGSM_ENCODER) += libgsm.o
660OBJS-$(CONFIG_LIBGSM_MS_DECODER) += libgsm.o660OBJS-$(CONFIG_LIBGSM_MS_DECODER) += libgsm.o
661OBJS-$(CONFIG_LIBGSM_MS_ENCODER) += libgsm.o661OBJS-$(CONFIG_LIBGSM_MS_ENCODER) += libgsm.o
662OBJS-$(CONFIG_LIBILBC_DECODER) += libilbc.o
663OBJS-$(CONFIG_LIBILBC_ENCODER) += libilbc.o
662OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o mpegaudiodecheader.o \664OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o mpegaudiodecheader.o \
663 audio_frame_queue.o665 audio_frame_queue.o
664OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER) += libopencore-amr.o \666OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER) += libopencore-amr.o \
libavcodec/allcodecs.c+1−0
@@ -410,6 +410,7 @@ void avcodec_register_all(void) · 409 unmodified lines
410 REGISTER_ENCODER (LIBFAAC, libfaac);410 REGISTER_ENCODER (LIBFAAC, libfaac);
411 REGISTER_ENCDEC (LIBGSM, libgsm);411 REGISTER_ENCDEC (LIBGSM, libgsm);
412 REGISTER_ENCDEC (LIBGSM_MS, libgsm_ms);412 REGISTER_ENCDEC (LIBGSM_MS, libgsm_ms);
413 REGISTER_ENCDEC (LIBILBC, libilbc);
413 REGISTER_ENCODER (LIBMP3LAME, libmp3lame);414 REGISTER_ENCODER (LIBMP3LAME, libmp3lame);
414 REGISTER_ENCDEC (LIBOPENCORE_AMRNB, libopencore_amrnb);415 REGISTER_ENCDEC (LIBOPENCORE_AMRNB, libopencore_amrnb);
415 REGISTER_DECODER (LIBOPENCORE_AMRWB, libopencore_amrwb);416 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
154 const float *src1, const float *win, int len);154 const float *src1, const float *win, int len);
155void ff_vector_fmul_scalar_neon(float *dst, const float *src, float mul,155void ff_vector_fmul_scalar_neon(float *dst, const float *src, float mul,
156 int len);156 int len);
157void ff_vector_fmac_scalar_neon(float *dst, const float *src, float mul,
158 int len);
159void ff_butterflies_float_neon(float *v1, float *v2, int len);157void ff_butterflies_float_neon(float *v1, float *v2, int len);
160float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len);158float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len);
161void ff_vector_fmul_reverse_neon(float *dst, const float *src0,159void 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
329 327
330 c->vector_fmul_window = ff_vector_fmul_window_neon;328 c->vector_fmul_window = ff_vector_fmul_window_neon;
331 c->vector_fmul_scalar = ff_vector_fmul_scalar_neon;329 c->vector_fmul_scalar = ff_vector_fmul_scalar_neon;
332 c->vector_fmac_scalar = ff_vector_fmac_scalar_neon;
333 c->butterflies_float = ff_butterflies_float_neon;330 c->butterflies_float = ff_butterflies_float_neon;
334 c->scalarproduct_float = ff_scalarproduct_float_neon;331 c->scalarproduct_float = ff_scalarproduct_float_neon;
335 c->vector_fmul_reverse = ff_vector_fmul_reverse_neon;332 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
682 .unreq len682 .unreq len
683endfunc683endfunc
684 684
685function ff_vector_fmac_scalar_neon, export=1
686VFP len .req r2
687VFP acc .req r3
688NOVFP len .req r3
689NOVFP acc .req r2
690VFP vdup.32 q15, d0[0]
691NOVFP 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]!
6991: 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
7182: vst1.32 {q10}, [r0,:128]!
719 vst1.32 {q11}, [r0,:128]!
720 ands len, len, #15
721 it eq
722 bxeq lr
7233: 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
731endfunc
732
733function ff_butterflies_float_neon, export=1685function ff_butterflies_float_neon, export=1
7341: vld1.32 {q0},[r0,:128]6861: vld1.32 {q0},[r0,:128]
735 vld1.32 {q1},[r1,:128]687 vld1.32 {q1},[r1,:128]
libavcodec/avcodec.h+4−0
@@ -407,6 +407,7 @@ enum CodecID { · 406 unmodified lines
407 CODEC_ID_BMV_AUDIO,407 CODEC_ID_BMV_AUDIO,
408 CODEC_ID_RALF,408 CODEC_ID_RALF,
409 CODEC_ID_IAC,409 CODEC_ID_IAC,
410 CODEC_ID_ILBC,
410 CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),411 CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
411 CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'),412 CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'),
412 CODEC_ID_SONIC = MKBETAG('S','O','N','C'),413 CODEC_ID_SONIC = MKBETAG('S','O','N','C'),
@@ -3470,6 +3471,9 @@ void av_destruct_packet(AVPacket *pkt); · 3057 unmodified lines
3470/**3471/**
3471 * Initialize optional fields of a packet with default values.3472 * Initialize optional fields of a packet with default values.
3472 *3473 *
3474 * Note, this does not touch the data and size members, which have to be
3475 * initialized separately.
3476 *
3473 * @param pkt packet3477 * @param pkt packet
3474 */3478 */
3475void av_init_packet(AVPacket *pkt);3479void av_init_packet(AVPacket *pkt);
libavcodec/dca.c+5−4
@@ -27,6 +27,7 @@ · 26 unmodified lines
27#include <stdio.h>27#include <stdio.h>
28 28
29#include "libavutil/common.h"29#include "libavutil/common.h"
30#include "libavutil/float_dsp.h"
30#include "libavutil/intmath.h"31#include "libavutil/intmath.h"
31#include "libavutil/intreadwrite.h"32#include "libavutil/intreadwrite.h"
32#include "libavutil/mathematics.h"33#include "libavutil/mathematics.h"
@@ -384,7 +385,7 @@ typedef struct { · 351 unmodified lines
384 int profile;385 int profile;
385 386
386 int debug_flag; ///< used for suppressing repeated error messages output387 int debug_flag; ///< used for suppressing repeated error messages output
387 DSPContext dsp;388 AVFloatDSPContext fdsp;
388 FFTContext imdct;389 FFTContext imdct;
389 SynthFilterContext synth;390 SynthFilterContext synth;
390 DCADSPContext dcadsp;391 DCADSPContext dcadsp;
@@ -2042,8 +2043,8 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 1651 unmodified lines
2042 float *back_chan = s->samples + s->channel_order_tab[s->xch_base_channel] * 256;2043 float *back_chan = s->samples + s->channel_order_tab[s->xch_base_channel] * 256;
2043 float *lt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 2] * 256;2044 float *lt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 2] * 256;
2044 float *rt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 1] * 256;2045 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->fdsp.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);2047 s->fdsp.vector_fmac_scalar(rt_chan, back_chan, -M_SQRT1_2, 256);
2047 }2048 }
2048 2049
2049 if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {2050 if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
@@ -2085,7 +2086,7 @@ static av_cold int dca_decode_init(AVCodecContext *avctx) · 35 unmodified lines
2085 s->avctx = avctx;2086 s->avctx = avctx;
2086 dca_init_vlcs();2087 dca_init_vlcs();
2087 2088
2088 ff_dsputil_init(&s->dsp, avctx);2089 avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
2089 ff_mdct_init(&s->imdct, 6, 1, 1.0);2090 ff_mdct_init(&s->imdct, 6, 1, 1.0);
2090 ff_synth_filter_init(&s->synth);2091 ff_synth_filter_init(&s->synth);
2091 ff_dcadsp_init(&s->dcadsp);2092 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
127static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,127static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
128 dirac_source_params *source)128 dirac_source_params *source)
129{129{
130 AVRational frame_rate = (AVRational){0,0};130 AVRational frame_rate = {0,0};
131 unsigned luma_depth = 8, luma_offset = 16;131 unsigned luma_depth = 8, luma_offset = 16;
132 int idx;132 int idx;
133 133
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
2509 dst[i] = src[i] * mul;2509 dst[i] = src[i] * mul;
2510}2510}
2511 2511
2512static 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
2520static void butterflies_float_c(float *av_restrict v1, float *av_restrict v2,2512static void butterflies_float_c(float *av_restrict v1, float *av_restrict v2,
2521 int len)2513 int len)
2522{2514{
@@ -3060,7 +3052,6 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) · 537 unmodified lines
3060 c->butterflies_float = butterflies_float_c;3052 c->butterflies_float = butterflies_float_c;
3061 c->butterflies_float_interleave = butterflies_float_interleave_c;3053 c->butterflies_float_interleave = butterflies_float_interleave_c;
3062 c->vector_fmul_scalar = vector_fmul_scalar_c;3054 c->vector_fmul_scalar = vector_fmul_scalar_c;
3063 c->vector_fmac_scalar = vector_fmac_scalar_c;
3064 3055
3065 c->shrink[0]= av_image_copy_plane;3056 c->shrink[0]= av_image_copy_plane;
3066 c->shrink[1]= ff_shrink22;3057 c->shrink[1]= ff_shrink22;
libavcodec/dsputil.h+0−11
@@ -420,17 +420,6 @@ typedef struct DSPContext { · 419 unmodified lines
420 */420 */
421 void (*vector_fmul_scalar)(float *dst, const float *src, float mul,421 void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
422 int len);422 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);
434 /**423 /**
435 * Calculate the scalar product of two vectors of floats.424 * Calculate the scalar product of two vectors of floats.
436 * @param v1 first vector, 16-byte aligned425 * @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
28static 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
40typedef struct ILBCDecContext {
41 const AVClass *class;
42 AVFrame frame;
43 iLBC_Dec_Inst_t decoder;
44 int enhance;
45} ILBCDecContext;
46
47static 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
52static const AVClass ilbc_dec_class = {
53 "libilbc", av_default_item_name, ilbc_dec_options, LIBAVUTIL_VERSION_INT
54};
55
56static 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
77static 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
106AVCodec 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
118typedef struct ILBCEncContext {
119 const AVClass *class;
120 iLBC_Enc_Inst_t encoder;
121 int mode;
122} ILBCEncContext;
123
124static 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
129static const AVClass ilbc_enc_class = {
130 "libilbc", av_default_item_name, ilbc_enc_options, LIBAVUTIL_VERSION_INT
131};
132
133static 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
165static 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
173static 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
191static const AVCodecDefault ilbc_encode_defaults[] = {
192 { "b", "0" },
193 { NULL }
194};
195
196AVCodec 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
514 return p->coeff*var / (q*p->count);514 return p->coeff*var / (q*p->count);
515}515}
516 516
517/*
518static 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
525static void update_predictor(Predictor *p, double q, double var, double size)517static void update_predictor(Predictor *p, double q, double var, double size)
526{518{
527 double new_coeff= size*q / (var + 1);519 double new_coeff= size*q / (var + 1);
@@ -561,10 +553,6 @@ static void adaptive_quantization(MpegEncContext *s, double q){ · 33 unmodified lines
561 int mb_y = mb_xy / s->mb_stride;553 int mb_y = mb_xy / s->mb_stride;
562 int mb_distance;554 int mb_distance;
563 float mb_factor = 0.0;555 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
568 if(spat_cplx < 4) spat_cplx= 4; //FIXME finetune556 if(spat_cplx < 4) spat_cplx= 4; //FIXME finetune
569 if(temp_cplx < 4) temp_cplx= 4; //FIXME finetune557 if(temp_cplx < 4) temp_cplx= 4; //FIXME finetune
570 558
libavcodec/utils.c+5−0
@@ -2138,6 +2138,11 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) · 2137 unmodified lines
2138 case 29: return 288;2138 case 29: return 288;
2139 case 37: return 480;2139 case 37: return 480;
2140 }2140 }
2141 } else if (id == CODEC_ID_ILBC) {
2142 switch (ba) {
2143 case 38: return 160;
2144 case 50: return 240;
2145 }
2141 }2146 }
2142 }2147 }
2143 2148
libavcodec/version.h+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
27 */27 */
28 28
29#define LIBAVCODEC_VERSION_MAJOR 5429#define LIBAVCODEC_VERSION_MAJOR 54
30#define LIBAVCODEC_VERSION_MINOR 2530#define LIBAVCODEC_VERSION_MINOR 26
31#define LIBAVCODEC_VERSION_MICRO 10031#define LIBAVCODEC_VERSION_MICRO 100
32 32
33#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \33#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
libavfilter/af_amix.c+19−11
@@ -32,6 +32,7 @@ · 31 unmodified lines
32#include "libavutil/audio_fifo.h"32#include "libavutil/audio_fifo.h"
33#include "libavutil/avassert.h"33#include "libavutil/avassert.h"
34#include "libavutil/avstring.h"34#include "libavutil/avstring.h"
35#include "libavutil/float_dsp.h"
35#include "libavutil/mathematics.h"36#include "libavutil/mathematics.h"
36#include "libavutil/opt.h"37#include "libavutil/opt.h"
37#include "libavutil/samplefmt.h"38#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
152 153
153typedef struct MixContext {154typedef struct MixContext {
154 const AVClass *class; /**< class for AVOptions */155 const AVClass *class; /**< class for AVOptions */
156 AVFloatDSPContext fdsp;
155 157
156 int nb_inputs; /**< number of inputs */158 int nb_inputs; /**< number of inputs */
157 int active_inputs; /**< number of input currently active */159 int active_inputs; /**< number of input currently active */
@@ -160,6 +162,7 @@ typedef struct MixContext { · 2 unmodified lines
160 162
161 int nb_channels; /**< number of channels */163 int nb_channels; /**< number of channels */
162 int sample_rate; /**< sample rate */164 int sample_rate; /**< sample rate */
165 int planar;
163 AVAudioFifo **fifos; /**< audio fifo for each input */166 AVAudioFifo **fifos; /**< audio fifo for each input */
164 uint8_t *input_state; /**< current state of each input */167 uint8_t *input_state; /**< current state of each input */
165 float *input_scale; /**< mixing scale factor for each input */168 float *input_scale; /**< mixing scale factor for each input */
@@ -224,6 +227,7 @@ static int config_output(AVFilterLink *outlink) · 58 unmodified lines
224 int i;227 int i;
225 char buf[64];228 char buf[64];
226 229
230 s->planar = av_sample_fmt_is_planar(outlink->format);
227 s->sample_rate = outlink->sample_rate;231 s->sample_rate = outlink->sample_rate;
228 outlink->time_base = (AVRational){ 1, outlink->sample_rate };232 outlink->time_base = (AVRational){ 1, outlink->sample_rate };
229 s->next_pts = AV_NOPTS_VALUE;233 s->next_pts = AV_NOPTS_VALUE;
@@ -264,14 +268,6 @@ static int config_output(AVFilterLink *outlink) · 34 unmodified lines
264 return 0;268 return 0;
265}269}
266 270
267/* TODO: move optimized version from DSPContext to libavutil */
268static 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
275/**271/**
276 * Read samples from the input FIFOs, mix, and write to the output link.272 * Read samples from the input FIFOs, mix, and write to the output link.
277 */273 */
@@ -294,11 +290,20 @@ static int output_frame(AVFilterLink *outlink, int nb_samples) · 16 unmodified lines
294 290
295 for (i = 0; i < s->nb_inputs; i++) {291 for (i = 0; i < s->nb_inputs; i++) {
296 if (s->input_state[i] == INPUT_ON) {292 if (s->input_state[i] == INPUT_ON) {
293 int planes, plane_size, p;
294
297 av_audio_fifo_read(s->fifos[i], (void **)in_buf->extended_data,295 av_audio_fifo_read(s->fifos[i], (void **)in_buf->extended_data,
298 nb_samples);296 nb_samples);
299 vector_fmac_scalar((float *)out_buf->extended_data[0],297
300 (float *) in_buf->extended_data[0],298 planes = s->planar ? s->nb_channels : 1;
301 s->input_scale[i], nb_samples * s->nb_channels);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 }
302 }307 }
303 }308 }
304 avfilter_unref_buffer(in_buf);309 avfilter_unref_buffer(in_buf);
@@ -501,6 +506,8 @@ static int init(AVFilterContext *ctx, const char *args, void *opaque) · 196 unmodified lines
501 ff_insert_inpad(ctx, i, &pad);506 ff_insert_inpad(ctx, i, &pad);
502 }507 }
503 508
509 avpriv_float_dsp_init(&s->fdsp, 0);
510
504 return 0;511 return 0;
505}512}
506 513
@@ -527,6 +534,7 @@ static int query_formats(AVFilterContext *ctx) · 20 unmodified lines
527{534{
528 AVFilterFormats *formats = NULL;535 AVFilterFormats *formats = NULL;
529 ff_add_format(&formats, AV_SAMPLE_FMT_FLT);536 ff_add_format(&formats, AV_SAMPLE_FMT_FLT);
537 ff_add_format(&formats, AV_SAMPLE_FMT_FLTP);
530 ff_set_common_formats(ctx, formats);538 ff_set_common_formats(ctx, formats);
531 ff_set_common_channel_layouts(ctx, ff_all_channel_layouts());539 ff_set_common_channel_layouts(ctx, ff_all_channel_layouts());
532 ff_set_common_samplerates(ctx, ff_all_samplerates());540 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
123OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o123OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
124OBJS-$(CONFIG_IDF_DEMUXER) += bintext.o124OBJS-$(CONFIG_IDF_DEMUXER) += bintext.o
125OBJS-$(CONFIG_IFF_DEMUXER) += iff.o125OBJS-$(CONFIG_IFF_DEMUXER) += iff.o
126OBJS-$(CONFIG_ILBC_DEMUXER) += ilbc.o
127OBJS-$(CONFIG_ILBC_MUXER) += ilbc.o
126OBJS-$(CONFIG_IMAGE2_DEMUXER) += img2dec.o img2.o128OBJS-$(CONFIG_IMAGE2_DEMUXER) += img2dec.o img2.o
127OBJS-$(CONFIG_IMAGE2_MUXER) += img2enc.o img2.o129OBJS-$(CONFIG_IMAGE2_MUXER) += img2enc.o img2.o
128OBJS-$(CONFIG_IMAGE2PIPE_DEMUXER) += img2dec.o img2.o130OBJS-$(CONFIG_IMAGE2PIPE_DEMUXER) += img2dec.o img2.o
@@ -281,6 +283,7 @@ OBJS-$(CONFIG_RTPDEC) += rdt.o \ · 152 unmodified lines
281 rtpdec_h263.o \283 rtpdec_h263.o \
282 rtpdec_h263_rfc2190.o \284 rtpdec_h263_rfc2190.o \
283 rtpdec_h264.o \285 rtpdec_h264.o \
286 rtpdec_ilbc.o \
284 rtpdec_latm.o \287 rtpdec_latm.o \
285 rtpdec_mpeg4.o \288 rtpdec_mpeg4.o \
286 rtpdec_qcelp.o \289 rtpdec_qcelp.o \
libavformat/allformats.c+1−0
@@ -116,6 +116,7 @@ void av_register_all(void) · 115 unmodified lines
116 REGISTER_DEMUXER (IDCIN, idcin);116 REGISTER_DEMUXER (IDCIN, idcin);
117 REGISTER_DEMUXER (IDF, idf);117 REGISTER_DEMUXER (IDF, idf);
118 REGISTER_DEMUXER (IFF, iff);118 REGISTER_DEMUXER (IFF, iff);
119 REGISTER_MUXDEMUX (ILBC, ilbc);
119 REGISTER_MUXDEMUX (IMAGE2, image2);120 REGISTER_MUXDEMUX (IMAGE2, image2);
120 REGISTER_MUXDEMUX (IMAGE2PIPE, image2pipe);121 REGISTER_MUXDEMUX (IMAGE2PIPE, image2pipe);
121 REGISTER_DEMUXER (INGENIENT, ingenient);122 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
759 return avio_seek_time(s->pb, stream_index, ts, flags);759 return avio_seek_time(s->pb, stream_index, ts, flags);
760}760}
761 761
762#if 0 /* don't know enough to implement this */
763static 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
789AVInputFormat ff_flv_demuxer = {762AVInputFormat ff_flv_demuxer = {
790 .name = "flv",763 .name = "flv",
791 .long_name = NULL_IF_CONFIG_SMALL("FLV format"),764 .long_name = NULL_IF_CONFIG_SMALL("FLV format"),
@@ -794,9 +767,6 @@ AVInputFormat ff_flv_demuxer = { · 2 unmodified lines
794 .read_header = flv_read_header,767 .read_header = flv_read_header,
795 .read_packet = flv_read_packet,768 .read_packet = flv_read_packet,
796 .read_seek = flv_read_seek,769 .read_seek = flv_read_seek,
797#if 0
798 .read_seek2 = flv_read_seek2,
799#endif
800 .read_close = flv_read_close,770 .read_close = flv_read_close,
801 .extensions = "flv",771 .extensions = "flv",
802};772};
libavformat/http.c+3−3
@@ -308,15 +308,15 @@ static int process_line(URLContext *h, char *line, int line_count, · 307 unmodified lines
308 strcpy(s->location, p);308 strcpy(s->location, p);
309 *new_location = 1;309 *new_location = 1;
310 } else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) {310 } else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) {
311 s->filesize = atoll(p);311 s->filesize = strtoll(p, NULL, 10);
312 } else if (!av_strcasecmp (tag, "Content-Range")) {312 } else if (!av_strcasecmp (tag, "Content-Range")) {
313 /* "bytes $from-$to/$document_size" */313 /* "bytes $from-$to/$document_size" */
314 const char *slash;314 const char *slash;
315 if (!strncmp (p, "bytes ", 6)) {315 if (!strncmp (p, "bytes ", 6)) {
316 p += 6;316 p += 6;
317 s->off = atoll(p);317 s->off = strtoll(p, NULL, 10);
318 if ((slash = strchr(p, '/')) && strlen(slash) > 0)318 if ((slash = strchr(p, '/')) && strlen(slash) > 0)
319 s->filesize = atoll(slash+1);319 s->filesize = strtoll(slash+1, NULL, 10);
320 }320 }
321 h->is_streamed = 0; /* we _can_ in fact seek */321 h->is_streamed = 0; /* we _can_ in fact seek */
322 } else if (!av_strcasecmp(tag, "Accept-Ranges") && !strncmp(p, "bytes", 5)) {322 } 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
25static const char mode20_header[] = "#!iLBC20\n";
26static const char mode30_header[] = "#!iLBC30\n";
27
28static 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
56static 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
63static 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
72static 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
103static 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
123AVInputFormat 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
132AVOutputFormat 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
259 { CODEC_ID_DVAUDIO, MKTAG('v', 'd', 'v', 'a') },259 { CODEC_ID_DVAUDIO, MKTAG('v', 'd', 'v', 'a') },
260 { CODEC_ID_DVAUDIO, MKTAG('d', 'v', 'c', 'a') },260 { CODEC_ID_DVAUDIO, MKTAG('d', 'v', 'c', 'a') },
261 { CODEC_ID_GSM, MKTAG('a', 'g', 's', 'm') },261 { CODEC_ID_GSM, MKTAG('a', 'g', 's', 'm') },
262 { CODEC_ID_ILBC, MKTAG('i', 'l', 'b', 'c') },
262 { CODEC_ID_MACE3, MKTAG('M', 'A', 'C', '3') },263 { CODEC_ID_MACE3, MKTAG('M', 'A', 'C', '3') },
263 { CODEC_ID_MACE6, MKTAG('M', 'A', 'C', '6') },264 { CODEC_ID_MACE6, MKTAG('M', 'A', 'C', '6') },
264 { CODEC_ID_MP1, MKTAG('.', 'm', 'p', '1') },265 { 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
1540 case CODEC_ID_GSM:1540 case CODEC_ID_GSM:
1541 case CODEC_ID_ADPCM_MS:1541 case CODEC_ID_ADPCM_MS:
1542 case CODEC_ID_ADPCM_IMA_WAV:1542 case CODEC_ID_ADPCM_IMA_WAV:
1543 case CODEC_ID_ILBC:
1543 st->codec->block_align = sc->bytes_per_frame;1544 st->codec->block_align = sc->bytes_per_frame;
1544 break;1545 break;
1545 case CODEC_ID_ALAC:1546 case CODEC_ID_ALAC:
libavformat/movenc.c+2−1
@@ -3371,7 +3371,8 @@ static int mov_write_header(AVFormatContext *s) · 3370 unmodified lines
3371 av_log(s, AV_LOG_WARNING, "track %d: codec frame size is not set\n", i);3371 av_log(s, AV_LOG_WARNING, "track %d: codec frame size is not set\n", i);
3372 track->audio_vbr = 1;3372 track->audio_vbr = 1;
3373 }else if(st->codec->codec_id == CODEC_ID_ADPCM_MS ||3373 }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){
3375 if (!st->codec->block_align) {3376 if (!st->codec->block_align) {
3376 av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i);3377 av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i);
3377 goto error;3378 goto error;
libavformat/mpegts.c+0−94
@@ -19,8 +19,6 @@ · 18 unmodified lines
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */20 */
21 21
22//#define USE_SYNCPOINT_SEARCH
23
24#include "libavutil/crc.h"22#include "libavutil/crc.h"
25#include "libavutil/intreadwrite.h"23#include "libavutil/intreadwrite.h"
26#include "libavutil/log.h"24#include "libavutil/log.h"
@@ -2161,92 +2159,6 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index, · 2134 unmodified lines
2161 return AV_NOPTS_VALUE;2159 return AV_NOPTS_VALUE;
2162}2160}
2163 2161
2164#ifdef USE_SYNCPOINT_SEARCH
2165
2166static 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
2230static 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
2250/**************************************************************/2162/**************************************************************/
2251/* parsing functions - called from other demuxers such as RTP */2163/* parsing functions - called from other demuxers such as RTP */
2252 2164
@@ -2313,9 +2225,6 @@ AVInputFormat ff_mpegts_demuxer = { · 60 unmodified lines
2313 .read_close = mpegts_read_close,2225 .read_close = mpegts_read_close,
2314 .read_timestamp = mpegts_get_dts,2226 .read_timestamp = mpegts_get_dts,
2315 .flags = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,2227 .flags = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
2316#ifdef USE_SYNCPOINT_SEARCH
2317 .read_seek2 = read_seek2,
2318#endif
2319};2228};
2320 2229
2321AVInputFormat ff_mpegtsraw_demuxer = {2230AVInputFormat ff_mpegtsraw_demuxer = {
@@ -2327,8 +2236,5 @@ AVInputFormat ff_mpegtsraw_demuxer = { · 5 unmodified lines
2327 .read_close = mpegts_read_close,2236 .read_close = mpegts_read_close,
2328 .read_timestamp = mpegts_get_dts,2237 .read_timestamp = mpegts_get_dts,
2329 .flags = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,2238 .flags = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
2330#ifdef USE_SYNCPOINT_SEARCH
2331 .read_seek2 = read_seek2,
2332#endif
2333 .priv_class = &mpegtsraw_class,2239 .priv_class = &mpegtsraw_class,
2334};2240};
libavformat/rtmpproto.c+8−0
@@ -76,6 +76,7 @@ typedef struct RTMPContext { · 75 unmodified lines
76 uint8_t* flv_data; ///< buffer with data for demuxer76 uint8_t* flv_data; ///< buffer with data for demuxer
77 int flv_size; ///< current buffer size77 int flv_size; ///< current buffer size
78 int flv_off; ///< number of bytes read from current buffer78 int flv_off; ///< number of bytes read from current buffer
79 int flv_nb_packets; ///< number of flv packets published
79 RTMPPacket out_pkt; ///< rtmp packet, created from flv a/v or metadata (for output)80 RTMPPacket out_pkt; ///< rtmp packet, created from flv a/v or metadata (for output)
80 uint32_t client_report_size; ///< number of bytes after which client should report to server81 uint32_t client_report_size; ///< number of bytes after which client should report to server
81 uint32_t bytes_read; ///< number of bytes read from server82 uint32_t bytes_read; ///< number of bytes read from server
@@ -90,6 +91,7 @@ typedef struct RTMPContext { · 8 unmodified lines
90 char* swfurl; ///< url of the swf player91 char* swfurl; ///< url of the swf player
91 int server_bw; ///< server bandwidth92 int server_bw; ///< server bandwidth
92 int client_buffer_time; ///< client buffer time in ms93 int client_buffer_time; ///< client buffer time in ms
94 int flush_interval; ///< number of packets flushed in the same request (RTMPT only)
93} RTMPContext;95} RTMPContext;
94 96
95#define PLAYER_KEY_OPEN_PART_LEN 30 ///< length of partial key used for first client digest signing97#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
1361 rt->flv_size = 0;1363 rt->flv_size = 0;
1362 rt->flv_off = 0;1364 rt->flv_off = 0;
1363 rt->flv_header_bytes = 0;1365 rt->flv_header_bytes = 0;
1366 rt->flv_nb_packets++;
1364 }1367 }
1365 } while (buf_temp - buf < size);1368 } while (buf_temp - buf < size);
1366 1369
1370 if (rt->flv_nb_packets < rt->flush_interval)
1371 return size;
1372 rt->flv_nb_packets = 0;
1373
1367 /* set stream into nonblocking mode */1374 /* set stream into nonblocking mode */
1368 rt->stream->flags |= AVIO_FLAG_NONBLOCK;1375 rt->stream->flags |= AVIO_FLAG_NONBLOCK;
1369 1376
@@ -1404,6 +1411,7 @@ static const AVOption rtmp_options[] = { · 34 unmodified lines
1404 {"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},1411 {"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},
1405 {"rtmp_conn", "Append arbitrary AMF data to the Connect message", OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},1412 {"rtmp_conn", "Append arbitrary AMF data to the Connect message", OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
1406 {"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},1413 {"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},
1407 {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), AV_OPT_TYPE_INT, {-2}, INT_MIN, INT_MAX, DEC, "rtmp_live"},1415 {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), AV_OPT_TYPE_INT, {-2}, INT_MIN, INT_MAX, DEC, "rtmp_live"},
1408 {"any", "both", 0, AV_OPT_TYPE_CONST, {-2}, 0, 0, DEC, "rtmp_live"},1416 {"any", "both", 0, AV_OPT_TYPE_CONST, {-2}, 0, 0, DEC, "rtmp_live"},
1409 {"live", "live stream", 0, AV_OPT_TYPE_CONST, {-1}, 0, 0, DEC, "rtmp_live"},1417 {"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
68 ff_register_dynamic_payload_handler(&ff_h263_2000_dynamic_handler);68 ff_register_dynamic_payload_handler(&ff_h263_2000_dynamic_handler);
69 ff_register_dynamic_payload_handler(&ff_h263_rfc2190_dynamic_handler);69 ff_register_dynamic_payload_handler(&ff_h263_rfc2190_dynamic_handler);
70 ff_register_dynamic_payload_handler(&ff_h264_dynamic_handler);70 ff_register_dynamic_payload_handler(&ff_h264_dynamic_handler);
71 ff_register_dynamic_payload_handler(&ff_ilbc_dynamic_handler);
71 ff_register_dynamic_payload_handler(&ff_vorbis_dynamic_handler);72 ff_register_dynamic_payload_handler(&ff_vorbis_dynamic_handler);
72 ff_register_dynamic_payload_handler(&ff_theora_dynamic_handler);73 ff_register_dynamic_payload_handler(&ff_theora_dynamic_handler);
73 ff_register_dynamic_payload_handler(&ff_qdm2_dynamic_handler);74 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
45extern RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler;45extern RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler;
46extern RTPDynamicProtocolHandler ff_h263_rfc2190_dynamic_handler;46extern RTPDynamicProtocolHandler ff_h263_rfc2190_dynamic_handler;
47extern RTPDynamicProtocolHandler ff_h264_dynamic_handler;47extern RTPDynamicProtocolHandler ff_h264_dynamic_handler;
48extern RTPDynamicProtocolHandler ff_ilbc_dynamic_handler;
48extern RTPDynamicProtocolHandler ff_mp4a_latm_dynamic_handler;49extern RTPDynamicProtocolHandler ff_mp4a_latm_dynamic_handler;
49extern RTPDynamicProtocolHandler ff_mp4v_es_dynamic_handler;50extern RTPDynamicProtocolHandler ff_mp4v_es_dynamic_handler;
50extern RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler;51extern 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
26static 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
46static 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
68RTPDynamicProtocolHandler 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
74 case CODEC_ID_VP8:74 case CODEC_ID_VP8:
75 case CODEC_ID_ADPCM_G722:75 case CODEC_ID_ADPCM_G722:
76 case CODEC_ID_ADPCM_G726:76 case CODEC_ID_ADPCM_G726:
77 case CODEC_ID_ILBC:
77 return 1;78 return 1;
78 default:79 default:
79 return 0;80 return 0;
@@ -187,6 +188,16 @@ static int rtp_write_header(AVFormatContext *s1) · 107 unmodified lines
187 * 8000, even if the sample rate is 16000. See RFC 3551. */188 * 8000, even if the sample rate is 16000. See RFC 3551. */
188 avpriv_set_pts_info(st, 32, 1, 8000);189 avpriv_set_pts_info(st, 32, 1, 8000);
189 break;190 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;
190 case CODEC_ID_AMR_NB:201 case CODEC_ID_AMR_NB:
191 case CODEC_ID_AMR_WB:202 case CODEC_ID_AMR_WB:
192 if (!s->max_frames_per_packet)203 if (!s->max_frames_per_packet)
@@ -395,6 +406,36 @@ static void rtp_send_mpegts_raw(AVFormatContext *s1, · 202 unmodified lines
395 }406 }
396}407}
397 408
409static 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
398static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)439static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
399{440{
400 RTPMuxContext *s = s1->priv_data;441 RTPMuxContext *s = s1->priv_data;
@@ -483,6 +524,9 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) · 82 unmodified lines
483 case CODEC_ID_VP8:524 case CODEC_ID_VP8:
484 ff_rtp_send_vp8(s1, pkt->data, size);525 ff_rtp_send_vp8(s1, pkt->data, size);
485 break;526 break;
527 case CODEC_ID_ILBC:
528 rtp_send_ilbc(s1, pkt->data, size);
529 break;
486 default:530 default:
487 /* better than nothing : send the codec raw data */531 /* better than nothing : send the codec raw data */
488 rtp_send_raw(s1, pkt->data, size);532 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
1279 "%s/UDP;multicast", trans_pref);1279 "%s/UDP;multicast", trans_pref);
1280 }1280 }
1281 if (s->oformat) {1281 if (s->oformat) {
1282 av_strlcat(transport, ";mode=receive", sizeof(transport));1282 av_strlcat(transport, ";mode=record", sizeof(transport));
1283 } else if (rt->server_type == RTSP_SERVER_REAL ||1283 } else if (rt->server_type == RTSP_SERVER_REAL ||
1284 rt->server_type == RTSP_SERVER_WMS)1284 rt->server_type == RTSP_SERVER_WMS)
1285 av_strlcat(transport, ";mode=play", sizeof(transport));1285 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
549 c->sample_rate);549 c->sample_rate);
550 break;550 break;
551 }551 }
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;
552 default:558 default:
553 /* Nothing special to do here... */559 /* Nothing special to do here... */
554 break;560 break;
libavformat/version.h+1−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
30#include "libavutil/avutil.h"30#include "libavutil/avutil.h"
31 31
32#define LIBAVFORMAT_VERSION_MAJOR 5432#define LIBAVFORMAT_VERSION_MAJOR 54
33#define LIBAVFORMAT_VERSION_MINOR 833#define LIBAVFORMAT_VERSION_MINOR 9
34#define LIBAVFORMAT_VERSION_MICRO 10034#define LIBAVFORMAT_VERSION_MICRO 100
35 35
36#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \36#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
libavresample/x86/audio_convert.asm+209−0
@@ -1,6 +1,7 @@
1;******************************************************************************1;******************************************************************************
2;* x86 optimized Format Conversion Utils2;* x86 optimized Format Conversion Utils
3;* Copyright (c) 2008 Loren Merritt3;* Copyright (c) 2008 Loren Merritt
4;* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
4;*5;*
5;* This file is part of Libav.6;* This file is part of Libav.
6;*7;*
@@ -21,9 +22,217 @@ · 14 unmodified lines
21 22
22%include "x86inc.asm"23%include "x86inc.asm"
23%include "x86util.asm"24%include "x86util.asm"
25%include "util.asm"
26
27SECTION_RODATA 32
28
29pf_s32_inv_scale: times 8 dd 0x30000000
30pf_s32_scale: times 8 dd 0x4f000000
31pf_s16_inv_scale: times 4 dd 0x38000000
32pf_s16_scale: times 4 dd 0x47000000
24 33
25SECTION_TEXT34SECTION_TEXT
26 35
36;------------------------------------------------------------------------------
37; void ff_conv_s16_to_s32(int32_t *dst, const int16_t *src, int len);
38;------------------------------------------------------------------------------
39
40INIT_XMM sse2
41cglobal 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
63cglobal 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
84INIT_XMM sse2
85CONV_S16_TO_FLT
86INIT_XMM sse4
87CONV_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
94cglobal 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
122INIT_MMX mmx
123CONV_S32_TO_S16
124INIT_XMM sse2
125CONV_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
132cglobal 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
156INIT_XMM sse2
157CONV_S32_TO_FLT
158%if HAVE_AVX
159INIT_YMM avx
160CONV_S32_TO_FLT
161%endif
162
163;------------------------------------------------------------------------------
164; void ff_conv_flt_to_s16(int16_t *dst, const float *src, int len);
165;------------------------------------------------------------------------------
166
167INIT_XMM sse2
168cglobal 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
200cglobal 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
229INIT_XMM sse2
230CONV_FLT_TO_S32
231%if HAVE_AVX
232INIT_YMM avx
233CONV_FLT_TO_S32
234%endif
235
27;-----------------------------------------------------------------------------236;-----------------------------------------------------------------------------
28; void ff_conv_fltp_to_flt_6ch(float *dst, float *const *src, int len,237; void ff_conv_fltp_to_flt_6ch(float *dst, float *const *src, int len,
29; int channels);238; int channels);
libavresample/x86/audio_convert_init.c+44−0
@@ -22,6 +22,22 @@ · 21 unmodified lines
22#include "libavutil/cpu.h"22#include "libavutil/cpu.h"
23#include "libavresample/audio_convert.h"23#include "libavresample/audio_convert.h"
24 24
25extern void ff_conv_s16_to_s32_sse2(int16_t *dst, const int32_t *src, int len);
26
27extern void ff_conv_s16_to_flt_sse2(float *dst, const int16_t *src, int len);
28extern void ff_conv_s16_to_flt_sse4(float *dst, const int16_t *src, int len);
29
30extern void ff_conv_s32_to_s16_mmx (int16_t *dst, const int32_t *src, int len);
31extern void ff_conv_s32_to_s16_sse2(int16_t *dst, const int32_t *src, int len);
32
33extern void ff_conv_s32_to_flt_sse2(float *dst, const int32_t *src, int len);
34extern void ff_conv_s32_to_flt_avx (float *dst, const int32_t *src, int len);
35
36extern void ff_conv_flt_to_s16_sse2(int16_t *dst, const float *src, int len);
37
38extern void ff_conv_flt_to_s32_sse2(int32_t *dst, const float *src, int len);
39extern void ff_conv_flt_to_s32_avx (int32_t *dst, const float *src, int len);
40
25extern void ff_conv_fltp_to_flt_6ch_mmx (float *dst, float *const *src, int len);41extern void ff_conv_fltp_to_flt_6ch_mmx (float *dst, float *const *src, int len);
26extern void ff_conv_fltp_to_flt_6ch_sse4(float *dst, float *const *src, int len);42extern void ff_conv_fltp_to_flt_6ch_sse4(float *dst, float *const *src, int len);
27extern void ff_conv_fltp_to_flt_6ch_avx (float *dst, float *const *src, int len);43extern 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
32 int mm_flags = av_get_cpu_flags();48 int mm_flags = av_get_cpu_flags();
33 49
34 if (mm_flags & AV_CPU_FLAG_MMX && HAVE_MMX) {50 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);
35 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,53 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
36 6, 1, 4, "MMX", ff_conv_fltp_to_flt_6ch_mmx);54 6, 1, 4, "MMX", ff_conv_fltp_to_flt_6ch_mmx);
37 }55 }
@@ -43,5 +61,31 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac) · 5 unmodified lines
43 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,61 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
44 6, 16, 4, "AVX", ff_conv_fltp_to_flt_6ch_avx);62 6, 16, 4, "AVX", ff_conv_fltp_to_flt_6ch_avx);
45 }63 }
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 }
46#endif90#endif
47}91}
libavutil/arm/float_dsp_init_neon.c+4−0
@@ -26,7 +26,11 @@ · 25 unmodified lines
26 26
27void ff_vector_fmul_neon(float *dst, const float *src0, const float *src1, int len);27void ff_vector_fmul_neon(float *dst, const float *src0, const float *src1, int len);
28 28
29void ff_vector_fmac_scalar_neon(float *dst, const float *src, float mul,
30 int len);
31
29void ff_float_dsp_init_neon(AVFloatDSPContext *fdsp)32void ff_float_dsp_init_neon(AVFloatDSPContext *fdsp)
30{33{
31 fdsp->vector_fmul = ff_vector_fmul_neon;34 fdsp->vector_fmul = ff_vector_fmul_neon;
35 fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_neon;
32}36}
libavutil/arm/float_dsp_neon.S+48−0
@@ -62,3 +62,51 @@ function ff_vector_fmul_neon, export=1 · 61 unmodified lines
623: vst1.32 {d16-d19},[r0,:128]!623: vst1.32 {d16-d19},[r0,:128]!
63 bx lr63 bx lr
64endfunc64endfunc
65
66function ff_vector_fmac_scalar_neon, export=1
67VFP len .req r2
68VFP acc .req r3
69NOVFP len .req r3
70NOVFP acc .req r2
71VFP vdup.32 q15, d0[0]
72NOVFP 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]!
801: 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
992: vst1.32 {q10}, [r0,:128]!
100 vst1.32 {q11}, [r0,:128]!
101 ands len, len, #15
102 it eq
103 bxeq lr
1043: 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
112endfunc
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
31 dst[i] = src0[i] * src1[i];31 dst[i] = src0[i] * src1[i];
32}32}
33 33
34static 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
34void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)42void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
35{43{
36 fdsp->vector_fmul = vector_fmul_c;44 fdsp->vector_fmul = vector_fmul_c;
45 fdsp->vector_fmac_scalar = vector_fmac_scalar_c;
37 46
38#if ARCH_ARM47#if ARCH_ARM
39 ff_float_dsp_init_arm(fdsp);48 ff_float_dsp_init_arm(fdsp);
libavutil/float_dsp.h+16−0
@@ -35,6 +35,22 @@ typedef struct AVFloatDSPContext { · 34 unmodified lines
35 */35 */
36 void (*vector_fmul)(float *dst, const float *src0, const float *src1,36 void (*vector_fmul)(float *dst, const float *src0, const float *src1,
37 int len);37 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);
38} AVFloatDSPContext;54} AVFloatDSPContext;
39 55
40/**56/**
libavutil/mem.c+6−0
@@ -94,6 +94,8 @@ void *av_malloc(size_t size) · 93 unmodified lines
94 if (size) //OS X on SDK 10.6 has a broken posix_memalign implementation94 if (size) //OS X on SDK 10.6 has a broken posix_memalign implementation
95 if (posix_memalign(&ptr,ALIGN,size))95 if (posix_memalign(&ptr,ALIGN,size))
96 ptr = NULL;96 ptr = NULL;
97#elif HAVE_ALIGNED_MALLOC
98 ptr = _aligned_malloc(size, ALIGN);
97#elif HAVE_MEMALIGN99#elif HAVE_MEMALIGN
98 ptr = memalign(ALIGN,size);100 ptr = memalign(ALIGN,size);
99 /* Why 64?101 /* Why 64?
@@ -145,6 +147,8 @@ void *av_realloc(void *ptr, size_t size) · 45 unmodified lines
145 ptr= realloc((char*)ptr - diff, size + diff);147 ptr= realloc((char*)ptr - diff, size + diff);
146 if(ptr) ptr = (char*)ptr + diff;148 if(ptr) ptr = (char*)ptr + diff;
147 return ptr;149 return ptr;
150#elif HAVE_ALIGNED_MALLOC
151 return _aligned_realloc(ptr, size + !size, ALIGN);
148#else152#else
149 return realloc(ptr, size + !size);153 return realloc(ptr, size + !size);
150#endif154#endif
@@ -170,6 +174,8 @@ void av_free(void *ptr) · 19 unmodified lines
170#if CONFIG_MEMALIGN_HACK174#if CONFIG_MEMALIGN_HACK
171 if (ptr)175 if (ptr)
172 free((char*)ptr - ((char*)ptr)[-1]);176 free((char*)ptr - ((char*)ptr)[-1]);
177#elif HAVE_ALIGNED_MALLOC
178 _aligned_free(ptr);
173#else179#else
174 free(ptr);180 free(ptr);
175#endif181#endif
libavutil/x86/float_dsp.asm+47−0
@@ -21,6 +21,7 @@ · 20 unmodified lines
21;******************************************************************************21;******************************************************************************
22 22
23%include "x86inc.asm"23%include "x86inc.asm"
24%include "x86util.asm"
24 25
25SECTION .text26SECTION .text
26 27
@@ -55,3 +56,49 @@ VECTOR_FMUL · 28 unmodified lines
55INIT_YMM avx56INIT_YMM avx
56VECTOR_FMUL57VECTOR_FMUL
57%endif58%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
66cglobal vector_fmac_scalar, 3,3,3, dst, src, len
67%else
68cglobal 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
99INIT_XMM sse
100VECTOR_FMAC_SCALAR
101%if HAVE_AVX
102INIT_YMM avx
103VECTOR_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
26extern void ff_vector_fmul_avx(float *dst, const float *src0, const float *src1,26extern void ff_vector_fmul_avx(float *dst, const float *src0, const float *src1,
27 int len);27 int len);
28 28
29extern void ff_vector_fmac_scalar_sse(float *dst, const float *src, float mul,
30 int len);
31extern void ff_vector_fmac_scalar_avx(float *dst, const float *src, float mul,
32 int len);
33
29void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp)34void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp)
30{35{
31#if HAVE_YASM36#if HAVE_YASM
@@ -33,9 +38,11 @@ void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp) · 1 unmodified line
33 38
34 if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) {39 if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) {
35 fdsp->vector_fmul = ff_vector_fmul_sse;40 fdsp->vector_fmul = ff_vector_fmul_sse;
41 fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_sse;
36 }42 }
37 if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) {43 if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) {
38 fdsp->vector_fmul = ff_vector_fmul_avx;44 fdsp->vector_fmul = ff_vector_fmul_avx;
45 fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_avx;
39 }46 }
40#endif47#endif
41}48}

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