[libav-devel] [PATCH] lavf: use designated initializers for all protocols

2011-04-07 Thread Anton Khirnov
This is more readable and makes it easier to reorder URLProtocol
members.
---
 libavformat/applehttpproto.c |   12 ++---
 libavformat/concat.c |   11 ++---
 libavformat/file.c   |   20 +-
 libavformat/gopher.c |   11 ++---
 libavformat/http.c   |   16 
 libavformat/librtmp.c|   90 ++---
 libavformat/mmst.c   |   10 ++---
 libavformat/rtmpproto.c  |   11 ++---
 libavformat/rtpproto.c   |   11 ++---
 libavformat/tcp.c|   11 ++---
 libavformat/udp.c|   11 ++---
 11 files changed, 97 insertions(+), 117 deletions(-)

diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c
index 52645f7..8842bd4 100644
--- a/libavformat/applehttpproto.c
+++ b/libavformat/applehttpproto.c
@@ -298,11 +298,9 @@ static int applehttp_close(URLContext *h)
 }
 
 URLProtocol ff_applehttp_protocol = {
-"applehttp",
-applehttp_open,
-applehttp_read,
-NULL, /* write */
-NULL, /* seek */
-applehttp_close,
-.flags = URL_PROTOCOL_FLAG_NESTED_SCHEME,
+.name  = "applehttp",
+.url_open  = applehttp_open,
+.url_read  = applehttp_read,
+.url_close = applehttp_close,
+.flags = URL_PROTOCOL_FLAG_NESTED_SCHEME,
 };
diff --git a/libavformat/concat.c b/libavformat/concat.c
index dbacc69..da9bee2 100644
--- a/libavformat/concat.c
+++ b/libavformat/concat.c
@@ -190,10 +190,9 @@ static int64_t concat_seek(URLContext *h, int64_t pos, int 
whence)
 }
 
 URLProtocol ff_concat_protocol = {
-"concat",
-concat_open,
-concat_read,
-NULL,
-concat_seek,
-concat_close,
+.name  = "concat",
+.url_open  = concat_open,
+.url_read  = concat_read,
+.url_seek  = concat_seek,
+.url_close = concat_close,
 };
diff --git a/libavformat/file.c b/libavformat/file.c
index 729061a..3293a53 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -95,12 +95,12 @@ static int file_close(URLContext *h)
 }
 
 URLProtocol ff_file_protocol = {
-"file",
-file_open,
-file_read,
-file_write,
-file_seek,
-file_close,
+.name= "file",
+.url_open= file_open,
+.url_read= file_read,
+.url_write   = file_write,
+.url_seek= file_seek,
+.url_close   = file_close,
 .url_get_file_handle = file_get_handle,
 };
 
@@ -131,10 +131,10 @@ static int pipe_open(URLContext *h, const char *filename, 
int flags)
 }
 
 URLProtocol ff_pipe_protocol = {
-"pipe",
-pipe_open,
-file_read,
-file_write,
+.name= "pipe",
+.url_open= pipe_open,
+.url_read= file_read,
+.url_write   = file_write,
 .url_get_file_handle = file_get_handle,
 };
 
diff --git a/libavformat/gopher.c b/libavformat/gopher.c
index cfc4424..cfc07e7 100644
--- a/libavformat/gopher.c
+++ b/libavformat/gopher.c
@@ -121,10 +121,9 @@ static int gopher_read(URLContext *h, uint8_t *buf, int 
size)
 
 
 URLProtocol ff_gopher_protocol = {
-"gopher",
-gopher_open,
-gopher_read,
-gopher_write,
-NULL, /*seek*/
-gopher_close,
+.name  = "gopher",
+.url_open  = gopher_open,
+.url_read  = gopher_read,
+.url_write = gopher_write,
+.url_close = gopher_close,
 };
diff --git a/libavformat/http.c b/libavformat/http.c
index 8d20527..bcfce80 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -505,13 +505,13 @@ http_get_file_handle(URLContext *h)
 }
 
 URLProtocol ff_http_protocol = {
-"http",
-http_open,
-http_read,
-http_write,
-http_seek,
-http_close,
+.name= "http",
+.url_open= http_open,
+.url_read= http_read,
+.url_write   = http_write,
+.url_seek= http_seek,
+.url_close   = http_close,
 .url_get_file_handle = http_get_file_handle,
-.priv_data_size = sizeof(HTTPContext),
-.priv_data_class = &httpcontext_class,
+.priv_data_size  = sizeof(HTTPContext),
+.priv_data_class = &httpcontext_class,
 };
diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
index f980402..5770e59 100644
--- a/libavformat/librtmp.c
+++ b/libavformat/librtmp.c
@@ -158,66 +158,56 @@ static int rtmp_get_file_handle(URLContext *s)
 }
 
 URLProtocol ff_rtmp_protocol = {
-"rtmp",
-rtmp_open,
-rtmp_read,
-rtmp_write,
-NULL,   /* seek */
-rtmp_close,
-NULL,   /* next */
-rtmp_read_pause,
-rtmp_read_seek,
-rtmp_get_file_handle
+.name= "rtmp",
+.url_open= rtmp_open,
+.url_read= rtmp_read,
+.url_write   = rtmp_write,
+.url_close   = rtmp_close,
+.url_read_pause  = rtmp_read_pause,
+.url_read_seek   = rtmp_read_seek,
+.url_get_file_handle = rtmp_get_file_handle
 };
 
 URLProtocol ff_rtmpt_pro

[libav-devel] [PATCH 2/2] avio: make URLProtocol internal.

2011-04-07 Thread Anton Khirnov
---
 libavformat/avio.h |6 +-
 libavformat/url.h  |   17 +
 2 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index 0a82f95..18e3edd 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -140,8 +140,11 @@ attribute_deprecated int url_poll(URLPollEntry 
*poll_table, int n, int timeout);
 
 
 #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the 
first part of a nested protocol scheme */
-#endif
 
+/**
+ * @deprecated This struct is to be made private. Use the higher-level
+ * AVIOContext-based API instead.
+ */
 typedef struct URLProtocol {
 const char *name;
 int (*url_open)(URLContext *h, const char *url, int flags);
@@ -158,6 +161,7 @@ typedef struct URLProtocol {
 const AVClass *priv_data_class;
 int flags;
 } URLProtocol;
+#endif
 
 #if FF_API_REGISTER_PROTOCOL
 extern URLProtocol *first_protocol;
diff --git a/libavformat/url.h b/libavformat/url.h
index b6c110d..bde06d9 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -43,6 +43,23 @@ typedef struct URLContext {
 int is_streamed;/**< true if streamed (no seek possible), 
default = false */
 int is_connected;
 } URLContext;
+
+typedef struct URLProtocol {
+const char *name;
+int (*url_open)( URLContext *h, const char *url, int flags);
+int (*url_read)( URLContext *h, unsigned char *buf, int size);
+int (*url_write)(URLContext *h, const unsigned char *buf, int size);
+int64_t (*url_seek)( URLContext *h, int64_t pos, int whence);
+int (*url_close)(URLContext *h);
+struct URLProtocol *next;
+int (*url_read_pause)(URLContext *h, int pause);
+int64_t (*url_read_seek)(URLContext *h, int stream_index,
+ int64_t timestamp, int flags);
+int (*url_get_file_handle)(URLContext *h);
+int priv_data_size;
+const AVClass *priv_data_class;
+int flags;
+} URLProtocol;
 #endif
 
 /**
-- 
1.7.4.1

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


[libav-devel] [PATCH 1/2] avio: make URLContext internal.

2011-04-07 Thread Anton Khirnov
---
 libavformat/avio.h  |3 ++-
 libavformat/avio_internal.h |1 +
 libavformat/file.c  |1 +
 libavformat/http.h  |2 +-
 libavformat/librtmp.c   |1 +
 libavformat/mms.h   |2 +-
 libavformat/rtmppkt.h   |1 +
 libavformat/rtpdec.h|1 +
 libavformat/rtpenc_chain.h  |1 +
 libavformat/url.h   |   11 +++
 10 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index 8302708..0a82f95 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -37,12 +37,14 @@
 
 /* unbuffered I/O */
 
+#if FF_API_OLD_AVIO
 /**
  * URL Context.
  * New fields can be added to the end with minor version bumps.
  * Removal, reordering and changes to existing fields require a major
  * version bump.
  * sizeof(URLContext) must not be used outside libav*.
+ * @deprecated This struct will be made private
  */
 typedef struct URLContext {
 #if FF_API_URL_CLASS
@@ -57,7 +59,6 @@ typedef struct URLContext {
 int is_connected;
 } URLContext;
 
-#if FF_API_OLD_AVIO
 typedef struct URLPollEntry {
 URLContext *handle;
 int events;
diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h
index 2879ee1..721a3c4 100644
--- a/libavformat/avio_internal.h
+++ b/libavformat/avio_internal.h
@@ -21,6 +21,7 @@
 #define AVFORMAT_AVIO_INTERNAL_H
 
 #include "avio.h"
+#include "url.h"
 
 int ffio_init_context(AVIOContext *s,
   unsigned char *buffer,
diff --git a/libavformat/file.c b/libavformat/file.c
index 729061a..4f4619d 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include "os_support.h"
+#include "url.h"
 
 
 /* standard file protocol */
diff --git a/libavformat/http.h b/libavformat/http.h
index 97f54cc..c5ff5e1 100644
--- a/libavformat/http.h
+++ b/libavformat/http.h
@@ -22,7 +22,7 @@
 #ifndef AVFORMAT_HTTP_H
 #define AVFORMAT_HTTP_H
 
-#include "avio.h"
+#include "url.h"
 
 /**
  * Set custom HTTP headers.
diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
index f980402..e13751c 100644
--- a/libavformat/librtmp.c
+++ b/libavformat/librtmp.c
@@ -25,6 +25,7 @@
  */
 
 #include "avformat.h"
+#include "url.h"
 
 #include 
 #include 
diff --git a/libavformat/mms.h b/libavformat/mms.h
index e85d59a..12e9ef0 100644
--- a/libavformat/mms.h
+++ b/libavformat/mms.h
@@ -21,7 +21,7 @@
 #ifndef AVFORMAT_MMS_H
 #define AVFORMAT_MMS_H
 
-#include "avformat.h"
+#include "url.h"
 
 typedef struct {
 int id;
diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
index 8ad2924..bb34758 100644
--- a/libavformat/rtmppkt.h
+++ b/libavformat/rtmppkt.h
@@ -23,6 +23,7 @@
 #define AVFORMAT_RTMPPKT_H
 
 #include "avformat.h"
+#include "url.h"
 
 /** maximum possible number of different RTMP channels */
 #define RTMP_CHANNELS 65599
diff --git a/libavformat/rtpdec.h b/libavformat/rtpdec.h
index 1d4a9b6..da53efc 100644
--- a/libavformat/rtpdec.h
+++ b/libavformat/rtpdec.h
@@ -25,6 +25,7 @@
 #include "libavcodec/avcodec.h"
 #include "avformat.h"
 #include "rtp.h"
+#include "url.h"
 
 typedef struct PayloadContext PayloadContext;
 typedef struct RTPDynamicProtocolHandler_s RTPDynamicProtocolHandler;
diff --git a/libavformat/rtpenc_chain.h b/libavformat/rtpenc_chain.h
index 678b49e..6bdddcf 100644
--- a/libavformat/rtpenc_chain.h
+++ b/libavformat/rtpenc_chain.h
@@ -23,6 +23,7 @@
 #define AVFORMAT_RTPENC_CHAIN_H
 
 #include "avformat.h"
+#include "url.h"
 
 AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
URLContext *handle, int packet_size);
diff --git a/libavformat/url.h b/libavformat/url.h
index b8ea6ad..b6c110d 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -32,6 +32,17 @@
 #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the 
first part of a nested protocol scheme */
 
 extern int (*url_interrupt_cb)(void);
+
+typedef struct URLContext {
+const AVClass *av_class;/**< information for av_log(). Set by 
url_open(). */
+struct URLProtocol *prot;
+void *priv_data;
+char *filename; /**< specified URL */
+int flags;
+int max_packet_size;/**< if non zero, the stream is packetized 
with this max packet size */
+int is_streamed;/**< true if streamed (no seek possible), 
default = false */
+int is_connected;
+} URLContext;
 #endif
 
 /**
-- 
1.7.4.1

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


[libav-devel] [PATCH] applehttp: don't use deprecated url_ functions.

2011-04-07 Thread Anton Khirnov
---
 libavformat/applehttp.c |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c
index 6c697c5..243f4a6 100644
--- a/libavformat/applehttp.c
+++ b/libavformat/applehttp.c
@@ -113,7 +113,7 @@ static void free_variant_list(AppleHTTPContext *c)
 av_free_packet(&var->pkt);
 av_free(var->pb.buffer);
 if (var->input)
-url_close(var->input);
+ffurl_close(var->input);
 if (var->ctx) {
 var->ctx->pb = NULL;
 av_close_input_file(var->ctx);
@@ -291,18 +291,18 @@ reload:
 goto reload;
 }
 
-ret = url_open(&v->input,
-   v->segments[v->cur_seq_no - v->start_seq_no]->url,
-   AVIO_RDONLY);
+ret = ffurl_open(&v->input,
+ v->segments[v->cur_seq_no - v->start_seq_no]->url,
+ AVIO_RDONLY);
 if (ret < 0)
 return ret;
 }
-ret = url_read(v->input, buf, buf_size);
+ret = ffurl_read(v->input, buf, buf_size);
 if (ret > 0)
 return ret;
 if (ret < 0 && ret != AVERROR_EOF)
 return ret;
-url_close(v->input);
+ffurl_close(v->input);
 v->input = NULL;
 v->cur_seq_no++;
 
@@ -435,7 +435,7 @@ static int recheck_discard_flags(AVFormatContext *s, int 
first)
 av_log(s, AV_LOG_INFO, "Now receiving variant %d\n", i);
 } else if (first && !v->cur_needed && v->needed) {
 if (v->input)
-url_close(v->input);
+ffurl_close(v->input);
 v->input = NULL;
 v->needed = 0;
 changed = 1;
@@ -517,7 +517,7 @@ static int applehttp_read_seek(AVFormatContext *s, int 
stream_index,
 struct variant *var = c->variants[i];
 int64_t pos = 0;
 if (var->input) {
-url_close(var->input);
+ffurl_close(var->input);
 var->input = NULL;
 }
 av_free_packet(&var->pkt);
-- 
1.7.4.1

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


Re: [libav-devel] [PATCH 2/2] add MicroDVD muxer and demuxer

2011-04-07 Thread Alexander Strange
On Thu, Apr 7, 2011 at 10:02 PM, Ronald S. Bultje  wrote:
> Hi,
>
> On Thu, Apr 7, 2011 at 1:01 AM, Alexander Strange  
> wrote:
>> On Apr 6, 2011, at 5:44 PM, Ronald S. Bultje wrote:
>>> On Tue, Apr 5, 2011 at 3:08 PM, Luca Barbato  wrote:
 +    if (buffer[0] && !(res = av_new_packet(pkt, len))) {
 +        memcpy(pkt->data, buffer, len);
 +        pkt->flags |= AV_PKT_FLAG_KEY;
 +        pkt->pos = pos;
 +        pkt->pts = pkt->dts = get_pts(buffer);
 +    }
>>>
>>> Sets no duration? Or is this one of those crazy formats where duration
>>> lasts until the next (potentially empty) subtitle?
>>>
>>> I didn't look very thoroughly, but it looks OK from a quick glance at it.
>>>
>>> Ronald
>>
>> MicroDVD looks like this:
>>
>> {1025}{1110}Oh no!
>>
>> The first {} is the start frame and the {} is the end frame.
>>
>> It is certainly failing to parse the duration, so I guess it's up to
>> you if half a demuxer is better than none.
>>
>> Storing the entire line as the packet reminds me of the ASS format
>> which is good for nothing except having a small ASS muxer.
>
> As opposed to stuffing multiple lines in a single AVPacket? I don't
> care too much about that, subtitles (except for their rendering) are
> largely irrelevant to performance of a video player...

It shouldn't store the {}{} in the packet, is what I meant.

> Having the (convergance_)duration set would still be nice though.
>

I was never sure why the mkv demuxer set convergence_duration instead
of duration; it didn't seem to help anything or match the description
of the field.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/6] avio: avio_ prefix for url_exist().

2011-04-07 Thread Anton Khirnov
On Thu, Apr 07, 2011 at 09:50:28PM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On Thu, Apr 7, 2011 at 4:40 PM, Anton Khirnov  wrote:
> > On Thu, Apr 07, 2011 at 04:34:39PM -0400, Ronald S. Bultje wrote:
> >> On Thu, Apr 7, 2011 at 3:16 PM, Anton Khirnov  wrote:
> >> > ---
> >> >  ffmpeg.c           |    2 +-
> >> >  ffserver.c         |    4 ++--
> >> >  libavformat/avio.c |    6 +-
> >> >  libavformat/avio.h |    3 ++-
> >> >  libavformat/img2.c |    6 +++---
> >> >  5 files changed, 13 insertions(+), 8 deletions(-)
> >>
> >> Should this be public? I don't think it should. For local files, it's
> >> trivial to re-implement in each place where it's needed. Does it work
> >> for non-file://-URIs?
> >
> > It uses url_open, so I see no reason why it wouldn't.
> 
> I guess it's fine. I'm not very comfortable with it being in lavf but
> who am I to say it doesn't belong there if our top committer of the
> year thinks otherwise? :-).
> 

See the first mail in the thread - I'm not exactly happy with it either.

-- 
Anton Khirnov


signature.asc
Description: Digital signature
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 6/6] avio: make URLProtocol internal.

2011-04-07 Thread Ronald S. Bultje
Hi,

On Thu, Apr 7, 2011 at 3:16 PM, Anton Khirnov  wrote:
> ---
>  libavformat/allformats.c     |    2 +-
>  libavformat/applehttpproto.c |    2 +-
>  libavformat/avio.c           |   26 +-
>  libavformat/avio.h           |    6 +-
>  libavformat/concat.c         |    2 +-
>  libavformat/file.c           |    4 ++--
>  libavformat/gopher.c         |    2 +-
>  libavformat/http.c           |    2 +-
>  libavformat/librtmp.c        |   10 +-
>  libavformat/md5proto.c       |    2 +-
>  libavformat/mmsh.c           |    2 +-
>  libavformat/mmst.c           |    2 +-
>  libavformat/rtmpproto.c      |    2 +-
>  libavformat/rtpproto.c       |    2 +-
>  libavformat/tcp.c            |    2 +-
>  libavformat/udp.c            |    2 +-
>  libavformat/url.h            |   28 
>  17 files changed, 61 insertions(+), 37 deletions(-)
>
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 9398d34..652a8e8 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -34,7 +34,7 @@
>  #define REGISTER_MUXDEMUX(X,x)  REGISTER_MUXER(X,x); REGISTER_DEMUXER(X,x)
>
>  #define REGISTER_PROTOCOL(X,x) { \
> -    extern URLProtocol ff_##x##_protocol; \
> +    extern FFURLProtocol ff_##x##_protocol; \

Same here, rename isn't necessary because the struct name won't be
exposed in the binary, api, symbol table or anything.

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


Re: [libav-devel] [PATCH 5/6] avio: make URLContext internal.

2011-04-07 Thread Ronald S. Bultje
Hi,

On Thu, Apr 7, 2011 at 3:16 PM, Anton Khirnov  wrote:
> ---
>  ffserver.c                   |    6 ++--
>  libavformat/applehttp.c      |    2 +-
>  libavformat/applehttpproto.c |   10 +++---
>  libavformat/avio.c           |   76 
> +-
>  libavformat/avio.h           |    3 +-
>  libavformat/avio_internal.h  |    7 ++--
>  libavformat/aviobuf.c        |   12 +++---
>  libavformat/concat.c         |   14 
>  libavformat/file.c           |   15 
>  libavformat/gopher.c         |   12 +++---
>  libavformat/http.c           |   32 +-
>  libavformat/http.h           |   10 +++---
>  libavformat/librtmp.c        |   15 
>  libavformat/md5proto.c       |   10 +++---
>  libavformat/mms.h            |    4 +-
>  libavformat/mmsh.c           |    6 ++--
>  libavformat/mmst.c           |    6 ++--
>  libavformat/rtmppkt.c        |    4 +-
>  libavformat/rtmppkt.h        |    5 ++-
>  libavformat/rtmpproto.c      |   38 ++--
>  libavformat/rtpdec.c         |    4 +-
>  libavformat/rtpdec.h         |   15 
>  libavformat/rtpenc_chain.c   |    2 +-
>  libavformat/rtpenc_chain.h   |    3 +-
>  libavformat/rtpproto.c       |   22 ++--
>  libavformat/rtsp.c           |    2 +-
>  libavformat/rtsp.h           |    8 ++--
>  libavformat/sapdec.c         |    2 +-
>  libavformat/sapenc.c         |    4 +-
>  libavformat/tcp.c            |   10 +++---
>  libavformat/udp.c            |   14 
>  libavformat/url.h            |   45 -
>  32 files changed, 219 insertions(+), 199 deletions(-)
>
> diff --git a/ffserver.c b/ffserver.c
> index 021b2e5..f4ea029 100644
> --- a/ffserver.c
> +++ b/ffserver.c
> @@ -174,7 +174,7 @@ typedef struct HTTPContext {
>     AVFormatContext *rtp_ctx[MAX_STREAMS];
>
>     /* RTP/UDP specific */
> -    URLContext *rtp_handles[MAX_STREAMS];
> +    FFURLContext *rtp_handles[MAX_STREAMS];

There isn't actually any reason to rename these. Their names aren't
exposed in our API. Internal structures (as opposed to functions,
which are non-static and thus exposed) are hidden (like static
functions, basically) and their name is thus free-form.

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


Re: [libav-devel] [PATCH 2/2] add MicroDVD muxer and demuxer

2011-04-07 Thread Ronald S. Bultje
Hi,

On Thu, Apr 7, 2011 at 1:01 AM, Alexander Strange  wrote:
> On Apr 6, 2011, at 5:44 PM, Ronald S. Bultje wrote:
>> On Tue, Apr 5, 2011 at 3:08 PM, Luca Barbato  wrote:
>>> +    if (buffer[0] && !(res = av_new_packet(pkt, len))) {
>>> +        memcpy(pkt->data, buffer, len);
>>> +        pkt->flags |= AV_PKT_FLAG_KEY;
>>> +        pkt->pos = pos;
>>> +        pkt->pts = pkt->dts = get_pts(buffer);
>>> +    }
>>
>> Sets no duration? Or is this one of those crazy formats where duration
>> lasts until the next (potentially empty) subtitle?
>>
>> I didn't look very thoroughly, but it looks OK from a quick glance at it.
>>
>> Ronald
>
> MicroDVD looks like this:
>
> {1025}{1110}Oh no!
>
> The first {} is the start frame and the {} is the end frame.
>
> It is certainly failing to parse the duration, so I guess it's up to
> you if half a demuxer is better than none.
>
> Storing the entire line as the packet reminds me of the ASS format
> which is good for nothing except having a small ASS muxer.

As opposed to stuffing multiple lines in a single AVPacket? I don't
care too much about that, subtitles (except for their rendering) are
largely irrelevant to performance of a video player...

Having the (convergance_)duration set would still be nice though.

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


Re: [libav-devel] [PATCH] Experimental DCA encoder

2011-04-07 Thread Ronald S. Bultje
Hi,

2011/4/7 Benjamin Larsson :
> +static inline int32_t mul32(int32_t a, int32_t b)
> +{
> +/* on >=i686, gcc compiles this into a single "imull" instruction */
> +int64_t r = (int64_t)a * b;
> +/* round the result before truncating - improves accuracy */
> +return (r + 0x8000) >> 32;
> +}

I believe this is what the MUL64() macro is for, then it works on
non-x86 archs also, but that doesn't round...

> +static int32_t cos_table[128];
[..]
> +static void qmf_init(void)

There should probably be a static inited = 0; that you set after
succesful init, since this function only has to run once, not every
time the codec re-inits.

> +int i;
> +int32_t c[17], s[17];
> +s[0] = 0;   /* sin(index * PI / 64) * 0x7fff */
> +c[0] = 0x7fff;  /* cos(index * PI / 64) * 0x7fff */
> +
> +for (i = 1; i <= 16; i++) {
> +s[i] = 2 * (mul32(c[i-1], 105372028) + mul32(s[i-1], 2144896908));
> +c[i] = 2 * (mul32(c[i-1], 2144896908) - mul32(s[i-1], 105372028));
> +}
> +
> +for (i = 0; i < 16; i++) {
> +cos_table[i] = c[i] >> 3; /* so that the output doesn't overflow */
> +cos_table[i+16] = s[16-i] >> 3;
> +cos_table[i+32] = -s[i] >> 3;
> +cos_table[i+48] = -c[16-i] >> 3;
> +cos_table[i+64] = -c[i] >> 3;
> +cos_table[i+80] = -s[16-i] >> 3;
> +cos_table[i+96] = s[i] >> 3;
> +cos_table[i+112] = c[16-i] >> 3;
> +}

For the cos-table, can you use libavcodec/sinewin.h functions? If not,
does this look like a proper int-implementation of the same thing that
we might want to share? E.g. does acenc_fixed.c have fixed-point cos
table generation also?

(I know, this is minor, ignore for now, not critical.)

> +static void qmf_decompose(DCAContext *c, int32_t in[32], int32_t out[32], 
> int channel)
> +{
> +int band, i, j, k;
> +int32_t resp;
> +int32_t accum[DCA_SUBBANDS_32];
> +
> +add_new_samples(c, in, DCA_SUBBANDS_32, channel);
> +
> +/* Calculate the dot product of the signal with the (possibly inverted)
> +   reference decoder's response to this vector:
> +   (0.0, 0.0, ..., 0.0, -1.0, 1.0, 0.0, ..., 0.0)
> +   so that -1.0 cancels 1.0 from the previous step */
> +
> +memset(accum,0,sizeof(accum));
> +
> +for (k = 48, j = 0, i = c->start[channel]; i < 512; k++, j++, i++)
> +accum[(k & 32) ? (31 - (k & 31)) : (k & 31)] += 
> mul32(c->history[channel][i], UnQMF[j]);
> +for (i = 0; i < c->start[channel]; k++, j++, i++)
> +accum[(k & 32) ? (31 - (k & 31)) : (k & 31)] += 
> mul32(c->history[channel][i], UnQMF[j]);
> +
> +resp = 0;
> +/* TODO: implement FFT instead of this naive calculation */
> +for (band = 0; band < DCA_SUBBANDS_32; band++) {
> +for (j = 0; j < 32; j++)
> +resp += mul32(accum[j], band_delta_factor(band, j));
> +
> +out[band] = (band & 2) ? (-resp) : resp;
> +}
> +}

I'll probably sound very naive, but what does this piece of the code do?

> +static void init_lfe_fir(void){
> +static int initialized;
> +int i;
> +if(initialized)
> +return;
> +for(i=0; i<512; i++)
> +lfe_fir_64i[i] = lfe_fir_64[i] * (1<<25); //float -> int32_t
> +initialized = 1;
> +}

This kind of stuff, along with cos tables, FFT etc, raises the
question why this wasn't implemented in float... Realistically, if
!CONFIG_SMALL, the table should be hardcoded.

The bitstream stuff I didn't review because I'm not very familiar with it...

> +static int DCA_encode_init(AVCodecContext *avctx) {
[..]
> +for(i=0; i<16; i++){
> +if(dca_sample_rates[i] == avctx->sample_rate)
> +break;
> +}
> +if(i==16){
> +av_log(avctx, AV_LOG_ERROR, "Sample rate %iHz not supported\n", 
> avctx->sample_rate);
> +return -1;
> +}
> +c->sample_rate_code = i;

That is pretty unhelpful. What samplerates _are_ supported? Better
yet, how would the user accomplish the resampling within ffmpeg?

> diff --git a/libavcodec/dcaenc.h b/libavcodec/dcaenc.h
[..]
> +/* This is a scaled version of the response of the reference decoder to
> +   this vector of subband samples: ( 1.0 0.0 0.0 ... 0.0 )
> +   */
> +
> +static const int32_t UnQMF[512] = {

??? What is that?

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


Re: [libav-devel] [PATCH 2/6] avio: avio_ prefix for url_exist().

2011-04-07 Thread Ronald S. Bultje
Hi,

On Thu, Apr 7, 2011 at 4:40 PM, Anton Khirnov  wrote:
> On Thu, Apr 07, 2011 at 04:34:39PM -0400, Ronald S. Bultje wrote:
>> On Thu, Apr 7, 2011 at 3:16 PM, Anton Khirnov  wrote:
>> > ---
>> >  ffmpeg.c           |    2 +-
>> >  ffserver.c         |    4 ++--
>> >  libavformat/avio.c |    6 +-
>> >  libavformat/avio.h |    3 ++-
>> >  libavformat/img2.c |    6 +++---
>> >  5 files changed, 13 insertions(+), 8 deletions(-)
>>
>> Should this be public? I don't think it should. For local files, it's
>> trivial to re-implement in each place where it's needed. Does it work
>> for non-file://-URIs?
>
> It uses url_open, so I see no reason why it wouldn't.

I guess it's fine. I'm not very comfortable with it being in lavf but
who am I to say it doesn't belong there if our top committer of the
year thinks otherwise? :-).

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


Re: [libav-devel] [FFmpeg-devel] GSoC project (JPEG 2000)

2011-04-07 Thread rukhsana afroz
On Wed, Apr 6, 2011 at 9:24 AM, Michael Niedermayer wrote:

>
> I suspect the If statement is there as the implementation only supports
> cblk_style==0
> the others simply are not implemented
>
> Do you think you can implement them?
>
>
>
Hi all,

I have submitted my proposal on GSoC this year. And Michael, I believe, I
shall be able to implement the missing features of the current
decoder/encoder. Particularly for this missing feature, I will get back to
you soon about the way I will implement this missing feature.

Thanks
Ruby

-- 
Rukhsana Ruby
Phd Student
Department of Electrical & Computer Engineering
The University of British Columbia

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


Re: [libav-devel] [FFmpeg-devel] GSoC project (JPEG 2000)

2011-04-07 Thread rukhsana afroz
On Wed, Apr 6, 2011 at 9:24 AM, Michael Niedermayer wrote:

> I suspect the If statement is there as the implementation only supports
> cblk_style==0
> the others simply are not implemented
>
> Do you think you can implement them?
>
> Hi all,

I have submitted my proposal on GSoC this year. And Michael, I believe, I
shall be able to implement the missing features of the current
decoder/encoder. Particularly for this missing feature, I will get back to
you soon about the way I will implement this missing feature.

Thanks
Ruby

-- 
Rukhsana Ruby
Phd Student
Department of Electrical & Computer Engineering
The University of British Columbia

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


Re: [libav-devel] [rfc] Protocol API

2011-04-07 Thread aviad rozenhek
On Thu, Apr 7, 2011 at 23:39, Anton Khirnov  wrote:

> On Thu, Apr 07, 2011 at 10:25:12PM +0200, Luca Barbato wrote:
>
> Of course it all depends on demand for such a thing, so who wants direct
> access to protocols, please speak up now.
>
> --
> Anton Khirnov
>

I want direct access to protocols


>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.11 (GNU/Linux)
>
> iEYEARECAAYFAk2eIRcACgkQtQoSQcBnB6tEwgCfRLC2+MeMN4DWO4oq4toffi+n
> E6EAn1Gq6wSyRh/hebI64QQojXo8Jx8y
> =BQzJ
> -END PGP SIGNATURE-
>
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
>
>


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


[libav-devel] [PATCH] Experimental DCA encoder

2011-04-07 Thread Benjamin Larsson
MvH
Benjamin Larsson
>From 72e6371e0c98e344275173452cec98940a33ef39 Mon Sep 17 00:00:00 2001
From: Alexander E. Patrakov 
Date: Fri, 8 Apr 2011 01:33:21 +0200
Subject: [PATCH] Experimental DCA encoder

---
 libavcodec/Makefile|1 +
 libavcodec/allcodecs.c |2 +-
 libavcodec/dcaenc.c|  581 
 libavcodec/dcaenc.h|  544 +
 4 files changed, 1127 insertions(+), 1 deletions(-)
 create mode 100644 libavcodec/dcaenc.c
 create mode 100644 libavcodec/dcaenc.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 837f7e2..195469d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -104,6 +104,7 @@ OBJS-$(CONFIG_COOK_DECODER)+= cook.o
 OBJS-$(CONFIG_CSCD_DECODER)+= cscd.o
 OBJS-$(CONFIG_CYUV_DECODER)+= cyuv.o
 OBJS-$(CONFIG_DCA_DECODER) += dca.o synth_filter.o dcadsp.o
+OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o
 OBJS-$(CONFIG_DFA_DECODER) += dfa.o
 OBJS-$(CONFIG_DNXHD_DECODER)   += dnxhddec.o dnxhddata.o
 OBJS-$(CONFIG_DNXHD_ENCODER)   += dnxhdenc.o dnxhddata.o   \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 7636392..9530358 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -238,7 +238,7 @@ void avcodec_register_all(void)
 REGISTER_DECODER (BINKAUDIO_DCT, binkaudio_dct);
 REGISTER_DECODER (BINKAUDIO_RDFT, binkaudio_rdft);
 REGISTER_DECODER (COOK, cook);
-REGISTER_DECODER (DCA, dca);
+REGISTER_ENCDEC  (DCA, dca);
 REGISTER_DECODER (DSICINAUDIO, dsicinaudio);
 REGISTER_DECODER (EAC3, eac3);
 REGISTER_ENCDEC  (FLAC, flac);
diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c
new file mode 100644
index 000..0362485
--- /dev/null
+++ b/libavcodec/dcaenc.c
@@ -0,0 +1,581 @@
+/*
+ * DCA encoder
+ * Copyright (C) 2008 Alexander E. Patrakov
+ *   2010 Benjamin Larsson
+ *   2011 Xiang Wang
+ * This file is part of Libav.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/common.h"
+#include "libavutil/avassert.h"
+#include "libavutil/audioconvert.h"
+#include "avcodec.h"
+#include "get_bits.h"
+#include "put_bits.h"
+#include "dcaenc.h"
+#include "dcadata.h"
+
+#undef NDEBUG
+
+#define MAX_CHANNELS 6
+#define DCA_SUBBANDS_32 32
+#define DCA_MAX_FRAME_SIZE 16383
+#define DCA_HEADER_SIZE 13
+
+#define DCA_SUBBANDS 32 ///< Subband activity count
+#define QUANTIZER_BITS 16
+#define SUBFRAMES 1
+#define SUBSUBFRAMES 4
+#define PCM_SAMPLES (SUBFRAMES*SUBSUBFRAMES*8)
+#define LFE_BITS 8
+#define LFE_INTERPOLATION 64
+#define LFE_PRESENT 2
+#define LFE_MISSING 0
+
+static const int8_t dca_lfe_index[] = {
+1,2,2,2,2,3,2,3,2,3,2,3,1,3,2,3
+};
+
+static const int8_t dca_channel_reorder_lfe[][9] = {
+{ 0, -1, -1, -1, -1, -1, -1, -1, -1},
+{ 0,  1, -1, -1, -1, -1, -1, -1, -1},
+{ 0,  1, -1, -1, -1, -1, -1, -1, -1},
+{ 0,  1, -1, -1, -1, -1, -1, -1, -1},
+{ 0,  1, -1, -1, -1, -1, -1, -1, -1},
+{ 1,  2,  0, -1, -1, -1, -1, -1, -1},
+{ 0,  1, -1,  2, -1, -1, -1, -1, -1},
+{ 1,  2,  0, -1,  3, -1, -1, -1, -1},
+{ 0,  1, -1,  2,  3, -1, -1, -1, -1},
+{ 1,  2,  0, -1,  3,  4, -1, -1, -1},
+{ 2,  3, -1,  0,  1,  4,  5, -1, -1},
+{ 1,  2,  0, -1,  3,  4,  5, -1, -1},
+{ 0, -1,  4,  5,  2,  3,  1, -1, -1},
+{ 3,  4,  1, -1,  0,  2,  5,  6, -1},
+{ 2,  3, -1,  5,  7,  0,  1,  4,  6},
+{ 3,  4,  1, -1,  0,  2,  5,  7,  6},
+};
+
+static const int8_t dca_channel_reorder_nolfe[][9] = {
+{ 0, -1, -1, -1, -1, -1, -1, -1, -1},
+{ 0,  1, -1, -1, -1, -1, -1, -1, -1},
+{ 0,  1, -1, -1, -1, -1, -1, -1, -1},
+{ 0,  1, -1, -1, -1, -1, -1, -1, -1},
+{ 0,  1, -1, -1, -1, -1, -1, -1, -1},
+{ 1,  2,  0, -1, -1, -1, -1, -1, -1},
+{ 0,  1,  2, -1, -1, -1, -1, -1, -1},
+{ 1,  2,  0,  3, -1, -1, -1, -1, -1},
+{ 0,  1,  2,  3, -1, -1, -1, -1, -1},
+{ 1,  2,  0,  3,  4, -1, -1, -1, -1},
+{ 2,  3,  0,  1,  4,  5, -1, -1, -1},
+{ 1,  2,  0,  3,  4,  5, -1, -1, -1},
+{ 0,  4,  5,  2,  3,  1, -1, -1, -1},
+{ 3,  4,  1,  0,  2,  5,  6, -1, -1},
+{ 2,  3,  5,  7,  0,  1,  4,  6, -1},
+{ 3,  4,  1,  0,  2,  5,  7,  6, -1},
+};
+
+type

Re: [libav-devel] [PATCH 1/3] introduce side information in AVPacket

2011-04-07 Thread Diego Biurrun
On Thu, Apr 07, 2011 at 10:28:25AM +0200, Kostya wrote:
> 
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1054,6 +1054,14 @@ typedef struct AVPacket {
>  int   size;
> +/**
> + * Additional packet data that may be provided by container. If present

by the container

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


Re: [libav-devel] [PATCH 2/2] Add support for AMR-WB encoding via libvo-amrwbenc

2011-04-07 Thread Martin Storsjö
On Fri, 8 Apr 2011, Diego Biurrun wrote:

> On Thu, Apr 07, 2011 at 12:45:13PM +0300, Martin Storsjö wrote:
> > 
> > --- /dev/null
> > +++ b/libavcodec/libvo-amrwbenc.c
> > @@ -0,0 +1,126 @@
> > +
> > +#include "avcodec.h"
> > +#include 
> 
> Place system headers before local headers, separate by an empty line.

Done

// MartinFrom da5a20a118336f68ef504d0cf712d18ccaa7ce50 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Tue, 29 Dec 2009 16:48:09 +0200
Subject: [PATCH 2/2] Add support for AMR-WB encoding via libvo-amrwbenc

The wrapper code is based on the libamr wrapper removed in SVN rev 19365.
---
 Changelog   |1 +
 configure   |6 ++
 doc/general.texi|3 +-
 libavcodec/Makefile |1 +
 libavcodec/allcodecs.c  |1 +
 libavcodec/libvo-amrwbenc.c |  127 +++
 libavcodec/version.h|2 +-
 7 files changed, 139 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/libvo-amrwbenc.c

diff --git a/Changelog b/Changelog
index 6a255d4..87ec036 100644
--- a/Changelog
+++ b/Changelog
@@ -84,6 +84,7 @@ version :
 - Chronomaster DFA decoder
 - Mobotix MxPEG decoder
 - AAC encoding via libvo-aacenc
+- AMR-WB encoding via libvo-amrwbenc
 
 
 version 0.6:
diff --git a/configure b/configure
index 8880fba..c632ce5 100755
--- a/configure
+++ b/configure
@@ -179,6 +179,7 @@ External library support:
   --enable-libspeexenable Speex decoding via libspeex [no]
   --enable-libtheora   enable Theora encoding via libtheora [no]
   --enable-libvo-aacencenable AAC encoding via libvo-aacenc [no]
+  --enable-libvo-amrwbenc  enable AMR-WB encoding via libvo-amrwbenc [no]
   --enable-libvorbis   enable Vorbis encoding via libvorbis,
native implementation exists [no]
   --enable-libvpx  enable VP8 support via libvpx [no]
@@ -939,6 +940,7 @@ CONFIG_LIST="
 libspeex
 libtheora
 libvo_aacenc
+libvo_amrwbenc
 libvorbis
 libvpx
 libx264
@@ -1387,6 +1389,7 @@ libschroedinger_encoder_deps="libschroedinger"
 libspeex_decoder_deps="libspeex"
 libtheora_encoder_deps="libtheora"
 libvo_aacenc_encoder_deps="libvo_aacenc"
+libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
 libvorbis_encoder_deps="libvorbis"
 libvpx_decoder_deps="libvpx"
 libvpx_encoder_deps="libvpx"
@@ -2529,6 +2532,7 @@ die_license_disabled nonfree libfaac
 die_license_disabled version3 libopencore_amrnb
 die_license_disabled version3 libopencore_amrwb
 die_license_disabled version3 libvo_aacenc
+die_license_disabled version3 libvo_amrwbenc
 
 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
 
@@ -2869,6 +2873,7 @@ enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schr
 enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
 enabled libtheora  && require  libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
 enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
+enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
 enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
 enabled libvpx && {
 enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
@@ -3138,6 +3143,7 @@ echo "libspeex enabled  ${libspeex-no}"
 echo "libtheora enabled ${libtheora-no}"
 echo "libva enabled ${vaapi-no}"
 echo "libvo-aacenc support  ${libvo_aacenc-no}"
+echo "libvo-amrwbenc support${libvo_amrwbenc-no}"
 echo "libvorbis enabled ${libvorbis-no}"
 echo "libvpx enabled${libvpx-no}"
 echo "libx264 enabled   ${libx264-no}"
diff --git a/doc/general.texi b/doc/general.texi
index a8fab31..2c7949d 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -588,7 +588,8 @@ following image formats are supported:
 @item ADPCM Yamaha   @tab  X  @tab  X
 @item AMR-NB @tab  E  @tab  X
 @tab encoding supported through external library libopencore-amrnb
-@item AMR-WB @tab @tab  X
+@item AMR-WB @tab  E  @tab  X
+@tab encoding supported through external library libvo-amrwbenc
 @item Apple lossless audio   @tab  X  @tab  X
 @tab QuickTime fourcc 'alac'
 @item Atrac 1@tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e9c40e4..1cdae2c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -569,6 +569,7 @@ OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER)+= libschroedingerenc.o \
 OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBVO_AACENC_ENCODER)   += libvo-aacenc.o mpeg4audio.o
+OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
 OBJS-$(CONFIG_LIBVORBIS_ENCODE

Re: [libav-devel] [PATCH 1/2] Add an AAC encoder by using the libvo-aacenc library

2011-04-07 Thread Martin Storsjö
On Fri, 8 Apr 2011, Diego Biurrun wrote:

> On Thu, Apr 07, 2011 at 12:18:53PM +0300, Martin Storsjö wrote:
> > ---
> >  Changelog |1 +
> >  configure |6 ++
> >  libavcodec/Makefile   |1 +
> >  libavcodec/allcodecs.c|1 +
> >  libavcodec/libvo-aacenc.c |  132 
> > +
> >  5 files changed, 141 insertions(+), 0 deletions(-)
> >  create mode 100644 libavcodec/libvo-aacenc.c
> 
> minor bump, docs update

Added

> > --- /dev/null
> > +++ b/libavcodec/libvo-aacenc.c
> > @@ -0,0 +1,132 @@
> > +/*
> > + * AAC encoder wrapper
> > + * Copyright (c) 2010 Martin Storsjo
> 
> 2011?

I actually wrote this in December, I've only done minor touchups since.

> > +#include "avcodec.h"
> > +#include 
> > +#include 
> > +#include "mpeg4audio.h"
> 
> Place system headers before local headers, separate by an empty line.

Done

> > +typedef struct AACContext {
> > +VO_AUDIO_CODECAPI codec_api;
> > +VO_HANDLE handle;
> > +VO_MEM_OPERATOR mem_operator;
> > +VO_CODEC_INIT_USERDATA user_data;
> > +} AACContext;
> > +
> > +static av_cold int aac_encode_init(AVCodecContext *avctx)
> > +{
> > +AACContext *s = avctx->priv_data;
> > +AACENC_PARAM params;
> > +int index;
> > +
> > +memset(¶ms, 0, sizeof(params));
> 
> Why not initialize params to 0 instead?

Fixed

> > +avctx->coded_frame = avcodec_alloc_frame();
> > +avctx->frame_size = 1024;
> 
> > +s->mem_operator.Alloc = cmnMemAlloc;
> > +s->mem_operator.Copy = cmnMemCopy;
> > +s->mem_operator.Free = cmnMemFree;
> > +s->mem_operator.Set = cmnMemSet;
> > +s->mem_operator.Check = cmnMemCheck;
> > +s->user_data.memflag = VO_IMF_USERMEMOPERATOR;
> > +s->user_data.memData = &s->mem_operator;
> > +s->codec_api.Init(&s->handle, VO_AUDIO_CodingAAC, &s->user_data);
> 
> > +params.sampleRate = avctx->sample_rate;
> > +params.bitRate = avctx->bit_rate;
> > +params.nChannels = avctx->channels;
> > +params.adtsUsed = 0;
> 
> > +avctx->extradata_size = 2;
> > +avctx->extradata = av_mallocz(avctx->extradata_size +
> > +  FF_INPUT_BUFFER_PADDING_SIZE);
> 
> nit: align the '='

Done

> > +static int aac_encode_frame(AVCodecContext *avctx,
> > +unsigned char *frame/*out*/,
> > +int buf_size, void *data/*in*/)
> > +{
> > +AACContext *s = avctx->priv_data;
> > +VO_CODECBUFFER input, output;
> > +VO_AUDIO_OUTPUTINFO output_info;
> > +
> > +memset(&input,   0, sizeof(input));
> > +memset(&output,  0, sizeof(output));
> > +memset(&output_info, 0, sizeof(output_info));
> 
> same, initialize to 0

Done

// MartinFrom b7a823b2da26d59976464b42d0b7e528cb7980fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Sun, 19 Dec 2010 21:40:23 +0200
Subject: [PATCH 1/2] Add an AAC encoder by using the libvo-aacenc library

---
 Changelog |1 +
 configure |6 ++
 doc/general.texi  |2 +-
 libavcodec/Makefile   |1 +
 libavcodec/allcodecs.c|1 +
 libavcodec/libvo-aacenc.c |  128 +
 libavcodec/version.h  |2 +-
 7 files changed, 139 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/libvo-aacenc.c

diff --git a/Changelog b/Changelog
index ec09c28..6a255d4 100644
--- a/Changelog
+++ b/Changelog
@@ -83,6 +83,7 @@ version :
 - Linux framebuffer input device added
 - Chronomaster DFA decoder
 - Mobotix MxPEG decoder
+- AAC encoding via libvo-aacenc
 
 
 version 0.6:
diff --git a/configure b/configure
index 92a809f..8880fba 100755
--- a/configure
+++ b/configure
@@ -178,6 +178,7 @@ External library support:
   --enable-libschroedinger enable Dirac support via libschroedinger [no]
   --enable-libspeexenable Speex decoding via libspeex [no]
   --enable-libtheora   enable Theora encoding via libtheora [no]
+  --enable-libvo-aacencenable AAC encoding via libvo-aacenc [no]
   --enable-libvorbis   enable Vorbis encoding via libvorbis,
native implementation exists [no]
   --enable-libvpx  enable VP8 support via libvpx [no]
@@ -937,6 +938,7 @@ CONFIG_LIST="
 libschroedinger
 libspeex
 libtheora
+libvo_aacenc
 libvorbis
 libvpx
 libx264
@@ -1384,6 +1386,7 @@ libschroedinger_decoder_deps="libschroedinger"
 libschroedinger_encoder_deps="libschroedinger"
 libspeex_decoder_deps="libspeex"
 libtheora_encoder_deps="libtheora"
+libvo_aacenc_encoder_deps="libvo_aacenc"
 libvorbis_encoder_deps="libvorbis"
 libvpx_decoder_deps="libvpx"
 libvpx_encoder_deps="libvpx"
@@ -2525,6 +2528,7 @@ die_license_disabled nonfree libfaac
 
 die_license_disabled version3 libopencore_amrnb
 die_license_disabled version3 libopencore_amrwb
+die_license_disabled version3 libvo_aacenc
 
 enabled version3 && { enabled gpl && enable gpl

Re: [libav-devel] [PATCH 2/2] add MicroDVD muxer and demuxer

2011-04-07 Thread Diego Biurrun
On Tue, Apr 05, 2011 at 09:08:44PM +0200, Luca Barbato wrote:
> From: Aurelien Jacobs 
> 
> --- /dev/null
> +++ b/libavformat/microdvddec.c
> @@ -0,0 +1,129 @@
> +/*
> + * MicroDVD subtitle demuxer
> + * Copyright (c) 2010  Aurelien Jacobs 
> + *
> + * This file is part of FFmpeg.

Ahem...

> +for (i=0; i<3; i++) {

whitespace around operators would make this more readable,
same for all other for loops.

> --- /dev/null
> +++ b/libavformat/microdvdenc.c
> @@ -0,0 +1,51 @@
> +/*
> + * MicroDVD subtitle muxer
> + * Copyright (c) 2010  Aurelien Jacobs 
> + *
> + * This file is part of FFmpeg.

again

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


Re: [libav-devel] [PATCH 1/2] Add an AAC encoder by using the libvo-aacenc library

2011-04-07 Thread Diego Biurrun
On Thu, Apr 07, 2011 at 12:18:53PM +0300, Martin Storsjö wrote:
> ---
>  Changelog |1 +
>  configure |6 ++
>  libavcodec/Makefile   |1 +
>  libavcodec/allcodecs.c|1 +
>  libavcodec/libvo-aacenc.c |  132 
> +
>  5 files changed, 141 insertions(+), 0 deletions(-)
>  create mode 100644 libavcodec/libvo-aacenc.c

minor bump, docs update

> --- /dev/null
> +++ b/libavcodec/libvo-aacenc.c
> @@ -0,0 +1,132 @@
> +/*
> + * AAC encoder wrapper
> + * Copyright (c) 2010 Martin Storsjo

2011?

> +#include "avcodec.h"
> +#include 
> +#include 
> +#include "mpeg4audio.h"

Place system headers before local headers, separate by an empty line.

> +typedef struct AACContext {
> +VO_AUDIO_CODECAPI codec_api;
> +VO_HANDLE handle;
> +VO_MEM_OPERATOR mem_operator;
> +VO_CODEC_INIT_USERDATA user_data;
> +} AACContext;
> +
> +static av_cold int aac_encode_init(AVCodecContext *avctx)
> +{
> +AACContext *s = avctx->priv_data;
> +AACENC_PARAM params;
> +int index;
> +
> +memset(¶ms, 0, sizeof(params));

Why not initialize params to 0 instead?

> +avctx->coded_frame = avcodec_alloc_frame();
> +avctx->frame_size = 1024;

> +s->mem_operator.Alloc = cmnMemAlloc;
> +s->mem_operator.Copy = cmnMemCopy;
> +s->mem_operator.Free = cmnMemFree;
> +s->mem_operator.Set = cmnMemSet;
> +s->mem_operator.Check = cmnMemCheck;
> +s->user_data.memflag = VO_IMF_USERMEMOPERATOR;
> +s->user_data.memData = &s->mem_operator;
> +s->codec_api.Init(&s->handle, VO_AUDIO_CodingAAC, &s->user_data);

> +params.sampleRate = avctx->sample_rate;
> +params.bitRate = avctx->bit_rate;
> +params.nChannels = avctx->channels;
> +params.adtsUsed = 0;

> +avctx->extradata_size = 2;
> +avctx->extradata = av_mallocz(avctx->extradata_size +
> +  FF_INPUT_BUFFER_PADDING_SIZE);

nit: align the '='

> +static int aac_encode_frame(AVCodecContext *avctx,
> +unsigned char *frame/*out*/,
> +int buf_size, void *data/*in*/)
> +{
> +AACContext *s = avctx->priv_data;
> +VO_CODECBUFFER input, output;
> +VO_AUDIO_OUTPUTINFO output_info;
> +
> +memset(&input,   0, sizeof(input));
> +memset(&output,  0, sizeof(output));
> +memset(&output_info, 0, sizeof(output_info));

same, initialize to 0

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


Re: [libav-devel] [PATCH 2/2] Add support for AMR-WB encoding via libvo-amrwbenc

2011-04-07 Thread Diego Biurrun
On Thu, Apr 07, 2011 at 12:45:13PM +0300, Martin Storsjö wrote:
> 
> --- /dev/null
> +++ b/libavcodec/libvo-amrwbenc.c
> @@ -0,0 +1,126 @@
> +
> +#include "avcodec.h"
> +#include 

Place system headers before local headers, separate by an empty line.

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


Re: [libav-devel] [PATCH 3/6] asfdec: remove a forgotten declaration of nonexistent function

2011-04-07 Thread Diego Biurrun
On Thu, Apr 07, 2011 at 09:16:20PM +0200, Anton Khirnov wrote:
> ---
>  libavformat/asfdec.c |2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)

OK

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


Re: [libav-devel] [PATCH 2/6] avio: avio_ prefix for url_exist().

2011-04-07 Thread Anton Khirnov
On Thu, Apr 07, 2011 at 04:34:39PM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On Thu, Apr 7, 2011 at 3:16 PM, Anton Khirnov  wrote:
> > ---
> >  ffmpeg.c           |    2 +-
> >  ffserver.c         |    4 ++--
> >  libavformat/avio.c |    6 +-
> >  libavformat/avio.h |    3 ++-
> >  libavformat/img2.c |    6 +++---
> >  5 files changed, 13 insertions(+), 8 deletions(-)
> 
> Should this be public? I don't think it should. For local files, it's
> trivial to re-implement in each place where it's needed. Does it work
> for non-file://-URIs?
> 

It uses url_open, so I see no reason why it wouldn't.

-- 
Anton Khirnov


signature.asc
Description: Digital signature
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [rfc] Protocol API

2011-04-07 Thread Anton Khirnov
On Thu, Apr 07, 2011 at 10:25:12PM +0200, Luca Barbato wrote:
> The old URLFoo api is now private, so we can try to shape it up aiming
> to have it ready and usable for the 0.8 (that means mid or end summer).
> 

I am not entirely convinced that protocols should be public at all. Lavf
is primarily a muxer/demuxer library, protocols aren't its main focus.

Of course it all depends on demand for such a thing, so who wants direct
access to protocols, please speak up now.

-- 
Anton Khirnov


signature.asc
Description: Digital signature
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/6] avio: avio_ prefix for url_exist().

2011-04-07 Thread Ronald S. Bultje
Hi,

On Thu, Apr 7, 2011 at 3:16 PM, Anton Khirnov  wrote:
> ---
>  ffmpeg.c           |    2 +-
>  ffserver.c         |    4 ++--
>  libavformat/avio.c |    6 +-
>  libavformat/avio.h |    3 ++-
>  libavformat/img2.c |    6 +++---
>  5 files changed, 13 insertions(+), 8 deletions(-)

Should this be public? I don't think it should. For local files, it's
trivial to re-implement in each place where it's needed. Does it work
for non-file://-URIs?

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


[libav-devel] [rfc] Protocol API

2011-04-07 Thread Luca Barbato
The old URLFoo api is now private, so we can try to shape it up aiming
to have it ready and usable for the 0.8 (that means mid or end summer).

I know that there are people using the low level protocols and they
might help brainstorming.

Needs:
- They should be chainable (applehttp uses http that uses tcp)
- They should be time and byte seekable
- They could share some common options (e.g. I want to be able set a
  protocol to listen if it is a network one)
- They will need a way to ask group polling and/or to satisfy specific
needs (e.g. rtp/rtsp situation)

Protocols that should be available:
low level
- udp
- tcp
- sctp (being polished a little in a branch on my github)
- dccp (I want it as well hadn't worked on it yet)
- unix socket (posted long ago, pending more polish)

Higher level (use the lower level ones)
- http
- rtp ** (this one is the muddiest)
- rtmp (librtmp and our native one)
- ssl (using an external library?)

strange stuff
- async (e.g. to avoid packets drop and desync in ffmpeg, I'm
considering also having an async chain-demuxer, experiments got posted
already more will come)


I hope that had piqued a bit your interest =)

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 4/6] avio: move two ff_udp_* functions from avio_internal to url.h

2011-04-07 Thread Luca Barbato
On 04/07/2011 09:16 PM, Anton Khirnov wrote:
> ---
>  libavformat/avio_internal.h |4 
>  libavformat/url.h   |4 
>  2 files changed, 4 insertions(+), 4 deletions(-)

Ok.


-- 

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

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


Re: [libav-devel] [PATCH 2/6] avio: avio_ prefix for url_exist().

2011-04-07 Thread Luca Barbato
On 04/07/2011 09:16 PM, Anton Khirnov wrote:
> ---
>  ffmpeg.c   |2 +-
>  ffserver.c |4 ++--
>  libavformat/avio.c |6 +-
>  libavformat/avio.h |3 ++-
>  libavformat/img2.c |6 +++---
>  5 files changed, 13 insertions(+), 8 deletions(-)

Ok.

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/6] avio: deprecate the typedef for URLInterruptCB

2011-04-07 Thread Luca Barbato
On 04/07/2011 09:16 PM, Anton Khirnov wrote:
> There's no particular reason to pollute the namespace with a typedef for
> it.

That makes it also more self-documenting, patch ok.

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


[libav-devel] [PATCH 6/6] avio: make URLProtocol internal.

2011-04-07 Thread Anton Khirnov
---
 libavformat/allformats.c |2 +-
 libavformat/applehttpproto.c |2 +-
 libavformat/avio.c   |   26 +-
 libavformat/avio.h   |6 +-
 libavformat/concat.c |2 +-
 libavformat/file.c   |4 ++--
 libavformat/gopher.c |2 +-
 libavformat/http.c   |2 +-
 libavformat/librtmp.c|   10 +-
 libavformat/md5proto.c   |2 +-
 libavformat/mmsh.c   |2 +-
 libavformat/mmst.c   |2 +-
 libavformat/rtmpproto.c  |2 +-
 libavformat/rtpproto.c   |2 +-
 libavformat/tcp.c|2 +-
 libavformat/udp.c|2 +-
 libavformat/url.h|   28 
 17 files changed, 61 insertions(+), 37 deletions(-)

diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 9398d34..652a8e8 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -34,7 +34,7 @@
 #define REGISTER_MUXDEMUX(X,x)  REGISTER_MUXER(X,x); REGISTER_DEMUXER(X,x)
 
 #define REGISTER_PROTOCOL(X,x) { \
-extern URLProtocol ff_##x##_protocol; \
+extern FFURLProtocol ff_##x##_protocol; \
 if(CONFIG_##X##_PROTOCOL) ffurl_register_protocol(&ff_##x##_protocol, 
sizeof(ff_##x##_protocol)); }
 
 void av_register_all(void)
diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c
index dad34e4..254e064 100644
--- a/libavformat/applehttpproto.c
+++ b/libavformat/applehttpproto.c
@@ -297,7 +297,7 @@ static int applehttp_close(FFURLContext *h)
 return 0;
 }
 
-URLProtocol ff_applehttp_protocol = {
+FFURLProtocol ff_applehttp_protocol = {
 "applehttp",
 applehttp_open,
 applehttp_read,
diff --git a/libavformat/avio.c b/libavformat/avio.c
index b1a31f1..b5320c8 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -48,11 +48,11 @@ static const AVClass urlcontext_class =
 
 static int default_interrupt_cb(void);
 
-URLProtocol *first_protocol = NULL;
+FFURLProtocol *first_protocol = NULL;
 int (*url_interrupt_cb)(void) = default_interrupt_cb;
 
 #if FF_API_OLD_AVIO
-URLProtocol *av_protocol_next(URLProtocol *p)
+FFURLProtocol *av_protocol_next(FFURLProtocol *p)
 {
 if(p) return p->next;
 else  return first_protocol;
@@ -61,7 +61,7 @@ URLProtocol *av_protocol_next(URLProtocol *p)
 
 const char *avio_enum_protocols(void **opaque, int output)
 {
-URLProtocol **p = opaque;
+FFURLProtocol **p = opaque;
 *p =   *p ? (*p)->next : first_protocol;
 if (!*p) return NULL;
 if ((output && (*p)->url_write) || (!output && (*p)->url_read))
@@ -69,11 +69,11 @@ const char *avio_enum_protocols(void **opaque, int output)
 return avio_enum_protocols(opaque, output);
 }
 
-int ffurl_register_protocol(URLProtocol *protocol, int size)
+int ffurl_register_protocol(FFURLProtocol *protocol, int size)
 {
-URLProtocol **p;
-if (size < sizeof(URLProtocol)) {
-URLProtocol* temp = av_mallocz(sizeof(URLProtocol));
+FFURLProtocol **p;
+if (size < sizeof(FFURLProtocol)) {
+FFURLProtocol* temp = av_mallocz(sizeof(FFURLProtocol));
 memcpy(temp, protocol, size);
 protocol = temp;
 }
@@ -93,21 +93,21 @@ struct URLProtocol_compat {
 int (*url_write)(FFURLContext *h, unsigned char *buf, int size);
 int64_t (*url_seek)(FFURLContext *h, int64_t pos, int whence);
 int (*url_close)(FFURLContext *h);
-struct URLProtocol *next;
+struct FFURLProtocol *next;
 };
 
-int av_register_protocol(URLProtocol *protocol)
+int av_register_protocol(FFURLProtocol *protocol)
 {
 return ffurl_register_protocol(protocol, sizeof(struct 
URLProtocol_compat));
 }
 
-int register_protocol(URLProtocol *protocol)
+int register_protocol(FFURLProtocol *protocol)
 {
 return ffurl_register_protocol(protocol, sizeof(struct 
URLProtocol_compat));
 }
 #endif
 
-static int url_alloc_for_protocol (FFURLContext **puc, struct URLProtocol *up,
+static int url_alloc_for_protocol (FFURLContext **puc, FFURLProtocol *up,
const char *filename, int flags)
 {
 FFURLContext *uc;
@@ -232,7 +232,7 @@ void url_set_interrupt_cb(URLInterruptCB *interrupt_cb)
 {
 avio_set_interrupt_cb(interrupt_cb);
 }
-int av_register_protocol2(URLProtocol *protocol, int size)
+int av_register_protocol2(FFURLProtocol *protocol, int size)
 {
 return ffurl_register_protocol(protocol, size);
 }
@@ -249,7 +249,7 @@ int url_exist(const char *filename)
 
 int ffurl_alloc(FFURLContext **puc, const char *filename, int flags)
 {
-URLProtocol *up;
+FFURLProtocol *up;
 char proto_str[128], proto_nested[128], *ptr;
 size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
 
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 0a82f95..18e3edd 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -140,8 +140,11 @@ attribute_deprecated int url_poll(URLPollEntry 
*poll_table, int n, int timeout);
 
 
 #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1

[libav-devel] [PATCH 4/6] avio: move two ff_udp_* functions from avio_internal to url.h

2011-04-07 Thread Anton Khirnov
---
 libavformat/avio_internal.h |4 
 libavformat/url.h   |4 
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h
index 5ef4cca..2879ee1 100644
--- a/libavformat/avio_internal.h
+++ b/libavformat/avio_internal.h
@@ -92,10 +92,6 @@ int ffio_read_pause(AVIOContext *h,int pause);
 int64_t ffio_read_seek (AVIOContext *h,int stream_index,
 int64_t timestamp, int flags);
 
-/* udp.c */
-int ff_udp_set_remote_url(URLContext *h, const char *uri);
-int ff_udp_get_local_port(URLContext *h);
-
 void ffio_init_checksum(AVIOContext *s,
 unsigned long (*update_checksum)(unsigned long c, 
const uint8_t *p, unsigned int len),
 unsigned long checksum);
diff --git a/libavformat/url.h b/libavformat/url.h
index 941b8af..0786c99 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -140,4 +140,8 @@ int ffurl_get_file_handle(URLContext *h);
  */
 int ffurl_register_protocol(URLProtocol *protocol, int size);
 
+/* udp.c */
+int ff_udp_set_remote_url(FFURLContext *h, const char *uri);
+int ff_udp_get_local_port(FFURLContext *h);
+
 #endif //AVFORMAT_URL_H
-- 
1.7.4.1

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


[libav-devel] [PATCH 2/6] avio: avio_ prefix for url_exist().

2011-04-07 Thread Anton Khirnov
---
 ffmpeg.c   |2 +-
 ffserver.c |4 ++--
 libavformat/avio.c |6 +-
 libavformat/avio.h |3 ++-
 libavformat/img2.c |6 +++---
 5 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 83e77dd..d7d1764 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3733,7 +3733,7 @@ static void opt_output_file(const char *filename)
 (strchr(filename, ':') == NULL ||
  filename[1] == ':' ||
  av_strstart(filename, "file:", NULL))) {
-if (url_exist(filename)) {
+if (avio_exist(filename)) {
 if (!using_stdin) {
 fprintf(stderr,"File '%s' already exists. Overwrite ? 
[y/N] ", filename);
 fflush(stderr);
diff --git a/ffserver.c b/ffserver.c
index 259aaca..021b2e5 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -3684,7 +3684,7 @@ static void build_feed_streams(void)
 for(feed = first_feed; feed != NULL; feed = feed->next_feed) {
 int fd;
 
-if (url_exist(feed->feed_filename)) {
+if (avio_exist(feed->feed_filename)) {
 /* See if it matches */
 AVFormatContext *s;
 int matches = 0;
@@ -3757,7 +3757,7 @@ static void build_feed_streams(void)
 unlink(feed->feed_filename);
 }
 }
-if (!url_exist(feed->feed_filename)) {
+if (!avio_exist(feed->feed_filename)) {
 AVFormatContext s1 = {0}, *s = &s1;
 
 if (feed->readonly) {
diff --git a/libavformat/avio.c b/libavformat/avio.c
index cdf18f6..cc5836e 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -236,6 +236,10 @@ int av_register_protocol2(URLProtocol *protocol, int size)
 {
 return ffurl_register_protocol(protocol, size);
 }
+int url_exist(const char *filename)
+{
+return avio_exist(filename);
+}
 #endif
 
 #define URL_SCHEME_CHARS\
@@ -365,7 +369,7 @@ int ffurl_close(URLContext *h)
 return ret;
 }
 
-int url_exist(const char *filename)
+int avio_exist(const char *filename)
 {
 URLContext *h;
 if (ffurl_open(&h, filename, AVIO_RDONLY) < 0)
diff --git a/libavformat/avio.h b/libavformat/avio.h
index b27ec80..8302708 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -116,13 +116,14 @@ attribute_deprecated int av_url_read_pause(URLContext *h, 
int pause);
 attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index,
   int64_t timestamp, int flags);
 attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void));
+attribute_deprecated int url_exist(const char *url);
 #endif
 
 /**
  * Return a non-zero value if the resource indicated by url
  * exists, 0 otherwise.
  */
-int url_exist(const char *url);
+int avio_exist(const char *url);
 
 /**
  * The callback is called in blocking functions to test regulary if
diff --git a/libavformat/img2.c b/libavformat/img2.c
index 59d9150..6022301 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -130,11 +130,11 @@ static int find_image_range(int *pfirst_index, int 
*plast_index,
 if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){
 *pfirst_index =
 *plast_index = 1;
-if(url_exist(buf))
+if(avio_exist(buf))
 return 0;
 return -1;
 }
-if (url_exist(buf))
+if (avio_exist(buf))
 break;
 }
 if (first_index == 5)
@@ -152,7 +152,7 @@ static int find_image_range(int *pfirst_index, int 
*plast_index,
 if (av_get_frame_filename(buf, sizeof(buf), path,
   last_index + range1) < 0)
 goto fail;
-if (!url_exist(buf))
+if (!avio_exist(buf))
 break;
 range = range1;
 /* just in case... */
-- 
1.7.4.1

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


[libav-devel] [PATCH 1/6] avio: deprecate the typedef for URLInterruptCB

2011-04-07 Thread Anton Khirnov
There's no particular reason to pollute the namespace with a typedef for
it.
---
 libavformat/avio.c |4 ++--
 libavformat/avio.h |6 ++
 libavformat/url.h  |2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index e68ae99..cdf18f6 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -49,7 +49,7 @@ static const AVClass urlcontext_class =
 static int default_interrupt_cb(void);
 
 URLProtocol *first_protocol = NULL;
-URLInterruptCB *url_interrupt_cb = default_interrupt_cb;
+int (*url_interrupt_cb)(void) = default_interrupt_cb;
 
 #if FF_API_OLD_AVIO
 URLProtocol *av_protocol_next(URLProtocol *p)
@@ -401,7 +401,7 @@ static int default_interrupt_cb(void)
 return 0;
 }
 
-void avio_set_interrupt_cb(URLInterruptCB *interrupt_cb)
+void avio_set_interrupt_cb(int (*interrupt_cb)(void))
 {
 if (!interrupt_cb)
 interrupt_cb = default_interrupt_cb;
diff --git a/libavformat/avio.h b/libavformat/avio.h
index f182794..b27ec80 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -90,11 +90,9 @@ typedef struct URLPollEntry {
  * silently ignored.
  */
 #define URL_FLAG_NONBLOCK 4
-#endif
 
 typedef int URLInterruptCB(void);
 
-#if FF_API_OLD_AVIO
 /**
  * @defgroup old_url_funcs Old url_* functions
  * @deprecated use the buffered API based on AVIOContext instead
@@ -117,7 +115,7 @@ attribute_deprecated void url_get_filename(URLContext *h, 
char *buf, int buf_siz
 attribute_deprecated int av_url_read_pause(URLContext *h, int pause);
 attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index,
   int64_t timestamp, int flags);
-attribute_deprecated void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
+attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void));
 #endif
 
 /**
@@ -132,7 +130,7 @@ int url_exist(const char *url);
  * in this case by the interrupted function. 'NULL' means no interrupt
  * callback is given.
  */
-void avio_set_interrupt_cb(URLInterruptCB *interrupt_cb);
+void avio_set_interrupt_cb(int (*interrupt_cb)(void));
 
 #if FF_API_OLD_AVIO
 /* not implemented */
diff --git a/libavformat/url.h b/libavformat/url.h
index 7482611..941b8af 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -31,7 +31,7 @@
 #if !FF_API_OLD_AVIO
 #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the 
first part of a nested protocol scheme */
 
-extern URLInterruptCB *url_interrupt_cb;
+extern int (*url_interrupt_cb)(void);
 #endif
 
 /**
-- 
1.7.4.1

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


[libav-devel] [PATCH 3/6] asfdec: remove a forgotten declaration of nonexistent function

2011-04-07 Thread Anton Khirnov
---
 libavformat/asfdec.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 14ef2a5..20b4987 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -31,8 +31,6 @@
 #include "asfcrypt.h"
 #include "avlanguage.h"
 
-void ff_mms_set_stream_selection(URLContext *h, AVFormatContext *format);
-
 typedef struct {
 int asfid2avid[128]; ///< conversion table from asf ID 2 
AVStream ID
 ASFStream streams[128];  ///< it's max number and it's not 
that big
-- 
1.7.4.1

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


[libav-devel] [PATCH] Last bits of avio cleanup

2011-04-07 Thread Anton Khirnov
Hi,
with those patches, the avio cleanup is finally complete.

I'm not very sure about url_exist. It's used in ffmpeg, ffserver and
img2, but there were some problems with it [1]. There were patches from
Stefano adding a replacement [2] [3] [4], but they didn't get much
attention. Maybe we could revive them.

[1] http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2010-January/081756.html
[2] http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2010-September/097863.html
[3] http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2010-September/097864.html
[4] http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2010-September/097865.html

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


Re: [libav-devel] [PATCH] proto: include os_support.h in network.h

2011-04-07 Thread Martin Storsjö
On Thu, 7 Apr 2011, Luca Barbato wrote:

> Fix compilation on systems without poll()
> ---
>  libavformat/network.h |1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/libavformat/network.h b/libavformat/network.h
> index 6943bc6..84a8f53 100644
> --- a/libavformat/network.h
> +++ b/libavformat/network.h
> @@ -22,6 +22,7 @@
>  #define AVFORMAT_NETWORK_H
>  
>  #include "config.h"
> +#include "os_support.h"
>  
>  #if HAVE_WINSOCK2_H
>  #include 
> -- 
> 1.7.4.1

OK

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


[libav-devel] [PATCH 2/2] avio: deprecate av_protocol_next().

2011-04-07 Thread Anton Khirnov
---
 cmdutils.c |   20 
 libavformat/avio.c |2 ++
 libavformat/avio.h |4 +++-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index 6901f56..cc10b48 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -653,20 +653,16 @@ void show_bsfs(void)
 
 void show_protocols(void)
 {
-URLProtocol *up=NULL;
+void *opaque = NULL;
+const char *name;
 
 printf("Supported file protocols:\n"
-   "I.. = Input  supported\n"
-   ".O. = Output supported\n"
-   "..S = Seek   supported\n"
-   "FLAGS NAME\n"
-   "- \n");
-while((up = av_protocol_next(up)))
-printf("%c%c%c   %s\n",
-   up->url_read  ? 'I' : '.',
-   up->url_write ? 'O' : '.',
-   up->url_seek  ? 'S' : '.',
-   up->name);
+   "Input:\n");
+while ((name = avio_enum_protocols(&opaque, 0)))
+printf("%s\n", name);
+printf("Output:\n");
+while ((name = avio_enum_protocols(&opaque, 1)))
+printf("%s\n", name);
 }
 
 void show_filters(void)
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 0ea66b3..e68ae99 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -51,11 +51,13 @@ static int default_interrupt_cb(void);
 URLProtocol *first_protocol = NULL;
 URLInterruptCB *url_interrupt_cb = default_interrupt_cb;
 
+#if FF_API_OLD_AVIO
 URLProtocol *av_protocol_next(URLProtocol *p)
 {
 if(p) return p->next;
 else  return first_protocol;
 }
+#endif
 
 const char *avio_enum_protocols(void **opaque, int output)
 {
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 294afcb..f182794 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -167,12 +167,14 @@ extern URLProtocol *first_protocol;
 extern URLInterruptCB *url_interrupt_cb;
 #endif
 
+#if FF_API_OLD_AVIO
 /**
  * If protocol is NULL, returns the first registered protocol,
  * if protocol is non-NULL, returns the next registered protocol after 
protocol,
  * or NULL if protocol is the last one.
  */
-URLProtocol *av_protocol_next(URLProtocol *p);
+attribute_deprecated URLProtocol *av_protocol_next(URLProtocol *p);
+#endif
 
 #if FF_API_REGISTER_PROTOCOL
 /**
-- 
1.7.4.1

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


[libav-devel] [PATCH 1/2] avio: add a function for iterating though protocol names.

2011-04-07 Thread Anton Khirnov
---
 libavformat/avio.c |   10 ++
 libavformat/avio.h |   13 +
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 1d40da6..0ea66b3 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -57,6 +57,16 @@ URLProtocol *av_protocol_next(URLProtocol *p)
 else  return first_protocol;
 }
 
+const char *avio_enum_protocols(void **opaque, int output)
+{
+URLProtocol **p = opaque;
+*p =   *p ? (*p)->next : first_protocol;
+if (!*p) return NULL;
+if ((output && (*p)->url_write) || (!output && (*p)->url_read))
+return (*p)->name;
+return avio_enum_protocols(opaque, output);
+}
+
 int ffurl_register_protocol(URLProtocol *protocol, int size)
 {
 URLProtocol **p;
diff --git a/libavformat/avio.h b/libavformat/avio.h
index e9aa499..294afcb 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -597,4 +597,17 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
 int udp_get_file_handle(URLContext *h);
 #endif
 
+/**
+ * Iterate through names of available protocols.
+ *
+ * @param opaque A private pointer representing current protocol.
+ *It must be a pointer to NULL on first iteration and will
+ *be updated by successive calls to avio_enum_protocols.
+ * @param output If set to 1, iterate over output protocols,
+ *   otherwise over input protocols.
+ *
+ * @return A static string containing the name of current protocol or NULL
+ */
+const char *avio_enum_protocols(void **opaque, int output);
+
 #endif /* AVFORMAT_AVIO_H */
-- 
1.7.4.1

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


Re: [libav-devel] [PATCH] configure: fail if an element is explicitely configured but dependencies are not enabled

2011-04-07 Thread Måns Rullgård
Reinhard Tartler  writes:

> On Sun, Apr 03, 2011 at 15:42:43 (CEST), Måns Rullgård wrote:
>
>> There is nothing confusing at all.  Two simple rules:
>>
>> 1. Everything is enabled by default.
>> 2. External libs must be explicitly enabled.
>>
>> Thus far, nobody has complained about this.  Until someone does, I'm not
>> changing it.  Your meta-complaint does not count.
>
> Can we have a switch (not necessarily a configure switch) to change
> policy 2?
>
> Background: The configure line in the debian package is awfully long
> because I try to enable any external libraries that are available in
> Debian, which makes /usr/bin/ffmpeg output a configuration string of
> several lines.

Weren't we going to prune the default console spam?

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


Re: [libav-devel] [PATCH 1/2] Add an AAC encoder by using the libvo-aacenc library

2011-04-07 Thread Martin Storsjö
On Thu, 7 Apr 2011, Alex Converse wrote:

> On Thu, Apr 7, 2011 at 2:18 AM, Martin Storsjö  wrote:
> > ---
> >  Changelog                 |    1 +
> >  configure                 |    6 ++
> >  libavcodec/Makefile       |    1 +
> >  libavcodec/allcodecs.c    |    1 +
> >  libavcodec/libvo-aacenc.c |  132 
> > +
> >  5 files changed, 141 insertions(+), 0 deletions(-)
> >  create mode 100644 libavcodec/libvo-aacenc.c
> >
> 
> Perhaps we should remove faac then? Do we need two third party aac encoders?

Probably not, if there aren't any particular features of libfaac that 
vo-aacenc doesn't have, that we care about. libfaac seems to support 
different profiles, and I'm not sure that the visualon code has support 
for that, at least not in the external api at the moment.

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


Re: [libav-devel] [PATCH 1/2] Add an AAC encoder by using the libvo-aacenc library

2011-04-07 Thread Alex Converse
On Thu, Apr 7, 2011 at 2:18 AM, Martin Storsjö  wrote:
> ---
>  Changelog                 |    1 +
>  configure                 |    6 ++
>  libavcodec/Makefile       |    1 +
>  libavcodec/allcodecs.c    |    1 +
>  libavcodec/libvo-aacenc.c |  132 
> +
>  5 files changed, 141 insertions(+), 0 deletions(-)
>  create mode 100644 libavcodec/libvo-aacenc.c
>

Perhaps we should remove faac then? Do we need two third party aac encoders?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] proto: include os_support.h in network.h

2011-04-07 Thread Luca Barbato
Fix compilation on systems without poll()
---
 libavformat/network.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/libavformat/network.h b/libavformat/network.h
index 6943bc6..84a8f53 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -22,6 +22,7 @@
 #define AVFORMAT_NETWORK_H
 
 #include "config.h"
+#include "os_support.h"
 
 #if HAVE_WINSOCK2_H
 #include 
-- 
1.7.4.1

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


Re: [libav-devel] [PATCH 1/2] Add an AAC encoder by using the libvo-aacenc library

2011-04-07 Thread Martin Storsjö
On Thu, 7 Apr 2011, Jindřich Makovička wrote:

> On Thu, Apr 7, 2011 at 11:18, Martin Storsjö  wrote:
> 
> > +    memset(¶ms, 0, sizeof(params));
> > +    params.sampleRate = avctx->sample_rate;
> > +    params.bitRate = avctx->bit_rate;
> > +    params.nChannels = avctx->channels;
> > +    params.adtsUsed = 0;
> 
> I think adtsUsed should be set based on CODEC_FLAG_GLOBAL_HEADER ,
> otherwise the AAC output muxed into MPEG-TS won't be playable.
> 
> i.e. params.adtsUsed = !(avctx->flags & CODEC_FLAG_GLOBAL_HEADER)

Good point, fixed locally.

Actually, .ts files with data encoded with this encoder, without this fix, 
apprears to work with ffplay at least, but other decoders might of course 
not be so tolerant.

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


Re: [libav-devel] [PATCH 1/2] Add an AAC encoder by using the libvo-aacenc library

2011-04-07 Thread Jindřich Makovička
On Thu, Apr 7, 2011 at 11:18, Martin Storsjö  wrote:

> +    memset(¶ms, 0, sizeof(params));
> +    params.sampleRate = avctx->sample_rate;
> +    params.bitRate = avctx->bit_rate;
> +    params.nChannels = avctx->channels;
> +    params.adtsUsed = 0;

I think adtsUsed should be set based on CODEC_FLAG_GLOBAL_HEADER ,
otherwise the AAC output muxed into MPEG-TS won't be playable.

i.e. params.adtsUsed = !(avctx->flags & CODEC_FLAG_GLOBAL_HEADER)

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


Re: [libav-devel] [PATCH 2/2] Add support for AMR-WB encoding via libvo-amrwbenc

2011-04-07 Thread Martin Storsjö
Minor issues with this patch that I noticed, will be fixed in the next 
round...

On Thu, 7 Apr 2011, Martin Storsjö wrote:

> The wrapper code is based on the libamr wrapper removed in SVN rev 19365.
> ---
>  Changelog   |1 +
>  configure   |6 ++
>  doc/general.texi|3 +-
>  libavcodec/Makefile |1 +
>  libavcodec/allcodecs.c  |1 +
>  libavcodec/libvo-amrwbenc.c |  128 
> +++
>  6 files changed, 139 insertions(+), 1 deletions(-)
>  create mode 100644 libavcodec/libvo-amrwbenc.c

Missing minor bump, added locally (for both of the patches)

> +#include "avcodec.h"
> +#include 
> +
> +static const char wb_bitrate_unsupported[] =
> +"bitrate not supported: use one of 6.6k, 8.85k, 12.65k, 14.25k, 15.85k, 
> 18.25k, 19.85k, 23.05k, or 23.85k\n";
> +

Long line, wrapped

> +typedef struct AMRWB_bitrates {
> +int rate;
> +int mode;
> +} AMRWB_bitrates;
> +
> +typedef struct AMRWBContext {
> +intframeCount;

Camelcase variable name, and the variable itself is useless, removed.

> +void  *state;
> +intmode;
> +intallow_dtx;
> +} AMRWBContext;
> +
> +static int getWBBitrateMode(int bitrate)
> +{
> +/* make the correspondance between bitrate and mode */
> +AMRWB_bitrates rates[] = { { 6600, 0},
> +   { 8850, 1},
> +   {12650, 2},
> +   {14250, 3},
> +   {15850, 4},
> +   {18250, 5},
> +   {19850, 6},
> +   {23050, 7},
> +   {23850, 8}, };
> +int i;
> +
> +for (i = 0; i < 9; i++)
> +if (rates[i].rate == bitrate)
> +return rates[i].mode;
> +/* no bitrate matching, return an error */
> +return -1;
> +}
> +
> +static av_cold int amr_wb_encode_init(AVCodecContext *avctx)
> +{
> +AMRWBContext *s = avctx->priv_data;
> +
> +s->frameCount = 0;
> +
> +if (avctx->sample_rate != 16000) {
> +av_log(avctx, AV_LOG_ERROR, "Only 16000Hz sample rate supported\n");
> +return -1;
> +}
> +
> +if (avctx->channels != 1) {
> +av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
> +return -1;
> +}
> +
> +if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) {
> +av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported);
> +return -1;
> +}
> +
> +avctx->frame_size  = 320;
> +avctx->coded_frame = avcodec_alloc_frame();
> +
> +s->state = E_IF_init();
> +s->allow_dtx = 0;
> +
> +return 0;
> +}
> +
> +static int amr_wb_encode_close(AVCodecContext *avctx)
> +{
> +AMRWBContext *s = avctx->priv_data;
> +
> +E_IF_exit(s->state);
> +av_freep(&avctx->coded_frame);
> +s->frameCount++;
> +return 0;
> +}
> +
> +static int amr_wb_encode_frame(AVCodecContext *avctx,
> +   unsigned char *frame/*out*/,
> +   int buf_size, void *data/*in*/)
> +{
> +AMRWBContext *s = avctx->priv_data;
> +int size;
> +
> +if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) {
> +av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported);
> +return -1;
> +}
> +size = E_IF_encode(s->state, s->mode, data, frame, s->allow_dtx);
> +return size;
> +}
> +
> +AVCodec ff_libvo_amrwbenc_encoder = {
> +"libvo_amrwbenc",
> +CODEC_TYPE_AUDIO,
> +CODEC_ID_AMR_WB,
> +sizeof(AMRWBContext),
> +amr_wb_encode_init,
> +amr_wb_encode_frame,
> +amr_wb_encode_close,
> +NULL,
> +.sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
> +.long_name = NULL_IF_CONFIG_SMALL("libvo-amrwbenc Adaptive Multi-Rate 
> (AMR) Wide-Band"),

Slightly long line, wrapped.

Updated version attached.

// MartinFrom 3d8a990399e80fd6c8092802ba65eed60169b582 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Tue, 29 Dec 2009 16:48:09 +0200
Subject: [PATCH 2/2] Add support for AMR-WB encoding via libvo-amrwbenc

The wrapper code is based on the libamr wrapper removed in SVN rev 19365.
---
 Changelog   |1 +
 configure   |6 ++
 doc/general.texi|3 +-
 libavcodec/Makefile |1 +
 libavcodec/allcodecs.c  |1 +
 libavcodec/libvo-amrwbenc.c |  126 +++
 libavcodec/version.h|2 +-
 7 files changed, 138 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/libvo-amrwbenc.c

diff --git a/Changelog b/Changelog
index 6a255d4..87ec036 100644
--- a/Changelog
+++ b/Changelog
@@ -84,6 +84,7 @@ version :
 - Chronomaster DFA decoder
 - Mobotix MxPEG decoder
 - AAC encoding via libvo-aacenc
+- AMR-WB encoding via libvo-amrwbenc
 
 
 version 0.6:
diff --git a/configure b/configure
index 8880fba..c632ce5 100755
--- a/confi

[libav-devel] [PATCH 2/2] Add support for AMR-WB encoding via libvo-amrwbenc

2011-04-07 Thread Martin Storsjö
The wrapper code is based on the libamr wrapper removed in SVN rev 19365.
---
 Changelog   |1 +
 configure   |6 ++
 doc/general.texi|3 +-
 libavcodec/Makefile |1 +
 libavcodec/allcodecs.c  |1 +
 libavcodec/libvo-amrwbenc.c |  128 +++
 6 files changed, 139 insertions(+), 1 deletions(-)
 create mode 100644 libavcodec/libvo-amrwbenc.c

diff --git a/Changelog b/Changelog
index 6a255d4..87ec036 100644
--- a/Changelog
+++ b/Changelog
@@ -84,6 +84,7 @@ version :
 - Chronomaster DFA decoder
 - Mobotix MxPEG decoder
 - AAC encoding via libvo-aacenc
+- AMR-WB encoding via libvo-amrwbenc
 
 
 version 0.6:
diff --git a/configure b/configure
index 8880fba..c632ce5 100755
--- a/configure
+++ b/configure
@@ -179,6 +179,7 @@ External library support:
   --enable-libspeexenable Speex decoding via libspeex [no]
   --enable-libtheora   enable Theora encoding via libtheora [no]
   --enable-libvo-aacencenable AAC encoding via libvo-aacenc [no]
+  --enable-libvo-amrwbenc  enable AMR-WB encoding via libvo-amrwbenc [no]
   --enable-libvorbis   enable Vorbis encoding via libvorbis,
native implementation exists [no]
   --enable-libvpx  enable VP8 support via libvpx [no]
@@ -939,6 +940,7 @@ CONFIG_LIST="
 libspeex
 libtheora
 libvo_aacenc
+libvo_amrwbenc
 libvorbis
 libvpx
 libx264
@@ -1387,6 +1389,7 @@ libschroedinger_encoder_deps="libschroedinger"
 libspeex_decoder_deps="libspeex"
 libtheora_encoder_deps="libtheora"
 libvo_aacenc_encoder_deps="libvo_aacenc"
+libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
 libvorbis_encoder_deps="libvorbis"
 libvpx_decoder_deps="libvpx"
 libvpx_encoder_deps="libvpx"
@@ -2529,6 +2532,7 @@ die_license_disabled nonfree libfaac
 die_license_disabled version3 libopencore_amrnb
 die_license_disabled version3 libopencore_amrwb
 die_license_disabled version3 libvo_aacenc
+die_license_disabled version3 libvo_amrwbenc
 
 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
 
@@ -2869,6 +2873,7 @@ enabled libschroedinger && require_pkg_config 
schroedinger-1.0 schroedinger/schr
 enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init 
-lspeex
 enabled libtheora  && require  libtheora theora/theoraenc.h th_info_init 
-ltheoraenc -ltheoradec -logg
 enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI 
-lvo-aacenc
+enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h 
E_IF_init -lvo-amrwbenc
 enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init 
-lvorbisenc -lvorbis -logg
 enabled libvpx && {
 enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" 
vpx_codec_dec_init_ver -lvpx ||
@@ -3138,6 +3143,7 @@ echo "libspeex enabled  ${libspeex-no}"
 echo "libtheora enabled ${libtheora-no}"
 echo "libva enabled ${vaapi-no}"
 echo "libvo-aacenc support  ${libvo_aacenc-no}"
+echo "libvo-amrwbenc support${libvo_amrwbenc-no}"
 echo "libvorbis enabled ${libvorbis-no}"
 echo "libvpx enabled${libvpx-no}"
 echo "libx264 enabled   ${libx264-no}"
diff --git a/doc/general.texi b/doc/general.texi
index 5d66e42..d4cdc3b 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -588,7 +588,8 @@ following image formats are supported:
 @item ADPCM Yamaha   @tab  X  @tab  X
 @item AMR-NB @tab  E  @tab  X
 @tab encoding supported through external library libopencore-amrnb
-@item AMR-WB @tab @tab  X
+@item AMR-WB @tab  E  @tab  X
+@tab encoding supported through external library libvo-amrwbenc
 @item Apple lossless audio   @tab  X  @tab  X
 @tab QuickTime fourcc 'alac'
 @item Atrac 1@tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e9c40e4..1cdae2c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -569,6 +569,7 @@ OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER)+= 
libschroedingerenc.o \
 OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBVO_AACENC_ENCODER)   += libvo-aacenc.o mpeg4audio.o
+OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
 OBJS-$(CONFIG_LIBVORBIS_ENCODER)  += libvorbis.o vorbis_data.o
 OBJS-$(CONFIG_LIBVPX_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_ENCODER) += libvpxenc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index e0323ac..40a7e23 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -367,6 +367,7 @@ void avcodec_register_all(void)
 REGISTER_DECODER (LIBSPEEX, libspeex);
 REGISTER_ENCODER (LIBTHEORA, libtheora);
 REGISTER_ENCODER (LIBVO_AACENC, libvo_aacenc);
+REGISTER_ENCODER (LIBVO_AMRWBENC, libvo_amrwbenc);
 REGISTER_ENCODER (LIBV

[libav-devel] [PATCH 1/2] Add an AAC encoder by using the libvo-aacenc library

2011-04-07 Thread Martin Storsjö
---
 Changelog |1 +
 configure |6 ++
 libavcodec/Makefile   |1 +
 libavcodec/allcodecs.c|1 +
 libavcodec/libvo-aacenc.c |  132 +
 5 files changed, 141 insertions(+), 0 deletions(-)
 create mode 100644 libavcodec/libvo-aacenc.c

diff --git a/Changelog b/Changelog
index ec09c28..6a255d4 100644
--- a/Changelog
+++ b/Changelog
@@ -83,6 +83,7 @@ version :
 - Linux framebuffer input device added
 - Chronomaster DFA decoder
 - Mobotix MxPEG decoder
+- AAC encoding via libvo-aacenc
 
 
 version 0.6:
diff --git a/configure b/configure
index 92a809f..8880fba 100755
--- a/configure
+++ b/configure
@@ -178,6 +178,7 @@ External library support:
   --enable-libschroedinger enable Dirac support via libschroedinger [no]
   --enable-libspeexenable Speex decoding via libspeex [no]
   --enable-libtheora   enable Theora encoding via libtheora [no]
+  --enable-libvo-aacencenable AAC encoding via libvo-aacenc [no]
   --enable-libvorbis   enable Vorbis encoding via libvorbis,
native implementation exists [no]
   --enable-libvpx  enable VP8 support via libvpx [no]
@@ -937,6 +938,7 @@ CONFIG_LIST="
 libschroedinger
 libspeex
 libtheora
+libvo_aacenc
 libvorbis
 libvpx
 libx264
@@ -1384,6 +1386,7 @@ libschroedinger_decoder_deps="libschroedinger"
 libschroedinger_encoder_deps="libschroedinger"
 libspeex_decoder_deps="libspeex"
 libtheora_encoder_deps="libtheora"
+libvo_aacenc_encoder_deps="libvo_aacenc"
 libvorbis_encoder_deps="libvorbis"
 libvpx_decoder_deps="libvpx"
 libvpx_encoder_deps="libvpx"
@@ -2525,6 +2528,7 @@ die_license_disabled nonfree libfaac
 
 die_license_disabled version3 libopencore_amrnb
 die_license_disabled version3 libopencore_amrwb
+die_license_disabled version3 libvo_aacenc
 
 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
 
@@ -2864,6 +2868,7 @@ enabled librtmp&& require_pkg_config librtmp 
librtmp/rtmp.h RTMP_Socket
 enabled libschroedinger && require_pkg_config schroedinger-1.0 
schroedinger/schro.h schro_init
 enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init 
-lspeex
 enabled libtheora  && require  libtheora theora/theoraenc.h th_info_init 
-ltheoraenc -ltheoradec -logg
+enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI 
-lvo-aacenc
 enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init 
-lvorbisenc -lvorbis -logg
 enabled libvpx && {
 enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" 
vpx_codec_dec_init_ver -lvpx ||
@@ -3132,6 +3137,7 @@ echo "libschroedinger enabled   ${libschroedinger-no}"
 echo "libspeex enabled  ${libspeex-no}"
 echo "libtheora enabled ${libtheora-no}"
 echo "libva enabled ${vaapi-no}"
+echo "libvo-aacenc support  ${libvo_aacenc-no}"
 echo "libvorbis enabled ${libvorbis-no}"
 echo "libvpx enabled${libvpx-no}"
 echo "libx264 enabled   ${libx264-no}"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 837f7e2..e9c40e4 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -568,6 +568,7 @@ OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER)+= 
libschroedingerenc.o \
  libdirac_libschro.o
 OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
+OBJS-$(CONFIG_LIBVO_AACENC_ENCODER)   += libvo-aacenc.o mpeg4audio.o
 OBJS-$(CONFIG_LIBVORBIS_ENCODER)  += libvorbis.o vorbis_data.o
 OBJS-$(CONFIG_LIBVPX_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_ENCODER) += libvpxenc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 7636392..e0323ac 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -366,6 +366,7 @@ void avcodec_register_all(void)
 REGISTER_ENCDEC  (LIBSCHROEDINGER, libschroedinger);
 REGISTER_DECODER (LIBSPEEX, libspeex);
 REGISTER_ENCODER (LIBTHEORA, libtheora);
+REGISTER_ENCODER (LIBVO_AACENC, libvo_aacenc);
 REGISTER_ENCODER (LIBVORBIS, libvorbis);
 REGISTER_ENCDEC  (LIBVPX, libvpx);
 REGISTER_ENCODER (LIBX264, libx264);
diff --git a/libavcodec/libvo-aacenc.c b/libavcodec/libvo-aacenc.c
new file mode 100644
index 000..34389f1
--- /dev/null
+++ b/libavcodec/libvo-aacenc.c
@@ -0,0 +1,132 @@
+/*
+ * AAC encoder wrapper
+ * Copyright (c) 2010 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

[libav-devel] [ANNOUNCEMENT] vo-aacenc 0.1.0 and vo-amrwbenc 0.1.0

2011-04-07 Thread Martin Storsjö
Hi,

When Google released the code for Android Gingerbread in December, they 
released source code for two new Apache 2.0 licensed audio encoders 
provided by VisualOn, for AAC and AMR-WB.

These encoders are now wrapped up in standalone encoder libraries, 
vo-aacenc and vo-amrwbenc, just as for opencore-amr (which included an 
AMR-NB encoder and decoder, and an AMR-WB decoder) before.

These projects, while not sharing any code with opencore-amr, are quite 
similar in their heritage and style (being a standalone wrapping of codecs 
from another framework), and are hosted under the opencore-amr sourceforge 
project for now. The release files are available at 
https://sourceforge.net/projects/opencore-amr/files/, and the code is 
available in git at 
git://opencore-amr.git.sourceforge.net/gitroot/opencore-amr/vo-aacenc
and 
git://opencore-amr.git.sourceforge.net/gitroot/opencore-amr/vo-amrwbenc 
respectively.

The same code is also available on github, at 
https://github.com/mstorsjo/vo-aacenc and 
https://github.com/mstorsjo/vo-amrwbenc for easier collaboration.

The vo-amrwbenc library provides a very minimal interface similar to what 
the old, unredistributable libamrwb used, so any code that used that 
library can easily be adapted to use vo-amrwbenc instead. The vo-aacenc 
library, on the other hand, directly exposes the VisualOn audio codec 
interface. Both libraries come with an optional example program showing 
how to use their interfaces.

The code in these libraries are (just as for opencore-amr) relicensed 
versions of 3GPP reference code, but all of it has, to the best of my 
knowledge, been checked for legal correctness by Google.

In addition to the original reference code, they also contain some 
optimizations for ARM, initially done by VisualOn, and further improved by 
Mans Rullgard.

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


Re: [libav-devel] [PATCH 1/3] introduce side information in AVPacket

2011-04-07 Thread Luca Barbato
On 04/07/2011 10:40 AM, Kostya wrote:
> Nothing (except for mail size limit in mailer) prevents you from sending such
> rename patch.

Will do soon =)

lu

-- 

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

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


Re: [libav-devel] [PATCH 1/2] lavf: update AVStream.nb_frames when muxing.

2011-04-07 Thread Anton Khirnov
On Wed, Apr 06, 2011 at 05:33:32PM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On Tue, Mar 29, 2011 at 1:38 PM, Anton Khirnov  wrote:
> > On Tue, Mar 29, 2011 at 10:09:35AM -0700, Ronald S. Bultje wrote:
> >> Hi,
> >>
> >> On Tue, Mar 29, 2011 at 9:55 AM, Anton Khirnov  wrote:
> >> > On Tue, Mar 29, 2011 at 05:59:49AM -0700, Ronald S. Bultje wrote:
> >> >>
> >> >> Not really. Can you confirm (likely requires a little debugging) that
> >> >> either with or without that piece of code, the number of mp2/3 frames
> >> >> written into a Xing or MPEG file is correct?
> >> >
> >> > Number of frames written is the same in both cases, since mp3 isn't
> >> > interleaved and no frames get written in av_write_trailer().
> >> > In any case, I don't see why the number of frames would be off by one.
> >> > If anything, wouldn't it be off by a huge amount when frame != packet?
> >> >
> >> > Anyways, what we can do is:
> >> > 1) abuse nb_frames field with a note that it will be wrong when packet
> >> > != frame (slightly evil)
> >> > 2) add a nb_packets field (somewhat bloaty)
> >> > 3) have each muxer manage this by itself (evil)
> >>
> >> You're confusing av_write_frame()/interleaved_frame() with
> >> av_write_packet(). They do exactly what you think they do (I hope).
> >
> > There is no av_write_packet() =p
> >
> > AFAIU (and please correct me if I am wrong), there is av_write_frame,
> > which takes an AVPacket and directly writes it to the output file and
> > av_interleaved_write_frame(), which also takes an AVPacket and adds it
> > to queue for proper interleaving.
> 
> Blegh. Anyway, can you confirm please that writing a MP3 (either
> stream-copy from whatever source, e.g. MPEG-1 system stream) as well
> as encoded MP3 using lame both writes out the correct number of frames
> in the Xing header?
> 

Encoding with the libmp3lame wrapper adds one frame of silence at the
end, so number of frames written is one higher then with -acodec copy.
Encoding with lame commandline tool adds a frame of silence at the
beginning and a frame of silence at then end, so number of frames
written is two higher than with -acodec copy.

-- 
Anton Khirnov


signature.asc
Description: Digital signature
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/3] introduce side information in AVPacket

2011-04-07 Thread Kostya
On Thu, Apr 07, 2011 at 09:53:11AM +0200, Luca Barbato wrote:
> On 04/07/2011 06:54 AM, Janne Grunau wrote:
> > On Wed, Apr 06, 2011 at 10:26:08PM +0200, Kostya Shishkov wrote:
> >> This adds side information to AVPacket
> >>
> >> ---
> >>  libavcodec/avcodec.h  |   21 +
> >>  libavcodec/avpacket.c |   39 +++
> >>  libavcodec/version.h  |2 +-
> >>  3 files changed, 61 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> >> index 95a933d..4b7bedc 100644
> >> --- a/libavcodec/avcodec.h
> >> +++ b/libavcodec/avcodec.h
> >> @@ -1054,6 +1054,14 @@ typedef struct AVPacket {
> >>  int64_t dts;
> >>  uint8_t *data;
> >>  int   size;
> >> +/**
> >> + * Additional packet data that may be provided by container. If 
> >> present
> >> + * it should declare side data type and size.
> >> + */
> >> +uint8_t *side_data;
> >> +int   side_data_size;
> >> +int   side_data_type;
> >> +
> >>  int   stream_index;
> >>  int   flags;
> >>  /**
> >> @@ -1089,6 +1097,9 @@ typedef struct AVPacket {
> >>  #define PKT_FLAG_KEY AV_PKT_FLAG_KEY
> >>  #endif
> >>  
> >> +#define AV_PKT_DATA_NONE 0 ///< no packet side information
> >> +#define AV_PKT_DATA_PAL  1 ///< packet side information contains new 
> >> palette
> > 
> > enum?
> > 
> >> +
> >>  /**
> >>   * Audio Video Frame.
> >>   * New fields can be added to the end of FF_COMMON_FRAME with minor 
> >> version
> >> @@ -3190,6 +3201,16 @@ void av_shrink_packet(AVPacket *pkt, int size);
> >>  int av_grow_packet(AVPacket *pkt, int grow_by);
> >>  
> >>  /**
> >> + * Allocate the side information of a packet.
> >> + *
> >> + * @param pkt packet
> >> + * @param type side information type (AV_PKT_DATA_*)
> >> + * @param size wanted side information size
> >> + * @return 0 if OK, AVERROR_xxx otherwise
> >> + */
> >> +int av_new_packet_side_data(AVPacket *pkt, int type, int size);
> > 
> > av_packet_new_side_data() is less confusing
> 
> I'd rather have avpacket_ as namespace.

Nothing (except for mail size limit in mailer) prevents you from sending such
rename patch.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/3] introduce side information in AVPacket

2011-04-07 Thread Kostya
On Wed, Apr 06, 2011 at 06:33:46PM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On Wed, Apr 6, 2011 at 4:26 PM, Kostya Shishkov
>  wrote:
> > This adds side information to AVPacket
> >
> > ---
> >  libavcodec/avcodec.h  |   21 +
> >  libavcodec/avpacket.c |   39 +++
> >  libavcodec/version.h  |    2 +-
> >  3 files changed, 61 insertions(+), 1 deletions(-)
> 
> There's some issues here:
> - what if we consider the "palette" as side-data in a stream with pal1
> pkt1 pkt2 pkt3 pal2 pkt4 pkt5 pkt6 pal3 pkt7 pkt8 pk9, and we seek to
> (the start of) pkt6? Is anyone (demuxer, probably) in charge of
> "forcing" the updated side-data after a seek?

unfortunately, no unless demuxer knows new palette chunk positions and reads
them along (can be done for some AVIs though, patchiswelcome)

> - what if we want multiple types of "side data"? E.g. RTSP with a
> palette _and_ a sequence nr.? I'd prefer separate variables for each
> of them in AVPacket, if we go this way. Any reason you want this
> generic side-data thing and have only one of them in AVPacket, instead
> of at least an array?

Feel free to extend as you see fit. For now I don't see any real-world
collisions in side data but it should be easy to extend.

> - I don't quite understand why we do special handling of palette
> changing in midstream, but no such thing for the (hypothetical) case
> of pix_fmt changing mid-stream, or codec changing midstream. Is that
> just because it doesn't happen in practice?

It happens but for most things it's not a normal practice (except for codec
change in some broadcast streams) while palette change is quite common with
palettised codecs and many containers (mostly for game codecs) have special
palette change chunk.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] oggdec: fix streaming with continuous audio streams (issue2337)

2011-04-07 Thread Luca Barbato
On 04/07/2011 10:23 AM, Clément Bœsch wrote:
> ---
>  libavformat/oggdec.c |   16 
>  libavformat/oggdec.h |1 +
>  2 files changed, 17 insertions(+), 0 deletions(-)
> 

Looks fine, I hope there aren't ogg files that break because somebody
decided putting streams around would be fun.

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/3] introduce side information in AVPacket

2011-04-07 Thread Luca Barbato
On 04/07/2011 06:54 AM, Janne Grunau wrote:
> On Wed, Apr 06, 2011 at 10:26:08PM +0200, Kostya Shishkov wrote:
>> This adds side information to AVPacket
>>
>> ---
>>  libavcodec/avcodec.h  |   21 +
>>  libavcodec/avpacket.c |   39 +++
>>  libavcodec/version.h  |2 +-
>>  3 files changed, 61 insertions(+), 1 deletions(-)
>>
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index 95a933d..4b7bedc 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -1054,6 +1054,14 @@ typedef struct AVPacket {
>>  int64_t dts;
>>  uint8_t *data;
>>  int   size;
>> +/**
>> + * Additional packet data that may be provided by container. If present
>> + * it should declare side data type and size.
>> + */
>> +uint8_t *side_data;
>> +int   side_data_size;
>> +int   side_data_type;
>> +
>>  int   stream_index;
>>  int   flags;
>>  /**
>> @@ -1089,6 +1097,9 @@ typedef struct AVPacket {
>>  #define PKT_FLAG_KEY AV_PKT_FLAG_KEY
>>  #endif
>>  
>> +#define AV_PKT_DATA_NONE 0 ///< no packet side information
>> +#define AV_PKT_DATA_PAL  1 ///< packet side information contains new palette
> 
> enum?
> 
>> +
>>  /**
>>   * Audio Video Frame.
>>   * New fields can be added to the end of FF_COMMON_FRAME with minor version
>> @@ -3190,6 +3201,16 @@ void av_shrink_packet(AVPacket *pkt, int size);
>>  int av_grow_packet(AVPacket *pkt, int grow_by);
>>  
>>  /**
>> + * Allocate the side information of a packet.
>> + *
>> + * @param pkt packet
>> + * @param type side information type (AV_PKT_DATA_*)
>> + * @param size wanted side information size
>> + * @return 0 if OK, AVERROR_xxx otherwise
>> + */
>> +int av_new_packet_side_data(AVPacket *pkt, int type, int size);
> 
> av_packet_new_side_data() is less confusing

I'd rather have avpacket_ as namespace.

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 3/3] Make demuxers and codecs use AVPacket for passing new palette

2011-04-07 Thread Kostya
On Wed, Apr 06, 2011 at 10:27:41PM +0200, Kostya Shishkov wrote:
> 

Refreshed version for av_new_packet_side_data() -> av_packet_new_size_data()
rename.
>From 46cc7e3047b196dc616d58ffeca2d69731627aa9 Mon Sep 17 00:00:00 2001
From: Kostya Shishkov 
Date: Thu, 7 Apr 2011 10:16:31 +0200
Subject: [PATCH 2/2] make demuxers and codecs use AVPacket for passing new palette

---
 libavcodec/8bps.c   |   18 --
 libavcodec/cinepak.c|   18 +-
 libavcodec/idcinvideo.c |   11 +--
 libavcodec/interplayvideo.c |   16 ++--
 libavcodec/kmvc.c   |   15 +--
 libavcodec/msrle.c  |   15 +++
 libavcodec/msvideo1.c   |   20 +---
 libavcodec/qpeg.c   |   11 ---
 libavcodec/qtrle.c  |   10 ++
 libavcodec/rawdec.c |7 ---
 libavcodec/smc.c|   12 +++-
 libavcodec/targa.c  |7 ---
 libavcodec/tscc.c   |8 +---
 libavformat/asf.h   |2 ++
 libavformat/asfdec.c|   18 --
 libavformat/avidec.c|   22 +-
 libavformat/idcin.c |   14 --
 libavformat/ipmovie.c   |   19 +++
 libavformat/isom.h  |2 ++
 libavformat/mov.c   |   17 -
 20 files changed, 131 insertions(+), 131 deletions(-)

diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c
index 1c6d406..c6081aa 100644
--- a/libavcodec/8bps.c
+++ b/libavcodec/8bps.c
@@ -50,6 +50,8 @@ typedef struct EightBpsContext {
 
 unsigned char planes;
 unsigned char planemap[4];
+
+uint32_t pal[256];
 } EightBpsContext;
 
 
@@ -129,13 +131,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
 }
 }
 
-if (avctx->palctrl) {
-memcpy (c->pic.data[1], avctx->palctrl->palette, AVPALETTE_SIZE);
-if (avctx->palctrl->palette_changed) {
+if (avctx->bits_per_coded_sample <= 8) {
+if (avpkt->side_data_type == AV_PKT_DATA_PAL) {
 c->pic.palette_has_changed = 1;
-avctx->palctrl->palette_changed = 0;
-} else
-c->pic.palette_has_changed = 0;
+memcpy(c->pal, avpkt->side_data, AVPALETTE_SIZE);
+}
+
+memcpy (c->pic.data[1], c->pal, AVPALETTE_SIZE);
 }
 
 *data_size = sizeof(AVFrame);
@@ -164,10 +166,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
 avctx->pix_fmt = PIX_FMT_PAL8;
 c->planes = 1;
 c->planemap[0] = 0; // 1st plane is palette indexes
-if (avctx->palctrl == NULL) {
-av_log(avctx, AV_LOG_ERROR, "Error: PAL8 format but no palette from demuxer.\n");
-return -1;
-}
 break;
 case 24:
 avctx->pix_fmt = avctx->get_format(avctx, pixfmt_rgb24);
diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c
index f325bdb..a441372 100644
--- a/libavcodec/cinepak.c
+++ b/libavcodec/cinepak.c
@@ -67,6 +67,7 @@ typedef struct CinepakContext {
 
 int sega_film_skip_bytes;
 
+uint32_t pal[256];
 } CinepakContext;
 
 static void cinepak_decode_codebook (cvid_codebook *codebook,
@@ -395,7 +396,7 @@ static av_cold int cinepak_decode_init(AVCodecContext *avctx)
 s->sega_film_skip_bytes = -1;  /* uninitialized state */
 
 // check for paletted data
-if ((avctx->palctrl == NULL) || (avctx->bits_per_coded_sample == 40)) {
+if (avctx->bits_per_coded_sample != 8) {
 s->palette_video = 0;
 avctx->pix_fmt = PIX_FMT_YUV420P;
 } else {
@@ -427,16 +428,15 @@ static int cinepak_decode_frame(AVCodecContext *avctx,
 return -1;
 }
 
+if (s->palette_video && avpkt->side_data_type == AV_PKT_DATA_PAL) {
+s->frame.palette_has_changed = 1;
+memcpy(s->pal, avpkt->side_data, AVPALETTE_SIZE);
+}
+
 cinepak_decode(s);
 
-if (s->palette_video) {
-memcpy (s->frame.data[1], avctx->palctrl->palette, AVPALETTE_SIZE);
-if (avctx->palctrl->palette_changed) {
-s->frame.palette_has_changed = 1;
-avctx->palctrl->palette_changed = 0;
-} else
-s->frame.palette_has_changed = 0;
-}
+if (s->palette_video)
+memcpy (s->frame.data[1], s->pal, AVPALETTE_SIZE);
 
 *data_size = sizeof(AVFrame);
 *(AVFrame*)data = s->frame;
diff --git a/libavcodec/idcinvideo.c b/libavcodec/idcinvideo.c
index b8d47ad..5ccdecb 100644
--- a/libavcodec/idcinvideo.c
+++ b/libavcodec/idcinvideo.c
@@ -72,6 +72,7 @@ typedef struct IdcinContext {
 hnode huff_nodes[256][HUF_TOKENS*2];
 int num_huff_nodes[256];
 
+uint

Re: [libav-devel] [PATCH 2/3] Do not copy side information in audio packet in Matroska muxer

2011-04-07 Thread Kostya
On Thu, Apr 07, 2011 at 09:55:12AM +0200, Kostya wrote:
> On Thu, Apr 07, 2011 at 06:59:24AM +0200, Janne Grunau wrote:
> > On Wed, Apr 06, 2011 at 10:27:08PM +0200, Kostya Shishkov wrote:
> > > ---
> > >  libavformat/matroskaenc.c |3 +++
> > >  1 files changed, 3 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> > > index e28ac42..99cb424 100644
> > > --- a/libavformat/matroskaenc.c
> > > +++ b/libavformat/matroskaenc.c
> > > @@ -1070,6 +1070,9 @@ static int mkv_copy_packet(MatroskaMuxContext *mkv, 
> > > const AVPacket *pkt)
> > >  
> > >  memcpy(mkv->cur_audio_pkt.data, pkt->data, pkt->size);
> > >  mkv->cur_audio_pkt.size = pkt->size;
> > > +mkv->cur_audio_pkt.side_data = NULL;
> > > +mkv->cur_audio_pkt.side_data_size = 0;
> > > +mkv->cur_audio_pkt.side_data_type = AV_PKT_DATA_NONE;
> > >  return 0;
> > >  }
> > 
> > not really necessary, it get's initialized to zero and should be never
> > written to. Getting rid of this custom copy_packet would be even better
> > of course.
> 
> Well, try applying the first patch and "make test" after that - somehow FFmpeg
> will create some weird packets with non-empty side information. I'll try to
> produce correct fix for that though.

Forgot to add one condition to av_dup_packet(), so this patch is not needed
anymore
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/3] introduce side information in AVPacket

2011-04-07 Thread Kostya
On Thu, Apr 07, 2011 at 06:54:29AM +0200, Janne Grunau wrote:
> On Wed, Apr 06, 2011 at 10:26:08PM +0200, Kostya Shishkov wrote:
> > This adds side information to AVPacket
> > 
> > ---
> >  libavcodec/avcodec.h  |   21 +
> >  libavcodec/avpacket.c |   39 +++
> >  libavcodec/version.h  |2 +-
> >  3 files changed, 61 insertions(+), 1 deletions(-)
> > 
> > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > index 95a933d..4b7bedc 100644
> > --- a/libavcodec/avcodec.h
> > +++ b/libavcodec/avcodec.h
> > @@ -1054,6 +1054,14 @@ typedef struct AVPacket {
> >  int64_t dts;
> >  uint8_t *data;
> >  int   size;
> > +/**
> > + * Additional packet data that may be provided by container. If present
> > + * it should declare side data type and size.
> > + */
> > +uint8_t *side_data;
> > +int   side_data_size;
> > +int   side_data_type;
> > +
> >  int   stream_index;
> >  int   flags;
> >  /**
> > @@ -1089,6 +1097,9 @@ typedef struct AVPacket {
> >  #define PKT_FLAG_KEY AV_PKT_FLAG_KEY
> >  #endif
> >  
> > +#define AV_PKT_DATA_NONE 0 ///< no packet side information
> > +#define AV_PKT_DATA_PAL  1 ///< packet side information contains new 
> > palette
> 
> enum?

not in that neighbourhood
 
> > +
> >  /**
> >   * Audio Video Frame.
> >   * New fields can be added to the end of FF_COMMON_FRAME with minor version
> > @@ -3190,6 +3201,16 @@ void av_shrink_packet(AVPacket *pkt, int size);
> >  int av_grow_packet(AVPacket *pkt, int grow_by);
> >  
> >  /**
> > + * Allocate the side information of a packet.
> > + *
> > + * @param pkt packet
> > + * @param type side information type (AV_PKT_DATA_*)
> > + * @param size wanted side information size
> > + * @return 0 if OK, AVERROR_xxx otherwise
> > + */
> > +int av_new_packet_side_data(AVPacket *pkt, int type, int size);
> 
> av_packet_new_side_data() is less confusing

renamed
 
> > +/**
> >   * @warning This is a hack - the packet memory allocation stuff is broken. 
> > The
> >   * packet is allocated if it was not really allocated.
> >   */
> > diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
> > index f6aef20..ef16bbd 100644
> > --- a/libavcodec/avpacket.c
> > +++ b/libavcodec/avpacket.c
> > @@ -26,12 +26,18 @@
> >  void av_destruct_packet_nofree(AVPacket *pkt)
> >  {
> >  pkt->data = NULL; pkt->size = 0;
> > +pkt->side_data  = NULL;
> > +pkt->side_data_size = 0;
> 
> is av_destruct_packet_nofree only called on duplicated packets?
> otherwise this leaks memory in cases there only packet.data is used and
> freed.

yes, it's for duplicated packets only

>From bb18bdff543fd8c5d3e3c89350520be7932594b9 Mon Sep 17 00:00:00 2001
From: Kostya Shishkov 
Date: Thu, 7 Apr 2011 09:45:47 +0200
Subject: [PATCH 1/2] introduce side information in AVPacket

---
 libavcodec/avcodec.h  |   21 +
 libavcodec/avpacket.c |   41 +
 libavcodec/version.h  |2 +-
 3 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 95a933d..3731a6c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1054,6 +1054,14 @@ typedef struct AVPacket {
 int64_t dts;
 uint8_t *data;
 int   size;
+/**
+ * Additional packet data that may be provided by container. If present
+ * it should declare side data type and size.
+ */
+uint8_t *side_data;
+int   side_data_size;
+int   side_data_type;
+
 int   stream_index;
 int   flags;
 /**
@@ -1089,6 +1097,9 @@ typedef struct AVPacket {
 #define PKT_FLAG_KEY AV_PKT_FLAG_KEY
 #endif
 
+#define AV_PKT_DATA_NONE 0 ///< no packet side information
+#define AV_PKT_DATA_PAL  1 ///< packet side information contains new palette
+
 /**
  * Audio Video Frame.
  * New fields can be added to the end of FF_COMMON_FRAME with minor version
@@ -3190,6 +3201,16 @@ void av_shrink_packet(AVPacket *pkt, int size);
 int av_grow_packet(AVPacket *pkt, int grow_by);
 
 /**
+ * Allocate the side information of a packet.
+ *
+ * @param pkt packet
+ * @param type side information type (AV_PKT_DATA_*)
+ * @param size wanted side information size
+ * @return 0 if OK, AVERROR_xxx otherwise
+ */
+int av_packet_new_side_data(AVPacket *pkt, int type, int size);
+
+/**
  * @warning This is a hack - the packet memory allocation stuff is broken. The
  * packet is allocated if it was not really allocated.
  */
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index f6aef20..2cce0f1 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -26,12 +26,18 @@
 void av_destruct_packet_nofree(AVPacket *pkt)
 {
 pkt->data = NULL; pkt->size = 0;
+pkt->side_data  = NULL;
+pkt->side_data_size = 0;
 }
 
 void av_destruct_packet(AVPacket *pkt)
 {
 av_free(pkt->data);
 pkt->data = NULL; pkt->size = 0;
+av_free(pkt->side_data);
+pkt->side_data  = NULL;
+

Re: [libav-devel] [PATCH] oggdec: fix streaming with continuous audio streams (issue2337)

2011-04-07 Thread Clément Bœsch
> From b686906d82d36b14236ce677bdf881f48a67bc02 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= 
> Date: Tue, 5 Apr 2011 00:29:01 +0200
> Subject: [PATCH] oggdec: fix streaming with continuous audio streams 
> (issue2337)
> 

New update following Luca's review on IRC: initmode renamed to page_begin,
and doxygen comment added.

-- 
Clément B.
From b129b2c17a8a4814a4a8ef70b2e6072b4ae33df7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= 
Date: Tue, 5 Apr 2011 00:29:01 +0200
Subject: [PATCH] oggdec: fix streaming with continuous audio streams (issue2337)

---
 libavformat/oggdec.c |   16 
 libavformat/oggdec.h |1 +
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index cd866d4..5cf4faa 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -164,6 +164,7 @@ ogg_new_stream (AVFormatContext * s, uint32_t serial)
 os->bufsize = DECODER_BUFFER_SIZE;
 os->buf = av_malloc(os->bufsize);
 os->header = -1;
+os->page_begin = 1;
 
 st = av_new_stream (s, idx);
 if (!st)
@@ -241,12 +242,27 @@ ogg_read_page (AVFormatContext * s, int *str)
 
 idx = ogg_find_stream (ogg, serial);
 if (idx < 0){
+for (i = 0; i < ogg->nstreams; i++) {
+if (!ogg->streams[i].page_begin) {
+int n;
+
+for (n = 0; n < ogg->nstreams; n++) {
+av_free(ogg->streams[n].buf);
+av_free(ogg->streams[n].private);
+}
+ogg->curidx   = -1;
+ogg->nstreams = 0;
+break;
+}
+}
 idx = ogg_new_stream (s, serial);
 if (idx < 0)
 return -1;
 }
 
 os = ogg->streams + idx;
+if (!(flags & OGG_FLAG_BOS))
+os->page_begin = 0;
 os->page_pos = avio_tell(bc) - 27;
 
 if(os->psize > 0)
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index 7d66cd5..785cd81 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -75,6 +75,7 @@ struct ogg_stream {
 int incomplete; ///< whether we're expecting a continuation in the next 
page
 int page_end;   ///< current packet is the last one completed in the page
 int keyframe_seek;
+int page_begin; ///< set to 1 if the stream only received a 
begin-of-stream packet, otherwise 0
 void *private;
 };
 
-- 
1.7.4.2



pgpIqz99qIDIe.pgp
Description: PGP signature
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/3] Do not copy side information in audio packet in Matroska muxer

2011-04-07 Thread Kostya
On Thu, Apr 07, 2011 at 06:59:24AM +0200, Janne Grunau wrote:
> On Wed, Apr 06, 2011 at 10:27:08PM +0200, Kostya Shishkov wrote:
> > ---
> >  libavformat/matroskaenc.c |3 +++
> >  1 files changed, 3 insertions(+), 0 deletions(-)
> > 
> > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> > index e28ac42..99cb424 100644
> > --- a/libavformat/matroskaenc.c
> > +++ b/libavformat/matroskaenc.c
> > @@ -1070,6 +1070,9 @@ static int mkv_copy_packet(MatroskaMuxContext *mkv, 
> > const AVPacket *pkt)
> >  
> >  memcpy(mkv->cur_audio_pkt.data, pkt->data, pkt->size);
> >  mkv->cur_audio_pkt.size = pkt->size;
> > +mkv->cur_audio_pkt.side_data = NULL;
> > +mkv->cur_audio_pkt.side_data_size = 0;
> > +mkv->cur_audio_pkt.side_data_type = AV_PKT_DATA_NONE;
> >  return 0;
> >  }
> 
> not really necessary, it get's initialized to zero and should be never
> written to. Getting rid of this custom copy_packet would be even better
> of course.

Well, try applying the first patch and "make test" after that - somehow FFmpeg
will create some weird packets with non-empty side information. I'll try to
produce correct fix for that though.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] configure: fail if an element is explicitely configured but dependencies are not enabled

2011-04-07 Thread Luca Barbato
On 04/07/2011 07:08 AM, Reinhard Tartler wrote:
> On Sun, Apr 03, 2011 at 15:42:43 (CEST), Måns Rullgård wrote:
> 
>> There is nothing confusing at all.  Two simple rules:
>>
>> 1. Everything is enabled by default.
>> 2. External libs must be explicitly enabled.
>>
>> Thus far, nobody has complained about this.  Until someone does, I'm not
>> changing it.  Your meta-complaint does not count.
> 
> Can we have a switch (not necessarily a configure switch) to change
> policy 2?
> 
> Background: The configure line in the debian package is awfully long
> because I try to enable any external libraries that are available in
> Debian, which makes /usr/bin/ffmpeg output a configuration string of
> several lines.

I'd rather not, having automagic deps is a bane in the long run IMHO.
What about providing an --enable-everything if you are positive it would
help your case?

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