Re: [libav-devel] [PATCH] raw dca muxer
On Sat, Apr 09, 2011 at 01:29:35AM +0200, Benjamin Larsson wrote: > From 0c70944526bfa9b9203f61f170f9d7bdacfac850 Mon Sep 17 00:00:00 2001 > From: Benjamin Larsson > Date: Sat, 9 Apr 2011 01:27:17 +0200 > Subject: [PATCH] Add raw DCA muxer for the experimental DCA encoder > > --- > libavformat/allformats.c |1 + > libavformat/rawenc.c | 16 > 2 files changed, 17 insertions(+), 0 deletions(-) > > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index 9398d34..55194d9 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -76,6 +76,7 @@ void av_register_all(void) > REGISTER_DEMUXER (CDG, cdg); > REGISTER_MUXER(CRC, crc); > REGISTER_MUXDEMUX (DAUD, daud); > +REGISTER_MUXER(DCA, dca); > REGISTER_DEMUXER (DFA, dfa); > REGISTER_MUXDEMUX (DIRAC, dirac); > REGISTER_MUXDEMUX (DNXHD, dnxhd); > diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c > index 00e43df..8e53b8f 100644 > --- a/libavformat/rawenc.c > +++ b/libavformat/rawenc.c > @@ -298,3 +298,19 @@ AVOutputFormat ff_rawvideo_muxer = { > .flags= AVFMT_NOTIMESTAMPS, > }; > #endif > + > +#if CONFIG_DCA_MUXER > +AVOutputFormat ff_dca_muxer = { > +"dca", > +NULL_IF_CONFIG_SMALL("raw DTS Coherent Acoustics"), > +NULL, > +"dca", > +0, > +CODEC_ID_DTS, > +CODEC_ID_NONE, > +NULL, > +ff_raw_write_packet, > +.flags= AVFMT_NOTIMESTAMPS, > +}; Please use designated initializers for everything, it's much more readable and makes it easier to reorder fields (which I'd like to do during the bump). And you can get rid of some 0 values. -- 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/5] lavf: mark av_pkt_dump(_log) for remove on $next+1 bump.
On Fri, Apr 08, 2011 at 11:37:24PM -0400, Alexander Strange wrote: > > On Apr 8, 2011, at 5:48 AM, Anton Khirnov wrote: > > > --- > > libavformat/avformat.h |4 +++- > > libavformat/utils.c|4 > > libavformat/version.h |3 +++ > > 3 files changed, 10 insertions(+), 1 deletions(-) > > > > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > > index 61babdc..6b1b2b4 100644 > > --- a/libavformat/avformat.h > > +++ b/libavformat/avformat.h > > @@ -978,7 +978,6 @@ void av_hex_dump_log(void *avcl, int level, uint8_t > > *buf, int size); > > */ > > void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st); > > > > -attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int > > dump_payload); > > > > /** > > * Send a nice dump of a packet to the log. > > @@ -994,7 +993,10 @@ attribute_deprecated void av_pkt_dump(FILE *f, > > AVPacket *pkt, int dump_payload); > > void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int > > dump_payload, > > AVStream *st); > > > > +#if FF_API_PKT_DUMP > > +attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int > > dump_payload); > > attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket > > *pkt, > > +#endif > > int dump_payload); > > Misplaced #endif > Oops, I wonder how it got there. Thanks for spotting it. -- Anton Khirnov From 65757f8eb687173fbc37a4898ce773e09c99a165 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 Apr 2011 07:30:33 +0200 Subject: [PATCH] avformat.h: fix a misplaced #endif --- libavformat/avformat.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 5c8456f..24c7958 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -998,8 +998,8 @@ void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, #if FF_API_PKT_DUMP attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, -#endif int dump_payload); +#endif /** * Initialize libavformat and register all the muxers, demuxers and -- 1.7.4.1 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] pthread: validate_thread_parameters() ignored slice-threading being intentionally off
On Sun, Apr 3, 2011 at 6:25 PM, Ronald S. Bultje wrote: > Hi, > > On Sun, Apr 3, 2011 at 1:56 PM, Luca Barbato wrote: >> On 04/03/2011 10:15 PM, Alexander Strange wrote: >>> The thread_type API allows you to request only FF_THREAD_FRAME (instead of >>> FRAME | SLICE), but it was being ignored. >>> We don't implement both of them at the same time, so there isn't an effect >>> on current codecs, except that you can request no kinds of threading now (a >>> bit useless). >> >> I'd make it as body of the commit message. > > Queued with that log msg. > > Ronald Push ping. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/5] lavf: mark av_pkt_dump(_log) for remove on $next+1 bump.
On Apr 8, 2011, at 5:48 AM, Anton Khirnov wrote: > --- > libavformat/avformat.h |4 +++- > libavformat/utils.c|4 > libavformat/version.h |3 +++ > 3 files changed, 10 insertions(+), 1 deletions(-) > > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index 61babdc..6b1b2b4 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -978,7 +978,6 @@ void av_hex_dump_log(void *avcl, int level, uint8_t *buf, > int size); > */ > void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st); > > -attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int > dump_payload); > > /** > * Send a nice dump of a packet to the log. > @@ -994,7 +993,10 @@ attribute_deprecated void av_pkt_dump(FILE *f, AVPacket > *pkt, int dump_payload); > void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, > AVStream *st); > > +#if FF_API_PKT_DUMP > +attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int > dump_payload); > attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket > *pkt, > +#endif > int dump_payload); Misplaced #endif > [..] ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] daud: Don't write packets that are too large to have their size expressed in the bytestream.
On 4/9/11 12:53 AM, Aℓex Converse wrote: On Fri, Apr 8, 2011 at 2:38 PM, Alex Converse wrote: --- libavformat/daud.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) Let's try it again with the words in the correct order. better it seems =) ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/3] Add avio_check() function.
On date Saturday 2011-04-09 02:03:19 +0200, Stefano Sabatini wrote: > On date Friday 2011-04-08 23:33:33 +0200, Luca Barbato wrote: > > On 4/8/11 8:10 PM, Anton Khirnov wrote: > > >From: Stefano Sabatini > > > > Seems fine in principle even if I won't use "check" and I'd merge it > > using ffurl namespace. > > Please wait because I have an updated patchset. Attached updated proof of concept patchset, completely untested (it's late and i need to sleep). I was trying to address Michael's comments: http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/102825/focus=118515 |requiring one call to url_check() for testing each flag is bad |a better api would be | |flags are a bit mask of which properties we want |and the return value provides these through similar flags I forgot why I didn't consider the patchset ready for posting after I tried to address that comment, but I vaguely remember there was some problematic corner case so it needs more testing. -- Driver does not carry cash. >From b563c12cb285f1e6eb8dc19d1a18323cd9280ea1 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 8 Apr 2011 18:32:25 +0200 Subject: [PATCH] avio: add avio_check() The new function is more flexible than url_exist(), as it allows to specify which access flags to check, and does not require an explicit open of the checked resource. --- libavformat/avio.c | 19 +++ libavformat/avio.h | 15 +++ 2 files changed, 34 insertions(+), 0 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index 7b066e3..cc57529 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -362,6 +362,25 @@ int url_exist(const char *filename) return 1; } +int avio_check(const char *url, int flags) +{ +URLContext *h; +int ret = ffurl_alloc(&h, url, flags); +if (ret) +return ret; + +if (h->prot->url_check) { +ret = h->prot->url_check(h, flags); +} else { +ret = ffurl_connect(h); +if (ret >= 0) +ret = flags; +} + +ffurl_close(h); +return ret; +} + int64_t ffurl_size(URLContext *h) { int64_t pos, size; diff --git a/libavformat/avio.h b/libavformat/avio.h index 03b6f6f..051c06e 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -127,6 +127,20 @@ attribute_deprecated void url_set_interrupt_cb(URLInterruptCB *interrupt_cb); int url_exist(const char *url); /** + * Return AVIO_* access flags corresponding to the access permissions + * of the resource in url, or a negative value corresponding to an + * AVERROR code in case of failure. The returned access flags are + * masked by the value in flags. + * + * @note This function is intrinsecally unsafe, in the sense that the + * checked resource may change its existence or permission status from + * one call to another. Thus you should not trust the returned value, + * unless you are sure that no other processes are accessing the + * checked resource. + */ +int avio_check(const char *url, int flags); + +/** * The callback is called in blocking functions to test regulary if * asynchronous interruption is needed. AVERROR_EXIT is returned * in this case by the interrupted function. 'NULL' means no interrupt @@ -157,6 +171,7 @@ typedef struct URLProtocol { int priv_data_size; const AVClass *priv_data_class; int flags; +int (*url_check)(URLContext *h, int mask); } URLProtocol; #if FF_API_REGISTER_PROTOCOL -- 1.7.2.3 >From 1dc3e93dc0ed88272dd427af81cf40410e1dad13 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 30 Sep 2010 13:21:42 +0200 Subject: [PATCH] file: implement url_check() callback in the file and pipe protocols --- libavformat/file.c | 16 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/libavformat/file.c b/libavformat/file.c index b8c7c4c..f939a8e 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -94,6 +94,20 @@ static int file_close(URLContext *h) return close(fd); } +static int file_check(URLContext *h, int mask) +{ +struct stat st; +int ret = stat(h->filename, &st); +if (ret < 0) +return AVERROR(errno); + +ret |= st.st_mode&S_IRUSR ? mask&AVIO_RDONLY : 0; +ret |= st.st_mode&S_IWUSR ? mask&AVIO_WRONLY : 0; +ret |= st.st_mode&S_IWUSR && st.st_mode&S_IRUSR ? mask&AVIO_RDWR : 0; + +return ret; +} + URLProtocol ff_file_protocol = { "file", file_open, @@ -102,6 +116,7 @@ URLProtocol ff_file_protocol = { file_seek, file_close, .url_get_file_handle = file_get_handle, +.url_check = file_check, }; #endif /* CONFIG_FILE_PROTOCOL */ @@ -136,6 +151,7 @@ URLProtocol ff_pipe_protocol = { file_read, file_write, .url_get_file_handle = file_get_handle, +.url_check = file_check, }; #endif /* CONFIG_PIPE_PROTOCOL */ -- 1.7.2.3 >From 3337ee5fd1ca5772c293f76e7c15267077c8001f Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 9 Apr 2011 01:32:37 +0200 Subject: [PATCH] prefer avi
Re: [libav-devel] [PATCH 3/3] Deprecate url_exist() and replace all its uses, use avio_check() instead.
On Sat, Apr 9, 2011 at 2:10 AM, Anton Khirnov wrote: > From: Stefano Sabatini > > The problem with url_exist() is that it tries to open a file in RDONLY > mode. If the file is a FIFO and there is a reading client, the open() > call will hang, and the ffmpeg process will get stuck. > > Using avio_check() with no access mode of ~0 check if the file simply > exists without attempting to open it, thus avoiding locks. > > Fix issue #1663. > --- > ffmpeg.c |2 +- > ffserver.c |4 ++-- > libavformat/avio.c |2 ++ > libavformat/avio.h |3 +++ > libavformat/img2.c |6 +++--- > 5 files changed, 11 insertions(+), 6 deletions(-) > > diff --git a/ffmpeg.c b/ffmpeg.c > index 46adb9a..3cd887b 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_check(filename, 0) != AVERROR(ENOENT)) { > if (!using_stdin) { > fprintf(stderr,"File '%s' already exists. Overwrite ? > [y/N] ", filename); > fflush(stderr); > diff --git a/ffserver.c b/ffserver.c > index eab8ae2..dd8ed23 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_check(feed->feed_filename, URL_RDONLY) > 0) { > /* 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_check(feed->feed_filename, URL_RDONLY) <= 0) { > AVFormatContext s1 = {0}, *s = &s1; > > if (feed->readonly) { > diff --git a/libavformat/avio.c b/libavformat/avio.c > index ecc7f27..f811073 100644 > --- a/libavformat/avio.c > +++ b/libavformat/avio.c > @@ -365,6 +365,7 @@ int ffurl_close(URLContext *h) > return ret; > } > > +#if FF_API_OLD_AVIO > int url_exist(const char *filename) > { > URLContext *h; > @@ -373,6 +374,7 @@ int url_exist(const char *filename) > ffurl_close(h); > return 1; > } > +#endif > > int avio_check(const char *url, int flags) > { > diff --git a/libavformat/avio.h b/libavformat/avio.h > index 823aa97..806822c 100644 > --- a/libavformat/avio.h > +++ b/libavformat/avio.h > @@ -119,11 +119,14 @@ attribute_deprecated int64_t > av_url_read_seek(URLContext *h, int stream_index, > attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void)); > #endif > > +#if FF_API_OLD_AVIO > /** > * Return a non-zero value if the resource indicated by url > * exists, 0 otherwise. > */ > +attribute_deprecated > int url_exist(const char *url); > +#endif > > /** > * Return a positive value if the resource indicated by url can be > diff --git a/libavformat/img2.c b/libavformat/img2.c > index 2b5d63b..917bae6 100644 > --- a/libavformat/img2.c > +++ b/libavformat/img2.c > @@ -131,11 +131,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_check(buf, URL_RDONLY) != AVERROR(ENOENT)) > return 0; > return -1; > } > -if (url_exist(buf)) > +if (avio_check(buf, URL_RDONLY) != AVERROR(ENOENT)) > break; > } > if (first_index == 5) > @@ -153,7 +153,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_check(buf, URL_RDONLY) == AVERROR(ENOENT)) > break; > range = range1; > /* just in case... */ > Couldn't avio_check() return other error values? > -- > 1.7.4.1 > > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel > ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/3] Add avio_check() function.
On date Friday 2011-04-08 23:33:33 +0200, Luca Barbato wrote: > On 4/8/11 8:10 PM, Anton Khirnov wrote: > >From: Stefano Sabatini > > Seems fine in principle even if I won't use "check" and I'd merge it > using ffurl namespace. Please wait because I have an updated patchset. -- An atom-blaster is a good weapon, but it can point both ways. -- Isaac Asimov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] raw dca muxer
Depends on the experimental DCA encoder. MvH Benjamin Larsson >From 0c70944526bfa9b9203f61f170f9d7bdacfac850 Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Sat, 9 Apr 2011 01:27:17 +0200 Subject: [PATCH] Add raw DCA muxer for the experimental DCA encoder --- libavformat/allformats.c |1 + libavformat/rawenc.c | 16 2 files changed, 17 insertions(+), 0 deletions(-) diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 9398d34..55194d9 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -76,6 +76,7 @@ void av_register_all(void) REGISTER_DEMUXER (CDG, cdg); REGISTER_MUXER(CRC, crc); REGISTER_MUXDEMUX (DAUD, daud); +REGISTER_MUXER(DCA, dca); REGISTER_DEMUXER (DFA, dfa); REGISTER_MUXDEMUX (DIRAC, dirac); REGISTER_MUXDEMUX (DNXHD, dnxhd); diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c index 00e43df..8e53b8f 100644 --- a/libavformat/rawenc.c +++ b/libavformat/rawenc.c @@ -298,3 +298,19 @@ AVOutputFormat ff_rawvideo_muxer = { .flags= AVFMT_NOTIMESTAMPS, }; #endif + +#if CONFIG_DCA_MUXER +AVOutputFormat ff_dca_muxer = { +"dca", +NULL_IF_CONFIG_SMALL("raw DTS Coherent Acoustics"), +NULL, +"dca", +0, +CODEC_ID_DTS, +CODEC_ID_NONE, +NULL, +ff_raw_write_packet, +.flags= AVFMT_NOTIMESTAMPS, +}; +#endif + -- 1.7.0.4 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] Experimental DCA encoder v2
Fixed some things but not others. MvH Benjamin Larsson >From 20a2180193d0fcfaaf71fb1d9f3bb4cd90a1ce0f 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 --- Changelog |1 + doc/general.texi |2 +- libavcodec/Makefile|1 + libavcodec/allcodecs.c |2 +- libavcodec/dcaenc.c| 587 libavcodec/dcaenc.h| 544 6 files changed, 1135 insertions(+), 2 deletions(-) create mode 100644 libavcodec/dcaenc.c create mode 100644 libavcodec/dcaenc.h diff --git a/Changelog b/Changelog index ec09c28..045c3f5 100644 --- a/Changelog +++ b/Changelog @@ -83,6 +83,7 @@ version : - Linux framebuffer input device added - Chronomaster DFA decoder - Mobotix MxPEG decoder +- Experimental DCA encoder version 0.6: diff --git a/doc/general.texi b/doc/general.texi index 5d66e42..2eeb609 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -599,7 +599,7 @@ following image formats are supported: @tab Codec used in Delphine Software International games. @item COOK @tab @tab X @tab All versions except 5.1 are supported. -@item DCA (DTS Coherent Acoustics) @tab @tab X +@item DCA (DTS Coherent Acoustics) @tab X @tab X @item DPCM id RoQ@tab X @tab X @tab Used in Quake III, Jedi Knight 2, other computer games. @item DPCM Interplay @tab @tab X 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..670cc3e --- /dev/null +++ b/libavcodec/dcaenc.c @@ -0,0 +1,587 @@ +/* + * DCA encoder + * Copyright (C) 2008 Alexander E. Patrakov + * 2010 Benjamin Larsson + * 2011 Xiang Wang + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "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}, +
Re: [libav-devel] [PATCH] daud: Don't write packets that are too large to have their size expressed in the bytestream.
On Fri, Apr 8, 2011 at 2:38 PM, Alex Converse wrote: > --- > libavformat/daud.c | 5 + > 1 files changed, 5 insertions(+), 0 deletions(-) > Let's try it again with the words in the correct order. From bd42249155271af2127a00260b6eb3d36d08891c Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 8 Apr 2011 14:35:17 -0700 Subject: [PATCH] daud: Don't write packets that are too large to have their size expressed in the bytestream. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="1" This is a multi-part message in MIME format. --1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit --- libavformat/daud.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) --1 Content-Type: text/x-patch; name="0001-daud-Don-t-write-packets-that-are-too-large-to-have-.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-daud-Don-t-write-packets-that-are-too-large-to-have-.patch" diff --git a/libavformat/daud.c b/libavformat/daud.c index ca9be27..1b3cfcf 100644 --- a/libavformat/daud.c +++ b/libavformat/daud.c @@ -57,6 +57,11 @@ static int daud_write_header(struct AVFormatContext *s) static int daud_write_packet(struct AVFormatContext *s, AVPacket *pkt) { +if (pkt->size > 65535) { +av_log(s, AV_LOG_ERROR, + "Packet size too large for s302m. (%d > 65535)\n", pkt->size); +return -1; +} avio_wb16(s->pb, pkt->size); avio_wb16(s->pb, 0x8010); // unknown avio_write(s->pb, pkt->data, pkt->size); --1-- ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] daud: Don't write packets that are too large to have their size expressed in the bytestream.
On 4/8/11 11:38 PM, Alex Converse wrote: --- libavformat/daud.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) Seems correct. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] daud: Don't write packets that are too large to have their size expressed in the bytestream.
--- libavformat/daud.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/libavformat/daud.c b/libavformat/daud.c index ca9be27..6f32ab6 100644 --- a/libavformat/daud.c +++ b/libavformat/daud.c @@ -57,6 +57,11 @@ static int daud_write_header(struct AVFormatContext *s) static int daud_write_packet(struct AVFormatContext *s, AVPacket *pkt) { +if (pkt->size > 65535) { +av_log(s, AV_LOG_ERROR, + "Packet too size large for s302m. (%d > 65535)\n", pkt->size); +return -1; +} avio_wb16(s->pb, pkt->size); avio_wb16(s->pb, 0x8010); // unknown avio_write(s->pb, pkt->data, pkt->size); ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/3] Add avio_check() function.
On 4/8/11 8:10 PM, Anton Khirnov wrote: From: Stefano Sabatini Seems fine in principle even if I won't use "check" and I'd merge it using ffurl namespace. lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 2/3] Implement url_check() in the file and pipe protocols.
On 4/8/11 8:10 PM, Anton Khirnov wrote: From: Stefano Sabatini Seems fine, a line more for the commit message would be welcome. lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/3] Add avio_check() function.
On 4/8/11 8:10 PM, Anton Khirnov wrote: diff --git a/libavformat/url.h b/libavformat/url.h index bde06d9..7a39b9c 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -59,6 +59,7 @@ typedef struct URLProtocol { int priv_data_size; const AVClass *priv_data_class; int flags; +int (*url_check)(URLContext *h, int flags); } URLProtocol; #endif It could/should be reordered sooner or later... ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 3/5] lavf: get rid of ffm-specific stuff in avformat.h
Hi, On Fri, Apr 8, 2011 at 10:45 AM, Ronald S. Bultje wrote: > On Fri, Apr 8, 2011 at 10:45 AM, Ronald S. Bultje wrote: >> Can we expose this somehow through private API? Can you think of other >> solutions? > > Private API == AVOption or so, not ff_*() API. OK turns out this is difficult, and FFM is out local hack anyway, so I don't mind. Please document that the variable is copied in two places for future reference. Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] Parse sprite data and decode sprites for WMVP and WVP2
On Fri, Apr 08, 2011 at 08:00:48PM +0200, Alberto Delmás wrote: > 2011/4/8 Kostya : > [...] > > All fixed. Yep, looks OK to me. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 1/3] Add avio_check() function.
From: Stefano Sabatini --- libavformat/avio.c | 16 libavformat/avio.h |9 + libavformat/url.h |1 + 3 files changed, 26 insertions(+), 0 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index ad1f1b4..ecc7f27 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -374,6 +374,22 @@ int url_exist(const char *filename) return 1; } +int avio_check(const char *url, int flags) +{ +URLContext *h; +int ret = url_alloc(&h, url, flags); +if (ret) +return ret; + +if (h->prot->url_check) +ret = h->prot->url_check(h, flags); +else +ret = (ret = url_connect(h)) < 0 ? ret : 1; + +url_close(h); +return ret; +} + int64_t ffurl_size(URLContext *h) { int64_t pos, size; diff --git a/libavformat/avio.h b/libavformat/avio.h index 7bb8d17..823aa97 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -126,6 +126,14 @@ attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void)); int url_exist(const char *url); /** + * Return a positive value if the resource indicated by url can be + * accessed with the mode indicated by flags, 0 if the resource cannot + * be accessed in that way, a negative value corresponding to an + * AVERROR code in case of failure. + */ +int avio_check(const char *url, int flags); + +/** * The callback is called in blocking functions to test regulary if * asynchronous interruption is needed. AVERROR_EXIT is returned * in this case by the interrupted function. 'NULL' means no interrupt @@ -159,6 +167,7 @@ typedef struct URLProtocol { int priv_data_size; const AVClass *priv_data_class; int flags; +int (*url_check)(URLContext *h, int flags); } URLProtocol; #endif diff --git a/libavformat/url.h b/libavformat/url.h index bde06d9..7a39b9c 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -59,6 +59,7 @@ typedef struct URLProtocol { int priv_data_size; const AVClass *priv_data_class; int flags; +int (*url_check)(URLContext *h, 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 3/3] Deprecate url_exist() and replace all its uses, use avio_check() instead.
From: Stefano Sabatini The problem with url_exist() is that it tries to open a file in RDONLY mode. If the file is a FIFO and there is a reading client, the open() call will hang, and the ffmpeg process will get stuck. Using avio_check() with no access mode of ~0 check if the file simply exists without attempting to open it, thus avoiding locks. Fix issue #1663. --- ffmpeg.c |2 +- ffserver.c |4 ++-- libavformat/avio.c |2 ++ libavformat/avio.h |3 +++ libavformat/img2.c |6 +++--- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 46adb9a..3cd887b 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_check(filename, 0) != AVERROR(ENOENT)) { if (!using_stdin) { fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename); fflush(stderr); diff --git a/ffserver.c b/ffserver.c index eab8ae2..dd8ed23 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_check(feed->feed_filename, URL_RDONLY) > 0) { /* 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_check(feed->feed_filename, URL_RDONLY) <= 0) { AVFormatContext s1 = {0}, *s = &s1; if (feed->readonly) { diff --git a/libavformat/avio.c b/libavformat/avio.c index ecc7f27..f811073 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -365,6 +365,7 @@ int ffurl_close(URLContext *h) return ret; } +#if FF_API_OLD_AVIO int url_exist(const char *filename) { URLContext *h; @@ -373,6 +374,7 @@ int url_exist(const char *filename) ffurl_close(h); return 1; } +#endif int avio_check(const char *url, int flags) { diff --git a/libavformat/avio.h b/libavformat/avio.h index 823aa97..806822c 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -119,11 +119,14 @@ attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index, attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void)); #endif +#if FF_API_OLD_AVIO /** * Return a non-zero value if the resource indicated by url * exists, 0 otherwise. */ +attribute_deprecated int url_exist(const char *url); +#endif /** * Return a positive value if the resource indicated by url can be diff --git a/libavformat/img2.c b/libavformat/img2.c index 2b5d63b..917bae6 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -131,11 +131,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_check(buf, URL_RDONLY) != AVERROR(ENOENT)) return 0; return -1; } -if (url_exist(buf)) +if (avio_check(buf, URL_RDONLY) != AVERROR(ENOENT)) break; } if (first_index == 5) @@ -153,7 +153,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_check(buf, URL_RDONLY) == AVERROR(ENOENT)) 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 2/3] Implement url_check() in the file and pipe protocols.
From: Stefano Sabatini --- libavformat/file.c | 12 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/libavformat/file.c b/libavformat/file.c index 31067ed..6eabdae 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -95,6 +95,16 @@ static int file_close(URLContext *h) return close(fd); } +static int file_check(URLContext *h, int flags) +{ +struct stat st; +int ret = stat(h->filename, &st); +if (ret < 0) +return AVERROR(errno); + +return !!(st.st_mode & flags); +} + URLProtocol ff_file_protocol = { .name= "file", .url_open= file_open, @@ -103,6 +113,7 @@ URLProtocol ff_file_protocol = { .url_seek= file_seek, .url_close = file_close, .url_get_file_handle = file_get_handle, +.url_check = file_check, }; #endif /* CONFIG_FILE_PROTOCOL */ @@ -137,6 +148,7 @@ URLProtocol ff_pipe_protocol = { .url_read= file_read, .url_write = file_write, .url_get_file_handle = file_get_handle, +.url_check = file_check, }; #endif /* CONFIG_PIPE_PROTOCOL */ -- 1.7.4.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] Parse sprite data and decode sprites for WMVP and WVP2
2011/4/8 Kostya : [...] All fixed. From 0f599e466e42a17a16609de5ec287ddfa17694a8 Mon Sep 17 00:00:00 2001 From: Alberto Delmas Date: Fri, 8 Apr 2011 18:49:40 +0200 Subject: [PATCH] Parse sprite data for WMVP and WVP2, and decode sprites for the latter --- libavcodec/vc1.c |3 - libavcodec/vc1.h |6 ++ libavcodec/vc1dec.c | 127 - libavcodec/version.h |2 +- libavformat/riff.c |1 + 5 files changed, 132 insertions(+), 7 deletions(-) diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 77e71db..b058a38 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -605,9 +605,6 @@ int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) { int pqindex, lowquant, status; -if(v->res_sprite) { -skip_bits(gb, 2); //not yet deciphered -} if(v->finterpflag) v->interpfrm = get_bits1(gb); skip_bits(gb, 2); //framecnt unused v->rangeredfrm = 0; diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h index 00dcfbf..d0c0ccc 100644 --- a/libavcodec/vc1.h +++ b/libavcodec/vc1.h @@ -306,6 +306,12 @@ typedef struct VC1Context{ uint8_t range_mapuv; //@} +/** Frame decoding info for sprite modes */ +//@{ +int new_sprite; +int two_sprites; +//@} + int p_frame_skipped; int bi_type; int x8_type; diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index cde284d..8200cde 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -3097,6 +3097,116 @@ static void vc1_decode_blocks(VC1Context *v, int mby_start, int mby_end) } } +static inline float get_float_val(GetBitContext* gb) +{ +return (float)get_bits_long(gb, 30) / (1<<15) - (1<<14); +} + +static void vc1_sprite_parse_transform(VC1Context *v, GetBitContext* gb, float c[7]) +{ +c[1] = c[3] = 0.0f; + +switch (get_bits(gb, 2)) { +case 0: +c[0] = 1.0f; +c[2] = get_float_val(gb); +c[4] = 1.0f; +break; +case 1: +c[0] = c[4] = get_float_val(gb); +c[2] = get_float_val(gb); +break; +case 2: +c[0] = get_float_val(gb); +c[2] = get_float_val(gb); +c[4] = get_float_val(gb); +break; +case 3: +av_log_ask_for_sample(v->s.avctx, NULL); +c[0] = get_float_val(gb); +c[1] = get_float_val(gb); +c[2] = get_float_val(gb); +c[3] = get_float_val(gb); +c[4] = get_float_val(gb); +break; +} +c[5] = get_float_val(gb); +if (get_bits1(gb)) +c[6] = get_float_val(gb); +else +c[6] = 1.0f; +} + +static void vc1_parse_sprites(VC1Context *v, GetBitContext* gb) +{ +int effect_type, effect_flag, effect_pcount1, effect_pcount2, i; +float effect_params1[14], effect_params2[10]; + +float coefs[2][7]; +vc1_sprite_parse_transform(v, gb, coefs[0]); +av_log(v->s.avctx, AV_LOG_DEBUG, "S1:"); +for (i = 0; i < 7; i++) +av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", coefs[0][i]); +av_log(v->s.avctx, AV_LOG_DEBUG, "\n"); + +if (v->two_sprites) { +vc1_sprite_parse_transform(v, gb, coefs[1]); +av_log(v->s.avctx, AV_LOG_DEBUG, "S2:"); +for (i = 0; i < 7; i++) +av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", coefs[1][i]); +av_log(v->s.avctx, AV_LOG_DEBUG, "\n"); +} +skip_bits(gb, 2); +if (effect_type = get_bits_long(gb, 30)){ +switch (effect_pcount1 = get_bits(gb, 4)) { +case 2: +effect_params1[0] = get_float_val(gb); +effect_params1[1] = get_float_val(gb); +break; +case 7: +vc1_sprite_parse_transform(v, gb, effect_params1); +break; +case 14: +vc1_sprite_parse_transform(v, gb, effect_params1); +vc1_sprite_parse_transform(v, gb, &effect_params1[7]); +break; +default: +av_log_ask_for_sample(v->s.avctx, NULL); +return; +} +if (effect_type != 13 || effect_params1[0] != coefs[0][6]) { +// effect 13 is simple alpha blending and matches the opacity above +av_log(v->s.avctx, AV_LOG_DEBUG, "Effect: %d; params: ", effect_type); +for (i = 0; i < effect_pcount1; i++) +av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", effect_params1[i]); +av_log(v->s.avctx, AV_LOG_DEBUG, "\n"); +} + +effect_pcount2 = get_bits(gb, 16); +if (effect_pcount2 > 10) { +av_log(v->s.avctx, AV_LOG_ERROR, "Too many effect parameters\n"); +return; +} else if (effect_pcount2) { +i = 0; +av_log(v->s.avctx, AV_LOG_DEBUG, "Effect params 2: "); +while (i < effect_pcount2){ +effect_params2[i] = get_float_val(gb); +av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", effect_params2[i]); +i++; +} +av_log(v->s.avctx, AV_LOG_DEBUG, "\n"); +
Re: [libav-devel] [PATCH 1/2] lavf: rename avf_sdp_create to av_sdp_create.
On 4/8/11 3:32 PM, Martin Storsjö wrote: On Fri, 8 Apr 2011, Ronald S. Bultje wrote: Hi, On Fri, Apr 8, 2011 at 6:36 AM, Diego Biurrun wrote: On Fri, Apr 08, 2011 at 12:24:34PM +0200, Anton Khirnov wrote: The new name is more consistent with the rest of the API. OK Luca, Martin, any opinions? Ok with me, but preferrably in two separate patches (renaming the local variable separately) as someone else suggested. Fine for me as well. lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] Parse sprite data and decode sprites for WMVP and WVP2
On Fri, Apr 08, 2011 at 07:07:30PM +0200, Alberto Delmás wrote: > > From fbaf5be431d60dd6e52b3da9fb0e9f42864629e6 Mon Sep 17 00:00:00 2001 > From: Alberto Delmas > Date: Fri, 8 Apr 2011 18:49:40 +0200 > Subject: [PATCH] Parse sprite data for WMVP and WVP2, and decode sprites for > the latter > > --- > libavcodec/vc1.c |3 - > libavcodec/vc1.h |6 ++ > libavcodec/vc1dec.c | 126 - > libavcodec/version.h |2 +- > libavformat/riff.c |1 + > 5 files changed, 131 insertions(+), 7 deletions(-) > [...] > diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c > index cde284d..551d2d6 100644 > --- a/libavcodec/vc1dec.c > +++ b/libavcodec/vc1dec.c > @@ -3097,6 +3097,116 @@ static void vc1_decode_blocks(VC1Context *v, int > mby_start, int mby_end) > } > } > > +static inline float get_float_val(GetBitContext* gb) > +{ > +return (float)get_bits_long(gb, 30) / (1<<15) - (1<<14); > +} > + > +static void vc1_sprite_parse_transform(VC1Context *v, GetBitContext* gb, > float c[7]) > +{ > +c[1] = c[3] = 0.0f; > + > +switch(get_bits(gb, 2)) { > +case 0: > +c[0] = 1.0f; > +c[2] = get_float_val(gb); > +c[4] = 1.0f; > +break; > +case 1: > +c[0] = c[4] = get_float_val(gb); > +c[2] = get_float_val(gb); > +break; > +case 2: > +c[0] = get_float_val(gb); > +c[2] = get_float_val(gb); > +c[4] = get_float_val(gb); > +break; > +case 3: > +av_log_ask_for_sample(v->s.avctx, NULL); > +c[0] = get_float_val(gb); > +c[1] = get_float_val(gb); > +c[2] = get_float_val(gb); > +c[3] = get_float_val(gb); > +c[4] = get_float_val(gb); > +break; > +} > +c[5] = get_float_val(gb); > +if (get_bits1(gb)) > +c[6] = get_float_val(gb); > +else > +c[6] = 1.0f; > +} > + > +static void vc1_parse_sprites(VC1Context *v, GetBitContext* gb) > +{ > +int effect_type, effect_flag, effect_pcount1, effect_pcount2, i; > +float effect_params1[14], effect_params2[10]; > + > +float coefs[2][7]; // scale_1, unused?, off_1, unused?, scale_2, off_2, > opacity please remove this comment > +vc1_sprite_parse_transform(v, gb, coefs[0]); > +av_log(v->s.avctx, AV_LOG_INFO, "S1:"); > +for (i = 0; i < 7; i++) > +av_log(v->s.avctx, AV_LOG_INFO, " %.3f", coefs[0][i]); > +av_log(v->s.avctx, AV_LOG_INFO, "\n"); > + > +if (v->two_sprites){ please use either "if (x) {" or "if(x){" (the former is better) everywhere, now it's weird > +vc1_sprite_parse_transform(v, gb, coefs[1]); > +av_log(v->s.avctx, AV_LOG_INFO, "S2:"); > +for (i = 0; i < 7; i++) > +av_log(v->s.avctx, AV_LOG_INFO, " %.3f", coefs[1][i]); > +av_log(v->s.avctx, AV_LOG_INFO, "\n"); > +} please use AV_LOG_DEBUG as level here and below for all transform information > +skip_bits(gb, 2); > +if (effect_type = get_bits_long(gb, 30)){ > +switch(effect_pcount1 = get_bits(gb, 4)){ > +case 2: > +effect_params1[0] = get_float_val(gb); > +effect_params1[1] = get_float_val(gb); > +break; > +case 7: > +vc1_sprite_parse_transform(v, gb, effect_params1); > +break; > +case 14: > +vc1_sprite_parse_transform(v, gb, effect_params1); > +vc1_sprite_parse_transform(v, gb, &effect_params1[7]); > +break; > +default: > +av_log_ask_for_sample(v->s.avctx, NULL); > +return; > +} > +if (effect_type != 13 || effect_params1[0] != coefs[0][6]){ > +// effect 13 is simple alpha blending and matches the opacity > above > +av_log(v->s.avctx, AV_LOG_INFO, "Effect: %d; params: ", > effect_type); > +for (i = 0; i < effect_pcount1; i++) > +av_log(v->s.avctx, AV_LOG_INFO, " %.3f", effect_params1[i]); > +av_log(v->s.avctx, AV_LOG_INFO, "\n"); > +} > + > +effect_pcount2 = get_bits(gb, 16); > +if (effect_pcount2 > 10){ > +av_log(v->s.avctx, AV_LOG_ERROR, "Too many effect parameters\n"); > +return; > +} else if (effect_pcount2) { > +i = 0; > +av_log(v->s.avctx, AV_LOG_INFO, "Effect params 2: "); > +while (i < effect_pcount2){ > +effect_params2[i] = get_float_val(gb); > +av_log(v->s.avctx, AV_LOG_INFO, " %.3f", effect_params2[i]); > +i++; > +} > +av_log(v->s.avctx, AV_LOG_INFO, "\n"); > +} > +} > +if (effect_flag = get_bits1(gb)) > +av_log(v->s.avctx, AV_LOG_INFO, "Effect flag set\n"); > + > +if (get_bits_count(gb) >= gb->size_in_bits + > + (v->s.avctx->codec_id == CODEC_ID_WMV3 ? 64 : 0)) > +av_log(v->s.avctx, AV_LOG_ERROR, "Buffer overrun\n");
[libav-devel] [PATCH] Parse sprite data and decode sprites for WMVP and WVP2
From fbaf5be431d60dd6e52b3da9fb0e9f42864629e6 Mon Sep 17 00:00:00 2001 From: Alberto Delmas Date: Fri, 8 Apr 2011 18:49:40 +0200 Subject: [PATCH] Parse sprite data for WMVP and WVP2, and decode sprites for the latter --- libavcodec/vc1.c |3 - libavcodec/vc1.h |6 ++ libavcodec/vc1dec.c | 126 - libavcodec/version.h |2 +- libavformat/riff.c |1 + 5 files changed, 131 insertions(+), 7 deletions(-) diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 77e71db..b058a38 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -605,9 +605,6 @@ int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) { int pqindex, lowquant, status; -if(v->res_sprite) { -skip_bits(gb, 2); //not yet deciphered -} if(v->finterpflag) v->interpfrm = get_bits1(gb); skip_bits(gb, 2); //framecnt unused v->rangeredfrm = 0; diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h index 00dcfbf..d0c0ccc 100644 --- a/libavcodec/vc1.h +++ b/libavcodec/vc1.h @@ -306,6 +306,12 @@ typedef struct VC1Context{ uint8_t range_mapuv; //@} +/** Frame decoding info for sprite modes */ +//@{ +int new_sprite; +int two_sprites; +//@} + int p_frame_skipped; int bi_type; int x8_type; diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index cde284d..551d2d6 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -3097,6 +3097,116 @@ static void vc1_decode_blocks(VC1Context *v, int mby_start, int mby_end) } } +static inline float get_float_val(GetBitContext* gb) +{ +return (float)get_bits_long(gb, 30) / (1<<15) - (1<<14); +} + +static void vc1_sprite_parse_transform(VC1Context *v, GetBitContext* gb, float c[7]) +{ +c[1] = c[3] = 0.0f; + +switch(get_bits(gb, 2)) { +case 0: +c[0] = 1.0f; +c[2] = get_float_val(gb); +c[4] = 1.0f; +break; +case 1: +c[0] = c[4] = get_float_val(gb); +c[2] = get_float_val(gb); +break; +case 2: +c[0] = get_float_val(gb); +c[2] = get_float_val(gb); +c[4] = get_float_val(gb); +break; +case 3: +av_log_ask_for_sample(v->s.avctx, NULL); +c[0] = get_float_val(gb); +c[1] = get_float_val(gb); +c[2] = get_float_val(gb); +c[3] = get_float_val(gb); +c[4] = get_float_val(gb); +break; +} +c[5] = get_float_val(gb); +if (get_bits1(gb)) +c[6] = get_float_val(gb); +else +c[6] = 1.0f; +} + +static void vc1_parse_sprites(VC1Context *v, GetBitContext* gb) +{ +int effect_type, effect_flag, effect_pcount1, effect_pcount2, i; +float effect_params1[14], effect_params2[10]; + +float coefs[2][7]; // scale_1, unused?, off_1, unused?, scale_2, off_2, opacity +vc1_sprite_parse_transform(v, gb, coefs[0]); +av_log(v->s.avctx, AV_LOG_INFO, "S1:"); +for (i = 0; i < 7; i++) +av_log(v->s.avctx, AV_LOG_INFO, " %.3f", coefs[0][i]); +av_log(v->s.avctx, AV_LOG_INFO, "\n"); + +if (v->two_sprites){ +vc1_sprite_parse_transform(v, gb, coefs[1]); +av_log(v->s.avctx, AV_LOG_INFO, "S2:"); +for (i = 0; i < 7; i++) +av_log(v->s.avctx, AV_LOG_INFO, " %.3f", coefs[1][i]); +av_log(v->s.avctx, AV_LOG_INFO, "\n"); +} +skip_bits(gb, 2); +if (effect_type = get_bits_long(gb, 30)){ +switch(effect_pcount1 = get_bits(gb, 4)){ +case 2: +effect_params1[0] = get_float_val(gb); +effect_params1[1] = get_float_val(gb); +break; +case 7: +vc1_sprite_parse_transform(v, gb, effect_params1); +break; +case 14: +vc1_sprite_parse_transform(v, gb, effect_params1); +vc1_sprite_parse_transform(v, gb, &effect_params1[7]); +break; +default: +av_log_ask_for_sample(v->s.avctx, NULL); +return; +} +if (effect_type != 13 || effect_params1[0] != coefs[0][6]){ +// effect 13 is simple alpha blending and matches the opacity above +av_log(v->s.avctx, AV_LOG_INFO, "Effect: %d; params: ", effect_type); +for (i = 0; i < effect_pcount1; i++) +av_log(v->s.avctx, AV_LOG_INFO, " %.3f", effect_params1[i]); +av_log(v->s.avctx, AV_LOG_INFO, "\n"); +} + +effect_pcount2 = get_bits(gb, 16); +if (effect_pcount2 > 10){ +av_log(v->s.avctx, AV_LOG_ERROR, "Too many effect parameters\n"); +return; +} else if (effect_pcount2) { +i = 0; +av_log(v->s.avctx, AV_LOG_INFO, "Effect params 2: "); +while (i < effect_pcount2){ +effect_params2[i] = get_float_val(gb); +av_log(v->s.avctx, AV_LOG_INFO, " %.3f", effect_params2[i]); +i++; +} +av_log(v->s.avctx, AV_LOG_INFO, "\n");
Re: [libav-devel] [PATCH 1/2] avio: add a function for iterating though protocol names.
Hi, On Fri, Apr 8, 2011 at 10:54 AM, Anton Khirnov wrote: > --- > 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 e043058..ab7a7f5 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; Please make that void *opaque. Otherwise OK with me, not super-excited about this solution but it'll have to do for now. Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 2/2] avio: deprecate av_protocol_next().
Hi, On Fri, Apr 8, 2011 at 10:54 AM, Anton Khirnov wrote: > --- > cmdutils.c | 20 > libavformat/avio.c | 2 ++ > libavformat/avio.h | 4 +++- > 3 files changed, 13 insertions(+), 13 deletions(-) This one is surely OK. Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] Experimental DCA encoder
"Ronald S. Bultje" writes: > 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... ARM has a rounding version of that instruction FWIW. -- Måns Rullgård m...@mansr.com ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 1/2] avio: add a function for iterating though protocol names.
--- 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 e043058..ab7a7f5 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 c39d2a0..9ea138e 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -600,4 +600,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
[libav-devel] [PATCH 2/2] avio: deprecate av_protocol_next().
--- 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 ab7a7f5..ad1f1b4 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -51,11 +51,13 @@ static int default_interrupt_cb(void); URLProtocol *first_protocol = NULL; int (*url_interrupt_cb)(void) = 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 9ea138e..7bb8d17 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -170,12 +170,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
Re: [libav-devel] [PATCH 3/5] lavf: get rid of ffm-specific stuff in avformat.h
Hi, On Fri, Apr 8, 2011 at 10:45 AM, Ronald S. Bultje wrote: > Can we expose this somehow through private API? Can you think of other > solutions? Private API == AVOption or so, not ff_*() API. Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 3/5] lavf: get rid of ffm-specific stuff in avformat.h
Hi, On Fri, Apr 8, 2011 at 10:42 AM, Anton Khirnov wrote: > On Fri, Apr 08, 2011 at 10:07:32AM -0400, Ronald S. Bultje wrote: >> Hi, >> >> On Fri, Apr 8, 2011 at 9:47 AM, Anton Khirnov wrote: >> > On Fri, Apr 08, 2011 at 07:43:35AM -0400, Ronald S. Bultje wrote: >> >> On Fri, Apr 8, 2011 at 5:48 AM, Anton Khirnov wrote: >> >> > --- >> >> > ffmpeg.c | 2 ++ >> >> > ffserver.c | 1 + >> >> > libavformat/avformat.h | 6 -- >> >> > libavformat/ffm.h | 5 + >> >> > 4 files changed, 8 insertions(+), 6 deletions(-) >> >> > >> >> > diff --git a/ffmpeg.c b/ffmpeg.c >> >> > index 83e77dd..749c9c7 100644 >> >> > --- a/ffmpeg.c >> >> > +++ b/ffmpeg.c >> >> > @@ -110,6 +110,8 @@ static const OptionDef options[]; >> >> > #define MAX_STREAMS 1024 /* arbitrary sanity check value */ >> >> > #endif >> >> > >> >> > +#define FFM_PACKET_SIZE 4096 >> >> > + >> >> > static const char *last_asked_format = NULL; >> >> > static AVFormatContext *input_files[MAX_FILES]; >> >> > static int64_t input_files_ts_offset[MAX_FILES]; >> >> >> >> Hacking ffserver is one thing, but this goes a little far. How about >> >> we make this a private AVOption? What is the exact use-case here? >> > >> > ffmpeg uses this value as the buffer size for ffm streams. >> >> Can we think of a cleaner way to export this? What about the other >> ffm_*() functions? Does ffserver use them (I bet it does). > > ffserver uses them, but i gave up trying to keep it clean. I'd like to > keep those hacks from ffmpeg though. Duplication is not nice, but > duplicating one line is much better than including a private header. I agree, again. But I don't think duplicating the define is any better. In fact, it's worse. Can we expose this somehow through private API? Can you think of other solutions? Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 2/5] lavf: make av_guess_image2_codec internal
Hi, On Fri, Apr 8, 2011 at 5:48 AM, Anton Khirnov wrote: > It doesn't look very useful as a public function. > --- > libavformat/avformat.h | 4 +++- > libavformat/img2.c | 8 > libavformat/internal.h | 2 ++ > libavformat/utils.c | 4 ++-- > libavformat/version.h | 3 +++ > 5 files changed, 18 insertions(+), 3 deletions(-) OK, I guess. Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 3/5] lavf: get rid of ffm-specific stuff in avformat.h
On Fri, Apr 08, 2011 at 10:07:32AM -0400, Ronald S. Bultje wrote: > Hi, > > On Fri, Apr 8, 2011 at 9:47 AM, Anton Khirnov wrote: > > On Fri, Apr 08, 2011 at 07:43:35AM -0400, Ronald S. Bultje wrote: > >> On Fri, Apr 8, 2011 at 5:48 AM, Anton Khirnov wrote: > >> > --- > >> > ffmpeg.c | 2 ++ > >> > ffserver.c | 1 + > >> > libavformat/avformat.h | 6 -- > >> > libavformat/ffm.h | 5 + > >> > 4 files changed, 8 insertions(+), 6 deletions(-) > >> > > >> > diff --git a/ffmpeg.c b/ffmpeg.c > >> > index 83e77dd..749c9c7 100644 > >> > --- a/ffmpeg.c > >> > +++ b/ffmpeg.c > >> > @@ -110,6 +110,8 @@ static const OptionDef options[]; > >> > #define MAX_STREAMS 1024 /* arbitrary sanity check value */ > >> > #endif > >> > > >> > +#define FFM_PACKET_SIZE 4096 > >> > + > >> > static const char *last_asked_format = NULL; > >> > static AVFormatContext *input_files[MAX_FILES]; > >> > static int64_t input_files_ts_offset[MAX_FILES]; > >> > >> Hacking ffserver is one thing, but this goes a little far. How about > >> we make this a private AVOption? What is the exact use-case here? > > > > ffmpeg uses this value as the buffer size for ffm streams. > > Can we think of a cleaner way to export this? What about the other > ffm_*() functions? Does ffserver use them (I bet it does). > ffserver uses them, but i gave up trying to keep it clean. I'd like to keep those hacks from ffmpeg though. Duplication is not nice, but duplicating one line is much better than including a private header. -- 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] Last bits of avio cleanup
Hi, On Thu, Apr 7, 2011 at 3:16 PM, Anton Khirnov wrote: > 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 Stefano can you comment on this please? Do you think this is better? Any outstanding issues? I definitely hate url_exists() and would like to shoot it with Mans' shotgun. Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/5] lavf: mark av_pkt_dump(_log) for remove on $next+1 bump.
Hi, On Fri, Apr 8, 2011 at 10:15 AM, Anton Khirnov wrote: > On Fri, Apr 08, 2011 at 10:10:18AM -0400, Ronald S. Bultje wrote: >> On Fri, Apr 8, 2011 at 9:43 AM, Anton Khirnov wrote: >> > On Fri, Apr 08, 2011 at 07:39:52AM -0400, Ronald S. Bultje wrote: >> >> On Fri, Apr 8, 2011 at 5:48 AM, Anton Khirnov wrote: >> >> > --- >> >> > libavformat/avformat.h | 4 +++- >> >> > libavformat/utils.c | 4 >> >> > libavformat/version.h | 3 +++ >> >> > 3 files changed, 10 insertions(+), 1 deletions(-) >> >> >> >> Any reason we don't want to remove it at the next one already, going >> >> by the evil "release, bump, release again" plan? >> >> >> > >> > As you already know =p, I think our policy should be to remove old stuff >> > only after a sufficiently (at least ~0.5y) long transition period. >> >> These *2() functions have been out for a few months, so it's long >> enough. I've keen on removing as much old cruft as possible. >> >> (It's not like this is critical API that every application definitely >> uses, unlike say avcodec_decode_audioX() or so... The chance of real >> problems is relatively small.) > > Only one month. > > Don't forget that we already have a bad reputation for breaking > compatibility often (undeserved, but still...). I'd prefer to be more > conservative with those things, unless they obstruct progress. That is > certainly not the case here. Fair enough, I already OK'ed the patch. But if the code was bigger or it would obstruct reordering of stuff in structs (i.e. ABI) I'd make a bigger deal about it maybe. Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/5] lavf: mark av_pkt_dump(_log) for remove on $next+1 bump.
On Fri, Apr 08, 2011 at 10:10:18AM -0400, Ronald S. Bultje wrote: > Hi, > > On Fri, Apr 8, 2011 at 9:43 AM, Anton Khirnov wrote: > > On Fri, Apr 08, 2011 at 07:39:52AM -0400, Ronald S. Bultje wrote: > >> On Fri, Apr 8, 2011 at 5:48 AM, Anton Khirnov wrote: > >> > --- > >> > libavformat/avformat.h | 4 +++- > >> > libavformat/utils.c | 4 > >> > libavformat/version.h | 3 +++ > >> > 3 files changed, 10 insertions(+), 1 deletions(-) > >> > >> Any reason we don't want to remove it at the next one already, going > >> by the evil "release, bump, release again" plan? > >> > > > > As you already know =p, I think our policy should be to remove old stuff > > only after a sufficiently (at least ~0.5y) long transition period. > > These *2() functions have been out for a few months, so it's long > enough. I've keen on removing as much old cruft as possible. > > (It's not like this is critical API that every application definitely > uses, unlike say avcodec_decode_audioX() or so... The chance of real > problems is relatively small.) Only one month. Don't forget that we already have a bad reputation for breaking compatibility often (undeserved, but still...). I'd prefer to be more conservative with those things, unless they obstruct progress. That is certainly not the case here. -- 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/5] lavf: mark av_pkt_dump(_log) for remove on $next+1 bump.
Hi, On Fri, Apr 8, 2011 at 9:43 AM, Anton Khirnov wrote: > On Fri, Apr 08, 2011 at 07:39:52AM -0400, Ronald S. Bultje wrote: >> On Fri, Apr 8, 2011 at 5:48 AM, Anton Khirnov wrote: >> > --- >> > libavformat/avformat.h | 4 +++- >> > libavformat/utils.c | 4 >> > libavformat/version.h | 3 +++ >> > 3 files changed, 10 insertions(+), 1 deletions(-) >> >> Any reason we don't want to remove it at the next one already, going >> by the evil "release, bump, release again" plan? >> > > As you already know =p, I think our policy should be to remove old stuff > only after a sufficiently (at least ~0.5y) long transition period. These *2() functions have been out for a few months, so it's long enough. I've keen on removing as much old cruft as possible. (It's not like this is critical API that every application definitely uses, unlike say avcodec_decode_audioX() or so... The chance of real problems is relatively small.) Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 3/5] lavf: get rid of ffm-specific stuff in avformat.h
Hi, On Fri, Apr 8, 2011 at 9:47 AM, Anton Khirnov wrote: > On Fri, Apr 08, 2011 at 07:43:35AM -0400, Ronald S. Bultje wrote: >> On Fri, Apr 8, 2011 at 5:48 AM, Anton Khirnov wrote: >> > --- >> > ffmpeg.c | 2 ++ >> > ffserver.c | 1 + >> > libavformat/avformat.h | 6 -- >> > libavformat/ffm.h | 5 + >> > 4 files changed, 8 insertions(+), 6 deletions(-) >> > >> > diff --git a/ffmpeg.c b/ffmpeg.c >> > index 83e77dd..749c9c7 100644 >> > --- a/ffmpeg.c >> > +++ b/ffmpeg.c >> > @@ -110,6 +110,8 @@ static const OptionDef options[]; >> > #define MAX_STREAMS 1024 /* arbitrary sanity check value */ >> > #endif >> > >> > +#define FFM_PACKET_SIZE 4096 >> > + >> > static const char *last_asked_format = NULL; >> > static AVFormatContext *input_files[MAX_FILES]; >> > static int64_t input_files_ts_offset[MAX_FILES]; >> >> Hacking ffserver is one thing, but this goes a little far. How about >> we make this a private AVOption? What is the exact use-case here? > > ffmpeg uses this value as the buffer size for ffm streams. Can we think of a cleaner way to export this? What about the other ffm_*() functions? Does ffserver use them (I bet it does). > I don't think it belongs in a public header. I agree. Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 7/9] avio: deprecate av_protocol_next().
On Fri, Apr 08, 2011 at 01:57:06PM +0200, Stefano Sabatini wrote: > On date Thursday 2011-04-07 00:18:48 +, Ronald S. Bultje wrote: > > Hi, > [...] > > > Another point is that an application may need to implement an ad-hoc > > > access protocol, this is not an hypotetical need as you can find many > > > of such requests in the libav-user archive. I can understand that the > > > API may need to be made hidden for the moment while it is reworked, > > > but then at some point it will be useful to make the protocol struct > > > public again. > > > > Let's consider that when a real usecase arises. > > > > The hypothetical "I need a custom protocol" means it's either to embed > > lavf demuxers in a non-FFmpeg/Libav framework, for which AVIOContext > > is better suited, > > yes > > > or for stuff that should be inside FFmpeg/Libav anyway. > > No, requirements can be pretty weird these days, you may need to > access another ad-hoc process, or use a private protocol which is not > useful enough to be embedded into the framework. This applies to most > configured elements in FFmpeg/Libav, we implement the stuff which is > publically useful but there are a lot of ad-hoc components which are > better implemented at the application level. > The point is, for most of those use cases you don't need access to URLProtocol, you can implement them on the AVIOContext level. -- 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 3/5] lavf: get rid of ffm-specific stuff in avformat.h
On Fri, Apr 08, 2011 at 07:43:35AM -0400, Ronald S. Bultje wrote: > Hi, > > On Fri, Apr 8, 2011 at 5:48 AM, Anton Khirnov wrote: > > --- > > ffmpeg.c | 2 ++ > > ffserver.c | 1 + > > libavformat/avformat.h | 6 -- > > libavformat/ffm.h | 5 + > > 4 files changed, 8 insertions(+), 6 deletions(-) > > > > diff --git a/ffmpeg.c b/ffmpeg.c > > index 83e77dd..749c9c7 100644 > > --- a/ffmpeg.c > > +++ b/ffmpeg.c > > @@ -110,6 +110,8 @@ static const OptionDef options[]; > > #define MAX_STREAMS 1024 /* arbitrary sanity check value */ > > #endif > > > > +#define FFM_PACKET_SIZE 4096 > > + > > static const char *last_asked_format = NULL; > > static AVFormatContext *input_files[MAX_FILES]; > > static int64_t input_files_ts_offset[MAX_FILES]; > > Hacking ffserver is one thing, but this goes a little far. How about > we make this a private AVOption? What is the exact use-case here? ffmpeg uses this value as the buffer size for ffm streams. I don't think it belongs in a public header. -- 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/5] lavf: mark av_pkt_dump(_log) for remove on $next+1 bump.
On Fri, Apr 08, 2011 at 07:39:52AM -0400, Ronald S. Bultje wrote: > Hi, > > On Fri, Apr 8, 2011 at 5:48 AM, Anton Khirnov wrote: > > --- > > libavformat/avformat.h | 4 +++- > > libavformat/utils.c | 4 > > libavformat/version.h | 3 +++ > > 3 files changed, 10 insertions(+), 1 deletions(-) > > Any reason we don't want to remove it at the next one already, going > by the evil "release, bump, release again" plan? > As you already know =p, I think our policy should be to remove old stuff only after a sufficiently (at least ~0.5y) long transition period. -- 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/2] lavf: rename avf_sdp_create to av_sdp_create.
On Fri, 8 Apr 2011, Ronald S. Bultje wrote: > Hi, > > On Fri, Apr 8, 2011 at 6:36 AM, Diego Biurrun wrote: > > On Fri, Apr 08, 2011 at 12:24:34PM +0200, Anton Khirnov wrote: > >> The new name is more consistent with the rest of the API. > > > > OK > > Luca, Martin, any opinions? Ok with me, but preferrably in two separate patches (renaming the local variable separately) as someone else suggested. // Martin ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/2] lavf: rename avf_sdp_create to av_sdp_create.
Hi, On Fri, Apr 8, 2011 at 6:36 AM, Diego Biurrun wrote: > On Fri, Apr 08, 2011 at 12:24:34PM +0200, Anton Khirnov wrote: >> The new name is more consistent with the rest of the API. > > OK Luca, Martin, any opinions? Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] Experimental DCA encoder
On Fri, Apr 08, 2011 at 07:53:32AM -0400, Ronald S. Bultje wrote: > Hi, [...] > > Ah, that's what the fixme is for I guess. Sounds ok to me then. > (Didn't Mans just implement fixed-point FFT or something like that? Or > was that "just" MDCT?) MDCT is often implemented via FFT. P.S. And if somebody gets crazy idea of implementing DTS-MA he should implement bitexact fixedpoint DCT32 they use inside QMF (and which is not given in DTS specs IIRC). ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] Experimental DCA encoder
Hi, On Fri, Apr 8, 2011 at 5:02 AM, Benjamin Larsson wrote: > On 04/08/2011 03:58 AM, Ronald S. Bultje wrote: >> 2011/4/7 Benjamin Larsson : >>> +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? > > Decomposes the signal into bands. Time domain -> frequency domain. Ah, that's what the fixme is for I guess. Sounds ok to me then. (Didn't Mans just implement fixed-point FFT or something like that? Or was that "just" MDCT?) Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 7/9] avio: deprecate av_protocol_next().
On date Thursday 2011-04-07 00:18:48 +, Ronald S. Bultje wrote: > Hi, [...] > > Another point is that an application may need to implement an ad-hoc > > access protocol, this is not an hypotetical need as you can find many > > of such requests in the libav-user archive. I can understand that the > > API may need to be made hidden for the moment while it is reworked, > > but then at some point it will be useful to make the protocol struct > > public again. > > Let's consider that when a real usecase arises. > > The hypothetical "I need a custom protocol" means it's either to embed > lavf demuxers in a non-FFmpeg/Libav framework, for which AVIOContext > is better suited, yes > or for stuff that should be inside FFmpeg/Libav anyway. No, requirements can be pretty weird these days, you may need to access another ad-hoc process, or use a private protocol which is not useful enough to be embedded into the framework. This applies to most configured elements in FFmpeg/Libav, we implement the stuff which is publically useful but there are a lot of ad-hoc components which are better implemented at the application level. > > Another possibility is to keep the struct public and warn the user in > > big capital letters that the interface is not considered stable yet > > and can break at each moment (nasty solution from the user POV but yet > > better than having to copy an header in your app). > > Manually include url.h is still possible. In fact, all our protocol > handlers do it. :-). > > > BTW "url" is a crappy prefix in this context and higly misleading > > (they are not URL parsing routines after all), I suggest something > > along the line of (ff|av)proto, the fact that most protocols deal with > > urls is purely accidental. > > The great thing is that it's internal API now, we can fix/change it. > I'd really like that. This also applies to other parts, including > libavfilter, where exposing an infant API can make progress a lot > slower than it should be. This is engineering, so we don't have The Perfect Solution but a set of constraints and tradeoffs. I agree that exposing an unstable interface is not safe, but unnecessarily limiting the functionality of the library is worse (point of view of external user/developer vs. point of view of packager/maintainer). Of course the final evaluation much depends on the value that you assign to each feature. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [rfc] Protocol API
On 4/8/11 1:35 PM, Stefano Sabatini wrote: 1) keep the header public but declare that the API is not considered stable and there is no guarantee of backward compatibility (similar to what is done with lavfi) 2) keep the header private while the API is reworked With 1) you still have the possibility to use that API in a custom application, without the need of brittle hacks (like copying into the application). I like better option 1, probably adding a guard LIBAV_TRANSIENT_API to make 100% sure people are aware about it. lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 2/2] avio: make URLProtocol internal.
Hi, On Fri, Apr 8, 2011 at 1:22 AM, Anton Khirnov wrote: > --- > libavformat/avio.h | 6 +- > libavformat/url.h | 17 + > 2 files changed, 22 insertions(+), 1 deletions(-) OK. This compiles after the bump, right? Ronald ___ 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
On Fri, Apr 08, 2011 at 01:44:09PM +0200, Anton Khirnov wrote: > On Thu, Apr 07, 2011 at 10:28:25AM +0200, Kostya wrote: > > 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 > > nit: I don't think it makes much sense to #define this. It's just for convenience. > > +#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; > > av_freep That should belong to separate patch cleaning whole avpacket.c, I've copied style, not written it. > > +pkt->side_data_size = 0; > > +pkt->side_data_type = AV_PKT_DATA_NONE; > > } > > > > void av_init_packet(AVPacket *pkt) > > @@ -44,6 +50,9 @@ void av_init_packet(AVPacket *pkt) > > pkt->flags = 0; > > pkt->stream_index = 0; > > pkt->destruct= NULL; > > +pkt->side_data = NULL; > > +pkt->side_data_size = 0; > > +pkt->side_data_type = AV_PKT_DATA_NONE; > > } > > > > int av_new_packet(AVPacket *pkt, int size) > > @@ -59,6 +68,9 @@ int av_new_packet(AVPacket *pkt, int size) > > av_init_packet(pkt); > > pkt->data = data; > > pkt->size = size; > > +pkt->side_data = NULL; > > +pkt->side_data_size = 0; > > +pkt->side_data_type = AV_PKT_DATA_NONE; > > that's already done in av_init_packet() indeed, will be dropped > > pkt->destruct = av_destruct_packet; > > if(!data) > > return AVERROR(ENOMEM); > > @@ -89,6 +101,21 @@ int av_grow_packet(AVPacket *pkt, int grow_by) > > return 0; > > } > > > > +int av_packet_new_side_data(AVPacket *pkt, int type, int size) > > +{ > > +void *new_ptr; > > +if ((unsigned)size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) > > +return -1; > > return AVERROR(EINVAL); see above av_grow_packet() > > +new_ptr = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); > > +if (!new_ptr) > > +return AVERROR(ENOMEM); > > +pkt->side_data = new_ptr; > > What's the point of new_ptr, you can malloc into pkt->side_data directly copy-paste effect, will be fixed > > +pkt->side_data_size = size; > > +pkt->side_data_type = type; > > +memset(pkt->side_data + pkt->side_data_size, 0, > > FF_INPUT_BUFFER_PADDING_SIZE); > > +return 0; > > +} > > + > > int av_dup_packet(AVPacket *pkt) > > { > > if (((pkt->destruct == av_destruct_packet_nofree) || (pkt->destruct == > > NULL)) && pkt->data) { > > @@ -96,6 +123,9 @@ int av_dup_packet(AVPacket *pkt) > > /* We duplicate the packet and don't forget to add the padding > > again. */ > >
Re: [libav-devel] [PATCH 1/3] introduce side information in AVPacket
On Fri, Apr 08, 2011 at 01:29:10PM +0200, Diego Biurrun wrote: > On Thu, Apr 07, 2011 at 10:28:25AM +0200, Kostya wrote: > > > > --- a/libavcodec/avcodec.h > > +++ b/libavcodec/avcodec.h > > @@ -1089,6 +1097,9 @@ typedef struct AVPacket { > > > > +#define AV_PKT_DATA_NONE 0 ///< no packet side information > > +#define AV_PKT_DATA_PAL 1 ///< packet side information contains new > > palette > > I keep thinking of PAL the TV standard - maybe you could type a few > extra chars and call this AV_PKT_DATA_PALETTE? Since I come from non-French SECAMland I don't have such associations but here you are. >From 5375c044115562b9601cc4f2fbbb3c931397c90c 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..2e1757a 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 the 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_NONE0 ///< no packet side information +#define AV_PKT_DATA_PALETTE 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; +pkt->side_data_size = 0; +pkt->side_data_type = AV_PKT_DATA_NONE; } void av_init_packet(AVPacket *pkt) @@ -44,6 +50,9 @@ void av_init_packet(AVPacket *pkt) pkt->flags = 0; pkt->stream_index = 0; pkt->destruct= NULL; +pkt->side_data = NULL; +pkt->side_data_size = 0; +pkt->side_data_type = AV_PKT_DATA_NONE; } int av_new_packet(AVPacket *pkt, int size) @@ -59,6 +68,9 @@ int av_new_packet(AVPacket *pkt, int size) av_init_packet(pkt); pkt->data = data; pkt->size = size; +pkt->side_data = NULL; +pkt->side_data_size = 0; +pkt->side_data_type = AV_PKT_DATA_NONE; pkt->destruct = av_destruct_packet; if(!data) return AVERROR(ENOMEM); @@ -89,6 +101,21 @@ int av_grow_packet(AVPacket *pkt, int grow_by) return 0; } +int av_packet_new_side_data(AVPacket *pkt, int type, int size) +{ +void *new_ptr; +if ((unsigned)size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) +return -1; +new_ptr = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); +if (!new_ptr) +return AVERROR(ENOMEM); +pkt->side_data = new_ptr; +pkt->side_data_size = size; +pkt->side_data_type = type; +memset(pkt->side_data + pkt->side_data_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); +return 0; +} + int av_dup_packet(AVPacket *pkt) { if (((pkt->destruct == av_destruct_packet_nofree) || (pkt->destruct == NULL)) && pkt->data) { @@ -96,6 +123,9 @@ int av_dup_packet(AVPacket *pkt) /* We duplicate the packet and don't forget to add the padding again. */ if((unsigned)pkt->size > (unsigned)pkt->size + FF_INPUT_BUFFER_PADDING_SIZE) return AVERROR(ENOMEM); +if((unsigned)pkt->side_data_size > + (unsigned)pkt->side_data_size + FF_INPUT_BUFFER_PADDING_SIZE) +return AVERROR(ENOMEM); data = av_malloc(pkt->size + FF_INPUT_BUFFER_PADDING_SIZE); if (!data) { return AVERROR(ENOMEM); @@ -103,6 +133,15 @@ int av_dup_packet(AVPacket *pkt) memcpy(da
Re: [libav-devel] [PATCH 1/3] introduce side information in AVPacket
On Thu, Apr 07, 2011 at 10:28:25AM +0200, Kostya wrote: > 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 nit: I don't think it makes much sense to #define this. > +#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; av_freep > +pkt->side_data_size = 0; > +pkt->side_data_type = AV_PKT_DATA_NONE; > } > > void av_init_packet(AVPacket *pkt) > @@ -44,6 +50,9 @@ void av_init_packet(AVPacket *pkt) > pkt->flags = 0; > pkt->stream_index = 0; > pkt->destruct= NULL; > +pkt->side_data = NULL; > +pkt->side_data_size = 0; > +pkt->side_data_type = AV_PKT_DATA_NONE; > } > > int av_new_packet(AVPacket *pkt, int size) > @@ -59,6 +68,9 @@ int av_new_packet(AVPacket *pkt, int size) > av_init_packet(pkt); > pkt->data = data; > pkt->size = size; > +pkt->side_data = NULL; > +pkt->side_data_size = 0; > +pkt->side_data_type = AV_PKT_DATA_NONE; that's already done in av_init_packet() > pkt->destruct = av_destruct_packet; > if(!data) > return AVERROR(ENOMEM); > @@ -89,6 +101,21 @@ int av_grow_packet(AVPacket *pkt, int grow_by) > return 0; > } > > +int av_packet_new_side_data(AVPacket *pkt, int type, int size) > +{ > +void *new_ptr; > +if ((unsigned)size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) > +return -1; return AVERROR(EINVAL); > +new_ptr = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); > +if (!new_ptr) > +return AVERROR(ENOMEM); > +pkt->side_data = new_ptr; What's the point of new_ptr, you can malloc into pkt->side_data directly > +pkt->side_data_size = size; > +pkt->side_data_type = type; > +memset(pkt->side_data + pkt->side_data_size, 0, > FF_INPUT_BUFFER_PADDING_SIZE); > +return 0; > +} > + > int av_dup_packet(AVPacket *pkt) > { > if (((pkt->destruct == av_destruct_packet_nofree) || (pkt->destruct == > NULL)) && pkt->data) { > @@ -96,6 +123,9 @@ int av_dup_packet(AVPacket *pkt) > /* We duplicate the packet and don't forget to add the padding > again. */ > if((unsigned)pkt->size > (unsigned)pkt->size + > FF_INPUT_BUFFER_PADDING_SIZE) > return AVERROR(ENOMEM); > +if((unsigned)pkt->side_data_size > > + (unsigned)pkt->side_data_size + FF_INPUT_BUFFER_PADDING_SIZE) > +return AVERROR(ENOMEM); AVERROR(EINVAL) would be better IMO. > data = av_malloc(pkt->size + FF_INPUT_BUFFER_PADDING_SIZE); > if (!data) { > return AVERROR(ENOMEM); > @@ -103,6 +133,15 @@ int av_dup_packet(AVPacket *pkt) > memcpy(data, pkt->data, pkt->size); >
Re: [libav-devel] [PATCH 3/5] lavf: get rid of ffm-specific stuff in avformat.h
Hi, On Fri, Apr 8, 2011 at 5:48 AM, Anton Khirnov wrote: > --- > ffmpeg.c | 2 ++ > ffserver.c | 1 + > libavformat/avformat.h | 6 -- > libavformat/ffm.h | 5 + > 4 files changed, 8 insertions(+), 6 deletions(-) > > diff --git a/ffmpeg.c b/ffmpeg.c > index 83e77dd..749c9c7 100644 > --- a/ffmpeg.c > +++ b/ffmpeg.c > @@ -110,6 +110,8 @@ static const OptionDef options[]; > #define MAX_STREAMS 1024 /* arbitrary sanity check value */ > #endif > > +#define FFM_PACKET_SIZE 4096 > + > static const char *last_asked_format = NULL; > static AVFormatContext *input_files[MAX_FILES]; > static int64_t input_files_ts_offset[MAX_FILES]; Hacking ffserver is one thing, but this goes a little far. How about we make this a private AVOption? What is the exact use-case here? Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [rfc] Protocol API
On date Friday 2011-04-08 02:52:13 +0300, aviad rozenhek wrote: > 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 +1 (and having the struct public allows to implement a custom protocol). But, if it there is the need to keep the struct private at least when it is "cleaned up", you can: 1) keep the header public but declare that the API is not considered stable and there is no guarantee of backward compatibility (similar to what is done with lavfi) 2) keep the header private while the API is reworked With 1) you still have the possibility to use that API in a custom application, without the need of brittle hacks (like copying into the application). ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/5] lavf: mark av_pkt_dump(_log) for remove on $next+1 bump.
Hi, On Fri, Apr 8, 2011 at 5:48 AM, Anton Khirnov wrote: > --- > libavformat/avformat.h | 4 +++- > libavformat/utils.c | 4 > libavformat/version.h | 3 +++ > 3 files changed, 10 insertions(+), 1 deletions(-) Any reason we don't want to remove it at the next one already, going by the evil "release, bump, release again" plan? But that is not so relevant, the functions are small, so patch OK. Ronald ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/2] avio: make URLContext internal.
Hi, On Fri, Apr 8, 2011 at 1:22 AM, Anton Khirnov wrote: > --- > 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(-) Loos OK, assuming it's been tested to compile and not give new warnings when the bump is done. Ronald ___ 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)
On 4/8/11 12:58 PM, Clément Bœsch wrote: On Thu, Apr 07, 2011 at 10:32:23AM +0200, Luca Barbato wrote: 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. Let me know what I could/should/have to test for this to get approved. It works here with my webradio, and with ogg with multiple audio channels. Of course, it's certainly not enough to assert it does not break anything. I'd push it this night or tomorrow night. lu ___ 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
On Thu, Apr 07, 2011 at 10:28:25AM +0200, Kostya wrote: > > --- a/libavcodec/avcodec.h > +++ b/libavcodec/avcodec.h > @@ -1089,6 +1097,9 @@ typedef struct AVPacket { > > +#define AV_PKT_DATA_NONE 0 ///< no packet side information > +#define AV_PKT_DATA_PAL 1 ///< packet side information contains new palette I keep thinking of PAL the TV standard - maybe you could type a few extra chars and call this AV_PKT_DATA_PALETTE? Diego ___ 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)
On Thu, Apr 07, 2011 at 10:32:23AM +0200, Luca Barbato wrote: > 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. > Let me know what I could/should/have to test for this to get approved. It works here with my webradio, and with ogg with multiple audio channels. Of course, it's certainly not enough to assert it does not break anything. -- Clément B. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/2] lavf: rename avf_sdp_create to av_sdp_create.
On Fri, Apr 08, 2011 at 12:24:34PM +0200, Anton Khirnov wrote: > The new name is more consistent with the rest of the API. OK Diego ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 2/2] lavf: rename a parameter of av_sdp_create from buff->buf
On Fri, Apr 08, 2011 at 12:24:35PM +0200, Anton Khirnov wrote: > This is more consistent with the rest of the API. OK Diego ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] Experimental DCA encoder
On Fri, Apr 08, 2011 at 01:41:37AM +0200, Benjamin Larsson wrote: > [...] Please make sure this compiles with --disable-everything --enable-encoder=dca. Diego ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/2] lavf: rename a parameter of av_sdp_create from buff->buf
This is more consistent with the rest of the API. --- libavformat/avformat.h |6 +++--- libavformat/sdp.c | 12 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 42020de..5c8456f 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1547,12 +1547,12 @@ int av_filename_number_test(const char *filename); * all the contexts in the array (an AVCodecContext per RTP stream) * must contain only one AVStream. * @param n_files number of AVCodecContexts contained in ac - * @param buff buffer where the SDP will be stored (must be allocated by - * the caller) + * @param buf buffer where the SDP will be stored (must be allocated by + *the caller) * @param size the size of the buffer * @return 0 if OK, AVERROR_xxx on error */ -int av_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size); +int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size); #if FF_API_SDP_CREATE attribute_deprecated int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size); diff --git a/libavformat/sdp.c b/libavformat/sdp.c index 0e46c33..005434c 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -474,14 +474,14 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des sdp_write_media_attributes(buff, size, c, payload_type); } -int av_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) +int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size) { AVMetadataTag *title = av_metadata_get(ac[0]->metadata, "title", NULL, 0); struct sdp_session_level s; int i, j, port, ttl, is_multicast; char dst[32], dst_type[5]; -memset(buff, 0, size); +memset(buf, 0, size); memset(&s, 0, sizeof(struct sdp_session_level)); s.user = "-"; s.src_addr = "127.0.0.1";/* FIXME: Properly set this */ @@ -506,7 +506,7 @@ int av_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) } } } -sdp_write_header(buff, size, &s); +sdp_write_header(buf, size, &s); dst[0] = 0; for (i = 0; i < n_files; i++) { @@ -518,11 +518,11 @@ int av_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) ttl = 0; } for (j = 0; j < ac[i]->nb_streams; j++) { -ff_sdp_write_media(buff, size, +ff_sdp_write_media(buf, size, ac[i]->streams[j]->codec, dst[0] ? dst : NULL, dst_type, (port > 0) ? port + j * 2 : 0, ttl); if (port <= 0) { -av_strlcatf(buff, size, +av_strlcatf(buf, size, "a=control:streamid=%d\r\n", i + j); } } @@ -531,7 +531,7 @@ int av_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) return 0; } #else -int av_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) +int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size) { return AVERROR(ENOSYS); } -- 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] lavf: rename avf_sdp_create to av_sdp_create.
The new name is more consistent with the rest of the API. --- ffmpeg.c |2 +- ffserver.c |2 +- libavformat/avformat.h |6 +- libavformat/rtspenc.c |2 +- libavformat/sapenc.c |2 +- libavformat/sdp.c | 11 +-- libavformat/version.h |3 +++ 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 749c9c7..4f2818b 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1799,7 +1799,7 @@ static void print_sdp(AVFormatContext **avc, int n) { char sdp[2048]; -avf_sdp_create(avc, n, sdp, sizeof(sdp)); +av_sdp_create(avc, n, sdp, sizeof(sdp)); printf("SDP:\n%s\n", sdp); fflush(stdout); } diff --git a/ffserver.c b/ffserver.c index 5c1ab0d..36cd9ce 100644 --- a/ffserver.c +++ b/ffserver.c @@ -2958,7 +2958,7 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, avc->streams[i]->codec = stream->streams[i]->codec; } *pbuffer = av_mallocz(2048); -avf_sdp_create(&avc, 1, *pbuffer, 2048); +av_sdp_create(&avc, 1, *pbuffer, 2048); sdp_done: #if !FF_API_MAX_STREAMS diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 0b50e92..42020de 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1552,7 +1552,11 @@ int av_filename_number_test(const char *filename); * @param size the size of the buffer * @return 0 if OK, AVERROR_xxx on error */ -int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size); +int av_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size); + +#if FF_API_SDP_CREATE +attribute_deprecated int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size); +#endif /** * Return a positive value if the given filename has one of the given diff --git a/libavformat/rtspenc.c b/libavformat/rtspenc.c index 684f2fe..c1fc97c 100644 --- a/libavformat/rtspenc.c +++ b/libavformat/rtspenc.c @@ -66,7 +66,7 @@ int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr) ff_url_join(sdp_ctx.filename, sizeof(sdp_ctx.filename), "rtsp", NULL, addr, -1, NULL); ctx_array[0] = &sdp_ctx; -if (avf_sdp_create(ctx_array, 1, sdp, SDP_MAX_SIZE)) { +if (av_sdp_create(ctx_array, 1, sdp, SDP_MAX_SIZE)) { av_free(sdp); return AVERROR_INVALIDDATA; } diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index e675986..455e653 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -208,7 +208,7 @@ static int sap_write_header(AVFormatContext *s) av_strlcpy(&sap->ann[pos], "application/sdp", sap->ann_size - pos); pos += strlen(&sap->ann[pos]) + 1; -if (avf_sdp_create(contexts, s->nb_streams, &sap->ann[pos], +if (av_sdp_create(contexts, s->nb_streams, &sap->ann[pos], sap->ann_size - pos)) { ret = AVERROR_INVALIDDATA; goto fail; diff --git a/libavformat/sdp.c b/libavformat/sdp.c index 02af7dc..0e46c33 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -474,7 +474,7 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des sdp_write_media_attributes(buff, size, c, payload_type); } -int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) +int av_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) { AVMetadataTag *title = av_metadata_get(ac[0]->metadata, "title", NULL, 0); struct sdp_session_level s; @@ -531,7 +531,7 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) return 0; } #else -int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) +int av_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) { return AVERROR(ENOSYS); } @@ -540,3 +540,10 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des { } #endif + +#if FF_API_SDP_CREATE +int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) +{ +return av_sdp_create(ac, n_files, buff, size); +} +#endif diff --git a/libavformat/version.h b/libavformat/version.h index cfe1f82..552a1bd 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -107,5 +107,8 @@ #ifndef FF_API_GUESS_IMG2_CODEC #define FF_API_GUESS_IMG2_CODEC(LIBAVFORMAT_VERSION_MAJOR < 54) #endif +#ifndef FF_API_SDP_CREATE +#define FF_API_SDP_CREATE (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif #endif //AVFORMAT_VERSION_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 4/5] lavf: rename avf_sdp_create to av_sdp_create.
On Fri, Apr 08, 2011 at 11:48:38AM +0200, Anton Khirnov wrote: > The new name is more consistent with the rest of the API. Also rename > its parameter from buff->buf, which is also more consistent. Push the parameter name change right away, separate from the rest. Diego ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] Experimental DCA encoder
On Fri, Apr 08, 2011 at 01:41:37AM +0200, Benjamin Larsson wrote: > > --- > libavcodec/Makefile|1 + > libavcodec/allcodecs.c |2 +- > libavcodec/dcaenc.c| 581 > > libavcodec/dcaenc.h| 544 + > 4 files changed, 1127 insertions(+), 1 deletions(-) changelog, docs update, minor bump > --- /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 That still contains some FFmpeg references, please fix. > +static void add_new_samples(DCAContext *c, const int32_t *in, int count, int > channel){ { on next line, long line > +static void qmf_decompose(DCAContext *c, int32_t in[32], int32_t out[32], > int channel) long line > +int band, i, j, k; > +int32_t resp; > +int32_t accum[DCA_SUBBANDS_32]; > + > +memset(accum,0,sizeof(accum)); Just initialize to 0 > +static int32_t lfe_fir_64i[512]; > +static int lfe_downsample(DCAContext *c, int32_t in[LFE_INTERPOLATION]){ { on next line > +static void init_lfe_fir(void){ ditto > +static int initialized; > +int i; > +if(initialized) if ( > +for(i=0; i<512; i++) for ( .. and please give those operators some room to breathe .. > +static void put_primary_audio_header(DCAContext *c) > +{ > +/* From dca.c */ > +static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 }; > +static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 }; That comment makes me suspicious - are these duplicated? > +/* Subband activity count */ > +for (ch=0; chprim_channels; ch++) { > + > +/* High frequency VQ start subband */ > +for (ch=0; chprim_channels; ch++) { > + > +/* Joint intensity coding index: 0, 0 */ > +for (ch=0; chprim_channels; ch++) { > + > +/* Transient mode codebook: A4, A4 (arbitrary) */ > +for (ch=0; chprim_channels; ch++) { > + > +/* Scale factor code book: 7 bit linear, 7-bit sqrt table (for each > channel) */ > +for (ch=0; chprim_channels; ch++) { > + > +/* Bit allocation quantizer select: linear 5-bit */ > +for (ch=0; chprim_channels; ch++) { > + > +/* Quantization index codebook select: dummy data > + to avoid transmission of scale factor adjustment */ > +for (i=1; i<11; i++) { > +for (ch=0; chprim_channels; ch++) { .. more operators in need of elbow room .. :) There are more instances below, same for 'if(' and 'for(', { on the wrong line and excessively long lines that could be shortened easily. Fixing would be appreciated. You could also drop (or not) some {} around if/for blocks. > +/** > + * 8-23 bits quantization > + * @param sample > + * @param bits > + */ > +static inline uint32_t quantize(int32_t sample, int bits) These Doxygen parameter comments are pretty useless. > +switch(avctx->channel_layout) { > + case AV_CH_LAYOUT_STEREO: c->a_mode = 2; c->num_channel = 2; break; switch ( > + case AV_CH_LAYOUT_5POINT0: c->a_mode = 9; c->num_channel = 9; break; > + case AV_CH_LAYOUT_5POINT1: c->a_mode = 9; c->num_channel = 9; break; > + case AV_CH_LAYOUT_5POINT0_BACK: c->a_mode = 9; c->num_channel = 9; > break; > + case AV_CH_LAYOUT_5POINT1_BACK: c->a_mode = 9; c->num_channel = 9; > break; > + default: > +av_log(avctx, AV_LOG_ERROR, "Only stereo, 5.1, 5.0, 5.0back and > 5.0front channel layouts supported at the moment!\n"); > +return AVERROR_PATCHWELCOME; > +} Indent the case statements at the same depth as the switch and fix that instance of 2-space indentation. > +AVCodec ff_dca_encoder = { > +.name = "dca", > +.type = CODEC_TYPE_AUDIO, > +.id = CODEC_ID_DTS, > +.priv_data_size = sizeof(DCAContext), > +.init = DCA_encode_init, > +.encode = DCA_encode_frame, > +.capabilities = CODEC_CAP_EXPERIMENTAL, > +.sample_fmts = (const enum > AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, > +NULL, > +NULL, > +}; pointless trailing NULLs, long_name missing > --- /dev/null > +++ b
[libav-devel] [PATCH 3/5] lavf: get rid of ffm-specific stuff in avformat.h
--- ffmpeg.c |2 ++ ffserver.c |1 + libavformat/avformat.h |6 -- libavformat/ffm.h |5 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 83e77dd..749c9c7 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -110,6 +110,8 @@ static const OptionDef options[]; #define MAX_STREAMS 1024/* arbitrary sanity check value */ #endif +#define FFM_PACKET_SIZE 4096 + static const char *last_asked_format = NULL; static AVFormatContext *input_files[MAX_FILES]; static int64_t input_files_ts_offset[MAX_FILES]; diff --git a/ffserver.c b/ffserver.c index 259aaca..5c1ab0d 100644 --- a/ffserver.c +++ b/ffserver.c @@ -29,6 +29,7 @@ #include #include #include "libavformat/avformat.h" +#include "libavformat/ffm.h" #include "libavformat/network.h" #include "libavformat/os_support.h" #include "libavformat/rtpdec.h" diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 37ec8a9..0b50e92 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1508,12 +1508,6 @@ int64_t parse_date(const char *datestr, int duration); */ int64_t av_gettime(void); -/* ffm-specific for ffserver */ -#define FFM_PACKET_SIZE 4096 -int64_t ffm_read_write_index(int fd); -int ffm_write_write_index(int fd, int64_t pos); -void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size); - #if FF_API_FIND_INFO_TAG /** * @deprecated use av_find_info_tag in libavutil instead. diff --git a/libavformat/ffm.h b/libavformat/ffm.h index 4c088d6..89a14a5 100644 --- a/libavformat/ffm.h +++ b/libavformat/ffm.h @@ -28,6 +28,7 @@ /* The FFM file is made of blocks of fixed size */ #define FFM_HEADER_SIZE 14 +#define FFM_PACKET_SIZE 4096 #define PACKET_ID 0x666d /* each packet contains frames (which can span several packets */ @@ -55,4 +56,8 @@ typedef struct FFMContext { uint8_t packet[FFM_PACKET_SIZE]; } FFMContext; +int64_t ffm_read_write_index(int fd); +int ffm_write_write_index(int fd, int64_t pos); +void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size); + #endif /* AVFORMAT_FFM_H */ -- 1.7.4.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 1/5] lavf: mark av_pkt_dump(_log) for remove on $next+1 bump.
--- libavformat/avformat.h |4 +++- libavformat/utils.c|4 libavformat/version.h |3 +++ 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 61babdc..6b1b2b4 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -978,7 +978,6 @@ void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size); */ void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st); -attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); /** * Send a nice dump of a packet to the log. @@ -994,7 +993,10 @@ attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, AVStream *st); +#if FF_API_PKT_DUMP +attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, +#endif int dump_payload); /** diff --git a/libavformat/utils.c b/libavformat/utils.c index da8f3fd..ca582b3 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3545,22 +3545,26 @@ static void pkt_dump_internal(void *avcl, FILE *f, int level, AVPacket *pkt, int av_hex_dump(f, pkt->data, pkt->size); } +#if FF_API_PKT_DUMP void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload) { AVRational tb = { 1, AV_TIME_BASE }; pkt_dump_internal(NULL, f, 0, pkt, dump_payload, tb); } +#endif void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st) { pkt_dump_internal(NULL, f, 0, pkt, dump_payload, st->time_base); } +#if FF_API_PKT_DUMP void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload) { AVRational tb = { 1, AV_TIME_BASE }; pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, tb); } +#endif void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, AVStream *st) diff --git a/libavformat/version.h b/libavformat/version.h index 58ef4b8..512195e 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -101,5 +101,8 @@ #ifndef FF_API_FIND_INFO_TAG #define FF_API_FIND_INFO_TAG (LIBAVFORMAT_VERSION_MAJOR < 54) #endif +#ifndef FF_API_PKT_DUMP +#define FF_API_PKT_DUMP(LIBAVFORMAT_VERSION_MAJOR < 54) +#endif #endif //AVFORMAT_VERSION_H -- 1.7.4.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 4/5] lavf: rename avf_sdp_create to av_sdp_create.
The new name is more consistent with the rest of the API. Also rename its parameter from buff->buf, which is also more consistent. --- ffmpeg.c |2 +- ffserver.c |2 +- libavformat/avformat.h | 10 +++--- libavformat/rtspenc.c |2 +- libavformat/sapenc.c |2 +- libavformat/sdp.c | 19 +-- libavformat/version.h |3 +++ 7 files changed, 27 insertions(+), 13 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 749c9c7..4f2818b 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1799,7 +1799,7 @@ static void print_sdp(AVFormatContext **avc, int n) { char sdp[2048]; -avf_sdp_create(avc, n, sdp, sizeof(sdp)); +av_sdp_create(avc, n, sdp, sizeof(sdp)); printf("SDP:\n%s\n", sdp); fflush(stdout); } diff --git a/ffserver.c b/ffserver.c index 5c1ab0d..36cd9ce 100644 --- a/ffserver.c +++ b/ffserver.c @@ -2958,7 +2958,7 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, avc->streams[i]->codec = stream->streams[i]->codec; } *pbuffer = av_mallocz(2048); -avf_sdp_create(&avc, 1, *pbuffer, 2048); +av_sdp_create(&avc, 1, *pbuffer, 2048); sdp_done: #if !FF_API_MAX_STREAMS diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 0b50e92..5c8456f 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1547,12 +1547,16 @@ int av_filename_number_test(const char *filename); * all the contexts in the array (an AVCodecContext per RTP stream) * must contain only one AVStream. * @param n_files number of AVCodecContexts contained in ac - * @param buff buffer where the SDP will be stored (must be allocated by - * the caller) + * @param buf buffer where the SDP will be stored (must be allocated by + *the caller) * @param size the size of the buffer * @return 0 if OK, AVERROR_xxx on error */ -int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size); +int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size); + +#if FF_API_SDP_CREATE +attribute_deprecated int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size); +#endif /** * Return a positive value if the given filename has one of the given diff --git a/libavformat/rtspenc.c b/libavformat/rtspenc.c index 684f2fe..c1fc97c 100644 --- a/libavformat/rtspenc.c +++ b/libavformat/rtspenc.c @@ -66,7 +66,7 @@ int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr) ff_url_join(sdp_ctx.filename, sizeof(sdp_ctx.filename), "rtsp", NULL, addr, -1, NULL); ctx_array[0] = &sdp_ctx; -if (avf_sdp_create(ctx_array, 1, sdp, SDP_MAX_SIZE)) { +if (av_sdp_create(ctx_array, 1, sdp, SDP_MAX_SIZE)) { av_free(sdp); return AVERROR_INVALIDDATA; } diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index e675986..455e653 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -208,7 +208,7 @@ static int sap_write_header(AVFormatContext *s) av_strlcpy(&sap->ann[pos], "application/sdp", sap->ann_size - pos); pos += strlen(&sap->ann[pos]) + 1; -if (avf_sdp_create(contexts, s->nb_streams, &sap->ann[pos], +if (av_sdp_create(contexts, s->nb_streams, &sap->ann[pos], sap->ann_size - pos)) { ret = AVERROR_INVALIDDATA; goto fail; diff --git a/libavformat/sdp.c b/libavformat/sdp.c index 02af7dc..005434c 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -474,14 +474,14 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des sdp_write_media_attributes(buff, size, c, payload_type); } -int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) +int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size) { AVMetadataTag *title = av_metadata_get(ac[0]->metadata, "title", NULL, 0); struct sdp_session_level s; int i, j, port, ttl, is_multicast; char dst[32], dst_type[5]; -memset(buff, 0, size); +memset(buf, 0, size); memset(&s, 0, sizeof(struct sdp_session_level)); s.user = "-"; s.src_addr = "127.0.0.1";/* FIXME: Properly set this */ @@ -506,7 +506,7 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) } } } -sdp_write_header(buff, size, &s); +sdp_write_header(buf, size, &s); dst[0] = 0; for (i = 0; i < n_files; i++) { @@ -518,11 +518,11 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) ttl = 0; } for (j = 0; j < ac[i]->nb_streams; j++) { -ff_sdp_write_media(buff, size, +ff_sdp_write_media(buf, size, ac[i]->streams[j]->codec, dst[0] ? dst : NULL, dst_type, (port > 0) ? port + j * 2 : 0, ttl); if (port <= 0) { -av_st
[libav-devel] [PATCH 5/5] lavf: bump minor and add an APIChanges entry for avformat cleanup
--- doc/APIchanges|5 + libavformat/version.h |2 +- 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 6f69e05..105c1f3 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -12,6 +12,11 @@ libavutil: 2009-03-08 API changes, most recent first: +2011-04-xx - lavf 52.106.0 - avformat.h + Minor avformat cleanup: +xx deprecate av_guess_image2_codec +xx rename avf_sdp_create->av_sdp_create + 2011-04-03 - lavf 52.105.0 - avio.h Large-scale renaming/deprecating of AVIOContext-related functions: 724f6a0 deprecate url_fdopen diff --git a/libavformat/version.h b/libavformat/version.h index 552a1bd..a29c2c6 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -24,7 +24,7 @@ #include "libavutil/avutil.h" #define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 105 +#define LIBAVFORMAT_VERSION_MINOR 106 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ -- 1.7.4.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/5] lavf: make av_guess_image2_codec internal
It doesn't look very useful as a public function. --- libavformat/avformat.h |4 +++- libavformat/img2.c |8 libavformat/internal.h |2 ++ libavformat/utils.c|4 ++-- libavformat/version.h |3 +++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 6b1b2b4..37ec8a9 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -899,7 +899,9 @@ AVInputFormat *av_iformat_next(AVInputFormat *f); */ AVOutputFormat *av_oformat_next(AVOutputFormat *f); -enum CodecID av_guess_image2_codec(const char *filename); +#if FF_API_GUESS_IMG2_CODEC +attribute_deprecated enum CodecID av_guess_image2_codec(const char *filename); +#endif /* XXX: Use automatic init with either ELF sections or C file parser */ /* modules. */ diff --git a/libavformat/img2.c b/libavformat/img2.c index 59d9150..2b5d63b 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -24,6 +24,7 @@ #include "libavutil/avstring.h" #include "avformat.h" #include "avio_internal.h" +#include "internal.h" #include typedef struct { @@ -183,9 +184,16 @@ static int read_probe(AVProbeData *p) return 0; } +enum CodecID ff_guess_image2_codec(const char *filename) +{ +return av_str2id(img_tags, filename); +} + +#if FF_API_GUESS_IMG2_CODEC enum CodecID av_guess_image2_codec(const char *filename){ return av_str2id(img_tags, filename); } +#endif static int read_header(AVFormatContext *s1, AVFormatParameters *ap) { diff --git a/libavformat/internal.h b/libavformat/internal.h index 7528dae..9bc2340 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -250,4 +250,6 @@ void ff_reduce_index(AVFormatContext *s, int stream_index); void ff_make_absolute_url(char *buf, int size, const char *base, const char *rel); +enum CodecID ff_guess_image2_codec(const char *filename); + #endif /* AVFORMAT_INTERNAL_H */ diff --git a/libavformat/utils.c b/libavformat/utils.c index ca582b3..1d58682 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -218,7 +218,7 @@ AVOutputFormat *av_guess_format(const char *short_name, const char *filename, #if CONFIG_IMAGE2_MUXER if (!short_name && filename && av_filename_number_test(filename) && -av_guess_image2_codec(filename) != CODEC_ID_NONE) { +ff_guess_image2_codec(filename) != CODEC_ID_NONE) { return av_guess_format("image2", NULL, NULL); } #endif @@ -271,7 +271,7 @@ enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, #if CONFIG_IMAGE2_MUXER if(!strcmp(fmt->name, "image2") || !strcmp(fmt->name, "image2pipe")){ -codec_id= av_guess_image2_codec(filename); +codec_id= ff_guess_image2_codec(filename); } #endif if(codec_id == CODEC_ID_NONE) diff --git a/libavformat/version.h b/libavformat/version.h index 512195e..cfe1f82 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -104,5 +104,8 @@ #ifndef FF_API_PKT_DUMP #define FF_API_PKT_DUMP(LIBAVFORMAT_VERSION_MAJOR < 54) #endif +#ifndef FF_API_GUESS_IMG2_CODEC +#define FF_API_GUESS_IMG2_CODEC(LIBAVFORMAT_VERSION_MAJOR < 54) +#endif #endif //AVFORMAT_VERSION_H -- 1.7.4.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] minor avformat.h cleanup
Hi, with the following patches, avformat.h should be reasonably clean for the upcoming bump. Further cleanup suggestions welcome. -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] Experimental DCA encoder
On 04/08/2011 03:58 AM, Ronald S. Bultje wrote: > 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... Ok >> +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. Ok >> +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;ut >> +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.) The costable is custom. And there is a float based transform in the decoder already. >> +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? Decomposes the signal into bands. Time domain -> frequency domain. >> +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. Don't really know but I'd like to keep the fixed-point code path for reg test purposes. > 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? It's the same as with every other libav encoder. But I guess it could print all the 16 supported sample rates. >> 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? The decomposition filter. > Ronald MvH Benjamin Larsson ___ libav-devel mailing list libav-devel@libav.org https:
Re: [libav-devel] [PATCH] lavf: use designated initializers for all protocols
On 4/8/11 7:43 AM, Anton Khirnov wrote: 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(-) Ok ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] applehttp: don't use deprecated url_ functions.
On Fri, 8 Apr 2011, Anton Khirnov wrote: > --- > 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 OK // Martin ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel