Re: [libav-devel] [PATCH V4 0/4] Support for HDMV Interactive Graphics Stream

2012-06-17 Thread David Girault
No comments on parts 2 to 4 of this patchset?

Regards,
David

Le jeudi 07 juin 2012 à 11:38 +0200, David Girault a écrit :
> New version (V4) of HDMV Interactive Graphics Stream support patch.
> More test were done and detected issue were addressed.
> 
> Tests was done with the x264 demo disk found here:
>  http://x264dev.multimedia.cx/archives/328
> Direct link to torrent file to download:
>  http://x264.nl/x264_Demo_Blu-ray.torrent
> 
> Other tests were done with bluray demo disks, especially the one from 
> AVSForum that use huge menu:
>  
> http://www.avsforum.com/t/1391873/reference-blu-ray-demo-disc-bd9-dvd-dl-media-bd50
> 
> This smaller calibration disc may also work but not tested yet:
>  http://www.avsforum.com/t/948496/avs-hd-709-blu-ray-mp4-calibration
> 
> 
> Play titles of x264 demo disk:
> 
> 1) With the small x264 demo disk, after mounting this iso image, you can  
> play a 720p video with 720p popup menu (2 pages):
> $ ./avplay -v debug /mnt/iso/BDMV/STREAM/0.m2ts 
> /mnt/iso/BDMV/STREAM/5.m2ts
> 
> In video window, type 'p' to switch menu pages, 'l/r/u/b' to navigate, 
> 'enter' to display current button in activated state. First page may have an 
> auto-activated button without any picture.
> 
> 2) Playing the two 1080p movies with 1080p popup menu in subpath:
> $ ./avplay -v debug /mnt/iso/BDMV/STREAM/2.m2ts 
> /mnt/iso/BDMV/STREAM/4.m2ts
> or
> $ ./avplay -v debug /mnt/iso/BDMV/STREAM/3.m2ts 
> /mnt/iso/BDMV/STREAM/4.m2ts
> 
> 3) Playing 1080p mpeg2 disc menu (single frame movie, menu in subpath):
> $ ./avplay -v debug /mnt/iso/BDMV/STREAM/6.m2ts 
> /mnt/iso/BDMV/STREAM/7.m2ts
> 
> Main disk menu may have only one frame (this is the case with this demo 
> bluray), this require heavy work to redisplay the overlay plane over the 
> video, requiring backup/restore of video picture in avplay. This is still 
> bugged but don't have idea 
> 
> 
> Play menu titles of AVSForum demo disk:
> 
> Most of them are multi-pages so remember to cycle displayed page using 'p' 
> key.
> 
> 1) Main menu
> 
> $ ./avplay -v debug /path/to/BD50/BDMV/STREAM/0.m2ts 
> /path/to/BD50/BDMV/STREAM/1.m2ts
> 
> 2) Sub-menus
> 
> $ ./avplay -v debug /path/to/BD50/BDMV/STREAM/0.m2ts 
> /path/to/BD50/BDMV/STREAM/00011.m2ts
> $ ./avplay -v debug /path/to/BD50/BDMV/STREAM/0.m2ts 
> /path/to/BD50/BDMV/STREAM/00012.m2ts
> 
> $ ./avplay -v debug /path/to/BD50/BDMV/STREAM/00018.m2ts 
> /path/to/BD50/BDMV/STREAM/00022.m2ts
> $ ./avplay -v debug /path/to/BD50/BDMV/STREAM/00018.m2ts 
> /path/to/BD50/BDMV/STREAM/00023.m2ts
> 
> $ ./avplay -v debug /path/to/BD50/BDMV/STREAM/0.m2ts 
> /path/to/BD50/BDMV/STREAM/00033.m2ts
> $ ./avplay -v debug /path/to/BD50/BDMV/STREAM/0.m2ts 
> /path/to/BD50/BDMV/STREAM/00037.m2ts
> 
> $ ./avplay -v debug /path/to/BD50/BDMV/STREAM/0.m2ts 
> /path/to/BD50/BDMV/STREAM/00044.m2ts
> $ ./avplay -v debug /path/to/BD50/BDMV/STREAM/0.m2ts 
> /path/to/BD50/BDMV/STREAM/00045.m2ts
> $ ./avplay -v debug /path/to/BD50/BDMV/STREAM/0.m2ts 
> /path/to/BD50/BDMV/STREAM/00046.m2ts
> 
> $ ./avplay -v debug /path/to/BD50/BDMV/STREAM/00051.m2ts 
> /path/to/BD50/BDMV/STREAM/00052.m2ts
> $ ./avplay -v debug /path/to/BD50/BDMV/STREAM/00051.m2ts 
> /path/to/BD50/BDMV/STREAM/00053.m2ts
> 
> 
> Regards,
> David
> 
> 
> David Girault (4):
>   libavcodec: Added HDMV Interactive Graphics Stream decoder
>   libavformat: Added HDMV Interactive Graphics Stream muxer/demuxer
>   avplay: Added support for displaying overlay media
>   avconv: Add support for muxing/extracting HDMV IGS stream
> 
>  avconv.c |   26 ++
>  avplay.c |  593 
>  cmdutils.h   |1 +
>  libavcodec/Makefile  |1 +
>  libavcodec/allcodecs.c   |3 +
>  libavcodec/avcodec.h |   53 
>  libavcodec/igsmnudec.c   |  743 
> ++
>  libavcodec/utils.c   |   36 +++
>  libavformat/Makefile |2 +
>  libavformat/allformats.c |1 +
>  libavformat/avformat.h   |1 +
>  libavformat/mnudec.c |  128 
>  libavformat/mnuenc.c |   66 
>  libavformat/mpegts.c |2 +
>  libavutil/avutil.h   |1 +
>  15 files changed, 1606 insertions(+), 51 deletions(-)
>  create mode 100644 libavcodec/igsmnudec.c
>  create mode 100644 libavformat/mnudec.c
>  create mode 100644 libavformat/mnuenc.c
> 


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


Re: [libav-devel] [PATCH 1/3] TCP: check listen()

2012-06-17 Thread Jordi Ortiz
>
>
> LGTM
>
> Should I resend the patch without the 1/3 on the subject email? Sorry for
that, didn't notice until now.

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


Re: [libav-devel] [PATCH 1/3] TCP: check listen()

2012-06-17 Thread Martin Storsjö

On Sun, 17 Jun 2012, Jordi Ortiz wrote:


Should I resend the patch without the 1/3 on the subject email? Sorry for
that, didn't notice until now.


No, that's not necessary, it's stripped out when applied anyway.

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


[libav-devel] [PATCH 2/8] lavfi/audio: don't set cur_buf in ff_filter_samples().

2012-06-17 Thread Anton Khirnov
It's redundant, since the input buffer is passed as a parameter to the
filter_samples() callback, and can lead to stale pointers remaining on
the link.
---
 libavfilter/audio.c |   15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavfilter/audio.c b/libavfilter/audio.c
index 0f5bacd..1489608 100644
--- a/libavfilter/audio.c
+++ b/libavfilter/audio.c
@@ -156,6 +156,7 @@ void ff_filter_samples(AVFilterLink *link, 
AVFilterBufferRef *samplesref)
 {
 void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *);
 AVFilterPad *dst = link->dstpad;
+AVFilterBufferRef *buf_out;
 
 FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1);
 
@@ -169,21 +170,21 @@ void ff_filter_samples(AVFilterLink *link, 
AVFilterBufferRef *samplesref)
"Copying audio data in avfilter (have perms %x, need %x, reject 
%x)\n",
samplesref->perms, link->dstpad->min_perms, 
link->dstpad->rej_perms);
 
-link->cur_buf = ff_default_get_audio_buffer(link, dst->min_perms,
-
samplesref->audio->nb_samples);
-link->cur_buf->pts= samplesref->pts;
-link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate;
+buf_out = ff_default_get_audio_buffer(link, dst->min_perms,
+  samplesref->audio->nb_samples);
+buf_out->pts= samplesref->pts;
+buf_out->audio->sample_rate = samplesref->audio->sample_rate;
 
 /* Copy actual data into new samples buffer */
-av_samples_copy(link->cur_buf->extended_data, 
samplesref->extended_data,
+av_samples_copy(buf_out->extended_data, samplesref->extended_data,
 0, 0, samplesref->audio->nb_samples,
 
av_get_channel_layout_nb_channels(link->channel_layout),
 link->format);
 
 avfilter_unref_buffer(samplesref);
 } else
-link->cur_buf = samplesref;
+buf_out = samplesref;
 
-filter_samples(link, link->cur_buf);
+filter_samples(link, buf_out);
 }
 
-- 
1.7.10

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


[libav-devel] [PATCH 1/8] lavfi/audio: eliminate ff_default_filter_samples().

2012-06-17 Thread Anton Khirnov
It currently does the following:
1) get a zeroed audio buffer
2) copy some properties (but not the data) of the input buffer to it
3) pass this buffer to the output filter
This looks useless and is indeed not used by any filters, therefore
delete it.

Make ff_null_filter_samples() (just pass the buffer to the next filter)
the new default.
---
 libavfilter/af_aformat.c |3 +--
 libavfilter/af_anull.c   |3 +--
 libavfilter/audio.c  |   26 +++---
 libavfilter/audio.h  |6 --
 4 files changed, 5 insertions(+), 33 deletions(-)

diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index 3a75b92..5b00d7d 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -139,8 +139,7 @@ AVFilter avfilter_af_aformat = {
 .priv_size = sizeof(AFormatContext),
 
 .inputs= (AVFilterPad[]) {{ .name= "default",
-.type= AVMEDIA_TYPE_AUDIO,
-.filter_samples  = 
ff_null_filter_samples },
+.type= AVMEDIA_TYPE_AUDIO, 
},
   { .name = NULL}},
 .outputs   = (AVFilterPad[]) {{ .name= "default",
 .type= AVMEDIA_TYPE_AUDIO},
diff --git a/libavfilter/af_anull.c b/libavfilter/af_anull.c
index 294586e..231fc8c 100644
--- a/libavfilter/af_anull.c
+++ b/libavfilter/af_anull.c
@@ -33,8 +33,7 @@ AVFilter avfilter_af_anull = {
 
 .inputs= (AVFilterPad[]) {{ .name = "default",
 .type = AVMEDIA_TYPE_AUDIO,
-.get_audio_buffer = 
ff_null_get_audio_buffer,
-.filter_samples   = ff_null_filter_samples 
},
+.get_audio_buffer = 
ff_null_get_audio_buffer, },
   { .name = NULL}},
 
 .outputs   = (AVFilterPad[]) {{ .name = "default",
diff --git a/libavfilter/audio.c b/libavfilter/audio.c
index a6fef9d..0f5bacd 100644
--- a/libavfilter/audio.c
+++ b/libavfilter/audio.c
@@ -146,32 +146,12 @@ fail:
 return NULL;
 }
 
-void ff_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
+static void default_filter_samples(AVFilterLink *link,
+   AVFilterBufferRef *samplesref)
 {
 ff_filter_samples(link->dst->outputs[0], samplesref);
 }
 
-/* FIXME: samplesref is same as link->cur_buf. Need to consider removing the 
redundant parameter. */
-void ff_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef 
*samplesref)
-{
-AVFilterLink *outlink = NULL;
-
-if (inlink->dst->nb_outputs)
-outlink = inlink->dst->outputs[0];
-
-if (outlink) {
-outlink->out_buf = ff_default_get_audio_buffer(inlink, AV_PERM_WRITE,
-   
samplesref->audio->nb_samples);
-outlink->out_buf->pts= samplesref->pts;
-outlink->out_buf->audio->sample_rate = samplesref->audio->sample_rate;
-ff_filter_samples(outlink, avfilter_ref_buffer(outlink->out_buf, ~0));
-avfilter_unref_buffer(outlink->out_buf);
-outlink->out_buf = NULL;
-}
-avfilter_unref_buffer(samplesref);
-inlink->cur_buf = NULL;
-}
-
 void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
 {
 void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *);
@@ -180,7 +160,7 @@ void ff_filter_samples(AVFilterLink *link, 
AVFilterBufferRef *samplesref)
 FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1);
 
 if (!(filter_samples = dst->filter_samples))
-filter_samples = ff_default_filter_samples;
+filter_samples = default_filter_samples;
 
 /* prepare to copy the samples if the buffer has insufficient permissions 
*/
 if ((dst->min_perms & samplesref->perms) != dst->min_perms ||
diff --git a/libavfilter/audio.h b/libavfilter/audio.h
index 935bec5..9af44f8 100644
--- a/libavfilter/audio.h
+++ b/libavfilter/audio.h
@@ -42,12 +42,6 @@ AVFilterBufferRef *ff_null_get_audio_buffer(AVFilterLink 
*link, int perms,
 AVFilterBufferRef *ff_get_audio_buffer(AVFilterLink *link, int perms,
  int nb_samples);
 
-/** default handler for filter_samples() for audio inputs */
-void ff_default_filter_samples(AVFilterLink *link, AVFilterBufferRef 
*samplesref);
-
-/** filter_samples() handler for filters which simply pass audio along */
-void ff_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
-
 /**
  * Send a buffer of audio samples to the next filter.
  *
-- 
1.7.10

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


[libav-devel] [PATCH 4/8] fifo: fix parenthesis placement.

2012-06-17 Thread Anton Khirnov
---
 libavfilter/fifo.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/fifo.c b/libavfilter/fifo.c
index 1785946..6d21d5d 100644
--- a/libavfilter/fifo.c
+++ b/libavfilter/fifo.c
@@ -78,7 +78,7 @@ static int request_frame(AVFilterLink *outlink)
 int ret;
 
 if (!fifo->root.next) {
-if ((ret = ff_request_frame(outlink->src->inputs[0]) < 0))
+if ((ret = ff_request_frame(outlink->src->inputs[0])) < 0)
 return ret;
 }
 
-- 
1.7.10

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


[libav-devel] [PATCH 5/8] lavfi/fifo: add audio version of the fifo filter.

2012-06-17 Thread Anton Khirnov
---
 libavfilter/Makefile |1 +
 libavfilter/allfilters.c |1 +
 libavfilter/fifo.c   |   71 +-
 3 files changed, 53 insertions(+), 20 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index a4cc7f3..377956e 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -25,6 +25,7 @@ OBJS = allfilters.o   
  \
vf_scale.o   \
video.o  \
 
+OBJS-$(CONFIG_AFIFO_FILTER)  += fifo.o
 OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o
 OBJS-$(CONFIG_AMIX_FILTER)   += af_amix.o
 OBJS-$(CONFIG_ANULL_FILTER)  += af_anull.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 118f09d..5a249c0 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -34,6 +34,7 @@ void avfilter_register_all(void)
 return;
 initialized = 1;
 
+REGISTER_FILTER (AFIFO,   afifo,   af);
 REGISTER_FILTER (AFORMAT, aformat, af);
 REGISTER_FILTER (AMIX,amix,af);
 REGISTER_FILTER (ANULL,   anull,   af);
diff --git a/libavfilter/fifo.c b/libavfilter/fifo.c
index 6d21d5d..3fa4faa 100644
--- a/libavfilter/fifo.c
+++ b/libavfilter/fifo.c
@@ -20,21 +20,22 @@
 
 /**
  * @file
- * FIFO buffering video filter
+ * FIFO buffering filter
  */
 
+#include "audio.h"
 #include "avfilter.h"
 #include "internal.h"
 #include "video.h"
 
-typedef struct BufPic {
-AVFilterBufferRef *picref;
-struct BufPic *next;
-} BufPic;
+typedef struct Buf {
+AVFilterBufferRef *buf;
+struct Buf*next;
+} Buf;
 
 typedef struct {
-BufPic  root;
-BufPic *last;   ///< last buffered picture
+Buf  root;
+Buf *last;   ///< last buffered frame
 } FifoContext;
 
 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
@@ -49,22 +50,22 @@ static av_cold int init(AVFilterContext *ctx, const char 
*args, void *opaque)
 static av_cold void uninit(AVFilterContext *ctx)
 {
 FifoContext *fifo = ctx->priv;
-BufPic *pic, *tmp;
+Buf *buf, *tmp;
 
-for (pic = fifo->root.next; pic; pic = tmp) {
-tmp = pic->next;
-avfilter_unref_buffer(pic->picref);
-av_free(pic);
+for (buf = fifo->root.next; buf; buf = tmp) {
+tmp = buf->next;
+avfilter_unref_buffer(buf->buf);
+av_free(buf);
 }
 }
 
-static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
+static void add_to_queue(AVFilterLink *inlink, AVFilterBufferRef *buf)
 {
 FifoContext *fifo = inlink->dst->priv;
 
-fifo->last->next = av_mallocz(sizeof(BufPic));
+fifo->last->next = av_mallocz(sizeof(Buf));
 fifo->last = fifo->last->next;
-fifo->last->picref = picref;
+fifo->last->buf = buf;
 }
 
 static void end_frame(AVFilterLink *inlink) { }
@@ -74,7 +75,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, 
int slice_dir) { }
 static int request_frame(AVFilterLink *outlink)
 {
 FifoContext *fifo = outlink->src->priv;
-BufPic *tmp;
+Buf *tmp;
 int ret;
 
 if (!fifo->root.next) {
@@ -84,9 +85,18 @@ static int request_frame(AVFilterLink *outlink)
 
 /* by doing this, we give ownership of the reference to the next filter,
  * so we don't have to worry about dereferencing it ourselves. */
-ff_start_frame(outlink, fifo->root.next->picref);
-ff_draw_slice (outlink, 0, outlink->h, 1);
-ff_end_frame  (outlink);
+switch (outlink->type) {
+case AVMEDIA_TYPE_VIDEO:
+ff_start_frame(outlink, fifo->root.next->buf);
+ff_draw_slice (outlink, 0, outlink->h, 1);
+ff_end_frame  (outlink);
+break;
+case AVMEDIA_TYPE_AUDIO:
+ff_filter_samples(outlink, fifo->root.next->buf);
+break;
+default:
+return AVERROR(EINVAL);
+}
 
 if (fifo->last == fifo->root.next)
 fifo->last = &fifo->root;
@@ -109,7 +119,7 @@ AVFilter avfilter_vf_fifo = {
 .inputs= (AVFilterPad[]) {{ .name= "default",
 .type= AVMEDIA_TYPE_VIDEO,
 .get_video_buffer= 
ff_null_get_video_buffer,
-.start_frame = start_frame,
+.start_frame = add_to_queue,
 .draw_slice  = draw_slice,
 .end_frame   = end_frame,
 .rej_perms   = AV_PERM_REUSE2, },
@@ -119,3 +129,24 @@ AVFilter avfilter_vf_fifo = {
 .request_frame   = request_frame, },
   { .name = NULL}},
 };
+
+AVFilter avfilter_af_afifo = {
+.name= "afifo",
+.description = NULL_I

[libav-devel] [PATCH 3/8] lavfi: rename vf_fifo.c -> fifo.c

2012-06-17 Thread Anton Khirnov
It will be used for audio too.
---
 libavfilter/Makefile  |2 +-
 libavfilter/fifo.c|  121 +
 libavfilter/vf_fifo.c |  121 -
 3 files changed, 122 insertions(+), 122 deletions(-)
 create mode 100644 libavfilter/fifo.c
 delete mode 100644 libavfilter/vf_fifo.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 955a97c..a4cc7f3 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -47,7 +47,7 @@ OBJS-$(CONFIG_DRAWBOX_FILTER)+= vf_drawbox.o
 OBJS-$(CONFIG_DRAWTEXT_FILTER)   += vf_drawtext.o
 OBJS-$(CONFIG_FADE_FILTER)   += vf_fade.o
 OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o
-OBJS-$(CONFIG_FIFO_FILTER)   += vf_fifo.o
+OBJS-$(CONFIG_FIFO_FILTER)   += fifo.o
 OBJS-$(CONFIG_FORMAT_FILTER) += vf_format.o
 OBJS-$(CONFIG_FPS_FILTER)+= vf_fps.o
 OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o
diff --git a/libavfilter/fifo.c b/libavfilter/fifo.c
new file mode 100644
index 000..1785946
--- /dev/null
+++ b/libavfilter/fifo.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2007 Bobby Bingham
+ *
+ * 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
+ * FIFO buffering video filter
+ */
+
+#include "avfilter.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct BufPic {
+AVFilterBufferRef *picref;
+struct BufPic *next;
+} BufPic;
+
+typedef struct {
+BufPic  root;
+BufPic *last;   ///< last buffered picture
+} FifoContext;
+
+static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
+{
+FifoContext *fifo = ctx->priv;
+fifo->last = &fifo->root;
+
+av_log(ctx, AV_LOG_INFO, "\n");
+return 0;
+}
+
+static av_cold void uninit(AVFilterContext *ctx)
+{
+FifoContext *fifo = ctx->priv;
+BufPic *pic, *tmp;
+
+for (pic = fifo->root.next; pic; pic = tmp) {
+tmp = pic->next;
+avfilter_unref_buffer(pic->picref);
+av_free(pic);
+}
+}
+
+static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
+{
+FifoContext *fifo = inlink->dst->priv;
+
+fifo->last->next = av_mallocz(sizeof(BufPic));
+fifo->last = fifo->last->next;
+fifo->last->picref = picref;
+}
+
+static void end_frame(AVFilterLink *inlink) { }
+
+static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { }
+
+static int request_frame(AVFilterLink *outlink)
+{
+FifoContext *fifo = outlink->src->priv;
+BufPic *tmp;
+int ret;
+
+if (!fifo->root.next) {
+if ((ret = ff_request_frame(outlink->src->inputs[0]) < 0))
+return ret;
+}
+
+/* by doing this, we give ownership of the reference to the next filter,
+ * so we don't have to worry about dereferencing it ourselves. */
+ff_start_frame(outlink, fifo->root.next->picref);
+ff_draw_slice (outlink, 0, outlink->h, 1);
+ff_end_frame  (outlink);
+
+if (fifo->last == fifo->root.next)
+fifo->last = &fifo->root;
+tmp = fifo->root.next->next;
+av_free(fifo->root.next);
+fifo->root.next = tmp;
+
+return 0;
+}
+
+AVFilter avfilter_vf_fifo = {
+.name  = "fifo",
+.description = NULL_IF_CONFIG_SMALL("Buffer input images and send them 
when they are requested."),
+
+.init  = init,
+.uninit= uninit,
+
+.priv_size = sizeof(FifoContext),
+
+.inputs= (AVFilterPad[]) {{ .name= "default",
+.type= AVMEDIA_TYPE_VIDEO,
+.get_video_buffer= 
ff_null_get_video_buffer,
+.start_frame = start_frame,
+.draw_slice  = draw_slice,
+.end_frame   = end_frame,
+.rej_perms   = AV_PERM_REUSE2, },
+  { .name = NULL}},
+.outputs   = (AVFilterPad[]) {{ .name= "default",
+.type= AVMEDIA_TYPE_VIDEO,
+.request_frame   = request_frame, },
+

[libav-devel] [PATCH 6/8] lavfi: support automatically inserting the fifo filter when needed.

2012-06-17 Thread Anton Khirnov
This breaks libavfilter ABI.
---
 doc/APIchanges  |2 +-
 libavfilter/avfilter.h  |8 +
 libavfilter/avfiltergraph.c |   40 +
 libavfilter/buffersink.c|   81 +++
 libavfilter/internal.h  |8 +
 libavfilter/version.h   |4 +--
 6 files changed, 79 insertions(+), 64 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 50cc787..bcb7208 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -4,7 +4,7 @@ since the last major version increase.
 The last version increases were:
 libavcodec:2012-01-27
 libavdevice:   2011-04-18
-libavfilter:   2011-04-18
+libavfilter:   2012-06-13
 libavformat:   2012-01-27
 libavresample: 2012-04-24
 libswscale:2011-06-20
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index aff662f..c92f7e1 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -363,6 +363,14 @@ struct AVFilterPad {
  * and another value on error.
  */
 int (*config_props)(AVFilterLink *link);
+
+/**
+ * The filter expects a fifo to be inserted on its input link,
+ * typically because it has a delay.
+ *
+ * input pads only.
+ */
+int needs_fifo;
 };
 #endif
 
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 3d463a8..95e0a21 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -591,12 +591,52 @@ static int graph_config_formats(AVFilterGraph *graph, 
AVClass *log_ctx)
 return 0;
 }
 
+static int graph_insert_fifos(AVFilterGraph *graph, AVClass *log_ctx)
+{
+AVFilterContext *f;
+int i, j, ret;
+int fifo_count = 0;
+
+for (i = 0; i < graph->filter_count; i++) {
+f = graph->filters[i];
+
+for (j = 0; j < f->nb_inputs; j++) {
+AVFilterLink *link = f->inputs[j];
+AVFilterContext *fifo_ctx;
+AVFilter *fifo;
+char name[32];
+
+if (!link->dstpad->needs_fifo)
+continue;
+
+fifo = f->inputs[j]->type == AVMEDIA_TYPE_VIDEO ?
+   avfilter_get_by_name("fifo") :
+   avfilter_get_by_name("afifo");
+
+snprintf(name, sizeof(name), "auto-inserted fifo %d", 
fifo_count++);
+
+ret = avfilter_graph_create_filter(&fifo_ctx, fifo, name, NULL,
+   NULL, graph);
+if (ret < 0)
+return ret;
+
+ret = avfilter_insert_filter(link, fifo_ctx, 0, 0);
+if (ret < 0)
+return ret;
+}
+}
+
+return 0;
+}
+
 int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
 {
 int ret;
 
 if ((ret = graph_check_validity(graphctx, log_ctx)))
 return ret;
+if ((ret = graph_insert_fifos(graphctx, log_ctx)) < 0)
+return ret;
 if ((ret = graph_config_formats(graphctx, log_ctx)))
 return ret;
 if ((ret = graph_config_links(graphctx, log_ctx)))
diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 13fb255..50d949b 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -25,7 +25,7 @@
 
 #include "libavutil/audio_fifo.h"
 #include "libavutil/audioconvert.h"
-#include "libavutil/fifo.h"
+#include "libavutil/avassert.h"
 #include "libavutil/mathematics.h"
 
 #include "audio.h"
@@ -34,86 +34,45 @@
 #include "internal.h"
 
 typedef struct {
-AVFifoBuffer *fifo;  ///< FIFO buffer of frame references
-
+AVFilterBufferRef *cur_buf;  ///< last buffer delivered on the sink
 AVAudioFifo  *audio_fifo;///< FIFO for audio samples
 int64_t next_pts;///< interpolating audio pts
 } BufferSinkContext;
 
-#define FIFO_INIT_SIZE 8
-
 static av_cold void uninit(AVFilterContext *ctx)
 {
 BufferSinkContext *sink = ctx->priv;
 
-while (sink->fifo && av_fifo_size(sink->fifo)) {
-AVFilterBufferRef *buf;
-av_fifo_generic_read(sink->fifo, &buf, sizeof(buf), NULL);
-avfilter_unref_buffer(buf);
-}
-av_fifo_free(sink->fifo);
-
 if (sink->audio_fifo)
 av_audio_fifo_free(sink->audio_fifo);
 }
 
-static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
-{
-BufferSinkContext *sink = ctx->priv;
-
-if (!(sink->fifo = 
av_fifo_alloc(FIFO_INIT_SIZE*sizeof(AVFilterBufferRef* {
-av_log(ctx, AV_LOG_ERROR, "Failed to allocate fifo\n");
-return AVERROR(ENOMEM);
-}
-
-return 0;
-}
-
-static void write_buf(AVFilterContext *ctx, AVFilterBufferRef *buf)
+static void start_frame(AVFilterLink *link, AVFilterBufferRef *buf)
 {
-BufferSinkContext *sink = ctx->priv;
-
-if (av_fifo_space(sink->fifo) < sizeof(AVFilterBufferRef *) &&
-(av_fifo_realloc2(sink->fifo, av_fifo_size(sink->fifo) * 2) < 0)) {
-av_log(ctx, AV_LOG_ERROR, "Error reallocating the FIFO.\n");
-return;
-}
+BufferSinkContext *s = link->d

[libav-devel] [PATCH 7/8] lavfi: allow audio filters to request a given number of samples.

2012-06-17 Thread Anton Khirnov
This makes synchronization simpler for filters with multiple inputs.
---
 libavfilter/avfilter.h |9 
 libavfilter/fifo.c |  141 +---
 2 files changed, 142 insertions(+), 8 deletions(-)

diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index c92f7e1..f09f086 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -595,6 +595,15 @@ struct AVFilterLink {
 AVFilterFormats *out_samplerates;
 struct AVFilterChannelLayouts  *in_channel_layouts;
 struct AVFilterChannelLayouts *out_channel_layouts;
+
+/**
+ * Audio only, the destination filter sets this to a non-zero value to
+ * request that buffers with the given number of samples should be sent to
+ * it. AVFilterPad.needs_fifo must also be set on the corresponding input
+ * pad.
+ * Last buffer before EOF will be padded with silence.
+ */
+int request_samples;
 };
 
 /**
diff --git a/libavfilter/fifo.c b/libavfilter/fifo.c
index 3fa4faa..bc43550 100644
--- a/libavfilter/fifo.c
+++ b/libavfilter/fifo.c
@@ -23,6 +23,11 @@
  * FIFO buffering filter
  */
 
+#include "libavutil/avassert.h"
+#include "libavutil/audioconvert.h"
+#include "libavutil/mathematics.h"
+#include "libavutil/samplefmt.h"
+
 #include "audio.h"
 #include "avfilter.h"
 #include "internal.h"
@@ -36,6 +41,13 @@ typedef struct Buf {
 typedef struct {
 Buf  root;
 Buf *last;   ///< last buffered frame
+
+/**
+ * When a specific number of output samples is requested, the partial
+ * buffer is stored here
+ */
+AVFilterBufferRef *buf_out;
+int allocated_samples;  ///< number of samples buf_out was allocated 
for
 } FifoContext;
 
 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
@@ -57,6 +69,8 @@ static av_cold void uninit(AVFilterContext *ctx)
 avfilter_unref_buffer(buf->buf);
 av_free(buf);
 }
+
+avfilter_unref_buffer(fifo->buf_out);
 }
 
 static void add_to_queue(AVFilterLink *inlink, AVFilterBufferRef *buf)
@@ -68,14 +82,125 @@ static void add_to_queue(AVFilterLink *inlink, 
AVFilterBufferRef *buf)
 fifo->last->buf = buf;
 }
 
+static void queue_pop(FifoContext *s)
+{
+Buf *tmp = s->root.next->next;
+if (s->last == s->root.next)
+s->last = &s->root;
+av_freep(&s->root.next);
+s->root.next = tmp;
+}
+
 static void end_frame(AVFilterLink *inlink) { }
 
 static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { }
 
+/**
+ * Move data pointers and pts offset samples forward.
+ */
+static void buffer_offset(AVFilterLink *link, AVFilterBufferRef *buf,
+  int offset)
+{
+int nb_channels = av_get_channel_layout_nb_channels(link->channel_layout);
+int planar = av_sample_fmt_is_planar(link->format);
+int planes = planar ? nb_channels : 1;
+int block_align = av_get_bytes_per_sample(link->format) * (planar ? 1 : 
nb_channels);
+int i;
+
+av_assert0(buf->audio->nb_samples > offset);
+
+for (i = 0; i < planes; i++)
+buf->extended_data[i] += block_align*offset;
+if (buf->data != buf->extended_data)
+memcpy(buf->data, buf->extended_data,
+   FFMIN(planes, FF_ARRAY_ELEMS(buf->data)) * sizeof(*buf->data));
+buf->linesize[0] -= block_align*offset;
+buf->audio->nb_samples -= offset;
+
+if (buf->pts != AV_NOPTS_VALUE) {
+buf->pts += av_rescale_q(offset, (AVRational){1, link->sample_rate},
+ link->time_base);
+}
+}
+
+static int return_audio_frame(AVFilterContext *ctx)
+{
+AVFilterLink *link = ctx->outputs[0];
+FifoContext *s = ctx->priv;
+AVFilterBufferRef *head = s->root.next->buf;
+AVFilterBufferRef *buf_out;
+int ret;
+
+if (!s->buf_out &&
+head->audio->nb_samples >= link->request_samples) {
+if (head->audio->nb_samples == link->request_samples) {
+buf_out = head;
+queue_pop(s);
+} else {
+buf_out = avfilter_ref_buffer(head, AV_PERM_READ);
+buf_out->audio->nb_samples = link->request_samples;
+buffer_offset(link, head, link->request_samples);
+}
+} else {
+int nb_channels = 
av_get_channel_layout_nb_channels(link->channel_layout);
+
+if (!s->buf_out) {
+s->buf_out = ff_get_audio_buffer(link, AV_PERM_WRITE,
+ link->request_samples);
+if (!s->buf_out)
+return AVERROR(ENOMEM);
+
+s->buf_out->audio->nb_samples = 0;
+s->buf_out->pts   = head->pts;
+s->allocated_samples  = link->request_samples;
+} else if (link->request_samples != s->allocated_samples) {
+av_log(ctx, AV_LOG_ERROR, "request_samples changed before the "
+   "buffer was returned.\n");
+return AVERROR(EINVAL);
+}
+
+while (s->buf_out

[libav-devel] [PATCH 8/8] lavfi: add join audio filter.

2012-06-17 Thread Anton Khirnov
It joins multiple input streams into one multi-channel output.
---
 Changelog|1 +
 doc/filters.texi |   37 
 libavfilter/Makefile |1 +
 libavfilter/af_join.c|  500 ++
 libavfilter/allfilters.c |1 +
 5 files changed, 540 insertions(+)
 create mode 100644 libavfilter/af_join.c

diff --git a/Changelog b/Changelog
index b80ff88..d9e96a7 100644
--- a/Changelog
+++ b/Changelog
@@ -25,6 +25,7 @@ version :
   be used with -of old.
 - Indeo Audio decoder
 - channelsplit audio filter
+- join audio filter
 
 
 version 0.8:
diff --git a/doc/filters.texi b/doc/filters.texi
index f17dad8..e40f879 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -232,6 +232,43 @@ front_center.wav -map '[LFE]' lfe.wav -map '[SL]' 
side_left.wav -map '[SR]'
 side_right.wav
 @end example
 
+@section join
+Join multiple input streams into one multi-channel stream.
+
+The filter accepts the following named parameters:
+@table @option
+
+@item inputs
+Number of input streams. Defaults to 2.
+
+@item channel_layout
+Desired output channel layout. Defaults to stereo.
+
+@item map
+Map channels from inputs to output. The argument is a comma-separated list of
+mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
+form. @var{input_idx} is the 0-based index of the input stream. 
@var{in_channel}
+can be either the name of the input channel (e.g. FR for front left) or its
+index in the specified input stream. @var{out_channel} is the name of the 
output
+channel.
+@end table
+
+The filter will attempt to guess the mappings when those are not specified
+explicitly. It does so by first trying to find an unused matching input channel
+and if that fails it picks the first unused input channel.
+
+E.g. to join 3 inputs (with properly set channel layouts)
+@example
+avconv -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
+@end example
+
+To build a 5.1 output from 6 single-channel streams:
+@example
+avconv -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
+'join=inputs=6:channel_layout=5.1:map=0.0-FL\,1.0-FR\,2.0-FC\,3.0-SL\,4.0-SR\,5.0-LFE'
+out
+@end example
+
 @section resample
 Convert the audio sample format, sample rate and channel layout. This filter is
 not meant to be used directly, it is inserted automatically by libavfilter
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 377956e..5fa85ce 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -32,6 +32,7 @@ OBJS-$(CONFIG_ANULL_FILTER)  += af_anull.o
 OBJS-$(CONFIG_ASPLIT_FILTER) += split.o
 OBJS-$(CONFIG_ASYNCTS_FILTER)+= af_asyncts.o
 OBJS-$(CONFIG_CHANNELSPLIT_FILTER)   += af_channelsplit.o
+OBJS-$(CONFIG_JOIN_FILTER)   += af_join.o
 OBJS-$(CONFIG_RESAMPLE_FILTER)   += af_resample.o
 
 OBJS-$(CONFIG_ANULLSRC_FILTER)   += asrc_anullsrc.o
diff --git a/libavfilter/af_join.c b/libavfilter/af_join.c
new file mode 100644
index 000..ab5e905
--- /dev/null
+++ b/libavfilter/af_join.c
@@ -0,0 +1,500 @@
+/*
+ *
+ * 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
+ * Audio join filter
+ *
+ * Join multiple audio inputs as different channels in
+ * a single output
+ */
+
+#include "libavutil/audioconvert.h"
+#include "libavutil/avassert.h"
+#include "libavutil/opt.h"
+
+#include "audio.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+
+typedef struct ChannelMap {
+int input;///< input stream index
+int   in_channel_idx; ///< index of in_channel in the input stream data
+uint64_t  in_channel; ///< layout describing the input channel
+uint64_t out_channel; ///< layout describing the output channel
+} ChannelMap;
+
+typedef struct JoinContext {
+const AVClass *class;
+
+int inputs;
+char *map;
+char*channel_layout_str;
+uint64_t channel_layout;
+
+int  nb_channels;
+ChannelMap *channels;
+
+/**
+ * Temporary storage for input frames, until we get one on each input.
+ */
+AVFilterBufferRef **input_frames;
+
+/**
+ *  Temporary storage for data pointers, for assembling the output buffer.
+ */
+

[libav-devel] [PATCH] mov_chan: Fix operator precedence by adding parentheses

2012-06-17 Thread Martin Storsjö
---
 libavformat/mov_chan.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index 874b8be..f9220d1 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -498,7 +498,7 @@ uint32_t ff_mov_get_channel_layout_tag(enum CodecID 
codec_id,
 
 /* find the layout tag for the specified channel layout */
 for (i = 0; layouts[i] != 0; i++) {
-if (layouts[i] & 0x != channels)
+if ((layouts[i] & 0x) != channels)
 continue;
 for (j = 0; layout_map[j].tag != 0; j++) {
 if (layout_map[j].tag== layouts[i] &&
-- 
1.7.9.4

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


Re: [libav-devel] [PATCH 3/8] lavfi: rename vf_fifo.c -> fifo.c

2012-06-17 Thread Diego Biurrun
On Sun, Jun 17, 2012 at 12:17:02PM +0200, Anton Khirnov wrote:
> It will be used for audio too.
> ---
>  libavfilter/Makefile  |2 +-
>  libavfilter/fifo.c|  121 
> +
>  libavfilter/vf_fifo.c |  121 
> -
>  3 files changed, 122 insertions(+), 122 deletions(-)
>  create mode 100644 libavfilter/fifo.c
>  delete mode 100644 libavfilter/vf_fifo.c

You appear to be missing -M from the git-send-email command line.
I have

  [diff]
  renames = copy

in my ~/.gitconfig, which sets this as default.

Otherwise patch LGTM.

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


Re: [libav-devel] [PATCH 4/8] fifo: fix parenthesis placement.

2012-06-17 Thread Diego Biurrun
On Sun, Jun 17, 2012 at 12:17:03PM +0200, Anton Khirnov wrote:
> ---
>  libavfilter/fifo.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

LGTM

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


Re: [libav-devel] [PATCH] mov_chan: Fix operator precedence by adding parentheses

2012-06-17 Thread Diego Biurrun
On Sun, Jun 17, 2012 at 02:31:00PM +0300, Martin Storsjö wrote:
> ---
>  libavformat/mov_chan.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

LGTM

Diego
___
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-17 Thread Diego Biurrun
On Sat, Jun 16, 2012 at 12:36:16PM +0200, Kostya Shishkov wrote:
> ---
> As a side note, I must say that lavf ASF demuxer outputs wrong data, so for
> example eleventh or twelfth frame in
> http://samples.ffmpeg.org/V-codecs/MSS1/screen_codec.wmv
> is demuxed wrong compared to MPlayer. And of course it causes decoding errors.

Who can fix it? :)

Please add a Bugzilla entry if we don't have one already...

> --- /dev/null
> +++ b/libavcodec/mss1.c
> @@ -0,0 +1,844 @@
> +
> +static void arith_init(ArithCoder *c, GetBitContext *gb)

av_cold?

You don't have av_cold on any function, which is surprising.

> +static int arith_get_bit(ArithCoder *c)
> +{
> +int range = c->high - c->low + 1;
> +int bit   = (((c->value - c->low) << 1) + 1) / range;
> +
> +if (bit)
> +c->low += range >> 1;
> +else
> +c->high = c->low + (range >> 1) - 1;
> +
> +arith_normalise(c);
> +
> +return bit;
> +}
> +
> +static int arith_get_bits(ArithCoder *c, int bits)
> +{
> +int range = c->high - c->low + 1;
> +int val   = (((c->value - c->low + 1) << bits) - 1) / range;
> +int prob  = range * val;
> +
> +c->high   = ((prob + range) >> bits) + c->low - 1;
> +c->low   += prob >> bits;
> +
> +arith_normalise(c);
> +
> +return val;
> +}
> +
> +static int arith_get_number(ArithCoder *c, int mod_val)
> +{
> +int range = c->high - c->low + 1;
> +int val   = ((c->value - c->low + 1) * mod_val - 1) / range;
> +int prob  = range * val;
> +
> +c->high   = (prob + range) / mod_val + c->low - 1;
> +c->low   += prob / mod_val;
> +
> +arith_normalise(c);
> +
> +return val;
> +}

This would be easy to refactor in Haskell ;)

> +static void model_init(Model *m, int num_syms, int thr_weight)

av_cold?

> +static void codec_init(MSS1Context *ctx)

av_cold?

> +c->pic.reference = 3;
> +c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
> +  FF_BUFFER_HINTS_REUSABLE;

align

> +if (!arith_get_bit(&acoder)) {
> +codec_reset(c);
> +pal_changed = decode_pal(c, &acoder);
> +c->corrupted = decode_intra(c, &acoder, 0, 0, avctx->width, 
> avctx->height);
> +c->pic.key_frame = 1;
> +c->pic.pict_type = AV_PICTURE_TYPE_I;

align

> +} else {
> +if (c->corrupted)
> +return AVERROR_INVALIDDATA;
> +c->corrupted = decode_inter(c, &acoder, 0, 0, avctx->width, 
> avctx->height);
> +c->pic.key_frame = 0;
> +c->pic.pict_type = AV_PICTURE_TYPE_P;
> +}

align

> +c->mask_linesize = FFALIGN(avctx->coded_width, 16);
> +c->mask = av_malloc(c->mask_linesize * avctx->coded_height);

align

> +static av_cold int decode_init(AVCodecContext *avctx)

av_cold

> +static av_cold int decode_end(AVCodecContext *avctx)

av_cold

I thought generic function names like decode_init/decode_end/decode_frame
should be avoided in modern code.  Should I make this an entry in the dev
docs?

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


[libav-devel] [PATCH] doc: Add missing protocols to list of supported protocols.

2012-06-17 Thread Diego Biurrun
---
 doc/general.texi |   15 +--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/doc/general.texi b/doc/general.texi
index dee8f9e..9a4746a 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -804,19 +804,30 @@ performance on systems without hardware floating point 
support).
 
 @multitable @columnfractions .4 .1
 @item Name @tab Support
-@item Apple HTTP Live Streaming @tab X
 @item file @tab X
 @item Gopher   @tab X
+@item HLS  @tab X
 @item HTTP @tab X
-@item MMS  @tab X
+@item HTTPS@tab X
+@item MMSH @tab X
+@item MMST @tab X
 @item pipe @tab X
+@item RTMP @tab X
+@item RTMPE@tab E
+@item RTMPS@tab E
+@item RTMPT@tab E
+@item RTMPTE   @tab E
 @item RTP  @tab X
+@item SCTP @tab X
 @item TCP  @tab X
+@item TLS  @tab X
 @item UDP  @tab X
 @end multitable
 
 @code{X} means that the protocol is supported.
 
+@code{E} means that support is provided through an external library.
+
 
 @section Input/Output Devices
 
-- 
1.7.1

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


Re: [libav-devel] [PATCH 1/1] mathematics.h: remove a couple of math defines

2012-06-17 Thread Diego Biurrun
On Fri, Jun 15, 2012 at 01:34:46PM +0200, Janne Grunau wrote:
> On 2012-06-14 23:32:00 +0200, Diego Biurrun wrote:
> > On Thu, Jun 14, 2012 at 08:18:19PM +0200, Janne Grunau wrote:
> > > While this defines are not defined by the C standard they are provided
> > > by the math.h header.
> >
> > these defines
> 
> fixed
> 
> > Are the defines in glibc math.h, guaranteed by POSIX to be there or ..?
> 
> XSI and they seem to be generally available on all FATE configs,
> libavcodec/atrac3.c uses M_PI without including mathematics.h directly
> or indirectly.

Patch OK with me then.

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


Re: [libav-devel] [PATCH] doc: Add missing protocols to list of supported protocols.

2012-06-17 Thread Martin Storsjö

On Sun, 17 Jun 2012, Diego Biurrun wrote:


---
doc/general.texi |   15 +--
1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/doc/general.texi b/doc/general.texi
index dee8f9e..9a4746a 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -804,19 +804,30 @@ performance on systems without hardware floating point 
support).

@multitable @columnfractions .4 .1
@item Name @tab Support
-@item Apple HTTP Live Streaming @tab X
@item file @tab X
@item Gopher   @tab X
+@item HLS  @tab X
@item HTTP @tab X
-@item MMS  @tab X
+@item HTTPS@tab X
+@item MMSH @tab X
+@item MMST @tab X
@item pipe @tab X
+@item RTMP @tab X
+@item RTMPE@tab E
+@item RTMPS@tab E
+@item RTMPT@tab E
+@item RTMPTE   @tab E
@item RTP  @tab X
+@item SCTP @tab X
@item TCP  @tab X
+@item TLS  @tab X
@item UDP  @tab X
@end multitable

@code{X} means that the protocol is supported.

+@code{E} means that support is provided through an external library.
+

@section Input/Output Devices

--
1.7.1


LGTM, thanks!

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


Re: [libav-devel] [PATCH] lavfi: add channelsplit audio filter.

2012-06-17 Thread Diego Biurrun
On Sat, Jun 09, 2012 at 08:21:11PM +0200, Anton Khirnov wrote:
> 
> --- a/Changelog
> +++ b/Changelog
> @@ -24,7 +24,7 @@ version :
>  - avprobe output is now standard INI or JSON. The old format can still
>be used with -of old.
>  - Indeo Audio decoder
> -
> +- channelsplit audio filter
>  
>  version 0.8:

stray empty line removal

> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -207,6 +207,31 @@ Maximum compensation in samples per second.
>  
> +@section channelsplit
> +Split each channel in input audio stream into a separate output stream.

in the input

> --- /dev/null
> +++ b/libavfilter/af_channelsplit.c
> @@ -0,0 +1,146 @@
> +static int init(AVFilterContext *ctx, const char *arg, void *opaque)
> +{
> +if (!(s->channel_layout = av_get_channel_layout(s->channel_layout_str))) 
> {
> +av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout '%s'.\n",
> +   s->channel_layout_str);
> +ret = AVERROR(EINVAL);
> +goto fail;
> +}
> +
> +fail:
> +av_opt_free(s);
> +return ret;
> +}

As this is the only goto, just calling the free function and returning
the proper value directly seems cleaner to me and would even save one
line.  Quite probably a matter of taste, do whatever you want.

> +static int query_formats(AVFilterContext *ctx)
> +{
> +ChannelSplitContext *s = ctx->priv;
> +AVFilterChannelLayouts *in_layouts = NULL;
> +int i;
> +
> +ff_set_common_formats(ctx, ff_planar_sample_fmts());
> +ff_set_common_samplerates(ctx, ff_all_samplerates());

idiosyncratic formatting

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


Re: [libav-devel] [PATCH 2/2] RTMPT protocol support

2012-06-17 Thread Diego Biurrun
On Sat, Jun 16, 2012 at 12:50:36PM +0200, Samuel Pitoiset wrote:
> This adds two protocols, but one of them is an internal implementation
> detail just used as an abstraction layer/generalization in the code. The
> RTMPT protocol implementation uses rtmphttp:// as an alternative to the
> tcp:// protocol. This allows moving most of the lower level logic out
> from the higher level generic rtmp code.
> ---
> - Fix missing proper dependecies in configure
> 
> --- a/configure
> +++ b/configure
> @@ -1511,6 +1511,10 @@ mmsh_protocol_select="http_protocol"
>  rtmp_protocol_deps="!librtmp_protocol"
>  rtmp_protocol_select="tcp_protocol"
> +rtmphttp_protocol_deps="!librtmp_protocol"
> +rtmphttp_protocol_select="http_protocol"
> +rtmpt_protocol_deps="!librtmp_protocol"
> +rtmpt_protocol_select="rtmphttp_protocol"
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -345,6 +345,7 @@ OBJS-$(CONFIG_MMST_PROTOCOL) += mmst.o mms.o 
> asf.o
>  OBJS-$(CONFIG_RTMP_PROTOCOL) += rtmpproto.o rtmppkt.o
> +OBJS-$(CONFIG_RTMPHTTP_PROTOCOL) += rtmphttp.o rtmpproto.o rtmppkt.o
>  OBJS-$(CONFIG_RTP_PROTOCOL)  += rtpproto.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 1320a28..69f27ab 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -256,6 +256,8 @@ void av_register_all(void)
>  REGISTER_PROTOCOL (RTMP, rtmp);
> +REGISTER_PROTOCOL (RTMPT, rtmpt);
> +REGISTER_PROTOCOL (RTMPHTTP, rtmphttp);
>  REGISTER_PROTOCOL (RTP, rtp);

I'm not convinced dependencies are fixed properly; you seem to be missing
at least a Makefile entry for the rtmpt protocol.  Try

  configure --disable-everything --enable-protocol=rtmphttp
  configure --disable-everything --enable-protocol=rtmpt

from a clean tree and see if it compiles properly.

> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -811,6 +811,7 @@ performance on systems without hardware floating point 
> support).
>  @item pipe @tab X
>  @item RTMP @tab X
> +@item RTMPT@tab X
>  @item RTP  @tab X
>  @item TCP  @tab X

You will need to adapt this to my latest documentation commit.

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


Re: [libav-devel] [PATCH 2/2] RTMPT protocol support

2012-06-17 Thread Samuel Pitoiset
On Sun, Jun 17, 2012 at 3:43 PM, Diego Biurrun  wrote:
> On Sat, Jun 16, 2012 at 12:50:36PM +0200, Samuel Pitoiset wrote:
>> This adds two protocols, but one of them is an internal implementation
>> detail just used as an abstraction layer/generalization in the code. The
>> RTMPT protocol implementation uses rtmphttp:// as an alternative to the
>> tcp:// protocol. This allows moving most of the lower level logic out
>> from the higher level generic rtmp code.
>> ---
>> - Fix missing proper dependecies in configure
>>
>> --- a/configure
>> +++ b/configure
>> @@ -1511,6 +1511,10 @@ mmsh_protocol_select="http_protocol"
>>  rtmp_protocol_deps="!librtmp_protocol"
>>  rtmp_protocol_select="tcp_protocol"
>> +rtmphttp_protocol_deps="!librtmp_protocol"
>> +rtmphttp_protocol_select="http_protocol"
>> +rtmpt_protocol_deps="!librtmp_protocol"
>> +rtmpt_protocol_select="rtmphttp_protocol"
>> --- a/libavformat/Makefile
>> +++ b/libavformat/Makefile
>> @@ -345,6 +345,7 @@ OBJS-$(CONFIG_MMST_PROTOCOL)             += mmst.o mms.o 
>> asf.o
>>  OBJS-$(CONFIG_RTMP_PROTOCOL)             += rtmpproto.o rtmppkt.o
>> +OBJS-$(CONFIG_RTMPHTTP_PROTOCOL)         += rtmphttp.o rtmpproto.o rtmppkt.o
>>  OBJS-$(CONFIG_RTP_PROTOCOL)              += rtpproto.o
>> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
>> index 1320a28..69f27ab 100644
>> --- a/libavformat/allformats.c
>> +++ b/libavformat/allformats.c
>> @@ -256,6 +256,8 @@ void av_register_all(void)
>>      REGISTER_PROTOCOL (RTMP, rtmp);
>> +    REGISTER_PROTOCOL (RTMPT, rtmpt);
>> +    REGISTER_PROTOCOL (RTMPHTTP, rtmphttp);
>>      REGISTER_PROTOCOL (RTP, rtp);
>
> I'm not convinced dependencies are fixed properly; you seem to be missing
> at least a Makefile entry for the rtmpt protocol.  Try
>
>  configure --disable-everything --enable-protocol=rtmphttp
>  configure --disable-everything --enable-protocol=rtmpt
>
> from a clean tree and see if it compiles properly.

Tested, it compiles properly.

>
>> --- a/doc/general.texi
>> +++ b/doc/general.texi
>> @@ -811,6 +811,7 @@ performance on systems without hardware floating point 
>> support).
>>  @item pipe         @tab X
>>  @item RTMP         @tab X
>> +@item RTMPT        @tab X
>>  @item RTP          @tab X
>>  @item TCP          @tab X
>
> You will need to adapt this to my latest documentation commit.

Rebased.



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


Re: [libav-devel] [PATCH 2/2] RTMPT protocol support

2012-06-17 Thread Martin Storsjö

On Sun, 17 Jun 2012, Samuel Pitoiset wrote:


On Sun, Jun 17, 2012 at 3:43 PM, Diego Biurrun  wrote:

On Sat, Jun 16, 2012 at 12:50:36PM +0200, Samuel Pitoiset wrote:

This adds two protocols, but one of them is an internal implementation
detail just used as an abstraction layer/generalization in the code. The
RTMPT protocol implementation uses rtmphttp:// as an alternative to the
tcp:// protocol. This allows moving most of the lower level logic out
from the higher level generic rtmp code.
---
- Fix missing proper dependecies in configure

--- a/configure
+++ b/configure
@@ -1511,6 +1511,10 @@ mmsh_protocol_select="http_protocol"
 rtmp_protocol_deps="!librtmp_protocol"
 rtmp_protocol_select="tcp_protocol"
+rtmphttp_protocol_deps="!librtmp_protocol"
+rtmphttp_protocol_select="http_protocol"
+rtmpt_protocol_deps="!librtmp_protocol"
+rtmpt_protocol_select="rtmphttp_protocol"
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -345,6 +345,7 @@ OBJS-$(CONFIG_MMST_PROTOCOL)             += mmst.o mms.o 
asf.o
 OBJS-$(CONFIG_RTMP_PROTOCOL)             += rtmpproto.o rtmppkt.o
+OBJS-$(CONFIG_RTMPHTTP_PROTOCOL)         += rtmphttp.o rtmpproto.o rtmppkt.o
 OBJS-$(CONFIG_RTP_PROTOCOL)              += rtpproto.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1320a28..69f27ab 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -256,6 +256,8 @@ void av_register_all(void)
     REGISTER_PROTOCOL (RTMP, rtmp);
+    REGISTER_PROTOCOL (RTMPT, rtmpt);
+    REGISTER_PROTOCOL (RTMPHTTP, rtmphttp);
     REGISTER_PROTOCOL (RTP, rtp);


I'm not convinced dependencies are fixed properly; you seem to be missing
at least a Makefile entry for the rtmpt protocol.  Try

 configure --disable-everything --enable-protocol=rtmphttp
 configure --disable-everything --enable-protocol=rtmpt

from a clean tree and see if it compiles properly.


Tested, it compiles properly.


Diego is right here, although you apparently manage to make it link 
anyway. The rtmphttp makefile entry is wrong, since it contains both the 
rtmphttp part and the rtmpt part.


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


Re: [libav-devel] [PATCH 2/2] RTMPT protocol support

2012-06-17 Thread Diego Biurrun
On Sun, Jun 17, 2012 at 05:02:15PM +0300, Martin Storsjö wrote:
> On Sun, 17 Jun 2012, Samuel Pitoiset wrote:
> >On Sun, Jun 17, 2012 at 3:43 PM, Diego Biurrun  wrote:
> >>On Sat, Jun 16, 2012 at 12:50:36PM +0200, Samuel Pitoiset wrote:
> >>>This adds two protocols, but one of them is an internal implementation
> >>>detail just used as an abstraction layer/generalization in the code. The
> >>>RTMPT protocol implementation uses rtmphttp:// as an alternative to the
> >>>tcp:// protocol. This allows moving most of the lower level logic out
> >>>from the higher level generic rtmp code.
> >>>---
> >>>- Fix missing proper dependecies in configure
> >>>
> >>>--- a/configure
> >>>+++ b/configure
> >>>@@ -1511,6 +1511,10 @@ mmsh_protocol_select="http_protocol"
> >>> rtmp_protocol_deps="!librtmp_protocol"
> >>> rtmp_protocol_select="tcp_protocol"
> >>>+rtmphttp_protocol_deps="!librtmp_protocol"
> >>>+rtmphttp_protocol_select="http_protocol"
> >>>+rtmpt_protocol_deps="!librtmp_protocol"
> >>>+rtmpt_protocol_select="rtmphttp_protocol"
> >>>--- a/libavformat/Makefile
> >>>+++ b/libavformat/Makefile
> >>>@@ -345,6 +345,7 @@ OBJS-$(CONFIG_MMST_PROTOCOL)             += mmst.o 
> >>>mms.o asf.o
> >>> OBJS-$(CONFIG_RTMP_PROTOCOL)             += rtmpproto.o rtmppkt.o
> >>>+OBJS-$(CONFIG_RTMPHTTP_PROTOCOL)         += rtmphttp.o rtmpproto.o 
> >>>rtmppkt.o
> >>> OBJS-$(CONFIG_RTP_PROTOCOL)              += rtpproto.o
> >>>diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> >>>index 1320a28..69f27ab 100644
> >>>--- a/libavformat/allformats.c
> >>>+++ b/libavformat/allformats.c
> >>>@@ -256,6 +256,8 @@ void av_register_all(void)
> >>>     REGISTER_PROTOCOL (RTMP, rtmp);
> >>>+    REGISTER_PROTOCOL (RTMPT, rtmpt);
> >>>+    REGISTER_PROTOCOL (RTMPHTTP, rtmphttp);
> >>>     REGISTER_PROTOCOL (RTP, rtp);
> >>
> >>I'm not convinced dependencies are fixed properly; you seem to be missing
> >>at least a Makefile entry for the rtmpt protocol.  Try
> >>
> >> configure --disable-everything --enable-protocol=rtmphttp
> >> configure --disable-everything --enable-protocol=rtmpt
> >>
> >>from a clean tree and see if it compiles properly.
> >
> >Tested, it compiles properly.
> 
> Diego is right here, although you apparently manage to make it link
> anyway. The rtmphttp makefile entry is wrong, since it contains both
> the rtmphttp part and the rtmpt part.

I think what you need is

configure:
  rtmphttp_protocol_deps="!librtmp_protocol"
  rtmphttp_protocol_select="http_protocol rtmp_protocol"
  rtmpt_protocol_deps="!librtmp_protocol"
  rtmpt_protocol_select="rtmphttp_protocol"

Makefile:
  OBJS-$(CONFIG_RTMPHTTP_PROTOCOL)         += rtmphttp.o
  OBJS-$(CONFIG_RTMPT_PROTOCOL)        += rtmpproto.o rtmppkt.o

This should both compile and link properly (please test) and express
the semantic dependencies correctly.

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


Re: [libav-devel] [PATCH 2/2] RTMPT protocol support

2012-06-17 Thread Martin Storsjö

On Sun, 17 Jun 2012, Diego Biurrun wrote:


On Sun, Jun 17, 2012 at 05:02:15PM +0300, Martin Storsjö wrote:

On Sun, 17 Jun 2012, Samuel Pitoiset wrote:

On Sun, Jun 17, 2012 at 3:43 PM, Diego Biurrun  wrote:

On Sat, Jun 16, 2012 at 12:50:36PM +0200, Samuel Pitoiset wrote:

This adds two protocols, but one of them is an internal implementation
detail just used as an abstraction layer/generalization in the code. The
RTMPT protocol implementation uses rtmphttp:// as an alternative to the
tcp:// protocol. This allows moving most of the lower level logic out
from the higher level generic rtmp code.
---
- Fix missing proper dependecies in configure

--- a/configure
+++ b/configure
@@ -1511,6 +1511,10 @@ mmsh_protocol_select="http_protocol"
 rtmp_protocol_deps="!librtmp_protocol"
 rtmp_protocol_select="tcp_protocol"
+rtmphttp_protocol_deps="!librtmp_protocol"
+rtmphttp_protocol_select="http_protocol"
+rtmpt_protocol_deps="!librtmp_protocol"
+rtmpt_protocol_select="rtmphttp_protocol"
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -345,6 +345,7 @@ OBJS-$(CONFIG_MMST_PROTOCOL)             += mmst.o mms.o 
asf.o
 OBJS-$(CONFIG_RTMP_PROTOCOL)             += rtmpproto.o rtmppkt.o
+OBJS-$(CONFIG_RTMPHTTP_PROTOCOL)         += rtmphttp.o rtmpproto.o rtmppkt.o
 OBJS-$(CONFIG_RTP_PROTOCOL)              += rtpproto.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1320a28..69f27ab 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -256,6 +256,8 @@ void av_register_all(void)
     REGISTER_PROTOCOL (RTMP, rtmp);
+    REGISTER_PROTOCOL (RTMPT, rtmpt);
+    REGISTER_PROTOCOL (RTMPHTTP, rtmphttp);
     REGISTER_PROTOCOL (RTP, rtp);


I'm not convinced dependencies are fixed properly; you seem to be missing
at least a Makefile entry for the rtmpt protocol.  Try

 configure --disable-everything --enable-protocol=rtmphttp
 configure --disable-everything --enable-protocol=rtmpt

from a clean tree and see if it compiles properly.


Tested, it compiles properly.


Diego is right here, although you apparently manage to make it link
anyway. The rtmphttp makefile entry is wrong, since it contains both
the rtmphttp part and the rtmpt part.


I think what you need is

configure:
 rtmphttp_protocol_deps="!librtmp_protocol"
 rtmphttp_protocol_select="http_protocol rtmp_protocol"


No, this one has no dependencies on the rtmp protocol, only on http - the 
existing configure lines are ok.



 rtmpt_protocol_deps="!librtmp_protocol"
 rtmpt_protocol_select="rtmphttp_protocol"

Makefile:
 OBJS-$(CONFIG_RTMPHTTP_PROTOCOL)         += rtmphttp.o
 OBJS-$(CONFIG_RTMPT_PROTOCOL)        += rtmpproto.o rtmppkt.o


Yes, this would be correct.

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


Re: [libav-devel] [PATCH 2/2] RTMPT protocol support

2012-06-17 Thread Diego Biurrun
On Sun, Jun 17, 2012 at 05:15:04PM +0300, Martin Storsjö wrote:
> On Sun, 17 Jun 2012, Diego Biurrun wrote:
> >On Sun, Jun 17, 2012 at 05:02:15PM +0300, Martin Storsjö wrote:
> >>On Sun, 17 Jun 2012, Samuel Pitoiset wrote:
> >>>On Sun, Jun 17, 2012 at 3:43 PM, Diego Biurrun  wrote:
> On Sat, Jun 16, 2012 at 12:50:36PM +0200, Samuel Pitoiset wrote:
> >This adds two protocols, but one of them is an internal implementation
> >detail just used as an abstraction layer/generalization in the code. The
> >RTMPT protocol implementation uses rtmphttp:// as an alternative to the
> >tcp:// protocol. This allows moving most of the lower level logic out
> >from the higher level generic rtmp code.
> >---
> >- Fix missing proper dependecies in configure
> >
> >--- a/configure
> >+++ b/configure
> >@@ -1511,6 +1511,10 @@ mmsh_protocol_select="http_protocol"
> > rtmp_protocol_deps="!librtmp_protocol"
> > rtmp_protocol_select="tcp_protocol"
> >+rtmphttp_protocol_deps="!librtmp_protocol"
> >+rtmphttp_protocol_select="http_protocol"
> >+rtmpt_protocol_deps="!librtmp_protocol"
> >+rtmpt_protocol_select="rtmphttp_protocol"
> >--- a/libavformat/Makefile
> >+++ b/libavformat/Makefile
> >@@ -345,6 +345,7 @@ OBJS-$(CONFIG_MMST_PROTOCOL)             += mmst.o 
> >mms.o asf.o
> > OBJS-$(CONFIG_RTMP_PROTOCOL)             += rtmpproto.o rtmppkt.o
> >+OBJS-$(CONFIG_RTMPHTTP_PROTOCOL)         += rtmphttp.o rtmpproto.o 
> >rtmppkt.o
> > OBJS-$(CONFIG_RTP_PROTOCOL)              += rtpproto.o
> >diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> >index 1320a28..69f27ab 100644
> >--- a/libavformat/allformats.c
> >+++ b/libavformat/allformats.c
> >@@ -256,6 +256,8 @@ void av_register_all(void)
> >     REGISTER_PROTOCOL (RTMP, rtmp);
> >+    REGISTER_PROTOCOL (RTMPT, rtmpt);
> >+    REGISTER_PROTOCOL (RTMPHTTP, rtmphttp);
> >     REGISTER_PROTOCOL (RTP, rtp);
> 
> I'm not convinced dependencies are fixed properly; you seem to be missing
> at least a Makefile entry for the rtmpt protocol.  Try
> 
>  configure --disable-everything --enable-protocol=rtmphttp
>  configure --disable-everything --enable-protocol=rtmpt
> 
> from a clean tree and see if it compiles properly.
> >>>
> >>>Tested, it compiles properly.
> >>
> >>Diego is right here, although you apparently manage to make it link
> >>anyway. The rtmphttp makefile entry is wrong, since it contains both
> >>the rtmphttp part and the rtmpt part.
> >
> >I think what you need is
> >
> >configure:
> > rtmphttp_protocol_deps="!librtmp_protocol"
> > rtmphttp_protocol_select="http_protocol rtmp_protocol"
> 
> No, this one has no dependencies on the rtmp protocol, only on http
> - the existing configure lines are ok.
> 
> > rtmpt_protocol_deps="!librtmp_protocol"
> > rtmpt_protocol_select="rtmphttp_protocol"
> >
> >Makefile:
> > OBJS-$(CONFIG_RTMPHTTP_PROTOCOL)         += rtmphttp.o
> > OBJS-$(CONFIG_RTMPT_PROTOCOL)        += rtmpproto.o rtmppkt.o
> 
> Yes, this would be correct.

Then I believe the correct build system lines are

configure:
  rtmphttp_protocol_deps="!librtmp_protocol"
  rtmphttp_protocol_select="http_protocol"
  rtmpt_protocol_deps="!librtmp_protocol"
  rtmpt_protocol_select="rtmp_protocol rtmphttp_protocol"

Makefile:
  OBJS-$(CONFIG_RTMPHTTP_PROTOCOL)         += rtmphttp.o
  OBJS-$(CONFIG_RTMPT_PROTOCOL)        += rtmpproto.o rtmppkt.o

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


Re: [libav-devel] [PATCH 2/2] RTMPT protocol support

2012-06-17 Thread Martin Storsjö

On Sun, 17 Jun 2012, Diego Biurrun wrote:


On Sun, Jun 17, 2012 at 05:15:04PM +0300, Martin Storsjö wrote:

On Sun, 17 Jun 2012, Diego Biurrun wrote:

On Sun, Jun 17, 2012 at 05:02:15PM +0300, Martin Storsjö wrote:

On Sun, 17 Jun 2012, Samuel Pitoiset wrote:

On Sun, Jun 17, 2012 at 3:43 PM, Diego Biurrun  wrote:

On Sat, Jun 16, 2012 at 12:50:36PM +0200, Samuel Pitoiset wrote:

This adds two protocols, but one of them is an internal implementation
detail just used as an abstraction layer/generalization in the code. The
RTMPT protocol implementation uses rtmphttp:// as an alternative to the
tcp:// protocol. This allows moving most of the lower level logic out
from the higher level generic rtmp code.
---
- Fix missing proper dependecies in configure

--- a/configure
+++ b/configure
@@ -1511,6 +1511,10 @@ mmsh_protocol_select="http_protocol"
 rtmp_protocol_deps="!librtmp_protocol"
 rtmp_protocol_select="tcp_protocol"
+rtmphttp_protocol_deps="!librtmp_protocol"
+rtmphttp_protocol_select="http_protocol"
+rtmpt_protocol_deps="!librtmp_protocol"
+rtmpt_protocol_select="rtmphttp_protocol"
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -345,6 +345,7 @@ OBJS-$(CONFIG_MMST_PROTOCOL)             += mmst.o mms.o 
asf.o
 OBJS-$(CONFIG_RTMP_PROTOCOL)             += rtmpproto.o rtmppkt.o
+OBJS-$(CONFIG_RTMPHTTP_PROTOCOL)         += rtmphttp.o rtmpproto.o rtmppkt.o
 OBJS-$(CONFIG_RTP_PROTOCOL)              += rtpproto.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1320a28..69f27ab 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -256,6 +256,8 @@ void av_register_all(void)
     REGISTER_PROTOCOL (RTMP, rtmp);
+    REGISTER_PROTOCOL (RTMPT, rtmpt);
+    REGISTER_PROTOCOL (RTMPHTTP, rtmphttp);
     REGISTER_PROTOCOL (RTP, rtp);


I'm not convinced dependencies are fixed properly; you seem to be missing
at least a Makefile entry for the rtmpt protocol.  Try

 configure --disable-everything --enable-protocol=rtmphttp
 configure --disable-everything --enable-protocol=rtmpt

from a clean tree and see if it compiles properly.


Tested, it compiles properly.


Diego is right here, although you apparently manage to make it link
anyway. The rtmphttp makefile entry is wrong, since it contains both
the rtmphttp part and the rtmpt part.


I think what you need is

configure:
rtmphttp_protocol_deps="!librtmp_protocol"
rtmphttp_protocol_select="http_protocol rtmp_protocol"


No, this one has no dependencies on the rtmp protocol, only on http
- the existing configure lines are ok.


rtmpt_protocol_deps="!librtmp_protocol"
rtmpt_protocol_select="rtmphttp_protocol"

Makefile:
OBJS-$(CONFIG_RTMPHTTP_PROTOCOL)         += rtmphttp.o
OBJS-$(CONFIG_RTMPT_PROTOCOL)        += rtmpproto.o rtmppkt.o


Yes, this would be correct.


Then I believe the correct build system lines are

configure:
 rtmphttp_protocol_deps="!librtmp_protocol"
 rtmphttp_protocol_select="http_protocol"
 rtmpt_protocol_deps="!librtmp_protocol"
 rtmpt_protocol_select="rtmp_protocol rtmphttp_protocol"


No, rtmpt does not depend on rtmp. Both rtmp and rtmpt are two different 
frontends to the same code, just like https and http, and rtmpt (with your 
suggestions) have the right object file dependencies in the makefile. 
There's nothing saying that the rtmp protocol has to be enabled for the 
rtmpt protocol to work, since one does not use the other, they're on the 
same hierarchical level.


// 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-17 Thread Kostya Shishkov
On Sun, Jun 17, 2012 at 03:01:40PM +0200, Diego Biurrun wrote:
> On Sat, Jun 16, 2012 at 12:36:16PM +0200, Kostya Shishkov wrote:
> > ---
> > As a side note, I must say that lavf ASF demuxer outputs wrong data, so for
> > example eleventh or twelfth frame in
> > http://samples.ffmpeg.org/V-codecs/MSS1/screen_codec.wmv
> > is demuxed wrong compared to MPlayer. And of course it causes decoding 
> > errors.
> 
> Who can fix it? :)
> 
> Please add a Bugzilla entry if we don't have one already...
> 
> > --- /dev/null
> > +++ b/libavcodec/mss1.c
> > @@ -0,0 +1,844 @@
> > +
> > +static void arith_init(ArithCoder *c, GetBitContext *gb)
> 
> av_cold?
> 
> You don't have av_cold on any function, which is surprising.

Yes, I could add some (and I'll do). But this function is called once per
frame.
 
> > +static int arith_get_bit(ArithCoder *c)
> > +{
> > +int range = c->high - c->low + 1;
> > +int bit   = (((c->value - c->low) << 1) + 1) / range;
> > +
> > +if (bit)
> > +c->low += range >> 1;
> > +else
> > +c->high = c->low + (range >> 1) - 1;
> > +
> > +arith_normalise(c);
> > +
> > +return bit;
> > +}
> > +
> > +static int arith_get_bits(ArithCoder *c, int bits)
> > +{
> > +int range = c->high - c->low + 1;
> > +int val   = (((c->value - c->low + 1) << bits) - 1) / range;
> > +int prob  = range * val;
> > +
> > +c->high   = ((prob + range) >> bits) + c->low - 1;
> > +c->low   += prob >> bits;
> > +
> > +arith_normalise(c);
> > +
> > +return val;
> > +}
> > +
> > +static int arith_get_number(ArithCoder *c, int mod_val)
> > +{
> > +int range = c->high - c->low + 1;
> > +int val   = ((c->value - c->low + 1) * mod_val - 1) / range;
> > +int prob  = range * val;
> > +
> > +c->high   = (prob + range) / mod_val + c->low - 1;
> > +c->low   += prob / mod_val;
> > +
> > +arith_normalise(c);
> > +
> > +return val;
> > +}
> 
> This would be easy to refactor in Haskell ;)

The question is why one should do that.

> > +static void model_init(Model *m, int num_syms, int thr_weight)
> 
> av_cold?
> 
> > +static void codec_init(MSS1Context *ctx)
> 
> av_cold?

and pixctx_init() too, done

> > +c->pic.reference = 3;
> > +c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE 
> > |
> > +  FF_BUFFER_HINTS_REUSABLE;
> 
> align
> 
> > +if (!arith_get_bit(&acoder)) {
> > +codec_reset(c);
> > +pal_changed = decode_pal(c, &acoder);
> > +c->corrupted = decode_intra(c, &acoder, 0, 0, avctx->width, 
> > avctx->height);
> > +c->pic.key_frame = 1;
> > +c->pic.pict_type = AV_PICTURE_TYPE_I;
> 
> align
> 
> > +} else {
> > +if (c->corrupted)
> > +return AVERROR_INVALIDDATA;
> > +c->corrupted = decode_inter(c, &acoder, 0, 0, avctx->width, 
> > avctx->height);
> > +c->pic.key_frame = 0;
> > +c->pic.pict_type = AV_PICTURE_TYPE_P;
> > +}
> 
> align
> 
> > +c->mask_linesize = FFALIGN(avctx->coded_width, 16);
> > +c->mask = av_malloc(c->mask_linesize * avctx->coded_height);
> 
> align
> 
> > +static av_cold int decode_init(AVCodecContext *avctx)
> 
> av_cold
> 
> > +static av_cold int decode_end(AVCodecContext *avctx)
> 
> av_cold

?

static av_colder int decode_end()
or
static av_frozen int decode_end()
 
> I thought generic function names like decode_init/decode_end/decode_frame
> should be avoided in modern code.  Should I make this an entry in the dev
> docs?

As you like, I'll prefix them meanwhile.
>From 3074e9b702af27c488c0f6dd6e4f85588f089b85 Mon Sep 17 00:00:00 2001
From: Kostya Shishkov 
Date: Fri, 15 Jun 2012 20:37:37 +0200
Subject: [PATCH] MS Screen 1 decoder

---
 Changelog  |1 +
 doc/general.texi   |2 +
 libavcodec/Makefile|1 +
 libavcodec/allcodecs.c |1 +
 libavcodec/avcodec.h   |1 +
 libavcodec/mss1.c  |  846 
 libavformat/riff.c |1 +
 7 files changed, 853 insertions(+), 0 deletions(-)
 create mode 100644 libavcodec/mss1.c

diff --git a/Changelog b/Changelog
index b80ff88..0b6d2e8 100644
--- a/Changelog
+++ b/Changelog
@@ -25,6 +25,7 @@ version :
   be used with -of old.
 - Indeo Audio decoder
 - channelsplit audio filter
+- Microsoft Screen codec decoder
 
 
 version 0.8:
diff --git a/doc/general.texi b/doc/general.texi
index dee8f9e..10e506c 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -520,6 +520,8 @@ following image formats are supported:
 @item LOCO   @tab @tab  X
 @item lossless MJPEG @tab  X  @tab  X
 @item Microsoft RLE  @tab @tab  X
+@item Microsoft Screen   @tab @tab  X
+@tab Also known as Windows Media Video V7 Screen.
 @item Microsoft Video 1  @tab @tab  X
 @item Mimic  @tab @tab  X
 @tab Used in MSN Messenger Webcam streams.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3bf

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

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

This still lacks a minor bump, I'll add it once the patchset is finalized.

diff --git a/Changelog b/Changelog
index b80ff88..b7c83ac 100644
--- a/Changelog
+++ b/Changelog
@@ -25,6 +25,7 @@ version :
   be used with -of old.
 - Indeo Audio decoder
 - channelsplit audio filter
+- iLBC encoding/decoding via libilbc
 
 
 version 0.8:
diff --git a/configure b/configure
index 4bb2030..953bdff 100755
--- a/configure
+++ b/configure
@@ -176,6 +176,7 @@ External library support:
   --enable-libfreetype enable libfreetype [no]
   --enable-libgsm  enable GSM support via libgsm [no]
   --enable-libmp3lame  enable MP3 encoding via libmp3lame [no]
+  --enable-libilbc enable iLBC de/encoding via libilbc [no]
   --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no]
   --enable-libpulseenable Pulseaudio input via libpulse [no]
   --enable-librtmp enable RTMP[E] support via librtmp [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"
@@ -2913,6 +2917,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
@@ -3202,6 +3207,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..d8f9a83 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -85,6 +85,14 @@ 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
+
+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 +715,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_LIBOPENCORE_AMRNB_DECODER)  += libopencore-amr.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 01d13d5.

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

2012-06-17 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 3/5] Implement the iLBC storage file format

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

This still lacks a minor bump, I'll add it once the patchset is finalized.

diff --git a/doc/general.texi b/doc/general.texi
index d8f9a83..09a1dd5 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -181,6 +181,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 ca4f7a0..d03ca83 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 1320a28..942a713 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..52290e3
--- /dev/null
+++ b/libavformat/ilbc.c
@@ -0,0 +1,139 @@
+/*
+ * 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;
+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_al

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

2012-06-17 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

This still lacks a minor bump, I'll add it once the patchset is finalized.

diff --git a/libavformat/Makefile b/libavformat/Makefile
index d03ca83..e927f07 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 5/5] rtpenc: Support packetizing iLBC

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

This still lacks a minor bump, I'll add it once the patchset is finalized.

diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 71eeb7e..bc1e4f4 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");
+return AVERROR(EINVAL);
+}
+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)
@@ -391,6 +402,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;
@@ -479,6 +520,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


[libav-devel] [PATCH] amr: Cosmetic cleanup

2012-06-17 Thread Martin Storsjö
Add spaces around operators, fix brace placement and whitespace to
match K&R style, vertically align code, remove redundant != 0 and
convert x == 0 into !x.
---
 libavformat/amr.c |   84 +
 1 file changed, 33 insertions(+), 51 deletions(-)

diff --git a/libavformat/amr.c b/libavformat/amr.c
index 96f559b..97eaccc 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -28,27 +28,22 @@ Only mono files are supported.
 #include "avformat.h"
 #include "internal.h"
 
-static const char AMR_header [] = "#!AMR\n";
-static const char AMRWB_header [] = "#!AMR-WB\n";
+static const char AMR_header[] = "#!AMR\n";
+static const char AMRWB_header[] = "#!AMR-WB\n";
 
 #if CONFIG_AMR_MUXER
 static int amr_write_header(AVFormatContext *s)
 {
-AVIOContext *pb = s->pb;
+AVIOContext*pb  = s->pb;
 AVCodecContext *enc = s->streams[0]->codec;
 
 s->priv_data = NULL;
 
-if (enc->codec_id == CODEC_ID_AMR_NB)
-{
+if (enc->codec_id == CODEC_ID_AMR_NB) {
 avio_write(pb, AMR_header,   sizeof(AMR_header)   - 1); /* magic 
number */
-}
-else if(enc->codec_id == CODEC_ID_AMR_WB)
-{
+} else if(enc->codec_id == CODEC_ID_AMR_WB) {
 avio_write(pb, AMRWB_header, sizeof(AMRWB_header) - 1); /* magic 
number */
-}
-else
-{
+} else {
 return -1;
 }
 avio_flush(pb);
@@ -69,7 +64,7 @@ static int amr_probe(AVProbeData *p)
 //This will also trigger multichannel files: "#!AMR_MC1.0\n" and
 //"#!AMR-WB_MC1.0\n" (not supported)
 
-if(memcmp(p->buf,AMR_header,5)==0)
+if (!memcmp(p->buf, AMR_header, 5))
 return AVPROBE_SCORE_MAX;
 else
 return 0;
@@ -85,29 +80,24 @@ static int amr_read_header(AVFormatContext *s)
 avio_read(pb, header, 6);
 
 st = avformat_new_stream(s, NULL);
-if (!st)
-{
+if (!st) {
 return AVERROR(ENOMEM);
 }
-if(memcmp(header,AMR_header,6)!=0)
-{
-avio_read(pb, header+6, 3);
-if(memcmp(header,AMRWB_header,9)!=0)
-{
+if (memcmp(header, AMR_header, 6)) {
+avio_read(pb, header + 6, 3);
+if (memcmp(header, AMRWB_header, 9)) {
 return -1;
 }
 
-st->codec->codec_tag = MKTAG('s', 'a', 'w', 'b');
-st->codec->codec_id = CODEC_ID_AMR_WB;
+st->codec->codec_tag   = MKTAG('s', 'a', 'w', 'b');
+st->codec->codec_id= CODEC_ID_AMR_WB;
 st->codec->sample_rate = 16000;
-}
-else
-{
-st->codec->codec_tag = MKTAG('s', 'a', 'm', 'r');
-st->codec->codec_id = CODEC_ID_AMR_NB;
+} else {
+st->codec->codec_tag   = MKTAG('s', 'a', 'm', 'r');
+st->codec->codec_id= CODEC_ID_AMR_NB;
 st->codec->sample_rate = 8000;
 }
-st->codec->channels = 1;
+st->codec->channels   = 1;
 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
 avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
 
@@ -115,40 +105,33 @@ static int amr_read_header(AVFormatContext *s)
 }
 
 static int amr_read_packet(AVFormatContext *s,
-  AVPacket *pkt)
+   AVPacket *pkt)
 {
 AVCodecContext *enc = s->streams[0]->codec;
 int read, size = 0, toc, mode;
 int64_t pos = avio_tell(s->pb);
 
-if (s->pb->eof_reached)
-{
+if (s->pb->eof_reached) {
 return AVERROR(EIO);
 }
 
 //FIXME this is wrong, this should rather be in a AVParset
-toc=avio_r8(s->pb);
+toc  = avio_r8(s->pb);
 mode = (toc >> 3) & 0x0F;
 
-if (enc->codec_id == CODEC_ID_AMR_NB)
-{
-static const uint8_t packed_size[16] = {12, 13, 15, 17, 19, 20, 26, 
31, 5, 0, 0, 0, 0, 0, 0, 0};
+if (enc->codec_id == CODEC_ID_AMR_NB) {
+static const uint8_t packed_size[16] = { 12, 13, 15, 17, 19, 20, 26, 
31, 5, 0, 0, 0, 0, 0, 0, 0 };
 
-size=packed_size[mode]+1;
-}
-else if(enc->codec_id == CODEC_ID_AMR_WB)
-{
-static uint8_t packed_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 
6, 6, 0, 0, 0, 1, 1};
+size = packed_size[mode] + 1;
+} else if(enc->codec_id == CODEC_ID_AMR_WB) {
+static uint8_t packed_size[16] = { 18, 24, 33, 37, 41, 47, 51, 59, 61, 
6, 6, 0, 0, 0, 1, 1 };
 
-size=packed_size[mode];
-}
-else
-{
+size = packed_size[mode];
+} else {
 assert(0);
 }
 
-if ( (size==0) || av_new_packet(pkt, size))
-{
+if (!size || av_new_packet(pkt, size)) {
 return AVERROR(EIO);
 }
 
@@ -156,13 +139,12 @@ static int amr_read_packet(AVFormatContext *s,
 s->streams[0]->codec->bit_rate = size*8*50;
 
 pkt->stream_index = 0;
-pkt->pos = pos;
-pkt->data[0]=toc;
-pkt->duration= enc->codec_id == CODEC_ID_AMR_NB ? 160 : 320;
-read = avio_read(s->pb, pkt->data+1, size-1);
+pkt->pos  = pos;
+pkt->data[0]  = toc;
+pkt->duration = enc->codec_id == CODEC_ID_AMR_NB ? 160 : 320;
+read  

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

2012-06-17 Thread Diego Biurrun
On Sun, Jun 17, 2012 at 04:54:36PM +0200, Kostya Shishkov wrote:
> On Sun, Jun 17, 2012 at 03:01:40PM +0200, Diego Biurrun wrote:
> > On Sat, Jun 16, 2012 at 12:36:16PM +0200, Kostya Shishkov wrote:
> > > +static int arith_get_bit(ArithCoder *c)
> > > +{
> > > +int range = c->high - c->low + 1;
> > > +int bit   = (((c->value - c->low) << 1) + 1) / range;
> > > +
> > > +if (bit)
> > > +c->low += range >> 1;
> > > +else
> > > +c->high = c->low + (range >> 1) - 1;
> > > +
> > > +arith_normalise(c);
> > > +
> > > +return bit;
> > > +}
> > > +
> > > +static int arith_get_bits(ArithCoder *c, int bits)
> > > +{
> > > +int range = c->high - c->low + 1;
> > > +int val   = (((c->value - c->low + 1) << bits) - 1) / range;
> > > +int prob  = range * val;
> > > +
> > > +c->high   = ((prob + range) >> bits) + c->low - 1;
> > > +c->low   += prob >> bits;
> > > +
> > > +arith_normalise(c);
> > > +
> > > +return val;
> > > +}
> > > +
> > > +static int arith_get_number(ArithCoder *c, int mod_val)
> > > +{
> > > +int range = c->high - c->low + 1;
> > > +int val   = ((c->value - c->low + 1) * mod_val - 1) / range;
> > > +int prob  = range * val;
> > > +
> > > +c->high   = (prob + range) / mod_val + c->low - 1;
> > > +c->low   += prob / mod_val;
> > > +
> > > +arith_normalise(c);
> > > +
> > > +return val;
> > > +}
> > 
> > This would be easy to refactor in Haskell ;)
> 
> The question is why one should do that.

For fun of course :)

> > > +static av_cold int decode_end(AVCodecContext *avctx)
> > 
> > av_cold
> 
> ?
> 
> static av_colder int decode_end()
> or
> static av_frozen int decode_end()

lol, I'm blind - but if in doubt, I'd go for "colder", no need to
freeze it just yet ;)

> > I thought generic function names like decode_init/decode_end/decode_frame
> > should be avoided in modern code.  Should I make this an entry in the dev
> > docs?
> 
> As you like, I'll prefix them meanwhile.

Please harass me if I don't produce a patch soon...

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


[libav-devel] [PATCH] rtpenc: Fix memory leaks in the muxer open function

2012-06-17 Thread Martin Storsjö
Also return a proper error code in these cases.
---
 libavformat/rtpenc.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 71eeb7e..6752fb6 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -198,11 +198,11 @@ static int rtp_write_header(AVFormatContext *s1)
 /* max_header_toc_size + the largest AMR payload must fit */
 if (1 + s->max_frames_per_packet + n > s->max_payload_size) {
 av_log(s1, AV_LOG_ERROR, "RTP max payload size too small for 
AMR\n");
-return -1;
+goto fail;
 }
 if (st->codec->channels != 1) {
 av_log(s1, AV_LOG_ERROR, "Only mono is supported\n");
-return -1;
+goto fail;
 }
 case CODEC_ID_AAC:
 s->num_frames = 0;
@@ -216,6 +216,10 @@ defaultcase:
 }
 
 return 0;
+
+fail:
+av_freep(&s->buf);
+return AVERROR(EINVAL);
 }
 
 /* send an rtcp sender report packet */
-- 
1.7.9.4

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


Re: [libav-devel] [PATCH] avcodec_init_packet documentation

2012-06-17 Thread Martin Storsjö

On Sat, 9 Jun 2012, Simon A. Eugster wrote:


Patch mentions that AVPacket::data has to be initialized.
Got random segfaults after applying changes in unrelated parts of my
code, took me quite some time to find out that it was because I did
not initialize them.


This is a good idea, I think you're not the only one who have run into 
this issue. I think I'd rather have the wording slightly changed though. 
Instead of saying "\c pkt->data and \c pkt->size must be initialized if 
they were not already.", I'd say "Note, this does not touch the data and 
size members" or something along those lines.


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


Re: [libav-devel] [PATCH 06/12] ratecontrol: remove disabled code

2012-06-17 Thread Kostya Shishkov
On Wed, Jun 13, 2012 at 04:34:29PM +0200, Diego Biurrun wrote:
> On Sat, May 19, 2012 at 05:34:19PM +0200, Diego Biurrun wrote:
> > On Fri, Jul 29, 2011 at 01:02:40PM +0200, Diego Biurrun wrote:
> > > ---
> > >  libavcodec/ratecontrol.c |   12 
> > >  1 files changed, 0 insertions(+), 12 deletions(-)
> > 
> > ping
> 
> .. ping ..

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


Re: [libav-devel] [PATCH] amr: Cosmetic cleanup

2012-06-17 Thread Diego Biurrun
On Sun, Jun 17, 2012 at 06:14:06PM +0300, Martin Storsjö wrote:
> 
> --- a/libavformat/amr.c
> +++ b/libavformat/amr.c
> @@ -28,27 +28,22 @@ Only mono files are supported.
>  
> -static const char AMR_header [] = "#!AMR\n";
> -static const char AMRWB_header [] = "#!AMR-WB\n";
> +static const char AMR_header[] = "#!AMR\n";
> +static const char AMRWB_header[] = "#!AMR-WB\n";

align the =

> +} else if(enc->codec_id == CODEC_ID_AMR_WB) {

if (

> @@ -69,7 +64,7 @@ static int amr_probe(AVProbeData *p)
>  //This will also trigger multichannel files: "#!AMR_MC1.0\n" and
>  //"#!AMR-WB_MC1.0\n" (not supported)

space after //, more below

> @@ -85,29 +80,24 @@ static int amr_read_header(AVFormatContext *s)
>  
>  st = avformat_new_stream(s, NULL);
> -if (!st)
> -{
> +if (!st) {
>  return AVERROR(ENOMEM);
>  }

drop {}

> @@ -115,40 +105,33 @@ static int amr_read_header(AVFormatContext *s)
>  
>  static int amr_read_packet(AVFormatContext *s,
> -  AVPacket *pkt)
> +   AVPacket *pkt)

join the lines instead

> +if (s->pb->eof_reached) {
>  return AVERROR(EIO);
>  }

drop {}

> -static const uint8_t packed_size[16] = {12, 13, 15, 17, 19, 20, 26, 
> 31, 5, 0, 0, 0, 0, 0, 0, 0};
> +static const uint8_t packed_size[16] = { 12, 13, 15, 17, 19, 20, 26, 
> 31, 5, 0, 0, 0, 0, 0, 0, 0 };

Break this long line.

> -static uint8_t packed_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 
> 61, 6, 6, 0, 0, 0, 1, 1};
> +static uint8_t packed_size[16] = { 18, 24, 33, 37, 41, 47, 51, 59, 
> 61, 6, 6, 0, 0, 0, 1, 1 };

ditto

> -if ( (size==0) || av_new_packet(pkt, size))
> -{
> +if (!size || av_new_packet(pkt, size)) {
>  return AVERROR(EIO);
>  }

drop {}

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


Re: [libav-devel] [PATCH 2/2] RTMPT protocol support

2012-06-17 Thread Samuel Pitoiset
On Sun, Jun 17, 2012 at 4:15 PM, Martin Storsjö  wrote:
> On Sun, 17 Jun 2012, Diego Biurrun wrote:
>
>> On Sun, Jun 17, 2012 at 05:02:15PM +0300, Martin Storsjö wrote:
>>>
>>> On Sun, 17 Jun 2012, Samuel Pitoiset wrote:

 On Sun, Jun 17, 2012 at 3:43 PM, Diego Biurrun  wrote:
>
> On Sat, Jun 16, 2012 at 12:50:36PM +0200, Samuel Pitoiset wrote:
>>
>> This adds two protocols, but one of them is an internal implementation
>> detail just used as an abstraction layer/generalization in the code.
>> The
>> RTMPT protocol implementation uses rtmphttp:// as an alternative to
>> the
>> tcp:// protocol. This allows moving most of the lower level logic out
>> from the higher level generic rtmp code.
>> ---
>> - Fix missing proper dependecies in configure
>>
>> --- a/configure
>> +++ b/configure
>> @@ -1511,6 +1511,10 @@ mmsh_protocol_select="http_protocol"
>>  rtmp_protocol_deps="!librtmp_protocol"
>>  rtmp_protocol_select="tcp_protocol"
>> +rtmphttp_protocol_deps="!librtmp_protocol"
>> +rtmphttp_protocol_select="http_protocol"
>> +rtmpt_protocol_deps="!librtmp_protocol"
>> +rtmpt_protocol_select="rtmphttp_protocol"
>> --- a/libavformat/Makefile
>> +++ b/libavformat/Makefile
>> @@ -345,6 +345,7 @@ OBJS-$(CONFIG_MMST_PROTOCOL)             += mmst.o
>> mms.o asf.o
>>  OBJS-$(CONFIG_RTMP_PROTOCOL)             += rtmpproto.o rtmppkt.o
>> +OBJS-$(CONFIG_RTMPHTTP_PROTOCOL)         += rtmphttp.o rtmpproto.o
>> rtmppkt.o
>>  OBJS-$(CONFIG_RTP_PROTOCOL)              += rtpproto.o
>> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
>> index 1320a28..69f27ab 100644
>> --- a/libavformat/allformats.c
>> +++ b/libavformat/allformats.c
>> @@ -256,6 +256,8 @@ void av_register_all(void)
>>      REGISTER_PROTOCOL (RTMP, rtmp);
>> +    REGISTER_PROTOCOL (RTMPT, rtmpt);
>> +    REGISTER_PROTOCOL (RTMPHTTP, rtmphttp);
>>      REGISTER_PROTOCOL (RTP, rtp);
>
>
> I'm not convinced dependencies are fixed properly; you seem to be
> missing
> at least a Makefile entry for the rtmpt protocol.  Try
>
>  configure --disable-everything --enable-protocol=rtmphttp
>  configure --disable-everything --enable-protocol=rtmpt
>
> from a clean tree and see if it compiles properly.


 Tested, it compiles properly.
>>>
>>>
>>> Diego is right here, although you apparently manage to make it link
>>> anyway. The rtmphttp makefile entry is wrong, since it contains both
>>> the rtmphttp part and the rtmpt part.
>>
>>
>> I think what you need is
>>
>> configure:
>>  rtmphttp_protocol_deps="!librtmp_protocol"
>>  rtmphttp_protocol_select="http_protocol rtmp_protocol"
>
>
> No, this one has no dependencies on the rtmp protocol, only on http - the
> existing configure lines are ok.
>
>
>>  rtmpt_protocol_deps="!librtmp_protocol"
>>  rtmpt_protocol_select="rtmphttp_protocol"
>>
>> Makefile:
>>  OBJS-$(CONFIG_RTMPHTTP_PROTOCOL)         += rtmphttp.o
>>  OBJS-$(CONFIG_RTMPT_PROTOCOL)            += rtmpproto.o rtmppkt.o
>
>
> Yes, this would be correct.

Yes, works fine, thanks to you.


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


[libav-devel] [PATCH] amr: Cosmetic cleanup

2012-06-17 Thread Martin Storsjö
Add spaces around operators, fix brace placement and whitespace to
match K&R style, vertically align code, remove redundant != 0 and
convert x == 0 into !x, drop useless braces.
---
 libavformat/amr.c |   97 ++---
 1 file changed, 40 insertions(+), 57 deletions(-)

diff --git a/libavformat/amr.c b/libavformat/amr.c
index 96f559b..12b2b7f 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -28,27 +28,22 @@ Only mono files are supported.
 #include "avformat.h"
 #include "internal.h"
 
-static const char AMR_header [] = "#!AMR\n";
-static const char AMRWB_header [] = "#!AMR-WB\n";
+static const char AMR_header[]   = "#!AMR\n";
+static const char AMRWB_header[] = "#!AMR-WB\n";
 
 #if CONFIG_AMR_MUXER
 static int amr_write_header(AVFormatContext *s)
 {
-AVIOContext *pb = s->pb;
+AVIOContext*pb  = s->pb;
 AVCodecContext *enc = s->streams[0]->codec;
 
 s->priv_data = NULL;
 
-if (enc->codec_id == CODEC_ID_AMR_NB)
-{
+if (enc->codec_id == CODEC_ID_AMR_NB) {
 avio_write(pb, AMR_header,   sizeof(AMR_header)   - 1); /* magic 
number */
-}
-else if(enc->codec_id == CODEC_ID_AMR_WB)
-{
+} else if (enc->codec_id == CODEC_ID_AMR_WB) {
 avio_write(pb, AMRWB_header, sizeof(AMRWB_header) - 1); /* magic 
number */
-}
-else
-{
+} else {
 return -1;
 }
 avio_flush(pb);
@@ -65,11 +60,11 @@ static int amr_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 static int amr_probe(AVProbeData *p)
 {
-//Only check for "#!AMR" which could be amr-wb, amr-nb.
-//This will also trigger multichannel files: "#!AMR_MC1.0\n" and
-//"#!AMR-WB_MC1.0\n" (not supported)
+// Only check for "#!AMR" which could be amr-wb, amr-nb.
+// This will also trigger multichannel files: "#!AMR_MC1.0\n" and
+// "#!AMR-WB_MC1.0\n" (not supported)
 
-if(memcmp(p->buf,AMR_header,5)==0)
+if (!memcmp(p->buf, AMR_header, 5))
 return AVPROBE_SCORE_MAX;
 else
 return 0;
@@ -86,83 +81,71 @@ static int amr_read_header(AVFormatContext *s)
 
 st = avformat_new_stream(s, NULL);
 if (!st)
-{
 return AVERROR(ENOMEM);
-}
-if(memcmp(header,AMR_header,6)!=0)
-{
-avio_read(pb, header+6, 3);
-if(memcmp(header,AMRWB_header,9)!=0)
-{
+if (memcmp(header, AMR_header, 6)) {
+avio_read(pb, header + 6, 3);
+if (memcmp(header, AMRWB_header, 9)) {
 return -1;
 }
 
-st->codec->codec_tag = MKTAG('s', 'a', 'w', 'b');
-st->codec->codec_id = CODEC_ID_AMR_WB;
+st->codec->codec_tag   = MKTAG('s', 'a', 'w', 'b');
+st->codec->codec_id= CODEC_ID_AMR_WB;
 st->codec->sample_rate = 16000;
-}
-else
-{
-st->codec->codec_tag = MKTAG('s', 'a', 'm', 'r');
-st->codec->codec_id = CODEC_ID_AMR_NB;
+} else {
+st->codec->codec_tag   = MKTAG('s', 'a', 'm', 'r');
+st->codec->codec_id= CODEC_ID_AMR_NB;
 st->codec->sample_rate = 8000;
 }
-st->codec->channels = 1;
+st->codec->channels   = 1;
 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
 avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
 
 return 0;
 }
 
-static int amr_read_packet(AVFormatContext *s,
-  AVPacket *pkt)
+static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
 AVCodecContext *enc = s->streams[0]->codec;
 int read, size = 0, toc, mode;
 int64_t pos = avio_tell(s->pb);
 
-if (s->pb->eof_reached)
-{
+if (s->pb->eof_reached) {
 return AVERROR(EIO);
 }
 
-//FIXME this is wrong, this should rather be in a AVParset
-toc=avio_r8(s->pb);
+// FIXME this is wrong, this should rather be in a AVParset
+toc  = avio_r8(s->pb);
 mode = (toc >> 3) & 0x0F;
 
-if (enc->codec_id == CODEC_ID_AMR_NB)
-{
-static const uint8_t packed_size[16] = {12, 13, 15, 17, 19, 20, 26, 
31, 5, 0, 0, 0, 0, 0, 0, 0};
+if (enc->codec_id == CODEC_ID_AMR_NB) {
+static const uint8_t packed_size[16] = {
+12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0
+};
 
-size=packed_size[mode]+1;
-}
-else if(enc->codec_id == CODEC_ID_AMR_WB)
-{
-static uint8_t packed_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 
6, 6, 0, 0, 0, 1, 1};
+size = packed_size[mode] + 1;
+} else if(enc->codec_id == CODEC_ID_AMR_WB) {
+static uint8_t packed_size[16] = {
+18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1
+};
 
-size=packed_size[mode];
-}
-else
-{
+size = packed_size[mode];
+} else {
 assert(0);
 }
 
-if ( (size==0) || av_new_packet(pkt, size))
-{
+if (!size || av_new_packet(pkt, size))
 return AVERROR(EIO);
-}
 
 /* Both AMR formats have 50 frames per second */
 s->streams[0]->codec->bit_rate = size*8*50;

Re: [libav-devel] [PATCH] amr: Cosmetic cleanup

2012-06-17 Thread Diego Biurrun
On Sun, Jun 17, 2012 at 06:43:04PM +0300, Martin Storsjö wrote:
> Add spaces around operators, fix brace placement and whitespace to
> match K&R style, vertically align code, remove redundant != 0 and
> convert x == 0 into !x, drop useless braces.
> ---
>  libavformat/amr.c |   97 
> ++---
>  1 file changed, 40 insertions(+), 57 deletions(-)

LGTM

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


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

2012-06-17 Thread Justin Ruggles
On 06/17/2012 11:03 AM, Martin Storsjö wrote:
> +if ((ret = ff_alloc_packet(avpkt, 50))) {
> +av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
> +return ret;
> +}
> +
> +WebRtcIlbcfix_EncodeImpl((WebRtc_UWord16*) avpkt->data, (const 
> WebRtc_Word16*) frame->data[0], &s->encoder);
> +
> +avpkt->pts  = frame->pts;

Since the encoder does not use CODEC_CAP_DELAY, it does not need to set
pts. Packet pts will be set to the frame pts by avcodec_encode_audio2().

-Justin

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


[libav-devel] [PATCH] RTMPT protocol support

2012-06-17 Thread Samuel Pitoiset
This adds two protocols, but one of them is an internal implementation
detail just used as an abstraction layer/generalization in the code. The
RTMPT protocol implementation uses rtmphttp:// as an alternative to the
tcp:// protocol. This allows moving most of the lower level logic out
from the higher level generic rtmp code.
---
- Fix capacity of the output buffer.
- Free stuff allocated in rtmp_http_open in case of failure (ie. 
rtmp_http_close()).
- Fix reading and parsing the client ID.
- Remove STATE_OPENED which is not necessary.
- Fix the 'close' request by reading previous unfinished request.
 Changelog|1 +
 configure|4 +
 doc/protocols.texi   |8 ++
 libavformat/Makefile |2 +
 libavformat/allformats.c |2 +
 libavformat/rtmphttp.c   |  247 ++
 libavformat/rtmpproto.c  |   31 +-
 libavformat/version.h|4 +-
 8 files changed, 294 insertions(+), 5 deletions(-)
 create mode 100644 libavformat/rtmphttp.c

diff --git a/Changelog b/Changelog
index b80ff88..4288aa3 100644
--- a/Changelog
+++ b/Changelog
@@ -25,6 +25,7 @@ version :
   be used with -of old.
 - Indeo Audio decoder
 - channelsplit audio filter
+- RTMPT protocol support
 
 
 version 0.8:
diff --git a/configure b/configure
index 4bb2030..d614366 100755
--- a/configure
+++ b/configure
@@ -1511,6 +1511,10 @@ mmsh_protocol_select="http_protocol"
 mmst_protocol_deps="network"
 rtmp_protocol_deps="!librtmp_protocol"
 rtmp_protocol_select="tcp_protocol"
+rtmphttp_protocol_deps="!librtmp_protocol"
+rtmphttp_protocol_select="http_protocol"
+rtmpt_protocol_deps="!librtmp_protocol"
+rtmpt_protocol_select="rtmphttp_protocol"
 rtp_protocol_select="udp_protocol"
 sctp_protocol_deps="network netinet_sctp_h"
 tcp_protocol_deps="network"
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 8492033..0b4f1b1 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -243,6 +243,14 @@ For example to read with @command{avplay} a multimedia 
resource named
 avplay rtmp://myserver/vod/sample
 @end example
 
+@section rtmpt
+
+Real-Time Messaging Protocol tunneled through HTTP.
+
+The Real-Time Messaging Protocol tunneled through HTTP (RTMPT) is used
+for streaming multimedia content within HTTP requests to traverse
+firewalls.
+
 @section rtmp, rtmpe, rtmps, rtmpt, rtmpte
 
 Real-Time Messaging Protocol and its variants supported through
diff --git a/libavformat/Makefile b/libavformat/Makefile
index ca4f7a0..6262324 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -345,6 +345,8 @@ OBJS-$(CONFIG_MMST_PROTOCOL) += mmst.o mms.o 
asf.o
 OBJS-$(CONFIG_MD5_PROTOCOL)  += md5proto.o
 OBJS-$(CONFIG_PIPE_PROTOCOL) += file.o
 OBJS-$(CONFIG_RTMP_PROTOCOL) += rtmpproto.o rtmppkt.o
+OBJS-$(CONFIG_RTMPHTTP_PROTOCOL) += rtmphttp.o
+OBJS-$(CONFIG_RTMPT_PROTOCOL)+= rtmpproto.o rtmppkt.o
 OBJS-$(CONFIG_RTP_PROTOCOL)  += rtpproto.o
 OBJS-$(CONFIG_SCTP_PROTOCOL) += sctp.o
 OBJS-$(CONFIG_TCP_PROTOCOL)  += tcp.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1320a28..69f27ab 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -256,6 +256,8 @@ void av_register_all(void)
 REGISTER_PROTOCOL (MD5,  md5);
 REGISTER_PROTOCOL (PIPE, pipe);
 REGISTER_PROTOCOL (RTMP, rtmp);
+REGISTER_PROTOCOL (RTMPT, rtmpt);
+REGISTER_PROTOCOL (RTMPHTTP, rtmphttp);
 REGISTER_PROTOCOL (RTP, rtp);
 REGISTER_PROTOCOL (SCTP, sctp);
 REGISTER_PROTOCOL (TCP, tcp);
diff --git a/libavformat/rtmphttp.c b/libavformat/rtmphttp.c
new file mode 100644
index 000..e430570
--- /dev/null
+++ b/libavformat/rtmphttp.c
@@ -0,0 +1,247 @@
+/*
+ * RTMP HTTP network protocol
+ * Copyright (c) 2012 Samuel Pitoiset
+ *
+ * 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
+ * RTMP HTTP protocol
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/intfloat.h"
+#include "libavutil/opt.h"
+#include "internal.h"
+#include "http.h"
+
+#define RTMPT_DEFAULT_PORT 80
+
+/* protocol handler state */
+typedef enum {
+STATE_START,///< client has not done anything yet
+STATE_WAITING,  ///< c

[libav-devel] [PATCH 1/2] amr: More space cleanup

2012-06-17 Thread Martin Storsjö
This was missed in the previous cleanup patch.
---
 libavformat/amr.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/amr.c b/libavformat/amr.c
index 12b2b7f..efb5edd 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -123,7 +123,7 @@ static int amr_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 };
 
 size = packed_size[mode] + 1;
-} else if(enc->codec_id == CODEC_ID_AMR_WB) {
+} else if (enc->codec_id == CODEC_ID_AMR_WB) {
 static uint8_t packed_size[16] = {
 18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1
 };
-- 
1.7.9.4

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


[libav-devel] [PATCH 2/2] amr: Mark an array const

2012-06-17 Thread Martin Storsjö
---
 libavformat/amr.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/amr.c b/libavformat/amr.c
index efb5edd..f20bc0a 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -124,7 +124,7 @@ static int amr_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 size = packed_size[mode] + 1;
 } else if (enc->codec_id == CODEC_ID_AMR_WB) {
-static uint8_t packed_size[16] = {
+static const uint8_t packed_size[16] = {
 18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1
 };
 
-- 
1.7.9.4

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


Re: [libav-devel] [PATCH] RTMPT protocol support

2012-06-17 Thread Samuel Pitoiset
On Sun, Jun 17, 2012 at 6:00 PM, Samuel Pitoiset
 wrote:
> This adds two protocols, but one of them is an internal implementation
> detail just used as an abstraction layer/generalization in the code. The
> RTMPT protocol implementation uses rtmphttp:// as an alternative to the
> tcp:// protocol. This allows moving most of the lower level logic out
> from the higher level generic rtmp code.
> ---
> - Fix capacity of the output buffer.
> - Free stuff allocated in rtmp_http_open in case of failure (ie. 
> rtmp_http_close()).
> - Fix reading and parsing the client ID.
> - Remove STATE_OPENED which is not necessary.
> - Fix the 'close' request by reading previous unfinished request.
>  Changelog                |    1 +
>  configure                |    4 +
>  doc/protocols.texi       |    8 ++
>  libavformat/Makefile     |    2 +
>  libavformat/allformats.c |    2 +
>  libavformat/rtmphttp.c   |  247 
> ++
>  libavformat/rtmpproto.c  |   31 +-
>  libavformat/version.h    |    4 +-
>  8 files changed, 294 insertions(+), 5 deletions(-)
>  create mode 100644 libavformat/rtmphttp.c

And fix building pinpointed by Diego.

I still have to fix the nonblocking stuff for publishing a stream... :/


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


[libav-devel] [PATCH] RTMPT protocol support

2012-06-17 Thread Samuel Pitoiset
This adds two protocols, but one of them is an internal implementation
detail just used as an abstraction layer/generalization in the code. The
RTMPT protocol implementation uses rtmphttp:// as an alternative to the
tcp:// protocol. This allows moving most of the lower level logic out
from the higher level generic rtmp code.
---
 Changelog|1 +
 configure|4 +
 doc/protocols.texi   |8 ++
 libavformat/Makefile |2 +
 libavformat/allformats.c |2 +
 libavformat/rtmphttp.c   |  267 ++
 libavformat/rtmpproto.c  |   38 ++-
 libavformat/version.h|4 +-
 8 files changed, 321 insertions(+), 5 deletions(-)
 create mode 100644 libavformat/rtmphttp.c

diff --git a/Changelog b/Changelog
index b80ff88..4288aa3 100644
--- a/Changelog
+++ b/Changelog
@@ -25,6 +25,7 @@ version :
   be used with -of old.
 - Indeo Audio decoder
 - channelsplit audio filter
+- RTMPT protocol support
 
 
 version 0.8:
diff --git a/configure b/configure
index 4bb2030..d614366 100755
--- a/configure
+++ b/configure
@@ -1511,6 +1511,10 @@ mmsh_protocol_select="http_protocol"
 mmst_protocol_deps="network"
 rtmp_protocol_deps="!librtmp_protocol"
 rtmp_protocol_select="tcp_protocol"
+rtmphttp_protocol_deps="!librtmp_protocol"
+rtmphttp_protocol_select="http_protocol"
+rtmpt_protocol_deps="!librtmp_protocol"
+rtmpt_protocol_select="rtmphttp_protocol"
 rtp_protocol_select="udp_protocol"
 sctp_protocol_deps="network netinet_sctp_h"
 tcp_protocol_deps="network"
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 8492033..0b4f1b1 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -243,6 +243,14 @@ For example to read with @command{avplay} a multimedia 
resource named
 avplay rtmp://myserver/vod/sample
 @end example
 
+@section rtmpt
+
+Real-Time Messaging Protocol tunneled through HTTP.
+
+The Real-Time Messaging Protocol tunneled through HTTP (RTMPT) is used
+for streaming multimedia content within HTTP requests to traverse
+firewalls.
+
 @section rtmp, rtmpe, rtmps, rtmpt, rtmpte
 
 Real-Time Messaging Protocol and its variants supported through
diff --git a/libavformat/Makefile b/libavformat/Makefile
index ca4f7a0..6262324 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -345,6 +345,8 @@ OBJS-$(CONFIG_MMST_PROTOCOL) += mmst.o mms.o 
asf.o
 OBJS-$(CONFIG_MD5_PROTOCOL)  += md5proto.o
 OBJS-$(CONFIG_PIPE_PROTOCOL) += file.o
 OBJS-$(CONFIG_RTMP_PROTOCOL) += rtmpproto.o rtmppkt.o
+OBJS-$(CONFIG_RTMPHTTP_PROTOCOL) += rtmphttp.o
+OBJS-$(CONFIG_RTMPT_PROTOCOL)+= rtmpproto.o rtmppkt.o
 OBJS-$(CONFIG_RTP_PROTOCOL)  += rtpproto.o
 OBJS-$(CONFIG_SCTP_PROTOCOL) += sctp.o
 OBJS-$(CONFIG_TCP_PROTOCOL)  += tcp.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1320a28..69f27ab 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -256,6 +256,8 @@ void av_register_all(void)
 REGISTER_PROTOCOL (MD5,  md5);
 REGISTER_PROTOCOL (PIPE, pipe);
 REGISTER_PROTOCOL (RTMP, rtmp);
+REGISTER_PROTOCOL (RTMPT, rtmpt);
+REGISTER_PROTOCOL (RTMPHTTP, rtmphttp);
 REGISTER_PROTOCOL (RTP, rtp);
 REGISTER_PROTOCOL (SCTP, sctp);
 REGISTER_PROTOCOL (TCP, tcp);
diff --git a/libavformat/rtmphttp.c b/libavformat/rtmphttp.c
new file mode 100644
index 000..cc45e27
--- /dev/null
+++ b/libavformat/rtmphttp.c
@@ -0,0 +1,267 @@
+/*
+ * RTMP HTTP network protocol
+ * Copyright (c) 2012 Samuel Pitoiset
+ *
+ * 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
+ * RTMP HTTP protocol
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/intfloat.h"
+#include "libavutil/opt.h"
+#include "internal.h"
+#include "http.h"
+
+#define RTMPT_DEFAULT_PORT 80
+
+/* protocol handler state */
+typedef enum {
+STATE_START,///< client has not done anything yet
+STATE_WAITING,  ///< client is waiting for a server reply
+STATE_READY,///< client is ready for sending requests
+} ClientState;
+
+/* protocol handler context */
+typedef struct RTMP_HTTPContext {
+URLContext   *stream;   ///< HTTP stream
+char host[256]; 

Re: [libav-devel] [PATCH] RTMPT protocol support

2012-06-17 Thread Samuel Pitoiset
On Sun, Jun 17, 2012 at 6:40 PM, Samuel Pitoiset
 wrote:
> This adds two protocols, but one of them is an internal implementation
> detail just used as an abstraction layer/generalization in the code. The
> RTMPT protocol implementation uses rtmphttp:// as an alternative to the
> tcp:// protocol. This allows moving most of the lower level logic out
> from the higher level generic rtmp code.
> ---
>  Changelog                |    1 +
>  configure                |    4 +
>  doc/protocols.texi       |    8 ++
>  libavformat/Makefile     |    2 +
>  libavformat/allformats.c |    2 +
>  libavformat/rtmphttp.c   |  267 
> ++
>  libavformat/rtmpproto.c  |   38 ++-
>  libavformat/version.h    |    4 +-
>  8 files changed, 321 insertions(+), 5 deletions(-)
>  create mode 100644 libavformat/rtmphttp.c

I (almost) fixed the nonblocking stuff. However, I still get 5 fps in
RTMP instead of 25 fps with RTMP... Any suggestions about that are
welcome. =)


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


Re: [libav-devel] [PATCH] RTMPT protocol support

2012-06-17 Thread Samuel Pitoiset
On Sun, Jun 17, 2012 at 6:48 PM, Samuel Pitoiset
 wrote:
> On Sun, Jun 17, 2012 at 6:40 PM, Samuel Pitoiset
>  wrote:
>> This adds two protocols, but one of them is an internal implementation
>> detail just used as an abstraction layer/generalization in the code. The
>> RTMPT protocol implementation uses rtmphttp:// as an alternative to the
>> tcp:// protocol. This allows moving most of the lower level logic out
>> from the higher level generic rtmp code.
>> ---
>>  Changelog                |    1 +
>>  configure                |    4 +
>>  doc/protocols.texi       |    8 ++
>>  libavformat/Makefile     |    2 +
>>  libavformat/allformats.c |    2 +
>>  libavformat/rtmphttp.c   |  267 
>> ++
>>  libavformat/rtmpproto.c  |   38 ++-
>>  libavformat/version.h    |    4 +-
>>  8 files changed, 321 insertions(+), 5 deletions(-)
>>  create mode 100644 libavformat/rtmphttp.c
>
> I (almost) fixed the nonblocking stuff. However, I still get 5 fps in
> RTMP instead of 25 fps with RTMP... Any suggestions about that are

*RTMPT instead ...

> welcome. =)
>
>
> --
> Best regards,
> Samuel Pitoiset.



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


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

2012-06-17 Thread Justin Ruggles
On 06/17/2012 11:03 AM, Martin Storsjö wrote:
> The library is 3-clause BSD licensed.
> ---
>  Changelog  |1 +
>  configure  |6 ++
>  doc/general.texi   |   10 +++
>  libavcodec/Makefile|2 +
>  libavcodec/allcodecs.c |1 +
>  libavcodec/avcodec.h   |1 +
>  libavcodec/libilbc.c   |  194 
> 
>  libavcodec/utils.c |5 ++
>  8 files changed, 220 insertions(+)
>  create mode 100644 libavcodec/libilbc.c
> 
> This still lacks a minor bump, I'll add it once the patchset is finalized.
[...]
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -85,6 +85,14 @@ 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
> +
> +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.

Maybe also add some introductory info like: "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."

[...]
> +#include "avcodec.h"
> +#include "libavutil/opt.h"
> +#include "internal.h"
> +#include 

put the system header before libav headers

[...]
> +static av_cold int ilbc_decode_close(AVCodecContext *avctx)
> +{
> +return 0;
> +}

This function is not required.

> +static int ilbc_decode_frame(AVCodecContext *avctx, void *data,
> + int *got_frame_ptr, AVPacket *avpkt)
> +{
> +const uint8_t *buf = avpkt->data;
> +int buf_size   = avpkt->size;
> +ILBCDecContext *s  = avctx->priv_data;

align the =

> +int ret;
> +
> +s->frame.nb_samples = s->decoder.blockl;
> +if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
> +av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
> +return ret;
> +}
> +
> +if (s->decoder.no_of_bytes > buf_size) {
> +av_log(avctx, AV_LOG_ERROR, "iLBC frame too short (%u, should be 
> %u)\n",
> +   buf_size, s->decoder.no_of_bytes);
> +return AVERROR_INVALIDDATA;
> +}

I would put the buf_size check before get_buffer().

> +
> +WebRtcIlbcfix_DecodeImpl((WebRtc_Word16*) s->frame.data[0], (const 
> WebRtc_UWord16*) buf, &s->decoder, 1);
> +

break the long line.

can this return an error?

[...]
> +if (avctx->sample_rate != 8000) {
> +av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
> +return AVERROR(ENOSYS);
> +}
> +
> +if (avctx->channels != 1) {
> +av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
> +return AVERROR(ENOSYS);
> +}

why ENOSYS? can iLBC ever be anything other than mono 8kHz? if not,
those should be EINVAL.

> +
> +if ((mode = get_mode(avctx)) < 0)
> +return AVERROR(EINVAL);

Having a private option to set 20ms or 30ms mode could be useful rather
than having to know the corresponding bitrate.


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


Re: [libav-devel] [PATCH] RTMPT protocol support

2012-06-17 Thread Martin Storsjö

On Sun, 17 Jun 2012, Samuel Pitoiset wrote:


This adds two protocols, but one of them is an internal implementation
detail just used as an abstraction layer/generalization in the code. The
RTMPT protocol implementation uses rtmphttp:// as an alternative to the
tcp:// protocol. This allows moving most of the lower level logic out
from the higher level generic rtmp code.
---
Changelog|1 +
configure|4 +
doc/protocols.texi   |8 ++
libavformat/Makefile |2 +
libavformat/allformats.c |2 +
libavformat/rtmphttp.c   |  267 ++
libavformat/rtmpproto.c  |   38 ++-
libavformat/version.h|4 +-
8 files changed, 321 insertions(+), 5 deletions(-)
create mode 100644 libavformat/rtmphttp.c

diff --git a/Changelog b/Changelog
index b80ff88..4288aa3 100644
--- a/Changelog
+++ b/Changelog
@@ -25,6 +25,7 @@ version :
  be used with -of old.
- Indeo Audio decoder
- channelsplit audio filter
+- RTMPT protocol support


version 0.8:
diff --git a/configure b/configure
index 4bb2030..d614366 100755
--- a/configure
+++ b/configure
@@ -1511,6 +1511,10 @@ mmsh_protocol_select="http_protocol"
mmst_protocol_deps="network"
rtmp_protocol_deps="!librtmp_protocol"
rtmp_protocol_select="tcp_protocol"
+rtmphttp_protocol_deps="!librtmp_protocol"
+rtmphttp_protocol_select="http_protocol"
+rtmpt_protocol_deps="!librtmp_protocol"
+rtmpt_protocol_select="rtmphttp_protocol"
rtp_protocol_select="udp_protocol"
sctp_protocol_deps="network netinet_sctp_h"
tcp_protocol_deps="network"
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 8492033..0b4f1b1 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -243,6 +243,14 @@ For example to read with @command{avplay} a multimedia 
resource named
avplay rtmp://myserver/vod/sample
@end example

+@section rtmpt
+
+Real-Time Messaging Protocol tunneled through HTTP.
+
+The Real-Time Messaging Protocol tunneled through HTTP (RTMPT) is used
+for streaming multimedia content within HTTP requests to traverse
+firewalls.
+
@section rtmp, rtmpe, rtmps, rtmpt, rtmpte

Real-Time Messaging Protocol and its variants supported through
diff --git a/libavformat/Makefile b/libavformat/Makefile
index ca4f7a0..6262324 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -345,6 +345,8 @@ OBJS-$(CONFIG_MMST_PROTOCOL) += mmst.o mms.o 
asf.o
OBJS-$(CONFIG_MD5_PROTOCOL)  += md5proto.o
OBJS-$(CONFIG_PIPE_PROTOCOL) += file.o
OBJS-$(CONFIG_RTMP_PROTOCOL) += rtmpproto.o rtmppkt.o
+OBJS-$(CONFIG_RTMPHTTP_PROTOCOL) += rtmphttp.o
+OBJS-$(CONFIG_RTMPT_PROTOCOL)+= rtmpproto.o rtmppkt.o
OBJS-$(CONFIG_RTP_PROTOCOL)  += rtpproto.o
OBJS-$(CONFIG_SCTP_PROTOCOL) += sctp.o
OBJS-$(CONFIG_TCP_PROTOCOL)  += tcp.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1320a28..69f27ab 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -256,6 +256,8 @@ void av_register_all(void)
REGISTER_PROTOCOL (MD5,  md5);
REGISTER_PROTOCOL (PIPE, pipe);
REGISTER_PROTOCOL (RTMP, rtmp);
+REGISTER_PROTOCOL (RTMPT, rtmpt);
+REGISTER_PROTOCOL (RTMPHTTP, rtmphttp);


Alphabetic order


REGISTER_PROTOCOL (RTP, rtp);
REGISTER_PROTOCOL (SCTP, sctp);
REGISTER_PROTOCOL (TCP, tcp);
diff --git a/libavformat/rtmphttp.c b/libavformat/rtmphttp.c
new file mode 100644
index 000..cc45e27
--- /dev/null
+++ b/libavformat/rtmphttp.c
@@ -0,0 +1,267 @@
+/*
+ * RTMP HTTP network protocol
+ * Copyright (c) 2012 Samuel Pitoiset
+ *
+ * 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
+ * RTMP HTTP protocol
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/intfloat.h"
+#include "libavutil/opt.h"
+#include "internal.h"
+#include "http.h"
+
+#define RTMPT_DEFAULT_PORT 80
+
+/* protocol handler state */
+typedef enum {
+STATE_START,///< client has not done anything yet
+STATE_WAITING,  ///< client is waiting for a server reply
+STATE_READY,///< client is ready for sending requests
+} ClientState;
+
+/* protocol handler context */
+typedef struct RTMP_HTTPContext {
+URLContext   *stream;   ///< HTTP stream
+

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

2012-06-17 Thread Justin Ruggles
On 06/17/2012 11:03 AM, Martin Storsjö wrote:
> +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;
> +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;
> +} else {
> +av_log(s, AV_LOG_ERROR, "Unrecognized iLBC file header\n");
> +return AVERROR_INVALIDDATA;
> +}
> +
> +return 0;
> +}

Since you're setting only packet durations and not timestamps, you
should also set st->start_time to 0 when initializing the stream.

The rest looks good.

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


Re: [libav-devel] [PATCH] RTMPT protocol support

2012-06-17 Thread Martin Storsjö

On Sun, 17 Jun 2012, Samuel Pitoiset wrote:


+static int rtmp_http_close(URLContext *h)
+{
+RTMP_HTTPContext *rt = h->priv_data;
+uint8_t tmp_buf[2048];
+int ret = 0;
+
+if (rt->state >= STATE_WAITING) {
+/* set stream into nonblocking mode */
+rt->stream->flags |= AVIO_FLAG_NONBLOCK;
+
+do {
+ret = rtmp_http_read(h, tmp_buf, sizeof(tmp_buf));
+} while (ret != AVERROR(EAGAIN));


You probably want while (ret > 0) here, since if you run into some other 
error than EAGAIN, you'll loop infinitely.


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


Re: [libav-devel] [PATCH 2/8] lavfi/audio: don't set cur_buf in ff_filter_samples().

2012-06-17 Thread Justin Ruggles
On 06/17/2012 06:17 AM, Anton Khirnov wrote:
> It's redundant, since the input buffer is passed as a parameter to the
> filter_samples() callback, and can lead to stale pointers remaining on
> the link.

makes sense. LGTM.

-Justin

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


Re: [libav-devel] [PATCH 5/8] lavfi/fifo: add audio version of the fifo filter.

2012-06-17 Thread Justin Ruggles
On 06/17/2012 06:17 AM, Anton Khirnov wrote:
> ---
>  libavfilter/Makefile |1 +
>  libavfilter/allfilters.c |1 +
>  libavfilter/fifo.c   |   71 
> +-
>  3 files changed, 53 insertions(+), 20 deletions(-)

LGTM

-Justin

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


[libav-devel] [PATCH] RTMPT protocol support

2012-06-17 Thread Samuel Pitoiset
This adds two protocols, but one of them is an internal implementation
detail just used as an abstraction layer/generalization in the code. The
RTMPT protocol implementation uses rtmphttp:// as an alternative to the
tcp:// protocol. This allows moving most of the lower level logic out
from the higher level generic rtmp code.
---
 Changelog|1 +
 configure|4 +
 doc/protocols.texi   |8 ++
 libavformat/Makefile |2 +
 libavformat/allformats.c |2 +
 libavformat/rtmphttp.c   |  245 ++
 libavformat/rtmpproto.c  |   31 +-
 libavformat/version.h|4 +-
 8 files changed, 292 insertions(+), 5 deletions(-)
 create mode 100644 libavformat/rtmphttp.c

diff --git a/Changelog b/Changelog
index b80ff88..4288aa3 100644
--- a/Changelog
+++ b/Changelog
@@ -25,6 +25,7 @@ version :
   be used with -of old.
 - Indeo Audio decoder
 - channelsplit audio filter
+- RTMPT protocol support
 
 
 version 0.8:
diff --git a/configure b/configure
index 4bb2030..d614366 100755
--- a/configure
+++ b/configure
@@ -1511,6 +1511,10 @@ mmsh_protocol_select="http_protocol"
 mmst_protocol_deps="network"
 rtmp_protocol_deps="!librtmp_protocol"
 rtmp_protocol_select="tcp_protocol"
+rtmphttp_protocol_deps="!librtmp_protocol"
+rtmphttp_protocol_select="http_protocol"
+rtmpt_protocol_deps="!librtmp_protocol"
+rtmpt_protocol_select="rtmphttp_protocol"
 rtp_protocol_select="udp_protocol"
 sctp_protocol_deps="network netinet_sctp_h"
 tcp_protocol_deps="network"
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 8492033..0b4f1b1 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -243,6 +243,14 @@ For example to read with @command{avplay} a multimedia 
resource named
 avplay rtmp://myserver/vod/sample
 @end example
 
+@section rtmpt
+
+Real-Time Messaging Protocol tunneled through HTTP.
+
+The Real-Time Messaging Protocol tunneled through HTTP (RTMPT) is used
+for streaming multimedia content within HTTP requests to traverse
+firewalls.
+
 @section rtmp, rtmpe, rtmps, rtmpt, rtmpte
 
 Real-Time Messaging Protocol and its variants supported through
diff --git a/libavformat/Makefile b/libavformat/Makefile
index ca4f7a0..6262324 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -345,6 +345,8 @@ OBJS-$(CONFIG_MMST_PROTOCOL) += mmst.o mms.o 
asf.o
 OBJS-$(CONFIG_MD5_PROTOCOL)  += md5proto.o
 OBJS-$(CONFIG_PIPE_PROTOCOL) += file.o
 OBJS-$(CONFIG_RTMP_PROTOCOL) += rtmpproto.o rtmppkt.o
+OBJS-$(CONFIG_RTMPHTTP_PROTOCOL) += rtmphttp.o
+OBJS-$(CONFIG_RTMPT_PROTOCOL)+= rtmpproto.o rtmppkt.o
 OBJS-$(CONFIG_RTP_PROTOCOL)  += rtpproto.o
 OBJS-$(CONFIG_SCTP_PROTOCOL) += sctp.o
 OBJS-$(CONFIG_TCP_PROTOCOL)  += tcp.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1320a28..42c588f 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -256,6 +256,8 @@ void av_register_all(void)
 REGISTER_PROTOCOL (MD5,  md5);
 REGISTER_PROTOCOL (PIPE, pipe);
 REGISTER_PROTOCOL (RTMP, rtmp);
+REGISTER_PROTOCOL (RTMPHTTP, rtmphttp);
+REGISTER_PROTOCOL (RTMPT, rtmpt);
 REGISTER_PROTOCOL (RTP, rtp);
 REGISTER_PROTOCOL (SCTP, sctp);
 REGISTER_PROTOCOL (TCP, tcp);
diff --git a/libavformat/rtmphttp.c b/libavformat/rtmphttp.c
new file mode 100644
index 000..70d5579
--- /dev/null
+++ b/libavformat/rtmphttp.c
@@ -0,0 +1,245 @@
+/*
+ * RTMP HTTP network protocol
+ * Copyright (c) 2012 Samuel Pitoiset
+ *
+ * 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
+ * RTMP HTTP protocol
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/intfloat.h"
+#include "libavutil/opt.h"
+#include "internal.h"
+#include "http.h"
+
+#define RTMPT_DEFAULT_PORT 80
+
+/* protocol handler context */
+typedef struct RTMP_HTTPContext {
+URLContext   *stream;   ///< HTTP stream
+char host[256]; ///< hostname of the server
+int  port;  ///< port to connect (default is 80)
+char client_id[64]; ///< client ID used for all requests 
except the first one
+int  seq;   ///< sequence ID used f

[libav-devel] [PATCH 1/2] http: Fail if reading if the connection has gone away

2012-06-17 Thread Martin Storsjö
This can happen if doing a new request using the same socket,
but the new request failed, which clears the urlcontext.
---
 libavformat/http.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/http.c b/libavformat/http.c
index b2f2ea9..2b5f2cc 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -510,6 +510,9 @@ static int http_read(URLContext *h, uint8_t *buf, int size)
 HTTPContext *s = h->priv_data;
 int err, new_location;
 
+if (!s->hd)
+return AVERROR_EOF;
+
 if (s->end_chunked_post) {
 if (!s->end_header) {
 err = http_read_header(h, &new_location);
-- 
1.7.9.4

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


[libav-devel] [PATCH 2/2] http: Properly handle chunked transfer-encoding for replies to post data

2012-06-17 Thread Martin Storsjö
---
 libavformat/http.c |   15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 2b5f2cc..a494193 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -353,6 +353,8 @@ static int http_read_header(URLContext *h, int 
*new_location)
 char line[1024];
 int err = 0;
 
+s->chunksize = -1;
+
 for (;;) {
 if ((err = http_get_line(s, line, sizeof(line))) < 0)
 return err;
@@ -470,7 +472,6 @@ static int http_connect(URLContext *h, const char *path, 
const char *local_path,
 s->http_code = 200;
 return 0;
 }
-s->chunksize = -1;
 
 /* wait for header */
 err = http_read_header(h, new_location);
@@ -513,14 +514,10 @@ static int http_read(URLContext *h, uint8_t *buf, int 
size)
 if (!s->hd)
 return AVERROR_EOF;
 
-if (s->end_chunked_post) {
-if (!s->end_header) {
-err = http_read_header(h, &new_location);
-if (err < 0)
-return err;
-}
-
-return http_buf_read(h, buf, size);
+if (s->end_chunked_post && !s->end_header) {
+err = http_read_header(h, &new_location);
+if (err < 0)
+return err;
 }
 
 if (s->chunksize >= 0) {
-- 
1.7.9.4

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


Re: [libav-devel] [PATCH] RTMPT protocol support

2012-06-17 Thread Martin Storsjö

On Sun, 17 Jun 2012, Samuel Pitoiset wrote:


This adds two protocols, but one of them is an internal implementation
detail just used as an abstraction layer/generalization in the code. The
RTMPT protocol implementation uses rtmphttp:// as an alternative to the
tcp:// protocol. This allows moving most of the lower level logic out
from the higher level generic rtmp code.
---
Changelog|1 +
configure|4 +
doc/protocols.texi   |8 ++
libavformat/Makefile |2 +
libavformat/allformats.c |2 +
libavformat/rtmphttp.c   |  245 ++
libavformat/rtmpproto.c  |   31 +-
libavformat/version.h|4 +-
8 files changed, 292 insertions(+), 5 deletions(-)
create mode 100644 libavformat/rtmphttp.c


I think this more or less is done now, I'll push it (perhaps with a few 
minor tweaks) after some more testing unless I find any other issues.


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


Re: [libav-devel] [PATCH V4 0/4] Support for HDMV Interactive Graphics Stream

2012-06-17 Thread Luca Barbato
On 06/17/2012 09:41 AM, David Girault wrote:
> No comments on parts 2 to 4 of this patchset?
> 

2 looks good I need to re-read it again once we decide how to handle the
data type

3 and 4 will change radically depending on that.

merging overlay with subtitle might be nice IMHO.

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] rtpenc: Fix memory leaks in the muxer open function

2012-06-17 Thread Luca Barbato
On 06/17/2012 05:20 PM, Martin Storsjö wrote:
> Also return a proper error code in these cases.
> ---
>  libavformat/rtpenc.c |8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 

Yai!

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/5] Add support for iLBC decoding/encoding via the external library libilbc

2012-06-17 Thread Martin Storsjö

On Sun, 17 Jun 2012, Justin Ruggles wrote:


[A bunch of comments trimmed]


Updated locally


On 06/17/2012 11:03 AM, Martin Storsjö wrote:

+
+WebRtcIlbcfix_DecodeImpl((WebRtc_Word16*) s->frame.data[0], (const 
WebRtc_UWord16*) buf, &s->decoder, 1);
+


break the long line.

can this return an error?


Nope, it returns void.


+
+if ((mode = get_mode(avctx)) < 0)
+return AVERROR(EINVAL);


Having a private option to set 20ms or 30ms mode could be useful rather
than having to know the corresponding bitrate.


That's also possible, although in this case, you don't need to know them 
exactly, anything below 14 kbps gets the 13.333 kbps mode, anything above 
gets the 15.200 one. (This is about the same as we do for AMR-NB, where we 
pick the mode that is the closest match.)


If we have an option, it would need to have a "auto"/0 mode as default, 
which picks it from the bitrate, otherwise one can't set it via the 
bitrate at all. If you still want the option, I can add it.


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


Re: [libav-devel] [PATCH 1/2] http: Fail if reading if the connection has gone away

2012-06-17 Thread Luca Barbato
On 06/17/2012 09:00 PM, Martin Storsjö wrote:
> This can happen if doing a new request using the same socket,
> but the new request failed, which clears the urlcontext.
> ---
>  libavformat/http.c |3 +++
>  1 file changed, 3 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


Re: [libav-devel] [PATCH 2/2] http: Properly handle chunked transfer-encoding for replies to post data

2012-06-17 Thread Luca Barbato
On 06/17/2012 09:00 PM, Martin Storsjö wrote:
> ---
>  libavformat/http.c |   15 ++-
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 

Seems fine to 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 1/2] amr: More space cleanup

2012-06-17 Thread Luca Barbato
On 06/17/2012 06:08 PM, Martin Storsjö wrote:
> This was missed in the previous cleanup patch.
> ---
>  libavformat/amr.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Patchset 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] RTMPT protocol support

2012-06-17 Thread Martin Storsjö

On Sun, 17 Jun 2012, Martin Storsjö wrote:


On Sun, 17 Jun 2012, Samuel Pitoiset wrote:


This adds two protocols, but one of them is an internal implementation
detail just used as an abstraction layer/generalization in the code. The
RTMPT protocol implementation uses rtmphttp:// as an alternative to the
tcp:// protocol. This allows moving most of the lower level logic out
from the higher level generic rtmp code.
---
Changelog|1 +
configure|4 +
doc/protocols.texi   |8 ++
libavformat/Makefile |2 +
libavformat/allformats.c |2 +
libavformat/rtmphttp.c   |  245 
++

libavformat/rtmpproto.c  |   31 +-
libavformat/version.h|4 +-
8 files changed, 292 insertions(+), 5 deletions(-)
create mode 100644 libavformat/rtmphttp.c


I think this more or less is done now, I'll push it (perhaps with a few minor 
tweaks) after some more testing unless I find any other issues.


This was good enough for now, so pushed.

A few things you still should look into:

- Do you get increased frame rate in your own test setup if you call the 
nonblocking read in rtmp_write only every N:th time? That batches up a few 
packets per HTTP request.


- If playing back data, and the server doesn't have anything to send 
(since it's sending data in real time), and you don't have any data to 
send either, the client and server together enter a kind of busy loop - 
the client tries to do a blocking read, and thus won't return until it 
actually has some data. So the client sends an idle request, the server 
responds to this with a 0-byte reply, so the client sends another idle 
request. As long as neither the client nor the server throttles this, it 
will consume as much bandwidth as it can get.


My suggestion is something like this: Keep track of the number of bytes 
read since the last request. If this is 0, and you get EOF, and you don't 
have any data to send either (and thus will send an idle request), wait a 
little (usleep for 20-50 ms or so) before retrying. This makes sure we 
don't wait if there's actually some data flowing happening, but avoids 
this busy loop with insane network traffic. The actual delay value doesn't 
matter that much. In my tests over loopback, it does many thousand 
requests per second - if you sleep 50 ms at a time at this point, it will 
"only" do up to 20 idle requests per second.


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


Re: [libav-devel] [PATCH] RTMPT protocol support

2012-06-17 Thread Martin Storsjö

On Sun, 17 Jun 2012, Martin Storsjö wrote:


On Sun, 17 Jun 2012, Martin Storsjö wrote:


On Sun, 17 Jun 2012, Samuel Pitoiset wrote:


This adds two protocols, but one of them is an internal implementation
detail just used as an abstraction layer/generalization in the code. The
RTMPT protocol implementation uses rtmphttp:// as an alternative to the
tcp:// protocol. This allows moving most of the lower level logic out
from the higher level generic rtmp code.
---
Changelog|1 +
configure|4 +
doc/protocols.texi   |8 ++
libavformat/Makefile |2 +
libavformat/allformats.c |2 +
libavformat/rtmphttp.c   |  245 
++

libavformat/rtmpproto.c  |   31 +-
libavformat/version.h|4 +-
8 files changed, 292 insertions(+), 5 deletions(-)
create mode 100644 libavformat/rtmphttp.c


I think this more or less is done now, I'll push it (perhaps with a few 
minor tweaks) after some more testing unless I find any other issues.


This was good enough for now, so pushed.

A few things you still should look into:

- Do you get increased frame rate in your own test setup if you call the 
nonblocking read in rtmp_write only every N:th time? That batches up a few 
packets per HTTP request.


- If playing back data, and the server doesn't have anything to send (since 
it's sending data in real time), and you don't have any data to send either, 
the client and server together enter a kind of busy loop - the client tries 
to do a blocking read, and thus won't return until it actually has some data. 
So the client sends an idle request, the server responds to this with a 
0-byte reply, so the client sends another idle request. As long as neither 
the client nor the server throttles this, it will consume as much bandwidth 
as it can get.


To reproduce this issue, watch the traffic flow using wireshark, when e.g. 
playing back rtmpt://server:1935/vod/sample.mp4 from your wowza test 
instance. Inbetween the sequences where the server has data to send, the 
client sends an insane amount of idle requests...


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


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

2012-06-17 Thread Justin Ruggles
On 06/17/2012 03:47 PM, Martin Storsjö wrote:
> On Sun, 17 Jun 2012, Justin Ruggles wrote:
> 
>> [A bunch of comments trimmed]
> 
> Updated locally
> 
>> On 06/17/2012 11:03 AM, Martin Storsjö wrote:
>>> +
>>> +WebRtcIlbcfix_DecodeImpl((WebRtc_Word16*) s->frame.data[0],
>>> (const WebRtc_UWord16*) buf, &s->decoder, 1);
>>> +
>>
>> break the long line.
>>
>> can this return an error?
> 
> Nope, it returns void.

ok.

>>> +
>>> +if ((mode = get_mode(avctx)) < 0)
>>> +return AVERROR(EINVAL);
>>
>> Having a private option to set 20ms or 30ms mode could be useful rather
>> than having to know the corresponding bitrate.
> 
> That's also possible, although in this case, you don't need to know them
> exactly, anything below 14 kbps gets the 13.333 kbps mode, anything
> above gets the 15.200 one. (This is about the same as we do for AMR-NB,
> where we pick the mode that is the closest match.)
> 
> If we have an option, it would need to have a "auto"/0 mode as default,
> which picks it from the bitrate, otherwise one can't set it via the
> bitrate at all. If you still want the option, I can add it.

Yes, that sounds fine. One way to do this would be to set the bit_rate
default to 0, then only use the mode option if the user does not set
bit_rate explicitly. That way you don't need an "auto" mode, you just
have a default mode for use when bit_rate is not specified.

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


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

2012-06-17 Thread Martin Storsjö

On Sun, 17 Jun 2012, Justin Ruggles wrote:


On 06/17/2012 03:47 PM, Martin Storsjö wrote:

On Sun, 17 Jun 2012, Justin Ruggles wrote:


[A bunch of comments trimmed]


Updated locally


On 06/17/2012 11:03 AM, Martin Storsjö wrote:

+
+WebRtcIlbcfix_DecodeImpl((WebRtc_Word16*) s->frame.data[0],
(const WebRtc_UWord16*) buf, &s->decoder, 1);
+


break the long line.

can this return an error?


Nope, it returns void.


ok.


+
+if ((mode = get_mode(avctx)) < 0)
+return AVERROR(EINVAL);


Having a private option to set 20ms or 30ms mode could be useful rather
than having to know the corresponding bitrate.


That's also possible, although in this case, you don't need to know them
exactly, anything below 14 kbps gets the 13.333 kbps mode, anything
above gets the 15.200 one. (This is about the same as we do for AMR-NB,
where we pick the mode that is the closest match.)

If we have an option, it would need to have a "auto"/0 mode as default,
which picks it from the bitrate, otherwise one can't set it via the
bitrate at all. If you still want the option, I can add it.


Yes, that sounds fine. One way to do this would be to set the bit_rate
default to 0, then only use the mode option if the user does not set
bit_rate explicitly. That way you don't need an "auto" mode, you just
have a default mode for use when bit_rate is not specified.


Ok, I'll give it a shot tomorrow.

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


[libav-devel] [PATCH] configure: Sort the library listings in the help text alphabetically

2012-06-17 Thread Martin Storsjö
Only these three libraries were out of order, the rest was already
neatly sorted.
---
 configure |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index d614366..a5d2787 100755
--- a/configure
+++ b/configure
@@ -166,9 +166,6 @@ External library support:
   --enable-bzlib   enable bzlib [autodetect]
   --enable-frei0r  enable frei0r video filtering
   --enable-gnutls  enable gnutls [no]
-  --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb 
[no]
-  --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
-  --enable-libopencv   enable video filtering via libopencv [no]
   --enable-libcdio enable audio CD grabbing with libcdio
   --enable-libdc1394   enable IIDC-1394 grabbing using libdc1394
and libraw1394 [no]
@@ -176,6 +173,9 @@ External library support:
   --enable-libfreetype enable libfreetype [no]
   --enable-libgsm  enable GSM support via libgsm [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]
+  --enable-libopencv   enable video filtering via libopencv [no]
   --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no]
   --enable-libpulseenable Pulseaudio input via libpulse [no]
   --enable-librtmp enable RTMP[E] support via librtmp [no]
-- 
1.7.9.4

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


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

2012-06-17 Thread Jordi Ortiz
---
 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

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


Re: [libav-devel] [PATCH] configure: Sort the library listings in the help text alphabetically

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

> Only these three libraries were out of order, the rest was already
> neatly sorted.
> ---
>  configure |6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/configure b/configure
> index d614366..a5d2787 100755
> --- a/configure
> +++ b/configure
> @@ -166,9 +166,6 @@ External library support:
>--enable-bzlib   enable bzlib [autodetect]
>--enable-frei0r  enable frei0r video filtering
>--enable-gnutls  enable gnutls [no]
> -  --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb 
> [no]
> -  --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb 
> [no]
> -  --enable-libopencv   enable video filtering via libopencv [no]
>--enable-libcdio enable audio CD grabbing with libcdio
>--enable-libdc1394   enable IIDC-1394 grabbing using libdc1394
> and libraw1394 [no]
> @@ -176,6 +173,9 @@ External library support:
>--enable-libfreetype enable libfreetype [no]
>--enable-libgsm  enable GSM support via libgsm [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]
> +  --enable-libopencv   enable video filtering via libopencv [no]
>--enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no]
>--enable-libpulseenable Pulseaudio input via libpulse [no]
>--enable-librtmp enable RTMP[E] support via librtmp [no]
> -- 

LGTM

-- 
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] build: fix bogus restrict redefinition

2012-06-17 Thread Luca Barbato
Replace all the instances of restrict with av_restrict.
That is made to cope with non-standard compilers that use a
different keyword.

---

This is the complete patch, I still think that using the sed expression would
work better.


 configure   |2 +-
 libavcodec/alpha/dsputil_alpha.c|4 ++--
 libavcodec/alpha/dsputil_alpha.h|4 ++--
 libavcodec/alpha/motion_est_alpha.c |4 ++--
 libavcodec/arm/dsputil_init_armv6.c |2 +-
 libavcodec/bfin/dsputil_bfin.h  |2 +-
 libavcodec/bfin/pixels_bfin.S   |2 +-
 libavcodec/dnxhdenc.c   |4 ++--
 libavcodec/dsputil.c|   10 +-
 libavcodec/dsputil.h|2 +-
 libavcodec/dsputil_template.c   |   12 ++--
 libavcodec/ituh263dec.c |2 +-
 libavcodec/mpegvideo.c  |4 ++--
 libavcodec/ppc/dsputil_altivec.c|4 ++--
 libavformat/rtpenc.h|4 ++--
 libavformat/rtpenc_h263.c   |4 ++--
 16 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/configure b/configure
index 4bb2030..a24bd52 100755
--- a/configure
+++ b/configure
@@ -3348,7 +3348,7 @@ cat > $TMPH 

[libav-devel] [PATCH 2/2] msvc: replace standard restrict keyword

2012-06-17 Thread Luca Barbato
Replace restrict instances with __restrict since it isn't supported.
---
 msvc/convert.sh |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/msvc/convert.sh b/msvc/convert.sh
index 2eb41e7..ac9b717 100644
--- a/msvc/convert.sh
+++ b/msvc/convert.sh
@@ -6,7 +6,8 @@ if test x$file = x; then
 fi
 
 echo "Converting ${file}"
-~/test ${file} 2>/dev/null | sed -e "s/\r\n/\n/" > ${file}.2
+~/test ${file} 2>/dev/null | \
+sed -e "s/\r\n/\n/" -e "s:\\* *\(restrict[ )]\):*__\1:g" > ${file}.2
 diff -u ${file} ${file}.2
 
 if test x$2 != x1; then
-- 
1.7.8.rc1

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


Re: [libav-devel] [PATCH] build: fix bogus restrict redefinition

2012-06-17 Thread Måns Rullgård
Luca Barbato  writes:

> Replace all the instances of restrict with av_restrict.
> That is made to cope with non-standard compilers that use a
> different keyword.
>
> ---
>
> This is the complete patch, I still think that using the sed expression would
> work better.

I agree this is not the preferred way.  If possible, we should keep to
standard syntax in the bulk of the code.  Requiring of developers to
substitute some other syntax in place of standard features is not nice
and is also prone to errors.  We have a rule against mixing statements
and declarations, yet such code keeps creeping in.  The same thing is
bound to happen with this.  The difference is that mixed code and
declarations cannot easily be fixed by a wrapper script, whereas
substituting an unsupported keyword like restrict is trivially done.

Seeing as a preprocessor is absolutely necessary anyway (to convert
designated initialisers), there is no reason for this preprocessor to
not also handle a couple keyword substitutions.  That way is minimally
intrusive in the code, and avoids unnecessary barriers for new developers.

-- 
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] Add Dolby/DPLII downmix support to libavresample

2012-06-17 Thread Justin Ruggles
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.

 doc/APIchanges   |3 ++
 libavresample/audio_mix.c|3 +-
 libavresample/audio_mix_matrix.c |   60 -
 libavresample/avresample.h   |3 +-
 libavresample/internal.h |1 +
 libavresample/options.c  |4 ++
 libavresample/version.h  |2 +-
 libavutil/audioconvert.h |7 
 8 files changed, 72 insertions(+), 11 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 50cc787..4d14882 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2011-04-18
 
 API changes, most recent first:
 
+2012-xx-xx - xxx - lavr 0.0.3
+  Add a parameter to avresample_build_matrix() for Dolby/DPLII downmixing.
+
 2012-xx-xx - xxx - lavfi 2.23.0 - avfilter.h
   Add AVFilterContext.nb_inputs/outputs. Deprecate
   AVFilterContext.input/output_count.
diff --git a/libavresample/audio_mix.c b/libavresample/audio_mix.c
index 7ab11b0..9319222 100644
--- a/libavresample/audio_mix.c
+++ b/libavresample/audio_mix.c
@@ -320,7 +320,8 @@ int ff_audio_mix_init(AVAudioResampleContext *avr)
   avr->center_mix_level,
   avr->surround_mix_level,
   avr->lfe_mix_level, 1, matrix_dbl,
-  avr->in_channels);
+  avr->in_channels,
+  avr->matrix_encoding);
 if (ret < 0) {
 av_free(matrix_dbl);
 return ret;
diff --git a/libavresample/audio_mix_matrix.c b/libavresample/audio_mix_matrix.c
index 6135b02..f7121c8 100644
--- a/libavresample/audio_mix_matrix.c
+++ b/libavresample/audio_mix_matrix.c
@@ -54,6 +54,8 @@
 #define SURROUND_DIRECT_LEFT   33
 #define SURROUND_DIRECT_RIGHT  34
 
+#define SQRT3_2  1.22474487139158904909  /* sqrt(3/2) */
+
 static av_always_inline int even(uint64_t layout)
 {
 return (!layout || (layout & (layout - 1)));
@@ -83,14 +85,21 @@ static int sane_layout(uint64_t layout)
 int avresample_build_matrix(uint64_t in_layout, uint64_t out_layout,
 double center_mix_level, double surround_mix_level,
 double lfe_mix_level, int normalize,
-double *matrix_out, int stride)
+double *matrix_out, int stride,
+enum AVMatrixEncoding matrix_encoding)
 {
 int i, j, out_i, out_j;
 double matrix[64][64] = {{0}};
-int64_t unaccounted = in_layout & ~out_layout;
+int64_t unaccounted;
 double maxcoef = 0;
 int in_channels, out_channels;
 
+if ((out_layout & AV_CH_LAYOUT_STEREO_DOWNMIX) == 
AV_CH_LAYOUT_STEREO_DOWNMIX) {
+out_layout = AV_CH_LAYOUT_STEREO;
+}
+
+unaccounted = in_layout & ~out_layout;
+
 in_channels  = av_get_channel_layout_nb_channels( in_layout);
 out_channels = av_get_channel_layout_nb_channels(out_layout);
 
@@ -140,8 +149,19 @@ int avresample_build_matrix(uint64_t in_layout, uint64_t 
out_layout,
 matrix[SIDE_LEFT ][BACK_CENTER] += M_SQRT1_2;
 matrix[SIDE_RIGHT][BACK_CENTER] += M_SQRT1_2;
 } else if (out_layout & AV_CH_FRONT_LEFT) {
-matrix[FRONT_LEFT ][BACK_CENTER] += surround_mix_level * M_SQRT1_2;
-matrix[FRONT_RIGHT][BACK_CENTER] += surround_mix_level * M_SQRT1_2;
+if (matrix_encoding == AV_MATRIX_ENCODING_DOLBY ||
+matrix_encoding == AV_MATRIX_ENCODING_DPLII) {
+if (unaccounted & (AV_CH_BACK_LEFT | AV_CH_SIDE_LEFT)) {
+matrix[FRONT_LEFT ][BACK_CENTER] -= surround_mix_level * 
M_SQRT1_2;
+matrix[FRONT_RIGHT][BACK_CENTER] += surround_mix_level * 
M_SQRT1_2;
+} else {
+matrix[FRONT_LEFT ][BACK_CENTER] -= surround_mix_level;
+matrix[FRONT_RIGHT][BACK_CENTER] += surround_mix_level;
+}
+} else {
+matrix[FRONT_LEFT ][BACK_CENTER] += surround_mix_level * 
M_SQRT1_2;
+matrix[FRONT_RIGHT][BACK_CENTER] += surround_mix_level * 
M_SQRT1_2;
+}
 } else if (out_layout & AV_CH_FRONT_CENTER) {
 matrix[FRONT_CENTER][BACK_CENTER] += surround_mix_level * 
M_SQRT1_2;
 } else
@@ -163,8 +183,20 @@ int avresample_build_matrix(uint64_t in_layout, uint64_t 
out_layout,
 matrix[SIDE_RIGHT][BACK_RIGHT] += 1.0;
 }
 } else if (out_layout & AV_CH_FRONT_LEFT) {
-matrix[FRONT_LEFT ][BACK_LEFT ] += surround_mix_level;
-matrix[FRONT_RIGHT][BACK_RIGHT] += surround_mix_level;
+if (matrix_encoding == AV

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

2012-06-17 Thread Justin Ruggles
On 06/10/2012 02: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(-)

ping.

-Justin

___
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-17 Thread Justin Ruggles
On 06/06/2012 02: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(-)

ping.

-Justin

___
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-17 Thread Justin Ruggles
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.

-Justin

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