Re: [libav-devel] [PATCH] Add Dolby/DPLII downmix support to libavresample

2012-06-18 Thread Luca Barbato
On 06/18/2012 04:01 AM, Justin Ruggles wrote:
> From: John Stebbins 
> 
> Signed-off-by: Justin Ruggles 
> ---
> This is a slightly modifed version of John's patch. It adds a micro bump and
> APIchanges entry, and it adds named constants for the matrix_encoding option.
> 

Fine for me.


-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/4] float_dsp: add x86-optimized functions for vector_fmac_scalar()

2012-06-18 Thread Luca Barbato
On 06/10/2012 08:13 PM, Justin Ruggles wrote:
> ---
> Removed ALIGN 16 before the loop. There was no measurable speed difference
> on x86-64 or x86-32.
> 
>  libavutil/float_dsp.h  |6 ++--
>  libavutil/x86/float_dsp.asm|   47 
> 
>  libavutil/x86/float_dsp_init.c |7 ++
>  3 files changed, 57 insertions(+), 3 deletions(-)
> 

Ok.


-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 6/6] lavr: Add x86-optimized function for flt to s32 conversion

2012-06-18 Thread Luca Barbato
On 06/06/2012 08:55 PM, Justin Ruggles wrote:
> ---
>  libavresample/x86/audio_convert.asm|   42 
> 
>  libavresample/x86/audio_convert_init.c |7 +
>  2 files changed, 49 insertions(+), 0 deletions(-)
> 

Looks ok, but my x86 asm/yasm knowledge isn't that good.

lu

-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] lavr: add x86-optimized functions for mixing 1-to-2 fltp with flt coeffs

2012-06-18 Thread Luca Barbato
On 06/18/2012 04:05 AM, Justin Ruggles wrote:
> On 06/05/2012 01:43 PM, Justin Ruggles wrote:
>> On 05/29/2012 04:41 PM, Justin Ruggles wrote:
>>> ---
>>>  libavresample/x86/audio_mix.asm|   34 
>>> ++
>>>  libavresample/x86/audio_mix_init.c |9 +
>>>  2 files changed, 43 insertions(+), 0 deletions(-)
>>
>> ping.
> 
> ping2.
> 

Both look fine.


-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/4] float_dsp: add x86-optimized functions for vector_fmac_scalar()

2012-06-18 Thread Christophe Gisquet
Hi,

2012/6/18 Justin Ruggles :
>> Removed ALIGN 16 before the loop. There was no measurable speed difference
>> on x86-64 or x86-32.
[...]
>
> ping.

Fine for me (there was nothing really mattering anyway).

Christophe
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH v2 1/5] Add support for iLBC decoding/encoding via the external library libilbc

2012-06-18 Thread Martin Storsjö
The library is 3-clause BSD licensed.
---
 Changelog  |1 +
 configure  |6 ++
 doc/general.texi   |   13 +++
 libavcodec/Makefile|2 +
 libavcodec/allcodecs.c |1 +
 libavcodec/avcodec.h   |1 +
 libavcodec/libilbc.c   |  209 
 libavcodec/utils.c |5 ++
 8 files changed, 238 insertions(+)
 create mode 100644 libavcodec/libilbc.c

diff --git a/Changelog b/Changelog
index 4288aa3..51b8c83 100644
--- a/Changelog
+++ b/Changelog
@@ -26,6 +26,7 @@ version :
 - Indeo Audio decoder
 - channelsplit audio filter
 - RTMPT protocol support
+- iLBC encoding/decoding via libilbc
 
 
 version 0.8:
diff --git a/configure b/configure
index a5d2787..ea80d48 100755
--- a/configure
+++ b/configure
@@ -172,6 +172,7 @@ External library support:
   --enable-libfaac enable FAAC support via libfaac [no]
   --enable-libfreetype enable libfreetype [no]
   --enable-libgsm  enable GSM support via libgsm [no]
+  --enable-libilbc enable iLBC de/encoding via libilbc [no]
   --enable-libmp3lame  enable MP3 encoding via libmp3lame [no]
   --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb 
[no]
   --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
@@ -945,6 +946,7 @@ CONFIG_LIST="
 libfaac
 libfreetype
 libgsm
+libilbc
 libmp3lame
 libopencore_amrnb
 libopencore_amrwb
@@ -1427,6 +1429,8 @@ libgsm_decoder_deps="libgsm"
 libgsm_encoder_deps="libgsm"
 libgsm_ms_decoder_deps="libgsm"
 libgsm_ms_encoder_deps="libgsm"
+libilbc_decoder_deps="libilbc"
+libilbc_encoder_deps="libilbc"
 libmp3lame_encoder_deps="libmp3lame"
 libopencore_amrnb_decoder_deps="libopencore_amrnb"
 libopencore_amrnb_encoder_deps="libopencore_amrnb"
@@ -2917,6 +2921,7 @@ enabled gnutls && require_pkg_config gnutls 
gnutls/gnutls.h gnutls_global_in
 enabled libfaac&& require2 libfaac "stdint.h faac.h" faacEncGetVersion 
-lfaac
 enabled libfreetype && require_pkg_config freetype2 "ft2build.h 
freetype/freetype.h" FT_Init_FreeType
 enabled libgsm && require  libgsm gsm/gsm.h gsm_create -lgsm
+enabled libilbc&& require  libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
 enabled libmp3lame && require  "libmp3lame >= 3.98.3" lame/lame.h 
lame_set_VBR_quality -lmp3lame
 enabled libopencore_amrnb  && require libopencore_amrnb 
opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
 enabled libopencore_amrwb  && require libopencore_amrwb 
opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
@@ -3206,6 +3211,7 @@ echo "libcdio support   ${libcdio-no}"
 echo "libdc1394 support ${libdc1394-no}"
 echo "libfaac enabled   ${libfaac-no}"
 echo "libgsm enabled${libgsm-no}"
+echo "libilbc enabled   ${libilbc-no}"
 echo "libmp3lame enabled${libmp3lame-no}"
 echo "libopencore-amrnb support ${libopencore_amrnb-no}"
 echo "libopencore-amrwb support ${libopencore_amrwb-no}"
diff --git a/doc/general.texi b/doc/general.texi
index 9a4746a..0c600ce 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -85,6 +85,17 @@ x264 is under the GNU Public License Version 2 or later
 details), you must upgrade Libav's license to GPL in order to use it.
 @end float
 
+@section libilbc
+
+iLBC is a narrowband speech codec that has been made freely available
+by Google as part of the WebRTC project. libilbc is a packaging friendly
+copy of the iLBC codec. Libav can make use of the libilbc library for
+iLBC encoding and decoding.
+
+Go to @url{https://github.com/dekkers/libilbc} and follow the instructions for
+installing the library. Then pass @code{--enable-libilbc} to configure to
+enable it.
+
 
 
 @chapter Supported File Formats and Codecs
@@ -707,6 +718,8 @@ following image formats are supported:
 @item GSM Microsoft variant  @tab  E  @tab  X
 @tab encoding supported through external library libgsm
 @item IAC (Indeo Audio Coder)  @tab @tab  X
+@item iLBC (Internet Low Bitrate Codec) @tab  E  @tab  E
+@tab encoding and decoding supported through external library libilbc
 @item IMC (Intel Music Coder)  @tab @tab  X
 @item MACE (Macintosh Audio Compression/Expansion) 3:1  @tab @tab  X
 @item MACE (Macintosh Audio Compression/Expansion) 6:1  @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3bfd78b..c4f7e98 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -596,6 +596,8 @@ OBJS-$(CONFIG_LIBGSM_DECODER) += libgsm.o
 OBJS-$(CONFIG_LIBGSM_ENCODER) += libgsm.o
 OBJS-$(CONFIG_LIBGSM_MS_DECODER)  += libgsm.o
 OBJS-$(CONFIG_LIBGSM_MS_ENCODER)  += libgsm.o
+OBJS-$(CONFIG_LIBILBC_DECODER)+= libilbc.o
+OBJS-$(CONFIG_LIBILBC_ENCODER)+= libilbc.o
 OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o mpegaudiodecheader.o 
\
  audio_frame_queue.o
 OBJS-$(CONFIG_LIBOPENCOR

[libav-devel] [PATCH v2 2/5] mov: Support muxing/demuxing iLBC

2012-06-18 Thread Martin Storsjö
The packet size, signalled via block_align, has to be passed via
the container.
---
 libavformat/isom.c   |1 +
 libavformat/mov.c|1 +
 libavformat/movenc.c |3 ++-
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/isom.c b/libavformat/isom.c
index 3ea8ce1..e5cde5a 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -244,6 +244,7 @@ const AVCodecTag ff_codec_movaudio_tags[] = {
 { CODEC_ID_DVAUDIO, MKTAG('v', 'd', 'v', 'a') },
 { CODEC_ID_DVAUDIO, MKTAG('d', 'v', 'c', 'a') },
 { CODEC_ID_GSM, MKTAG('a', 'g', 's', 'm') },
+{ CODEC_ID_ILBC,MKTAG('i', 'l', 'b', 'c') },
 { CODEC_ID_MACE3,   MKTAG('M', 'A', 'C', '3') },
 { CODEC_ID_MACE6,   MKTAG('M', 'A', 'C', '6') },
 { CODEC_ID_MP1, MKTAG('.', 'm', 'p', '1') },
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1395259..44dc2c8 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1456,6 +1456,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext 
*pb, int entries)
 case CODEC_ID_GSM:
 case CODEC_ID_ADPCM_MS:
 case CODEC_ID_ADPCM_IMA_WAV:
+case CODEC_ID_ILBC:
 st->codec->block_align = sc->bytes_per_frame;
 break;
 case CODEC_ID_ALAC:
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index bf888bc..350ac95 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3095,7 +3095,8 @@ static int mov_write_header(AVFormatContext *s)
 }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){
 track->timescale = st->codec->sample_rate;
 /* set sample_size for PCM and ADPCM */
-if (av_get_bits_per_sample(st->codec->codec_id)) {
+if (av_get_bits_per_sample(st->codec->codec_id) ||
+st->codec->codec_id == CODEC_ID_ILBC) {
 if (!st->codec->block_align) {
 av_log(s, AV_LOG_ERROR, "track %d: codec block align is 
not set\n", i);
 goto error;
-- 
1.7.9.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH v2 3/5] Implement the iLBC storage file format

2012-06-18 Thread Martin Storsjö
---
 doc/general.texi |1 +
 libavformat/Makefile |2 +
 libavformat/allformats.c |1 +
 libavformat/ilbc.c   |  140 ++
 4 files changed, 144 insertions(+)
 create mode 100644 libavformat/ilbc.c

diff --git a/doc/general.texi b/doc/general.texi
index 0c600ce..82a181c 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -184,6 +184,7 @@ library:
 @item IEC61937 encapsulation @tab X @tab X
 @item IFF   @tab   @tab X
 @tab Interchange File Format
+@item iLBC  @tab X @tab X
 @item Interplay MVE @tab   @tab X
 @tab Format used in various Interplay computer games.
 @item IV8   @tab   @tab X
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 6262324..88e8db4 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -110,6 +110,8 @@ OBJS-$(CONFIG_H264_MUXER)+= rawenc.o
 OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o
 OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
 OBJS-$(CONFIG_IFF_DEMUXER)   += iff.o
+OBJS-$(CONFIG_ILBC_DEMUXER)  += ilbc.o
+OBJS-$(CONFIG_ILBC_MUXER)+= ilbc.o
 OBJS-$(CONFIG_IMAGE2_DEMUXER)+= img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE2_MUXER)  += img2enc.o img2.o
 OBJS-$(CONFIG_IMAGE2PIPE_DEMUXER)+= img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 42c588f..8456398 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -108,6 +108,7 @@ void av_register_all(void)
 REGISTER_DEMUXER  (HLS, hls);
 REGISTER_DEMUXER  (IDCIN, idcin);
 REGISTER_DEMUXER  (IFF, iff);
+REGISTER_MUXDEMUX (ILBC, ilbc);
 REGISTER_MUXDEMUX (IMAGE2, image2);
 REGISTER_MUXDEMUX (IMAGE2PIPE, image2pipe);
 REGISTER_DEMUXER  (INGENIENT, ingenient);
diff --git a/libavformat/ilbc.c b/libavformat/ilbc.c
new file mode 100644
index 000..5d0483c
--- /dev/null
+++ b/libavformat/ilbc.c
@@ -0,0 +1,140 @@
+/*
+ * iLBC storage file format
+ * Copyright (c) 2012 Martin Storsjo
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "internal.h"
+
+static const char mode20_header[] = "#!iLBC20\n";
+static const char mode30_header[] = "#!iLBC30\n";
+
+static int ilbc_write_header(AVFormatContext *s)
+{
+AVIOContext *pb = s->pb;
+AVCodecContext *enc;
+
+if (s->nb_streams != 1) {
+av_log(s, AV_LOG_ERROR, "Unsupported number of streams\n");
+return AVERROR(EINVAL);
+}
+enc = s->streams[0]->codec;
+
+if (enc->codec_id != CODEC_ID_ILBC) {
+av_log(s, AV_LOG_ERROR, "Unsupported codec\n");
+return AVERROR(EINVAL);
+}
+
+if (enc->block_align == 50) {
+avio_write(pb, mode30_header, sizeof(mode30_header) - 1);
+} else if (enc->block_align == 38) {
+avio_write(pb, mode20_header, sizeof(mode20_header) - 1);
+} else {
+av_log(s, AV_LOG_ERROR, "Unsupported mode\n");
+return AVERROR(EINVAL);
+}
+avio_flush(pb);
+return 0;
+}
+
+static int ilbc_write_packet(AVFormatContext *s, AVPacket *pkt)
+{
+avio_write(s->pb, pkt->data, pkt->size);
+avio_flush(s->pb);
+return 0;
+}
+
+static int ilbc_probe(AVProbeData *p)
+{
+// Only check for "#!iLBC" which matches both formats
+if (!memcmp(p->buf, mode20_header, 6))
+return AVPROBE_SCORE_MAX;
+else
+return 0;
+}
+
+static int ilbc_read_header(AVFormatContext *s)
+{
+AVIOContext *pb = s->pb;
+AVStream *st;
+uint8_t header[9];
+
+avio_read(pb, header, 9);
+
+st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+st->codec->codec_id = CODEC_ID_ILBC;
+st->codec->sample_rate = 8000;
+st->codec->channels = 1;
+st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+st->start_time = 0;
+avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+if (!memcmp(header, mode20_header, sizeof(mode20_header) - 1)) {
+st->codec->block_align = 38;
+st->codec->bit_rate = 15200;
+} else if (!memcmp(header, mode30_header, sizeof(mode30_header) - 1)) {
+st->codec->block_align = 50;
+st->codec->bit_rate = 1;
+  

[libav-devel] [PATCH v2 4/5] rtpdec: Add a depacketizer for iLBC

2012-06-18 Thread Martin Storsjö
---
 libavformat/Makefile |1 +
 libavformat/rtpdec.c |1 +
 libavformat/rtpdec_formats.h |1 +
 libavformat/rtpdec_ilbc.c|   62 ++
 4 files changed, 65 insertions(+)
 create mode 100644 libavformat/rtpdec_ilbc.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 88e8db4..f3f0372 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -264,6 +264,7 @@ OBJS-$(CONFIG_RTPDEC)+= rdt.o \
 rtpdec_h263.o \
 rtpdec_h263_rfc2190.o \
 rtpdec_h264.o \
+rtpdec_ilbc.o \
 rtpdec_latm.o \
 rtpdec_mpeg4.o \
 rtpdec_qcelp.o \
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 41e6eb4..b3bce24 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -68,6 +68,7 @@ void av_register_rtp_dynamic_payload_handlers(void)
 ff_register_dynamic_payload_handler(&ff_h263_2000_dynamic_handler);
 ff_register_dynamic_payload_handler(&ff_h263_rfc2190_dynamic_handler);
 ff_register_dynamic_payload_handler(&ff_h264_dynamic_handler);
+ff_register_dynamic_payload_handler(&ff_ilbc_dynamic_handler);
 ff_register_dynamic_payload_handler(&ff_vorbis_dynamic_handler);
 ff_register_dynamic_payload_handler(&ff_theora_dynamic_handler);
 ff_register_dynamic_payload_handler(&ff_qdm2_dynamic_handler);
diff --git a/libavformat/rtpdec_formats.h b/libavformat/rtpdec_formats.h
index 60edecb..aaa1809 100644
--- a/libavformat/rtpdec_formats.h
+++ b/libavformat/rtpdec_formats.h
@@ -45,6 +45,7 @@ extern RTPDynamicProtocolHandler ff_h263_1998_dynamic_handler;
 extern RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler;
 extern RTPDynamicProtocolHandler ff_h263_rfc2190_dynamic_handler;
 extern RTPDynamicProtocolHandler ff_h264_dynamic_handler;
+extern RTPDynamicProtocolHandler ff_ilbc_dynamic_handler;
 extern RTPDynamicProtocolHandler ff_mp4a_latm_dynamic_handler;
 extern RTPDynamicProtocolHandler ff_mp4v_es_dynamic_handler;
 extern RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler;
diff --git a/libavformat/rtpdec_ilbc.c b/libavformat/rtpdec_ilbc.c
new file mode 100644
index 000..92f168f
--- /dev/null
+++ b/libavformat/rtpdec_ilbc.c
@@ -0,0 +1,62 @@
+/*
+ * RTP iLBC Depacketizer, RFC 3952
+ * Copyright (c) 2012 Martin Storsjo
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "rtpdec_formats.h"
+#include "libavutil/avstring.h"
+
+static int ilbc_parse_fmtp(AVStream *stream, PayloadContext *data,
+   char *attr, char *value)
+{
+if (!strcmp(attr, "mode")) {
+int mode = atoi(value);
+switch (mode) {
+case 20:
+stream->codec->block_align = 38;
+break;
+case 30:
+stream->codec->block_align = 50;
+break;
+}
+}
+return 0;
+}
+
+static int ilbc_parse_sdp_line(AVFormatContext *s, int st_index,
+   PayloadContext *data, const char *line)
+{
+const char *p;
+
+if (st_index < 0)
+return 0;
+
+if (av_strstart(line, "fmtp:", &p)) {
+return ff_parse_fmtp(s->streams[st_index], data, p, ilbc_parse_fmtp);
+}
+return 0;
+}
+
+RTPDynamicProtocolHandler ff_ilbc_dynamic_handler = {
+.enc_name = "iLBC",
+.codec_type   = AVMEDIA_TYPE_AUDIO,
+.codec_id = CODEC_ID_ILBC,
+.parse_sdp_a_line = ilbc_parse_sdp_line,
+};
-- 
1.7.9.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH v2 5/5] rtpenc: Support packetizing iLBC

2012-06-18 Thread Martin Storsjö
---
 libavformat/rtpenc.c |   44 
 libavformat/sdp.c|6 ++
 2 files changed, 50 insertions(+)

diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 6752fb6..9ee9d09 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -74,6 +74,7 @@ static int is_supported(enum CodecID id)
 case CODEC_ID_VP8:
 case CODEC_ID_ADPCM_G722:
 case CODEC_ID_ADPCM_G726:
+case CODEC_ID_ILBC:
 return 1;
 default:
 return 0;
@@ -187,6 +188,16 @@ static int rtp_write_header(AVFormatContext *s1)
  * 8000, even if the sample rate is 16000. See RFC 3551. */
 avpriv_set_pts_info(st, 32, 1, 8000);
 break;
+case CODEC_ID_ILBC:
+if (!st->codec->block_align) {
+av_log(s1, AV_LOG_ERROR, "No iLBC block size specified\n");
+goto fail;
+}
+if (!s->max_frames_per_packet)
+s->max_frames_per_packet = 1;
+s->max_frames_per_packet = FFMIN(s->max_frames_per_packet,
+ s->max_payload_size / 
st->codec->block_align);
+goto defaultcase;
 case CODEC_ID_AMR_NB:
 case CODEC_ID_AMR_WB:
 if (!s->max_frames_per_packet)
@@ -395,6 +406,36 @@ static void rtp_send_mpegts_raw(AVFormatContext *s1,
 }
 }
 
+static int rtp_send_ilbc(AVFormatContext *s1, const uint8_t *buf, int size)
+{
+RTPMuxContext *s = s1->priv_data;
+AVStream *st = s1->streams[0];
+int frame_duration = av_get_audio_frame_duration(st->codec, 0);
+int frame_size = st->codec->block_align;
+int frames = size / frame_size;
+
+while (frames > 0) {
+int n = FFMIN(s->max_frames_per_packet - s->num_frames, frames);
+
+if (!s->num_frames) {
+s->buf_ptr = s->buf;
+s->timestamp = s->cur_timestamp;
+}
+memcpy(s->buf_ptr, buf, n * frame_size);
+frames   -= n;
+s->num_frames+= n;
+s->buf_ptr   += n * frame_size;
+buf  += n * frame_size;
+s->cur_timestamp += n * frame_duration;
+
+if (s->num_frames == s->max_frames_per_packet) {
+ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 1);
+s->num_frames = 0;
+}
+}
+return 0;
+}
+
 static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
 {
 RTPMuxContext *s = s1->priv_data;
@@ -483,6 +524,9 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket 
*pkt)
 case CODEC_ID_VP8:
 ff_rtp_send_vp8(s1, pkt->data, size);
 break;
+case CODEC_ID_ILBC:
+rtp_send_ilbc(s1, pkt->data, size);
+break;
 default:
 /* better than nothing : send the codec raw data */
 rtp_send_raw(s1, pkt->data, size);
diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index 9692aab..4392646 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -544,6 +544,12 @@ static char *sdp_write_media_attributes(char *buff, int 
size, AVCodecContext *c,
  c->sample_rate);
 break;
 }
+case CODEC_ID_ILBC:
+av_strlcatf(buff, size, "a=rtpmap:%d iLBC/%d\r\n"
+"a=fmtp:%d mode=%d\r\n",
+ payload_type, c->sample_rate,
+ payload_type, c->block_align == 38 ? 20 : 
30);
+break;
 default:
 /* Nothing special to do here... */
 break;
-- 
1.7.9.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] TCP: Use AI_PASSIVE flag when no address is set

2012-06-18 Thread Martin Storsjö

On Sun, 17 Jun 2012, Jordi Ortiz wrote:


---
libavformat/tcp.c |7 ++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 7e348f7..c9ff47a 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -65,7 +65,12 @@ static int tcp_open(URLContext *h, const char *uri, int 
flags)
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
snprintf(portstr, sizeof(portstr), "%d", port);
-ret = getaddrinfo(hostname, portstr, &hints, &ai);
+if (listen_socket && !hostname[0]) {
+hints.ai_flags |= AI_PASSIVE;
+ret = getaddrinfo(NULL, portstr, &hints, &ai);
+}
+else
+ret = getaddrinfo(hostname, portstr, &hints, &ai);
if (ret) {
av_log(h, AV_LOG_ERROR,
   "Failed to resolve hostname %s: %s\n",
--
1.7.10


I'd rather have you split this in two. There's two almost separate issues 
here. If listen_socket is set, you should set AI_PASSIVE, regardless of 
the hostname. The glibc manpage says "If node is not NULL, then the 
AI_PASSIVE flag is ignored.", so it doesn't hurt but doesn't add anything 
either. The OS X manpage says:


If the AI_PASSIVE bit is set it indicates that the returned socket 
address structure is intended for use in a call to bind(2).

[...]
If the AI_PASSIVE bit is not set, the returned socket address structure 
will be ready for use in a call to connect(2) for a connection-oriented 
protocol or connect(2), sendto(2), or sendmsg(2) if a connectionless 
protocol was chosen.


Therefore I think it's more correct semantics to always set this flag if 
we're going to bind/listen.


Then once we've set the flag, you can pass NULL to gethostname for empty 
hostnames, if listening, as a separate feature/change.


// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] rtpenc: Allow requesting H264 RTP packetization mode 0

2012-06-18 Thread Luca Barbato
On 06/15/2012 01:32 PM, Martin Storsjö wrote:
> This requires all NAL units to fit within single RTP packets. It
> doesn't change the actual packetization for packets that fit, but
> errors out and gives a helpful hint if the NAL units would have to
> be split, and signals the right packetization mode in the SDP.
> ---
>  libavformat/rtpenc.h  |2 ++
>  libavformat/rtpenc_h264.c |6 ++
>  libavformat/sdp.c |   11 ---
>  libavformat/version.h |2 +-
>  4 files changed, 17 insertions(+), 4 deletions(-)

Ok.


-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH v2 4/5] rtpdec: Add a depacketizer for iLBC

2012-06-18 Thread Luca Barbato
On 06/18/2012 10:40 AM, Martin Storsjö wrote:
> +static int ilbc_parse_fmtp(AVStream *stream, PayloadContext *data,
> +   char *attr, char *value)
> +{
> +if (!strcmp(attr, "mode")) {
> +int mode = atoi(value);
> +switch (mode) {
> +case 20:
> +stream->codec->block_align = 38;
> +break;
> +case 30:
> +stream->codec->block_align = 50;
> +break;
> +}
> +}
> +return 0;
> +}

Anything different wouldn't be reported as error?

lu

-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH v2 4/5] rtpdec: Add a depacketizer for iLBC

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Luca Barbato wrote:


On 06/18/2012 10:40 AM, Martin Storsjö wrote:

+static int ilbc_parse_fmtp(AVStream *stream, PayloadContext *data,
+   char *attr, char *value)
+{
+if (!strcmp(attr, "mode")) {
+int mode = atoi(value);
+switch (mode) {
+case 20:
+stream->codec->block_align = 38;
+break;
+case 30:
+stream->codec->block_align = 50;
+break;
+}
+}
+return 0;
+}


Anything different wouldn't be reported as error?


Good point, I'll try to improve it.

// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH v2 5/5] rtpenc: Support packetizing iLBC

2012-06-18 Thread Luca Barbato
On 06/18/2012 10:40 AM, Martin Storsjö wrote:
> +case CODEC_ID_ILBC:
> +if (!st->codec->block_align) {
> +av_log(s1, AV_LOG_ERROR, "No iLBC block size specified\n");
> +goto fail;
> +}

who's setting this value? shall we check it is one of the two supported
one? Can we have a fallback instead of an error?

> +case CODEC_ID_ILBC:
> +av_strlcatf(buff, size, "a=rtpmap:%d iLBC/%d\r\n"
> +"a=fmtp:%d mode=%d\r\n",
> + payload_type, c->sample_rate,
> + payload_type, c->block_align == 38 ? 20 
> : 30);
> +break;

I guess we should be stricter in the check before.

lu

-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH v2 5/5] rtpenc: Support packetizing iLBC

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Luca Barbato wrote:


On 06/18/2012 10:40 AM, Martin Storsjö wrote:

+case CODEC_ID_ILBC:
+if (!st->codec->block_align) {
+av_log(s1, AV_LOG_ERROR, "No iLBC block size specified\n");
+goto fail;
+}


who's setting this value? shall we check it is one of the two supported
one? Can we have a fallback instead of an error?


It's set by the demuxer (if doing stream copy) or by the encoder - if it 
isn't set, the data is unparsable.


I guess I could make this check stricter to check for the two supported 
values.


// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 4/5] rtpdec: Add a depacketizer for iLBC

2012-06-18 Thread Martin Storsjö
---
 libavformat/Makefile |1 +
 libavformat/rtpdec.c |1 +
 libavformat/rtpdec_formats.h |1 +
 libavformat/rtpdec_ilbc.c|   73 ++
 4 files changed, 76 insertions(+)
 create mode 100644 libavformat/rtpdec_ilbc.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 88e8db4..f3f0372 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -264,6 +264,7 @@ OBJS-$(CONFIG_RTPDEC)+= rdt.o \
 rtpdec_h263.o \
 rtpdec_h263_rfc2190.o \
 rtpdec_h264.o \
+rtpdec_ilbc.o \
 rtpdec_latm.o \
 rtpdec_mpeg4.o \
 rtpdec_qcelp.o \
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 41e6eb4..b3bce24 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -68,6 +68,7 @@ void av_register_rtp_dynamic_payload_handlers(void)
 ff_register_dynamic_payload_handler(&ff_h263_2000_dynamic_handler);
 ff_register_dynamic_payload_handler(&ff_h263_rfc2190_dynamic_handler);
 ff_register_dynamic_payload_handler(&ff_h264_dynamic_handler);
+ff_register_dynamic_payload_handler(&ff_ilbc_dynamic_handler);
 ff_register_dynamic_payload_handler(&ff_vorbis_dynamic_handler);
 ff_register_dynamic_payload_handler(&ff_theora_dynamic_handler);
 ff_register_dynamic_payload_handler(&ff_qdm2_dynamic_handler);
diff --git a/libavformat/rtpdec_formats.h b/libavformat/rtpdec_formats.h
index 60edecb..aaa1809 100644
--- a/libavformat/rtpdec_formats.h
+++ b/libavformat/rtpdec_formats.h
@@ -45,6 +45,7 @@ extern RTPDynamicProtocolHandler ff_h263_1998_dynamic_handler;
 extern RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler;
 extern RTPDynamicProtocolHandler ff_h263_rfc2190_dynamic_handler;
 extern RTPDynamicProtocolHandler ff_h264_dynamic_handler;
+extern RTPDynamicProtocolHandler ff_ilbc_dynamic_handler;
 extern RTPDynamicProtocolHandler ff_mp4a_latm_dynamic_handler;
 extern RTPDynamicProtocolHandler ff_mp4v_es_dynamic_handler;
 extern RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler;
diff --git a/libavformat/rtpdec_ilbc.c b/libavformat/rtpdec_ilbc.c
new file mode 100644
index 000..7159dcf
--- /dev/null
+++ b/libavformat/rtpdec_ilbc.c
@@ -0,0 +1,73 @@
+/*
+ * RTP iLBC Depacketizer, RFC 3952
+ * Copyright (c) 2012 Martin Storsjo
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "rtpdec_formats.h"
+#include "libavutil/avstring.h"
+
+static int ilbc_parse_fmtp(AVStream *stream, PayloadContext *data,
+   char *attr, char *value)
+{
+if (!strcmp(attr, "mode")) {
+int mode = atoi(value);
+switch (mode) {
+case 20:
+stream->codec->block_align = 38;
+break;
+case 30:
+stream->codec->block_align = 50;
+break;
+default:
+av_log(NULL, AV_LOG_ERROR, "Unsupported iLBC mode %d\n", mode);
+return AVERROR(EINVAL);
+}
+}
+return 0;
+}
+
+static int ilbc_parse_sdp_line(AVFormatContext *s, int st_index,
+   PayloadContext *data, const char *line)
+{
+const char *p;
+AVStream *st;
+
+if (st_index < 0)
+return 0;
+st = s->streams[st_index];
+
+if (av_strstart(line, "fmtp:", &p)) {
+int ret = ff_parse_fmtp(st, data, p, ilbc_parse_fmtp);
+if (ret < 0)
+return ret;
+if (!st->codec->block_align) {
+av_log(s, AV_LOG_ERROR, "No iLBC mode set\n");
+return AVERROR(EINVAL);
+}
+}
+return 0;
+}
+
+RTPDynamicProtocolHandler ff_ilbc_dynamic_handler = {
+.enc_name = "iLBC",
+.codec_type   = AVMEDIA_TYPE_AUDIO,
+.codec_id = CODEC_ID_ILBC,
+.parse_sdp_a_line = ilbc_parse_sdp_line,
+};
-- 
1.7.9.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 5/5] rtpenc: Support packetizing iLBC

2012-06-18 Thread Martin Storsjö
---
 libavformat/rtpenc.c |   44 
 libavformat/sdp.c|6 ++
 2 files changed, 50 insertions(+)

diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 6752fb6..9cf1a16 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -74,6 +74,7 @@ static int is_supported(enum CodecID id)
 case CODEC_ID_VP8:
 case CODEC_ID_ADPCM_G722:
 case CODEC_ID_ADPCM_G726:
+case CODEC_ID_ILBC:
 return 1;
 default:
 return 0;
@@ -187,6 +188,16 @@ static int rtp_write_header(AVFormatContext *s1)
  * 8000, even if the sample rate is 16000. See RFC 3551. */
 avpriv_set_pts_info(st, 32, 1, 8000);
 break;
+case CODEC_ID_ILBC:
+if (st->codec->block_align != 38 && st->codec->block_align != 50) {
+av_log(s1, AV_LOG_ERROR, "Incorrect iLBC block size specified\n");
+goto fail;
+}
+if (!s->max_frames_per_packet)
+s->max_frames_per_packet = 1;
+s->max_frames_per_packet = FFMIN(s->max_frames_per_packet,
+ s->max_payload_size / 
st->codec->block_align);
+goto defaultcase;
 case CODEC_ID_AMR_NB:
 case CODEC_ID_AMR_WB:
 if (!s->max_frames_per_packet)
@@ -395,6 +406,36 @@ static void rtp_send_mpegts_raw(AVFormatContext *s1,
 }
 }
 
+static int rtp_send_ilbc(AVFormatContext *s1, const uint8_t *buf, int size)
+{
+RTPMuxContext *s = s1->priv_data;
+AVStream *st = s1->streams[0];
+int frame_duration = av_get_audio_frame_duration(st->codec, 0);
+int frame_size = st->codec->block_align;
+int frames = size / frame_size;
+
+while (frames > 0) {
+int n = FFMIN(s->max_frames_per_packet - s->num_frames, frames);
+
+if (!s->num_frames) {
+s->buf_ptr = s->buf;
+s->timestamp = s->cur_timestamp;
+}
+memcpy(s->buf_ptr, buf, n * frame_size);
+frames   -= n;
+s->num_frames+= n;
+s->buf_ptr   += n * frame_size;
+buf  += n * frame_size;
+s->cur_timestamp += n * frame_duration;
+
+if (s->num_frames == s->max_frames_per_packet) {
+ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 1);
+s->num_frames = 0;
+}
+}
+return 0;
+}
+
 static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
 {
 RTPMuxContext *s = s1->priv_data;
@@ -483,6 +524,9 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket 
*pkt)
 case CODEC_ID_VP8:
 ff_rtp_send_vp8(s1, pkt->data, size);
 break;
+case CODEC_ID_ILBC:
+rtp_send_ilbc(s1, pkt->data, size);
+break;
 default:
 /* better than nothing : send the codec raw data */
 rtp_send_raw(s1, pkt->data, size);
diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index 7df8b13..1867225 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -549,6 +549,12 @@ static char *sdp_write_media_attributes(char *buff, int 
size, AVCodecContext *c,
  c->sample_rate);
 break;
 }
+case CODEC_ID_ILBC:
+av_strlcatf(buff, size, "a=rtpmap:%d iLBC/%d\r\n"
+"a=fmtp:%d mode=%d\r\n",
+ payload_type, c->sample_rate,
+ payload_type, c->block_align == 38 ? 20 : 
30);
+break;
 default:
 /* Nothing special to do here... */
 break;
-- 
1.7.9.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] snow: remove a VLA.

2012-06-18 Thread Måns Rullgård
"Ronald S. Bultje"  writes:

> From: "Ronald S. Bultje" 
>
> ---
>  libavcodec/snowenc.c |   42 ++
>  1 file changed, 22 insertions(+), 20 deletions(-)
>
> diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
> index 7b010e1..ac276f9 100644
> --- a/libavcodec/snowenc.c
> +++ b/libavcodec/snowenc.c
> @@ -662,7 +662,7 @@ static inline int get_block_bits(SnowContext *s, int x, 
> int y, int w){
>  }
>  }
>
> -static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, 
> const uint8_t *obmc_edged){
> +static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, 
> uint8_t (* const obmc_edged)[MB_SIZE * 2]){

That const doesn't do what you probably think it does.  This declares
the pointer as const, not what it points to.  Same comment applies
elsewhere as well.

[...]

>  const int b_w= (MB_SIZE >> s->block_max_depth);
> -uint8_t obmc_edged[b_w*2][b_w*2];
> +uint8_t obmc_edged[MB_SIZE * 2][MB_SIZE * 2];
>
> +assert(b_w <= MB_SIZE);

The assert is rather pointless considering how b_w is calculated.

Rest of patch looks OK.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 5/5] rtpenc: Support packetizing iLBC

2012-06-18 Thread Luca Barbato
On 06/18/2012 12:37 PM, Martin Storsjö wrote:
> ---
>  libavformat/rtpenc.c |   44 
>  libavformat/sdp.c|6 ++
>  2 files changed, 50 insertions(+)
> 

Ok.


-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] rtmp: Add a new option 'rtmp_flush_interval', for setting the number of packets flushed in the same request

2012-06-18 Thread Samuel Pitoiset
This options is only needed for RTMPT.
---
 doc/protocols.texi  |4 
 libavformat/rtmpproto.c |8 
 2 files changed, 12 insertions(+)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 0b4f1b1..e90d1b4 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -217,6 +217,10 @@ times to construct arbitrary AMF sequences.
 Version of the Flash plugin used to run the SWF player. The default
 is LNX 9,0,124,2.
 
+@item rtmp_flush_interval
+Number of packets flushed in the same request (RTMPT only). The default
+is 10.
+
 @item rtmp_live
 Specify that the media is a live stream. No resuming or seeking in
 live streams is possible. The default value is @code{any}, which means the
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index b3e2a30..c82302f 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -90,6 +90,7 @@ typedef struct RTMPContext {
 char* swfurl; ///< url of the swf player
 int   server_bw;  ///< server bandwidth
 int   client_buffer_time; ///< client buffer time in ms
+int   flush_interval; ///< number of packets flushed 
in the same request (RTMPT only)
 } RTMPContext;
 
 #define PLAYER_KEY_OPEN_PART_LEN 30   ///< length of partial key used for 
first client digest signing
@@ -1295,6 +1296,7 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
 const uint8_t *buf_temp = buf;
 uint8_t c;
 int ret;
+static int nb_packets = 0;
 
 do {
 if (rt->skip_bytes) {
@@ -1361,9 +1363,14 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
 rt->flv_size = 0;
 rt->flv_off = 0;
 rt->flv_header_bytes = 0;
+nb_packets++;
 }
 } while (buf_temp - buf < size);
 
+if (nb_packets < rt->flush_interval)
+return size;
+nb_packets = 0;
+
 /* set stream into nonblocking mode */
 rt->stream->flags |= AVIO_FLAG_NONBLOCK;
 
@@ -1404,6 +1411,7 @@ static const AVOption rtmp_options[] = {
 {"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},
 {"rtmp_conn", "Append arbitrary AMF data to the Connect message", 
OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
 {"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},
+{"rtmp_flush_interval", "Number of packets flushed in the same request 
(RTMPT only).", OFFSET(flush_interval), AV_OPT_TYPE_INT, {10}, 0, INT_MAX, 
DEC|ENC},
 {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), 
AV_OPT_TYPE_INT, {-2}, INT_MIN, INT_MAX, DEC, "rtmp_live"},
 {"any", "both", 0, AV_OPT_TYPE_CONST, {-2}, 0, 0, DEC, "rtmp_live"},
 {"live", "live stream", 0, AV_OPT_TYPE_CONST, {-1}, 0, 0, DEC, 
"rtmp_live"},
-- 
1.7.10.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] rtmp: Add a new option 'rtmp_flush_interval', for setting the number of packets flushed in the same request

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Samuel Pitoiset wrote:


This options is only needed for RTMPT.
---
doc/protocols.texi  |4 
libavformat/rtmpproto.c |8 
2 files changed, 12 insertions(+)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 0b4f1b1..e90d1b4 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -217,6 +217,10 @@ times to construct arbitrary AMF sequences.
Version of the Flash plugin used to run the SWF player. The default
is LNX 9,0,124,2.

+@item rtmp_flush_interval
+Number of packets flushed in the same request (RTMPT only). The default
+is 10.
+
@item rtmp_live
Specify that the media is a live stream. No resuming or seeking in
live streams is possible. The default value is @code{any}, which means the
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index b3e2a30..c82302f 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -90,6 +90,7 @@ typedef struct RTMPContext {
char* swfurl; ///< url of the swf player
int   server_bw;  ///< server bandwidth
int   client_buffer_time; ///< client buffer time in ms
+int   flush_interval; ///< number of packets flushed 
in the same request (RTMPT only)
} RTMPContext;

#define PLAYER_KEY_OPEN_PART_LEN 30   ///< length of partial key used for first 
client digest signing
@@ -1295,6 +1296,7 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
const uint8_t *buf_temp = buf;
uint8_t c;
int ret;
+static int nb_packets = 0;


This is not ok, it will misbehave if you have more than one instance of it 
running in the same process.




do {
if (rt->skip_bytes) {
@@ -1361,9 +1363,14 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
rt->flv_size = 0;
rt->flv_off = 0;
rt->flv_header_bytes = 0;
+nb_packets++;
}
} while (buf_temp - buf < size);

+if (nb_packets < rt->flush_interval)
+return size;
+nb_packets = 0;
+
/* set stream into nonblocking mode */
rt->stream->flags |= AVIO_FLAG_NONBLOCK;

@@ -1404,6 +1411,7 @@ static const AVOption rtmp_options[] = {
{"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},
{"rtmp_conn", "Append arbitrary AMF data to the Connect message", 
OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{"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},
+{"rtmp_flush_interval", "Number of packets flushed in the same request (RTMPT 
only).", OFFSET(flush_interval), AV_OPT_TYPE_INT, {10}, 0, INT_MAX, DEC|ENC},


Since this only is relevant to writing, you could remove DEC.

// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] rtmp: Add a new option 'rtmp_flush_interval', for setting the number of packets flushed in the same request

2012-06-18 Thread Samuel Pitoiset
This options is only needed for RTMPT.
---
 doc/protocols.texi  |4 
 libavformat/rtmpproto.c |8 
 2 files changed, 12 insertions(+)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 0b4f1b1..e90d1b4 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -217,6 +217,10 @@ times to construct arbitrary AMF sequences.
 Version of the Flash plugin used to run the SWF player. The default
 is LNX 9,0,124,2.
 
+@item rtmp_flush_interval
+Number of packets flushed in the same request (RTMPT only). The default
+is 10.
+
 @item rtmp_live
 Specify that the media is a live stream. No resuming or seeking in
 live streams is possible. The default value is @code{any}, which means the
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index b3e2a30..b48274b 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -76,6 +76,7 @@ typedef struct RTMPContext {
 uint8_t*  flv_data;   ///< buffer with data for demuxer
 int   flv_size;   ///< current buffer size
 int   flv_off;///< number of bytes read from 
current buffer
+int   flv_nb_packets; ///< number of flv packets 
published
 RTMPPacketout_pkt;///< rtmp packet, created from 
flv a/v or metadata (for output)
 uint32_t  client_report_size; ///< number of bytes after which 
client should report to server
 uint32_t  bytes_read; ///< number of bytes read from 
server
@@ -90,6 +91,7 @@ typedef struct RTMPContext {
 char* swfurl; ///< url of the swf player
 int   server_bw;  ///< server bandwidth
 int   client_buffer_time; ///< client buffer time in ms
+int   flush_interval; ///< number of packets flushed 
in the same request (RTMPT only)
 } RTMPContext;
 
 #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)
 rt->flv_size = 0;
 rt->flv_off = 0;
 rt->flv_header_bytes = 0;
+rt->flv_nb_packets++;
 }
 } while (buf_temp - buf < size);
 
+if (rt->flv_nb_packets < rt->flush_interval)
+return size;
+rt->flv_nb_packets = 0;
+
 /* set stream into nonblocking mode */
 rt->stream->flags |= AVIO_FLAG_NONBLOCK;
 
@@ -1404,6 +1411,7 @@ static const AVOption rtmp_options[] = {
 {"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},
 {"rtmp_conn", "Append arbitrary AMF data to the Connect message", 
OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
 {"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},
+{"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},
 {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), 
AV_OPT_TYPE_INT, {-2}, INT_MIN, INT_MAX, DEC, "rtmp_live"},
 {"any", "both", 0, AV_OPT_TYPE_CONST, {-2}, 0, 0, DEC, "rtmp_live"},
 {"live", "live stream", 0, AV_OPT_TYPE_CONST, {-1}, 0, 0, DEC, 
"rtmp_live"},
-- 
1.7.10.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] rtsp: Send mode=record instead of mode=receive

2012-06-18 Thread Martin Storsjö
This seems to be the correct mode to send, according to the
original RTSP RFC, and matches the method RECORD which is
sent later when starting to send data.

Darwin Streaming Server works fine with either of them.
---
 libavformat/rtsp.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 19fdaf1..a70ea04 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1284,7 +1284,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const 
char *host, int port,
  "%s/UDP;multicast", trans_pref);
 }
 if (s->oformat) {
-av_strlcat(transport, ";mode=receive", sizeof(transport));
+av_strlcat(transport, ";mode=record", sizeof(transport));
 } else if (rt->server_type == RTSP_SERVER_REAL ||
rt->server_type == RTSP_SERVER_WMS)
 av_strlcat(transport, ";mode=play", sizeof(transport));
-- 
1.7.9.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] rtmp: Add a new option 'rtmp_flush_interval', for setting the number of packets flushed in the same request

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Samuel Pitoiset wrote:


This options is only needed for RTMPT.
---
doc/protocols.texi  |4 
libavformat/rtmpproto.c |8 
2 files changed, 12 insertions(+)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 0b4f1b1..e90d1b4 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -217,6 +217,10 @@ times to construct arbitrary AMF sequences.
Version of the Flash plugin used to run the SWF player. The default
is LNX 9,0,124,2.

+@item rtmp_flush_interval
+Number of packets flushed in the same request (RTMPT only). The default
+is 10.
+
@item rtmp_live
Specify that the media is a live stream. No resuming or seeking in
live streams is possible. The default value is @code{any}, which means the
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index b3e2a30..b48274b 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -76,6 +76,7 @@ typedef struct RTMPContext {
uint8_t*  flv_data;   ///< buffer with data for demuxer
int   flv_size;   ///< current buffer size
int   flv_off;///< number of bytes read from 
current buffer
+int   flv_nb_packets; ///< number of flv packets 
published
RTMPPacketout_pkt;///< rtmp packet, created from 
flv a/v or metadata (for output)
uint32_t  client_report_size; ///< number of bytes after which 
client should report to server
uint32_t  bytes_read; ///< number of bytes read from 
server
@@ -90,6 +91,7 @@ typedef struct RTMPContext {
char* swfurl; ///< url of the swf player
int   server_bw;  ///< server bandwidth
int   client_buffer_time; ///< client buffer time in ms
+int   flush_interval; ///< number of packets flushed 
in the same request (RTMPT only)
} RTMPContext;

#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)
rt->flv_size = 0;
rt->flv_off = 0;
rt->flv_header_bytes = 0;
+rt->flv_nb_packets++;
}
} while (buf_temp - buf < size);

+if (rt->flv_nb_packets < rt->flush_interval)
+return size;
+rt->flv_nb_packets = 0;
+
/* set stream into nonblocking mode */
rt->stream->flags |= AVIO_FLAG_NONBLOCK;

@@ -1404,6 +1411,7 @@ static const AVOption rtmp_options[] = {
{"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},
{"rtmp_conn", "Append arbitrary AMF data to the Connect message", 
OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{"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},
+{"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},
{"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), 
AV_OPT_TYPE_INT, {-2}, INT_MIN, INT_MAX, DEC, "rtmp_live"},
{"any", "both", 0, AV_OPT_TYPE_CONST, {-2}, 0, 0, DEC, "rtmp_live"},
{"live", "live stream", 0, AV_OPT_TYPE_CONST, {-1}, 0, 0, DEC, "rtmp_live"},
--
1.7.10.3


Ok

// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] Change all uses of restrict to use av_restrict instead.

2012-06-18 Thread Diego Biurrun
On Fri, Jun 15, 2012 at 06:02:11PM -0700, Ronald S. Bultje wrote:
> On Fri, Jun 15, 2012 at 5:41 PM, Måns Rullgård  wrote:
> > "Ronald S. Bultje"  writes:
> >> From: "Ronald S. Bultje" 
> >>
> >> Defining restrict results - for some compilers - in changing other
> >> uses of the restrict keyword also, e.g. __declspec(restrict) gets
> >> changed to __declspec(__restrict) on MSVC. This causes compilation
> >> failures. Therefore, using a private namespace macro instead is
> >> more reliable and robust.
> >
> > NAK.  restrict is a C99 keyword, and we use C99 features all over the
> > place.  Whatever preprocessor is used to handle, for instance,
> > designated initialisers can just as easily handle these keywords.
> 
> By which law were we decreed that c99 shall be the end of the world?

We set out to demand basic standard support from our environment a long
time ago.  We did the same with the build system.  It has to be a POSIX
shell and utilities userland.  Nowadays this is not such a big deal but
back in the days this left still-popular Solaris and some BSDs behind.

At some point the systems catched up and nowadays this is a requirement
that all modern systems fulfill without much trickery.  At the same time
it has allowed us to keep the build system much more maintainable and
its maintainers sane.

For C99 it is the same story mostly.  There were incompatible goals:
portability and language features, so a reasonably recent standard was
picked as the required baseline.  IIRC this left at least icc out back
in the days, but it has catched up pretty nicely since.

Now MSVC is a completely different story as it is Windows, Microsoft,
nonfree and not standards-compliant.  To top it off none of the people
that requested supporting it ever really contributed.  So for a long
time, that was really out of the question.

Now going back to plain C89 is pretty much out of the question.  Nobody
wants to give up their new shiny.  Whether or not we need full C99 is
an open question.

> I wish to support a compiler that does not support c99. Shall we work
> together and make that happen or shall we just cry like little zealous
> babies while the real world passes by?

Comments like this are not exactly helping, but you know that.

Let's instead cooperate on getting the sensible parts of this patch in.
I have already extracted a piece, more have followed.  Start with the
simple pieces and work your way up from there.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 0/7] More cherries from Ronald's MSVC patch

2012-06-18 Thread Mans Rullgard
These patches all look reasonable to me, though some more review can't
hurt.

Ronald S. Bultje (7):
  dirac: replace compound literal with normal initialiser
  Replace some #if/else in struct initialisers with conditional
expressions
  mem: add support for _aligned_malloc() as found on Windows
  network: winsock2: protect EFOO error constant definitions with
ifdefs
  attributes: add av_always_inline definition for msvc
  mpegts: remove unused (incomplete?) seeking code
  http: replace atoll() with strtoll()

 configure |4 +-
 libavcodec/dirac.c|2 +-
 libavformat/asfenc.c  |   12 +-
 libavformat/avienc.c  |6 +--
 libavformat/flvenc.c  |6 +--
 libavformat/http.c|6 +--
 libavformat/matroskaenc.c |   18 ++---
 libavformat/movenc.c  |   18 ++---
 libavformat/mpegts.c  |   96 -
 libavformat/network.h |8 
 libavformat/nutenc.c  |9 +
 libavutil/attributes.h|2 +
 libavutil/mem.c   |6 +++
 13 files changed, 35 insertions(+), 158 deletions(-)

-- 
1.7.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 4/7] network: winsock2: protect EFOO error constant definitions with ifdefs

2012-06-18 Thread Mans Rullgard
From: "Ronald S. Bultje" 

---
 libavformat/network.h |8 
 1 file changed, 8 insertions(+)

diff --git a/libavformat/network.h b/libavformat/network.h
index 72d01d2..5c70e2d 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -31,10 +31,18 @@
 #include 
 #include 
 
+#ifndef EPROTONOSUPPORT
 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
+#endif
+#ifndef ETIMEDOUT
 #define ETIMEDOUT   WSAETIMEDOUT
+#endif
+#ifndef ECONNREFUSED
 #define ECONNREFUSEDWSAECONNREFUSED
+#endif
+#ifndef EINPROGRESS
 #define EINPROGRESS WSAEINPROGRESS
+#endif
 
 int ff_neterrno(void);
 #else
-- 
1.7.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 3/7] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Mans Rullgard
From: "Ronald S. Bultje" 

---
 configure   |4 +++-
 libavutil/mem.c |6 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index a5d2787..f1f58a7 100755
--- a/configure
+++ b/configure
@@ -1049,6 +1049,7 @@ HAVE_LIST="
 $ARCH_EXT_LIST
 $HAVE_LIST_PUB
 $THREADS_LIST
+aligned_malloc
 aligned_stack
 alsa_asoundlib_h
 altivec_h
@@ -2834,6 +2835,7 @@ check_func  ${malloc_prefix}memalign&& enable 
memalign
 check_func  mkstemp
 check_func  mmap
 check_func  ${malloc_prefix}posix_memalign  && enable posix_memalign
+check_func  ${malloc_prefix}_aligned_malloc && enable aligned_malloc
 check_func  setrlimit
 check_func  strerror_r
 check_func  strptime
@@ -3139,7 +3141,7 @@ check_deps $CONFIG_LIST   \
 
 enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
 
-! enabled_any memalign posix_memalign &&
+! enabled_any memalign posix_memalign aligned_malloc &&
 enabled_any $need_memalign && enable memalign_hack
 
 echo "install prefix$prefix"
diff --git a/libavutil/mem.c b/libavutil/mem.c
index bf1a542..0fe9f54 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -84,6 +84,8 @@ void *av_malloc(size_t size)
 #elif HAVE_POSIX_MEMALIGN
 if (posix_memalign(&ptr,32,size))
 ptr = NULL;
+#elif HAVE_ALIGNED_MALLOC
+ptr = _aligned_malloc(size, 32);
 #elif HAVE_MEMALIGN
 ptr = memalign(32,size);
 /* Why 64?
@@ -131,6 +133,8 @@ void *av_realloc(void *ptr, size_t size)
 if(!ptr) return av_malloc(size);
 diff= ((char*)ptr)[-1];
 return (char*)realloc((char*)ptr - diff, size + diff) + diff;
+#elif HAVE_ALIGNED_MALLOC
+return _aligned_realloc(ptr, size, 32);
 #else
 return realloc(ptr, size);
 #endif
@@ -141,6 +145,8 @@ void av_free(void *ptr)
 #if CONFIG_MEMALIGN_HACK
 if (ptr)
 free((char*)ptr - ((char*)ptr)[-1]);
+#elif HAVE_ALIGNED_MALLOC
+_aligned_free(ptr);
 #else
 free(ptr);
 #endif
-- 
1.7.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/7] Replace some #if/else in struct initialisers with conditional expressions

2012-06-18 Thread Mans Rullgard
From: "Ronald S. Bultje" 

---
 libavformat/asfenc.c  |   12 ++--
 libavformat/avienc.c  |6 +-
 libavformat/flvenc.c  |6 +-
 libavformat/matroskaenc.c |   18 +++---
 libavformat/movenc.c  |   18 +++---
 libavformat/nutenc.c  |9 ++---
 6 files changed, 12 insertions(+), 57 deletions(-)

diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index e45232d..a8814eb 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -884,11 +884,7 @@ AVOutputFormat ff_asf_muxer = {
 .mime_type  = "video/x-ms-asf",
 .extensions = "asf,wmv,wma",
 .priv_data_size = sizeof(ASFContext),
-#if CONFIG_LIBMP3LAME
-.audio_codec= CODEC_ID_MP3,
-#else
-.audio_codec= CODEC_ID_MP2,
-#endif
+.audio_codec= CONFIG_LIBMP3LAME ? CODEC_ID_MP3 : CODEC_ID_MP2,
 .video_codec= CODEC_ID_MSMPEG4V3,
 .write_header   = asf_write_header,
 .write_packet   = asf_write_packet,
@@ -907,11 +903,7 @@ AVOutputFormat ff_asf_stream_muxer = {
 .mime_type  = "video/x-ms-asf",
 .extensions = "asf,wmv,wma",
 .priv_data_size = sizeof(ASFContext),
-#if CONFIG_LIBMP3LAME
-.audio_codec= CODEC_ID_MP3,
-#else
-.audio_codec= CODEC_ID_MP2,
-#endif
+.audio_codec= CONFIG_LIBMP3LAME ? CODEC_ID_MP3 : CODEC_ID_MP2,
 .video_codec= CODEC_ID_MSMPEG4V3,
 .write_header   = asf_write_stream_header,
 .write_packet   = asf_write_packet,
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 3689f57..2cf8fb0 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -645,11 +645,7 @@ AVOutputFormat ff_avi_muxer = {
 .mime_type = "video/x-msvideo",
 .extensions= "avi",
 .priv_data_size= sizeof(AVIContext),
-#if CONFIG_LIBMP3LAME_ENCODER
-.audio_codec   = CODEC_ID_MP3,
-#else
-.audio_codec   = CODEC_ID_AC3,
-#endif
+.audio_codec   = CONFIG_LIBMP3LAME_ENCODER ? CODEC_ID_MP3 : 
CODEC_ID_AC3,
 .video_codec   = CODEC_ID_MPEG4,
 .write_header  = avi_write_header,
 .write_packet  = avi_write_packet,
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 62756a1..7f832a1 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -528,11 +528,7 @@ AVOutputFormat ff_flv_muxer = {
 .mime_type  = "video/x-flv",
 .extensions = "flv",
 .priv_data_size = sizeof(FLVContext),
-#if CONFIG_LIBMP3LAME
-.audio_codec= CODEC_ID_MP3,
-#else // CONFIG_LIBMP3LAME
-.audio_codec= CODEC_ID_ADPCM_SWF,
-#endif // CONFIG_LIBMP3LAME
+.audio_codec= CONFIG_LIBMP3LAME ? CODEC_ID_MP3 : CODEC_ID_ADPCM_SWF,
 .video_codec= CODEC_ID_FLV1,
 .write_header   = flv_write_header,
 .write_packet   = flv_write_packet,
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 61a91d7..f8d9019 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1292,16 +1292,8 @@ AVOutputFormat ff_matroska_muxer = {
 .mime_type = "video/x-matroska",
 .extensions= "mkv",
 .priv_data_size= sizeof(MatroskaMuxContext),
-#if CONFIG_LIBVORBIS_ENCODER
-.audio_codec   = CODEC_ID_VORBIS,
-#else
-.audio_codec   = CODEC_ID_AC3,
-#endif
-#if CONFIG_LIBX264_ENCODER
-.video_codec   = CODEC_ID_H264,
-#else
-.video_codec   = CODEC_ID_MPEG4,
-#endif
+.audio_codec   = CONFIG_LIBVORBIS_ENCODER ? CODEC_ID_VORBIS : 
CODEC_ID_AC3,
+.video_codec   = CONFIG_LIBX264_ENCODER ? CODEC_ID_H264 : 
CODEC_ID_MPEG4,
 .write_header  = mkv_write_header,
 .write_packet  = mkv_write_packet,
 .write_trailer = mkv_write_trailer,
@@ -1339,11 +1331,7 @@ AVOutputFormat ff_matroska_audio_muxer = {
 .mime_type = "audio/x-matroska",
 .extensions= "mka",
 .priv_data_size= sizeof(MatroskaMuxContext),
-#if CONFIG_LIBVORBIS_ENCODER
-.audio_codec   = CODEC_ID_VORBIS,
-#else
-.audio_codec   = CODEC_ID_AC3,
-#endif
+.audio_codec   = CONFIG_LIBVORBIS_ENCODER ? CODEC_ID_VORBIS : 
CODEC_ID_AC3,
 .video_codec   = CODEC_ID_NONE,
 .write_header  = mkv_write_header,
 .write_packet  = mkv_write_packet,
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index bf888bc..008ee99 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3251,11 +3251,7 @@ AVOutputFormat ff_mov_muxer = {
 .extensions= "mov",
 .priv_data_size= sizeof(MOVMuxContext),
 .audio_codec   = CODEC_ID_AAC,
-#if CONFIG_LIBX264_ENCODER
-.video_codec   = CODEC_ID_H264,
-#else
-.video_codec   = CODEC_ID_MPEG4,
-#endif
+.video_codec   = CONFIG_LIBX264_ENCODER ? CODEC_ID_H264 : 
CODEC_ID_MPEG4,
 .write_header  = mov_write_header,
 .write_packet  = mov_write_packet,
 .write_trailer = mov_write_trailer,
@@ -3292,11 +3288,7 @@ AVOutputFormat ff_mp4_muxer = {
 .extensions   

[libav-devel] [PATCH 5/7] attributes: add av_always_inline definition for msvc

2012-06-18 Thread Mans Rullgard
From: "Ronald S. Bultje" 

---
 libavutil/attributes.h |2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavutil/attributes.h b/libavutil/attributes.h
index ef990a1..c0bac3f 100644
--- a/libavutil/attributes.h
+++ b/libavutil/attributes.h
@@ -35,6 +35,8 @@
 #ifndef av_always_inline
 #if AV_GCC_VERSION_AT_LEAST(3,1)
 #define av_always_inline __attribute__((always_inline)) inline
+#elif defined(_MSC_VER)
+#define av_always_inline __forceinline
 #else
 #define av_always_inline inline
 #endif
-- 
1.7.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 7/7] http: replace atoll() with strtoll()

2012-06-18 Thread Mans Rullgard
From: "Ronald S. Bultje" 

---
 libavformat/http.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index a494193..8ccb649 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -309,15 +309,15 @@ static int process_line(URLContext *h, char *line, int 
line_count,
 strcpy(s->location, p);
 *new_location = 1;
 } else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == 
-1) {
-s->filesize = atoll(p);
+s->filesize = strtoll(p, NULL, 10);
 } else if (!av_strcasecmp (tag, "Content-Range")) {
 /* "bytes $from-$to/$document_size" */
 const char *slash;
 if (!strncmp (p, "bytes ", 6)) {
 p += 6;
-s->off = atoll(p);
+s->off = strtoll(p, NULL, 10);
 if ((slash = strchr(p, '/')) && strlen(slash) > 0)
-s->filesize = atoll(slash+1);
+s->filesize = strtoll(slash+1, NULL, 10);
 }
 h->is_streamed = 0; /* we _can_ in fact seek */
 } else if (!av_strcasecmp(tag, "Accept-Ranges") && !strncmp(p, 
"bytes", 5)) {
-- 
1.7.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 1/7] dirac: replace compound literal with normal initialiser

2012-06-18 Thread Mans Rullgard
From: "Ronald S. Bultje" 

---
 libavcodec/dirac.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/dirac.c b/libavcodec/dirac.c
index bf56088..07329e3 100644
--- a/libavcodec/dirac.c
+++ b/libavcodec/dirac.c
@@ -108,7 +108,7 @@ static const enum PixelFormat dirac_pix_fmt[2][3] = {
 static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
dirac_source_params *source)
 {
-AVRational frame_rate = (AVRational){0,0};
+AVRational frame_rate = {0,0};
 unsigned luma_depth = 8, luma_offset = 16;
 int idx;
 
-- 
1.7.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 6/7] mpegts: remove unused (incomplete?) seeking code

2012-06-18 Thread Mans Rullgard
From: "Ronald S. Bultje" 

---
 libavformat/mpegts.c |   96 --
 1 file changed, 96 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index ebc5f2c..5b44c0e 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -19,8 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-//#define USE_SYNCPOINT_SEARCH
-
 #include "libavutil/crc.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/log.h"
@@ -2093,92 +2091,6 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int 
stream_index,
 return timestamp;
 }
 
-#ifdef USE_SYNCPOINT_SEARCH
-
-static int read_seek2(AVFormatContext *s,
-  int stream_index,
-  int64_t min_ts,
-  int64_t target_ts,
-  int64_t max_ts,
-  int flags)
-{
-int64_t pos;
-
-int64_t ts_ret, ts_adj;
-int stream_index_gen_search;
-AVStream *st;
-AVParserState *backup;
-
-backup = ff_store_parser_state(s);
-
-// detect direction of seeking for search purposes
-flags |= (target_ts - min_ts > (uint64_t)(max_ts - target_ts)) ?
- AVSEEK_FLAG_BACKWARD : 0;
-
-if (flags & AVSEEK_FLAG_BYTE) {
-// use position directly, we will search starting from it
-pos = target_ts;
-} else {
-// search for some position with good timestamp match
-if (stream_index < 0) {
-stream_index_gen_search = av_find_default_stream_index(s);
-if (stream_index_gen_search < 0) {
-ff_restore_parser_state(s, backup);
-return -1;
-}
-
-st = s->streams[stream_index_gen_search];
-// timestamp for default must be expressed in AV_TIME_BASE units
-ts_adj = av_rescale(target_ts,
-st->time_base.den,
-AV_TIME_BASE * (int64_t)st->time_base.num);
-} else {
-ts_adj = target_ts;
-stream_index_gen_search = stream_index;
-}
-pos = ff_gen_search(s, stream_index_gen_search, ts_adj,
-0, INT64_MAX, -1,
-AV_NOPTS_VALUE,
-AV_NOPTS_VALUE,
-flags, &ts_ret, mpegts_get_pcr);
-if (pos < 0) {
-ff_restore_parser_state(s, backup);
-return -1;
-}
-}
-
-// search for actual matching keyframe/starting position for all streams
-if (ff_gen_syncpoint_search(s, stream_index, pos,
-min_ts, target_ts, max_ts,
-flags) < 0) {
-ff_restore_parser_state(s, backup);
-return -1;
-}
-
-ff_free_parser_state(s, backup);
-return 0;
-}
-
-static int read_seek(AVFormatContext *s, int stream_index, int64_t target_ts, 
int flags)
-{
-int ret;
-if (flags & AVSEEK_FLAG_BACKWARD) {
-flags &= ~AVSEEK_FLAG_BACKWARD;
-ret = read_seek2(s, stream_index, INT64_MIN, target_ts, target_ts, 
flags);
-if (ret < 0)
-// for compatibility reasons, seek to the best-fitting timestamp
-ret = read_seek2(s, stream_index, INT64_MIN, target_ts, INT64_MAX, 
flags);
-} else {
-ret = read_seek2(s, stream_index, target_ts, target_ts, INT64_MAX, 
flags);
-if (ret < 0)
-// for compatibility reasons, seek to the best-fitting timestamp
-ret = read_seek2(s, stream_index, INT64_MIN, target_ts, INT64_MAX, 
flags);
-}
-return ret;
-}
-
-#else
-
 static int read_seek(AVFormatContext *s, int stream_index, int64_t target_ts, 
int flags){
 MpegTSContext *ts = s->priv_data;
 uint8_t buf[TS_PACKET_SIZE];
@@ -2202,8 +2114,6 @@ static int read_seek(AVFormatContext *s, int 
stream_index, int64_t target_ts, in
 return 0;
 }
 
-#endif
-
 /**/
 /* parsing functions - called from other demuxers such as RTP */
 
@@ -2268,9 +2178,6 @@ AVInputFormat ff_mpegts_demuxer = {
 .read_seek  = read_seek,
 .read_timestamp = mpegts_get_pcr,
 .flags  = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
-#ifdef USE_SYNCPOINT_SEARCH
-.read_seek2 = read_seek2,
-#endif
 };
 
 AVInputFormat ff_mpegtsraw_demuxer = {
@@ -2283,8 +2190,5 @@ AVInputFormat ff_mpegtsraw_demuxer = {
 .read_seek  = read_seek,
 .read_timestamp = mpegts_get_pcr,
 .flags  = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
-#ifdef USE_SYNCPOINT_SEARCH
-.read_seek2 = read_seek2,
-#endif
 .priv_class = &mpegtsraw_class,
 };
-- 
1.7.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/7] dirac: replace compound literal with normal initialiser

2012-06-18 Thread Janne Grunau
On 2012-06-18 14:37:00 +0100, Måns Rullgård wrote:
> From: "Ronald S. Bultje" 
> 
> ---
>  libavcodec/dirac.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/dirac.c b/libavcodec/dirac.c
> index bf56088..07329e3 100644
> --- a/libavcodec/dirac.c
> +++ b/libavcodec/dirac.c
> @@ -108,7 +108,7 @@ static const enum PixelFormat dirac_pix_fmt[2][3] = {
>  static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
> dirac_source_params *source)
>  {
> -AVRational frame_rate = (AVRational){0,0};
> +AVRational frame_rate = {0,0};
>  unsigned luma_depth = 8, luma_offset = 16;
>  int idx;

ok

Janne
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 4/7] network: winsock2: protect EFOO error constant definitions with ifdefs

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Mans Rullgard wrote:


From: "Ronald S. Bultje" 

---
libavformat/network.h |8 
1 file changed, 8 insertions(+)

diff --git a/libavformat/network.h b/libavformat/network.h
index 72d01d2..5c70e2d 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -31,10 +31,18 @@
#include 
#include 

+#ifndef EPROTONOSUPPORT
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
+#endif
+#ifndef ETIMEDOUT
#define ETIMEDOUT   WSAETIMEDOUT
+#endif
+#ifndef ECONNREFUSED
#define ECONNREFUSEDWSAECONNREFUSED
+#endif
+#ifndef EINPROGRESS
#define EINPROGRESS WSAEINPROGRESS
+#endif

int ff_neterrno(void);
#else
--
1.7.10.2


Ok

// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 7/7] http: replace atoll() with strtoll()

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Mans Rullgard wrote:


From: "Ronald S. Bultje" 

---
libavformat/http.c |6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index a494193..8ccb649 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -309,15 +309,15 @@ static int process_line(URLContext *h, char *line, int 
line_count,
strcpy(s->location, p);
*new_location = 1;
} else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) 
{
-s->filesize = atoll(p);
+s->filesize = strtoll(p, NULL, 10);
} else if (!av_strcasecmp (tag, "Content-Range")) {
/* "bytes $from-$to/$document_size" */
const char *slash;
if (!strncmp (p, "bytes ", 6)) {
p += 6;
-s->off = atoll(p);
+s->off = strtoll(p, NULL, 10);
if ((slash = strchr(p, '/')) && strlen(slash) > 0)
-s->filesize = atoll(slash+1);
+s->filesize = strtoll(slash+1, NULL, 10);
}
h->is_streamed = 0; /* we _can_ in fact seek */
} else if (!av_strcasecmp(tag, "Accept-Ranges") && !strncmp(p, "bytes", 
5)) {
--
1.7.10.2


Ok

// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 5/7] attributes: add av_always_inline definition for msvc

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Mans Rullgard wrote:


From: "Ronald S. Bultje" 

---
libavutil/attributes.h |2 ++
1 file changed, 2 insertions(+)

diff --git a/libavutil/attributes.h b/libavutil/attributes.h
index ef990a1..c0bac3f 100644
--- a/libavutil/attributes.h
+++ b/libavutil/attributes.h
@@ -35,6 +35,8 @@
#ifndef av_always_inline
#if AV_GCC_VERSION_AT_LEAST(3,1)
#define av_always_inline __attribute__((always_inline)) inline
+#elif defined(_MSC_VER)
+#define av_always_inline __forceinline
#else
#define av_always_inline inline
#endif
--
1.7.10.2


LGTM

// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/7] Replace some #if/else in struct initialisers with conditional expressions

2012-06-18 Thread Kostya Shishkov
On Mon, Jun 18, 2012 at 02:37:01PM +0100, Mans Rullgard wrote:
> From: "Ronald S. Bultje" 
> 
> ---
>  libavformat/asfenc.c  |   12 ++--
>  libavformat/avienc.c  |6 +-
>  libavformat/flvenc.c  |6 +-
>  libavformat/matroskaenc.c |   18 +++---
>  libavformat/movenc.c  |   18 +++---
>  libavformat/nutenc.c  |9 ++---
>  6 files changed, 12 insertions(+), 57 deletions(-)

LGeTM
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/7] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Mans Rullgard wrote:


From: "Ronald S. Bultje" 

---
configure   |4 +++-
libavutil/mem.c |6 ++
2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index a5d2787..f1f58a7 100755
--- a/configure
+++ b/configure
@@ -1049,6 +1049,7 @@ HAVE_LIST="
$ARCH_EXT_LIST
$HAVE_LIST_PUB
$THREADS_LIST
+aligned_malloc
aligned_stack
alsa_asoundlib_h
altivec_h
@@ -2834,6 +2835,7 @@ check_func  ${malloc_prefix}memalign&& enable 
memalign
check_func  mkstemp
check_func  mmap
check_func  ${malloc_prefix}posix_memalign  && enable posix_memalign
+check_func  ${malloc_prefix}_aligned_malloc && enable aligned_malloc


On mingw, this function is only available if such a version of the MSVCRT 
is targeted that contain it, controlled via the headers. Currently, since 
this doesn't test the headers but only tests linking, it will succeed 
regardless. A check which tries to include it from the header (malloc.h) 
would be better in this case, I think.


// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/7] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Kostya Shishkov
On Mon, Jun 18, 2012 at 02:37:02PM +0100, Mans Rullgard wrote:
> From: "Ronald S. Bultje" 
> 
> ---
>  configure   |4 +++-
>  libavutil/mem.c |6 ++
>  2 files changed, 9 insertions(+), 1 deletion(-)

probably OK
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 6/7] mpegts: remove unused (incomplete?) seeking code

2012-06-18 Thread Kostya Shishkov
On Mon, Jun 18, 2012 at 02:37:05PM +0100, Mans Rullgard wrote:
> From: "Ronald S. Bultje" 
> 
> ---
>  libavformat/mpegts.c |   96 
> --
>  1 file changed, 96 deletions(-)

LGTM
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/7] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Måns Rullgård
Martin Storsjö  writes:

> On Mon, 18 Jun 2012, Mans Rullgard wrote:
>
>> From: "Ronald S. Bultje" 
>>
>> ---
>> configure   |4 +++-
>> libavutil/mem.c |6 ++
>> 2 files changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/configure b/configure
>> index a5d2787..f1f58a7 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1049,6 +1049,7 @@ HAVE_LIST="
>> $ARCH_EXT_LIST
>> $HAVE_LIST_PUB
>> $THREADS_LIST
>> +aligned_malloc
>> aligned_stack
>> alsa_asoundlib_h
>> altivec_h
>> @@ -2834,6 +2835,7 @@ check_func  ${malloc_prefix}memalign&& 
>> enable memalign
>> check_func  mkstemp
>> check_func  mmap
>> check_func  ${malloc_prefix}posix_memalign  && enable posix_memalign
>> +check_func  ${malloc_prefix}_aligned_malloc && enable aligned_malloc
>
> On mingw, this function is only available if such a version of the
> MSVCRT is targeted that contain it, controlled via the
> headers. Currently, since this doesn't test the headers but only tests
> linking, it will succeed regardless. A check which tries to include it
> from the header (malloc.h) would be better in this case, I think.

Do you have such a system?  Could you help testing it?

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 6/7] mpegts: remove unused (incomplete?) seeking code

2012-06-18 Thread Måns Rullgård
Mans Rullgard  writes:

> From: "Ronald S. Bultje" 
>
> ---
>  libavformat/mpegts.c |   96 
> --
>  1 file changed, 96 deletions(-)
>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index ebc5f2c..5b44c0e 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -19,8 +19,6 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
>   */
>
> -//#define USE_SYNCPOINT_SEARCH
> -
>  #include "libavutil/crc.h"
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/log.h"
> @@ -2093,92 +2091,6 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int 
> stream_index,
>  return timestamp;
>  }
>
> -#ifdef USE_SYNCPOINT_SEARCH
> -
> -static int read_seek2(AVFormatContext *s,
> -  int stream_index,
> -  int64_t min_ts,
> -  int64_t target_ts,
> -  int64_t max_ts,
> -  int flags)
> -{

Does anyone know what this code was intended for and why it was disabled?

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] MS Screen 1 decoder

2012-06-18 Thread Martin Storsjö

diff --git a/libavcodec/mss1.c b/libavcodec/mss1.c
new file mode 100644
index 000..ba1a613
--- /dev/null
+++ b/libavcodec/mss1.c
@@ -0,0 +1,846 @@
+/*
+ * Microsoft Screen 1 (aka Windows Media Video V7 Screen) decoder
+ * Copyright (c) 2012 Konstantin Shishkov
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Microsoft Screen 1 (aka Windows Media Video V7 Screen) decoder
+ */
+
+#include "libavutil/intfloat.h"
+#include "libavutil/intreadwrite.h"
+#include "avcodec.h"
+#include "get_bits.h"
+
+enum SplitMode {
+SPLIT_VERT = 0,
+SPLIT_HOR,
+SPLIT_NONE
+};
+
+typedef struct ArithCoder {
+int low, high, value;
+GetBitContext *gb;
+} ArithCoder;
+
+#define MODEL_MIN_SYMS 2
+#define MODEL_MAX_SYMS 256
+#define THRESH_ADAPTIVE -1
+#define THRESH_LOW  15
+#define THRESH_HIGH 50
+#define THRESH_KOSTYA 1986


Nice easter egg ;P (aka unused define)

I didn't find anything objectionable in the rest of the patch, but I'm not 
very familiar with this kind of code, so my review perhaps isn't the most 
valuable one.


// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/7] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Janne Grunau
On 2012-06-18 14:37:02 +0100, Måns Rullgård wrote:
> From: "Ronald S. Bultje" 
> 
> ---
>  configure   |4 +++-
>  libavutil/mem.c |6 ++
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index a5d2787..f1f58a7 100755
> --- a/configure
> +++ b/configure
> @@ -1049,6 +1049,7 @@ HAVE_LIST="
>  $ARCH_EXT_LIST
>  $HAVE_LIST_PUB
>  $THREADS_LIST
> +aligned_malloc
>  aligned_stack
>  alsa_asoundlib_h
>  altivec_h
> @@ -2834,6 +2835,7 @@ check_func  ${malloc_prefix}memalign&& 
> enable memalign
>  check_func  mkstemp
>  check_func  mmap
>  check_func  ${malloc_prefix}posix_memalign  && enable posix_memalign
> +check_func  ${malloc_prefix}_aligned_malloc && enable aligned_malloc
>  check_func  setrlimit
>  check_func  strerror_r
>  check_func  strptime

we could set malloc_prefix to _aligned_ for msvc. It avoids unfortunately
only the #ifdef for free. malloc and realloc still needs the ifdef due to
the extra argument. Not really clearer, both ways are ok.

Configure check is inconsistent with the code, either loose the
${malloc_prefix} from the configure check or add the defines for
MALLOC_PREFIX_aligned_* in mem.c

Janne
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/7] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Måns Rullgård wrote:


Martin Storsjö  writes:


On Mon, 18 Jun 2012, Mans Rullgard wrote:


From: "Ronald S. Bultje" 

---
configure   |4 +++-
libavutil/mem.c |6 ++
2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index a5d2787..f1f58a7 100755
--- a/configure
+++ b/configure
@@ -1049,6 +1049,7 @@ HAVE_LIST="
$ARCH_EXT_LIST
$HAVE_LIST_PUB
$THREADS_LIST
+aligned_malloc
aligned_stack
alsa_asoundlib_h
altivec_h
@@ -2834,6 +2835,7 @@ check_func  ${malloc_prefix}memalign&& enable 
memalign
check_func  mkstemp
check_func  mmap
check_func  ${malloc_prefix}posix_memalign  && enable posix_memalign
+check_func  ${malloc_prefix}_aligned_malloc && enable aligned_malloc


On mingw, this function is only available if such a version of the
MSVCRT is targeted that contain it, controlled via the
headers. Currently, since this doesn't test the headers but only tests
linking, it will succeed regardless. A check which tries to include it
from the header (malloc.h) would be better in this case, I think.


Do you have such a system?  Could you help testing it?


Yes, I can try to make a better version of this patch and test it as far 
as I can :-)


// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/7] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Sean McGovern
On Monday, June 18, 2012, Måns Rullgård  wrote:
> Martin Storsjö  writes:
>
>> On Mon, 18 Jun 2012, Mans Rullgard wrote:
>>
>>> From: "Ronald S. Bultje" 
>>>
>>> ---
>>> configure   |4 +++-
>>> libavutil/mem.c |6 ++
>>> 2 files changed, 9 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/configure b/configure
>>> index a5d2787..f1f58a7 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -1049,6 +1049,7 @@ HAVE_LIST="
>>> $ARCH_EXT_LIST
>>> $HAVE_LIST_PUB
>>> $THREADS_LIST
>>> +aligned_malloc
>>> aligned_stack
>>> alsa_asoundlib_h
>>> altivec_h
>>> @@ -2834,6 +2835,7 @@ check_func  ${malloc_prefix}memalign
 && enable memalign
>>> check_func  mkstemp
>>> check_func  mmap
>>> check_func  ${malloc_prefix}posix_memalign  && enable posix_memalign
>>> +check_func  ${malloc_prefix}_aligned_malloc && enable
aligned_malloc
>>
>> On mingw, this function is only available if such a version of the
>> MSVCRT is targeted that contain it, controlled via the
>> headers. Currently, since this doesn't test the headers but only tests
>> linking, it will succeed regardless. A check which tries to include it
>> from the header (malloc.h) would be better in this case, I think.
>
> Do you have such a system?  Could you help testing it?

Mike Kostylev controls the mingw FATE runs. Maybe ping him?

-- Sean McG
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 6/7] mpegts: remove unused (incomplete?) seeking code

2012-06-18 Thread Diego Elio Pettenò
Il 18/06/2012 15:48, Måns Rullgård ha scritto:
> Does anyone know what this code was intended for and why it was disabled?

It does remind me of something that is/was also in xine but I don't know
for sure..

-- 
Diego Elio Pettenò — Flameeyes
flamee...@flameeyes.eu — http://blog.flameeyes.eu/


___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/7] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Måns Rullgård
Janne Grunau  writes:

> On 2012-06-18 14:37:02 +0100, Måns Rullgård wrote:
>> From: "Ronald S. Bultje" 
>> 
>> ---
>>  configure   |4 +++-
>>  libavutil/mem.c |6 ++
>>  2 files changed, 9 insertions(+), 1 deletion(-)
>> 
>> diff --git a/configure b/configure
>> index a5d2787..f1f58a7 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1049,6 +1049,7 @@ HAVE_LIST="
>>  $ARCH_EXT_LIST
>>  $HAVE_LIST_PUB
>>  $THREADS_LIST
>> +aligned_malloc
>>  aligned_stack
>>  alsa_asoundlib_h
>>  altivec_h
>> @@ -2834,6 +2835,7 @@ check_func  ${malloc_prefix}memalign&& 
>> enable memalign
>>  check_func  mkstemp
>>  check_func  mmap
>>  check_func  ${malloc_prefix}posix_memalign  && enable posix_memalign
>> +check_func  ${malloc_prefix}_aligned_malloc && enable aligned_malloc
>>  check_func  setrlimit
>>  check_func  strerror_r
>>  check_func  strptime
>
> we could set malloc_prefix to _aligned_ for msvc. It avoids unfortunately
> only the #ifdef for free. malloc and realloc still needs the ifdef due to
> the extra argument. Not really clearer, both ways are ok.
>
> Configure check is inconsistent with the code, either loose the
> ${malloc_prefix} from the configure check or add the defines for
> MALLOC_PREFIX_aligned_* in mem.c

I was going to suggest dropping the ${malloc_prefix} here.  This feature
exists so the standard allocator can be replaced by a custom one, and
there's no reason why a custom allocator can't use the standard
interface.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/2] rtmp: Reduce the number of idle posts sent by sleeping 50ms

2012-06-18 Thread Samuel Pitoiset
---
 libavformat/rtmphttp.c |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/libavformat/rtmphttp.c b/libavformat/rtmphttp.c
index fdcff50..7c58f2b 100644
--- a/libavformat/rtmphttp.c
+++ b/libavformat/rtmphttp.c
@@ -24,6 +24,8 @@
  * RTMP HTTP protocol
  */
 
+#include 
+
 #include "libavutil/avstring.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/opt.h"
@@ -44,6 +46,7 @@ typedef struct RTMP_HTTPContext {
 int  out_capacity;  ///< current output buffer capacity
 int  initialized;   ///< flag indicating when the http context 
is initialized
 int  finishing; ///< flag indicating when the client 
closes the connection
+int  nb_bytes_read; ///< number of bytes read since the last 
request
 } RTMP_HTTPContext;
 
 static int rtmp_http_send_cmd(URLContext *h, const char *cmd)
@@ -122,6 +125,13 @@ static int rtmp_http_read(URLContext *h, uint8_t *buf, int 
size)
 
 if ((ret = rtmp_http_send_cmd(h, "idle")) < 0)
 return ret;
+rt->nb_bytes_read = 0;
+}
+
+if (rt->nb_bytes_read == 0) {
+/* Wait 50ms before retrying to read a server reply in
+ * order to reduce the number of idle requets. */
+ usleep(5);
 }
 
 if (h->flags & AVIO_FLAG_NONBLOCK) {
@@ -131,6 +141,7 @@ static int rtmp_http_read(URLContext *h, uint8_t *buf, int 
size)
 } else {
 off  += ret;
 size -= ret;
+rt->nb_bytes_read += ret;
 }
 } while (off <= 0);
 
-- 
1.7.10.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] MS Screen 1 decoder

2012-06-18 Thread Kostya Shishkov
On Mon, Jun 18, 2012 at 04:48:43PM +0300, Martin Storsjö wrote:
> >diff --git a/libavcodec/mss1.c b/libavcodec/mss1.c
> >new file mode 100644
> >index 000..ba1a613
> >--- /dev/null
> >+++ b/libavcodec/mss1.c
> >@@ -0,0 +1,846 @@
> >+/*
> >+ * Microsoft Screen 1 (aka Windows Media Video V7 Screen) decoder
> >+ * Copyright (c) 2012 Konstantin Shishkov
> >+ *
> >+ * This file is part of Libav.
> >+ *
> >+ * Libav is free software; you can redistribute it and/or
> >+ * modify it under the terms of the GNU Lesser General Public
> >+ * License as published by the Free Software Foundation; either
> >+ * version 2.1 of the License, or (at your option) any later version.
> >+ *
> >+ * Libav is distributed in the hope that it will be useful,
> >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> >+ * Lesser General Public License for more details.
> >+ *
> >+ * You should have received a copy of the GNU Lesser General Public
> >+ * License along with Libav; if not, write to the Free Software
> >+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> >USA
> >+ */
> >+
> >+/**
> >+ * @file
> >+ * Microsoft Screen 1 (aka Windows Media Video V7 Screen) decoder
> >+ */
> >+
> >+#include "libavutil/intfloat.h"
> >+#include "libavutil/intreadwrite.h"
> >+#include "avcodec.h"
> >+#include "get_bits.h"
> >+
> >+enum SplitMode {
> >+SPLIT_VERT = 0,
> >+SPLIT_HOR,
> >+SPLIT_NONE
> >+};
> >+
> >+typedef struct ArithCoder {
> >+int low, high, value;
> >+GetBitContext *gb;
> >+} ArithCoder;
> >+
> >+#define MODEL_MIN_SYMS 2
> >+#define MODEL_MAX_SYMS 256
> >+#define THRESH_ADAPTIVE -1
> >+#define THRESH_LOW  15
> >+#define THRESH_HIGH 50
> >+#define THRESH_KOSTYA 1986
> 
> Nice easter egg ;P (aka unused define)

Indeed it's wrong (should be 1985 instead).
 
> I didn't find anything objectionable in the rest of the patch, but
> I'm not very familiar with this kind of code, so my review perhaps
> isn't the most valuable one.

Well, the code is rather simple. And any review is better than the lack of
them.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] rtmp: Reduce the number of idle posts sent by sleeping 50ms

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Samuel Pitoiset wrote:


---
libavformat/rtmphttp.c |   11 +++
1 file changed, 11 insertions(+)

diff --git a/libavformat/rtmphttp.c b/libavformat/rtmphttp.c
index fdcff50..7c58f2b 100644
--- a/libavformat/rtmphttp.c
+++ b/libavformat/rtmphttp.c
@@ -24,6 +24,8 @@
 * RTMP HTTP protocol
 */

+#include 
+
#include "libavutil/avstring.h"
#include "libavutil/intfloat.h"
#include "libavutil/opt.h"
@@ -44,6 +46,7 @@ typedef struct RTMP_HTTPContext {
int  out_capacity;  ///< current output buffer capacity
int  initialized;   ///< flag indicating when the http context 
is initialized
int  finishing; ///< flag indicating when the client closes 
the connection
+int  nb_bytes_read; ///< number of bytes read since the last 
request
} RTMP_HTTPContext;

static int rtmp_http_send_cmd(URLContext *h, const char *cmd)
@@ -122,6 +125,13 @@ static int rtmp_http_read(URLContext *h, uint8_t *buf, int 
size)

if ((ret = rtmp_http_send_cmd(h, "idle")) < 0)
return ret;
+rt->nb_bytes_read = 0;


Please reset nb_bytes_read in _send_cmd instead of here, then it will be 
reset more consistently for each request.



+}
+
+if (rt->nb_bytes_read == 0) {
+/* Wait 50ms before retrying to read a server reply in
+ * order to reduce the number of idle requets. */
+ usleep(5);
}


Move this into the if branch where you send an idle request, and move it 
before sending the new request. If we're publishing a stream (and thus 
normally don't receive any data, but send data ourselves), there's no need 
for us to slow it down. It's only needed if we don't have anything to 
send, and the server doesn't have anything either.


// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] MS Screen 1 decoder

2012-06-18 Thread Christophe Gisquet
Hi,

> +typedef struct Model {
> +    int cum_prob[MODEL_MAX_SYMS + 1];
> +    int weights[MODEL_MAX_SYMS + 1];
> +    int idx2sym[MODEL_MAX_SYMS + 1];
> +    int sym2idx[MODEL_MAX_SYMS + 1];
> +    int num_syms;
> +    int thr_weight, threshold;
> +} Model;

How high are the weights typically? Same for the LUT values of idx2sym
and sym2idx. num_syms seems to be set to 8 or 2, but there is probably
something I missed in between.

Basically, I am wondering if a smaller type could be used.

> +static void arith_normalise(ArithCoder *c)
[...]
> +static int arith_get_bit(ArithCoder *c)
[...]
> +static int arith_get_bits(ArithCoder *c, int bits)
[...]
> +static int arith_get_number(ArithCoder *c, int mod_val)

I guess you are not interested in this part, but probably those (and
mostly those) could benefit from some av_inline, but most compilers
probably get it right on their own.

> +memset(neighbours, src[-1], 4);

Something like AV_WN32A(neighbours, src[-1]*0x01010101) maybe? I guess
other parts would be more in need than this but still...

I haven't checked even remotely if there is any issue with incorrect
bitstreams, which would probably be a more interesting review.

-- 
Christophe
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] flvdec: remove incomplete, disabled seeking code

2012-06-18 Thread Mans Rullgard
From: "Ronald S. Bultje" 

---
 libavformat/flvdec.c |   30 --
 1 file changed, 30 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index f04f4fe..8e9759b 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -749,33 +749,6 @@ static int flv_read_seek(AVFormatContext *s, int 
stream_index,
 return avio_seek_time(s->pb, stream_index, ts, flags);
 }
 
-#if 0 /* don't know enough to implement this */
-static int flv_read_seek2(AVFormatContext *s, int stream_index,
-int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
-{
-int ret = AVERROR(ENOSYS);
-
-if (ts - min_ts > (uint64_t)(max_ts - ts)) flags |= AVSEEK_FLAG_BACKWARD;
-
-if (!s->pb->seekable) {
-if (stream_index < 0) {
-stream_index = av_find_default_stream_index(s);
-if (stream_index < 0)
-return -1;
-
-/* timestamp for default must be expressed in AV_TIME_BASE units */
-ts = av_rescale_rnd(ts, 1000, AV_TIME_BASE,
-flags & AVSEEK_FLAG_BACKWARD ? AV_ROUND_DOWN : AV_ROUND_UP);
-}
-ret = avio_seek_time(s->pb, stream_index, ts, flags);
-}
-
-if (ret == AVERROR(ENOSYS))
-ret = av_seek_frame(s, stream_index, ts, flags);
-return ret;
-}
-#endif
-
 AVInputFormat ff_flv_demuxer = {
 .name   = "flv",
 .long_name  = NULL_IF_CONFIG_SMALL("FLV format"),
@@ -784,9 +757,6 @@ AVInputFormat ff_flv_demuxer = {
 .read_header= flv_read_header,
 .read_packet= flv_read_packet,
 .read_seek  = flv_read_seek,
-#if 0
-.read_seek2 = flv_read_seek2,
-#endif
 .read_close = flv_read_close,
 .extensions = "flv",
 };
-- 
1.7.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] MS Screen 1 decoder

2012-06-18 Thread Kostya Shishkov
On Mon, Jun 18, 2012 at 04:16:01PM +0200, Christophe Gisquet wrote:
> Hi,
> 
> > +typedef struct Model {
> > +    int cum_prob[MODEL_MAX_SYMS + 1];
> > +    int weights[MODEL_MAX_SYMS + 1];
> > +    int idx2sym[MODEL_MAX_SYMS + 1];
> > +    int sym2idx[MODEL_MAX_SYMS + 1];
> > +    int num_syms;
> > +    int thr_weight, threshold;
> > +} Model;
> 
> How high are the weights typically? Same for the LUT values of idx2sym
> and sym2idx. num_syms seems to be set to 8 or 2, but there is probably
> something I missed in between.

There's one model for all pixel values (i.e. 256 symbols).
Original decoder can have up to 1023 symbols but I have not found such large
model anywhere.
 
> Basically, I am wondering if a smaller type could be used.

It can, but I don't think it's worth the effort (even though in practice
probably every field can be made int8_t or uint8_t).

> > +static void arith_normalise(ArithCoder *c)
> [...]
> > +static int arith_get_bit(ArithCoder *c)
> [...]
> > +static int arith_get_bits(ArithCoder *c, int bits)
> [...]
> > +static int arith_get_number(ArithCoder *c, int mod_val)
> 
> I guess you are not interested in this part, but probably those (and
> mostly those) could benefit from some av_inline, but most compilers
> probably get it right on their own.
> 
> > +memset(neighbours, src[-1], 4);
> 
> Something like AV_WN32A(neighbours, src[-1]*0x01010101) maybe? I guess
> other parts would be more in need than this but still...
> 
> I haven't checked even remotely if there is any issue with incorrect
> bitstreams, which would probably be a more interesting review.

Well, since we use checked bitstream reader there's no possibility of
overreads during arithmetic coder normalisation and it should not go into
infinite loops (I check partitioning).
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] flvdec: remove incomplete, disabled seeking code

2012-06-18 Thread Kostya Shishkov
On Mon, Jun 18, 2012 at 03:22:56PM +0100, Mans Rullgard wrote:
> From: "Ronald S. Bultje" 
> 
> ---
>  libavformat/flvdec.c |   30 --
>  1 file changed, 30 deletions(-)

LGTM
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH v2 1/5] Add support for iLBC decoding/encoding via the external library libilbc

2012-06-18 Thread Justin Ruggles
On 06/18/2012 04:39 AM, Martin Storsjö wrote:
> The library is 3-clause BSD licensed.
> ---
>  Changelog  |1 +
>  configure  |6 ++
>  doc/general.texi   |   13 +++
>  libavcodec/Makefile|2 +
>  libavcodec/allcodecs.c |1 +
>  libavcodec/avcodec.h   |1 +
>  libavcodec/libilbc.c   |  209 
> 
>  libavcodec/utils.c |5 ++
>  8 files changed, 238 insertions(+)
>  create mode 100644 libavcodec/libilbc.c

LGTM.

-Justin

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] MS Screen 1 decoder

2012-06-18 Thread Christophe Gisquet
2012/6/18 Kostya Shishkov :
>> How high are the weights typically? Same for the LUT values of idx2sym
>> and sym2idx. num_syms seems to be set to 8 or 2, but there is probably
>> something I missed in between.
>
> There's one model for all pixel values (i.e. 256 symbols).
> Original decoder can have up to 1023 symbols but I have not found such large
> model anywhere.
>
>> Basically, I am wondering if a smaller type could be used.
>
> It can, but I don't think it's worth the effort (even though in practice
> probably every field can be made int8_t or uint8_t).

Is the -1 initialization of those LUTS really needed btw? If yes (I'm
missing how, as negative values from the LUTs do not seem to be
checked), then probably int16_t is needed.

How does the original decoder detect/what are the characteristics of a
bitstream with such values? Some "need samples" warning may be added
then.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH v2 3/5] Implement the iLBC storage file format

2012-06-18 Thread Justin Ruggles
On 06/18/2012 04:40 AM, Martin Storsjö wrote:
> ---
>  doc/general.texi |1 +
>  libavformat/Makefile |2 +
>  libavformat/allformats.c |1 +
>  libavformat/ilbc.c   |  140 
> ++
>  4 files changed, 144 insertions(+)
>  create mode 100644 libavformat/ilbc.c
[...]
> +AVOutputFormat ff_ilbc_muxer = {
> +.name = "ilbc",
> +.long_name= NULL_IF_CONFIG_SMALL("iLBC storage file format"),
> +.mime_type= "audio/iLBC",
> +.extensions   = "lbc",
> +.audio_codec  = CODEC_ID_ILBC,
> +.write_header = ilbc_write_header,
> +.write_packet = ilbc_write_packet,
> +};

Since this raw format has no coded timestamps, it should use the
AVFMT_NOTIMESTAMPS flag.

The rest LGTM.

-Justin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH v2 2/5] mov: Support muxing/demuxing iLBC

2012-06-18 Thread Justin Ruggles
On 06/18/2012 04:40 AM, Martin Storsjö wrote:
> The packet size, signalled via block_align, has to be passed via
> the container.
> ---
>  libavformat/isom.c   |1 +
>  libavformat/mov.c|1 +
>  libavformat/movenc.c |3 ++-
>  3 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/isom.c b/libavformat/isom.c
> index 3ea8ce1..e5cde5a 100644
> --- a/libavformat/isom.c
> +++ b/libavformat/isom.c
> @@ -244,6 +244,7 @@ const AVCodecTag ff_codec_movaudio_tags[] = {
>  { CODEC_ID_DVAUDIO, MKTAG('v', 'd', 'v', 'a') },
>  { CODEC_ID_DVAUDIO, MKTAG('d', 'v', 'c', 'a') },
>  { CODEC_ID_GSM, MKTAG('a', 'g', 's', 'm') },
> +{ CODEC_ID_ILBC,MKTAG('i', 'l', 'b', 'c') },
>  { CODEC_ID_MACE3,   MKTAG('M', 'A', 'C', '3') },
>  { CODEC_ID_MACE6,   MKTAG('M', 'A', 'C', '6') },
>  { CODEC_ID_MP1, MKTAG('.', 'm', 'p', '1') },
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 1395259..44dc2c8 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1456,6 +1456,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext 
> *pb, int entries)
>  case CODEC_ID_GSM:
>  case CODEC_ID_ADPCM_MS:
>  case CODEC_ID_ADPCM_IMA_WAV:
> +case CODEC_ID_ILBC:
>  st->codec->block_align = sc->bytes_per_frame;
>  break;
>  case CODEC_ID_ALAC:
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index bf888bc..350ac95 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -3095,7 +3095,8 @@ static int mov_write_header(AVFormatContext *s)
>  }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){
>  track->timescale = st->codec->sample_rate;
>  /* set sample_size for PCM and ADPCM */
> -if (av_get_bits_per_sample(st->codec->codec_id)) {
> +if (av_get_bits_per_sample(st->codec->codec_id) ||
> +st->codec->codec_id == CODEC_ID_ILBC) {
>  if (!st->codec->block_align) {
>  av_log(s, AV_LOG_ERROR, "track %d: codec block align is 
> not set\n", i);
>  goto error;

LGTM

-Justin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] MS Screen 1 decoder

2012-06-18 Thread Kostya Shishkov
On Mon, Jun 18, 2012 at 04:34:04PM +0200, Christophe Gisquet wrote:
> 2012/6/18 Kostya Shishkov :
> >> How high are the weights typically? Same for the LUT values of idx2sym
> >> and sym2idx. num_syms seems to be set to 8 or 2, but there is probably
> >> something I missed in between.
> >
> > There's one model for all pixel values (i.e. 256 symbols).
> > Original decoder can have up to 1023 symbols but I have not found such large
> > model anywhere.
> >
> >> Basically, I am wondering if a smaller type could be used.
> >
> > It can, but I don't think it's worth the effort (even though in practice
> > probably every field can be made int8_t or uint8_t).
> 
> Is the -1 initialization of those LUTS really needed btw? If yes (I'm
> missing how, as negative values from the LUTs do not seem to be
> checked), then probably int16_t is needed.
>  
> How does the original decoder detect/what are the characteristics of a
> bitstream with such values? Some "need samples" warning may be added
> then.

weights[0] need it as a special guard value, others are just for internal
state checking in case something goes wrong.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Martin Storsjö
From: "Ronald S. Bultje" 

The check uses check_func_header, since this function is
conditionally available depending on the targeted MSVCRT
version.
---
 configure   |4 +++-
 libavutil/mem.c |6 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index a5d2787..3e3cbd5 100755
--- a/configure
+++ b/configure
@@ -1049,6 +1049,7 @@ HAVE_LIST="
 $ARCH_EXT_LIST
 $HAVE_LIST_PUB
 $THREADS_LIST
+aligned_malloc
 aligned_stack
 alsa_asoundlib_h
 altivec_h
@@ -2834,6 +2835,7 @@ check_func  ${malloc_prefix}memalign&& enable 
memalign
 check_func  mkstemp
 check_func  mmap
 check_func  ${malloc_prefix}posix_memalign  && enable posix_memalign
+check_func_headers malloc.h _aligned_malloc && enable aligned_malloc
 check_func  setrlimit
 check_func  strerror_r
 check_func  strptime
@@ -3139,7 +3141,7 @@ check_deps $CONFIG_LIST   \
 
 enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
 
-! enabled_any memalign posix_memalign &&
+! enabled_any memalign posix_memalign aligned_malloc &&
 enabled_any $need_memalign && enable memalign_hack
 
 echo "install prefix$prefix"
diff --git a/libavutil/mem.c b/libavutil/mem.c
index bf1a542..0fe9f54 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -84,6 +84,8 @@ void *av_malloc(size_t size)
 #elif HAVE_POSIX_MEMALIGN
 if (posix_memalign(&ptr,32,size))
 ptr = NULL;
+#elif HAVE_ALIGNED_MALLOC
+ptr = _aligned_malloc(size, 32);
 #elif HAVE_MEMALIGN
 ptr = memalign(32,size);
 /* Why 64?
@@ -131,6 +133,8 @@ void *av_realloc(void *ptr, size_t size)
 if(!ptr) return av_malloc(size);
 diff= ((char*)ptr)[-1];
 return (char*)realloc((char*)ptr - diff, size + diff) + diff;
+#elif HAVE_ALIGNED_MALLOC
+return _aligned_realloc(ptr, size, 32);
 #else
 return realloc(ptr, size);
 #endif
@@ -141,6 +145,8 @@ void av_free(void *ptr)
 #if CONFIG_MEMALIGN_HACK
 if (ptr)
 free((char*)ptr - ((char*)ptr)[-1]);
+#elif HAVE_ALIGNED_MALLOC
+_aligned_free(ptr);
 #else
 free(ptr);
 #endif
-- 
1.7.9.5

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Måns Rullgård
Martin Storsjö  writes:

> From: "Ronald S. Bultje" 
>
> The check uses check_func_header, since this function is
> conditionally available depending on the targeted MSVCRT
> version.
> ---
>  configure   |4 +++-
>  libavutil/mem.c |6 ++
>  2 files changed, 9 insertions(+), 1 deletion(-)

LGTM

Were you able to test this both with and without the function visible?

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Måns Rullgård wrote:


Martin Storsjö  writes:


From: "Ronald S. Bultje" 

The check uses check_func_header, since this function is
conditionally available depending on the targeted MSVCRT
version.
---
 configure   |4 +++-
 libavutil/mem.c |6 ++
 2 files changed, 9 insertions(+), 1 deletion(-)


LGTM

Were you able to test this both with and without the function visible?


Yes, if I added --extra-cflags=-D__MSVCRT_VERSION__=0x700, the function is 
detected, and the test fails without it.


// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] flvdec: remove incomplete, disabled seeking code

2012-06-18 Thread Diego Biurrun
On Mon, Jun 18, 2012 at 03:22:56PM +0100, Mans Rullgard wrote:
> 
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -749,33 +749,6 @@ static int flv_read_seek(AVFormatContext *s, int 
> stream_index,
>  
> -#if 0 /* don't know enough to implement this */
> -static int flv_read_seek2(AVFormatContext *s, int stream_index,
> -int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
> -{
> -int ret = AVERROR(ENOSYS);
> -
> -if (ts - min_ts > (uint64_t)(max_ts - ts)) flags |= AVSEEK_FLAG_BACKWARD;
> -
> -if (!s->pb->seekable) {
> -if (stream_index < 0) {
> -stream_index = av_find_default_stream_index(s);
> -if (stream_index < 0)
> -return -1;
> -
> -/* timestamp for default must be expressed in AV_TIME_BASE units 
> */
> -ts = av_rescale_rnd(ts, 1000, AV_TIME_BASE,
> -flags & AVSEEK_FLAG_BACKWARD ? AV_ROUND_DOWN : AV_ROUND_UP);
> -}
> -ret = avio_seek_time(s->pb, stream_index, ts, flags);
> -}
> -
> -if (ret == AVERROR(ENOSYS))
> -ret = av_seek_frame(s, stream_index, ts, flags);
> -return ret;
> -}
> -#endif
> -
> @@ -784,9 +757,6 @@ AVInputFormat ff_flv_demuxer = {
>  .read_packet= flv_read_packet,
>  .read_seek  = flv_read_seek,
> -#if 0
> -.read_seek2 = flv_read_seek2,
> -#endif
>  .read_close = flv_read_close,
>  .extensions = "flv",

I sent this same thing ages ago :)

https://patches.libav.org/patch/6548/

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Måns Rullgård
Martin Storsjö  writes:

> On Mon, 18 Jun 2012, Måns Rullgård wrote:
>
>> Martin Storsjö  writes:
>>
>>> From: "Ronald S. Bultje" 
>>>
>>> The check uses check_func_header, since this function is
>>> conditionally available depending on the targeted MSVCRT
>>> version.
>>> ---
>>>  configure   |4 +++-
>>>  libavutil/mem.c |6 ++
>>>  2 files changed, 9 insertions(+), 1 deletion(-)
>>
>> LGTM
>>
>> Were you able to test this both with and without the function visible?
>
> Yes, if I added --extra-cflags=-D__MSVCRT_VERSION__=0x700, the

What does that version number signify?

> function is detected, and the test fails without it.

Great, patch seems good to go then.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 05/12] flvdec: remove disabled code

2012-06-18 Thread Måns Rullgård
Diego Biurrun  writes:

> ---
>  libavformat/flvdec.c |   30 --
>  1 files changed, 0 insertions(+), 30 deletions(-)

LGTM

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] rtsp: Send mode=record instead of mode=receive

2012-06-18 Thread Jordi Ortiz
2012/6/18 Martin Storsjö 

> This seems to be the correct mode to send, according to the
> original RTSP RFC, and matches the method RECORD which is
> sent later when starting to send data.
>
> Darwin Streaming Server works fine with either of them.
> ---
>  libavformat/rtsp.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

OK
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Måns Rullgård wrote:


Martin Storsjö  writes:


On Mon, 18 Jun 2012, Måns Rullgård wrote:


Martin Storsjö  writes:


From: "Ronald S. Bultje" 

The check uses check_func_header, since this function is
conditionally available depending on the targeted MSVCRT
version.
---
 configure   |4 +++-
 libavutil/mem.c |6 ++
 2 files changed, 9 insertions(+), 1 deletion(-)


LGTM

Were you able to test this both with and without the function visible?


Yes, if I added --extra-cflags=-D__MSVCRT_VERSION__=0x700, the


What does that version number signify?


MS Visual C runtime version, which corresponds to the Visual C++ version 
that provided that runtime. The default runtime for mingw is 6.0, 
implemented by "msvcrt.dll", from Visual C++ 6.0 (from just around the 
stone age). Visual C++ 7.0 (2003 I think) seems to have added this 
function.


// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Måns Rullgård
Martin Storsjö  writes:

> On Mon, 18 Jun 2012, Måns Rullgård wrote:
>
>> Martin Storsjö  writes:
>>
>>> On Mon, 18 Jun 2012, Måns Rullgård wrote:
>>>
 Martin Storsjö  writes:

> From: "Ronald S. Bultje" 
>
> The check uses check_func_header, since this function is
> conditionally available depending on the targeted MSVCRT
> version.
> ---
>  configure   |4 +++-
>  libavutil/mem.c |6 ++
>  2 files changed, 9 insertions(+), 1 deletion(-)

 LGTM

 Were you able to test this both with and without the function visible?
>>>
>>> Yes, if I added --extra-cflags=-D__MSVCRT_VERSION__=0x700, the
>>
>> What does that version number signify?
>
> MS Visual C runtime version, which corresponds to the Visual C++
> version that provided that runtime. The default runtime for mingw is
> 6.0, implemented by "msvcrt.dll", from Visual C++ 6.0 (from just
> around the stone age). Visual C++ 7.0 (2003 I think) seems to have
> added this function.

So what does this mean in terms of which systems a binary built
with/without that flag will run on?

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Diego Elio Pettenò
Il 18/06/2012 18:28, Måns Rullgård ha scritto:
> So what does this mean in terms of which systems a binary built
> with/without that flag will run on?

As far as I can tell, even version 7 is compatible with 2k and later. I
think it's 2010 that starts killing anything below XP.

-- 
Diego Elio Pettenò — Flameeyes
flamee...@flameeyes.eu — http://blog.flameeyes.eu/


___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Måns Rullgård
Diego Elio Pettenò  writes:

> Il 18/06/2012 18:28, Måns Rullgård ha scritto:
>> So what does this mean in terms of which systems a binary built
>> with/without that flag will run on?
>
> As far as I can tell, even version 7 is compatible with 2k and later.

If that's the case, we should consider adding that flag by default.
IIRC we already require 2k for something else.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Alex Converse
On Mon, Jun 18, 2012 at 9:33 AM, Måns Rullgård  wrote:
>
> Diego Elio Pettenò  writes:
>
> > Il 18/06/2012 18:28, Måns Rullgård ha scritto:
> >> So what does this mean in terms of which systems a binary built
> >> with/without that flag will run on?
> >
> > As far as I can tell, even version 7 is compatible with 2k and later.
>
> If that's the case, we should consider adding that flag by default.
> IIRC we already require 2k for something else.
>

I'm not trying to advocate a particular position here, but here is a
little bit of background on msvcrt vs versioned runtimes:

http://msdn.microsoft.com/en-us/library/abx4dbyh(VS.71).aspx :

What is the difference between msvcrt.dll and msvcr71.dll?

The msvcrt.dll is now a "known DLL," meaning that it is a system
component owned and built by Windows. It is intended for future use
only by system-level components. An application should use and
redistribute msvcr71.dll, and it should avoid placing a copy or using
an existing copy of msvcr71.dll in the system directory. Instead, the
application should keep a copy of msvcr71.dll in its application
directory with the program executable. Any application built with
Visual C++ .NET using the /MD switch will necessarily use msvcr71.dll.

http://www.xchat-wdk.org/developers/kk-s-article

Long and detailed
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] Change all uses of restrict to use av_restrict instead.

2012-06-18 Thread Reinhard Tartler
On Mon, Jun 18, 2012 at 3:26 PM, Diego Biurrun  wrote:

>> I wish to support a compiler that does not support c99. Shall we work
>> together and make that happen or shall we just cry like little zealous
>> babies while the real world passes by?
>
> Comments like this are not exactly helping, but you know that.
>
> Let's instead cooperate on getting the sensible parts of this patch in.

Just to clarify, does this imply that you reject Ronald's goal of
having "resonable MSVC support in libav proper"?

-- 
regards,
    Reinhard
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Alex Converse wrote:


On Mon, Jun 18, 2012 at 9:33 AM, Måns Rullgård  wrote:


Diego Elio Pettenò  writes:

> Il 18/06/2012 18:28, Måns Rullgård ha scritto:
>> So what does this mean in terms of which systems a binary built
>> with/without that flag will run on?
>
> As far as I can tell, even version 7 is compatible with 2k and later.

If that's the case, we should consider adding that flag by default.
IIRC we already require 2k for something else.



I'm not trying to advocate a particular position here, but here is a
little bit of background on msvcrt vs versioned runtimes:

http://msdn.microsoft.com/en-us/library/abx4dbyh(VS.71).aspx :

What is the difference between msvcrt.dll and msvcr71.dll?

The msvcrt.dll is now a "known DLL," meaning that it is a system
component owned and built by Windows. It is intended for future use
only by system-level components. An application should use and
redistribute msvcr71.dll, and it should avoid placing a copy or using
an existing copy of msvcr71.dll in the system directory. Instead, the
application should keep a copy of msvcr71.dll in its application
directory with the program executable. Any application built with
Visual C++ .NET using the /MD switch will necessarily use msvcr71.dll.


That does make sense and fits my picture on how one is supposed to do 
things on windows. The mingw default of using the plain msvcrt.dll matches 
the unix style more then, where you use whatever libc the system happens 
to have. Mingw seems to have link libraries for all those versioned 
runtimes, too, so I guess it's possible to choose the runtime to link to, 
in some way.


Anyway, I guess nobody is opposed to this patch going in as is, the 
default targeted version would be a separate patch.


// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Derek Buitenhuis
On 18/06/2012 1:35 PM, Martin Storsjö wrote:
>> I'm not trying to advocate a particular position here, but here is a
>> > little bit of background on msvcrt vs versioned runtimes:
>> >
>> > http://msdn.microsoft.com/en-us/library/abx4dbyh(VS.71).aspx :
>> >
>> > What is the difference between msvcrt.dll and msvcr71.dll?
>> >
>> > The msvcrt.dll is now a "known DLL," meaning that it is a system
>> > component owned and built by Windows. It is intended for future use
>> > only by system-level components. An application should use and
>> > redistribute msvcr71.dll, and it should avoid placing a copy or using
>> > an existing copy of msvcr71.dll in the system directory. Instead, the
>> > application should keep a copy of msvcr71.dll in its application
>> > directory with the program executable. Any application built with
>> > Visual C++ .NET using the /MD switch will necessarily use msvcr71.dll.
> That does make sense and fits my picture on how one is supposed to do 
> things on windows. The mingw default of using the plain msvcrt.dll matches 
> the unix style more then, where you use whatever libc the system happens 
> to have. Mingw seems to have link libraries for all those versioned 
> runtimes, too, so I guess it's possible to choose the runtime to link to, 
> in some way.
> 
> Anyway, I guess nobody is opposed to this patch going in as is, the 
> default targeted version would be a separate patch.

Is there any problem with just using /MT and requiring and MSVC
version from this decade to build? This all seems very dumb and
roundabout.

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] dxva2: add missing include.

2012-06-18 Thread Måns Rullgård
"Ronald S. Bultje"  writes:

> Hi,
>
> On Thu, Jun 14, 2012 at 4:09 PM, Jean-Baptiste Kempf  
> wrote:
>> On Thu, Jun 14, 2012 at 04:05:40PM -0700, Ronald S. Bultje wrote :
>>> > This should break every mingw compilation.
>>>
>>> Why? Is the header un-mingw'y?
>>
>> AFAIK, no Mingw installation has it.
>>
>> Especially since dxva.h is about DxVA, and libavcodec uses DxVA2.
>
> dxva.h on MSVC defines basic structs like DXVA_PicParams, which are
> required by our dxva implementations. How do I distinguish between the
> two versions so I know whether two include  or not?

Would adding a configure check for dxva.h and including it conditionally
work everywhere?

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Måns Rullgård
Derek Buitenhuis  writes:

> On 18/06/2012 1:35 PM, Martin Storsjö wrote:
>>> I'm not trying to advocate a particular position here, but here is a
>>> > little bit of background on msvcrt vs versioned runtimes:
>>> >
>>> > http://msdn.microsoft.com/en-us/library/abx4dbyh(VS.71).aspx :
>>> >
>>> > What is the difference between msvcrt.dll and msvcr71.dll?
>>> >
>>> > The msvcrt.dll is now a "known DLL," meaning that it is a system
>>> > component owned and built by Windows. It is intended for future use
>>> > only by system-level components. An application should use and
>>> > redistribute msvcr71.dll, and it should avoid placing a copy or using
>>> > an existing copy of msvcr71.dll in the system directory. Instead, the
>>> > application should keep a copy of msvcr71.dll in its application
>>> > directory with the program executable. Any application built with
>>> > Visual C++ .NET using the /MD switch will necessarily use msvcr71.dll.
>> That does make sense and fits my picture on how one is supposed to do 
>> things on windows. The mingw default of using the plain msvcrt.dll matches 
>> the unix style more then, where you use whatever libc the system happens 
>> to have. Mingw seems to have link libraries for all those versioned 
>> runtimes, too, so I guess it's possible to choose the runtime to link to, 
>> in some way.
>> 
>> Anyway, I guess nobody is opposed to this patch going in as is, the 
>> default targeted version would be a separate patch.
>
> Is there any problem with just using /MT

What does that do?

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Derek Buitenhuis
On 18/06/2012 2:41 PM, Måns Rullgård wrote:
> What does that do?

Static msvcrt linkage (no reliance on msvcrXX.dll).

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Måns Rullgård
Derek Buitenhuis  writes:

> On 18/06/2012 2:41 PM, Måns Rullgård wrote:
>> What does that do?
>
> Static msvcrt linkage (no reliance on msvcrXX.dll).

And how does that relate to the patch at hand?  Does it magically
provide one of the already supported memalign() variants?

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Måns Rullgård wrote:


Derek Buitenhuis  writes:


On 18/06/2012 2:41 PM, Måns Rullgård wrote:

What does that do?


Static msvcrt linkage (no reliance on msvcrXX.dll).


And how does that relate to the patch at hand?  Does it magically
provide one of the already supported memalign() variants?


If one were to be using MSVC, one wouldn't have to compromise with the 
baseline runtime to target, since the runtime is built in.


However, that's not related to the patch at all. And for mingw, one can't 
statically link the runtime.


For mingw however, there apparently is a __mingw_aligned_malloc which does 
about the same, and is included in the small mingw runtime which indeed is 
statically linked. So we can add a separate function check for that one 
(patch coming up soon) and use it if found - then the target msvcrt 
version wouldn't matter at all for this.


// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/7] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Luca Barbato
On 06/18/2012 03:57 PM, Måns Rullgård wrote:
> I was going to suggest dropping the ${malloc_prefix} here.  This feature
> exists so the standard allocator can be replaced by a custom one, and
> there's no reason why a custom allocator can't use the standard
> interface.

Makes sense.

lu

-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for _aligned_malloc() as found on Windows

2012-06-18 Thread Derek Buitenhuis
On 18/06/2012 2:57 PM, Martin Storsjö wrote:
> On Mon, 18 Jun 2012, Måns Rullgård wrote:
> 
>> Derek Buitenhuis  writes:
>>
>>> On 18/06/2012 2:41 PM, Måns Rullgård wrote:
 What does that do?
>>>
>>> Static msvcrt linkage (no reliance on msvcrXX.dll).
>>
>> And how does that relate to the patch at hand?  Does it magically
>> provide one of the already supported memalign() variants?

Sorry, it is indeed unrelated. Ignore the /MT bit then.

My apologies. I need to push some coffee onto my brain.

> If one were to be using MSVC, one wouldn't have to compromise with the 
> baseline runtime to target, since the runtime is built in.
> 
> However, that's not related to the patch at all. And for mingw, one can't 
> statically link the runtime.

Ditto.

> For mingw however, there apparently is a __mingw_aligned_malloc which does 
> about the same, and is included in the small mingw runtime which indeed is 
> statically linked. So we can add a separate function check for that one 
> (patch coming up soon) and use it if found - then the target msvcrt 
> version wouldn't matter at all for this.

Yeah, this has been discussed on IRC... i was just going to shoot at email
about it off ;).

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] mxfdec: replace right-shift by av_log2(foo) with division by foo

2012-06-18 Thread Mans Rullgard
From: "Ronald S. Bultje" 

Since all operands involved are constants, the division can be
computed at compile time whereas av_log2() cannot.
---
 libavformat/mxfdec.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index dd10240..15a0ac0 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1084,7 +1084,7 @@ static int mxf_compute_ptses_fake_index(MXFContext *mxf, 
MXFIndexTable *index_ta
 if (index_table->nb_ptses <= 0)
 return 0;
 
-if (index_table->nb_ptses > INT_MAX >> av_log2(sizeof(AVIndexEntry)) + 1)
+if (index_table->nb_ptses > INT_MAX / sizeof(AVIndexEntry))
 return AVERROR(ENOMEM);
 
 index_table->ptses  = av_mallocz(index_table->nb_ptses *
@@ -1196,7 +1196,7 @@ static int mxf_compute_index_tables(MXFContext *mxf)
 }
 }
 
-if (mxf->nb_index_tables > INT_MAX >> av_log2(sizeof(MXFIndexTable)) + 1 ||
+if (mxf->nb_index_tables > INT_MAX / sizeof(MXFIndexTable) ||
 !(mxf->index_tables = av_mallocz(mxf->nb_index_tables *
  sizeof(MXFIndexTable {
 av_log(mxf->fc, AV_LOG_ERROR, "failed to allocate index tables\n");
-- 
1.7.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mxfdec: replace right-shift by av_log2(foo) with division by foo

2012-06-18 Thread Luca Barbato
On 06/18/2012 09:18 PM, Mans Rullgard wrote:
> From: "Ronald S. Bultje" 
> 
> Since all operands involved are constants, the division can be
> computed at compile time whereas av_log2() cannot.
> ---
>  libavformat/mxfdec.c |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Ok.

-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mxfdec: replace right-shift by av_log2(foo) with division by foo

2012-06-18 Thread Kostya Shishkov
On Mon, Jun 18, 2012 at 08:18:38PM +0100, Mans Rullgard wrote:
> From: "Ronald S. Bultje" 
> 
> Since all operands involved are constants, the division can be
> computed at compile time whereas av_log2() cannot.
> ---
>  libavformat/mxfdec.c |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index dd10240..15a0ac0 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -1084,7 +1084,7 @@ static int mxf_compute_ptses_fake_index(MXFContext 
> *mxf, MXFIndexTable *index_ta
>  if (index_table->nb_ptses <= 0)
>  return 0;
>  
> -if (index_table->nb_ptses > INT_MAX >> av_log2(sizeof(AVIndexEntry)) + 1)
> +if (index_table->nb_ptses > INT_MAX / sizeof(AVIndexEntry))
>  return AVERROR(ENOMEM);
>  
>  index_table->ptses  = av_mallocz(index_table->nb_ptses *
> @@ -1196,7 +1196,7 @@ static int mxf_compute_index_tables(MXFContext *mxf)
>  }
>  }
>  
> -if (mxf->nb_index_tables > INT_MAX >> av_log2(sizeof(MXFIndexTable)) + 1 
> ||
> +if (mxf->nb_index_tables > INT_MAX / sizeof(MXFIndexTable) ||
>  !(mxf->index_tables = av_mallocz(mxf->nb_index_tables *
>   sizeof(MXFIndexTable {
>  av_log(mxf->fc, AV_LOG_ERROR, "failed to allocate index tables\n");
> -- 

Isn't it / (sizeof(elem) * 2) ?
Otherwise LGTM
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] mem: add support for __mingw_aligned_malloc()

2012-06-18 Thread Martin Storsjö
This function is like _aligned_malloc(), but part of the statically
linked mingw runtime, so it's available regardless of the targeted
MSVCRT version.
---
 configure   |4 +++-
 libavutil/mem.c |6 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 0baa755..16cadd5 100755
--- a/configure
+++ b/configure
@@ -1109,6 +1109,7 @@ HAVE_LIST="
 malloc_h
 MapViewOfFile
 memalign
+mingw_aligned_malloc
 mkstemp
 mmap
 netinet_sctp_h
@@ -2840,6 +2841,7 @@ check_func  mkstemp
 check_func  mmap
 check_func  ${malloc_prefix}posix_memalign  && enable posix_memalign
 check_func_headers malloc.h _aligned_malloc && enable aligned_malloc
+check_func  __mingw_aligned_malloc  && enable mingw_aligned_malloc
 check_func  setrlimit
 check_func  strerror_r
 check_func  strptime
@@ -3146,7 +3148,7 @@ check_deps $CONFIG_LIST   \
 
 enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
 
-! enabled_any memalign posix_memalign aligned_malloc &&
+! enabled_any memalign posix_memalign aligned_malloc mingw_aligned_malloc &&
 enabled_any $need_memalign && enable memalign_hack
 
 echo "install prefix$prefix"
diff --git a/libavutil/mem.c b/libavutil/mem.c
index 0fe9f54..79fb179 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -86,6 +86,8 @@ void *av_malloc(size_t size)
 ptr = NULL;
 #elif HAVE_ALIGNED_MALLOC
 ptr = _aligned_malloc(size, 32);
+#elif HAVE_MINGW_ALIGNED_MALLOC
+ptr = __mingw_aligned_malloc(size, 32);
 #elif HAVE_MEMALIGN
 ptr = memalign(32,size);
 /* Why 64?
@@ -135,6 +137,8 @@ void *av_realloc(void *ptr, size_t size)
 return (char*)realloc((char*)ptr - diff, size + diff) + diff;
 #elif HAVE_ALIGNED_MALLOC
 return _aligned_realloc(ptr, size, 32);
+#elif HAVE_MINGW_ALIGNED_MALLOC
+return __mingw_aligned_realloc(ptr, size, 32);
 #else
 return realloc(ptr, size);
 #endif
@@ -147,6 +151,8 @@ void av_free(void *ptr)
 free((char*)ptr - ((char*)ptr)[-1]);
 #elif HAVE_ALIGNED_MALLOC
 _aligned_free(ptr);
+#elif HAVE_MINGW_ALIGNED_MALLOC
+__mingw_aligned_free(ptr);
 #else
 free(ptr);
 #endif
-- 
1.7.9.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for __mingw_aligned_malloc()

2012-06-18 Thread Måns Rullgård
Martin Storsjö  writes:

> This function is like _aligned_malloc(), but part of the statically
> linked mingw runtime, so it's available regardless of the targeted
> MSVCRT version.
> ---
>  configure   |4 +++-
>  libavutil/mem.c |6 ++
>  2 files changed, 9 insertions(+), 1 deletion(-)

The question is, do we care about msvcrt versions that don't have
_aligned_malloc?  If not, selecting a recent enough msvcrt version (by
adding the appropriate -D flag) achieves the same goal without the
clutter.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mxfdec: replace right-shift by av_log2(foo) with division by foo

2012-06-18 Thread Måns Rullgård
Kostya Shishkov  writes:

> On Mon, Jun 18, 2012 at 08:18:38PM +0100, Mans Rullgard wrote:
>> From: "Ronald S. Bultje" 
>> 
>> Since all operands involved are constants, the division can be
>> computed at compile time whereas av_log2() cannot.
>> ---
>>  libavformat/mxfdec.c |4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
>> index dd10240..15a0ac0 100644
>> --- a/libavformat/mxfdec.c
>> +++ b/libavformat/mxfdec.c
>> @@ -1084,7 +1084,7 @@ static int mxf_compute_ptses_fake_index(MXFContext 
>> *mxf, MXFIndexTable *index_ta
>>  if (index_table->nb_ptses <= 0)
>>  return 0;
>>  
>> -if (index_table->nb_ptses > INT_MAX >> av_log2(sizeof(AVIndexEntry)) + 
>> 1)
>> +if (index_table->nb_ptses > INT_MAX / sizeof(AVIndexEntry))
>>  return AVERROR(ENOMEM);
>>  
>>  index_table->ptses  = av_mallocz(index_table->nb_ptses *
>> @@ -1196,7 +1196,7 @@ static int mxf_compute_index_tables(MXFContext *mxf)
>>  }
>>  }
>>  
>> -if (mxf->nb_index_tables > INT_MAX >> av_log2(sizeof(MXFIndexTable)) + 
>> 1 ||
>> +if (mxf->nb_index_tables > INT_MAX / sizeof(MXFIndexTable) ||
>>  !(mxf->index_tables = av_mallocz(mxf->nb_index_tables *
>>   sizeof(MXFIndexTable {
>>  av_log(mxf->fc, AV_LOG_ERROR, "failed to allocate index tables\n");
>> -- 
>
> Isn't it / (sizeof(elem) * 2) ?

Yes, although I wonder where that came from.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for __mingw_aligned_malloc()

2012-06-18 Thread Martin Storsjö

On Mon, 18 Jun 2012, Måns Rullgård wrote:


Martin Storsjö  writes:


This function is like _aligned_malloc(), but part of the statically
linked mingw runtime, so it's available regardless of the targeted
MSVCRT version.
---
 configure   |4 +++-
 libavutil/mem.c |6 ++
 2 files changed, 9 insertions(+), 1 deletion(-)


The question is, do we care about msvcrt versions that don't have
_aligned_malloc?  If not, selecting a recent enough msvcrt version (by
adding the appropriate -D flag) achieves the same goal without the
clutter.


That's a valid point.

I checked, and it doesn't seem to be present in the Win2k version of 
msvcrt.dll, and I think we still run on that platform.


// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for __mingw_aligned_malloc()

2012-06-18 Thread Måns Rullgård
Martin Storsjö  writes:

> On Mon, 18 Jun 2012, Måns Rullgård wrote:
>
>> Martin Storsjö  writes:
>>
>>> This function is like _aligned_malloc(), but part of the statically
>>> linked mingw runtime, so it's available regardless of the targeted
>>> MSVCRT version.
>>> ---
>>>  configure   |4 +++-
>>>  libavutil/mem.c |6 ++
>>>  2 files changed, 9 insertions(+), 1 deletion(-)
>>
>> The question is, do we care about msvcrt versions that don't have
>> _aligned_malloc?  If not, selecting a recent enough msvcrt version (by
>> adding the appropriate -D flag) achieves the same goal without the
>> clutter.
>
> That's a valid point.
>
> I checked, and it doesn't seem to be present in the Win2k version of
> msvcrt.dll, and I think we still run on that platform.

Maybe it's time to drop win2k support.  Does anyone actually still use it?

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for __mingw_aligned_malloc()

2012-06-18 Thread Derek Buitenhuis
On 18/06/2012 4:04 PM, Måns Rullgård wrote:
> Maybe it's time to drop win2k support.  Does anyone actually still use it?

I think we should. MS doesn't even support it anymore. If someone
is using it, they're already using unpatched and unsupported
software.

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] lavc: Extend the documentation for avcodec_init_packet

2012-06-18 Thread Martin Storsjö
From: "Simon A. Eugster" 

Add a note that pkt->data and pkt->size must be initialized.
---
 libavcodec/avcodec.h |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 94c2ed7..63f2fc8 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3284,6 +3284,17 @@ void av_destruct_packet(AVPacket *pkt);
 /**
  * Initialize optional fields of a packet with default values.
  *
+ * Note, this does not touch the data and size members, which have to be
+ * initialized separately.
+ * \code{.cpp}
+// [...]
+AVPacket pkt;
+av_init_packet(&pkt);
+pkt.data = NULL;
+pkt.size = 0;
+avcodec_encode_video2(codec, &pkt, picture, &ok);
+ * \endcode
+ *
  * @param pkt packet
  */
 void av_init_packet(AVPacket *pkt);
-- 
1.7.9.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mem: add support for __mingw_aligned_malloc()

2012-06-18 Thread Sean McGovern
On Monday, June 18, 2012, Derek Buitenhuis 
wrote:
> On 18/06/2012 4:04 PM, Måns Rullgård wrote:
>> Maybe it's time to drop win2k support.  Does anyone actually still use
it?
>
> I think we should. MS doesn't even support it anymore. If someone
> is using it, they're already using unpatched and unsupported
> software.

Aye, extended support for Win2K ended in 2005.

-- Sean McG.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] lavc: Extend the documentation for avcodec_init_packet

2012-06-18 Thread Justin Ruggles
On 06/18/2012 04:19 PM, Martin Storsjö wrote:
> From: "Simon A. Eugster" 
> 
> Add a note that pkt->data and pkt->size must be initialized.
> ---
>  libavcodec/avcodec.h |   11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 94c2ed7..63f2fc8 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -3284,6 +3284,17 @@ void av_destruct_packet(AVPacket *pkt);
>  /**
>   * Initialize optional fields of a packet with default values.
>   *
> + * Note, this does not touch the data and size members, which have to be
> + * initialized separately.
> + * \code{.cpp}
> +// [...]
> +AVPacket pkt;
> +av_init_packet(&pkt);
> +pkt.data = NULL;
> +pkt.size = 0;
> +avcodec_encode_video2(codec, &pkt, picture, &ok);
> + * \endcode
> + *
>   * @param pkt packet
>   */
>  void av_init_packet(AVPacket *pkt);

I don't think the example code really adds anything useful here. The
note looks fine though.

-Justin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 4/4] lavr: resampling: add support for s32p, fltp, and dblp internal sample formats

2012-06-18 Thread Justin Ruggles
Based partially on implementation by Michael Niedermayer  in
libswresample in FFmpeg. See commits:
7f1ae79d38c4edba9dbd31d7bf797e525298ac55
24ab1abfb6d55bf330022df4b10d7aec80b3f116
---
Changed the RENAME macro to SET_TYPE per Diego's request.

 libavresample/resample.c  |  163 +
 libavresample/resample_template.c |  102 +++
 libavresample/utils.c |   22 +-
 3 files changed, 199 insertions(+), 88 deletions(-)
 create mode 100644 libavresample/resample_template.c

diff --git a/libavresample/resample.c b/libavresample/resample.c
index 7316e4e..1c3d13a 100644
--- a/libavresample/resample.c
+++ b/libavresample/resample.c
@@ -24,34 +24,10 @@
 #include "internal.h"
 #include "audio_data.h"
 
-#ifdef CONFIG_RESAMPLE_FLT
-/* float template */
-#define FILTER_SHIFT  0
-#define FELEM float
-#define FELEM2float
-#define FELEMLfloat
-#elifdef CONFIG_RESAMPLE_S32
-/* s32 template */
-#define FILTER_SHIFT  30
-#define FELEM int32_t
-#define FELEM2int64_t
-#define FELEMLint64_t
-#define FELEM_MAX INT32_MAX
-#define FELEM_MIN INT32_MIN
-#else
-/* s16 template */
-#define FILTER_SHIFT  15
-#define FELEM int16_t
-#define FELEM2int32_t
-#define FELEMLint64_t
-#define FELEM_MAX INT16_MAX
-#define FELEM_MIN INT16_MIN
-#endif
-
 struct ResampleContext {
 AVAudioResampleContext *avr;
 AudioData *buffer;
-FELEM *filter_bank;
+uint8_t *filter_bank;
 int filter_length;
 int ideal_dst_incr;
 int dst_incr;
@@ -65,8 +41,32 @@ struct ResampleContext {
 enum AVResampleFilterType filter_type;
 int kaiser_beta;
 double factor;
+void (*set_filter)(void *filter, double *tab, int phase, int tap_count);
+void (*resample_one)(struct ResampleContext *c, int no_filter, void *dst0,
+ int dst_index, const void *src0, int src_size,
+ int index, int frac);
 };
 
+
+/* double template */
+#define CONFIG_RESAMPLE_DBL
+#include "resample_template.c"
+#undef CONFIG_RESAMPLE_DBL
+
+/* float template */
+#define CONFIG_RESAMPLE_FLT
+#include "resample_template.c"
+#undef CONFIG_RESAMPLE_FLT
+
+/* s32 template */
+#define CONFIG_RESAMPLE_S32
+#include "resample_template.c"
+#undef CONFIG_RESAMPLE_S32
+
+/* s16 template */
+#include "resample_template.c"
+
+
 /**
  * 0th order modified bessel function of the first kind.
  */
@@ -98,13 +98,13 @@ static double bessel(double x)
  * @param  kaiser_beta  kaiser window beta
  * @return  0 on success, negative AVERROR code on failure
  */
-static int build_filter(FELEM *filter, double factor, int tap_count,
-int phase_count, int scale, int filter_type,
-int kaiser_beta)
+static int build_filter(ResampleContext *c)
 {
 int ph, i;
-double x, y, w;
+double x, y, w, factor;
 double *tab;
+int tap_count= c->filter_length;
+int phase_count  = 1 << c->phase_shift;
 const int center = (tap_count - 1) / 2;
 
 tab = av_malloc(tap_count * sizeof(*tab));
@@ -112,8 +112,7 @@ static int build_filter(FELEM *filter, double factor, int 
tap_count,
 return AVERROR(ENOMEM);
 
 /* if upsampling, only need to interpolate, no filter */
-if (factor > 1.0)
-factor = 1.0;
+factor = FFMIN(c->factor, 1.0);
 
 for (ph = 0; ph < phase_count; ph++) {
 double norm = 0;
@@ -121,7 +120,7 @@ static int build_filter(FELEM *filter, double factor, int 
tap_count,
 x = M_PI * ((double)(i - center) - (double)ph / phase_count) * 
factor;
 if (x == 0) y = 1.0;
 elsey = sin(x) / x;
-switch (filter_type) {
+switch (c->filter_type) {
 case AV_RESAMPLE_FILTER_TYPE_CUBIC: {
 const float d = -0.5; //first order derivative = -0.5
 x = fabs(((double)(i - center) - (double)ph / phase_count) * 
factor);
@@ -137,23 +136,18 @@ static int build_filter(FELEM *filter, double factor, int 
tap_count,
 break;
 case AV_RESAMPLE_FILTER_TYPE_KAISER:
 w  = 2.0 * x / (factor * tap_count * M_PI);
-y *= bessel(kaiser_beta * sqrt(FFMAX(1 - w * w, 0)));
+y *= bessel(c->kaiser_beta * sqrt(FFMAX(1 - w * w, 0)));
 break;
 }
 
 tab[i] = y;
 norm  += y;
 }
-
 /* normalize so that an uniform color remains the same */
-for (i = 0; i < tap_count; i++) {
-#ifdef CONFIG_RESAMPLE_FLT
-filter[ph * tap_count + i] = tab[i] / norm;
-#else
-filter[ph * tap_count + i] = av_clip(lrintf(tab[i] * scale / norm),
- FELEM_MIN, FELEM_MAX);
-#endif
-}
+for (i = 0; i < tap_count; i++)
+tab[i] = tab[i] / norm;
+
+c->set_filter(c->filter_bank, 

Re: [libav-devel] [PATCH] af_amix: move per-input MixContext fields into a separate struct

2012-06-18 Thread Justin Ruggles
On 06/10/2012 05:50 PM, Justin Ruggles wrote:
> simplifies allocation
> ---
> Fixed a memleak in the previous patch.
> 
>  libavfilter/af_amix.c |   77 
> +++--
>  1 files changed, 36 insertions(+), 41 deletions(-)

ping.

-Justin

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] x32 status

2012-06-18 Thread Diego Elio Pettenò
Since Gentoo now has some kind of support for x32 I was able to get a
system running with it.

Seems like it's going to be a trainwreck:

 - sizeof(void*) == sizeof(long) == sizeof(sizeof(0)) == 4
   which means we really have no way to find out whether this is
   32-bit or 64-bit;

 - afaict yasm does not have support for x32 so we're stuck without
   yasm;

 - in general it's a bloody mess.

-- 
Diego Elio Pettenò — Flameeyes
flamee...@flameeyes.eu — http://blog.flameeyes.eu/

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] x32 status

2012-06-18 Thread Måns Rullgård
Diego Elio Pettenò  writes:

> Since Gentoo now has some kind of support for x32 I was able to get a
> system running with it.
>
> Seems like it's going to be a trainwreck:
>
>  - sizeof(void*) == sizeof(long) == sizeof(sizeof(0)) == 4
>which means we really have no way to find out whether this is
>32-bit or 64-bit;
>
>  - afaict yasm does not have support for x32 so we're stuck without
>yasm;
>
>  - in general it's a bloody mess.

Add to this that the inline asm probably doesn't even remotely work
properly, if it even compiles, with the x32 ABI.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


  1   2   >