From michaelni at gmx.at Fri Aug 1 00:22:24 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 1 Aug 2014 00:22:24 +0200 Subject: [FFmpeg-devel] [FATESERVER/PATCH] Update to new website style In-Reply-To: <20140731215559.GF4649@nb4> References: <1406758854-6675-1-git-send-email-timothygu99@gmail.com> <20140731195435.GD4649@nb4> <20140731215559.GF4649@nb4> Message-ID: <20140731222224.GG4649@nb4> On Thu, Jul 31, 2014 at 11:55:59PM +0200, Michael Niedermayer wrote: > On Thu, Jul 31, 2014 at 02:11:25PM -0700, Timothy Gu wrote: > > On Thu, Jul 31, 2014 at 12:54 PM, Michael Niedermayer wrote: > > > > > also light gray text on yellow/green is rather hard to read > > > > where? on index page yellow corresponds to black text color, while > > green corresponds to white. > > index, see attached > (was with firefox) > if you cant reproduce, then ill retry and restart firefox to make > sure it doest cache anything was a firefox cache issue applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From lou at lrcd.com Fri Aug 1 01:04:18 2014 From: lou at lrcd.com (Lou Logan) Date: Thu, 31 Jul 2014 15:04:18 -0800 Subject: [FFmpeg-devel] [PATCH] doc/indevs: mention required configure options Message-ID: <1406847858-8249-1-git-send-email-lou@lrcd.com> For x11grab, libcdio, and libdc1394 input devices. Signed-off-by: Lou Logan --- doc/indevs.texi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/indevs.texi b/doc/indevs.texi index e0e7e67..ce409b9 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -488,7 +488,8 @@ ffplay -f lavfi "movie=test.avi[out0];amovie=test.wav[out1]" Audio-CD input device based on cdio. To enable this input device during configuration you need libcdio -installed on your system. +installed on your system. Requires the configure option + at code{--enable-libcdio}. This device allows playing and grabbing from an Audio-CD. @@ -502,6 +503,8 @@ ffmpeg -f libcdio -i /dev/sr0 cd.wav IIDC1394 input device, based on libdc1394 and libraw1394. +Requires the configure option @code{--enable-libdc1394}. + @section openal The OpenAL input device provides audio capture on all systems with a @@ -830,6 +833,9 @@ other filename will be interpreted as device number 0. X11 video input device. +Depends on X11, Xext, and Xfixes. Requires the configure option + at code{--enable-x11grab}. + This device allows one to capture a region of an X11 display. The filename passed as input has the syntax: -- 2.0.2 From michaelni at gmx.at Fri Aug 1 01:42:55 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 1 Aug 2014 01:42:55 +0200 Subject: [FFmpeg-devel] [PATCH] doc/indevs: mention required configure options In-Reply-To: <1406847858-8249-1-git-send-email-lou@lrcd.com> References: <1406847858-8249-1-git-send-email-lou@lrcd.com> Message-ID: <20140731234255.GH4649@nb4> On Thu, Jul 31, 2014 at 03:04:18PM -0800, Lou Logan wrote: > For x11grab, libcdio, and libdc1394 input devices. > > Signed-off-by: Lou Logan > --- > doc/indevs.texi | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are too smart to engage in politics are punished by being governed by those who are dumber. -- Plato -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Fri Aug 1 01:54:14 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 1 Aug 2014 01:54:14 +0200 Subject: [FFmpeg-devel] [PATCH] h264_mp4toannexb_bsf: always set idr_sps_pps_seen when SPS/PPS is seen. In-Reply-To: <1406814051-10850-1-git-send-email-benoit.fouet@free.fr> References: <1406814051-10850-1-git-send-email-benoit.fouet@free.fr> Message-ID: <20140731235414.GI4649@nb4> On Thu, Jul 31, 2014 at 03:40:51PM +0200, Benoit Fouet wrote: > In order not to break a sequence like "SPS IDR SPS IDR", the boolean > telling that the SPS/PPS has been seen should always be set. > --- > libavcodec/h264_mp4toannexb_bsf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The educated differ from the uneducated as much as the living from the dead. -- Aristotle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From cehoyos at ag.or.at Fri Aug 1 01:54:57 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Fri, 1 Aug 2014 01:54:57 +0200 Subject: [FFmpeg-devel] [PATCH]Do not select a default subtitle output stream with incorrect subtitle type Message-ID: <201408010154.57991.cehoyos@ag.or.at> Hi! When transcoding an input file with subtitles to mkv, ffmpeg by default tries to encode the subtitles even if the input contains bitmap subtitles. Attached patch should fix this issue reported in ticket #3819 (and before iirc). This patch currently does not work correctly for teletext input streams because no properties are defined for teletext, I suspect it should be (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB). In any case, this corner-case should not affect this patch imo. Please review, Carl Eugen -------------- next part -------------- diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 2adefc5..6e12ab2 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -1869,8 +1869,16 @@ static int open_output_file(OptionsContext *o, const char *filename) if (!o->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || subtitle_codec_name)) { for (i = 0; i < nb_input_streams; i++) if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { - new_subtitle_stream(o, oc, i); - break; + if (subtitle_codec_name || + avcodec_find_encoder(oc->oformat->subtitle_codec) && + avcodec_descriptor_get(avcodec_find_encoder(oc->oformat->subtitle_codec)->id) && + avcodec_descriptor_get(input_streams[i]->st->codec->codec_id) && + avcodec_descriptor_get(avcodec_find_encoder(oc->oformat->subtitle_codec)->id)->props & + avcodec_descriptor_get(input_streams[i]->st->codec->codec_id)->props & + (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB)) { + new_subtitle_stream(o, oc, i); + break; + } } } /* do something with data? */ From lou at lrcd.com Fri Aug 1 01:57:47 2014 From: lou at lrcd.com (Lou Logan) Date: Thu, 31 Jul 2014 15:57:47 -0800 Subject: [FFmpeg-devel] [PATCH] doc/indevs: mention required configure options In-Reply-To: <20140731234255.GH4649@nb4> References: <1406847858-8249-1-git-send-email-lou@lrcd.com> <20140731234255.GH4649@nb4> Message-ID: <20140731155747.116f3bdb@lrcd.com> On Fri, 1 Aug 2014 01:42:55 +0200, Michael Niedermayer wrote: > LGTM Pushed. From cehoyos at ag.or.at Fri Aug 1 02:07:27 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Fri, 1 Aug 2014 00:07:27 +0000 (UTC) Subject: [FFmpeg-devel] =?utf-8?q?=5BPATCH_4/4=5D_lavfi/vf=5Ffps=3A_accept?= =?utf-8?q?_EOF_timestamp=2E?= References: <1406756689-27697-1-git-send-email-george@nsup.org> <1406756689-27697-4-git-send-email-george@nsup.org> Message-ID: Nicolas George nsup.org> writes: > This makes the FPS filter duplicate the last frame to take > its duration into account, exactly like the other ones. > > TODO find corresponding trac ticket(s). I didn't test but this may be ticket #2674. Carl Eugen From michaelni at gmx.at Fri Aug 1 03:16:31 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 1 Aug 2014 03:16:31 +0200 Subject: [FFmpeg-devel] FFmpeg and OPW Message-ID: <20140801011631.GJ4649@nb4> Hi all OPW (Outreach Program for Women) is twice per year (compared to google summer of code which is just once a year) FFmpeg can participate in the next round but we need to fund at least 1 intern/student (6250 USD) for that. OPW is not run by a large corporation with deep pockets. Thus my mail here, if you are/represent a company or know one who does and who uses and benefits from FFmpeg, and has the financial resources, please consider to donate or ask/forward this mail. Why should you donate? Well the money will be used to fund a intern working on and improving FFmpeg. (assuming there will be a intern who wants to work on FFmpeg in OPW) Maybe it will be a failure, maybe it will lead to some minor improvments in FFmpeg, maybe it will majorly improve FFmpeg. And maybe we gain a new long term contributor. And improvments in FFmpeg again benefit you as company or user of FFmpeg. Also if you donate 6250$ to OPW for ffmpeg you get your logo at https://gnome.org/opw/ Either way for FFmpeg to be part of the next OPW round we need at least 1 payment commitment of 6250 USD by the end of August at the latest Please keep opw at ffmpeg.org in CC if you have questions or want to donate. PS: there are 2 ways to donate, one is directly to OPW/Gnome, this way you get your logo at gnome.org/opw if you donate at least 6250USD or through https://co.clickandpledge.com/advanced/default.aspx?wid=56226 for smaller sums. PS2: in case we get more than 6250$, on our SPI (clickandpledge) account the additional funding may be used for future ffmpeg-OPW rounds or things similar in spirit to OPW and GSOC. Thanks! -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Everything should be made as simple as possible, but not simpler. -- Albert Einstein -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From u at pkh.me Fri Aug 1 10:04:17 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Fri, 1 Aug 2014 10:04:17 +0200 Subject: [FFmpeg-devel] [PATCH]Do not select a default subtitle output stream with incorrect subtitle type In-Reply-To: <201408010154.57991.cehoyos@ag.or.at> References: <201408010154.57991.cehoyos@ag.or.at> Message-ID: <20140801080417.GE10372@leki> On Fri, Aug 01, 2014 at 01:54:57AM +0200, Carl Eugen Hoyos wrote: > Hi! > > When transcoding an input file with subtitles to mkv, ffmpeg by default tries > to encode the subtitles even if the input contains bitmap subtitles. > Attached patch should fix this issue reported in ticket #3819 (and before > iirc). > > This patch currently does not work correctly for teletext input streams > because no properties are defined for teletext, I suspect it should be > (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB). In any case, this > corner-case should not affect this patch imo. > > Please review, Carl Eugen > diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c > index 2adefc5..6e12ab2 100644 > --- a/ffmpeg_opt.c > +++ b/ffmpeg_opt.c > @@ -1869,8 +1869,16 @@ static int open_output_file(OptionsContext *o, const char *filename) > if (!o->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || subtitle_codec_name)) { > for (i = 0; i < nb_input_streams; i++) > if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { > - new_subtitle_stream(o, oc, i); > - break; > + if (subtitle_codec_name || > + avcodec_find_encoder(oc->oformat->subtitle_codec) && > + avcodec_descriptor_get(avcodec_find_encoder(oc->oformat->subtitle_codec)->id) && > + avcodec_descriptor_get(input_streams[i]->st->codec->codec_id) && > + avcodec_descriptor_get(avcodec_find_encoder(oc->oformat->subtitle_codec)->id)->props & > + avcodec_descriptor_get(input_streams[i]->st->codec->codec_id)->props & You have a scope opened here, please use 2 intermediate const to store the 2 descriptor pointers, because it's currently unreadable. > + (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB)) { > + new_subtitle_stream(o, oc, i); > + break; > + } BTW, do we have an obvious warning nowadays if someone tries to map a bitmap sub to a text one? I believe it is in the same spirit of what that patch is trying to fix, so it should be included as part of it, or at least the same patchset. > } > } > /* do something with data? */ -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From danieloberhoff at gmail.com Fri Aug 1 12:10:50 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Fri, 1 Aug 2014 12:10:50 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <20140729074334.GB1420@leki> References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140729074334.GB1420@leki> Message-ID: <25526652-0D09-4303-9668-D9488BED4DA9@googlemail.com> Am 29.07.2014 um 09:43 schrieb Cl?ment B?sch : > On Tue, Jul 29, 2014 at 08:04:50AM +0200, Daniel Oberhoff wrote: >> Updated patch: ? >> +static av_cold int init(AVFilterContext *ctx) >> +{ >> + return 0; >> +} >> + >> +static av_cold void uninit(AVFilterContext *ctx) >> +{ >> +} >> + > > It doesn't work with NULL I suppose? What do you mean? This was copied pasted I think from rotate. All the other comments I just applied. Will send an updated patch today. From danieloberhoff at gmail.com Fri Aug 1 12:13:22 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Fri, 1 Aug 2014 12:13:22 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> Message-ID: Am 29.07.2014 um 09:54 schrieb Carl Eugen Hoyos : > Daniel Oberhoff gmail.com> writes: > >> OBJS-$(CONFIG_ZOOMPAN_FILTER) += vf_zoompan.o >> +OBJS-$(CONFIG_RECTIFICATION_FILTER) += vf_rectification.o > >> REGISTER_FILTER(ZOOMPAN, zoompan, vf); >> + REGISTER_FILTER(RECTIFICATION, rectification, vf); > > Keep the alphabetic ordering please. > Ok >> + AV_PIX_FMT_YUV410P, >> + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, >> + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, >> + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, >> + AV_PIX_FMT_NONE > > I have no idea what this filter does and since the > most important format (yuv420p) is supported, this > doesn't really matter but yuv410p and yuva444p are > quite exotic formats, I would at least have > expected yuv422p, yuva420p and yuv444p in the list. > > Did you test all above formats (at least the left row)? Added the one from your list that was missing. Can you suggest an easy way of testing all these formats? Best Daniel From u at pkh.me Fri Aug 1 12:19:02 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Fri, 1 Aug 2014 12:19:02 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <25526652-0D09-4303-9668-D9488BED4DA9@googlemail.com> References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140729074334.GB1420@leki> <25526652-0D09-4303-9668-D9488BED4DA9@googlemail.com> Message-ID: <20140801101902.GF10372@leki> On Fri, Aug 01, 2014 at 12:10:50PM +0200, Daniel Oberhoff wrote: > > Am 29.07.2014 um 09:43 schrieb Cl?ment B?sch : > > > On Tue, Jul 29, 2014 at 08:04:50AM +0200, Daniel Oberhoff wrote: > >> Updated patch: > > ? > > >> +static av_cold int init(AVFilterContext *ctx) > >> +{ > >> + return 0; > >> +} > >> + > >> +static av_cold void uninit(AVFilterContext *ctx) > >> +{ > >> +} > >> + > > > > It doesn't work with NULL I suppose? > > What do you mean? This was copied pasted I think from rotate. > I mean if you set init to NULL (or just don't set an init callback); I don't remember if the callback is mandatory. [...] -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From onemda at gmail.com Fri Aug 1 12:21:03 2014 From: onemda at gmail.com (Paul B Mahol) Date: Fri, 1 Aug 2014 12:21:03 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <20140801101902.GF10372@leki> References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140729074334.GB1420@leki> <25526652-0D09-4303-9668-D9488BED4DA9@googlemail.com> <20140801101902.GF10372@leki> Message-ID: On Fri, Aug 1, 2014 at 12:19 PM, Cl?ment B?sch wrote: > On Fri, Aug 01, 2014 at 12:10:50PM +0200, Daniel Oberhoff wrote: > > > > Am 29.07.2014 um 09:43 schrieb Cl?ment B?sch : > > > > > On Tue, Jul 29, 2014 at 08:04:50AM +0200, Daniel Oberhoff wrote: > > >> Updated patch: > > > > ? > > > > >> +static av_cold int init(AVFilterContext *ctx) > > >> +{ > > >> + return 0; > > >> +} > > >> + > > >> +static av_cold void uninit(AVFilterContext *ctx) > > >> +{ > > >> +} > > >> + > > > > > > It doesn't work with NULL I suppose? > > > > What do you mean? This was copied pasted I think from rotate. > > > > I mean if you set init to NULL (or just don't set an init callback); I > don't remember if the callback is mandatory. > > Init callback is not mandatory. From u at pkh.me Fri Aug 1 12:22:33 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Fri, 1 Aug 2014 12:22:33 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> Message-ID: <20140801102233.GG10372@leki> On Fri, Aug 01, 2014 at 12:13:22PM +0200, Daniel Oberhoff wrote: > > Am 29.07.2014 um 09:54 schrieb Carl Eugen Hoyos : > > > Daniel Oberhoff gmail.com> writes: > > > >> OBJS-$(CONFIG_ZOOMPAN_FILTER) += vf_zoompan.o > >> +OBJS-$(CONFIG_RECTIFICATION_FILTER) += vf_rectification.o > > > >> REGISTER_FILTER(ZOOMPAN, zoompan, vf); > >> + REGISTER_FILTER(RECTIFICATION, rectification, vf); > > > > Keep the alphabetic ordering please. > > > > Ok > > >> + AV_PIX_FMT_YUV410P, > >> + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, > >> + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, > >> + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, > >> + AV_PIX_FMT_NONE > > > > I have no idea what this filter does and since the > > most important format (yuv420p) is supported, this > > doesn't really matter but yuv410p and yuva444p are > > quite exotic formats, I would at least have > > expected yuv422p, yuva420p and yuv444p in the list. > > > > Did you test all above formats (at least the left row)? > > Added the one from your list that was missing. Can you suggest an easy way of testing all these formats? > add a format filter before yours in the filtergraph (-vf format=yuv410p,rectification ...) If you want to add a FATE test (which would be really awesome), you can grep for "video_filter" in tests/fate/filter-video.mak (to test all pixel formats the filter supports), or just make a standard test with framecrc. [...] -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From michaelni at gmx.at Fri Aug 1 12:35:19 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 1 Aug 2014 12:35:19 +0200 Subject: [FFmpeg-devel] [PATCH] h264_mp4toannexb_bsf: always set idr_sps_pps_seen when SPS/PPS is seen. In-Reply-To: <20140731235414.GI4649@nb4> References: <1406814051-10850-1-git-send-email-benoit.fouet@free.fr> <20140731235414.GI4649@nb4> Message-ID: <20140801103519.GK4649@nb4> On Fri, Aug 01, 2014 at 01:54:14AM +0200, Michael Niedermayer wrote: > On Thu, Jul 31, 2014 at 03:40:51PM +0200, Benoit Fouet wrote: > > In order not to break a sequence like "SPS IDR SPS IDR", the boolean > > telling that the SPS/PPS has been seen should always be set. > > --- > > libavcodec/h264_mp4toannexb_bsf.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > LGTM applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Fri Aug 1 12:35:40 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 1 Aug 2014 12:35:40 +0200 Subject: [FFmpeg-devel] [PATCH] h264: remove useless assignment. In-Reply-To: <1406809922-5214-1-git-send-email-benoit.fouet@free.fr> References: <1406809922-5214-1-git-send-email-benoit.fouet@free.fr> Message-ID: <20140801103540.GL4649@nb4> On Thu, Jul 31, 2014 at 02:32:02PM +0200, Benoit Fouet wrote: > source index, as well as dest one, is unconditionnaly set afterwards, > before being effectively used. > --- > libavcodec/h264.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/libavcodec/h264.c b/libavcodec/h264.c > index 10905db..8fa35c7 100644 > --- a/libavcodec/h264.c > +++ b/libavcodec/h264.c > @@ -296,7 +296,6 @@ const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, > // use second escape buffer for inter data > bufidx = h->nal_unit_type == NAL_DPC ? 1 : 0; > > - si = h->rbsp_buffer_size[bufidx]; > av_fast_padded_malloc(&h->rbsp_buffer[bufidx], &h->rbsp_buffer_size[bufidx], length+MAX_MBPAIR_SIZE); > dst = h->rbsp_buffer[bufidx]; applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Awnsering whenever a program halts or runs forever is On a turing machine, in general impossible (turings halting problem). On any real computer, always possible as a real computer has a finite number of states N, and will either halt in less than N cycles or never halt. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From danieloberhoff at gmail.com Fri Aug 1 12:56:42 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Fri, 1 Aug 2014 12:56:42 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <20140801102233.GG10372@leki> References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> Message-ID: Am 01.08.2014 um 12:22 schrieb Cl?ment B?sch : > On Fri, Aug 01, 2014 at 12:13:22PM +0200, Daniel Oberhoff wrote: >> >> Am 29.07.2014 um 09:54 schrieb Carl Eugen Hoyos : >> >>> Daniel Oberhoff gmail.com> writes: >>> >>>> OBJS-$(CONFIG_ZOOMPAN_FILTER) += vf_zoompan.o >>>> +OBJS-$(CONFIG_RECTIFICATION_FILTER) += vf_rectification.o >>> >>>> REGISTER_FILTER(ZOOMPAN, zoompan, vf); >>>> + REGISTER_FILTER(RECTIFICATION, rectification, vf); >>> >>> Keep the alphabetic ordering please. >>> >> >> Ok >> >>>> + AV_PIX_FMT_YUV410P, >>>> + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, >>>> + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, >>>> + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, >>>> + AV_PIX_FMT_NONE >>> >>> I have no idea what this filter does and since the >>> most important format (yuv420p) is supported, this >>> doesn't really matter but yuv410p and yuva444p are >>> quite exotic formats, I would at least have >>> expected yuv422p, yuva420p and yuv444p in the list. >>> >>> Did you test all above formats (at least the left row)? >> >> Added the one from your list that was missing. Can you suggest an easy way of testing all these formats? >> > > > add a format filter before yours in the filtergraph (-vf > format=yuv410p,rectification ?) Ok, borders can be a bitt different, but otherwise all work now, except vuy444p, which ffmpeg reports as invalid. btw, how can I get the components of a given color in the colorspace? > If you want to add a FATE test (which would be really awesome), you can > grep for "video_filter" in tests/fate/filter-video.mak (to test all pixel > formats the filter supports), or just make a standard test with framecrc. > > [...] I did that by adding this: FATE_FILTER_PIXFMTS-$(CONFIG_RECTIFICATION_FILTER) += fate-filter-pixfmts-rectification fate-filter-pixfmts-rectification: CMD = pixfmts "0.6:0.4:0.65:0.4" then I ran make fate-filter-pixfmts-rectification GEN=1 which made a file test/data/fate/filter-pixfmts-rectification.rep do I check this in or not? running make fate-filter-pixfmts-rectification GEN=1 runs fine? Best Daniel From cehoyos at ag.or.at Fri Aug 1 13:07:10 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Fri, 1 Aug 2014 11:07:10 +0000 (UTC) Subject: [FFmpeg-devel] rectification filter References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> Message-ID: Daniel Oberhoff gmail.com> writes: > all work now, except vuy444p It's yuv444p Carl Eugen From danieloberhoff at gmail.com Fri Aug 1 13:08:58 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Fri, 1 Aug 2014 13:08:58 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> Message-ID: <6A121A20-D5E4-4481-9737-4CA601560451@googlemail.com> Am 01.08.2014 um 13:07 schrieb Carl Eugen Hoyos : > Daniel Oberhoff gmail.com> writes: > >> all work now, except vuy444p > > It's yuv444p oops :). And how about that test/data/fate/filter-pixfmts-rectification.rep file? Should I commit that? Best From cehoyos at ag.or.at Fri Aug 1 14:45:54 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Fri, 1 Aug 2014 12:45:54 +0000 (UTC) Subject: [FFmpeg-devel] rectification filter References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> <6A121A20-D5E4-4481-9737-4CA601560451@googlemail.com> Message-ID: Daniel Oberhoff gmail.com> writes: > And how about that test/data/fate/filter-pixfmts-rectification.rep > file? Imo, please send a patch without fate test first, this can still be done. Did you already explain if / how this filter is different from / better than the vignette filter? Carl Eugen From benoit.fouet at free.fr Fri Aug 1 15:31:30 2014 From: benoit.fouet at free.fr (Benoit Fouet) Date: Fri, 1 Aug 2014 15:31:30 +0200 Subject: [FFmpeg-devel] [PATCH] h264_mp4toannexb_bsf: rename first_idr to new_idr Message-ID: <1406899890-10706-1-git-send-email-benoit.fouet@free.fr> --- libavcodec/h264_mp4toannexb_bsf.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index e0c1385..739ff95 100644 --- a/libavcodec/h264_mp4toannexb_bsf.c +++ b/libavcodec/h264_mp4toannexb_bsf.c @@ -27,7 +27,7 @@ typedef struct H264BSFContext { uint8_t length_size; - uint8_t first_idr; + uint8_t new_idr; uint8_t idr_sps_pps_seen; int extradata_parsed; } H264BSFContext; @@ -155,7 +155,7 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, if (ret < 0) return ret; ctx->length_size = ret; - ctx->first_idr = 1; + ctx->new_idr = 1; ctx->idr_sps_pps_seen = 0; ctx->extradata_parsed = 1; } @@ -182,22 +182,22 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, /* if this is a new IDR picture following an IDR picture, reset the idr flag. * Just check first_mb_in_slice to be 0 as this is the simplest solution. * This could be checking idr_pic_id instead, but would complexify the parsing. */ - if (!ctx->first_idr && unit_type == 5 && (buf[1] & 0x80)) - ctx->first_idr = 1; + if (!ctx->new_idr && unit_type == 5 && (buf[1] & 0x80)) + ctx->new_idr = 1; /* prepend only to the first type 5 NAL unit of an IDR picture, if no sps/pps are already present */ - if (ctx->first_idr && unit_type == 5 && !ctx->idr_sps_pps_seen) { + if (ctx->new_idr && unit_type == 5 && !ctx->idr_sps_pps_seen) { if ((ret=alloc_and_copy(poutbuf, poutbuf_size, avctx->extradata, avctx->extradata_size, buf, nal_size)) < 0) goto fail; - ctx->first_idr = 0; + ctx->new_idr = 0; } else { if ((ret=alloc_and_copy(poutbuf, poutbuf_size, NULL, 0, buf, nal_size)) < 0) goto fail; - if (!ctx->first_idr && unit_type == 1) { - ctx->first_idr = 1; + if (!ctx->new_idr && unit_type == 1) { + ctx->new_idr = 1; ctx->idr_sps_pps_seen = 0; } } -- 2.0.1.442.g7fe6834 From kierank at obe.tv Fri Aug 1 15:49:50 2014 From: kierank at obe.tv (Kieran Kunhya) Date: Fri, 1 Aug 2014 14:49:50 +0100 Subject: [FFmpeg-devel] [PATCH] Add support for Opus in MPEG-TS In-Reply-To: <20140731181354.GC4649@nb4> References: <20140728061836.29645.88322@daenerys.khirnov.net> <1406554914-6965-1-git-send-email-kierank@obe.tv> <20140731181354.GC4649@nb4> Message-ID: On 31 July 2014 19:13, Michael Niedermayer wrote: > On Mon, Jul 28, 2014 at 02:41:54PM +0100, Kieran Kunhya wrote: >> --- >> libavcodec/opus.c | 11 +--- >> libavcodec/opus.h | 9 +++ >> libavcodec/opus_parser.c | 138 +++++++++++++++++++++++++++++++++++++++++----- >> libavcodec/opusdec.c | 1 + >> libavformat/mpegts.c | 54 ++++++++++++++++++ >> 5 files changed, 192 insertions(+), 21 deletions(-) > > how can this be tested ? / do you have a sample ? I will probably make a sample of something. From nedeljko.babic at imgtec.com Fri Aug 1 15:53:06 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:06 +0200 Subject: [FFmpeg-devel] Implementation of fixed point AAC decoder Message-ID: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Few months ago I sent implementation of fixed point AAC decoder for review. Since it was sent in parallel with implementation of fixed point AC3 decoder, we decided to first finish the work on AC3 decoder and then to continue with AAC using experience gained from submission process for AC3. We also had some other responsibilities so submission of AAC was on hold. I am resubmitting implementation of fixed point AAC for review. We made changes requested in previous review and some additional changes so the code conforms more to FFmpegs coding rules. Code is rebased to the newest version. Please have a look. Thanks, -Nedeljko From nedeljko.babic at imgtec.com Fri Aug 1 15:53:11 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:11 +0200 Subject: [FFmpeg-devel] [PATCH 05/14] libavcodec: Implementation of AAC_fixed_decoder (LC-module) [5/5] In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-6-git-send-email-nedeljko.babic@imgtec.com> From: Jovan Zelincevic Build system modified Signed-off-by: Nedeljko Babic --- configure | 1 + libavcodec/Makefile | 16 +++++++++++++--- libavcodec/aacdec.c | 1 - libavcodec/aacdec_fixed.c | 1 - libavcodec/allcodecs.c | 1 + 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 9c3af50..0b3ff41 100755 --- a/configure +++ b/configure @@ -2028,6 +2028,7 @@ mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp" # decoders / encoders aac_decoder_select="mdct sinewin" +aac_fixed_decoder_select="mdct sinewin" aac_encoder_select="audio_frame_queue iirfilter mdct sinewin" aac_latm_decoder_select="aac_decoder aac_latm_parser" ac3_decoder_select="ac3_parser ac3dsp bswapdsp mdct" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 6fe05ee..3ce317d 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -23,7 +23,9 @@ OBJS = allcodecs.o \ codec_desc.o \ dv_profile.o \ fmtconvert.o \ + float_emu_tab.o \ imgconvert.o \ + log2_tab.o \ mathtables.o \ options.o \ parser.o \ @@ -91,6 +93,7 @@ RDFT-OBJS-$(CONFIG_HARDCODED_TABLES) += sin_tables.o OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes) OBJS-$(CONFIG_SHARED) += log2_tab.o OBJS-$(CONFIG_SINEWIN) += sinewin.o +OBJS-$(CONFIG_SINEWIN) += sinewin.o sinewin_fixed.o OBJS-$(CONFIG_TPELDSP) += tpeldsp.o OBJS-$(CONFIG_VAAPI) += vaapi.o OBJS-$(CONFIG_VDA) += vda.o @@ -105,6 +108,8 @@ OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \ aacadtsdec.o mpeg4audio.o kbdwin.o \ sbrdsp.o aacpsdsp.o +OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o \ + aacadtsdec.o mpeg4audio.o kbdwin.o OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \ aacpsy.o aactab.o \ psymodel.o mpeg4audio.o kbdwin.o @@ -870,6 +875,7 @@ TOOLS = fourcc2pixfmt HOSTPROGS = aac_tablegen \ aacps_tablegen \ cbrt_tablegen \ + cbrt_fixed_tablegen \ cos_tablegen \ dsd_tablegen \ dv_tablegen \ @@ -878,6 +884,7 @@ HOSTPROGS = aac_tablegen \ pcm_tablegen \ qdm2_tablegen \ sinewin_tablegen \ + sinewin_fixed_tablegen \ CLEANFILES = *_tables.c *_tables.h *_tablegen$(HOSTEXESUF) @@ -896,9 +903,9 @@ else $(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=0 endif -GEN_HEADERS = cbrt_tables.h aacps_tables.h aac_tables.h dsd_tables.h dv_tables.h \ - sinewin_tables.h mpegaudio_tables.h motionpixels_tables.h \ - pcm_tables.h qdm2_tables.h +GEN_HEADERS = cbrt_tables.h cbrt_fixed_tables.h aacps_tables.h aac_tables.h dsd_tables.h \ + dv_tables.h sinewin_tables.h sinewin_fixed_tables.h mpegaudio_tables.h \ + motionpixels_tables.h pcm_tables.h qdm2_tables.h GEN_HEADERS := $(addprefix $(SUBDIR), $(GEN_HEADERS)) $(GEN_HEADERS): $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF) @@ -906,11 +913,14 @@ $(GEN_HEADERS): $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF) ifdef CONFIG_HARDCODED_TABLES $(SUBDIR)aacdec.o: $(SUBDIR)cbrt_tables.h +$(SUBDIR)aacdec_fixed.o: $(SUBDIR)cbrt_fixed_tables.h $(SUBDIR)aacps.o: $(SUBDIR)aacps_tables.h $(SUBDIR)aactab.o: $(SUBDIR)aac_tables.h +$(SUBDIR)aactab_fixed.o: $(SUBDIR)aac_fixed_tables.h $(SUBDIR)dsddec.o: $(SUBDIR)dsd_tables.h $(SUBDIR)dvenc.o: $(SUBDIR)dv_tables.h $(SUBDIR)sinewin.o: $(SUBDIR)sinewin_tables.h +$(SUBDIR)sinewin_fixed.o: $(SUBDIR)sinewin_fixed_tables.h $(SUBDIR)mpegaudiodec_fixed.o: $(SUBDIR)mpegaudio_tables.h $(SUBDIR)mpegaudiodec_float.o: $(SUBDIR)mpegaudio_tables.h $(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 8cdd353..95c6d65 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -35,7 +35,6 @@ #define FFT_FLOAT 1 #define FFT_FIXED_32 0 #define USE_FIXED 0 -#define CONFIG_FIXED 0 #include "libavutil/float_dsp.h" #include "libavutil/opt.h" diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c index e6f43ce..9f0d4e6 100644 --- a/libavcodec/aacdec_fixed.c +++ b/libavcodec/aacdec_fixed.c @@ -61,7 +61,6 @@ #define FFT_FLOAT 0 #define FFT_FIXED_32 1 #define USE_FIXED 1 -#define CONFIG_FIXED 1 #include "libavutil/fixed_dsp.h" #include "libavutil/opt.h" diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 7650543..8275ba9 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -322,6 +322,7 @@ void avcodec_register_all(void) /* audio codecs */ REGISTER_ENCDEC (AAC, aac); + REGISTER_DECODER(AAC_FIXED, aac_fixed); REGISTER_DECODER(AAC_LATM, aac_latm); REGISTER_ENCDEC (AC3, ac3); REGISTER_ENCDEC (AC3_FIXED, ac3_fixed); -- 1.8.2.1 From nedeljko.babic at imgtec.com Fri Aug 1 15:53:08 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:08 +0200 Subject: [FFmpeg-devel] [PATCH 02/14] libavcodec: Implementation of AAC_fixed_decoder (LC-module) [2/5] In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-3-git-send-email-nedeljko.babic@imgtec.com> From: Djordje Pesut Add float emulation Signed-off-by: Nedeljko Babic --- libavcodec/aac_float_emu.h | 698 +++++++++++++++++++++++++++++++++++++++++++++ libavcodec/float_emu.h | 400 ++++++++++++++++++++++++++ libavcodec/float_emu_tab.c | 296 +++++++++++++++++++ 3 files changed, 1394 insertions(+) create mode 100644 libavcodec/aac_float_emu.h create mode 100644 libavcodec/float_emu.h create mode 100644 libavcodec/float_emu_tab.c diff --git a/libavcodec/aac_float_emu.h b/libavcodec/aac_float_emu.h new file mode 100644 index 0000000..f7a4fa0 --- /dev/null +++ b/libavcodec/aac_float_emu.h @@ -0,0 +1,698 @@ +/* + * Copyright (c) 2012 + * MIPS Technologies, Inc., California. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of is + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Author: Stanislav Ocovaj (stanislav.ocovaj imgtec com) + * + * This file is part of FFmpeg. + * + * 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 + */ + +#if !defined(_AAC_FLOAT_EMU_) +#define _AAC_FLOAT_EMU_ + +#include "libavutil/common.h" + +typedef struct aac_float_t { + int mant; + int expo; +} aac_float_t; + +#define ADD_SUFFIX(a) a ## _fixed +#define Q30(x) (int)((x)*1073741824.0 + 0.5) +#define Q31(x) (int)((x)*2147483648.0 + 0.5) + +#define ff_log2_tab ADD_SUFFIX(ff_log2_tab) +#define divTable ADD_SUFFIX(divTable) +#define sqrtTab ADD_SUFFIX(sqrtTab) +#define sqrExpMultTab ADD_SUFFIX(sqrExpMultTab) +#define aac_costbl_1 ADD_SUFFIX(aac_costbl_1) +#define aac_costbl_2 ADD_SUFFIX(aac_costbl_2) +#define aac_sintbl_2 ADD_SUFFIX(aac_sintbl_2) +#define aac_costbl_3 ADD_SUFFIX(aac_costbl_3) +#define aac_sintbl_3 ADD_SUFFIX(aac_sintbl_3) +#define aac_costbl_4 ADD_SUFFIX(aac_costbl_4) +#define aac_sintbl_4 ADD_SUFFIX(aac_sintbl_4) + +static const aac_float_t FLOAT_0 = { 0, 0}; +static const aac_float_t FLOAT_05 = { 536870912, 0}; +static const aac_float_t FLOAT_1 = { 536870912, 1}; +static const aac_float_t FLOAT_EPSILON = { 703687442, -16}; +static const aac_float_t FLOAT_1584893192 = { 850883053, 1}; +static const aac_float_t FLOAT_100000 = { 819200000, 17}; +static const aac_float_t FLOAT_0999999 = {1073740750, 0}; + +static const uint8_t ff_log2_tab[256] = { + 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 +}; + +static int divTable[128] = { + Q30(0.9999999995), Q30(0.9922480620), Q30(0.9846153846), Q30(0.9770992366), + Q30(0.9696969697), Q30(0.9624060150), Q30(0.9552238807), Q30(0.9481481481), + Q30(0.9411764704), Q30(0.9343065694), Q30(0.9275362319), Q30(0.9208633094), + Q30(0.9142857143), Q30(0.9078014186), Q30(0.9014084507), Q30(0.8951048949), + Q30(0.8888888890), Q30(0.8827586207), Q30(0.8767123288), Q30(0.8707482992), + Q30(0.8648648649), Q30(0.8590604025), Q30(0.8533333335), Q30(0.8476821193), + Q30(0.8421052634), Q30(0.8366013071), Q30(0.8311688313), Q30(0.8258064515), + Q30(0.8205128205), Q30(0.8152866242), Q30(0.8101265822), Q30(0.8050314467), + Q30(0.7999999998), Q30(0.7950310558), Q30(0.7901234566), Q30(0.7852760735), + Q30(0.7804878047), Q30(0.7757575759), Q30(0.7710843375), Q30(0.7664670660), + Q30(0.7619047621), Q30(0.7573964498), Q30(0.7529411763), Q30(0.7485380117), + Q30(0.7441860465), Q30(0.7398843933), Q30(0.7356321840), Q30(0.7314285715), + Q30(0.7272727271), Q30(0.7231638418), Q30(0.7191011235), Q30(0.7150837989), + Q30(0.7111111111), Q30(0.7071823203), Q30(0.7032967033), Q30(0.6994535518), + Q30(0.6956521738), Q30(0.6918918919), Q30(0.6881720428), Q30(0.6844919785), + Q30(0.6808510637), Q30(0.6772486772), Q30(0.6736842105), Q30(0.6701570679), + Q30(0.6666666665), Q30(0.6632124353), Q30(0.6597938146), Q30(0.6564102564), + Q30(0.6530612246), Q30(0.6497461931), Q30(0.6464646463), Q30(0.6432160805), + Q30(0.6400000001), Q30(0.6368159205), Q30(0.6336633665), Q30(0.6305418718), + Q30(0.6274509802), Q30(0.6243902440), Q30(0.6213592235), Q30(0.6183574880), + Q30(0.6153846155), Q30(0.6124401912), Q30(0.6095238095), Q30(0.6066350709), + Q30(0.6037735851), Q30(0.6009389670), Q30(0.5981308413), Q30(0.5953488373), + Q30(0.5925925928), Q30(0.5898617511), Q30(0.5871559633), Q30(0.5844748858), + Q30(0.5818181820), Q30(0.5791855203), Q30(0.5765765766), Q30(0.5739910314), + Q30(0.5714285714), Q30(0.5688888887), Q30(0.5663716816), Q30(0.5638766522), + Q30(0.5614035088), Q30(0.5589519651), Q30(0.5565217393), Q30(0.5541125541), + Q30(0.5517241377), Q30(0.5493562231), Q30(0.5470085470), Q30(0.5446808510), + Q30(0.5423728814), Q30(0.5400843881), Q30(0.5378151261), Q30(0.5355648533), + Q30(0.5333333332), Q30(0.5311203320), Q30(0.5289256200), Q30(0.5267489711), + Q30(0.5245901640), Q30(0.5224489798), Q30(0.5203252034), Q30(0.5182186235), + Q30(0.5161290322), Q30(0.5140562248), Q30(0.5120000001), Q30(0.5099601592), + Q30(0.5079365079), Q30(0.5059288535), Q30(0.5039370079), Q30(0.5019607842) +}; + +static int sqrtTab[512+1] = { /* sqrt(x), 0.5<=x<1 */ + Q30(0.7071067812), Q30(0.7077969783), Q30(0.7084865030), Q30(0.7091753576), + Q30(0.7098635430), Q30(0.7105510626), Q30(0.7112379172), Q30(0.7119241091), + Q30(0.7126096408), Q30(0.7132945131), Q30(0.7139787287), Q30(0.7146622892), + Q30(0.7153451964), Q30(0.7160274521), Q30(0.7167090587), Q30(0.7173900176), + Q30(0.7180703310), Q30(0.7187500000), Q30(0.7194290273), Q30(0.7201074138), + Q30(0.7207851619), Q30(0.7214622740), Q30(0.7221387504), Q30(0.7228145939), + Q30(0.7234898065), Q30(0.7241643891), Q30(0.7248383439), Q30(0.7255116729), + Q30(0.7261843774), Q30(0.7268564594), Q30(0.7275279206), Q30(0.7281987625), + Q30(0.7288689869), Q30(0.7295385958), Q30(0.7302075904), Q30(0.7308759727), + Q30(0.7315437444), Q30(0.7322109072), Q30(0.7328774626), Q30(0.7335434123), + Q30(0.7342087580), Q30(0.7348735011), Q30(0.7355376435), Q30(0.7362011867), + Q30(0.7368641328), Q30(0.7375264824), Q30(0.7381882383), Q30(0.7388494010), + Q30(0.7395099727), Q30(0.7401699550), Q30(0.7408293495), Q30(0.7414881573), + Q30(0.7421463802), Q30(0.7428040202), Q30(0.7434610785), Q30(0.7441175561), + Q30(0.7447734554), Q30(0.7454287778), Q30(0.7460835241), Q30(0.7467376967), + Q30(0.7473912966), Q30(0.7480443250), Q30(0.7486967845), Q30(0.7493486754), + Q30(0.7500000000), Q30(0.7506507593), Q30(0.7513009552), Q30(0.7519505885), + Q30(0.7525996612), Q30(0.7532481747), Q30(0.7538961302), Q30(0.7545435294), + Q30(0.7551903734), Q30(0.7558366638), Q30(0.7564824023), Q30(0.7571275900), + Q30(0.7577722282), Q30(0.7584163188), Q30(0.7590598627), Q30(0.7597028613), + Q30(0.7603453165), Q30(0.7609872287), Q30(0.7616286003), Q30(0.7622694322), + Q30(0.7629097258), Q30(0.7635494824), Q30(0.7641887036), Q30(0.7648273907), + Q30(0.7654655445), Q30(0.7661031671), Q30(0.7667402592), Q30(0.7673768224), + Q30(0.7680128580), Q30(0.7686483674), Q30(0.7692833515), Q30(0.7699178122), + Q30(0.7705517504), Q30(0.7711851676), Q30(0.7718180646), Q30(0.7724504434), + Q30(0.7730823047), Q30(0.7737136502), Q30(0.7743444811), Q30(0.7749747979), + Q30(0.7756046029), Q30(0.7762338966), Q30(0.7768626809), Q30(0.7774909567), + Q30(0.7781187249), Q30(0.7787459870), Q30(0.7793727447), Q30(0.7799989986), + Q30(0.7806247496), Q30(0.7812500000), Q30(0.7818747503), Q30(0.7824990018), + Q30(0.7831227556), Q30(0.7837460130), Q30(0.7843687749), Q30(0.7849910432), + Q30(0.7856128183), Q30(0.7862341017), Q30(0.7868548944), Q30(0.7874751980), + Q30(0.7880950132), Q30(0.7887143414), Q30(0.7893331838), Q30(0.7899515415), + Q30(0.7905694149), Q30(0.7911868063), Q30(0.7918037162), Q30(0.7924201456), + Q30(0.7930360963), Q30(0.7936515687), Q30(0.7942665643), Q30(0.7948810840), + Q30(0.7954951287), Q30(0.7961087003), Q30(0.7967217988), Q30(0.7973344265), + Q30(0.7979465835), Q30(0.7985582710), Q30(0.7991694906), Q30(0.7997802431), + Q30(0.8003905294), Q30(0.8010003511), Q30(0.8016097085), Q30(0.8022186034), + Q30(0.8028270360), Q30(0.8034350080), Q30(0.8040425205), Q30(0.8046495742), + Q30(0.8052561702), Q30(0.8058623099), Q30(0.8064679937), Q30(0.8070732229), + Q30(0.8076779991), Q30(0.8082823223), Q30(0.8088861941), Q30(0.8094896153), + Q30(0.8100925875), Q30(0.8106951108), Q30(0.8112971867), Q30(0.8118988159), + Q30(0.8125000000), Q30(0.8131007394), Q30(0.8137010355), Q30(0.8143008887), + Q30(0.8149003005), Q30(0.8154992717), Q30(0.8160978034), Q30(0.8166958964), + Q30(0.8172935518), Q30(0.8178907707), Q30(0.8184875534), Q30(0.8190839016), + Q30(0.8196798153), Q30(0.8202752969), Q30(0.8208703459), Q30(0.8214649642), + Q30(0.8220591522), Q30(0.8226529113), Q30(0.8232462420), Q30(0.8238391452), + Q30(0.8244316224), Q30(0.8250236739), Q30(0.8256153008), Q30(0.8262065044), + Q30(0.8267972847), Q30(0.8273876435), Q30(0.8279775814), Q30(0.8285670988), + Q30(0.8291561976), Q30(0.8297448778), Q30(0.8303331411), Q30(0.8309209873), + Q30(0.8315084185), Q30(0.8320954349), Q30(0.8326820373), Q30(0.8332682266), + Q30(0.8338540038), Q30(0.8344393703), Q30(0.8350243261), Q30(0.8356088721), + Q30(0.8361930102), Q30(0.8367767399), Q30(0.8373600631), Q30(0.8379429798), + Q30(0.8385254918), Q30(0.8391075991), Q30(0.8396893027), Q30(0.8402706035), + Q30(0.8408515030), Q30(0.8414320010), Q30(0.8420120990), Q30(0.8425917975), + Q30(0.8431710978), Q30(0.8437500000), Q30(0.8443285055), Q30(0.8449066146), + Q30(0.8454843285), Q30(0.8460616483), Q30(0.8466385738), Q30(0.8472151072), + Q30(0.8477912480), Q30(0.8483669977), Q30(0.8489423566), Q30(0.8495173263), + Q30(0.8500919067), Q30(0.8506660992), Q30(0.8512399043), Q30(0.8518133233), + Q30(0.8523863559), Q30(0.8529590038), Q30(0.8535312680), Q30(0.8541031480), + Q30(0.8546746457), Q30(0.8552457616), Q30(0.8558164961), Q30(0.8563868506), + Q30(0.8569568251), Q30(0.8575264211), Q30(0.8580956385), Q30(0.8586644791), + Q30(0.8592329426), Q30(0.8598010307), Q30(0.8603687435), Q30(0.8609360820), + Q30(0.8615030469), Q30(0.8620696389), Q30(0.8626358588), Q30(0.8632017071), + Q30(0.8637671852), Q30(0.8643322927), Q30(0.8648970313), Q30(0.8654614016), + Q30(0.8660254036), Q30(0.8665890391), Q30(0.8671523076), Q30(0.8677152111), + Q30(0.8682777495), Q30(0.8688399233), Q30(0.8694017339), Q30(0.8699631817), + Q30(0.8705242672), Q30(0.8710849914), Q30(0.8716453551), Q30(0.8722053585), + Q30(0.8727650028), Q30(0.8733242881), Q30(0.8738832157), Q30(0.8744417862), + Q30(0.8750000000), Q30(0.8755578580), Q30(0.8761153608), Q30(0.8766725087), + Q30(0.8772293031), Q30(0.8777857441), Q30(0.8783418327), Q30(0.8788975696), + Q30(0.8794529550), Q30(0.8800079902), Q30(0.8805626752), Q30(0.8811170114), + Q30(0.8816709989), Q30(0.8822246385), Q30(0.8827779307), Q30(0.8833308765), + Q30(0.8838834763), Q30(0.8844357310), Q30(0.8849876411), Q30(0.8855392071), + Q30(0.8860904300), Q30(0.8866413101), Q30(0.8871918479), Q30(0.8877420444), + Q30(0.8882919000), Q30(0.8888414158), Q30(0.8893905920), Q30(0.8899394292), + Q30(0.8904879279), Q30(0.8910360895), Q30(0.8915839135), Q30(0.8921314017), + Q30(0.8926785537), Q30(0.8932253704), Q30(0.8937718528), Q30(0.8943180013), + Q30(0.8948638164), Q30(0.8954092991), Q30(0.8959544492), Q30(0.8964992678), + Q30(0.8970437557), Q30(0.8975879136), Q30(0.8981317417), Q30(0.8986752401), + Q30(0.8992184107), Q30(0.8997612530), Q30(0.9003037680), Q30(0.9008459565), + Q30(0.9013878191), Q30(0.9019293557), Q30(0.9024705673), Q30(0.9030114547), + Q30(0.9035520186), Q30(0.9040922588), Q30(0.9046321767), Q30(0.9051717725), + Q30(0.9057110464), Q30(0.9062500000), Q30(0.9067886332), Q30(0.9073269465), + Q30(0.9078649404), Q30(0.9084026157), Q30(0.9089399735), Q30(0.9094770132), + Q30(0.9100137362), Q30(0.9105501426), Q30(0.9110862338), Q30(0.9116220092), + Q30(0.9121574699), Q30(0.9126926167), Q30(0.9132274496), Q30(0.9137619697), + Q30(0.9142961772), Q30(0.9148300732), Q30(0.9153636573), Q30(0.9158969307), + Q30(0.9164298936), Q30(0.9169625468), Q30(0.9174948912), Q30(0.9180269265), + Q30(0.9185586534), Q30(0.9190900731), Q30(0.9196211854), Q30(0.9201519913), + Q30(0.9206824913), Q30(0.9212126858), Q30(0.9217425752), Q30(0.9222721602), + Q30(0.9228014410), Q30(0.9233304188), Q30(0.9238590938), Q30(0.9243874662), + Q30(0.9249155368), Q30(0.9254433061), Q30(0.9259707746), Q30(0.9264979423), + Q30(0.9270248110), Q30(0.9275513799), Q30(0.9280776503), Q30(0.9286036226), + Q30(0.9291292969), Q30(0.9296546737), Q30(0.9301797543), Q30(0.9307045382), + Q30(0.9312290265), Q30(0.9317532196), Q30(0.9322771183), Q30(0.9328007223), + Q30(0.9333240325), Q30(0.9338470497), Q30(0.9343697741), Q30(0.9348922065), + Q30(0.9354143469), Q30(0.9359361958), Q30(0.9364577541), Q30(0.9369790219), + Q30(0.9375000000), Q30(0.9380206889), Q30(0.9385410887), Q30(0.9390612002), + Q30(0.9395810235), Q30(0.9401005600), Q30(0.9406198091), Q30(0.9411387718), + Q30(0.9416574482), Q30(0.9421758396), Q30(0.9426939455), Q30(0.9432117669), + Q30(0.9437293042), Q30(0.9442465580), Q30(0.9447635286), Q30(0.9452802162), + Q30(0.9457966220), Q30(0.9463127456), Q30(0.9468285879), Q30(0.9473441495), + Q30(0.9478594307), Q30(0.9483744316), Q30(0.9488891531), Q30(0.9494035956), + Q30(0.9499177597), Q30(0.9504316454), Q30(0.9509452535), Q30(0.9514585841), + Q30(0.9519716380), Q30(0.9524844158), Q30(0.9529969175), Q30(0.9535091440), + Q30(0.9540210953), Q30(0.9545327718), Q30(0.9550441746), Q30(0.9555553030), + Q30(0.9560661586), Q30(0.9565767418), Q30(0.9570870521), Q30(0.9575970904), + Q30(0.9581068573), Q30(0.9586163531), Q30(0.9591255784), Q30(0.9596345332), + Q30(0.9601432183), Q30(0.9606516343), Q30(0.9611597811), Q30(0.9616676597), + Q30(0.9621752701), Q30(0.9626826127), Q30(0.9631896880), Q30(0.9636964966), + Q30(0.9642030387), Q30(0.9647093150), Q30(0.9652153258), Q30(0.9657210712), + Q30(0.9662265521), Q30(0.9667317686), Q30(0.9672367214), Q30(0.9677414102), + Q30(0.9682458364), Q30(0.9687500000), Q30(0.9692539014), Q30(0.9697575406), + Q30(0.9702609186), Q30(0.9707640354), Q30(0.9712668918), Q30(0.9717694880), + Q30(0.9722718243), Q30(0.9727739012), Q30(0.9732757187), Q30(0.9737772783), + Q30(0.9742785795), Q30(0.9747796226), Q30(0.9752804083), Q30(0.9757809374), + Q30(0.9762812094), Q30(0.9767812253), Q30(0.9772809856), Q30(0.9777804906), + Q30(0.9782797401), Q30(0.9787787353), Q30(0.9792774762), Q30(0.9797759629), + Q30(0.9802741962), Q30(0.9807721768), Q30(0.9812699044), Q30(0.9817673797), + Q30(0.9822646030), Q30(0.9827615744), Q30(0.9832582953), Q30(0.9837547648), + Q30(0.9842509842), Q30(0.9847469535), Q30(0.9852426732), Q30(0.9857381433), + Q30(0.9862333648), Q30(0.9867283376), Q30(0.9872230627), Q30(0.9877175395), + Q30(0.9882117687), Q30(0.9887057510), Q30(0.9891994870), Q30(0.9896929762), + Q30(0.9901862200), Q30(0.9906792180), Q30(0.9911719705), Q30(0.9916644781), + Q30(0.9921567417), Q30(0.9926487608), Q30(0.9931405364), Q30(0.9936320684), + Q30(0.9941233573), Q30(0.9946144037), Q30(0.9951052079), Q30(0.9955957700), + Q30(0.9960860908), Q30(0.9965761700), Q30(0.9970660084), Q30(0.9975556061), + Q30(0.9980449639), Q30(0.9985340820), Q30(0.9990229602), Q30(0.9995115995), + 0x3FFFFFFF +}; + +static int sqrExpMultTab[2] = { + Q30(0.5000000000), Q30(0.7071067812) +}; + +static int aac_costbl_1[16] = { + Q30( 1.000000000000000), Q30( 0.980785280403230), Q30( 0.923879532511287), Q30( 0.831469612302545), + Q30( 0.707106781186548), Q30( 0.555570233019602), Q30( 0.382683432365090), Q30( 0.195090322016128), + Q30( 0.000000000000000), Q30(-0.195090322016128), Q30(-0.382683432365090), Q30(-0.555570233019602), + Q30(-0.707106781186547), Q30(-0.831469612302545), Q30(-0.923879532511287), Q30(-0.980785280403230) +}; + +static int aac_costbl_2[32] = { + Q30(1.000000000000000), Q30(0.999981175282601), Q30(0.999924701839145), Q30(0.999830581795823), + Q30(0.999698818696204), Q30(0.999529417501093), Q30(0.999322384588350), Q30(0.999077727752645), + Q30(0.998795456205172), Q30(0.998475580573295), Q30(0.998118112900149), Q30(0.997723066644192), + Q30(0.997290456678690), Q30(0.996820299291166), Q30(0.996312612182778), Q30(0.995767414467660), + Q30(0.995184726672197), Q30(0.994564570734255), Q30(0.993906970002356), Q30(0.993211949234795), + Q30(0.992479534598710), Q30(0.991709753669100), Q30(0.990902635427780), Q30(0.990058210262297), + Q30(0.989176509964781), Q30(0.988257567730749), Q30(0.987301418157858), Q30(0.986308097244599), + Q30(0.985277642388941), Q30(0.984210092386929), Q30(0.983105487431216), Q30(0.981963869109555) +}; + +static int aac_sintbl_2[32] = { + Q30(0.000000000000000), Q30(0.006135884649154), Q30(0.012271538285720), Q30(0.018406729905805), + Q30(0.024541228522912), Q30(0.030674803176637), Q30(0.036807222941359), Q30(0.042938256934941), + Q30(0.049067674327418), Q30(0.055195244349690), Q30(0.061320736302209), Q30(0.067443919563664), + Q30(0.073564563599667), Q30(0.079682437971430), Q30(0.085797312344440), Q30(0.091908956497133), + Q30(0.098017140329561), Q30(0.104121633872055), Q30(0.110222207293883), Q30(0.116318630911905), + Q30(0.122410675199216), Q30(0.128498110793793), Q30(0.134580708507126), Q30(0.140658239332849), + Q30(0.146730474455362), Q30(0.152797185258443), Q30(0.158858143333861), Q30(0.164913120489970), + Q30(0.170961888760301), Q30(0.177004220412149), Q30(0.183039887955141), Q30(0.189068664149806) +}; + +static int aac_costbl_3[32] = { + Q30(1.000000000000000), Q30(0.999999981616429), Q30(0.999999926465718), Q30(0.999999834547868), + Q30(0.999999705862882), Q30(0.999999540410766), Q30(0.999999338191526), Q30(0.999999099205168), + Q30(0.999998823451702), Q30(0.999998510931138), Q30(0.999998161643487), Q30(0.999997775588762), + Q30(0.999997352766978), Q30(0.999996893178150), Q30(0.999996396822294), Q30(0.999995863699430), + Q30(0.999995293809576), Q30(0.999994687152754), Q30(0.999994043728986), Q30(0.999993363538295), + Q30(0.999992646580707), Q30(0.999991892856248), Q30(0.999991102364946), Q30(0.999990275106829), + Q30(0.999989411081928), Q30(0.999988510290276), Q30(0.999987572731904), Q30(0.999986598406848), + Q30(0.999985587315143), Q30(0.999984539456827), Q30(0.999983454831938), Q30(0.999982333440515) +}; + +static int aac_sintbl_3[32] = { + Q30(0.000000000000000), Q30(0.000191747597311), Q30(0.000383495187571), Q30(0.000575242763732), + Q30(0.000766990318743), Q30(0.000958737845553), Q30(0.001150485337114), Q30(0.001342232786374), + Q30(0.001533980186285), Q30(0.001725727529795), Q30(0.001917474809855), Q30(0.002109222019416), + Q30(0.002300969151426), Q30(0.002492716198836), Q30(0.002684463154596), Q30(0.002876210011656), + Q30(0.003067956762966), Q30(0.003259703401476), Q30(0.003451449920136), Q30(0.003643196311896), + Q30(0.003834942569706), Q30(0.004026688686517), Q30(0.004218434655277), Q30(0.004410180468938), + Q30(0.004601926120449), Q30(0.004793671602760), Q30(0.004985416908822), Q30(0.005177162031584), + Q30(0.005368906963996), Q30(0.005560651699010), Q30(0.005752396229574), Q30(0.005944140548639) +}; + +static int aac_costbl_4[33] = { + Q30(1.000000000000000), Q30(0.999999999982047), Q30(0.999999999928189), Q30(0.999999999838426), + Q30(0.999999999712757), Q30(0.999999999551182), Q30(0.999999999353703), Q30(0.999999999120317), + Q30(0.999999998851027), Q30(0.999999998545831), Q30(0.999999998204729), Q30(0.999999997827723), + Q30(0.999999997414810), Q30(0.999999996965993), Q30(0.999999996481270), Q30(0.999999995960641), + Q30(0.999999995404107), Q30(0.999999994811668), Q30(0.999999994183323), Q30(0.999999993519073), + Q30(0.999999992818918), Q30(0.999999992082857), Q30(0.999999991310890), Q30(0.999999990503019), + Q30(0.999999989659241), Q30(0.999999988779559), Q30(0.999999987863971), Q30(0.999999986912477), + Q30(0.999999985925079), Q30(0.999999984901774), Q30(0.999999983842565), Q30(0.999999982747450), + Q30(0.999999981616429) +}; + +static int aac_sintbl_4[33] = { + Q30(0.000000000000000), Q30(0.000005992112453), Q30(0.000011984224905), Q30(0.000017976337357), + Q30(0.000023968449808), Q30(0.000029960562259), Q30(0.000035952674708), Q30(0.000041944787156), + Q30(0.000047936899603), Q30(0.000053929012048), Q30(0.000059921124491), Q30(0.000065913236932), + Q30(0.000071905349370), Q30(0.000077897461806), Q30(0.000083889574239), Q30(0.000089881686669), + Q30(0.000095873799096), Q30(0.000101865911519), Q30(0.000107858023939), Q30(0.000113850136355), + Q30(0.000119842248767), Q30(0.000125834361174), Q30(0.000131826473577), Q30(0.000137818585975), + Q30(0.000143810698369), Q30(0.000149802810757), Q30(0.000155794923139), Q30(0.000161787035517), + Q30(0.000167779147888), Q30(0.000173771260253), Q30(0.000179763372612), Q30(0.000185755484965), + Q30(0.000191747597311) +}; + + +static av_always_inline av_const int av_log2_c_emu(unsigned int v) +{ + int n = 0; + if (v & 0xffff0000) { + v >>= 16; + n += 16; + } + if (v & 0xff00) { + v >>= 8; + n += 8; + } + n += ff_log2_tab[v]; + + return n; +} + +static av_always_inline aac_float_t int2float(const int x, const int exp) +{ + aac_float_t ret; + int nz; + + if (x == 0) + { + ret.mant = 0; + ret.expo = 0; + } + else + { + ret.expo = exp; + ret.mant = x; + nz = 29 - av_log2_c_emu(FFABS(ret.mant)); + ret.mant <<= nz; + ret.expo -= nz; + } + + return ret; +} + +static av_always_inline aac_float_t float_add(aac_float_t a, aac_float_t b) +{ + int diff, nz; + int expa = a.expo; + int expb = b.expo; + int manta = a.mant; + int mantb = b.mant; + aac_float_t res; + + if (manta == 0) + return b; + + if (mantb == 0) + return a; + + diff = expa - expb; + if (diff < 0) // expa < expb + { + diff = -diff; + if (diff >= 31) + manta = 0; + else if (diff != 0) + manta >>= diff; + expa = expb; + } + else // expa >= expb + { + if (diff >= 31) + mantb = 0; + else if (diff != 0) + mantb >>= diff; + } + + manta = manta + mantb; + if (manta == 0) + expa = 0; + else + { + nz = 30 - av_log2_c_emu(FFABS(manta)); + manta <<= nz; + manta >>= 1; + expa -= (nz-1); + } + + res.mant = manta; + res.expo = expa; + + return res; +} + +static av_always_inline aac_float_t float_sub(aac_float_t a, aac_float_t b) +{ + int diff, nz; + int expa = a.expo; + int expb = b.expo; + int manta = a.mant; + int mantb = b.mant; + aac_float_t res; + + if (manta == 0) + { + res.mant = -mantb; + res.expo = expb; + return res; + } + + if (mantb == 0) + return a; + + diff = expa - expb; + if (diff < 0) // expa < expb + { + diff = -diff; + if (diff >= 31) + manta = 0; + else if (diff != 0) + manta >>= diff; + expa = expb; + } + else // expa >= expb + { + if (diff >= 31) + mantb = 0; + else if (diff != 0) + mantb >>= diff; + } + + manta = manta - mantb; + if (manta == 0) + expa = 0; + else + { + nz = 30 - av_log2_c_emu(FFABS(manta)); + manta <<= nz; + manta >>= 1; + expa -= (nz-1); + } + + res.mant = manta; + res.expo = expa; + + return res; +} + +static av_always_inline aac_float_t float_mul(aac_float_t a, aac_float_t b) +{ + aac_float_t res; + int mant; + int expa = a.expo; + int expb = b.expo; + long long accu; + + expa = expa + expb; + accu = (long long)a.mant * b.mant; + mant = (int)((accu + 0x20000000) >> 30); + if (mant == 0) + expa = 0; + else if (mant < 536870912 && mant > -536870912) + { + mant <<= 1; + expa = expa - 1; + } + res.mant = mant; + res.expo = expa; + + return res; +} + +static av_always_inline aac_float_t float_recip(const aac_float_t a) +{ + aac_float_t r; + int s; + int manta, expa; + + manta = a.mant; + expa = a.expo; + + expa = 1 - expa; + r.expo = expa; + + s = manta >> 31; + manta = (manta ^ s) - s; + + manta = divTable[(manta - 0x20000000) >> 22]; + + r.mant = (manta ^ s) - s; + + return r; +} + +static av_always_inline aac_float_t float_div(aac_float_t a, aac_float_t b) +{ + aac_float_t res; + aac_float_t iB, tmp; + int mantb; + + mantb = b.mant; + if (mantb != 0) + { + iB = float_recip(b); + // newton iteration to double precision + tmp = float_sub(FLOAT_1, float_mul(b, iB)); + iB = float_add(iB, float_mul(iB, tmp)); + res = float_mul(a, iB); + } + else + { + res.mant = 1; + res.expo = 2147483647; + } + + return res; +} + +static av_always_inline int float_gt(aac_float_t a, aac_float_t b) +{ + int expa = a.expo; + int expb = b.expo; + int manta = a.mant; + int mantb = b.mant; + + if (manta == 0) + expa = 0x80000000; + + if (mantb == 0) + expb = 0x80000000; + + if (expa > expb) + return 1; + else if (expa < expb) + return 0; + else // expa == expb + { + if (manta > mantb) + return 1; + else + return 0; + } +} + +static av_always_inline aac_float_t float_sqrt(aac_float_t val) +{ + int exp; + int tabIndex, rem; + int mant; + long long accu; + aac_float_t res; + + exp = val.expo; + mant = val.mant; + + if (mant == 0) + { + res.mant = 0; + res.expo = 0; + } + else + { + tabIndex = (mant - 536870912); + tabIndex = tabIndex >> 20; + + rem = mant & 0xfffff; + accu = (long long)sqrtTab[tabIndex] * (0x100000-rem); + accu += (long long)sqrtTab[tabIndex+1] * rem; + mant = (int)((accu + 0x80000) >> 20); + + accu = (long long)sqrExpMultTab[exp&1] * mant; + mant = (int)((accu + 0x10000000) >> 29); + if (mant < 1073741824) + exp -= 2; + else + mant >>= 1; + + res.mant = mant; + res.expo = (exp>>1)+1; + } + + return res; +} + +static av_always_inline void aac_fixed_sincos(int a, int *s, int *c) +{ + int idx, sign; + int sv, cv; + int st, ct; + long long accu; + + idx = a >> 26; + sign = (idx << 27) >> 31; + cv = aac_costbl_1[idx & 0xf]; + cv = (cv ^ sign) - sign; + + idx -= 8; + sign = (idx << 27) >> 31; + sv = aac_costbl_1[idx & 0xf]; + sv = (sv ^ sign) - sign; + + idx = a >> 21; + ct = aac_costbl_2[idx & 0x1f]; + st = aac_sintbl_2[idx & 0x1f]; + + accu = (long long)cv*ct; + accu -= (long long)sv*st; + idx = (int)((accu + 0x20000000) >> 30); + + accu = (long long)cv*st; + accu += (long long)sv*ct; + sv = (int)((accu + 0x20000000) >> 30); + cv = idx; + + idx = a >> 16; + ct = aac_costbl_3[idx & 0x1f]; + st = aac_sintbl_3[idx & 0x1f]; + + accu = (long long)cv*ct; + accu -= (long long)sv*st; + idx = (int)((accu + 0x20000000) >> 30); + + accu = (long long)cv*st; + accu += (long long)sv*ct; + sv = (int)((accu + 0x20000000) >> 30); + cv = idx; + + idx = a >> 11; + accu = (long long)aac_costbl_4[idx & 0x1f]*(0x800 - (a&0x7ff)); + accu += (long long)aac_costbl_4[(idx & 0x1f)+1]*(a&0x7ff); + ct = (int)((accu + 0x400) >> 11); + accu = (long long)aac_sintbl_4[idx & 0x1f]*(0x800 - (a&0x7ff)); + accu += (long long)aac_sintbl_4[(idx & 0x1f)+1]*(a&0x7ff); + st = (int)((accu + 0x400) >> 11); + + accu = (long long)cv*ct; + accu -= (long long)sv*st; + *c = (int)((accu + 0x20000000) >> 30); + + accu = (long long)cv*st; + accu += (long long)sv*ct; + *s = (int)((accu + 0x20000000) >> 30); +} + +#undef ff_log2_tab +#undef divTable +#undef sqrtTab +#undef sqrExpMultTab +#undef aac_costbl_1 +#undef aac_costbl_2 +#undef aac_sintbl_2 +#undef aac_costbl_3 +#undef aac_sintbl_3 +#undef aac_costbl_4 +#undef aac_sintbl_4 + +#endif /* _AAC_FLOAT_EMU_ */ diff --git a/libavcodec/float_emu.h b/libavcodec/float_emu.h new file mode 100644 index 0000000..23ebf1b --- /dev/null +++ b/libavcodec/float_emu.h @@ -0,0 +1,400 @@ +/* + * Copyright (c) 2012 + * MIPS Technologies, Inc., California. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of is + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Author: Stanislav Ocovaj (stanislav.ocovaj imgtec com) + * + * This file is part of FFmpeg. + * + * 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 + */ + +#ifndef AVUTIL_FLOAT_EMU_H +#define AVUTIL_FLOAT_EMU_H + +#include "libavutil/common.h" +#include "libavutil/intmath.h" + +extern const int divTable[128]; +extern const int sqrtTab[513]; +extern const int sqrExpMultTab[2]; +extern const int aac_costbl_1[16]; +extern const int aac_costbl_2[32]; +extern const int aac_sintbl_2[32]; +extern const int aac_costbl_3[32]; +extern const int aac_sintbl_3[32]; +extern const int aac_costbl_4[33]; +extern const int aac_sintbl_4[33]; + +typedef struct aac_float_t { + int mant; + int expo; +} aac_float_t; + +static const aac_float_t FLOAT_0 = { 0, 0}; +static const aac_float_t FLOAT_05 = { 536870912, 0}; +static const aac_float_t FLOAT_1 = { 536870912, 1}; +static const aac_float_t FLOAT_EPSILON = { 703687442, -16}; +static const aac_float_t FLOAT_1584893192 = { 850883053, 1}; +static const aac_float_t FLOAT_100000 = { 819200000, 17}; +static const aac_float_t FLOAT_0999999 = {1073740750, 0}; + +static av_always_inline aac_float_t int2float(const int x, const int exp) +{ + aac_float_t ret; + int nz; + + if (x == 0) + { + ret.mant = 0; + ret.expo = 0; + } + else + { + ret.expo = exp; + ret.mant = x; + nz = 29 - ff_log2(FFABS(ret.mant)); + ret.mant <<= nz; + ret.expo -= nz; + } + + return ret; +} + +static av_always_inline aac_float_t float_add(aac_float_t a, aac_float_t b) +{ + int diff, nz; + int expa = a.expo; + int expb = b.expo; + int manta = a.mant; + int mantb = b.mant; + aac_float_t res; + + if (manta == 0) + return b; + + if (mantb == 0) + return a; + + diff = expa - expb; + if (diff < 0) // expa < expb + { + diff = -diff; + if (diff >= 31) + manta = 0; + else if (diff != 0) + manta >>= diff; + expa = expb; + } + else // expa >= expb + { + if (diff >= 31) + mantb = 0; + else if (diff != 0) + mantb >>= diff; + } + + manta = manta + mantb; + if (manta == 0) + expa = 0; + else + { + nz = 30 - ff_log2(FFABS(manta)); + manta <<= nz; + manta >>= 1; + expa -= (nz-1); + } + + res.mant = manta; + res.expo = expa; + + return res; +} + +static av_always_inline aac_float_t float_sub(aac_float_t a, aac_float_t b) +{ + int diff, nz; + int expa = a.expo; + int expb = b.expo; + int manta = a.mant; + int mantb = b.mant; + aac_float_t res; + + if (manta == 0) + { + res.mant = -mantb; + res.expo = expb; + return res; + } + + if (mantb == 0) + return a; + + diff = expa - expb; + if (diff < 0) // expa < expb + { + diff = -diff; + if (diff >= 31) + manta = 0; + else if (diff != 0) + manta >>= diff; + expa = expb; + } + else // expa >= expb + { + if (diff >= 31) + mantb = 0; + else if (diff != 0) + mantb >>= diff; + } + + manta = manta - mantb; + if (manta == 0) + expa = 0; + else + { + nz = 30 - ff_log2(FFABS(manta)); + manta <<= nz; + manta >>= 1; + expa -= (nz-1); + } + + res.mant = manta; + res.expo = expa; + + return res; +} + +static av_always_inline aac_float_t float_mul(aac_float_t a, aac_float_t b) +{ + aac_float_t res; + int mant; + int expa = a.expo; + int expb = b.expo; + long long accu; + + expa = expa + expb; + accu = (long long)a.mant * b.mant; + mant = (int)((accu + 0x20000000) >> 30); + if (mant == 0) + expa = 0; + else if (mant < 536870912 && mant > -536870912) + { + mant <<= 1; + expa = expa - 1; + } + res.mant = mant; + res.expo = expa; + + return res; +} + +static av_always_inline aac_float_t float_recip(const aac_float_t a) +{ + aac_float_t r; + int s; + int manta, expa; + + manta = a.mant; + expa = a.expo; + + expa = 1 - expa; + r.expo = expa; + + s = manta >> 31; + manta = (manta ^ s) - s; + + manta = divTable[(manta - 0x20000000) >> 22]; + + r.mant = (manta ^ s) - s; + + return r; +} + +static av_always_inline aac_float_t float_div(aac_float_t a, aac_float_t b) +{ + aac_float_t res; + aac_float_t iB, tmp; + int mantb; + + mantb = b.mant; + if (mantb != 0) + { + iB = float_recip(b); + // newton iteration to double precision + tmp = float_sub(FLOAT_1, float_mul(b, iB)); + iB = float_add(iB, float_mul(iB, tmp)); + res = float_mul(a, iB); + } + else + { + res.mant = 1; + res.expo = 2147483647; + } + + return res; +} + +static av_always_inline int float_gt(aac_float_t a, aac_float_t b) +{ + int expa = a.expo; + int expb = b.expo; + int manta = a.mant; + int mantb = b.mant; + + if (manta == 0) + expa = 0x80000000; + + if (mantb == 0) + expb = 0x80000000; + + if (expa > expb) + return 1; + else if (expa < expb) + return 0; + else // expa == expb + { + if (manta > mantb) + return 1; + else + return 0; + } +} + +static av_always_inline aac_float_t float_sqrt(aac_float_t val) +{ + int exp; + int tabIndex, rem; + int mant; + long long accu; + aac_float_t res; + + exp = val.expo; + mant = val.mant; + + if (mant == 0) + { + res.mant = 0; + res.expo = 0; + } + else + { + tabIndex = (mant - 536870912); + tabIndex = tabIndex >> 20; + + rem = mant & 0xfffff; + accu = (long long)sqrtTab[tabIndex] * (0x100000-rem); + accu += (long long)sqrtTab[tabIndex+1] * rem; + mant = (int)((accu + 0x80000) >> 20); + + accu = (long long)sqrExpMultTab[exp&1] * mant; + mant = (int)((accu + 0x10000000) >> 29); + if (mant < 1073741824) + exp -= 2; + else + mant >>= 1; + + res.mant = mant; + res.expo = (exp>>1)+1; + } + + return res; +} + +static av_always_inline void aac_fixed_sincos(int a, int *s, int *c) +{ + int idx, sign; + int sv, cv; + int st, ct; + long long accu; + + idx = a >> 26; + sign = (idx << 27) >> 31; + cv = aac_costbl_1[idx & 0xf]; + cv = (cv ^ sign) - sign; + + idx -= 8; + sign = (idx << 27) >> 31; + sv = aac_costbl_1[idx & 0xf]; + sv = (sv ^ sign) - sign; + + idx = a >> 21; + ct = aac_costbl_2[idx & 0x1f]; + st = aac_sintbl_2[idx & 0x1f]; + + accu = (long long)cv*ct; + accu -= (long long)sv*st; + idx = (int)((accu + 0x20000000) >> 30); + + accu = (long long)cv*st; + accu += (long long)sv*ct; + sv = (int)((accu + 0x20000000) >> 30); + cv = idx; + + idx = a >> 16; + ct = aac_costbl_3[idx & 0x1f]; + st = aac_sintbl_3[idx & 0x1f]; + + accu = (long long)cv*ct; + accu -= (long long)sv*st; + idx = (int)((accu + 0x20000000) >> 30); + + accu = (long long)cv*st; + accu += (long long)sv*ct; + sv = (int)((accu + 0x20000000) >> 30); + cv = idx; + + idx = a >> 11; + accu = (long long)aac_costbl_4[idx & 0x1f]*(0x800 - (a&0x7ff)); + accu += (long long)aac_costbl_4[(idx & 0x1f)+1]*(a&0x7ff); + ct = (int)((accu + 0x400) >> 11); + accu = (long long)aac_sintbl_4[idx & 0x1f]*(0x800 - (a&0x7ff)); + accu += (long long)aac_sintbl_4[(idx & 0x1f)+1]*(a&0x7ff); + st = (int)((accu + 0x400) >> 11); + + accu = (long long)cv*ct; + accu -= (long long)sv*st; + *c = (int)((accu + 0x20000000) >> 30); + + accu = (long long)cv*st; + accu += (long long)sv*ct; + *s = (int)((accu + 0x20000000) >> 30); +} + +#endif /* AVUTIL_FLOAT_EMU_H */ diff --git a/libavcodec/float_emu_tab.c b/libavcodec/float_emu_tab.c new file mode 100644 index 0000000..fb0f829 --- /dev/null +++ b/libavcodec/float_emu_tab.c @@ -0,0 +1,296 @@ +/* + * Copyright (c) 2012 + * MIPS Technologies, Inc., California. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of is + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Author: Stanislav Ocovaj (stanislav.ocovaj imgtec com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#define Q30(x) (int)((x)*1073741824.0 + 0.5) + +const int divTable[128] = { + Q30(0.9999999995), Q30(0.9922480620), Q30(0.9846153846), Q30(0.9770992366), + Q30(0.9696969697), Q30(0.9624060150), Q30(0.9552238807), Q30(0.9481481481), + Q30(0.9411764704), Q30(0.9343065694), Q30(0.9275362319), Q30(0.9208633094), + Q30(0.9142857143), Q30(0.9078014186), Q30(0.9014084507), Q30(0.8951048949), + Q30(0.8888888890), Q30(0.8827586207), Q30(0.8767123288), Q30(0.8707482992), + Q30(0.8648648649), Q30(0.8590604025), Q30(0.8533333335), Q30(0.8476821193), + Q30(0.8421052634), Q30(0.8366013071), Q30(0.8311688313), Q30(0.8258064515), + Q30(0.8205128205), Q30(0.8152866242), Q30(0.8101265822), Q30(0.8050314467), + Q30(0.7999999998), Q30(0.7950310558), Q30(0.7901234566), Q30(0.7852760735), + Q30(0.7804878047), Q30(0.7757575759), Q30(0.7710843375), Q30(0.7664670660), + Q30(0.7619047621), Q30(0.7573964498), Q30(0.7529411763), Q30(0.7485380117), + Q30(0.7441860465), Q30(0.7398843933), Q30(0.7356321840), Q30(0.7314285715), + Q30(0.7272727271), Q30(0.7231638418), Q30(0.7191011235), Q30(0.7150837989), + Q30(0.7111111111), Q30(0.7071823203), Q30(0.7032967033), Q30(0.6994535518), + Q30(0.6956521738), Q30(0.6918918919), Q30(0.6881720428), Q30(0.6844919785), + Q30(0.6808510637), Q30(0.6772486772), Q30(0.6736842105), Q30(0.6701570679), + Q30(0.6666666665), Q30(0.6632124353), Q30(0.6597938146), Q30(0.6564102564), + Q30(0.6530612246), Q30(0.6497461931), Q30(0.6464646463), Q30(0.6432160805), + Q30(0.6400000001), Q30(0.6368159205), Q30(0.6336633665), Q30(0.6305418718), + Q30(0.6274509802), Q30(0.6243902440), Q30(0.6213592235), Q30(0.6183574880), + Q30(0.6153846155), Q30(0.6124401912), Q30(0.6095238095), Q30(0.6066350709), + Q30(0.6037735851), Q30(0.6009389670), Q30(0.5981308413), Q30(0.5953488373), + Q30(0.5925925928), Q30(0.5898617511), Q30(0.5871559633), Q30(0.5844748858), + Q30(0.5818181820), Q30(0.5791855203), Q30(0.5765765766), Q30(0.5739910314), + Q30(0.5714285714), Q30(0.5688888887), Q30(0.5663716816), Q30(0.5638766522), + Q30(0.5614035088), Q30(0.5589519651), Q30(0.5565217393), Q30(0.5541125541), + Q30(0.5517241377), Q30(0.5493562231), Q30(0.5470085470), Q30(0.5446808510), + Q30(0.5423728814), Q30(0.5400843881), Q30(0.5378151261), Q30(0.5355648533), + Q30(0.5333333332), Q30(0.5311203320), Q30(0.5289256200), Q30(0.5267489711), + Q30(0.5245901640), Q30(0.5224489798), Q30(0.5203252034), Q30(0.5182186235), + Q30(0.5161290322), Q30(0.5140562248), Q30(0.5120000001), Q30(0.5099601592), + Q30(0.5079365079), Q30(0.5059288535), Q30(0.5039370079), Q30(0.5019607842) +}; + +const int sqrtTab[512+1] = { /* sqrt(x), 0.5<=x<1 */ + Q30(0.7071067812), Q30(0.7077969783), Q30(0.7084865030), Q30(0.7091753576), + Q30(0.7098635430), Q30(0.7105510626), Q30(0.7112379172), Q30(0.7119241091), + Q30(0.7126096408), Q30(0.7132945131), Q30(0.7139787287), Q30(0.7146622892), + Q30(0.7153451964), Q30(0.7160274521), Q30(0.7167090587), Q30(0.7173900176), + Q30(0.7180703310), Q30(0.7187500000), Q30(0.7194290273), Q30(0.7201074138), + Q30(0.7207851619), Q30(0.7214622740), Q30(0.7221387504), Q30(0.7228145939), + Q30(0.7234898065), Q30(0.7241643891), Q30(0.7248383439), Q30(0.7255116729), + Q30(0.7261843774), Q30(0.7268564594), Q30(0.7275279206), Q30(0.7281987625), + Q30(0.7288689869), Q30(0.7295385958), Q30(0.7302075904), Q30(0.7308759727), + Q30(0.7315437444), Q30(0.7322109072), Q30(0.7328774626), Q30(0.7335434123), + Q30(0.7342087580), Q30(0.7348735011), Q30(0.7355376435), Q30(0.7362011867), + Q30(0.7368641328), Q30(0.7375264824), Q30(0.7381882383), Q30(0.7388494010), + Q30(0.7395099727), Q30(0.7401699550), Q30(0.7408293495), Q30(0.7414881573), + Q30(0.7421463802), Q30(0.7428040202), Q30(0.7434610785), Q30(0.7441175561), + Q30(0.7447734554), Q30(0.7454287778), Q30(0.7460835241), Q30(0.7467376967), + Q30(0.7473912966), Q30(0.7480443250), Q30(0.7486967845), Q30(0.7493486754), + Q30(0.7500000000), Q30(0.7506507593), Q30(0.7513009552), Q30(0.7519505885), + Q30(0.7525996612), Q30(0.7532481747), Q30(0.7538961302), Q30(0.7545435294), + Q30(0.7551903734), Q30(0.7558366638), Q30(0.7564824023), Q30(0.7571275900), + Q30(0.7577722282), Q30(0.7584163188), Q30(0.7590598627), Q30(0.7597028613), + Q30(0.7603453165), Q30(0.7609872287), Q30(0.7616286003), Q30(0.7622694322), + Q30(0.7629097258), Q30(0.7635494824), Q30(0.7641887036), Q30(0.7648273907), + Q30(0.7654655445), Q30(0.7661031671), Q30(0.7667402592), Q30(0.7673768224), + Q30(0.7680128580), Q30(0.7686483674), Q30(0.7692833515), Q30(0.7699178122), + Q30(0.7705517504), Q30(0.7711851676), Q30(0.7718180646), Q30(0.7724504434), + Q30(0.7730823047), Q30(0.7737136502), Q30(0.7743444811), Q30(0.7749747979), + Q30(0.7756046029), Q30(0.7762338966), Q30(0.7768626809), Q30(0.7774909567), + Q30(0.7781187249), Q30(0.7787459870), Q30(0.7793727447), Q30(0.7799989986), + Q30(0.7806247496), Q30(0.7812500000), Q30(0.7818747503), Q30(0.7824990018), + Q30(0.7831227556), Q30(0.7837460130), Q30(0.7843687749), Q30(0.7849910432), + Q30(0.7856128183), Q30(0.7862341017), Q30(0.7868548944), Q30(0.7874751980), + Q30(0.7880950132), Q30(0.7887143414), Q30(0.7893331838), Q30(0.7899515415), + Q30(0.7905694149), Q30(0.7911868063), Q30(0.7918037162), Q30(0.7924201456), + Q30(0.7930360963), Q30(0.7936515687), Q30(0.7942665643), Q30(0.7948810840), + Q30(0.7954951287), Q30(0.7961087003), Q30(0.7967217988), Q30(0.7973344265), + Q30(0.7979465835), Q30(0.7985582710), Q30(0.7991694906), Q30(0.7997802431), + Q30(0.8003905294), Q30(0.8010003511), Q30(0.8016097085), Q30(0.8022186034), + Q30(0.8028270360), Q30(0.8034350080), Q30(0.8040425205), Q30(0.8046495742), + Q30(0.8052561702), Q30(0.8058623099), Q30(0.8064679937), Q30(0.8070732229), + Q30(0.8076779991), Q30(0.8082823223), Q30(0.8088861941), Q30(0.8094896153), + Q30(0.8100925875), Q30(0.8106951108), Q30(0.8112971867), Q30(0.8118988159), + Q30(0.8125000000), Q30(0.8131007394), Q30(0.8137010355), Q30(0.8143008887), + Q30(0.8149003005), Q30(0.8154992717), Q30(0.8160978034), Q30(0.8166958964), + Q30(0.8172935518), Q30(0.8178907707), Q30(0.8184875534), Q30(0.8190839016), + Q30(0.8196798153), Q30(0.8202752969), Q30(0.8208703459), Q30(0.8214649642), + Q30(0.8220591522), Q30(0.8226529113), Q30(0.8232462420), Q30(0.8238391452), + Q30(0.8244316224), Q30(0.8250236739), Q30(0.8256153008), Q30(0.8262065044), + Q30(0.8267972847), Q30(0.8273876435), Q30(0.8279775814), Q30(0.8285670988), + Q30(0.8291561976), Q30(0.8297448778), Q30(0.8303331411), Q30(0.8309209873), + Q30(0.8315084185), Q30(0.8320954349), Q30(0.8326820373), Q30(0.8332682266), + Q30(0.8338540038), Q30(0.8344393703), Q30(0.8350243261), Q30(0.8356088721), + Q30(0.8361930102), Q30(0.8367767399), Q30(0.8373600631), Q30(0.8379429798), + Q30(0.8385254918), Q30(0.8391075991), Q30(0.8396893027), Q30(0.8402706035), + Q30(0.8408515030), Q30(0.8414320010), Q30(0.8420120990), Q30(0.8425917975), + Q30(0.8431710978), Q30(0.8437500000), Q30(0.8443285055), Q30(0.8449066146), + Q30(0.8454843285), Q30(0.8460616483), Q30(0.8466385738), Q30(0.8472151072), + Q30(0.8477912480), Q30(0.8483669977), Q30(0.8489423566), Q30(0.8495173263), + Q30(0.8500919067), Q30(0.8506660992), Q30(0.8512399043), Q30(0.8518133233), + Q30(0.8523863559), Q30(0.8529590038), Q30(0.8535312680), Q30(0.8541031480), + Q30(0.8546746457), Q30(0.8552457616), Q30(0.8558164961), Q30(0.8563868506), + Q30(0.8569568251), Q30(0.8575264211), Q30(0.8580956385), Q30(0.8586644791), + Q30(0.8592329426), Q30(0.8598010307), Q30(0.8603687435), Q30(0.8609360820), + Q30(0.8615030469), Q30(0.8620696389), Q30(0.8626358588), Q30(0.8632017071), + Q30(0.8637671852), Q30(0.8643322927), Q30(0.8648970313), Q30(0.8654614016), + Q30(0.8660254036), Q30(0.8665890391), Q30(0.8671523076), Q30(0.8677152111), + Q30(0.8682777495), Q30(0.8688399233), Q30(0.8694017339), Q30(0.8699631817), + Q30(0.8705242672), Q30(0.8710849914), Q30(0.8716453551), Q30(0.8722053585), + Q30(0.8727650028), Q30(0.8733242881), Q30(0.8738832157), Q30(0.8744417862), + Q30(0.8750000000), Q30(0.8755578580), Q30(0.8761153608), Q30(0.8766725087), + Q30(0.8772293031), Q30(0.8777857441), Q30(0.8783418327), Q30(0.8788975696), + Q30(0.8794529550), Q30(0.8800079902), Q30(0.8805626752), Q30(0.8811170114), + Q30(0.8816709989), Q30(0.8822246385), Q30(0.8827779307), Q30(0.8833308765), + Q30(0.8838834763), Q30(0.8844357310), Q30(0.8849876411), Q30(0.8855392071), + Q30(0.8860904300), Q30(0.8866413101), Q30(0.8871918479), Q30(0.8877420444), + Q30(0.8882919000), Q30(0.8888414158), Q30(0.8893905920), Q30(0.8899394292), + Q30(0.8904879279), Q30(0.8910360895), Q30(0.8915839135), Q30(0.8921314017), + Q30(0.8926785537), Q30(0.8932253704), Q30(0.8937718528), Q30(0.8943180013), + Q30(0.8948638164), Q30(0.8954092991), Q30(0.8959544492), Q30(0.8964992678), + Q30(0.8970437557), Q30(0.8975879136), Q30(0.8981317417), Q30(0.8986752401), + Q30(0.8992184107), Q30(0.8997612530), Q30(0.9003037680), Q30(0.9008459565), + Q30(0.9013878191), Q30(0.9019293557), Q30(0.9024705673), Q30(0.9030114547), + Q30(0.9035520186), Q30(0.9040922588), Q30(0.9046321767), Q30(0.9051717725), + Q30(0.9057110464), Q30(0.9062500000), Q30(0.9067886332), Q30(0.9073269465), + Q30(0.9078649404), Q30(0.9084026157), Q30(0.9089399735), Q30(0.9094770132), + Q30(0.9100137362), Q30(0.9105501426), Q30(0.9110862338), Q30(0.9116220092), + Q30(0.9121574699), Q30(0.9126926167), Q30(0.9132274496), Q30(0.9137619697), + Q30(0.9142961772), Q30(0.9148300732), Q30(0.9153636573), Q30(0.9158969307), + Q30(0.9164298936), Q30(0.9169625468), Q30(0.9174948912), Q30(0.9180269265), + Q30(0.9185586534), Q30(0.9190900731), Q30(0.9196211854), Q30(0.9201519913), + Q30(0.9206824913), Q30(0.9212126858), Q30(0.9217425752), Q30(0.9222721602), + Q30(0.9228014410), Q30(0.9233304188), Q30(0.9238590938), Q30(0.9243874662), + Q30(0.9249155368), Q30(0.9254433061), Q30(0.9259707746), Q30(0.9264979423), + Q30(0.9270248110), Q30(0.9275513799), Q30(0.9280776503), Q30(0.9286036226), + Q30(0.9291292969), Q30(0.9296546737), Q30(0.9301797543), Q30(0.9307045382), + Q30(0.9312290265), Q30(0.9317532196), Q30(0.9322771183), Q30(0.9328007223), + Q30(0.9333240325), Q30(0.9338470497), Q30(0.9343697741), Q30(0.9348922065), + Q30(0.9354143469), Q30(0.9359361958), Q30(0.9364577541), Q30(0.9369790219), + Q30(0.9375000000), Q30(0.9380206889), Q30(0.9385410887), Q30(0.9390612002), + Q30(0.9395810235), Q30(0.9401005600), Q30(0.9406198091), Q30(0.9411387718), + Q30(0.9416574482), Q30(0.9421758396), Q30(0.9426939455), Q30(0.9432117669), + Q30(0.9437293042), Q30(0.9442465580), Q30(0.9447635286), Q30(0.9452802162), + Q30(0.9457966220), Q30(0.9463127456), Q30(0.9468285879), Q30(0.9473441495), + Q30(0.9478594307), Q30(0.9483744316), Q30(0.9488891531), Q30(0.9494035956), + Q30(0.9499177597), Q30(0.9504316454), Q30(0.9509452535), Q30(0.9514585841), + Q30(0.9519716380), Q30(0.9524844158), Q30(0.9529969175), Q30(0.9535091440), + Q30(0.9540210953), Q30(0.9545327718), Q30(0.9550441746), Q30(0.9555553030), + Q30(0.9560661586), Q30(0.9565767418), Q30(0.9570870521), Q30(0.9575970904), + Q30(0.9581068573), Q30(0.9586163531), Q30(0.9591255784), Q30(0.9596345332), + Q30(0.9601432183), Q30(0.9606516343), Q30(0.9611597811), Q30(0.9616676597), + Q30(0.9621752701), Q30(0.9626826127), Q30(0.9631896880), Q30(0.9636964966), + Q30(0.9642030387), Q30(0.9647093150), Q30(0.9652153258), Q30(0.9657210712), + Q30(0.9662265521), Q30(0.9667317686), Q30(0.9672367214), Q30(0.9677414102), + Q30(0.9682458364), Q30(0.9687500000), Q30(0.9692539014), Q30(0.9697575406), + Q30(0.9702609186), Q30(0.9707640354), Q30(0.9712668918), Q30(0.9717694880), + Q30(0.9722718243), Q30(0.9727739012), Q30(0.9732757187), Q30(0.9737772783), + Q30(0.9742785795), Q30(0.9747796226), Q30(0.9752804083), Q30(0.9757809374), + Q30(0.9762812094), Q30(0.9767812253), Q30(0.9772809856), Q30(0.9777804906), + Q30(0.9782797401), Q30(0.9787787353), Q30(0.9792774762), Q30(0.9797759629), + Q30(0.9802741962), Q30(0.9807721768), Q30(0.9812699044), Q30(0.9817673797), + Q30(0.9822646030), Q30(0.9827615744), Q30(0.9832582953), Q30(0.9837547648), + Q30(0.9842509842), Q30(0.9847469535), Q30(0.9852426732), Q30(0.9857381433), + Q30(0.9862333648), Q30(0.9867283376), Q30(0.9872230627), Q30(0.9877175395), + Q30(0.9882117687), Q30(0.9887057510), Q30(0.9891994870), Q30(0.9896929762), + Q30(0.9901862200), Q30(0.9906792180), Q30(0.9911719705), Q30(0.9916644781), + Q30(0.9921567417), Q30(0.9926487608), Q30(0.9931405364), Q30(0.9936320684), + Q30(0.9941233573), Q30(0.9946144037), Q30(0.9951052079), Q30(0.9955957700), + Q30(0.9960860908), Q30(0.9965761700), Q30(0.9970660084), Q30(0.9975556061), + Q30(0.9980449639), Q30(0.9985340820), Q30(0.9990229602), Q30(0.9995115995), + 0x3FFFFFFF +}; + +const int sqrExpMultTab[2] = { + Q30(0.5000000000), Q30(0.7071067812) +}; + +const int aac_costbl_1[16] = { + Q30( 1.000000000000000), Q30( 0.980785280403230), Q30( 0.923879532511287), Q30( 0.831469612302545), + Q30( 0.707106781186548), Q30( 0.555570233019602), Q30( 0.382683432365090), Q30( 0.195090322016128), + Q30( 0.000000000000000), Q30(-0.195090322016128), Q30(-0.382683432365090), Q30(-0.555570233019602), + Q30(-0.707106781186547), Q30(-0.831469612302545), Q30(-0.923879532511287), Q30(-0.980785280403230) +}; + +const int aac_costbl_2[32] = { + Q30(1.000000000000000), Q30(0.999981175282601), Q30(0.999924701839145), Q30(0.999830581795823), + Q30(0.999698818696204), Q30(0.999529417501093), Q30(0.999322384588350), Q30(0.999077727752645), + Q30(0.998795456205172), Q30(0.998475580573295), Q30(0.998118112900149), Q30(0.997723066644192), + Q30(0.997290456678690), Q30(0.996820299291166), Q30(0.996312612182778), Q30(0.995767414467660), + Q30(0.995184726672197), Q30(0.994564570734255), Q30(0.993906970002356), Q30(0.993211949234795), + Q30(0.992479534598710), Q30(0.991709753669100), Q30(0.990902635427780), Q30(0.990058210262297), + Q30(0.989176509964781), Q30(0.988257567730749), Q30(0.987301418157858), Q30(0.986308097244599), + Q30(0.985277642388941), Q30(0.984210092386929), Q30(0.983105487431216), Q30(0.981963869109555) +}; + +const int aac_sintbl_2[32] = { + Q30(0.000000000000000), Q30(0.006135884649154), Q30(0.012271538285720), Q30(0.018406729905805), + Q30(0.024541228522912), Q30(0.030674803176637), Q30(0.036807222941359), Q30(0.042938256934941), + Q30(0.049067674327418), Q30(0.055195244349690), Q30(0.061320736302209), Q30(0.067443919563664), + Q30(0.073564563599667), Q30(0.079682437971430), Q30(0.085797312344440), Q30(0.091908956497133), + Q30(0.098017140329561), Q30(0.104121633872055), Q30(0.110222207293883), Q30(0.116318630911905), + Q30(0.122410675199216), Q30(0.128498110793793), Q30(0.134580708507126), Q30(0.140658239332849), + Q30(0.146730474455362), Q30(0.152797185258443), Q30(0.158858143333861), Q30(0.164913120489970), + Q30(0.170961888760301), Q30(0.177004220412149), Q30(0.183039887955141), Q30(0.189068664149806) +}; + +const int aac_costbl_3[32] = { + Q30(1.000000000000000), Q30(0.999999981616429), Q30(0.999999926465718), Q30(0.999999834547868), + Q30(0.999999705862882), Q30(0.999999540410766), Q30(0.999999338191526), Q30(0.999999099205168), + Q30(0.999998823451702), Q30(0.999998510931138), Q30(0.999998161643487), Q30(0.999997775588762), + Q30(0.999997352766978), Q30(0.999996893178150), Q30(0.999996396822294), Q30(0.999995863699430), + Q30(0.999995293809576), Q30(0.999994687152754), Q30(0.999994043728986), Q30(0.999993363538295), + Q30(0.999992646580707), Q30(0.999991892856248), Q30(0.999991102364946), Q30(0.999990275106829), + Q30(0.999989411081928), Q30(0.999988510290276), Q30(0.999987572731904), Q30(0.999986598406848), + Q30(0.999985587315143), Q30(0.999984539456827), Q30(0.999983454831938), Q30(0.999982333440515) +}; + +const int aac_sintbl_3[32] = { + Q30(0.000000000000000), Q30(0.000191747597311), Q30(0.000383495187571), Q30(0.000575242763732), + Q30(0.000766990318743), Q30(0.000958737845553), Q30(0.001150485337114), Q30(0.001342232786374), + Q30(0.001533980186285), Q30(0.001725727529795), Q30(0.001917474809855), Q30(0.002109222019416), + Q30(0.002300969151426), Q30(0.002492716198836), Q30(0.002684463154596), Q30(0.002876210011656), + Q30(0.003067956762966), Q30(0.003259703401476), Q30(0.003451449920136), Q30(0.003643196311896), + Q30(0.003834942569706), Q30(0.004026688686517), Q30(0.004218434655277), Q30(0.004410180468938), + Q30(0.004601926120449), Q30(0.004793671602760), Q30(0.004985416908822), Q30(0.005177162031584), + Q30(0.005368906963996), Q30(0.005560651699010), Q30(0.005752396229574), Q30(0.005944140548639) +}; + +const int aac_costbl_4[33] = { + Q30(1.000000000000000), Q30(0.999999999982047), Q30(0.999999999928189), Q30(0.999999999838426), + Q30(0.999999999712757), Q30(0.999999999551182), Q30(0.999999999353703), Q30(0.999999999120317), + Q30(0.999999998851027), Q30(0.999999998545831), Q30(0.999999998204729), Q30(0.999999997827723), + Q30(0.999999997414810), Q30(0.999999996965993), Q30(0.999999996481270), Q30(0.999999995960641), + Q30(0.999999995404107), Q30(0.999999994811668), Q30(0.999999994183323), Q30(0.999999993519073), + Q30(0.999999992818918), Q30(0.999999992082857), Q30(0.999999991310890), Q30(0.999999990503019), + Q30(0.999999989659241), Q30(0.999999988779559), Q30(0.999999987863971), Q30(0.999999986912477), + Q30(0.999999985925079), Q30(0.999999984901774), Q30(0.999999983842565), Q30(0.999999982747450), + Q30(0.999999981616429) +}; + +const int aac_sintbl_4[33] = { + Q30(0.000000000000000), Q30(0.000005992112453), Q30(0.000011984224905), Q30(0.000017976337357), + Q30(0.000023968449808), Q30(0.000029960562259), Q30(0.000035952674708), Q30(0.000041944787156), + Q30(0.000047936899603), Q30(0.000053929012048), Q30(0.000059921124491), Q30(0.000065913236932), + Q30(0.000071905349370), Q30(0.000077897461806), Q30(0.000083889574239), Q30(0.000089881686669), + Q30(0.000095873799096), Q30(0.000101865911519), Q30(0.000107858023939), Q30(0.000113850136355), + Q30(0.000119842248767), Q30(0.000125834361174), Q30(0.000131826473577), Q30(0.000137818585975), + Q30(0.000143810698369), Q30(0.000149802810757), Q30(0.000155794923139), Q30(0.000161787035517), + Q30(0.000167779147888), Q30(0.000173771260253), Q30(0.000179763372612), Q30(0.000185755484965), + Q30(0.000191747597311) +}; -- 1.8.2.1 From nedeljko.babic at imgtec.com Fri Aug 1 15:53:13 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:13 +0200 Subject: [FFmpeg-devel] [PATCH 07/14] libavcodec: Implementation of AAC_fixed_decoder (SBR-module) [2/4] In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-8-git-send-email-nedeljko.babic@imgtec.com> From: Jovan Zelincevic Converte tables to fixed point. Signed-off-by: Nedeljko Babic --- libavcodec/aacsbrdata.h | 688 ++++++++++++++++++++++++------------------------ 1 file changed, 344 insertions(+), 344 deletions(-) diff --git a/libavcodec/aacsbrdata.h b/libavcodec/aacsbrdata.h index 12575ee..6c9c4d4 100644 --- a/libavcodec/aacsbrdata.h +++ b/libavcodec/aacsbrdata.h @@ -267,354 +267,354 @@ static const int8_t sbr_offset[6][16] = { }; ///< window coefficients for analysis/synthesis QMF banks -static DECLARE_ALIGNED(32, float, sbr_qmf_window_ds)[320]; -static DECLARE_ALIGNED(32, float, sbr_qmf_window_us)[640] = { - 0.0000000000, -0.0005525286, -0.0005617692, -0.0004947518, - -0.0004875227, -0.0004893791, -0.0005040714, -0.0005226564, - -0.0005466565, -0.0005677802, -0.0005870930, -0.0006132747, - -0.0006312493, -0.0006540333, -0.0006777690, -0.0006941614, - -0.0007157736, -0.0007255043, -0.0007440941, -0.0007490598, - -0.0007681371, -0.0007724848, -0.0007834332, -0.0007779869, - -0.0007803664, -0.0007801449, -0.0007757977, -0.0007630793, - -0.0007530001, -0.0007319357, -0.0007215391, -0.0006917937, - -0.0006650415, -0.0006341594, -0.0005946118, -0.0005564576, - -0.0005145572, -0.0004606325, -0.0004095121, -0.0003501175, - -0.0002896981, -0.0002098337, -0.0001446380, -0.0000617334, - 0.0000134949, 0.0001094383, 0.0002043017, 0.0002949531, - 0.0004026540, 0.0005107388, 0.0006239376, 0.0007458025, - 0.0008608443, 0.0009885988, 0.0011250155, 0.0012577884, - 0.0013902494, 0.0015443219, 0.0016868083, 0.0018348265, - 0.0019841140, 0.0021461583, 0.0023017254, 0.0024625616, - 0.0026201758, 0.0027870464, 0.0029469447, 0.0031125420, - 0.0032739613, 0.0034418874, 0.0036008268, 0.0037603922, - 0.0039207432, 0.0040819753, 0.0042264269, 0.0043730719, - 0.0045209852, 0.0046606460, 0.0047932560, 0.0049137603, - 0.0050393022, 0.0051407353, 0.0052461166, 0.0053471681, - 0.0054196775, 0.0054876040, 0.0055475714, 0.0055938023, - 0.0056220643, 0.0056455196, 0.0056389199, 0.0056266114, - 0.0055917128, 0.0055404363, 0.0054753783, 0.0053838975, - 0.0052715758, 0.0051382275, 0.0049839687, 0.0048109469, - 0.0046039530, 0.0043801861, 0.0041251642, 0.0038456408, - 0.0035401246, 0.0032091885, 0.0028446757, 0.0024508540, - 0.0020274176, 0.0015784682, 0.0010902329, 0.0005832264, - 0.0000276045, -0.0005464280, -0.0011568135, -0.0018039472, - -0.0024826723, -0.0031933778, -0.0039401124, -0.0047222596, - -0.0055337211, -0.0063792293, -0.0072615816, -0.0081798233, - -0.0091325329, -0.0101150215, -0.0111315548, -0.0121849995, - 0.0132718220, 0.0143904666, 0.0155405553, 0.0167324712, - 0.0179433381, 0.0191872431, 0.0204531793, 0.0217467550, - 0.0230680169, 0.0244160992, 0.0257875847, 0.0271859429, - 0.0286072173, 0.0300502657, 0.0315017608, 0.0329754081, - 0.0344620948, 0.0359697560, 0.0374812850, 0.0390053679, - 0.0405349170, 0.0420649094, 0.0436097542, 0.0451488405, - 0.0466843027, 0.0482165720, 0.0497385755, 0.0512556155, - 0.0527630746, 0.0542452768, 0.0557173648, 0.0571616450, - 0.0585915683, 0.0599837480, 0.0613455171, 0.0626857808, - 0.0639715898, 0.0652247106, 0.0664367512, 0.0676075985, - 0.0687043828, 0.0697630244, 0.0707628710, 0.0717002673, - 0.0725682583, 0.0733620255, 0.0741003642, 0.0747452558, - 0.0753137336, 0.0758008358, 0.0761992479, 0.0764992170, - 0.0767093490, 0.0768173975, 0.0768230011, 0.0767204924, - 0.0765050718, 0.0761748321, 0.0757305756, 0.0751576255, - 0.0744664394, 0.0736406005, 0.0726774642, 0.0715826364, - 0.0703533073, 0.0689664013, 0.0674525021, 0.0657690668, - 0.0639444805, 0.0619602779, 0.0598166570, 0.0575152691, - 0.0550460034, 0.0524093821, 0.0495978676, 0.0466303305, - 0.0434768782, 0.0401458278, 0.0366418116, 0.0329583930, - 0.0290824006, 0.0250307561, 0.0207997072, 0.0163701258, - 0.0117623832, 0.0069636862, 0.0019765601, -0.0032086896, - -0.0085711749, -0.0141288827, -0.0198834129, -0.0258227288, - -0.0319531274, -0.0382776572, -0.0447806821, -0.0514804176, - -0.0583705326, -0.0654409853, -0.0726943300, -0.0801372934, - -0.0877547536, -0.0955533352, -0.1035329531, -0.1116826931, - -0.1200077984, -0.1285002850, -0.1371551761, -0.1459766491, - -0.1549607071, -0.1640958855, -0.1733808172, -0.1828172548, - -0.1923966745, -0.2021250176, -0.2119735853, -0.2219652696, - -0.2320690870, -0.2423016884, -0.2526480309, -0.2631053299, - -0.2736634040, -0.2843214189, -0.2950716717, -0.3059098575, - -0.3168278913, -0.3278113727, -0.3388722693, -0.3499914122, - 0.3611589903, 0.3723795546, 0.3836350013, 0.3949211761, - 0.4062317676, 0.4175696896, 0.4289119920, 0.4402553754, - 0.4515996535, 0.4629308085, 0.4742453214, 0.4855253091, - 0.4967708254, 0.5079817500, 0.5191234970, 0.5302240895, - 0.5412553448, 0.5522051258, 0.5630789140, 0.5738524131, - 0.5845403235, 0.5951123086, 0.6055783538, 0.6159109932, - 0.6261242695, 0.6361980107, 0.6461269695, 0.6559016302, - 0.6655139880, 0.6749663190, 0.6842353293, 0.6933282376, - 0.7022388719, 0.7109410426, 0.7194462634, 0.7277448900, - 0.7358211758, 0.7436827863, 0.7513137456, 0.7587080760, - 0.7658674865, 0.7727780881, 0.7794287519, 0.7858353120, - 0.7919735841, 0.7978466413, 0.8034485751, 0.8087695004, - 0.8138191270, 0.8185776004, 0.8230419890, 0.8272275347, - 0.8311038457, 0.8346937361, 0.8379717337, 0.8409541392, - 0.8436238281, 0.8459818469, 0.8480315777, 0.8497805198, - 0.8511971524, 0.8523047035, 0.8531020949, 0.8535720573, - 0.8537385600, +static DECLARE_ALIGNED(32, INTFLOAT, sbr_qmf_window_ds)[320]; +static DECLARE_ALIGNED(32, INTFLOAT, sbr_qmf_window_us)[640] = { + Q31( 0.0000000000f), Q31(-0.0005525286f), Q31(-0.0005617692f), Q31(-0.0004947518f), + Q31(-0.0004875227f), Q31(-0.0004893791f), Q31(-0.0005040714f), Q31(-0.0005226564f), + Q31(-0.0005466565f), Q31(-0.0005677802f), Q31(-0.0005870930f), Q31(-0.0006132747f), + Q31(-0.0006312493f), Q31(-0.0006540333f), Q31(-0.0006777690f), Q31(-0.0006941614f), + Q31(-0.0007157736f), Q31(-0.0007255043f), Q31(-0.0007440941f), Q31(-0.0007490598f), + Q31(-0.0007681371f), Q31(-0.0007724848f), Q31(-0.0007834332f), Q31(-0.0007779869f), + Q31(-0.0007803664f), Q31(-0.0007801449f), Q31(-0.0007757977f), Q31(-0.0007630793f), + Q31(-0.0007530001f), Q31(-0.0007319357f), Q31(-0.0007215391f), Q31(-0.0006917937f), + Q31(-0.0006650415f), Q31(-0.0006341594f), Q31(-0.0005946118f), Q31(-0.0005564576f), + Q31(-0.0005145572f), Q31(-0.0004606325f), Q31(-0.0004095121f), Q31(-0.0003501175f), + Q31(-0.0002896981f), Q31(-0.0002098337f), Q31(-0.0001446380f), Q31(-0.0000617334f), + Q31( 0.0000134949f), Q31( 0.0001094383f), Q31( 0.0002043017f), Q31( 0.0002949531f), + Q31( 0.0004026540f), Q31( 0.0005107388f), Q31( 0.0006239376f), Q31( 0.0007458025f), + Q31( 0.0008608443f), Q31( 0.0009885988f), Q31( 0.0011250155f), Q31( 0.0012577884f), + Q31( 0.0013902494f), Q31( 0.0015443219f), Q31( 0.0016868083f), Q31( 0.0018348265f), + Q31( 0.0019841140f), Q31( 0.0021461583f), Q31( 0.0023017254f), Q31( 0.0024625616f), + Q31( 0.0026201758f), Q31( 0.0027870464f), Q31( 0.0029469447f), Q31( 0.0031125420f), + Q31( 0.0032739613f), Q31( 0.0034418874f), Q31( 0.0036008268f), Q31( 0.0037603922f), + Q31( 0.0039207432f), Q31( 0.0040819753f), Q31( 0.0042264269f), Q31( 0.0043730719f), + Q31( 0.0045209852f), Q31( 0.0046606460f), Q31( 0.0047932560f), Q31( 0.0049137603f), + Q31( 0.0050393022f), Q31( 0.0051407353f), Q31( 0.0052461166f), Q31( 0.0053471681f), + Q31( 0.0054196775f), Q31( 0.0054876040f), Q31( 0.0055475714f), Q31( 0.0055938023f), + Q31( 0.0056220643f), Q31( 0.0056455196f), Q31( 0.0056389199f), Q31( 0.0056266114f), + Q31( 0.0055917128f), Q31( 0.0055404363f), Q31( 0.0054753783f), Q31( 0.0053838975f), + Q31( 0.0052715758f), Q31( 0.0051382275f), Q31( 0.0049839687f), Q31( 0.0048109469f), + Q31( 0.0046039530f), Q31( 0.0043801861f), Q31( 0.0041251642f), Q31( 0.0038456408f), + Q31( 0.0035401246f), Q31( 0.0032091885f), Q31( 0.0028446757f), Q31( 0.0024508540f), + Q31( 0.0020274176f), Q31( 0.0015784682f), Q31( 0.0010902329f), Q31( 0.0005832264f), + Q31( 0.0000276045f), Q31(-0.0005464280f), Q31(-0.0011568135f), Q31(-0.0018039472f), + Q31(-0.0024826723f), Q31(-0.0031933778f), Q31(-0.0039401124f), Q31(-0.0047222596f), + Q31(-0.0055337211f), Q31(-0.0063792293f), Q31(-0.0072615816f), Q31(-0.0081798233f), + Q31(-0.0091325329f), Q31(-0.0101150215f), Q31(-0.0111315548f), Q31(-0.0121849995f), + Q31( 0.0132718220f), Q31( 0.0143904666f), Q31( 0.0155405553f), Q31( 0.0167324712f), + Q31( 0.0179433381f), Q31( 0.0191872431f), Q31( 0.0204531793f), Q31( 0.0217467550f), + Q31( 0.0230680169f), Q31( 0.0244160992f), Q31( 0.0257875847f), Q31( 0.0271859429f), + Q31( 0.0286072173f), Q31( 0.0300502657f), Q31( 0.0315017608f), Q31( 0.0329754081f), + Q31( 0.0344620948f), Q31( 0.0359697560f), Q31( 0.0374812850f), Q31( 0.0390053679f), + Q31( 0.0405349170f), Q31( 0.0420649094f), Q31( 0.0436097542f), Q31( 0.0451488405f), + Q31( 0.0466843027f), Q31( 0.0482165720f), Q31( 0.0497385755f), Q31( 0.0512556155f), + Q31( 0.0527630746f), Q31( 0.0542452768f), Q31( 0.0557173648f), Q31( 0.0571616450f), + Q31( 0.0585915683f), Q31( 0.0599837480f), Q31( 0.0613455171f), Q31( 0.0626857808f), + Q31( 0.0639715898f), Q31( 0.0652247106f), Q31( 0.0664367512f), Q31( 0.0676075985f), + Q31( 0.0687043828f), Q31( 0.0697630244f), Q31( 0.0707628710f), Q31( 0.0717002673f), + Q31( 0.0725682583f), Q31( 0.0733620255f), Q31( 0.0741003642f), Q31( 0.0747452558f), + Q31( 0.0753137336f), Q31( 0.0758008358f), Q31( 0.0761992479f), Q31( 0.0764992170f), + Q31( 0.0767093490f), Q31( 0.0768173975f), Q31( 0.0768230011f), Q31( 0.0767204924f), + Q31( 0.0765050718f), Q31( 0.0761748321f), Q31( 0.0757305756f), Q31( 0.0751576255f), + Q31( 0.0744664394f), Q31( 0.0736406005f), Q31( 0.0726774642f), Q31( 0.0715826364f), + Q31( 0.0703533073f), Q31( 0.0689664013f), Q31( 0.0674525021f), Q31( 0.0657690668f), + Q31( 0.0639444805f), Q31( 0.0619602779f), Q31( 0.0598166570f), Q31( 0.0575152691f), + Q31( 0.0550460034f), Q31( 0.0524093821f), Q31( 0.0495978676f), Q31( 0.0466303305f), + Q31( 0.0434768782f), Q31( 0.0401458278f), Q31( 0.0366418116f), Q31( 0.0329583930f), + Q31( 0.0290824006f), Q31( 0.0250307561f), Q31( 0.0207997072f), Q31( 0.0163701258f), + Q31( 0.0117623832f), Q31( 0.0069636862f), Q31( 0.0019765601f), Q31(-0.0032086896f), + Q31(-0.0085711749f), Q31(-0.0141288827f), Q31(-0.0198834129f), Q31(-0.0258227288f), + Q31(-0.0319531274f), Q31(-0.0382776572f), Q31(-0.0447806821f), Q31(-0.0514804176f), + Q31(-0.0583705326f), Q31(-0.0654409853f), Q31(-0.0726943300f), Q31(-0.0801372934f), + Q31(-0.0877547536f), Q31(-0.0955533352f), Q31(-0.1035329531f), Q31(-0.1116826931f), + Q31(-0.1200077984f), Q31(-0.1285002850f), Q31(-0.1371551761f), Q31(-0.1459766491f), + Q31(-0.1549607071f), Q31(-0.1640958855f), Q31(-0.1733808172f), Q31(-0.1828172548f), + Q31(-0.1923966745f), Q31(-0.2021250176f), Q31(-0.2119735853f), Q31(-0.2219652696f), + Q31(-0.2320690870f), Q31(-0.2423016884f), Q31(-0.2526480309f), Q31(-0.2631053299f), + Q31(-0.2736634040f), Q31(-0.2843214189f), Q31(-0.2950716717f), Q31(-0.3059098575f), + Q31(-0.3168278913f), Q31(-0.3278113727f), Q31(-0.3388722693f), Q31(-0.3499914122f), + Q31( 0.3611589903f), Q31( 0.3723795546f), Q31( 0.3836350013f), Q31( 0.3949211761f), + Q31( 0.4062317676f), Q31( 0.4175696896f), Q31( 0.4289119920f), Q31( 0.4402553754f), + Q31( 0.4515996535f), Q31( 0.4629308085f), Q31( 0.4742453214f), Q31( 0.4855253091f), + Q31( 0.4967708254f), Q31( 0.5079817500f), Q31( 0.5191234970f), Q31( 0.5302240895f), + Q31( 0.5412553448f), Q31( 0.5522051258f), Q31( 0.5630789140f), Q31( 0.5738524131f), + Q31( 0.5845403235f), Q31( 0.5951123086f), Q31( 0.6055783538f), Q31( 0.6159109932f), + Q31( 0.6261242695f), Q31( 0.6361980107f), Q31( 0.6461269695f), Q31( 0.6559016302f), + Q31( 0.6655139880f), Q31( 0.6749663190f), Q31( 0.6842353293f), Q31( 0.6933282376f), + Q31( 0.7022388719f), Q31( 0.7109410426f), Q31( 0.7194462634f), Q31( 0.7277448900f), + Q31( 0.7358211758f), Q31( 0.7436827863f), Q31( 0.7513137456f), Q31( 0.7587080760f), + Q31( 0.7658674865f), Q31( 0.7727780881f), Q31( 0.7794287519f), Q31( 0.7858353120f), + Q31( 0.7919735841f), Q31( 0.7978466413f), Q31( 0.8034485751f), Q31( 0.8087695004f), + Q31( 0.8138191270f), Q31( 0.8185776004f), Q31( 0.8230419890f), Q31( 0.8272275347f), + Q31( 0.8311038457f), Q31( 0.8346937361f), Q31( 0.8379717337f), Q31( 0.8409541392f), + Q31( 0.8436238281f), Q31( 0.8459818469f), Q31( 0.8480315777f), Q31( 0.8497805198f), + Q31( 0.8511971524f), Q31( 0.8523047035f), Q31( 0.8531020949f), Q31( 0.8535720573f), + Q31( 0.8537385600f), }; /* First eight entries repeated at end to simplify SIMD implementations. */ -const DECLARE_ALIGNED(16, float, ff_sbr_noise_table)[][2] = { -{-0.99948153278296, -0.59483417516607}, { 0.97113454393991, -0.67528515225647}, -{ 0.14130051758487, -0.95090983575689}, {-0.47005496701697, -0.37340549728647}, -{ 0.80705063769351, 0.29653668284408}, {-0.38981478896926, 0.89572605717087}, -{-0.01053049862020, -0.66959058036166}, {-0.91266367957293, -0.11522938140034}, -{ 0.54840422910309, 0.75221367176302}, { 0.40009252867955, -0.98929400334421}, -{-0.99867974711855, -0.88147068645358}, {-0.95531076805040, 0.90908757154593}, -{-0.45725933317144, -0.56716323646760}, {-0.72929675029275, -0.98008272727324}, -{ 0.75622801399036, 0.20950329995549}, { 0.07069442601050, -0.78247898470706}, -{ 0.74496252926055, -0.91169004445807}, {-0.96440182703856, -0.94739918296622}, -{ 0.30424629369539, -0.49438267012479}, { 0.66565033746925, 0.64652935542491}, -{ 0.91697008020594, 0.17514097332009}, {-0.70774918760427, 0.52548653416543}, -{-0.70051415345560, -0.45340028808763}, {-0.99496513054797, -0.90071908066973}, -{ 0.98164490790123, -0.77463155528697}, {-0.54671580548181, -0.02570928536004}, -{-0.01689629065389, 0.00287506445732}, {-0.86110349531986, 0.42548583726477}, -{-0.98892980586032, -0.87881132267556}, { 0.51756627678691, 0.66926784710139}, -{-0.99635026409640, -0.58107730574765}, {-0.99969370862163, 0.98369989360250}, -{ 0.55266258627194, 0.59449057465591}, { 0.34581177741673, 0.94879421061866}, -{ 0.62664209577999, -0.74402970906471}, {-0.77149701404973, -0.33883658042801}, -{-0.91592244254432, 0.03687901376713}, {-0.76285492357887, -0.91371867919124}, -{ 0.79788337195331, -0.93180971199849}, { 0.54473080610200, -0.11919206037186}, -{-0.85639281671058, 0.42429854760451}, {-0.92882402971423, 0.27871809078609}, -{-0.11708371046774, -0.99800843444966}, { 0.21356749817493, -0.90716295627033}, -{-0.76191692573909, 0.99768118356265}, { 0.98111043100884, -0.95854459734407}, -{-0.85913269895572, 0.95766566168880}, {-0.93307242253692, 0.49431757696466}, -{ 0.30485754879632, -0.70540034357529}, { 0.85289650925190, 0.46766131791044}, -{ 0.91328082618125, -0.99839597361769}, {-0.05890199924154, 0.70741827819497}, -{ 0.28398686150148, 0.34633555702188}, { 0.95258164539612, -0.54893416026939}, -{-0.78566324168507, -0.75568541079691}, {-0.95789495447877, -0.20423194696966}, -{ 0.82411158711197, 0.96654618432562}, {-0.65185446735885, -0.88734990773289}, -{-0.93643603134666, 0.99870790442385}, { 0.91427159529618, -0.98290505544444}, -{-0.70395684036886, 0.58796798221039}, { 0.00563771969365, 0.61768196727244}, -{ 0.89065051931895, 0.52783352697585}, {-0.68683707712762, 0.80806944710339}, -{ 0.72165342518718, -0.69259857349564}, {-0.62928247730667, 0.13627037407335}, -{ 0.29938434065514, -0.46051329682246}, {-0.91781958879280, -0.74012716684186}, -{ 0.99298717043688, 0.40816610075661}, { 0.82368298622748, -0.74036047190173}, -{-0.98512833386833, -0.99972330709594}, {-0.95915368242257, -0.99237800466040}, -{-0.21411126572790, -0.93424819052545}, {-0.68821476106884, -0.26892306315457}, -{ 0.91851997982317, 0.09358228901785}, {-0.96062769559127, 0.36099095133739}, -{ 0.51646184922287, -0.71373332873917}, { 0.61130721139669, 0.46950141175917}, -{ 0.47336129371299, -0.27333178296162}, { 0.90998308703519, 0.96715662938132}, -{ 0.44844799194357, 0.99211574628306}, { 0.66614891079092, 0.96590176169121}, -{ 0.74922239129237, -0.89879858826087}, {-0.99571588506485, 0.52785521494349}, -{ 0.97401082477563, -0.16855870075190}, { 0.72683747733879, -0.48060774432251}, -{ 0.95432193457128, 0.68849603408441}, {-0.72962208425191, -0.76608443420917}, -{-0.85359479233537, 0.88738125901579}, {-0.81412430338535, -0.97480768049637}, -{-0.87930772356786, 0.74748307690436}, {-0.71573331064977, -0.98570608178923}, -{ 0.83524300028228, 0.83702537075163}, {-0.48086065601423, -0.98848504923531}, -{ 0.97139128574778, 0.80093621198236}, { 0.51992825347895, 0.80247631400510}, -{-0.00848591195325, -0.76670128000486}, {-0.70294374303036, 0.55359910445577}, -{-0.95894428168140, -0.43265504344783}, { 0.97079252950321, 0.09325857238682}, -{-0.92404293670797, 0.85507704027855}, {-0.69506469500450, 0.98633412625459}, -{ 0.26559203620024, 0.73314307966524}, { 0.28038443336943, 0.14537913654427}, -{-0.74138124825523, 0.99310339807762}, {-0.01752795995444, -0.82616635284178}, -{-0.55126773094930, -0.98898543862153}, { 0.97960898850996, -0.94021446752851}, -{-0.99196309146936, 0.67019017358456}, {-0.67684928085260, 0.12631491649378}, -{ 0.09140039465500, -0.20537731453108}, {-0.71658965751996, -0.97788200391224}, -{ 0.81014640078925, 0.53722648362443}, { 0.40616991671205, -0.26469008598449}, -{-0.67680188682972, 0.94502052337695}, { 0.86849774348749, -0.18333598647899}, -{-0.99500381284851, -0.02634122068550}, { 0.84329189340667, 0.10406957462213}, -{-0.09215968531446, 0.69540012101253}, { 0.99956173327206, -0.12358542001404}, -{-0.79732779473535, -0.91582524736159}, { 0.96349973642406, 0.96640458041000}, -{-0.79942778496547, 0.64323902822857}, {-0.11566039853896, 0.28587846253726}, -{-0.39922954514662, 0.94129601616966}, { 0.99089197565987, -0.92062625581587}, -{ 0.28631285179909, -0.91035047143603}, {-0.83302725605608, -0.67330410892084}, -{ 0.95404443402072, 0.49162765398743}, {-0.06449863579434, 0.03250560813135}, -{-0.99575054486311, 0.42389784469507}, {-0.65501142790847, 0.82546114655624}, -{-0.81254441908887, -0.51627234660629}, {-0.99646369485481, 0.84490533520752}, -{ 0.00287840603348, 0.64768261158166}, { 0.70176989408455, -0.20453028573322}, -{ 0.96361882270190, 0.40706967140989}, {-0.68883758192426, 0.91338958840772}, -{-0.34875585502238, 0.71472290693300}, { 0.91980081243087, 0.66507455644919}, -{-0.99009048343881, 0.85868021604848}, { 0.68865791458395, 0.55660316809678}, -{-0.99484402129368, -0.20052559254934}, { 0.94214511408023, -0.99696425367461}, -{-0.67414626793544, 0.49548221180078}, {-0.47339353684664, -0.85904328834047}, -{ 0.14323651387360, -0.94145598222488}, {-0.29268293575672, 0.05759224927952}, -{ 0.43793861458754, -0.78904969892724}, {-0.36345126374441, 0.64874435357162}, -{-0.08750604656825, 0.97686944362527}, {-0.96495267812511, -0.53960305946511}, -{ 0.55526940659947, 0.78891523734774}, { 0.73538215752630, 0.96452072373404}, -{-0.30889773919437, -0.80664389776860}, { 0.03574995626194, -0.97325616900959}, -{ 0.98720684660488, 0.48409133691962}, {-0.81689296271203, -0.90827703628298}, -{ 0.67866860118215, 0.81284503870856}, {-0.15808569732583, 0.85279555024382}, -{ 0.80723395114371, -0.24717418514605}, { 0.47788757329038, -0.46333147839295}, -{ 0.96367554763201, 0.38486749303242}, {-0.99143875716818, -0.24945277239809}, -{ 0.83081876925833, -0.94780851414763}, {-0.58753191905341, 0.01290772389163}, -{ 0.95538108220960, -0.85557052096538}, {-0.96490920476211, -0.64020970923102}, -{-0.97327101028521, 0.12378128133110}, { 0.91400366022124, 0.57972471346930}, -{-0.99925837363824, 0.71084847864067}, {-0.86875903507313, -0.20291699203564}, -{-0.26240034795124, -0.68264554369108}, {-0.24664412953388, -0.87642273115183}, -{ 0.02416275806869, 0.27192914288905}, { 0.82068619590515, -0.85087787994476}, -{ 0.88547373760759, -0.89636802901469}, {-0.18173078152226, -0.26152145156800}, -{ 0.09355476558534, 0.54845123045604}, {-0.54668414224090, 0.95980774020221}, -{ 0.37050990604091, -0.59910140383171}, {-0.70373594262891, 0.91227665827081}, -{-0.34600785879594, -0.99441426144200}, {-0.68774481731008, -0.30238837956299}, -{-0.26843291251234, 0.83115668004362}, { 0.49072334613242, -0.45359708737775}, -{ 0.38975993093975, 0.95515358099121}, {-0.97757125224150, 0.05305894580606}, -{-0.17325552859616, -0.92770672250494}, { 0.99948035025744, 0.58285545563426}, -{-0.64946246527458, 0.68645507104960}, {-0.12016920576437, -0.57147322153312}, -{-0.58947456517751, -0.34847132454388}, {-0.41815140454465, 0.16276422358861}, -{ 0.99885650204884, 0.11136095490444}, {-0.56649614128386, -0.90494866361587}, -{ 0.94138021032330, 0.35281916733018}, {-0.75725076534641, 0.53650549640587}, -{ 0.20541973692630, -0.94435144369918}, { 0.99980371023351, 0.79835913565599}, -{ 0.29078277605775, 0.35393777921520}, {-0.62858772103030, 0.38765693387102}, -{ 0.43440904467688, -0.98546330463232}, {-0.98298583762390, 0.21021524625209}, -{ 0.19513029146934, -0.94239832251867}, {-0.95476662400101, 0.98364554179143}, -{ 0.93379635304810, -0.70881994583682}, {-0.85235410573336, -0.08342347966410}, -{-0.86425093011245, -0.45795025029466}, { 0.38879779059045, 0.97274429344593}, -{ 0.92045124735495, -0.62433652524220}, { 0.89162532251878, 0.54950955570563}, -{-0.36834336949252, 0.96458298020975}, { 0.93891760988045, -0.89968353740388}, -{ 0.99267657565094, -0.03757034316958}, {-0.94063471614176, 0.41332338538963}, -{ 0.99740224117019, -0.16830494996370}, {-0.35899413170555, -0.46633226649613}, -{ 0.05237237274947, -0.25640361602661}, { 0.36703583957424, -0.38653265641875}, -{ 0.91653180367913, -0.30587628726597}, { 0.69000803499316, 0.90952171386132}, -{-0.38658751133527, 0.99501571208985}, {-0.29250814029851, 0.37444994344615}, -{-0.60182204677608, 0.86779651036123}, {-0.97418588163217, 0.96468523666475}, -{ 0.88461574003963, 0.57508405276414}, { 0.05198933055162, 0.21269661669964}, -{-0.53499621979720, 0.97241553731237}, {-0.49429560226497, 0.98183865291903}, -{-0.98935142339139, -0.40249159006933}, {-0.98081380091130, -0.72856895534041}, -{-0.27338148835532, 0.99950922447209}, { 0.06310802338302, -0.54539587529618}, -{-0.20461677199539, -0.14209977628489}, { 0.66223843141647, 0.72528579940326}, -{-0.84764345483665, 0.02372316801261}, {-0.89039863483811, 0.88866581484602}, -{ 0.95903308477986, 0.76744927173873}, { 0.73504123909879, -0.03747203173192}, -{-0.31744434966056, -0.36834111883652}, {-0.34110827591623, 0.40211222807691}, -{ 0.47803883714199, -0.39423219786288}, { 0.98299195879514, 0.01989791390047}, -{-0.30963073129751, -0.18076720599336}, { 0.99992588229018, -0.26281872094289}, -{-0.93149731080767, -0.98313162570490}, { 0.99923472302773, -0.80142993767554}, -{-0.26024169633417, -0.75999759855752}, {-0.35712514743563, 0.19298963768574}, -{-0.99899084509530, 0.74645156992493}, { 0.86557171579452, 0.55593866696299}, -{ 0.33408042438752, 0.86185953874709}, { 0.99010736374716, 0.04602397576623}, -{-0.66694269691195, -0.91643611810148}, { 0.64016792079480, 0.15649530836856}, -{ 0.99570534804836, 0.45844586038111}, {-0.63431466947340, 0.21079116459234}, -{-0.07706847005931, -0.89581437101329}, { 0.98590090577724, 0.88241721133981}, -{ 0.80099335254678, -0.36851896710853}, { 0.78368131392666, 0.45506999802597}, -{ 0.08707806671691, 0.80938994918745}, {-0.86811883080712, 0.39347308654705}, -{-0.39466529740375, -0.66809432114456}, { 0.97875325649683, -0.72467840967746}, -{-0.95038560288864, 0.89563219587625}, { 0.17005239424212, 0.54683053962658}, -{-0.76910792026848, -0.96226617549298}, { 0.99743281016846, 0.42697157037567}, -{ 0.95437383549973, 0.97002324109952}, { 0.99578905365569, -0.54106826257356}, -{ 0.28058259829990, -0.85361420634036}, { 0.85256524470573, -0.64567607735589}, -{-0.50608540105128, -0.65846015480300}, {-0.97210735183243, -0.23095213067791}, -{ 0.95424048234441, -0.99240147091219}, {-0.96926570524023, 0.73775654896574}, -{ 0.30872163214726, 0.41514960556126}, {-0.24523839572639, 0.63206633394807}, -{-0.33813265086024, -0.38661779441897}, {-0.05826828420146, -0.06940774188029}, -{-0.22898461455054, 0.97054853316316}, {-0.18509915019881, 0.47565762892084}, -{-0.10488238045009, -0.87769947402394}, {-0.71886586182037, 0.78030982480538}, -{ 0.99793873738654, 0.90041310491497}, { 0.57563307626120, -0.91034337352097}, -{ 0.28909646383717, 0.96307783970534}, { 0.42188998312520, 0.48148651230437}, -{ 0.93335049681047, -0.43537023883588}, {-0.97087374418267, 0.86636445711364}, -{ 0.36722871286923, 0.65291654172961}, {-0.81093025665696, 0.08778370229363}, -{-0.26240603062237, -0.92774095379098}, { 0.83996497984604, 0.55839849139647}, -{-0.99909615720225, -0.96024605713970}, { 0.74649464155061, 0.12144893606462}, -{-0.74774595569805, -0.26898062008959}, { 0.95781667469567, -0.79047927052628}, -{ 0.95472308713099, -0.08588776019550}, { 0.48708332746299, 0.99999041579432}, -{ 0.46332038247497, 0.10964126185063}, {-0.76497004940162, 0.89210929242238}, -{ 0.57397389364339, 0.35289703373760}, { 0.75374316974495, 0.96705214651335}, -{-0.59174397685714, -0.89405370422752}, { 0.75087906691890, -0.29612672982396}, -{-0.98607857336230, 0.25034911730023}, {-0.40761056640505, -0.90045573444695}, -{ 0.66929266740477, 0.98629493401748}, {-0.97463695257310, -0.00190223301301}, -{ 0.90145509409859, 0.99781390365446}, {-0.87259289048043, 0.99233587353666}, -{-0.91529461447692, -0.15698707534206}, {-0.03305738840705, -0.37205262859764}, -{ 0.07223051368337, -0.88805001733626}, { 0.99498012188353, 0.97094358113387}, -{-0.74904939500519, 0.99985483641521}, { 0.04585228574211, 0.99812337444082}, -{-0.89054954257993, -0.31791913188064}, {-0.83782144651251, 0.97637632547466}, -{ 0.33454804933804, -0.86231516800408}, {-0.99707579362824, 0.93237990079441}, -{-0.22827527843994, 0.18874759397997}, { 0.67248046289143, -0.03646211390569}, -{-0.05146538187944, -0.92599700120679}, { 0.99947295749905, 0.93625229707912}, -{ 0.66951124390363, 0.98905825623893}, {-0.99602956559179, -0.44654715757688}, -{ 0.82104905483590, 0.99540741724928}, { 0.99186510988782, 0.72023001312947}, -{-0.65284592392918, 0.52186723253637}, { 0.93885443798188, -0.74895312615259}, -{ 0.96735248738388, 0.90891816978629}, {-0.22225968841114, 0.57124029781228}, -{-0.44132783753414, -0.92688840659280}, {-0.85694974219574, 0.88844532719844}, -{ 0.91783042091762, -0.46356892383970}, { 0.72556974415690, -0.99899555770747}, -{-0.99711581834508, 0.58211560180426}, { 0.77638976371966, 0.94321834873819}, -{ 0.07717324253925, 0.58638399856595}, {-0.56049829194163, 0.82522301569036}, -{ 0.98398893639988, 0.39467440420569}, { 0.47546946844938, 0.68613044836811}, -{ 0.65675089314631, 0.18331637134880}, { 0.03273375457980, -0.74933109564108}, -{-0.38684144784738, 0.51337349030406}, {-0.97346267944545, -0.96549364384098}, -{-0.53282156061942, -0.91423265091354}, { 0.99817310731176, 0.61133572482148}, -{-0.50254500772635, -0.88829338134294}, { 0.01995873238855, 0.85223515096765}, -{ 0.99930381973804, 0.94578896296649}, { 0.82907767600783, -0.06323442598128}, -{-0.58660709669728, 0.96840773806582}, {-0.17573736667267, -0.48166920859485}, -{ 0.83434292401346, -0.13023450646997}, { 0.05946491307025, 0.20511047074866}, -{ 0.81505484574602, -0.94685947861369}, {-0.44976380954860, 0.40894572671545}, -{-0.89746474625671, 0.99846578838537}, { 0.39677256130792, -0.74854668609359}, -{-0.07588948563079, 0.74096214084170}, { 0.76343198951445, 0.41746629422634}, -{-0.74490104699626, 0.94725911744610}, { 0.64880119792759, 0.41336660830571}, -{ 0.62319537462542, -0.93098313552599}, { 0.42215817594807, -0.07712787385208}, -{ 0.02704554141885, -0.05417518053666}, { 0.80001773566818, 0.91542195141039}, -{-0.79351832348816, -0.36208897989136}, { 0.63872359151636, 0.08128252493444}, -{ 0.52890520960295, 0.60048872455592}, { 0.74238552914587, 0.04491915291044}, -{ 0.99096131449250, -0.19451182854402}, {-0.80412329643109, -0.88513818199457}, -{-0.64612616129736, 0.72198674804544}, { 0.11657770663191, -0.83662833815041}, -{-0.95053182488101, -0.96939905138082}, {-0.62228872928622, 0.82767262846661}, -{ 0.03004475787316, -0.99738896333384}, {-0.97987214341034, 0.36526129686425}, -{-0.99986980746200, -0.36021610299715}, { 0.89110648599879, -0.97894250343044}, -{ 0.10407960510582, 0.77357793811619}, { 0.95964737821728, -0.35435818285502}, -{ 0.50843233159162, 0.96107691266205}, { 0.17006334670615, -0.76854025314829}, -{ 0.25872675063360, 0.99893303933816}, {-0.01115998681937, 0.98496019742444}, -{-0.79598702973261, 0.97138411318894}, {-0.99264708948101, -0.99542822402536}, -{-0.99829663752818, 0.01877138824311}, {-0.70801016548184, 0.33680685948117}, -{-0.70467057786826, 0.93272777501857}, { 0.99846021905254, -0.98725746254433}, -{-0.63364968534650, -0.16473594423746}, {-0.16258217500792, -0.95939125400802}, -{-0.43645594360633, -0.94805030113284}, {-0.99848471702976, 0.96245166923809}, -{-0.16796458968998, -0.98987511890470}, {-0.87979225745213, -0.71725725041680}, -{ 0.44183099021786, -0.93568974498761}, { 0.93310180125532, -0.99913308068246}, -{-0.93941931782002, -0.56409379640356}, {-0.88590003188677, 0.47624600491382}, -{ 0.99971463703691, -0.83889954253462}, {-0.75376385639978, 0.00814643438625}, -{ 0.93887685615875, -0.11284528204636}, { 0.85126435782309, 0.52349251543547}, -{ 0.39701421446381, 0.81779634174316}, {-0.37024464187437, -0.87071656222959}, -{-0.36024828242896, 0.34655735648287}, {-0.93388812549209, -0.84476541096429}, -{-0.65298804552119, -0.18439575450921}, { 0.11960319006843, 0.99899346780168}, -{ 0.94292565553160, 0.83163906518293}, { 0.75081145286948, -0.35533223142265}, -{ 0.56721979748394, -0.24076836414499}, { 0.46857766746029, -0.30140233457198}, -{ 0.97312313923635, -0.99548191630031}, {-0.38299976567017, 0.98516909715427}, -{ 0.41025800019463, 0.02116736935734}, { 0.09638062008048, 0.04411984381457}, -{-0.85283249275397, 0.91475563922421}, { 0.88866808958124, -0.99735267083226}, -{-0.48202429536989, -0.96805608884164}, { 0.27572582416567, 0.58634753335832}, -{-0.65889129659168, 0.58835634138583}, { 0.98838086953732, 0.99994349600236}, -{-0.20651349620689, 0.54593044066355}, {-0.62126416356920, -0.59893681700392}, -{ 0.20320105410437, -0.86879180355289}, {-0.97790548600584, 0.96290806999242}, -{ 0.11112534735126, 0.21484763313301}, {-0.41368337314182, 0.28216837680365}, -{ 0.24133038992960, 0.51294362630238}, {-0.66393410674885, -0.08249679629081}, -{-0.53697829178752, -0.97649903936228}, {-0.97224737889348, 0.22081333579837}, -{ 0.87392477144549, -0.12796173740361}, { 0.19050361015753, 0.01602615387195}, -{-0.46353441212724, -0.95249041539006}, {-0.07064096339021, -0.94479803205886}, -{-0.92444085484466, -0.10457590187436}, {-0.83822593578728, -0.01695043208885}, -{ 0.75214681811150, -0.99955681042665}, {-0.42102998829339, 0.99720941999394}, -{-0.72094786237696, -0.35008961934255}, { 0.78843311019251, 0.52851398958271}, -{ 0.97394027897442, -0.26695944086561}, { 0.99206463477946, -0.57010120849429}, -{ 0.76789609461795, -0.76519356730966}, {-0.82002421836409, -0.73530179553767}, -{ 0.81924990025724, 0.99698425250579}, {-0.26719850873357, 0.68903369776193}, -{-0.43311260380975, 0.85321815947490}, { 0.99194979673836, 0.91876249766422}, -{-0.80692001248487, -0.32627540663214}, { 0.43080003649976, -0.21919095636638}, -{ 0.67709491937357, -0.95478075822906}, { 0.56151770568316, -0.70693811747778}, -{ 0.10831862810749, -0.08628837174592}, { 0.91229417540436, -0.65987351408410}, -{-0.48972893932274, 0.56289246362686}, {-0.89033658689697, -0.71656563987082}, -{ 0.65269447475094, 0.65916004833932}, { 0.67439478141121, -0.81684380846796}, -{-0.47770832416973, -0.16789556203025}, {-0.99715979260878, -0.93565784007648}, -{-0.90889593602546, 0.62034397054380}, {-0.06618622548177, -0.23812217221359}, -{ 0.99430266919728, 0.18812555317553}, { 0.97686402381843, -0.28664534366620}, -{ 0.94813650221268, -0.97506640027128}, {-0.95434497492853, -0.79607978501983}, -{-0.49104783137150, 0.32895214359663}, { 0.99881175120751, 0.88993983831354}, -{ 0.50449166760303, -0.85995072408434}, { 0.47162891065108, -0.18680204049569}, -{-0.62081581361840, 0.75000676218956}, {-0.43867015250812, 0.99998069244322}, -{ 0.98630563232075, -0.53578899600662}, {-0.61510362277374, -0.89515019899997}, -{-0.03841517601843, -0.69888815681179}, {-0.30102157304644, -0.07667808922205}, -{ 0.41881284182683, 0.02188098922282}, {-0.86135454941237, 0.98947480909359}, -{ 0.67226861393788, -0.13494389011014}, {-0.70737398842068, -0.76547349325992}, -{ 0.94044946687963, 0.09026201157416}, {-0.82386352534327, 0.08924768823676}, -{-0.32070666698656, 0.50143421908753}, { 0.57593163224487, -0.98966422921509}, -{-0.36326018419965, 0.07440243123228}, { 0.99979044674350, -0.14130287347405}, -{-0.92366023326932, -0.97979298068180}, {-0.44607178518598, -0.54233252016394}, -{ 0.44226800932956, 0.71326756742752}, { 0.03671907158312, 0.63606389366675}, -{ 0.52175424682195, -0.85396826735705}, {-0.94701139690956, -0.01826348194255}, -{-0.98759606946049, 0.82288714303073}, { 0.87434794743625, 0.89399495655433}, -{-0.93412041758744, 0.41374052024363}, { 0.96063943315511, 0.93116709541280}, -{ 0.97534253457837, 0.86150930812689}, { 0.99642466504163, 0.70190043427512}, -{-0.94705089665984, -0.29580042814306}, { 0.91599807087376, -0.98147830385781}, +const DECLARE_ALIGNED(16, INTFLOAT, AAC_RENAME(ff_sbr_noise_table))[][2] = { +{Q31(-0.99948153278296f), Q31(-0.59483417516607f)}, {Q31( 0.97113454393991f), Q31(-0.67528515225647f)}, +{Q31( 0.14130051758487f), Q31(-0.95090983575689f)}, {Q31(-0.47005496701697f), Q31(-0.37340549728647f)}, +{Q31( 0.80705063769351f), Q31( 0.29653668284408f)}, {Q31(-0.38981478896926f), Q31( 0.89572605717087f)}, +{Q31(-0.01053049862020f), Q31(-0.66959058036166f)}, {Q31(-0.91266367957293f), Q31(-0.11522938140034f)}, +{Q31( 0.54840422910309f), Q31( 0.75221367176302f)}, {Q31( 0.40009252867955f), Q31(-0.98929400334421f)}, +{Q31(-0.99867974711855f), Q31(-0.88147068645358f)}, {Q31(-0.95531076805040f), Q31( 0.90908757154593f)}, +{Q31(-0.45725933317144f), Q31(-0.56716323646760f)}, {Q31(-0.72929675029275f), Q31(-0.98008272727324f)}, +{Q31( 0.75622801399036f), Q31( 0.20950329995549f)}, {Q31( 0.07069442601050f), Q31(-0.78247898470706f)}, +{Q31( 0.74496252926055f), Q31(-0.91169004445807f)}, {Q31(-0.96440182703856f), Q31(-0.94739918296622f)}, +{Q31( 0.30424629369539f), Q31(-0.49438267012479f)}, {Q31( 0.66565033746925f), Q31( 0.64652935542491f)}, +{Q31( 0.91697008020594f), Q31( 0.17514097332009f)}, {Q31(-0.70774918760427f), Q31( 0.52548653416543f)}, +{Q31(-0.70051415345560f), Q31(-0.45340028808763f)}, {Q31(-0.99496513054797f), Q31(-0.90071908066973f)}, +{Q31( 0.98164490790123f), Q31(-0.77463155528697f)}, {Q31(-0.54671580548181f), Q31(-0.02570928536004f)}, +{Q31(-0.01689629065389f), Q31( 0.00287506445732f)}, {Q31(-0.86110349531986f), Q31( 0.42548583726477f)}, +{Q31(-0.98892980586032f), Q31(-0.87881132267556f)}, {Q31( 0.51756627678691f), Q31( 0.66926784710139f)}, +{Q31(-0.99635026409640f), Q31(-0.58107730574765f)}, {Q31(-0.99969370862163f), Q31( 0.98369989360250f)}, +{Q31( 0.55266258627194f), Q31( 0.59449057465591f)}, {Q31( 0.34581177741673f), Q31( 0.94879421061866f)}, +{Q31( 0.62664209577999f), Q31(-0.74402970906471f)}, {Q31(-0.77149701404973f), Q31(-0.33883658042801f)}, +{Q31(-0.91592244254432f), Q31( 0.03687901376713f)}, {Q31(-0.76285492357887f), Q31(-0.91371867919124f)}, +{Q31( 0.79788337195331f), Q31(-0.93180971199849f)}, {Q31( 0.54473080610200f), Q31(-0.11919206037186f)}, +{Q31(-0.85639281671058f), Q31( 0.42429854760451f)}, {Q31(-0.92882402971423f), Q31( 0.27871809078609f)}, +{Q31(-0.11708371046774f), Q31(-0.99800843444966f)}, {Q31( 0.21356749817493f), Q31(-0.90716295627033f)}, +{Q31(-0.76191692573909f), Q31( 0.99768118356265f)}, {Q31( 0.98111043100884f), Q31(-0.95854459734407f)}, +{Q31(-0.85913269895572f), Q31( 0.95766566168880f)}, {Q31(-0.93307242253692f), Q31( 0.49431757696466f)}, +{Q31( 0.30485754879632f), Q31(-0.70540034357529f)}, {Q31( 0.85289650925190f), Q31( 0.46766131791044f)}, +{Q31( 0.91328082618125f), Q31(-0.99839597361769f)}, {Q31(-0.05890199924154f), Q31( 0.70741827819497f)}, +{Q31( 0.28398686150148f), Q31( 0.34633555702188f)}, {Q31( 0.95258164539612f), Q31(-0.54893416026939f)}, +{Q31(-0.78566324168507f), Q31(-0.75568541079691f)}, {Q31(-0.95789495447877f), Q31(-0.20423194696966f)}, +{Q31( 0.82411158711197f), Q31( 0.96654618432562f)}, {Q31(-0.65185446735885f), Q31(-0.88734990773289f)}, +{Q31(-0.93643603134666f), Q31( 0.99870790442385f)}, {Q31( 0.91427159529618f), Q31(-0.98290505544444f)}, +{Q31(-0.70395684036886f), Q31( 0.58796798221039f)}, {Q31( 0.00563771969365f), Q31( 0.61768196727244f)}, +{Q31( 0.89065051931895f), Q31( 0.52783352697585f)}, {Q31(-0.68683707712762f), Q31( 0.80806944710339f)}, +{Q31( 0.72165342518718f), Q31(-0.69259857349564f)}, {Q31(-0.62928247730667f), Q31( 0.13627037407335f)}, +{Q31( 0.29938434065514f), Q31(-0.46051329682246f)}, {Q31(-0.91781958879280f), Q31(-0.74012716684186f)}, +{Q31( 0.99298717043688f), Q31( 0.40816610075661f)}, {Q31( 0.82368298622748f), Q31(-0.74036047190173f)}, +{Q31(-0.98512833386833f), Q31(-0.99972330709594f)}, {Q31(-0.95915368242257f), Q31(-0.99237800466040f)}, +{Q31(-0.21411126572790f), Q31(-0.93424819052545f)}, {Q31(-0.68821476106884f), Q31(-0.26892306315457f)}, +{Q31( 0.91851997982317f), Q31( 0.09358228901785f)}, {Q31(-0.96062769559127f), Q31( 0.36099095133739f)}, +{Q31( 0.51646184922287f), Q31(-0.71373332873917f)}, {Q31( 0.61130721139669f), Q31( 0.46950141175917f)}, +{Q31( 0.47336129371299f), Q31(-0.27333178296162f)}, {Q31( 0.90998308703519f), Q31( 0.96715662938132f)}, +{Q31( 0.44844799194357f), Q31( 0.99211574628306f)}, {Q31( 0.66614891079092f), Q31( 0.96590176169121f)}, +{Q31( 0.74922239129237f), Q31(-0.89879858826087f)}, {Q31(-0.99571588506485f), Q31( 0.52785521494349f)}, +{Q31( 0.97401082477563f), Q31(-0.16855870075190f)}, {Q31( 0.72683747733879f), Q31(-0.48060774432251f)}, +{Q31( 0.95432193457128f), Q31( 0.68849603408441f)}, {Q31(-0.72962208425191f), Q31(-0.76608443420917f)}, +{Q31(-0.85359479233537f), Q31( 0.88738125901579f)}, {Q31(-0.81412430338535f), Q31(-0.97480768049637f)}, +{Q31(-0.87930772356786f), Q31( 0.74748307690436f)}, {Q31(-0.71573331064977f), Q31(-0.98570608178923f)}, +{Q31( 0.83524300028228f), Q31( 0.83702537075163f)}, {Q31(-0.48086065601423f), Q31(-0.98848504923531f)}, +{Q31( 0.97139128574778f), Q31( 0.80093621198236f)}, {Q31( 0.51992825347895f), Q31( 0.80247631400510f)}, +{Q31(-0.00848591195325f), Q31(-0.76670128000486f)}, {Q31(-0.70294374303036f), Q31( 0.55359910445577f)}, +{Q31(-0.95894428168140f), Q31(-0.43265504344783f)}, {Q31( 0.97079252950321f), Q31( 0.09325857238682f)}, +{Q31(-0.92404293670797f), Q31( 0.85507704027855f)}, {Q31(-0.69506469500450f), Q31( 0.98633412625459f)}, +{Q31( 0.26559203620024f), Q31( 0.73314307966524f)}, {Q31( 0.28038443336943f), Q31( 0.14537913654427f)}, +{Q31(-0.74138124825523f), Q31( 0.99310339807762f)}, {Q31(-0.01752795995444f), Q31(-0.82616635284178f)}, +{Q31(-0.55126773094930f), Q31(-0.98898543862153f)}, {Q31( 0.97960898850996f), Q31(-0.94021446752851f)}, +{Q31(-0.99196309146936f), Q31( 0.67019017358456f)}, {Q31(-0.67684928085260f), Q31( 0.12631491649378f)}, +{Q31( 0.09140039465500f), Q31(-0.20537731453108f)}, {Q31(-0.71658965751996f), Q31(-0.97788200391224f)}, +{Q31( 0.81014640078925f), Q31( 0.53722648362443f)}, {Q31( 0.40616991671205f), Q31(-0.26469008598449f)}, +{Q31(-0.67680188682972f), Q31( 0.94502052337695f)}, {Q31( 0.86849774348749f), Q31(-0.18333598647899f)}, +{Q31(-0.99500381284851f), Q31(-0.02634122068550f)}, {Q31( 0.84329189340667f), Q31( 0.10406957462213f)}, +{Q31(-0.09215968531446f), Q31( 0.69540012101253f)}, {Q31( 0.99956173327206f), Q31(-0.12358542001404f)}, +{Q31(-0.79732779473535f), Q31(-0.91582524736159f)}, {Q31( 0.96349973642406f), Q31( 0.96640458041000f)}, +{Q31(-0.79942778496547f), Q31( 0.64323902822857f)}, {Q31(-0.11566039853896f), Q31( 0.28587846253726f)}, +{Q31(-0.39922954514662f), Q31( 0.94129601616966f)}, {Q31( 0.99089197565987f), Q31(-0.92062625581587f)}, +{Q31( 0.28631285179909f), Q31(-0.91035047143603f)}, {Q31(-0.83302725605608f), Q31(-0.67330410892084f)}, +{Q31( 0.95404443402072f), Q31( 0.49162765398743f)}, {Q31(-0.06449863579434f), Q31( 0.03250560813135f)}, +{Q31(-0.99575054486311f), Q31( 0.42389784469507f)}, {Q31(-0.65501142790847f), Q31( 0.82546114655624f)}, +{Q31(-0.81254441908887f), Q31(-0.51627234660629f)}, {Q31(-0.99646369485481f), Q31( 0.84490533520752f)}, +{Q31( 0.00287840603348f), Q31( 0.64768261158166f)}, {Q31( 0.70176989408455f), Q31(-0.20453028573322f)}, +{Q31( 0.96361882270190f), Q31( 0.40706967140989f)}, {Q31(-0.68883758192426f), Q31( 0.91338958840772f)}, +{Q31(-0.34875585502238f), Q31( 0.71472290693300f)}, {Q31( 0.91980081243087f), Q31( 0.66507455644919f)}, +{Q31(-0.99009048343881f), Q31( 0.85868021604848f)}, {Q31( 0.68865791458395f), Q31( 0.55660316809678f)}, +{Q31(-0.99484402129368f), Q31(-0.20052559254934f)}, {Q31( 0.94214511408023f), Q31(-0.99696425367461f)}, +{Q31(-0.67414626793544f), Q31( 0.49548221180078f)}, {Q31(-0.47339353684664f), Q31(-0.85904328834047f)}, +{Q31( 0.14323651387360f), Q31(-0.94145598222488f)}, {Q31(-0.29268293575672f), Q31( 0.05759224927952f)}, +{Q31( 0.43793861458754f), Q31(-0.78904969892724f)}, {Q31(-0.36345126374441f), Q31( 0.64874435357162f)}, +{Q31(-0.08750604656825f), Q31( 0.97686944362527f)}, {Q31(-0.96495267812511f), Q31(-0.53960305946511f)}, +{Q31( 0.55526940659947f), Q31( 0.78891523734774f)}, {Q31( 0.73538215752630f), Q31( 0.96452072373404f)}, +{Q31(-0.30889773919437f), Q31(-0.80664389776860f)}, {Q31( 0.03574995626194f), Q31(-0.97325616900959f)}, +{Q31( 0.98720684660488f), Q31( 0.48409133691962f)}, {Q31(-0.81689296271203f), Q31(-0.90827703628298f)}, +{Q31( 0.67866860118215f), Q31( 0.81284503870856f)}, {Q31(-0.15808569732583f), Q31( 0.85279555024382f)}, +{Q31( 0.80723395114371f), Q31(-0.24717418514605f)}, {Q31( 0.47788757329038f), Q31(-0.46333147839295f)}, +{Q31( 0.96367554763201f), Q31( 0.38486749303242f)}, {Q31(-0.99143875716818f), Q31(-0.24945277239809f)}, +{Q31( 0.83081876925833f), Q31(-0.94780851414763f)}, {Q31(-0.58753191905341f), Q31( 0.01290772389163f)}, +{Q31( 0.95538108220960f), Q31(-0.85557052096538f)}, {Q31(-0.96490920476211f), Q31(-0.64020970923102f)}, +{Q31(-0.97327101028521f), Q31( 0.12378128133110f)}, {Q31( 0.91400366022124f), Q31( 0.57972471346930f)}, +{Q31(-0.99925837363824f), Q31( 0.71084847864067f)}, {Q31(-0.86875903507313f), Q31(-0.20291699203564f)}, +{Q31(-0.26240034795124f), Q31(-0.68264554369108f)}, {Q31(-0.24664412953388f), Q31(-0.87642273115183f)}, +{Q31( 0.02416275806869f), Q31( 0.27192914288905f)}, {Q31( 0.82068619590515f), Q31(-0.85087787994476f)}, +{Q31( 0.88547373760759f), Q31(-0.89636802901469f)}, {Q31(-0.18173078152226f), Q31(-0.26152145156800f)}, +{Q31( 0.09355476558534f), Q31( 0.54845123045604f)}, {Q31(-0.54668414224090f), Q31( 0.95980774020221f)}, +{Q31( 0.37050990604091f), Q31(-0.59910140383171f)}, {Q31(-0.70373594262891f), Q31( 0.91227665827081f)}, +{Q31(-0.34600785879594f), Q31(-0.99441426144200f)}, {Q31(-0.68774481731008f), Q31(-0.30238837956299f)}, +{Q31(-0.26843291251234f), Q31( 0.83115668004362f)}, {Q31( 0.49072334613242f), Q31(-0.45359708737775f)}, +{Q31( 0.38975993093975f), Q31( 0.95515358099121f)}, {Q31(-0.97757125224150f), Q31( 0.05305894580606f)}, +{Q31(-0.17325552859616f), Q31(-0.92770672250494f)}, {Q31( 0.99948035025744f), Q31( 0.58285545563426f)}, +{Q31(-0.64946246527458f), Q31( 0.68645507104960f)}, {Q31(-0.12016920576437f), Q31(-0.57147322153312f)}, +{Q31(-0.58947456517751f), Q31(-0.34847132454388f)}, {Q31(-0.41815140454465f), Q31( 0.16276422358861f)}, +{Q31( 0.99885650204884f), Q31( 0.11136095490444f)}, {Q31(-0.56649614128386f), Q31(-0.90494866361587f)}, +{Q31( 0.94138021032330f), Q31( 0.35281916733018f)}, {Q31(-0.75725076534641f), Q31( 0.53650549640587f)}, +{Q31( 0.20541973692630f), Q31(-0.94435144369918f)}, {Q31( 0.99980371023351f), Q31( 0.79835913565599f)}, +{Q31( 0.29078277605775f), Q31( 0.35393777921520f)}, {Q31(-0.62858772103030f), Q31( 0.38765693387102f)}, +{Q31( 0.43440904467688f), Q31(-0.98546330463232f)}, {Q31(-0.98298583762390f), Q31( 0.21021524625209f)}, +{Q31( 0.19513029146934f), Q31(-0.94239832251867f)}, {Q31(-0.95476662400101f), Q31( 0.98364554179143f)}, +{Q31( 0.93379635304810f), Q31(-0.70881994583682f)}, {Q31(-0.85235410573336f), Q31(-0.08342347966410f)}, +{Q31(-0.86425093011245f), Q31(-0.45795025029466f)}, {Q31( 0.38879779059045f), Q31( 0.97274429344593f)}, +{Q31( 0.92045124735495f), Q31(-0.62433652524220f)}, {Q31( 0.89162532251878f), Q31( 0.54950955570563f)}, +{Q31(-0.36834336949252f), Q31( 0.96458298020975f)}, {Q31( 0.93891760988045f), Q31(-0.89968353740388f)}, +{Q31( 0.99267657565094f), Q31(-0.03757034316958f)}, {Q31(-0.94063471614176f), Q31( 0.41332338538963f)}, +{Q31( 0.99740224117019f), Q31(-0.16830494996370f)}, {Q31(-0.35899413170555f), Q31(-0.46633226649613f)}, +{Q31( 0.05237237274947f), Q31(-0.25640361602661f)}, {Q31( 0.36703583957424f), Q31(-0.38653265641875f)}, +{Q31( 0.91653180367913f), Q31(-0.30587628726597f)}, {Q31( 0.69000803499316f), Q31( 0.90952171386132f)}, +{Q31(-0.38658751133527f), Q31( 0.99501571208985f)}, {Q31(-0.29250814029851f), Q31( 0.37444994344615f)}, +{Q31(-0.60182204677608f), Q31( 0.86779651036123f)}, {Q31(-0.97418588163217f), Q31( 0.96468523666475f)}, +{Q31( 0.88461574003963f), Q31( 0.57508405276414f)}, {Q31( 0.05198933055162f), Q31( 0.21269661669964f)}, +{Q31(-0.53499621979720f), Q31( 0.97241553731237f)}, {Q31(-0.49429560226497f), Q31( 0.98183865291903f)}, +{Q31(-0.98935142339139f), Q31(-0.40249159006933f)}, {Q31(-0.98081380091130f), Q31(-0.72856895534041f)}, +{Q31(-0.27338148835532f), Q31( 0.99950922447209f)}, {Q31( 0.06310802338302f), Q31(-0.54539587529618f)}, +{Q31(-0.20461677199539f), Q31(-0.14209977628489f)}, {Q31( 0.66223843141647f), Q31( 0.72528579940326f)}, +{Q31(-0.84764345483665f), Q31( 0.02372316801261f)}, {Q31(-0.89039863483811f), Q31( 0.88866581484602f)}, +{Q31( 0.95903308477986f), Q31( 0.76744927173873f)}, {Q31( 0.73504123909879f), Q31(-0.03747203173192f)}, +{Q31(-0.31744434966056f), Q31(-0.36834111883652f)}, {Q31(-0.34110827591623f), Q31( 0.40211222807691f)}, +{Q31( 0.47803883714199f), Q31(-0.39423219786288f)}, {Q31( 0.98299195879514f), Q31( 0.01989791390047f)}, +{Q31(-0.30963073129751f), Q31(-0.18076720599336f)}, {Q31( 0.99992588229018f), Q31(-0.26281872094289f)}, +{Q31(-0.93149731080767f), Q31(-0.98313162570490f)}, {Q31( 0.99923472302773f), Q31(-0.80142993767554f)}, +{Q31(-0.26024169633417f), Q31(-0.75999759855752f)}, {Q31(-0.35712514743563f), Q31( 0.19298963768574f)}, +{Q31(-0.99899084509530f), Q31( 0.74645156992493f)}, {Q31( 0.86557171579452f), Q31( 0.55593866696299f)}, +{Q31( 0.33408042438752f), Q31( 0.86185953874709f)}, {Q31( 0.99010736374716f), Q31( 0.04602397576623f)}, +{Q31(-0.66694269691195f), Q31(-0.91643611810148f)}, {Q31( 0.64016792079480f), Q31( 0.15649530836856f)}, +{Q31( 0.99570534804836f), Q31( 0.45844586038111f)}, {Q31(-0.63431466947340f), Q31( 0.21079116459234f)}, +{Q31(-0.07706847005931f), Q31(-0.89581437101329f)}, {Q31( 0.98590090577724f), Q31( 0.88241721133981f)}, +{Q31( 0.80099335254678f), Q31(-0.36851896710853f)}, {Q31( 0.78368131392666f), Q31( 0.45506999802597f)}, +{Q31( 0.08707806671691f), Q31( 0.80938994918745f)}, {Q31(-0.86811883080712f), Q31( 0.39347308654705f)}, +{Q31(-0.39466529740375f), Q31(-0.66809432114456f)}, {Q31( 0.97875325649683f), Q31(-0.72467840967746f)}, +{Q31(-0.95038560288864f), Q31( 0.89563219587625f)}, {Q31( 0.17005239424212f), Q31( 0.54683053962658f)}, +{Q31(-0.76910792026848f), Q31(-0.96226617549298f)}, {Q31( 0.99743281016846f), Q31( 0.42697157037567f)}, +{Q31( 0.95437383549973f), Q31( 0.97002324109952f)}, {Q31( 0.99578905365569f), Q31(-0.54106826257356f)}, +{Q31( 0.28058259829990f), Q31(-0.85361420634036f)}, {Q31( 0.85256524470573f), Q31(-0.64567607735589f)}, +{Q31(-0.50608540105128f), Q31(-0.65846015480300f)}, {Q31(-0.97210735183243f), Q31(-0.23095213067791f)}, +{Q31( 0.95424048234441f), Q31(-0.99240147091219f)}, {Q31(-0.96926570524023f), Q31( 0.73775654896574f)}, +{Q31( 0.30872163214726f), Q31( 0.41514960556126f)}, {Q31(-0.24523839572639f), Q31( 0.63206633394807f)}, +{Q31(-0.33813265086024f), Q31(-0.38661779441897f)}, {Q31(-0.05826828420146f), Q31(-0.06940774188029f)}, +{Q31(-0.22898461455054f), Q31( 0.97054853316316f)}, {Q31(-0.18509915019881f), Q31( 0.47565762892084f)}, +{Q31(-0.10488238045009f), Q31(-0.87769947402394f)}, {Q31(-0.71886586182037f), Q31( 0.78030982480538f)}, +{Q31( 0.99793873738654f), Q31( 0.90041310491497f)}, {Q31( 0.57563307626120f), Q31(-0.91034337352097f)}, +{Q31( 0.28909646383717f), Q31( 0.96307783970534f)}, {Q31( 0.42188998312520f), Q31( 0.48148651230437f)}, +{Q31( 0.93335049681047f), Q31(-0.43537023883588f)}, {Q31(-0.97087374418267f), Q31( 0.86636445711364f)}, +{Q31( 0.36722871286923f), Q31( 0.65291654172961f)}, {Q31(-0.81093025665696f), Q31( 0.08778370229363f)}, +{Q31(-0.26240603062237f), Q31(-0.92774095379098f)}, {Q31( 0.83996497984604f), Q31( 0.55839849139647f)}, +{Q31(-0.99909615720225f), Q31(-0.96024605713970f)}, {Q31( 0.74649464155061f), Q31( 0.12144893606462f)}, +{Q31(-0.74774595569805f), Q31(-0.26898062008959f)}, {Q31( 0.95781667469567f), Q31(-0.79047927052628f)}, +{Q31( 0.95472308713099f), Q31(-0.08588776019550f)}, {Q31( 0.48708332746299f), Q31( 0.99999041579432f)}, +{Q31( 0.46332038247497f), Q31( 0.10964126185063f)}, {Q31(-0.76497004940162f), Q31( 0.89210929242238f)}, +{Q31( 0.57397389364339f), Q31( 0.35289703373760f)}, {Q31( 0.75374316974495f), Q31( 0.96705214651335f)}, +{Q31(-0.59174397685714f), Q31(-0.89405370422752f)}, {Q31( 0.75087906691890f), Q31(-0.29612672982396f)}, +{Q31(-0.98607857336230f), Q31( 0.25034911730023f)}, {Q31(-0.40761056640505f), Q31(-0.90045573444695f)}, +{Q31( 0.66929266740477f), Q31( 0.98629493401748f)}, {Q31(-0.97463695257310f), Q31(-0.00190223301301f)}, +{Q31( 0.90145509409859f), Q31( 0.99781390365446f)}, {Q31(-0.87259289048043f), Q31( 0.99233587353666f)}, +{Q31(-0.91529461447692f), Q31(-0.15698707534206f)}, {Q31(-0.03305738840705f), Q31(-0.37205262859764f)}, +{Q31( 0.07223051368337f), Q31(-0.88805001733626f)}, {Q31( 0.99498012188353f), Q31( 0.97094358113387f)}, +{Q31(-0.74904939500519f), Q31( 0.99985483641521f)}, {Q31( 0.04585228574211f), Q31( 0.99812337444082f)}, +{Q31(-0.89054954257993f), Q31(-0.31791913188064f)}, {Q31(-0.83782144651251f), Q31( 0.97637632547466f)}, +{Q31( 0.33454804933804f), Q31(-0.86231516800408f)}, {Q31(-0.99707579362824f), Q31( 0.93237990079441f)}, +{Q31(-0.22827527843994f), Q31( 0.18874759397997f)}, {Q31( 0.67248046289143f), Q31(-0.03646211390569f)}, +{Q31(-0.05146538187944f), Q31(-0.92599700120679f)}, {Q31( 0.99947295749905f), Q31( 0.93625229707912f)}, +{Q31( 0.66951124390363f), Q31( 0.98905825623893f)}, {Q31(-0.99602956559179f), Q31(-0.44654715757688f)}, +{Q31( 0.82104905483590f), Q31( 0.99540741724928f)}, {Q31( 0.99186510988782f), Q31( 0.72023001312947f)}, +{Q31(-0.65284592392918f), Q31( 0.52186723253637f)}, {Q31( 0.93885443798188f), Q31(-0.74895312615259f)}, +{Q31( 0.96735248738388f), Q31( 0.90891816978629f)}, {Q31(-0.22225968841114f), Q31( 0.57124029781228f)}, +{Q31(-0.44132783753414f), Q31(-0.92688840659280f)}, {Q31(-0.85694974219574f), Q31( 0.88844532719844f)}, +{Q31( 0.91783042091762f), Q31(-0.46356892383970f)}, {Q31( 0.72556974415690f), Q31(-0.99899555770747f)}, +{Q31(-0.99711581834508f), Q31( 0.58211560180426f)}, {Q31( 0.77638976371966f), Q31( 0.94321834873819f)}, +{Q31( 0.07717324253925f), Q31( 0.58638399856595f)}, {Q31(-0.56049829194163f), Q31( 0.82522301569036f)}, +{Q31( 0.98398893639988f), Q31( 0.39467440420569f)}, {Q31( 0.47546946844938f), Q31( 0.68613044836811f)}, +{Q31( 0.65675089314631f), Q31( 0.18331637134880f)}, {Q31( 0.03273375457980f), Q31(-0.74933109564108f)}, +{Q31(-0.38684144784738f), Q31( 0.51337349030406f)}, {Q31(-0.97346267944545f), Q31(-0.96549364384098f)}, +{Q31(-0.53282156061942f), Q31(-0.91423265091354f)}, {Q31( 0.99817310731176f), Q31( 0.61133572482148f)}, +{Q31(-0.50254500772635f), Q31(-0.88829338134294f)}, {Q31( 0.01995873238855f), Q31( 0.85223515096765f)}, +{Q31( 0.99930381973804f), Q31( 0.94578896296649f)}, {Q31( 0.82907767600783f), Q31(-0.06323442598128f)}, +{Q31(-0.58660709669728f), Q31( 0.96840773806582f)}, {Q31(-0.17573736667267f), Q31(-0.48166920859485f)}, +{Q31( 0.83434292401346f), Q31(-0.13023450646997f)}, {Q31( 0.05946491307025f), Q31( 0.20511047074866f)}, +{Q31( 0.81505484574602f), Q31(-0.94685947861369f)}, {Q31(-0.44976380954860f), Q31( 0.40894572671545f)}, +{Q31(-0.89746474625671f), Q31( 0.99846578838537f)}, {Q31( 0.39677256130792f), Q31(-0.74854668609359f)}, +{Q31(-0.07588948563079f), Q31( 0.74096214084170f)}, {Q31( 0.76343198951445f), Q31( 0.41746629422634f)}, +{Q31(-0.74490104699626f), Q31( 0.94725911744610f)}, {Q31( 0.64880119792759f), Q31( 0.41336660830571f)}, +{Q31( 0.62319537462542f), Q31(-0.93098313552599f)}, {Q31( 0.42215817594807f), Q31(-0.07712787385208f)}, +{Q31( 0.02704554141885f), Q31(-0.05417518053666f)}, {Q31( 0.80001773566818f), Q31( 0.91542195141039f)}, +{Q31(-0.79351832348816f), Q31(-0.36208897989136f)}, {Q31( 0.63872359151636f), Q31( 0.08128252493444f)}, +{Q31( 0.52890520960295f), Q31( 0.60048872455592f)}, {Q31( 0.74238552914587f), Q31( 0.04491915291044f)}, +{Q31( 0.99096131449250f), Q31(-0.19451182854402f)}, {Q31(-0.80412329643109f), Q31(-0.88513818199457f)}, +{Q31(-0.64612616129736f), Q31( 0.72198674804544f)}, {Q31( 0.11657770663191f), Q31(-0.83662833815041f)}, +{Q31(-0.95053182488101f), Q31(-0.96939905138082f)}, {Q31(-0.62228872928622f), Q31( 0.82767262846661f)}, +{Q31( 0.03004475787316f), Q31(-0.99738896333384f)}, {Q31(-0.97987214341034f), Q31( 0.36526129686425f)}, +{Q31(-0.99986980746200f), Q31(-0.36021610299715f)}, {Q31( 0.89110648599879f), Q31(-0.97894250343044f)}, +{Q31( 0.10407960510582f), Q31( 0.77357793811619f)}, {Q31( 0.95964737821728f), Q31(-0.35435818285502f)}, +{Q31( 0.50843233159162f), Q31( 0.96107691266205f)}, {Q31( 0.17006334670615f), Q31(-0.76854025314829f)}, +{Q31( 0.25872675063360f), Q31( 0.99893303933816f)}, {Q31(-0.01115998681937f), Q31( 0.98496019742444f)}, +{Q31(-0.79598702973261f), Q31( 0.97138411318894f)}, {Q31(-0.99264708948101f), Q31(-0.99542822402536f)}, +{Q31(-0.99829663752818f), Q31( 0.01877138824311f)}, {Q31(-0.70801016548184f), Q31( 0.33680685948117f)}, +{Q31(-0.70467057786826f), Q31( 0.93272777501857f)}, {Q31( 0.99846021905254f), Q31(-0.98725746254433f)}, +{Q31(-0.63364968534650f), Q31(-0.16473594423746f)}, {Q31(-0.16258217500792f), Q31(-0.95939125400802f)}, +{Q31(-0.43645594360633f), Q31(-0.94805030113284f)}, {Q31(-0.99848471702976f), Q31( 0.96245166923809f)}, +{Q31(-0.16796458968998f), Q31(-0.98987511890470f)}, {Q31(-0.87979225745213f), Q31(-0.71725725041680f)}, +{Q31( 0.44183099021786f), Q31(-0.93568974498761f)}, {Q31( 0.93310180125532f), Q31(-0.99913308068246f)}, +{Q31(-0.93941931782002f), Q31(-0.56409379640356f)}, {Q31(-0.88590003188677f), Q31( 0.47624600491382f)}, +{Q31( 0.99971463703691f), Q31(-0.83889954253462f)}, {Q31(-0.75376385639978f), Q31( 0.00814643438625f)}, +{Q31( 0.93887685615875f), Q31(-0.11284528204636f)}, {Q31( 0.85126435782309f), Q31( 0.52349251543547f)}, +{Q31( 0.39701421446381f), Q31( 0.81779634174316f)}, {Q31(-0.37024464187437f), Q31(-0.87071656222959f)}, +{Q31(-0.36024828242896f), Q31( 0.34655735648287f)}, {Q31(-0.93388812549209f), Q31(-0.84476541096429f)}, +{Q31(-0.65298804552119f), Q31(-0.18439575450921f)}, {Q31( 0.11960319006843f), Q31( 0.99899346780168f)}, +{Q31( 0.94292565553160f), Q31( 0.83163906518293f)}, {Q31( 0.75081145286948f), Q31(-0.35533223142265f)}, +{Q31( 0.56721979748394f), Q31(-0.24076836414499f)}, {Q31( 0.46857766746029f), Q31(-0.30140233457198f)}, +{Q31( 0.97312313923635f), Q31(-0.99548191630031f)}, {Q31(-0.38299976567017f), Q31( 0.98516909715427f)}, +{Q31( 0.41025800019463f), Q31( 0.02116736935734f)}, {Q31( 0.09638062008048f), Q31( 0.04411984381457f)}, +{Q31(-0.85283249275397f), Q31( 0.91475563922421f)}, {Q31( 0.88866808958124f), Q31(-0.99735267083226f)}, +{Q31(-0.48202429536989f), Q31(-0.96805608884164f)}, {Q31( 0.27572582416567f), Q31( 0.58634753335832f)}, +{Q31(-0.65889129659168f), Q31( 0.58835634138583f)}, {Q31( 0.98838086953732f), Q31( 0.99994349600236f)}, +{Q31(-0.20651349620689f), Q31( 0.54593044066355f)}, {Q31(-0.62126416356920f), Q31(-0.59893681700392f)}, +{Q31( 0.20320105410437f), Q31(-0.86879180355289f)}, {Q31(-0.97790548600584f), Q31( 0.96290806999242f)}, +{Q31( 0.11112534735126f), Q31( 0.21484763313301f)}, {Q31(-0.41368337314182f), Q31( 0.28216837680365f)}, +{Q31( 0.24133038992960f), Q31( 0.51294362630238f)}, {Q31(-0.66393410674885f), Q31(-0.08249679629081f)}, +{Q31(-0.53697829178752f), Q31(-0.97649903936228f)}, {Q31(-0.97224737889348f), Q31( 0.22081333579837f)}, +{Q31( 0.87392477144549f), Q31(-0.12796173740361f)}, {Q31( 0.19050361015753f), Q31( 0.01602615387195f)}, +{Q31(-0.46353441212724f), Q31(-0.95249041539006f)}, {Q31(-0.07064096339021f), Q31(-0.94479803205886f)}, +{Q31(-0.92444085484466f), Q31(-0.10457590187436f)}, {Q31(-0.83822593578728f), Q31(-0.01695043208885f)}, +{Q31( 0.75214681811150f), Q31(-0.99955681042665f)}, {Q31(-0.42102998829339f), Q31( 0.99720941999394f)}, +{Q31(-0.72094786237696f), Q31(-0.35008961934255f)}, {Q31( 0.78843311019251f), Q31( 0.52851398958271f)}, +{Q31( 0.97394027897442f), Q31(-0.26695944086561f)}, {Q31( 0.99206463477946f), Q31(-0.57010120849429f)}, +{Q31( 0.76789609461795f), Q31(-0.76519356730966f)}, {Q31(-0.82002421836409f), Q31(-0.73530179553767f)}, +{Q31( 0.81924990025724f), Q31( 0.99698425250579f)}, {Q31(-0.26719850873357f), Q31( 0.68903369776193f)}, +{Q31(-0.43311260380975f), Q31( 0.85321815947490f)}, {Q31( 0.99194979673836f), Q31( 0.91876249766422f)}, +{Q31(-0.80692001248487f), Q31(-0.32627540663214f)}, {Q31( 0.43080003649976f), Q31(-0.21919095636638f)}, +{Q31( 0.67709491937357f), Q31(-0.95478075822906f)}, {Q31( 0.56151770568316f), Q31(-0.70693811747778f)}, +{Q31( 0.10831862810749f), Q31(-0.08628837174592f)}, {Q31( 0.91229417540436f), Q31(-0.65987351408410f)}, +{Q31(-0.48972893932274f), Q31( 0.56289246362686f)}, {Q31(-0.89033658689697f), Q31(-0.71656563987082f)}, +{Q31( 0.65269447475094f), Q31( 0.65916004833932f)}, {Q31( 0.67439478141121f), Q31(-0.81684380846796f)}, +{Q31(-0.47770832416973f), Q31(-0.16789556203025f)}, {Q31(-0.99715979260878f), Q31(-0.93565784007648f)}, +{Q31(-0.90889593602546f), Q31( 0.62034397054380f)}, {Q31(-0.06618622548177f), Q31(-0.23812217221359f)}, +{Q31( 0.99430266919728f), Q31( 0.18812555317553f)}, {Q31( 0.97686402381843f), Q31(-0.28664534366620f)}, +{Q31( 0.94813650221268f), Q31(-0.97506640027128f)}, {Q31(-0.95434497492853f), Q31(-0.79607978501983f)}, +{Q31(-0.49104783137150f), Q31( 0.32895214359663f)}, {Q31( 0.99881175120751f), Q31( 0.88993983831354f)}, +{Q31( 0.50449166760303f), Q31(-0.85995072408434f)}, {Q31( 0.47162891065108f), Q31(-0.18680204049569f)}, +{Q31(-0.62081581361840f), Q31( 0.75000676218956f)}, {Q31(-0.43867015250812f), Q31( 0.99998069244322f)}, +{Q31( 0.98630563232075f), Q31(-0.53578899600662f)}, {Q31(-0.61510362277374f), Q31(-0.89515019899997f)}, +{Q31(-0.03841517601843f), Q31(-0.69888815681179f)}, {Q31(-0.30102157304644f), Q31(-0.07667808922205f)}, +{Q31( 0.41881284182683f), Q31( 0.02188098922282f)}, {Q31(-0.86135454941237f), Q31( 0.98947480909359f)}, +{Q31( 0.67226861393788f), Q31(-0.13494389011014f)}, {Q31(-0.70737398842068f), Q31(-0.76547349325992f)}, +{Q31( 0.94044946687963f), Q31( 0.09026201157416f)}, {Q31(-0.82386352534327f), Q31( 0.08924768823676f)}, +{Q31(-0.32070666698656f), Q31( 0.50143421908753f)}, {Q31( 0.57593163224487f), Q31(-0.98966422921509f)}, +{Q31(-0.36326018419965f), Q31( 0.07440243123228f)}, {Q31( 0.99979044674350f), Q31(-0.14130287347405f)}, +{Q31(-0.92366023326932f), Q31(-0.97979298068180f)}, {Q31(-0.44607178518598f), Q31(-0.54233252016394f)}, +{Q31( 0.44226800932956f), Q31( 0.71326756742752f)}, {Q31( 0.03671907158312f), Q31( 0.63606389366675f)}, +{Q31( 0.52175424682195f), Q31(-0.85396826735705f)}, {Q31(-0.94701139690956f), Q31(-0.01826348194255f)}, +{Q31(-0.98759606946049f), Q31( 0.82288714303073f)}, {Q31( 0.87434794743625f), Q31( 0.89399495655433f)}, +{Q31(-0.93412041758744f), Q31( 0.41374052024363f)}, {Q31( 0.96063943315511f), Q31( 0.93116709541280f)}, +{Q31( 0.97534253457837f), Q31( 0.86150930812689f)}, {Q31( 0.99642466504163f), Q31( 0.70190043427512f)}, +{Q31(-0.94705089665984f), Q31(-0.29580042814306f)}, {Q31( 0.91599807087376f), Q31(-0.98147830385781f)}, // Start of duplicated table -{-0.99948153278296, -0.59483417516607}, { 0.97113454393991, -0.67528515225647}, -{ 0.14130051758487, -0.95090983575689}, {-0.47005496701697, -0.37340549728647}, -{ 0.80705063769351, 0.29653668284408}, {-0.38981478896926, 0.89572605717087}, -{-0.01053049862020, -0.66959058036166}, {-0.91266367957293, -0.11522938140034}, +{Q31(-0.99948153278296f), Q31(-0.59483417516607f)}, {Q31( 0.97113454393991f), Q31(-0.67528515225647f)}, +{Q31( 0.14130051758487f), Q31(-0.95090983575689f)}, {Q31(-0.47005496701697f), Q31(-0.37340549728647f)}, +{Q31( 0.80705063769351f), Q31( 0.29653668284408f)}, {Q31(-0.38981478896926f), Q31( 0.89572605717087f)}, +{Q31(-0.01053049862020f), Q31(-0.66959058036166f)}, {Q31(-0.91266367957293f), Q31(-0.11522938140034f)}, }; #endif /* AVCODEC_AACSBRDATA_H */ -- 1.8.2.1 From nedeljko.babic at imgtec.com Fri Aug 1 15:53:09 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:09 +0200 Subject: [FFmpeg-devel] [PATCH 03/14] libavcodec: Implementation of AAC_fixed_decoder (LC-module) [3/5] In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-4-git-send-email-nedeljko.babic@imgtec.com> From: Jovan Zelincevic Add fixed point implementation of functions for generating tables Signed-off-by: Nedeljko Babic --- libavcodec/aacdectab.h | 34 +-- libavcodec/aactab.c | 486 +++++++++++++++++++++++++++++++++ libavcodec/aactab.h | 4 + libavcodec/cbrt_fixed_tablegen.c | 24 ++ libavcodec/cbrt_tablegen.c | 3 + libavcodec/cbrt_tablegen.h | 17 +- libavcodec/cbrt_tablegen_template.c | 2 +- libavcodec/sinewin.c | 1 + libavcodec/sinewin.h | 20 +- libavcodec/sinewin_fixed.c | 21 ++ libavcodec/sinewin_fixed_tablegen.c | 24 ++ libavcodec/sinewin_tablegen.c | 3 + libavcodec/sinewin_tablegen.h | 31 ++- libavcodec/sinewin_tablegen_template.c | 20 +- libavcodec/tableprint.h | 2 + 15 files changed, 657 insertions(+), 35 deletions(-) create mode 100644 libavcodec/cbrt_fixed_tablegen.c create mode 100644 libavcodec/sinewin_fixed.c create mode 100644 libavcodec/sinewin_fixed_tablegen.c diff --git a/libavcodec/aacdectab.h b/libavcodec/aacdectab.h index 4a12b4f..16dd89f 100644 --- a/libavcodec/aacdectab.h +++ b/libavcodec/aacdectab.h @@ -38,9 +38,9 @@ /* @name ltp_coef * Table of the LTP coefficients */ -static const float ltp_coef[8] = { - 0.570829, 0.696616, 0.813004, 0.911304, - 0.984900, 1.067894, 1.194601, 1.369533, +static const INTFLOAT ltp_coef[8] = { + Q30(0.570829f), Q30(0.696616f), Q30(0.813004f), Q30(0.911304f), + Q30(0.984900f), Q30(1.067894f), Q30(1.194601f), Q30(1.369533f), }; /* @name tns_tmp2_map @@ -49,28 +49,28 @@ static const float ltp_coef[8] = { * respectively. * @{ */ -static const float tns_tmp2_map_1_3[4] = { - 0.00000000, -0.43388373, 0.64278758, 0.34202015, +static const INTFLOAT tns_tmp2_map_1_3[4] = { + Q31(0.00000000f), Q31(-0.43388373f), Q31(0.64278758f), Q31(0.34202015f), }; -static const float tns_tmp2_map_0_3[8] = { - 0.00000000, -0.43388373, -0.78183150, -0.97492790, - 0.98480773, 0.86602539, 0.64278758, 0.34202015, +static const INTFLOAT tns_tmp2_map_0_3[8] = { + Q31(0.00000000f), Q31(-0.43388373f), Q31(-0.78183150f), Q31(-0.97492790f), + Q31(0.98480773f), Q31( 0.86602539f), Q31( 0.64278758f), Q31( 0.34202015f), }; -static const float tns_tmp2_map_1_4[8] = { - 0.00000000, -0.20791170, -0.40673664, -0.58778524, - 0.67369562, 0.52643216, 0.36124167, 0.18374951, +static const INTFLOAT tns_tmp2_map_1_4[8] = { + Q31(0.00000000f), Q31(-0.20791170f), Q31(-0.40673664f), Q31(-0.58778524f), + Q31(0.67369562f), Q31( 0.52643216f), Q31( 0.36124167f), Q31( 0.18374951f), }; -static const float tns_tmp2_map_0_4[16] = { - 0.00000000, -0.20791170, -0.40673664, -0.58778524, - -0.74314481, -0.86602539, -0.95105654, -0.99452192, - 0.99573416, 0.96182561, 0.89516330, 0.79801720, - 0.67369562, 0.52643216, 0.36124167, 0.18374951, +static const INTFLOAT tns_tmp2_map_0_4[16] = { + Q31( 0.00000000f), Q31(-0.20791170f), Q31(-0.40673664f), Q31(-0.58778524f), + Q31(-0.74314481f), Q31(-0.86602539f), Q31(-0.95105654f), Q31(-0.99452192f), + Q31( 0.99573416f), Q31( 0.96182561f), Q31( 0.89516330f), Q31( 0.79801720f), + Q31( 0.67369562f), Q31( 0.52643216f), Q31( 0.36124167f), Q31( 0.18374951f), }; -static const float * const tns_tmp2_map[4] = { +static const INTFLOAT * const tns_tmp2_map[4] = { tns_tmp2_map_0_3, tns_tmp2_map_0_4, tns_tmp2_map_1_3, diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c index eb882e8..7d0e8cd 100644 --- a/libavcodec/aactab.c +++ b/libavcodec/aactab.c @@ -35,6 +35,8 @@ DECLARE_ALIGNED(32, float, ff_aac_kbd_long_1024)[1024]; DECLARE_ALIGNED(32, float, ff_aac_kbd_short_128)[128]; +DECLARE_ALIGNED(32, int, ff_aac_kbd_long_1024_fixed)[1024]; +DECLARE_ALIGNED(32, int, ff_aac_kbd_short_128_fixed)[128]; const uint8_t ff_aac_num_swb_1024[] = { 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40, 40 @@ -1727,3 +1729,487 @@ const DECLARE_ALIGNED(32, float, ff_aac_eld_window)[1920] = { -0.00116552, -0.00115223, -0.00113877, -0.00112517, -0.00111144, -0.00109764, -0.00108377, -0.00106989, }; + +/* Q30 representation of ff_aac_eld_window table */ +const DECLARE_ALIGNED(32, int, ff_aac_eld_window_fixed)[1920] = { + 0x003783ba, 0x005d04f4, 0x008ae226, 0x00c02021, + 0x00fb1804, 0x013a30a8, 0x017be9e6, 0x01bf296c, + 0x02033204, 0x0247502c, 0x028adab0, 0x02cd9568, + 0x030fa980, 0x03513dc0, 0x03927274, 0x03d363e0, + 0x04142e40, 0x0454edc0, 0x0495bd48, 0x04d6a060, + 0x051786d8, 0x05586548, 0x059935e8, 0x05d9feb0, + 0x061acea0, 0x065bb680, 0x069cc800, 0x06de13f0, + 0x071fa748, 0x07618b80, 0x07a3c7a8, 0x07e66da0, + 0x082999d0, 0x086d6590, 0x08b1e640, 0x08f72850, + 0x093d3120, 0x09840550, 0x09cba880, 0x0a1415f0, + 0x0a5d41b0, 0x0aa720d0, 0x0af1a9a0, 0x0b3cce70, + 0x0b887ec0, 0x0bd4ac10, 0x0c214a70, 0x0c6e5130, + 0x0cbbba50, 0x0d098130, 0x0d57a240, 0x0da61a60, + 0x0df4e620, 0x0e4401d0, 0x0e9369f0, 0x0ee31de0, + 0x0f332000, 0x0f837180, 0x0fd412a0, 0x10250260, + 0x10763f20, 0x10c7c660, 0x11199560, 0x116baa00, + 0x11be0400, 0x1210a1c0, 0x12638180, 0x12b69ee0, + 0x1309f3e0, 0x135d7ac0, 0x13b12dc0, 0x1404ffa0, + 0x1458dd40, 0x14acb720, 0x15008120, 0x15543260, + 0x15a7c460, 0x15fb3160, 0x164e7520, 0x16a193c0, + 0x16f49740, 0x17478720, 0x179a6720, 0x17ed3720, + 0x183ff460, 0x18929c20, 0x18e52b00, 0x19379c00, + 0x1989e900, 0x19dc0ca0, 0x1a2e0280, 0x1a7fc400, + 0x1ad14a00, 0x1b228ec0, 0x1b738ea0, 0x1bc44540, + 0x1c14ada0, 0x1c64c380, 0x1cb48440, 0x1d03f420, + 0x1d531c00, 0x1da20160, 0x1df0a660, 0x1e3f0860, + 0x1e8d2340, 0x1edaf340, 0x1f2875e0, 0x1f75a700, + 0x1fc281e0, 0x200f0380, 0x205b2ac0, 0x20a6f980, + 0x20f27200, 0x213d9600, 0x21886580, 0x21d2e040, + 0x221d0640, 0x2266d6c0, 0x22b05180, 0x22f97580, + 0x23424280, 0x238ab880, 0x23d2d780, 0x241aa040, + 0x246213c0, 0x24a93300, 0x24efff80, 0x25367b40, + 0x256f68c0, 0x25b53580, 0x25faa580, 0x263fb940, + 0x26847080, 0x26c8cbc0, 0x270ccb00, 0x27506e40, + 0x2793b600, 0x27d6a200, 0x281932c0, 0x285b6880, + 0x289d4400, 0x28dec5c0, 0x291feec0, 0x2960bf80, + 0x29a137c0, 0x29e15800, 0x2a212000, 0x2a609080, + 0x2a9fa980, 0x2ade6b40, 0x2b1cd600, 0x2b5aea00, + 0x2b98a740, 0x2bd60d80, 0x2c131cc0, 0x2c4fd500, + 0x2c8c3600, 0x2cc83f00, 0x2d03f040, 0x2d3f48c0, + 0x2d7a48c0, 0x2db4ef40, 0x2def3c40, 0x2e292ec0, + 0x2e62c700, 0x2e9c0400, 0x2ed4e580, 0x2f0d6ac0, + 0x2f4592c0, 0x2f7d5c80, 0x2fb4c6c0, 0x2febd140, + 0x30227b40, 0x3058c400, 0x308eab40, 0x30c43040, + 0x30f95100, 0x312e0d00, 0x31626240, 0x31965040, + 0x31c9d5c0, 0x31fcf240, 0x322fa480, 0x3261ec00, + 0x3293c7c0, 0x32c53680, 0x32f63780, 0x3326c9c0, + 0x3356ec00, 0x33869d00, 0x33b5db80, 0x33e4a700, + 0x3412fdc0, 0x3440df40, 0x346e4a80, 0x349b3e40, + 0x34c7ba00, 0x34f3bd80, 0x351f47c0, 0x354a5840, + 0x3574ee40, 0x359f0900, 0x35c8a840, 0x35f1cb80, + 0x361a71c0, 0x36429a80, 0x366a4580, 0x36917280, + 0x36b82100, 0x36de5180, 0x37040340, 0x372936c0, + 0x374dec40, 0x37722340, 0x3795dc40, 0x37b91780, + 0x37dbd600, 0x37fe18c0, 0x381fe080, 0x38412e00, + 0x38620280, 0x38825f40, 0x38a24540, 0x38c1b680, + 0x38e0b5c0, 0x38ff4540, 0x391d6800, 0x393b20c0, + 0x39587280, 0x39755fc0, 0x3991eb80, 0x39ae1a80, + 0x39c9f280, 0x39e57980, 0x3a00b600, 0x3a1bae00, + 0x3a366800, 0x3a50e9c0, 0x3a6b3a40, 0x3a8560c0, + 0x3a9f6640, 0x3ab95400, 0x3ad332c0, 0x3aed0680, + 0x3b06cf80, 0x3b208d40, 0x3b3a3e80, 0x3b53cb80, + 0x3b6d0780, 0x3b85c380, 0x3b9dd0c0, 0x3bb4eb40, + 0x3bcabac0, 0x3bdee680, 0x3bf11680, 0x3c011440, + 0x3c179ac0, 0x3c1c4f00, 0x3c21aa40, 0x3c278880, + 0x3c2dba80, 0x3c341140, 0x3c3a5e80, 0x3c409100, + 0x3c46b480, 0x3c4cd5c0, 0x3c530180, 0x3c593cc0, + 0x3c5f84c0, 0x3c65d640, 0x3c6c2e40, 0x3c728b40, + 0x3c78ee80, 0x3c7f5840, 0x3c85c940, 0x3c8c4240, + 0x3c92c380, 0x3c994cc0, 0x3c9fde40, 0x3ca67880, + 0x3cad1ac0, 0x3cb3c540, 0x3cba7800, 0x3cc132c0, + 0x3cc7f640, 0x3ccec280, 0x3cd59800, 0x3cdc76c0, + 0x3ce35e80, 0x3cea4f00, 0x3cf147c0, 0x3cf84900, + 0x3cff5340, 0x3d0666c0, 0x3d0d8400, 0x3d14ab40, + 0x3d1bdc00, 0x3d2315c0, 0x3d2a5880, 0x3d31a440, + 0x3d38f900, 0x3d405780, 0x3d47c040, 0x3d4f3300, + 0x3d56af40, 0x3d5e3500, 0x3d65c380, 0x3d6d5ac0, + 0x3d74fb40, 0x3d7ca540, 0x3d845900, 0x3d8c1680, + 0x3d93dd00, 0x3d9bac80, 0x3da38400, 0x3dab6400, + 0x3db34c80, 0x3dbb3dc0, 0x3dc33840, 0x3dcb3bc0, + 0x3dd347c0, 0x3ddb5bc0, 0x3de37780, 0x3deb9b00, + 0x3df3c600, 0x3dfbf940, 0x3e0434c0, 0x3e0c7840, + 0x3e14c3c0, 0x3e1d1640, 0x3e256f80, 0x3e2dcf40, + 0x3e363580, 0x3e3ea300, 0x3e4717c0, 0x3e4f9380, + 0x3e581600, 0x3e609e40, 0x3e692c40, 0x3e71bf80, + 0x3e7a5840, 0x3e82f740, 0x3e8b9c40, 0x3e944700, + 0x3e9cf780, 0x3ea5ad00, 0x3eae66c0, 0x3eb72500, + 0x3ebfe780, 0x3ec8af00, 0x3ed17b80, 0x3eda4d00, + 0x3ee32340, 0x3eebfd40, 0x3ef4dac0, 0x3efdbbc0, + 0x3f06a040, 0x3f0f88c0, 0x3f187540, 0x3f216600, + 0x3f2a5a80, 0x3f335200, 0x3f3c4c40, 0x3f454940, + 0x3f4e4940, 0x3f574c80, 0x3f605340, 0x3f695dc0, + 0x3f726b40, 0x3f7b7b40, 0x3f848dc0, 0x3f8da240, + 0x3f96b940, 0x3f9fd300, 0x3fa8f040, 0x3fb21080, + 0x3fbb33c0, 0x3fc459c0, 0x3fcd81c0, 0x3fd6abc0, + 0x3fdfd780, 0x3fe90480, 0x3ff23280, 0x3ffb6100, + 0x40049f80, 0x400dd080, 0x40170400, 0x40203880, + 0x40296f00, 0x4032a600, 0x403bde00, 0x40451680, + 0x404e4f00, 0x40578700, 0x4060be80, 0x4069f500, + 0x40732b80, 0x407c6280, 0x40859980, 0x408ed100, + 0x40980800, 0x40a13f00, 0x40aa7500, 0x40b3a980, + 0x40bcdd80, 0x40c61180, 0x40cf4500, 0x40d87800, + 0x40e1ab00, 0x40eadc80, 0x40f40c80, 0x40fd3a80, + 0x41066700, 0x410f9300, 0x4118bd80, 0x4121e700, + 0x412b0f80, 0x41343580, 0x413d5880, 0x41467980, + 0x414f9780, 0x4158b380, 0x4161cd80, 0x416ae580, + 0x4173fb00, 0x417d0d00, 0x41861b80, 0x418f2600, + 0x41982c80, 0x41a12f80, 0x41aa3000, 0x41b32c80, + 0x41bc2580, 0x41c51a00, 0x41ce0900, 0x41d6f300, + 0x41dfd800, 0x41e8b880, 0x41f19400, 0x41fa6b80, + 0x42033d00, 0x420c0900, 0x4214cf00, 0x421d8e00, + 0x42264680, 0x422ef980, 0x4237a680, 0x42404d80, + 0x4248ee00, 0x42518780, 0x425a1a00, 0x4262a480, + 0x426b2800, 0x4273a400, 0x427c1980, 0x42848880, + 0x428cef80, 0x42954f00, 0x429da680, 0x42a5f500, + 0x42ae3b80, 0x42b67a00, 0x42beb100, 0x42c6e080, + 0x42cf0780, 0x42d72680, 0x42df3c00, 0x42e74880, + 0x42ef4c80, 0x42f74880, 0x42ff3c80, 0x43072880, + 0x430f0c80, 0x4316e800, 0x431eba00, 0x43268380, + 0x432e4480, 0x4335fd00, 0x433dae80, 0x43455800, + 0x434cfa00, 0x43549400, 0x435c2500, 0x4363ad80, + 0x436b2e00, 0x4372a700, 0x437a1800, 0x43818200, + 0x4388e400, 0x43903f00, 0x43979200, 0x439edd00, + 0x43a62080, 0x43ad5c80, 0x43b49180, 0x43bbbf80, + 0x43c2e800, 0x43ca0b00, 0x43d12980, 0x43d84280, + 0x43df5200, 0x43e65500, 0x43ed4800, 0x43f43080, + 0x43fb1c80, 0x44021b80, 0x44093a00, 0x44106480, + 0x44176700, 0x441e0c00, 0x44241e00, 0x44297380, + 0x4425dc00, 0x44240180, 0x441ff300, 0x4419e300, + 0x44123f80, 0x44097500, 0x43ffe900, 0x43f5e700, + 0x43eb9f00, 0x43e13f00, 0x43d6f200, 0x43ccbd80, + 0x43c28400, 0x43b82780, 0x43ad8b00, 0x43a29c80, + 0x43975180, 0x438ba080, 0x437f8180, 0x4372fd00, + 0x43662b00, 0x43592480, 0x434c0000, 0x433ecd00, + 0x43319180, 0x43245300, 0x43171700, 0x4309da80, + 0x42fc9300, 0x42ef3500, 0x42e1b600, 0x42d40280, + 0x42c60000, 0x42b79300, 0x42a8a180, 0x42991a00, + 0x4288f200, 0x42782100, 0x42669e00, 0x42546880, + 0x42418800, 0x422e0480, 0x4219e500, 0x42053680, + 0x41f00980, 0x41da7080, 0x41c47b00, 0x41ae3600, + 0x4197ab80, 0x4180e400, 0x4169e780, 0x4152bb00, + 0x413b5e80, 0x4123d180, 0x410c1480, 0x40f42100, + 0x40dbed00, 0x40c36c80, 0x40aa9600, 0x40915f80, + 0x4077c100, 0x405db280, 0x40432c80, 0x40282580, + 0x400c9280, 0x3ff068c0, 0x3fd39dc0, 0x3fb62bc0, + 0x3f981200, 0x3f795080, 0x3f59e780, 0x3f39ebc0, + 0x3f198680, 0x3ef8e100, 0x3ed82440, 0x3eb76c80, + 0x3e96c940, 0x3e764900, 0x3e55f980, 0x3e35cb00, + 0x3e1590c0, 0x3df51cc0, 0x3dd44200, 0x3db2e640, + 0x3d910200, 0x3d6e8e40, 0x3d4b8480, 0x3d27e600, + 0x3d03bc00, 0x3cdf0fc0, 0x3cb9eb80, 0x3c946240, + 0x3c6e9180, 0x3c489700, 0x3c229000, 0x3bfc95c0, + 0x3bd6bd00, 0x3bb11a80, 0x3b8bc180, 0x3b669bc0, + 0x3b416a00, 0x3b1beb80, 0x3af5e140, 0x3acf3300, + 0x3aa7ef80, 0x3a802780, 0x3a57eb80, 0x3a2f5880, + 0x3a069640, 0x39ddcd40, 0x39b524c0, 0x398ca540, + 0x39643800, 0x393bc540, 0x39133580, 0x38ea7ac0, + 0x38c19040, 0x389871c0, 0x386f1b40, 0x38458e00, + 0x381bd000, 0x37f1e780, 0x37c7db00, 0x379db080, + 0x37736e80, 0x37491b00, 0x371ebcc0, 0x36f45980, + 0x36c96600, 0x369ed300, 0x36740380, 0x3648ffc0, + 0x361dcf40, 0x35f27a00, 0x35c70780, 0x359b7f80, + 0x356fe9c0, 0x35444dc0, 0x3518b280, 0x34ed1940, + 0x34c17c00, 0x3495d4c0, 0x346a1d40, 0x343e4300, + 0x34122840, 0x33e5ae00, 0x33b8b780, 0x338b4dc0, + 0x335d9f00, 0x332fdc00, 0x33023440, 0x32d4cc40, + 0x32a7bc80, 0x327b1d40, 0x324f04c0, 0x32235280, + 0x31f7b100, 0x31cbc7c0, 0x319f4140, 0x3171fb40, + 0x31440840, 0x31157d00, 0x30e66e80, 0x30b6fc40, + 0x30875080, 0x30579600, 0x3027f700, 0x2ff89140, + 0x2fc976c0, 0x2f9ab880, 0x2f6c6780, 0x2f3e8780, + 0x2f111000, 0x2ee3f800, 0x2eb73480, 0x2e8a9840, + 0x2e5dd340, 0x2e3093c0, 0x2e028ac0, 0x2dd39680, + 0x2da3c480, 0x2d732380, 0x2d41c400, 0x2d0fd300, + 0x2cdd9ac0, 0x2cab6640, 0x2c797f00, 0x2c480d40, + 0x2c171700, 0x2be6a0c0, 0x2bb6ae80, 0x2b8739c0, + 0x2b583200, 0x2b298600, 0x2afb2400, 0x2accfa40, + 0x2a9ef500, 0x2a710100, 0x2a430ac0, 0x2a14f9c0, + 0x29e6b0c0, 0x29b81240, 0x29890140, 0x29596900, + 0x29293e00, 0x28f87500, 0x28c70340, 0x2894efc0, + 0x28625140, 0x282f4040, 0x27fbd5c0, 0x27c83540, + 0x27948ec0, 0x27611240, 0x272def80, 0x26fb4cc0, + 0x26c94780, 0x2697fcc0, 0x26678880, 0x2637f740, + 0x26094540, 0x25db6dc0, 0x25ae6b40, 0x25821680, + 0x255627c0, 0x252a55c0, 0x24fe5680, 0x24d1db40, + 0x24a48fc0, 0x24761f40, 0x244637c0, 0x2414c900, + 0x23e20240, 0x23ae1740, 0x23793bc0, 0x2343cc00, + 0x230e4ac0, 0x22d93c80, 0x22a52400, 0x22725180, + 0x2240e480, 0x2210f9c0, 0x21e2ab40, 0x21b5c7c0, + 0x2189d2c0, 0x215e4d40, 0x2132b900, 0x2106ba80, + 0x20da1940, 0x20ac9d80, 0x207e11c0, 0x204e77c0, + 0x201e0880, 0x1fecfea0, 0x1fbb94e0, 0x1f8a0500, + 0x1f59d340, 0x1f27ac20, 0x1ef67c60, 0x1ec64e40, + 0x1e96fdc0, 0x1e686400, 0x1e3a5a00, 0x1e0cae80, + 0x1ddf25e0, 0x1db18460, 0x1d839020, 0x1d5536e0, + 0x1d268e80, 0x1cf7ae60, 0x1cc8aea0, 0x1c99af00, + 0x1c6ad820, 0x1c3c5280, 0x1c0e4500, 0x1be0ab60, + 0x1bb35620, 0x1b861400, 0x1b58b480, 0x1b2b1a00, + 0x1afd39c0, 0x1acf09a0, 0x1aa080c0, 0x1a71b020, + 0x1a42c2a0, 0x1a13e420, 0x19e53fc0, 0x19b6eb00, + 0x1988e620, 0x195b3060, 0x192dc8a0, 0x1900a8a0, + 0x18d3c4e0, 0x18a711e0, 0x187a83e0, 0x184e10e0, + 0x1821b060, 0x17f55a00, 0x17c90580, 0x179cb100, + 0x177060a0, 0x17441880, 0x1717dd20, 0x16ebb080, + 0x16bf9260, 0x169382e0, 0x166781c0, 0x163b8f80, + 0x160fade0, 0x15e3de40, 0x15b82220, 0x158c7ae0, + 0x1560ea80, 0x15357240, 0x150a1400, 0x14ded020, + 0x14b3a640, 0x148895a0, 0x145d9dc0, 0x1432bde0, + 0x1407f540, 0x13dd4380, 0x13b2a860, 0x13882460, + 0x135db880, 0x133365a0, 0x13092cc0, 0x12df0e60, + 0x12b50aa0, 0x128b2120, 0x12615200, 0x12379da0, + 0x120e04c0, 0x11e48820, 0x11bb2860, 0x1191e600, + 0x1168c080, 0x113fb7a0, 0x1116cb40, 0x10edfba0, + 0x10c54a00, 0x109cb7a0, 0x10744560, 0x104bf420, + 0x1023c3e0, 0x0ffbb500, 0x0fd3c790, 0x0fabfbe0, + 0x0f845290, 0x0f5ccc40, 0x0f356970, 0x0f0e2a60, + 0x0ee70eb0, 0x0ec01610, 0x0e994040, 0x0e728d50, + 0x0e4bfdf0, 0x0e2592c0, 0x0dff4c70, 0x0dd92af0, + 0x0db32da0, 0x0d8d53e0, 0x0d679cf0, 0x0d420880, + 0x0d1c9680, 0x0cf74700, 0x0cd219f0, 0x0cad0eb0, + 0x0c882450, 0x0c6359a0, 0x0c3ead90, 0x0c1a1f80, + 0x0bf5af40, 0x0bd15cf0, 0x0bad2870, 0x0b891440, + 0x0b652530, 0x0b416020, 0x0b1dca30, 0x0afa6810, + 0x0ad73ee0, 0x0ab45370, 0x0a91aac0, 0x0a6f49b0, + 0x0a4da7f0, 0x0a2c7e20, 0x0a0ba310, 0x09eb1220, + 0x09cac6e0, 0x09aabc70, 0x098aee40, 0x096b57a0, + 0x094bf400, 0x092cbea0, 0x090db2e0, 0x08eecef0, + 0x08d01360, 0x08b18110, 0x089318b0, 0x0874db00, + 0x0856c880, 0x0838e1b0, 0x081b2730, 0x07fd99a8, + 0x07e03a28, 0x07c309a8, 0x07a60910, 0x07893918, + 0x076c99d0, 0x07502b90, 0x0733ee70, 0x0717e2f8, + 0x06fc09b8, 0x06e06378, 0x06c4f0b8, 0x06a9b1c8, + 0x068ea6a0, 0x0673cf18, 0x06592b18, 0x063ebad0, + 0x06247ed0, 0x060a7780, 0x05f0a570, 0x05d708b8, + 0x05bda128, 0x05a46e80, 0x058b7078, 0x0572a740, + 0x055a1330, 0x0541b4d8, 0x05298c98, 0x05119a88, + 0x04f9de50, 0x04e257a0, 0x04cb0630, 0x04b3ea00, + 0x049d0378, 0x04865308, 0x046fd918, 0x045995a8, + 0x04438860, 0x042db0d0, 0x04180ea0, 0x0402a1d0, + 0x03ed6abc, 0x03d869b8, 0x03c39f28, 0x03af0af0, + 0x039aaca0, 0x038683b4, 0x03728fc0, 0x035ed0b0, + 0x034b46c4, 0x0337f254, 0x0324d3a0, 0x0311eab0, + 0x02ff370c, 0x02ecb85c, 0x02da6e34, 0x02c858a8, + 0x02b67820, 0x02a4cd28, 0x02935820, 0x02821920, + 0x02710fac, 0x02603b54, 0x024f9bb4, 0x023f308c, + 0x022ef9e8, 0x021ef7c8, 0x020f2a40, 0x01ff908e, + 0x01f02974, 0x01e0f38a, 0x01d1ed94, 0x01c316d6, + 0x01b46f5e, 0x01a5f720, 0x0197ae28, 0x018994ea, + 0x017bac54, 0x016df546, 0x016070ae, 0x01532078, + 0x01460760, 0x01392834, 0x012c85a4, 0x01201f7a, + 0x0113f27c, 0x0107fb6c, 0x00fc36fd, 0x00f0a2d5, + 0x00e53d51, 0x00da050f, 0x00cef88c, 0x00c41869, + 0x00b9671f, 0x00aee754, 0x00a49b80, 0x009a8384, + 0x00909ca6, 0x0086e400, 0x007d56e3, 0x0073f48f, + 0x006abe70, 0x0061b5de, 0x0058dc65, 0x005033b5, + 0x0047be30, 0x003f7e30, 0x00377619, 0x002fa4d4, + 0x002805ee, 0x002094cb, 0x00194cb8, 0x00122856, + 0x000b215c, 0x00043148, 0xfffd51f1, 0xfff683a1, + 0xffefcd4e, 0xffe93630, 0xffe2c57e, 0xffdc855d, + 0xffd682c4, 0xffd0cad4, 0xffcb6a2d, 0xffc663bd, + 0xffc1b070, 0xffbd48e2, 0xffb92571, 0xffb53a55, + 0xffb1779d, 0xffadcd39, 0xffaa2b43, 0xffa68856, + 0xffa2e142, 0xff9f332d, 0xff9b7b9d, 0xff97bf2f, + 0xff9409e3, 0xff9067e3, 0xff8ce557, 0xff898bf1, + 0xff866307, 0xff8371d0, 0xff80bf64, 0xff7e4ebb, + 0xff7c1eab, 0xff7a2e05, 0xff787b48, 0xff770281, + 0xff75bd07, 0xff74a3f8, 0xff73b0b3, 0xff72dd03, + 0xff72237f, 0xff717ebf, 0xff70e94d, 0xff705f5a, + 0xff6fde6b, 0xff6f6427, 0xff6eee41, 0xff6e7d0c, + 0xff6e135a, 0xff6db404, 0xff6d61f9, 0xff6d2055, + 0xff6cf268, 0xff6cdb77, 0xff6cdebc, 0xff6cff48, + 0xff6d3fca, 0xff6da307, 0xff6e2b83, 0xff6eda14, + 0xff6fad6e, 0xff70a464, 0xff71bd9e, 0xff72f663, + 0xff744a81, 0xff75b5c5, 0xff77340a, 0xff78c0a7, + 0xff7a5694, 0xff7bf0dd, 0xff7d8abc, 0xff7f2302, + 0xff80bc09, 0xff825855, 0xff83fa57, 0xff85a55c, + 0xff875d22, 0xff892599, 0xff8b025e, 0xff8cf53c, + 0xff8efdf5, 0xff911c48, 0xff934fca, 0xff959676, + 0xff97ec87, 0xff9a4e36, 0xff9cb7d2, 0xff9f26cd, + 0xffa199cf, 0xffa40f75, 0xffa6867d, 0xffa8feb2, + 0xffab78e0, 0xffadf5c8, 0xffb07640, 0xffb2fba1, + 0xffb587a2, 0xffb81bfc, 0xffbaba47, 0xffbd6237, + 0xffc011a9, 0xffc2c67a, 0xffc57e85, 0xffc83894, + 0xffcaf41b, 0xffcdb0b9, 0xffd06e18, 0xffd32bf8, + 0xffd5ea38, 0xffd8a8c4, 0xffdb6765, 0xffde25fc, + 0xffe0e472, 0xffe3a2b3, 0xffe66088, 0xffe91da7, + 0xffebd979, 0xffee9352, 0xfff14ab1, 0xfff3fef7, + 0xfff6af95, 0xfff95c0d, 0xfffc03c8, 0xfffea65a, + 0x00015885, 0x0003f2e9, 0x00068a73, 0x00091e8d, + 0x000bae7f, 0x000e39bf, 0x0010bf96, 0x00133f78, + 0x0015b8c4, 0x00182ae4, 0x001a9558, 0x001cf7b3, + 0x001f51e0, 0x0021a3b4, 0x0023ed25, 0x00262df2, + 0x002865c5, 0x002a9469, 0x002cb967, 0x002ed4aa, + 0x0030e607, 0x0032ed88, 0x0034eb2f, 0x0036de23, + 0x0038c503, 0x003a9e4c, 0x003c68a7, 0x003e23dd, + 0x003fd0db, 0x00417083, 0x0043038b, 0x00448adf, + 0x00460741, 0x0047799c, 0x0048e2b3, 0x004a42af, + 0x004b98fb, 0x004ce50b, 0x004e2654, 0x004f5b5d, + 0x005081c3, 0x00519717, 0x00529920, 0x005386d0, + 0x0054603f, 0x00552581, 0x0055d6cc, 0x00567558, + 0x0057033d, 0x005782b4, 0x0057f5b6, 0x00585e46, + 0x0058be68, 0x005917ff, 0x00596ce4, 0x0059bcc0, + 0x005a053a, 0x005a43ef, 0x005a76af, 0x005a9b37, + 0x005aaf39, 0x005ab07b, 0x005a9cef, 0x005a7349, + 0x005a3328, 0x0059dc0a, 0x00596db0, 0x0058e8e5, + 0x00584f98, 0x0057a3c1, 0x0056e738, 0x00561bec, + 0x005543df, 0x0054610b, 0x0053753e, 0x0052824e, + 0x005189f6, 0x00508ded, 0x004f8fc0, 0x004e8fd1, + 0x004d8d27, 0x004c86d7, 0x004b7c0a, 0x004a6b33, + 0x00495239, 0x00482f0e, 0x0046ffc4, 0x0045c201, + 0x00447337, 0x004310cc, 0x00419871, 0x004008e5, + 0x003e6231, 0x003ca461, 0x003acf8a, 0x0038e57a, + 0x0036e981, 0x0034defa, 0x0032c94b, 0x0030acc6, + 0x002e8eb4, 0x002c7452, 0x002a62aa, 0x00285bbf, + 0x00265eda, 0x00246b24, 0x00227f9c, 0x002098e7, + 0x001eb13b, 0x001cc2ef, 0x001ac899, 0x0018be3d, + 0x0016a198, 0x00147065, 0x00122897, 0x000fcbc5, + 0x000d5f03, 0x000ae77a, 0x00086a52, 0x0005eb92, + 0x00036e4a, 0x0000f57e, 0xfffe8415, 0xfffc1a79, + 0xfff9b6bc, 0xfff756da, 0xfff4f8d1, 0xfff29ade, + 0xfff03b88, 0xffedd94d, 0xffeb7296, 0xffe9072c, + 0xffe6981b, 0xffe4265c, 0xffe1b30f, 0xffdf3f2c, + 0xffdccb9e, 0xffda5994, 0xffd7ea0d, 0xffd57d61, + 0xffd31303, 0xffd0aa28, 0xffce4244, 0xffcbdb41, + 0xffc97596, 0xffc711a3, 0xffc4af9e, 0xffc24fa7, + 0xffbff1de, 0xffbd969a, 0xffbb3e45, 0xffb8e8d6, + 0xffb695f5, 0xffb44522, 0xffb1f628, 0xffafa8f1, + 0xffad5d92, 0xffab140b, 0xffa8cc1d, 0xffa68591, + 0xffa44067, 0xffa1fca0, 0xff9fba30, 0xff9d7903, + 0xff9b3917, 0xff98fa6e, 0xff96bd07, 0xff9480b7, + 0xff924532, 0xff900a25, 0xff8dcf42, 0xff8b9434, + 0xff895885, 0xff871bd4, 0xff84dd8b, 0xff829d34, + 0xff805a44, 0xff7e142e, 0xff7bca72, 0xff797c84, + 0xff7729e4, 0xff74d205, 0xff727452, 0xff70101f, + 0xff6da494, 0xff6b30d2, 0xff68b3f5, 0xff662d32, + 0xff639bd2, 0xff60ff0a, 0xff5e562d, 0xff5ba3e1, + 0xff58ee3a, 0xff563c23, 0xff5394f4, 0xff50fd1f, + 0xff4e759a, 0xff4bff33, 0xff499ad5, 0xff47490b, + 0xff450a37, 0xff42deb8, 0xff40c6d0, 0xff3ec2bf, + 0xff3cd29a, 0xff3af682, 0xff392e6b, 0xff377a4b, + 0xff35d9f8, 0xff344d45, 0xff32d3e9, 0xff316d97, + 0xff3019da, 0xff2ed83b, 0xff2da830, 0xff2c88c0, + 0xff2b78b5, 0xff2a76cd, 0xff298185, 0xff289891, + 0xff27bc7e, 0xff26ee22, 0xff262e29, 0xff257cdd, + 0xff24d9f5, 0xff244525, 0xff23be16, 0xff234489, + 0xff22d853, 0xff227948, 0xff22273e, 0xff21e1d3, + 0xff21a872, 0xff217a7a, 0xff215749, 0xff213ecb, + 0xff21319f, 0xff21305d, 0xff213bb0, 0xff2153c3, + 0xff21782c, 0xff21a893, 0xff21e478, 0xff222bdb, + 0xff227f27, 0xff22debe, 0xff234b0a, 0xff23c395, + 0xff24471e, 0xff24d42c, 0xff25695d, 0xff260539, + 0xff26a653, 0xff274b29, 0xff27f22e, 0xff2899d3, + 0xff295976, 0xff29f2ae, 0xff2a96d8, 0xff2b45f5, + 0xff2bffe4, 0xff2cc4bb, 0xff2d9459, 0xff2e6edf, + 0xff2f544d, 0xff3044b8, 0xff314035, 0xff3246fb, + 0xff33591f, 0xff3476e1, 0xff35a061, 0xff36d535, + 0xff381490, 0xff395db0, 0xff3aafd5, 0xff3c0ac9, + 0xff3d6ed7, 0xff3edc55, 0xff405383, 0xff41d3f6, + 0xff435ccd, 0xff44ed10, 0xff4683d4, 0xff482081, + 0xff49c298, 0xff4b69ac, 0xff4d1548, 0xff4ec4f6, + 0xff50781e, 0xff522e21, 0xff53e693, 0xff55a15e, + 0xff575f18, 0xff592023, 0xff5ae4df, 0xff5cacb5, + 0xff5e75e3, 0xff603ee6, 0xff620630, 0xff63caac, + 0xff658b56, 0xff67476e, 0xff68fe12, 0xff6aaea1, + 0xff6c589a, 0xff6dfb87, 0xff6f96e8, 0xff712a66, + 0xff72b5a0, 0xff74382c, 0xff75b1d4, 0xff772277, + 0xff788a21, 0xff79e8e6, 0xff7b3ef1, 0xff7c8c99, + 0xff7dd24a, 0xff7f108d, 0xff804805, 0xff817d0e, + 0xff82b74b, 0xff83fde7, 0xff855763, 0xff86c623, + 0xff884905, 0xff89ded2, 0xff8b8647, 0xff8d3e4d, + 0xff8f05cd, 0xff90dbc6, 0xff92bf2b, 0xff94af05, + 0xff96aa27, 0xff98af9a, 0xff9abe48, 0xff9cd544, + 0xff9ef3c2, 0xffa118eb, 0xffa343fe, 0xffa57424, + 0xffa7a891, 0xffa9e085, 0xffac1b32, 0xffae5803, + 0xffb09681, 0xffb2d622, 0xffb51678, 0xffb75705, + 0xffb99726, 0xffbbd646, 0xffbe13d8, 0xffc04f26, + 0xffc2879b, 0xffc4bc73, 0xffc6ed25, 0xffc918e4, + 0xffcb3eb9, 0xffcd5dcd, 0xffcf754a, 0xffd184d9, + 0xffd38c90, 0xffd58ca5, 0xffd7854e, 0xffd97695, + 0xffdb606f, 0xffdd42d2, 0xffdf1da8, 0xffe0f09c, + 0xffe2bb01, 0xffe47c42, 0xffe633c7, 0xffe7e151, + 0xffe98535, 0xffeb1fb5, 0xffecb10f, 0xffee3945, + 0xffefb7ea, 0xfff12cbf, 0xfff29763, 0xfff3f78a, + 0xfff54cbf, 0xfff69696, 0xfff7d4b9, 0xfff90749, + 0xfffa2ee6, 0xfffb4c3d, 0xfffc6004, 0xfffd6af1, + 0xfffe6ddb, 0xffff69b9, 0x00005f4b, 0x00014e7f, + 0x00023646, 0x000315b4, 0x0003ebd3, 0x0004b74a, + 0x00057677, 0x000627e2, 0x0006ca09, 0x00075ce1, + 0x0007e196, 0x00085955, 0x0008c556, 0x00092751, + 0x00098153, 0x0009d581, 0x000a25be, 0x000a732b, + 0x000abe1f, 0x000b06e4, 0x000b4db1, 0x000b91fa, + 0x000bd266, 0x000c0da0, 0x000c426e, 0x000c6ffb, + 0x000c95b0, 0x000cb2f7, 0x000cc76e, 0x000cd317, + 0x000cd647, 0x000cd17f, 0x000cc52b, 0x000cb1ea, + 0x000c98c0, 0x000c7a62, 0x000c57c7, 0x000c3187, + 0x000c0862, 0x000bdcd8, 0x000baf81, 0x000b80c7, + 0x000b50ec, 0x000b202f, 0x000aeec6, 0x000abcb2, + 0x000a89d2, 0x000a5605, 0x000a2116, 0x0009eafb, + 0x0009b37d, 0x00097a9d, 0x00094030, 0x00090440, + 0x0008c6b9, 0x000887ae, 0x0008470c, 0x00080512, + 0x0007c1f6, 0x00077df9, 0x0007395a, 0x0006f45b, + 0x0006af67, 0x00066abe, 0x000626b6, 0x0005e38f, + 0x0005a1a0, 0x0005611e, 0x00052234, 0x0004e502, + 0x0004a95d, 0x00046f46, 0x00043691, 0x0003ff33, + 0x0003c90d, 0x0003941f, 0x00036047, 0x00032d9c, + 0x0002fc1e, 0x0002cbed, 0x00029d1e, 0x00026fbc, + 0x000243f2, 0x000219d6, 0x0001f17d, 0x0001caf1, + 0x0001a63e, 0x00018363, 0x00016256, 0x00014316, + 0x0001258f, 0x000109cb, 0x0000efaa, 0x0000d720, + 0x0000c03a, 0x0000aacb, 0x000096de, 0x0000846a, + 0x0000736d, 0x000063d3, 0x000055a6, 0x000048d0, + 0x00003d47, 0x000032f6, 0x000029dc, 0x000021d9, + 0x00001ae3, 0x000014ee, 0x00000fdb, 0x00000ba9, + 0x00000839, 0x00000589, 0x00000370, 0x000001ee, + 0x000000d7, 0x00000036, 0xffffffe1, 0xffffffc1, + 0xffffffd6, 0xfffffff6, 0x0000000b, 0x0000000b, + 0x0000000b, 0x0000000b, 0xfffffff6, 0xffffffd6, + 0xffffffcb, 0xffffffe1, 0x00000036, 0x000000d7, + 0x000001ce, 0x0000033b, 0x00000529, 0x000007ad, + 0x00000ac8, 0x00000e99, 0x00001316, 0x0000185e, + 0x00001e7e, 0x00002575, 0x00002d4c, 0x0000361b, + 0x00003fd6, 0x00004a93, 0x00005647, 0x00006312, + 0x000070de, 0x00007fad, 0x00008f87, 0x0000a064, + 0x0000b242, 0x0000c52d, 0x0000d919, 0x0000ee12, + 0x0001040c, 0x00011b13, 0x0001331b, 0x00014c30, + 0x0001663c, 0x0001814a, 0x00019d4f, 0x0001ba35, + 0x0001d7e7, 0x0001f645, 0x00021544, 0x000234c3, + 0x000254b9, 0x00027505, 0x000295a7, 0x0002b67e, + 0x0002d7a1, 0x0002f904, 0x00031ab2, 0x00033ca0, + 0x00035ee5, 0x0003818a, 0x0003a485, 0x0003c7e1, + 0x0003eb72, 0x00040f0e, 0x0004329f, 0x000455e6, + 0x000478c0, 0x00049aef, 0x0004bc52, 0x0004dca9, + 0x0004fbde, 0x000519c5, 0x00053635, 0x0005512d, + 0x00056aae, 0x000582a1, 0x00059927, 0x0005ae40, + 0x0005c1f6, 0x0005d455, 0x0005e572, 0x0005f56d, + 0x00060446, 0x0006121e, 0x00061f09, 0x00062b08, + 0x00063605, 0x00063feb, 0x00064899, 0x00064ff1, + 0x000655a5, 0x00065996, 0x00065b6f, 0x00065af8, + 0x000657e9, 0x000651d4, 0x00064884, 0x00063bae, + 0x00062b33, 0x00061706, 0x0005fefd, 0x0005e344, + 0x0005c405, 0x0005a195, 0x00057c41, 0x00055473, + 0x00052ac2, 0x0004ffc4, 0x0004d410, 0x0004a7e5, + 0x00047b4f, 0x00044e39, 0x00042096, 0x0003f208, + 0x0003c1e1, 0x00038f77, 0x00035a12, 0x00032127, + 0x0002e476, 0x0002a389, 0x00025e29, 0x0002146d, + 0x0001c700, 0x00017682, 0x000123a1, 0x0000cefd, + 0x000078f7, 0x0000221a, 0xffffcad2, 0xffff7333, + 0xffff1b1f, 0xfffec254, 0xfffe6892, 0xfffe0da3, + 0xfffdb15d, 0xfffd5394, 0xfffcf413, 0xfffc92e4, + 0xfffc3033, 0xfffbcc2a, 0xfffb6715, 0xfffb0114, + 0xfffa9a5c, 0xfffa3338, 0xfff9cbd5, 0xfff96451, + 0xfff8fcad, 0xfff894dd, 0xfff82cd9, 0xfff7c4a9, + 0xfff75c6e, 0xfff6f45f, 0xfff68c85, 0xfff62501, + 0xfff5bde8, 0xfff5575b, 0xfff4f17a, 0xfff48c65, + 0xfff42811, 0xfff3c489, 0xfff361d8, 0xfff30009, + 0xfff29f3b, 0xfff23f79, 0xfff1e0d9, 0xfff1835c, + 0xfff1272b, 0xfff0cc47, 0xfff072d0, 0xfff01ad1, + 0xffefc46a, 0xffef6fa5, 0xffef1ca4, 0xffeecb7b, + 0xffee7c20, 0xffee2eb3, 0xffede33e, 0xffed99c2, + 0xffed524a, 0xffed0cdf, 0xffecc98e, 0xffec884a, + 0xffec4935, 0xffec0c39, 0xffebd176, 0xffeb98ec, + 0xffeb62a5, 0xffeb2eae, 0xffeafd1a, 0xffeacdeb, + 0xffeaa12a, 0xffea76cd, 0xffea4ef4, 0xffea29a0, + 0xffea06e6, 0xffe9e6cf, 0xffe9c97e, 0xffe9aebc, + 0xffe99652, 0xffe97fd7, 0xffe96ad4, 0xffe95712, + 0xffe9447e, 0xffe93316, 0xffe922cf, 0xffe913a1, + 0xffe90589, 0xffe8f888, 0xffe8ec94, 0xffe8e1c2, + 0xffe8d807, 0xffe8cf78, 0xffe8c816, 0xffe8c1ec, + 0xffe8bd04, 0xffe8b968, 0xffe8b72f, 0xffe8b64e, + 0xffe8b6d9, 0xffe8b8dd, 0xffe8bc6d, 0xffe8c18b, + 0xffe8c841, 0xffe8d0a5, 0xffe8dacb, 0xffe8e69f, + 0xffe8f42b, 0xffe9035a, 0xffe9142c, 0xffe926a1, + 0xffe93ab8, 0xffe95067, 0xffe967b9, 0xffe980ae, + 0xffe99b3b, 0xffe9b755, 0xffe9d512, 0xffe9f45c, + 0xffea1533, 0xffea3798, 0xffea5b8a, 0xffea8109, + 0xffeaa800, 0xffead07a, 0xffeafa56, 0xffeb259f, + 0xffeb5255, 0xffeb8062, 0xffebafdd, 0xffebe0af, + 0xffec12cf, 0xffec4630, 0xffec7ade, 0xffecb0a4, + 0xffece775, 0xffed1f33, 0xffed57a8, 0xffed90b3, + 0xffedca49, 0xffee042b, 0xffee3e58, 0xffee788f, +}; diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h index 5ed8508..058f8af 100644 --- a/libavcodec/aactab.h +++ b/libavcodec/aactab.h @@ -46,7 +46,11 @@ */ DECLARE_ALIGNED(32, extern float, ff_aac_kbd_long_1024)[1024]; DECLARE_ALIGNED(32, extern float, ff_aac_kbd_short_128)[128]; +DECLARE_ALIGNED(32, extern int, ff_aac_kbd_long_1024_fixed)[1024]; +DECLARE_ALIGNED(32, extern int, ff_aac_kbd_long_512_fixed)[512]; +DECLARE_ALIGNED(32, extern int, ff_aac_kbd_short_128_fixed)[128]; const DECLARE_ALIGNED(32, extern float, ff_aac_eld_window)[1920]; +const DECLARE_ALIGNED(32, extern int, ff_aac_eld_window_fixed)[1920]; // @} /* @name number of scalefactor window bands for long and short transform windows respectively diff --git a/libavcodec/cbrt_fixed_tablegen.c b/libavcodec/cbrt_fixed_tablegen.c new file mode 100644 index 0000000..24d2fbb --- /dev/null +++ b/libavcodec/cbrt_fixed_tablegen.c @@ -0,0 +1,24 @@ +/* + * Generate a header file for hardcoded AAC cube-root table + * + * Copyright (c) 2010 Reimar D??ffinger + * + * This file is part of FFmpeg. + * + * 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 + */ + +#define USE_FIXED 1 +#include "cbrt_tablegen_template.c" diff --git a/libavcodec/cbrt_tablegen.c b/libavcodec/cbrt_tablegen.c index 59918ae..8c2235e 100644 --- a/libavcodec/cbrt_tablegen.c +++ b/libavcodec/cbrt_tablegen.c @@ -19,3 +19,6 @@ * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#define USE_FIXED 0 +#include "cbrt_tablegen_template.c" diff --git a/libavcodec/cbrt_tablegen.h b/libavcodec/cbrt_tablegen.h index 0db64fc..f3a5220 100644 --- a/libavcodec/cbrt_tablegen.h +++ b/libavcodec/cbrt_tablegen.h @@ -26,13 +26,26 @@ #include #include +#if USE_FIXED +#define CBRT_RENAME(a) a ## _fixed +#define CBRT(x) (int)floor((x).f * 8192 + 0.5) +#else +#define CBRT_RENAME(a) a +#define CBRT(x) x.i +#endif + #if CONFIG_HARDCODED_TABLES +#if USE_FIXED +#define cbrt_tableinit_fixed() +#include "libavcodec/cbrt_fixed_tables.h" +#else #define cbrt_tableinit() #include "libavcodec/cbrt_tables.h" +#endif #else static uint32_t cbrt_tab[1 << 13]; -static void cbrt_tableinit(void) +static void CBRT_RENAME(cbrt_tableinit)(void) { if (!cbrt_tab[(1<<13) - 1]) { int i; @@ -43,7 +56,7 @@ static void cbrt_tableinit(void) uint32_t i; } f; f.f = pow(i, 1.0 / 3.0) * i; - cbrt_tab[i] = f.i; + cbrt_tab[i] = CBRT(f); } } } diff --git a/libavcodec/cbrt_tablegen_template.c b/libavcodec/cbrt_tablegen_template.c index 33746d2..0061141 100644 --- a/libavcodec/cbrt_tablegen_template.c +++ b/libavcodec/cbrt_tablegen_template.c @@ -27,7 +27,7 @@ int main(void) { - cbrt_tableinit(); + CBRT_RENAME(cbrt_tableinit)(); write_fileheader(); diff --git a/libavcodec/sinewin.c b/libavcodec/sinewin.c index 1fa0e95..4532dc7 100644 --- a/libavcodec/sinewin.c +++ b/libavcodec/sinewin.c @@ -16,5 +16,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#define USE_FIXED 0 #include "sinewin.h" #include "sinewin_tablegen.h" diff --git a/libavcodec/sinewin.h b/libavcodec/sinewin.h index 2268fd5..5f0a74a 100644 --- a/libavcodec/sinewin.h +++ b/libavcodec/sinewin.h @@ -30,20 +30,32 @@ # define SINETABLE_CONST #endif +#ifndef USE_FIXED +#define USE_FIXED 0 +#endif + +#if USE_FIXED +#define SINEWIN_SUFFIX(a) a ## _fixed +#define INTFLOAT int +#else +#define SINEWIN_SUFFIX(a) a +#define INTFLOAT float +#endif + #define SINETABLE(size) \ - SINETABLE_CONST DECLARE_ALIGNED(32, float, ff_sine_##size)[size] + SINETABLE_CONST DECLARE_ALIGNED(32, INTFLOAT, SINEWIN_SUFFIX(ff_sine_##size))[size] /** * Generate a sine window. * @param window pointer to half window * @param n size of half window */ -void ff_sine_window_init(float *window, int n); +void SINEWIN_SUFFIX(ff_sine_window_init)(INTFLOAT *window, int n); /** * initialize the specified entry of ff_sine_windows */ -void ff_init_ff_sine_windows(int index); +void SINEWIN_SUFFIX(ff_init_ff_sine_windows)(int index); extern SINETABLE( 32); extern SINETABLE( 64); @@ -55,6 +67,6 @@ extern SINETABLE(2048); extern SINETABLE(4096); extern SINETABLE(8192); -extern SINETABLE_CONST float * const ff_sine_windows[14]; +extern SINETABLE_CONST INTFLOAT * const SINEWIN_SUFFIX(ff_sine_windows)[14]; #endif /* AVCODEC_SINEWIN_H */ diff --git a/libavcodec/sinewin_fixed.c b/libavcodec/sinewin_fixed.c new file mode 100644 index 0000000..27ead29 --- /dev/null +++ b/libavcodec/sinewin_fixed.c @@ -0,0 +1,21 @@ +/* + * This file is part of FFmpeg. + * + * 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 + */ + +#define USE_FIXED 1 +#include "sinewin.h" +#include "sinewin_tablegen.h" diff --git a/libavcodec/sinewin_fixed_tablegen.c b/libavcodec/sinewin_fixed_tablegen.c new file mode 100644 index 0000000..977e6f3 --- /dev/null +++ b/libavcodec/sinewin_fixed_tablegen.c @@ -0,0 +1,24 @@ +/* + * Generate a header file for hardcoded sine windows + * + * Copyright (c) 2009 Reimar D??ffinger + * + * This file is part of FFmpeg. + * + * 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 + */ + +#define USE_FIXED 1 +#include "sinewin_tablegen_template.c" diff --git a/libavcodec/sinewin_tablegen.c b/libavcodec/sinewin_tablegen.c index 2013b95..dd60266 100644 --- a/libavcodec/sinewin_tablegen.c +++ b/libavcodec/sinewin_tablegen.c @@ -19,3 +19,6 @@ * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#define USE_FIXED 0 +#include "sinewin_tablegen_template.c" diff --git a/libavcodec/sinewin_tablegen.h b/libavcodec/sinewin_tablegen.h index 2b9c4f2..e1623b4 100644 --- a/libavcodec/sinewin_tablegen.h +++ b/libavcodec/sinewin_tablegen.h @@ -41,26 +41,41 @@ SINETABLE(2048); SINETABLE(4096); SINETABLE(8192); #else +#if USE_FIXED +#include "libavcodec/sinewin_fixed_tables.h" +#else #include "libavcodec/sinewin_tables.h" #endif +#endif + +#if USE_FIXED +#define SINEWIN_SUFFIX(a) a ## _fixed +#define INTFLOAT int +#define SIN_FIX(a) (int)floor((a) * 0x80000000 + 0.5) +#else +#define SINEWIN_SUFFIX(a) a +#define INTFLOAT float +#define SIN_FIX(a) a +#endif -SINETABLE_CONST float * const ff_sine_windows[] = { +SINETABLE_CONST INTFLOAT * const SINEWIN_SUFFIX(ff_sine_windows)[] = { NULL, NULL, NULL, NULL, NULL, // unused - ff_sine_32 , ff_sine_64 , - ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048, ff_sine_4096, ff_sine_8192 + SINEWIN_SUFFIX(ff_sine_32) , SINEWIN_SUFFIX(ff_sine_64), SINEWIN_SUFFIX(ff_sine_128), + SINEWIN_SUFFIX(ff_sine_256), SINEWIN_SUFFIX(ff_sine_512), SINEWIN_SUFFIX(ff_sine_1024), + SINEWIN_SUFFIX(ff_sine_2048), SINEWIN_SUFFIX(ff_sine_4096), SINEWIN_SUFFIX(ff_sine_8192) }; // Generate a sine window. -av_cold void ff_sine_window_init(float *window, int n) { +av_cold void SINEWIN_SUFFIX(ff_sine_window_init)(INTFLOAT *window, int n) { int i; for(i = 0; i < n; i++) - window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n))); + window[i] = SIN_FIX(sinf((i + 0.5) * (M_PI / (2.0 * n)))); } -av_cold void ff_init_ff_sine_windows(int index) { - assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows)); +av_cold void SINEWIN_SUFFIX(ff_init_ff_sine_windows)(int index) { + assert(index >= 0 && index < FF_ARRAY_ELEMS(SINEWIN_SUFFIX(ff_sine_windows))); #if !CONFIG_HARDCODED_TABLES - ff_sine_window_init(ff_sine_windows[index], 1 << index); + SINEWIN_SUFFIX(ff_sine_window_init)(SINEWIN_SUFFIX(ff_sine_windows)[index], 1 << index); #endif } diff --git a/libavcodec/sinewin_tablegen_template.c b/libavcodec/sinewin_tablegen_template.c index 50eb1a0..4a03dc0 100644 --- a/libavcodec/sinewin_tablegen_template.c +++ b/libavcodec/sinewin_tablegen_template.c @@ -22,9 +22,23 @@ #include #define CONFIG_HARDCODED_TABLES 0 + +#if USE_FIXED +#define ADD_SUFFIX(a) a ## _fixed +#define INTFLOAT int +#define WRITE_FUNC write_int32_t_array + +#else + +#define ADD_SUFFIX(a) a +#define INTFLOAT float +#define WRITE_FUNC write_float_array + +#endif + #define SINETABLE_CONST #define SINETABLE(size) \ - float ff_sine_##size[size] + INTFLOAT ADD_SUFFIX(ff_sine_##size)[size] #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) #include "sinewin_tablegen.h" #include "tableprint.h" @@ -36,9 +50,9 @@ int main(void) write_fileheader(); for (i = 5; i <= 13; i++) { - ff_init_ff_sine_windows(i); + ADD_SUFFIX(ff_init_ff_sine_windows)(i); printf("SINETABLE(%4i) = {\n", 1 << i); - write_float_array(ff_sine_windows[i], 1 << i); + WRITE_FUNC(ADD_SUFFIX(ff_sine_windows)[i], 1 << i); printf("};\n"); } diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h index 26d063e..0fe374e 100644 --- a/libavcodec/tableprint.h +++ b/libavcodec/tableprint.h @@ -64,6 +64,7 @@ void write_int8_t_array (const int8_t *, int); void write_uint8_t_array (const uint8_t *, int); void write_uint16_t_array (const uint16_t *, int); void write_uint32_t_array (const uint32_t *, int); +void write_int32_t_array (const int32_t *, int); void write_float_array (const float *, int); void write_int8_t_2d_array (const void *, int, int); void write_uint8_t_2d_array (const void *, int, int); @@ -105,6 +106,7 @@ WRITE_1D_FUNC(int8_t, "%3"PRIi8, 15) WRITE_1D_FUNC(uint8_t, "0x%02"PRIx8, 15) WRITE_1D_FUNC(uint16_t, "0x%08"PRIx16, 7) WRITE_1D_FUNC(uint32_t, "0x%08"PRIx32, 7) +WRITE_1D_FUNC(int32_t, "0x%08"PRIx32, 7) WRITE_1D_FUNC(float, "%.18e", 3) WRITE_2D_FUNC(int8_t) -- 1.8.2.1 From nedeljko.babic at imgtec.com Fri Aug 1 15:53:20 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:20 +0200 Subject: [FFmpeg-devel] [PATCH 14/14] Edit documentation and versioning In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-15-git-send-email-nedeljko.babic@imgtec.com> From: Jovan Zelincevic Signed-off-by: Nedeljko Babic --- Changelog | 1 + doc/general.texi | 2 +- doc/mips.txt | 6 ++++++ libavutil/version.h | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 067f72a..c786d19 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. version : +- AAC fixed-point decoding version 2.3: diff --git a/doc/general.texi b/doc/general.texi index 35db917..368198d 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -821,7 +821,7 @@ following image formats are supported: @item 8SVX fibonacci @tab @tab X @item AAC+ @tab E @tab X @tab encoding supported through external library libaacplus - at item AAC @tab E @tab X + at item AAC @tab E @tab IX @tab encoding supported through external library libfaac and libvo-aacenc @item AC-3 @tab IX @tab IX @item ADPCM 4X Movie @tab @tab X diff --git a/doc/mips.txt b/doc/mips.txt index 8c6779f..8fb97a3 100644 --- a/doc/mips.txt +++ b/doc/mips.txt @@ -48,9 +48,15 @@ Files that have MIPS copyright notice in them: float_dsp_mips.c libm_mips.h * libavcodec/ + aac_float_emu.h + aacdec_fixed.c + aacsbr_fixed.c + aacsbr_template.c fft_fixed_32.c fft_init_table.c fft_table.h + float_emu_tab.c + float_emu.h mdct_fixed_32.c * libavcodec/mips/ aaccoder_mips.c diff --git a/libavutil/version.h b/libavutil/version.h index 42e2db5..b4d511d 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -57,7 +57,7 @@ #define LIBAVUTIL_VERSION_MAJOR 52 #define LIBAVUTIL_VERSION_MINOR 94 -#define LIBAVUTIL_VERSION_MICRO 100 +#define LIBAVUTIL_VERSION_MICRO 101 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ -- 1.8.2.1 From nedeljko.babic at imgtec.com Fri Aug 1 15:53:16 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:16 +0200 Subject: [FFmpeg-devel] [PATCH 10/14] libavcodec: Implementation of AAC_fixed_decoder (PS-module) [1/4] In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-11-git-send-email-nedeljko.babic@imgtec.com> From: Djordje Pesut Move existing code to a new file. Signed-off-by: Nedeljko Babic --- libavcodec/aacps.c | 157 ----------------------------------------- libavcodec/aacps_float.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 157 deletions(-) create mode 100644 libavcodec/aacps_float.c diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c index 20012f9..fdaae3f 100644 --- a/libavcodec/aacps.c +++ b/libavcodec/aacps.c @@ -749,163 +749,6 @@ static void remap20(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC], } } -static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34) -{ - int e, b, k; - - float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11; - float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12; - float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21; - float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22; - int8_t *opd_hist = ps->opd_hist; - int8_t *ipd_hist = ps->ipd_hist; - int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; - int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; - int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; - int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; - int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf; - int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf; - int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf; - int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf; - const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; - TABLE_CONST float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; - - //Remapping - if (ps->num_env_old) { - memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0])); - memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0])); - memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0])); - memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0])); - memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0])); - memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0])); - memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0])); - memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0])); - } - - if (is34) { - remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); - remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); - if (ps->enable_ipdopd) { - remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); - remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); - } - if (!ps->is34bands_old) { - map_val_20_to_34(H11[0][0]); - map_val_20_to_34(H11[1][0]); - map_val_20_to_34(H12[0][0]); - map_val_20_to_34(H12[1][0]); - map_val_20_to_34(H21[0][0]); - map_val_20_to_34(H21[1][0]); - map_val_20_to_34(H22[0][0]); - map_val_20_to_34(H22[1][0]); - ipdopd_reset(ipd_hist, opd_hist); - } - } else { - remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); - remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); - if (ps->enable_ipdopd) { - remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); - remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); - } - if (ps->is34bands_old) { - map_val_34_to_20(H11[0][0]); - map_val_34_to_20(H11[1][0]); - map_val_34_to_20(H12[0][0]); - map_val_34_to_20(H12[1][0]); - map_val_34_to_20(H21[0][0]); - map_val_34_to_20(H21[1][0]); - map_val_34_to_20(H22[0][0]); - map_val_34_to_20(H22[1][0]); - ipdopd_reset(ipd_hist, opd_hist); - } - } - - //Mixing - for (e = 0; e < ps->num_env; e++) { - for (b = 0; b < NR_PAR_BANDS[is34]; b++) { - float h11, h12, h21, h22; - h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0]; - h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1]; - h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2]; - h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3]; - - if (!PS_BASELINE && ps->enable_ipdopd && b < NR_IPDOPD_BANDS[is34]) { - //The spec say says to only run this smoother when enable_ipdopd - //is set but the reference decoder appears to run it constantly - float h11i, h12i, h21i, h22i; - float ipd_adj_re, ipd_adj_im; - int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b]; - int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b]; - float opd_re = pd_re_smooth[opd_idx]; - float opd_im = pd_im_smooth[opd_idx]; - float ipd_re = pd_re_smooth[ipd_idx]; - float ipd_im = pd_im_smooth[ipd_idx]; - opd_hist[b] = opd_idx & 0x3F; - ipd_hist[b] = ipd_idx & 0x3F; - - ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im; - ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im; - h11i = h11 * opd_im; - h11 = h11 * opd_re; - h12i = h12 * ipd_adj_im; - h12 = h12 * ipd_adj_re; - h21i = h21 * opd_im; - h21 = h21 * opd_re; - h22i = h22 * ipd_adj_im; - h22 = h22 * ipd_adj_re; - H11[1][e+1][b] = h11i; - H12[1][e+1][b] = h12i; - H21[1][e+1][b] = h21i; - H22[1][e+1][b] = h22i; - } - H11[0][e+1][b] = h11; - H12[0][e+1][b] = h12; - H21[0][e+1][b] = h21; - H22[0][e+1][b] = h22; - } - for (k = 0; k < NR_BANDS[is34]; k++) { - float h[2][4]; - float h_step[2][4]; - int start = ps->border_position[e]; - int stop = ps->border_position[e+1]; - float width = 1.f / (stop - start); - b = k_to_i[k]; - h[0][0] = H11[0][e][b]; - h[0][1] = H12[0][e][b]; - h[0][2] = H21[0][e][b]; - h[0][3] = H22[0][e][b]; - if (!PS_BASELINE && ps->enable_ipdopd) { - //Is this necessary? ps_04_new seems unchanged - if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) { - h[1][0] = -H11[1][e][b]; - h[1][1] = -H12[1][e][b]; - h[1][2] = -H21[1][e][b]; - h[1][3] = -H22[1][e][b]; - } else { - h[1][0] = H11[1][e][b]; - h[1][1] = H12[1][e][b]; - h[1][2] = H21[1][e][b]; - h[1][3] = H22[1][e][b]; - } - } - //Interpolation - h_step[0][0] = (H11[0][e+1][b] - h[0][0]) * width; - h_step[0][1] = (H12[0][e+1][b] - h[0][1]) * width; - h_step[0][2] = (H21[0][e+1][b] - h[0][2]) * width; - h_step[0][3] = (H22[0][e+1][b] - h[0][3]) * width; - if (!PS_BASELINE && ps->enable_ipdopd) { - h_step[1][0] = (H11[1][e+1][b] - h[1][0]) * width; - h_step[1][1] = (H12[1][e+1][b] - h[1][1]) * width; - h_step[1][2] = (H21[1][e+1][b] - h[1][2]) * width; - h_step[1][3] = (H22[1][e+1][b] - h[1][3]) * width; - } - ps->dsp.stereo_interpolate[!PS_BASELINE && ps->enable_ipdopd]( - l[k] + start + 1, r[k] + start + 1, - h, h_step, stop - start); - } - } -} - int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top) { LOCAL_ALIGNED_16(float, Lbuf, [91], [32][2]); diff --git a/libavcodec/aacps_float.c b/libavcodec/aacps_float.c new file mode 100644 index 0000000..93a498c --- /dev/null +++ b/libavcodec/aacps_float.c @@ -0,0 +1,177 @@ +/* + * MPEG-4 Parametric Stereo decoding functions + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * 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 + */ + +static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34) +{ + int e, b, k; + + float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11; + float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12; + float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21; + float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22; + int8_t *opd_hist = ps->opd_hist; + int8_t *ipd_hist = ps->ipd_hist; + int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf; + int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf; + int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf; + int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf; + const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; + TABLE_CONST float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; + + //Remapping + if (ps->num_env_old) { + memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0])); + memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0])); + memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0])); + memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0])); + memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0])); + memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0])); + memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0])); + memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0])); + } + + if (is34) { + remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); + remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); + if (ps->enable_ipdopd) { + remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); + remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); + } + if (!ps->is34bands_old) { + map_val_20_to_34(H11[0][0]); + map_val_20_to_34(H11[1][0]); + map_val_20_to_34(H12[0][0]); + map_val_20_to_34(H12[1][0]); + map_val_20_to_34(H21[0][0]); + map_val_20_to_34(H21[1][0]); + map_val_20_to_34(H22[0][0]); + map_val_20_to_34(H22[1][0]); + ipdopd_reset(ipd_hist, opd_hist); + } + } else { + remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); + remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); + if (ps->enable_ipdopd) { + remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); + remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); + } + if (ps->is34bands_old) { + map_val_34_to_20(H11[0][0]); + map_val_34_to_20(H11[1][0]); + map_val_34_to_20(H12[0][0]); + map_val_34_to_20(H12[1][0]); + map_val_34_to_20(H21[0][0]); + map_val_34_to_20(H21[1][0]); + map_val_34_to_20(H22[0][0]); + map_val_34_to_20(H22[1][0]); + ipdopd_reset(ipd_hist, opd_hist); + } + } + + //Mixing + for (e = 0; e < ps->num_env; e++) { + for (b = 0; b < NR_PAR_BANDS[is34]; b++) { + float h11, h12, h21, h22; + h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0]; + h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1]; + h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2]; + h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3]; + + if (!PS_BASELINE && ps->enable_ipdopd && b < NR_IPDOPD_BANDS[is34]) { + //The spec say says to only run this smoother when enable_ipdopd + //is set but the reference decoder appears to run it constantly + float h11i, h12i, h21i, h22i; + float ipd_adj_re, ipd_adj_im; + int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b]; + int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b]; + float opd_re = pd_re_smooth[opd_idx]; + float opd_im = pd_im_smooth[opd_idx]; + float ipd_re = pd_re_smooth[ipd_idx]; + float ipd_im = pd_im_smooth[ipd_idx]; + opd_hist[b] = opd_idx & 0x3F; + ipd_hist[b] = ipd_idx & 0x3F; + + ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im; + ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im; + h11i = h11 * opd_im; + h11 = h11 * opd_re; + h12i = h12 * ipd_adj_im; + h12 = h12 * ipd_adj_re; + h21i = h21 * opd_im; + h21 = h21 * opd_re; + h22i = h22 * ipd_adj_im; + h22 = h22 * ipd_adj_re; + H11[1][e+1][b] = h11i; + H12[1][e+1][b] = h12i; + H21[1][e+1][b] = h21i; + H22[1][e+1][b] = h22i; + } + H11[0][e+1][b] = h11; + H12[0][e+1][b] = h12; + H21[0][e+1][b] = h21; + H22[0][e+1][b] = h22; + } + for (k = 0; k < NR_BANDS[is34]; k++) { + float h[2][4]; + float h_step[2][4]; + int start = ps->border_position[e]; + int stop = ps->border_position[e+1]; + float width = 1.f / (stop - start); + b = k_to_i[k]; + h[0][0] = H11[0][e][b]; + h[0][1] = H12[0][e][b]; + h[0][2] = H21[0][e][b]; + h[0][3] = H22[0][e][b]; + if (!PS_BASELINE && ps->enable_ipdopd) { + //Is this necessary? ps_04_new seems unchanged + if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) { + h[1][0] = -H11[1][e][b]; + h[1][1] = -H12[1][e][b]; + h[1][2] = -H21[1][e][b]; + h[1][3] = -H22[1][e][b]; + } else { + h[1][0] = H11[1][e][b]; + h[1][1] = H12[1][e][b]; + h[1][2] = H21[1][e][b]; + h[1][3] = H22[1][e][b]; + } + } + //Interpolation + h_step[0][0] = (H11[0][e+1][b] - h[0][0]) * width; + h_step[0][1] = (H12[0][e+1][b] - h[0][1]) * width; + h_step[0][2] = (H21[0][e+1][b] - h[0][2]) * width; + h_step[0][3] = (H22[0][e+1][b] - h[0][3]) * width; + if (!PS_BASELINE && ps->enable_ipdopd) { + h_step[1][0] = (H11[1][e+1][b] - h[1][0]) * width; + h_step[1][1] = (H12[1][e+1][b] - h[1][1]) * width; + h_step[1][2] = (H21[1][e+1][b] - h[1][2]) * width; + h_step[1][3] = (H22[1][e+1][b] - h[1][3]) * width; + } + ps->dsp.stereo_interpolate[!PS_BASELINE && ps->enable_ipdopd]( + l[k] + start + 1, r[k] + start + 1, + h, h_step, stop - start); + } + } +} -- 1.8.2.1 From nedeljko.babic at imgtec.com Fri Aug 1 15:53:15 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:15 +0200 Subject: [FFmpeg-devel] [PATCH 09/14] libavcodec: Implementation of AAC_fixed_decoder (SBR-module) [4/4] In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-10-git-send-email-nedeljko.babic@imgtec.com> From: Jovan Zelincevic Build system modified. Signed-off-by: Nedeljko Babic --- libavcodec/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3ce317d..5931554 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -107,9 +107,10 @@ OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \ aacadtsdec.o mpeg4audio.o kbdwin.o \ - sbrdsp.o aacpsdsp.o -OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o \ - aacadtsdec.o mpeg4audio.o kbdwin.o + sbrdsp_float.o aacpsdsp.o +OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o \ + aacadtsdec.o mpeg4audio.o kbdwin.o \ + sbrdsp_fixed.o OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \ aacpsy.o aactab.o \ psymodel.o mpeg4audio.o kbdwin.o -- 1.8.2.1 From nedeljko.babic at imgtec.com Fri Aug 1 15:53:10 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:10 +0200 Subject: [FFmpeg-devel] [PATCH 04/14] libavcodec/libavutil: Implementation of AAC_fixed_decoder (LC-module) [4/5] In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-5-git-send-email-nedeljko.babic@imgtec.com> From: Djordje Pesut Add fixed point implementation Signed-off-by: Nedeljko Babic --- libavcodec/aac.h | 102 ++++++++-- libavcodec/aacdec.c | 5 + libavcodec/aacdec_fixed.c | 458 ++++++++++++++++++++++++++++++++++++++++++ libavcodec/aacdec_template.c | 461 +++++++++++++++++++++++++++++++------------ libavcodec/fmtconvert.c | 17 ++ libavcodec/fmtconvert.h | 2 + libavcodec/lpc.h | 48 +++++ libavcodec/mdct_template.c | 9 +- libavutil/fixed_dsp.c | 70 ++++++- libavutil/fixed_dsp.h | 53 +++++ 10 files changed, 1071 insertions(+), 154 deletions(-) create mode 100644 libavcodec/aacdec_fixed.c diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 1bcd95c..35e871b 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -30,8 +30,60 @@ #ifndef AVCODEC_AAC_H #define AVCODEC_AAC_H +#ifndef USE_FIXED +#define USE_FIXED 0 +#endif + +#if USE_FIXED + +#define FFT_FLOAT 0 +#define FFT_FIXED_32 1 + +#define AAC_RENAME(x) x ## _fixed +#define AAC_RENAME_32(x) x ## _fixed_32 +#define INTFLOAT int +#define SHORTFLOAT int16_t +#define AAC_FLOAT aac_float_t +#define AAC_SIGNE int +#define FIXR(a) ((int)((a) * 1 + 0.5)) +#define FIXR10(a) ((int)((a) * 1024.0 + 0.5)) +#define Q23(a) (int)((a) * 8388608.0 + 0.5) +#define Q30(x) (int)((x)*1073741824.0 + 0.5) +#define Q31(x) (int)((x)*2147483648.0 + 0.5) +#define RANGE15(x) x +#define GET_GAIN(x, y) (-(y) << (x)) + 1024 +#define AAC_MUL26(x, y) (int)(((int64_t)(x) * (y) + 0x2000000) >> 26) +#define AAC_MUL30(x, y) (int)(((int64_t)(x) * (y) + 0x20000000) >> 30) +#define AAC_MUL31(x, y) (int)(((int64_t)(x) * (y) + 0x40000000) >> 31) + +#else + +#define FFT_FLOAT 1 +#define FFT_FIXED_32 0 + +#define AAC_RENAME(x) x +#define AAC_RENAME_32(x) x +#define INTFLOAT float +#define SHORTFLOAT float +#define AAC_FLOAT float +#define AAC_SIGNE unsigned +#define FIXR(x) ((float)(x)) +#define FIXR10(x) ((float)(x)) +#define Q23(x) x +#define Q30(x) x +#define Q31(x) x +#define RANGE15(x) (32768.0 * (x)) +#define GET_GAIN(x, y) powf((x), -(y)) +#define AAC_MUL26(x, y) ((x) * (y)) +#define AAC_MUL30(x, y) ((x) * (y)) +#define AAC_MUL31(x, y) ((x) * (y)) + +#endif /* USE_FIXED */ + #include "libavutil/float_dsp.h" +#include "libavutil/fixed_dsp.h" #include "avcodec.h" +#include "dsputil.h" #include "fft.h" #include "mpeg4audio.h" #include "sbr.h" @@ -125,12 +177,12 @@ typedef struct OutputConfiguration { * Predictor State */ typedef struct PredictorState { - float cor0; - float cor1; - float var0; - float var1; - float r0; - float r1; + AAC_FLOAT cor0; + AAC_FLOAT cor1; + AAC_FLOAT var0; + AAC_FLOAT var1; + AAC_FLOAT r0; + AAC_FLOAT r1; } PredictorState; #define MAX_PREDICTORS 672 @@ -147,7 +199,7 @@ typedef struct PredictorState { typedef struct LongTermPrediction { int8_t present; int16_t lag; - float coef; + INTFLOAT coef; int8_t used[MAX_LTP_LONG_SFB]; } LongTermPrediction; @@ -181,7 +233,7 @@ typedef struct TemporalNoiseShaping { int length[8][4]; int direction[8][4]; int order[8][4]; - float coef[8][4][TNS_MAX_ORDER]; + INTFLOAT coef[8][4][TNS_MAX_ORDER]; } TemporalNoiseShaping; /** @@ -218,7 +270,7 @@ typedef struct ChannelCoupling { int ch_select[8]; /**< [0] shared list of gains; [1] list of gains for right channel; * [2] list of gains for left channel; [3] lists of gains for both channels */ - float gain[16][120]; + INTFLOAT gain[16][120]; } ChannelCoupling; /** @@ -230,15 +282,16 @@ typedef struct SingleChannelElement { Pulse pulse; enum BandType band_type[128]; ///< band types int band_type_run_end[120]; ///< band type run end points - float sf[120]; ///< scalefactors + INTFLOAT sf[120]; ///< scalefactors int sf_idx[128]; ///< scalefactor indices (used by encoder) uint8_t zeroes[128]; ///< band is not coded (used by encoder) - DECLARE_ALIGNED(32, float, coeffs)[1024]; ///< coefficients for IMDCT - DECLARE_ALIGNED(32, float, saved)[1536]; ///< overlap - DECLARE_ALIGNED(32, float, ret_buf)[2048]; ///< PCM output buffer - DECLARE_ALIGNED(16, float, ltp_state)[3072]; ///< time signal for LTP + DECLARE_ALIGNED(32, INTFLOAT, coeffs)[1024]; ///< coefficients for IMDCT + DECLARE_ALIGNED(32, INTFLOAT, saved)[1024]; ///< overlap + DECLARE_ALIGNED(32, INTFLOAT, ret_buf)[2048]; ///< PCM output buffer + DECLARE_ALIGNED(16, INTFLOAT, ltp_state)[3072]; ///< time signal for LTP + DECLARE_ALIGNED(32, int, temp_sbr)[2048]; ///< PCM intermediate buffer for SBR PredictorState predictor_state[MAX_PREDICTORS]; - float *ret; ///< PCM output + INTFLOAT *ret; ///< PCM output } SingleChannelElement; /** @@ -281,7 +334,7 @@ struct AACContext { * (We do not want to have these on the stack.) * @{ */ - DECLARE_ALIGNED(32, float, buf_mdct)[1024]; + DECLARE_ALIGNED(32, INTFLOAT, buf_mdct)[1024]; /** @} */ /** @@ -292,8 +345,13 @@ struct AACContext { FFTContext mdct_small; FFTContext mdct_ld; FFTContext mdct_ltp; + DSPContext dsp; FmtConvertContext fmt_conv; +#if USE_FIXED + AVFixedDSPContext *fdsp; +#else AVFloatDSPContext fdsp; +#endif /* USE_FIXED */ int random_state; /** @} */ @@ -313,7 +371,7 @@ struct AACContext { int dmono_mode; ///< 0->not dmono, 1->use first channel, 2->use second channel /** @} */ - DECLARE_ALIGNED(32, float, temp)[128]; + DECLARE_ALIGNED(32, INTFLOAT, temp)[128]; OutputConfiguration oc[2]; int warned_num_aac_frames; @@ -321,14 +379,18 @@ struct AACContext { /* aacdec functions pointers */ void (*imdct_and_windowing)(AACContext *ac, SingleChannelElement *sce); void (*apply_ltp)(AACContext *ac, SingleChannelElement *sce); - void (*apply_tns)(float coef[1024], TemporalNoiseShaping *tns, + void (*apply_tns)(INTFLOAT coef[1024], TemporalNoiseShaping *tns, IndividualChannelStream *ics, int decode); - void (*windowing_and_mdct_ltp)(AACContext *ac, float *out, - float *in, IndividualChannelStream *ics); + void (*windowing_and_mdct_ltp)(AACContext *ac, INTFLOAT *out, + INTFLOAT *in, IndividualChannelStream *ics); void (*update_ltp)(AACContext *ac, SingleChannelElement *sce); + void (*vector_pow43)(int *coefs, int len); + void (*subband_scale)(int *dst, int *src, int scale, int offset, int len); + void (*imdct_and_windowing_fixed)(AACContext *ac, SingleChannelElement *sce); }; +extern int exp2tab[4]; void ff_aacdec_init_mips(AACContext *c); #endif /* AVCODEC_AAC_H */ diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 2e6d2bc..8cdd353 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -32,6 +32,11 @@ * @author Maxim Gavrilov ( maxim.gavrilov gmail com ) */ +#define FFT_FLOAT 1 +#define FFT_FIXED_32 0 +#define USE_FIXED 0 +#define CONFIG_FIXED 0 + #include "libavutil/float_dsp.h" #include "libavutil/opt.h" #include "avcodec.h" diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c new file mode 100644 index 0000000..e6f43ce --- /dev/null +++ b/libavcodec/aacdec_fixed.c @@ -0,0 +1,458 @@ +/* + * Copyright (c) 2013 + * MIPS Technologies, Inc., California. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * AAC decoder fixed-point implementation + * + * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org ) + * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com ) + * + * This file is part of FFmpeg. + * + * 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 + */ + +/** + * @file + * AAC decoder + * @author Oded Shimon ( ods15 ods15 dyndns org ) + * @author Maxim Gavrilov ( maxim.gavrilov gmail com ) + * + * Fixed point implementation + * @author Stanislav Ocovaj ( stanislav.ocovaj imgtec com ) + */ + +#define FFT_FLOAT 0 +#define FFT_FIXED_32 1 +#define USE_FIXED 1 +#define CONFIG_FIXED 1 + +#include "libavutil/fixed_dsp.h" +#include "libavutil/opt.h" +#include "avcodec.h" +#include "internal.h" +#include "get_bits.h" +#include "fft.h" +#include "fmtconvert.h" +#include "lpc.h" +#include "kbdwin.h" +#include "sinewin.h" + +#include "aac.h" +#include "aactab.h" +#include "aacdectab.h" +#include "cbrt_tablegen.h" +#include "sbr.h" +#include "aacsbr.h" +#include "mpeg4audio.h" +#include "aacadtsdec.h" +#include "libavutil/intfloat.h" + +#include +#include +#include +#include + +static av_always_inline void reset_predict_state(PredictorState *ps) +{ + ps->r0.mant = 0; + ps->r0.expo = 0; + ps->r1.mant = 0; + ps->r1.expo = 0; + ps->cor0.mant = 0; + ps->cor0.expo = 0; + ps->cor1.mant = 0; + ps->cor1.expo = 0; + ps->var0.mant = 0x20000000; + ps->var0.expo = 1; + ps->var1.mant = 0x20000000; + ps->var1.expo = 1; +} + +int exp2tab[4] = { Q31(1.0000000000/2), Q31(1.1892071150/2), Q31(1.4142135624/2), Q31(1.6817928305/2) }; // 2^0, 2^0.25, 2^0.5, 2^0.75 + +static inline int *DEC_SPAIR(int *dst, unsigned idx) +{ + dst[0] = (idx & 15) - 4; + dst[1] = (idx>>4 & 15) - 4; + + return dst + 2; +} + +static inline int *DEC_SQUAD(int *dst, unsigned idx) +{ + dst[0] = (idx & 3) - 1; + dst[1] = (idx>>2 & 3) - 1; + dst[2] = (idx>>4 & 3) - 1; + dst[3] = (idx>>6 & 3) - 1; + + return dst + 4; +} + +static inline int *DEC_UPAIR(int *dst, unsigned idx, unsigned sign) +{ + dst[0] = (idx & 15) * (1 - (((int)sign>>1)<<1)); + dst[1] = (idx>>4 & 15) * (1 - (((int)sign&1)<<1)); + + return dst + 2; +} + +static inline int *DEC_UQUAD(int *dst, unsigned idx, unsigned sign) +{ + unsigned nz = idx >> 12; + + dst[0] = (idx & 3) * (1 + (((int)sign>>31)<<1)); + sign <<= nz & 1; nz >>= 1; + dst[1] = (idx>>2 & 3) * (1 + (((int)sign>>31)<<1)); + sign <<= nz & 1; nz >>= 1; + dst[2] = (idx>>4 & 3) * (1 + (((int)sign>>31)<<1)); + sign <<= nz & 1; nz >>= 1; + dst[3] = (idx>>6 & 3) * (1 + (((int)sign>>31)<<1)); + + return dst + 4; +} + +static void vector_pow43(int *coefs, int len) +{ + int i, coef; + + for (i=0; i> 2); + + if (s > 0) { + round = 1 << (s-1); + for (i=0; i> 32); + dst[i] = ((int)(out+round) >> s) * ssign; + } + } + else { + s = s + 32; + round = 1 << (s-1); + for (i=0; i> s); + dst[i] = out * ssign; + } + } +} + +static void noise_scale(int *coefs, int scale, int band_energy, int len) +{ + int64_t accu; + int ssign = scale < 0 ? -1 : 1; + int s = FFABS(scale); + unsigned int round; + int i, out, c = exp2tab[s & 3]; + int nlz = 0; + + while (band_energy > 0x7fff) { + band_energy >>= 1; + nlz++; + } + c /= band_energy; + s = 21 + nlz - (s >> 2); + + if (s > 0) { + round = 1 << (s-1); + for (i=0; i> 32); + coefs[i] = ((int)(out+round) >> s) * ssign; + } + } + else { + s = s + 32; + round = 1 << (s-1); + for (i=0; i> s); + coefs[i] = out * ssign; + } + } +} + +static av_always_inline aac_float_t flt16_round(aac_float_t pf) +{ + aac_float_t tmp; + int s; + + tmp.expo = pf.expo; + s = pf.mant >> 31; + tmp.mant = (pf.mant ^ s) - s; + tmp.mant = (tmp.mant + 0x00200000U) & 0xFFC00000U; + tmp.mant = (tmp.mant ^ s) - s; + + return tmp; +} + +static av_always_inline aac_float_t flt16_even(aac_float_t pf) +{ + aac_float_t tmp; + int s; + + tmp.expo = pf.expo; + s = pf.mant >> 31; + tmp.mant = (pf.mant ^ s) - s; + tmp.mant = (tmp.mant + 0x001FFFFFU + (tmp.mant & 0x00400000U >> 16)) & 0xFFC00000U; + tmp.mant = (tmp.mant ^ s) - s; + + return tmp; +} + +static av_always_inline aac_float_t flt16_trunc(aac_float_t pf) +{ + aac_float_t pun; + int s; + + pun.expo = pf.expo; + s = pf.mant >> 31; + pun.mant = (pf.mant ^ s) - s; + pun.mant = pun.mant & 0xFFC00000U; + pun.mant = (pun.mant ^ s) - s; + + return pun; +} + +static av_always_inline void predict(PredictorState *ps, int *coef, + int output_enable) +{ + const aac_float_t a = { 1023410176, 0 }; // 61.0 / 64 + const aac_float_t alpha = { 973078528, 0 }; // 29.0 / 32 + aac_float_t e0, e1; + aac_float_t pv; + aac_float_t k1, k2; + aac_float_t r0 = ps->r0, r1 = ps->r1; + aac_float_t cor0 = ps->cor0, cor1 = ps->cor1; + aac_float_t var0 = ps->var0, var1 = ps->var1; + aac_float_t tmp; + + if (var0.expo > 1 || (var0.expo == 1 && var0.mant > 0x20000000)) { + tmp = float_recip(var0); + k1 = float_mul(cor0, flt16_even(float_mul(a, tmp))); + } + else { + k1.mant = 0; + k1.expo = 0; + } + + if (var1.expo > 1 || (var1.expo == 1 && var1.mant > 0x20000000)) { + tmp = float_recip(var1); + k2 = float_mul(cor1, flt16_even(float_mul(a, tmp))); + } + else { + k2.mant = 0; + k2.expo = 0; + } + + tmp = float_mul(k1, r0); + pv = flt16_round(float_add(tmp, float_mul(k2, r1))); + if (output_enable) { + int shift = 28 - pv.expo; + + if (shift < 31) + *coef += (pv.mant + (1<<(shift-1))) >> shift; + } + + e0 = int2float(*coef, 28); + e1 = float_sub(e0, tmp); + + ps->cor1 = flt16_trunc(float_add(float_mul(alpha, cor1), float_mul(r1, e1))); + tmp = float_add(float_mul(r1, r1), float_mul(e1, e1)); + tmp.expo--; + ps->var1 = flt16_trunc(float_add(float_mul(alpha, var1), tmp)); + ps->cor0 = flt16_trunc(float_add(float_mul(alpha, cor0), float_mul(r0, e0))); + tmp = float_add(float_mul(r0, r0), float_mul(e0, e0)); + tmp.expo--; + ps->var0 = flt16_trunc(float_add(float_mul(alpha, var0), tmp)); + + ps->r1 = flt16_trunc(float_mul(a, float_sub(r0, float_mul(k1, e0)))); + ps->r0 = flt16_trunc(float_mul(a, e0)); +} + + +static const int cce_scale_fixed[8] = { + Q30(1.0), //2^(0/8) + Q30(1.0905077327), //2^(1/8) + Q30(1.1892071150), //2^(2/8) + Q30(1.2968395547), //2^(3/8) + Q30(1.4142135624), //2^(4/8) + Q30(1.5422108254), //2^(5/8) + Q30(1.6817928305), //2^(6/8) + Q30(1.8340080864), //2^(7/8) +}; + +/** + * Apply dependent channel coupling (applied before IMDCT). + * + * @param index index into coupling gain array + */ +static void apply_dependent_coupling_fixed(AACContext *ac, + SingleChannelElement *target, + ChannelElement *cce, int index) +{ + IndividualChannelStream *ics = &cce->ch[0].ics; + const uint16_t *offsets = ics->swb_offset; + int *dest = target->coeffs; + const int *src = cce->ch[0].coeffs; + int g, i, group, k, idx = 0; + if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) { + av_log(ac->avctx, AV_LOG_ERROR, + "Dependent coupling is not supported together with LTP\n"); + return; + } + for (g = 0; g < ics->num_window_groups; g++) { + for (i = 0; i < ics->max_sfb; i++, idx++) { + if (cce->ch[0].band_type[idx] != ZERO_BT) { + const int gain = cce->coup.gain[index][idx]; + int shift, round, c, tmp; + int64_t accu; + + if (gain < 0) { + c = -cce_scale_fixed[-gain & 7]; + shift = (-gain-1024) >> 3; + } + else { + c = cce_scale_fixed[gain & 7]; + shift = (gain-1024) >> 3; + } + + if (shift < 0) { + shift = -shift; + round = 1 << (shift - 1); + + for (group = 0; group < ics->group_len[g]; group++) { + for (k = offsets[i]; k < offsets[i + 1]; k++) { + // XXX dsputil-ize + accu = (int64_t)src[group * 128 + k]*c; + tmp = (int)((accu + (int64_t)0x1000000000) >> 37); + dest[group * 128 + k] += (tmp + round) >> shift; + } + } + } + else { + for (group = 0; group < ics->group_len[g]; group++) { + for (k = offsets[i]; k < offsets[i + 1]; k++) { + // XXX dsputil-ize + accu = (int64_t)src[group * 128 + k]*c; + tmp = (int)((accu + (int64_t)0x1000000000) >> 37); + dest[group * 128 + k] += tmp << shift; + } + } + } + } + } + dest += ics->group_len[g] * 128; + src += ics->group_len[g] * 128; + } +} + +/** + * Apply independent channel coupling (applied after IMDCT). + * + * @param index index into coupling gain array + */ +static void apply_independent_coupling_fixed(AACContext *ac, + SingleChannelElement *target, + ChannelElement *cce, int index) +{ + int i, c, shift, round, tmp; + const int gain = cce->coup.gain[index][0]; + const int *src = cce->ch[0].ret; + int *dest = target->ret; + const int len = 1024 << (ac->oc[1].m4ac.sbr == 1); + int64_t accu; + + c = cce_scale_fixed[gain & 7]; + shift = (gain-1024) >> 3; + if (shift < 0) { + shift = -shift; + round = 1 << (shift - 1); + + for (i = 0; i < len; i++) { + accu = (int64_t)src[i]*c; + tmp = (int)((accu + (int64_t)0x1000000000) >> 37); + dest[i] += (tmp + round) >> shift; + } + } + else { + for (i = 0; i < len; i++) { + accu = (int64_t)src[i]*c; + tmp = (int)((accu + (int64_t)0x1000000000) >> 37); + dest[i] += tmp << shift; + } + } +} + +#include "aacdec_template.c" + +AVCodec ff_aac_fixed_decoder = { + .name = "aac_fixed", + .type = AVMEDIA_TYPE_AUDIO, + .id = AV_CODEC_ID_AAC, + .priv_data_size = sizeof(AACContext), + .init = aac_decode_init, + .close = aac_decode_close, + .decode = aac_decode_frame, + .long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"), + .sample_fmts = (const enum AVSampleFormat[]) { + AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_NONE + }, + .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1, + .channel_layouts = aac_channel_layout, + .flush = flush, +}; diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index a3613fb..da0f0a0 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -132,7 +132,7 @@ static av_cold int che_configure(AACContext *ac, if (!ac->che[type][id]) { if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement)))) return AVERROR(ENOMEM); - ff_aac_sbr_ctx_init(ac, &ac->che[type][id]->sbr); + AAC_RENAME(ff_aac_sbr_ctx_init)(ac, &ac->che[type][id]->sbr); } if (type != TYPE_CCE) { if (*channels >= MAX_CHANNELS - (type == TYPE_CPE || (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1))) { @@ -147,7 +147,7 @@ static av_cold int che_configure(AACContext *ac, } } else { if (ac->che[type][id]) - ff_aac_sbr_ctx_close(&ac->che[type][id]->sbr); + AAC_RENAME(ff_aac_sbr_ctx_close)(&ac->che[type][id]->sbr); av_freep(&ac->che[type][id]); } return 0; @@ -181,7 +181,7 @@ static int frame_configure_elements(AVCodecContext *avctx) /* map output channel pointers to AVFrame data */ for (ch = 0; ch < avctx->channels; ch++) { if (ac->output_element[ch]) - ac->output_element[ch]->ret = (float *)ac->frame->extended_data[ch]; + ac->output_element[ch]->ret = (INTFLOAT *)ac->frame->extended_data[ch]; } return 0; @@ -1020,8 +1020,11 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) ac->oc[1].m4ac.sample_rate = avctx->sample_rate; aacdec_init(ac); - +#if USE_FIXED + avctx->sample_fmt = AV_SAMPLE_FMT_S32P; +#else avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; +#endif /* USE_FIXED */ if (avctx->extradata_size > 0) { if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, @@ -1076,10 +1079,15 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) AAC_INIT_VLC_STATIC( 9, 366); AAC_INIT_VLC_STATIC(10, 462); - ff_aac_sbr_init(); + AAC_RENAME(ff_aac_sbr_init)(); ff_fmt_convert_init(&ac->fmt_conv, avctx); + +#if USE_FIXED + ac->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & CODEC_FLAG_BITEXACT); +#else avpriv_float_dsp_init(&ac->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); +#endif /* USE_FIXED */ ac->random_state = 0x1f2e3d4c; @@ -1095,18 +1103,18 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) sizeof(ff_aac_scalefactor_code[0]), 352); - ff_mdct_init(&ac->mdct, 11, 1, 1.0 / (32768.0 * 1024.0)); - ff_mdct_init(&ac->mdct_ld, 10, 1, 1.0 / (32768.0 * 512.0)); - ff_mdct_init(&ac->mdct_small, 8, 1, 1.0 / (32768.0 * 128.0)); - ff_mdct_init(&ac->mdct_ltp, 11, 0, -2.0 * 32768.0); + AAC_RENAME_32(ff_mdct_init)(&ac->mdct, 11, 1, 1.0 / RANGE15(1024.0)); + AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ld, 10, 1, 1.0 / RANGE15(512.0)); + AAC_RENAME_32(ff_mdct_init)(&ac->mdct_small, 8, 1, 1.0 / RANGE15(128.0)); + AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ltp, 11, 0, RANGE15(-2.0)); // window initialization - ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); - ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128); - ff_init_ff_sine_windows(10); - ff_init_ff_sine_windows( 9); - ff_init_ff_sine_windows( 7); + AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_long_1024), 4.0, 1024); + AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_short_128), 6.0, 128); + AAC_RENAME(ff_init_ff_sine_windows)(10); + AAC_RENAME(ff_init_ff_sine_windows)( 9); + AAC_RENAME(ff_init_ff_sine_windows)( 7); - cbrt_tableinit(); + AAC_RENAME(cbrt_tableinit)(); return 0; } @@ -1318,7 +1326,7 @@ static int decode_band_types(AACContext *ac, enum BandType band_type[120], * * @return Returns error status. 0 - OK, !0 - error */ -static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, +static int decode_scalefactors(AACContext *ac, INTFLOAT sf[120], GetBitContext *gb, unsigned int global_gain, IndividualChannelStream *ics, enum BandType band_type[120], @@ -1333,7 +1341,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, int run_end = band_type_run_end[idx]; if (band_type[idx] == ZERO_BT) { for (; i < run_end; i++, idx++) - sf[idx] = 0.0; + sf[idx] = FIXR(0.); } else if ((band_type[idx] == INTENSITY_BT) || (band_type[idx] == INTENSITY_BT2)) { for (; i < run_end; i++, idx++) { @@ -1345,7 +1353,11 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, "Clipped intensity stereo position (%d -> %d)", offset[2], clipped_offset); } +#if USE_FIXED + sf[idx] = 100 - clipped_offset; +#else sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + POW_SF2_ZERO]; +#endif /* USE_FIXED */ } } else if (band_type[idx] == NOISE_BT) { for (; i < run_end; i++, idx++) { @@ -1360,7 +1372,11 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, "Clipped noise gain (%d -> %d)", offset[1], clipped_offset); } +#if USE_FIXED + sf[idx] = -(100 + clipped_offset); +#else sf[idx] = -ff_aac_pow2sf_tab[clipped_offset + POW_SF2_ZERO]; +#endif /* USE_FIXED */ } } else { for (; i < run_end; i++, idx++) { @@ -1370,7 +1386,11 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, "Scalefactor (%d) out of range.\n", offset[0]); return AVERROR_INVALIDDATA; } +#if USE_FIXED + sf[idx] = -offset[0]; +#else sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO]; +#endif /* USE_FIXED */ } } } @@ -1477,8 +1497,8 @@ static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb, * * @return Returns error status. 0 - OK, !0 - error */ -static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], - GetBitContext *gb, const float sf[120], +static int decode_spectrum_and_dequant(AACContext *ac, INTFLOAT coef[1024], + GetBitContext *gb, const INTFLOAT sf[120], int pulse_present, const Pulse *pulse, const IndividualChannelStream *ics, enum BandType band_type[120]) @@ -1486,49 +1506,64 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], int i, k, g, idx = 0; const int c = 1024 / ics->num_windows; const uint16_t *offsets = ics->swb_offset; - float *coef_base = coef; + INTFLOAT *coef_base = coef; for (g = 0; g < ics->num_windows; g++) memset(coef + g * 128 + offsets[ics->max_sfb], 0, - sizeof(float) * (c - offsets[ics->max_sfb])); + sizeof(INTFLOAT) * (c - offsets[ics->max_sfb])); for (g = 0; g < ics->num_window_groups; g++) { unsigned g_len = ics->group_len[g]; for (i = 0; i < ics->max_sfb; i++, idx++) { const unsigned cbt_m1 = band_type[idx] - 1; - float *cfo = coef + offsets[i]; + INTFLOAT *cfo = coef + offsets[i]; int off_len = offsets[i + 1] - offsets[i]; int group; if (cbt_m1 >= INTENSITY_BT2 - 1) { - for (group = 0; group < g_len; group++, cfo+=128) { - memset(cfo, 0, off_len * sizeof(float)); + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { + memset(cfo, 0, off_len * sizeof(INTFLOAT)); } } else if (cbt_m1 == NOISE_BT - 1) { - for (group = 0; group < g_len; group++, cfo+=128) { + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { +#if !USE_FIXED float scale; - float band_energy; +#endif /* !USE_FIXED */ + INTFLOAT band_energy; for (k = 0; k < off_len; k++) { ac->random_state = lcg_random(ac->random_state); +#if USE_FIXED + cfo[k] = ac->random_state >> 3; + +#else cfo[k] = ac->random_state; +#endif /* USE_FIXED */ } +#if USE_FIXED + band_energy = ac->fdsp->scalarproduct_fixed(cfo, cfo, off_len); + band_energy = fixed_sqrt(band_energy, 31); + noise_scale(cfo, sf[idx], band_energy, off_len); +#else band_energy = ac->fdsp.scalarproduct_float(cfo, cfo, off_len); scale = sf[idx] / sqrtf(band_energy); ac->fdsp.vector_fmul_scalar(cfo, cfo, scale, off_len); +#endif /* USE_FIXED */ } } else { +#if !USE_FIXED const float *vq = ff_aac_codebook_vector_vals[cbt_m1]; +#endif /* !USE_FIXED */ const uint16_t *cb_vector_idx = ff_aac_codebook_vector_idx[cbt_m1]; VLC_TYPE (*vlc_tab)[2] = vlc_spectral[cbt_m1].table; OPEN_READER(re, gb); switch (cbt_m1 >> 1) { case 0: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { + INTFLOAT *cf = cfo; int len = off_len; do { @@ -1538,14 +1573,18 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], UPDATE_CACHE(re, gb); GET_VLC(code, re, gb, vlc_tab, 8, 2); cb_idx = cb_vector_idx[code]; +#if USE_FIXED + cf = DEC_SQUAD(cf, cb_idx); +#else cf = VMUL4(cf, vq, cb_idx, sf + idx); +#endif /* USE_FIXED */ } while (len -= 4); } break; case 1: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { + INTFLOAT *cf = cfo; int len = off_len; do { @@ -1560,14 +1599,18 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], nnz = cb_idx >> 8 & 15; bits = nnz ? GET_CACHE(re, gb) : 0; LAST_SKIP_BITS(re, gb, nnz); +#if USE_FIXED + cf = DEC_UQUAD(cf, cb_idx, bits); +#else cf = VMUL4S(cf, vq, cb_idx, bits, sf + idx); +#endif /* USE_FIXED */ } while (len -= 4); } break; case 2: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { + INTFLOAT *cf = cfo; int len = off_len; do { @@ -1577,15 +1620,19 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], UPDATE_CACHE(re, gb); GET_VLC(code, re, gb, vlc_tab, 8, 2); cb_idx = cb_vector_idx[code]; +#if USE_FIXED + cf = DEC_SPAIR(cf, cb_idx); +#else cf = VMUL2(cf, vq, cb_idx, sf + idx); +#endif /* USE_FIXED */ } while (len -= 2); } break; case 3: case 4: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { + INTFLOAT *cf = cfo; int len = off_len; do { @@ -1600,15 +1647,24 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], nnz = cb_idx >> 8 & 15; sign = nnz ? SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12) : 0; LAST_SKIP_BITS(re, gb, nnz); +#if USE_FIXED + cf = DEC_UPAIR(cf, cb_idx, sign); +#else cf = VMUL2S(cf, vq, cb_idx, sign, sf + idx); +#endif /* USE_FIXED */ } while (len -= 2); } break; default: - for (group = 0; group < g_len; group++, cfo+=128) { + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { +#if USE_FIXED + int *icf = cfo; + int v; +#else float *cf = cfo; uint32_t *icf = (uint32_t *) cf; +#endif /* USE_FIXED */ int len = off_len; do { @@ -1652,18 +1708,33 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], b += 4; n = (1 << b) + SHOW_UBITS(re, gb, b); LAST_SKIP_BITS(re, gb, b); +#if USE_FIXED + v = n; + if (bits & 1U<<31) + v = -v; + *icf++ = v; +#else *icf++ = cbrt_tab[n] | (bits & 1U<<31); +#endif /* USE_FIXED */ bits <<= 1; } else { +#if USE_FIXED + v = cb_idx & 15; + if (bits & 1U<<31) + v = -v; + *icf++ = v; +#else unsigned v = ((const uint32_t*)vq)[cb_idx & 15]; *icf++ = (bits & 1U<<31) | v; +#endif /* USE_FIXED */ bits <<= !!v; } cb_idx >>= 4; } } while (len -= 2); - +#if !USE_FIXED ac->fdsp.vector_fmul_scalar(cfo, cfo, sf[idx], off_len); +#endif /* !USE_FIXED */ } } @@ -1676,19 +1747,48 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], if (pulse_present) { idx = 0; for (i = 0; i < pulse->num_pulse; i++) { - float co = coef_base[ pulse->pos[i] ]; + INTFLOAT co = coef_base[ pulse->pos[i] ]; while (offsets[idx + 1] <= pulse->pos[i]) idx++; if (band_type[idx] != NOISE_BT && sf[idx]) { - float ico = -pulse->amp[i]; + INTFLOAT ico = -pulse->amp[i]; +#if USE_FIXED + if (co) { + ico = co + (co > 0 ? -ico : ico); + } + coef_base[ pulse->pos[i] ] = ico; +#else if (co) { co /= sf[idx]; ico = co / sqrtf(sqrtf(fabsf(co))) + (co > 0 ? -ico : ico); } coef_base[ pulse->pos[i] ] = cbrtf(fabsf(ico)) * ico * sf[idx]; +#endif /* USE_FIXED */ + } + } + } +#if USE_FIXED + coef = coef_base; + idx = 0; + for (g = 0; g < ics->num_window_groups; g++) { + unsigned g_len = ics->group_len[g]; + + for (i = 0; i < ics->max_sfb; i++, idx++) { + const unsigned cbt_m1 = band_type[idx] - 1; + int *cfo = coef + offsets[i]; + int off_len = offsets[i + 1] - offsets[i]; + int group; + + if (cbt_m1 < NOISE_BT - 1) { + for (group = 0; group < (int)g_len; group++, cfo+=128) { + ac->vector_pow43(cfo, off_len); + ac->subband_scale(cfo, cfo, sf[idx], 34, off_len); + } } } + coef += g_len << 7; } +#endif /* USE_FIXED */ return 0; } @@ -1737,7 +1837,7 @@ static int decode_ics(AACContext *ac, SingleChannelElement *sce, Pulse pulse; TemporalNoiseShaping *tns = &sce->tns; IndividualChannelStream *ics = &sce->ics; - float *out = sce->coeffs; + INTFLOAT *out = sce->coeffs; int global_gain, eld_syntax, er_syntax, pulse_present = 0; int ret; @@ -1811,8 +1911,8 @@ static int decode_ics(AACContext *ac, SingleChannelElement *sce, static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe) { const IndividualChannelStream *ics = &cpe->ch[0].ics; - float *ch0 = cpe->ch[0].coeffs; - float *ch1 = cpe->ch[1].coeffs; + INTFLOAT *ch0 = cpe->ch[0].coeffs; + INTFLOAT *ch1 = cpe->ch[1].coeffs; int g, i, group, idx = 0; const uint16_t *offsets = ics->swb_offset; for (g = 0; g < ics->num_window_groups; g++) { @@ -1820,10 +1920,17 @@ static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe) if (cpe->ms_mask[idx] && cpe->ch[0].band_type[idx] < NOISE_BT && cpe->ch[1].band_type[idx] < NOISE_BT) { +#if USE_FIXED + for (group = 0; group < ics->group_len[g]; group++) { + ac->fdsp->butterflies_fixed(ch0 + group * 128 + offsets[i], + ch1 + group * 128 + offsets[i], + offsets[i+1] - offsets[i]); +#else for (group = 0; group < ics->group_len[g]; group++) { ac->fdsp.butterflies_float(ch0 + group * 128 + offsets[i], ch1 + group * 128 + offsets[i], offsets[i+1] - offsets[i]); +#endif /* USE_FIXED */ } } } @@ -1844,11 +1951,11 @@ static void apply_intensity_stereo(AACContext *ac, { const IndividualChannelStream *ics = &cpe->ch[1].ics; SingleChannelElement *sce1 = &cpe->ch[1]; - float *coef0 = cpe->ch[0].coeffs, *coef1 = cpe->ch[1].coeffs; + INTFLOAT *coef0 = cpe->ch[0].coeffs, *coef1 = cpe->ch[1].coeffs; const uint16_t *offsets = ics->swb_offset; int g, group, i, idx = 0; int c; - float scale; + INTFLOAT scale; for (g = 0; g < ics->num_window_groups; g++) { for (i = 0; i < ics->max_sfb;) { if (sce1->band_type[idx] == INTENSITY_BT || @@ -1860,10 +1967,18 @@ static void apply_intensity_stereo(AACContext *ac, c *= 1 - 2 * cpe->ms_mask[idx]; scale = c * sce1->sf[idx]; for (group = 0; group < ics->group_len[g]; group++) +#if USE_FIXED + ac->subband_scale(coef1 + group * 128 + offsets[i], + coef0 + group * 128 + offsets[i], + scale, + 23, + offsets[i + 1] - offsets[i]); +#else ac->fdsp.vector_fmul_scalar(coef1 + group * 128 + offsets[i], coef0 + group * 128 + offsets[i], scale, offsets[i + 1] - offsets[i]); +#endif /* USE_FIXED */ } } else { int bt_run_end = sce1->band_type_run_end[idx]; @@ -1939,7 +2054,7 @@ static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) int num_gain = 0; int c, g, sfb, ret; int sign; - float scale; + INTFLOAT scale; SingleChannelElement *sce = &che->ch[0]; ChannelCoupling *coup = &che->coup; @@ -1959,7 +2074,7 @@ static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1); sign = get_bits(gb, 1); - scale = cce_scale[get_bits(gb, 2)]; + scale = AAC_RENAME(cce_scale)[get_bits(gb, 2)]; if ((ret = decode_ics(ac, sce, gb, 0, 0))) return ret; @@ -1968,11 +2083,11 @@ static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) int idx = 0; int cge = 1; int gain = 0; - float gain_cache = 1.0; + INTFLOAT gain_cache = FIXR10(1.); if (c) { cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb); gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0; - gain_cache = powf(scale, -gain); + gain_cache = GET_GAIN(scale, gain); } if (coup->coupling_point == AFTER_IMDCT) { coup->gain[c][0] = gain_cache; @@ -1989,7 +2104,7 @@ static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) s -= 2 * (t & 0x1); t >>= 1; } - gain_cache = powf(scale, -t) * s; + gain_cache = GET_GAIN(scale, t) * s; } } coup->gain[c][idx] = gain_cache; @@ -2135,7 +2250,7 @@ static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, ac->oc[1].m4ac.sbr = 1; ac->avctx->profile = FF_PROFILE_AAC_HE; } - res = ff_decode_sbr_extension(ac, &che->sbr, gb, crc_flag, cnt, elem_type); + res = AAC_RENAME(ff_decode_sbr_extension)(ac, &che->sbr, gb, crc_flag, cnt, elem_type); break; case EXT_DYNAMIC_RANGE: res = decode_dynamic_range(&ac->che_drc, gb); @@ -2158,14 +2273,14 @@ static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, * @param decode 1 if tool is used normally, 0 if tool is used in LTP. * @param coef spectral coefficients */ -static void apply_tns(float coef[1024], TemporalNoiseShaping *tns, +static void apply_tns(INTFLOAT coef[1024], TemporalNoiseShaping *tns, IndividualChannelStream *ics, int decode) { const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb); int w, filt, m, i; int bottom, top, order, start, end, size, inc; - float lpc[TNS_MAX_ORDER]; - float tmp[TNS_MAX_ORDER+1]; + INTFLOAT lpc[TNS_MAX_ORDER]; + INTFLOAT tmp[TNS_MAX_ORDER+1]; for (w = 0; w < ics->num_windows; w++) { bottom = ics->num_swb; @@ -2177,7 +2292,7 @@ static void apply_tns(float coef[1024], TemporalNoiseShaping *tns, continue; // tns_decode_coef - compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0); + AAC_RENAME(compute_lpc_coefs)(tns->coef[w][filt], order, lpc, 0, 0, 0); start = ics->swb_offset[FFMIN(bottom, mmm)]; end = ics->swb_offset[FFMIN( top, mmm)]; @@ -2195,13 +2310,13 @@ static void apply_tns(float coef[1024], TemporalNoiseShaping *tns, // ar filter for (m = 0; m < size; m++, start += inc) for (i = 1; i <= FFMIN(m, order); i++) - coef[start] -= coef[start - i * inc] * lpc[i - 1]; + coef[start] -= AAC_MUL26(coef[start - i * inc], lpc[i - 1]); } else { // ma filter for (m = 0; m < size; m++, start += inc) { tmp[0] = coef[start]; for (i = 1; i <= FFMIN(m, order); i++) - coef[start] += tmp[i] * lpc[i - 1]; + coef[start] += AAC_MUL26(tmp[i], lpc[i - 1]); for (i = order; i > 0; i--) tmp[i] = tmp[i - 1]; } @@ -2214,26 +2329,41 @@ static void apply_tns(float coef[1024], TemporalNoiseShaping *tns, * Apply windowing and MDCT to obtain the spectral * coefficient from the predicted sample by LTP. */ -static void windowing_and_mdct_ltp(AACContext *ac, float *out, - float *in, IndividualChannelStream *ics) +static void windowing_and_mdct_ltp(AACContext *ac, INTFLOAT *out, + INTFLOAT *in, IndividualChannelStream *ics) { - const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; - const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; - const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; - const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; - + const INTFLOAT *lwindow = ics->use_kb_window[0] ? AAC_RENAME(ff_aac_kbd_long_1024) : AAC_RENAME(ff_sine_1024); + const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME(ff_aac_kbd_short_128) : AAC_RENAME(ff_sine_128); + const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME(ff_aac_kbd_long_1024) : AAC_RENAME(ff_sine_1024); + const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME(ff_aac_kbd_short_128) : AAC_RENAME(ff_sine_128); + +#if USE_FIXED + if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) { + ac->fdsp->vector_fmul(in, in, lwindow_prev, 1024); + } else { + memset(in, 0, 448 * sizeof(INTFLOAT)); + ac->fdsp->vector_fmul(in + 448, in + 448, swindow_prev, 128); + } + if (ics->window_sequence[0] != LONG_START_SEQUENCE) { + ac->fdsp->vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024); + } else { + ac->fdsp->vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); + memset(in + 1024 + 576, 0, 448 * sizeof(INTFLOAT)); + } +#else if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) { ac->fdsp.vector_fmul(in, in, lwindow_prev, 1024); } else { - memset(in, 0, 448 * sizeof(float)); + memset(in, 0, 448 * sizeof(INTFLOAT)); ac->fdsp.vector_fmul(in + 448, in + 448, swindow_prev, 128); } if (ics->window_sequence[0] != LONG_START_SEQUENCE) { ac->fdsp.vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024); } else { ac->fdsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); - memset(in + 1024 + 576, 0, 448 * sizeof(float)); + memset(in + 1024 + 576, 0, 448 * sizeof(INTFLOAT)); } +#endif /* USE_FIXED */ ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in); } @@ -2247,15 +2377,15 @@ static void apply_ltp(AACContext *ac, SingleChannelElement *sce) int i, sfb; if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { - float *predTime = sce->ret; - float *predFreq = ac->buf_mdct; + INTFLOAT *predTime = sce->ret; + INTFLOAT *predFreq = ac->buf_mdct; int16_t num_samples = 2048; if (ltp->lag < 1024) num_samples = ltp->lag + 1024; for (i = 0; i < num_samples; i++) - predTime[i] = sce->ltp_state[i + 2048 - ltp->lag] * ltp->coef; - memset(&predTime[i], 0, (2048 - i) * sizeof(float)); + predTime[i] = AAC_MUL30(sce->ltp_state[i + 2048 - ltp->lag], ltp->coef); + memset(&predTime[i], 0, (2048 - i) * sizeof(INTFLOAT)); ac->windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics); @@ -2275,28 +2405,40 @@ static void apply_ltp(AACContext *ac, SingleChannelElement *sce) static void update_ltp(AACContext *ac, SingleChannelElement *sce) { IndividualChannelStream *ics = &sce->ics; - float *saved = sce->saved; - float *saved_ltp = sce->coeffs; - const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; - const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; + INTFLOAT *saved = sce->saved; + INTFLOAT *saved_ltp = sce->coeffs; + const INTFLOAT *lwindow = ics->use_kb_window[0] ? AAC_RENAME(ff_aac_kbd_long_1024) : AAC_RENAME(ff_sine_1024); + const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME(ff_aac_kbd_short_128) : AAC_RENAME(ff_sine_128); int i; if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - memcpy(saved_ltp, saved, 512 * sizeof(float)); - memset(saved_ltp + 576, 0, 448 * sizeof(float)); + memcpy(saved_ltp, saved, 512 * sizeof(INTFLOAT)); + memset(saved_ltp + 576, 0, 448 * sizeof(INTFLOAT)); +#if USE_FIXED + ac->fdsp->vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); +#else ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); +#endif /* USE_FIXED */ for (i = 0; i < 64; i++) - saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i]; + saved_ltp[i + 512] = AAC_MUL31(ac->buf_mdct[1023 - i], swindow[63 - i]); } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { - memcpy(saved_ltp, ac->buf_mdct + 512, 448 * sizeof(float)); - memset(saved_ltp + 576, 0, 448 * sizeof(float)); + memcpy(saved_ltp, ac->buf_mdct + 512, 448 * sizeof(INTFLOAT)); + memset(saved_ltp + 576, 0, 448 * sizeof(INTFLOAT)); +#if USE_FIXED + ac->fdsp->vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); +#else ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); +#endif /* USE_FIXED */ for (i = 0; i < 64; i++) - saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i]; + saved_ltp[i + 512] = AAC_MUL31(ac->buf_mdct[1023 - i], swindow[63 - i]); } else { // LONG_STOP or ONLY_LONG +#if USE_FIXED + ac->fdsp->vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, &lwindow[512], 512); +#else ac->fdsp.vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, &lwindow[512], 512); +#endif /* USE_FIXED */ for (i = 0; i < 512; i++) - saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * lwindow[511 - i]; + saved_ltp[i + 512] = AAC_MUL31(ac->buf_mdct[1023 - i], lwindow[511 - i]); } memcpy(sce->ltp_state, sce->ltp_state+1024, 1024 * sizeof(*sce->ltp_state)); @@ -2310,22 +2452,27 @@ static void update_ltp(AACContext *ac, SingleChannelElement *sce) static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce) { IndividualChannelStream *ics = &sce->ics; - float *in = sce->coeffs; - float *out = sce->ret; - float *saved = sce->saved; - const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; - const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; - const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; - float *buf = ac->buf_mdct; - float *temp = ac->temp; + INTFLOAT *in = sce->coeffs; + INTFLOAT *out = sce->ret; + INTFLOAT *saved = sce->saved; + const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME(ff_aac_kbd_short_128) : AAC_RENAME(ff_sine_128); + const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME(ff_aac_kbd_long_1024) : AAC_RENAME(ff_sine_1024); + const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME(ff_aac_kbd_short_128) : AAC_RENAME(ff_sine_128); + INTFLOAT *buf = ac->buf_mdct; + INTFLOAT *temp = ac->temp; int i; // imdct if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { for (i = 0; i < 1024; i += 128) ac->mdct_small.imdct_half(&ac->mdct_small, buf + i, in + i); - } else + } else { ac->mdct.imdct_half(&ac->mdct, buf, in); +#if USE_FIXED + for (i=0; i<1024; i++) + buf[i] = (buf[i] + 4) >> 3; +#endif /* USE_FIXED */ + } /* window overlapping * NOTE: To simplify the overlapping code, all 'meaningless' short to long @@ -2335,70 +2482,106 @@ static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce) */ if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) && (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) { +#if USE_FIXED + ac->fdsp->vector_fmul_window( out, saved, buf, lwindow_prev, 512); +#else ac->fdsp.vector_fmul_window( out, saved, buf, lwindow_prev, 512); +#endif /* USE_FIXED */ } else { - memcpy( out, saved, 448 * sizeof(float)); + memcpy( out, saved, 448 * sizeof(INTFLOAT)); if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { +#if USE_FIXED + ac->fdsp->vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, 64); + ac->fdsp->vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, 64); + ac->fdsp->vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, 64); + ac->fdsp->vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, 64); + ac->fdsp->vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, 64); +#else ac->fdsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, 64); ac->fdsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, 64); ac->fdsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, 64); ac->fdsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, 64); ac->fdsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, 64); - memcpy( out + 448 + 4*128, temp, 64 * sizeof(float)); +#endif /* USE_FIXED */ + memcpy( out + 448 + 4*128, temp, 64 * sizeof(INTFLOAT)); } else { +#if USE_FIXED + ac->fdsp->vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 64); +#else ac->fdsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 64); - memcpy( out + 576, buf + 64, 448 * sizeof(float)); +#endif /* USE_FIXED */ + memcpy( out + 576, buf + 64, 448 * sizeof(INTFLOAT)); } } // buffer update if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - memcpy( saved, temp + 64, 64 * sizeof(float)); + memcpy( saved, temp + 64, 64 * sizeof(INTFLOAT)); +#if USE_FIXED + ac->fdsp->vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 64); + ac->fdsp->vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 64); + ac->fdsp->vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 64); +#else ac->fdsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 64); ac->fdsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 64); ac->fdsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 64); - memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float)); +#endif + memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(INTFLOAT)); } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { - memcpy( saved, buf + 512, 448 * sizeof(float)); - memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float)); + memcpy( saved, buf + 512, 448 * sizeof(INTFLOAT)); + memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(INTFLOAT)); } else { // LONG_STOP or ONLY_LONG - memcpy( saved, buf + 512, 512 * sizeof(float)); + memcpy( saved, buf + 512, 512 * sizeof(INTFLOAT)); } } static void imdct_and_windowing_ld(AACContext *ac, SingleChannelElement *sce) { IndividualChannelStream *ics = &sce->ics; - float *in = sce->coeffs; - float *out = sce->ret; - float *saved = sce->saved; - float *buf = ac->buf_mdct; + INTFLOAT *in = sce->coeffs; + INTFLOAT *out = sce->ret; + INTFLOAT *saved = sce->saved; + INTFLOAT *buf = ac->buf_mdct; // imdct ac->mdct.imdct_half(&ac->mdct_ld, buf, in); +#if USE_FIXED + int i; + for (i = 0; i < 1024; i++) + buf[i] = (buf[i] + 2) >> 2; +#endif /* USE_FIXED */ + // window overlapping if (ics->use_kb_window[1]) { // AAC LD uses a low overlap sine window instead of a KBD window - memcpy(out, saved, 192 * sizeof(float)); + memcpy(out, saved, 192 * sizeof(INTFLOAT)); +#if USE_FIXED + ac->fdsp->vector_fmul_window(out + 192, saved + 192, buf, ff_sine_128_fixed, 64); +#else ac->fdsp.vector_fmul_window(out + 192, saved + 192, buf, ff_sine_128, 64); - memcpy( out + 320, buf + 64, 192 * sizeof(float)); +#endif /* USE_FIXED */ + memcpy( out + 320, buf + 64, 192 * sizeof(INTFLOAT)); } else { +#if USE_FIXED + ac->fdsp->vector_fmul_window(out, saved, buf, ff_sine_512_fixed, 256); +#else ac->fdsp.vector_fmul_window(out, saved, buf, ff_sine_512, 256); +#endif /* USE_FIXED */ } // buffer update - memcpy(saved, buf + 256, 256 * sizeof(float)); + memcpy(saved, buf + 256, 256 * sizeof(INTFLOAT)); } static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce) { - float *in = sce->coeffs; - float *out = sce->ret; - float *saved = sce->saved; - const float *const window = ff_aac_eld_window; - float *buf = ac->buf_mdct; + INTFLOAT *in = sce->coeffs; + INTFLOAT *out = sce->ret; + INTFLOAT *saved = sce->saved; + const INTFLOAT *const window = AAC_RENAME(ff_aac_eld_window); + INTFLOAT *buf = ac->buf_mdct; int i; const int n = 512; const int n2 = n >> 1; @@ -2410,11 +2593,17 @@ static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce) // International Conference on Audio, Language and Image Processing, ICALIP 2008. // URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4590245&isnumber=4589950 for (i = 0; i < n2; i+=2) { - float temp; + INTFLOAT temp; temp = in[i ]; in[i ] = -in[n - 1 - i]; in[n - 1 - i] = temp; temp = -in[i + 1]; in[i + 1] = in[n - 2 - i]; in[n - 2 - i] = temp; } ac->mdct.imdct_half(&ac->mdct_ld, buf, in); + +#if USE_FIXED + for (i = 0; i < 1024; i++) + buf[i] = (buf[i] + 1) >> 1; +#endif /* USE_FIXED */ + for (i = 0; i < n; i+=2) { buf[i] = -buf[i]; } @@ -2426,26 +2615,26 @@ static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce) // The spec says to use samples [0..511] but the reference decoder uses // samples [128..639]. for (i = n4; i < n2; i ++) { - out[i - n4] = buf[n2 - 1 - i] * window[i - n4] + - saved[ i + n2] * window[i + n - n4] + - -saved[ n + n2 - 1 - i] * window[i + 2*n - n4] + - -saved[2*n + n2 + i] * window[i + 3*n - n4]; + out[i - n4] = AAC_MUL31( buf[ n2 - 1 - i] , window[i - n4]) + + AAC_MUL31( saved[ i + n2] , window[i + n - n4]) + + AAC_MUL31(-saved[ n + n2 - 1 - i] , window[i + 2*n - n4]) + + AAC_MUL31(-saved[ 2*n + n2 + i] , window[i + 3*n - n4]); } for (i = 0; i < n2; i ++) { - out[n4 + i] = buf[i] * window[i + n2 - n4] + - -saved[ n - 1 - i] * window[i + n2 + n - n4] + - -saved[ n + i] * window[i + n2 + 2*n - n4] + - saved[2*n + n - 1 - i] * window[i + n2 + 3*n - n4]; + out[n4 + i] = AAC_MUL31( buf[ i] , window[i + n2 - n4]) + + AAC_MUL31(-saved[ n - 1 - i] , window[i + n2 + n - n4]) + + AAC_MUL31(-saved[ n + i] , window[i + n2 + 2*n - n4]) + + AAC_MUL31( saved[2*n + n - 1 - i] , window[i + n2 + 3*n - n4]); } for (i = 0; i < n4; i ++) { - out[n2 + n4 + i] = buf[ i + n2] * window[i + n - n4] + - -saved[ n2 - 1 - i] * window[i + 2*n - n4] + - -saved[ n + n2 + i] * window[i + 3*n - n4]; + out[n2 + n4 + i] = AAC_MUL31( buf[ i + n2] , window[i + n - n4]) + + AAC_MUL31(-saved[n2 - 1 - i] , window[i + 2*n - n4]) + + AAC_MUL31(-saved[n + n2 + i] , window[i + 3*n - n4]); } // buffer update - memmove(saved + n, saved, 2 * n * sizeof(float)); - memcpy( saved, buf, n * sizeof(float)); + memmove(saved + n, saved, 2 * n * sizeof(INTFLOAT)); + memcpy( saved, buf, n * sizeof(INTFLOAT)); } /** @@ -2505,7 +2694,7 @@ static void spectral_to_sample(AACContext *ac) ChannelElement *che = ac->che[type][i]; if (che) { if (type <= TYPE_CPE) - apply_channel_coupling(ac, che, type, i, BEFORE_TNS, apply_dependent_coupling); + apply_channel_coupling(ac, che, type, i, BEFORE_TNS, AAC_RENAME(apply_dependent_coupling)); if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) { if (che->ch[0].ics.predictor_present) { if (che->ch[0].ics.ltp.present) @@ -2519,7 +2708,7 @@ static void spectral_to_sample(AACContext *ac) if (che->ch[1].tns.present) ac->apply_tns(che->ch[1].coeffs, &che->ch[1].tns, &che->ch[1].ics, 1); if (type <= TYPE_CPE) - apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling); + apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, AAC_RENAME(apply_dependent_coupling)); if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) { imdct_and_window(ac, &che->ch[0]); if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) @@ -2530,11 +2719,22 @@ static void spectral_to_sample(AACContext *ac) ac->update_ltp(ac, &che->ch[1]); } if (ac->oc[1].m4ac.sbr > 0) { - ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret); + AAC_RENAME(ff_sbr_apply)(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret); } } if (type <= TYPE_CCE) - apply_channel_coupling(ac, che, type, i, AFTER_IMDCT, apply_independent_coupling); + apply_channel_coupling(ac, che, type, i, AFTER_IMDCT, AAC_RENAME(apply_independent_coupling)); + +#if USE_FIXED + { + int j; + /* preparation for resampler */ + for(j = 0; j<2048; j++){ + che->ch[0].ret[j] = (int32_t)av_clipl_int32((int64_t)che->ch[0].ret[j]<<7)+0x8000; + che->ch[1].ret[j] = (int32_t)av_clipl_int32((int64_t)che->ch[1].ret[j]<<7)+0x8000; + } + } +#endif /* USE_FIXED */ } } } @@ -2909,7 +3109,7 @@ static av_cold int aac_decode_close(AVCodecContext *avctx) for (i = 0; i < MAX_ELEM_ID; i++) { for (type = 0; type < 4; type++) { if (ac->che[type][i]) - ff_aac_sbr_ctx_close(&ac->che[type][i]->sbr); + AAC_RENAME(ff_aac_sbr_ctx_close)(&ac->che[type][i]->sbr); av_freep(&ac->che[type][i]); } } @@ -2928,9 +3128,16 @@ static void aacdec_init(AACContext *c) c->apply_tns = apply_tns; c->windowing_and_mdct_ltp = windowing_and_mdct_ltp; c->update_ltp = update_ltp; +#if USE_FIXED + c->vector_pow43 = vector_pow43; + c->imdct_and_windowing_fixed = imdct_and_windowing; + c->subband_scale = subband_scale; +#endif +#if !USE_FIXED if(ARCH_MIPS) ff_aacdec_init_mips(c); +#endif /* !USE_FIXED */ } /** * AVOptions for Japanese DTV specific extensions (ADTS only) diff --git a/libavcodec/fmtconvert.c b/libavcodec/fmtconvert.c index fb4302c..f5171bb 100644 --- a/libavcodec/fmtconvert.c +++ b/libavcodec/fmtconvert.c @@ -68,6 +68,22 @@ static void float_to_int16_interleave_c(int16_t *dst, const float **src, } } +static void int_to_int16_interleave_c(int16_t *dst, const int **src, long len, int channels) +{ + int i, j, c; + + if (channels==2){ + for (i=0; i> 9); + dst[2*i+1] = av_clip_int16((*(src[1]+i) + 256) >> 9); + } + }else{ + for (c=0; c> 9); + } +} + void ff_float_interleave_c(float *dst, const float **src, unsigned int len, int channels) { @@ -93,6 +109,7 @@ av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx) c->int32_to_float_fmul_array8 = int32_to_float_fmul_array8_c; c->float_to_int16 = float_to_int16_c; c->float_to_int16_interleave = float_to_int16_interleave_c; + c->int_to_int16_interleave = int_to_int16_interleave_c; c->float_interleave = ff_float_interleave_c; if (ARCH_ARM) ff_fmt_convert_init_arm(c, avctx); diff --git a/libavcodec/fmtconvert.h b/libavcodec/fmtconvert.h index 30abcc3..2aeb173 100644 --- a/libavcodec/fmtconvert.h +++ b/libavcodec/fmtconvert.h @@ -86,6 +86,8 @@ typedef struct FmtConvertContext { void (*float_to_int16_interleave)(int16_t *dst, const float **src, long len, int channels); + void (*int_to_int16_interleave)(int16_t *dst, const int **src, + long len, int channels); /** * Convert multiple arrays of float to an array of interleaved float. * diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h index c323230..e02ea77 100644 --- a/libavcodec/lpc.h +++ b/libavcodec/lpc.h @@ -194,4 +194,52 @@ static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order, return 0; } +static inline int compute_lpc_coefs_fixed(const int *autoc, int max_order, int *lpc, + int lpc_stride, int fail, int normalize) +{ + int i, j; + int *lpc_last = lpc; + int err; + long long accu; + + av_assert2(normalize || !fail); + + if (normalize) + err = *autoc++; + + if (fail && (autoc[max_order - 1] == 0 || err <= 0)) + return -1; + + for(i=0; i> 5; + + if (normalize) { + for(j=0; j>1; j++) { + int f = lpc_last[ j]; + int b = lpc_last[i-1-j]; + + accu = (long long)r * b; + lpc[ j] = f + (int)((accu + 0x2000000) >> 26); + accu = (long long)r * f; + lpc[i-1-j] = b + (int)((accu + 0x2000000) >> 26); + } + + if (fail && err < 0) + return -1; + + lpc_last = lpc; + lpc += lpc_stride; + } + return 0; +} + #endif /* AVCODEC_LPC_H */ diff --git a/libavcodec/mdct_template.c b/libavcodec/mdct_template.c index 7fa8bcc..a4fc86e 100644 --- a/libavcodec/mdct_template.c +++ b/libavcodec/mdct_template.c @@ -81,8 +81,13 @@ av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale) scale = sqrt(fabs(scale)); for(i=0;itcos[i*tstep] = FIX15(-cos(alpha) * scale); - s->tsin[i*tstep] = FIX15(-sin(alpha) * scale); +#if FFT_FIXED_32 + s->tcos[i*tstep] = (FFTSample)floor(-cos(alpha) * 2147483648.0 + 0.5); + s->tsin[i*tstep] = (FFTSample)floor(-sin(alpha) * 2147483648.0 + 0.5); +#else + s->tcos[i*tstep] = FIX15(-cos(alpha) * scale); + s->tsin[i*tstep] = FIX15(-sin(alpha) * scale); +#endif } return 0; fail: diff --git a/libavutil/fixed_dsp.c b/libavutil/fixed_dsp.c index b99fea5..711252f 100644 --- a/libavutil/fixed_dsp.c +++ b/libavutil/fixed_dsp.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Author: Nedeljko Babic (nbabic at mips.com) + * Author: Nedeljko Babic (nedeljko.babic imgtec com) * * This file is part of FFmpeg. * @@ -47,7 +47,29 @@ #include "fixed_dsp.h" -static void vector_fmul_window_fixed_scaled_c(int16_t *dst, const int32_t *src0, +static void vector_fmul_add_c(int *dst, const int *src0, const int *src1, const int *src2, int len){ + int i; + int64_t accu; + + for (i=0; i> 31); + } +} + +static void vector_fmul_reverse_c(int *dst, const int *src0, const int *src1, int len) +{ + int i; + int64_t accu; + + src1 += len-1; + for (i=0; i> 31); + } +} + +static void vector_fmul_window_scaled_c(int16_t *dst, const int32_t *src0, const int32_t *src1, const int32_t *win, int len, uint8_t bits) { @@ -68,7 +90,7 @@ static void vector_fmul_window_fixed_scaled_c(int16_t *dst, const int32_t *src0, } } -static void vector_fmul_window_fixed_c(int32_t *dst, const int32_t *src0, +static void vector_fmul_window_c(int32_t *dst, const int32_t *src0, const int32_t *src1, const int32_t *win, int len) { @@ -88,11 +110,49 @@ static void vector_fmul_window_fixed_c(int32_t *dst, const int32_t *src0, } } +static void vector_fmul_c(int *dst, const int *src0, const int *src1, int len) +{ + int i; + int64_t accu; + + for (i = 0; i < len; i++){ + accu = (int64_t)src0[i] * src1[i]; + dst[i] = (int)((accu+0x40000000) >> 31); + } +} + +static int ff_scalarproduct_fixed_c(const int *v1, const int *v2, int len) +{ + int64_t p = 0; + int i; + + for (i = 0; i < len; i++) + p += (int64_t)v1[i] * v2[i]; + + return (int)((p + 0x40000000) >> 31); +} + +static void butterflies_fixed_c(int *v1, int *v2, int len) +{ + int i; + + for (i = 0; i < len; i++){ + int t = v1[i] - v2[i]; + v1[i] += v2[i]; + v2[i] = t; + } +} + AVFixedDSPContext * avpriv_alloc_fixed_dsp(int bit_exact) { AVFixedDSPContext * fdsp = av_malloc(sizeof(AVFixedDSPContext)); - fdsp->vector_fmul_window_scaled = vector_fmul_window_fixed_scaled_c; - fdsp->vector_fmul_window = vector_fmul_window_fixed_c; + fdsp->vector_fmul = vector_fmul_c; + fdsp->vector_fmul_add = vector_fmul_add_c; + fdsp->vector_fmul_reverse = vector_fmul_reverse_c; + fdsp->vector_fmul_window_scaled = vector_fmul_window_scaled_c; + fdsp->vector_fmul_window = vector_fmul_window_c; + fdsp->butterflies_fixed = butterflies_fixed_c; + fdsp->scalarproduct_fixed = ff_scalarproduct_fixed_c; return fdsp; } diff --git a/libavutil/fixed_dsp.h b/libavutil/fixed_dsp.h index ff6f365..3035d19 100644 --- a/libavutil/fixed_dsp.h +++ b/libavutil/fixed_dsp.h @@ -54,6 +54,25 @@ #include "libavcodec/mathops.h" typedef struct AVFixedDSPContext { + /* assume len is a multiple of 16, and arrays are 32-byte aligned */ + + /** + * Calculate the product of two vectors of integers and store the result in + * a vector of integers. + * + * @param dst output vector + * constraints: 32-byte aligned + * @param src0 first input vector + * constraints: 32-byte aligned + * @param src1 second input vector + * constraints: 32-byte aligned + * @param len number of elements in the input + * constraints: multiple of 16 + */ + void (*vector_fmul)(int *dst, const int *src0, const int *src1, + int len); + + void (*vector_fmul_reverse)(int *dst, const int *src0, const int *src1, int len); /** * Overlap/add with window function. * Used primarily by MDCT-based audio codecs. @@ -92,6 +111,40 @@ typedef struct AVFixedDSPContext { */ void (*vector_fmul_window)(int32_t *dst, const int32_t *src0, const int32_t *src1, const int32_t *win, int len); + /** + * Calculate the product of two vectors of integers, add a third vector of + * integers and store the result in a vector of integers. + * + * @param dst output vector + * constraints: 32-byte aligned + * @param src0 first input vector + * constraints: 32-byte aligned + * @param src1 second input vector + * constraints: 32-byte aligned + * @param src1 third input vector + * constraints: 32-byte aligned + * @param len number of elements in the input + * constraints: multiple of 16 + */ + void (*vector_fmul_add)(int *dst, const int *src0, const int *src1, + const int *src2, int len); + + /** + * Calculate the scalar product of two vectors of floats. + * @param v1 first vector, 16-byte aligned + * @param v2 second vector, 16-byte aligned + * @param len length of vectors, multiple of 4 + */ + int (*scalarproduct_fixed)(const int *v1, const int *v2, int len); + + /** + * Calculate the sum and difference of two vectors of integers. + * + * @param v1 first input vector, sum output, 16-byte aligned + * @param v2 second input vector, difference output, 16-byte aligned + * @param len length of vectors, multiple of 4 + */ + void (*butterflies_fixed)(int *av_restrict v1, int *av_restrict v2, int len); } AVFixedDSPContext; /** -- 1.8.2.1 From nedeljko.babic at imgtec.com Fri Aug 1 15:53:07 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:07 +0200 Subject: [FFmpeg-devel] [PATCH 01/14] libavcodec: Implementation of AAC_fixed_decoder (LC-module) [1/5] In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-2-git-send-email-nedeljko.babic@imgtec.com> From: Jovan Zelincevic Move existing code to the new template files Signed-off-by: Nedeljko Babic --- libavcodec/aacdec.c | 3073 +------------------------------- libavcodec/aacdec_template.c | 2957 ++++++++++++++++++++++++++++++ libavcodec/cbrt_tablegen.c | 16 - libavcodec/cbrt_tablegen_template.c | 37 + libavcodec/sinewin_tablegen.c | 25 - libavcodec/sinewin_tablegen_template.c | 46 + 6 files changed, 3119 insertions(+), 3035 deletions(-) create mode 100644 libavcodec/aacdec_template.c create mode 100644 libavcodec/cbrt_tablegen_template.c create mode 100644 libavcodec/sinewin_tablegen_template.c diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 10c509b..2e6d2bc 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -32,55 +32,6 @@ * @author Maxim Gavrilov ( maxim.gavrilov gmail com ) */ -/* - * supported tools - * - * Support? Name - * N (code in SoC repo) gain control - * Y block switching - * Y window shapes - standard - * N window shapes - Low Delay - * Y filterbank - standard - * N (code in SoC repo) filterbank - Scalable Sample Rate - * Y Temporal Noise Shaping - * Y Long Term Prediction - * Y intensity stereo - * Y channel coupling - * Y frequency domain prediction - * Y Perceptual Noise Substitution - * Y Mid/Side stereo - * N Scalable Inverse AAC Quantization - * N Frequency Selective Switch - * N upsampling filter - * Y quantization & coding - AAC - * N quantization & coding - TwinVQ - * N quantization & coding - BSAC - * N AAC Error Resilience tools - * N Error Resilience payload syntax - * N Error Protection tool - * N CELP - * N Silence Compression - * N HVXC - * N HVXC 4kbits/s VR - * N Structured Audio tools - * N Structured Audio Sample Bank Format - * N MIDI - * N Harmonic and Individual Lines plus Noise - * N Text-To-Speech Interface - * Y Spectral Band Replication - * Y (not in this code) Layer-1 - * Y (not in this code) Layer-2 - * Y (not in this code) Layer-3 - * N SinuSoidal Coding (Transient, Sinusoid, Noise) - * Y Parametric Stereo - * N Direct Stream Transfer - * Y Enhanced AAC Low Delay (ER AAC ELD) - * - * Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication. - * - HE AAC v2 comprises LC AAC with Spectral Band Replication and - Parametric Stereo. - */ - #include "libavutil/float_dsp.h" #include "libavutil/opt.h" #include "avcodec.h" @@ -114,888 +65,6 @@ # include "mips/aacdec_mips.h" #endif -static VLC vlc_scalefactors; -static VLC vlc_spectral[11]; - -static int output_configure(AACContext *ac, - uint8_t layout_map[MAX_ELEM_ID*4][3], int tags, - enum OCStatus oc_type, int get_new_frame); - -#define overread_err "Input buffer exhausted before END element found\n" - -static int count_channels(uint8_t (*layout)[3], int tags) -{ - int i, sum = 0; - for (i = 0; i < tags; i++) { - int syn_ele = layout[i][0]; - int pos = layout[i][2]; - sum += (1 + (syn_ele == TYPE_CPE)) * - (pos != AAC_CHANNEL_OFF && pos != AAC_CHANNEL_CC); - } - return sum; -} - -/** - * Check for the channel element in the current channel position configuration. - * If it exists, make sure the appropriate element is allocated and map the - * channel order to match the internal FFmpeg channel layout. - * - * @param che_pos current channel position configuration - * @param type channel element type - * @param id channel element id - * @param channels count of the number of channels in the configuration - * - * @return Returns error status. 0 - OK, !0 - error - */ -static av_cold int che_configure(AACContext *ac, - enum ChannelPosition che_pos, - int type, int id, int *channels) -{ - if (*channels >= MAX_CHANNELS) - return AVERROR_INVALIDDATA; - if (che_pos) { - if (!ac->che[type][id]) { - if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement)))) - return AVERROR(ENOMEM); - ff_aac_sbr_ctx_init(ac, &ac->che[type][id]->sbr); - } - if (type != TYPE_CCE) { - if (*channels >= MAX_CHANNELS - (type == TYPE_CPE || (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1))) { - av_log(ac->avctx, AV_LOG_ERROR, "Too many channels\n"); - return AVERROR_INVALIDDATA; - } - ac->output_element[(*channels)++] = &ac->che[type][id]->ch[0]; - if (type == TYPE_CPE || - (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1)) { - ac->output_element[(*channels)++] = &ac->che[type][id]->ch[1]; - } - } - } else { - if (ac->che[type][id]) - ff_aac_sbr_ctx_close(&ac->che[type][id]->sbr); - av_freep(&ac->che[type][id]); - } - return 0; -} - -static int frame_configure_elements(AVCodecContext *avctx) -{ - AACContext *ac = avctx->priv_data; - int type, id, ch, ret; - - /* set channel pointers to internal buffers by default */ - for (type = 0; type < 4; type++) { - for (id = 0; id < MAX_ELEM_ID; id++) { - ChannelElement *che = ac->che[type][id]; - if (che) { - che->ch[0].ret = che->ch[0].ret_buf; - che->ch[1].ret = che->ch[1].ret_buf; - } - } - } - - /* get output buffer */ - av_frame_unref(ac->frame); - if (!avctx->channels) - return 1; - - ac->frame->nb_samples = 2048; - if ((ret = ff_get_buffer(avctx, ac->frame, 0)) < 0) - return ret; - - /* map output channel pointers to AVFrame data */ - for (ch = 0; ch < avctx->channels; ch++) { - if (ac->output_element[ch]) - ac->output_element[ch]->ret = (float *)ac->frame->extended_data[ch]; - } - - return 0; -} - -struct elem_to_channel { - uint64_t av_position; - uint8_t syn_ele; - uint8_t elem_id; - uint8_t aac_position; -}; - -static int assign_pair(struct elem_to_channel e2c_vec[MAX_ELEM_ID], - uint8_t (*layout_map)[3], int offset, uint64_t left, - uint64_t right, int pos) -{ - if (layout_map[offset][0] == TYPE_CPE) { - e2c_vec[offset] = (struct elem_to_channel) { - .av_position = left | right, - .syn_ele = TYPE_CPE, - .elem_id = layout_map[offset][1], - .aac_position = pos - }; - return 1; - } else { - e2c_vec[offset] = (struct elem_to_channel) { - .av_position = left, - .syn_ele = TYPE_SCE, - .elem_id = layout_map[offset][1], - .aac_position = pos - }; - e2c_vec[offset + 1] = (struct elem_to_channel) { - .av_position = right, - .syn_ele = TYPE_SCE, - .elem_id = layout_map[offset + 1][1], - .aac_position = pos - }; - return 2; - } -} - -static int count_paired_channels(uint8_t (*layout_map)[3], int tags, int pos, - int *current) -{ - int num_pos_channels = 0; - int first_cpe = 0; - int sce_parity = 0; - int i; - for (i = *current; i < tags; i++) { - if (layout_map[i][2] != pos) - break; - if (layout_map[i][0] == TYPE_CPE) { - if (sce_parity) { - if (pos == AAC_CHANNEL_FRONT && !first_cpe) { - sce_parity = 0; - } else { - return -1; - } - } - num_pos_channels += 2; - first_cpe = 1; - } else { - num_pos_channels++; - sce_parity ^= 1; - } - } - if (sce_parity && - ((pos == AAC_CHANNEL_FRONT && first_cpe) || pos == AAC_CHANNEL_SIDE)) - return -1; - *current = i; - return num_pos_channels; -} - -static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags) -{ - int i, n, total_non_cc_elements; - struct elem_to_channel e2c_vec[4 * MAX_ELEM_ID] = { { 0 } }; - int num_front_channels, num_side_channels, num_back_channels; - uint64_t layout; - - if (FF_ARRAY_ELEMS(e2c_vec) < tags) - return 0; - - i = 0; - num_front_channels = - count_paired_channels(layout_map, tags, AAC_CHANNEL_FRONT, &i); - if (num_front_channels < 0) - return 0; - num_side_channels = - count_paired_channels(layout_map, tags, AAC_CHANNEL_SIDE, &i); - if (num_side_channels < 0) - return 0; - num_back_channels = - count_paired_channels(layout_map, tags, AAC_CHANNEL_BACK, &i); - if (num_back_channels < 0) - return 0; - - i = 0; - if (num_front_channels & 1) { - e2c_vec[i] = (struct elem_to_channel) { - .av_position = AV_CH_FRONT_CENTER, - .syn_ele = TYPE_SCE, - .elem_id = layout_map[i][1], - .aac_position = AAC_CHANNEL_FRONT - }; - i++; - num_front_channels--; - } - if (num_front_channels >= 4) { - i += assign_pair(e2c_vec, layout_map, i, - AV_CH_FRONT_LEFT_OF_CENTER, - AV_CH_FRONT_RIGHT_OF_CENTER, - AAC_CHANNEL_FRONT); - num_front_channels -= 2; - } - if (num_front_channels >= 2) { - i += assign_pair(e2c_vec, layout_map, i, - AV_CH_FRONT_LEFT, - AV_CH_FRONT_RIGHT, - AAC_CHANNEL_FRONT); - num_front_channels -= 2; - } - while (num_front_channels >= 2) { - i += assign_pair(e2c_vec, layout_map, i, - UINT64_MAX, - UINT64_MAX, - AAC_CHANNEL_FRONT); - num_front_channels -= 2; - } - - if (num_side_channels >= 2) { - i += assign_pair(e2c_vec, layout_map, i, - AV_CH_SIDE_LEFT, - AV_CH_SIDE_RIGHT, - AAC_CHANNEL_FRONT); - num_side_channels -= 2; - } - while (num_side_channels >= 2) { - i += assign_pair(e2c_vec, layout_map, i, - UINT64_MAX, - UINT64_MAX, - AAC_CHANNEL_SIDE); - num_side_channels -= 2; - } - - while (num_back_channels >= 4) { - i += assign_pair(e2c_vec, layout_map, i, - UINT64_MAX, - UINT64_MAX, - AAC_CHANNEL_BACK); - num_back_channels -= 2; - } - if (num_back_channels >= 2) { - i += assign_pair(e2c_vec, layout_map, i, - AV_CH_BACK_LEFT, - AV_CH_BACK_RIGHT, - AAC_CHANNEL_BACK); - num_back_channels -= 2; - } - if (num_back_channels) { - e2c_vec[i] = (struct elem_to_channel) { - .av_position = AV_CH_BACK_CENTER, - .syn_ele = TYPE_SCE, - .elem_id = layout_map[i][1], - .aac_position = AAC_CHANNEL_BACK - }; - i++; - num_back_channels--; - } - - if (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) { - e2c_vec[i] = (struct elem_to_channel) { - .av_position = AV_CH_LOW_FREQUENCY, - .syn_ele = TYPE_LFE, - .elem_id = layout_map[i][1], - .aac_position = AAC_CHANNEL_LFE - }; - i++; - } - while (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) { - e2c_vec[i] = (struct elem_to_channel) { - .av_position = UINT64_MAX, - .syn_ele = TYPE_LFE, - .elem_id = layout_map[i][1], - .aac_position = AAC_CHANNEL_LFE - }; - i++; - } - - // Must choose a stable sort - total_non_cc_elements = n = i; - do { - int next_n = 0; - for (i = 1; i < n; i++) - if (e2c_vec[i - 1].av_position > e2c_vec[i].av_position) { - FFSWAP(struct elem_to_channel, e2c_vec[i - 1], e2c_vec[i]); - next_n = i; - } - n = next_n; - } while (n > 0); - - layout = 0; - for (i = 0; i < total_non_cc_elements; i++) { - layout_map[i][0] = e2c_vec[i].syn_ele; - layout_map[i][1] = e2c_vec[i].elem_id; - layout_map[i][2] = e2c_vec[i].aac_position; - if (e2c_vec[i].av_position != UINT64_MAX) { - layout |= e2c_vec[i].av_position; - } - } - - return layout; -} - -/** - * Save current output configuration if and only if it has been locked. - */ -static void push_output_configuration(AACContext *ac) { - if (ac->oc[1].status == OC_LOCKED) { - ac->oc[0] = ac->oc[1]; - } - ac->oc[1].status = OC_NONE; -} - -/** - * Restore the previous output configuration if and only if the current - * configuration is unlocked. - */ -static void pop_output_configuration(AACContext *ac) { - if (ac->oc[1].status != OC_LOCKED && ac->oc[0].status != OC_NONE) { - ac->oc[1] = ac->oc[0]; - ac->avctx->channels = ac->oc[1].channels; - ac->avctx->channel_layout = ac->oc[1].channel_layout; - output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, - ac->oc[1].status, 0); - } -} - -/** - * Configure output channel order based on the current program - * configuration element. - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int output_configure(AACContext *ac, - uint8_t layout_map[MAX_ELEM_ID * 4][3], int tags, - enum OCStatus oc_type, int get_new_frame) -{ - AVCodecContext *avctx = ac->avctx; - int i, channels = 0, ret; - uint64_t layout = 0; - - if (ac->oc[1].layout_map != layout_map) { - memcpy(ac->oc[1].layout_map, layout_map, tags * sizeof(layout_map[0])); - ac->oc[1].layout_map_tags = tags; - } - - // Try to sniff a reasonable channel order, otherwise output the - // channels in the order the PCE declared them. - if (avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE) - layout = sniff_channel_order(layout_map, tags); - for (i = 0; i < tags; i++) { - int type = layout_map[i][0]; - int id = layout_map[i][1]; - int position = layout_map[i][2]; - // Allocate or free elements depending on if they are in the - // current program configuration. - ret = che_configure(ac, position, type, id, &channels); - if (ret < 0) - return ret; - } - if (ac->oc[1].m4ac.ps == 1 && channels == 2) { - if (layout == AV_CH_FRONT_CENTER) { - layout = AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT; - } else { - layout = 0; - } - } - - memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0])); - if (layout) avctx->channel_layout = layout; - ac->oc[1].channel_layout = layout; - avctx->channels = ac->oc[1].channels = channels; - ac->oc[1].status = oc_type; - - if (get_new_frame) { - if ((ret = frame_configure_elements(ac->avctx)) < 0) - return ret; - } - - return 0; -} - -static void flush(AVCodecContext *avctx) -{ - AACContext *ac= avctx->priv_data; - int type, i, j; - - for (type = 3; type >= 0; type--) { - for (i = 0; i < MAX_ELEM_ID; i++) { - ChannelElement *che = ac->che[type][i]; - if (che) { - for (j = 0; j <= 1; j++) { - memset(che->ch[j].saved, 0, sizeof(che->ch[j].saved)); - } - } - } - } -} - -/** - * Set up channel positions based on a default channel configuration - * as specified in table 1.17. - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int set_default_channel_config(AVCodecContext *avctx, - uint8_t (*layout_map)[3], - int *tags, - int channel_config) -{ - if (channel_config < 1 || channel_config > 7) { - av_log(avctx, AV_LOG_ERROR, - "invalid default channel configuration (%d)\n", - channel_config); - return AVERROR_INVALIDDATA; - } - *tags = tags_per_config[channel_config]; - memcpy(layout_map, aac_channel_layout_map[channel_config - 1], - *tags * sizeof(*layout_map)); - - /* - * AAC specification has 7.1(wide) as a default layout for 8-channel streams. - * However, at least Nero AAC encoder encodes 7.1 streams using the default - * channel config 7, mapping the side channels of the original audio stream - * to the second AAC_CHANNEL_FRONT pair in the AAC stream. Similarly, e.g. FAAD - * decodes the second AAC_CHANNEL_FRONT pair as side channels, therefore decoding - * the incorrect streams as if they were correct (and as the encoder intended). - * - * As actual intended 7.1(wide) streams are very rare, default to assuming a - * 7.1 layout was intended. - */ - if (channel_config == 7 && avctx->strict_std_compliance < FF_COMPLIANCE_STRICT) { - av_log(avctx, AV_LOG_INFO, "Assuming an incorrectly encoded 7.1 channel layout" - " instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode" - " according to the specification instead.\n", FF_COMPLIANCE_STRICT); - layout_map[2][2] = AAC_CHANNEL_SIDE; - } - - return 0; -} - -static ChannelElement *get_che(AACContext *ac, int type, int elem_id) -{ - /* For PCE based channel configurations map the channels solely based - * on tags. */ - if (!ac->oc[1].m4ac.chan_config) { - return ac->tag_che_map[type][elem_id]; - } - // Allow single CPE stereo files to be signalled with mono configuration. - if (!ac->tags_mapped && type == TYPE_CPE && - ac->oc[1].m4ac.chan_config == 1) { - uint8_t layout_map[MAX_ELEM_ID*4][3]; - int layout_map_tags; - push_output_configuration(ac); - - av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n"); - - if (set_default_channel_config(ac->avctx, layout_map, - &layout_map_tags, 2) < 0) - return NULL; - if (output_configure(ac, layout_map, layout_map_tags, - OC_TRIAL_FRAME, 1) < 0) - return NULL; - - ac->oc[1].m4ac.chan_config = 2; - ac->oc[1].m4ac.ps = 0; - } - // And vice-versa - if (!ac->tags_mapped && type == TYPE_SCE && - ac->oc[1].m4ac.chan_config == 2) { - uint8_t layout_map[MAX_ELEM_ID * 4][3]; - int layout_map_tags; - push_output_configuration(ac); - - av_log(ac->avctx, AV_LOG_DEBUG, "stereo with SCE\n"); - - if (set_default_channel_config(ac->avctx, layout_map, - &layout_map_tags, 1) < 0) - return NULL; - if (output_configure(ac, layout_map, layout_map_tags, - OC_TRIAL_FRAME, 1) < 0) - return NULL; - - ac->oc[1].m4ac.chan_config = 1; - if (ac->oc[1].m4ac.sbr) - ac->oc[1].m4ac.ps = -1; - } - /* For indexed channel configurations map the channels solely based - * on position. */ - switch (ac->oc[1].m4ac.chan_config) { - case 7: - if (ac->tags_mapped == 3 && type == TYPE_CPE) { - ac->tags_mapped++; - return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2]; - } - case 6: - /* Some streams incorrectly code 5.1 audio as - * SCE[0] CPE[0] CPE[1] SCE[1] - * instead of - * SCE[0] CPE[0] CPE[1] LFE[0]. - * If we seem to have encountered such a stream, transfer - * the LFE[0] element to the SCE[1]'s mapping */ - if (ac->tags_mapped == tags_per_config[ac->oc[1].m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) { - ac->tags_mapped++; - return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0]; - } - case 5: - if (ac->tags_mapped == 2 && type == TYPE_CPE) { - ac->tags_mapped++; - return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1]; - } - case 4: - if (ac->tags_mapped == 2 && - ac->oc[1].m4ac.chan_config == 4 && - type == TYPE_SCE) { - ac->tags_mapped++; - return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1]; - } - case 3: - case 2: - if (ac->tags_mapped == (ac->oc[1].m4ac.chan_config != 2) && - type == TYPE_CPE) { - ac->tags_mapped++; - return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0]; - } else if (ac->oc[1].m4ac.chan_config == 2) { - return NULL; - } - case 1: - if (!ac->tags_mapped && type == TYPE_SCE) { - ac->tags_mapped++; - return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][0]; - } - default: - return NULL; - } -} - -/** - * Decode an array of 4 bit element IDs, optionally interleaved with a - * stereo/mono switching bit. - * - * @param type speaker type/position for these channels - */ -static void decode_channel_map(uint8_t layout_map[][3], - enum ChannelPosition type, - GetBitContext *gb, int n) -{ - while (n--) { - enum RawDataBlockType syn_ele; - switch (type) { - case AAC_CHANNEL_FRONT: - case AAC_CHANNEL_BACK: - case AAC_CHANNEL_SIDE: - syn_ele = get_bits1(gb); - break; - case AAC_CHANNEL_CC: - skip_bits1(gb); - syn_ele = TYPE_CCE; - break; - case AAC_CHANNEL_LFE: - syn_ele = TYPE_LFE; - break; - default: - av_assert0(0); - } - layout_map[0][0] = syn_ele; - layout_map[0][1] = get_bits(gb, 4); - layout_map[0][2] = type; - layout_map++; - } -} - -/** - * Decode program configuration element; reference: table 4.2. - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac, - uint8_t (*layout_map)[3], - GetBitContext *gb) -{ - int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc; - int sampling_index; - int comment_len; - int tags; - - skip_bits(gb, 2); // object_type - - sampling_index = get_bits(gb, 4); - if (m4ac->sampling_index != sampling_index) - av_log(avctx, AV_LOG_WARNING, - "Sample rate index in program config element does not " - "match the sample rate index configured by the container.\n"); - - num_front = get_bits(gb, 4); - num_side = get_bits(gb, 4); - num_back = get_bits(gb, 4); - num_lfe = get_bits(gb, 2); - num_assoc_data = get_bits(gb, 3); - num_cc = get_bits(gb, 4); - - if (get_bits1(gb)) - skip_bits(gb, 4); // mono_mixdown_tag - if (get_bits1(gb)) - skip_bits(gb, 4); // stereo_mixdown_tag - - if (get_bits1(gb)) - skip_bits(gb, 3); // mixdown_coeff_index and pseudo_surround - - if (get_bits_left(gb) < 4 * (num_front + num_side + num_back + num_lfe + num_assoc_data + num_cc)) { - av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err); - return -1; - } - decode_channel_map(layout_map , AAC_CHANNEL_FRONT, gb, num_front); - tags = num_front; - decode_channel_map(layout_map + tags, AAC_CHANNEL_SIDE, gb, num_side); - tags += num_side; - decode_channel_map(layout_map + tags, AAC_CHANNEL_BACK, gb, num_back); - tags += num_back; - decode_channel_map(layout_map + tags, AAC_CHANNEL_LFE, gb, num_lfe); - tags += num_lfe; - - skip_bits_long(gb, 4 * num_assoc_data); - - decode_channel_map(layout_map + tags, AAC_CHANNEL_CC, gb, num_cc); - tags += num_cc; - - align_get_bits(gb); - - /* comment field, first byte is length */ - comment_len = get_bits(gb, 8) * 8; - if (get_bits_left(gb) < comment_len) { - av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err); - return AVERROR_INVALIDDATA; - } - skip_bits_long(gb, comment_len); - return tags; -} - -/** - * Decode GA "General Audio" specific configuration; reference: table 4.1. - * - * @param ac pointer to AACContext, may be null - * @param avctx pointer to AVCCodecContext, used for logging - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx, - GetBitContext *gb, - MPEG4AudioConfig *m4ac, - int channel_config) -{ - int extension_flag, ret, ep_config, res_flags; - uint8_t layout_map[MAX_ELEM_ID*4][3]; - int tags = 0; - - if (get_bits1(gb)) { // frameLengthFlag - avpriv_request_sample(avctx, "960/120 MDCT window"); - return AVERROR_PATCHWELCOME; - } - - if (get_bits1(gb)) // dependsOnCoreCoder - skip_bits(gb, 14); // coreCoderDelay - extension_flag = get_bits1(gb); - - if (m4ac->object_type == AOT_AAC_SCALABLE || - m4ac->object_type == AOT_ER_AAC_SCALABLE) - skip_bits(gb, 3); // layerNr - - if (channel_config == 0) { - skip_bits(gb, 4); // element_instance_tag - tags = decode_pce(avctx, m4ac, layout_map, gb); - if (tags < 0) - return tags; - } else { - if ((ret = set_default_channel_config(avctx, layout_map, - &tags, channel_config))) - return ret; - } - - if (count_channels(layout_map, tags) > 1) { - m4ac->ps = 0; - } else if (m4ac->sbr == 1 && m4ac->ps == -1) - m4ac->ps = 1; - - if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) - return ret; - - if (extension_flag) { - switch (m4ac->object_type) { - case AOT_ER_BSAC: - skip_bits(gb, 5); // numOfSubFrame - skip_bits(gb, 11); // layer_length - break; - case AOT_ER_AAC_LC: - case AOT_ER_AAC_LTP: - case AOT_ER_AAC_SCALABLE: - case AOT_ER_AAC_LD: - res_flags = get_bits(gb, 3); - if (res_flags) { - avpriv_report_missing_feature(avctx, - "AAC data resilience (flags %x)", - res_flags); - return AVERROR_PATCHWELCOME; - } - break; - } - skip_bits1(gb); // extensionFlag3 (TBD in version 3) - } - switch (m4ac->object_type) { - case AOT_ER_AAC_LC: - case AOT_ER_AAC_LTP: - case AOT_ER_AAC_SCALABLE: - case AOT_ER_AAC_LD: - ep_config = get_bits(gb, 2); - if (ep_config) { - avpriv_report_missing_feature(avctx, - "epConfig %d", ep_config); - return AVERROR_PATCHWELCOME; - } - } - return 0; -} - -static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx, - GetBitContext *gb, - MPEG4AudioConfig *m4ac, - int channel_config) -{ - int ret, ep_config, res_flags; - uint8_t layout_map[MAX_ELEM_ID*4][3]; - int tags = 0; - const int ELDEXT_TERM = 0; - - m4ac->ps = 0; - m4ac->sbr = 0; - - if (get_bits1(gb)) { // frameLengthFlag - avpriv_request_sample(avctx, "960/120 MDCT window"); - return AVERROR_PATCHWELCOME; - } - - res_flags = get_bits(gb, 3); - if (res_flags) { - avpriv_report_missing_feature(avctx, - "AAC data resilience (flags %x)", - res_flags); - return AVERROR_PATCHWELCOME; - } - - if (get_bits1(gb)) { // ldSbrPresentFlag - avpriv_report_missing_feature(avctx, - "Low Delay SBR"); - return AVERROR_PATCHWELCOME; - } - - while (get_bits(gb, 4) != ELDEXT_TERM) { - int len = get_bits(gb, 4); - if (len == 15) - len += get_bits(gb, 8); - if (len == 15 + 255) - len += get_bits(gb, 16); - if (get_bits_left(gb) < len * 8 + 4) { - av_log(ac->avctx, AV_LOG_ERROR, overread_err); - return AVERROR_INVALIDDATA; - } - skip_bits_long(gb, 8 * len); - } - - if ((ret = set_default_channel_config(avctx, layout_map, - &tags, channel_config))) - return ret; - - if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) - return ret; - - ep_config = get_bits(gb, 2); - if (ep_config) { - avpriv_report_missing_feature(avctx, - "epConfig %d", ep_config); - return AVERROR_PATCHWELCOME; - } - return 0; -} - -/** - * Decode audio specific configuration; reference: table 1.13. - * - * @param ac pointer to AACContext, may be null - * @param avctx pointer to AVCCodecContext, used for logging - * @param m4ac pointer to MPEG4AudioConfig, used for parsing - * @param data pointer to buffer holding an audio specific config - * @param bit_size size of audio specific config or data in bits - * @param sync_extension look for an appended sync extension - * - * @return Returns error status or number of consumed bits. <0 - error - */ -static int decode_audio_specific_config(AACContext *ac, - AVCodecContext *avctx, - MPEG4AudioConfig *m4ac, - const uint8_t *data, int bit_size, - int sync_extension) -{ - GetBitContext gb; - int i, ret; - - av_dlog(avctx, "audio specific config size %d\n", bit_size >> 3); - for (i = 0; i < bit_size >> 3; i++) - av_dlog(avctx, "%02x ", data[i]); - av_dlog(avctx, "\n"); - - if ((ret = init_get_bits(&gb, data, bit_size)) < 0) - return ret; - - if ((i = avpriv_mpeg4audio_get_config(m4ac, data, bit_size, - sync_extension)) < 0) - return AVERROR_INVALIDDATA; - if (m4ac->sampling_index > 12) { - av_log(avctx, AV_LOG_ERROR, - "invalid sampling rate index %d\n", - m4ac->sampling_index); - return AVERROR_INVALIDDATA; - } - if (m4ac->object_type == AOT_ER_AAC_LD && - (m4ac->sampling_index < 3 || m4ac->sampling_index > 7)) { - av_log(avctx, AV_LOG_ERROR, - "invalid low delay sampling rate index %d\n", - m4ac->sampling_index); - return AVERROR_INVALIDDATA; - } - - skip_bits_long(&gb, i); - - switch (m4ac->object_type) { - case AOT_AAC_MAIN: - case AOT_AAC_LC: - case AOT_AAC_LTP: - case AOT_ER_AAC_LC: - case AOT_ER_AAC_LD: - if ((ret = decode_ga_specific_config(ac, avctx, &gb, - m4ac, m4ac->chan_config)) < 0) - return ret; - break; - case AOT_ER_AAC_ELD: - if ((ret = decode_eld_specific_config(ac, avctx, &gb, - m4ac, m4ac->chan_config)) < 0) - return ret; - break; - default: - avpriv_report_missing_feature(avctx, - "Audio object type %s%d", - m4ac->sbr == 1 ? "SBR+" : "", - m4ac->object_type); - return AVERROR(ENOSYS); - } - - av_dlog(avctx, - "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n", - m4ac->object_type, m4ac->chan_config, m4ac->sampling_index, - m4ac->sample_rate, m4ac->sbr, - m4ac->ps); - - return get_bits_count(&gb); -} - -/** - * linear congruential pseudorandom number generator - * - * @param previous_val pointer to the current state of the generator - * - * @return Returns a 32-bit pseudorandom integer - */ -static av_always_inline int lcg_random(unsigned previous_val) -{ - union { unsigned u; int s; } v = { previous_val * 1664525u + 1013904223 }; - return v.s; -} - static av_always_inline void reset_predict_state(PredictorState *ps) { ps->r0 = 0.0f; @@ -1006,529 +75,35 @@ static av_always_inline void reset_predict_state(PredictorState *ps) ps->var1 = 1.0f; } -static void reset_all_predictors(PredictorState *ps) +#ifndef VMUL2 +static inline float *VMUL2(float *dst, const float *v, unsigned idx, + const float *scale) { - int i; - for (i = 0; i < MAX_PREDICTORS; i++) - reset_predict_state(&ps[i]); + float s = *scale; + *dst++ = v[idx & 15] * s; + *dst++ = v[idx>>4 & 15] * s; + return dst; } +#endif -static int sample_rate_idx (int rate) +#ifndef VMUL4 +static inline float *VMUL4(float *dst, const float *v, unsigned idx, + const float *scale) { - if (92017 <= rate) return 0; - else if (75132 <= rate) return 1; - else if (55426 <= rate) return 2; - else if (46009 <= rate) return 3; - else if (37566 <= rate) return 4; - else if (27713 <= rate) return 5; - else if (23004 <= rate) return 6; - else if (18783 <= rate) return 7; - else if (13856 <= rate) return 8; - else if (11502 <= rate) return 9; - else if (9391 <= rate) return 10; - else return 11; + float s = *scale; + *dst++ = v[idx & 3] * s; + *dst++ = v[idx>>2 & 3] * s; + *dst++ = v[idx>>4 & 3] * s; + *dst++ = v[idx>>6 & 3] * s; + return dst; } +#endif -static void reset_predictor_group(PredictorState *ps, int group_num) +#ifndef VMUL2S +static inline float *VMUL2S(float *dst, const float *v, unsigned idx, + unsigned sign, const float *scale) { - int i; - for (i = group_num - 1; i < MAX_PREDICTORS; i += 30) - reset_predict_state(&ps[i]); -} - -#define AAC_INIT_VLC_STATIC(num, size) \ - INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \ - ff_aac_spectral_bits[num], sizeof(ff_aac_spectral_bits[num][0]), \ - sizeof(ff_aac_spectral_bits[num][0]), \ - ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), \ - sizeof(ff_aac_spectral_codes[num][0]), \ - size); - -static void aacdec_init(AACContext *ac); - -static av_cold int aac_decode_init(AVCodecContext *avctx) -{ - AACContext *ac = avctx->priv_data; - int ret; - - ac->avctx = avctx; - ac->oc[1].m4ac.sample_rate = avctx->sample_rate; - - aacdec_init(ac); - - avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; - - if (avctx->extradata_size > 0) { - if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, - avctx->extradata, - avctx->extradata_size * 8, - 1)) < 0) - return ret; - } else { - int sr, i; - uint8_t layout_map[MAX_ELEM_ID*4][3]; - int layout_map_tags; - - sr = sample_rate_idx(avctx->sample_rate); - ac->oc[1].m4ac.sampling_index = sr; - ac->oc[1].m4ac.channels = avctx->channels; - ac->oc[1].m4ac.sbr = -1; - ac->oc[1].m4ac.ps = -1; - - for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++) - if (ff_mpeg4audio_channels[i] == avctx->channels) - break; - if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) { - i = 0; - } - ac->oc[1].m4ac.chan_config = i; - - if (ac->oc[1].m4ac.chan_config) { - int ret = set_default_channel_config(avctx, layout_map, - &layout_map_tags, ac->oc[1].m4ac.chan_config); - if (!ret) - output_configure(ac, layout_map, layout_map_tags, - OC_GLOBAL_HDR, 0); - else if (avctx->err_recognition & AV_EF_EXPLODE) - return AVERROR_INVALIDDATA; - } - } - - if (avctx->channels > MAX_CHANNELS) { - av_log(avctx, AV_LOG_ERROR, "Too many channels\n"); - return AVERROR_INVALIDDATA; - } - - AAC_INIT_VLC_STATIC( 0, 304); - AAC_INIT_VLC_STATIC( 1, 270); - AAC_INIT_VLC_STATIC( 2, 550); - AAC_INIT_VLC_STATIC( 3, 300); - AAC_INIT_VLC_STATIC( 4, 328); - AAC_INIT_VLC_STATIC( 5, 294); - AAC_INIT_VLC_STATIC( 6, 306); - AAC_INIT_VLC_STATIC( 7, 268); - AAC_INIT_VLC_STATIC( 8, 510); - AAC_INIT_VLC_STATIC( 9, 366); - AAC_INIT_VLC_STATIC(10, 462); - - ff_aac_sbr_init(); - - ff_fmt_convert_init(&ac->fmt_conv, avctx); - avpriv_float_dsp_init(&ac->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); - - ac->random_state = 0x1f2e3d4c; - - ff_aac_tableinit(); - - INIT_VLC_STATIC(&vlc_scalefactors, 7, - FF_ARRAY_ELEMS(ff_aac_scalefactor_code), - ff_aac_scalefactor_bits, - sizeof(ff_aac_scalefactor_bits[0]), - sizeof(ff_aac_scalefactor_bits[0]), - ff_aac_scalefactor_code, - sizeof(ff_aac_scalefactor_code[0]), - sizeof(ff_aac_scalefactor_code[0]), - 352); - - ff_mdct_init(&ac->mdct, 11, 1, 1.0 / (32768.0 * 1024.0)); - ff_mdct_init(&ac->mdct_ld, 10, 1, 1.0 / (32768.0 * 512.0)); - ff_mdct_init(&ac->mdct_small, 8, 1, 1.0 / (32768.0 * 128.0)); - ff_mdct_init(&ac->mdct_ltp, 11, 0, -2.0 * 32768.0); - // window initialization - ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); - ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128); - ff_init_ff_sine_windows(10); - ff_init_ff_sine_windows( 9); - ff_init_ff_sine_windows( 7); - - cbrt_tableinit(); - - return 0; -} - -/** - * Skip data_stream_element; reference: table 4.10. - */ -static int skip_data_stream_element(AACContext *ac, GetBitContext *gb) -{ - int byte_align = get_bits1(gb); - int count = get_bits(gb, 8); - if (count == 255) - count += get_bits(gb, 8); - if (byte_align) - align_get_bits(gb); - - if (get_bits_left(gb) < 8 * count) { - av_log(ac->avctx, AV_LOG_ERROR, "skip_data_stream_element: "overread_err); - return AVERROR_INVALIDDATA; - } - skip_bits_long(gb, 8 * count); - return 0; -} - -static int decode_prediction(AACContext *ac, IndividualChannelStream *ics, - GetBitContext *gb) -{ - int sfb; - if (get_bits1(gb)) { - ics->predictor_reset_group = get_bits(gb, 5); - if (ics->predictor_reset_group == 0 || - ics->predictor_reset_group > 30) { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid Predictor Reset Group.\n"); - return AVERROR_INVALIDDATA; - } - } - for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]); sfb++) { - ics->prediction_used[sfb] = get_bits1(gb); - } - return 0; -} - -/** - * Decode Long Term Prediction data; reference: table 4.xx. - */ -static void decode_ltp(LongTermPrediction *ltp, - GetBitContext *gb, uint8_t max_sfb) -{ - int sfb; - - ltp->lag = get_bits(gb, 11); - ltp->coef = ltp_coef[get_bits(gb, 3)]; - for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++) - ltp->used[sfb] = get_bits1(gb); -} - -/** - * Decode Individual Channel Stream info; reference: table 4.6. - */ -static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, - GetBitContext *gb) -{ - int aot = ac->oc[1].m4ac.object_type; - if (aot != AOT_ER_AAC_ELD) { - if (get_bits1(gb)) { - av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n"); - return AVERROR_INVALIDDATA; - } - ics->window_sequence[1] = ics->window_sequence[0]; - ics->window_sequence[0] = get_bits(gb, 2); - if (aot == AOT_ER_AAC_LD && - ics->window_sequence[0] != ONLY_LONG_SEQUENCE) { - av_log(ac->avctx, AV_LOG_ERROR, - "AAC LD is only defined for ONLY_LONG_SEQUENCE but " - "window sequence %d found.\n", ics->window_sequence[0]); - ics->window_sequence[0] = ONLY_LONG_SEQUENCE; - return AVERROR_INVALIDDATA; - } - ics->use_kb_window[1] = ics->use_kb_window[0]; - ics->use_kb_window[0] = get_bits1(gb); - } - ics->num_window_groups = 1; - ics->group_len[0] = 1; - if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - int i; - ics->max_sfb = get_bits(gb, 4); - for (i = 0; i < 7; i++) { - if (get_bits1(gb)) { - ics->group_len[ics->num_window_groups - 1]++; - } else { - ics->num_window_groups++; - ics->group_len[ics->num_window_groups - 1] = 1; - } - } - ics->num_windows = 8; - ics->swb_offset = ff_swb_offset_128[ac->oc[1].m4ac.sampling_index]; - ics->num_swb = ff_aac_num_swb_128[ac->oc[1].m4ac.sampling_index]; - ics->tns_max_bands = ff_tns_max_bands_128[ac->oc[1].m4ac.sampling_index]; - ics->predictor_present = 0; - } else { - ics->max_sfb = get_bits(gb, 6); - ics->num_windows = 1; - if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) { - ics->swb_offset = ff_swb_offset_512[ac->oc[1].m4ac.sampling_index]; - ics->num_swb = ff_aac_num_swb_512[ac->oc[1].m4ac.sampling_index]; - ics->tns_max_bands = ff_tns_max_bands_512[ac->oc[1].m4ac.sampling_index]; - if (!ics->num_swb || !ics->swb_offset) - return AVERROR_BUG; - } else { - ics->swb_offset = ff_swb_offset_1024[ac->oc[1].m4ac.sampling_index]; - ics->num_swb = ff_aac_num_swb_1024[ac->oc[1].m4ac.sampling_index]; - ics->tns_max_bands = ff_tns_max_bands_1024[ac->oc[1].m4ac.sampling_index]; - } - if (aot != AOT_ER_AAC_ELD) { - ics->predictor_present = get_bits1(gb); - ics->predictor_reset_group = 0; - } - if (ics->predictor_present) { - if (aot == AOT_AAC_MAIN) { - if (decode_prediction(ac, ics, gb)) { - goto fail; - } - } else if (aot == AOT_AAC_LC || - aot == AOT_ER_AAC_LC) { - av_log(ac->avctx, AV_LOG_ERROR, - "Prediction is not allowed in AAC-LC.\n"); - goto fail; - } else { - if (aot == AOT_ER_AAC_LD) { - av_log(ac->avctx, AV_LOG_ERROR, - "LTP in ER AAC LD not yet implemented.\n"); - return AVERROR_PATCHWELCOME; - } - if ((ics->ltp.present = get_bits(gb, 1))) - decode_ltp(&ics->ltp, gb, ics->max_sfb); - } - } - } - - if (ics->max_sfb > ics->num_swb) { - av_log(ac->avctx, AV_LOG_ERROR, - "Number of scalefactor bands in group (%d) " - "exceeds limit (%d).\n", - ics->max_sfb, ics->num_swb); - goto fail; - } - - return 0; -fail: - ics->max_sfb = 0; - return AVERROR_INVALIDDATA; -} - -/** - * Decode band types (section_data payload); reference: table 4.46. - * - * @param band_type array of the used band type - * @param band_type_run_end array of the last scalefactor band of a band type run - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_band_types(AACContext *ac, enum BandType band_type[120], - int band_type_run_end[120], GetBitContext *gb, - IndividualChannelStream *ics) -{ - int g, idx = 0; - const int bits = (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) ? 3 : 5; - for (g = 0; g < ics->num_window_groups; g++) { - int k = 0; - while (k < ics->max_sfb) { - uint8_t sect_end = k; - int sect_len_incr; - int sect_band_type = get_bits(gb, 4); - if (sect_band_type == 12) { - av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n"); - return AVERROR_INVALIDDATA; - } - do { - sect_len_incr = get_bits(gb, bits); - sect_end += sect_len_incr; - if (get_bits_left(gb) < 0) { - av_log(ac->avctx, AV_LOG_ERROR, "decode_band_types: "overread_err); - return AVERROR_INVALIDDATA; - } - if (sect_end > ics->max_sfb) { - av_log(ac->avctx, AV_LOG_ERROR, - "Number of bands (%d) exceeds limit (%d).\n", - sect_end, ics->max_sfb); - return AVERROR_INVALIDDATA; - } - } while (sect_len_incr == (1 << bits) - 1); - for (; k < sect_end; k++) { - band_type [idx] = sect_band_type; - band_type_run_end[idx++] = sect_end; - } - } - } - return 0; -} - -/** - * Decode scalefactors; reference: table 4.47. - * - * @param global_gain first scalefactor value as scalefactors are differentially coded - * @param band_type array of the used band type - * @param band_type_run_end array of the last scalefactor band of a band type run - * @param sf array of scalefactors or intensity stereo positions - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, - unsigned int global_gain, - IndividualChannelStream *ics, - enum BandType band_type[120], - int band_type_run_end[120]) -{ - int g, i, idx = 0; - int offset[3] = { global_gain, global_gain - 90, 0 }; - int clipped_offset; - int noise_flag = 1; - for (g = 0; g < ics->num_window_groups; g++) { - for (i = 0; i < ics->max_sfb;) { - int run_end = band_type_run_end[idx]; - if (band_type[idx] == ZERO_BT) { - for (; i < run_end; i++, idx++) - sf[idx] = 0.0; - } else if ((band_type[idx] == INTENSITY_BT) || - (band_type[idx] == INTENSITY_BT2)) { - for (; i < run_end; i++, idx++) { - offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; - clipped_offset = av_clip(offset[2], -155, 100); - if (offset[2] != clipped_offset) { - avpriv_request_sample(ac->avctx, - "If you heard an audible artifact, there may be a bug in the decoder. " - "Clipped intensity stereo position (%d -> %d)", - offset[2], clipped_offset); - } - sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + POW_SF2_ZERO]; - } - } else if (band_type[idx] == NOISE_BT) { - for (; i < run_end; i++, idx++) { - if (noise_flag-- > 0) - offset[1] += get_bits(gb, 9) - 256; - else - offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; - clipped_offset = av_clip(offset[1], -100, 155); - if (offset[1] != clipped_offset) { - avpriv_request_sample(ac->avctx, - "If you heard an audible artifact, there may be a bug in the decoder. " - "Clipped noise gain (%d -> %d)", - offset[1], clipped_offset); - } - sf[idx] = -ff_aac_pow2sf_tab[clipped_offset + POW_SF2_ZERO]; - } - } else { - for (; i < run_end; i++, idx++) { - offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; - if (offset[0] > 255U) { - av_log(ac->avctx, AV_LOG_ERROR, - "Scalefactor (%d) out of range.\n", offset[0]); - return AVERROR_INVALIDDATA; - } - sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO]; - } - } - } - } - return 0; -} - -/** - * Decode pulse data; reference: table 4.7. - */ -static int decode_pulses(Pulse *pulse, GetBitContext *gb, - const uint16_t *swb_offset, int num_swb) -{ - int i, pulse_swb; - pulse->num_pulse = get_bits(gb, 2) + 1; - pulse_swb = get_bits(gb, 6); - if (pulse_swb >= num_swb) - return -1; - pulse->pos[0] = swb_offset[pulse_swb]; - pulse->pos[0] += get_bits(gb, 5); - if (pulse->pos[0] >= swb_offset[num_swb]) - return -1; - pulse->amp[0] = get_bits(gb, 4); - for (i = 1; i < pulse->num_pulse; i++) { - pulse->pos[i] = get_bits(gb, 5) + pulse->pos[i - 1]; - if (pulse->pos[i] >= swb_offset[num_swb]) - return -1; - pulse->amp[i] = get_bits(gb, 4); - } - return 0; -} - -/** - * Decode Temporal Noise Shaping data; reference: table 4.48. - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns, - GetBitContext *gb, const IndividualChannelStream *ics) -{ - int w, filt, i, coef_len, coef_res, coef_compress; - const int is8 = ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE; - const int tns_max_order = is8 ? 7 : ac->oc[1].m4ac.object_type == AOT_AAC_MAIN ? 20 : 12; - for (w = 0; w < ics->num_windows; w++) { - if ((tns->n_filt[w] = get_bits(gb, 2 - is8))) { - coef_res = get_bits1(gb); - - for (filt = 0; filt < tns->n_filt[w]; filt++) { - int tmp2_idx; - tns->length[w][filt] = get_bits(gb, 6 - 2 * is8); - - if ((tns->order[w][filt] = get_bits(gb, 5 - 2 * is8)) > tns_max_order) { - av_log(ac->avctx, AV_LOG_ERROR, - "TNS filter order %d is greater than maximum %d.\n", - tns->order[w][filt], tns_max_order); - tns->order[w][filt] = 0; - return AVERROR_INVALIDDATA; - } - if (tns->order[w][filt]) { - tns->direction[w][filt] = get_bits1(gb); - coef_compress = get_bits1(gb); - coef_len = coef_res + 3 - coef_compress; - tmp2_idx = 2 * coef_compress + coef_res; - - for (i = 0; i < tns->order[w][filt]; i++) - tns->coef[w][filt][i] = tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)]; - } - } - } - } - return 0; -} - -/** - * Decode Mid/Side data; reference: table 4.54. - * - * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s; - * [1] mask is decoded from bitstream; [2] mask is all 1s; - * [3] reserved for scalable AAC - */ -static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb, - int ms_present) -{ - int idx; - if (ms_present == 1) { - for (idx = 0; - idx < cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb; - idx++) - cpe->ms_mask[idx] = get_bits1(gb); - } else if (ms_present == 2) { - memset(cpe->ms_mask, 1, sizeof(cpe->ms_mask[0]) * cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb); - } -} - -#ifndef VMUL2 -static inline float *VMUL2(float *dst, const float *v, unsigned idx, - const float *scale) -{ - float s = *scale; - *dst++ = v[idx & 15] * s; - *dst++ = v[idx>>4 & 15] * s; - return dst; -} -#endif - -#ifndef VMUL4 -static inline float *VMUL4(float *dst, const float *v, unsigned idx, - const float *scale) -{ - float s = *scale; - *dst++ = v[idx & 3] * s; - *dst++ = v[idx>>2 & 3] * s; - *dst++ = v[idx>>4 & 3] * s; - *dst++ = v[idx>>6 & 3] * s; - return dst; -} -#endif - -#ifndef VMUL2S -static inline float *VMUL2S(float *dst, const float *v, unsigned idx, - unsigned sign, const float *scale) -{ - union av_intfloat32 s0, s1; + union av_intfloat32 s0, s1; s0.f = s1.f = *scale; s0.i ^= sign >> 1 << 31; @@ -1543,1067 +118,84 @@ static inline float *VMUL2S(float *dst, const float *v, unsigned idx, #ifndef VMUL4S static inline float *VMUL4S(float *dst, const float *v, unsigned idx, - unsigned sign, const float *scale) -{ - unsigned nz = idx >> 12; - union av_intfloat32 s = { .f = *scale }; - union av_intfloat32 t; - - t.i = s.i ^ (sign & 1U<<31); - *dst++ = v[idx & 3] * t.f; - - sign <<= nz & 1; nz >>= 1; - t.i = s.i ^ (sign & 1U<<31); - *dst++ = v[idx>>2 & 3] * t.f; - - sign <<= nz & 1; nz >>= 1; - t.i = s.i ^ (sign & 1U<<31); - *dst++ = v[idx>>4 & 3] * t.f; - - sign <<= nz & 1; - t.i = s.i ^ (sign & 1U<<31); - *dst++ = v[idx>>6 & 3] * t.f; - - return dst; -} -#endif - -/** - * Decode spectral data; reference: table 4.50. - * Dequantize and scale spectral data; reference: 4.6.3.3. - * - * @param coef array of dequantized, scaled spectral data - * @param sf array of scalefactors or intensity stereo positions - * @param pulse_present set if pulses are present - * @param pulse pointer to pulse data struct - * @param band_type array of the used band type - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], - GetBitContext *gb, const float sf[120], - int pulse_present, const Pulse *pulse, - const IndividualChannelStream *ics, - enum BandType band_type[120]) -{ - int i, k, g, idx = 0; - const int c = 1024 / ics->num_windows; - const uint16_t *offsets = ics->swb_offset; - float *coef_base = coef; - - for (g = 0; g < ics->num_windows; g++) - memset(coef + g * 128 + offsets[ics->max_sfb], 0, - sizeof(float) * (c - offsets[ics->max_sfb])); - - for (g = 0; g < ics->num_window_groups; g++) { - unsigned g_len = ics->group_len[g]; - - for (i = 0; i < ics->max_sfb; i++, idx++) { - const unsigned cbt_m1 = band_type[idx] - 1; - float *cfo = coef + offsets[i]; - int off_len = offsets[i + 1] - offsets[i]; - int group; - - if (cbt_m1 >= INTENSITY_BT2 - 1) { - for (group = 0; group < g_len; group++, cfo+=128) { - memset(cfo, 0, off_len * sizeof(float)); - } - } else if (cbt_m1 == NOISE_BT - 1) { - for (group = 0; group < g_len; group++, cfo+=128) { - float scale; - float band_energy; - - for (k = 0; k < off_len; k++) { - ac->random_state = lcg_random(ac->random_state); - cfo[k] = ac->random_state; - } - - band_energy = ac->fdsp.scalarproduct_float(cfo, cfo, off_len); - scale = sf[idx] / sqrtf(band_energy); - ac->fdsp.vector_fmul_scalar(cfo, cfo, scale, off_len); - } - } else { - const float *vq = ff_aac_codebook_vector_vals[cbt_m1]; - const uint16_t *cb_vector_idx = ff_aac_codebook_vector_idx[cbt_m1]; - VLC_TYPE (*vlc_tab)[2] = vlc_spectral[cbt_m1].table; - OPEN_READER(re, gb); - - switch (cbt_m1 >> 1) { - case 0: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; - int len = off_len; - - do { - int code; - unsigned cb_idx; - - UPDATE_CACHE(re, gb); - GET_VLC(code, re, gb, vlc_tab, 8, 2); - cb_idx = cb_vector_idx[code]; - cf = VMUL4(cf, vq, cb_idx, sf + idx); - } while (len -= 4); - } - break; - - case 1: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; - int len = off_len; - - do { - int code; - unsigned nnz; - unsigned cb_idx; - uint32_t bits; - - UPDATE_CACHE(re, gb); - GET_VLC(code, re, gb, vlc_tab, 8, 2); - cb_idx = cb_vector_idx[code]; - nnz = cb_idx >> 8 & 15; - bits = nnz ? GET_CACHE(re, gb) : 0; - LAST_SKIP_BITS(re, gb, nnz); - cf = VMUL4S(cf, vq, cb_idx, bits, sf + idx); - } while (len -= 4); - } - break; - - case 2: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; - int len = off_len; - - do { - int code; - unsigned cb_idx; - - UPDATE_CACHE(re, gb); - GET_VLC(code, re, gb, vlc_tab, 8, 2); - cb_idx = cb_vector_idx[code]; - cf = VMUL2(cf, vq, cb_idx, sf + idx); - } while (len -= 2); - } - break; - - case 3: - case 4: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; - int len = off_len; - - do { - int code; - unsigned nnz; - unsigned cb_idx; - unsigned sign; - - UPDATE_CACHE(re, gb); - GET_VLC(code, re, gb, vlc_tab, 8, 2); - cb_idx = cb_vector_idx[code]; - nnz = cb_idx >> 8 & 15; - sign = nnz ? SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12) : 0; - LAST_SKIP_BITS(re, gb, nnz); - cf = VMUL2S(cf, vq, cb_idx, sign, sf + idx); - } while (len -= 2); - } - break; - - default: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; - uint32_t *icf = (uint32_t *) cf; - int len = off_len; - - do { - int code; - unsigned nzt, nnz; - unsigned cb_idx; - uint32_t bits; - int j; - - UPDATE_CACHE(re, gb); - GET_VLC(code, re, gb, vlc_tab, 8, 2); - - if (!code) { - *icf++ = 0; - *icf++ = 0; - continue; - } - - cb_idx = cb_vector_idx[code]; - nnz = cb_idx >> 12; - nzt = cb_idx >> 8; - bits = SHOW_UBITS(re, gb, nnz) << (32-nnz); - LAST_SKIP_BITS(re, gb, nnz); - - for (j = 0; j < 2; j++) { - if (nzt & 1< 8) { - av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n"); - return AVERROR_INVALIDDATA; - } - - SKIP_BITS(re, gb, b + 1); - b += 4; - n = (1 << b) + SHOW_UBITS(re, gb, b); - LAST_SKIP_BITS(re, gb, b); - *icf++ = cbrt_tab[n] | (bits & 1U<<31); - bits <<= 1; - } else { - unsigned v = ((const uint32_t*)vq)[cb_idx & 15]; - *icf++ = (bits & 1U<<31) | v; - bits <<= !!v; - } - cb_idx >>= 4; - } - } while (len -= 2); - - ac->fdsp.vector_fmul_scalar(cfo, cfo, sf[idx], off_len); - } - } - - CLOSE_READER(re, gb); - } - } - coef += g_len << 7; - } - - if (pulse_present) { - idx = 0; - for (i = 0; i < pulse->num_pulse; i++) { - float co = coef_base[ pulse->pos[i] ]; - while (offsets[idx + 1] <= pulse->pos[i]) - idx++; - if (band_type[idx] != NOISE_BT && sf[idx]) { - float ico = -pulse->amp[i]; - if (co) { - co /= sf[idx]; - ico = co / sqrtf(sqrtf(fabsf(co))) + (co > 0 ? -ico : ico); - } - coef_base[ pulse->pos[i] ] = cbrtf(fabsf(ico)) * ico * sf[idx]; - } - } - } - return 0; -} - -static av_always_inline float flt16_round(float pf) -{ - union av_intfloat32 tmp; - tmp.f = pf; - tmp.i = (tmp.i + 0x00008000U) & 0xFFFF0000U; - return tmp.f; -} - -static av_always_inline float flt16_even(float pf) -{ - union av_intfloat32 tmp; - tmp.f = pf; - tmp.i = (tmp.i + 0x00007FFFU + (tmp.i & 0x00010000U >> 16)) & 0xFFFF0000U; - return tmp.f; -} - -static av_always_inline float flt16_trunc(float pf) -{ - union av_intfloat32 pun; - pun.f = pf; - pun.i &= 0xFFFF0000U; - return pun.f; -} - -static av_always_inline void predict(PredictorState *ps, float *coef, - int output_enable) -{ - const float a = 0.953125; // 61.0 / 64 - const float alpha = 0.90625; // 29.0 / 32 - float e0, e1; - float pv; - float k1, k2; - float r0 = ps->r0, r1 = ps->r1; - float cor0 = ps->cor0, cor1 = ps->cor1; - float var0 = ps->var0, var1 = ps->var1; - - k1 = var0 > 1 ? cor0 * flt16_even(a / var0) : 0; - k2 = var1 > 1 ? cor1 * flt16_even(a / var1) : 0; - - pv = flt16_round(k1 * r0 + k2 * r1); - if (output_enable) - *coef += pv; - - e0 = *coef; - e1 = e0 - k1 * r0; - - ps->cor1 = flt16_trunc(alpha * cor1 + r1 * e1); - ps->var1 = flt16_trunc(alpha * var1 + 0.5f * (r1 * r1 + e1 * e1)); - ps->cor0 = flt16_trunc(alpha * cor0 + r0 * e0); - ps->var0 = flt16_trunc(alpha * var0 + 0.5f * (r0 * r0 + e0 * e0)); - - ps->r1 = flt16_trunc(a * (r0 - k1 * e0)); - ps->r0 = flt16_trunc(a * e0); -} - -/** - * Apply AAC-Main style frequency domain prediction. - */ -static void apply_prediction(AACContext *ac, SingleChannelElement *sce) -{ - int sfb, k; - - if (!sce->ics.predictor_initialized) { - reset_all_predictors(sce->predictor_state); - sce->ics.predictor_initialized = 1; - } - - if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { - for (sfb = 0; - sfb < ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]; - sfb++) { - for (k = sce->ics.swb_offset[sfb]; - k < sce->ics.swb_offset[sfb + 1]; - k++) { - predict(&sce->predictor_state[k], &sce->coeffs[k], - sce->ics.predictor_present && - sce->ics.prediction_used[sfb]); - } - } - if (sce->ics.predictor_reset_group) - reset_predictor_group(sce->predictor_state, - sce->ics.predictor_reset_group); - } else - reset_all_predictors(sce->predictor_state); -} - -/** - * Decode an individual_channel_stream payload; reference: table 4.44. - * - * @param common_window Channels have independent [0], or shared [1], Individual Channel Stream information. - * @param scale_flag scalable [1] or non-scalable [0] AAC (Unused until scalable AAC is implemented.) - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_ics(AACContext *ac, SingleChannelElement *sce, - GetBitContext *gb, int common_window, int scale_flag) -{ - Pulse pulse; - TemporalNoiseShaping *tns = &sce->tns; - IndividualChannelStream *ics = &sce->ics; - float *out = sce->coeffs; - int global_gain, eld_syntax, er_syntax, pulse_present = 0; - int ret; - - eld_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; - er_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_LC || - ac->oc[1].m4ac.object_type == AOT_ER_AAC_LTP || - ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD || - ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; - - /* This assignment is to silence a GCC warning about the variable being used - * uninitialized when in fact it always is. - */ - pulse.num_pulse = 0; - - global_gain = get_bits(gb, 8); - - if (!common_window && !scale_flag) { - if (decode_ics_info(ac, ics, gb) < 0) - return AVERROR_INVALIDDATA; - } - - if ((ret = decode_band_types(ac, sce->band_type, - sce->band_type_run_end, gb, ics)) < 0) - return ret; - if ((ret = decode_scalefactors(ac, sce->sf, gb, global_gain, ics, - sce->band_type, sce->band_type_run_end)) < 0) - return ret; - - pulse_present = 0; - if (!scale_flag) { - if (!eld_syntax && (pulse_present = get_bits1(gb))) { - if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - av_log(ac->avctx, AV_LOG_ERROR, - "Pulse tool not allowed in eight short sequence.\n"); - return AVERROR_INVALIDDATA; - } - if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) { - av_log(ac->avctx, AV_LOG_ERROR, - "Pulse data corrupt or invalid.\n"); - return AVERROR_INVALIDDATA; - } - } - tns->present = get_bits1(gb); - if (tns->present && !er_syntax) - if (decode_tns(ac, tns, gb, ics) < 0) - return AVERROR_INVALIDDATA; - if (!eld_syntax && get_bits1(gb)) { - avpriv_request_sample(ac->avctx, "SSR"); - return AVERROR_PATCHWELCOME; - } - // I see no textual basis in the spec for this occurring after SSR gain - // control, but this is what both reference and real implmentations do - if (tns->present && er_syntax) - if (decode_tns(ac, tns, gb, ics) < 0) - return AVERROR_INVALIDDATA; - } - - if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present, - &pulse, ics, sce->band_type) < 0) - return AVERROR_INVALIDDATA; - - if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN && !common_window) - apply_prediction(ac, sce); - - return 0; -} - -/** - * Mid/Side stereo decoding; reference: 4.6.8.1.3. - */ -static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe) -{ - const IndividualChannelStream *ics = &cpe->ch[0].ics; - float *ch0 = cpe->ch[0].coeffs; - float *ch1 = cpe->ch[1].coeffs; - int g, i, group, idx = 0; - const uint16_t *offsets = ics->swb_offset; - for (g = 0; g < ics->num_window_groups; g++) { - for (i = 0; i < ics->max_sfb; i++, idx++) { - if (cpe->ms_mask[idx] && - cpe->ch[0].band_type[idx] < NOISE_BT && - cpe->ch[1].band_type[idx] < NOISE_BT) { - for (group = 0; group < ics->group_len[g]; group++) { - ac->fdsp.butterflies_float(ch0 + group * 128 + offsets[i], - ch1 + group * 128 + offsets[i], - offsets[i+1] - offsets[i]); - } - } - } - ch0 += ics->group_len[g] * 128; - ch1 += ics->group_len[g] * 128; - } -} - -/** - * intensity stereo decoding; reference: 4.6.8.2.3 - * - * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s; - * [1] mask is decoded from bitstream; [2] mask is all 1s; - * [3] reserved for scalable AAC - */ -static void apply_intensity_stereo(AACContext *ac, - ChannelElement *cpe, int ms_present) -{ - const IndividualChannelStream *ics = &cpe->ch[1].ics; - SingleChannelElement *sce1 = &cpe->ch[1]; - float *coef0 = cpe->ch[0].coeffs, *coef1 = cpe->ch[1].coeffs; - const uint16_t *offsets = ics->swb_offset; - int g, group, i, idx = 0; - int c; - float scale; - for (g = 0; g < ics->num_window_groups; g++) { - for (i = 0; i < ics->max_sfb;) { - if (sce1->band_type[idx] == INTENSITY_BT || - sce1->band_type[idx] == INTENSITY_BT2) { - const int bt_run_end = sce1->band_type_run_end[idx]; - for (; i < bt_run_end; i++, idx++) { - c = -1 + 2 * (sce1->band_type[idx] - 14); - if (ms_present) - c *= 1 - 2 * cpe->ms_mask[idx]; - scale = c * sce1->sf[idx]; - for (group = 0; group < ics->group_len[g]; group++) - ac->fdsp.vector_fmul_scalar(coef1 + group * 128 + offsets[i], - coef0 + group * 128 + offsets[i], - scale, - offsets[i + 1] - offsets[i]); - } - } else { - int bt_run_end = sce1->band_type_run_end[idx]; - idx += bt_run_end - i; - i = bt_run_end; - } - } - coef0 += ics->group_len[g] * 128; - coef1 += ics->group_len[g] * 128; - } -} - -/** - * Decode a channel_pair_element; reference: table 4.4. - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe) -{ - int i, ret, common_window, ms_present = 0; - int eld_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; - - common_window = eld_syntax || get_bits1(gb); - if (common_window) { - if (decode_ics_info(ac, &cpe->ch[0].ics, gb)) - return AVERROR_INVALIDDATA; - i = cpe->ch[1].ics.use_kb_window[0]; - cpe->ch[1].ics = cpe->ch[0].ics; - cpe->ch[1].ics.use_kb_window[1] = i; - if (cpe->ch[1].ics.predictor_present && - (ac->oc[1].m4ac.object_type != AOT_AAC_MAIN)) - if ((cpe->ch[1].ics.ltp.present = get_bits(gb, 1))) - decode_ltp(&cpe->ch[1].ics.ltp, gb, cpe->ch[1].ics.max_sfb); - ms_present = get_bits(gb, 2); - if (ms_present == 3) { - av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n"); - return AVERROR_INVALIDDATA; - } else if (ms_present) - decode_mid_side_stereo(cpe, gb, ms_present); - } - if ((ret = decode_ics(ac, &cpe->ch[0], gb, common_window, 0))) - return ret; - if ((ret = decode_ics(ac, &cpe->ch[1], gb, common_window, 0))) - return ret; - - if (common_window) { - if (ms_present) - apply_mid_side_stereo(ac, cpe); - if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN) { - apply_prediction(ac, &cpe->ch[0]); - apply_prediction(ac, &cpe->ch[1]); - } - } - - apply_intensity_stereo(ac, cpe, ms_present); - return 0; -} - -static const float cce_scale[] = { - 1.09050773266525765921, //2^(1/8) - 1.18920711500272106672, //2^(1/4) - M_SQRT2, - 2, -}; - -/** - * Decode coupling_channel_element; reference: table 4.8. - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) -{ - int num_gain = 0; - int c, g, sfb, ret; - int sign; - float scale; - SingleChannelElement *sce = &che->ch[0]; - ChannelCoupling *coup = &che->coup; - - coup->coupling_point = 2 * get_bits1(gb); - coup->num_coupled = get_bits(gb, 3); - for (c = 0; c <= coup->num_coupled; c++) { - num_gain++; - coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE; - coup->id_select[c] = get_bits(gb, 4); - if (coup->type[c] == TYPE_CPE) { - coup->ch_select[c] = get_bits(gb, 2); - if (coup->ch_select[c] == 3) - num_gain++; - } else - coup->ch_select[c] = 2; - } - coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1); - - sign = get_bits(gb, 1); - scale = cce_scale[get_bits(gb, 2)]; - - if ((ret = decode_ics(ac, sce, gb, 0, 0))) - return ret; - - for (c = 0; c < num_gain; c++) { - int idx = 0; - int cge = 1; - int gain = 0; - float gain_cache = 1.0; - if (c) { - cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb); - gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0; - gain_cache = powf(scale, -gain); - } - if (coup->coupling_point == AFTER_IMDCT) { - coup->gain[c][0] = gain_cache; - } else { - for (g = 0; g < sce->ics.num_window_groups; g++) { - for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) { - if (sce->band_type[idx] != ZERO_BT) { - if (!cge) { - int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; - if (t) { - int s = 1; - t = gain += t; - if (sign) { - s -= 2 * (t & 0x1); - t >>= 1; - } - gain_cache = powf(scale, -t) * s; - } - } - coup->gain[c][idx] = gain_cache; - } - } - } - } - } - return 0; -} - -/** - * Parse whether channels are to be excluded from Dynamic Range Compression; reference: table 4.53. - * - * @return Returns number of bytes consumed. - */ -static int decode_drc_channel_exclusions(DynamicRangeControl *che_drc, - GetBitContext *gb) -{ - int i; - int num_excl_chan = 0; - - do { - for (i = 0; i < 7; i++) - che_drc->exclude_mask[num_excl_chan++] = get_bits1(gb); - } while (num_excl_chan < MAX_CHANNELS - 7 && get_bits1(gb)); - - return num_excl_chan / 7; -} - -/** - * Decode dynamic range information; reference: table 4.52. - * - * @return Returns number of bytes consumed. - */ -static int decode_dynamic_range(DynamicRangeControl *che_drc, - GetBitContext *gb) -{ - int n = 1; - int drc_num_bands = 1; - int i; - - /* pce_tag_present? */ - if (get_bits1(gb)) { - che_drc->pce_instance_tag = get_bits(gb, 4); - skip_bits(gb, 4); // tag_reserved_bits - n++; - } - - /* excluded_chns_present? */ - if (get_bits1(gb)) { - n += decode_drc_channel_exclusions(che_drc, gb); - } - - /* drc_bands_present? */ - if (get_bits1(gb)) { - che_drc->band_incr = get_bits(gb, 4); - che_drc->interpolation_scheme = get_bits(gb, 4); - n++; - drc_num_bands += che_drc->band_incr; - for (i = 0; i < drc_num_bands; i++) { - che_drc->band_top[i] = get_bits(gb, 8); - n++; - } - } - - /* prog_ref_level_present? */ - if (get_bits1(gb)) { - che_drc->prog_ref_level = get_bits(gb, 7); - skip_bits1(gb); // prog_ref_level_reserved_bits - n++; - } - - for (i = 0; i < drc_num_bands; i++) { - che_drc->dyn_rng_sgn[i] = get_bits1(gb); - che_drc->dyn_rng_ctl[i] = get_bits(gb, 7); - n++; - } - - return n; -} - -static int decode_fill(AACContext *ac, GetBitContext *gb, int len) { - uint8_t buf[256]; - int i, major, minor; - - if (len < 13+7*8) - goto unknown; - - get_bits(gb, 13); len -= 13; - - for(i=0; i+1=8; i++, len-=8) - buf[i] = get_bits(gb, 8); - - buf[i] = 0; - if (ac->avctx->debug & FF_DEBUG_PICT_INFO) - av_log(ac->avctx, AV_LOG_DEBUG, "FILL:%s\n", buf); - - if (sscanf(buf, "libfaac %d.%d", &major, &minor) == 2){ - ac->avctx->internal->skip_samples = 1024; - } + unsigned sign, const float *scale) +{ + unsigned nz = idx >> 12; + union av_intfloat32 s = { .f = *scale }; + union av_intfloat32 t; -unknown: - skip_bits_long(gb, len); + t.i = s.i ^ (sign & 1U<<31); + *dst++ = v[idx & 3] * t.f; - return 0; -} + sign <<= nz & 1; nz >>= 1; + t.i = s.i ^ (sign & 1U<<31); + *dst++ = v[idx>>2 & 3] * t.f; -/** - * Decode extension data (incomplete); reference: table 4.51. - * - * @param cnt length of TYPE_FIL syntactic element in bytes - * - * @return Returns number of bytes consumed - */ -static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, - ChannelElement *che, enum RawDataBlockType elem_type) -{ - int crc_flag = 0; - int res = cnt; - switch (get_bits(gb, 4)) { // extension type - case EXT_SBR_DATA_CRC: - crc_flag++; - case EXT_SBR_DATA: - if (!che) { - av_log(ac->avctx, AV_LOG_ERROR, "SBR was found before the first channel element.\n"); - return res; - } else if (!ac->oc[1].m4ac.sbr) { - av_log(ac->avctx, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n"); - skip_bits_long(gb, 8 * cnt - 4); - return res; - } else if (ac->oc[1].m4ac.sbr == -1 && ac->oc[1].status == OC_LOCKED) { - av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n"); - skip_bits_long(gb, 8 * cnt - 4); - return res; - } else if (ac->oc[1].m4ac.ps == -1 && ac->oc[1].status < OC_LOCKED && ac->avctx->channels == 1) { - ac->oc[1].m4ac.sbr = 1; - ac->oc[1].m4ac.ps = 1; - ac->avctx->profile = FF_PROFILE_AAC_HE_V2; - output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, - ac->oc[1].status, 1); - } else { - ac->oc[1].m4ac.sbr = 1; - ac->avctx->profile = FF_PROFILE_AAC_HE; - } - res = ff_decode_sbr_extension(ac, &che->sbr, gb, crc_flag, cnt, elem_type); - break; - case EXT_DYNAMIC_RANGE: - res = decode_dynamic_range(&ac->che_drc, gb); - break; - case EXT_FILL: - decode_fill(ac, gb, 8 * cnt - 4); - break; - case EXT_FILL_DATA: - case EXT_DATA_ELEMENT: - default: - skip_bits_long(gb, 8 * cnt - 4); - break; - }; - return res; -} + sign <<= nz & 1; nz >>= 1; + t.i = s.i ^ (sign & 1U<<31); + *dst++ = v[idx>>4 & 3] * t.f; -/** - * Decode Temporal Noise Shaping filter coefficients and apply all-pole filters; reference: 4.6.9.3. - * - * @param decode 1 if tool is used normally, 0 if tool is used in LTP. - * @param coef spectral coefficients - */ -static void apply_tns(float coef[1024], TemporalNoiseShaping *tns, - IndividualChannelStream *ics, int decode) -{ - const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb); - int w, filt, m, i; - int bottom, top, order, start, end, size, inc; - float lpc[TNS_MAX_ORDER]; - float tmp[TNS_MAX_ORDER+1]; - - for (w = 0; w < ics->num_windows; w++) { - bottom = ics->num_swb; - for (filt = 0; filt < tns->n_filt[w]; filt++) { - top = bottom; - bottom = FFMAX(0, top - tns->length[w][filt]); - order = tns->order[w][filt]; - if (order == 0) - continue; - - // tns_decode_coef - compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0); - - start = ics->swb_offset[FFMIN(bottom, mmm)]; - end = ics->swb_offset[FFMIN( top, mmm)]; - if ((size = end - start) <= 0) - continue; - if (tns->direction[w][filt]) { - inc = -1; - start = end - 1; - } else { - inc = 1; - } - start += w * 128; + sign <<= nz & 1; + t.i = s.i ^ (sign & 1U<<31); + *dst++ = v[idx>>6 & 3] * t.f; - if (decode) { - // ar filter - for (m = 0; m < size; m++, start += inc) - for (i = 1; i <= FFMIN(m, order); i++) - coef[start] -= coef[start - i * inc] * lpc[i - 1]; - } else { - // ma filter - for (m = 0; m < size; m++, start += inc) { - tmp[0] = coef[start]; - for (i = 1; i <= FFMIN(m, order); i++) - coef[start] += tmp[i] * lpc[i - 1]; - for (i = order; i > 0; i--) - tmp[i] = tmp[i - 1]; - } - } - } - } + return dst; } +#endif -/** - * Apply windowing and MDCT to obtain the spectral - * coefficient from the predicted sample by LTP. - */ -static void windowing_and_mdct_ltp(AACContext *ac, float *out, - float *in, IndividualChannelStream *ics) +static av_always_inline float flt16_round(float pf) { - const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; - const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; - const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; - const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; - - if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) { - ac->fdsp.vector_fmul(in, in, lwindow_prev, 1024); - } else { - memset(in, 0, 448 * sizeof(float)); - ac->fdsp.vector_fmul(in + 448, in + 448, swindow_prev, 128); - } - if (ics->window_sequence[0] != LONG_START_SEQUENCE) { - ac->fdsp.vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024); - } else { - ac->fdsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); - memset(in + 1024 + 576, 0, 448 * sizeof(float)); - } - ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in); + union av_intfloat32 tmp; + tmp.f = pf; + tmp.i = (tmp.i + 0x00008000U) & 0xFFFF0000U; + return tmp.f; } -/** - * Apply the long term prediction - */ -static void apply_ltp(AACContext *ac, SingleChannelElement *sce) +static av_always_inline float flt16_even(float pf) { - const LongTermPrediction *ltp = &sce->ics.ltp; - const uint16_t *offsets = sce->ics.swb_offset; - int i, sfb; - - if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { - float *predTime = sce->ret; - float *predFreq = ac->buf_mdct; - int16_t num_samples = 2048; - - if (ltp->lag < 1024) - num_samples = ltp->lag + 1024; - for (i = 0; i < num_samples; i++) - predTime[i] = sce->ltp_state[i + 2048 - ltp->lag] * ltp->coef; - memset(&predTime[i], 0, (2048 - i) * sizeof(float)); - - ac->windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics); - - if (sce->tns.present) - ac->apply_tns(predFreq, &sce->tns, &sce->ics, 0); - - for (sfb = 0; sfb < FFMIN(sce->ics.max_sfb, MAX_LTP_LONG_SFB); sfb++) - if (ltp->used[sfb]) - for (i = offsets[sfb]; i < offsets[sfb + 1]; i++) - sce->coeffs[i] += predFreq[i]; - } + union av_intfloat32 tmp; + tmp.f = pf; + tmp.i = (tmp.i + 0x00007FFFU + (tmp.i & 0x00010000U >> 16)) & 0xFFFF0000U; + return tmp.f; } -/** - * Update the LTP buffer for next frame - */ -static void update_ltp(AACContext *ac, SingleChannelElement *sce) +static av_always_inline float flt16_trunc(float pf) { - IndividualChannelStream *ics = &sce->ics; - float *saved = sce->saved; - float *saved_ltp = sce->coeffs; - const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; - const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; - int i; - - if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - memcpy(saved_ltp, saved, 512 * sizeof(float)); - memset(saved_ltp + 576, 0, 448 * sizeof(float)); - ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); - for (i = 0; i < 64; i++) - saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i]; - } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { - memcpy(saved_ltp, ac->buf_mdct + 512, 448 * sizeof(float)); - memset(saved_ltp + 576, 0, 448 * sizeof(float)); - ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); - for (i = 0; i < 64; i++) - saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i]; - } else { // LONG_STOP or ONLY_LONG - ac->fdsp.vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, &lwindow[512], 512); - for (i = 0; i < 512; i++) - saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * lwindow[511 - i]; - } - - memcpy(sce->ltp_state, sce->ltp_state+1024, 1024 * sizeof(*sce->ltp_state)); - memcpy(sce->ltp_state+1024, sce->ret, 1024 * sizeof(*sce->ltp_state)); - memcpy(sce->ltp_state+2048, saved_ltp, 1024 * sizeof(*sce->ltp_state)); + union av_intfloat32 pun; + pun.f = pf; + pun.i &= 0xFFFF0000U; + return pun.f; } -/** - * Conduct IMDCT and windowing. - */ -static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce) +static av_always_inline void predict(PredictorState *ps, float *coef, + int output_enable) { - IndividualChannelStream *ics = &sce->ics; - float *in = sce->coeffs; - float *out = sce->ret; - float *saved = sce->saved; - const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; - const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; - const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; - float *buf = ac->buf_mdct; - float *temp = ac->temp; - int i; - - // imdct - if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - for (i = 0; i < 1024; i += 128) - ac->mdct_small.imdct_half(&ac->mdct_small, buf + i, in + i); - } else - ac->mdct.imdct_half(&ac->mdct, buf, in); - - /* window overlapping - * NOTE: To simplify the overlapping code, all 'meaningless' short to long - * and long to short transitions are considered to be short to short - * transitions. This leaves just two cases (long to long and short to short) - * with a little special sauce for EIGHT_SHORT_SEQUENCE. - */ - if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) && - (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) { - ac->fdsp.vector_fmul_window( out, saved, buf, lwindow_prev, 512); - } else { - memcpy( out, saved, 448 * sizeof(float)); - - if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - ac->fdsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, 64); - ac->fdsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, 64); - ac->fdsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, 64); - ac->fdsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, 64); - ac->fdsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, 64); - memcpy( out + 448 + 4*128, temp, 64 * sizeof(float)); - } else { - ac->fdsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 64); - memcpy( out + 576, buf + 64, 448 * sizeof(float)); - } - } + const float a = 0.953125; // 61.0 / 64 + const float alpha = 0.90625; // 29.0 / 32 + float e0, e1; + float pv; + float k1, k2; + float r0 = ps->r0, r1 = ps->r1; + float cor0 = ps->cor0, cor1 = ps->cor1; + float var0 = ps->var0, var1 = ps->var1; - // buffer update - if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - memcpy( saved, temp + 64, 64 * sizeof(float)); - ac->fdsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 64); - ac->fdsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 64); - ac->fdsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 64); - memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float)); - } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { - memcpy( saved, buf + 512, 448 * sizeof(float)); - memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float)); - } else { // LONG_STOP or ONLY_LONG - memcpy( saved, buf + 512, 512 * sizeof(float)); - } -} + k1 = var0 > 1 ? cor0 * flt16_even(a / var0) : 0; + k2 = var1 > 1 ? cor1 * flt16_even(a / var1) : 0; -static void imdct_and_windowing_ld(AACContext *ac, SingleChannelElement *sce) -{ - IndividualChannelStream *ics = &sce->ics; - float *in = sce->coeffs; - float *out = sce->ret; - float *saved = sce->saved; - float *buf = ac->buf_mdct; - - // imdct - ac->mdct.imdct_half(&ac->mdct_ld, buf, in); - - // window overlapping - if (ics->use_kb_window[1]) { - // AAC LD uses a low overlap sine window instead of a KBD window - memcpy(out, saved, 192 * sizeof(float)); - ac->fdsp.vector_fmul_window(out + 192, saved + 192, buf, ff_sine_128, 64); - memcpy( out + 320, buf + 64, 192 * sizeof(float)); - } else { - ac->fdsp.vector_fmul_window(out, saved, buf, ff_sine_512, 256); - } + pv = flt16_round(k1 * r0 + k2 * r1); + if (output_enable) + *coef += pv; - // buffer update - memcpy(saved, buf + 256, 256 * sizeof(float)); -} + e0 = *coef; + e1 = e0 - k1 * r0; -static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce) -{ - float *in = sce->coeffs; - float *out = sce->ret; - float *saved = sce->saved; - const float *const window = ff_aac_eld_window; - float *buf = ac->buf_mdct; - int i; - const int n = 512; - const int n2 = n >> 1; - const int n4 = n >> 2; - - // Inverse transform, mapped to the conventional IMDCT by - // Chivukula, R.K.; Reznik, Y.A.; Devarajan, V., - // "Efficient algorithms for MPEG-4 AAC-ELD, AAC-LD and AAC-LC filterbanks," - // International Conference on Audio, Language and Image Processing, ICALIP 2008. - // URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4590245&isnumber=4589950 - for (i = 0; i < n2; i+=2) { - float temp; - temp = in[i ]; in[i ] = -in[n - 1 - i]; in[n - 1 - i] = temp; - temp = -in[i + 1]; in[i + 1] = in[n - 2 - i]; in[n - 2 - i] = temp; - } - ac->mdct.imdct_half(&ac->mdct_ld, buf, in); - for (i = 0; i < n; i+=2) { - buf[i] = -buf[i]; - } - // Like with the regular IMDCT at this point we still have the middle half - // of a transform but with even symmetry on the left and odd symmetry on - // the right - - // window overlapping - // The spec says to use samples [0..511] but the reference decoder uses - // samples [128..639]. - for (i = n4; i < n2; i ++) { - out[i - n4] = buf[n2 - 1 - i] * window[i - n4] + - saved[ i + n2] * window[i + n - n4] + - -saved[ n + n2 - 1 - i] * window[i + 2*n - n4] + - -saved[2*n + n2 + i] * window[i + 3*n - n4]; - } - for (i = 0; i < n2; i ++) { - out[n4 + i] = buf[i] * window[i + n2 - n4] + - -saved[ n - 1 - i] * window[i + n2 + n - n4] + - -saved[ n + i] * window[i + n2 + 2*n - n4] + - saved[2*n + n - 1 - i] * window[i + n2 + 3*n - n4]; - } - for (i = 0; i < n4; i ++) { - out[n2 + n4 + i] = buf[ i + n2] * window[i + n - n4] + - -saved[ n2 - 1 - i] * window[i + 2*n - n4] + - -saved[ n + n2 + i] * window[i + 3*n - n4]; - } + ps->cor1 = flt16_trunc(alpha * cor1 + r1 * e1); + ps->var1 = flt16_trunc(alpha * var1 + 0.5f * (r1 * r1 + e1 * e1)); + ps->cor0 = flt16_trunc(alpha * cor0 + r0 * e0); + ps->var0 = flt16_trunc(alpha * var0 + 0.5f * (r0 * r0 + e0 * e0)); - // buffer update - memmove(saved + n, saved, 2 * n * sizeof(float)); - memcpy( saved, buf, n * sizeof(float)); + ps->r1 = flt16_trunc(a * (r0 - k1 * e0)); + ps->r0 = flt16_trunc(a * e0); } /** @@ -2661,479 +253,7 @@ static void apply_independent_coupling(AACContext *ac, dest[i] += gain * src[i]; } -/** - * channel coupling transformation interface - * - * @param apply_coupling_method pointer to (in)dependent coupling function - */ -static void apply_channel_coupling(AACContext *ac, ChannelElement *cc, - enum RawDataBlockType type, int elem_id, - enum CouplingPoint coupling_point, - void (*apply_coupling_method)(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)) -{ - int i, c; - - for (i = 0; i < MAX_ELEM_ID; i++) { - ChannelElement *cce = ac->che[TYPE_CCE][i]; - int index = 0; - - if (cce && cce->coup.coupling_point == coupling_point) { - ChannelCoupling *coup = &cce->coup; - - for (c = 0; c <= coup->num_coupled; c++) { - if (coup->type[c] == type && coup->id_select[c] == elem_id) { - if (coup->ch_select[c] != 1) { - apply_coupling_method(ac, &cc->ch[0], cce, index); - if (coup->ch_select[c] != 0) - index++; - } - if (coup->ch_select[c] != 2) - apply_coupling_method(ac, &cc->ch[1], cce, index++); - } else - index += 1 + (coup->ch_select[c] == 3); - } - } - } -} - -/** - * Convert spectral data to float samples, applying all supported tools as appropriate. - */ -static void spectral_to_sample(AACContext *ac) -{ - int i, type; - void (*imdct_and_window)(AACContext *ac, SingleChannelElement *sce); - switch (ac->oc[1].m4ac.object_type) { - case AOT_ER_AAC_LD: - imdct_and_window = imdct_and_windowing_ld; - break; - case AOT_ER_AAC_ELD: - imdct_and_window = imdct_and_windowing_eld; - break; - default: - imdct_and_window = ac->imdct_and_windowing; - } - for (type = 3; type >= 0; type--) { - for (i = 0; i < MAX_ELEM_ID; i++) { - ChannelElement *che = ac->che[type][i]; - if (che) { - if (type <= TYPE_CPE) - apply_channel_coupling(ac, che, type, i, BEFORE_TNS, apply_dependent_coupling); - if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) { - if (che->ch[0].ics.predictor_present) { - if (che->ch[0].ics.ltp.present) - ac->apply_ltp(ac, &che->ch[0]); - if (che->ch[1].ics.ltp.present && type == TYPE_CPE) - ac->apply_ltp(ac, &che->ch[1]); - } - } - if (che->ch[0].tns.present) - ac->apply_tns(che->ch[0].coeffs, &che->ch[0].tns, &che->ch[0].ics, 1); - if (che->ch[1].tns.present) - ac->apply_tns(che->ch[1].coeffs, &che->ch[1].tns, &che->ch[1].ics, 1); - if (type <= TYPE_CPE) - apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling); - if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) { - imdct_and_window(ac, &che->ch[0]); - if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) - ac->update_ltp(ac, &che->ch[0]); - if (type == TYPE_CPE) { - imdct_and_window(ac, &che->ch[1]); - if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) - ac->update_ltp(ac, &che->ch[1]); - } - if (ac->oc[1].m4ac.sbr > 0) { - ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret); - } - } - if (type <= TYPE_CCE) - apply_channel_coupling(ac, che, type, i, AFTER_IMDCT, apply_independent_coupling); - } - } - } -} - -static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) -{ - int size; - AACADTSHeaderInfo hdr_info; - uint8_t layout_map[MAX_ELEM_ID*4][3]; - int layout_map_tags, ret; - - size = avpriv_aac_parse_header(gb, &hdr_info); - if (size > 0) { - if (!ac->warned_num_aac_frames && hdr_info.num_aac_frames != 1) { - // This is 2 for "VLB " audio in NSV files. - // See samples/nsv/vlb_audio. - avpriv_report_missing_feature(ac->avctx, - "More than one AAC RDB per ADTS frame"); - ac->warned_num_aac_frames = 1; - } - push_output_configuration(ac); - if (hdr_info.chan_config) { - ac->oc[1].m4ac.chan_config = hdr_info.chan_config; - if ((ret = set_default_channel_config(ac->avctx, - layout_map, - &layout_map_tags, - hdr_info.chan_config)) < 0) - return ret; - if ((ret = output_configure(ac, layout_map, layout_map_tags, - FFMAX(ac->oc[1].status, - OC_TRIAL_FRAME), 0)) < 0) - return ret; - } else { - ac->oc[1].m4ac.chan_config = 0; - /** - * dual mono frames in Japanese DTV can have chan_config 0 - * WITHOUT specifying PCE. - * thus, set dual mono as default. - */ - if (ac->dmono_mode && ac->oc[0].status == OC_NONE) { - layout_map_tags = 2; - layout_map[0][0] = layout_map[1][0] = TYPE_SCE; - layout_map[0][2] = layout_map[1][2] = AAC_CHANNEL_FRONT; - layout_map[0][1] = 0; - layout_map[1][1] = 1; - if (output_configure(ac, layout_map, layout_map_tags, - OC_TRIAL_FRAME, 0)) - return -7; - } - } - ac->oc[1].m4ac.sample_rate = hdr_info.sample_rate; - ac->oc[1].m4ac.sampling_index = hdr_info.sampling_index; - ac->oc[1].m4ac.object_type = hdr_info.object_type; - if (ac->oc[0].status != OC_LOCKED || - ac->oc[0].m4ac.chan_config != hdr_info.chan_config || - ac->oc[0].m4ac.sample_rate != hdr_info.sample_rate) { - ac->oc[1].m4ac.sbr = -1; - ac->oc[1].m4ac.ps = -1; - } - if (!hdr_info.crc_absent) - skip_bits(gb, 16); - } - return size; -} - -static int aac_decode_er_frame(AVCodecContext *avctx, void *data, - int *got_frame_ptr, GetBitContext *gb) -{ - AACContext *ac = avctx->priv_data; - ChannelElement *che; - int err, i; - int samples = 1024; - int chan_config = ac->oc[1].m4ac.chan_config; - int aot = ac->oc[1].m4ac.object_type; - - if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) - samples >>= 1; - - ac->frame = data; - - if ((err = frame_configure_elements(avctx)) < 0) - return err; - - // The FF_PROFILE_AAC_* defines are all object_type - 1 - // This may lead to an undefined profile being signaled - ac->avctx->profile = ac->oc[1].m4ac.object_type - 1; - - ac->tags_mapped = 0; - - if (chan_config < 0 || chan_config >= 8) { - avpriv_request_sample(avctx, "Unknown ER channel configuration %d", - ac->oc[1].m4ac.chan_config); - return AVERROR_INVALIDDATA; - } - for (i = 0; i < tags_per_config[chan_config]; i++) { - const int elem_type = aac_channel_layout_map[chan_config-1][i][0]; - const int elem_id = aac_channel_layout_map[chan_config-1][i][1]; - if (!(che=get_che(ac, elem_type, elem_id))) { - av_log(ac->avctx, AV_LOG_ERROR, - "channel element %d.%d is not allocated\n", - elem_type, elem_id); - return AVERROR_INVALIDDATA; - } - if (aot != AOT_ER_AAC_ELD) - skip_bits(gb, 4); - switch (elem_type) { - case TYPE_SCE: - err = decode_ics(ac, &che->ch[0], gb, 0, 0); - break; - case TYPE_CPE: - err = decode_cpe(ac, gb, che); - break; - case TYPE_LFE: - err = decode_ics(ac, &che->ch[0], gb, 0, 0); - break; - } - if (err < 0) - return err; - } - - spectral_to_sample(ac); - - ac->frame->nb_samples = samples; - ac->frame->sample_rate = avctx->sample_rate; - *got_frame_ptr = 1; - - skip_bits_long(gb, get_bits_left(gb)); - return 0; -} - -static int aac_decode_frame_int(AVCodecContext *avctx, void *data, - int *got_frame_ptr, GetBitContext *gb, AVPacket *avpkt) -{ - AACContext *ac = avctx->priv_data; - ChannelElement *che = NULL, *che_prev = NULL; - enum RawDataBlockType elem_type, elem_type_prev = TYPE_END; - int err, elem_id; - int samples = 0, multiplier, audio_found = 0, pce_found = 0; - int is_dmono, sce_count = 0; - - ac->frame = data; - - if (show_bits(gb, 12) == 0xfff) { - if ((err = parse_adts_frame_header(ac, gb)) < 0) { - av_log(avctx, AV_LOG_ERROR, "Error decoding AAC frame header.\n"); - goto fail; - } - if (ac->oc[1].m4ac.sampling_index > 12) { - av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->oc[1].m4ac.sampling_index); - err = AVERROR_INVALIDDATA; - goto fail; - } - } - - if ((err = frame_configure_elements(avctx)) < 0) - goto fail; - - // The FF_PROFILE_AAC_* defines are all object_type - 1 - // This may lead to an undefined profile being signaled - ac->avctx->profile = ac->oc[1].m4ac.object_type - 1; - - ac->tags_mapped = 0; - // parse - while ((elem_type = get_bits(gb, 3)) != TYPE_END) { - elem_id = get_bits(gb, 4); - - if (elem_type < TYPE_DSE) { - if (!(che=get_che(ac, elem_type, elem_id))) { - av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", - elem_type, elem_id); - err = AVERROR_INVALIDDATA; - goto fail; - } - samples = 1024; - } - - switch (elem_type) { - - case TYPE_SCE: - err = decode_ics(ac, &che->ch[0], gb, 0, 0); - audio_found = 1; - sce_count++; - break; - - case TYPE_CPE: - err = decode_cpe(ac, gb, che); - audio_found = 1; - break; - - case TYPE_CCE: - err = decode_cce(ac, gb, che); - break; - - case TYPE_LFE: - err = decode_ics(ac, &che->ch[0], gb, 0, 0); - audio_found = 1; - break; - - case TYPE_DSE: - err = skip_data_stream_element(ac, gb); - break; - - case TYPE_PCE: { - uint8_t layout_map[MAX_ELEM_ID*4][3]; - int tags; - push_output_configuration(ac); - tags = decode_pce(avctx, &ac->oc[1].m4ac, layout_map, gb); - if (tags < 0) { - err = tags; - break; - } - if (pce_found) { - av_log(avctx, AV_LOG_ERROR, - "Not evaluating a further program_config_element as this construct is dubious at best.\n"); - } else { - err = output_configure(ac, layout_map, tags, OC_TRIAL_PCE, 1); - if (!err) - ac->oc[1].m4ac.chan_config = 0; - pce_found = 1; - } - break; - } - - case TYPE_FIL: - if (elem_id == 15) - elem_id += get_bits(gb, 8) - 1; - if (get_bits_left(gb) < 8 * elem_id) { - av_log(avctx, AV_LOG_ERROR, "TYPE_FIL: "overread_err); - err = AVERROR_INVALIDDATA; - goto fail; - } - while (elem_id > 0) - elem_id -= decode_extension_payload(ac, gb, elem_id, che_prev, elem_type_prev); - err = 0; /* FIXME */ - break; - - default: - err = AVERROR_BUG; /* should not happen, but keeps compiler happy */ - break; - } - - che_prev = che; - elem_type_prev = elem_type; - - if (err) - goto fail; - - if (get_bits_left(gb) < 3) { - av_log(avctx, AV_LOG_ERROR, overread_err); - err = AVERROR_INVALIDDATA; - goto fail; - } - } - - spectral_to_sample(ac); - - multiplier = (ac->oc[1].m4ac.sbr == 1) ? ac->oc[1].m4ac.ext_sample_rate > ac->oc[1].m4ac.sample_rate : 0; - samples <<= multiplier; - - if (ac->oc[1].status && audio_found) { - avctx->sample_rate = ac->oc[1].m4ac.sample_rate << multiplier; - avctx->frame_size = samples; - ac->oc[1].status = OC_LOCKED; - } - - if (multiplier) { - int side_size; - const uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size); - if (side && side_size>=4) - AV_WL32(side, 2*AV_RL32(side)); - } - - *got_frame_ptr = !!samples; - if (samples) { - ac->frame->nb_samples = samples; - ac->frame->sample_rate = avctx->sample_rate; - } else - av_frame_unref(ac->frame); - *got_frame_ptr = !!samples; - - /* for dual-mono audio (SCE + SCE) */ - is_dmono = ac->dmono_mode && sce_count == 2 && - ac->oc[1].channel_layout == (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT); - if (is_dmono) { - if (ac->dmono_mode == 1) - ((AVFrame *)data)->data[1] =((AVFrame *)data)->data[0]; - else if (ac->dmono_mode == 2) - ((AVFrame *)data)->data[0] =((AVFrame *)data)->data[1]; - } - - return 0; -fail: - pop_output_configuration(ac); - return err; -} - -static int aac_decode_frame(AVCodecContext *avctx, void *data, - int *got_frame_ptr, AVPacket *avpkt) -{ - AACContext *ac = avctx->priv_data; - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; - GetBitContext gb; - int buf_consumed; - int buf_offset; - int err; - int new_extradata_size; - const uint8_t *new_extradata = av_packet_get_side_data(avpkt, - AV_PKT_DATA_NEW_EXTRADATA, - &new_extradata_size); - int jp_dualmono_size; - const uint8_t *jp_dualmono = av_packet_get_side_data(avpkt, - AV_PKT_DATA_JP_DUALMONO, - &jp_dualmono_size); - - if (new_extradata && 0) { - av_free(avctx->extradata); - avctx->extradata = av_mallocz(new_extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); - if (!avctx->extradata) - return AVERROR(ENOMEM); - avctx->extradata_size = new_extradata_size; - memcpy(avctx->extradata, new_extradata, new_extradata_size); - push_output_configuration(ac); - if (decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, - avctx->extradata, - avctx->extradata_size*8, 1) < 0) { - pop_output_configuration(ac); - return AVERROR_INVALIDDATA; - } - } - - ac->dmono_mode = 0; - if (jp_dualmono && jp_dualmono_size > 0) - ac->dmono_mode = 1 + *jp_dualmono; - if (ac->force_dmono_mode >= 0) - ac->dmono_mode = ac->force_dmono_mode; - - if (INT_MAX / 8 <= buf_size) - return AVERROR_INVALIDDATA; - - if ((err = init_get_bits(&gb, buf, buf_size * 8)) < 0) - return err; - - switch (ac->oc[1].m4ac.object_type) { - case AOT_ER_AAC_LC: - case AOT_ER_AAC_LTP: - case AOT_ER_AAC_LD: - case AOT_ER_AAC_ELD: - err = aac_decode_er_frame(avctx, data, got_frame_ptr, &gb); - break; - default: - err = aac_decode_frame_int(avctx, data, got_frame_ptr, &gb, avpkt); - } - if (err < 0) - return err; - - buf_consumed = (get_bits_count(&gb) + 7) >> 3; - for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++) - if (buf[buf_offset]) - break; - - return buf_size > buf_offset ? buf_consumed : buf_size; -} - -static av_cold int aac_decode_close(AVCodecContext *avctx) -{ - AACContext *ac = avctx->priv_data; - int i, type; - - for (i = 0; i < MAX_ELEM_ID; i++) { - for (type = 0; type < 4; type++) { - if (ac->che[type][i]) - ff_aac_sbr_ctx_close(&ac->che[type][i]->sbr); - av_freep(&ac->che[type][i]); - } - } - - ff_mdct_end(&ac->mdct); - ff_mdct_end(&ac->mdct_small); - ff_mdct_end(&ac->mdct_ld); - ff_mdct_end(&ac->mdct_ltp); - return 0; -} - +#include "aacdec_template.c" #define LOAS_SYNC_WORD 0x2b7 ///< 11 bits LOAS sync word @@ -3405,41 +525,6 @@ static av_cold int latm_decode_init(AVCodecContext *avctx) return ret; } -static void aacdec_init(AACContext *c) -{ - c->imdct_and_windowing = imdct_and_windowing; - c->apply_ltp = apply_ltp; - c->apply_tns = apply_tns; - c->windowing_and_mdct_ltp = windowing_and_mdct_ltp; - c->update_ltp = update_ltp; - - if(ARCH_MIPS) - ff_aacdec_init_mips(c); -} -/** - * AVOptions for Japanese DTV specific extensions (ADTS only) - */ -#define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM -static const AVOption options[] = { - {"dual_mono_mode", "Select the channel to decode for dual mono", - offsetof(AACContext, force_dmono_mode), AV_OPT_TYPE_INT, {.i64=-1}, -1, 2, - AACDEC_FLAGS, "dual_mono_mode"}, - - {"auto", "autoselection", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, - {"main", "Select Main/Left channel", 0, AV_OPT_TYPE_CONST, {.i64= 1}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, - {"sub" , "Select Sub/Right channel", 0, AV_OPT_TYPE_CONST, {.i64= 2}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, - {"both", "Select both channels", 0, AV_OPT_TYPE_CONST, {.i64= 0}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, - - {NULL}, -}; - -static const AVClass aac_decoder_class = { - .class_name = "AAC decoder", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; - AVCodec ff_aac_decoder = { .name = "aac", .long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"), diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c new file mode 100644 index 0000000..a3613fb --- /dev/null +++ b/libavcodec/aacdec_template.c @@ -0,0 +1,2957 @@ +/* + * AAC decoder + * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org ) + * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com ) + * Copyright (c) 2008-2013 Alex Converse + * + * AAC LATM decoder + * Copyright (c) 2008-2010 Paul Kendall + * Copyright (c) 2010 Janne Grunau + * + * AAC decoder fixed-point implementation + * Copyright (c) 2013 + * MIPS Technologies, Inc., California. + * + * This file is part of FFmpeg. + * + * 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 + */ + +/** + * @file + * AAC decoder + * @author Oded Shimon ( ods15 ods15 dyndns org ) + * @author Maxim Gavrilov ( maxim.gavrilov gmail com ) + * + * AAC decoder fixed-point implementation + * @author Stanislav Ocovaj ( stanislav.ocovaj imgtec com ) + * @author Nedeljko Babic ( nedeljko.babic imgtec com ) + */ + +/* + * supported tools + * + * Support? Name + * N (code in SoC repo) gain control + * Y block switching + * Y window shapes - standard + * N window shapes - Low Delay + * Y filterbank - standard + * N (code in SoC repo) filterbank - Scalable Sample Rate + * Y Temporal Noise Shaping + * Y Long Term Prediction + * Y intensity stereo + * Y channel coupling + * Y frequency domain prediction + * Y Perceptual Noise Substitution + * Y Mid/Side stereo + * N Scalable Inverse AAC Quantization + * N Frequency Selective Switch + * N upsampling filter + * Y quantization & coding - AAC + * N quantization & coding - TwinVQ + * N quantization & coding - BSAC + * N AAC Error Resilience tools + * N Error Resilience payload syntax + * N Error Protection tool + * N CELP + * N Silence Compression + * N HVXC + * N HVXC 4kbits/s VR + * N Structured Audio tools + * N Structured Audio Sample Bank Format + * N MIDI + * N Harmonic and Individual Lines plus Noise + * N Text-To-Speech Interface + * Y Spectral Band Replication + * Y (not in this code) Layer-1 + * Y (not in this code) Layer-2 + * Y (not in this code) Layer-3 + * N SinuSoidal Coding (Transient, Sinusoid, Noise) + * Y Parametric Stereo + * N Direct Stream Transfer + * Y Enhanced AAC Low Delay (ER AAC ELD) + * + * Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication. + * - HE AAC v2 comprises LC AAC with Spectral Band Replication and + Parametric Stereo. + */ + +static VLC vlc_scalefactors; +static VLC vlc_spectral[11]; + +static int output_configure(AACContext *ac, + uint8_t layout_map[MAX_ELEM_ID*4][3], int tags, + enum OCStatus oc_type, int get_new_frame); + +#define overread_err "Input buffer exhausted before END element found\n" + +static int count_channels(uint8_t (*layout)[3], int tags) +{ + int i, sum = 0; + for (i = 0; i < tags; i++) { + int syn_ele = layout[i][0]; + int pos = layout[i][2]; + sum += (1 + (syn_ele == TYPE_CPE)) * + (pos != AAC_CHANNEL_OFF && pos != AAC_CHANNEL_CC); + } + return sum; +} + +/** + * Check for the channel element in the current channel position configuration. + * If it exists, make sure the appropriate element is allocated and map the + * channel order to match the internal FFmpeg channel layout. + * + * @param che_pos current channel position configuration + * @param type channel element type + * @param id channel element id + * @param channels count of the number of channels in the configuration + * + * @return Returns error status. 0 - OK, !0 - error + */ +static av_cold int che_configure(AACContext *ac, + enum ChannelPosition che_pos, + int type, int id, int *channels) +{ + if (*channels >= MAX_CHANNELS) + return AVERROR_INVALIDDATA; + if (che_pos) { + if (!ac->che[type][id]) { + if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement)))) + return AVERROR(ENOMEM); + ff_aac_sbr_ctx_init(ac, &ac->che[type][id]->sbr); + } + if (type != TYPE_CCE) { + if (*channels >= MAX_CHANNELS - (type == TYPE_CPE || (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1))) { + av_log(ac->avctx, AV_LOG_ERROR, "Too many channels\n"); + return AVERROR_INVALIDDATA; + } + ac->output_element[(*channels)++] = &ac->che[type][id]->ch[0]; + if (type == TYPE_CPE || + (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1)) { + ac->output_element[(*channels)++] = &ac->che[type][id]->ch[1]; + } + } + } else { + if (ac->che[type][id]) + ff_aac_sbr_ctx_close(&ac->che[type][id]->sbr); + av_freep(&ac->che[type][id]); + } + return 0; +} + +static int frame_configure_elements(AVCodecContext *avctx) +{ + AACContext *ac = avctx->priv_data; + int type, id, ch, ret; + + /* set channel pointers to internal buffers by default */ + for (type = 0; type < 4; type++) { + for (id = 0; id < MAX_ELEM_ID; id++) { + ChannelElement *che = ac->che[type][id]; + if (che) { + che->ch[0].ret = che->ch[0].ret_buf; + che->ch[1].ret = che->ch[1].ret_buf; + } + } + } + + /* get output buffer */ + av_frame_unref(ac->frame); + if (!avctx->channels) + return 1; + + ac->frame->nb_samples = 2048; + if ((ret = ff_get_buffer(avctx, ac->frame, 0)) < 0) + return ret; + + /* map output channel pointers to AVFrame data */ + for (ch = 0; ch < avctx->channels; ch++) { + if (ac->output_element[ch]) + ac->output_element[ch]->ret = (float *)ac->frame->extended_data[ch]; + } + + return 0; +} + +struct elem_to_channel { + uint64_t av_position; + uint8_t syn_ele; + uint8_t elem_id; + uint8_t aac_position; +}; + +static int assign_pair(struct elem_to_channel e2c_vec[MAX_ELEM_ID], + uint8_t (*layout_map)[3], int offset, uint64_t left, + uint64_t right, int pos) +{ + if (layout_map[offset][0] == TYPE_CPE) { + e2c_vec[offset] = (struct elem_to_channel) { + .av_position = left | right, + .syn_ele = TYPE_CPE, + .elem_id = layout_map[offset][1], + .aac_position = pos + }; + return 1; + } else { + e2c_vec[offset] = (struct elem_to_channel) { + .av_position = left, + .syn_ele = TYPE_SCE, + .elem_id = layout_map[offset][1], + .aac_position = pos + }; + e2c_vec[offset + 1] = (struct elem_to_channel) { + .av_position = right, + .syn_ele = TYPE_SCE, + .elem_id = layout_map[offset + 1][1], + .aac_position = pos + }; + return 2; + } +} + +static int count_paired_channels(uint8_t (*layout_map)[3], int tags, int pos, + int *current) +{ + int num_pos_channels = 0; + int first_cpe = 0; + int sce_parity = 0; + int i; + for (i = *current; i < tags; i++) { + if (layout_map[i][2] != pos) + break; + if (layout_map[i][0] == TYPE_CPE) { + if (sce_parity) { + if (pos == AAC_CHANNEL_FRONT && !first_cpe) { + sce_parity = 0; + } else { + return -1; + } + } + num_pos_channels += 2; + first_cpe = 1; + } else { + num_pos_channels++; + sce_parity ^= 1; + } + } + if (sce_parity && + ((pos == AAC_CHANNEL_FRONT && first_cpe) || pos == AAC_CHANNEL_SIDE)) + return -1; + *current = i; + return num_pos_channels; +} + +static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags) +{ + int i, n, total_non_cc_elements; + struct elem_to_channel e2c_vec[4 * MAX_ELEM_ID] = { { 0 } }; + int num_front_channels, num_side_channels, num_back_channels; + uint64_t layout; + + if (FF_ARRAY_ELEMS(e2c_vec) < tags) + return 0; + + i = 0; + num_front_channels = + count_paired_channels(layout_map, tags, AAC_CHANNEL_FRONT, &i); + if (num_front_channels < 0) + return 0; + num_side_channels = + count_paired_channels(layout_map, tags, AAC_CHANNEL_SIDE, &i); + if (num_side_channels < 0) + return 0; + num_back_channels = + count_paired_channels(layout_map, tags, AAC_CHANNEL_BACK, &i); + if (num_back_channels < 0) + return 0; + + i = 0; + if (num_front_channels & 1) { + e2c_vec[i] = (struct elem_to_channel) { + .av_position = AV_CH_FRONT_CENTER, + .syn_ele = TYPE_SCE, + .elem_id = layout_map[i][1], + .aac_position = AAC_CHANNEL_FRONT + }; + i++; + num_front_channels--; + } + if (num_front_channels >= 4) { + i += assign_pair(e2c_vec, layout_map, i, + AV_CH_FRONT_LEFT_OF_CENTER, + AV_CH_FRONT_RIGHT_OF_CENTER, + AAC_CHANNEL_FRONT); + num_front_channels -= 2; + } + if (num_front_channels >= 2) { + i += assign_pair(e2c_vec, layout_map, i, + AV_CH_FRONT_LEFT, + AV_CH_FRONT_RIGHT, + AAC_CHANNEL_FRONT); + num_front_channels -= 2; + } + while (num_front_channels >= 2) { + i += assign_pair(e2c_vec, layout_map, i, + UINT64_MAX, + UINT64_MAX, + AAC_CHANNEL_FRONT); + num_front_channels -= 2; + } + + if (num_side_channels >= 2) { + i += assign_pair(e2c_vec, layout_map, i, + AV_CH_SIDE_LEFT, + AV_CH_SIDE_RIGHT, + AAC_CHANNEL_FRONT); + num_side_channels -= 2; + } + while (num_side_channels >= 2) { + i += assign_pair(e2c_vec, layout_map, i, + UINT64_MAX, + UINT64_MAX, + AAC_CHANNEL_SIDE); + num_side_channels -= 2; + } + + while (num_back_channels >= 4) { + i += assign_pair(e2c_vec, layout_map, i, + UINT64_MAX, + UINT64_MAX, + AAC_CHANNEL_BACK); + num_back_channels -= 2; + } + if (num_back_channels >= 2) { + i += assign_pair(e2c_vec, layout_map, i, + AV_CH_BACK_LEFT, + AV_CH_BACK_RIGHT, + AAC_CHANNEL_BACK); + num_back_channels -= 2; + } + if (num_back_channels) { + e2c_vec[i] = (struct elem_to_channel) { + .av_position = AV_CH_BACK_CENTER, + .syn_ele = TYPE_SCE, + .elem_id = layout_map[i][1], + .aac_position = AAC_CHANNEL_BACK + }; + i++; + num_back_channels--; + } + + if (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) { + e2c_vec[i] = (struct elem_to_channel) { + .av_position = AV_CH_LOW_FREQUENCY, + .syn_ele = TYPE_LFE, + .elem_id = layout_map[i][1], + .aac_position = AAC_CHANNEL_LFE + }; + i++; + } + while (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) { + e2c_vec[i] = (struct elem_to_channel) { + .av_position = UINT64_MAX, + .syn_ele = TYPE_LFE, + .elem_id = layout_map[i][1], + .aac_position = AAC_CHANNEL_LFE + }; + i++; + } + + // Must choose a stable sort + total_non_cc_elements = n = i; + do { + int next_n = 0; + for (i = 1; i < n; i++) + if (e2c_vec[i - 1].av_position > e2c_vec[i].av_position) { + FFSWAP(struct elem_to_channel, e2c_vec[i - 1], e2c_vec[i]); + next_n = i; + } + n = next_n; + } while (n > 0); + + layout = 0; + for (i = 0; i < total_non_cc_elements; i++) { + layout_map[i][0] = e2c_vec[i].syn_ele; + layout_map[i][1] = e2c_vec[i].elem_id; + layout_map[i][2] = e2c_vec[i].aac_position; + if (e2c_vec[i].av_position != UINT64_MAX) { + layout |= e2c_vec[i].av_position; + } + } + + return layout; +} + +/** + * Save current output configuration if and only if it has been locked. + */ +static void push_output_configuration(AACContext *ac) { + if (ac->oc[1].status == OC_LOCKED) { + ac->oc[0] = ac->oc[1]; + } + ac->oc[1].status = OC_NONE; +} + +/** + * Restore the previous output configuration if and only if the current + * configuration is unlocked. + */ +static void pop_output_configuration(AACContext *ac) { + if (ac->oc[1].status != OC_LOCKED && ac->oc[0].status != OC_NONE) { + ac->oc[1] = ac->oc[0]; + ac->avctx->channels = ac->oc[1].channels; + ac->avctx->channel_layout = ac->oc[1].channel_layout; + output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, + ac->oc[1].status, 0); + } +} + +/** + * Configure output channel order based on the current program + * configuration element. + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int output_configure(AACContext *ac, + uint8_t layout_map[MAX_ELEM_ID * 4][3], int tags, + enum OCStatus oc_type, int get_new_frame) +{ + AVCodecContext *avctx = ac->avctx; + int i, channels = 0, ret; + uint64_t layout = 0; + + if (ac->oc[1].layout_map != layout_map) { + memcpy(ac->oc[1].layout_map, layout_map, tags * sizeof(layout_map[0])); + ac->oc[1].layout_map_tags = tags; + } + + // Try to sniff a reasonable channel order, otherwise output the + // channels in the order the PCE declared them. + if (avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE) + layout = sniff_channel_order(layout_map, tags); + for (i = 0; i < tags; i++) { + int type = layout_map[i][0]; + int id = layout_map[i][1]; + int position = layout_map[i][2]; + // Allocate or free elements depending on if they are in the + // current program configuration. + ret = che_configure(ac, position, type, id, &channels); + if (ret < 0) + return ret; + } + if (ac->oc[1].m4ac.ps == 1 && channels == 2) { + if (layout == AV_CH_FRONT_CENTER) { + layout = AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT; + } else { + layout = 0; + } + } + + memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0])); + if (layout) avctx->channel_layout = layout; + ac->oc[1].channel_layout = layout; + avctx->channels = ac->oc[1].channels = channels; + ac->oc[1].status = oc_type; + + if (get_new_frame) { + if ((ret = frame_configure_elements(ac->avctx)) < 0) + return ret; + } + + return 0; +} + +static void flush(AVCodecContext *avctx) +{ + AACContext *ac= avctx->priv_data; + int type, i, j; + + for (type = 3; type >= 0; type--) { + for (i = 0; i < MAX_ELEM_ID; i++) { + ChannelElement *che = ac->che[type][i]; + if (che) { + for (j = 0; j <= 1; j++) { + memset(che->ch[j].saved, 0, sizeof(che->ch[j].saved)); + } + } + } + } +} + +/** + * Set up channel positions based on a default channel configuration + * as specified in table 1.17. + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int set_default_channel_config(AVCodecContext *avctx, + uint8_t (*layout_map)[3], + int *tags, + int channel_config) +{ + if (channel_config < 1 || channel_config > 7) { + av_log(avctx, AV_LOG_ERROR, + "invalid default channel configuration (%d)\n", + channel_config); + return AVERROR_INVALIDDATA; + } + *tags = tags_per_config[channel_config]; + memcpy(layout_map, aac_channel_layout_map[channel_config - 1], + *tags * sizeof(*layout_map)); + + /* + * AAC specification has 7.1(wide) as a default layout for 8-channel streams. + * However, at least Nero AAC encoder encodes 7.1 streams using the default + * channel config 7, mapping the side channels of the original audio stream + * to the second AAC_CHANNEL_FRONT pair in the AAC stream. Similarly, e.g. FAAD + * decodes the second AAC_CHANNEL_FRONT pair as side channels, therefore decoding + * the incorrect streams as if they were correct (and as the encoder intended). + * + * As actual intended 7.1(wide) streams are very rare, default to assuming a + * 7.1 layout was intended. + */ + if (channel_config == 7 && avctx->strict_std_compliance < FF_COMPLIANCE_STRICT) { + av_log(avctx, AV_LOG_INFO, "Assuming an incorrectly encoded 7.1 channel layout" + " instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode" + " according to the specification instead.\n", FF_COMPLIANCE_STRICT); + layout_map[2][2] = AAC_CHANNEL_SIDE; + } + + return 0; +} + +static ChannelElement *get_che(AACContext *ac, int type, int elem_id) +{ + /* For PCE based channel configurations map the channels solely based + * on tags. */ + if (!ac->oc[1].m4ac.chan_config) { + return ac->tag_che_map[type][elem_id]; + } + // Allow single CPE stereo files to be signalled with mono configuration. + if (!ac->tags_mapped && type == TYPE_CPE && + ac->oc[1].m4ac.chan_config == 1) { + uint8_t layout_map[MAX_ELEM_ID*4][3]; + int layout_map_tags; + push_output_configuration(ac); + + av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n"); + + if (set_default_channel_config(ac->avctx, layout_map, + &layout_map_tags, 2) < 0) + return NULL; + if (output_configure(ac, layout_map, layout_map_tags, + OC_TRIAL_FRAME, 1) < 0) + return NULL; + + ac->oc[1].m4ac.chan_config = 2; + ac->oc[1].m4ac.ps = 0; + } + // And vice-versa + if (!ac->tags_mapped && type == TYPE_SCE && + ac->oc[1].m4ac.chan_config == 2) { + uint8_t layout_map[MAX_ELEM_ID * 4][3]; + int layout_map_tags; + push_output_configuration(ac); + + av_log(ac->avctx, AV_LOG_DEBUG, "stereo with SCE\n"); + + if (set_default_channel_config(ac->avctx, layout_map, + &layout_map_tags, 1) < 0) + return NULL; + if (output_configure(ac, layout_map, layout_map_tags, + OC_TRIAL_FRAME, 1) < 0) + return NULL; + + ac->oc[1].m4ac.chan_config = 1; + if (ac->oc[1].m4ac.sbr) + ac->oc[1].m4ac.ps = -1; + } + /* For indexed channel configurations map the channels solely based + * on position. */ + switch (ac->oc[1].m4ac.chan_config) { + case 7: + if (ac->tags_mapped == 3 && type == TYPE_CPE) { + ac->tags_mapped++; + return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2]; + } + case 6: + /* Some streams incorrectly code 5.1 audio as + * SCE[0] CPE[0] CPE[1] SCE[1] + * instead of + * SCE[0] CPE[0] CPE[1] LFE[0]. + * If we seem to have encountered such a stream, transfer + * the LFE[0] element to the SCE[1]'s mapping */ + if (ac->tags_mapped == tags_per_config[ac->oc[1].m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) { + ac->tags_mapped++; + return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0]; + } + case 5: + if (ac->tags_mapped == 2 && type == TYPE_CPE) { + ac->tags_mapped++; + return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1]; + } + case 4: + if (ac->tags_mapped == 2 && + ac->oc[1].m4ac.chan_config == 4 && + type == TYPE_SCE) { + ac->tags_mapped++; + return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1]; + } + case 3: + case 2: + if (ac->tags_mapped == (ac->oc[1].m4ac.chan_config != 2) && + type == TYPE_CPE) { + ac->tags_mapped++; + return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0]; + } else if (ac->oc[1].m4ac.chan_config == 2) { + return NULL; + } + case 1: + if (!ac->tags_mapped && type == TYPE_SCE) { + ac->tags_mapped++; + return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][0]; + } + default: + return NULL; + } +} + +/** + * Decode an array of 4 bit element IDs, optionally interleaved with a + * stereo/mono switching bit. + * + * @param type speaker type/position for these channels + */ +static void decode_channel_map(uint8_t layout_map[][3], + enum ChannelPosition type, + GetBitContext *gb, int n) +{ + while (n--) { + enum RawDataBlockType syn_ele; + switch (type) { + case AAC_CHANNEL_FRONT: + case AAC_CHANNEL_BACK: + case AAC_CHANNEL_SIDE: + syn_ele = get_bits1(gb); + break; + case AAC_CHANNEL_CC: + skip_bits1(gb); + syn_ele = TYPE_CCE; + break; + case AAC_CHANNEL_LFE: + syn_ele = TYPE_LFE; + break; + default: + av_assert0(0); + } + layout_map[0][0] = syn_ele; + layout_map[0][1] = get_bits(gb, 4); + layout_map[0][2] = type; + layout_map++; + } +} + +/** + * Decode program configuration element; reference: table 4.2. + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac, + uint8_t (*layout_map)[3], + GetBitContext *gb) +{ + int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc; + int sampling_index; + int comment_len; + int tags; + + skip_bits(gb, 2); // object_type + + sampling_index = get_bits(gb, 4); + if (m4ac->sampling_index != sampling_index) + av_log(avctx, AV_LOG_WARNING, + "Sample rate index in program config element does not " + "match the sample rate index configured by the container.\n"); + + num_front = get_bits(gb, 4); + num_side = get_bits(gb, 4); + num_back = get_bits(gb, 4); + num_lfe = get_bits(gb, 2); + num_assoc_data = get_bits(gb, 3); + num_cc = get_bits(gb, 4); + + if (get_bits1(gb)) + skip_bits(gb, 4); // mono_mixdown_tag + if (get_bits1(gb)) + skip_bits(gb, 4); // stereo_mixdown_tag + + if (get_bits1(gb)) + skip_bits(gb, 3); // mixdown_coeff_index and pseudo_surround + + if (get_bits_left(gb) < 4 * (num_front + num_side + num_back + num_lfe + num_assoc_data + num_cc)) { + av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err); + return -1; + } + decode_channel_map(layout_map , AAC_CHANNEL_FRONT, gb, num_front); + tags = num_front; + decode_channel_map(layout_map + tags, AAC_CHANNEL_SIDE, gb, num_side); + tags += num_side; + decode_channel_map(layout_map + tags, AAC_CHANNEL_BACK, gb, num_back); + tags += num_back; + decode_channel_map(layout_map + tags, AAC_CHANNEL_LFE, gb, num_lfe); + tags += num_lfe; + + skip_bits_long(gb, 4 * num_assoc_data); + + decode_channel_map(layout_map + tags, AAC_CHANNEL_CC, gb, num_cc); + tags += num_cc; + + align_get_bits(gb); + + /* comment field, first byte is length */ + comment_len = get_bits(gb, 8) * 8; + if (get_bits_left(gb) < comment_len) { + av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err); + return AVERROR_INVALIDDATA; + } + skip_bits_long(gb, comment_len); + return tags; +} + +/** + * Decode GA "General Audio" specific configuration; reference: table 4.1. + * + * @param ac pointer to AACContext, may be null + * @param avctx pointer to AVCCodecContext, used for logging + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx, + GetBitContext *gb, + MPEG4AudioConfig *m4ac, + int channel_config) +{ + int extension_flag, ret, ep_config, res_flags; + uint8_t layout_map[MAX_ELEM_ID*4][3]; + int tags = 0; + + if (get_bits1(gb)) { // frameLengthFlag + avpriv_request_sample(avctx, "960/120 MDCT window"); + return AVERROR_PATCHWELCOME; + } + + if (get_bits1(gb)) // dependsOnCoreCoder + skip_bits(gb, 14); // coreCoderDelay + extension_flag = get_bits1(gb); + + if (m4ac->object_type == AOT_AAC_SCALABLE || + m4ac->object_type == AOT_ER_AAC_SCALABLE) + skip_bits(gb, 3); // layerNr + + if (channel_config == 0) { + skip_bits(gb, 4); // element_instance_tag + tags = decode_pce(avctx, m4ac, layout_map, gb); + if (tags < 0) + return tags; + } else { + if ((ret = set_default_channel_config(avctx, layout_map, + &tags, channel_config))) + return ret; + } + + if (count_channels(layout_map, tags) > 1) { + m4ac->ps = 0; + } else if (m4ac->sbr == 1 && m4ac->ps == -1) + m4ac->ps = 1; + + if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) + return ret; + + if (extension_flag) { + switch (m4ac->object_type) { + case AOT_ER_BSAC: + skip_bits(gb, 5); // numOfSubFrame + skip_bits(gb, 11); // layer_length + break; + case AOT_ER_AAC_LC: + case AOT_ER_AAC_LTP: + case AOT_ER_AAC_SCALABLE: + case AOT_ER_AAC_LD: + res_flags = get_bits(gb, 3); + if (res_flags) { + avpriv_report_missing_feature(avctx, + "AAC data resilience (flags %x)", + res_flags); + return AVERROR_PATCHWELCOME; + } + break; + } + skip_bits1(gb); // extensionFlag3 (TBD in version 3) + } + switch (m4ac->object_type) { + case AOT_ER_AAC_LC: + case AOT_ER_AAC_LTP: + case AOT_ER_AAC_SCALABLE: + case AOT_ER_AAC_LD: + ep_config = get_bits(gb, 2); + if (ep_config) { + avpriv_report_missing_feature(avctx, + "epConfig %d", ep_config); + return AVERROR_PATCHWELCOME; + } + } + return 0; +} + +static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx, + GetBitContext *gb, + MPEG4AudioConfig *m4ac, + int channel_config) +{ + int ret, ep_config, res_flags; + uint8_t layout_map[MAX_ELEM_ID*4][3]; + int tags = 0; + const int ELDEXT_TERM = 0; + + m4ac->ps = 0; + m4ac->sbr = 0; + + if (get_bits1(gb)) { // frameLengthFlag + avpriv_request_sample(avctx, "960/120 MDCT window"); + return AVERROR_PATCHWELCOME; + } + + res_flags = get_bits(gb, 3); + if (res_flags) { + avpriv_report_missing_feature(avctx, + "AAC data resilience (flags %x)", + res_flags); + return AVERROR_PATCHWELCOME; + } + + if (get_bits1(gb)) { // ldSbrPresentFlag + avpriv_report_missing_feature(avctx, + "Low Delay SBR"); + return AVERROR_PATCHWELCOME; + } + + while (get_bits(gb, 4) != ELDEXT_TERM) { + int len = get_bits(gb, 4); + if (len == 15) + len += get_bits(gb, 8); + if (len == 15 + 255) + len += get_bits(gb, 16); + if (get_bits_left(gb) < len * 8 + 4) { + av_log(ac->avctx, AV_LOG_ERROR, overread_err); + return AVERROR_INVALIDDATA; + } + skip_bits_long(gb, 8 * len); + } + + if ((ret = set_default_channel_config(avctx, layout_map, + &tags, channel_config))) + return ret; + + if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) + return ret; + + ep_config = get_bits(gb, 2); + if (ep_config) { + avpriv_report_missing_feature(avctx, + "epConfig %d", ep_config); + return AVERROR_PATCHWELCOME; + } + return 0; +} + +/** + * Decode audio specific configuration; reference: table 1.13. + * + * @param ac pointer to AACContext, may be null + * @param avctx pointer to AVCCodecContext, used for logging + * @param m4ac pointer to MPEG4AudioConfig, used for parsing + * @param data pointer to buffer holding an audio specific config + * @param bit_size size of audio specific config or data in bits + * @param sync_extension look for an appended sync extension + * + * @return Returns error status or number of consumed bits. <0 - error + */ +static int decode_audio_specific_config(AACContext *ac, + AVCodecContext *avctx, + MPEG4AudioConfig *m4ac, + const uint8_t *data, int bit_size, + int sync_extension) +{ + GetBitContext gb; + int i, ret; + + av_dlog(avctx, "audio specific config size %d\n", bit_size >> 3); + for (i = 0; i < bit_size >> 3; i++) + av_dlog(avctx, "%02x ", data[i]); + av_dlog(avctx, "\n"); + + if ((ret = init_get_bits(&gb, data, bit_size)) < 0) + return ret; + + if ((i = avpriv_mpeg4audio_get_config(m4ac, data, bit_size, + sync_extension)) < 0) + return AVERROR_INVALIDDATA; + if (m4ac->sampling_index > 12) { + av_log(avctx, AV_LOG_ERROR, + "invalid sampling rate index %d\n", + m4ac->sampling_index); + return AVERROR_INVALIDDATA; + } + if (m4ac->object_type == AOT_ER_AAC_LD && + (m4ac->sampling_index < 3 || m4ac->sampling_index > 7)) { + av_log(avctx, AV_LOG_ERROR, + "invalid low delay sampling rate index %d\n", + m4ac->sampling_index); + return AVERROR_INVALIDDATA; + } + + skip_bits_long(&gb, i); + + switch (m4ac->object_type) { + case AOT_AAC_MAIN: + case AOT_AAC_LC: + case AOT_AAC_LTP: + case AOT_ER_AAC_LC: + case AOT_ER_AAC_LD: + if ((ret = decode_ga_specific_config(ac, avctx, &gb, + m4ac, m4ac->chan_config)) < 0) + return ret; + break; + case AOT_ER_AAC_ELD: + if ((ret = decode_eld_specific_config(ac, avctx, &gb, + m4ac, m4ac->chan_config)) < 0) + return ret; + break; + default: + avpriv_report_missing_feature(avctx, + "Audio object type %s%d", + m4ac->sbr == 1 ? "SBR+" : "", + m4ac->object_type); + return AVERROR(ENOSYS); + } + + av_dlog(avctx, + "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n", + m4ac->object_type, m4ac->chan_config, m4ac->sampling_index, + m4ac->sample_rate, m4ac->sbr, + m4ac->ps); + + return get_bits_count(&gb); +} + +/** + * linear congruential pseudorandom number generator + * + * @param previous_val pointer to the current state of the generator + * + * @return Returns a 32-bit pseudorandom integer + */ +static av_always_inline int lcg_random(unsigned previous_val) +{ + union { unsigned u; int s; } v = { previous_val * 1664525u + 1013904223 }; + return v.s; +} + +static void reset_all_predictors(PredictorState *ps) +{ + int i; + for (i = 0; i < MAX_PREDICTORS; i++) + reset_predict_state(&ps[i]); +} + +static int sample_rate_idx (int rate) +{ + if (92017 <= rate) return 0; + else if (75132 <= rate) return 1; + else if (55426 <= rate) return 2; + else if (46009 <= rate) return 3; + else if (37566 <= rate) return 4; + else if (27713 <= rate) return 5; + else if (23004 <= rate) return 6; + else if (18783 <= rate) return 7; + else if (13856 <= rate) return 8; + else if (11502 <= rate) return 9; + else if (9391 <= rate) return 10; + else return 11; +} + +static void reset_predictor_group(PredictorState *ps, int group_num) +{ + int i; + for (i = group_num - 1; i < MAX_PREDICTORS; i += 30) + reset_predict_state(&ps[i]); +} + +#define AAC_INIT_VLC_STATIC(num, size) \ + INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \ + ff_aac_spectral_bits[num], sizeof(ff_aac_spectral_bits[num][0]), \ + sizeof(ff_aac_spectral_bits[num][0]), \ + ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), \ + sizeof(ff_aac_spectral_codes[num][0]), \ + size); + +static void aacdec_init(AACContext *ac); + +static av_cold int aac_decode_init(AVCodecContext *avctx) +{ + AACContext *ac = avctx->priv_data; + int ret; + + ac->avctx = avctx; + ac->oc[1].m4ac.sample_rate = avctx->sample_rate; + + aacdec_init(ac); + + avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; + + if (avctx->extradata_size > 0) { + if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, + avctx->extradata, + avctx->extradata_size * 8, + 1)) < 0) + return ret; + } else { + int sr, i; + uint8_t layout_map[MAX_ELEM_ID*4][3]; + int layout_map_tags; + + sr = sample_rate_idx(avctx->sample_rate); + ac->oc[1].m4ac.sampling_index = sr; + ac->oc[1].m4ac.channels = avctx->channels; + ac->oc[1].m4ac.sbr = -1; + ac->oc[1].m4ac.ps = -1; + + for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++) + if (ff_mpeg4audio_channels[i] == avctx->channels) + break; + if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) { + i = 0; + } + ac->oc[1].m4ac.chan_config = i; + + if (ac->oc[1].m4ac.chan_config) { + int ret = set_default_channel_config(avctx, layout_map, + &layout_map_tags, ac->oc[1].m4ac.chan_config); + if (!ret) + output_configure(ac, layout_map, layout_map_tags, + OC_GLOBAL_HDR, 0); + else if (avctx->err_recognition & AV_EF_EXPLODE) + return AVERROR_INVALIDDATA; + } + } + + if (avctx->channels > MAX_CHANNELS) { + av_log(avctx, AV_LOG_ERROR, "Too many channels\n"); + return AVERROR_INVALIDDATA; + } + + AAC_INIT_VLC_STATIC( 0, 304); + AAC_INIT_VLC_STATIC( 1, 270); + AAC_INIT_VLC_STATIC( 2, 550); + AAC_INIT_VLC_STATIC( 3, 300); + AAC_INIT_VLC_STATIC( 4, 328); + AAC_INIT_VLC_STATIC( 5, 294); + AAC_INIT_VLC_STATIC( 6, 306); + AAC_INIT_VLC_STATIC( 7, 268); + AAC_INIT_VLC_STATIC( 8, 510); + AAC_INIT_VLC_STATIC( 9, 366); + AAC_INIT_VLC_STATIC(10, 462); + + ff_aac_sbr_init(); + + ff_fmt_convert_init(&ac->fmt_conv, avctx); + avpriv_float_dsp_init(&ac->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); + + ac->random_state = 0x1f2e3d4c; + + ff_aac_tableinit(); + + INIT_VLC_STATIC(&vlc_scalefactors, 7, + FF_ARRAY_ELEMS(ff_aac_scalefactor_code), + ff_aac_scalefactor_bits, + sizeof(ff_aac_scalefactor_bits[0]), + sizeof(ff_aac_scalefactor_bits[0]), + ff_aac_scalefactor_code, + sizeof(ff_aac_scalefactor_code[0]), + sizeof(ff_aac_scalefactor_code[0]), + 352); + + ff_mdct_init(&ac->mdct, 11, 1, 1.0 / (32768.0 * 1024.0)); + ff_mdct_init(&ac->mdct_ld, 10, 1, 1.0 / (32768.0 * 512.0)); + ff_mdct_init(&ac->mdct_small, 8, 1, 1.0 / (32768.0 * 128.0)); + ff_mdct_init(&ac->mdct_ltp, 11, 0, -2.0 * 32768.0); + // window initialization + ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); + ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128); + ff_init_ff_sine_windows(10); + ff_init_ff_sine_windows( 9); + ff_init_ff_sine_windows( 7); + + cbrt_tableinit(); + + return 0; +} + +/** + * Skip data_stream_element; reference: table 4.10. + */ +static int skip_data_stream_element(AACContext *ac, GetBitContext *gb) +{ + int byte_align = get_bits1(gb); + int count = get_bits(gb, 8); + if (count == 255) + count += get_bits(gb, 8); + if (byte_align) + align_get_bits(gb); + + if (get_bits_left(gb) < 8 * count) { + av_log(ac->avctx, AV_LOG_ERROR, "skip_data_stream_element: "overread_err); + return AVERROR_INVALIDDATA; + } + skip_bits_long(gb, 8 * count); + return 0; +} + +static int decode_prediction(AACContext *ac, IndividualChannelStream *ics, + GetBitContext *gb) +{ + int sfb; + if (get_bits1(gb)) { + ics->predictor_reset_group = get_bits(gb, 5); + if (ics->predictor_reset_group == 0 || + ics->predictor_reset_group > 30) { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid Predictor Reset Group.\n"); + return AVERROR_INVALIDDATA; + } + } + for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]); sfb++) { + ics->prediction_used[sfb] = get_bits1(gb); + } + return 0; +} + +/** + * Decode Long Term Prediction data; reference: table 4.xx. + */ +static void decode_ltp(LongTermPrediction *ltp, + GetBitContext *gb, uint8_t max_sfb) +{ + int sfb; + + ltp->lag = get_bits(gb, 11); + ltp->coef = ltp_coef[get_bits(gb, 3)]; + for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++) + ltp->used[sfb] = get_bits1(gb); +} + +/** + * Decode Individual Channel Stream info; reference: table 4.6. + */ +static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, + GetBitContext *gb) +{ + int aot = ac->oc[1].m4ac.object_type; + if (aot != AOT_ER_AAC_ELD) { + if (get_bits1(gb)) { + av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n"); + return AVERROR_INVALIDDATA; + } + ics->window_sequence[1] = ics->window_sequence[0]; + ics->window_sequence[0] = get_bits(gb, 2); + if (aot == AOT_ER_AAC_LD && + ics->window_sequence[0] != ONLY_LONG_SEQUENCE) { + av_log(ac->avctx, AV_LOG_ERROR, + "AAC LD is only defined for ONLY_LONG_SEQUENCE but " + "window sequence %d found.\n", ics->window_sequence[0]); + ics->window_sequence[0] = ONLY_LONG_SEQUENCE; + return AVERROR_INVALIDDATA; + } + ics->use_kb_window[1] = ics->use_kb_window[0]; + ics->use_kb_window[0] = get_bits1(gb); + } + ics->num_window_groups = 1; + ics->group_len[0] = 1; + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + int i; + ics->max_sfb = get_bits(gb, 4); + for (i = 0; i < 7; i++) { + if (get_bits1(gb)) { + ics->group_len[ics->num_window_groups - 1]++; + } else { + ics->num_window_groups++; + ics->group_len[ics->num_window_groups - 1] = 1; + } + } + ics->num_windows = 8; + ics->swb_offset = ff_swb_offset_128[ac->oc[1].m4ac.sampling_index]; + ics->num_swb = ff_aac_num_swb_128[ac->oc[1].m4ac.sampling_index]; + ics->tns_max_bands = ff_tns_max_bands_128[ac->oc[1].m4ac.sampling_index]; + ics->predictor_present = 0; + } else { + ics->max_sfb = get_bits(gb, 6); + ics->num_windows = 1; + if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) { + ics->swb_offset = ff_swb_offset_512[ac->oc[1].m4ac.sampling_index]; + ics->num_swb = ff_aac_num_swb_512[ac->oc[1].m4ac.sampling_index]; + ics->tns_max_bands = ff_tns_max_bands_512[ac->oc[1].m4ac.sampling_index]; + if (!ics->num_swb || !ics->swb_offset) + return AVERROR_BUG; + } else { + ics->swb_offset = ff_swb_offset_1024[ac->oc[1].m4ac.sampling_index]; + ics->num_swb = ff_aac_num_swb_1024[ac->oc[1].m4ac.sampling_index]; + ics->tns_max_bands = ff_tns_max_bands_1024[ac->oc[1].m4ac.sampling_index]; + } + if (aot != AOT_ER_AAC_ELD) { + ics->predictor_present = get_bits1(gb); + ics->predictor_reset_group = 0; + } + if (ics->predictor_present) { + if (aot == AOT_AAC_MAIN) { + if (decode_prediction(ac, ics, gb)) { + goto fail; + } + } else if (aot == AOT_AAC_LC || + aot == AOT_ER_AAC_LC) { + av_log(ac->avctx, AV_LOG_ERROR, + "Prediction is not allowed in AAC-LC.\n"); + goto fail; + } else { + if (aot == AOT_ER_AAC_LD) { + av_log(ac->avctx, AV_LOG_ERROR, + "LTP in ER AAC LD not yet implemented.\n"); + return AVERROR_PATCHWELCOME; + } + if ((ics->ltp.present = get_bits(gb, 1))) + decode_ltp(&ics->ltp, gb, ics->max_sfb); + } + } + } + + if (ics->max_sfb > ics->num_swb) { + av_log(ac->avctx, AV_LOG_ERROR, + "Number of scalefactor bands in group (%d) " + "exceeds limit (%d).\n", + ics->max_sfb, ics->num_swb); + goto fail; + } + + return 0; +fail: + ics->max_sfb = 0; + return AVERROR_INVALIDDATA; +} + +/** + * Decode band types (section_data payload); reference: table 4.46. + * + * @param band_type array of the used band type + * @param band_type_run_end array of the last scalefactor band of a band type run + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_band_types(AACContext *ac, enum BandType band_type[120], + int band_type_run_end[120], GetBitContext *gb, + IndividualChannelStream *ics) +{ + int g, idx = 0; + const int bits = (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) ? 3 : 5; + for (g = 0; g < ics->num_window_groups; g++) { + int k = 0; + while (k < ics->max_sfb) { + uint8_t sect_end = k; + int sect_len_incr; + int sect_band_type = get_bits(gb, 4); + if (sect_band_type == 12) { + av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n"); + return AVERROR_INVALIDDATA; + } + do { + sect_len_incr = get_bits(gb, bits); + sect_end += sect_len_incr; + if (get_bits_left(gb) < 0) { + av_log(ac->avctx, AV_LOG_ERROR, "decode_band_types: "overread_err); + return AVERROR_INVALIDDATA; + } + if (sect_end > ics->max_sfb) { + av_log(ac->avctx, AV_LOG_ERROR, + "Number of bands (%d) exceeds limit (%d).\n", + sect_end, ics->max_sfb); + return AVERROR_INVALIDDATA; + } + } while (sect_len_incr == (1 << bits) - 1); + for (; k < sect_end; k++) { + band_type [idx] = sect_band_type; + band_type_run_end[idx++] = sect_end; + } + } + } + return 0; +} + +/** + * Decode scalefactors; reference: table 4.47. + * + * @param global_gain first scalefactor value as scalefactors are differentially coded + * @param band_type array of the used band type + * @param band_type_run_end array of the last scalefactor band of a band type run + * @param sf array of scalefactors or intensity stereo positions + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, + unsigned int global_gain, + IndividualChannelStream *ics, + enum BandType band_type[120], + int band_type_run_end[120]) +{ + int g, i, idx = 0; + int offset[3] = { global_gain, global_gain - 90, 0 }; + int clipped_offset; + int noise_flag = 1; + for (g = 0; g < ics->num_window_groups; g++) { + for (i = 0; i < ics->max_sfb;) { + int run_end = band_type_run_end[idx]; + if (band_type[idx] == ZERO_BT) { + for (; i < run_end; i++, idx++) + sf[idx] = 0.0; + } else if ((band_type[idx] == INTENSITY_BT) || + (band_type[idx] == INTENSITY_BT2)) { + for (; i < run_end; i++, idx++) { + offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; + clipped_offset = av_clip(offset[2], -155, 100); + if (offset[2] != clipped_offset) { + avpriv_request_sample(ac->avctx, + "If you heard an audible artifact, there may be a bug in the decoder. " + "Clipped intensity stereo position (%d -> %d)", + offset[2], clipped_offset); + } + sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + POW_SF2_ZERO]; + } + } else if (band_type[idx] == NOISE_BT) { + for (; i < run_end; i++, idx++) { + if (noise_flag-- > 0) + offset[1] += get_bits(gb, 9) - 256; + else + offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; + clipped_offset = av_clip(offset[1], -100, 155); + if (offset[1] != clipped_offset) { + avpriv_request_sample(ac->avctx, + "If you heard an audible artifact, there may be a bug in the decoder. " + "Clipped noise gain (%d -> %d)", + offset[1], clipped_offset); + } + sf[idx] = -ff_aac_pow2sf_tab[clipped_offset + POW_SF2_ZERO]; + } + } else { + for (; i < run_end; i++, idx++) { + offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; + if (offset[0] > 255U) { + av_log(ac->avctx, AV_LOG_ERROR, + "Scalefactor (%d) out of range.\n", offset[0]); + return AVERROR_INVALIDDATA; + } + sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO]; + } + } + } + } + return 0; +} + +/** + * Decode pulse data; reference: table 4.7. + */ +static int decode_pulses(Pulse *pulse, GetBitContext *gb, + const uint16_t *swb_offset, int num_swb) +{ + int i, pulse_swb; + pulse->num_pulse = get_bits(gb, 2) + 1; + pulse_swb = get_bits(gb, 6); + if (pulse_swb >= num_swb) + return -1; + pulse->pos[0] = swb_offset[pulse_swb]; + pulse->pos[0] += get_bits(gb, 5); + if (pulse->pos[0] >= swb_offset[num_swb]) + return -1; + pulse->amp[0] = get_bits(gb, 4); + for (i = 1; i < pulse->num_pulse; i++) { + pulse->pos[i] = get_bits(gb, 5) + pulse->pos[i - 1]; + if (pulse->pos[i] >= swb_offset[num_swb]) + return -1; + pulse->amp[i] = get_bits(gb, 4); + } + return 0; +} + +/** + * Decode Temporal Noise Shaping data; reference: table 4.48. + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns, + GetBitContext *gb, const IndividualChannelStream *ics) +{ + int w, filt, i, coef_len, coef_res, coef_compress; + const int is8 = ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE; + const int tns_max_order = is8 ? 7 : ac->oc[1].m4ac.object_type == AOT_AAC_MAIN ? 20 : 12; + for (w = 0; w < ics->num_windows; w++) { + if ((tns->n_filt[w] = get_bits(gb, 2 - is8))) { + coef_res = get_bits1(gb); + + for (filt = 0; filt < tns->n_filt[w]; filt++) { + int tmp2_idx; + tns->length[w][filt] = get_bits(gb, 6 - 2 * is8); + + if ((tns->order[w][filt] = get_bits(gb, 5 - 2 * is8)) > tns_max_order) { + av_log(ac->avctx, AV_LOG_ERROR, + "TNS filter order %d is greater than maximum %d.\n", + tns->order[w][filt], tns_max_order); + tns->order[w][filt] = 0; + return AVERROR_INVALIDDATA; + } + if (tns->order[w][filt]) { + tns->direction[w][filt] = get_bits1(gb); + coef_compress = get_bits1(gb); + coef_len = coef_res + 3 - coef_compress; + tmp2_idx = 2 * coef_compress + coef_res; + + for (i = 0; i < tns->order[w][filt]; i++) + tns->coef[w][filt][i] = tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)]; + } + } + } + } + return 0; +} + +/** + * Decode Mid/Side data; reference: table 4.54. + * + * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s; + * [1] mask is decoded from bitstream; [2] mask is all 1s; + * [3] reserved for scalable AAC + */ +static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb, + int ms_present) +{ + int idx; + if (ms_present == 1) { + for (idx = 0; + idx < cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb; + idx++) + cpe->ms_mask[idx] = get_bits1(gb); + } else if (ms_present == 2) { + memset(cpe->ms_mask, 1, sizeof(cpe->ms_mask[0]) * cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb); + } +} + +/** + * Decode spectral data; reference: table 4.50. + * Dequantize and scale spectral data; reference: 4.6.3.3. + * + * @param coef array of dequantized, scaled spectral data + * @param sf array of scalefactors or intensity stereo positions + * @param pulse_present set if pulses are present + * @param pulse pointer to pulse data struct + * @param band_type array of the used band type + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], + GetBitContext *gb, const float sf[120], + int pulse_present, const Pulse *pulse, + const IndividualChannelStream *ics, + enum BandType band_type[120]) +{ + int i, k, g, idx = 0; + const int c = 1024 / ics->num_windows; + const uint16_t *offsets = ics->swb_offset; + float *coef_base = coef; + + for (g = 0; g < ics->num_windows; g++) + memset(coef + g * 128 + offsets[ics->max_sfb], 0, + sizeof(float) * (c - offsets[ics->max_sfb])); + + for (g = 0; g < ics->num_window_groups; g++) { + unsigned g_len = ics->group_len[g]; + + for (i = 0; i < ics->max_sfb; i++, idx++) { + const unsigned cbt_m1 = band_type[idx] - 1; + float *cfo = coef + offsets[i]; + int off_len = offsets[i + 1] - offsets[i]; + int group; + + if (cbt_m1 >= INTENSITY_BT2 - 1) { + for (group = 0; group < g_len; group++, cfo+=128) { + memset(cfo, 0, off_len * sizeof(float)); + } + } else if (cbt_m1 == NOISE_BT - 1) { + for (group = 0; group < g_len; group++, cfo+=128) { + float scale; + float band_energy; + + for (k = 0; k < off_len; k++) { + ac->random_state = lcg_random(ac->random_state); + cfo[k] = ac->random_state; + } + + band_energy = ac->fdsp.scalarproduct_float(cfo, cfo, off_len); + scale = sf[idx] / sqrtf(band_energy); + ac->fdsp.vector_fmul_scalar(cfo, cfo, scale, off_len); + } + } else { + const float *vq = ff_aac_codebook_vector_vals[cbt_m1]; + const uint16_t *cb_vector_idx = ff_aac_codebook_vector_idx[cbt_m1]; + VLC_TYPE (*vlc_tab)[2] = vlc_spectral[cbt_m1].table; + OPEN_READER(re, gb); + + switch (cbt_m1 >> 1) { + case 0: + for (group = 0; group < g_len; group++, cfo+=128) { + float *cf = cfo; + int len = off_len; + + do { + int code; + unsigned cb_idx; + + UPDATE_CACHE(re, gb); + GET_VLC(code, re, gb, vlc_tab, 8, 2); + cb_idx = cb_vector_idx[code]; + cf = VMUL4(cf, vq, cb_idx, sf + idx); + } while (len -= 4); + } + break; + + case 1: + for (group = 0; group < g_len; group++, cfo+=128) { + float *cf = cfo; + int len = off_len; + + do { + int code; + unsigned nnz; + unsigned cb_idx; + uint32_t bits; + + UPDATE_CACHE(re, gb); + GET_VLC(code, re, gb, vlc_tab, 8, 2); + cb_idx = cb_vector_idx[code]; + nnz = cb_idx >> 8 & 15; + bits = nnz ? GET_CACHE(re, gb) : 0; + LAST_SKIP_BITS(re, gb, nnz); + cf = VMUL4S(cf, vq, cb_idx, bits, sf + idx); + } while (len -= 4); + } + break; + + case 2: + for (group = 0; group < g_len; group++, cfo+=128) { + float *cf = cfo; + int len = off_len; + + do { + int code; + unsigned cb_idx; + + UPDATE_CACHE(re, gb); + GET_VLC(code, re, gb, vlc_tab, 8, 2); + cb_idx = cb_vector_idx[code]; + cf = VMUL2(cf, vq, cb_idx, sf + idx); + } while (len -= 2); + } + break; + + case 3: + case 4: + for (group = 0; group < g_len; group++, cfo+=128) { + float *cf = cfo; + int len = off_len; + + do { + int code; + unsigned nnz; + unsigned cb_idx; + unsigned sign; + + UPDATE_CACHE(re, gb); + GET_VLC(code, re, gb, vlc_tab, 8, 2); + cb_idx = cb_vector_idx[code]; + nnz = cb_idx >> 8 & 15; + sign = nnz ? SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12) : 0; + LAST_SKIP_BITS(re, gb, nnz); + cf = VMUL2S(cf, vq, cb_idx, sign, sf + idx); + } while (len -= 2); + } + break; + + default: + for (group = 0; group < g_len; group++, cfo+=128) { + float *cf = cfo; + uint32_t *icf = (uint32_t *) cf; + int len = off_len; + + do { + int code; + unsigned nzt, nnz; + unsigned cb_idx; + uint32_t bits; + int j; + + UPDATE_CACHE(re, gb); + GET_VLC(code, re, gb, vlc_tab, 8, 2); + + if (!code) { + *icf++ = 0; + *icf++ = 0; + continue; + } + + cb_idx = cb_vector_idx[code]; + nnz = cb_idx >> 12; + nzt = cb_idx >> 8; + bits = SHOW_UBITS(re, gb, nnz) << (32-nnz); + LAST_SKIP_BITS(re, gb, nnz); + + for (j = 0; j < 2; j++) { + if (nzt & 1< 8) { + av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n"); + return AVERROR_INVALIDDATA; + } + + SKIP_BITS(re, gb, b + 1); + b += 4; + n = (1 << b) + SHOW_UBITS(re, gb, b); + LAST_SKIP_BITS(re, gb, b); + *icf++ = cbrt_tab[n] | (bits & 1U<<31); + bits <<= 1; + } else { + unsigned v = ((const uint32_t*)vq)[cb_idx & 15]; + *icf++ = (bits & 1U<<31) | v; + bits <<= !!v; + } + cb_idx >>= 4; + } + } while (len -= 2); + + ac->fdsp.vector_fmul_scalar(cfo, cfo, sf[idx], off_len); + } + } + + CLOSE_READER(re, gb); + } + } + coef += g_len << 7; + } + + if (pulse_present) { + idx = 0; + for (i = 0; i < pulse->num_pulse; i++) { + float co = coef_base[ pulse->pos[i] ]; + while (offsets[idx + 1] <= pulse->pos[i]) + idx++; + if (band_type[idx] != NOISE_BT && sf[idx]) { + float ico = -pulse->amp[i]; + if (co) { + co /= sf[idx]; + ico = co / sqrtf(sqrtf(fabsf(co))) + (co > 0 ? -ico : ico); + } + coef_base[ pulse->pos[i] ] = cbrtf(fabsf(ico)) * ico * sf[idx]; + } + } + } + return 0; +} + +/** + * Apply AAC-Main style frequency domain prediction. + */ +static void apply_prediction(AACContext *ac, SingleChannelElement *sce) +{ + int sfb, k; + + if (!sce->ics.predictor_initialized) { + reset_all_predictors(sce->predictor_state); + sce->ics.predictor_initialized = 1; + } + + if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { + for (sfb = 0; + sfb < ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]; + sfb++) { + for (k = sce->ics.swb_offset[sfb]; + k < sce->ics.swb_offset[sfb + 1]; + k++) { + predict(&sce->predictor_state[k], &sce->coeffs[k], + sce->ics.predictor_present && + sce->ics.prediction_used[sfb]); + } + } + if (sce->ics.predictor_reset_group) + reset_predictor_group(sce->predictor_state, + sce->ics.predictor_reset_group); + } else + reset_all_predictors(sce->predictor_state); +} + +/** + * Decode an individual_channel_stream payload; reference: table 4.44. + * + * @param common_window Channels have independent [0], or shared [1], Individual Channel Stream information. + * @param scale_flag scalable [1] or non-scalable [0] AAC (Unused until scalable AAC is implemented.) + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_ics(AACContext *ac, SingleChannelElement *sce, + GetBitContext *gb, int common_window, int scale_flag) +{ + Pulse pulse; + TemporalNoiseShaping *tns = &sce->tns; + IndividualChannelStream *ics = &sce->ics; + float *out = sce->coeffs; + int global_gain, eld_syntax, er_syntax, pulse_present = 0; + int ret; + + eld_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; + er_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_LC || + ac->oc[1].m4ac.object_type == AOT_ER_AAC_LTP || + ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD || + ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; + + /* This assignment is to silence a GCC warning about the variable being used + * uninitialized when in fact it always is. + */ + pulse.num_pulse = 0; + + global_gain = get_bits(gb, 8); + + if (!common_window && !scale_flag) { + if (decode_ics_info(ac, ics, gb) < 0) + return AVERROR_INVALIDDATA; + } + + if ((ret = decode_band_types(ac, sce->band_type, + sce->band_type_run_end, gb, ics)) < 0) + return ret; + if ((ret = decode_scalefactors(ac, sce->sf, gb, global_gain, ics, + sce->band_type, sce->band_type_run_end)) < 0) + return ret; + + pulse_present = 0; + if (!scale_flag) { + if (!eld_syntax && (pulse_present = get_bits1(gb))) { + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + av_log(ac->avctx, AV_LOG_ERROR, + "Pulse tool not allowed in eight short sequence.\n"); + return AVERROR_INVALIDDATA; + } + if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) { + av_log(ac->avctx, AV_LOG_ERROR, + "Pulse data corrupt or invalid.\n"); + return AVERROR_INVALIDDATA; + } + } + tns->present = get_bits1(gb); + if (tns->present && !er_syntax) + if (decode_tns(ac, tns, gb, ics) < 0) + return AVERROR_INVALIDDATA; + if (!eld_syntax && get_bits1(gb)) { + avpriv_request_sample(ac->avctx, "SSR"); + return AVERROR_PATCHWELCOME; + } + // I see no textual basis in the spec for this occurring after SSR gain + // control, but this is what both reference and real implmentations do + if (tns->present && er_syntax) + if (decode_tns(ac, tns, gb, ics) < 0) + return AVERROR_INVALIDDATA; + } + + if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present, + &pulse, ics, sce->band_type) < 0) + return AVERROR_INVALIDDATA; + + if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN && !common_window) + apply_prediction(ac, sce); + + return 0; +} + +/** + * Mid/Side stereo decoding; reference: 4.6.8.1.3. + */ +static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe) +{ + const IndividualChannelStream *ics = &cpe->ch[0].ics; + float *ch0 = cpe->ch[0].coeffs; + float *ch1 = cpe->ch[1].coeffs; + int g, i, group, idx = 0; + const uint16_t *offsets = ics->swb_offset; + for (g = 0; g < ics->num_window_groups; g++) { + for (i = 0; i < ics->max_sfb; i++, idx++) { + if (cpe->ms_mask[idx] && + cpe->ch[0].band_type[idx] < NOISE_BT && + cpe->ch[1].band_type[idx] < NOISE_BT) { + for (group = 0; group < ics->group_len[g]; group++) { + ac->fdsp.butterflies_float(ch0 + group * 128 + offsets[i], + ch1 + group * 128 + offsets[i], + offsets[i+1] - offsets[i]); + } + } + } + ch0 += ics->group_len[g] * 128; + ch1 += ics->group_len[g] * 128; + } +} + +/** + * intensity stereo decoding; reference: 4.6.8.2.3 + * + * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s; + * [1] mask is decoded from bitstream; [2] mask is all 1s; + * [3] reserved for scalable AAC + */ +static void apply_intensity_stereo(AACContext *ac, + ChannelElement *cpe, int ms_present) +{ + const IndividualChannelStream *ics = &cpe->ch[1].ics; + SingleChannelElement *sce1 = &cpe->ch[1]; + float *coef0 = cpe->ch[0].coeffs, *coef1 = cpe->ch[1].coeffs; + const uint16_t *offsets = ics->swb_offset; + int g, group, i, idx = 0; + int c; + float scale; + for (g = 0; g < ics->num_window_groups; g++) { + for (i = 0; i < ics->max_sfb;) { + if (sce1->band_type[idx] == INTENSITY_BT || + sce1->band_type[idx] == INTENSITY_BT2) { + const int bt_run_end = sce1->band_type_run_end[idx]; + for (; i < bt_run_end; i++, idx++) { + c = -1 + 2 * (sce1->band_type[idx] - 14); + if (ms_present) + c *= 1 - 2 * cpe->ms_mask[idx]; + scale = c * sce1->sf[idx]; + for (group = 0; group < ics->group_len[g]; group++) + ac->fdsp.vector_fmul_scalar(coef1 + group * 128 + offsets[i], + coef0 + group * 128 + offsets[i], + scale, + offsets[i + 1] - offsets[i]); + } + } else { + int bt_run_end = sce1->band_type_run_end[idx]; + idx += bt_run_end - i; + i = bt_run_end; + } + } + coef0 += ics->group_len[g] * 128; + coef1 += ics->group_len[g] * 128; + } +} + +/** + * Decode a channel_pair_element; reference: table 4.4. + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe) +{ + int i, ret, common_window, ms_present = 0; + int eld_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; + + common_window = eld_syntax || get_bits1(gb); + if (common_window) { + if (decode_ics_info(ac, &cpe->ch[0].ics, gb)) + return AVERROR_INVALIDDATA; + i = cpe->ch[1].ics.use_kb_window[0]; + cpe->ch[1].ics = cpe->ch[0].ics; + cpe->ch[1].ics.use_kb_window[1] = i; + if (cpe->ch[1].ics.predictor_present && + (ac->oc[1].m4ac.object_type != AOT_AAC_MAIN)) + if ((cpe->ch[1].ics.ltp.present = get_bits(gb, 1))) + decode_ltp(&cpe->ch[1].ics.ltp, gb, cpe->ch[1].ics.max_sfb); + ms_present = get_bits(gb, 2); + if (ms_present == 3) { + av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n"); + return AVERROR_INVALIDDATA; + } else if (ms_present) + decode_mid_side_stereo(cpe, gb, ms_present); + } + if ((ret = decode_ics(ac, &cpe->ch[0], gb, common_window, 0))) + return ret; + if ((ret = decode_ics(ac, &cpe->ch[1], gb, common_window, 0))) + return ret; + + if (common_window) { + if (ms_present) + apply_mid_side_stereo(ac, cpe); + if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN) { + apply_prediction(ac, &cpe->ch[0]); + apply_prediction(ac, &cpe->ch[1]); + } + } + + apply_intensity_stereo(ac, cpe, ms_present); + return 0; +} + +static const float cce_scale[] = { + 1.09050773266525765921, //2^(1/8) + 1.18920711500272106672, //2^(1/4) + M_SQRT2, + 2, +}; + +/** + * Decode coupling_channel_element; reference: table 4.8. + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) +{ + int num_gain = 0; + int c, g, sfb, ret; + int sign; + float scale; + SingleChannelElement *sce = &che->ch[0]; + ChannelCoupling *coup = &che->coup; + + coup->coupling_point = 2 * get_bits1(gb); + coup->num_coupled = get_bits(gb, 3); + for (c = 0; c <= coup->num_coupled; c++) { + num_gain++; + coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE; + coup->id_select[c] = get_bits(gb, 4); + if (coup->type[c] == TYPE_CPE) { + coup->ch_select[c] = get_bits(gb, 2); + if (coup->ch_select[c] == 3) + num_gain++; + } else + coup->ch_select[c] = 2; + } + coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1); + + sign = get_bits(gb, 1); + scale = cce_scale[get_bits(gb, 2)]; + + if ((ret = decode_ics(ac, sce, gb, 0, 0))) + return ret; + + for (c = 0; c < num_gain; c++) { + int idx = 0; + int cge = 1; + int gain = 0; + float gain_cache = 1.0; + if (c) { + cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb); + gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0; + gain_cache = powf(scale, -gain); + } + if (coup->coupling_point == AFTER_IMDCT) { + coup->gain[c][0] = gain_cache; + } else { + for (g = 0; g < sce->ics.num_window_groups; g++) { + for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) { + if (sce->band_type[idx] != ZERO_BT) { + if (!cge) { + int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; + if (t) { + int s = 1; + t = gain += t; + if (sign) { + s -= 2 * (t & 0x1); + t >>= 1; + } + gain_cache = powf(scale, -t) * s; + } + } + coup->gain[c][idx] = gain_cache; + } + } + } + } + } + return 0; +} + +/** + * Parse whether channels are to be excluded from Dynamic Range Compression; reference: table 4.53. + * + * @return Returns number of bytes consumed. + */ +static int decode_drc_channel_exclusions(DynamicRangeControl *che_drc, + GetBitContext *gb) +{ + int i; + int num_excl_chan = 0; + + do { + for (i = 0; i < 7; i++) + che_drc->exclude_mask[num_excl_chan++] = get_bits1(gb); + } while (num_excl_chan < MAX_CHANNELS - 7 && get_bits1(gb)); + + return num_excl_chan / 7; +} + +/** + * Decode dynamic range information; reference: table 4.52. + * + * @return Returns number of bytes consumed. + */ +static int decode_dynamic_range(DynamicRangeControl *che_drc, + GetBitContext *gb) +{ + int n = 1; + int drc_num_bands = 1; + int i; + + /* pce_tag_present? */ + if (get_bits1(gb)) { + che_drc->pce_instance_tag = get_bits(gb, 4); + skip_bits(gb, 4); // tag_reserved_bits + n++; + } + + /* excluded_chns_present? */ + if (get_bits1(gb)) { + n += decode_drc_channel_exclusions(che_drc, gb); + } + + /* drc_bands_present? */ + if (get_bits1(gb)) { + che_drc->band_incr = get_bits(gb, 4); + che_drc->interpolation_scheme = get_bits(gb, 4); + n++; + drc_num_bands += che_drc->band_incr; + for (i = 0; i < drc_num_bands; i++) { + che_drc->band_top[i] = get_bits(gb, 8); + n++; + } + } + + /* prog_ref_level_present? */ + if (get_bits1(gb)) { + che_drc->prog_ref_level = get_bits(gb, 7); + skip_bits1(gb); // prog_ref_level_reserved_bits + n++; + } + + for (i = 0; i < drc_num_bands; i++) { + che_drc->dyn_rng_sgn[i] = get_bits1(gb); + che_drc->dyn_rng_ctl[i] = get_bits(gb, 7); + n++; + } + + return n; +} + +static int decode_fill(AACContext *ac, GetBitContext *gb, int len) { + uint8_t buf[256]; + int i, major, minor; + + if (len < 13+7*8) + goto unknown; + + get_bits(gb, 13); len -= 13; + + for(i=0; i+1=8; i++, len-=8) + buf[i] = get_bits(gb, 8); + + buf[i] = 0; + if (ac->avctx->debug & FF_DEBUG_PICT_INFO) + av_log(ac->avctx, AV_LOG_DEBUG, "FILL:%s\n", buf); + + if (sscanf(buf, "libfaac %d.%d", &major, &minor) == 2){ + ac->avctx->internal->skip_samples = 1024; + } + +unknown: + skip_bits_long(gb, len); + + return 0; +} + +/** + * Decode extension data (incomplete); reference: table 4.51. + * + * @param cnt length of TYPE_FIL syntactic element in bytes + * + * @return Returns number of bytes consumed + */ +static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, + ChannelElement *che, enum RawDataBlockType elem_type) +{ + int crc_flag = 0; + int res = cnt; + switch (get_bits(gb, 4)) { // extension type + case EXT_SBR_DATA_CRC: + crc_flag++; + case EXT_SBR_DATA: + if (!che) { + av_log(ac->avctx, AV_LOG_ERROR, "SBR was found before the first channel element.\n"); + return res; + } else if (!ac->oc[1].m4ac.sbr) { + av_log(ac->avctx, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n"); + skip_bits_long(gb, 8 * cnt - 4); + return res; + } else if (ac->oc[1].m4ac.sbr == -1 && ac->oc[1].status == OC_LOCKED) { + av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n"); + skip_bits_long(gb, 8 * cnt - 4); + return res; + } else if (ac->oc[1].m4ac.ps == -1 && ac->oc[1].status < OC_LOCKED && ac->avctx->channels == 1) { + ac->oc[1].m4ac.sbr = 1; + ac->oc[1].m4ac.ps = 1; + ac->avctx->profile = FF_PROFILE_AAC_HE_V2; + output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, + ac->oc[1].status, 1); + } else { + ac->oc[1].m4ac.sbr = 1; + ac->avctx->profile = FF_PROFILE_AAC_HE; + } + res = ff_decode_sbr_extension(ac, &che->sbr, gb, crc_flag, cnt, elem_type); + break; + case EXT_DYNAMIC_RANGE: + res = decode_dynamic_range(&ac->che_drc, gb); + break; + case EXT_FILL: + decode_fill(ac, gb, 8 * cnt - 4); + break; + case EXT_FILL_DATA: + case EXT_DATA_ELEMENT: + default: + skip_bits_long(gb, 8 * cnt - 4); + break; + }; + return res; +} + +/** + * Decode Temporal Noise Shaping filter coefficients and apply all-pole filters; reference: 4.6.9.3. + * + * @param decode 1 if tool is used normally, 0 if tool is used in LTP. + * @param coef spectral coefficients + */ +static void apply_tns(float coef[1024], TemporalNoiseShaping *tns, + IndividualChannelStream *ics, int decode) +{ + const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb); + int w, filt, m, i; + int bottom, top, order, start, end, size, inc; + float lpc[TNS_MAX_ORDER]; + float tmp[TNS_MAX_ORDER+1]; + + for (w = 0; w < ics->num_windows; w++) { + bottom = ics->num_swb; + for (filt = 0; filt < tns->n_filt[w]; filt++) { + top = bottom; + bottom = FFMAX(0, top - tns->length[w][filt]); + order = tns->order[w][filt]; + if (order == 0) + continue; + + // tns_decode_coef + compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0); + + start = ics->swb_offset[FFMIN(bottom, mmm)]; + end = ics->swb_offset[FFMIN( top, mmm)]; + if ((size = end - start) <= 0) + continue; + if (tns->direction[w][filt]) { + inc = -1; + start = end - 1; + } else { + inc = 1; + } + start += w * 128; + + if (decode) { + // ar filter + for (m = 0; m < size; m++, start += inc) + for (i = 1; i <= FFMIN(m, order); i++) + coef[start] -= coef[start - i * inc] * lpc[i - 1]; + } else { + // ma filter + for (m = 0; m < size; m++, start += inc) { + tmp[0] = coef[start]; + for (i = 1; i <= FFMIN(m, order); i++) + coef[start] += tmp[i] * lpc[i - 1]; + for (i = order; i > 0; i--) + tmp[i] = tmp[i - 1]; + } + } + } + } +} + +/** + * Apply windowing and MDCT to obtain the spectral + * coefficient from the predicted sample by LTP. + */ +static void windowing_and_mdct_ltp(AACContext *ac, float *out, + float *in, IndividualChannelStream *ics) +{ + const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; + const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; + const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; + const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; + + if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) { + ac->fdsp.vector_fmul(in, in, lwindow_prev, 1024); + } else { + memset(in, 0, 448 * sizeof(float)); + ac->fdsp.vector_fmul(in + 448, in + 448, swindow_prev, 128); + } + if (ics->window_sequence[0] != LONG_START_SEQUENCE) { + ac->fdsp.vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024); + } else { + ac->fdsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); + memset(in + 1024 + 576, 0, 448 * sizeof(float)); + } + ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in); +} + +/** + * Apply the long term prediction + */ +static void apply_ltp(AACContext *ac, SingleChannelElement *sce) +{ + const LongTermPrediction *ltp = &sce->ics.ltp; + const uint16_t *offsets = sce->ics.swb_offset; + int i, sfb; + + if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { + float *predTime = sce->ret; + float *predFreq = ac->buf_mdct; + int16_t num_samples = 2048; + + if (ltp->lag < 1024) + num_samples = ltp->lag + 1024; + for (i = 0; i < num_samples; i++) + predTime[i] = sce->ltp_state[i + 2048 - ltp->lag] * ltp->coef; + memset(&predTime[i], 0, (2048 - i) * sizeof(float)); + + ac->windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics); + + if (sce->tns.present) + ac->apply_tns(predFreq, &sce->tns, &sce->ics, 0); + + for (sfb = 0; sfb < FFMIN(sce->ics.max_sfb, MAX_LTP_LONG_SFB); sfb++) + if (ltp->used[sfb]) + for (i = offsets[sfb]; i < offsets[sfb + 1]; i++) + sce->coeffs[i] += predFreq[i]; + } +} + +/** + * Update the LTP buffer for next frame + */ +static void update_ltp(AACContext *ac, SingleChannelElement *sce) +{ + IndividualChannelStream *ics = &sce->ics; + float *saved = sce->saved; + float *saved_ltp = sce->coeffs; + const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; + const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; + int i; + + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + memcpy(saved_ltp, saved, 512 * sizeof(float)); + memset(saved_ltp + 576, 0, 448 * sizeof(float)); + ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); + for (i = 0; i < 64; i++) + saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i]; + } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { + memcpy(saved_ltp, ac->buf_mdct + 512, 448 * sizeof(float)); + memset(saved_ltp + 576, 0, 448 * sizeof(float)); + ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); + for (i = 0; i < 64; i++) + saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i]; + } else { // LONG_STOP or ONLY_LONG + ac->fdsp.vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, &lwindow[512], 512); + for (i = 0; i < 512; i++) + saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * lwindow[511 - i]; + } + + memcpy(sce->ltp_state, sce->ltp_state+1024, 1024 * sizeof(*sce->ltp_state)); + memcpy(sce->ltp_state+1024, sce->ret, 1024 * sizeof(*sce->ltp_state)); + memcpy(sce->ltp_state+2048, saved_ltp, 1024 * sizeof(*sce->ltp_state)); +} + +/** + * Conduct IMDCT and windowing. + */ +static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce) +{ + IndividualChannelStream *ics = &sce->ics; + float *in = sce->coeffs; + float *out = sce->ret; + float *saved = sce->saved; + const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; + const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; + const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; + float *buf = ac->buf_mdct; + float *temp = ac->temp; + int i; + + // imdct + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + for (i = 0; i < 1024; i += 128) + ac->mdct_small.imdct_half(&ac->mdct_small, buf + i, in + i); + } else + ac->mdct.imdct_half(&ac->mdct, buf, in); + + /* window overlapping + * NOTE: To simplify the overlapping code, all 'meaningless' short to long + * and long to short transitions are considered to be short to short + * transitions. This leaves just two cases (long to long and short to short) + * with a little special sauce for EIGHT_SHORT_SEQUENCE. + */ + if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) && + (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) { + ac->fdsp.vector_fmul_window( out, saved, buf, lwindow_prev, 512); + } else { + memcpy( out, saved, 448 * sizeof(float)); + + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + ac->fdsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, 64); + ac->fdsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, 64); + ac->fdsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, 64); + ac->fdsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, 64); + ac->fdsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, 64); + memcpy( out + 448 + 4*128, temp, 64 * sizeof(float)); + } else { + ac->fdsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 64); + memcpy( out + 576, buf + 64, 448 * sizeof(float)); + } + } + + // buffer update + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + memcpy( saved, temp + 64, 64 * sizeof(float)); + ac->fdsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 64); + ac->fdsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 64); + ac->fdsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 64); + memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float)); + } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { + memcpy( saved, buf + 512, 448 * sizeof(float)); + memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float)); + } else { // LONG_STOP or ONLY_LONG + memcpy( saved, buf + 512, 512 * sizeof(float)); + } +} + +static void imdct_and_windowing_ld(AACContext *ac, SingleChannelElement *sce) +{ + IndividualChannelStream *ics = &sce->ics; + float *in = sce->coeffs; + float *out = sce->ret; + float *saved = sce->saved; + float *buf = ac->buf_mdct; + + // imdct + ac->mdct.imdct_half(&ac->mdct_ld, buf, in); + + // window overlapping + if (ics->use_kb_window[1]) { + // AAC LD uses a low overlap sine window instead of a KBD window + memcpy(out, saved, 192 * sizeof(float)); + ac->fdsp.vector_fmul_window(out + 192, saved + 192, buf, ff_sine_128, 64); + memcpy( out + 320, buf + 64, 192 * sizeof(float)); + } else { + ac->fdsp.vector_fmul_window(out, saved, buf, ff_sine_512, 256); + } + + // buffer update + memcpy(saved, buf + 256, 256 * sizeof(float)); +} + +static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce) +{ + float *in = sce->coeffs; + float *out = sce->ret; + float *saved = sce->saved; + const float *const window = ff_aac_eld_window; + float *buf = ac->buf_mdct; + int i; + const int n = 512; + const int n2 = n >> 1; + const int n4 = n >> 2; + + // Inverse transform, mapped to the conventional IMDCT by + // Chivukula, R.K.; Reznik, Y.A.; Devarajan, V., + // "Efficient algorithms for MPEG-4 AAC-ELD, AAC-LD and AAC-LC filterbanks," + // International Conference on Audio, Language and Image Processing, ICALIP 2008. + // URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4590245&isnumber=4589950 + for (i = 0; i < n2; i+=2) { + float temp; + temp = in[i ]; in[i ] = -in[n - 1 - i]; in[n - 1 - i] = temp; + temp = -in[i + 1]; in[i + 1] = in[n - 2 - i]; in[n - 2 - i] = temp; + } + ac->mdct.imdct_half(&ac->mdct_ld, buf, in); + for (i = 0; i < n; i+=2) { + buf[i] = -buf[i]; + } + // Like with the regular IMDCT at this point we still have the middle half + // of a transform but with even symmetry on the left and odd symmetry on + // the right + + // window overlapping + // The spec says to use samples [0..511] but the reference decoder uses + // samples [128..639]. + for (i = n4; i < n2; i ++) { + out[i - n4] = buf[n2 - 1 - i] * window[i - n4] + + saved[ i + n2] * window[i + n - n4] + + -saved[ n + n2 - 1 - i] * window[i + 2*n - n4] + + -saved[2*n + n2 + i] * window[i + 3*n - n4]; + } + for (i = 0; i < n2; i ++) { + out[n4 + i] = buf[i] * window[i + n2 - n4] + + -saved[ n - 1 - i] * window[i + n2 + n - n4] + + -saved[ n + i] * window[i + n2 + 2*n - n4] + + saved[2*n + n - 1 - i] * window[i + n2 + 3*n - n4]; + } + for (i = 0; i < n4; i ++) { + out[n2 + n4 + i] = buf[ i + n2] * window[i + n - n4] + + -saved[ n2 - 1 - i] * window[i + 2*n - n4] + + -saved[ n + n2 + i] * window[i + 3*n - n4]; + } + + // buffer update + memmove(saved + n, saved, 2 * n * sizeof(float)); + memcpy( saved, buf, n * sizeof(float)); +} + +/** + * channel coupling transformation interface + * + * @param apply_coupling_method pointer to (in)dependent coupling function + */ +static void apply_channel_coupling(AACContext *ac, ChannelElement *cc, + enum RawDataBlockType type, int elem_id, + enum CouplingPoint coupling_point, + void (*apply_coupling_method)(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)) +{ + int i, c; + + for (i = 0; i < MAX_ELEM_ID; i++) { + ChannelElement *cce = ac->che[TYPE_CCE][i]; + int index = 0; + + if (cce && cce->coup.coupling_point == coupling_point) { + ChannelCoupling *coup = &cce->coup; + + for (c = 0; c <= coup->num_coupled; c++) { + if (coup->type[c] == type && coup->id_select[c] == elem_id) { + if (coup->ch_select[c] != 1) { + apply_coupling_method(ac, &cc->ch[0], cce, index); + if (coup->ch_select[c] != 0) + index++; + } + if (coup->ch_select[c] != 2) + apply_coupling_method(ac, &cc->ch[1], cce, index++); + } else + index += 1 + (coup->ch_select[c] == 3); + } + } + } +} + +/** + * Convert spectral data to float samples, applying all supported tools as appropriate. + */ +static void spectral_to_sample(AACContext *ac) +{ + int i, type; + void (*imdct_and_window)(AACContext *ac, SingleChannelElement *sce); + switch (ac->oc[1].m4ac.object_type) { + case AOT_ER_AAC_LD: + imdct_and_window = imdct_and_windowing_ld; + break; + case AOT_ER_AAC_ELD: + imdct_and_window = imdct_and_windowing_eld; + break; + default: + imdct_and_window = ac->imdct_and_windowing; + } + for (type = 3; type >= 0; type--) { + for (i = 0; i < MAX_ELEM_ID; i++) { + ChannelElement *che = ac->che[type][i]; + if (che) { + if (type <= TYPE_CPE) + apply_channel_coupling(ac, che, type, i, BEFORE_TNS, apply_dependent_coupling); + if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) { + if (che->ch[0].ics.predictor_present) { + if (che->ch[0].ics.ltp.present) + ac->apply_ltp(ac, &che->ch[0]); + if (che->ch[1].ics.ltp.present && type == TYPE_CPE) + ac->apply_ltp(ac, &che->ch[1]); + } + } + if (che->ch[0].tns.present) + ac->apply_tns(che->ch[0].coeffs, &che->ch[0].tns, &che->ch[0].ics, 1); + if (che->ch[1].tns.present) + ac->apply_tns(che->ch[1].coeffs, &che->ch[1].tns, &che->ch[1].ics, 1); + if (type <= TYPE_CPE) + apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling); + if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) { + imdct_and_window(ac, &che->ch[0]); + if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) + ac->update_ltp(ac, &che->ch[0]); + if (type == TYPE_CPE) { + imdct_and_window(ac, &che->ch[1]); + if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) + ac->update_ltp(ac, &che->ch[1]); + } + if (ac->oc[1].m4ac.sbr > 0) { + ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret); + } + } + if (type <= TYPE_CCE) + apply_channel_coupling(ac, che, type, i, AFTER_IMDCT, apply_independent_coupling); + } + } + } +} + +static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) +{ + int size; + AACADTSHeaderInfo hdr_info; + uint8_t layout_map[MAX_ELEM_ID*4][3]; + int layout_map_tags, ret; + + size = avpriv_aac_parse_header(gb, &hdr_info); + if (size > 0) { + if (!ac->warned_num_aac_frames && hdr_info.num_aac_frames != 1) { + // This is 2 for "VLB " audio in NSV files. + // See samples/nsv/vlb_audio. + avpriv_report_missing_feature(ac->avctx, + "More than one AAC RDB per ADTS frame"); + ac->warned_num_aac_frames = 1; + } + push_output_configuration(ac); + if (hdr_info.chan_config) { + ac->oc[1].m4ac.chan_config = hdr_info.chan_config; + if ((ret = set_default_channel_config(ac->avctx, + layout_map, + &layout_map_tags, + hdr_info.chan_config)) < 0) + return ret; + if ((ret = output_configure(ac, layout_map, layout_map_tags, + FFMAX(ac->oc[1].status, + OC_TRIAL_FRAME), 0)) < 0) + return ret; + } else { + ac->oc[1].m4ac.chan_config = 0; + /** + * dual mono frames in Japanese DTV can have chan_config 0 + * WITHOUT specifying PCE. + * thus, set dual mono as default. + */ + if (ac->dmono_mode && ac->oc[0].status == OC_NONE) { + layout_map_tags = 2; + layout_map[0][0] = layout_map[1][0] = TYPE_SCE; + layout_map[0][2] = layout_map[1][2] = AAC_CHANNEL_FRONT; + layout_map[0][1] = 0; + layout_map[1][1] = 1; + if (output_configure(ac, layout_map, layout_map_tags, + OC_TRIAL_FRAME, 0)) + return -7; + } + } + ac->oc[1].m4ac.sample_rate = hdr_info.sample_rate; + ac->oc[1].m4ac.sampling_index = hdr_info.sampling_index; + ac->oc[1].m4ac.object_type = hdr_info.object_type; + if (ac->oc[0].status != OC_LOCKED || + ac->oc[0].m4ac.chan_config != hdr_info.chan_config || + ac->oc[0].m4ac.sample_rate != hdr_info.sample_rate) { + ac->oc[1].m4ac.sbr = -1; + ac->oc[1].m4ac.ps = -1; + } + if (!hdr_info.crc_absent) + skip_bits(gb, 16); + } + return size; +} + +static int aac_decode_er_frame(AVCodecContext *avctx, void *data, + int *got_frame_ptr, GetBitContext *gb) +{ + AACContext *ac = avctx->priv_data; + ChannelElement *che; + int err, i; + int samples = 1024; + int chan_config = ac->oc[1].m4ac.chan_config; + int aot = ac->oc[1].m4ac.object_type; + + if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) + samples >>= 1; + + ac->frame = data; + + if ((err = frame_configure_elements(avctx)) < 0) + return err; + + // The FF_PROFILE_AAC_* defines are all object_type - 1 + // This may lead to an undefined profile being signaled + ac->avctx->profile = ac->oc[1].m4ac.object_type - 1; + + ac->tags_mapped = 0; + + if (chan_config < 0 || chan_config >= 8) { + avpriv_request_sample(avctx, "Unknown ER channel configuration %d", + ac->oc[1].m4ac.chan_config); + return AVERROR_INVALIDDATA; + } + for (i = 0; i < tags_per_config[chan_config]; i++) { + const int elem_type = aac_channel_layout_map[chan_config-1][i][0]; + const int elem_id = aac_channel_layout_map[chan_config-1][i][1]; + if (!(che=get_che(ac, elem_type, elem_id))) { + av_log(ac->avctx, AV_LOG_ERROR, + "channel element %d.%d is not allocated\n", + elem_type, elem_id); + return AVERROR_INVALIDDATA; + } + if (aot != AOT_ER_AAC_ELD) + skip_bits(gb, 4); + switch (elem_type) { + case TYPE_SCE: + err = decode_ics(ac, &che->ch[0], gb, 0, 0); + break; + case TYPE_CPE: + err = decode_cpe(ac, gb, che); + break; + case TYPE_LFE: + err = decode_ics(ac, &che->ch[0], gb, 0, 0); + break; + } + if (err < 0) + return err; + } + + spectral_to_sample(ac); + + ac->frame->nb_samples = samples; + ac->frame->sample_rate = avctx->sample_rate; + *got_frame_ptr = 1; + + skip_bits_long(gb, get_bits_left(gb)); + return 0; +} + +static int aac_decode_frame_int(AVCodecContext *avctx, void *data, + int *got_frame_ptr, GetBitContext *gb, AVPacket *avpkt) +{ + AACContext *ac = avctx->priv_data; + ChannelElement *che = NULL, *che_prev = NULL; + enum RawDataBlockType elem_type, elem_type_prev = TYPE_END; + int err, elem_id; + int samples = 0, multiplier, audio_found = 0, pce_found = 0; + int is_dmono, sce_count = 0; + + ac->frame = data; + + if (show_bits(gb, 12) == 0xfff) { + if ((err = parse_adts_frame_header(ac, gb)) < 0) { + av_log(avctx, AV_LOG_ERROR, "Error decoding AAC frame header.\n"); + goto fail; + } + if (ac->oc[1].m4ac.sampling_index > 12) { + av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->oc[1].m4ac.sampling_index); + err = AVERROR_INVALIDDATA; + goto fail; + } + } + + if ((err = frame_configure_elements(avctx)) < 0) + goto fail; + + // The FF_PROFILE_AAC_* defines are all object_type - 1 + // This may lead to an undefined profile being signaled + ac->avctx->profile = ac->oc[1].m4ac.object_type - 1; + + ac->tags_mapped = 0; + // parse + while ((elem_type = get_bits(gb, 3)) != TYPE_END) { + elem_id = get_bits(gb, 4); + + if (elem_type < TYPE_DSE) { + if (!(che=get_che(ac, elem_type, elem_id))) { + av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", + elem_type, elem_id); + err = AVERROR_INVALIDDATA; + goto fail; + } + samples = 1024; + } + + switch (elem_type) { + + case TYPE_SCE: + err = decode_ics(ac, &che->ch[0], gb, 0, 0); + audio_found = 1; + sce_count++; + break; + + case TYPE_CPE: + err = decode_cpe(ac, gb, che); + audio_found = 1; + break; + + case TYPE_CCE: + err = decode_cce(ac, gb, che); + break; + + case TYPE_LFE: + err = decode_ics(ac, &che->ch[0], gb, 0, 0); + audio_found = 1; + break; + + case TYPE_DSE: + err = skip_data_stream_element(ac, gb); + break; + + case TYPE_PCE: { + uint8_t layout_map[MAX_ELEM_ID*4][3]; + int tags; + push_output_configuration(ac); + tags = decode_pce(avctx, &ac->oc[1].m4ac, layout_map, gb); + if (tags < 0) { + err = tags; + break; + } + if (pce_found) { + av_log(avctx, AV_LOG_ERROR, + "Not evaluating a further program_config_element as this construct is dubious at best.\n"); + } else { + err = output_configure(ac, layout_map, tags, OC_TRIAL_PCE, 1); + if (!err) + ac->oc[1].m4ac.chan_config = 0; + pce_found = 1; + } + break; + } + + case TYPE_FIL: + if (elem_id == 15) + elem_id += get_bits(gb, 8) - 1; + if (get_bits_left(gb) < 8 * elem_id) { + av_log(avctx, AV_LOG_ERROR, "TYPE_FIL: "overread_err); + err = AVERROR_INVALIDDATA; + goto fail; + } + while (elem_id > 0) + elem_id -= decode_extension_payload(ac, gb, elem_id, che_prev, elem_type_prev); + err = 0; /* FIXME */ + break; + + default: + err = AVERROR_BUG; /* should not happen, but keeps compiler happy */ + break; + } + + che_prev = che; + elem_type_prev = elem_type; + + if (err) + goto fail; + + if (get_bits_left(gb) < 3) { + av_log(avctx, AV_LOG_ERROR, overread_err); + err = AVERROR_INVALIDDATA; + goto fail; + } + } + + spectral_to_sample(ac); + + multiplier = (ac->oc[1].m4ac.sbr == 1) ? ac->oc[1].m4ac.ext_sample_rate > ac->oc[1].m4ac.sample_rate : 0; + samples <<= multiplier; + + if (ac->oc[1].status && audio_found) { + avctx->sample_rate = ac->oc[1].m4ac.sample_rate << multiplier; + avctx->frame_size = samples; + ac->oc[1].status = OC_LOCKED; + } + + if (multiplier) { + int side_size; + const uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size); + if (side && side_size>=4) + AV_WL32(side, 2*AV_RL32(side)); + } + + *got_frame_ptr = !!samples; + if (samples) { + ac->frame->nb_samples = samples; + ac->frame->sample_rate = avctx->sample_rate; + } else + av_frame_unref(ac->frame); + *got_frame_ptr = !!samples; + + /* for dual-mono audio (SCE + SCE) */ + is_dmono = ac->dmono_mode && sce_count == 2 && + ac->oc[1].channel_layout == (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT); + if (is_dmono) { + if (ac->dmono_mode == 1) + ((AVFrame *)data)->data[1] =((AVFrame *)data)->data[0]; + else if (ac->dmono_mode == 2) + ((AVFrame *)data)->data[0] =((AVFrame *)data)->data[1]; + } + + return 0; +fail: + pop_output_configuration(ac); + return err; +} + +static int aac_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame_ptr, AVPacket *avpkt) +{ + AACContext *ac = avctx->priv_data; + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; + GetBitContext gb; + int buf_consumed; + int buf_offset; + int err; + int new_extradata_size; + const uint8_t *new_extradata = av_packet_get_side_data(avpkt, + AV_PKT_DATA_NEW_EXTRADATA, + &new_extradata_size); + int jp_dualmono_size; + const uint8_t *jp_dualmono = av_packet_get_side_data(avpkt, + AV_PKT_DATA_JP_DUALMONO, + &jp_dualmono_size); + + if (new_extradata && 0) { + av_free(avctx->extradata); + avctx->extradata = av_mallocz(new_extradata_size + + FF_INPUT_BUFFER_PADDING_SIZE); + if (!avctx->extradata) + return AVERROR(ENOMEM); + avctx->extradata_size = new_extradata_size; + memcpy(avctx->extradata, new_extradata, new_extradata_size); + push_output_configuration(ac); + if (decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, + avctx->extradata, + avctx->extradata_size*8, 1) < 0) { + pop_output_configuration(ac); + return AVERROR_INVALIDDATA; + } + } + + ac->dmono_mode = 0; + if (jp_dualmono && jp_dualmono_size > 0) + ac->dmono_mode = 1 + *jp_dualmono; + if (ac->force_dmono_mode >= 0) + ac->dmono_mode = ac->force_dmono_mode; + + if (INT_MAX / 8 <= buf_size) + return AVERROR_INVALIDDATA; + + if ((err = init_get_bits(&gb, buf, buf_size * 8)) < 0) + return err; + + switch (ac->oc[1].m4ac.object_type) { + case AOT_ER_AAC_LC: + case AOT_ER_AAC_LTP: + case AOT_ER_AAC_LD: + case AOT_ER_AAC_ELD: + err = aac_decode_er_frame(avctx, data, got_frame_ptr, &gb); + break; + default: + err = aac_decode_frame_int(avctx, data, got_frame_ptr, &gb, avpkt); + } + if (err < 0) + return err; + + buf_consumed = (get_bits_count(&gb) + 7) >> 3; + for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++) + if (buf[buf_offset]) + break; + + return buf_size > buf_offset ? buf_consumed : buf_size; +} + +static av_cold int aac_decode_close(AVCodecContext *avctx) +{ + AACContext *ac = avctx->priv_data; + int i, type; + + for (i = 0; i < MAX_ELEM_ID; i++) { + for (type = 0; type < 4; type++) { + if (ac->che[type][i]) + ff_aac_sbr_ctx_close(&ac->che[type][i]->sbr); + av_freep(&ac->che[type][i]); + } + } + + ff_mdct_end(&ac->mdct); + ff_mdct_end(&ac->mdct_small); + ff_mdct_end(&ac->mdct_ld); + ff_mdct_end(&ac->mdct_ltp); + return 0; +} + +static void aacdec_init(AACContext *c) +{ + c->imdct_and_windowing = imdct_and_windowing; + c->apply_ltp = apply_ltp; + c->apply_tns = apply_tns; + c->windowing_and_mdct_ltp = windowing_and_mdct_ltp; + c->update_ltp = update_ltp; + + if(ARCH_MIPS) + ff_aacdec_init_mips(c); +} +/** + * AVOptions for Japanese DTV specific extensions (ADTS only) + */ +#define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM +static const AVOption options[] = { + {"dual_mono_mode", "Select the channel to decode for dual mono", + offsetof(AACContext, force_dmono_mode), AV_OPT_TYPE_INT, {.i64=-1}, -1, 2, + AACDEC_FLAGS, "dual_mono_mode"}, + + {"auto", "autoselection", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, + {"main", "Select Main/Left channel", 0, AV_OPT_TYPE_CONST, {.i64= 1}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, + {"sub" , "Select Sub/Right channel", 0, AV_OPT_TYPE_CONST, {.i64= 2}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, + {"both", "Select both channels", 0, AV_OPT_TYPE_CONST, {.i64= 0}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, + + {NULL}, +}; + +static const AVClass aac_decoder_class = { + .class_name = "AAC decoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; diff --git a/libavcodec/cbrt_tablegen.c b/libavcodec/cbrt_tablegen.c index e0a8e63..59918ae 100644 --- a/libavcodec/cbrt_tablegen.c +++ b/libavcodec/cbrt_tablegen.c @@ -19,19 +19,3 @@ * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include -#define CONFIG_HARDCODED_TABLES 0 -#include "cbrt_tablegen.h" -#include "tableprint.h" - -int main(void) -{ - cbrt_tableinit(); - - write_fileheader(); - - WRITE_ARRAY("static const", uint32_t, cbrt_tab); - - return 0; -} diff --git a/libavcodec/cbrt_tablegen_template.c b/libavcodec/cbrt_tablegen_template.c new file mode 100644 index 0000000..33746d2 --- /dev/null +++ b/libavcodec/cbrt_tablegen_template.c @@ -0,0 +1,37 @@ +/* + * Generate a header file for hardcoded AAC cube-root table + * + * Copyright (c) 2010 Reimar D?ffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#define CONFIG_HARDCODED_TABLES 0 +#include "cbrt_tablegen.h" +#include "tableprint.h" + +int main(void) +{ + cbrt_tableinit(); + + write_fileheader(); + + WRITE_ARRAY("static const", uint32_t, cbrt_tab); + + return 0; +} diff --git a/libavcodec/sinewin_tablegen.c b/libavcodec/sinewin_tablegen.c index 561ae3e..2013b95 100644 --- a/libavcodec/sinewin_tablegen.c +++ b/libavcodec/sinewin_tablegen.c @@ -19,28 +19,3 @@ * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include -#define CONFIG_HARDCODED_TABLES 0 -#define SINETABLE_CONST -#define SINETABLE(size) \ - float ff_sine_##size[size] -#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) -#include "sinewin_tablegen.h" -#include "tableprint.h" - -int main(void) -{ - int i; - - write_fileheader(); - - for (i = 5; i <= 13; i++) { - ff_init_ff_sine_windows(i); - printf("SINETABLE(%4i) = {\n", 1 << i); - write_float_array(ff_sine_windows[i], 1 << i); - printf("};\n"); - } - - return 0; -} diff --git a/libavcodec/sinewin_tablegen_template.c b/libavcodec/sinewin_tablegen_template.c new file mode 100644 index 0000000..50eb1a0 --- /dev/null +++ b/libavcodec/sinewin_tablegen_template.c @@ -0,0 +1,46 @@ +/* + * Generate a header file for hardcoded sine windows + * + * Copyright (c) 2009 Reimar D?ffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#define CONFIG_HARDCODED_TABLES 0 +#define SINETABLE_CONST +#define SINETABLE(size) \ + float ff_sine_##size[size] +#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) +#include "sinewin_tablegen.h" +#include "tableprint.h" + +int main(void) +{ + int i; + + write_fileheader(); + + for (i = 5; i <= 13; i++) { + ff_init_ff_sine_windows(i); + printf("SINETABLE(%4i) = {\n", 1 << i); + write_float_array(ff_sine_windows[i], 1 << i); + printf("};\n"); + } + + return 0; +} -- 1.8.2.1 From nedeljko.babic at imgtec.com Fri Aug 1 15:53:17 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:17 +0200 Subject: [FFmpeg-devel] [PATCH 11/14] libavcodec: Implementation of AAC_fixed_decoder (PS-module) [2/4] In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-12-git-send-email-nedeljko.babic@imgtec.com> From: Jovan Zelincevic Add fixed point implementation of functions for generating tables. Signed-off-by: Nedeljko Babic --- libavcodec/aacps_fixed_tablegen.c | 94 +++++++++ libavcodec/aacps_fixed_tablegen.h | 429 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 523 insertions(+) create mode 100644 libavcodec/aacps_fixed_tablegen.c create mode 100644 libavcodec/aacps_fixed_tablegen.h diff --git a/libavcodec/aacps_fixed_tablegen.c b/libavcodec/aacps_fixed_tablegen.c new file mode 100644 index 0000000..b2fda6e --- /dev/null +++ b/libavcodec/aacps_fixed_tablegen.c @@ -0,0 +1,94 @@ +/* + * Generate a header file for hardcoded Parametric Stereo tables + * + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#define CONFIG_HARDCODED_TABLES 0 + +#include "aacps_fixed_tablegen.h" +#include "tableprint.h" + +void write_int32_t_3d_array (const void *p, int b, int c, int d) +{ + int i; + const int32_t *f = p; + for (i = 0; i < b; i++) { + printf("{\n"); + write_uint32_t_2d_array(f, c, d); + printf("},\n"); + f += c * d; + } +} + +void write_int32_t_4d_array (const void *p, int a, int b, int c, int d) +{ + int i; + const int32_t *f = p; + for (i = 0; i < a; i++) { + printf("{\n"); + write_int32_t_3d_array(f, b, c, d); + printf("},\n"); + f += b * c * d; + } +} + +int main(void) +{ + ps_tableinit(); + + write_fileheader(); + + printf("static const int32_t pd_re_smooth[8*8*8] = {\n"); + write_int32_t_array(pd_re_smooth, 8*8*8); + printf("};\n"); + printf("static const int32_t pd_im_smooth[8*8*8] = {\n"); + write_int32_t_array(pd_im_smooth, 8*8*8); + printf("};\n"); + + printf("static const int32_t HA[46][8][4] = {\n"); + write_int32_t_3d_array(HA, 46, 8, 4); + printf("};\n"); + printf("static const int32_t HB[46][8][4] = {\n"); + write_int32_t_3d_array(HB, 46, 8, 4); + printf("};\n"); + + printf("static const DECLARE_ALIGNED(16, int32_t, f20_0_8)[8][8][2] = {\n"); + write_int32_t_3d_array(f20_0_8, 8, 8, 2); + printf("};\n"); + printf("static const DECLARE_ALIGNED(16, int32_t, f34_0_12)[12][8][2] = {\n"); + write_int32_t_3d_array(f34_0_12, 12, 8, 2); + printf("};\n"); + printf("static const DECLARE_ALIGNED(16, int32_t, f34_1_8)[8][8][2] = {\n"); + write_int32_t_3d_array(f34_1_8, 8, 8, 2); + printf("};\n"); + printf("static const DECLARE_ALIGNED(16, int32_t, f34_2_4)[4][8][2] = {\n"); + write_int32_t_3d_array(f34_2_4, 4, 8, 2); + printf("};\n"); + + printf("static const DECLARE_ALIGNED(16, int32_t, Q_fract_allpass)[2][50][3][2] = {\n"); + write_int32_t_4d_array(Q_fract_allpass, 2, 50, 3, 2); + printf("};\n"); + printf("static const DECLARE_ALIGNED(16, int32_t, phi_fract)[2][50][2] = {\n"); + write_int32_t_3d_array(phi_fract, 2, 50, 2); + printf("};\n"); + + return 0; +} diff --git a/libavcodec/aacps_fixed_tablegen.h b/libavcodec/aacps_fixed_tablegen.h new file mode 100644 index 0000000..ffb0007 --- /dev/null +++ b/libavcodec/aacps_fixed_tablegen.h @@ -0,0 +1,429 @@ +/* + * Header file for hardcoded Parametric Stereo tables + * + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * 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 + */ + +#ifndef AACPS_TABLEGEN_FIXED_H +#define AACPS_TABLEGEN_FIXED_H + +#include +#include + +#if CONFIG_HARDCODED_TABLES +#define ps_tableinit() +#define TABLE_CONST const +#include "libavcodec/aacps_fixed_tables.h" +#else +#include "libavutil/common.h" +#include "libavutil/mathematics.h" +#include "libavutil/mem.h" + +#include "float_emu.h" +#include "float_emu_tab.c" +#define NR_ALLPASS_BANDS20 30 +#define NR_ALLPASS_BANDS34 50 +#define PS_AP_LINKS 3 +#define TABLE_CONST +#define Q30(x) (int)((x)*1073741824.0 + 0.5) +#define Q31(x) (int)((x)*2147483648.0 + 0.5) +static int pd_re_smooth[8*8*8]; +static int pd_im_smooth[8*8*8]; +static int HA[46][8][4]; +static int HB[46][8][4]; +static DECLARE_ALIGNED(16, int, f20_0_8) [ 8][8][2]; +static DECLARE_ALIGNED(16, int, f34_0_12)[12][8][2]; +static DECLARE_ALIGNED(16, int, f34_1_8) [ 8][8][2]; +static DECLARE_ALIGNED(16, int, f34_2_4) [ 4][8][2]; +static DECLARE_ALIGNED(16, int, Q_fract_allpass)[2][50][3][2]; +static DECLARE_ALIGNED(16, int, phi_fract)[2][50][2]; + +static const int g0_Q8[] = { + Q31(0.00746082949812f), Q31(0.02270420949825f), Q31(0.04546865930473f), Q31(0.07266113929591f), + Q31(0.09885108575264f), Q31(0.11793710567217f), Q31(0.125f) +}; + +static const int g0_Q12[] = { + Q31(0.04081179924692f), Q31(0.03812810994926f), Q31(0.05144908135699f), Q31(0.06399831151592f), + Q31(0.07428313801106f), Q31(0.08100347892914f), Q31(0.08333333333333f) +}; + +static const int g1_Q8[] = { + Q31(0.01565675600122f), Q31(0.03752716391991f), Q31(0.05417891378782f), Q31(0.08417044116767f), + Q31(0.10307344158036f), Q31(0.12222452249753f), Q31(0.125f) +}; + +static const int g2_Q4[] = { + Q31(-0.05908211155639f), Q31(-0.04871498374946f), Q31(0.0f), Q31(0.07778723915851f), + Q31( 0.16486303567403f), Q31( 0.23279856662996f), Q31(0.25f) +}; + +static const int sintbl_4[4] = { 0, 1073741824, 0, -1073741824 }; +static const int costbl_4[4] = { 1073741824, 0, -1073741824, 0 }; +static const int sintbl_8[8] = { 0, 759250125, 1073741824, 759250125, + 0, -759250125, -1073741824, -759250125 }; +static const int costbl_8[8] = { 1073741824, 759250125, 0, -759250125, + -1073741824, -759250125, 0, 759250125 }; +static const int sintbl_12[12] = { 0, 536870912, 929887697, 1073741824, + 929887697, 536870912, 0, -536870912, + -929887697, -1073741824, -929887697, -536870912 }; +static const int costbl_12[12] = { 1073741824, 929887697, 536870912, 0, + -536870912, -929887697, -1073741824, -929887697, + -536870912, 0, 536870912, 929887697 }; + +static void make_filters_from_proto(int (*filter)[8][2], const int *proto, int bands) +{ + + const int *sinptr, *cosptr; + int s, c, sinhalf, coshalf; + int q, n; + long long accu; + + if (bands == 4) { + sinptr = sintbl_4; + cosptr = costbl_4; + sinhalf = 759250125; + coshalf = 759250125; + } else if (bands == 8) { + sinptr = sintbl_8; + cosptr = costbl_8; + sinhalf = 410903207; + coshalf = 992008094; + } else { + sinptr = sintbl_12; + cosptr = costbl_12; + sinhalf = 277904834; + coshalf = 1037154959; + } + + for (q = 0; q < bands; q++) { + for (n = 0; n < 7; n++) { + int theta = (q*(n-6) + (n>>1) - 3) % bands; + + if (theta < 0) + theta += bands; + s = sinptr[theta]; + c = cosptr[theta]; + + if (n & 1) { + accu = (long long)c * coshalf; + accu -= (long long)s * sinhalf; + theta = (int)((accu + 0x20000000) >> 30); + + accu = (long long)s * coshalf; + accu += (long long)c * sinhalf; + s = (int)((accu + 0x20000000) >> 30); + c = theta; + } + accu = (long long)proto[n] * c; + filter[q][n][0] = (int)((accu + 0x20000000) >> 30); + + accu = (long long)proto[n] * s; + filter[q][n][1] = -(int)((accu + 0x20000000) >> 30); + } + } +} + +static void ps_tableinit(void) +{ + static const int ipdopd_sin[] = { Q30(0), Q30(M_SQRT1_2), Q30(1), Q30( M_SQRT1_2), Q30( 0), Q30(-M_SQRT1_2), Q30(-1), Q30(-M_SQRT1_2) }; + static const int ipdopd_cos[] = { Q30(1), Q30(M_SQRT1_2), Q30(0), Q30(-M_SQRT1_2), Q30(-1), Q30(-M_SQRT1_2), Q30( 0), Q30( M_SQRT1_2) }; + int pd0, pd1, pd2; + int idx; + + static const int alpha_tab[] = + { + Q30(1.5146213770f/M_PI), Q30(1.5181334019f/M_PI), Q30(1.5234849453f/M_PI), Q30(1.5369486809f/M_PI), Q30(1.5500687361f/M_PI), Q30(1.5679757595f/M_PI), + Q30(1.4455626011f/M_PI), Q30(1.4531552792f/M_PI), Q30(1.4648091793f/M_PI), Q30(1.4945238829f/M_PI), Q30(1.5239057541f/M_PI), Q30(1.5644006729f/M_PI), + Q30(1.3738563061f/M_PI), Q30(1.3851221800f/M_PI), Q30(1.4026404619f/M_PI), Q30(1.4484288692f/M_PI), Q30(1.4949874878f/M_PI), Q30(1.5604078770f/M_PI), + Q30(1.2645189762f/M_PI), Q30(1.2796478271f/M_PI), Q30(1.3038636446f/M_PI), Q30(1.3710125685f/M_PI), Q30(1.4443849325f/M_PI), Q30(1.5532352924f/M_PI), + Q30(1.1507037878f/M_PI), Q30(1.1669205427f/M_PI), Q30(1.1938756704f/M_PI), Q30(1.2754167318f/M_PI), Q30(1.3761177063f/M_PI), Q30(1.5429240465f/M_PI), + Q30(1.0079245567f/M_PI), Q30(1.0208238363f/M_PI), Q30(1.0433073044f/M_PI), Q30(1.1208510399f/M_PI), Q30(1.2424604893f/M_PI), Q30(1.5185726881f/M_PI), + Q30(0.8995233774f/M_PI), Q30(0.9069069624f/M_PI), Q30(0.9201194048f/M_PI), Q30(0.9698365927f/M_PI), Q30(1.0671583414f/M_PI), Q30(1.4647934437f/M_PI), + Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), + Q30(0.6712729335f/M_PI), Q30(0.6638893485f/M_PI), Q30(0.6506769061f/M_PI), Q30(0.6009597182f/M_PI), Q30(0.5036380291f/M_PI), Q30(0.1060028747f/M_PI), + Q30(0.5628717542f/M_PI), Q30(0.5499725342f/M_PI), Q30(0.5274890065f/M_PI), Q30(0.4499453008f/M_PI), Q30(0.3283358216f/M_PI), Q30(0.0522236861f/M_PI), + Q30(0.4200925827f/M_PI), Q30(0.4038758278f/M_PI), Q30(0.3769206405f/M_PI), Q30(0.2953795493f/M_PI), Q30(0.1946786791f/M_PI), Q30(0.0278722942f/M_PI), + Q30(0.3062773645f/M_PI), Q30(0.2911485136f/M_PI), Q30(0.2669326365f/M_PI), Q30(0.1997837722f/M_PI), Q30(0.1264114529f/M_PI), Q30(0.0175609849f/M_PI), + Q30(0.1969399750f/M_PI), Q30(0.1856741160f/M_PI), Q30(0.1681558639f/M_PI), Q30(0.1223674342f/M_PI), Q30(0.0758088827f/M_PI), Q30(0.0103884479f/M_PI), + Q30(0.1252337098f/M_PI), Q30(0.1176410317f/M_PI), Q30(0.1059871912f/M_PI), Q30(0.0762724727f/M_PI), Q30(0.0468905345f/M_PI), Q30(0.0063956482f/M_PI), + Q30(0.0561749674f/M_PI), Q30(0.0526629239f/M_PI), Q30(0.0473113805f/M_PI), Q30(0.0338476151f/M_PI), Q30(0.0207276177f/M_PI), Q30(0.0028205961f/M_PI), + Q30(1.5676341057f/M_PI), Q30(1.5678333044f/M_PI), Q30(1.5681363344f/M_PI), Q30(1.5688960552f/M_PI), Q30(1.5696337223f/M_PI), Q30(1.5706381798f/M_PI), + Q30(1.5651730299f/M_PI), Q30(1.5655272007f/M_PI), Q30(1.5660660267f/M_PI), Q30(1.5674170256f/M_PI), Q30(1.5687289238f/M_PI), Q30(1.5705151558f/M_PI), + Q30(1.5607966185f/M_PI), Q30(1.5614265203f/M_PI), Q30(1.5623844862f/M_PI), Q30(1.5647867918f/M_PI), Q30(1.5671195984f/M_PI), Q30(1.5702962875f/M_PI), + Q30(1.5530153513f/M_PI), Q30(1.5541347265f/M_PI), Q30(1.5558375120f/M_PI), Q30(1.5601085424f/M_PI), Q30(1.5642569065f/M_PI), Q30(1.5699069500f/M_PI), + Q30(1.5391840935f/M_PI), Q30(1.5411708355f/M_PI), Q30(1.5441943407f/M_PI), Q30(1.5517836809f/M_PI), Q30(1.5591609478f/M_PI), Q30(1.5692136288f/M_PI), + Q30(1.5146213770f/M_PI), Q30(1.5181334019f/M_PI), Q30(1.5234849453f/M_PI), Q30(1.5369486809f/M_PI), Q30(1.5500687361f/M_PI), Q30(1.5679757595f/M_PI), + Q30(1.4915299416f/M_PI), Q30(1.4964480400f/M_PI), Q30(1.5039558411f/M_PI), Q30(1.5229074955f/M_PI), Q30(1.5414420366f/M_PI), Q30(1.5667995214f/M_PI), + Q30(1.4590617418f/M_PI), Q30(1.4658898115f/M_PI), Q30(1.4763505459f/M_PI), Q30(1.5029321909f/M_PI), Q30(1.5291173458f/M_PI), Q30(1.5651149750f/M_PI), + Q30(1.4136143923f/M_PI), Q30(1.4229322672f/M_PI), Q30(1.4373078346f/M_PI), Q30(1.4743183851f/M_PI), Q30(1.5113102198f/M_PI), Q30(1.5626684427f/M_PI), + Q30(1.3505556583f/M_PI), Q30(1.3628427982f/M_PI), Q30(1.3820509911f/M_PI), Q30(1.4327841997f/M_PI), Q30(1.4850014448f/M_PI), Q30(1.5590143204f/M_PI), + Q30(1.2645189762f/M_PI), Q30(1.2796478271f/M_PI), Q30(1.3038636446f/M_PI), Q30(1.3710125685f/M_PI), Q30(1.4443849325f/M_PI), Q30(1.5532352924f/M_PI), + Q30(1.1919227839f/M_PI), Q30(1.2081253529f/M_PI), Q30(1.2346779108f/M_PI), Q30(1.3123005629f/M_PI), Q30(1.4034168720f/M_PI), Q30(1.5471596718f/M_PI), + Q30(1.1061993837f/M_PI), Q30(1.1219338179f/M_PI), Q30(1.1484941244f/M_PI), Q30(1.2320860624f/M_PI), Q30(1.3421301842f/M_PI), Q30(1.5373806953f/M_PI), + Q30(1.0079245567f/M_PI), Q30(1.0208238363f/M_PI), Q30(1.0433073044f/M_PI), Q30(1.1208510399f/M_PI), Q30(1.2424604893f/M_PI), Q30(1.5185726881f/M_PI), + Q30(0.8995233774f/M_PI), Q30(0.9069069624f/M_PI), Q30(0.9201194048f/M_PI), Q30(0.9698365927f/M_PI), Q30(1.0671583414f/M_PI), Q30(1.4647934437f/M_PI), + Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), + Q30(0.6712729335f/M_PI), Q30(0.6638893485f/M_PI), Q30(0.6506769061f/M_PI), Q30(0.6009597182f/M_PI), Q30(0.5036380291f/M_PI), Q30(0.1060028747f/M_PI), + Q30(0.5628717542f/M_PI), Q30(0.5499725342f/M_PI), Q30(0.5274890065f/M_PI), Q30(0.4499453008f/M_PI), Q30(0.3283358216f/M_PI), Q30(0.0522236861f/M_PI), + Q30(0.4645969570f/M_PI), Q30(0.4488625824f/M_PI), Q30(0.4223022461f/M_PI), Q30(0.3387103081f/M_PI), Q30(0.2286661267f/M_PI), Q30(0.0334156826f/M_PI), + Q30(0.3788735867f/M_PI), Q30(0.3626709878f/M_PI), Q30(0.3361184299f/M_PI), Q30(0.2584958076f/M_PI), Q30(0.1673794836f/M_PI), Q30(0.0236366931f/M_PI), + Q30(0.3062773645f/M_PI), Q30(0.2911485136f/M_PI), Q30(0.2669326365f/M_PI), Q30(0.1997837722f/M_PI), Q30(0.1264114529f/M_PI), Q30(0.0175609849f/M_PI), + Q30(0.2202406377f/M_PI), Q30(0.2079535723f/M_PI), Q30(0.1887452900f/M_PI), Q30(0.1380121708f/M_PI), Q30(0.0857949182f/M_PI), Q30(0.0117820343f/M_PI), + Q30(0.1571819335f/M_PI), Q30(0.1478640437f/M_PI), Q30(0.1334884763f/M_PI), Q30(0.0964778885f/M_PI), Q30(0.0594860613f/M_PI), Q30(0.0081279324f/M_PI), + Q30(0.1117345318f/M_PI), Q30(0.1049065739f/M_PI), Q30(0.0944457650f/M_PI), Q30(0.0678641573f/M_PI), Q30(0.0416790098f/M_PI), Q30(0.0056813755f/M_PI), + Q30(0.0792663917f/M_PI), Q30(0.0743482932f/M_PI), Q30(0.0668405443f/M_PI), Q30(0.0478888862f/M_PI), Q30(0.0293543357f/M_PI), Q30(0.0039967746f/M_PI), + Q30(0.0561749674f/M_PI), Q30(0.0526629239f/M_PI), Q30(0.0473113805f/M_PI), Q30(0.0338476151f/M_PI), Q30(0.0207276177f/M_PI), Q30(0.0028205961f/M_PI), + Q30(0.0316122435f/M_PI), Q30(0.0296254847f/M_PI), Q30(0.0266019460f/M_PI), Q30(0.0190126132f/M_PI), Q30(0.0116353342f/M_PI), Q30(0.0015827164f/M_PI), + Q30(0.0177809205f/M_PI), Q30(0.0166615788f/M_PI), Q30(0.0149587989f/M_PI), Q30(0.0106877899f/M_PI), Q30(0.0065393616f/M_PI), Q30(0.0008894200f/M_PI), + Q30(0.0099996664f/M_PI), Q30(0.0093698399f/M_PI), Q30(0.0084118480f/M_PI), Q30(0.0060095116f/M_PI), Q30(0.0036767013f/M_PI), Q30(0.0005000498f/M_PI), + Q30(0.0056233541f/M_PI), Q30(0.0052691097f/M_PI), Q30(0.0047303112f/M_PI), Q30(0.0033792770f/M_PI), Q30(0.0020674451f/M_PI), Q30(0.0002811795f/M_PI), + Q30(0.0031622672f/M_PI), Q30(0.0029630491f/M_PI), Q30(0.0026600463f/M_PI), Q30(0.0019002859f/M_PI), Q30(0.0011625893f/M_PI), Q30(0.0001581155f/M_PI) + }; + + static const int gamma_tab[] = + { + Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0433459543f/M_PI), Q30(0.0672172382f/M_PI), Q30(0.0997167900f/M_PI), Q30(0.1162951663f/M_PI), Q30(0.1250736862f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0672341362f/M_PI), Q30(0.1045235619f/M_PI), Q30(0.1558904350f/M_PI), Q30(0.1824723780f/M_PI), Q30(0.1966800541f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1315985769f/M_PI), Q30(0.2072522491f/M_PI), Q30(0.3188187480f/M_PI), Q30(0.3825501204f/M_PI), Q30(0.4193951190f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1784276664f/M_PI), Q30(0.2856673002f/M_PI), Q30(0.4630723596f/M_PI), Q30(0.5971632004f/M_PI), Q30(0.7603877187f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1315985769f/M_PI), Q30(0.2072522491f/M_PI), Q30(0.3188187480f/M_PI), Q30(0.3825501204f/M_PI), Q30(0.4193951190f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0672341362f/M_PI), Q30(0.1045235619f/M_PI), Q30(0.1558904350f/M_PI), Q30(0.1824723780f/M_PI), Q30(0.1966800541f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0433459543f/M_PI), Q30(0.0672172382f/M_PI), Q30(0.0997167900f/M_PI), Q30(0.1162951663f/M_PI), Q30(0.1250736862f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0011053939f/M_PI), Q30(0.0017089852f/M_PI), Q30(0.0025254129f/M_PI), Q30(0.0029398468f/M_PI), Q30(0.0031597170f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0019607407f/M_PI), Q30(0.0030395309f/M_PI), Q30(0.0044951206f/M_PI), Q30(0.0052305623f/M_PI), Q30(0.0056152637f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0034913034f/M_PI), Q30(0.0054070661f/M_PI), Q30(0.0079917293f/M_PI), Q30(0.0092999367f/M_PI), Q30(0.0099875759f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0062100487f/M_PI), Q30(0.0096135242f/M_PI), Q30(0.0142110568f/M_PI), Q30(0.0165348612f/M_PI), Q30(0.0177587029f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0110366223f/M_PI), Q30(0.0170863140f/M_PI), Q30(0.0252620988f/M_PI), Q30(0.0293955617f/M_PI), Q30(0.0315726399f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0275881495f/M_PI), Q30(0.0427365713f/M_PI), Q30(0.0632618815f/M_PI), Q30(0.0736731067f/M_PI), Q30(0.0791663304f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0387469754f/M_PI), Q30(0.0600636788f/M_PI), Q30(0.0890387669f/M_PI), Q30(0.1037906483f/M_PI), Q30(0.1115923747f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0541138873f/M_PI), Q30(0.0839984417f/M_PI), Q30(0.1248718798f/M_PI), Q30(0.1458375156f/M_PI), Q30(0.1569785923f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0747506917f/M_PI), Q30(0.1163287833f/M_PI), Q30(0.1738867164f/M_PI), Q30(0.2038587779f/M_PI), Q30(0.2199459076f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1212290376f/M_PI), Q30(0.1903949380f/M_PI), Q30(0.2907958031f/M_PI), Q30(0.3466993868f/M_PI), Q30(0.3782821596f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1418247074f/M_PI), Q30(0.2240308374f/M_PI), Q30(0.3474813402f/M_PI), Q30(0.4202919006f/M_PI), Q30(0.4637607038f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1784276664f/M_PI), Q30(0.2856673002f/M_PI), Q30(0.4630723596f/M_PI), Q30(0.5971632004f/M_PI), Q30(0.7603877187f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1418247074f/M_PI), Q30(0.2240308374f/M_PI), Q30(0.3474813402f/M_PI), Q30(0.4202919006f/M_PI), Q30(0.4637607038f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1212290376f/M_PI), Q30(0.1903949380f/M_PI), Q30(0.2907958031f/M_PI), Q30(0.3466993868f/M_PI), Q30(0.3782821596f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0747506917f/M_PI), Q30(0.1163287833f/M_PI), Q30(0.1738867164f/M_PI), Q30(0.2038587779f/M_PI), Q30(0.2199459076f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0541138873f/M_PI), Q30(0.0839984417f/M_PI), Q30(0.1248718798f/M_PI), Q30(0.1458375156f/M_PI), Q30(0.1569785923f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0387469754f/M_PI), Q30(0.0600636788f/M_PI), Q30(0.0890387669f/M_PI), Q30(0.1037906483f/M_PI), Q30(0.1115923747f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0275881495f/M_PI), Q30(0.0427365713f/M_PI), Q30(0.0632618815f/M_PI), Q30(0.0736731067f/M_PI), Q30(0.0791663304f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0110366223f/M_PI), Q30(0.0170863140f/M_PI), Q30(0.0252620988f/M_PI), Q30(0.0293955617f/M_PI), Q30(0.0315726399f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0062100487f/M_PI), Q30(0.0096135242f/M_PI), Q30(0.0142110568f/M_PI), Q30(0.0165348612f/M_PI), Q30(0.0177587029f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0034913034f/M_PI), Q30(0.0054070661f/M_PI), Q30(0.0079917293f/M_PI), Q30(0.0092999367f/M_PI), Q30(0.0099875759f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0019607407f/M_PI), Q30(0.0030395309f/M_PI), Q30(0.0044951206f/M_PI), Q30(0.0052305623f/M_PI), Q30(0.0056152637f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0011053939f/M_PI), Q30(0.0017089852f/M_PI), Q30(0.0025254129f/M_PI), Q30(0.0029398468f/M_PI), Q30(0.0031597170f/M_PI) + }; + + static const int iid_par_dequant_c1[] = { + //iid_par_dequant_default + Q30(1.41198278375959f), Q30(1.40313815268360f), Q30(1.38687670404960f), Q30(1.34839972492648f), + Q30(1.29124937110028f), Q30(1.19603741667993f), Q30(1.10737240362323f), Q30(1), + Q30(0.87961716655242f), Q30(0.75464859232732f), Q30(0.57677990744575f), Q30(0.42640143271122f), + Q30(0.27671828230984f), Q30(0.17664462766713f), Q30(0.07940162697653f), + //iid_par_dequant_fine + Q30(1.41420649135832f), Q30(1.41419120222364f), Q30(1.41414285699784f), Q30(1.41399000859438f), + Q30(1.41350698548044f), Q30(1.41198278375959f), Q30(1.40977302262355f), Q30(1.40539479488545f), + Q30(1.39677960498402f), Q30(1.38005309967827f), Q30(1.34839972492648f), Q30(1.31392017367631f), + Q30(1.26431008149654f), Q30(1.19603741667993f), Q30(1.10737240362323f), Q30(1), + Q30(0.87961716655242f), Q30(0.75464859232732f), Q30(0.63365607219232f), Q30(0.52308104267543f), + Q30(0.42640143271122f), Q30(0.30895540465965f), Q30(0.22137464873077f), Q30(0.15768788954414f), + Q30(0.11198225164225f), Q30(0.07940162697653f), Q30(0.04469901562677f), Q30(0.02514469318284f), + Q30(0.01414142856998f), Q30(0.00795258154731f), Q30(0.00447211359449f), + }; + + static const int acos_icc_invq[] = { + Q31(0), Q31(0.178427635f/M_PI), Q31(0.28566733f/M_PI), Q31(0.46307236f/M_PI), Q31(0.59716315f/M_PI), Q31(0.78539816f/M_PI), Q31(1.10030855f/M_PI), Q31(1.57079633f/M_PI) + }; + int iid, icc; + + int k, m; + static const int8_t f_center_20[] = { + -3, -1, 1, 3, 5, 7, 10, 14, 18, 22, + }; + static const int32_t f_center_34[] = { + Q31( 2/768.0),Q31( 6/768.0),Q31(10/768.0),Q31(14/768.0),Q31( 18/768.0),Q31( 22/768.0),Q31( 26/768.0),Q31(30/768.0), + Q31( 34/768.0),Q31(-10/768.0),Q31(-6/768.0),Q31(-2/768.0),Q31( 51/768.0),Q31( 57/768.0),Q31( 15/768.0),Q31(21/768.0), + Q31( 27/768.0),Q31( 33/768.0),Q31(39/768.0),Q31(45/768.0),Q31( 54/768.0),Q31( 66/768.0),Q31( 78/768.0),Q31(42/768.0), + Q31(102/768.0),Q31( 66/768.0),Q31(78/768.0),Q31(90/768.0),Q31(102/768.0),Q31(114/768.0),Q31(126/768.0),Q31(90/768.0) + }; + static const int fractional_delay_links[] = { Q31(0.43f), Q31(0.75f), Q31(0.347f) }; + const int fractional_delay_gain = Q31(0.39f); + long long accu; + + for (pd0 = 0; pd0 < 8; pd0++) { + int pd0_re = (ipdopd_cos[pd0]+2)>>2; + int pd0_im = (ipdopd_sin[pd0]+2)>>2; + for (pd1 = 0; pd1 < 8; pd1++) { + int pd1_re = ipdopd_cos[pd1] >> 1; + int pd1_im = ipdopd_sin[pd1] >> 1; + for (pd2 = 0; pd2 < 8; pd2++) { + int shift, round; + int pd2_re = ipdopd_cos[pd2]; + int pd2_im = ipdopd_sin[pd2]; + int re_smooth = pd0_re + pd1_re + pd2_re; + int im_smooth = pd0_im + pd1_im + pd2_im; + + aac_float_t pd_mag = int2float(((ipdopd_cos[(pd0-pd1)&7]+8)>>4) + ((ipdopd_cos[(pd0-pd2)&7]+4)>>3) + + ((ipdopd_cos[(pd1-pd2)&7]+2)>>2) + 0x15000000, 2); + pd_mag = float_div(FLOAT_1, float_sqrt(pd_mag)); + shift = 30 - pd_mag.expo; + round = 1 << (shift-1); + accu = (long long)re_smooth * pd_mag.mant; + pd_re_smooth[pd0*64+pd1*8+pd2] = (int)((accu + round) >> shift); + accu = (long long)im_smooth * pd_mag.mant; + pd_im_smooth[pd0*64+pd1*8+pd2] = (int)((accu + round) >> shift); + } + } + } + + idx = 0; + for (iid = 0; iid < 46; iid++) { + int c1, c2; + + c1 = iid_par_dequant_c1[iid]; + if (iid < 15) + c2 = iid_par_dequant_c1[14-iid]; + else + c2 = iid_par_dequant_c1[60-iid]; + + for (icc = 0; icc < 8; icc++) { + /*if (PS_BASELINE || ps->icc_mode < 3)*/{ + int alpha, beta; + int ca, sa, cb, sb; + + alpha = acos_icc_invq[icc]; + accu = (long long)alpha * 1518500250; + beta = (int)((accu + 0x40000000) >> 31); + accu = (long long)beta * (c1 - c2); + alpha >>= 1; + beta = (int)((accu + 0x40000000) >> 31); + aac_fixed_sincos(beta + alpha, &sa, &ca); + aac_fixed_sincos(beta - alpha, &sb, &cb); + + accu = (long long)c2 * ca; + HA[iid][icc][0] = (int)((accu + 0x20000000) >> 30); + accu = (long long)c1 * cb; + HA[iid][icc][1] = (int)((accu + 0x20000000) >> 30); + accu = (long long)c2 * sa; + HA[iid][icc][2] = (int)((accu + 0x20000000) >> 30); + accu = (long long)c1 * sb; + HA[iid][icc][3] = (int)((accu + 0x20000000) >> 30); + } /* else */ { + int alpha_int, gamma_int; + int alpha_c_int, alpha_s_int, gamma_c_int, gamma_s_int; + + alpha_int = alpha_tab[idx]; + gamma_int = gamma_tab[idx]; + + aac_fixed_sincos(alpha_int, &alpha_s_int, &alpha_c_int); + aac_fixed_sincos(gamma_int, &gamma_s_int, &gamma_c_int); + + accu = (long long)alpha_c_int * 1518500250; + alpha_c_int = (int)((accu + 0x20000000) >> 30); + accu = (long long)alpha_s_int * 1518500250; + alpha_s_int = (int)((accu + 0x20000000) >> 30); + + accu = (long long)alpha_c_int * gamma_c_int; + HB[iid][icc][0] = (int)((accu + 0x20000000) >> 30); + accu = (long long)alpha_s_int * gamma_c_int; + HB[iid][icc][1] = (int)((accu + 0x20000000) >> 30); + accu = (long long)alpha_s_int * gamma_s_int; + HB[iid][icc][2] = -(int)((accu + 0x20000000) >> 30); + accu = (long long)alpha_c_int * gamma_s_int; + HB[iid][icc][3] = (int)((accu + 0x20000000) >> 30); + } + + if (icc < 5 || icc > 6) + idx++; + } + } + + for (k = 0; k < NR_ALLPASS_BANDS20; k++) { + int theta, f_center; + int c, s; + + if (k < FF_ARRAY_ELEMS(f_center_20)) + f_center = f_center_20[k]; + else + f_center = (k << 3) - 52; + + for (m = 0; m < PS_AP_LINKS; m++) { + accu = (long long)fractional_delay_links[m] * f_center; + theta = (int)((accu + 8) >> 4); + aac_fixed_sincos(-theta, &s, &c); + Q_fract_allpass[0][k][m][0] = c; + Q_fract_allpass[0][k][m][1] = s; + } + + accu = (long long)fractional_delay_gain * f_center; + theta = (int)((accu + 8) >> 4); + aac_fixed_sincos(-theta, &s, &c); + phi_fract[0][k][0] = c; + phi_fract[0][k][1] = s; + } + + for (k = 0; k < NR_ALLPASS_BANDS34; k++) { + int theta, f_center; + int c, s; + + if (k < FF_ARRAY_ELEMS(f_center_34)) + f_center = f_center_34[k]; + else + f_center = (k << 26) - (53 << 25); + + for (m = 0; m < PS_AP_LINKS; m++) { + accu = (long long)fractional_delay_links[m] * f_center; + theta = (int)((accu + 0x10000000) >> 27); + aac_fixed_sincos(-theta, &s, &c); + Q_fract_allpass[1][k][m][0] = c; + Q_fract_allpass[1][k][m][1] = s; + } + + accu = (long long)fractional_delay_gain * f_center; + theta = (int)((accu + 0x10000000) >> 27); + aac_fixed_sincos(-theta, &s, &c); + phi_fract[1][k][0] = c; + phi_fract[1][k][1] = s; + } + + make_filters_from_proto(f20_0_8, g0_Q8, 8); + make_filters_from_proto(f34_0_12, g0_Q12, 12); + make_filters_from_proto(f34_1_8, g1_Q8, 8); + make_filters_from_proto(f34_2_4, g2_Q4, 4); +} +#endif /* CONFIG_HARDCODED_TABLES */ + +#endif /* AACPS_FIXED_TABLEGEN_H */ -- 1.8.2.1 From nedeljko.babic at imgtec.com Fri Aug 1 15:53:12 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:12 +0200 Subject: [FFmpeg-devel] [PATCH 06/14] libavcodec: Implementation of AAC_fixed_decoder (SBR-module) [1/4] In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-7-git-send-email-nedeljko.babic@imgtec.com> From: Djordje Pesut Move the existing code to a new template file. Signed-off-by: Nedeljko Babic --- libavcodec/aacsbr.c | 1418 ------------------------------------------ libavcodec/aacsbr.h | 45 ++ libavcodec/aacsbr_template.c | 1406 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1451 insertions(+), 1418 deletions(-) create mode 100644 libavcodec/aacsbr_template.c diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index 290fb81..5b23579 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -41,259 +41,13 @@ #include #include -#define ENVELOPE_ADJUSTMENT_OFFSET 2 -#define NOISE_FLOOR_OFFSET 6.0f - #if ARCH_MIPS #include "mips/aacsbr_mips.h" #endif /* ARCH_MIPS */ -/** - * SBR VLC tables - */ -enum { - T_HUFFMAN_ENV_1_5DB, - F_HUFFMAN_ENV_1_5DB, - T_HUFFMAN_ENV_BAL_1_5DB, - F_HUFFMAN_ENV_BAL_1_5DB, - T_HUFFMAN_ENV_3_0DB, - F_HUFFMAN_ENV_3_0DB, - T_HUFFMAN_ENV_BAL_3_0DB, - F_HUFFMAN_ENV_BAL_3_0DB, - T_HUFFMAN_NOISE_3_0DB, - T_HUFFMAN_NOISE_BAL_3_0DB, -}; - -/** - * bs_frame_class - frame class of current SBR frame (14496-3 sp04 p98) - */ -enum { - FIXFIX, - FIXVAR, - VARFIX, - VARVAR, -}; - -enum { - EXTENSION_ID_PS = 2, -}; - static VLC vlc_sbr[10]; -static const int8_t vlc_sbr_lav[10] = - { 60, 60, 24, 24, 31, 31, 12, 12, 31, 12 }; - -#define SBR_INIT_VLC_STATIC(num, size) \ - INIT_VLC_STATIC(&vlc_sbr[num], 9, sbr_tmp[num].table_size / sbr_tmp[num].elem_size, \ - sbr_tmp[num].sbr_bits , 1, 1, \ - sbr_tmp[num].sbr_codes, sbr_tmp[num].elem_size, sbr_tmp[num].elem_size, \ - size) - -#define SBR_VLC_ROW(name) \ - { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) } - static void aacsbr_func_ptr_init(AACSBRContext *c); -av_cold void ff_aac_sbr_init(void) -{ - int n; - static const struct { - const void *sbr_codes, *sbr_bits; - const unsigned int table_size, elem_size; - } sbr_tmp[] = { - SBR_VLC_ROW(t_huffman_env_1_5dB), - SBR_VLC_ROW(f_huffman_env_1_5dB), - SBR_VLC_ROW(t_huffman_env_bal_1_5dB), - SBR_VLC_ROW(f_huffman_env_bal_1_5dB), - SBR_VLC_ROW(t_huffman_env_3_0dB), - SBR_VLC_ROW(f_huffman_env_3_0dB), - SBR_VLC_ROW(t_huffman_env_bal_3_0dB), - SBR_VLC_ROW(f_huffman_env_bal_3_0dB), - SBR_VLC_ROW(t_huffman_noise_3_0dB), - SBR_VLC_ROW(t_huffman_noise_bal_3_0dB), - }; - - // SBR VLC table initialization - SBR_INIT_VLC_STATIC(0, 1098); - SBR_INIT_VLC_STATIC(1, 1092); - SBR_INIT_VLC_STATIC(2, 768); - SBR_INIT_VLC_STATIC(3, 1026); - SBR_INIT_VLC_STATIC(4, 1058); - SBR_INIT_VLC_STATIC(5, 1052); - SBR_INIT_VLC_STATIC(6, 544); - SBR_INIT_VLC_STATIC(7, 544); - SBR_INIT_VLC_STATIC(8, 592); - SBR_INIT_VLC_STATIC(9, 512); - - for (n = 1; n < 320; n++) - sbr_qmf_window_us[320 + n] = sbr_qmf_window_us[320 - n]; - sbr_qmf_window_us[384] = -sbr_qmf_window_us[384]; - sbr_qmf_window_us[512] = -sbr_qmf_window_us[512]; - - for (n = 0; n < 320; n++) - sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n]; - - ff_ps_init(); -} - -/** Places SBR in pure upsampling mode. */ -static void sbr_turnoff(SpectralBandReplication *sbr) { - sbr->start = 0; - // Init defults used in pure upsampling mode - sbr->kx[1] = 32; //Typo in spec, kx' inits to 32 - sbr->m[1] = 0; - // Reset values for first SBR header - sbr->data[0].e_a[1] = sbr->data[1].e_a[1] = -1; - memset(&sbr->spectrum_params, -1, sizeof(SpectrumParameters)); -} - -av_cold void ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr) -{ - if(sbr->mdct.mdct_bits) - return; - sbr->kx[0] = sbr->kx[1]; - sbr_turnoff(sbr); - sbr->data[0].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); - sbr->data[1].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); - /* SBR requires samples to be scaled to +/-32768.0 to work correctly. - * mdct scale factors are adjusted to scale up from +/-1.0 at analysis - * and scale back down at synthesis. */ - ff_mdct_init(&sbr->mdct, 7, 1, 1.0 / (64 * 32768.0)); - ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0 * 32768.0); - ff_ps_ctx_init(&sbr->ps); - ff_sbrdsp_init(&sbr->dsp); - aacsbr_func_ptr_init(&sbr->c); -} - -av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr) -{ - ff_mdct_end(&sbr->mdct); - ff_mdct_end(&sbr->mdct_ana); -} - -static int qsort_comparison_function_int16(const void *a, const void *b) -{ - return *(const int16_t *)a - *(const int16_t *)b; -} - -static inline int in_table_int16(const int16_t *table, int last_el, int16_t needle) -{ - int i; - for (i = 0; i <= last_el; i++) - if (table[i] == needle) - return 1; - return 0; -} - -/// Limiter Frequency Band Table (14496-3 sp04 p198) -static void sbr_make_f_tablelim(SpectralBandReplication *sbr) -{ - int k; - if (sbr->bs_limiter_bands > 0) { - static const float bands_warped[3] = { 1.32715174233856803909f, //2^(0.49/1.2) - 1.18509277094158210129f, //2^(0.49/2) - 1.11987160404675912501f }; //2^(0.49/3) - const float lim_bands_per_octave_warped = bands_warped[sbr->bs_limiter_bands - 1]; - int16_t patch_borders[7]; - uint16_t *in = sbr->f_tablelim + 1, *out = sbr->f_tablelim; - - patch_borders[0] = sbr->kx[1]; - for (k = 1; k <= sbr->num_patches; k++) - patch_borders[k] = patch_borders[k-1] + sbr->patch_num_subbands[k-1]; - - memcpy(sbr->f_tablelim, sbr->f_tablelow, - (sbr->n[0] + 1) * sizeof(sbr->f_tablelow[0])); - if (sbr->num_patches > 1) - memcpy(sbr->f_tablelim + sbr->n[0] + 1, patch_borders + 1, - (sbr->num_patches - 1) * sizeof(patch_borders[0])); - - qsort(sbr->f_tablelim, sbr->num_patches + sbr->n[0], - sizeof(sbr->f_tablelim[0]), - qsort_comparison_function_int16); - - sbr->n_lim = sbr->n[0] + sbr->num_patches - 1; - while (out < sbr->f_tablelim + sbr->n_lim) { - if (*in >= *out * lim_bands_per_octave_warped) { - *++out = *in++; - } else if (*in == *out || - !in_table_int16(patch_borders, sbr->num_patches, *in)) { - in++; - sbr->n_lim--; - } else if (!in_table_int16(patch_borders, sbr->num_patches, *out)) { - *out = *in++; - sbr->n_lim--; - } else { - *++out = *in++; - } - } - } else { - sbr->f_tablelim[0] = sbr->f_tablelow[0]; - sbr->f_tablelim[1] = sbr->f_tablelow[sbr->n[0]]; - sbr->n_lim = 1; - } -} - -static unsigned int read_sbr_header(SpectralBandReplication *sbr, GetBitContext *gb) -{ - unsigned int cnt = get_bits_count(gb); - uint8_t bs_header_extra_1; - uint8_t bs_header_extra_2; - int old_bs_limiter_bands = sbr->bs_limiter_bands; - SpectrumParameters old_spectrum_params; - - sbr->start = 1; - - // Save last spectrum parameters variables to compare to new ones - memcpy(&old_spectrum_params, &sbr->spectrum_params, sizeof(SpectrumParameters)); - - sbr->bs_amp_res_header = get_bits1(gb); - sbr->spectrum_params.bs_start_freq = get_bits(gb, 4); - sbr->spectrum_params.bs_stop_freq = get_bits(gb, 4); - sbr->spectrum_params.bs_xover_band = get_bits(gb, 3); - skip_bits(gb, 2); // bs_reserved - - bs_header_extra_1 = get_bits1(gb); - bs_header_extra_2 = get_bits1(gb); - - if (bs_header_extra_1) { - sbr->spectrum_params.bs_freq_scale = get_bits(gb, 2); - sbr->spectrum_params.bs_alter_scale = get_bits1(gb); - sbr->spectrum_params.bs_noise_bands = get_bits(gb, 2); - } else { - sbr->spectrum_params.bs_freq_scale = 2; - sbr->spectrum_params.bs_alter_scale = 1; - sbr->spectrum_params.bs_noise_bands = 2; - } - - // Check if spectrum parameters changed - if (memcmp(&old_spectrum_params, &sbr->spectrum_params, sizeof(SpectrumParameters))) - sbr->reset = 1; - - if (bs_header_extra_2) { - sbr->bs_limiter_bands = get_bits(gb, 2); - sbr->bs_limiter_gains = get_bits(gb, 2); - sbr->bs_interpol_freq = get_bits1(gb); - sbr->bs_smoothing_mode = get_bits1(gb); - } else { - sbr->bs_limiter_bands = 2; - sbr->bs_limiter_gains = 2; - sbr->bs_interpol_freq = 1; - sbr->bs_smoothing_mode = 1; - } - - if (sbr->bs_limiter_bands != old_bs_limiter_bands && !sbr->reset) - sbr_make_f_tablelim(sbr); - - return get_bits_count(gb) - cnt; -} - -static int array_min_int16(const int16_t *array, int nel) -{ - int i, min = array[0]; - for (i = 1; i < nel; i++) - min = FFMIN(array[i], min); - return min; -} - static void make_bands(int16_t* bands, int start, int stop, int num_bands) { int k, previous, present; @@ -312,813 +66,6 @@ static void make_bands(int16_t* bands, int start, int stop, int num_bands) bands[num_bands-1] = stop - previous; } -static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band) -{ - // Requirements (14496-3 sp04 p205) - if (n_master <= 0) { - av_log(avctx, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master); - return -1; - } - if (bs_xover_band >= n_master) { - av_log(avctx, AV_LOG_ERROR, - "Invalid bitstream, crossover band index beyond array bounds: %d\n", - bs_xover_band); - return -1; - } - return 0; -} - -/// Master Frequency Band Table (14496-3 sp04 p194) -static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, - SpectrumParameters *spectrum) -{ - unsigned int temp, max_qmf_subbands; - unsigned int start_min, stop_min; - int k; - const int8_t *sbr_offset_ptr; - int16_t stop_dk[13]; - - if (sbr->sample_rate < 32000) { - temp = 3000; - } else if (sbr->sample_rate < 64000) { - temp = 4000; - } else - temp = 5000; - - switch (sbr->sample_rate) { - case 16000: - sbr_offset_ptr = sbr_offset[0]; - break; - case 22050: - sbr_offset_ptr = sbr_offset[1]; - break; - case 24000: - sbr_offset_ptr = sbr_offset[2]; - break; - case 32000: - sbr_offset_ptr = sbr_offset[3]; - break; - case 44100: case 48000: case 64000: - sbr_offset_ptr = sbr_offset[4]; - break; - case 88200: case 96000: case 128000: case 176400: case 192000: - sbr_offset_ptr = sbr_offset[5]; - break; - default: - av_log(ac->avctx, AV_LOG_ERROR, - "Unsupported sample rate for SBR: %d\n", sbr->sample_rate); - return -1; - } - - start_min = ((temp << 7) + (sbr->sample_rate >> 1)) / sbr->sample_rate; - stop_min = ((temp << 8) + (sbr->sample_rate >> 1)) / sbr->sample_rate; - - sbr->k[0] = start_min + sbr_offset_ptr[spectrum->bs_start_freq]; - - if (spectrum->bs_stop_freq < 14) { - sbr->k[2] = stop_min; - make_bands(stop_dk, stop_min, 64, 13); - qsort(stop_dk, 13, sizeof(stop_dk[0]), qsort_comparison_function_int16); - for (k = 0; k < spectrum->bs_stop_freq; k++) - sbr->k[2] += stop_dk[k]; - } else if (spectrum->bs_stop_freq == 14) { - sbr->k[2] = 2*sbr->k[0]; - } else if (spectrum->bs_stop_freq == 15) { - sbr->k[2] = 3*sbr->k[0]; - } else { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid bs_stop_freq: %d\n", spectrum->bs_stop_freq); - return -1; - } - sbr->k[2] = FFMIN(64, sbr->k[2]); - - // Requirements (14496-3 sp04 p205) - if (sbr->sample_rate <= 32000) { - max_qmf_subbands = 48; - } else if (sbr->sample_rate == 44100) { - max_qmf_subbands = 35; - } else if (sbr->sample_rate >= 48000) - max_qmf_subbands = 32; - else - av_assert0(0); - - if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid bitstream, too many QMF subbands: %d\n", sbr->k[2] - sbr->k[0]); - return -1; - } - - if (!spectrum->bs_freq_scale) { - int dk, k2diff; - - dk = spectrum->bs_alter_scale + 1; - sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1; - if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) - return -1; - - for (k = 1; k <= sbr->n_master; k++) - sbr->f_master[k] = dk; - - k2diff = sbr->k[2] - sbr->k[0] - sbr->n_master * dk; - if (k2diff < 0) { - sbr->f_master[1]--; - sbr->f_master[2]-= (k2diff < -1); - } else if (k2diff) { - sbr->f_master[sbr->n_master]++; - } - - sbr->f_master[0] = sbr->k[0]; - for (k = 1; k <= sbr->n_master; k++) - sbr->f_master[k] += sbr->f_master[k - 1]; - - } else { - int half_bands = 7 - spectrum->bs_freq_scale; // bs_freq_scale = {1,2,3} - int two_regions, num_bands_0; - int vdk0_max, vdk1_min; - int16_t vk0[49]; - - if (49 * sbr->k[2] > 110 * sbr->k[0]) { - two_regions = 1; - sbr->k[1] = 2 * sbr->k[0]; - } else { - two_regions = 0; - sbr->k[1] = sbr->k[2]; - } - - num_bands_0 = lrintf(half_bands * log2f(sbr->k[1] / (float)sbr->k[0])) * 2; - - if (num_bands_0 <= 0) { // Requirements (14496-3 sp04 p205) - av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0); - return -1; - } - - vk0[0] = 0; - - make_bands(vk0+1, sbr->k[0], sbr->k[1], num_bands_0); - - qsort(vk0 + 1, num_bands_0, sizeof(vk0[1]), qsort_comparison_function_int16); - vdk0_max = vk0[num_bands_0]; - - vk0[0] = sbr->k[0]; - for (k = 1; k <= num_bands_0; k++) { - if (vk0[k] <= 0) { // Requirements (14496-3 sp04 p205) - av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]); - return -1; - } - vk0[k] += vk0[k-1]; - } - - if (two_regions) { - int16_t vk1[49]; - float invwarp = spectrum->bs_alter_scale ? 0.76923076923076923077f - : 1.0f; // bs_alter_scale = {0,1} - int num_bands_1 = lrintf(half_bands * invwarp * - log2f(sbr->k[2] / (float)sbr->k[1])) * 2; - - make_bands(vk1+1, sbr->k[1], sbr->k[2], num_bands_1); - - vdk1_min = array_min_int16(vk1 + 1, num_bands_1); - - if (vdk1_min < vdk0_max) { - int change; - qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16); - change = FFMIN(vdk0_max - vk1[1], (vk1[num_bands_1] - vk1[1]) >> 1); - vk1[1] += change; - vk1[num_bands_1] -= change; - } - - qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16); - - vk1[0] = sbr->k[1]; - for (k = 1; k <= num_bands_1; k++) { - if (vk1[k] <= 0) { // Requirements (14496-3 sp04 p205) - av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]); - return -1; - } - vk1[k] += vk1[k-1]; - } - - sbr->n_master = num_bands_0 + num_bands_1; - if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) - return -1; - memcpy(&sbr->f_master[0], vk0, - (num_bands_0 + 1) * sizeof(sbr->f_master[0])); - memcpy(&sbr->f_master[num_bands_0 + 1], vk1 + 1, - num_bands_1 * sizeof(sbr->f_master[0])); - - } else { - sbr->n_master = num_bands_0; - if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) - return -1; - memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0])); - } - } - - return 0; -} - -/// High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46) -static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr) -{ - int i, k, sb = 0; - int msb = sbr->k[0]; - int usb = sbr->kx[1]; - int goal_sb = ((1000 << 11) + (sbr->sample_rate >> 1)) / sbr->sample_rate; - - sbr->num_patches = 0; - - if (goal_sb < sbr->kx[1] + sbr->m[1]) { - for (k = 0; sbr->f_master[k] < goal_sb; k++) ; - } else - k = sbr->n_master; - - do { - int odd = 0; - for (i = k; i == k || sb > (sbr->k[0] - 1 + msb - odd); i--) { - sb = sbr->f_master[i]; - odd = (sb + sbr->k[0]) & 1; - } - - // Requirements (14496-3 sp04 p205) sets the maximum number of patches to 5. - // After this check the final number of patches can still be six which is - // illegal however the Coding Technologies decoder check stream has a final - // count of 6 patches - if (sbr->num_patches > 5) { - av_log(ac->avctx, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches); - return -1; - } - - sbr->patch_num_subbands[sbr->num_patches] = FFMAX(sb - usb, 0); - sbr->patch_start_subband[sbr->num_patches] = sbr->k[0] - odd - sbr->patch_num_subbands[sbr->num_patches]; - - if (sbr->patch_num_subbands[sbr->num_patches] > 0) { - usb = sb; - msb = sb; - sbr->num_patches++; - } else - msb = sbr->kx[1]; - - if (sbr->f_master[k] - sb < 3) - k = sbr->n_master; - } while (sb != sbr->kx[1] + sbr->m[1]); - - if (sbr->num_patches > 1 && sbr->patch_num_subbands[sbr->num_patches-1] < 3) - sbr->num_patches--; - - return 0; -} - -/// Derived Frequency Band Tables (14496-3 sp04 p197) -static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr) -{ - int k, temp; - - sbr->n[1] = sbr->n_master - sbr->spectrum_params.bs_xover_band; - sbr->n[0] = (sbr->n[1] + 1) >> 1; - - memcpy(sbr->f_tablehigh, &sbr->f_master[sbr->spectrum_params.bs_xover_band], - (sbr->n[1] + 1) * sizeof(sbr->f_master[0])); - sbr->m[1] = sbr->f_tablehigh[sbr->n[1]] - sbr->f_tablehigh[0]; - sbr->kx[1] = sbr->f_tablehigh[0]; - - // Requirements (14496-3 sp04 p205) - if (sbr->kx[1] + sbr->m[1] > 64) { - av_log(ac->avctx, AV_LOG_ERROR, - "Stop frequency border too high: %d\n", sbr->kx[1] + sbr->m[1]); - return -1; - } - if (sbr->kx[1] > 32) { - av_log(ac->avctx, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]); - return -1; - } - - sbr->f_tablelow[0] = sbr->f_tablehigh[0]; - temp = sbr->n[1] & 1; - for (k = 1; k <= sbr->n[0]; k++) - sbr->f_tablelow[k] = sbr->f_tablehigh[2 * k - temp]; - - sbr->n_q = FFMAX(1, lrintf(sbr->spectrum_params.bs_noise_bands * - log2f(sbr->k[2] / (float)sbr->kx[1]))); // 0 <= bs_noise_bands <= 3 - if (sbr->n_q > 5) { - av_log(ac->avctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q); - return -1; - } - - sbr->f_tablenoise[0] = sbr->f_tablelow[0]; - temp = 0; - for (k = 1; k <= sbr->n_q; k++) { - temp += (sbr->n[0] - temp) / (sbr->n_q + 1 - k); - sbr->f_tablenoise[k] = sbr->f_tablelow[temp]; - } - - if (sbr_hf_calc_npatches(ac, sbr) < 0) - return -1; - - sbr_make_f_tablelim(sbr); - - sbr->data[0].f_indexnoise = 0; - sbr->data[1].f_indexnoise = 0; - - return 0; -} - -static av_always_inline void get_bits1_vector(GetBitContext *gb, uint8_t *vec, - int elements) -{ - int i; - for (i = 0; i < elements; i++) { - vec[i] = get_bits1(gb); - } -} - -/** ceil(log2(index+1)) */ -static const int8_t ceil_log2[] = { - 0, 1, 2, 2, 3, 3, -}; - -static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, - GetBitContext *gb, SBRData *ch_data) -{ - int i; - unsigned bs_pointer = 0; - // frameLengthFlag ? 15 : 16; 960 sample length frames unsupported; this value is numTimeSlots - int abs_bord_trail = 16; - int num_rel_lead, num_rel_trail; - unsigned bs_num_env_old = ch_data->bs_num_env; - - ch_data->bs_freq_res[0] = ch_data->bs_freq_res[ch_data->bs_num_env]; - ch_data->bs_amp_res = sbr->bs_amp_res_header; - ch_data->t_env_num_env_old = ch_data->t_env[bs_num_env_old]; - - switch (ch_data->bs_frame_class = get_bits(gb, 2)) { - case FIXFIX: - ch_data->bs_num_env = 1 << get_bits(gb, 2); - num_rel_lead = ch_data->bs_num_env - 1; - if (ch_data->bs_num_env == 1) - ch_data->bs_amp_res = 0; - - if (ch_data->bs_num_env > 4) { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n", - ch_data->bs_num_env); - return -1; - } - - ch_data->t_env[0] = 0; - ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; - - abs_bord_trail = (abs_bord_trail + (ch_data->bs_num_env >> 1)) / - ch_data->bs_num_env; - for (i = 0; i < num_rel_lead; i++) - ch_data->t_env[i + 1] = ch_data->t_env[i] + abs_bord_trail; - - ch_data->bs_freq_res[1] = get_bits1(gb); - for (i = 1; i < ch_data->bs_num_env; i++) - ch_data->bs_freq_res[i + 1] = ch_data->bs_freq_res[1]; - break; - case FIXVAR: - abs_bord_trail += get_bits(gb, 2); - num_rel_trail = get_bits(gb, 2); - ch_data->bs_num_env = num_rel_trail + 1; - ch_data->t_env[0] = 0; - ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; - - for (i = 0; i < num_rel_trail; i++) - ch_data->t_env[ch_data->bs_num_env - 1 - i] = - ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2; - - bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); - - for (i = 0; i < ch_data->bs_num_env; i++) - ch_data->bs_freq_res[ch_data->bs_num_env - i] = get_bits1(gb); - break; - case VARFIX: - ch_data->t_env[0] = get_bits(gb, 2); - num_rel_lead = get_bits(gb, 2); - ch_data->bs_num_env = num_rel_lead + 1; - ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; - - for (i = 0; i < num_rel_lead; i++) - ch_data->t_env[i + 1] = ch_data->t_env[i] + 2 * get_bits(gb, 2) + 2; - - bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); - - get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env); - break; - case VARVAR: - ch_data->t_env[0] = get_bits(gb, 2); - abs_bord_trail += get_bits(gb, 2); - num_rel_lead = get_bits(gb, 2); - num_rel_trail = get_bits(gb, 2); - ch_data->bs_num_env = num_rel_lead + num_rel_trail + 1; - - if (ch_data->bs_num_env > 5) { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n", - ch_data->bs_num_env); - return -1; - } - - ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; - - for (i = 0; i < num_rel_lead; i++) - ch_data->t_env[i + 1] = ch_data->t_env[i] + 2 * get_bits(gb, 2) + 2; - for (i = 0; i < num_rel_trail; i++) - ch_data->t_env[ch_data->bs_num_env - 1 - i] = - ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2; - - bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); - - get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env); - break; - } - - if (bs_pointer > ch_data->bs_num_env + 1) { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n", - bs_pointer); - return -1; - } - - for (i = 1; i <= ch_data->bs_num_env; i++) { - if (ch_data->t_env[i-1] > ch_data->t_env[i]) { - av_log(ac->avctx, AV_LOG_ERROR, "Non monotone time borders\n"); - return -1; - } - } - - ch_data->bs_num_noise = (ch_data->bs_num_env > 1) + 1; - - ch_data->t_q[0] = ch_data->t_env[0]; - ch_data->t_q[ch_data->bs_num_noise] = ch_data->t_env[ch_data->bs_num_env]; - if (ch_data->bs_num_noise > 1) { - unsigned int idx; - if (ch_data->bs_frame_class == FIXFIX) { - idx = ch_data->bs_num_env >> 1; - } else if (ch_data->bs_frame_class & 1) { // FIXVAR or VARVAR - idx = ch_data->bs_num_env - FFMAX((int)bs_pointer - 1, 1); - } else { // VARFIX - if (!bs_pointer) - idx = 1; - else if (bs_pointer == 1) - idx = ch_data->bs_num_env - 1; - else // bs_pointer > 1 - idx = bs_pointer - 1; - } - ch_data->t_q[1] = ch_data->t_env[idx]; - } - - ch_data->e_a[0] = -(ch_data->e_a[1] != bs_num_env_old); // l_APrev - ch_data->e_a[1] = -1; - if ((ch_data->bs_frame_class & 1) && bs_pointer) { // FIXVAR or VARVAR and bs_pointer != 0 - ch_data->e_a[1] = ch_data->bs_num_env + 1 - bs_pointer; - } else if ((ch_data->bs_frame_class == 2) && (bs_pointer > 1)) // VARFIX and bs_pointer > 1 - ch_data->e_a[1] = bs_pointer - 1; - - return 0; -} - -static void copy_sbr_grid(SBRData *dst, const SBRData *src) { - //These variables are saved from the previous frame rather than copied - dst->bs_freq_res[0] = dst->bs_freq_res[dst->bs_num_env]; - dst->t_env_num_env_old = dst->t_env[dst->bs_num_env]; - dst->e_a[0] = -(dst->e_a[1] != dst->bs_num_env); - - //These variables are read from the bitstream and therefore copied - memcpy(dst->bs_freq_res+1, src->bs_freq_res+1, sizeof(dst->bs_freq_res)-sizeof(*dst->bs_freq_res)); - memcpy(dst->t_env, src->t_env, sizeof(dst->t_env)); - memcpy(dst->t_q, src->t_q, sizeof(dst->t_q)); - dst->bs_num_env = src->bs_num_env; - dst->bs_amp_res = src->bs_amp_res; - dst->bs_num_noise = src->bs_num_noise; - dst->bs_frame_class = src->bs_frame_class; - dst->e_a[1] = src->e_a[1]; -} - -/// Read how the envelope and noise floor data is delta coded -static void read_sbr_dtdf(SpectralBandReplication *sbr, GetBitContext *gb, - SBRData *ch_data) -{ - get_bits1_vector(gb, ch_data->bs_df_env, ch_data->bs_num_env); - get_bits1_vector(gb, ch_data->bs_df_noise, ch_data->bs_num_noise); -} - -/// Read inverse filtering data -static void read_sbr_invf(SpectralBandReplication *sbr, GetBitContext *gb, - SBRData *ch_data) -{ - int i; - - memcpy(ch_data->bs_invf_mode[1], ch_data->bs_invf_mode[0], 5 * sizeof(uint8_t)); - for (i = 0; i < sbr->n_q; i++) - ch_data->bs_invf_mode[0][i] = get_bits(gb, 2); -} - -static void read_sbr_envelope(SpectralBandReplication *sbr, GetBitContext *gb, - SBRData *ch_data, int ch) -{ - int bits; - int i, j, k; - VLC_TYPE (*t_huff)[2], (*f_huff)[2]; - int t_lav, f_lav; - const int delta = (ch == 1 && sbr->bs_coupling == 1) + 1; - const int odd = sbr->n[1] & 1; - - if (sbr->bs_coupling && ch) { - if (ch_data->bs_amp_res) { - bits = 5; - t_huff = vlc_sbr[T_HUFFMAN_ENV_BAL_3_0DB].table; - t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_BAL_3_0DB]; - f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_3_0DB].table; - f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_3_0DB]; - } else { - bits = 6; - t_huff = vlc_sbr[T_HUFFMAN_ENV_BAL_1_5DB].table; - t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_BAL_1_5DB]; - f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_1_5DB].table; - f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_1_5DB]; - } - } else { - if (ch_data->bs_amp_res) { - bits = 6; - t_huff = vlc_sbr[T_HUFFMAN_ENV_3_0DB].table; - t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_3_0DB]; - f_huff = vlc_sbr[F_HUFFMAN_ENV_3_0DB].table; - f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB]; - } else { - bits = 7; - t_huff = vlc_sbr[T_HUFFMAN_ENV_1_5DB].table; - t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_1_5DB]; - f_huff = vlc_sbr[F_HUFFMAN_ENV_1_5DB].table; - f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_1_5DB]; - } - } - - for (i = 0; i < ch_data->bs_num_env; i++) { - if (ch_data->bs_df_env[i]) { - // bs_freq_res[0] == bs_freq_res[bs_num_env] from prev frame - if (ch_data->bs_freq_res[i + 1] == ch_data->bs_freq_res[i]) { - for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) - ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); - } else if (ch_data->bs_freq_res[i + 1]) { - for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { - k = (j + odd) >> 1; // find k such that f_tablelow[k] <= f_tablehigh[j] < f_tablelow[k + 1] - ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); - } - } else { - for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { - k = j ? 2*j - odd : 0; // find k such that f_tablehigh[k] == f_tablelow[j] - ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); - } - } - } else { - ch_data->env_facs[i + 1][0] = delta * get_bits(gb, bits); // bs_env_start_value_balance - for (j = 1; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) - ch_data->env_facs[i + 1][j] = ch_data->env_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); - } - } - - //assign 0th elements of env_facs from last elements - memcpy(ch_data->env_facs[0], ch_data->env_facs[ch_data->bs_num_env], - sizeof(ch_data->env_facs[0])); -} - -static void read_sbr_noise(SpectralBandReplication *sbr, GetBitContext *gb, - SBRData *ch_data, int ch) -{ - int i, j; - VLC_TYPE (*t_huff)[2], (*f_huff)[2]; - int t_lav, f_lav; - int delta = (ch == 1 && sbr->bs_coupling == 1) + 1; - - if (sbr->bs_coupling && ch) { - t_huff = vlc_sbr[T_HUFFMAN_NOISE_BAL_3_0DB].table; - t_lav = vlc_sbr_lav[T_HUFFMAN_NOISE_BAL_3_0DB]; - f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_3_0DB].table; - f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_3_0DB]; - } else { - t_huff = vlc_sbr[T_HUFFMAN_NOISE_3_0DB].table; - t_lav = vlc_sbr_lav[T_HUFFMAN_NOISE_3_0DB]; - f_huff = vlc_sbr[F_HUFFMAN_ENV_3_0DB].table; - f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB]; - } - - for (i = 0; i < ch_data->bs_num_noise; i++) { - if (ch_data->bs_df_noise[i]) { - for (j = 0; j < sbr->n_q; j++) - ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav); - } else { - ch_data->noise_facs[i + 1][0] = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level - for (j = 1; j < sbr->n_q; j++) - ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); - } - } - - //assign 0th elements of noise_facs from last elements - memcpy(ch_data->noise_facs[0], ch_data->noise_facs[ch_data->bs_num_noise], - sizeof(ch_data->noise_facs[0])); -} - -static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, - GetBitContext *gb, - int bs_extension_id, int *num_bits_left) -{ - switch (bs_extension_id) { - case EXTENSION_ID_PS: - if (!ac->oc[1].m4ac.ps) { - av_log(ac->avctx, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n"); - skip_bits_long(gb, *num_bits_left); // bs_fill_bits - *num_bits_left = 0; - } else { -#if 1 - *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps, *num_bits_left); - ac->avctx->profile = FF_PROFILE_AAC_HE_V2; -#else - avpriv_report_missing_feature(ac->avctx, "Parametric Stereo"); - skip_bits_long(gb, *num_bits_left); // bs_fill_bits - *num_bits_left = 0; -#endif - } - break; - default: - // some files contain 0-padding - if (bs_extension_id || *num_bits_left > 16 || show_bits(gb, *num_bits_left)) - avpriv_request_sample(ac->avctx, "Reserved SBR extensions"); - skip_bits_long(gb, *num_bits_left); // bs_fill_bits - *num_bits_left = 0; - break; - } -} - -static int read_sbr_single_channel_element(AACContext *ac, - SpectralBandReplication *sbr, - GetBitContext *gb) -{ - if (get_bits1(gb)) // bs_data_extra - skip_bits(gb, 4); // bs_reserved - - if (read_sbr_grid(ac, sbr, gb, &sbr->data[0])) - return -1; - read_sbr_dtdf(sbr, gb, &sbr->data[0]); - read_sbr_invf(sbr, gb, &sbr->data[0]); - read_sbr_envelope(sbr, gb, &sbr->data[0], 0); - read_sbr_noise(sbr, gb, &sbr->data[0], 0); - - if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb))) - get_bits1_vector(gb, sbr->data[0].bs_add_harmonic, sbr->n[1]); - - return 0; -} - -static int read_sbr_channel_pair_element(AACContext *ac, - SpectralBandReplication *sbr, - GetBitContext *gb) -{ - if (get_bits1(gb)) // bs_data_extra - skip_bits(gb, 8); // bs_reserved - - if ((sbr->bs_coupling = get_bits1(gb))) { - if (read_sbr_grid(ac, sbr, gb, &sbr->data[0])) - return -1; - copy_sbr_grid(&sbr->data[1], &sbr->data[0]); - read_sbr_dtdf(sbr, gb, &sbr->data[0]); - read_sbr_dtdf(sbr, gb, &sbr->data[1]); - read_sbr_invf(sbr, gb, &sbr->data[0]); - memcpy(sbr->data[1].bs_invf_mode[1], sbr->data[1].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0])); - memcpy(sbr->data[1].bs_invf_mode[0], sbr->data[0].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0])); - read_sbr_envelope(sbr, gb, &sbr->data[0], 0); - read_sbr_noise(sbr, gb, &sbr->data[0], 0); - read_sbr_envelope(sbr, gb, &sbr->data[1], 1); - read_sbr_noise(sbr, gb, &sbr->data[1], 1); - } else { - if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]) || - read_sbr_grid(ac, sbr, gb, &sbr->data[1])) - return -1; - read_sbr_dtdf(sbr, gb, &sbr->data[0]); - read_sbr_dtdf(sbr, gb, &sbr->data[1]); - read_sbr_invf(sbr, gb, &sbr->data[0]); - read_sbr_invf(sbr, gb, &sbr->data[1]); - read_sbr_envelope(sbr, gb, &sbr->data[0], 0); - read_sbr_envelope(sbr, gb, &sbr->data[1], 1); - read_sbr_noise(sbr, gb, &sbr->data[0], 0); - read_sbr_noise(sbr, gb, &sbr->data[1], 1); - } - - if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb))) - get_bits1_vector(gb, sbr->data[0].bs_add_harmonic, sbr->n[1]); - if ((sbr->data[1].bs_add_harmonic_flag = get_bits1(gb))) - get_bits1_vector(gb, sbr->data[1].bs_add_harmonic, sbr->n[1]); - - return 0; -} - -static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, - GetBitContext *gb, int id_aac) -{ - unsigned int cnt = get_bits_count(gb); - - if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) { - if (read_sbr_single_channel_element(ac, sbr, gb)) { - sbr_turnoff(sbr); - return get_bits_count(gb) - cnt; - } - } else if (id_aac == TYPE_CPE) { - if (read_sbr_channel_pair_element(ac, sbr, gb)) { - sbr_turnoff(sbr); - return get_bits_count(gb) - cnt; - } - } else { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid bitstream - cannot apply SBR to element type %d\n", id_aac); - sbr_turnoff(sbr); - return get_bits_count(gb) - cnt; - } - if (get_bits1(gb)) { // bs_extended_data - int num_bits_left = get_bits(gb, 4); // bs_extension_size - if (num_bits_left == 15) - num_bits_left += get_bits(gb, 8); // bs_esc_count - - num_bits_left <<= 3; - while (num_bits_left > 7) { - num_bits_left -= 2; - read_sbr_extension(ac, sbr, gb, get_bits(gb, 2), &num_bits_left); // bs_extension_id - } - if (num_bits_left < 0) { - av_log(ac->avctx, AV_LOG_ERROR, "SBR Extension over read.\n"); - } - if (num_bits_left > 0) - skip_bits(gb, num_bits_left); - } - - return get_bits_count(gb) - cnt; -} - -static void sbr_reset(AACContext *ac, SpectralBandReplication *sbr) -{ - int err; - err = sbr_make_f_master(ac, sbr, &sbr->spectrum_params); - if (err >= 0) - err = sbr_make_f_derived(ac, sbr); - if (err < 0) { - av_log(ac->avctx, AV_LOG_ERROR, - "SBR reset failed. Switching SBR to pure upsampling mode.\n"); - sbr_turnoff(sbr); - } -} - -/** - * Decode Spectral Band Replication extension data; reference: table 4.55. - * - * @param crc flag indicating the presence of CRC checksum - * @param cnt length of TYPE_FIL syntactic element in bytes - * - * @return Returns number of bytes consumed from the TYPE_FIL element. - */ -int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, - GetBitContext *gb_host, int crc, int cnt, int id_aac) -{ - unsigned int num_sbr_bits = 0, num_align_bits; - unsigned bytes_read; - GetBitContext gbc = *gb_host, *gb = &gbc; - skip_bits_long(gb_host, cnt*8 - 4); - - sbr->reset = 0; - - if (!sbr->sample_rate) - sbr->sample_rate = 2 * ac->oc[1].m4ac.sample_rate; //TODO use the nominal sample rate for arbitrary sample rate support - if (!ac->oc[1].m4ac.ext_sample_rate) - ac->oc[1].m4ac.ext_sample_rate = 2 * ac->oc[1].m4ac.sample_rate; - - if (crc) { - skip_bits(gb, 10); // bs_sbr_crc_bits; TODO - implement CRC check - num_sbr_bits += 10; - } - - //Save some state from the previous frame. - sbr->kx[0] = sbr->kx[1]; - sbr->m[0] = sbr->m[1]; - sbr->kx_and_m_pushed = 1; - - num_sbr_bits++; - if (get_bits1(gb)) // bs_header_flag - num_sbr_bits += read_sbr_header(sbr, gb); - - if (sbr->reset) - sbr_reset(ac, sbr); - - if (sbr->start) - num_sbr_bits += read_sbr_data(ac, sbr, gb, id_aac); - - num_align_bits = ((cnt << 3) - 4 - num_sbr_bits) & 7; - bytes_read = ((num_sbr_bits + num_align_bits + 4) >> 3); - - if (bytes_read > cnt) { - av_log(ac->avctx, AV_LOG_ERROR, - "Expected to read %d SBR bytes actually read %d.\n", cnt, bytes_read); - } - return cnt; -} - /// Dequantization and stereo decoding (14496-3 sp04 p203) static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) { @@ -1177,84 +124,6 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) } } -/** - * Analysis QMF Bank (14496-3 sp04 p206) - * - * @param x pointer to the beginning of the first sample window - * @param W array of complex-valued samples split into subbands - */ -#ifndef sbr_qmf_analysis -static void sbr_qmf_analysis(AVFloatDSPContext *dsp, FFTContext *mdct, - SBRDSPContext *sbrdsp, const float *in, float *x, - float z[320], float W[2][32][32][2], int buf_idx) -{ - int i; - memcpy(x , x+1024, (320-32)*sizeof(x[0])); - memcpy(x+288, in, 1024*sizeof(x[0])); - for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames - // are not supported - dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320); - sbrdsp->sum64x5(z); - sbrdsp->qmf_pre_shuffle(z); - mdct->imdct_half(mdct, z, z+64); - sbrdsp->qmf_post_shuffle(W[buf_idx][i], z); - x += 32; - } -} -#endif - -/** - * Synthesis QMF Bank (14496-3 sp04 p206) and Downsampled Synthesis QMF Bank - * (14496-3 sp04 p206) - */ -#ifndef sbr_qmf_synthesis -static void sbr_qmf_synthesis(FFTContext *mdct, - SBRDSPContext *sbrdsp, AVFloatDSPContext *dsp, - float *out, float X[2][38][64], - float mdct_buf[2][64], - float *v0, int *v_off, const unsigned int div) -{ - int i, n; - const float *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us; - const int step = 128 >> div; - float *v; - for (i = 0; i < 32; i++) { - if (*v_off < step) { - int saved_samples = (1280 - 128) >> div; - memcpy(&v0[SBR_SYNTHESIS_BUF_SIZE - saved_samples], v0, saved_samples * sizeof(float)); - *v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - step; - } else { - *v_off -= step; - } - v = v0 + *v_off; - if (div) { - for (n = 0; n < 32; n++) { - X[0][i][ n] = -X[0][i][n]; - X[0][i][32+n] = X[1][i][31-n]; - } - mdct->imdct_half(mdct, mdct_buf[0], X[0][i]); - sbrdsp->qmf_deint_neg(v, mdct_buf[0]); - } else { - sbrdsp->neg_odd_64(X[1][i]); - mdct->imdct_half(mdct, mdct_buf[0], X[0][i]); - mdct->imdct_half(mdct, mdct_buf[1], X[1][i]); - sbrdsp->qmf_deint_bfly(v, mdct_buf[1], mdct_buf[0]); - } - dsp->vector_fmul (out, v , sbr_qmf_window , 64 >> div); - dsp->vector_fmul_add(out, v + ( 192 >> div), sbr_qmf_window + ( 64 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + ( 256 >> div), sbr_qmf_window + (128 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + ( 448 >> div), sbr_qmf_window + (192 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + ( 512 >> div), sbr_qmf_window + (256 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + ( 704 >> div), sbr_qmf_window + (320 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + ( 768 >> div), sbr_qmf_window + (384 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + ( 960 >> div), sbr_qmf_window + (448 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + (1024 >> div), sbr_qmf_window + (512 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + (1216 >> div), sbr_qmf_window + (576 >> div), out , 64 >> div); - out += 64 >> div; - } -} -#endif - /** High Frequency Generation (14496-3 sp04 p214+) and Inverse Filtering * (14496-3 sp04 p214) * Warning: This routine does not seem numerically stable. @@ -1334,203 +203,6 @@ static void sbr_chirp(SpectralBandReplication *sbr, SBRData *ch_data) } } -/// Generate the subband filtered lowband -static int sbr_lf_gen(AACContext *ac, SpectralBandReplication *sbr, - float X_low[32][40][2], const float W[2][32][32][2], - int buf_idx) -{ - int i, k; - const int t_HFGen = 8; - const int i_f = 32; - memset(X_low, 0, 32*sizeof(*X_low)); - for (k = 0; k < sbr->kx[1]; k++) { - for (i = t_HFGen; i < i_f + t_HFGen; i++) { - X_low[k][i][0] = W[buf_idx][i - t_HFGen][k][0]; - X_low[k][i][1] = W[buf_idx][i - t_HFGen][k][1]; - } - } - buf_idx = 1-buf_idx; - for (k = 0; k < sbr->kx[0]; k++) { - for (i = 0; i < t_HFGen; i++) { - X_low[k][i][0] = W[buf_idx][i + i_f - t_HFGen][k][0]; - X_low[k][i][1] = W[buf_idx][i + i_f - t_HFGen][k][1]; - } - } - return 0; -} - -/// High Frequency Generator (14496-3 sp04 p215) -static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, - float X_high[64][40][2], const float X_low[32][40][2], - const float (*alpha0)[2], const float (*alpha1)[2], - const float bw_array[5], const uint8_t *t_env, - int bs_num_env) -{ - int j, x; - int g = 0; - int k = sbr->kx[1]; - for (j = 0; j < sbr->num_patches; j++) { - for (x = 0; x < sbr->patch_num_subbands[j]; x++, k++) { - const int p = sbr->patch_start_subband[j] + x; - while (g <= sbr->n_q && k >= sbr->f_tablenoise[g]) - g++; - g--; - - if (g < 0) { - av_log(ac->avctx, AV_LOG_ERROR, - "ERROR : no subband found for frequency %d\n", k); - return -1; - } - - sbr->dsp.hf_gen(X_high[k] + ENVELOPE_ADJUSTMENT_OFFSET, - X_low[p] + ENVELOPE_ADJUSTMENT_OFFSET, - alpha0[p], alpha1[p], bw_array[g], - 2 * t_env[0], 2 * t_env[bs_num_env]); - } - } - if (k < sbr->m[1] + sbr->kx[1]) - memset(X_high + k, 0, (sbr->m[1] + sbr->kx[1] - k) * sizeof(*X_high)); - - return 0; -} - -/// Generate the subband filtered lowband -static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][38][64], - const float Y0[38][64][2], const float Y1[38][64][2], - const float X_low[32][40][2], int ch) -{ - int k, i; - const int i_f = 32; - const int i_Temp = FFMAX(2*sbr->data[ch].t_env_num_env_old - i_f, 0); - memset(X, 0, 2*sizeof(*X)); - for (k = 0; k < sbr->kx[0]; k++) { - for (i = 0; i < i_Temp; i++) { - X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; - X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; - } - } - for (; k < sbr->kx[0] + sbr->m[0]; k++) { - for (i = 0; i < i_Temp; i++) { - X[0][i][k] = Y0[i + i_f][k][0]; - X[1][i][k] = Y0[i + i_f][k][1]; - } - } - - for (k = 0; k < sbr->kx[1]; k++) { - for (i = i_Temp; i < 38; i++) { - X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; - X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; - } - } - for (; k < sbr->kx[1] + sbr->m[1]; k++) { - for (i = i_Temp; i < i_f; i++) { - X[0][i][k] = Y1[i][k][0]; - X[1][i][k] = Y1[i][k][1]; - } - } - return 0; -} - -/** High Frequency Adjustment (14496-3 sp04 p217) and Mapping - * (14496-3 sp04 p217) - */ -static int sbr_mapping(AACContext *ac, SpectralBandReplication *sbr, - SBRData *ch_data, int e_a[2]) -{ - int e, i, m; - - memset(ch_data->s_indexmapped[1], 0, 7*sizeof(ch_data->s_indexmapped[1])); - for (e = 0; e < ch_data->bs_num_env; e++) { - const unsigned int ilim = sbr->n[ch_data->bs_freq_res[e + 1]]; - uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow; - int k; - - if (sbr->kx[1] != table[0]) { - av_log(ac->avctx, AV_LOG_ERROR, "kx != f_table{high,low}[0]. " - "Derived frequency tables were not regenerated.\n"); - sbr_turnoff(sbr); - return AVERROR_BUG; - } - for (i = 0; i < ilim; i++) - for (m = table[i]; m < table[i + 1]; m++) - sbr->e_origmapped[e][m - sbr->kx[1]] = ch_data->env_facs[e+1][i]; - - // ch_data->bs_num_noise > 1 => 2 noise floors - k = (ch_data->bs_num_noise > 1) && (ch_data->t_env[e] >= ch_data->t_q[1]); - for (i = 0; i < sbr->n_q; i++) - for (m = sbr->f_tablenoise[i]; m < sbr->f_tablenoise[i + 1]; m++) - sbr->q_mapped[e][m - sbr->kx[1]] = ch_data->noise_facs[k+1][i]; - - for (i = 0; i < sbr->n[1]; i++) { - if (ch_data->bs_add_harmonic_flag) { - const unsigned int m_midpoint = - (sbr->f_tablehigh[i] + sbr->f_tablehigh[i + 1]) >> 1; - - ch_data->s_indexmapped[e + 1][m_midpoint - sbr->kx[1]] = ch_data->bs_add_harmonic[i] * - (e >= e_a[1] || (ch_data->s_indexmapped[0][m_midpoint - sbr->kx[1]] == 1)); - } - } - - for (i = 0; i < ilim; i++) { - int additional_sinusoid_present = 0; - for (m = table[i]; m < table[i + 1]; m++) { - if (ch_data->s_indexmapped[e + 1][m - sbr->kx[1]]) { - additional_sinusoid_present = 1; - break; - } - } - memset(&sbr->s_mapped[e][table[i] - sbr->kx[1]], additional_sinusoid_present, - (table[i + 1] - table[i]) * sizeof(sbr->s_mapped[e][0])); - } - } - - memcpy(ch_data->s_indexmapped[0], ch_data->s_indexmapped[ch_data->bs_num_env], sizeof(ch_data->s_indexmapped[0])); - return 0; -} - -/// Estimation of current envelope (14496-3 sp04 p218) -static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2], - SpectralBandReplication *sbr, SBRData *ch_data) -{ - int e, m; - int kx1 = sbr->kx[1]; - - if (sbr->bs_interpol_freq) { - for (e = 0; e < ch_data->bs_num_env; e++) { - const float recip_env_size = 0.5f / (ch_data->t_env[e + 1] - ch_data->t_env[e]); - int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; - int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; - - for (m = 0; m < sbr->m[1]; m++) { - float sum = sbr->dsp.sum_square(X_high[m+kx1] + ilb, iub - ilb); - e_curr[e][m] = sum * recip_env_size; - } - } - } else { - int k, p; - - for (e = 0; e < ch_data->bs_num_env; e++) { - const int env_size = 2 * (ch_data->t_env[e + 1] - ch_data->t_env[e]); - int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; - int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; - const uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow; - - for (p = 0; p < sbr->n[ch_data->bs_freq_res[e + 1]]; p++) { - float sum = 0.0f; - const int den = env_size * (table[p + 1] - table[p]); - - for (k = table[p]; k < table[p + 1]; k++) { - sum += sbr->dsp.sum_square(X_high[k] + ilb, iub - ilb); - } - sum /= den; - for (k = table[p]; k < table[p + 1]; k++) { - e_curr[e][k - kx1] = sum; - } - } - } - } -} - /** * Calculation of levels of additional HF signal components (14496-3 sp04 p219) * and Calculation of gain (14496-3 sp04 p219) @@ -1678,93 +350,3 @@ static void sbr_hf_assemble(float Y1[38][64][2], ch_data->f_indexnoise = indexnoise; ch_data->f_indexsine = indexsine; } - -void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, - float* L, float* R) -{ - int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate; - int ch; - int nch = (id_aac == TYPE_CPE) ? 2 : 1; - int err; - - if (!sbr->kx_and_m_pushed) { - sbr->kx[0] = sbr->kx[1]; - sbr->m[0] = sbr->m[1]; - } else { - sbr->kx_and_m_pushed = 0; - } - - if (sbr->start) { - sbr_dequant(sbr, id_aac); - } - for (ch = 0; ch < nch; ch++) { - /* decode channel */ - sbr_qmf_analysis(&ac->fdsp, &sbr->mdct_ana, &sbr->dsp, ch ? R : L, sbr->data[ch].analysis_filterbank_samples, - (float*)sbr->qmf_filter_scratch, - sbr->data[ch].W, sbr->data[ch].Ypos); - sbr->c.sbr_lf_gen(ac, sbr, sbr->X_low, - (const float (*)[32][32][2]) sbr->data[ch].W, - sbr->data[ch].Ypos); - sbr->data[ch].Ypos ^= 1; - if (sbr->start) { - sbr->c.sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1, - (const float (*)[40][2]) sbr->X_low, sbr->k[0]); - sbr_chirp(sbr, &sbr->data[ch]); - sbr_hf_gen(ac, sbr, sbr->X_high, - (const float (*)[40][2]) sbr->X_low, - (const float (*)[2]) sbr->alpha0, - (const float (*)[2]) sbr->alpha1, - sbr->data[ch].bw_array, sbr->data[ch].t_env, - sbr->data[ch].bs_num_env); - - // hf_adj - err = sbr_mapping(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a); - if (!err) { - sbr_env_estimate(sbr->e_curr, sbr->X_high, sbr, &sbr->data[ch]); - sbr_gain_calc(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a); - sbr->c.sbr_hf_assemble(sbr->data[ch].Y[sbr->data[ch].Ypos], - (const float (*)[40][2]) sbr->X_high, - sbr, &sbr->data[ch], - sbr->data[ch].e_a); - } - } - - /* synthesis */ - sbr->c.sbr_x_gen(sbr, sbr->X[ch], - (const float (*)[64][2]) sbr->data[ch].Y[1-sbr->data[ch].Ypos], - (const float (*)[64][2]) sbr->data[ch].Y[ sbr->data[ch].Ypos], - (const float (*)[40][2]) sbr->X_low, ch); - } - - if (ac->oc[1].m4ac.ps == 1) { - if (sbr->ps.start) { - ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); - } else { - memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0])); - } - nch = 2; - } - - sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, &ac->fdsp, - L, sbr->X[0], sbr->qmf_filter_scratch, - sbr->data[0].synthesis_filterbank_samples, - &sbr->data[0].synthesis_filterbank_samples_offset, - downsampled); - if (nch == 2) - sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, &ac->fdsp, - R, sbr->X[1], sbr->qmf_filter_scratch, - sbr->data[1].synthesis_filterbank_samples, - &sbr->data[1].synthesis_filterbank_samples_offset, - downsampled); -} - -static void aacsbr_func_ptr_init(AACSBRContext *c) -{ - c->sbr_lf_gen = sbr_lf_gen; - c->sbr_hf_assemble = sbr_hf_assemble; - c->sbr_x_gen = sbr_x_gen; - c->sbr_hf_inverse_filter = sbr_hf_inverse_filter; - - if(ARCH_MIPS) - ff_aacsbr_func_ptr_init_mips(c); -} diff --git a/libavcodec/aacsbr.h b/libavcodec/aacsbr.h index f5e33ab..476bc65 100644 --- a/libavcodec/aacsbr.h +++ b/libavcodec/aacsbr.h @@ -33,6 +33,51 @@ #include "aac.h" #include "sbr.h" +#define ENVELOPE_ADJUSTMENT_OFFSET 2 +#define NOISE_FLOOR_OFFSET FIXR(6.0f) + +/** + * SBR VLC tables + */ +enum { + T_HUFFMAN_ENV_1_5DB, + F_HUFFMAN_ENV_1_5DB, + T_HUFFMAN_ENV_BAL_1_5DB, + F_HUFFMAN_ENV_BAL_1_5DB, + T_HUFFMAN_ENV_3_0DB, + F_HUFFMAN_ENV_3_0DB, + T_HUFFMAN_ENV_BAL_3_0DB, + F_HUFFMAN_ENV_BAL_3_0DB, + T_HUFFMAN_NOISE_3_0DB, + T_HUFFMAN_NOISE_BAL_3_0DB, +}; + +/** + * bs_frame_class - frame class of current SBR frame (14496-3 sp04 p98) + */ +enum { + FIXFIX, + FIXVAR, + VARFIX, + VARVAR, +}; + +enum { + EXTENSION_ID_PS = 2, +}; + +static const int8_t vlc_sbr_lav[10] = + { 60, 60, 24, 24, 31, 31, 12, 12, 31, 12 }; + +#define SBR_INIT_VLC_STATIC(num, size) \ + INIT_VLC_STATIC(&vlc_sbr[num], 9, sbr_tmp[num].table_size / sbr_tmp[num].elem_size, \ + sbr_tmp[num].sbr_bits , 1, 1, \ + sbr_tmp[num].sbr_codes, sbr_tmp[num].elem_size, sbr_tmp[num].elem_size, \ + size) + +#define SBR_VLC_ROW(name) \ + { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) } + /** Initialize SBR. */ void ff_aac_sbr_init(void); /** Initialize one SBR context. */ diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c new file mode 100644 index 0000000..7bfb215 --- /dev/null +++ b/libavcodec/aacsbr_template.c @@ -0,0 +1,1406 @@ +/* + * AAC Spectral Band Replication decoding functions + * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) + * Copyright (c) 2009-2010 Alex Converse + * + * Fixed point code + * Copyright (c) 2013 + * MIPS Technologies, Inc., California. + * + * This file is part of FFmpeg. + * + * 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 + */ + +/** + * @file + * AAC Spectral Band Replication decoding functions + * @author Robert Swain ( rob opendot cl ) + * @author Stanislav Ocovaj ( stanislav.ocovaj at imgtec.com ) + * @author Zoran Basaric ( zoran.basaric at imgtec.com ) + */ + +av_cold void ff_aac_sbr_init(void) +{ + int n; + static const struct { + const void *sbr_codes, *sbr_bits; + const unsigned int table_size, elem_size; + } sbr_tmp[] = { + SBR_VLC_ROW(t_huffman_env_1_5dB), + SBR_VLC_ROW(f_huffman_env_1_5dB), + SBR_VLC_ROW(t_huffman_env_bal_1_5dB), + SBR_VLC_ROW(f_huffman_env_bal_1_5dB), + SBR_VLC_ROW(t_huffman_env_3_0dB), + SBR_VLC_ROW(f_huffman_env_3_0dB), + SBR_VLC_ROW(t_huffman_env_bal_3_0dB), + SBR_VLC_ROW(f_huffman_env_bal_3_0dB), + SBR_VLC_ROW(t_huffman_noise_3_0dB), + SBR_VLC_ROW(t_huffman_noise_bal_3_0dB), + }; + + // SBR VLC table initialization + SBR_INIT_VLC_STATIC(0, 1098); + SBR_INIT_VLC_STATIC(1, 1092); + SBR_INIT_VLC_STATIC(2, 768); + SBR_INIT_VLC_STATIC(3, 1026); + SBR_INIT_VLC_STATIC(4, 1058); + SBR_INIT_VLC_STATIC(5, 1052); + SBR_INIT_VLC_STATIC(6, 544); + SBR_INIT_VLC_STATIC(7, 544); + SBR_INIT_VLC_STATIC(8, 592); + SBR_INIT_VLC_STATIC(9, 512); + + for (n = 1; n < 320; n++) + sbr_qmf_window_us[320 + n] = sbr_qmf_window_us[320 - n]; + sbr_qmf_window_us[384] = -sbr_qmf_window_us[384]; + sbr_qmf_window_us[512] = -sbr_qmf_window_us[512]; + + for (n = 0; n < 320; n++) + sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n]; + + ff_ps_init(); +} + +/** Places SBR in pure upsampling mode. */ +static void sbr_turnoff(SpectralBandReplication *sbr) { + sbr->start = 0; + // Init defults used in pure upsampling mode + sbr->kx[1] = 32; //Typo in spec, kx' inits to 32 + sbr->m[1] = 0; + // Reset values for first SBR header + sbr->data[0].e_a[1] = sbr->data[1].e_a[1] = -1; + memset(&sbr->spectrum_params, -1, sizeof(SpectrumParameters)); +} + +av_cold void ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr) +{ + if(sbr->mdct.mdct_bits) + return; + sbr->kx[0] = sbr->kx[1]; + sbr_turnoff(sbr); + sbr->data[0].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); + sbr->data[1].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); + /* SBR requires samples to be scaled to +/-32768.0 to work correctly. + * mdct scale factors are adjusted to scale up from +/-1.0 at analysis + * and scale back down at synthesis. */ + ff_mdct_init(&sbr->mdct, 7, 1, 1.0 / (64 * 32768.0)); + ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0 * 32768.0); + ff_ps_ctx_init(&sbr->ps); + ff_sbrdsp_init(&sbr->dsp); + aacsbr_func_ptr_init(&sbr->c); +} + +av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr) +{ + ff_mdct_end(&sbr->mdct); + ff_mdct_end(&sbr->mdct_ana); +} + +static int qsort_comparison_function_int16(const void *a, const void *b) +{ + return *(const int16_t *)a - *(const int16_t *)b; +} + +static inline int in_table_int16(const int16_t *table, int last_el, int16_t needle) +{ + int i; + for (i = 0; i <= last_el; i++) + if (table[i] == needle) + return 1; + return 0; +} + +/// Limiter Frequency Band Table (14496-3 sp04 p198) +static void sbr_make_f_tablelim(SpectralBandReplication *sbr) +{ + int k; + if (sbr->bs_limiter_bands > 0) { + static const float bands_warped[3] = { 1.32715174233856803909f, //2^(0.49/1.2) + 1.18509277094158210129f, //2^(0.49/2) + 1.11987160404675912501f }; //2^(0.49/3) + const float lim_bands_per_octave_warped = bands_warped[sbr->bs_limiter_bands - 1]; + int16_t patch_borders[7]; + uint16_t *in = sbr->f_tablelim + 1, *out = sbr->f_tablelim; + + patch_borders[0] = sbr->kx[1]; + for (k = 1; k <= sbr->num_patches; k++) + patch_borders[k] = patch_borders[k-1] + sbr->patch_num_subbands[k-1]; + + memcpy(sbr->f_tablelim, sbr->f_tablelow, + (sbr->n[0] + 1) * sizeof(sbr->f_tablelow[0])); + if (sbr->num_patches > 1) + memcpy(sbr->f_tablelim + sbr->n[0] + 1, patch_borders + 1, + (sbr->num_patches - 1) * sizeof(patch_borders[0])); + + qsort(sbr->f_tablelim, sbr->num_patches + sbr->n[0], + sizeof(sbr->f_tablelim[0]), + qsort_comparison_function_int16); + + sbr->n_lim = sbr->n[0] + sbr->num_patches - 1; + while (out < sbr->f_tablelim + sbr->n_lim) { + if (*in >= *out * lim_bands_per_octave_warped) { + *++out = *in++; + } else if (*in == *out || + !in_table_int16(patch_borders, sbr->num_patches, *in)) { + in++; + sbr->n_lim--; + } else if (!in_table_int16(patch_borders, sbr->num_patches, *out)) { + *out = *in++; + sbr->n_lim--; + } else { + *++out = *in++; + } + } + } else { + sbr->f_tablelim[0] = sbr->f_tablelow[0]; + sbr->f_tablelim[1] = sbr->f_tablelow[sbr->n[0]]; + sbr->n_lim = 1; + } +} + +static unsigned int read_sbr_header(SpectralBandReplication *sbr, GetBitContext *gb) +{ + unsigned int cnt = get_bits_count(gb); + uint8_t bs_header_extra_1; + uint8_t bs_header_extra_2; + int old_bs_limiter_bands = sbr->bs_limiter_bands; + SpectrumParameters old_spectrum_params; + + sbr->start = 1; + + // Save last spectrum parameters variables to compare to new ones + memcpy(&old_spectrum_params, &sbr->spectrum_params, sizeof(SpectrumParameters)); + + sbr->bs_amp_res_header = get_bits1(gb); + sbr->spectrum_params.bs_start_freq = get_bits(gb, 4); + sbr->spectrum_params.bs_stop_freq = get_bits(gb, 4); + sbr->spectrum_params.bs_xover_band = get_bits(gb, 3); + skip_bits(gb, 2); // bs_reserved + + bs_header_extra_1 = get_bits1(gb); + bs_header_extra_2 = get_bits1(gb); + + if (bs_header_extra_1) { + sbr->spectrum_params.bs_freq_scale = get_bits(gb, 2); + sbr->spectrum_params.bs_alter_scale = get_bits1(gb); + sbr->spectrum_params.bs_noise_bands = get_bits(gb, 2); + } else { + sbr->spectrum_params.bs_freq_scale = 2; + sbr->spectrum_params.bs_alter_scale = 1; + sbr->spectrum_params.bs_noise_bands = 2; + } + + // Check if spectrum parameters changed + if (memcmp(&old_spectrum_params, &sbr->spectrum_params, sizeof(SpectrumParameters))) + sbr->reset = 1; + + if (bs_header_extra_2) { + sbr->bs_limiter_bands = get_bits(gb, 2); + sbr->bs_limiter_gains = get_bits(gb, 2); + sbr->bs_interpol_freq = get_bits1(gb); + sbr->bs_smoothing_mode = get_bits1(gb); + } else { + sbr->bs_limiter_bands = 2; + sbr->bs_limiter_gains = 2; + sbr->bs_interpol_freq = 1; + sbr->bs_smoothing_mode = 1; + } + + if (sbr->bs_limiter_bands != old_bs_limiter_bands && !sbr->reset) + sbr_make_f_tablelim(sbr); + + return get_bits_count(gb) - cnt; +} + +static int array_min_int16(const int16_t *array, int nel) +{ + int i, min = array[0]; + for (i = 1; i < nel; i++) + min = FFMIN(array[i], min); + return min; +} + +static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band) +{ + // Requirements (14496-3 sp04 p205) + if (n_master <= 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master); + return -1; + } + if (bs_xover_band >= n_master) { + av_log(avctx, AV_LOG_ERROR, + "Invalid bitstream, crossover band index beyond array bounds: %d\n", + bs_xover_band); + return -1; + } + return 0; +} + +/// Master Frequency Band Table (14496-3 sp04 p194) +static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, + SpectrumParameters *spectrum) +{ + unsigned int temp, max_qmf_subbands; + unsigned int start_min, stop_min; + int k; + const int8_t *sbr_offset_ptr; + int16_t stop_dk[13]; + + if (sbr->sample_rate < 32000) { + temp = 3000; + } else if (sbr->sample_rate < 64000) { + temp = 4000; + } else + temp = 5000; + + switch (sbr->sample_rate) { + case 16000: + sbr_offset_ptr = sbr_offset[0]; + break; + case 22050: + sbr_offset_ptr = sbr_offset[1]; + break; + case 24000: + sbr_offset_ptr = sbr_offset[2]; + break; + case 32000: + sbr_offset_ptr = sbr_offset[3]; + break; + case 44100: case 48000: case 64000: + sbr_offset_ptr = sbr_offset[4]; + break; + case 88200: case 96000: case 128000: case 176400: case 192000: + sbr_offset_ptr = sbr_offset[5]; + break; + default: + av_log(ac->avctx, AV_LOG_ERROR, + "Unsupported sample rate for SBR: %d\n", sbr->sample_rate); + return -1; + } + + start_min = ((temp << 7) + (sbr->sample_rate >> 1)) / sbr->sample_rate; + stop_min = ((temp << 8) + (sbr->sample_rate >> 1)) / sbr->sample_rate; + + sbr->k[0] = start_min + sbr_offset_ptr[spectrum->bs_start_freq]; + + if (spectrum->bs_stop_freq < 14) { + sbr->k[2] = stop_min; + make_bands(stop_dk, stop_min, 64, 13); + qsort(stop_dk, 13, sizeof(stop_dk[0]), qsort_comparison_function_int16); + for (k = 0; k < spectrum->bs_stop_freq; k++) + sbr->k[2] += stop_dk[k]; + } else if (spectrum->bs_stop_freq == 14) { + sbr->k[2] = 2*sbr->k[0]; + } else if (spectrum->bs_stop_freq == 15) { + sbr->k[2] = 3*sbr->k[0]; + } else { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid bs_stop_freq: %d\n", spectrum->bs_stop_freq); + return -1; + } + sbr->k[2] = FFMIN(64, sbr->k[2]); + + // Requirements (14496-3 sp04 p205) + if (sbr->sample_rate <= 32000) { + max_qmf_subbands = 48; + } else if (sbr->sample_rate == 44100) { + max_qmf_subbands = 35; + } else if (sbr->sample_rate >= 48000) + max_qmf_subbands = 32; + else + av_assert0(0); + + if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid bitstream, too many QMF subbands: %d\n", sbr->k[2] - sbr->k[0]); + return -1; + } + + if (!spectrum->bs_freq_scale) { + int dk, k2diff; + + dk = spectrum->bs_alter_scale + 1; + sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1; + if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) + return -1; + + for (k = 1; k <= sbr->n_master; k++) + sbr->f_master[k] = dk; + + k2diff = sbr->k[2] - sbr->k[0] - sbr->n_master * dk; + if (k2diff < 0) { + sbr->f_master[1]--; + sbr->f_master[2]-= (k2diff < -1); + } else if (k2diff) { + sbr->f_master[sbr->n_master]++; + } + + sbr->f_master[0] = sbr->k[0]; + for (k = 1; k <= sbr->n_master; k++) + sbr->f_master[k] += sbr->f_master[k - 1]; + + } else { + int half_bands = 7 - spectrum->bs_freq_scale; // bs_freq_scale = {1,2,3} + int two_regions, num_bands_0; + int vdk0_max, vdk1_min; + int16_t vk0[49]; + + if (49 * sbr->k[2] > 110 * sbr->k[0]) { + two_regions = 1; + sbr->k[1] = 2 * sbr->k[0]; + } else { + two_regions = 0; + sbr->k[1] = sbr->k[2]; + } + + num_bands_0 = lrintf(half_bands * log2f(sbr->k[1] / (float)sbr->k[0])) * 2; + + if (num_bands_0 <= 0) { // Requirements (14496-3 sp04 p205) + av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0); + return -1; + } + + vk0[0] = 0; + + make_bands(vk0+1, sbr->k[0], sbr->k[1], num_bands_0); + + qsort(vk0 + 1, num_bands_0, sizeof(vk0[1]), qsort_comparison_function_int16); + vdk0_max = vk0[num_bands_0]; + + vk0[0] = sbr->k[0]; + for (k = 1; k <= num_bands_0; k++) { + if (vk0[k] <= 0) { // Requirements (14496-3 sp04 p205) + av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]); + return -1; + } + vk0[k] += vk0[k-1]; + } + + if (two_regions) { + int16_t vk1[49]; + float invwarp = spectrum->bs_alter_scale ? 0.76923076923076923077f + : 1.0f; // bs_alter_scale = {0,1} + int num_bands_1 = lrintf(half_bands * invwarp * + log2f(sbr->k[2] / (float)sbr->k[1])) * 2; + + make_bands(vk1+1, sbr->k[1], sbr->k[2], num_bands_1); + + vdk1_min = array_min_int16(vk1 + 1, num_bands_1); + + if (vdk1_min < vdk0_max) { + int change; + qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16); + change = FFMIN(vdk0_max - vk1[1], (vk1[num_bands_1] - vk1[1]) >> 1); + vk1[1] += change; + vk1[num_bands_1] -= change; + } + + qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16); + + vk1[0] = sbr->k[1]; + for (k = 1; k <= num_bands_1; k++) { + if (vk1[k] <= 0) { // Requirements (14496-3 sp04 p205) + av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]); + return -1; + } + vk1[k] += vk1[k-1]; + } + + sbr->n_master = num_bands_0 + num_bands_1; + if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) + return -1; + memcpy(&sbr->f_master[0], vk0, + (num_bands_0 + 1) * sizeof(sbr->f_master[0])); + memcpy(&sbr->f_master[num_bands_0 + 1], vk1 + 1, + num_bands_1 * sizeof(sbr->f_master[0])); + + } else { + sbr->n_master = num_bands_0; + if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) + return -1; + memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0])); + } + } + + return 0; +} + +/// High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46) +static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr) +{ + int i, k, sb = 0; + int msb = sbr->k[0]; + int usb = sbr->kx[1]; + int goal_sb = ((1000 << 11) + (sbr->sample_rate >> 1)) / sbr->sample_rate; + + sbr->num_patches = 0; + + if (goal_sb < sbr->kx[1] + sbr->m[1]) { + for (k = 0; sbr->f_master[k] < goal_sb; k++) ; + } else + k = sbr->n_master; + + do { + int odd = 0; + for (i = k; i == k || sb > (sbr->k[0] - 1 + msb - odd); i--) { + sb = sbr->f_master[i]; + odd = (sb + sbr->k[0]) & 1; + } + + // Requirements (14496-3 sp04 p205) sets the maximum number of patches to 5. + // After this check the final number of patches can still be six which is + // illegal however the Coding Technologies decoder check stream has a final + // count of 6 patches + if (sbr->num_patches > 5) { + av_log(ac->avctx, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches); + return -1; + } + + sbr->patch_num_subbands[sbr->num_patches] = FFMAX(sb - usb, 0); + sbr->patch_start_subband[sbr->num_patches] = sbr->k[0] - odd - sbr->patch_num_subbands[sbr->num_patches]; + + if (sbr->patch_num_subbands[sbr->num_patches] > 0) { + usb = sb; + msb = sb; + sbr->num_patches++; + } else + msb = sbr->kx[1]; + + if (sbr->f_master[k] - sb < 3) + k = sbr->n_master; + } while (sb != sbr->kx[1] + sbr->m[1]); + + if (sbr->num_patches > 1 && sbr->patch_num_subbands[sbr->num_patches-1] < 3) + sbr->num_patches--; + + return 0; +} + +/// Derived Frequency Band Tables (14496-3 sp04 p197) +static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr) +{ + int k, temp; + + sbr->n[1] = sbr->n_master - sbr->spectrum_params.bs_xover_band; + sbr->n[0] = (sbr->n[1] + 1) >> 1; + + memcpy(sbr->f_tablehigh, &sbr->f_master[sbr->spectrum_params.bs_xover_band], + (sbr->n[1] + 1) * sizeof(sbr->f_master[0])); + sbr->m[1] = sbr->f_tablehigh[sbr->n[1]] - sbr->f_tablehigh[0]; + sbr->kx[1] = sbr->f_tablehigh[0]; + + // Requirements (14496-3 sp04 p205) + if (sbr->kx[1] + sbr->m[1] > 64) { + av_log(ac->avctx, AV_LOG_ERROR, + "Stop frequency border too high: %d\n", sbr->kx[1] + sbr->m[1]); + return -1; + } + if (sbr->kx[1] > 32) { + av_log(ac->avctx, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]); + return -1; + } + + sbr->f_tablelow[0] = sbr->f_tablehigh[0]; + temp = sbr->n[1] & 1; + for (k = 1; k <= sbr->n[0]; k++) + sbr->f_tablelow[k] = sbr->f_tablehigh[2 * k - temp]; + + sbr->n_q = FFMAX(1, lrintf(sbr->spectrum_params.bs_noise_bands * + log2f(sbr->k[2] / (float)sbr->kx[1]))); // 0 <= bs_noise_bands <= 3 + if (sbr->n_q > 5) { + av_log(ac->avctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q); + return -1; + } + + sbr->f_tablenoise[0] = sbr->f_tablelow[0]; + temp = 0; + for (k = 1; k <= sbr->n_q; k++) { + temp += (sbr->n[0] - temp) / (sbr->n_q + 1 - k); + sbr->f_tablenoise[k] = sbr->f_tablelow[temp]; + } + + if (sbr_hf_calc_npatches(ac, sbr) < 0) + return -1; + + sbr_make_f_tablelim(sbr); + + sbr->data[0].f_indexnoise = 0; + sbr->data[1].f_indexnoise = 0; + + return 0; +} + +static av_always_inline void get_bits1_vector(GetBitContext *gb, uint8_t *vec, + int elements) +{ + int i; + for (i = 0; i < elements; i++) { + vec[i] = get_bits1(gb); + } +} + +/** ceil(log2(index+1)) */ +static const int8_t ceil_log2[] = { + 0, 1, 2, 2, 3, 3, +}; + +static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, + GetBitContext *gb, SBRData *ch_data) +{ + int i; + unsigned bs_pointer = 0; + // frameLengthFlag ? 15 : 16; 960 sample length frames unsupported; this value is numTimeSlots + int abs_bord_trail = 16; + int num_rel_lead, num_rel_trail; + unsigned bs_num_env_old = ch_data->bs_num_env; + + ch_data->bs_freq_res[0] = ch_data->bs_freq_res[ch_data->bs_num_env]; + ch_data->bs_amp_res = sbr->bs_amp_res_header; + ch_data->t_env_num_env_old = ch_data->t_env[bs_num_env_old]; + + switch (ch_data->bs_frame_class = get_bits(gb, 2)) { + case FIXFIX: + ch_data->bs_num_env = 1 << get_bits(gb, 2); + num_rel_lead = ch_data->bs_num_env - 1; + if (ch_data->bs_num_env == 1) + ch_data->bs_amp_res = 0; + + if (ch_data->bs_num_env > 4) { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n", + ch_data->bs_num_env); + return -1; + } + + ch_data->t_env[0] = 0; + ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; + + abs_bord_trail = (abs_bord_trail + (ch_data->bs_num_env >> 1)) / + ch_data->bs_num_env; + for (i = 0; i < num_rel_lead; i++) + ch_data->t_env[i + 1] = ch_data->t_env[i] + abs_bord_trail; + + ch_data->bs_freq_res[1] = get_bits1(gb); + for (i = 1; i < ch_data->bs_num_env; i++) + ch_data->bs_freq_res[i + 1] = ch_data->bs_freq_res[1]; + break; + case FIXVAR: + abs_bord_trail += get_bits(gb, 2); + num_rel_trail = get_bits(gb, 2); + ch_data->bs_num_env = num_rel_trail + 1; + ch_data->t_env[0] = 0; + ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; + + for (i = 0; i < num_rel_trail; i++) + ch_data->t_env[ch_data->bs_num_env - 1 - i] = + ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2; + + bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); + + for (i = 0; i < ch_data->bs_num_env; i++) + ch_data->bs_freq_res[ch_data->bs_num_env - i] = get_bits1(gb); + break; + case VARFIX: + ch_data->t_env[0] = get_bits(gb, 2); + num_rel_lead = get_bits(gb, 2); + ch_data->bs_num_env = num_rel_lead + 1; + ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; + + for (i = 0; i < num_rel_lead; i++) + ch_data->t_env[i + 1] = ch_data->t_env[i] + 2 * get_bits(gb, 2) + 2; + + bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); + + get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env); + break; + case VARVAR: + ch_data->t_env[0] = get_bits(gb, 2); + abs_bord_trail += get_bits(gb, 2); + num_rel_lead = get_bits(gb, 2); + num_rel_trail = get_bits(gb, 2); + ch_data->bs_num_env = num_rel_lead + num_rel_trail + 1; + + if (ch_data->bs_num_env > 5) { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n", + ch_data->bs_num_env); + return -1; + } + + ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; + + for (i = 0; i < num_rel_lead; i++) + ch_data->t_env[i + 1] = ch_data->t_env[i] + 2 * get_bits(gb, 2) + 2; + for (i = 0; i < num_rel_trail; i++) + ch_data->t_env[ch_data->bs_num_env - 1 - i] = + ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2; + + bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); + + get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env); + break; + } + + if (bs_pointer > ch_data->bs_num_env + 1) { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n", + bs_pointer); + return -1; + } + + for (i = 1; i <= ch_data->bs_num_env; i++) { + if (ch_data->t_env[i-1] > ch_data->t_env[i]) { + av_log(ac->avctx, AV_LOG_ERROR, "Non monotone time borders\n"); + return -1; + } + } + + ch_data->bs_num_noise = (ch_data->bs_num_env > 1) + 1; + + ch_data->t_q[0] = ch_data->t_env[0]; + ch_data->t_q[ch_data->bs_num_noise] = ch_data->t_env[ch_data->bs_num_env]; + if (ch_data->bs_num_noise > 1) { + unsigned int idx; + if (ch_data->bs_frame_class == FIXFIX) { + idx = ch_data->bs_num_env >> 1; + } else if (ch_data->bs_frame_class & 1) { // FIXVAR or VARVAR + idx = ch_data->bs_num_env - FFMAX((int)bs_pointer - 1, 1); + } else { // VARFIX + if (!bs_pointer) + idx = 1; + else if (bs_pointer == 1) + idx = ch_data->bs_num_env - 1; + else // bs_pointer > 1 + idx = bs_pointer - 1; + } + ch_data->t_q[1] = ch_data->t_env[idx]; + } + + ch_data->e_a[0] = -(ch_data->e_a[1] != bs_num_env_old); // l_APrev + ch_data->e_a[1] = -1; + if ((ch_data->bs_frame_class & 1) && bs_pointer) { // FIXVAR or VARVAR and bs_pointer != 0 + ch_data->e_a[1] = ch_data->bs_num_env + 1 - bs_pointer; + } else if ((ch_data->bs_frame_class == 2) && (bs_pointer > 1)) // VARFIX and bs_pointer > 1 + ch_data->e_a[1] = bs_pointer - 1; + + return 0; +} + +static void copy_sbr_grid(SBRData *dst, const SBRData *src) { + //These variables are saved from the previous frame rather than copied + dst->bs_freq_res[0] = dst->bs_freq_res[dst->bs_num_env]; + dst->t_env_num_env_old = dst->t_env[dst->bs_num_env]; + dst->e_a[0] = -(dst->e_a[1] != dst->bs_num_env); + + //These variables are read from the bitstream and therefore copied + memcpy(dst->bs_freq_res+1, src->bs_freq_res+1, sizeof(dst->bs_freq_res)-sizeof(*dst->bs_freq_res)); + memcpy(dst->t_env, src->t_env, sizeof(dst->t_env)); + memcpy(dst->t_q, src->t_q, sizeof(dst->t_q)); + dst->bs_num_env = src->bs_num_env; + dst->bs_amp_res = src->bs_amp_res; + dst->bs_num_noise = src->bs_num_noise; + dst->bs_frame_class = src->bs_frame_class; + dst->e_a[1] = src->e_a[1]; +} + +/// Read how the envelope and noise floor data is delta coded +static void read_sbr_dtdf(SpectralBandReplication *sbr, GetBitContext *gb, + SBRData *ch_data) +{ + get_bits1_vector(gb, ch_data->bs_df_env, ch_data->bs_num_env); + get_bits1_vector(gb, ch_data->bs_df_noise, ch_data->bs_num_noise); +} + +/// Read inverse filtering data +static void read_sbr_invf(SpectralBandReplication *sbr, GetBitContext *gb, + SBRData *ch_data) +{ + int i; + + memcpy(ch_data->bs_invf_mode[1], ch_data->bs_invf_mode[0], 5 * sizeof(uint8_t)); + for (i = 0; i < sbr->n_q; i++) + ch_data->bs_invf_mode[0][i] = get_bits(gb, 2); +} + +static void read_sbr_envelope(SpectralBandReplication *sbr, GetBitContext *gb, + SBRData *ch_data, int ch) +{ + int bits; + int i, j, k; + VLC_TYPE (*t_huff)[2], (*f_huff)[2]; + int t_lav, f_lav; + const int delta = (ch == 1 && sbr->bs_coupling == 1) + 1; + const int odd = sbr->n[1] & 1; + + if (sbr->bs_coupling && ch) { + if (ch_data->bs_amp_res) { + bits = 5; + t_huff = vlc_sbr[T_HUFFMAN_ENV_BAL_3_0DB].table; + t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_BAL_3_0DB]; + f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_3_0DB].table; + f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_3_0DB]; + } else { + bits = 6; + t_huff = vlc_sbr[T_HUFFMAN_ENV_BAL_1_5DB].table; + t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_BAL_1_5DB]; + f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_1_5DB].table; + f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_1_5DB]; + } + } else { + if (ch_data->bs_amp_res) { + bits = 6; + t_huff = vlc_sbr[T_HUFFMAN_ENV_3_0DB].table; + t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_3_0DB]; + f_huff = vlc_sbr[F_HUFFMAN_ENV_3_0DB].table; + f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB]; + } else { + bits = 7; + t_huff = vlc_sbr[T_HUFFMAN_ENV_1_5DB].table; + t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_1_5DB]; + f_huff = vlc_sbr[F_HUFFMAN_ENV_1_5DB].table; + f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_1_5DB]; + } + } + + for (i = 0; i < ch_data->bs_num_env; i++) { + if (ch_data->bs_df_env[i]) { + // bs_freq_res[0] == bs_freq_res[bs_num_env] from prev frame + if (ch_data->bs_freq_res[i + 1] == ch_data->bs_freq_res[i]) { + for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) + ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); + } else if (ch_data->bs_freq_res[i + 1]) { + for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { + k = (j + odd) >> 1; // find k such that f_tablelow[k] <= f_tablehigh[j] < f_tablelow[k + 1] + ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); + } + } else { + for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { + k = j ? 2*j - odd : 0; // find k such that f_tablehigh[k] == f_tablelow[j] + ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); + } + } + } else { + ch_data->env_facs[i + 1][0] = delta * get_bits(gb, bits); // bs_env_start_value_balance + for (j = 1; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) + ch_data->env_facs[i + 1][j] = ch_data->env_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); + } + } + + //assign 0th elements of env_facs from last elements + memcpy(ch_data->env_facs[0], ch_data->env_facs[ch_data->bs_num_env], + sizeof(ch_data->env_facs[0])); +} + +static void read_sbr_noise(SpectralBandReplication *sbr, GetBitContext *gb, + SBRData *ch_data, int ch) +{ + int i, j; + VLC_TYPE (*t_huff)[2], (*f_huff)[2]; + int t_lav, f_lav; + int delta = (ch == 1 && sbr->bs_coupling == 1) + 1; + + if (sbr->bs_coupling && ch) { + t_huff = vlc_sbr[T_HUFFMAN_NOISE_BAL_3_0DB].table; + t_lav = vlc_sbr_lav[T_HUFFMAN_NOISE_BAL_3_0DB]; + f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_3_0DB].table; + f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_3_0DB]; + } else { + t_huff = vlc_sbr[T_HUFFMAN_NOISE_3_0DB].table; + t_lav = vlc_sbr_lav[T_HUFFMAN_NOISE_3_0DB]; + f_huff = vlc_sbr[F_HUFFMAN_ENV_3_0DB].table; + f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB]; + } + + for (i = 0; i < ch_data->bs_num_noise; i++) { + if (ch_data->bs_df_noise[i]) { + for (j = 0; j < sbr->n_q; j++) + ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav); + } else { + ch_data->noise_facs[i + 1][0] = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level + for (j = 1; j < sbr->n_q; j++) + ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); + } + } + + //assign 0th elements of noise_facs from last elements + memcpy(ch_data->noise_facs[0], ch_data->noise_facs[ch_data->bs_num_noise], + sizeof(ch_data->noise_facs[0])); +} + +static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, + GetBitContext *gb, + int bs_extension_id, int *num_bits_left) +{ + switch (bs_extension_id) { + case EXTENSION_ID_PS: + if (!ac->oc[1].m4ac.ps) { + av_log(ac->avctx, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n"); + skip_bits_long(gb, *num_bits_left); // bs_fill_bits + *num_bits_left = 0; + } else { +#if 1 + *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps, *num_bits_left); + ac->avctx->profile = FF_PROFILE_AAC_HE_V2; +#else + avpriv_report_missing_feature(ac->avctx, "Parametric Stereo"); + skip_bits_long(gb, *num_bits_left); // bs_fill_bits + *num_bits_left = 0; +#endif + } + break; + default: + // some files contain 0-padding + if (bs_extension_id || *num_bits_left > 16 || show_bits(gb, *num_bits_left)) + avpriv_request_sample(ac->avctx, "Reserved SBR extensions"); + skip_bits_long(gb, *num_bits_left); // bs_fill_bits + *num_bits_left = 0; + break; + } +} + +static int read_sbr_single_channel_element(AACContext *ac, + SpectralBandReplication *sbr, + GetBitContext *gb) +{ + if (get_bits1(gb)) // bs_data_extra + skip_bits(gb, 4); // bs_reserved + + if (read_sbr_grid(ac, sbr, gb, &sbr->data[0])) + return -1; + read_sbr_dtdf(sbr, gb, &sbr->data[0]); + read_sbr_invf(sbr, gb, &sbr->data[0]); + read_sbr_envelope(sbr, gb, &sbr->data[0], 0); + read_sbr_noise(sbr, gb, &sbr->data[0], 0); + + if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb))) + get_bits1_vector(gb, sbr->data[0].bs_add_harmonic, sbr->n[1]); + + return 0; +} + +static int read_sbr_channel_pair_element(AACContext *ac, + SpectralBandReplication *sbr, + GetBitContext *gb) +{ + if (get_bits1(gb)) // bs_data_extra + skip_bits(gb, 8); // bs_reserved + + if ((sbr->bs_coupling = get_bits1(gb))) { + if (read_sbr_grid(ac, sbr, gb, &sbr->data[0])) + return -1; + copy_sbr_grid(&sbr->data[1], &sbr->data[0]); + read_sbr_dtdf(sbr, gb, &sbr->data[0]); + read_sbr_dtdf(sbr, gb, &sbr->data[1]); + read_sbr_invf(sbr, gb, &sbr->data[0]); + memcpy(sbr->data[1].bs_invf_mode[1], sbr->data[1].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0])); + memcpy(sbr->data[1].bs_invf_mode[0], sbr->data[0].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0])); + read_sbr_envelope(sbr, gb, &sbr->data[0], 0); + read_sbr_noise(sbr, gb, &sbr->data[0], 0); + read_sbr_envelope(sbr, gb, &sbr->data[1], 1); + read_sbr_noise(sbr, gb, &sbr->data[1], 1); + } else { + if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]) || + read_sbr_grid(ac, sbr, gb, &sbr->data[1])) + return -1; + read_sbr_dtdf(sbr, gb, &sbr->data[0]); + read_sbr_dtdf(sbr, gb, &sbr->data[1]); + read_sbr_invf(sbr, gb, &sbr->data[0]); + read_sbr_invf(sbr, gb, &sbr->data[1]); + read_sbr_envelope(sbr, gb, &sbr->data[0], 0); + read_sbr_envelope(sbr, gb, &sbr->data[1], 1); + read_sbr_noise(sbr, gb, &sbr->data[0], 0); + read_sbr_noise(sbr, gb, &sbr->data[1], 1); + } + + if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb))) + get_bits1_vector(gb, sbr->data[0].bs_add_harmonic, sbr->n[1]); + if ((sbr->data[1].bs_add_harmonic_flag = get_bits1(gb))) + get_bits1_vector(gb, sbr->data[1].bs_add_harmonic, sbr->n[1]); + + return 0; +} + +static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, + GetBitContext *gb, int id_aac) +{ + unsigned int cnt = get_bits_count(gb); + + if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) { + if (read_sbr_single_channel_element(ac, sbr, gb)) { + sbr_turnoff(sbr); + return get_bits_count(gb) - cnt; + } + } else if (id_aac == TYPE_CPE) { + if (read_sbr_channel_pair_element(ac, sbr, gb)) { + sbr_turnoff(sbr); + return get_bits_count(gb) - cnt; + } + } else { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid bitstream - cannot apply SBR to element type %d\n", id_aac); + sbr_turnoff(sbr); + return get_bits_count(gb) - cnt; + } + if (get_bits1(gb)) { // bs_extended_data + int num_bits_left = get_bits(gb, 4); // bs_extension_size + if (num_bits_left == 15) + num_bits_left += get_bits(gb, 8); // bs_esc_count + + num_bits_left <<= 3; + while (num_bits_left > 7) { + num_bits_left -= 2; + read_sbr_extension(ac, sbr, gb, get_bits(gb, 2), &num_bits_left); // bs_extension_id + } + if (num_bits_left < 0) { + av_log(ac->avctx, AV_LOG_ERROR, "SBR Extension over read.\n"); + } + if (num_bits_left > 0) + skip_bits(gb, num_bits_left); + } + + return get_bits_count(gb) - cnt; +} + +static void sbr_reset(AACContext *ac, SpectralBandReplication *sbr) +{ + int err; + err = sbr_make_f_master(ac, sbr, &sbr->spectrum_params); + if (err >= 0) + err = sbr_make_f_derived(ac, sbr); + if (err < 0) { + av_log(ac->avctx, AV_LOG_ERROR, + "SBR reset failed. Switching SBR to pure upsampling mode.\n"); + sbr_turnoff(sbr); + } +} + +/** + * Decode Spectral Band Replication extension data; reference: table 4.55. + * + * @param crc flag indicating the presence of CRC checksum + * @param cnt length of TYPE_FIL syntactic element in bytes + * + * @return Returns number of bytes consumed from the TYPE_FIL element. + */ +int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, + GetBitContext *gb_host, int crc, int cnt, int id_aac) +{ + unsigned int num_sbr_bits = 0, num_align_bits; + unsigned bytes_read; + GetBitContext gbc = *gb_host, *gb = &gbc; + skip_bits_long(gb_host, cnt*8 - 4); + + sbr->reset = 0; + + if (!sbr->sample_rate) + sbr->sample_rate = 2 * ac->oc[1].m4ac.sample_rate; //TODO use the nominal sample rate for arbitrary sample rate support + if (!ac->oc[1].m4ac.ext_sample_rate) + ac->oc[1].m4ac.ext_sample_rate = 2 * ac->oc[1].m4ac.sample_rate; + + if (crc) { + skip_bits(gb, 10); // bs_sbr_crc_bits; TODO - implement CRC check + num_sbr_bits += 10; + } + + //Save some state from the previous frame. + sbr->kx[0] = sbr->kx[1]; + sbr->m[0] = sbr->m[1]; + sbr->kx_and_m_pushed = 1; + + num_sbr_bits++; + if (get_bits1(gb)) // bs_header_flag + num_sbr_bits += read_sbr_header(sbr, gb); + + if (sbr->reset) + sbr_reset(ac, sbr); + + if (sbr->start) + num_sbr_bits += read_sbr_data(ac, sbr, gb, id_aac); + + num_align_bits = ((cnt << 3) - 4 - num_sbr_bits) & 7; + bytes_read = ((num_sbr_bits + num_align_bits + 4) >> 3); + + if (bytes_read > cnt) { + av_log(ac->avctx, AV_LOG_ERROR, + "Expected to read %d SBR bytes actually read %d.\n", cnt, bytes_read); + } + return cnt; +} + +/** + * Analysis QMF Bank (14496-3 sp04 p206) + * + * @param x pointer to the beginning of the first sample window + * @param W array of complex-valued samples split into subbands + */ +#ifndef sbr_qmf_analysis +static void sbr_qmf_analysis(AVFloatDSPContext *dsp, FFTContext *mdct, + SBRDSPContext *sbrdsp, const float *in, float *x, + float z[320], float W[2][32][32][2], int buf_idx) +{ + int i; + memcpy(x , x+1024, (320-32)*sizeof(x[0])); + memcpy(x+288, in, 1024*sizeof(x[0])); + for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames + // are not supported + dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320); + sbrdsp->sum64x5(z); + sbrdsp->qmf_pre_shuffle(z); + mdct->imdct_half(mdct, z, z+64); + sbrdsp->qmf_post_shuffle(W[buf_idx][i], z); + x += 32; + } +} +#endif + +/** + * Synthesis QMF Bank (14496-3 sp04 p206) and Downsampled Synthesis QMF Bank + * (14496-3 sp04 p206) + */ +#ifndef sbr_qmf_synthesis +static void sbr_qmf_synthesis(FFTContext *mdct, + SBRDSPContext *sbrdsp, AVFloatDSPContext *dsp, + float *out, float X[2][38][64], + float mdct_buf[2][64], + float *v0, int *v_off, const unsigned int div) +{ + int i, n; + const float *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us; + const int step = 128 >> div; + float *v; + for (i = 0; i < 32; i++) { + if (*v_off < step) { + int saved_samples = (1280 - 128) >> div; + memcpy(&v0[SBR_SYNTHESIS_BUF_SIZE - saved_samples], v0, saved_samples * sizeof(float)); + *v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - step; + } else { + *v_off -= step; + } + v = v0 + *v_off; + if (div) { + for (n = 0; n < 32; n++) { + X[0][i][ n] = -X[0][i][n]; + X[0][i][32+n] = X[1][i][31-n]; + } + mdct->imdct_half(mdct, mdct_buf[0], X[0][i]); + sbrdsp->qmf_deint_neg(v, mdct_buf[0]); + } else { + sbrdsp->neg_odd_64(X[1][i]); + mdct->imdct_half(mdct, mdct_buf[0], X[0][i]); + mdct->imdct_half(mdct, mdct_buf[1], X[1][i]); + sbrdsp->qmf_deint_bfly(v, mdct_buf[1], mdct_buf[0]); + } + dsp->vector_fmul (out, v , sbr_qmf_window , 64 >> div); + dsp->vector_fmul_add(out, v + ( 192 >> div), sbr_qmf_window + ( 64 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + ( 256 >> div), sbr_qmf_window + (128 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + ( 448 >> div), sbr_qmf_window + (192 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + ( 512 >> div), sbr_qmf_window + (256 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + ( 704 >> div), sbr_qmf_window + (320 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + ( 768 >> div), sbr_qmf_window + (384 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + ( 960 >> div), sbr_qmf_window + (448 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + (1024 >> div), sbr_qmf_window + (512 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + (1216 >> div), sbr_qmf_window + (576 >> div), out , 64 >> div); + out += 64 >> div; + } +} +#endif + +/// Generate the subband filtered lowband +static int sbr_lf_gen(AACContext *ac, SpectralBandReplication *sbr, + float X_low[32][40][2], const float W[2][32][32][2], + int buf_idx) +{ + int i, k; + const int t_HFGen = 8; + const int i_f = 32; + memset(X_low, 0, 32*sizeof(*X_low)); + for (k = 0; k < sbr->kx[1]; k++) { + for (i = t_HFGen; i < i_f + t_HFGen; i++) { + X_low[k][i][0] = W[buf_idx][i - t_HFGen][k][0]; + X_low[k][i][1] = W[buf_idx][i - t_HFGen][k][1]; + } + } + buf_idx = 1-buf_idx; + for (k = 0; k < sbr->kx[0]; k++) { + for (i = 0; i < t_HFGen; i++) { + X_low[k][i][0] = W[buf_idx][i + i_f - t_HFGen][k][0]; + X_low[k][i][1] = W[buf_idx][i + i_f - t_HFGen][k][1]; + } + } + return 0; +} + +/// High Frequency Generator (14496-3 sp04 p215) +static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, + float X_high[64][40][2], const float X_low[32][40][2], + const float (*alpha0)[2], const float (*alpha1)[2], + const float bw_array[5], const uint8_t *t_env, + int bs_num_env) +{ + int j, x; + int g = 0; + int k = sbr->kx[1]; + for (j = 0; j < sbr->num_patches; j++) { + for (x = 0; x < sbr->patch_num_subbands[j]; x++, k++) { + const int p = sbr->patch_start_subband[j] + x; + while (g <= sbr->n_q && k >= sbr->f_tablenoise[g]) + g++; + g--; + + if (g < 0) { + av_log(ac->avctx, AV_LOG_ERROR, + "ERROR : no subband found for frequency %d\n", k); + return -1; + } + + sbr->dsp.hf_gen(X_high[k] + ENVELOPE_ADJUSTMENT_OFFSET, + X_low[p] + ENVELOPE_ADJUSTMENT_OFFSET, + alpha0[p], alpha1[p], bw_array[g], + 2 * t_env[0], 2 * t_env[bs_num_env]); + } + } + if (k < sbr->m[1] + sbr->kx[1]) + memset(X_high + k, 0, (sbr->m[1] + sbr->kx[1] - k) * sizeof(*X_high)); + + return 0; +} + +/// Generate the subband filtered lowband +static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][38][64], + const float Y0[38][64][2], const float Y1[38][64][2], + const float X_low[32][40][2], int ch) +{ + int k, i; + const int i_f = 32; + const int i_Temp = FFMAX(2*sbr->data[ch].t_env_num_env_old - i_f, 0); + memset(X, 0, 2*sizeof(*X)); + for (k = 0; k < sbr->kx[0]; k++) { + for (i = 0; i < i_Temp; i++) { + X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; + X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; + } + } + for (; k < sbr->kx[0] + sbr->m[0]; k++) { + for (i = 0; i < i_Temp; i++) { + X[0][i][k] = Y0[i + i_f][k][0]; + X[1][i][k] = Y0[i + i_f][k][1]; + } + } + + for (k = 0; k < sbr->kx[1]; k++) { + for (i = i_Temp; i < 38; i++) { + X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; + X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; + } + } + for (; k < sbr->kx[1] + sbr->m[1]; k++) { + for (i = i_Temp; i < i_f; i++) { + X[0][i][k] = Y1[i][k][0]; + X[1][i][k] = Y1[i][k][1]; + } + } + return 0; +} + +/** High Frequency Adjustment (14496-3 sp04 p217) and Mapping + * (14496-3 sp04 p217) + */ +static int sbr_mapping(AACContext *ac, SpectralBandReplication *sbr, + SBRData *ch_data, int e_a[2]) +{ + int e, i, m; + + memset(ch_data->s_indexmapped[1], 0, 7*sizeof(ch_data->s_indexmapped[1])); + for (e = 0; e < ch_data->bs_num_env; e++) { + const unsigned int ilim = sbr->n[ch_data->bs_freq_res[e + 1]]; + uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow; + int k; + + if (sbr->kx[1] != table[0]) { + av_log(ac->avctx, AV_LOG_ERROR, "kx != f_table{high,low}[0]. " + "Derived frequency tables were not regenerated.\n"); + sbr_turnoff(sbr); + return AVERROR_BUG; + } + for (i = 0; i < ilim; i++) + for (m = table[i]; m < table[i + 1]; m++) + sbr->e_origmapped[e][m - sbr->kx[1]] = ch_data->env_facs[e+1][i]; + + // ch_data->bs_num_noise > 1 => 2 noise floors + k = (ch_data->bs_num_noise > 1) && (ch_data->t_env[e] >= ch_data->t_q[1]); + for (i = 0; i < sbr->n_q; i++) + for (m = sbr->f_tablenoise[i]; m < sbr->f_tablenoise[i + 1]; m++) + sbr->q_mapped[e][m - sbr->kx[1]] = ch_data->noise_facs[k+1][i]; + + for (i = 0; i < sbr->n[1]; i++) { + if (ch_data->bs_add_harmonic_flag) { + const unsigned int m_midpoint = + (sbr->f_tablehigh[i] + sbr->f_tablehigh[i + 1]) >> 1; + + ch_data->s_indexmapped[e + 1][m_midpoint - sbr->kx[1]] = ch_data->bs_add_harmonic[i] * + (e >= e_a[1] || (ch_data->s_indexmapped[0][m_midpoint - sbr->kx[1]] == 1)); + } + } + + for (i = 0; i < ilim; i++) { + int additional_sinusoid_present = 0; + for (m = table[i]; m < table[i + 1]; m++) { + if (ch_data->s_indexmapped[e + 1][m - sbr->kx[1]]) { + additional_sinusoid_present = 1; + break; + } + } + memset(&sbr->s_mapped[e][table[i] - sbr->kx[1]], additional_sinusoid_present, + (table[i + 1] - table[i]) * sizeof(sbr->s_mapped[e][0])); + } + } + + memcpy(ch_data->s_indexmapped[0], ch_data->s_indexmapped[ch_data->bs_num_env], sizeof(ch_data->s_indexmapped[0])); + return 0; +} + +/// Estimation of current envelope (14496-3 sp04 p218) +static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2], + SpectralBandReplication *sbr, SBRData *ch_data) +{ + int e, m; + int kx1 = sbr->kx[1]; + + if (sbr->bs_interpol_freq) { + for (e = 0; e < ch_data->bs_num_env; e++) { + const float recip_env_size = 0.5f / (ch_data->t_env[e + 1] - ch_data->t_env[e]); + int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; + int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; + + for (m = 0; m < sbr->m[1]; m++) { + float sum = sbr->dsp.sum_square(X_high[m+kx1] + ilb, iub - ilb); + e_curr[e][m] = sum * recip_env_size; + } + } + } else { + int k, p; + + for (e = 0; e < ch_data->bs_num_env; e++) { + const int env_size = 2 * (ch_data->t_env[e + 1] - ch_data->t_env[e]); + int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; + int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; + const uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow; + + for (p = 0; p < sbr->n[ch_data->bs_freq_res[e + 1]]; p++) { + float sum = 0.0f; + const int den = env_size * (table[p + 1] - table[p]); + + for (k = table[p]; k < table[p + 1]; k++) { + sum += sbr->dsp.sum_square(X_high[k] + ilb, iub - ilb); + } + sum /= den; + for (k = table[p]; k < table[p + 1]; k++) { + e_curr[e][k - kx1] = sum; + } + } + } + } +} + +void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, + float* L, float* R) +{ + int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate; + int ch; + int nch = (id_aac == TYPE_CPE) ? 2 : 1; + int err; + + if (!sbr->kx_and_m_pushed) { + sbr->kx[0] = sbr->kx[1]; + sbr->m[0] = sbr->m[1]; + } else { + sbr->kx_and_m_pushed = 0; + } + + if (sbr->start) { + sbr_dequant(sbr, id_aac); + } + for (ch = 0; ch < nch; ch++) { + /* decode channel */ + sbr_qmf_analysis(&ac->fdsp, &sbr->mdct_ana, &sbr->dsp, ch ? R : L, sbr->data[ch].analysis_filterbank_samples, + (float*)sbr->qmf_filter_scratch, + sbr->data[ch].W, sbr->data[ch].Ypos); + sbr->c.sbr_lf_gen(ac, sbr, sbr->X_low, + (const float (*)[32][32][2]) sbr->data[ch].W, + sbr->data[ch].Ypos); + sbr->data[ch].Ypos ^= 1; + if (sbr->start) { + sbr->c.sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1, + (const float (*)[40][2]) sbr->X_low, sbr->k[0]); + sbr_chirp(sbr, &sbr->data[ch]); + sbr_hf_gen(ac, sbr, sbr->X_high, + (const float (*)[40][2]) sbr->X_low, + (const float (*)[2]) sbr->alpha0, + (const float (*)[2]) sbr->alpha1, + sbr->data[ch].bw_array, sbr->data[ch].t_env, + sbr->data[ch].bs_num_env); + + // hf_adj + err = sbr_mapping(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a); + if (!err) { + sbr_env_estimate(sbr->e_curr, sbr->X_high, sbr, &sbr->data[ch]); + sbr_gain_calc(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a); + sbr->c.sbr_hf_assemble(sbr->data[ch].Y[sbr->data[ch].Ypos], + (const float (*)[40][2]) sbr->X_high, + sbr, &sbr->data[ch], + sbr->data[ch].e_a); + } + } + + /* synthesis */ + sbr->c.sbr_x_gen(sbr, sbr->X[ch], + (const float (*)[64][2]) sbr->data[ch].Y[1-sbr->data[ch].Ypos], + (const float (*)[64][2]) sbr->data[ch].Y[ sbr->data[ch].Ypos], + (const float (*)[40][2]) sbr->X_low, ch); + } + + if (ac->oc[1].m4ac.ps == 1) { + if (sbr->ps.start) { + ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); + } else { + memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0])); + } + nch = 2; + } + + sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, &ac->fdsp, + L, sbr->X[0], sbr->qmf_filter_scratch, + sbr->data[0].synthesis_filterbank_samples, + &sbr->data[0].synthesis_filterbank_samples_offset, + downsampled); + if (nch == 2) + sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, &ac->fdsp, + R, sbr->X[1], sbr->qmf_filter_scratch, + sbr->data[1].synthesis_filterbank_samples, + &sbr->data[1].synthesis_filterbank_samples_offset, + downsampled); +} + +static void aacsbr_func_ptr_init(AACSBRContext *c) +{ + c->sbr_lf_gen = sbr_lf_gen; + c->sbr_hf_assemble = sbr_hf_assemble; + c->sbr_x_gen = sbr_x_gen; + c->sbr_hf_inverse_filter = sbr_hf_inverse_filter; + + if(ARCH_MIPS) + ff_aacsbr_func_ptr_init_mips(c); +} -- 1.8.2.1 From nedeljko.babic at imgtec.com Fri Aug 1 15:53:19 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:19 +0200 Subject: [FFmpeg-devel] [PATCH 13/14] libavcodec: Implementation of AAC_fixed_decoder (PS-module) [4/4] In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-14-git-send-email-nedeljko.babic@imgtec.com> From: Jovan Zelincevic Build system modified. Signed-off-by: Nedeljko Babic --- libavcodec/Makefile | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 5931554..2f68cf5 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -105,12 +105,12 @@ OBJS-$(CONFIG_VP3DSP) += vp3dsp.o OBJS-$(CONFIG_ZERO12V_DECODER) += 012v.o OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o -OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \ +OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps_float.o \ aacadtsdec.o mpeg4audio.o kbdwin.o \ - sbrdsp_float.o aacpsdsp.o -OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o \ + sbrdsp_float.o aacpsdsp_float.o +OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o aacps_fixed.o \ aacadtsdec.o mpeg4audio.o kbdwin.o \ - sbrdsp_fixed.o + sbrdsp_fixed.o aacpsdsp_fixed.o OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \ aacpsy.o aactab.o \ psymodel.o mpeg4audio.o kbdwin.o @@ -875,6 +875,7 @@ TOOLS = fourcc2pixfmt HOSTPROGS = aac_tablegen \ aacps_tablegen \ + aacps_fixed_tablegen \ cbrt_tablegen \ cbrt_fixed_tablegen \ cos_tablegen \ @@ -904,9 +905,10 @@ else $(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=0 endif -GEN_HEADERS = cbrt_tables.h cbrt_fixed_tables.h aacps_tables.h aac_tables.h dsd_tables.h \ - dv_tables.h sinewin_tables.h sinewin_fixed_tables.h mpegaudio_tables.h \ - motionpixels_tables.h pcm_tables.h qdm2_tables.h +GEN_HEADERS = cbrt_tables.h cbrt_fixed_tables.h aacps_tables.h aacps_fixed_tables.h \ + aac_tables.h dsd_tables.h dv_tables.h sinewin_tables.h \ + sinewin_fixed_tables.h mpegaudio_tables.h motionpixels_tables.h \ + pcm_tables.h qdm2_tables.h GEN_HEADERS := $(addprefix $(SUBDIR), $(GEN_HEADERS)) $(GEN_HEADERS): $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF) @@ -915,7 +917,8 @@ $(GEN_HEADERS): $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF) ifdef CONFIG_HARDCODED_TABLES $(SUBDIR)aacdec.o: $(SUBDIR)cbrt_tables.h $(SUBDIR)aacdec_fixed.o: $(SUBDIR)cbrt_fixed_tables.h -$(SUBDIR)aacps.o: $(SUBDIR)aacps_tables.h +$(SUBDIR)aacps_float.o: $(SUBDIR)aacps_tables.h +$(SUBDIR)aacps_fixed.o: $(SUBDIR)aacps_fixed_tables.h $(SUBDIR)aactab.o: $(SUBDIR)aac_tables.h $(SUBDIR)aactab_fixed.o: $(SUBDIR)aac_fixed_tables.h $(SUBDIR)dsddec.o: $(SUBDIR)dsd_tables.h -- 1.8.2.1 From nedeljko.babic at imgtec.com Fri Aug 1 15:53:14 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:14 +0200 Subject: [FFmpeg-devel] [PATCH 08/14] libavcodec: Implementation of AAC_fixed_decoder (SBR-module) [3/4] In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-9-git-send-email-nedeljko.babic@imgtec.com> From: Djordje Pesut Add fixed poind code. Signed-off-by: Nedeljko Babic --- libavcodec/aac.h | 51 +--- libavcodec/aac_defines.h | 77 ++++++ libavcodec/aacsbr.c | 3 + libavcodec/aacsbr.h | 13 +- libavcodec/aacsbr_fixed.c | 555 +++++++++++++++++++++++++++++++++++++++++++ libavcodec/aacsbr_template.c | 226 ++++++++++++++---- libavcodec/sbr.h | 78 +++--- libavcodec/sbrdsp.c | 295 ----------------------- libavcodec/sbrdsp.h | 36 +-- libavcodec/sbrdsp_fixed.c | 364 ++++++++++++++++++++++++++++ libavcodec/sbrdsp_float.c | 225 ++++++++++++++++++ libavcodec/sbrdsp_template.c | 97 ++++++++ 12 files changed, 1565 insertions(+), 455 deletions(-) create mode 100644 libavcodec/aac_defines.h create mode 100644 libavcodec/aacsbr_fixed.c delete mode 100644 libavcodec/sbrdsp.c create mode 100644 libavcodec/sbrdsp_fixed.c create mode 100644 libavcodec/sbrdsp_float.c create mode 100644 libavcodec/sbrdsp_template.c diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 35e871b..f81ddaf 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -30,56 +30,7 @@ #ifndef AVCODEC_AAC_H #define AVCODEC_AAC_H -#ifndef USE_FIXED -#define USE_FIXED 0 -#endif - -#if USE_FIXED - -#define FFT_FLOAT 0 -#define FFT_FIXED_32 1 - -#define AAC_RENAME(x) x ## _fixed -#define AAC_RENAME_32(x) x ## _fixed_32 -#define INTFLOAT int -#define SHORTFLOAT int16_t -#define AAC_FLOAT aac_float_t -#define AAC_SIGNE int -#define FIXR(a) ((int)((a) * 1 + 0.5)) -#define FIXR10(a) ((int)((a) * 1024.0 + 0.5)) -#define Q23(a) (int)((a) * 8388608.0 + 0.5) -#define Q30(x) (int)((x)*1073741824.0 + 0.5) -#define Q31(x) (int)((x)*2147483648.0 + 0.5) -#define RANGE15(x) x -#define GET_GAIN(x, y) (-(y) << (x)) + 1024 -#define AAC_MUL26(x, y) (int)(((int64_t)(x) * (y) + 0x2000000) >> 26) -#define AAC_MUL30(x, y) (int)(((int64_t)(x) * (y) + 0x20000000) >> 30) -#define AAC_MUL31(x, y) (int)(((int64_t)(x) * (y) + 0x40000000) >> 31) - -#else - -#define FFT_FLOAT 1 -#define FFT_FIXED_32 0 - -#define AAC_RENAME(x) x -#define AAC_RENAME_32(x) x -#define INTFLOAT float -#define SHORTFLOAT float -#define AAC_FLOAT float -#define AAC_SIGNE unsigned -#define FIXR(x) ((float)(x)) -#define FIXR10(x) ((float)(x)) -#define Q23(x) x -#define Q30(x) x -#define Q31(x) x -#define RANGE15(x) (32768.0 * (x)) -#define GET_GAIN(x, y) powf((x), -(y)) -#define AAC_MUL26(x, y) ((x) * (y)) -#define AAC_MUL30(x, y) ((x) * (y)) -#define AAC_MUL31(x, y) ((x) * (y)) - -#endif /* USE_FIXED */ - +#include "aac_defines.h" #include "libavutil/float_dsp.h" #include "libavutil/fixed_dsp.h" #include "avcodec.h" diff --git a/libavcodec/aac_defines.h b/libavcodec/aac_defines.h new file mode 100644 index 0000000..71568e3 --- /dev/null +++ b/libavcodec/aac_defines.h @@ -0,0 +1,77 @@ +/* + * AAC defines + * + * This file is part of FFmpeg. + * + * 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 + */ + +#ifndef AVCODEC_AAC_DEFINES_H +#define AVCODEC_AAC_DEFINES_H + +#ifndef USE_FIXED +#define USE_FIXED 0 +#endif + +#if USE_FIXED + +#define FFT_FLOAT 0 +#define FFT_FIXED_32 1 + +#define AAC_RENAME(x) x ## _fixed +#define AAC_RENAME_32(x) x ## _fixed_32 +#define INTFLOAT int +#define SHORTFLOAT int16_t +#define AAC_FLOAT aac_float_t +#define AAC_SIGNE int +#define FIXR(a) ((int)((a) * 1 + 0.5)) +#define FIXR10(a) ((int)((a) * 1024.0 + 0.5)) +#define Q23(a) (int)((a) * 8388608.0 + 0.5) +#define Q30(x) (int)((x)*1073741824.0 + 0.5) +#define Q31(x) (int)((x)*2147483648.0 + 0.5) +#define RANGE15(x) x +#define GET_GAIN(x, y) (-(y) << (x)) + 1024 +#define AAC_MUL26(x, y) (int)(((int64_t)(x) * (y) + 0x2000000) >> 26) +#define AAC_MUL30(x, y) (int)(((int64_t)(x) * (y) + 0x20000000) >> 30) +#define AAC_MUL31(x, y) (int)(((int64_t)(x) * (y) + 0x40000000) >> 31) +#define AAC_SRA_R(x, y) (int)(((x) + (1 << ((y) - 1))) >> (y)) + +#else + +#define FFT_FLOAT 1 +#define FFT_FIXED_32 0 + +#define AAC_RENAME(x) x +#define AAC_RENAME_32(x) x +#define INTFLOAT float +#define SHORTFLOAT float +#define AAC_FLOAT float +#define AAC_SIGNE unsigned +#define FIXR(x) ((float)(x)) +#define FIXR10(x) ((float)(x)) +#define Q23(x) x +#define Q30(x) x +#define Q31(x) x +#define RANGE15(x) (32768.0 * (x)) +#define GET_GAIN(x, y) powf((x), -(y)) +#define AAC_MUL26(x, y) ((x) * (y)) +#define AAC_MUL30(x, y) ((x) * (y)) +#define AAC_MUL31(x, y) ((x) * (y)) +#define AAC_SRA_R(x, y) (x) + +#endif /* USE_FIXED */ + +#endif /* AVCODEC_AAC_DEFINES_H */ + diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index 5b23579..8c6f901 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -25,6 +25,7 @@ * AAC Spectral Band Replication decoding functions * @author Robert Swain ( rob opendot cl ) */ +#define USE_FIXED 0 #include "aac.h" #include "sbr.h" @@ -350,3 +351,5 @@ static void sbr_hf_assemble(float Y1[38][64][2], ch_data->f_indexnoise = indexnoise; ch_data->f_indexsine = indexsine; } + +#include "aacsbr_template.c" diff --git a/libavcodec/aacsbr.h b/libavcodec/aacsbr.h index 476bc65..87b4947 100644 --- a/libavcodec/aacsbr.h +++ b/libavcodec/aacsbr.h @@ -79,18 +79,17 @@ static const int8_t vlc_sbr_lav[10] = { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) } /** Initialize SBR. */ -void ff_aac_sbr_init(void); +void AAC_RENAME(ff_aac_sbr_init)(void); /** Initialize one SBR context. */ -void ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr); +void AAC_RENAME(ff_aac_sbr_ctx_init)(AACContext *ac, SpectralBandReplication *sbr); /** Close one SBR context. */ -void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr); +void AAC_RENAME(ff_aac_sbr_ctx_close)(SpectralBandReplication *sbr); /** Decode one SBR element. */ -int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, +int AAC_RENAME(ff_decode_sbr_extension)(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int crc, int cnt, int id_aac); /** Apply one SBR element to one AAC element. */ -void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, - float* L, float *R); - +void AAC_RENAME(ff_sbr_apply)(AACContext *ac, SpectralBandReplication *sbr, int id_aac, + INTFLOAT* L, INTFLOAT *R); void ff_aacsbr_func_ptr_init_mips(AACSBRContext *c); #endif /* AVCODEC_AACSBR_H */ diff --git a/libavcodec/aacsbr_fixed.c b/libavcodec/aacsbr_fixed.c new file mode 100644 index 0000000..ec00846 --- /dev/null +++ b/libavcodec/aacsbr_fixed.c @@ -0,0 +1,555 @@ +/* + * Copyright (c) 2013 + * MIPS Technologies, Inc., California. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * AAC Spectral Band Replication decoding functions (fixed-point) + * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) + * Copyright (c) 2009-2010 Alex Converse + * + * This file is part of FFmpeg. + * + * 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 + */ + +/** + * @file + * AAC Spectral Band Replication decoding functions (fixed-point) + * @author Robert Swain ( rob opendot cl ) + * @author Stanislav Ocovaj ( stanislav.ocovaj imgtec com ) + */ +#define USE_FIXED 1 + +#include "aac.h" +#include "sbr.h" +#include "aacsbr.h" + +#include "aacsbrdata.h" +#include "fft.h" +#include "aacps.h" +#include "sbrdsp.h" +#include "libavutil/internal.h" +#include "libavutil/libm.h" +#include "libavutil/avassert.h" + +#include +#include +#include + +static VLC vlc_sbr[10]; + +static void aacsbr_func_ptr_init(AACSBRContext *c); +static const int CONST_LN2 = Q31(0.6931471806/256); // ln(2)/256 +static const int CONST_RECIP_LN2 = Q31(0.7213475204); // 0.5/ln(2) +static const int CONST_SQRT2 = Q30(0.7071067812); // sqrt(2)/2 +static const int CONST_076923 = Q31(0.76923076923076923077f); + +int fixed_log_table[10] = +{ + Q31(1.0/2), Q31(1.0/3), Q31(1.0/4), Q31(1.0/5), Q31(1.0/6), Q31(1.0/7), Q31(1.0/8), Q31(1.0/9), Q31(1.0/10), Q31(1.0/11) +}; + +static int fixed_log(int x) +{ + int i, ret, xpow, tmp; + + ret = x; + xpow = x; + for (i=0; i<10; i+=2){ + xpow = (int)(((int64_t)xpow * x + 0x40000000) >> 31); + tmp = (int)(((int64_t)xpow * fixed_log_table[i] + 0x40000000) >> 31); + ret -= tmp; + + xpow = (int)(((int64_t)xpow * x + 0x40000000) >> 31); + tmp = (int)(((int64_t)xpow * fixed_log_table[i+1] + 0x40000000) >> 31); + ret += tmp; + } + + return ret; +} + +int fixed_exp_table[7] = +{ + Q31(1.0/2), Q31(1.0/6), Q31(1.0/24), Q31(1.0/120), Q31(1.0/720), Q31(1.0/5040), Q31(1.0/40320) +}; + +static int fixed_exp(int x) +{ + int i, ret, xpow, tmp; + int64_t accu; + + ret = 0x800000 + x; + xpow = x; + for (i=0; i<7; i++){ + accu = (int64_t)xpow * x; + xpow = (int)((accu + 0x400000) >> 23); + accu = (int64_t)xpow * fixed_exp_table[i]; + tmp = (int)((accu + 0x40000000) >> 31); + ret += tmp; + } + + return ret; +} + +static void make_bands(int16_t* bands, int start, int stop, int num_bands) +{ + int k, previous, present; + int base, prod, nz = 0; + int64_t accu; + + base = (stop << 23) / start; + while (base < 0x40000000){ + base <<= 1; + nz++; + } + base = fixed_log(base - 0x80000000); + base = (((base+128)>>8) + (8-nz)*CONST_LN2) / num_bands; + base = fixed_exp(base); + + previous = start; + prod = start << 23; + + for (k = 0; k < num_bands-1; k++) { + accu = (int64_t)prod * base; + prod = (int)((accu + 0x400000) >> 23); + present = (prod + 0x400000) >> 23; + bands[k] = present - previous; + previous = present; + } + bands[num_bands-1] = stop - previous; +} + +/// Dequantization and stereo decoding (14496-3 sp04 p203) +static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) +{ + int k, e; + int ch; + + if (id_aac == TYPE_CPE && sbr->bs_coupling) { + int alpha = sbr->data[0].bs_amp_res ? 2 : 1; + int pan_offset = sbr->data[0].bs_amp_res ? 12 : 24; + for (e = 1; e <= sbr->data[0].bs_num_env; e++) { + for (k = 0; k < sbr->n[sbr->data[0].bs_freq_res[e]]; k++) { + aac_float_t temp1, temp2, fac; + + temp1.expo = sbr->data[0].env_facs[e][k].mant * alpha + 14; + if (temp1.expo & 1) + temp1.mant = 759250125; + else + temp1.mant = 0x20000000; + temp1.expo = (temp1.expo >> 1) + 1; + + temp2.expo = (pan_offset - sbr->data[1].env_facs[e][k].mant) * alpha; + if (temp2.expo & 1) + temp2.mant = 759250125; + else + temp2.mant = 0x20000000; + temp2.expo = (temp2.expo >> 1) + 1; + fac = float_div(temp1, float_add(FLOAT_1, temp2)); + sbr->data[0].env_facs[e][k] = fac; + sbr->data[1].env_facs[e][k] = float_mul(fac, temp2); + } + } + for (e = 1; e <= sbr->data[0].bs_num_noise; e++) { + for (k = 0; k < sbr->n_q; k++) { + aac_float_t temp1, temp2, fac; + + temp1.expo = NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs[e][k].mant + 2; + temp1.mant = 0x20000000; + temp2.expo = 12 - sbr->data[1].noise_facs[e][k].mant + 1; + temp2.mant = 0x20000000; + fac = float_div(temp1, float_add(FLOAT_1, temp2)); + sbr->data[0].noise_facs[e][k] = fac; + sbr->data[1].noise_facs[e][k] = float_mul(fac, temp2); + } + } + } else { // SCE or one non-coupled CPE + for (ch = 0; ch < (id_aac == TYPE_CPE) + 1; ch++) { + int alpha = sbr->data[ch].bs_amp_res ? 2 : 1; + for (e = 1; e <= sbr->data[ch].bs_num_env; e++) + for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++){ + aac_float_t temp1; + + temp1.expo = alpha * sbr->data[ch].env_facs[e][k].mant + 12; + if (temp1.expo & 1) + temp1.mant = 759250125; + else + temp1.mant = 0x20000000; + temp1.expo = (temp1.expo >> 1) + 1; + + sbr->data[ch].env_facs[e][k] = temp1; + } + for (e = 1; e <= sbr->data[ch].bs_num_noise; e++) + for (k = 0; k < sbr->n_q; k++){ + sbr->data[ch].noise_facs[e][k].expo = NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs[e][k].mant + 1; + sbr->data[ch].noise_facs[e][k].mant = 0x20000000; + } + } + } +} + +/** High Frequency Generation (14496-3 sp04 p214+) and Inverse Filtering + * (14496-3 sp04 p214) + * Warning: This routine does not seem numerically stable. + */ +static void sbr_hf_inverse_filter(SBRDSPContext *dsp, + int (*alpha0)[2], int (*alpha1)[2], + const int X_low[32][40][2], int k0) +{ + int k; + int shift, round; + int64_t accu; + + for (k = 0; k < k0; k++) { + aac_float_t phi[3][2][2]; + aac_float_t a00, a01, a10, a11; + aac_float_t dk; + + dsp->autocorrelate(X_low[k], phi); + + dk = float_sub(float_mul(phi[2][1][0], phi[1][0][0]), + float_mul(float_add(float_mul(phi[1][1][0], phi[1][1][0]), float_mul(phi[1][1][1], phi[1][1][1])), FLOAT_0999999)); + + if (!dk.mant) { + a10 = FLOAT_0; + a11 = FLOAT_0; + } else { + aac_float_t temp_real, temp_im; + temp_real = float_sub(float_sub(float_mul(phi[0][0][0], phi[1][1][0]), + float_mul(phi[0][0][1], phi[1][1][1])), + float_mul(phi[0][1][0], phi[1][0][0])); + temp_im = float_sub(float_add(float_mul(phi[0][0][0], phi[1][1][1]), + float_mul(phi[0][0][1], phi[1][1][0])), + float_mul(phi[0][1][1], phi[1][0][0])); + + a10 = float_div(temp_real, dk); + a11 = float_div(temp_im, dk); + } + + if (!phi[1][0][0].mant) { + a00 = FLOAT_0; + a01 = FLOAT_0; + } else { + aac_float_t temp_real, temp_im; + temp_real = float_add(phi[0][0][0], float_add(float_mul(a10, phi[1][1][0]), + float_mul(a11, phi[1][1][1]))); + temp_im = float_add(phi[0][0][1], float_sub(float_mul(a11, phi[1][1][0]), + float_mul(a10, phi[1][1][1]))); + + temp_real.mant = -temp_real.mant; + temp_im.mant = -temp_im.mant; + a00 = float_div(temp_real, phi[1][0][0]); + a01 = float_div(temp_im, phi[1][0][0]); + } + + shift = a00.expo; + if (shift >= 3) + alpha0[k][0] = 0x7fffffff; + else { + a00.mant <<= 1; + shift = 2-shift; + if (shift == 0) + alpha0[k][0] = a00.mant; + else { + round = 1 << (shift-1); + alpha0[k][0] = (a00.mant + round) >> shift; + } + } + + shift = a01.expo; + if (shift >= 3) + alpha0[k][1] = 0x7fffffff; + else { + a01.mant <<= 1; + shift = 2-shift; + if (shift == 0) + alpha0[k][1] = a01.mant; + else { + round = 1 << (shift-1); + alpha0[k][1] = (a01.mant + round) >> shift; + } + } + shift = a10.expo; + if (shift >= 3) + alpha1[k][0] = 0x7fffffff; + else { + a10.mant <<= 1; + shift = 2-shift; + if (shift == 0) + alpha1[k][0] = a10.mant; + else { + round = 1 << (shift-1); + alpha1[k][0] = (a10.mant + round) >> shift; + } + } + + shift = a11.expo; + if (shift >= 3) + alpha1[k][1] = 0x7fffffff; + else { + a11.mant <<= 1; + shift = 2-shift; + if (shift == 0) + alpha1[k][1] = a11.mant; + else { + round = 1 << (shift-1); + alpha1[k][1] = (a11.mant + round) >> shift; + } + } + + accu = (int64_t)(alpha1[k][0]>>1) * (alpha1[k][0]>>1); + accu += (int64_t)(alpha1[k][1]>>1) * (alpha1[k][1]>>1); + shift = (int)((accu + 0x40000000) >> 31); + if (shift >= (16<<25)){ + alpha1[k][0] = 0; + alpha1[k][1] = 0; + alpha0[k][0] = 0; + alpha0[k][1] = 0; + } + + accu = (int64_t)(alpha0[k][0]>>1) * (alpha0[k][0]>>1); + accu += (int64_t)(alpha0[k][1]>>1) * (alpha0[k][1]>>1); + shift = (int)((accu + 0x40000000) >> 31); + if (shift >= (16<<25)){ + alpha1[k][0] = 0; + alpha1[k][1] = 0; + alpha0[k][0] = 0; + alpha0[k][1] = 0; + } + } +} + +/// Chirp Factors (14496-3 sp04 p214) +static void sbr_chirp(SpectralBandReplication *sbr, SBRData *ch_data) +{ + int i; + int new_bw; + static const int bw_tab[] = { 0, 1610612736, 1932735283, 2104533975 }; + int64_t accu; + + for (i = 0; i < sbr->n_q; i++) { + if (ch_data->bs_invf_mode[0][i] + ch_data->bs_invf_mode[1][i] == 1) + new_bw = 1288490189; + else + new_bw = bw_tab[ch_data->bs_invf_mode[0][i]]; + + if (new_bw < ch_data->bw_array[i]){ + accu = (int64_t)new_bw * 1610612736; + accu += (int64_t)ch_data->bw_array[i] * 0x20000000; + new_bw = (int)((accu + 0x40000000) >> 31); + } else { + accu = (int64_t)new_bw * 1946157056; + accu += (int64_t)ch_data->bw_array[i] * 201326592; + new_bw = (int)((accu + 0x40000000) >> 31); + } + ch_data->bw_array[i] = new_bw < 33554432 ? 0 : new_bw; + } +} + +/** + * Calculation of levels of additional HF signal components (14496-3 sp04 p219) + * and Calculation of gain (14496-3 sp04 p219) + */ +static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr, + SBRData *ch_data, const int e_a[2]) +{ + int e, k, m; + // max gain limits : -3dB, 0dB, 3dB, inf dB (limiter off) + static const aac_float_t limgain[4] = { { 760155524, 0 }, { 0x20000000, 1 }, { 758351638, 1 }, { 625000000, 34 } }; + + for (e = 0; e < ch_data->bs_num_env; e++) { + int delta = !((e == e_a[1]) || (e == e_a[0])); + for (k = 0; k < sbr->n_lim; k++) { + aac_float_t gain_boost, gain_max; + aac_float_t sum[2] = { { 0, 0}, { 0, 0 } }; + for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { + const aac_float_t temp = float_div(sbr->e_origmapped[e][m], float_add(FLOAT_1, sbr->q_mapped[e][m])); + sbr->q_m[e][m] = float_sqrt(float_mul(temp, sbr->q_mapped[e][m])); + sbr->s_m[e][m] = float_sqrt(float_mul(temp, int2float(ch_data->s_indexmapped[e + 1][m], 30))); + if (!sbr->s_mapped[e][m]) { + if (delta) { + sbr->gain[e][m] = float_sqrt(float_div(sbr->e_origmapped[e][m], + float_mul(float_add(FLOAT_1, sbr->e_curr[e][m]), + float_add(FLOAT_1, sbr->q_mapped[e][m])))); + } else { + sbr->gain[e][m] = float_sqrt(float_div(sbr->e_origmapped[e][m], + float_add(FLOAT_1, sbr->e_curr[e][m]))); + } + } else { + sbr->gain[e][m] = float_sqrt(float_div(float_mul(sbr->e_origmapped[e][m], sbr->q_mapped[e][m]), + float_mul(float_add(FLOAT_1, sbr->e_curr[e][m]), + float_add(FLOAT_1, sbr->q_mapped[e][m])))); + } + } + for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { + sum[0] = float_add(sum[0], sbr->e_origmapped[e][m]); + sum[1] = float_add(sum[1], sbr->e_curr[e][m]); + } + gain_max = float_mul(limgain[sbr->bs_limiter_gains], float_sqrt(float_div(float_add(FLOAT_EPSILON, sum[0]), float_add(FLOAT_EPSILON, sum[1])))); + if (float_gt(gain_max, FLOAT_100000)) + gain_max = FLOAT_100000; + for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { + aac_float_t q_m_max = float_div(float_mul(sbr->q_m[e][m], gain_max), sbr->gain[e][m]); + if (float_gt(sbr->q_m[e][m], q_m_max)) + sbr->q_m[e][m] = q_m_max; + if (float_gt(sbr->gain[e][m], gain_max)) + sbr->gain[e][m] = gain_max; + } + sum[0] = sum[1] = FLOAT_0; + for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { + sum[0] = float_add(sum[0], sbr->e_origmapped[e][m]); + sum[1] = float_add(sum[1], float_mul(float_mul(sbr->e_curr[e][m], sbr->gain[e][m]), sbr->gain[e][m])); + sum[1] = float_add(sum[1], float_mul(sbr->s_m[e][m], sbr->s_m[e][m])); + if (delta && !sbr->s_m[e][m].mant) + sum[1] = float_add(sum[1], float_mul(sbr->q_m[e][m], sbr->q_m[e][m])); + } + gain_boost = float_sqrt(float_div(float_add(FLOAT_EPSILON, sum[0]), float_add(FLOAT_EPSILON, sum[1]))); + if (float_gt(gain_boost, FLOAT_1584893192)) + gain_boost = FLOAT_1584893192; + + for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { + sbr->gain[e][m] = float_mul(sbr->gain[e][m], gain_boost); + sbr->q_m[e][m] = float_mul(sbr->q_m[e][m], gain_boost); + sbr->s_m[e][m] = float_mul(sbr->s_m[e][m], gain_boost); + } + } + } +} + +/// Assembling HF Signals (14496-3 sp04 p220) +static void sbr_hf_assemble(int Y1[38][64][2], + const int X_high[64][40][2], + SpectralBandReplication *sbr, SBRData *ch_data, + const int e_a[2]) +{ + int e, i, j, m; + const int h_SL = 4 * !sbr->bs_smoothing_mode; + const int kx = sbr->kx[1]; + const int m_max = sbr->m[1]; + static const aac_float_t h_smooth[5] = { + { 715827883, -1 }, + { 647472402, -1 }, + { 937030863, -2 }, + { 989249804, -3 }, + { 546843842, -4 }, + }; + aac_float_t (*g_temp)[48] = ch_data->g_temp, (*q_temp)[48] = ch_data->q_temp; + int indexnoise = ch_data->f_indexnoise; + int indexsine = ch_data->f_indexsine; + + if (sbr->reset) { + for (i = 0; i < h_SL; i++) { + memcpy(g_temp[i + 2*ch_data->t_env[0]], sbr->gain[0], m_max * sizeof(sbr->gain[0][0])); + memcpy(q_temp[i + 2*ch_data->t_env[0]], sbr->q_m[0], m_max * sizeof(sbr->q_m[0][0])); + } + } else if (h_SL) { + memcpy(g_temp[2*ch_data->t_env[0]], g_temp[2*ch_data->t_env_num_env_old], 4*sizeof(g_temp[0])); + memcpy(q_temp[2*ch_data->t_env[0]], q_temp[2*ch_data->t_env_num_env_old], 4*sizeof(q_temp[0])); + } + + for (e = 0; e < ch_data->bs_num_env; e++) { + for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) { + memcpy(g_temp[h_SL + i], sbr->gain[e], m_max * sizeof(sbr->gain[0][0])); + memcpy(q_temp[h_SL + i], sbr->q_m[e], m_max * sizeof(sbr->q_m[0][0])); + } + } + + for (e = 0; e < ch_data->bs_num_env; e++) { + for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) { + aac_float_t g_filt_tab[48]; + aac_float_t q_filt_tab[48]; + aac_float_t *g_filt, *q_filt; + + if (h_SL && e != e_a[0] && e != e_a[1]) { + g_filt = g_filt_tab; + q_filt = q_filt_tab; + for (m = 0; m < m_max; m++) { + const int idx1 = i + h_SL; + g_filt[m].mant = g_filt[m].expo = 0; + q_filt[m].mant = q_filt[m].expo = 0; + for (j = 0; j <= h_SL; j++) { + g_filt[m] = float_add(g_filt[m], float_mul(g_temp[idx1 - j][m], h_smooth[j])); + q_filt[m] = float_add(q_filt[m], float_mul(q_temp[idx1 - j][m], h_smooth[j])); + } + } + } else { + g_filt = g_temp[i + h_SL]; + q_filt = q_temp[i]; + } + + sbr->dsp.hf_g_filt(Y1[i] + kx, X_high + kx, g_filt, m_max, + i + ENVELOPE_ADJUSTMENT_OFFSET); + + if (e != e_a[0] && e != e_a[1]) { + sbr->dsp.hf_apply_noise[indexsine](Y1[i] + kx, sbr->s_m[e], + q_filt, indexnoise, + kx, m_max); + } else { + int idx = indexsine&1; + int A = (1-((indexsine+(kx & 1))&2)); + int B = (A^(-idx)) + idx; + int *out = &Y1[i][kx][idx]; + int shift, round; + + aac_float_t *in = sbr->s_m[e]; + for (m = 0; m+1 < m_max; m+=2) { + shift = 22 - in[m ].expo; + round = 1 << (shift-1); + out[2*m ] += (in[m ].mant * A + round) >> shift; + + shift = 22 - in[m+1].expo; + round = 1 << (shift-1); + out[2*m+2] += (in[m+1].mant * B + round) >> shift; + } + if(m_max&1) + { + shift = 22 - in[m ].expo; + round = 1 << (shift-1); + + out[2*m ] += (in[m ].mant * A + round) >> shift; + } + } + indexnoise = (indexnoise + m_max) & 0x1ff; + indexsine = (indexsine + 1) & 3; + } + } + ch_data->f_indexnoise = indexnoise; + ch_data->f_indexsine = indexsine; +} + +#include "aacsbr_template.c" diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c index 7bfb215..fa06314 100644 --- a/libavcodec/aacsbr_template.c +++ b/libavcodec/aacsbr_template.c @@ -32,7 +32,7 @@ * @author Zoran Basaric ( zoran.basaric at imgtec.com ) */ -av_cold void ff_aac_sbr_init(void) +av_cold void AAC_RENAME(ff_aac_sbr_init)(void) { int n; static const struct { @@ -71,7 +71,7 @@ av_cold void ff_aac_sbr_init(void) for (n = 0; n < 320; n++) sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n]; - ff_ps_init(); + AAC_RENAME(ff_ps_init)(); } /** Places SBR in pure upsampling mode. */ @@ -85,7 +85,7 @@ static void sbr_turnoff(SpectralBandReplication *sbr) { memset(&sbr->spectrum_params, -1, sizeof(SpectrumParameters)); } -av_cold void ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr) +av_cold void AAC_RENAME(ff_aac_sbr_ctx_init)(AACContext *ac, SpectralBandReplication *sbr) { if(sbr->mdct.mdct_bits) return; @@ -96,17 +96,17 @@ av_cold void ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr) /* SBR requires samples to be scaled to +/-32768.0 to work correctly. * mdct scale factors are adjusted to scale up from +/-1.0 at analysis * and scale back down at synthesis. */ - ff_mdct_init(&sbr->mdct, 7, 1, 1.0 / (64 * 32768.0)); - ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0 * 32768.0); - ff_ps_ctx_init(&sbr->ps); - ff_sbrdsp_init(&sbr->dsp); + AAC_RENAME_32(ff_mdct_init)(&sbr->mdct, 7, 1, 1.0 / (64 * 32768.0)); + AAC_RENAME_32(ff_mdct_init)(&sbr->mdct_ana, 7, 1, -2.0 * 32768.0); + AAC_RENAME(ff_ps_ctx_init)(&sbr->ps); + AAC_RENAME(ff_sbrdsp_init)(&sbr->dsp); aacsbr_func_ptr_init(&sbr->c); } -av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr) +av_cold void AAC_RENAME(ff_aac_sbr_ctx_close)(SpectralBandReplication *sbr) { - ff_mdct_end(&sbr->mdct); - ff_mdct_end(&sbr->mdct_ana); + AAC_RENAME_32(ff_mdct_end)(&sbr->mdct); + AAC_RENAME_32(ff_mdct_end)(&sbr->mdct_ana); } static int qsort_comparison_function_int16(const void *a, const void *b) @@ -128,10 +128,10 @@ static void sbr_make_f_tablelim(SpectralBandReplication *sbr) { int k; if (sbr->bs_limiter_bands > 0) { - static const float bands_warped[3] = { 1.32715174233856803909f, //2^(0.49/1.2) - 1.18509277094158210129f, //2^(0.49/2) - 1.11987160404675912501f }; //2^(0.49/3) - const float lim_bands_per_octave_warped = bands_warped[sbr->bs_limiter_bands - 1]; + static const INTFLOAT bands_warped[3] = { Q23(1.32715174233856803909f), //2^(0.49/1.2) + Q23(1.18509277094158210129f), //2^(0.49/2) + Q23(1.11987160404675912501f) }; //2^(0.49/3) + const INTFLOAT lim_bands_per_octave_warped = bands_warped[sbr->bs_limiter_bands - 1]; int16_t patch_borders[7]; uint16_t *in = sbr->f_tablelim + 1, *out = sbr->f_tablelim; @@ -151,7 +151,11 @@ static void sbr_make_f_tablelim(SpectralBandReplication *sbr) sbr->n_lim = sbr->n[0] + sbr->num_patches - 1; while (out < sbr->f_tablelim + sbr->n_lim) { +#if USE_FIXED + if ((*in << 23) >= *out * lim_bands_per_octave_warped) { +#else if (*in >= *out * lim_bands_per_octave_warped) { +#endif /* USE_FIXED */ *++out = *in++; } else if (*in == *out || !in_table_int16(patch_borders, sbr->num_patches, *in)) { @@ -357,6 +361,9 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, int two_regions, num_bands_0; int vdk0_max, vdk1_min; int16_t vk0[49]; +#if USE_FIXED + int tmp, nz = 0; +#endif /* USE_FIXED */ if (49 * sbr->k[2] > 110 * sbr->k[0]) { two_regions = 1; @@ -366,7 +373,19 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, sbr->k[1] = sbr->k[2]; } +#if USE_FIXED + tmp = (sbr->k[1] << 23) / sbr->k[0]; + while (tmp < 0x40000000) { + tmp <<= 1; + nz++; + } + tmp = fixed_log(tmp - 0x80000000); + tmp = (int)(((int64_t)tmp * CONST_RECIP_LN2 + 0x20000000) >> 30); + tmp = (((tmp + 128) >> 8) + ((8 - nz) << 23)) * half_bands; + num_bands_0 = ((tmp + 0x400000) >> 23) * 2; +#else num_bands_0 = lrintf(half_bands * log2f(sbr->k[1] / (float)sbr->k[0])) * 2; +#endif /* USE_FIXED */ if (num_bands_0 <= 0) { // Requirements (14496-3 sp04 p205) av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0); @@ -391,11 +410,27 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, if (two_regions) { int16_t vk1[49]; +#if USE_FIXED + int num_bands_1; + + tmp = (sbr->k[2] << 23) / sbr->k[1]; + nz = 0; + while (tmp < 0x40000000) { + tmp <<= 1; + nz++; + } + tmp = fixed_log(tmp - 0x80000000); + tmp = (int)(((int64_t)tmp * CONST_RECIP_LN2 + 0x20000000) >> 30); + tmp = (((tmp + 128) >> 8) + ((8 - nz) << 23)) * half_bands; + if (spectrum->bs_alter_scale) + tmp = (int)(((int64_t)tmp * CONST_076923 + 0x40000000) >> 31); + num_bands_1 = ((tmp + 0x400000) >> 23) * 2; +#else float invwarp = spectrum->bs_alter_scale ? 0.76923076923076923077f : 1.0f; // bs_alter_scale = {0,1} int num_bands_1 = lrintf(half_bands * invwarp * log2f(sbr->k[2] / (float)sbr->k[1])) * 2; - +#endif /* USE_FIXED */ make_bands(vk1+1, sbr->k[1], sbr->k[2], num_bands_1); vdk1_min = array_min_int16(vk1 + 1, num_bands_1); @@ -493,6 +528,9 @@ static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr) static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr) { int k, temp; +#if USE_FIXED + int nz = 0; +#endif /* USE_FIXED */ sbr->n[1] = sbr->n_master - sbr->spectrum_params.bs_xover_band; sbr->n[0] = (sbr->n[1] + 1) >> 1; @@ -517,9 +555,24 @@ static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr) temp = sbr->n[1] & 1; for (k = 1; k <= sbr->n[0]; k++) sbr->f_tablelow[k] = sbr->f_tablehigh[2 * k - temp]; +#if USE_FIXED + temp = (sbr->k[2] << 23) / sbr->kx[1]; + while (temp < 0x40000000) { + temp <<= 1; + nz++; + } + temp = fixed_log(temp - 0x80000000); + temp = (int)(((int64_t)temp * CONST_RECIP_LN2 + 0x20000000) >> 30); + temp = (((temp + 128) >> 8) + ((8 - nz) << 23)) * sbr->spectrum_params.bs_noise_bands; + sbr->n_q = (temp + 0x400000) >> 23; + if (sbr->n_q < 1) + sbr->n_q = 1; +#else sbr->n_q = FFMAX(1, lrintf(sbr->spectrum_params.bs_noise_bands * log2f(sbr->k[2] / (float)sbr->kx[1]))); // 0 <= bs_noise_bands <= 3 +#endif /* USE_FIXED */ + if (sbr->n_q > 5) { av_log(ac->avctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q); return -1; @@ -775,6 +828,31 @@ static void read_sbr_envelope(SpectralBandReplication *sbr, GetBitContext *gb, } } +#if USE_FIXED + for (i = 0; i < ch_data->bs_num_env; i++) { + if (ch_data->bs_df_env[i]) { + // bs_freq_res[0] == bs_freq_res[bs_num_env] from prev frame + if (ch_data->bs_freq_res[i + 1] == ch_data->bs_freq_res[i]) { + for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) + ch_data->env_facs[i + 1][j].mant = ch_data->env_facs[i][j].mant + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); + } else if (ch_data->bs_freq_res[i + 1]) { + for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { + k = (j + odd) >> 1; // find k such that f_tablelow[k] <= f_tablehigh[j] < f_tablelow[k + 1] + ch_data->env_facs[i + 1][j].mant = ch_data->env_facs[i][k].mant + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); + } + } else { + for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { + k = j ? 2*j - odd : 0; // find k such that f_tablehigh[k] == f_tablelow[j] + ch_data->env_facs[i + 1][j].mant = ch_data->env_facs[i][k].mant + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); + } + } + } else { + ch_data->env_facs[i + 1][0].mant = delta * get_bits(gb, bits); // bs_env_start_value_balance + for (j = 1; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) + ch_data->env_facs[i + 1][j].mant = ch_data->env_facs[i + 1][j - 1].mant + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); + } + } +#else for (i = 0; i < ch_data->bs_num_env; i++) { if (ch_data->bs_df_env[i]) { // bs_freq_res[0] == bs_freq_res[bs_num_env] from prev frame @@ -798,6 +876,7 @@ static void read_sbr_envelope(SpectralBandReplication *sbr, GetBitContext *gb, ch_data->env_facs[i + 1][j] = ch_data->env_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); } } +#endif /* USE_FIXED */ //assign 0th elements of env_facs from last elements memcpy(ch_data->env_facs[0], ch_data->env_facs[ch_data->bs_num_env], @@ -824,6 +903,18 @@ static void read_sbr_noise(SpectralBandReplication *sbr, GetBitContext *gb, f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB]; } +#if USE_FIXED + for (i = 0; i < ch_data->bs_num_noise; i++) { + if (ch_data->bs_df_noise[i]) { + for (j = 0; j < sbr->n_q; j++) + ch_data->noise_facs[i + 1][j].mant = ch_data->noise_facs[i][j].mant + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav); + } else { + ch_data->noise_facs[i + 1][0].mant = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level + for (j = 1; j < sbr->n_q; j++) + ch_data->noise_facs[i + 1][j].mant = ch_data->noise_facs[i + 1][j - 1].mant + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); + } + } +#else for (i = 0; i < ch_data->bs_num_noise; i++) { if (ch_data->bs_df_noise[i]) { for (j = 0; j < sbr->n_q; j++) @@ -834,6 +925,7 @@ static void read_sbr_noise(SpectralBandReplication *sbr, GetBitContext *gb, ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); } } +#endif /* USE_FIXED */ //assign 0th elements of noise_facs from last elements memcpy(ch_data->noise_facs[0], ch_data->noise_facs[ch_data->bs_num_noise], @@ -852,7 +944,7 @@ static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, *num_bits_left = 0; } else { #if 1 - *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps, *num_bits_left); + *num_bits_left -= AAC_RENAME(ff_ps_read_data)(ac->avctx, gb, &sbr->ps, *num_bits_left); ac->avctx->profile = FF_PROFILE_AAC_HE_V2; #else avpriv_report_missing_feature(ac->avctx, "Parametric Stereo"); @@ -995,7 +1087,7 @@ static void sbr_reset(AACContext *ac, SpectralBandReplication *sbr) * * @return Returns number of bytes consumed from the TYPE_FIL element. */ -int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, +int AAC_RENAME(ff_decode_sbr_extension)(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb_host, int crc, int cnt, int id_aac) { unsigned int num_sbr_bits = 0, num_align_bits; @@ -1047,9 +1139,13 @@ int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, * @param W array of complex-valued samples split into subbands */ #ifndef sbr_qmf_analysis +#if USE_FIXED +static void sbr_qmf_analysis(AVFixedDSPContext *dsp, FFTContext *mdct, +#else static void sbr_qmf_analysis(AVFloatDSPContext *dsp, FFTContext *mdct, - SBRDSPContext *sbrdsp, const float *in, float *x, - float z[320], float W[2][32][32][2], int buf_idx) +#endif /* USE_FIXED */ + SBRDSPContext *sbrdsp, const INTFLOAT *in, INTFLOAT *x, + INTFLOAT z[320], INTFLOAT W[2][32][32][2], int buf_idx) { int i; memcpy(x , x+1024, (320-32)*sizeof(x[0])); @@ -1072,19 +1168,24 @@ static void sbr_qmf_analysis(AVFloatDSPContext *dsp, FFTContext *mdct, */ #ifndef sbr_qmf_synthesis static void sbr_qmf_synthesis(FFTContext *mdct, +#if USE_FIXED + SBRDSPContext *sbrdsp, AVFixedDSPContext *dsp, +#else SBRDSPContext *sbrdsp, AVFloatDSPContext *dsp, - float *out, float X[2][38][64], - float mdct_buf[2][64], - float *v0, int *v_off, const unsigned int div) +#endif /* USE_FIXED */ + INTFLOAT *out, INTFLOAT X[2][38][64], + INTFLOAT mdct_buf[2][64], + INTFLOAT *v0, int *v_off, const unsigned int div) { int i, n; - const float *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us; + const INTFLOAT *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us; const int step = 128 >> div; - float *v; + INTFLOAT *v; + for (i = 0; i < 32; i++) { if (*v_off < step) { int saved_samples = (1280 - 128) >> div; - memcpy(&v0[SBR_SYNTHESIS_BUF_SIZE - saved_samples], v0, saved_samples * sizeof(float)); + memcpy(&v0[SBR_SYNTHESIS_BUF_SIZE - saved_samples], v0, saved_samples * sizeof(INTFLOAT)); *v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - step; } else { *v_off -= step; @@ -1120,7 +1221,7 @@ static void sbr_qmf_synthesis(FFTContext *mdct, /// Generate the subband filtered lowband static int sbr_lf_gen(AACContext *ac, SpectralBandReplication *sbr, - float X_low[32][40][2], const float W[2][32][32][2], + INTFLOAT X_low[32][40][2], const INTFLOAT W[2][32][32][2], int buf_idx) { int i, k; @@ -1145,9 +1246,9 @@ static int sbr_lf_gen(AACContext *ac, SpectralBandReplication *sbr, /// High Frequency Generator (14496-3 sp04 p215) static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, - float X_high[64][40][2], const float X_low[32][40][2], - const float (*alpha0)[2], const float (*alpha1)[2], - const float bw_array[5], const uint8_t *t_env, + INTFLOAT X_high[64][40][2], const INTFLOAT X_low[32][40][2], + const INTFLOAT (*alpha0)[2], const INTFLOAT (*alpha1)[2], + const INTFLOAT bw_array[5], const uint8_t *t_env, int bs_num_env) { int j, x; @@ -1179,9 +1280,9 @@ static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, } /// Generate the subband filtered lowband -static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][38][64], - const float Y0[38][64][2], const float Y1[38][64][2], - const float X_low[32][40][2], int ch) +static int sbr_x_gen(SpectralBandReplication *sbr, INTFLOAT X[2][38][64], + const INTFLOAT Y0[38][64][2], const INTFLOAT Y1[38][64][2], + const INTFLOAT X_low[32][40][2], int ch) { int k, i; const int i_f = 32; @@ -1273,7 +1374,7 @@ static int sbr_mapping(AACContext *ac, SpectralBandReplication *sbr, } /// Estimation of current envelope (14496-3 sp04 p218) -static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2], +static void sbr_env_estimate(AAC_FLOAT (*e_curr)[48], INTFLOAT X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data) { int e, m; @@ -1281,13 +1382,21 @@ static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2], if (sbr->bs_interpol_freq) { for (e = 0; e < ch_data->bs_num_env; e++) { +#if USE_FIXED + const aac_float_t recip_env_size = int2float(0x20000000 / (ch_data->t_env[e + 1] - ch_data->t_env[e]), 0); +#else const float recip_env_size = 0.5f / (ch_data->t_env[e + 1] - ch_data->t_env[e]); +#endif /* USE_FIXED */ int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; for (m = 0; m < sbr->m[1]; m++) { - float sum = sbr->dsp.sum_square(X_high[m+kx1] + ilb, iub - ilb); + AAC_FLOAT sum = sbr->dsp.sum_square(X_high[m+kx1] + ilb, iub - ilb); +#if USE_FIXED + e_curr[e][m] = float_mul(sum, recip_env_size); +#else e_curr[e][m] = sum * recip_env_size; +#endif /* USE_FIXED */ } } } else { @@ -1300,6 +1409,14 @@ static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2], const uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow; for (p = 0; p < sbr->n[ch_data->bs_freq_res[e + 1]]; p++) { +#if USE_FIXED + aac_float_t sum = { 0, 0 }; + const aac_float_t den = int2float(0x20000000 / (env_size * (table[p + 1] - table[p])), 1); + for (k = table[p]; k < table[p + 1]; k++) { + sum = float_add(sum, sbr->dsp.sum_square(X_high[k] + ilb, iub - ilb)); + } + sum = float_mul(sum, den); +#else float sum = 0.0f; const int den = env_size * (table[p + 1] - table[p]); @@ -1307,6 +1424,7 @@ static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2], sum += sbr->dsp.sum_square(X_high[k] + ilb, iub - ilb); } sum /= den; +#endif /* USE_FIXED */ for (k = table[p]; k < table[p + 1]; k++) { e_curr[e][k - kx1] = sum; } @@ -1315,8 +1433,8 @@ static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2], } } -void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, - float* L, float* R) +void AAC_RENAME(ff_sbr_apply)(AACContext *ac, SpectralBandReplication *sbr, int id_aac, + INTFLOAT* L, INTFLOAT* R) { int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate; int ch; @@ -1335,21 +1453,25 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, } for (ch = 0; ch < nch; ch++) { /* decode channel */ +#if USE_FIXED + sbr_qmf_analysis(ac->fdsp, &sbr->mdct_ana, &sbr->dsp, ch ? R : L, sbr->data[ch].analysis_filterbank_samples, +#else sbr_qmf_analysis(&ac->fdsp, &sbr->mdct_ana, &sbr->dsp, ch ? R : L, sbr->data[ch].analysis_filterbank_samples, - (float*)sbr->qmf_filter_scratch, +#endif /* USE_FIXED */ + (INTFLOAT*)sbr->qmf_filter_scratch, sbr->data[ch].W, sbr->data[ch].Ypos); sbr->c.sbr_lf_gen(ac, sbr, sbr->X_low, - (const float (*)[32][32][2]) sbr->data[ch].W, + (const INTFLOAT (*)[32][32][2]) sbr->data[ch].W, sbr->data[ch].Ypos); sbr->data[ch].Ypos ^= 1; if (sbr->start) { sbr->c.sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1, - (const float (*)[40][2]) sbr->X_low, sbr->k[0]); + (const INTFLOAT (*)[40][2]) sbr->X_low, sbr->k[0]); sbr_chirp(sbr, &sbr->data[ch]); sbr_hf_gen(ac, sbr, sbr->X_high, - (const float (*)[40][2]) sbr->X_low, - (const float (*)[2]) sbr->alpha0, - (const float (*)[2]) sbr->alpha1, + (const INTFLOAT (*)[40][2]) sbr->X_low, + (const INTFLOAT (*)[2]) sbr->alpha0, + (const INTFLOAT (*)[2]) sbr->alpha1, sbr->data[ch].bw_array, sbr->data[ch].t_env, sbr->data[ch].bs_num_env); @@ -1359,7 +1481,7 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, sbr_env_estimate(sbr->e_curr, sbr->X_high, sbr, &sbr->data[ch]); sbr_gain_calc(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a); sbr->c.sbr_hf_assemble(sbr->data[ch].Y[sbr->data[ch].Ypos], - (const float (*)[40][2]) sbr->X_high, + (const INTFLOAT (*)[40][2]) sbr->X_high, sbr, &sbr->data[ch], sbr->data[ch].e_a); } @@ -1367,27 +1489,35 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, /* synthesis */ sbr->c.sbr_x_gen(sbr, sbr->X[ch], - (const float (*)[64][2]) sbr->data[ch].Y[1-sbr->data[ch].Ypos], - (const float (*)[64][2]) sbr->data[ch].Y[ sbr->data[ch].Ypos], - (const float (*)[40][2]) sbr->X_low, ch); + (const INTFLOAT (*)[64][2]) sbr->data[ch].Y[1-sbr->data[ch].Ypos], + (const INTFLOAT (*)[64][2]) sbr->data[ch].Y[ sbr->data[ch].Ypos], + (const INTFLOAT (*)[40][2]) sbr->X_low, ch); } if (ac->oc[1].m4ac.ps == 1) { if (sbr->ps.start) { - ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); + AAC_RENAME(ff_ps_apply)(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); } else { memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0])); } nch = 2; } +#if USE_FIXED + sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, ac->fdsp, +#else sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, &ac->fdsp, +#endif /* USE_FIXED */ L, sbr->X[0], sbr->qmf_filter_scratch, sbr->data[0].synthesis_filterbank_samples, &sbr->data[0].synthesis_filterbank_samples_offset, downsampled); if (nch == 2) +#if USE_FIXED + sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, ac->fdsp, +#else sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, &ac->fdsp, +#endif /* USE_FIXED */ R, sbr->X[1], sbr->qmf_filter_scratch, sbr->data[1].synthesis_filterbank_samples, &sbr->data[1].synthesis_filterbank_samples_offset, @@ -1401,6 +1531,8 @@ static void aacsbr_func_ptr_init(AACSBRContext *c) c->sbr_x_gen = sbr_x_gen; c->sbr_hf_inverse_filter = sbr_hf_inverse_filter; +#if !USE_FIXED if(ARCH_MIPS) ff_aacsbr_func_ptr_init_mips(c); +#endif } diff --git a/libavcodec/sbr.h b/libavcodec/sbr.h index e28fccd..f78a37d 100644 --- a/libavcodec/sbr.h +++ b/libavcodec/sbr.h @@ -66,9 +66,9 @@ typedef struct SBRData { */ unsigned bs_frame_class; unsigned bs_add_harmonic_flag; - unsigned bs_num_env; + AAC_SIGNE bs_num_env; uint8_t bs_freq_res[7]; - unsigned bs_num_noise; + AAC_SIGNE bs_num_noise; uint8_t bs_df_env[5]; uint8_t bs_df_noise[2]; uint8_t bs_invf_mode[2][5]; @@ -80,25 +80,25 @@ typedef struct SBRData { * @name State variables * @{ */ - DECLARE_ALIGNED(32, float, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE]; - DECLARE_ALIGNED(32, float, analysis_filterbank_samples) [1312]; + DECLARE_ALIGNED(32, INTFLOAT, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE]; + DECLARE_ALIGNED(32, INTFLOAT, analysis_filterbank_samples) [1312]; int synthesis_filterbank_samples_offset; ///l_APrev and l_A int e_a[2]; ///Chirp factors - float bw_array[5]; + INTFLOAT bw_array[5]; ///QMF values of the original signal - float W[2][32][32][2]; + INTFLOAT W[2][32][32][2]; ///QMF output of the HF adjustor int Ypos; - DECLARE_ALIGNED(16, float, Y)[2][38][64][2]; - DECLARE_ALIGNED(16, float, g_temp)[42][48]; - float q_temp[42][48]; + DECLARE_ALIGNED(16, INTFLOAT, Y)[2][38][64][2]; + DECLARE_ALIGNED(16, AAC_FLOAT, g_temp)[42][48]; + AAC_FLOAT q_temp[42][48]; uint8_t s_indexmapped[8][48]; ///Envelope scalefactors - float env_facs[6][48]; + AAC_FLOAT env_facs[6][48]; ///Noise scalefactors - float noise_facs[3][5]; + AAC_FLOAT noise_facs[3][5]; ///Envelope time borders uint8_t t_env[8]; ///Envelope time border of the last envelope of the previous frame @@ -117,18 +117,18 @@ typedef struct SpectralBandReplication SpectralBandReplication; */ typedef struct AACSBRContext { int (*sbr_lf_gen)(AACContext *ac, SpectralBandReplication *sbr, - float X_low[32][40][2], const float W[2][32][32][2], + INTFLOAT X_low[32][40][2], const INTFLOAT W[2][32][32][2], int buf_idx); - void (*sbr_hf_assemble)(float Y1[38][64][2], - const float X_high[64][40][2], + void (*sbr_hf_assemble)(INTFLOAT Y1[38][64][2], + const INTFLOAT X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data, const int e_a[2]); - int (*sbr_x_gen)(SpectralBandReplication *sbr, float X[2][38][64], - const float Y0[38][64][2], const float Y1[38][64][2], - const float X_low[32][40][2], int ch); + int (*sbr_x_gen)(SpectralBandReplication *sbr, INTFLOAT X[2][38][64], + const INTFLOAT Y0[38][64][2], const INTFLOAT Y1[38][64][2], + const INTFLOAT X_low[32][40][2], int ch); void (*sbr_hf_inverse_filter)(SBRDSPContext *dsp, - float (*alpha0)[2], float (*alpha1)[2], - const float X_low[32][40][2], int k0); + INTFLOAT (*alpha0)[2], INTFLOAT (*alpha1)[2], + const INTFLOAT X_low[32][40][2], int k0); } AACSBRContext; /** @@ -150,23 +150,23 @@ struct SpectralBandReplication { unsigned bs_smoothing_mode; /** @} */ unsigned bs_coupling; - unsigned k[5]; ///< k0, k1, k2 + AAC_SIGNE k[5]; ///< k0, k1, k2 ///kx', and kx respectively, kx is the first QMF subband where SBR is used. ///kx' is its value from the previous frame - unsigned kx[2]; + AAC_SIGNE kx[2]; ///M' and M respectively, M is the number of QMF subbands that use SBR. - unsigned m[2]; + AAC_SIGNE m[2]; unsigned kx_and_m_pushed; ///The number of frequency bands in f_master - unsigned n_master; + AAC_SIGNE n_master; SBRData data[2]; PSContext ps; ///N_Low and N_High respectively, the number of frequency bands for low and high resolution - unsigned n[2]; + AAC_SIGNE n[2]; ///Number of noise floor bands - unsigned n_q; + AAC_SIGNE n_q; ///Number of limiter bands - unsigned n_lim; + AAC_SIGNE n_lim; ///The master QMF frequency grouping uint16_t f_master[49]; ///Frequency borders for low resolution SBR @@ -177,33 +177,33 @@ struct SpectralBandReplication { uint16_t f_tablenoise[6]; ///Frequency borders for the limiter uint16_t f_tablelim[30]; - unsigned num_patches; + AAC_SIGNE num_patches; uint8_t patch_num_subbands[6]; uint8_t patch_start_subband[6]; ///QMF low frequency input to the HF generator - DECLARE_ALIGNED(16, float, X_low)[32][40][2]; + DECLARE_ALIGNED(16, INTFLOAT, X_low)[32][40][2]; ///QMF output of the HF generator - DECLARE_ALIGNED(16, float, X_high)[64][40][2]; + DECLARE_ALIGNED(16, INTFLOAT, X_high)[64][40][2]; ///QMF values of the reconstructed signal - DECLARE_ALIGNED(16, float, X)[2][2][38][64]; + DECLARE_ALIGNED(16, INTFLOAT, X)[2][2][38][64]; ///Zeroth coefficient used to filter the subband signals - DECLARE_ALIGNED(16, float, alpha0)[64][2]; + DECLARE_ALIGNED(16, INTFLOAT, alpha0)[64][2]; ///First coefficient used to filter the subband signals - DECLARE_ALIGNED(16, float, alpha1)[64][2]; + DECLARE_ALIGNED(16, INTFLOAT, alpha1)[64][2]; ///Dequantized envelope scalefactors, remapped - float e_origmapped[7][48]; + AAC_FLOAT e_origmapped[7][48]; ///Dequantized noise scalefactors, remapped - float q_mapped[7][48]; + AAC_FLOAT q_mapped[7][48]; ///Sinusoidal presence, remapped uint8_t s_mapped[7][48]; ///Estimated envelope - float e_curr[7][48]; + AAC_FLOAT e_curr[7][48]; ///Amplitude adjusted noise scalefactors - float q_m[7][48]; + AAC_FLOAT q_m[7][48]; ///Sinusoidal levels - float s_m[7][48]; - float gain[7][48]; - DECLARE_ALIGNED(32, float, qmf_filter_scratch)[5][64]; + AAC_FLOAT s_m[7][48]; + AAC_FLOAT gain[7][48]; + DECLARE_ALIGNED(32, INTFLOAT, qmf_filter_scratch)[5][64]; FFTContext mdct_ana; FFTContext mdct; SBRDSPContext dsp; diff --git a/libavcodec/sbrdsp.c b/libavcodec/sbrdsp.c deleted file mode 100644 index e4f053b..0000000 --- a/libavcodec/sbrdsp.c +++ /dev/null @@ -1,295 +0,0 @@ -/* - * AAC Spectral Band Replication decoding functions - * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) - * Copyright (c) 2009-2010 Alex Converse - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" -#include "libavutil/attributes.h" -#include "libavutil/intfloat.h" -#include "sbrdsp.h" - -static void sbr_sum64x5_c(float *z) -{ - int k; - for (k = 0; k < 64; k++) { - float f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256]; - z[k] = f; - } -} - -static float sbr_sum_square_c(float (*x)[2], int n) -{ - float sum0 = 0.0f, sum1 = 0.0f; - int i; - - for (i = 0; i < n; i += 2) - { - sum0 += x[i + 0][0] * x[i + 0][0]; - sum1 += x[i + 0][1] * x[i + 0][1]; - sum0 += x[i + 1][0] * x[i + 1][0]; - sum1 += x[i + 1][1] * x[i + 1][1]; - } - - return sum0 + sum1; -} - -static void sbr_neg_odd_64_c(float *x) -{ - union av_intfloat32 *xi = (union av_intfloat32*) x; - int i; - for (i = 1; i < 64; i += 4) { - xi[i + 0].i ^= 1U << 31; - xi[i + 2].i ^= 1U << 31; - } -} - -static void sbr_qmf_pre_shuffle_c(float *z) -{ - union av_intfloat32 *zi = (union av_intfloat32*) z; - int k; - zi[64].i = zi[0].i; - zi[65].i = zi[1].i; - for (k = 1; k < 31; k += 2) { - zi[64 + 2 * k + 0].i = zi[64 - k].i ^ (1U << 31); - zi[64 + 2 * k + 1].i = zi[ k + 1].i; - zi[64 + 2 * k + 2].i = zi[63 - k].i ^ (1U << 31); - zi[64 + 2 * k + 3].i = zi[ k + 2].i; - } - - zi[64 + 2 * 31 + 0].i = zi[64 - 31].i ^ (1U << 31); - zi[64 + 2 * 31 + 1].i = zi[31 + 1].i; -} - -static void sbr_qmf_post_shuffle_c(float W[32][2], const float *z) -{ - const union av_intfloat32 *zi = (const union av_intfloat32*) z; - union av_intfloat32 *Wi = (union av_intfloat32*) W; - int k; - for (k = 0; k < 32; k += 2) { - Wi[2 * k + 0].i = zi[63 - k].i ^ (1U << 31); - Wi[2 * k + 1].i = zi[ k + 0].i; - Wi[2 * k + 2].i = zi[62 - k].i ^ (1U << 31); - Wi[2 * k + 3].i = zi[ k + 1].i; - } -} - -static void sbr_qmf_deint_neg_c(float *v, const float *src) -{ - const union av_intfloat32 *si = (const union av_intfloat32*)src; - union av_intfloat32 *vi = (union av_intfloat32*)v; - int i; - for (i = 0; i < 32; i++) { - vi[ i].i = si[63 - 2 * i ].i; - vi[63 - i].i = si[63 - 2 * i - 1].i ^ (1U << 31); - } -} - -static void sbr_qmf_deint_bfly_c(float *v, const float *src0, const float *src1) -{ - int i; - for (i = 0; i < 64; i++) { - v[ i] = src0[i] - src1[63 - i]; - v[127 - i] = src0[i] + src1[63 - i]; - } -} - - -#if 0 - /* This code is slower because it multiplies memory accesses. - * It is left for educational purposes and because it may offer - * a better reference for writing arch-specific DSP functions. */ -static av_always_inline void autocorrelate(const float x[40][2], - float phi[3][2][2], int lag) -{ - int i; - float real_sum = 0.0f; - float imag_sum = 0.0f; - if (lag) { - for (i = 1; i < 38; i++) { - real_sum += x[i][0] * x[i+lag][0] + x[i][1] * x[i+lag][1]; - imag_sum += x[i][0] * x[i+lag][1] - x[i][1] * x[i+lag][0]; - } - phi[2-lag][1][0] = real_sum + x[ 0][0] * x[lag][0] + x[ 0][1] * x[lag][1]; - phi[2-lag][1][1] = imag_sum + x[ 0][0] * x[lag][1] - x[ 0][1] * x[lag][0]; - if (lag == 1) { - phi[0][0][0] = real_sum + x[38][0] * x[39][0] + x[38][1] * x[39][1]; - phi[0][0][1] = imag_sum + x[38][0] * x[39][1] - x[38][1] * x[39][0]; - } - } else { - for (i = 1; i < 38; i++) { - real_sum += x[i][0] * x[i][0] + x[i][1] * x[i][1]; - } - phi[2][1][0] = real_sum + x[ 0][0] * x[ 0][0] + x[ 0][1] * x[ 0][1]; - phi[1][0][0] = real_sum + x[38][0] * x[38][0] + x[38][1] * x[38][1]; - } -} - -static void sbr_autocorrelate_c(const float x[40][2], float phi[3][2][2]) -{ - autocorrelate(x, phi, 0); - autocorrelate(x, phi, 1); - autocorrelate(x, phi, 2); -} -#else -static void sbr_autocorrelate_c(const float x[40][2], float phi[3][2][2]) -{ - float real_sum2 = x[0][0] * x[2][0] + x[0][1] * x[2][1]; - float imag_sum2 = x[0][0] * x[2][1] - x[0][1] * x[2][0]; - float real_sum1 = 0.0f, imag_sum1 = 0.0f, real_sum0 = 0.0f; - int i; - for (i = 1; i < 38; i++) { - real_sum0 += x[i][0] * x[i ][0] + x[i][1] * x[i ][1]; - real_sum1 += x[i][0] * x[i + 1][0] + x[i][1] * x[i + 1][1]; - imag_sum1 += x[i][0] * x[i + 1][1] - x[i][1] * x[i + 1][0]; - real_sum2 += x[i][0] * x[i + 2][0] + x[i][1] * x[i + 2][1]; - imag_sum2 += x[i][0] * x[i + 2][1] - x[i][1] * x[i + 2][0]; - } - phi[2 - 2][1][0] = real_sum2; - phi[2 - 2][1][1] = imag_sum2; - phi[2 ][1][0] = real_sum0 + x[ 0][0] * x[ 0][0] + x[ 0][1] * x[ 0][1]; - phi[1 ][0][0] = real_sum0 + x[38][0] * x[38][0] + x[38][1] * x[38][1]; - phi[2 - 1][1][0] = real_sum1 + x[ 0][0] * x[ 1][0] + x[ 0][1] * x[ 1][1]; - phi[2 - 1][1][1] = imag_sum1 + x[ 0][0] * x[ 1][1] - x[ 0][1] * x[ 1][0]; - phi[0 ][0][0] = real_sum1 + x[38][0] * x[39][0] + x[38][1] * x[39][1]; - phi[0 ][0][1] = imag_sum1 + x[38][0] * x[39][1] - x[38][1] * x[39][0]; -#endif -} - -static void sbr_hf_gen_c(float (*X_high)[2], const float (*X_low)[2], - const float alpha0[2], const float alpha1[2], - float bw, int start, int end) -{ - float alpha[4]; - int i; - - alpha[0] = alpha1[0] * bw * bw; - alpha[1] = alpha1[1] * bw * bw; - alpha[2] = alpha0[0] * bw; - alpha[3] = alpha0[1] * bw; - - for (i = start; i < end; i++) { - X_high[i][0] = - X_low[i - 2][0] * alpha[0] - - X_low[i - 2][1] * alpha[1] + - X_low[i - 1][0] * alpha[2] - - X_low[i - 1][1] * alpha[3] + - X_low[i][0]; - X_high[i][1] = - X_low[i - 2][1] * alpha[0] + - X_low[i - 2][0] * alpha[1] + - X_low[i - 1][1] * alpha[2] + - X_low[i - 1][0] * alpha[3] + - X_low[i][1]; - } -} - -static void sbr_hf_g_filt_c(float (*Y)[2], const float (*X_high)[40][2], - const float *g_filt, int m_max, intptr_t ixh) -{ - int m; - - for (m = 0; m < m_max; m++) { - Y[m][0] = X_high[m][ixh][0] * g_filt[m]; - Y[m][1] = X_high[m][ixh][1] * g_filt[m]; - } -} - -static av_always_inline void sbr_hf_apply_noise(float (*Y)[2], - const float *s_m, - const float *q_filt, - int noise, - float phi_sign0, - float phi_sign1, - int m_max) -{ - int m; - - for (m = 0; m < m_max; m++) { - float y0 = Y[m][0]; - float y1 = Y[m][1]; - noise = (noise + 1) & 0x1ff; - if (s_m[m]) { - y0 += s_m[m] * phi_sign0; - y1 += s_m[m] * phi_sign1; - } else { - y0 += q_filt[m] * ff_sbr_noise_table[noise][0]; - y1 += q_filt[m] * ff_sbr_noise_table[noise][1]; - } - Y[m][0] = y0; - Y[m][1] = y1; - phi_sign1 = -phi_sign1; - } -} - -static void sbr_hf_apply_noise_0(float (*Y)[2], const float *s_m, - const float *q_filt, int noise, - int kx, int m_max) -{ - sbr_hf_apply_noise(Y, s_m, q_filt, noise, 1.0, 0.0, m_max); -} - -static void sbr_hf_apply_noise_1(float (*Y)[2], const float *s_m, - const float *q_filt, int noise, - int kx, int m_max) -{ - float phi_sign = 1 - 2 * (kx & 1); - sbr_hf_apply_noise(Y, s_m, q_filt, noise, 0.0, phi_sign, m_max); -} - -static void sbr_hf_apply_noise_2(float (*Y)[2], const float *s_m, - const float *q_filt, int noise, - int kx, int m_max) -{ - sbr_hf_apply_noise(Y, s_m, q_filt, noise, -1.0, 0.0, m_max); -} - -static void sbr_hf_apply_noise_3(float (*Y)[2], const float *s_m, - const float *q_filt, int noise, - int kx, int m_max) -{ - float phi_sign = 1 - 2 * (kx & 1); - sbr_hf_apply_noise(Y, s_m, q_filt, noise, 0.0, -phi_sign, m_max); -} - -av_cold void ff_sbrdsp_init(SBRDSPContext *s) -{ - s->sum64x5 = sbr_sum64x5_c; - s->sum_square = sbr_sum_square_c; - s->neg_odd_64 = sbr_neg_odd_64_c; - s->qmf_pre_shuffle = sbr_qmf_pre_shuffle_c; - s->qmf_post_shuffle = sbr_qmf_post_shuffle_c; - s->qmf_deint_neg = sbr_qmf_deint_neg_c; - s->qmf_deint_bfly = sbr_qmf_deint_bfly_c; - s->autocorrelate = sbr_autocorrelate_c; - s->hf_gen = sbr_hf_gen_c; - s->hf_g_filt = sbr_hf_g_filt_c; - - s->hf_apply_noise[0] = sbr_hf_apply_noise_0; - s->hf_apply_noise[1] = sbr_hf_apply_noise_1; - s->hf_apply_noise[2] = sbr_hf_apply_noise_2; - s->hf_apply_noise[3] = sbr_hf_apply_noise_3; - - if (ARCH_ARM) - ff_sbrdsp_init_arm(s); - if (ARCH_X86) - ff_sbrdsp_init_x86(s); - if (ARCH_MIPS) - ff_sbrdsp_init_mips(s); -} diff --git a/libavcodec/sbrdsp.h b/libavcodec/sbrdsp.h index 1c1bcdf..75cc095 100644 --- a/libavcodec/sbrdsp.h +++ b/libavcodec/sbrdsp.h @@ -22,29 +22,31 @@ #define AVCODEC_SBRDSP_H #include +#include "aac_defines.h" +#include "float_emu.h" typedef struct SBRDSPContext { - void (*sum64x5)(float *z); - float (*sum_square)(float (*x)[2], int n); - void (*neg_odd_64)(float *x); - void (*qmf_pre_shuffle)(float *z); - void (*qmf_post_shuffle)(float W[32][2], const float *z); - void (*qmf_deint_neg)(float *v, const float *src); - void (*qmf_deint_bfly)(float *v, const float *src0, const float *src1); - void (*autocorrelate)(const float x[40][2], float phi[3][2][2]); - void (*hf_gen)(float (*X_high)[2], const float (*X_low)[2], - const float alpha0[2], const float alpha1[2], - float bw, int start, int end); - void (*hf_g_filt)(float (*Y)[2], const float (*X_high)[40][2], - const float *g_filt, int m_max, intptr_t ixh); - void (*hf_apply_noise[4])(float (*Y)[2], const float *s_m, - const float *q_filt, int noise, + void (*sum64x5)(INTFLOAT *z); + AAC_FLOAT (*sum_square)(INTFLOAT (*x)[2], int n); + void (*neg_odd_64)(INTFLOAT *x); + void (*qmf_pre_shuffle)(INTFLOAT *z); + void (*qmf_post_shuffle)(INTFLOAT W[32][2], const INTFLOAT *z); + void (*qmf_deint_neg)(INTFLOAT *v, const INTFLOAT *src); + void (*qmf_deint_bfly)(INTFLOAT *v, const INTFLOAT *src0, const INTFLOAT *src1); + void (*autocorrelate)(const INTFLOAT x[40][2], AAC_FLOAT phi[3][2][2]); + void (*hf_gen)(INTFLOAT (*X_high)[2], const INTFLOAT (*X_low)[2], + const INTFLOAT alpha0[2], const INTFLOAT alpha1[2], + INTFLOAT bw, int start, int end); + void (*hf_g_filt)(INTFLOAT (*Y)[2], const INTFLOAT (*X_high)[40][2], + const AAC_FLOAT *g_filt, int m_max, intptr_t ixh); + void (*hf_apply_noise[4])(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m, + const AAC_FLOAT *q_filt, int noise, int kx, int m_max); } SBRDSPContext; -extern const float ff_sbr_noise_table[][2]; +extern const INTFLOAT AAC_RENAME(ff_sbr_noise_table)[][2]; -void ff_sbrdsp_init(SBRDSPContext *s); +void AAC_RENAME(ff_sbrdsp_init)(SBRDSPContext *s); void ff_sbrdsp_init_arm(SBRDSPContext *s); void ff_sbrdsp_init_x86(SBRDSPContext *s); void ff_sbrdsp_init_mips(SBRDSPContext *s); diff --git a/libavcodec/sbrdsp_fixed.c b/libavcodec/sbrdsp_fixed.c new file mode 100644 index 0000000..df961b6 --- /dev/null +++ b/libavcodec/sbrdsp_fixed.c @@ -0,0 +1,364 @@ +/* + * AAC Spectral Band Replication decoding functions + * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) + * Copyright (c) 2009-2010 Alex Converse + * + * This file is part of FFmpeg. + * + * 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 + */ + +#define USE_FIXED 1 + +#include "aac.h" +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/intfloat.h" +#include "sbrdsp.h" + +static aac_float_t sbr_sum_square_c(int (*x)[2], int n) +{ + aac_float_t ret; + long long accu = 0; + int i, nz, round; + + for (i = 0; i < n; i += 2) { + accu += (long long)x[i + 0][0] * x[i + 0][0]; + accu += (long long)x[i + 0][1] * x[i + 0][1]; + accu += (long long)x[i + 1][0] * x[i + 1][0]; + accu += (long long)x[i + 1][1] * x[i + 1][1]; + } + + i = (int)(accu >> 32); + if (i == 0) { + nz = 31; + } else { + nz = 0; + while (FFABS(i) < 0x40000000) { + i <<= 1; + nz++; + } + } + + nz = 32-nz; + round = 1 << (nz-1); + i = (int)((accu+round) >> nz); + i >>= 1; + ret = int2float(i, nz + 15); + + return ret; +} + +static void sbr_neg_odd_64_c(int *x) +{ + int i; + for (i = 1; i < 64; i += 2) + x[i] = -x[i]; +} + +static void sbr_qmf_pre_shuffle_c(int *z) +{ + int k; + z[64] = z[0]; + z[65] = z[1]; + for (k = 1; k < 32; k++) { + z[64+2*k ] = -z[64 - k]; + z[64+2*k+1] = z[ k + 1]; + } +} + +static void sbr_qmf_post_shuffle_c(int W[32][2], const int *z) +{ + int k; + for (k = 0; k < 32; k++) { + W[k][0] = -z[63-k]; + W[k][1] = z[k]; + } +} + +static void sbr_qmf_deint_neg_c(int *v, const int *src) +{ + int i; + for (i = 0; i < 32; i++) { + v[ i] = ( src[63 - 2*i ] + 16) >> 5; + v[63 - i] = (-src[63 - 2*i - 1] + 16) >> 5; + } +} + +static av_always_inline void autocorrelate(const int x[40][2], aac_float_t phi[3][2][2], int lag) +{ + int i, nz, round, mant, expo; + long long real_sum, imag_sum; + long long accu_re = 0, accu_im = 0; + + if (lag) { + for (i = 1; i < 38; i++) { + accu_re += (long long)x[i][0] * x[i+lag][0]; + accu_re += (long long)x[i][1] * x[i+lag][1]; + accu_im += (long long)x[i][0] * x[i+lag][1]; + accu_im -= (long long)x[i][1] * x[i+lag][0]; + } + + real_sum = accu_re; + imag_sum = accu_im; + + accu_re += (long long)x[ 0][0] * x[lag][0]; + accu_re += (long long)x[ 0][1] * x[lag][1]; + accu_im += (long long)x[ 0][0] * x[lag][1]; + accu_im -= (long long)x[ 0][1] * x[lag][0]; + + i = (int)(accu_re >> 32); + if (i == 0) { + nz = 31; + } else { + nz = 0; + while (FFABS(i) < 0x40000000) { + i <<= 1; + nz++; + } + } + + nz = 32-nz; + round = 1 << (nz-1); + mant = (int)((accu_re+round) >> nz); + mant = (mant + 64)>>7; + mant <<= 6; + expo = nz + 15; + phi[2-lag][1][0] = int2float(mant, expo); + + i = (int)(accu_im >> 32); + if (i == 0) { + nz = 31; + } else { + nz = 0; + while (FFABS(i) < 0x40000000) { + i <<= 1; + nz++; + } + } + + nz = 32-nz; + round = 1 << (nz-1); + mant = (int)((accu_im+round) >> nz); + mant = (mant + 64)>>7; + mant <<= 6; + expo = nz + 15; + phi[2-lag][1][1] = int2float(mant, expo); + + if (lag == 1) { + accu_re = real_sum; + accu_im = imag_sum; + accu_re += (long long)x[38][0] * x[39][0]; + accu_re += (long long)x[38][1] * x[39][1]; + accu_im += (long long)x[38][0] * x[39][1]; + accu_im -= (long long)x[38][1] * x[39][0]; + + i = (int)(accu_re >> 32); + if (i == 0) { + nz = 31; + } else { + nz = 0; + while (FFABS(i) < 0x40000000) { + i <<= 1; + nz++; + } + } + + nz = 32-nz; + round = 1 << (nz-1); + mant = (int)((accu_re+round) >> nz); + mant = (mant + 64)>>7; + mant <<= 6; + expo = nz + 15; + phi[0][0][0] = int2float(mant, expo); + + i = (int)(accu_im >> 32); + if (i == 0) { + nz = 31; + } else { + nz = 0; + while (FFABS(i) < 0x40000000) { + i <<= 1; + nz++; + } + } + + nz = 32-nz; + round = 1 << (nz-1); + mant = (int)((accu_im+round) >> nz); + mant = (mant + 64)>>7; + mant <<= 6; + expo = nz + 15; + phi[0][0][1] = int2float(mant, expo); + } + } else { + for (i = 1; i < 38; i++) { + accu_re += (long long)x[i][0] * x[i][0]; + accu_re += (long long)x[i][1] * x[i][1]; + } + real_sum = accu_re; + accu_re += (long long)x[ 0][0] * x[ 0][0]; + accu_re += (long long)x[ 0][1] * x[ 0][1]; + + i = (int)(accu_re >> 32); + if (i == 0) { + nz = 31; + } else { + nz = 0; + while (FFABS(i) < 0x40000000) { + i <<= 1; + nz++; + } + } + + nz = 32-nz; + round = 1 << (nz-1); + mant = (int)((accu_re+round) >> nz); + mant = (mant + 64)>>7; + mant <<= 6; + expo = nz + 15; + phi[2][1][0] = int2float(mant, expo); + + accu_re = real_sum; + accu_re += (long long)x[38][0] * x[38][0]; + accu_re += (long long)x[38][1] * x[38][1]; + + i = (int)(accu_re >> 32); + if (i == 0) { + nz = 31; + } else { + nz = 0; + while (FFABS(i) < 0x40000000) { + i <<= 1; + nz++; + } + } + + nz = 32-nz; + round = 1 << (nz-1); + mant = (int)((accu_re+round) >> nz); + mant = (mant + 64)>>7; + mant <<= 6; + expo = nz + 15; + phi[1][0][0] = int2float(mant, expo); + } +} + +static void sbr_autocorrelate_c(const int x[40][2], aac_float_t phi[3][2][2]) +{ + autocorrelate(x, phi, 0); + autocorrelate(x, phi, 1); + autocorrelate(x, phi, 2); +} + +static void sbr_hf_gen_c(int (*X_high)[2], const int (*X_low)[2], + const int alpha0[2], const int alpha1[2], + int bw, int start, int end) +{ + int alpha[4]; + int i; + long long accu; + + accu = (long long)alpha0[0] * bw; + alpha[2] = (int)((accu + 0x40000000) >> 31); + accu = (long long)alpha0[1] * bw; + alpha[3] = (int)((accu + 0x40000000) >> 31); + accu = (long long)bw * bw; + bw = (int)((accu + 0x40000000) >> 31); + accu = (long long)alpha1[0] * bw; + alpha[0] = (int)((accu + 0x40000000) >> 31); + accu = (long long)alpha1[1] * bw; + alpha[1] = (int)((accu + 0x40000000) >> 31); + + for (i = start; i < end; i++) { + accu = (long long)X_low[i][0] * 0x20000000; + accu += (long long)X_low[i - 2][0] * alpha[0]; + accu -= (long long)X_low[i - 2][1] * alpha[1]; + accu += (long long)X_low[i - 1][0] * alpha[2]; + accu -= (long long)X_low[i - 1][1] * alpha[3]; + X_high[i][0] = (int)((accu + 0x10000000) >> 29); + + accu = (long long)X_low[i][1] * 0x20000000; + accu += (long long)X_low[i - 2][1] * alpha[0]; + accu += (long long)X_low[i - 2][0] * alpha[1]; + accu += (long long)X_low[i - 1][1] * alpha[2]; + accu += (long long)X_low[i - 1][0] * alpha[3]; + X_high[i][1] = (int)((accu + 0x10000000) >> 29); + } +} + +static void sbr_hf_g_filt_c(int (*Y)[2], const int (*X_high)[40][2], + const aac_float_t *g_filt, int m_max, intptr_t ixh) +{ + int m, r; + long long accu; + + for (m = 0; m < m_max; m++) { + r = 1 << (22-g_filt[m].expo); + accu = (long long)X_high[m][ixh][0] * ((g_filt[m].mant + 64)>>7); + Y[m][0] = (int)((accu + r) >> (23-g_filt[m].expo)); + + accu = (long long)X_high[m][ixh][1] * ((g_filt[m].mant + 64)>>7); + Y[m][1] = (int)((accu + r) >> (23-g_filt[m].expo)); + } +} + +static av_always_inline void sbr_hf_apply_noise(int (*Y)[2], + const aac_float_t *s_m, + const aac_float_t *q_filt, + int noise, + int phi_sign0, + int phi_sign1, + int m_max) +{ + int m; + + for (m = 0; m < m_max; m++) { + int y0 = Y[m][0]; + int y1 = Y[m][1]; + noise = (noise + 1) & 0x1ff; + if (s_m[m].mant) { + int shift, round; + + shift = 22 - s_m[m].expo; + if (shift < 30) { + round = 1 << (shift-1); + y0 += (s_m[m].mant * phi_sign0 + round) >> shift; + y1 += (s_m[m].mant * phi_sign1 + round) >> shift; + } + } else { + int shift, round, tmp; + long long accu; + + shift = 22 - q_filt[m].expo; + if (shift < 30) { + round = 1 << (shift-1); + + accu = (long long)q_filt[m].mant * ff_sbr_noise_table_fixed[noise][0]; + tmp = (int)((accu + 0x40000000) >> 31); + y0 += (tmp + round) >> shift; + + accu = (long long)q_filt[m].mant * ff_sbr_noise_table_fixed[noise][1]; + tmp = (int)((accu + 0x40000000) >> 31); + y1 += (tmp + round) >> shift; + } + } + Y[m][0] = y0; + Y[m][1] = y1; + phi_sign1 = -phi_sign1; + } +} + +#include "sbrdsp_template.c" diff --git a/libavcodec/sbrdsp_float.c b/libavcodec/sbrdsp_float.c new file mode 100644 index 0000000..cc432b6 --- /dev/null +++ b/libavcodec/sbrdsp_float.c @@ -0,0 +1,225 @@ +/* + * AAC Spectral Band Replication decoding functions + * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) + * Copyright (c) 2009-2010 Alex Converse + * + * This file is part of FFmpeg. + * + * 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 + */ + +#define USE_FIXED 0 + +#include "aac.h" +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/intfloat.h" +#include "sbrdsp.h" + +static float sbr_sum_square_c(float (*x)[2], int n) +{ + float sum0 = 0.0f, sum1 = 0.0f; + int i; + + for (i = 0; i < n; i += 2) + { + sum0 += x[i + 0][0] * x[i + 0][0]; + sum1 += x[i + 0][1] * x[i + 0][1]; + sum0 += x[i + 1][0] * x[i + 1][0]; + sum1 += x[i + 1][1] * x[i + 1][1]; + } + + return sum0 + sum1; +} + +static void sbr_neg_odd_64_c(float *x) +{ + union av_intfloat32 *xi = (union av_intfloat32*) x; + int i; + for (i = 1; i < 64; i += 4) { + xi[i + 0].i ^= 1U << 31; + xi[i + 2].i ^= 1U << 31; + } +} + +static void sbr_qmf_pre_shuffle_c(float *z) +{ + union av_intfloat32 *zi = (union av_intfloat32*) z; + int k; + zi[64].i = zi[0].i; + zi[65].i = zi[1].i; + for (k = 1; k < 31; k += 2) { + zi[64 + 2 * k + 0].i = zi[64 - k].i ^ (1U << 31); + zi[64 + 2 * k + 1].i = zi[ k + 1].i; + zi[64 + 2 * k + 2].i = zi[63 - k].i ^ (1U << 31); + zi[64 + 2 * k + 3].i = zi[ k + 2].i; + } + + zi[64 + 2 * 31 + 0].i = zi[64 - 31].i ^ (1U << 31); + zi[64 + 2 * 31 + 1].i = zi[31 + 1].i; +} + +static void sbr_qmf_post_shuffle_c(float W[32][2], const float *z) +{ + const union av_intfloat32 *zi = (const union av_intfloat32*) z; + union av_intfloat32 *Wi = (union av_intfloat32*) W; + int k; + for (k = 0; k < 32; k += 2) { + Wi[2 * k + 0].i = zi[63 - k].i ^ (1U << 31); + Wi[2 * k + 1].i = zi[ k + 0].i; + Wi[2 * k + 2].i = zi[62 - k].i ^ (1U << 31); + Wi[2 * k + 3].i = zi[ k + 1].i; + } +} + +static void sbr_qmf_deint_neg_c(float *v, const float *src) +{ + const union av_intfloat32 *si = (const union av_intfloat32*)src; + union av_intfloat32 *vi = (union av_intfloat32*)v; + int i; + for (i = 0; i < 32; i++) { + vi[ i].i = si[63 - 2 * i ].i; + vi[63 - i].i = si[63 - 2 * i - 1].i ^ (1U << 31); + } +} + +#if 0 + /* This code is slower because it multiplies memory accesses. + * It is left for educational purposes and because it may offer + * a better reference for writing arch-specific DSP functions. */ +static av_always_inline void autocorrelate(const float x[40][2], + float phi[3][2][2], int lag) +{ + int i; + float real_sum = 0.0f; + float imag_sum = 0.0f; + if (lag) { + for (i = 1; i < 38; i++) { + real_sum += x[i][0] * x[i+lag][0] + x[i][1] * x[i+lag][1]; + imag_sum += x[i][0] * x[i+lag][1] - x[i][1] * x[i+lag][0]; + } + phi[2-lag][1][0] = real_sum + x[ 0][0] * x[lag][0] + x[ 0][1] * x[lag][1]; + phi[2-lag][1][1] = imag_sum + x[ 0][0] * x[lag][1] - x[ 0][1] * x[lag][0]; + if (lag == 1) { + phi[0][0][0] = real_sum + x[38][0] * x[39][0] + x[38][1] * x[39][1]; + phi[0][0][1] = imag_sum + x[38][0] * x[39][1] - x[38][1] * x[39][0]; + } + } else { + for (i = 1; i < 38; i++) { + real_sum += x[i][0] * x[i][0] + x[i][1] * x[i][1]; + } + phi[2][1][0] = real_sum + x[ 0][0] * x[ 0][0] + x[ 0][1] * x[ 0][1]; + phi[1][0][0] = real_sum + x[38][0] * x[38][0] + x[38][1] * x[38][1]; + } +} + +static void sbr_autocorrelate_c(const float x[40][2], float phi[3][2][2]) +{ + autocorrelate(x, phi, 0); + autocorrelate(x, phi, 1); + autocorrelate(x, phi, 2); +} +#else +static void sbr_autocorrelate_c(const float x[40][2], float phi[3][2][2]) +{ + float real_sum2 = x[0][0] * x[2][0] + x[0][1] * x[2][1]; + float imag_sum2 = x[0][0] * x[2][1] - x[0][1] * x[2][0]; + float real_sum1 = 0.0f, imag_sum1 = 0.0f, real_sum0 = 0.0f; + int i; + for (i = 1; i < 38; i++) { + real_sum0 += x[i][0] * x[i ][0] + x[i][1] * x[i ][1]; + real_sum1 += x[i][0] * x[i + 1][0] + x[i][1] * x[i + 1][1]; + imag_sum1 += x[i][0] * x[i + 1][1] - x[i][1] * x[i + 1][0]; + real_sum2 += x[i][0] * x[i + 2][0] + x[i][1] * x[i + 2][1]; + imag_sum2 += x[i][0] * x[i + 2][1] - x[i][1] * x[i + 2][0]; + } + phi[2 - 2][1][0] = real_sum2; + phi[2 - 2][1][1] = imag_sum2; + phi[2 ][1][0] = real_sum0 + x[ 0][0] * x[ 0][0] + x[ 0][1] * x[ 0][1]; + phi[1 ][0][0] = real_sum0 + x[38][0] * x[38][0] + x[38][1] * x[38][1]; + phi[2 - 1][1][0] = real_sum1 + x[ 0][0] * x[ 1][0] + x[ 0][1] * x[ 1][1]; + phi[2 - 1][1][1] = imag_sum1 + x[ 0][0] * x[ 1][1] - x[ 0][1] * x[ 1][0]; + phi[0 ][0][0] = real_sum1 + x[38][0] * x[39][0] + x[38][1] * x[39][1]; + phi[0 ][0][1] = imag_sum1 + x[38][0] * x[39][1] - x[38][1] * x[39][0]; +#endif +} + +static void sbr_hf_gen_c(float (*X_high)[2], const float (*X_low)[2], + const float alpha0[2], const float alpha1[2], + float bw, int start, int end) +{ + float alpha[4]; + int i; + + alpha[0] = alpha1[0] * bw * bw; + alpha[1] = alpha1[1] * bw * bw; + alpha[2] = alpha0[0] * bw; + alpha[3] = alpha0[1] * bw; + + for (i = start; i < end; i++) { + X_high[i][0] = + X_low[i - 2][0] * alpha[0] - + X_low[i - 2][1] * alpha[1] + + X_low[i - 1][0] * alpha[2] - + X_low[i - 1][1] * alpha[3] + + X_low[i][0]; + X_high[i][1] = + X_low[i - 2][1] * alpha[0] + + X_low[i - 2][0] * alpha[1] + + X_low[i - 1][1] * alpha[2] + + X_low[i - 1][0] * alpha[3] + + X_low[i][1]; + } +} + +static void sbr_hf_g_filt_c(float (*Y)[2], const float (*X_high)[40][2], + const float *g_filt, int m_max, intptr_t ixh) +{ + int m; + + for (m = 0; m < m_max; m++) { + Y[m][0] = X_high[m][ixh][0] * g_filt[m]; + Y[m][1] = X_high[m][ixh][1] * g_filt[m]; + } +} + +static av_always_inline void sbr_hf_apply_noise(float (*Y)[2], + const float *s_m, + const float *q_filt, + int noise, + float phi_sign0, + float phi_sign1, + int m_max) +{ + int m; + + for (m = 0; m < m_max; m++) { + float y0 = Y[m][0]; + float y1 = Y[m][1]; + noise = (noise + 1) & 0x1ff; + if (s_m[m]) { + y0 += s_m[m] * phi_sign0; + y1 += s_m[m] * phi_sign1; + } else { + y0 += q_filt[m] * ff_sbr_noise_table[noise][0]; + y1 += q_filt[m] * ff_sbr_noise_table[noise][1]; + } + Y[m][0] = y0; + Y[m][1] = y1; + phi_sign1 = -phi_sign1; + } +} + +#include "sbrdsp_template.c" diff --git a/libavcodec/sbrdsp_template.c b/libavcodec/sbrdsp_template.c new file mode 100644 index 0000000..b649dfd --- /dev/null +++ b/libavcodec/sbrdsp_template.c @@ -0,0 +1,97 @@ +/* + * AAC Spectral Band Replication decoding functions + * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) + * Copyright (c) 2009-2010 Alex Converse + * + * This file is part of FFmpeg. + * + * 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 + */ + +static void sbr_sum64x5_c(INTFLOAT *z) +{ + int k; + for (k = 0; k < 64; k++) { + INTFLOAT f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256]; + z[k] = f; + } +} + +static void sbr_qmf_deint_bfly_c(INTFLOAT *v, const INTFLOAT *src0, const INTFLOAT *src1) +{ + int i; + for (i = 0; i < 64; i++) { + v[ i] = AAC_SRA_R((src0[i] - src1[63 - i]), 5); + v[127 - i] = AAC_SRA_R((src0[i] + src1[63 - i]), 5); + } +} + +static void sbr_hf_apply_noise_0(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m, + const AAC_FLOAT *q_filt, int noise, + int kx, int m_max) +{ + sbr_hf_apply_noise(Y, s_m, q_filt, noise, (INTFLOAT)1.0, (INTFLOAT)0.0, m_max); +} + +static void sbr_hf_apply_noise_1(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m, + const AAC_FLOAT *q_filt, int noise, + int kx, int m_max) +{ + INTFLOAT phi_sign = 1 - 2 * (kx & 1); + sbr_hf_apply_noise(Y, s_m, q_filt, noise, (INTFLOAT)0.0, phi_sign, m_max); +} + +static void sbr_hf_apply_noise_2(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m, + const AAC_FLOAT *q_filt, int noise, + int kx, int m_max) +{ + sbr_hf_apply_noise(Y, s_m, q_filt, noise, (INTFLOAT)-1.0, (INTFLOAT)0.0, m_max); +} + +static void sbr_hf_apply_noise_3(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m, + const AAC_FLOAT *q_filt, int noise, + int kx, int m_max) +{ + INTFLOAT phi_sign = 1 - 2 * (kx & 1); + sbr_hf_apply_noise(Y, s_m, q_filt, noise, (INTFLOAT)0.0, -phi_sign, m_max); +} + +av_cold void AAC_RENAME(ff_sbrdsp_init)(SBRDSPContext *s) +{ + s->sum64x5 = sbr_sum64x5_c; + s->sum_square = sbr_sum_square_c; + s->neg_odd_64 = sbr_neg_odd_64_c; + s->qmf_pre_shuffle = sbr_qmf_pre_shuffle_c; + s->qmf_post_shuffle = sbr_qmf_post_shuffle_c; + s->qmf_deint_neg = sbr_qmf_deint_neg_c; + s->qmf_deint_bfly = sbr_qmf_deint_bfly_c; + s->autocorrelate = sbr_autocorrelate_c; + s->hf_gen = sbr_hf_gen_c; + s->hf_g_filt = sbr_hf_g_filt_c; + + s->hf_apply_noise[0] = sbr_hf_apply_noise_0; + s->hf_apply_noise[1] = sbr_hf_apply_noise_1; + s->hf_apply_noise[2] = sbr_hf_apply_noise_2; + s->hf_apply_noise[3] = sbr_hf_apply_noise_3; + +#if !USE_FIXED + if (ARCH_ARM) + ff_sbrdsp_init_arm(s); + if (ARCH_X86) + ff_sbrdsp_init_x86(s); + if (ARCH_MIPS) + ff_sbrdsp_init_mips(s); +#endif /* !USE_FIXED */ +} -- 1.8.2.1 From nedeljko.babic at imgtec.com Fri Aug 1 15:53:18 2014 From: nedeljko.babic at imgtec.com (Nedeljko Babic) Date: Fri, 1 Aug 2014 15:53:18 +0200 Subject: [FFmpeg-devel] [PATCH 12/14] libavcodec: Implementation of AAC_fixed_decoder (PS-module) [3/4] In-Reply-To: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <1406901200-4862-13-git-send-email-nedeljko.babic@imgtec.com> From: Djordje Pesut Add fixed point implementation. Signed-off-by: Nedeljko Babic --- libavcodec/aac_defines.h | 36 +++++ libavcodec/aacps.c | 350 ++++++++++++++++++++++++++++++++++------- libavcodec/aacps.h | 28 ++-- libavcodec/aacps_fixed.c | 25 +++ libavcodec/aacps_float.c | 157 +----------------- libavcodec/aacpsdata.c | 6 +- libavcodec/aacpsdsp.c | 216 ------------------------- libavcodec/aacpsdsp.h | 30 ++-- libavcodec/aacpsdsp_fixed.c | 27 ++++ libavcodec/aacpsdsp_float.c | 27 ++++ libavcodec/aacpsdsp_template.c | 221 ++++++++++++++++++++++++++ 11 files changed, 663 insertions(+), 460 deletions(-) create mode 100644 libavcodec/aacps_fixed.c delete mode 100644 libavcodec/aacpsdsp.c create mode 100644 libavcodec/aacpsdsp_fixed.c create mode 100644 libavcodec/aacpsdsp_float.c create mode 100644 libavcodec/aacpsdsp_template.c diff --git a/libavcodec/aac_defines.h b/libavcodec/aac_defines.h index 71568e3..e3d736d 100644 --- a/libavcodec/aac_defines.h +++ b/libavcodec/aac_defines.h @@ -33,6 +33,7 @@ #define AAC_RENAME(x) x ## _fixed #define AAC_RENAME_32(x) x ## _fixed_32 #define INTFLOAT int +#define INT64FLOAT int64_t #define SHORTFLOAT int16_t #define AAC_FLOAT aac_float_t #define AAC_SIGNE int @@ -43,9 +44,33 @@ #define Q31(x) (int)((x)*2147483648.0 + 0.5) #define RANGE15(x) x #define GET_GAIN(x, y) (-(y) << (x)) + 1024 +#define AAC_MUL16(x, y) (int)(((int64_t)(x) * (y) + 0x8000) >> 16) #define AAC_MUL26(x, y) (int)(((int64_t)(x) * (y) + 0x2000000) >> 26) #define AAC_MUL30(x, y) (int)(((int64_t)(x) * (y) + 0x20000000) >> 30) #define AAC_MUL31(x, y) (int)(((int64_t)(x) * (y) + 0x40000000) >> 31) +#define AAC_MADD28(x, y, a, b) (int)((((int64_t)(x) * (y)) + \ + ((int64_t)(a) * (b)) + \ + 0x8000000) >> 28) +#define AAC_MADD30(x, y, a, b) (int)((((int64_t)(x) * (y)) + \ + ((int64_t)(a) * (b)) + \ + 0x20000000) >> 30) +#define AAC_MADD30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \ + ((int64_t)(a) * (b)) + \ + ((int64_t)(c) * (d)) + \ + ((int64_t)(e) * (f)) + \ + 0x20000000) >> 30) +#define AAC_MSUB30(x, y, a, b) (int)((((int64_t)(x) * (y)) - \ + ((int64_t)(a) * (b)) + \ + 0x20000000) >> 30) +#define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \ + ((int64_t)(a) * (b)) - \ + ((int64_t)(c) * (d)) - \ + ((int64_t)(e) * (f)) + \ + 0x20000000) >> 30) +#define AAC_MSUB31_V3(x, y, z) (int)((((int64_t)(x) * (z)) - \ + ((int64_t)(y) * (z)) + \ + 0x40000000) >> 31) +#define AAC_HALF_SUM(x, y) (x) >> 1 + (y) >> 1 #define AAC_SRA_R(x, y) (int)(((x) + (1 << ((y) - 1))) >> (y)) #else @@ -56,6 +81,7 @@ #define AAC_RENAME(x) x #define AAC_RENAME_32(x) x #define INTFLOAT float +#define INT64FLOAT float #define SHORTFLOAT float #define AAC_FLOAT float #define AAC_SIGNE unsigned @@ -66,9 +92,19 @@ #define Q31(x) x #define RANGE15(x) (32768.0 * (x)) #define GET_GAIN(x, y) powf((x), -(y)) +#define AAC_MUL16(x, y) ((x) * (y)) #define AAC_MUL26(x, y) ((x) * (y)) #define AAC_MUL30(x, y) ((x) * (y)) #define AAC_MUL31(x, y) ((x) * (y)) +#define AAC_MADD28(x, y, a, b) ((x) * (y) + (a) * (b)) +#define AAC_MADD30(x, y, a, b) ((x) * (y) + (a) * (b)) +#define AAC_MADD30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) + \ + (c) * (d) + (e) * (f)) +#define AAC_MSUB30(x, y, a, b) ((x) * (y) - (a) * (b)) +#define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) - \ + (c) * (d) - (e) * (f)) +#define AAC_MSUB31_V3(x, y, z) ((x) - (y)) * (z) +#define AAC_HALF_SUM(x, y) ((x) + (y)) * 0.5f #define AAC_SRA_R(x, y) (x) #endif /* USE_FIXED */ diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c index fdaae3f..fe01796 100644 --- a/libavcodec/aacps.c +++ b/libavcodec/aacps.c @@ -21,12 +21,17 @@ #include #include "libavutil/common.h" -#include "libavutil/internal.h" #include "libavutil/mathematics.h" #include "avcodec.h" #include "get_bits.h" #include "aacps.h" +#if USE_FIXED +#include "aacps_fixed_tablegen.h" +#include "dsputil.h" +#else +#include "libavutil/internal.h" #include "aacps_tablegen.h" +#endif /* USE_FIXED */ #include "aacpsdata.c" #define PS_BASELINE 0 ///< Operate in Baseline PS mode @@ -148,7 +153,7 @@ static void ipdopd_reset(int8_t *ipd_hist, int8_t *opd_hist) } } -int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left) +int AAC_RENAME(ff_ps_read_data)(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left) { int e; int bit_count_start = get_bits_count(gb_host); @@ -302,35 +307,42 @@ err: /** Split one subband into 2 subsubbands with a symmetric real filter. * The filter must have its non-center even coefficients equal to zero. */ -static void hybrid2_re(float (*in)[2], float (*out)[32][2], const float filter[8], int len, int reverse) +static void hybrid2_re(INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], const INTFLOAT filter[8], int len, int reverse) { int i, j; + for (i = 0; i < len; i++, in++) { - float re_in = filter[6] * in[6][0]; //real inphase - float re_op = 0.0f; //real out of phase - float im_in = filter[6] * in[6][1]; //imag inphase - float im_op = 0.0f; //imag out of phase + INT64FLOAT re_in = AAC_MUL31(filter[6], in[6][0]); //real inphase + INT64FLOAT re_op = 0.0f; //real out of phase + INT64FLOAT im_in = AAC_MUL31(filter[6], in[6][1]); //imag inphase + INT64FLOAT im_op = 0.0f; //imag out of phase for (j = 0; j < 6; j += 2) { - re_op += filter[j+1] * (in[j+1][0] + in[12-j-1][0]); - im_op += filter[j+1] * (in[j+1][1] + in[12-j-1][1]); + re_op += (INT64FLOAT)filter[j+1] * (in[j+1][0] + in[12-j-1][0]); + im_op += (INT64FLOAT)filter[j+1] * (in[j+1][1] + in[12-j-1][1]); } - out[ reverse][i][0] = re_in + re_op; - out[ reverse][i][1] = im_in + im_op; - out[!reverse][i][0] = re_in - re_op; - out[!reverse][i][1] = im_in - im_op; + +#if USE_FIXED + re_op = (re_op + 0x40000000) >> 31; + im_op = (im_op + 0x40000000) >> 31; +#endif /* USE_FIXED */ + + out[ reverse][i][0] = (INTFLOAT)(re_in + re_op); + out[ reverse][i][1] = (INTFLOAT)(im_in + im_op); + out[!reverse][i][0] = (INTFLOAT)(re_in - re_op); + out[!reverse][i][1] = (INTFLOAT)(im_in - im_op); } } /** Split one subband into 6 subsubbands with a complex filter */ -static void hybrid6_cx(PSDSPContext *dsp, float (*in)[2], float (*out)[32][2], - TABLE_CONST float (*filter)[8][2], int len) +static void hybrid6_cx(PSDSPContext *dsp, INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], + TABLE_CONST INTFLOAT (*filter)[8][2], int len) { int i; int N = 8; - LOCAL_ALIGNED_16(float, temp, [8], [2]); + LOCAL_ALIGNED_16(INTFLOAT, temp, [8], [2]); for (i = 0; i < len; i++, in++) { - dsp->hybrid_analysis(temp, in, (const float (*)[8][2]) filter, 1, N); + dsp->hybrid_analysis(temp, in, (const INTFLOAT (*)[8][2]) filter, 1, N); out[0][i][0] = temp[6][0]; out[0][i][1] = temp[6][1]; out[1][i][0] = temp[7][0]; @@ -347,18 +359,18 @@ static void hybrid6_cx(PSDSPContext *dsp, float (*in)[2], float (*out)[32][2], } static void hybrid4_8_12_cx(PSDSPContext *dsp, - float (*in)[2], float (*out)[32][2], - TABLE_CONST float (*filter)[8][2], int N, int len) + INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], + TABLE_CONST INTFLOAT (*filter)[8][2], int N, int len) { int i; for (i = 0; i < len; i++, in++) { - dsp->hybrid_analysis(out[0] + i, in, (const float (*)[8][2]) filter, 32, N); + dsp->hybrid_analysis(out[0] + i, in, (const INTFLOAT (*)[8][2]) filter, 32, N); } } -static void hybrid_analysis(PSDSPContext *dsp, float out[91][32][2], - float in[5][44][2], float L[2][38][64], +static void hybrid_analysis(PSDSPContext *dsp, INTFLOAT out[91][32][2], + INTFLOAT in[5][44][2], INTFLOAT L[2][38][64], int is34, int len) { int i, j; @@ -387,8 +399,8 @@ static void hybrid_analysis(PSDSPContext *dsp, float out[91][32][2], } } -static void hybrid_synthesis(PSDSPContext *dsp, float out[2][38][64], - float in[91][32][2], int is34, int len) +static void hybrid_synthesis(PSDSPContext *dsp, INTFLOAT out[2][38][64], + INTFLOAT in[91][32][2], int is34, int len) { int i, n; if (is34) { @@ -429,7 +441,7 @@ static void hybrid_synthesis(PSDSPContext *dsp, float out[2][38][64], } /// All-pass filter decay slope -#define DECAY_SLOPE 0.05f +#define DECAY_SLOPE Q30(0.05f) /// Number of frequency bands that can be addressed by the parameter index, b(k) static const int NR_PAR_BANDS[] = { 20, 34 }; static const int NR_IPDOPD_BANDS[] = { 11, 17 }; @@ -483,28 +495,45 @@ static void map_idx_34_to_20(int8_t *par_mapped, const int8_t *par, int full) } } -static void map_val_34_to_20(float par[PS_MAX_NR_IIDICC]) +static void map_val_34_to_20(INTFLOAT par[PS_MAX_NR_IIDICC]) { +#if USE_FIXED + long long accu; + + accu = (long long)(par[ 0] + (par[ 1]>>1)) * 1431655765; + par[ 0] = (int)((accu + 0x40000000) >> 31); + accu = (long long)((par[ 1]>>1) + par[ 2]) * 1431655765; + par[ 1] = (int)((accu + 0x40000000) >> 31); + accu = (long long)(par[ 3] + (par[ 4]>>1)) * 1431655765; + par[ 2] = (int)((accu + 0x40000000) >> 31); + accu = (long long)((par[ 4]>>1) + par[ 5]) * 1431655765; + par[ 3] = (int)((accu + 0x40000000) >> 31); +#else par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f; par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f; par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f; par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333f; - par[ 4] = ( par[ 6] + par[ 7]) * 0.5f; - par[ 5] = ( par[ 8] + par[ 9]) * 0.5f; +#endif /* USE_FIXED */ + par[ 4] = AAC_HALF_SUM(par[ 6], par[ 7]); + par[ 5] = AAC_HALF_SUM(par[ 8], par[ 9]); par[ 6] = par[10]; par[ 7] = par[11]; - par[ 8] = ( par[12] + par[13]) * 0.5f; - par[ 9] = ( par[14] + par[15]) * 0.5f; + par[ 8] = AAC_HALF_SUM(par[12], par[13]); + par[ 9] = AAC_HALF_SUM(par[14], par[15]); par[10] = par[16]; par[11] = par[17]; par[12] = par[18]; par[13] = par[19]; - par[14] = ( par[20] + par[21]) * 0.5f; - par[15] = ( par[22] + par[23]) * 0.5f; - par[16] = ( par[24] + par[25]) * 0.5f; - par[17] = ( par[26] + par[27]) * 0.5f; + par[14] = AAC_HALF_SUM(par[20], par[21]); + par[15] = AAC_HALF_SUM(par[22], par[23]); + par[16] = AAC_HALF_SUM(par[24], par[25]); + par[17] = AAC_HALF_SUM(par[26], par[27]); +#if USE_FIXED + par[18] = (((par[28]+2)>>2) + ((par[29]+2)>>2) + ((par[30]+2)>>2) + ((par[31]+2)>>2)); +#else par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f; - par[19] = ( par[32] + par[33]) * 0.5f; +#endif /* USE_FIXED */ + par[19] = AAC_HALF_SUM(par[32], par[33]); } static void map_idx_10_to_34(int8_t *par_mapped, const int8_t *par, int full) @@ -589,7 +618,7 @@ static void map_idx_20_to_34(int8_t *par_mapped, const int8_t *par, int full) par_mapped[ 0] = par[ 0]; } -static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC]) +static void map_val_20_to_34(INTFLOAT par[PS_MAX_NR_IIDICC]) { par[33] = par[19]; par[32] = par[19]; @@ -620,27 +649,30 @@ static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC]) par[ 7] = par[ 4]; par[ 6] = par[ 4]; par[ 5] = par[ 3]; - par[ 4] = (par[ 2] + par[ 3]) * 0.5f; + par[ 4] = AAC_HALF_SUM(par[ 2], par[ 3]); par[ 3] = par[ 2]; par[ 2] = par[ 1]; - par[ 1] = (par[ 0] + par[ 1]) * 0.5f; + par[ 1] = AAC_HALF_SUM(par[ 0], par[ 1]); } -static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[32][2], int is34) +static void decorrelation(PSContext *ps, INTFLOAT (*out)[32][2], const INTFLOAT (*s)[32][2], int is34) { - LOCAL_ALIGNED_16(float, power, [34], [PS_QMF_TIME_SLOTS]); - LOCAL_ALIGNED_16(float, transient_gain, [34], [PS_QMF_TIME_SLOTS]); - float *peak_decay_nrg = ps->peak_decay_nrg; - float *power_smooth = ps->power_smooth; - float *peak_decay_diff_smooth = ps->peak_decay_diff_smooth; - float (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay; - float (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay; - const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; - const float peak_decay_factor = 0.76592833836465f; + + LOCAL_ALIGNED_16(INTFLOAT, power, [34], [PS_QMF_TIME_SLOTS]); + LOCAL_ALIGNED_16(INTFLOAT, transient_gain, [34], [PS_QMF_TIME_SLOTS]); + INTFLOAT *peak_decay_nrg = ps->peak_decay_nrg; + INTFLOAT *power_smooth = ps->power_smooth; + INTFLOAT *peak_decay_diff_smooth = ps->peak_decay_diff_smooth; + INTFLOAT (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay; + INTFLOAT (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay; +#if USE_FIXED == 0 const float transient_impact = 1.5f; const float a_smooth = 0.25f; ///< Smoothing coefficient +#endif /* USE_FIXED */ + const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; int i, k, m, n; int n0 = 0, nL = 32; + const INTFLOAT peak_decay_factor = Q31(0.76592833836465f);; memset(power, 0, 34 * sizeof(*power)); @@ -658,6 +690,33 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3 } //Transient detection +#if USE_FIXED + for (i = 0; i < NR_PAR_BANDS[is34]; i++) { + for (n = n0; n < nL; n++) { + long long accu; + int decayed_peak; + int denom; + + accu = (long long)peak_decay_factor * peak_decay_nrg[i]; + decayed_peak = (int)((accu + 0x40000000) >> 31); + peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]); + power_smooth[i] += (power[i][n] - power_smooth[i] + 2) >> 2; + peak_decay_diff_smooth[i] += (peak_decay_nrg[i] - power[i][n] - peak_decay_diff_smooth[i] + 2) >> 2; + denom = peak_decay_diff_smooth[i] + (peak_decay_diff_smooth[i] >> 1); + if (denom > power_smooth[i]) { + int p = power_smooth[i]; + while (denom < 0x40000000) { + denom <<= 1; + p <<= 1; + } + transient_gain[i][n] = p / (denom >> 16); + } + else { + transient_gain[i][n] = 1 << 16; + } + } + } +#else for (i = 0; i < NR_PAR_BANDS[is34]; i++) { for (n = n0; n < nL; n++) { float decayed_peak = peak_decay_factor * peak_decay_nrg[i]; @@ -671,6 +730,7 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3 } } +#endif /* USE_FIXED */ //Decorrelation and transient reduction // PS_AP_LINKS - 1 // ----- @@ -681,8 +741,22 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3 //d[k][z] (out) = transient_gain_mapped[k][z] * H[k][z] * s[k][z] for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) { int b = k_to_i[k]; - float g_decay_slope = 1.f - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]); - g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f); +#if USE_FIXED + int g_decay_slope; + + if (k - DECAY_CUTOFF[is34] <= 0) { + g_decay_slope = 1 << 30; + } + else if (k - DECAY_CUTOFF[is34] >= 20) { + g_decay_slope = 0; + } + else { + g_decay_slope = (1 << 30) - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]); + } +#else + float g_decay_slope = 1.f - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]); + g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f); +#endif /* USE_FIXED */ memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0])); memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0])); for (m = 0; m < PS_AP_LINKS; m++) { @@ -690,7 +764,7 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3 } ps->dsp.decorrelate(out[k], delay[k] + PS_MAX_DELAY - 2, ap_delay[k], phi_fract[is34][k], - (const float (*)[2]) Q_fract_allpass[is34][k], + (const INTFLOAT (*)[2]) Q_fract_allpass[is34][k], transient_gain[b], g_decay_slope, nL - n0); } for (; k < SHORT_DELAY_BAND[is34]; k++) { @@ -749,10 +823,170 @@ static void remap20(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC], } } -int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top) +static void stereo_processing(PSContext *ps, INTFLOAT (*l)[32][2], INTFLOAT (*r)[32][2], int is34) +{ + int e, b, k; + + INTFLOAT (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11; + INTFLOAT (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12; + INTFLOAT (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21; + INTFLOAT (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22; + int8_t *opd_hist = ps->opd_hist; + int8_t *ipd_hist = ps->ipd_hist; + int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf; + int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf; + int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf; + int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf; + const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; + TABLE_CONST INTFLOAT (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; + + //Remapping + if (ps->num_env_old) { + memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0])); + memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0])); + memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0])); + memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0])); + memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0])); + memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0])); + memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0])); + memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0])); + } + + if (is34) { + remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); + remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); + if (ps->enable_ipdopd) { + remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); + remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); + } + if (!ps->is34bands_old) { + map_val_20_to_34(H11[0][0]); + map_val_20_to_34(H11[1][0]); + map_val_20_to_34(H12[0][0]); + map_val_20_to_34(H12[1][0]); + map_val_20_to_34(H21[0][0]); + map_val_20_to_34(H21[1][0]); + map_val_20_to_34(H22[0][0]); + map_val_20_to_34(H22[1][0]); + ipdopd_reset(ipd_hist, opd_hist); + } + } else { + remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); + remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); + if (ps->enable_ipdopd) { + remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); + remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); + } + if (ps->is34bands_old) { + map_val_34_to_20(H11[0][0]); + map_val_34_to_20(H11[1][0]); + map_val_34_to_20(H12[0][0]); + map_val_34_to_20(H12[1][0]); + map_val_34_to_20(H21[0][0]); + map_val_34_to_20(H21[1][0]); + map_val_34_to_20(H22[0][0]); + map_val_34_to_20(H22[1][0]); + ipdopd_reset(ipd_hist, opd_hist); + } + } + + //Mixing + for (e = 0; e < ps->num_env; e++) { + for (b = 0; b < NR_PAR_BANDS[is34]; b++) { + INTFLOAT h11, h12, h21, h22; + h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0]; + h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1]; + h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2]; + h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3]; + + if (!PS_BASELINE && ps->enable_ipdopd && b < NR_IPDOPD_BANDS[is34]) { + //The spec say says to only run this smoother when enable_ipdopd + //is set but the reference decoder appears to run it constantly + INTFLOAT h11i, h12i, h21i, h22i; + INTFLOAT ipd_adj_re, ipd_adj_im; + int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b]; + int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b]; + INTFLOAT opd_re = pd_re_smooth[opd_idx]; + INTFLOAT opd_im = pd_im_smooth[opd_idx]; + INTFLOAT ipd_re = pd_re_smooth[ipd_idx]; + INTFLOAT ipd_im = pd_im_smooth[ipd_idx]; + opd_hist[b] = opd_idx & 0x3F; + ipd_hist[b] = ipd_idx & 0x3F; + + ipd_adj_re = AAC_MADD30(opd_re, ipd_re, opd_im, ipd_im); + ipd_adj_im = AAC_MSUB30(opd_im, ipd_re, opd_re, ipd_im); + h11i = AAC_MUL30(h11, opd_im); + h11 = AAC_MUL30(h11, opd_re); + h12i = AAC_MUL30(h12, ipd_adj_im); + h12 = AAC_MUL30(h12, ipd_adj_re); + h21i = AAC_MUL30(h21, opd_im); + h21 = AAC_MUL30(h21, opd_re); + h22i = AAC_MUL30(h22, ipd_adj_im); + h22 = AAC_MUL30(h22, ipd_adj_re); + H11[1][e+1][b] = h11i; + H12[1][e+1][b] = h12i; + H21[1][e+1][b] = h21i; + H22[1][e+1][b] = h22i; + } + H11[0][e+1][b] = h11; + H12[0][e+1][b] = h12; + H21[0][e+1][b] = h21; + H22[0][e+1][b] = h22; + } + for (k = 0; k < NR_BANDS[is34]; k++) { + INTFLOAT h[2][4]; + INTFLOAT h_step[2][4]; + int start = ps->border_position[e]; + int stop = ps->border_position[e+1]; + INTFLOAT width = Q30(1.f) / (stop - start); +#if USE_FIXED + width <<= 1; +#endif + b = k_to_i[k]; + h[0][0] = H11[0][e][b]; + h[0][1] = H12[0][e][b]; + h[0][2] = H21[0][e][b]; + h[0][3] = H22[0][e][b]; + if (!PS_BASELINE && ps->enable_ipdopd) { + //Is this necessary? ps_04_new seems unchanged + if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) { + h[1][0] = -H11[1][e][b]; + h[1][1] = -H12[1][e][b]; + h[1][2] = -H21[1][e][b]; + h[1][3] = -H22[1][e][b]; + } else { + h[1][0] = H11[1][e][b]; + h[1][1] = H12[1][e][b]; + h[1][2] = H21[1][e][b]; + h[1][3] = H22[1][e][b]; + } + } + //Interpolation + h_step[0][0] = AAC_MSUB31_V3(H11[0][e+1][b], h[0][0], width); + h_step[0][1] = AAC_MSUB31_V3(H12[0][e+1][b], h[0][1], width); + h_step[0][2] = AAC_MSUB31_V3(H21[0][e+1][b], h[0][2], width); + h_step[0][3] = AAC_MSUB31_V3(H22[0][e+1][b], h[0][3], width); + if (!PS_BASELINE && ps->enable_ipdopd) { + h_step[1][0] = AAC_MSUB31_V3(H11[1][e+1][b], h[1][0], width); + h_step[1][1] = AAC_MSUB31_V3(H12[1][e+1][b], h[1][1], width); + h_step[1][2] = AAC_MSUB31_V3(H21[1][e+1][b], h[1][2], width); + h_step[1][3] = AAC_MSUB31_V3(H22[1][e+1][b], h[1][3], width); + } + ps->dsp.stereo_interpolate[!PS_BASELINE && ps->enable_ipdopd]( + l[k] + start + 1, r[k] + start + 1, + h, h_step, stop - start); + } + } +} + +int AAC_RENAME(ff_ps_apply)(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top) { - LOCAL_ALIGNED_16(float, Lbuf, [91], [32][2]); - LOCAL_ALIGNED_16(float, Rbuf, [91], [32][2]); + LOCAL_ALIGNED_16(INTFLOAT, Lbuf, [91], [32][2]); + LOCAL_ALIGNED_16(INTFLOAT, Rbuf, [91], [32][2]); const int len = 32; int is34 = ps->is34bands; @@ -762,7 +996,7 @@ int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*sizeof(ps->ap_delay[0])); hybrid_analysis(&ps->dsp, Lbuf, ps->in_buf, L, is34, len); - decorrelation(ps, Rbuf, (const float (*)[32][2]) Lbuf, is34); + decorrelation(ps, Rbuf, (const INTFLOAT (*)[32][2]) Lbuf, is34); stereo_processing(ps, Lbuf, Rbuf, is34); hybrid_synthesis(&ps->dsp, L, Lbuf, is34, len); hybrid_synthesis(&ps->dsp, R, Rbuf, is34, len); @@ -779,7 +1013,7 @@ int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float #define PS_VLC_ROW(name) \ { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) } -av_cold void ff_ps_init(void) { +av_cold void AAC_RENAME(ff_ps_init)(void) { // Syntax initialization static const struct { const void *ps_codes, *ps_bits; @@ -811,7 +1045,7 @@ av_cold void ff_ps_init(void) { ps_tableinit(); } -av_cold void ff_ps_ctx_init(PSContext *ps) +av_cold void AAC_RENAME(ff_ps_ctx_init)(PSContext *ps) { - ff_psdsp_init(&ps->dsp); + AAC_RENAME(ff_psdsp_init)(&ps->dsp); } diff --git a/libavcodec/aacps.h b/libavcodec/aacps.h index 29323ff..4703ce4 100644 --- a/libavcodec/aacps.h +++ b/libavcodec/aacps.h @@ -61,24 +61,24 @@ typedef struct PSContext { int is34bands; int is34bands_old; - DECLARE_ALIGNED(16, float, in_buf)[5][44][2]; - DECLARE_ALIGNED(16, float, delay)[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2]; - DECLARE_ALIGNED(16, float, ap_delay)[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2]; - DECLARE_ALIGNED(16, float, peak_decay_nrg)[34]; - DECLARE_ALIGNED(16, float, power_smooth)[34]; - DECLARE_ALIGNED(16, float, peak_decay_diff_smooth)[34]; - DECLARE_ALIGNED(16, float, H11)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; - DECLARE_ALIGNED(16, float, H12)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; - DECLARE_ALIGNED(16, float, H21)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; - DECLARE_ALIGNED(16, float, H22)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; + DECLARE_ALIGNED(16, INTFLOAT, in_buf)[5][44][2]; + DECLARE_ALIGNED(16, INTFLOAT, delay)[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2]; + DECLARE_ALIGNED(16, INTFLOAT, ap_delay)[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2]; + DECLARE_ALIGNED(16, INTFLOAT, peak_decay_nrg)[34]; + DECLARE_ALIGNED(16, INTFLOAT, power_smooth)[34]; + DECLARE_ALIGNED(16, INTFLOAT, peak_decay_diff_smooth)[34]; + DECLARE_ALIGNED(16, INTFLOAT, H11)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; + DECLARE_ALIGNED(16, INTFLOAT, H12)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; + DECLARE_ALIGNED(16, INTFLOAT, H21)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; + DECLARE_ALIGNED(16, INTFLOAT, H22)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; int8_t opd_hist[PS_MAX_NR_IIDICC]; int8_t ipd_hist[PS_MAX_NR_IIDICC]; PSDSPContext dsp; } PSContext; -void ff_ps_init(void); -void ff_ps_ctx_init(PSContext *ps); -int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int bits_left); -int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top); +void AAC_RENAME(ff_ps_init)(void); +void AAC_RENAME(ff_ps_ctx_init)(PSContext *ps); +int AAC_RENAME(ff_ps_read_data)(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int bits_left); +int AAC_RENAME(ff_ps_apply)(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top); #endif /* AVCODEC_PS_H */ diff --git a/libavcodec/aacps_fixed.c b/libavcodec/aacps_fixed.c new file mode 100644 index 0000000..e95ec37 --- /dev/null +++ b/libavcodec/aacps_fixed.c @@ -0,0 +1,25 @@ +/* + * MPEG-4 Parametric Stereo decoding functions + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * 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 + */ + +#define USE_FIXED 1 + +#include "aacps.c" + diff --git a/libavcodec/aacps_float.c b/libavcodec/aacps_float.c index 93a498c..73259c1 100644 --- a/libavcodec/aacps_float.c +++ b/libavcodec/aacps_float.c @@ -19,159 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34) -{ - int e, b, k; +#define USE_FIXED 0 - float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11; - float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12; - float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21; - float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22; - int8_t *opd_hist = ps->opd_hist; - int8_t *ipd_hist = ps->ipd_hist; - int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; - int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; - int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; - int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; - int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf; - int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf; - int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf; - int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf; - const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; - TABLE_CONST float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; - - //Remapping - if (ps->num_env_old) { - memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0])); - memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0])); - memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0])); - memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0])); - memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0])); - memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0])); - memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0])); - memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0])); - } - - if (is34) { - remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); - remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); - if (ps->enable_ipdopd) { - remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); - remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); - } - if (!ps->is34bands_old) { - map_val_20_to_34(H11[0][0]); - map_val_20_to_34(H11[1][0]); - map_val_20_to_34(H12[0][0]); - map_val_20_to_34(H12[1][0]); - map_val_20_to_34(H21[0][0]); - map_val_20_to_34(H21[1][0]); - map_val_20_to_34(H22[0][0]); - map_val_20_to_34(H22[1][0]); - ipdopd_reset(ipd_hist, opd_hist); - } - } else { - remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); - remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); - if (ps->enable_ipdopd) { - remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); - remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); - } - if (ps->is34bands_old) { - map_val_34_to_20(H11[0][0]); - map_val_34_to_20(H11[1][0]); - map_val_34_to_20(H12[0][0]); - map_val_34_to_20(H12[1][0]); - map_val_34_to_20(H21[0][0]); - map_val_34_to_20(H21[1][0]); - map_val_34_to_20(H22[0][0]); - map_val_34_to_20(H22[1][0]); - ipdopd_reset(ipd_hist, opd_hist); - } - } - - //Mixing - for (e = 0; e < ps->num_env; e++) { - for (b = 0; b < NR_PAR_BANDS[is34]; b++) { - float h11, h12, h21, h22; - h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0]; - h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1]; - h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2]; - h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3]; - - if (!PS_BASELINE && ps->enable_ipdopd && b < NR_IPDOPD_BANDS[is34]) { - //The spec say says to only run this smoother when enable_ipdopd - //is set but the reference decoder appears to run it constantly - float h11i, h12i, h21i, h22i; - float ipd_adj_re, ipd_adj_im; - int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b]; - int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b]; - float opd_re = pd_re_smooth[opd_idx]; - float opd_im = pd_im_smooth[opd_idx]; - float ipd_re = pd_re_smooth[ipd_idx]; - float ipd_im = pd_im_smooth[ipd_idx]; - opd_hist[b] = opd_idx & 0x3F; - ipd_hist[b] = ipd_idx & 0x3F; - - ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im; - ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im; - h11i = h11 * opd_im; - h11 = h11 * opd_re; - h12i = h12 * ipd_adj_im; - h12 = h12 * ipd_adj_re; - h21i = h21 * opd_im; - h21 = h21 * opd_re; - h22i = h22 * ipd_adj_im; - h22 = h22 * ipd_adj_re; - H11[1][e+1][b] = h11i; - H12[1][e+1][b] = h12i; - H21[1][e+1][b] = h21i; - H22[1][e+1][b] = h22i; - } - H11[0][e+1][b] = h11; - H12[0][e+1][b] = h12; - H21[0][e+1][b] = h21; - H22[0][e+1][b] = h22; - } - for (k = 0; k < NR_BANDS[is34]; k++) { - float h[2][4]; - float h_step[2][4]; - int start = ps->border_position[e]; - int stop = ps->border_position[e+1]; - float width = 1.f / (stop - start); - b = k_to_i[k]; - h[0][0] = H11[0][e][b]; - h[0][1] = H12[0][e][b]; - h[0][2] = H21[0][e][b]; - h[0][3] = H22[0][e][b]; - if (!PS_BASELINE && ps->enable_ipdopd) { - //Is this necessary? ps_04_new seems unchanged - if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) { - h[1][0] = -H11[1][e][b]; - h[1][1] = -H12[1][e][b]; - h[1][2] = -H21[1][e][b]; - h[1][3] = -H22[1][e][b]; - } else { - h[1][0] = H11[1][e][b]; - h[1][1] = H12[1][e][b]; - h[1][2] = H21[1][e][b]; - h[1][3] = H22[1][e][b]; - } - } - //Interpolation - h_step[0][0] = (H11[0][e+1][b] - h[0][0]) * width; - h_step[0][1] = (H12[0][e+1][b] - h[0][1]) * width; - h_step[0][2] = (H21[0][e+1][b] - h[0][2]) * width; - h_step[0][3] = (H22[0][e+1][b] - h[0][3]) * width; - if (!PS_BASELINE && ps->enable_ipdopd) { - h_step[1][0] = (H11[1][e+1][b] - h[1][0]) * width; - h_step[1][1] = (H12[1][e+1][b] - h[1][1]) * width; - h_step[1][2] = (H21[1][e+1][b] - h[1][2]) * width; - h_step[1][3] = (H22[1][e+1][b] - h[1][3]) * width; - } - ps->dsp.stereo_interpolate[!PS_BASELINE && ps->enable_ipdopd]( - l[k] + start + 1, r[k] + start + 1, - h, h_step, stop - start); - } - } -} +#include "aacps.c" diff --git a/libavcodec/aacpsdata.c b/libavcodec/aacpsdata.c index 7431cae..5c1a1b0 100644 --- a/libavcodec/aacpsdata.c +++ b/libavcodec/aacpsdata.c @@ -157,7 +157,7 @@ static const int8_t k_to_i_34[] = { 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }; -static const float g1_Q2[] = { - 0.0f, 0.01899487526049f, 0.0f, -0.07293139167538f, - 0.0f, 0.30596630545168f, 0.5f +static const INTFLOAT g1_Q2[] = { + Q31(0.0f), Q31(0.01899487526049f), Q31(0.0f), Q31(-0.07293139167538f), + Q31(0.0f), Q31(0.30596630545168f), Q31(0.5f) }; diff --git a/libavcodec/aacpsdsp.c b/libavcodec/aacpsdsp.c deleted file mode 100644 index 5dc1a6a..0000000 --- a/libavcodec/aacpsdsp.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2010 Alex Converse - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" -#include "libavutil/attributes.h" -#include "aacpsdsp.h" - -static void ps_add_squares_c(float *dst, const float (*src)[2], int n) -{ - int i; - for (i = 0; i < n; i++) - dst[i] += src[i][0] * src[i][0] + src[i][1] * src[i][1]; -} - -static void ps_mul_pair_single_c(float (*dst)[2], float (*src0)[2], float *src1, - int n) -{ - int i; - for (i = 0; i < n; i++) { - dst[i][0] = src0[i][0] * src1[i]; - dst[i][1] = src0[i][1] * src1[i]; - } -} - -static void ps_hybrid_analysis_c(float (*out)[2], float (*in)[2], - const float (*filter)[8][2], - int stride, int n) -{ - int i, j; - - for (i = 0; i < n; i++) { - float sum_re = filter[i][6][0] * in[6][0]; - float sum_im = filter[i][6][0] * in[6][1]; - - for (j = 0; j < 6; j++) { - float in0_re = in[j][0]; - float in0_im = in[j][1]; - float in1_re = in[12-j][0]; - float in1_im = in[12-j][1]; - sum_re += filter[i][j][0] * (in0_re + in1_re) - - filter[i][j][1] * (in0_im - in1_im); - sum_im += filter[i][j][0] * (in0_im + in1_im) + - filter[i][j][1] * (in0_re - in1_re); - } - out[i * stride][0] = sum_re; - out[i * stride][1] = sum_im; - } -} - -static void ps_hybrid_analysis_ileave_c(float (*out)[32][2], float L[2][38][64], - int i, int len) -{ - int j; - - for (; i < 64; i++) { - for (j = 0; j < len; j++) { - out[i][j][0] = L[0][j][i]; - out[i][j][1] = L[1][j][i]; - } - } -} - -static void ps_hybrid_synthesis_deint_c(float out[2][38][64], - float (*in)[32][2], - int i, int len) -{ - int n; - - for (; i < 64; i++) { - for (n = 0; n < len; n++) { - out[0][n][i] = in[i][n][0]; - out[1][n][i] = in[i][n][1]; - } - } -} - -static void ps_decorrelate_c(float (*out)[2], float (*delay)[2], - float (*ap_delay)[PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2], - const float phi_fract[2], const float (*Q_fract)[2], - const float *transient_gain, - float g_decay_slope, - int len) -{ - static const float a[] = { 0.65143905753106f, - 0.56471812200776f, - 0.48954165955695f }; - float ag[PS_AP_LINKS]; - int m, n; - - for (m = 0; m < PS_AP_LINKS; m++) - ag[m] = a[m] * g_decay_slope; - - for (n = 0; n < len; n++) { - float in_re = delay[n][0] * phi_fract[0] - delay[n][1] * phi_fract[1]; - float in_im = delay[n][0] * phi_fract[1] + delay[n][1] * phi_fract[0]; - for (m = 0; m < PS_AP_LINKS; m++) { - float a_re = ag[m] * in_re; - float a_im = ag[m] * in_im; - float link_delay_re = ap_delay[m][n+2-m][0]; - float link_delay_im = ap_delay[m][n+2-m][1]; - float fractional_delay_re = Q_fract[m][0]; - float fractional_delay_im = Q_fract[m][1]; - float apd_re = in_re; - float apd_im = in_im; - in_re = link_delay_re * fractional_delay_re - - link_delay_im * fractional_delay_im - a_re; - in_im = link_delay_re * fractional_delay_im + - link_delay_im * fractional_delay_re - a_im; - ap_delay[m][n+5][0] = apd_re + ag[m] * in_re; - ap_delay[m][n+5][1] = apd_im + ag[m] * in_im; - } - out[n][0] = transient_gain[n] * in_re; - out[n][1] = transient_gain[n] * in_im; - } -} - -static void ps_stereo_interpolate_c(float (*l)[2], float (*r)[2], - float h[2][4], float h_step[2][4], - int len) -{ - float h0 = h[0][0]; - float h1 = h[0][1]; - float h2 = h[0][2]; - float h3 = h[0][3]; - float hs0 = h_step[0][0]; - float hs1 = h_step[0][1]; - float hs2 = h_step[0][2]; - float hs3 = h_step[0][3]; - int n; - - for (n = 0; n < len; n++) { - //l is s, r is d - float l_re = l[n][0]; - float l_im = l[n][1]; - float r_re = r[n][0]; - float r_im = r[n][1]; - h0 += hs0; - h1 += hs1; - h2 += hs2; - h3 += hs3; - l[n][0] = h0 * l_re + h2 * r_re; - l[n][1] = h0 * l_im + h2 * r_im; - r[n][0] = h1 * l_re + h3 * r_re; - r[n][1] = h1 * l_im + h3 * r_im; - } -} - -static void ps_stereo_interpolate_ipdopd_c(float (*l)[2], float (*r)[2], - float h[2][4], float h_step[2][4], - int len) -{ - float h00 = h[0][0], h10 = h[1][0]; - float h01 = h[0][1], h11 = h[1][1]; - float h02 = h[0][2], h12 = h[1][2]; - float h03 = h[0][3], h13 = h[1][3]; - float hs00 = h_step[0][0], hs10 = h_step[1][0]; - float hs01 = h_step[0][1], hs11 = h_step[1][1]; - float hs02 = h_step[0][2], hs12 = h_step[1][2]; - float hs03 = h_step[0][3], hs13 = h_step[1][3]; - int n; - - for (n = 0; n < len; n++) { - //l is s, r is d - float l_re = l[n][0]; - float l_im = l[n][1]; - float r_re = r[n][0]; - float r_im = r[n][1]; - h00 += hs00; - h01 += hs01; - h02 += hs02; - h03 += hs03; - h10 += hs10; - h11 += hs11; - h12 += hs12; - h13 += hs13; - - l[n][0] = h00 * l_re + h02 * r_re - h10 * l_im - h12 * r_im; - l[n][1] = h00 * l_im + h02 * r_im + h10 * l_re + h12 * r_re; - r[n][0] = h01 * l_re + h03 * r_re - h11 * l_im - h13 * r_im; - r[n][1] = h01 * l_im + h03 * r_im + h11 * l_re + h13 * r_re; - } -} - -av_cold void ff_psdsp_init(PSDSPContext *s) -{ - s->add_squares = ps_add_squares_c; - s->mul_pair_single = ps_mul_pair_single_c; - s->hybrid_analysis = ps_hybrid_analysis_c; - s->hybrid_analysis_ileave = ps_hybrid_analysis_ileave_c; - s->hybrid_synthesis_deint = ps_hybrid_synthesis_deint_c; - s->decorrelate = ps_decorrelate_c; - s->stereo_interpolate[0] = ps_stereo_interpolate_c; - s->stereo_interpolate[1] = ps_stereo_interpolate_ipdopd_c; - - if (ARCH_ARM) - ff_psdsp_init_arm(s); - if (ARCH_MIPS) - ff_psdsp_init_mips(s); -} diff --git a/libavcodec/aacpsdsp.h b/libavcodec/aacpsdsp.h index 0ef3023..9e3c5aa 100644 --- a/libavcodec/aacpsdsp.h +++ b/libavcodec/aacpsdsp.h @@ -21,33 +21,35 @@ #ifndef LIBAVCODEC_AACPSDSP_H #define LIBAVCODEC_AACPSDSP_H +#include "aac_defines.h" + #define PS_QMF_TIME_SLOTS 32 #define PS_AP_LINKS 3 #define PS_MAX_AP_DELAY 5 typedef struct PSDSPContext { - void (*add_squares)(float *dst, const float (*src)[2], int n); - void (*mul_pair_single)(float (*dst)[2], float (*src0)[2], float *src1, + void (*add_squares)(INTFLOAT *dst, const INTFLOAT (*src)[2], int n); + void (*mul_pair_single)(INTFLOAT (*dst)[2], INTFLOAT (*src0)[2], INTFLOAT *src1, int n); - void (*hybrid_analysis)(float (*out)[2], float (*in)[2], - const float (*filter)[8][2], + void (*hybrid_analysis)(INTFLOAT (*out)[2], INTFLOAT (*in)[2], + const INTFLOAT (*filter)[8][2], int stride, int n); - void (*hybrid_analysis_ileave)(float (*out)[32][2], float L[2][38][64], + void (*hybrid_analysis_ileave)(INTFLOAT (*out)[32][2], INTFLOAT L[2][38][64], int i, int len); - void (*hybrid_synthesis_deint)(float out[2][38][64], float (*in)[32][2], + void (*hybrid_synthesis_deint)(INTFLOAT out[2][38][64], INTFLOAT (*in)[32][2], int i, int len); - void (*decorrelate)(float (*out)[2], float (*delay)[2], - float (*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2], - const float phi_fract[2], const float (*Q_fract)[2], - const float *transient_gain, - float g_decay_slope, + void (*decorrelate)(INTFLOAT (*out)[2], INTFLOAT (*delay)[2], + INTFLOAT (*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2], + const INTFLOAT phi_fract[2], const INTFLOAT (*Q_fract)[2], + const INTFLOAT *transient_gain, + INTFLOAT g_decay_slope, int len); - void (*stereo_interpolate[2])(float (*l)[2], float (*r)[2], - float h[2][4], float h_step[2][4], + void (*stereo_interpolate[2])(INTFLOAT (*l)[2], INTFLOAT (*r)[2], + INTFLOAT h[2][4], INTFLOAT h_step[2][4], int len); } PSDSPContext; -void ff_psdsp_init(PSDSPContext *s); +void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s); void ff_psdsp_init_arm(PSDSPContext *s); void ff_psdsp_init_mips(PSDSPContext *s); diff --git a/libavcodec/aacpsdsp_fixed.c b/libavcodec/aacpsdsp_fixed.c new file mode 100644 index 0000000..4852c5e --- /dev/null +++ b/libavcodec/aacpsdsp_fixed.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * 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 + */ + +#define USE_FIXED 1 + +#include "config.h" +#include "libavutil/attributes.h" +#include "aacpsdsp.h" + +#include "aacpsdsp_template.c" diff --git a/libavcodec/aacpsdsp_float.c b/libavcodec/aacpsdsp_float.c new file mode 100644 index 0000000..4a29612 --- /dev/null +++ b/libavcodec/aacpsdsp_float.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * 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 + */ + +#define USE_FIXED 0 + +#include "config.h" +#include "libavutil/attributes.h" +#include "aacpsdsp.h" + +#include "aacpsdsp_template.c" diff --git a/libavcodec/aacpsdsp_template.c b/libavcodec/aacpsdsp_template.c new file mode 100644 index 0000000..66d5418 --- /dev/null +++ b/libavcodec/aacpsdsp_template.c @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include + +static void ps_add_squares_c(INTFLOAT *dst, const INTFLOAT (*src)[2], int n) +{ + int i; + for (i = 0; i < n; i++) + dst[i] += AAC_MADD28(src[i][0], src[i][0], src[i][1], src[i][1]); +} + +static void ps_mul_pair_single_c(INTFLOAT (*dst)[2], INTFLOAT (*src0)[2], INTFLOAT *src1, + int n) +{ + int i; + for (i = 0; i < n; i++) { + dst[i][0] = AAC_MUL16(src0[i][0], src1[i]); + dst[i][1] = AAC_MUL16(src0[i][1], src1[i]); + } +} + +static void ps_hybrid_analysis_c(INTFLOAT (*out)[2], INTFLOAT (*in)[2], + const INTFLOAT (*filter)[8][2], + int stride, int n) +{ + int i, j; + + for (i = 0; i < n; i++) { + INT64FLOAT sum_re = (INT64FLOAT)filter[i][6][0] * in[6][0]; + INT64FLOAT sum_im = (INT64FLOAT)filter[i][6][0] * in[6][1]; + + for (j = 0; j < 6; j++) { + INTFLOAT in0_re = in[j][0]; + INTFLOAT in0_im = in[j][1]; + INTFLOAT in1_re = in[12-j][0]; + INTFLOAT in1_im = in[12-j][1]; + sum_re += (INT64FLOAT)filter[i][j][0] * (in0_re + in1_re) - + (INT64FLOAT)filter[i][j][1] * (in0_im - in1_im); + sum_im += (INT64FLOAT)filter[i][j][0] * (in0_im + in1_im) + + (INT64FLOAT)filter[i][j][1] * (in0_re - in1_re); + } +#if USE_FIXED + out[i * stride][0] = (int)((sum_re + 0x40000000) >> 31); + out[i * stride][1] = (int)((sum_im + 0x40000000) >> 31); +#else + out[i * stride][0] = sum_re; + out[i * stride][1] = sum_im; +#endif /* USE_FIXED */ + } +} +static void ps_hybrid_analysis_ileave_c(INTFLOAT (*out)[32][2], INTFLOAT L[2][38][64], + int i, int len) +{ + int j; + + for (; i < 64; i++) { + for (j = 0; j < len; j++) { + out[i][j][0] = L[0][j][i]; + out[i][j][1] = L[1][j][i]; + } + } +} + +static void ps_hybrid_synthesis_deint_c(INTFLOAT out[2][38][64], + INTFLOAT (*in)[32][2], + int i, int len) +{ + int n; + + for (; i < 64; i++) { + for (n = 0; n < len; n++) { + out[0][n][i] = in[i][n][0]; + out[1][n][i] = in[i][n][1]; + } + } +} + +static void ps_decorrelate_c(INTFLOAT (*out)[2], INTFLOAT (*delay)[2], + INTFLOAT (*ap_delay)[PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2], + const INTFLOAT phi_fract[2], const INTFLOAT (*Q_fract)[2], + const INTFLOAT *transient_gain, + INTFLOAT g_decay_slope, + int len) +{ + static const INTFLOAT a[] = { Q31(0.65143905753106f), + Q31(0.56471812200776f), + Q31(0.48954165955695f) }; + INTFLOAT ag[PS_AP_LINKS]; + int m, n; + + for (m = 0; m < PS_AP_LINKS; m++) + ag[m] = AAC_MUL30(a[m], g_decay_slope); + + for (n = 0; n < len; n++) { + INTFLOAT in_re = AAC_MSUB30(delay[n][0], phi_fract[0], delay[n][1], phi_fract[1]); + INTFLOAT in_im = AAC_MADD30(delay[n][0], phi_fract[1], delay[n][1], phi_fract[0]); + for (m = 0; m < PS_AP_LINKS; m++) { + INTFLOAT a_re = AAC_MUL31(ag[m], in_re); + INTFLOAT a_im = AAC_MUL31(ag[m], in_im); + INTFLOAT link_delay_re = ap_delay[m][n+2-m][0]; + INTFLOAT link_delay_im = ap_delay[m][n+2-m][1]; + INTFLOAT fractional_delay_re = Q_fract[m][0]; + INTFLOAT fractional_delay_im = Q_fract[m][1]; + INTFLOAT apd_re = in_re; + INTFLOAT apd_im = in_im; + in_re = AAC_MSUB30(link_delay_re, fractional_delay_re, + link_delay_im, fractional_delay_im); + in_re -= a_re; + in_im = AAC_MADD30(link_delay_re, fractional_delay_im, + link_delay_im, fractional_delay_re); + in_im -= a_im; + ap_delay[m][n+5][0] = apd_re + AAC_MUL31(ag[m], in_re); + ap_delay[m][n+5][1] = apd_im + AAC_MUL31(ag[m], in_im); + } + out[n][0] = AAC_MUL16(transient_gain[n], in_re); + out[n][1] = AAC_MUL16(transient_gain[n], in_im); + } +} + +static void ps_stereo_interpolate_c(INTFLOAT (*l)[2], INTFLOAT (*r)[2], + INTFLOAT h[2][4], INTFLOAT h_step[2][4], + int len) +{ + INTFLOAT h0 = h[0][0]; + INTFLOAT h1 = h[0][1]; + INTFLOAT h2 = h[0][2]; + INTFLOAT h3 = h[0][3]; + INTFLOAT hs0 = h_step[0][0]; + INTFLOAT hs1 = h_step[0][1]; + INTFLOAT hs2 = h_step[0][2]; + INTFLOAT hs3 = h_step[0][3]; + int n; + + for (n = 0; n < len; n++) { + //l is s, r is d + INTFLOAT l_re = l[n][0]; + INTFLOAT l_im = l[n][1]; + INTFLOAT r_re = r[n][0]; + INTFLOAT r_im = r[n][1]; + h0 += hs0; + h1 += hs1; + h2 += hs2; + h3 += hs3; + l[n][0] = AAC_MADD30(h0, l_re, h2, r_re); + l[n][1] = AAC_MADD30(h0, l_im, h2, r_im); + r[n][0] = AAC_MADD30(h1, l_re, h3, r_re); + r[n][1] = AAC_MADD30(h1, l_im, h3, r_im); + } +} + +static void ps_stereo_interpolate_ipdopd_c(INTFLOAT (*l)[2], INTFLOAT (*r)[2], + INTFLOAT h[2][4], INTFLOAT h_step[2][4], + int len) +{ + INTFLOAT h00 = h[0][0], h10 = h[1][0]; + INTFLOAT h01 = h[0][1], h11 = h[1][1]; + INTFLOAT h02 = h[0][2], h12 = h[1][2]; + INTFLOAT h03 = h[0][3], h13 = h[1][3]; + INTFLOAT hs00 = h_step[0][0], hs10 = h_step[1][0]; + INTFLOAT hs01 = h_step[0][1], hs11 = h_step[1][1]; + INTFLOAT hs02 = h_step[0][2], hs12 = h_step[1][2]; + INTFLOAT hs03 = h_step[0][3], hs13 = h_step[1][3]; + int n; + + for (n = 0; n < len; n++) { + //l is s, r is d + INTFLOAT l_re = l[n][0]; + INTFLOAT l_im = l[n][1]; + INTFLOAT r_re = r[n][0]; + INTFLOAT r_im = r[n][1]; + h00 += hs00; + h01 += hs01; + h02 += hs02; + h03 += hs03; + h10 += hs10; + h11 += hs11; + h12 += hs12; + h13 += hs13; + + l[n][0] = AAC_MSUB30_V8(h00, l_re, h02, r_re, h10, l_im, h12, r_im); + l[n][1] = AAC_MADD30_V8(h00, l_im, h02, r_im, h10, l_re, h12, r_re); + r[n][0] = AAC_MSUB30_V8(h01, l_re, h03, r_re, h11, l_im, h13, r_im); + r[n][1] = AAC_MADD30_V8(h01, l_im, h03, r_im, h11, l_re, h13, r_re); + } +} + +av_cold void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s) +{ + s->add_squares = ps_add_squares_c; + s->mul_pair_single = ps_mul_pair_single_c; + s->hybrid_analysis = ps_hybrid_analysis_c; + s->hybrid_analysis_ileave = ps_hybrid_analysis_ileave_c; + s->hybrid_synthesis_deint = ps_hybrid_synthesis_deint_c; + s->decorrelate = ps_decorrelate_c; + s->stereo_interpolate[0] = ps_stereo_interpolate_c; + s->stereo_interpolate[1] = ps_stereo_interpolate_ipdopd_c; + +#if !USE_FIXED + if (ARCH_ARM) + ff_psdsp_init_arm(s); + if (ARCH_MIPS) + ff_psdsp_init_mips(s); +#endif /* !USE_FIXED */ +} -- 1.8.2.1 From david at davidfavor.com Fri Aug 1 17:03:44 2014 From: david at davidfavor.com (David Favor) Date: Fri, 01 Aug 2014 10:03:44 -0500 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <53D5895B.2090102@googlemail.com> References: <53D5895B.2090102@googlemail.com> Message-ID: <53DBAC50.7060407@davidfavor.com> Andreas Cadhalpun wrote: > Hi all, > > some of you may have noticed a weird ffmpeg package in the NEW queue[1]. > Let me explain: ... ... ... and make kittens cry... ... ... ... Primary reason for Debian kittens crying right now... is ffmpeg being missing... From david at davidfavor.com Fri Aug 1 17:21:17 2014 From: david at davidfavor.com (David Favor) Date: Fri, 01 Aug 2014 10:21:17 -0500 Subject: [FFmpeg-devel] Mac/OSX question about clang + avfoundation + indev support Message-ID: <53DBB06D.9030307@davidfavor.com> Summary: No clang or gcc invocation incantation seems to produce avfoundation indev support. Need someone smarter than me to suggest how I can debug this, to produce a Portfile fix for MacPorts. Thanks. _______ Yesterday I fired up ffmpeg to capture a MacBook Pro iSight Webcam stream. Sounds easy... Ugh... Not so... Here's the problem... (All examples using latest git pull.) David-Favor-iMac# git describe n2.0-10562-g229a1e8 First... let's see if configure knows enough to ferret out avfoundation... David-Favor-iMac# ./configure --list-indevs alsa iec61883 pulse avfoundation jack qtkit bktr lavfi sndio dshow libcdio v4l2 dv1394 libdc1394 vfwcap fbdev openal x11grab gdigrab oss Great... configure discovers both avfoundation + old deprecated qtkit... So far so good... When configure runs... still looks good... Enabled indevs: avfoundation lavfi qtkit And compilation passes... ... CC libavdevice/avfoundation.o CC libavdevice/lavfi.o CC libavdevice/qtkit.o ... Adding or leaving out specific indev enabling has no effect on final executable... --enable-indev=qtkit --enable-indev=avfoundation The only effect is if clang is used, qtkit indev available + if gcc-4.8.2 used, then qtkit indev is missing. Neither clang or gcc-4.8.2 produces avfoundation indev. Compile system is latest OSX + XCode + MacPorts. David-Favor-iMac> xcodebuild -version Xcode 5.1.1 Build version 5B1008 David-Favor-iMac> clang --version clang version 3.4.2 (tags/RELEASE_34/dot2-final) Target: x86_64-apple-darwin13.3.0 Thread model: posix David-Favor-iMac> gcc --version gcc (MacPorts gcc48 4.8.2_2) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. _______ David-Favor-iMac# ffmpeg -devices ffmpeg version 2.3.1-2014-08-01-65165-g229a1e8 Copyright (c) 2000-2014 the FFmpeg developers built on Aug 1 2014 10:13:00 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) configuration: --cc=/usr/bin/clang --prefix=/david-favor-tools/osx-10.9 --mandir=/david-favor-tools/osx-10.9/share/man --enable-gpl --enable-yasm --arch=x86_64 --enable-version3 --enable-pthreads --enable-shared --disable-static --disable-debug --extra-cflags='-I/david-favor-tools/osx-10.9/include -I/opt/local/include -I/usr/local/include -I/usr/include' --extra-ldflags='-Wl,-rpath,/david-favor-tools/osx-10.9/lib -Wl,-rpath,/opt/local/lib -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/lib -L/david-favor-tools/osx-10.9/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib' --enable-ffplay --enable-ffprobe --enable-ffserver --enable-indev=qtkit --enable-indev=avfoundation --enable-runtime-cpudetect --enable-nonfree --enable-zlib --enable-bzlib --enable-openssl --enable-gnutls --enable-swscale --enable-avfilter --enable-avresample --enable-postproc --enable-vda --enable-libfribidi --enable-libmp3lame --enable-libfaac --enable-libfdk_aac --enable-libvpx --enable-libtheora --enable-libvorbis --enable-libxvid --enable-libopus --enable-libopenjpeg --enable-libschroedinger --enable-libspeex --enable-libbluray --enable-libx264 --enable-libx265 --enable-postproc --enable-frei0r --enable-libopencore-amrnb --enable-fontconfig --enable-libfreetype --enable-libmodplug --enable-libass libavutil 52. 94.100 / 52. 94.100 libavcodec 55. 71.100 / 55. 71.100 libavformat 55. 50.100 / 55. 50.100 libavdevice 55. 13.102 / 55. 13.102 libavfilter 4. 11.102 / 4. 11.102 libavresample 1. 3. 0 / 1. 3. 0 libswscale 2. 6.100 / 2. 6.100 libswresample 0. 19.100 / 0. 19.100 libpostproc 52. 3.100 / 52. 3.100 Devices: D. = Demuxing supported .E = Muxing supported -- D lavfi Libavfilter virtual input device D qtkit QTKit input device E sdl SDL output device E xv XV (XVideo) output device From david at davidfavor.com Fri Aug 1 17:39:37 2014 From: david at davidfavor.com (David Favor) Date: Fri, 01 Aug 2014 10:39:37 -0500 Subject: [FFmpeg-devel] Mac/OSX question about clang + avfoundation + indev support In-Reply-To: <53DBB06D.9030307@davidfavor.com> References: <53DBB06D.9030307@davidfavor.com> Message-ID: <53DBB4B9.1020605@davidfavor.com> Additional information related to my first message. Building with gcc produces no trace of avfoundation support in full help. Building with clang shows... AVFoundation input device AVOptions: -list_devices .D...... list available devices (from 0 to 1) (default 0) true .D...... false .D...... -video_device_index .D...... select video device by index for devices with same name (starts at 0) (from -1 to INT_MAX) (default -1) -pixel_format .D...... set pixel format (default yuv420p) So many avfoundation is referenced through some sort of Libavfilter incantation. https://trac.ffmpeg.org/wiki/Capture/Webcam suggest no + maybe the docs are just missing some vital bit of information to use avfoundation. From michaelni at gmx.at Fri Aug 1 18:05:26 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 1 Aug 2014 18:05:26 +0200 Subject: [FFmpeg-devel] [PATCH] h264_mp4toannexb_bsf: rename first_idr to new_idr In-Reply-To: <1406899890-10706-1-git-send-email-benoit.fouet@free.fr> References: <1406899890-10706-1-git-send-email-benoit.fouet@free.fr> Message-ID: <20140801160526.GM4649@nb4> On Fri, Aug 01, 2014 at 03:31:30PM +0200, Benoit Fouet wrote: > --- > libavcodec/h264_mp4toannexb_bsf.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The greatest way to live with honor in this world is to be what we pretend to be. -- Socrates -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From danieloberhoff at gmail.com Fri Aug 1 18:47:38 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Fri, 1 Aug 2014 18:47:38 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> <6A121A20-D5E4-4481-9737-4CA601560451@googlemail.com> Message-ID: <6A11773B-CF55-4FA2-BB5E-B1C0EC728A2D@googlemail.com> Von meinem iPhone gesendet > Am 01.08.2014 um 14:45 schrieb Carl Eugen Hoyos : > > Daniel Oberhoff gmail.com> writes: > >> And how about that test/data/fate/filter-pixfmts-rectification.rep >> file? > > Imo, please send a patch without fate test first, > this can still be done. > Kinda already made one I think, just not sure what to commit :) > Did you already explain if / how this filter is > different from / better than the vignette filter? Its completely differen. Vignette modulates brightness, this one geometry, but I will mention it. > Carl Eugen > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From Reimar.Doeffinger at gmx.de Fri Aug 1 21:08:50 2014 From: Reimar.Doeffinger at gmx.de (Reimar =?iso-8859-1?Q?D=F6ffinger?=) Date: Fri, 1 Aug 2014 21:08:50 +0200 Subject: [FFmpeg-devel] [PATCH 02/14] libavcodec: Implementation of AAC_fixed_decoder (LC-module) [2/5] In-Reply-To: <1406901200-4862-3-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> <1406901200-4862-3-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <20140801190850.GA4224@reimardoeffinger.de> On Fri, Aug 01, 2014 at 03:53:08PM +0200, Nedeljko Babic wrote: > +#if !defined(_AAC_FLOAT_EMU_) > +#define _AAC_FLOAT_EMU_ That is not out usual style 1) We use #ifndef 2) Identifiers starting with _ + upper case letter are reserved by POSIX and never should be used 3) The naming convention is like e.g. AVCODEC_AAC_FLOAT_EMU_H > +static const uint8_t ff_log2_tab[256] = { One with the same name exists in libavutil, I am not sure that is a good idea. > +static int divTable[128] = { These and the following ones seem to lack "const". > + Q30(0.9999999995), Q30(0.9922480620), Q30(0.9846153846), Q30(0.9770992366), I'm a bit unsure btw. if this makes more sense than coding the converted numbers. It feels like it combines the disadvantages, since it neither avoids code duplication with the float tables nor does it compiler/architecture dependence completely (I think). > +static av_always_inline av_const int av_log2_c_emu(unsigned int v) Since this duplicates existing code it definitely should have a comment. Also if performance is the reason there is a question whether we should at least internally have libavutil provide it instead, to at least avoid duplication. Though to be honest on most architectures the solution to it being slow should be to provide a ASM version. > +static av_always_inline aac_float_t int2float(const int x, const int exp) Those "const" are kind of pointless IMHO. > + aac_float_t ret; > + int nz; > + > + if (x == 0) > + { > + ret.mant = 0; > + ret.expo = 0; > + } > + else > + { > + ret.expo = exp; > + ret.mant = x; > + nz = 29 - av_log2_c_emu(FFABS(ret.mant)); > + ret.mant <<= nz; > + ret.expo -= nz; nz is only used here, so it should be declared here. Also int nz = 29 - av_log2_c_emu(FFABS(x)); ret.expo = exp - nz; ret.mant = x << nz; seems more readable to me. > +static av_always_inline aac_float_t float_add(aac_float_t a, aac_float_t b) > +{ > + int diff, nz; > + int expa = a.expo; > + int expb = b.expo; > + int manta = a.mant; > + int mantb = b.mant; I don't think those local copies are a good idea, at least for readability. > + if (manta == 0) > + return b; > + > + if (mantb == 0) > + return a; > + > + diff = expa - expb; > + if (diff < 0) // expa < expb > + { > + diff = -diff; > + if (diff >= 31) > + manta = 0; > + else if (diff != 0) > + manta >>= diff; > + expa = expb; > + } > + else // expa >= expb > + { > + if (diff >= 31) > + mantb = 0; > + else if (diff != 0) > + mantb >>= diff; > + } > + > + manta = manta + mantb; > + if (manta == 0) > + expa = 0; > + else > + { > + nz = 30 - av_log2_c_emu(FFABS(manta)); > + manta <<= nz; > + manta >>= 1; > + expa -= (nz-1); > + } I think this needs a good thinking over. If diff was calculated first, the >= 31/ <= -31 checks could be combined with the checks for 0. In the upper if, diff can obviously not be 0, also the != 0 check can certainly only make performance worse. For all functions, I think there should be a look at what rounding mode they end up using in the end and document that. This one looks like round to 0. > +static av_always_inline aac_float_t float_sub(aac_float_t a, aac_float_t b) Why would this need a whole separate implementation instead of changing the sign of b and calling add? > +static av_always_inline aac_float_t float_mul(aac_float_t a, aac_float_t b) > +{ > + aac_float_t res; > + int mant; > + int expa = a.expo; > + int expb = b.expo; > + long long accu; > + > + expa = expa + expb; > + accu = (long long)a.mant * b.mant; I'd suggest using types like int64_t. > + mant = (int)((accu + 0x20000000) >> 30); This suddenly seems to use round-to-nearest-away as rounding mode/ > + if (mant == 0) > + expa = 0; > + else if (mant < 536870912 && mant > -536870912) > + { These constants would be vastly more readable in hex. > + mant <<= 1; > + expa = expa - 1; expa--; > + if (mantb != 0) > + { > + iB = float_recip(b); > + // newton iteration to double precision > + tmp = float_sub(FLOAT_1, float_mul(b, iB)); > + iB = float_add(iB, float_mul(iB, tmp)); > + res = float_mul(a, iB); > + } > + else > + { > + res.mant = 1; > + res.expo = 2147483647; Hexadecimal would be nicer. Also, this seems to be the only function so far that handles infinity correctly. I have some doubts of the value of that, as long as it is the only one. If there's a particular reason why it only needs to be supported here, that should be documented. > +static av_always_inline int float_gt(aac_float_t a, aac_float_t b) > +{ > + int expa = a.expo; > + int expb = b.expo; > + int manta = a.mant; > + int mantb = b.mant; > + > + if (manta == 0) > + expa = 0x80000000; > + > + if (mantb == 0) > + expb = 0x80000000; > + > + if (expa > expb) > + return 1; > + else if (expa < expb) > + return 0; > + else // expa == expb > + { > + if (manta > mantb) > + return 1; > + else > + return 0; > + } Does this actually work? The expa/expb assignment seems to invoke undefined behaviour by itself, but then it also seems to just not handle negative numbers, at least not if the exponent differs?!? I decided to rather skip reviewing the rest. > +++ b/libavcodec/float_emu.h That seems like the same file once more. > +++ b/libavcodec/float_emu_tab.c And these tables seem familiar, too. From Reimar.Doeffinger at gmx.de Fri Aug 1 21:15:20 2014 From: Reimar.Doeffinger at gmx.de (Reimar =?iso-8859-1?Q?D=F6ffinger?=) Date: Fri, 1 Aug 2014 21:15:20 +0200 Subject: [FFmpeg-devel] [PATCH 06/14] libavcodec: Implementation of AAC_fixed_decoder (SBR-module) [1/4] In-Reply-To: <1406901200-4862-7-git-send-email-nedeljko.babic@imgtec.com> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> <1406901200-4862-7-git-send-email-nedeljko.babic@imgtec.com> Message-ID: <20140801191520.GB4224@reimardoeffinger.de> On Fri, Aug 01, 2014 at 03:53:12PM +0200, Nedeljko Babic wrote: > From: Djordje Pesut > > Move the existing code to a new template file. If code was only moved (I have not checked), I don't think adding your copyright is appropriate. From michaelni at gmx.at Fri Aug 1 22:29:25 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 1 Aug 2014 22:29:25 +0200 Subject: [FFmpeg-devel] [PATCH] avformat/util: change av_find_default_stream_index() to use a score based system Message-ID: <1406924965-2288-1-git-send-email-michaelni@gmx.at> Disfavor video streams with unknown resolution and no packets Fixes seeking in audio-only-speex.flv Signed-off-by: Michael Niedermayer --- libavformat/utils.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 4cfebf2..6d94672 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1531,23 +1531,31 @@ static void flush_packet_queue(AVFormatContext *s) int av_find_default_stream_index(AVFormatContext *s) { - int first_audio_index = -1; int i; AVStream *st; + int best_stream = 0; + int best_score = -1; if (s->nb_streams <= 0) return -1; for (i = 0; i < s->nb_streams; i++) { + int score = 0; st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && !(st->disposition & AV_DISPOSITION_ATTACHED_PIC)) { - return i; + score += 100; + if (!st->codec->width && !st->codec->height && !st->codec_info_nb_frames) + score -= 75; + } + if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) + score += 50; + + if (score > best_score) { + best_score = score; + best_stream = i; } - if (first_audio_index < 0 && - st->codec->codec_type == AVMEDIA_TYPE_AUDIO) - first_audio_index = i; } - return first_audio_index >= 0 ? first_audio_index : 0; + return best_stream; } /** Flush the frame reader. */ -- 1.7.9.5 From tempn at mi.rr.com Sat Aug 2 02:37:27 2014 From: tempn at mi.rr.com (compn) Date: Fri, 1 Aug 2014 20:37:27 -0400 Subject: [FFmpeg-devel] [PATCH] fix tls/tcp protocol after a 302 move in https Message-ID: <20140801203727.00004837@mi.rr.com> patch from https://trac.ffmpeg.org/ticket/3824 -compn -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: patch.txt URL: From michaelni at gmx.at Sat Aug 2 02:57:10 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 02:57:10 +0200 Subject: [FFmpeg-devel] [PATCH] fix tls/tcp protocol after a 302 move in https In-Reply-To: <20140801203727.00004837@mi.rr.com> References: <20140801203727.00004837@mi.rr.com> Message-ID: <20140802005710.GN4649@nb4> On Fri, Aug 01, 2014 at 08:37:27PM -0400, compn wrote: > patch from https://trac.ffmpeg.org/ticket/3824 > > -compn > diff --git a/libavformat/http.c b/libavformat/http.c > index 33585b0..3dffaee 100644 > --- a/libavformat/http.c > +++ b/libavformat/http.c > @@ -229,6 +229,7 @@ redo: > memset(&s->auth_state, 0, sizeof(s->auth_state)); > attempts = 0; > location_changed = 0; > + lower_proto = "tcp"; > goto redo; > } > return 0; probably ok, iam not maintainer of http.c though who is the author of this change though (as you write "patch from") ? if its not you, please set the author of the commit correctly [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Complexity theory is the science of finding the exact solution to an approximation. Benchmarking OTOH is finding an approximation of the exact -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From protogonoi at gmail.com Sat Aug 2 04:01:37 2014 From: protogonoi at gmail.com (Matt Oliver) Date: Sat, 2 Aug 2014 12:01:37 +1000 Subject: [FFmpeg-devel] [PATCH] msvc: fix implicitly declared read/close. Message-ID: MSVC/ICL does not have unistd.h as standard and instead declares read/close functions in io.h. This is currently handled in some files but not in a couple. Adding an include for io.h where needed adds the correct declarations. -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-msvc-fix-implicitly-declared-read-close.patch Type: application/octet-stream Size: 1258 bytes Desc: not available URL: From linzhenan at pku.edu.cn Sat Aug 2 07:37:10 2014 From: linzhenan at pku.edu.cn (Zhenan Lin) Date: Sat, 2 Aug 2014 13:37:10 +0800 Subject: [FFmpeg-devel] HEVC SIMD Optimization on PowerPC Message-ID: <002801cfae13$cea3b2c0$6beb1840$@pku.edu.cn> Hi, all, Our team plans to contribute SIMD optimization on PowerPC for HEVC Encoder or Decoder in FFmpeg. Before it, we'd like to know if there has been related works (completed or in progress) and if this optimization is in demand. Thanks! Zhenan Lin Institute of Computer Science and Technology Peking University From michaelni at gmx.at Sat Aug 2 12:49:52 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 12:49:52 +0200 Subject: [FFmpeg-devel] [PATCH 3/4] ffmpeg: use av_buffersrc_close(). In-Reply-To: <1406756689-27697-3-git-send-email-george@nsup.org> References: <1406756689-27697-1-git-send-email-george@nsup.org> <1406756689-27697-3-git-send-email-george@nsup.org> Message-ID: <20140802104952.GO4649@nb4> On Wed, Jul 30, 2014 at 11:44:48PM +0200, Nicolas George wrote: > Signed-off-by: Nicolas George > --- > ffmpeg.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Asymptotically faster algorithms should always be preferred if you have asymptotical amounts of data -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sat Aug 2 13:00:13 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 13:00:13 +0200 Subject: [FFmpeg-devel] [PATCH 2/4] lavfi/buffersrc: add add av_buffersrc_close(). In-Reply-To: <1406756689-27697-2-git-send-email-george@nsup.org> References: <1406756689-27697-1-git-send-email-george@nsup.org> <1406756689-27697-2-git-send-email-george@nsup.org> Message-ID: <20140802110013.GP4649@nb4> On Wed, Jul 30, 2014 at 11:44:47PM +0200, Nicolas George wrote: > Also deprecate adding a NULL frame to mark EOF. > > TODO APIchanges entry, version bump. > > Signed-off-by: Nicolas George > --- > libavfilter/buffersrc.c | 40 ++++++++++++++++++++++++++++++---------- > libavfilter/buffersrc.h | 15 +++++++++++++++ > 2 files changed, 45 insertions(+), 10 deletions(-) > > diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c > index 27d3db0..6d71587 100644 > --- a/libavfilter/buffersrc.c > +++ b/libavfilter/buffersrc.c > @@ -63,6 +63,7 @@ typedef struct BufferSourceContext { > char *channel_layout_str; > > int eof; > + int64_t eof_pts; > } BufferSourceContext; > > #define CHECK_VIDEO_PARAM_CHANGE(s, c, width, height, format)\ > @@ -77,6 +78,27 @@ typedef struct BufferSourceContext { > return AVERROR(EINVAL);\ > } > > +static int push_if_flag(AVFilterContext *ctx, int flags) > +{ > + return (flags & AV_BUFFERSRC_FLAG_PUSH) ? > + ctx->output_pads[0].request_frame(ctx->outputs[0]) : 0; > +} > + > +int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, int flags) > +{ > + BufferSourceContext *s = ctx->priv; > + > + if (pts == AV_NOPTS_VALUE) { > + av_log(ctx, AV_LOG_WARNING, "No EOF timestamp\n"); > + /* FIXME use duration for audio */ > + pts = av_rescale_q(ctx->outputs[0]->current_pts, > + AV_TIME_BASE_Q, ctx->outputs[0]->time_base) + 1; > + } > + s->eof_pts = pts; > + s->eof = 1; > + return push_if_flag(ctx, flags); > +} > + > int attribute_align_arg av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame) > { > return av_buffersrc_add_frame_flags(ctx, (AVFrame *)frame, > @@ -125,8 +147,7 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx, > s->nb_failed_requests = 0; > > if (!frame) { > - s->eof = 1; > - return 0; > + return av_buffersrc_close(ctx, AV_NOPTS_VALUE, flags); > } else if (s->eof) > return AVERROR(EINVAL); > > @@ -177,11 +198,7 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx, > return ret; > } > > - if ((flags & AV_BUFFERSRC_FLAG_PUSH)) > - if ((ret = ctx->output_pads[0].request_frame(ctx->outputs[0])) < 0) > - return ret; > - > - return 0; > + return push_if_flag(ctx, flags); > } some of this patch seems to be factorizing code, other add fuctionality like ff_filter_link_close() all LGTM i think but maybe should be split [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From tempn at mi.rr.com Sat Aug 2 13:18:22 2014 From: tempn at mi.rr.com (compn) Date: Sat, 2 Aug 2014 07:18:22 -0400 Subject: [FFmpeg-devel] HEVC SIMD Optimization on PowerPC In-Reply-To: <002801cfae13$cea3b2c0$6beb1840$@pku.edu.cn> References: <002801cfae13$cea3b2c0$6beb1840$@pku.edu.cn> Message-ID: <20140802071822.0000323b@mi.rr.com> On Sat, 2 Aug 2014 13:37:10 +0800 "Zhenan Lin" wrote: > Hi, all, > > > > Our team plans to contribute SIMD optimization on PowerPC for HEVC i thought powerpc was dead? i dont know if anyone is working on it. -compn From michaelni at gmx.at Sat Aug 2 14:25:21 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 14:25:21 +0200 Subject: [FFmpeg-devel] [PATCH] ffserver: initialize pbuffer in prepare_sdp_description() Message-ID: <1406982321-16738-1-git-send-email-michaelni@gmx.at> also check pbuffer before use Found-by: CSA Signed-off-by: Michael Niedermayer --- ffserver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ffserver.c b/ffserver.c index 00153b4..956d9f5 100644 --- a/ffserver.c +++ b/ffserver.c @@ -2977,6 +2977,8 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, AVDictionaryEntry *entry = av_dict_get(stream->metadata, "title", NULL, 0); int i; + *pbuffer = NULL; + avc = avformat_alloc_context(); if (avc == NULL || !rtp_format) { return -1; @@ -3013,7 +3015,7 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, av_free(avc); av_free(avs); - return strlen(*pbuffer); + return *pbuffer ? strlen(*pbuffer) : AVERROR(ENOMEM); } static void rtsp_cmd_options(HTTPContext *c, const char *url) -- 1.7.9.5 From michaelni at gmx.at Sat Aug 2 14:48:46 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 14:48:46 +0200 Subject: [FFmpeg-devel] [PATCH 0/4] Exploit compile-time constant In-Reply-To: <1406567848-6368-1-git-send-email-christophe.gisquet@gmail.com> References: <1406567848-6368-1-git-send-email-christophe.gisquet@gmail.com> Message-ID: <20140802124846.GQ4649@nb4> On Mon, Jul 28, 2014 at 05:17:24PM +0000, Christophe Gisquet wrote: > MAX_PB_SIZE is used or assumed for various buffer strides. In some cases, > it is used as constant parameter(s) to functions. > > Make use of that knowledge to: > - not pass the parameter > - avoid extra GPR usage > - precompute addresses / offsets > > Premature optimization and overall not that useful. > Before: > 46092 decicycles in oma, 1028766 runs, 19810 skips > 10174 decicycles in chroma, 2065859 runs, 31293 skips > > After: > 45634 decicycles in luma, 1027414 runs, 21162 skips > 9932 decicycles in chroma, 2063780 runs, 33372 skips is this for apply/push or just RFC/WIP ? you say "Premature optimization and overall not that useful." i would tend to suggest to apply it as it improves speed ... > > Christophe Gisquet (4): > hevc: move MAX_PB_SIZE declaration > hevcdsp: remove compilation-time-fixed parameter > hevcdsp: remove more instances of compile-time-fixed parameters > x86: hevcdsp: use compilation-time-fixed constant seems to fail with libavcodec/x86/hevc_mc.asm:1258: error: (add:2) cannot reference symbol `MAX_PB_SIZE' in preprocessor [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sat Aug 2 14:50:52 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 14:50:52 +0200 Subject: [FFmpeg-devel] HEVC SIMD Optimization on PowerPC In-Reply-To: <20140802071822.0000323b@mi.rr.com> References: <002801cfae13$cea3b2c0$6beb1840$@pku.edu.cn> <20140802071822.0000323b@mi.rr.com> Message-ID: <20140802125052.GR4649@nb4> On Sat, Aug 02, 2014 at 07:18:22AM -0400, compn wrote: > On Sat, 2 Aug 2014 13:37:10 +0800 > "Zhenan Lin" wrote: > > > Hi, all, > > > > > > > > Our team plans to contribute SIMD optimization on PowerPC for HEVC > > i thought powerpc was dead? i thought so too, but powerpc optimizations certainly are welcome, if someone wants to write some [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB it is not once nor twice but times without number that the same ideas make their appearance in the world. -- Aristotle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sat Aug 2 15:08:38 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 15:08:38 +0200 Subject: [FFmpeg-devel] [PATCH] msvc: fix implicitly declared read/close. In-Reply-To: References: Message-ID: <20140802130838.GS4649@nb4> On Sat, Aug 02, 2014 at 12:01:37PM +1000, Matt Oliver wrote: > MSVC/ICL does not have unistd.h as standard and instead declares read/close > functions in io.h. This is currently handled in some files but not in a > couple. Adding an include for io.h where needed adds the correct > declarations. > libavcodec/libxvid.c | 4 ++++ > libavcodec/libxvid_rc.c | 4 ++++ > libavutil/random_seed.c | 3 +++ > 3 files changed, 11 insertions(+) > 9df30ccc9f607fe515c1058f85e6f6bce0e07984 0001-msvc-fix-implicitly-declared-read-close.patch > From a9df2f27cf88e5e2e0a518daaba41b1b9ce8bdcb Mon Sep 17 00:00:00 2001 > From: Matthew Oliver > Date: Sat, 2 Aug 2014 11:08:29 +1000 > Subject: [PATCH] msvc: fix implicitly declared read/close. applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From stefasab at gmail.com Sat Aug 2 16:40:45 2014 From: stefasab at gmail.com (Stefano Sabatini) Date: Sat, 2 Aug 2014 16:40:45 +0200 Subject: [FFmpeg-devel] [PATCH] doc/ffserver: merge paragraph starting with "What happens next?" with previous one Message-ID: <1406990445-26221-1-git-send-email-stefasab@gmail.com> The name of the paragraph sounded a bit silly, and its text is small so it's better to merge it with the previous paragraph. --- doc/ffserver.texi | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/doc/ffserver.texi b/doc/ffserver.texi index fb90dd6..2bf8152 100644 --- a/doc/ffserver.texi +++ b/doc/ffserver.texi @@ -203,11 +203,9 @@ WARNING: trying to stream test1.mpg doesn't work with WMP as it tries to transfer the entire file before starting to play. The same is true of AVI files. - at section What happens next? - -You should edit the ffserver.conf file to suit your needs (in terms of -frame rates etc). Then install ffserver and ffmpeg, write a script to start -them up, and off you go. +You should edit the @file{ffserver.conf} file to suit your needs (in +terms of frame rates etc). Then install @command{ffserver} and + at command{ffmpeg}, write a script to start them up, and off you go. @section What else can it do? -- 1.8.3.2 From stefasab at gmail.com Sat Aug 2 16:40:53 2014 From: stefasab at gmail.com (Stefano Sabatini) Date: Sat, 2 Aug 2014 16:40:53 +0200 Subject: [FFmpeg-devel] [PATCH] ffserver: deprecate Port and BindAddress options in favor of HTTPPort and HTTPBindAddress Message-ID: <1406990453-26347-1-git-send-email-stefasab@gmail.com> The new option names are more explicit. --- doc/ffserver.conf | 4 ++-- doc/ffserver.texi | 19 ++++++++++++++----- ffserver.c | 10 +++++++--- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/doc/ffserver.conf b/doc/ffserver.conf index 094c093..b756961 100644 --- a/doc/ffserver.conf +++ b/doc/ffserver.conf @@ -1,11 +1,11 @@ # Port on which the server is listening. You must select a different # port from your standard HTTP web server if it is running on the same # computer. -Port 8090 +HTTPPort 8090 # Address on which the server is bound. Only useful if you have # several network interfaces. -BindAddress 0.0.0.0 +HTTPBindAddress 0.0.0.0 # Number of simultaneous HTTP connections that can be handled. It has # to be defined *before* the MaxClients parameter, since it defines the diff --git a/doc/ffserver.texi b/doc/ffserver.texi index 2bf8152..77273d2 100644 --- a/doc/ffserver.texi +++ b/doc/ffserver.texi @@ -66,7 +66,7 @@ http://@var{ffserver_ip_address}:@var{http_port}/@var{feed_name} where @var{ffserver_ip_address} is the IP address of the machine where @command{ffserver} is installed, @var{http_port} is the port number of -the HTTP server (configured through the @option{Port} option), and +the HTTP server (configured through the @option{HTTPPort} option), and @var{feed_name} is the name of the corresponding feed defined in the configuration file. @@ -101,7 +101,7 @@ http://@var{ffserver_ip_address}:@var{rtsp_port}/@var{stream_name}[@var{options} the configuration file. @var{options} is a list of options specified after the URL which affects how the stream is served by @command{ffserver}. @var{http_port} and @var{rtsp_port} are the HTTP -and RTSP ports configured with the options @var{Port} and +and RTSP ports configured with the options @var{HTTPPort} and @var{RTSPPort} respectively. In case the stream is associated to a feed, the encoding parameters @@ -352,20 +352,29 @@ allow everybody else. @section Global options @table @option + at item HTTPPort @var{port_number} @item Port @var{port_number} @item RTSPPort @var{port_number} -Set TCP port number on which the HTTP/RTSP server is listening. You -must select a different port from your standard HTTP web server if it -is running on the same computer. + at var{HTTPPort} sets the HTTP server listening TCP port number, + at var{RTSPPort} sets the RTSP server listening TCP port number. + + at var{Port} is the equivalent of @var{HTTPPort} and is deprecated. + +You must select a different port from your standard HTTP web server if +it is running on the same computer. If not specified, no corresponding server will be created. + at item HTTPBindAddress @var{ip_address} @item BindAddress @var{ip_address} @item RTSPBindAddress @var{ip_address} Set address on which the HTTP/RTSP server is bound. Only useful if you have several network interfaces. + at var{BindAddress} is the equivalent of @var{HTTPBindAddress} and is +deprecated. + @item MaxHTTPConnections @var{n} Set number of simultaneous HTTP connections that can be handled. It has to be defined @emph{before} the @option{MaxClients} parameter, diff --git a/ffserver.c b/ffserver.c index 00153b4..75049c1 100644 --- a/ffserver.c +++ b/ffserver.c @@ -4079,14 +4079,18 @@ static int parse_ffconfig(const char *filename) get_arg(cmd, sizeof(cmd), &p); - if (!av_strcasecmp(cmd, "Port")) { + if (!av_strcasecmp(cmd, "Port") || !av_strcasecmp(cmd, "HTTPPort")) { + if (!av_strcasecmp(cmd, "Port")) + WARNING("Port option is deprecated, use HTTPPort instead\n"); get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > 65536) { - ERROR("Invalid_port: %s\n", arg); + ERROR("Invalid port: %s\n", arg); } my_http_addr.sin_port = htons(val); - } else if (!av_strcasecmp(cmd, "BindAddress")) { + } else if (!av_strcasecmp(cmd, "HTTPBindAddress") || !av_strcasecmp(cmd, "BindAddress")) { + if (!av_strcasecmp(cmd, "BindAddress")) + WARNING("BindAddress option is deprecated, use HTTPBindAddress instead\n"); get_arg(arg, sizeof(arg), &p); if (resolve_host(&my_http_addr.sin_addr, arg) != 0) { ERROR("%s:%d: Invalid host/IP address: %s\n", arg); -- 1.8.3.2 From timothygu99 at gmail.com Sat Aug 2 16:50:14 2014 From: timothygu99 at gmail.com (Timothy Gu) Date: Sat, 2 Aug 2014 07:50:14 -0700 Subject: [FFmpeg-devel] [PATCH] doc/ffserver: merge paragraph starting with "What happens next?" with previous one In-Reply-To: <1406990445-26221-1-git-send-email-stefasab@gmail.com> References: <1406990445-26221-1-git-send-email-stefasab@gmail.com> Message-ID: On Aug 2, 2014 7:40 AM, "Stefano Sabatini" wrote: > > The name of the paragraph sounded a bit silly, and its text is small so > it's better to merge it with the previous paragraph. > --- > doc/ffserver.texi | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) OK. [...] Timothy From stefasab at gmail.com Sat Aug 2 16:51:16 2014 From: stefasab at gmail.com (Stefano Sabatini) Date: Sat, 2 Aug 2014 16:51:16 +0200 Subject: [FFmpeg-devel] [PATCH] ffserver: initialize pbuffer in prepare_sdp_description() In-Reply-To: <1406982321-16738-1-git-send-email-michaelni@gmx.at> References: <1406982321-16738-1-git-send-email-michaelni@gmx.at> Message-ID: <20140802145116.GD32146@barisone> On date Saturday 2014-08-02 14:25:21 +0200, Michael Niedermayer encoded: > also check pbuffer before use > > Found-by: CSA > Signed-off-by: Michael Niedermayer > --- > ffserver.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/ffserver.c b/ffserver.c > index 00153b4..956d9f5 100644 > --- a/ffserver.c > +++ b/ffserver.c > @@ -2977,6 +2977,8 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, > AVDictionaryEntry *entry = av_dict_get(stream->metadata, "title", NULL, 0); > int i; > > + *pbuffer = NULL; > + > avc = avformat_alloc_context(); > if (avc == NULL || !rtp_format) { > return -1; > @@ -3013,7 +3015,7 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, > av_free(avc); > av_free(avs); > > - return strlen(*pbuffer); > + return *pbuffer ? strlen(*pbuffer) : AVERROR(ENOMEM); > } > > static void rtsp_cmd_options(HTTPContext *c, const char *url) LGTM. -- FFmpeg = Faithless Fostering Magnificient Portable Egregious Geek From stefasab at gmail.com Sat Aug 2 17:20:44 2014 From: stefasab at gmail.com (Stefano Sabatini) Date: Sat, 2 Aug 2014 17:20:44 +0200 Subject: [FFmpeg-devel] [PATCH 1/4] lavfi: add filter metaframes infrastructure. In-Reply-To: <1406756689-27697-1-git-send-email-george@nsup.org> References: <1406756689-27697-1-git-send-email-george@nsup.org> Message-ID: <20140802152044.GE32146@barisone> On date Wednesday 2014-07-30 23:44:46 +0200, Nicolas George encoded: > Metaframes are frames without data, identified by a negative > format code, used to carry special conditions. > They are sent only to filter that declare supporting them. > The only metaframe for now is EOF; this mechanism augments > the current mechanism based on request_frame() returning > AVERROR_EOF, with the advantage that the EOF metaframe carries > a timestamp. > The metaframes are a purely internal API and do not leak to > the application. > > Signed-off-by: Nicolas George > --- > libavfilter/avfilter.c | 73 +++++++++++++++++++++++++++++++++++++++++++++----- > libavfilter/internal.h | 34 +++++++++++++++++++++++ > 2 files changed, 100 insertions(+), 7 deletions(-) > > > Changed the name to "metaframes". > Allocate the frame with the classic method. > > > diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c > index 7b11467..7894173 100644 > --- a/libavfilter/avfilter.c > +++ b/libavfilter/avfilter.c > @@ -346,15 +346,16 @@ int ff_request_frame(AVFilterLink *link) > ret = link->srcpad->request_frame(link); > else if (link->src->inputs[0]) > ret = ff_request_frame(link->src->inputs[0]); > - if (ret == AVERROR_EOF && link->partial_buf) { > - AVFrame *pbuf = link->partial_buf; > - link->partial_buf = NULL; > - ret = ff_filter_frame_framed(link, pbuf); > - } > if (ret < 0) { > + if (!link->frame_requested) { > + av_assert0(ret == AVERROR_EOF); > + ret = 0; > + } > link->frame_requested = 0; > - if (ret == AVERROR_EOF) > - link->closed = 1; > + if (ret == AVERROR_EOF) { > + ret = ff_filter_link_close(link, AV_NOPTS_VALUE); > + return ret < 0 ? ret : AVERROR_EOF; > + } > } else { > av_assert0(!link->frame_requested || > link->flags & FF_LINK_FLAG_REQUEST_LOOP); > @@ -1132,10 +1133,52 @@ static int ff_filter_frame_needs_framing(AVFilterLink *link, AVFrame *frame) > return ret; > } > > +static int ff_filter_metaframe(AVFilterLink *link, AVFrame *frame) > +{ > + AVFrame *pbuf = link->partial_buf; > + int ret; > + > + if (pbuf) { > + link->partial_buf = NULL; > + if ((ret = ff_filter_frame_framed(link, pbuf)) < 0) > + return ret; > + } > + > + if ((link->dst->filter->flags & FF_FILTER_FLAG_SUPPORT_METAFRAMES)) { > + ret = link->dstpad->filter_frame ? > + link->dstpad->filter_frame(link, frame) : > + default_filter_frame(link, frame); > + if (ret < 0) > + return ret; It shall probably execute the remaining part of the function even in case of failure. > + } > + > + switch (frame->format) { > + > + case FF_METAFRAME_EOF: > + link->closed = 1; > + break; > + > + case 0: > + case FF_METAFRAME_NOP: > + /* Not implemented yet because not used either for now. > + Caveat: if the same metaframe is forwarded to the next filter > + and the next filter changes the type, the type change must not be > + taken into account for the first link. */ I find this a bit confusing. Can you explain why the NOP metaframe is needed? > + > + default: > + av_assert0(!"reached"); > + } > + > + return ret; > +} > + > int ff_filter_frame(AVFilterLink *link, AVFrame *frame) > { > FF_TPRINTF_START(NULL, filter_frame); ff_tlog_link(NULL, link, 1); ff_tlog(NULL, " "); ff_tlog_ref(NULL, frame, 1); > > + if (frame->format < -1) > + return ff_filter_metaframe(link, frame); > + > /* Consistency checks */ > if (link->type == AVMEDIA_TYPE_VIDEO) { > if (strcmp(link->dst->filter->name, "scale")) { > @@ -1162,6 +1205,22 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame) > } > } > > +int ff_filter_link_close(AVFilterLink *link, int64_t pts) > +{ > + AVFrame *frame; > + int ret; > + > + if (link->closed) > + return 0; > + if (!(frame = av_frame_alloc())) > + return AVERROR(ENOMEM); > + frame->format = FF_METAFRAME_EOF; > + frame->pts = pts; > + ret = ff_filter_frame(link, frame); > + av_frame_free(&frame); > + return ret; > +} > + > const AVClass *avfilter_get_class(void) > { > return &avfilter_class; > diff --git a/libavfilter/internal.h b/libavfilter/internal.h > index 308b115..fbe603a 100644 > --- a/libavfilter/internal.h > +++ b/libavfilter/internal.h > @@ -374,4 +374,38 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name); > */ > void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter); > > +/** > + * The filter can accept metaframes. > + * Metaframes are AVFrame structures with a negative format field. > + * The framework will take default actions based on the metaframe type. > + * The destination filter is allowed to reset the type to inhibit the > + * default actions. > + */ > +#define FF_FILTER_FLAG_SUPPORT_METAFRAMES (1 << 24) > + > +/** > + * Types of metaframes that can be passer to a filter. > + */ > +enum { > + /** > + * Do not do anything. > + * Can be used by the destination filter to inhibit default handling. > + */ > + FF_METAFRAME_NOP = -1, > + > + /** > + * The input has reached EOF. > + * The pts field holds the timestamp of the end of the stream, > + * therefore allowing to compute the duration of the last frame. > + * The frame structure still belongs to the framework and must not be > + * stored by the destination filter; it also may be incomplete. > + */ > + FF_METAFRAME_EOF = AVERROR_EOF, > +}; > + > +/** > + * Close the link by sending the EOF metaframes to the destination filter. > + */ > +int ff_filter_link_close(AVFilterLink *link, int64_t pts); > + > #endif /* AVFILTER_INTERNAL_H */ LGTM otherwise. -- FFmpeg = Foolish Forgiving Mortal Power Exxagerate Gnome From michaelni at gmx.at Sat Aug 2 18:14:04 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 18:14:04 +0200 Subject: [FFmpeg-devel] mir-swamp.org Message-ID: <20140802161404.GB4658@nb4> Hi mir-swamp Ive found out about your free online static code analysis thingy and tried to use it for the FFmpeg project, I thought it cant hurt and maybe could help finding and fixing some bugs ... Ive 2 comments 1. Refusing members from gmail (and i assume other free mail services) is a major problem, most people use gmail and most invites i did sent went out to gmail users. Also there was no error or warning when sending the invites, people just cant accept the invite then, and not even if they try from another email address 2. When marking some issues as fixed or ignore that seems to be lost on the next build -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From derek.buitenhuis at gmail.com Sat Aug 2 18:23:51 2014 From: derek.buitenhuis at gmail.com (Derek Buitenhuis) Date: Sat, 02 Aug 2014 17:23:51 +0100 Subject: [FFmpeg-devel] mir-swamp.org In-Reply-To: <20140802161404.GB4658@nb4> References: <20140802161404.GB4658@nb4> Message-ID: <53DD1097.9030007@gmail.com> On 8/2/2014 5:14 PM, Michael Niedermayer wrote: > 1. Refusing members from gmail (and i assume other free mail services) > is a major problem, most people use gmail and most invites i did sent > went out to gmail users. Also there was no error or warning when > sending the invites, people just cant accept the invite then, and > not even if they try from another email address FWIW I got an invite at my gmail account. (Only replying to the list so as not to spam their support address.) - Derek From derek.buitenhuis at gmail.com Sat Aug 2 18:25:31 2014 From: derek.buitenhuis at gmail.com (Derek Buitenhuis) Date: Sat, 02 Aug 2014 17:25:31 +0100 Subject: [FFmpeg-devel] mir-swamp.org In-Reply-To: <53DD1097.9030007@gmail.com> References: <20140802161404.GB4658@nb4> <53DD1097.9030007@gmail.com> Message-ID: <53DD10FB.5020801@gmail.com> On 8/2/2014 5:23 PM, Derek Buitenhuis wrote: > FWIW I got an invite at my gmail account. Never mind, I can't actually register. - Derek From michaelni at gmx.at Sat Aug 2 18:33:18 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 18:33:18 +0200 Subject: [FFmpeg-devel] [PATCH] ffserver: initialize pbuffer in prepare_sdp_description() In-Reply-To: <20140802145116.GD32146@barisone> References: <1406982321-16738-1-git-send-email-michaelni@gmx.at> <20140802145116.GD32146@barisone> Message-ID: <20140802163318.GU4649@nb4> On Sat, Aug 02, 2014 at 04:51:16PM +0200, Stefano Sabatini wrote: > On date Saturday 2014-08-02 14:25:21 +0200, Michael Niedermayer encoded: > > also check pbuffer before use > > > > Found-by: CSA > > Signed-off-by: Michael Niedermayer > > --- > > ffserver.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/ffserver.c b/ffserver.c > > index 00153b4..956d9f5 100644 > > --- a/ffserver.c > > +++ b/ffserver.c > > @@ -2977,6 +2977,8 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, > > AVDictionaryEntry *entry = av_dict_get(stream->metadata, "title", NULL, 0); > > int i; > > > > + *pbuffer = NULL; > > + > > avc = avformat_alloc_context(); > > if (avc == NULL || !rtp_format) { > > return -1; > > @@ -3013,7 +3015,7 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, > > av_free(avc); > > av_free(avs); > > > > - return strlen(*pbuffer); > > + return *pbuffer ? strlen(*pbuffer) : AVERROR(ENOMEM); > > } > > > > static void rtsp_cmd_options(HTTPContext *c, const char *url) > > LGTM. applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From tempn at mi.rr.com Sat Aug 2 19:29:46 2014 From: tempn at mi.rr.com (compn) Date: Sat, 2 Aug 2014 13:29:46 -0400 Subject: [FFmpeg-devel] HEVC SIMD Optimization on PowerPC In-Reply-To: <20140802125052.GR4649@nb4> References: <002801cfae13$cea3b2c0$6beb1840$@pku.edu.cn> <20140802071822.0000323b@mi.rr.com> <20140802125052.GR4649@nb4> Message-ID: <20140802132946.00001a8a@mi.rr.com> On Sat, 2 Aug 2014 14:50:52 +0200 Michael Niedermayer wrote: > On Sat, Aug 02, 2014 at 07:18:22AM -0400, compn wrote: > > On Sat, 2 Aug 2014 13:37:10 +0800 > > "Zhenan Lin" wrote: > > > > > Hi, all, > > > > > > > > > > > > Our team plans to contribute SIMD optimization on PowerPC for HEVC > > > > i thought powerpc was dead? > > i thought so too, but powerpc optimizations certainly are welcome, > if someone wants to write some ubitux linked me to the latest powerpc https://en.wikipedia.org/wiki/POWER8 so i guess ppc isnt dead yet. -compn From u at pkh.me Sat Aug 2 20:20:17 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Sat, 2 Aug 2014 20:20:17 +0200 Subject: [FFmpeg-devel] [PATCH 1/5] avutil: add pixelutils API Message-ID: <1407003621-13611-1-git-send-email-u@pkh.me> --- configure | 2 + doc/APIchanges | 3 ++ libavutil/Makefile | 2 + libavutil/pixelutils.c | 85 ++++++++++++++++++++++++++++++ libavutil/pixelutils.h | 76 +++++++++++++++++++++++++++ libavutil/version.h | 2 +- libavutil/x86/Makefile | 4 ++ libavutil/x86/pixelutils.asm | 111 ++++++++++++++++++++++++++++++++++++++++ libavutil/x86/pixelutils.h | 26 ++++++++++ libavutil/x86/pixelutils_init.c | 54 +++++++++++++++++++ 10 files changed, 364 insertions(+), 1 deletion(-) create mode 100644 libavutil/pixelutils.c create mode 100644 libavutil/pixelutils.h create mode 100644 libavutil/x86/pixelutils.asm create mode 100644 libavutil/x86/pixelutils.h create mode 100644 libavutil/x86/pixelutils_init.c diff --git a/configure b/configure index 9c3af50..57edd1d 100755 --- a/configure +++ b/configure @@ -144,6 +144,7 @@ Component options: --disable-mdct disable MDCT code --disable-rdft disable RDFT code --disable-fft disable FFT code + --disable-pixelutils disable pixel utils in libavutil Hardware accelerators: --disable-dxva2 disable DXVA2 code [autodetect] @@ -1451,6 +1452,7 @@ SUBSYSTEM_LIST=" lsp lzo mdct + pixelutils network rdft " diff --git a/doc/APIchanges b/doc/APIchanges index abca377..69ca682 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2012-10-22 API changes, most recent first: +2014-08-02 - xxxxxxx - lavu 52.95.100 - pixelutils.h + Add pixelutils API with SAD functions + 2014-07-30 - ba3e331 - lavu 52.94.100 - frame.h Add av_frame_side_data_name() diff --git a/libavutil/Makefile b/libavutil/Makefile index 91751dc..6114cc9 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -44,6 +44,7 @@ HEADERS = adler32.h \ opt.h \ parseutils.h \ pixdesc.h \ + pixelutils.h \ pixfmt.h \ random_seed.h \ replaygain.h \ @@ -113,6 +114,7 @@ OBJS = adler32.o \ opt.o \ parseutils.o \ pixdesc.o \ + pixelutils.o \ random_seed.o \ rational.o \ rc4.o \ diff --git a/libavutil/pixelutils.c b/libavutil/pixelutils.c new file mode 100644 index 0000000..146a882 --- /dev/null +++ b/libavutil/pixelutils.c @@ -0,0 +1,85 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "common.h" +#include "pixelutils.h" + +#if CONFIG_PIXELUTILS + +#include "x86/pixelutils.h" + +static av_always_inline int sad_wxh(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2, + int w, int h) +{ + int x, y, sum = 0; + + for (y = 0; y < h; y++) { + for (x = 0; x < w; x++) + sum += abs(src1[x] - src2[x]); + src1 += stride1; + src2 += stride2; + } + return sum; +} + +#define DECLARE_BLOCK_FUNCTIONS(size) \ +static int block_sad_##size##x##size##_c(const uint8_t *src1, ptrdiff_t stride1, \ + const uint8_t *src2, ptrdiff_t stride2) \ +{ \ + return sad_wxh(src1, stride1, src2, stride2, size, size); \ +} + +DECLARE_BLOCK_FUNCTIONS(2) +DECLARE_BLOCK_FUNCTIONS(4) +DECLARE_BLOCK_FUNCTIONS(8) +DECLARE_BLOCK_FUNCTIONS(16) + +#endif /* CONFIG_PIXELUTILS */ + +av_cold AVPixelUtils *av_pixelutils_alloc(void) +{ + return av_mallocz(sizeof(AVPixelUtils)); +} + +av_cold int av_pixelutils_init(AVPixelUtils *s, void *log_ctx) +{ +#if !CONFIG_PIXELUTILS + av_log(log_ctx, AV_LOG_ERROR, "pixelutils support is required " + "but libavutil is not compiled with it\n"); + return AVERROR(EINVAL); +#else + +#define ASSIGN_BLOCK_FUNCTIONS(size) do { \ + s->sad [AV_PIXEL_BLOCKSZ_##size##x##size] = \ + s->sad_u[AV_PIXEL_BLOCKSZ_##size##x##size] = block_sad_##size##x##size##_c; \ +} while (0) + + ASSIGN_BLOCK_FUNCTIONS(2); + ASSIGN_BLOCK_FUNCTIONS(4); + ASSIGN_BLOCK_FUNCTIONS(8); + ASSIGN_BLOCK_FUNCTIONS(16); + +#if ARCH_X86 + ff_pixelutils_init_x86(s); +#endif + + return 0; +#endif /* CONFIG_PIXELUTILS */ +} diff --git a/libavutil/pixelutils.h b/libavutil/pixelutils.h new file mode 100644 index 0000000..862d607 --- /dev/null +++ b/libavutil/pixelutils.h @@ -0,0 +1,76 @@ +/* + * This file is part of FFmpeg. + * + * 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 + */ + +#ifndef AVUTIL_PIXELUTILS_H +#define AVUTIL_PIXELUTILS_H + +#include +#include +#include "common.h" + +enum AVPixelUtilsBlockSize { + // Warning: only add entries at the end for ABI compatibility. + // Ideally, keep only squared dimensions in that enum. + AV_PIXEL_BLOCKSZ_2x2, + AV_PIXEL_BLOCKSZ_4x4, + AV_PIXEL_BLOCKSZ_8x8, + AV_PIXEL_BLOCKSZ_16x16, + AV_PIXEL_BLOCKSZ_NB +}; + +/** + * Sum of abs(src1[x] - src2[x]) + */ +typedef int (*av_pixelutils_sad_fn)(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2); + +typedef struct AVPixelUtils { + /** + * Sum of absolute differences block functions. + * src1 and src2 addresses need to be aligned to the block size. + */ + av_pixelutils_sad_fn sad[AV_PIXEL_BLOCKSZ_NB]; + + /** + * Sum of absolute differences block functions, (half) unaligned version. + * src1 address needs to be aligned to the block size. + * src2 has no alignment requirement; the 'u' refers to this second source. + */ + av_pixelutils_sad_fn sad_u[AV_PIXEL_BLOCKSZ_NB]; +} AVPixelUtils; + +/** + * Allocate and initialize pixel utils context. + * + * The context remains uninitialized and you need to use av_pixelutils_init() + * on it. + */ +AVPixelUtils *av_pixelutils_alloc(void); + +/** + * Initialize the pixel utils context. + * + * @param s a pointer to a AVPixelUtils structure to initialize + * @param log_ctx context used for logging + * @return >= 0 on success, AVERROR(EINVAL) if libavutil pixelutils code wasn't + * compiled in (an explicit error message will be automatically emitted in this + * case), and another value < 0 for any other error. + */ +int av_pixelutils_init(AVPixelUtils *s, void *log_ctx); + +#endif /* AVUTIL_PIXELUTILS_H */ diff --git a/libavutil/version.h b/libavutil/version.h index 42e2db5..9af8f5f 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -56,7 +56,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 52 -#define LIBAVUTIL_VERSION_MINOR 94 +#define LIBAVUTIL_VERSION_MINOR 95 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff --git a/libavutil/x86/Makefile b/libavutil/x86/Makefile index 1e19082..ad3bdfc 100644 --- a/libavutil/x86/Makefile +++ b/libavutil/x86/Makefile @@ -2,7 +2,11 @@ OBJS += x86/cpu.o \ x86/float_dsp_init.o \ x86/lls_init.o \ +OBJS-$(CONFIG_PIXELUTILS) += x86/pixelutils_init.o \ + YASM-OBJS += x86/cpuid.o \ x86/emms.o \ x86/float_dsp.o \ x86/lls.o \ + +YASM-OBJS-$(CONFIG_PIXELUTILS) += x86/pixelutils.o \ diff --git a/libavutil/x86/pixelutils.asm b/libavutil/x86/pixelutils.asm new file mode 100644 index 0000000..b4db2cd --- /dev/null +++ b/libavutil/x86/pixelutils.asm @@ -0,0 +1,111 @@ +;****************************************************************************** +;* Pixel utilities SIMD +;* +;* Copyright (C) 2002-2004 Michael Niedermayer +;* Copyright (C) 2014 Cl?ment B?sch +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "x86util.asm" + +SECTION_TEXT + +;------------------------------------------------------------------------------- +; int ff_pixelutils_sad_8x8_mmx(const uint8_t *src1, ptrdiff_t stride1, +; const uint8_t *src2, ptrdiff_t stride2); +;------------------------------------------------------------------------------- +INIT_MMX mmx +cglobal pixelutils_sad_8x8, 4,4,0, src1, stride1, src2, stride2 + pxor m7, m7 + pxor m6, m6 +%rep 4 + mova m0, [src1q] + mova m2, [src1q + stride1q] + mova m1, [src2q] + mova m3, [src2q + stride2q] + psubusb m4, m0, m1 + psubusb m5, m2, m3 + psubusb m1, m0 + psubusb m3, m2 + por m1, m4 + por m3, m5 + punpcklbw m0, m1, m7 + punpcklbw m2, m3, m7 + punpckhbw m1, m7 + punpckhbw m3, m7 + paddw m0, m1 + paddw m2, m3 + paddw m0, m2 + paddw m6, m0 + lea src1q, [src1q + 2*stride1q] + lea src2q, [src2q + 2*stride2q] +%endrep + psrlq m0, m6, 32 + paddw m6, m0 + psrlq m0, m6, 16 + paddw m6, m0 + movd eax, m6 + movzx eax, ax + RET + +;------------------------------------------------------------------------------- +; int ff_pixelutils_sad_8x8_mmxext(const uint8_t *src1, ptrdiff_t stride1, +; const uint8_t *src2, ptrdiff_t stride2); +;------------------------------------------------------------------------------- +INIT_MMX mmxext +cglobal pixelutils_sad_8x8, 4,4,0, src1, stride1, src2, stride2 + pxor m2, m2 +%rep 4 + mova m0, [src1q] + mova m1, [src1q + stride1q] + psadbw m0, [src2q] + psadbw m1, [src2q + stride2q] + paddw m2, m0 + paddw m2, m1 + lea src1q, [src1q + 2*stride1q] + lea src2q, [src2q + 2*stride2q] +%endrep + movd eax, m2 + RET + +;------------------------------------------------------------------------------- +; int ff_pixelutils_sad_[au]_16x16_sse(const uint8_t *src1, ptrdiff_t stride1, +; const uint8_t *src2, ptrdiff_t stride2); +;------------------------------------------------------------------------------- +%macro SAD_16x16 1 +INIT_XMM sse +cglobal pixelutils_sad_%1_16x16, 4,4,3, src1, stride1, src2, stride2 + pxor m2, m2 +%rep 8 + mov%1 m0, [src2q] + mov%1 m1, [src2q + stride1q] + psadbw m0, [src1q] + psadbw m1, [src1q + stride2q] + paddw m2, m0 + paddw m2, m1 + lea src1q, [src1q + 2*stride1q] + lea src2q, [src2q + 2*stride2q] +%endrep + movhlps m0, m2 + paddw m2, m0 + movd eax, m2 + RET +%endmacro + +SAD_16x16 a +SAD_16x16 u diff --git a/libavutil/x86/pixelutils.h b/libavutil/x86/pixelutils.h new file mode 100644 index 0000000..386b490 --- /dev/null +++ b/libavutil/x86/pixelutils.h @@ -0,0 +1,26 @@ +/* + * This file is part of FFmpeg. + * + * 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 + */ + +#ifndef AVUTIL_X86_PIXELUTILS_H +#define AVUTIL_X86_PIXELUTILS_H + +#include "libavutil/pixelutils.h" + +void ff_pixelutils_init_x86(AVPixelUtils *s); + +#endif /* AVUTIL_X86_PIXELUTILS_H */ diff --git a/libavutil/x86/pixelutils_init.c b/libavutil/x86/pixelutils_init.c new file mode 100644 index 0000000..701492f --- /dev/null +++ b/libavutil/x86/pixelutils_init.c @@ -0,0 +1,54 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#include "pixelutils.h" +#include "cpu.h" + +int ff_pixelutils_sad_8x8_mmx(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2); +int ff_pixelutils_sad_8x8_mmxext(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2); +int ff_pixelutils_sad_a_16x16_sse(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2); +int ff_pixelutils_sad_u_16x16_sse(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2); + +void ff_pixelutils_init_x86(AVPixelUtils *s) +{ + int cpu_flags = av_get_cpu_flags(); + + //TODO: add 16x16 mmx + //TODO: add 32x32 + + if (EXTERNAL_MMX(cpu_flags)) { + s->sad [AV_PIXEL_BLOCKSZ_8x8] = + s->sad_u[AV_PIXEL_BLOCKSZ_8x8] = ff_pixelutils_sad_8x8_mmx; + } + + if (EXTERNAL_MMXEXT(cpu_flags)) { + s->sad [AV_PIXEL_BLOCKSZ_8x8] = + s->sad_u[AV_PIXEL_BLOCKSZ_8x8] = ff_pixelutils_sad_8x8_mmxext; + } + + if (EXTERNAL_SSE(cpu_flags)) { + s->sad [AV_PIXEL_BLOCKSZ_16x16] = ff_pixelutils_sad_a_16x16_sse; + s->sad_u[AV_PIXEL_BLOCKSZ_16x16] = ff_pixelutils_sad_u_16x16_sse; + } +} -- 2.0.2 From u at pkh.me Sat Aug 2 20:20:18 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Sat, 2 Aug 2014 20:20:18 +0200 Subject: [FFmpeg-devel] [PATCH 2/5] build: remove wrong avcodec dep in decimate In-Reply-To: <1407003621-13611-1-git-send-email-u@pkh.me> References: <1407003621-13611-1-git-send-email-u@pkh.me> Message-ID: <1407003621-13611-2-git-send-email-u@pkh.me> This was probably a mistake with mpdecimate. The decimate filter doesn't depend on avcodec. --- configure | 1 - 1 file changed, 1 deletion(-) diff --git a/configure b/configure index 57edd1d..5159f10 100755 --- a/configure +++ b/configure @@ -5241,7 +5241,6 @@ enabled amovie_filter && prepend avfilter_deps "avformat avcodec" enabled aresample_filter && prepend avfilter_deps "swresample" enabled asyncts_filter && prepend avfilter_deps "avresample" enabled atempo_filter && prepend avfilter_deps "avcodec" -enabled decimate_filter && prepend avfilter_deps "avcodec" enabled deshake_filter && prepend avfilter_deps "avcodec" enabled ebur128_filter && enabled swresample && prepend avfilter_deps "swresample" enabled elbg_filter && prepend avfilter_deps "avcodec" -- 2.0.2 From u at pkh.me Sat Aug 2 20:20:19 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Sat, 2 Aug 2014 20:20:19 +0200 Subject: [FFmpeg-devel] [PATCH 3/5] avfilter/deshake: remove avcodec dependency In-Reply-To: <1407003621-13611-1-git-send-email-u@pkh.me> References: <1407003621-13611-1-git-send-email-u@pkh.me> Message-ID: <1407003621-13611-3-git-send-email-u@pkh.me> --- configure | 4 +--- libavfilter/deshake.h | 5 ++--- libavfilter/vf_deshake.c | 27 +++++++++++++++------------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/configure b/configure index 5159f10..bc187a5 100755 --- a/configure +++ b/configure @@ -2531,8 +2531,7 @@ cropdetect_filter_deps="gpl" dctdnoiz_filter_deps="avcodec" dctdnoiz_filter_select="dct" delogo_filter_deps="gpl" -deshake_filter_deps="avcodec" -deshake_filter_select="me_cmp" +deshake_filter_select="pixelutils" drawtext_filter_deps="libfreetype" ebur128_filter_deps="gpl" flite_filter_deps="libflite" @@ -5241,7 +5240,6 @@ enabled amovie_filter && prepend avfilter_deps "avformat avcodec" enabled aresample_filter && prepend avfilter_deps "swresample" enabled asyncts_filter && prepend avfilter_deps "avresample" enabled atempo_filter && prepend avfilter_deps "avcodec" -enabled deshake_filter && prepend avfilter_deps "avcodec" enabled ebur128_filter && enabled swresample && prepend avfilter_deps "swresample" enabled elbg_filter && prepend avfilter_deps "avcodec" enabled mcdeint_filter && prepend avfilter_deps "avcodec" diff --git a/libavfilter/deshake.h b/libavfilter/deshake.h index 615953c..f61ed80 100644 --- a/libavfilter/deshake.h +++ b/libavfilter/deshake.h @@ -24,8 +24,8 @@ #include "config.h" #include "avfilter.h" -#include "libavcodec/dsputil.h" #include "transform.h" +#include "libavutil/pixelutils.h" #if CONFIG_OPENCL #include "libavutil/opencl.h" #endif @@ -80,8 +80,7 @@ typedef struct { int blocksize; ///< Size of blocks to compare int contrast; ///< Contrast threshold int search; ///< Motion search method - AVCodecContext *avctx; - DSPContext c; ///< Context providing optimized SAD methods + av_pixelutils_sad_fn sad; ///< Sum of the absolute difference function Transform last; ///< Transform from last frame int refcount; ///< Number of reference frames (defines averaging window) FILE *fp; diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c index 50aa451..cd32ecf 100644 --- a/libavfilter/vf_deshake.c +++ b/libavfilter/vf_deshake.c @@ -57,7 +57,6 @@ #include "libavutil/mem.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" -#include "libavcodec/dsputil.h" #include "deshake.h" #include "deshake_opencl.h" @@ -132,9 +131,8 @@ static void find_block_motion(DeshakeContext *deshake, uint8_t *src1, int smallest = INT_MAX; int tmp, tmp2; - #define CMP(i, j) deshake->c.sad[0](NULL, src1 + cy * stride + cx, \ - src2 + (j) * stride + (i), stride, \ - deshake->blocksize) + #define CMP(i, j) deshake->sad(src1 + cy * stride + cx, stride,\ + src2 + (j) * stride + (i), stride) if (deshake->search == EXHAUSTIVE) { // Compare every possible position - this is sloooow! @@ -201,7 +199,7 @@ static int block_contrast(uint8_t *src, int x, int y, int stride, int blocksize) int i, j, pos; for (i = 0; i <= blocksize * 2; i++) { - // We use a width of 16 here to match the libavcodec sad functions + // We use a width of 16 here to match the sad function for (j = 0; j <= 15; j++) { pos = (y - i) * stride + (x - j); if (src[pos] < lowest) @@ -263,7 +261,7 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2, pos = 0; // Find motion for every block and store the motion vector in the counts for (y = deshake->ry; y < height - deshake->ry - (deshake->blocksize * 2); y += deshake->blocksize * 2) { - // We use a width of 16 here to match the libavcodec sad functions + // We use a width of 16 here to match the sad function for (x = deshake->rx; x < width - deshake->rx - 16; x += 16) { // If the contrast is too low, just skip this block as it probably // won't be very useful to us. @@ -351,6 +349,17 @@ static av_cold int init(AVFilterContext *ctx) int ret; DeshakeContext *deshake = ctx->priv; + AVPixelUtils *pixels = av_pixelutils_alloc(); + if (!pixels) + return AVERROR(ENOMEM); + ret = av_pixelutils_init(pixels, deshake); + if (ret < 0) { + av_free(pixels); + return ret; + } + deshake->sad = pixels->sad_u[AV_PIXEL_BLOCKSZ_16x16]; // XXX: configurable? + av_free(pixels); + deshake->refcount = 20; // XXX: add to options? deshake->blocksize /= 2; deshake->blocksize = av_clip(deshake->blocksize, 4, 128); @@ -413,9 +422,6 @@ static int config_props(AVFilterLink *link) deshake->last.angle = 0; deshake->last.zoom = 0; - deshake->avctx = avcodec_alloc_context3(NULL); - avpriv_dsputil_init(&deshake->c, deshake->avctx); - return 0; } @@ -428,9 +434,6 @@ static av_cold void uninit(AVFilterContext *ctx) av_frame_free(&deshake->ref); if (deshake->fp) fclose(deshake->fp); - if (deshake->avctx) - avcodec_close(deshake->avctx); - av_freep(&deshake->avctx); } static int filter_frame(AVFilterLink *link, AVFrame *in) -- 2.0.2 From u at pkh.me Sat Aug 2 20:20:20 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Sat, 2 Aug 2014 20:20:20 +0200 Subject: [FFmpeg-devel] [PATCH 4/5] avfilter/mp_decimate: remove avcodec dependency In-Reply-To: <1407003621-13611-1-git-send-email-u@pkh.me> References: <1407003621-13611-1-git-send-email-u@pkh.me> Message-ID: <1407003621-13611-4-git-send-email-u@pkh.me> --- configure | 4 ++-- libavfilter/vf_mpdecimate.c | 44 ++++++++++++++++++++------------------------ 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/configure b/configure index bc187a5..210cafb 100755 --- a/configure +++ b/configure @@ -2549,8 +2549,8 @@ ladspa_filter_extralibs='$ldl' mcdeint_filter_deps="avcodec gpl" movie_filter_deps="avcodec avformat" mp_filter_deps="gpl avcodec swscale inline_asm" -mpdecimate_filter_deps="gpl avcodec" -mpdecimate_filter_select="me_cmp pixblockdsp" +mpdecimate_filter_deps="gpl" +mpdecimate_filter_select="pixelutils" mptestsrc_filter_deps="gpl" negate_filter_deps="lut_filter" perspective_filter_deps="gpl" diff --git a/libavfilter/vf_mpdecimate.c b/libavfilter/vf_mpdecimate.c index c667a9f..76af175 100644 --- a/libavfilter/vf_mpdecimate.c +++ b/libavfilter/vf_mpdecimate.c @@ -26,9 +26,8 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" +#include "libavutil/pixelutils.h" #include "libavutil/timestamp.h" -#include "libavcodec/dsputil.h" -#include "libavcodec/pixblockdsp.h" #include "avfilter.h" #include "internal.h" #include "formats.h" @@ -49,9 +48,7 @@ typedef struct { int hsub, vsub; ///< chroma subsampling values AVFrame *ref; ///< reference picture - DSPContext dspctx; ///< context providing optimized diff routines - PixblockDSPContext pdsp; - AVCodecContext *avctx; ///< codec context required for the DSPContext + av_pixelutils_sad_fn sad; ///< sum of absolute difference function } DecimateContext; #define OFFSET(x) offsetof(DecimateContext, x) @@ -72,25 +69,21 @@ AVFILTER_DEFINE_CLASS(mpdecimate); * Return 1 if the two planes are different, 0 otherwise. */ static int diff_planes(AVFilterContext *ctx, - uint8_t *cur, uint8_t *ref, int linesize, + uint8_t *cur, int cur_linesize, + uint8_t *ref, int ref_linesize, int w, int h) { DecimateContext *decimate = ctx->priv; - DSPContext *dspctx = &decimate->dspctx; - PixblockDSPContext *pdsp = &decimate->pdsp; int x, y; int d, c = 0; int t = (w/16)*(h/16)*decimate->frac; - int16_t block[8*8]; /* compute difference for blocks of 8x8 bytes */ for (y = 0; y < h-7; y += 4) { for (x = 8; x < w-7; x += 4) { - pdsp->diff_pixels(block, - cur+x+y*linesize, - ref+x+y*linesize, linesize); - d = dspctx->sum_abs_dctelem(block); + d = decimate->sad(cur + y*cur_linesize + x, cur_linesize, + ref + y*ref_linesize + x, ref_linesize); if (d > decimate->hi) return 1; if (d > decimate->lo) { @@ -124,7 +117,8 @@ static int decimate_frame(AVFilterContext *ctx, int vsub = plane == 1 || plane == 2 ? decimate->vsub : 0; int hsub = plane == 1 || plane == 2 ? decimate->hsub : 0; if (diff_planes(ctx, - cur->data[plane], ref->data[plane], ref->linesize[plane], + cur->data[plane], cur->linesize[plane], + ref->data[plane], ref->linesize[plane], FF_CEIL_RSHIFT(ref->width, hsub), FF_CEIL_RSHIFT(ref->height, vsub))) return 0; @@ -135,17 +129,23 @@ static int decimate_frame(AVFilterContext *ctx, static av_cold int init(AVFilterContext *ctx) { + int ret; DecimateContext *decimate = ctx->priv; + AVPixelUtils *pixels = av_pixelutils_alloc(); + if (!pixels) + return AVERROR(ENOMEM); + ret = av_pixelutils_init(pixels, decimate); + if (ret < 0) { + av_free(pixels); + return ret; + } + decimate->sad = pixels->sad_u[AV_PIXEL_BLOCKSZ_8x8]; + av_free(pixels); + av_log(ctx, AV_LOG_VERBOSE, "max_drop_count:%d hi:%d lo:%d frac:%f\n", decimate->max_drop_count, decimate->hi, decimate->lo, decimate->frac); - decimate->avctx = avcodec_alloc_context3(NULL); - if (!decimate->avctx) - return AVERROR(ENOMEM); - avpriv_dsputil_init(&decimate->dspctx, decimate->avctx); - ff_pixblockdsp_init(&decimate->pdsp, decimate->avctx); - return 0; } @@ -153,10 +153,6 @@ static av_cold void uninit(AVFilterContext *ctx) { DecimateContext *decimate = ctx->priv; av_frame_free(&decimate->ref); - if (decimate->avctx) { - avcodec_close(decimate->avctx); - av_freep(&decimate->avctx); - } } static int query_formats(AVFilterContext *ctx) -- 2.0.2 From u at pkh.me Sat Aug 2 20:20:21 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Sat, 2 Aug 2014 20:20:21 +0200 Subject: [FFmpeg-devel] [PATCH 5/5] avfilter/select: remove optional avcodec dependency In-Reply-To: <1407003621-13611-1-git-send-email-u@pkh.me> References: <1407003621-13611-1-git-send-email-u@pkh.me> Message-ID: <1407003621-13611-5-git-send-email-u@pkh.me> --- configure | 1 + libavfilter/f_select.c | 58 +++++++++++++++++--------------------------------- 2 files changed, 21 insertions(+), 38 deletions(-) diff --git a/configure b/configure index 210cafb..b9b1e3b 100755 --- a/configure +++ b/configure @@ -2564,6 +2564,7 @@ removelogo_filter_deps="avcodec avformat swscale" resample_filter_deps="avresample" sab_filter_deps="gpl swscale" scale_filter_deps="swscale" +select_filter_select="pixelutils" smartblur_filter_deps="gpl swscale" showspectrum_filter_deps="avcodec" showspectrum_filter_select="rdft" diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c index 8d2c860..eb56454 100644 --- a/libavfilter/f_select.c +++ b/libavfilter/f_select.c @@ -28,16 +28,13 @@ #include "libavutil/fifo.h" #include "libavutil/internal.h" #include "libavutil/opt.h" +#include "libavutil/pixelutils.h" #include "avfilter.h" #include "audio.h" #include "formats.h" #include "internal.h" #include "video.h" -#if CONFIG_AVCODEC -#include "libavcodec/dsputil.h" -#endif - static const char *const var_names[] = { "TB", ///< timebase @@ -144,11 +141,8 @@ typedef struct SelectContext { AVExpr *expr; double var_values[VAR_VARS_NB]; int do_scene_detect; ///< 1 if the expression requires scene detection variables, 0 otherwise -#if CONFIG_AVCODEC - AVCodecContext *avctx; ///< codec context required for the DSPContext (scene detect only) - DSPContext c; ///< context providing optimized SAD methods (scene detect only) + av_pixelutils_sad_fn sad; ///< Sum of the absolute difference function (scene detect only) double prev_mafd; ///< previous MAFD (scene detect only) -#endif AVFrame *prev_picref; ///< previous frame (scene detect only) double select; int select_out; ///< mark the selected output pad index @@ -200,6 +194,7 @@ static av_cold int init(AVFilterContext *ctx) static int config_input(AVFilterLink *inlink) { + int ret = 0; SelectContext *select = inlink->dst->priv; select->var_values[VAR_N] = 0.0; @@ -240,18 +235,21 @@ static int config_input(AVFilterLink *inlink) select->var_values[VAR_SAMPLE_RATE] = inlink->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN; -#if CONFIG_AVCODEC if (select->do_scene_detect) { - select->avctx = avcodec_alloc_context3(NULL); - if (!select->avctx) + AVPixelUtils *pixels = av_pixelutils_alloc(); + if (!pixels) return AVERROR(ENOMEM); - avpriv_dsputil_init(&select->c, select->avctx); + ret = av_pixelutils_init(pixels, select); + if (ret < 0) { + av_free(pixels); + return ret; + } + select->sad = pixels->sad[AV_PIXEL_BLOCKSZ_8x8]; + av_free(pixels); } -#endif - return 0; + return ret; } -#if CONFIG_AVCODEC static double get_scene_score(AVFilterContext *ctx, AVFrame *frame) { double ret = 0; @@ -259,24 +257,23 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *frame) AVFrame *prev_picref = select->prev_picref; if (prev_picref && - frame->height == prev_picref->height && - frame->width == prev_picref->width && - frame->linesize[0] == prev_picref->linesize[0]) { + frame->height == prev_picref->height && + frame->width == prev_picref->width) { int x, y, nb_sad = 0; int64_t sad = 0; double mafd, diff; uint8_t *p1 = frame->data[0]; uint8_t *p2 = prev_picref->data[0]; - const int linesize = frame->linesize[0]; + const int p1_linesize = frame->linesize[0]; + const int p2_linesize = prev_picref->linesize[0]; for (y = 0; y < frame->height - 8; y += 8) { for (x = 0; x < frame->width*3 - 8; x += 8) { - sad += select->c.sad[1](NULL, p1 + x, p2 + x, - linesize, 8); + sad += select->sad(p1 + x, p1_linesize, p2 + x, p2_linesize); nb_sad += 8 * 8; } - p1 += 8 * linesize; - p2 += 8 * linesize; + p1 += 8 * p1_linesize; + p2 += 8 * p2_linesize; } emms_c(); mafd = nb_sad ? (double)sad / nb_sad : 0; @@ -288,7 +285,6 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *frame) select->prev_picref = av_frame_clone(frame); return ret; } -#endif #define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d)) #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)) @@ -320,7 +316,6 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame) !frame->interlaced_frame ? INTERLACE_TYPE_P : frame->top_field_first ? INTERLACE_TYPE_T : INTERLACE_TYPE_B; select->var_values[VAR_PICT_TYPE] = frame->pict_type; -#if CONFIG_AVCODEC if (select->do_scene_detect) { char buf[32]; select->var_values[VAR_SCENE] = get_scene_score(ctx, frame); @@ -328,7 +323,6 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame) snprintf(buf, sizeof(buf), "%f", select->var_values[VAR_SCENE]); av_dict_set(avpriv_frame_get_metadatap(frame), "lavfi.scene_score", buf, 0); } -#endif break; } @@ -418,15 +412,9 @@ static av_cold void uninit(AVFilterContext *ctx) for (i = 0; i < ctx->nb_outputs; i++) av_freep(&ctx->output_pads[i].name); -#if CONFIG_AVCODEC if (select->do_scene_detect) { av_frame_free(&select->prev_picref); - if (select->avctx) { - avcodec_close(select->avctx); - av_freep(&select->avctx); - } } -#endif } static int query_formats(AVFilterContext *ctx) @@ -495,17 +483,11 @@ AVFILTER_DEFINE_CLASS(select); static av_cold int select_init(AVFilterContext *ctx) { - SelectContext *select = ctx->priv; int ret; if ((ret = init(ctx)) < 0) return ret; - if (select->do_scene_detect && !CONFIG_AVCODEC) { - av_log(ctx, AV_LOG_ERROR, "Scene detection is not available without libavcodec.\n"); - return AVERROR(EINVAL); - } - return 0; } -- 2.0.2 From lukasz.m.luki2 at gmail.com Sat Aug 2 20:30:39 2014 From: lukasz.m.luki2 at gmail.com (Lukasz Marek) Date: Sat, 02 Aug 2014 20:30:39 +0200 Subject: [FFmpeg-devel] [PATCH 1/5] avutil: add pixelutils API In-Reply-To: <1407003621-13611-1-git-send-email-u@pkh.me> References: <1407003621-13611-1-git-send-email-u@pkh.me> Message-ID: <53DD2E4F.6060705@gmail.com> > +static av_always_inline int sad_wxh(const uint8_t *src1, ptrdiff_t stride1, > + const uint8_t *src2, ptrdiff_t stride2, > + int w, int h) > +{ > + int x, y, sum = 0; > + > + for (y = 0; y < h; y++) { > + for (x = 0; x < w; x++) > + sum += abs(src1[x] - src2[x]); minor: I came out of nowhere to this patch, but maybe FFABS? :) > + src1 += stride1; > + src2 += stride2; > + } > + return sum; > +} From onemda at gmail.com Sat Aug 2 20:30:56 2014 From: onemda at gmail.com (Paul B Mahol) Date: Sat, 2 Aug 2014 20:30:56 +0200 Subject: [FFmpeg-devel] [PATCH 2/5] build: remove wrong avcodec dep in decimate In-Reply-To: <1407003621-13611-2-git-send-email-u@pkh.me> References: <1407003621-13611-1-git-send-email-u@pkh.me> <1407003621-13611-2-git-send-email-u@pkh.me> Message-ID: On Sat, Aug 2, 2014 at 8:20 PM, Cl?ment B?sch wrote: > This was probably a mistake with mpdecimate. The decimate filter doesn't > depend on avcodec. > --- > configure | 1 - > 1 file changed, 1 deletion(-) > lgtm From michaelni at gmx.at Sat Aug 2 20:35:27 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 20:35:27 +0200 Subject: [FFmpeg-devel] [PATCH 1/5] avutil: add pixelutils API In-Reply-To: <1407003621-13611-1-git-send-email-u@pkh.me> References: <1407003621-13611-1-git-send-email-u@pkh.me> Message-ID: <20140802183527.GV4649@nb4> On Sat, Aug 02, 2014 at 08:20:17PM +0200, Cl?ment B?sch wrote: > --- > configure | 2 + > doc/APIchanges | 3 ++ > libavutil/Makefile | 2 + > libavutil/pixelutils.c | 85 ++++++++++++++++++++++++++++++ > libavutil/pixelutils.h | 76 +++++++++++++++++++++++++++ > libavutil/version.h | 2 +- > libavutil/x86/Makefile | 4 ++ > libavutil/x86/pixelutils.asm | 111 ++++++++++++++++++++++++++++++++++++++++ > libavutil/x86/pixelutils.h | 26 ++++++++++ > libavutil/x86/pixelutils_init.c | 54 +++++++++++++++++++ > 10 files changed, 364 insertions(+), 1 deletion(-) > create mode 100644 libavutil/pixelutils.c > create mode 100644 libavutil/pixelutils.h > create mode 100644 libavutil/x86/pixelutils.asm > create mode 100644 libavutil/x86/pixelutils.h > create mode 100644 libavutil/x86/pixelutils_init.c [...] > diff --git a/libavutil/pixelutils.h b/libavutil/pixelutils.h > new file mode 100644 > index 0000000..862d607 > --- /dev/null > +++ b/libavutil/pixelutils.h > @@ -0,0 +1,76 @@ > +/* > + * This file is part of FFmpeg. > + * > + * 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 > + */ > + > +#ifndef AVUTIL_PIXELUTILS_H > +#define AVUTIL_PIXELUTILS_H > + > +#include > +#include > +#include "common.h" > + > +enum AVPixelUtilsBlockSize { > + // Warning: only add entries at the end for ABI compatibility. > + // Ideally, keep only squared dimensions in that enum. > + AV_PIXEL_BLOCKSZ_2x2, > + AV_PIXEL_BLOCKSZ_4x4, > + AV_PIXEL_BLOCKSZ_8x8, > + AV_PIXEL_BLOCKSZ_16x16, > + AV_PIXEL_BLOCKSZ_NB > +}; > + > +/** > + * Sum of abs(src1[x] - src2[x]) > + */ > +typedef int (*av_pixelutils_sad_fn)(const uint8_t *src1, ptrdiff_t stride1, > + const uint8_t *src2, ptrdiff_t stride2); > + > +typedef struct AVPixelUtils { > + /** > + * Sum of absolute differences block functions. > + * src1 and src2 addresses need to be aligned to the block size. > + */ > + av_pixelutils_sad_fn sad[AV_PIXEL_BLOCKSZ_NB]; > + > + /** > + * Sum of absolute differences block functions, (half) unaligned version. > + * src1 address needs to be aligned to the block size. > + * src2 has no alignment requirement; the 'u' refers to this second source. > + */ > + av_pixelutils_sad_fn sad_u[AV_PIXEL_BLOCKSZ_NB]; the ABI depends on AV_PIXEL_BLOCKSZ_NB with this design as the arrays in the struct depend on its value so no enum values could be added [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Complexity theory is the science of finding the exact solution to an approximation. Benchmarking OTOH is finding an approximation of the exact -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From u at pkh.me Sat Aug 2 20:43:12 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Sat, 2 Aug 2014 20:43:12 +0200 Subject: [FFmpeg-devel] [PATCH 1/5] avutil: add pixelutils API In-Reply-To: <53DD2E4F.6060705@gmail.com> References: <1407003621-13611-1-git-send-email-u@pkh.me> <53DD2E4F.6060705@gmail.com> Message-ID: <20140802184312.GL10372@leki> On Sat, Aug 02, 2014 at 08:30:39PM +0200, Lukasz Marek wrote: > >+static av_always_inline int sad_wxh(const uint8_t *src1, ptrdiff_t stride1, > >+ const uint8_t *src2, ptrdiff_t stride2, > >+ int w, int h) > >+{ > >+ int x, y, sum = 0; > >+ > >+ for (y = 0; y < h; y++) { > >+ for (x = 0; x < w; x++) > >+ sum += abs(src1[x] - src2[x]); > > minor: I came out of nowhere to this patch, but maybe FFABS? :) > No difference in generated ASM here -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From michaelni at gmx.at Sat Aug 2 21:05:56 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 21:05:56 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec/avdct: Add get_pixels() Message-ID: <1407006356-14253-1-git-send-email-michaelni@gmx.at> TODO: version bump, update libavfilters to use it Suggested-by: ubitux Signed-off-by: Michael Niedermayer --- libavcodec/avdct.c | 9 +++++++++ libavcodec/avdct.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/libavcodec/avdct.c b/libavcodec/avdct.c index 58f4974..2521256 100644 --- a/libavcodec/avdct.c +++ b/libavcodec/avdct.c @@ -21,6 +21,7 @@ #include "avcodec.h" #include "idctdsp.h" #include "fdctdsp.h" +#include "pixblockdsp.h" #include "avdct.h" #define OFFSET(x) offsetof(AVDCT,x) @@ -117,6 +118,14 @@ int avcodec_dct_init(AVDCT *dsp) } #endif +#if CONFIG_PIXBLOCKDSP + { + PixblockDSPContext pdsp; + ff_pixblockdsp_init(&pdsp, avctx); + COPY(pdsp, get_pixels); + } +#endif + avcodec_close(avctx); av_free(avctx); diff --git a/libavcodec/avdct.h b/libavcodec/avdct.h index 4c9d00f..4190203 100644 --- a/libavcodec/avdct.h +++ b/libavcodec/avdct.h @@ -61,6 +61,10 @@ typedef struct AVDCT { * must use AVOptions to set this field. */ int idct_algo; + + void (*get_pixels)(int16_t *block /* align 16 */, + const uint8_t *pixels /* align 8 */, + int line_size); } AVDCT; /** -- 1.7.9.5 From jamrial at gmail.com Sat Aug 2 21:29:39 2014 From: jamrial at gmail.com (James Almer) Date: Sat, 02 Aug 2014 16:29:39 -0300 Subject: [FFmpeg-devel] [PATCH 1/5] avutil: add pixelutils API In-Reply-To: <1407003621-13611-1-git-send-email-u@pkh.me> References: <1407003621-13611-1-git-send-email-u@pkh.me> Message-ID: <53DD3C23.1010105@gmail.com> On 02/08/14 3:20 PM, Cl?ment B?sch wrote: > + psrlq m0, m6, 32 > + paddw m6, m0 > + psrlq m0, m6, 16 > + paddw m6, m0 > + movd eax, m6 > + movzx eax, ax You could use the HADDW macro here. > +;------------------------------------------------------------------------------- > +; int ff_pixelutils_sad_8x8_mmxext(const uint8_t *src1, ptrdiff_t stride1, > +; const uint8_t *src2, ptrdiff_t stride2); > +;------------------------------------------------------------------------------- > +INIT_MMX mmxext > +cglobal pixelutils_sad_8x8, 4,4,0, src1, stride1, src2, stride2 > + pxor m2, m2 > +%rep 4 > + mova m0, [src1q] > + mova m1, [src1q + stride1q] > + psadbw m0, [src2q] > + psadbw m1, [src2q + stride2q] > + paddw m2, m0 > + paddw m2, m1 > + lea src1q, [src1q + 2*stride1q] > + lea src2q, [src2q + 2*stride2q] > +%endrep > + movd eax, m2 > + RET Adding sad16x16 mmxext should be a matter of using add instead of lea, changing the %rep amount, and using 8 instead of stride[12]q for the mova and psadbw. > --- /dev/null > +++ b/libavutil/x86/pixelutils.h > @@ -0,0 +1,26 @@ > +/* > + * This file is part of FFmpeg. > + * > + * 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 > + */ > + > +#ifndef AVUTIL_X86_PIXELUTILS_H > +#define AVUTIL_X86_PIXELUTILS_H > + > +#include "libavutil/pixelutils.h" > + > +void ff_pixelutils_init_x86(AVPixelUtils *s); This prototype should be in libavutil/pixelutils.h No need to make a whole new header just for it. Maybe you could add a quick test for these functions? Look at lavc/motion-test.c and lavu/float-dsp.c From michaelni at gmx.at Sat Aug 2 21:43:18 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 21:43:18 +0200 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/takdec: move tmp declaration to where its used Message-ID: <1407008599-18700-1-git-send-email-michaelni@gmx.at> Makes the code a bit easier to read Signed-off-by: Michael Niedermayer --- libavcodec/takdec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c index 9bfbfcc..83abab6 100644 --- a/libavcodec/takdec.c +++ b/libavcodec/takdec.c @@ -371,7 +371,7 @@ static int decode_subframe(TAKDecContext *s, int32_t *decoded, int subframe_size, int prev_subframe_size) { GetBitContext *gb = &s->gb; - int tmp, x, y, i, j, ret = 0; + int x, y, i, j, ret = 0; int dshift, size, filter_quant, filter_order; int tfilter[MAX_PREDICTORS]; @@ -421,7 +421,7 @@ static int decode_subframe(TAKDecContext *s, int32_t *decoded, s->predictors[2] = get_sbits(gb, size) << (10 - size); s->predictors[3] = get_sbits(gb, size) << (10 - size); if (filter_order > 4) { - tmp = size - get_bits1(gb); + int tmp = size - get_bits1(gb); for (i = 4; i < filter_order; i++) { if (!(i & 3)) @@ -448,7 +448,7 @@ static int decode_subframe(TAKDecContext *s, int32_t *decoded, x = 1 << (32 - (15 - filter_quant)); y = 1 << ((15 - filter_quant) - 1); for (i = 0, j = filter_order - 1; i < filter_order / 2; i++, j--) { - tmp = y + tfilter[j]; + int tmp = y + tfilter[j]; s->filter[j] = x - ((tfilter[i] + y) >> (15 - filter_quant)); s->filter[i] = x - ((tfilter[j] + y) >> (15 - filter_quant)); } @@ -463,7 +463,7 @@ static int decode_subframe(TAKDecContext *s, int32_t *decoded, y = FF_ARRAY_ELEMS(s->residues) - filter_order; x = subframe_size - filter_order; while (x > 0) { - tmp = FFMIN(y, x); + int tmp = FFMIN(y, x); for (i = 0; i < tmp; i++) { int v = 1 << (filter_quant - 1); -- 1.7.9.5 From michaelni at gmx.at Sat Aug 2 21:43:19 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 21:43:19 +0200 Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/takdec: remove unused variable In-Reply-To: <1407008599-18700-1-git-send-email-michaelni@gmx.at> References: <1407008599-18700-1-git-send-email-michaelni@gmx.at> Message-ID: <1407008599-18700-2-git-send-email-michaelni@gmx.at> Found-by: CSA Signed-off-by: Michael Niedermayer --- libavcodec/takdec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c index 83abab6..5810a01 100644 --- a/libavcodec/takdec.c +++ b/libavcodec/takdec.c @@ -448,7 +448,6 @@ static int decode_subframe(TAKDecContext *s, int32_t *decoded, x = 1 << (32 - (15 - filter_quant)); y = 1 << ((15 - filter_quant) - 1); for (i = 0, j = filter_order - 1; i < filter_order / 2; i++, j--) { - int tmp = y + tfilter[j]; s->filter[j] = x - ((tfilter[i] + y) >> (15 - filter_quant)); s->filter[i] = x - ((tfilter[j] + y) >> (15 - filter_quant)); } -- 1.7.9.5 From michaelni at gmx.at Sat Aug 2 22:37:30 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 2 Aug 2014 22:37:30 +0200 Subject: [FFmpeg-devel] [PATCH] avformat/tee: flip assigment direction Message-ID: <1407011850-3099-1-git-send-email-michaelni@gmx.at> Found-by: CSA Signed-off-by: Michael Niedermayer --- libavformat/tee.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/tee.c b/libavformat/tee.c index f26e157..681f943 100644 --- a/libavformat/tee.c +++ b/libavformat/tee.c @@ -467,7 +467,7 @@ static int tee_write_packet(AVFormatContext *avf, AVPacket *pkt) if ((ret = av_copy_packet(&pkt2, pkt)) < 0 || (ret = av_dup_packet(&pkt2))< 0) if (!ret_all) { - ret = ret_all; + ret_all = ret; continue; } tb = avf ->streams[s ]->time_base; -- 1.7.9.5 From u at pkh.me Sat Aug 2 23:13:42 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Sat, 2 Aug 2014 23:13:42 +0200 Subject: [FFmpeg-devel] [PATCH 1/5] avutil: add pixelutils API In-Reply-To: <53DD3C23.1010105@gmail.com> References: <1407003621-13611-1-git-send-email-u@pkh.me> <53DD3C23.1010105@gmail.com> Message-ID: <20140802211342.GM10372@leki> On Sat, Aug 02, 2014 at 04:29:39PM -0300, James Almer wrote: > On 02/08/14 3:20 PM, Cl?ment B?sch wrote: > > + psrlq m0, m6, 32 > > + paddw m6, m0 > > + psrlq m0, m6, 16 > > + paddw m6, m0 > > + movd eax, m6 > > + movzx eax, ax > > You could use the HADDW macro here. > error: undefined symbol `pw_1' (first use) sounds somehow constraining. I'll keep my version until you benchmark to prove me HADDW is faster on an old MMX cpu ;) > > +;------------------------------------------------------------------------------- > > +; int ff_pixelutils_sad_8x8_mmxext(const uint8_t *src1, ptrdiff_t stride1, > > +; const uint8_t *src2, ptrdiff_t stride2); > > +;------------------------------------------------------------------------------- > > +INIT_MMX mmxext > > +cglobal pixelutils_sad_8x8, 4,4,0, src1, stride1, src2, stride2 > > + pxor m2, m2 > > +%rep 4 > > + mova m0, [src1q] > > + mova m1, [src1q + stride1q] > > + psadbw m0, [src2q] > > + psadbw m1, [src2q + stride2q] > > + paddw m2, m0 > > + paddw m2, m1 > > + lea src1q, [src1q + 2*stride1q] > > + lea src2q, [src2q + 2*stride2q] > > +%endrep > > + movd eax, m2 > > + RET > > Adding sad16x16 mmxext should be a matter of using add instead of lea, changing > the %rep amount, and using 8 instead of stride[12]q for the mova and psadbw. > Yeah right, added. Thanks. > > --- /dev/null > > +++ b/libavutil/x86/pixelutils.h > > @@ -0,0 +1,26 @@ > > +/* > > + * This file is part of FFmpeg. > > + * > > + * 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 > > + */ > > + > > +#ifndef AVUTIL_X86_PIXELUTILS_H > > +#define AVUTIL_X86_PIXELUTILS_H > > + > > +#include "libavutil/pixelutils.h" > > + > > +void ff_pixelutils_init_x86(AVPixelUtils *s); > > This prototype should be in libavutil/pixelutils.h > No need to make a whole new header just for it. > No, libavutil/pixelutils.h is public, I don't want to have private prototypes in it. > Maybe you could add a quick test for these functions? Look at lavc/motion-test.c and > lavu/float-dsp.c Added. I'll resubmit a patchset in a moment. -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From u at pkh.me Sat Aug 2 23:15:02 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Sat, 2 Aug 2014 23:15:02 +0200 Subject: [FFmpeg-devel] [PATCH 1/5] avutil: add pixelutils API In-Reply-To: <20140802183527.GV4649@nb4> References: <1407003621-13611-1-git-send-email-u@pkh.me> <20140802183527.GV4649@nb4> Message-ID: <20140802211502.GN10372@leki> On Sat, Aug 02, 2014 at 08:35:27PM +0200, Michael Niedermayer wrote: [...] > > +typedef struct AVPixelUtils { > > + /** > > + * Sum of absolute differences block functions. > > + * src1 and src2 addresses need to be aligned to the block size. > > + */ > > + av_pixelutils_sad_fn sad[AV_PIXEL_BLOCKSZ_NB]; > > + > > + /** > > + * Sum of absolute differences block functions, (half) unaligned version. > > + * src1 address needs to be aligned to the block size. > > + * src2 has no alignment requirement; the 'u' refers to this second source. > > + */ > > + av_pixelutils_sad_fn sad_u[AV_PIXEL_BLOCKSZ_NB]; > > the ABI depends on AV_PIXEL_BLOCKSZ_NB with this design as the arrays > in the struct depend on its value so no enum values could be added Right. I simplified the whole API with calling just one function. It simplifies a lot the usage in filters and it's also ABI stable. New patchset incoming. [...] -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From jamrial at gmail.com Sat Aug 2 23:25:01 2014 From: jamrial at gmail.com (James Almer) Date: Sat, 02 Aug 2014 18:25:01 -0300 Subject: [FFmpeg-devel] [PATCH 1/5] avutil: add pixelutils API In-Reply-To: <20140802211342.GM10372@leki> References: <1407003621-13611-1-git-send-email-u@pkh.me> <53DD3C23.1010105@gmail.com> <20140802211342.GM10372@leki> Message-ID: <53DD572D.1020509@gmail.com> On 02/08/14 6:13 PM, Cl?ment B?sch wrote: > On Sat, Aug 02, 2014 at 04:29:39PM -0300, James Almer wrote: >> On 02/08/14 3:20 PM, Cl?ment B?sch wrote: >>> + psrlq m0, m6, 32 >>> + paddw m6, m0 >>> + psrlq m0, m6, 16 >>> + paddw m6, m0 >>> + movd eax, m6 >>> + movzx eax, ax >> >> You could use the HADDW macro here. >> > > error: undefined symbol `pw_1' (first use) > > sounds somehow constraining. I'll keep my version until you benchmark to > prove me HADDW is faster on an old MMX cpu ;) I have no idea if it's faster, nor a way to test that for that matter. It's four instructions instead of six, but pmaddwd + memory operand is probably not fast enough on old cpus. > >>> +;------------------------------------------------------------------------------- >>> +; int ff_pixelutils_sad_8x8_mmxext(const uint8_t *src1, ptrdiff_t stride1, >>> +; const uint8_t *src2, ptrdiff_t stride2); >>> +;------------------------------------------------------------------------------- >>> +INIT_MMX mmxext >>> +cglobal pixelutils_sad_8x8, 4,4,0, src1, stride1, src2, stride2 >>> + pxor m2, m2 >>> +%rep 4 >>> + mova m0, [src1q] >>> + mova m1, [src1q + stride1q] >>> + psadbw m0, [src2q] >>> + psadbw m1, [src2q + stride2q] >>> + paddw m2, m0 >>> + paddw m2, m1 >>> + lea src1q, [src1q + 2*stride1q] >>> + lea src2q, [src2q + 2*stride2q] >>> +%endrep >>> + movd eax, m2 >>> + RET >> >> Adding sad16x16 mmxext should be a matter of using add instead of lea, changing >> the %rep amount, and using 8 instead of stride[12]q for the mova and psadbw. >> > > Yeah right, added. Thanks. > >>> --- /dev/null >>> +++ b/libavutil/x86/pixelutils.h >>> @@ -0,0 +1,26 @@ >>> +/* >>> + * This file is part of FFmpeg. >>> + * >>> + * 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 >>> + */ >>> + >>> +#ifndef AVUTIL_X86_PIXELUTILS_H >>> +#define AVUTIL_X86_PIXELUTILS_H >>> + >>> +#include "libavutil/pixelutils.h" >>> + >>> +void ff_pixelutils_init_x86(AVPixelUtils *s); >> >> This prototype should be in libavutil/pixelutils.h >> No need to make a whole new header just for it. >> > > No, libavutil/pixelutils.h is public, I don't want to have private > prototypes in it. Right, forgot it was public. I had lavc dsp stuff in mind when i said that. > >> Maybe you could add a quick test for these functions? Look at lavc/motion-test.c and >> lavu/float-dsp.c > > Added. > > I'll resubmit a patchset in a moment. > > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > From george at nsup.org Sat Aug 2 23:29:26 2014 From: george at nsup.org (Nicolas George) Date: Sat, 2 Aug 2014 23:29:26 +0200 Subject: [FFmpeg-devel] [PATCH] avformat/tee: flip assigment direction In-Reply-To: <1407011850-3099-1-git-send-email-michaelni@gmx.at> References: <1407011850-3099-1-git-send-email-michaelni@gmx.at> Message-ID: <20140802212926.GA32558@phare.normalesup.org> Le quintidi 15 thermidor, an CCXXII, Michael Niedermayer a ?crit?: > Found-by: CSA > Signed-off-by: Michael Niedermayer > --- > libavformat/tee.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) That looks clearly right. Thanks. Regards, -- Nicolas George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From u at pkh.me Sat Aug 2 23:34:06 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Sat, 2 Aug 2014 23:34:06 +0200 Subject: [FFmpeg-devel] pixelutils API [v2] Message-ID: <1407015251-10660-1-git-send-email-u@pkh.me> Second attempt. Since previously: - much simpler usage (you basically just call av_pixelutils_get_sad_fn() as a user); filters patches updated accordingly. - 16x16 mmxext added (thanks jamrial) - FATE tests Note for the context since I didn't write anything about it in the previous patchset: this is in continuation to avcodec/AVDCT in order to drop dsputils which has been removed from Libav (but kept in FFmpeg for compatibility). After this patchset, libavfilter should be free of dsputils leftovers. BTW, the scope of the pixelutils is to have a bunch of optimized pixel utilities for filters. Currently, we only have SAD utils, more functions are welcome as long as it sticks to this very generic pixels scope: for example, DCT stuff belongs to avcodec/AVDCT (at least for now), and an optimized pixel function that won't be useful for multiple filters belongs in the local context of that filter. A good candidate could be SAD for full-frames, or maybe pixel lines functions for interlaced stuff. pixelutils are optional. It will be enabled in libavutil only on demand (typically if a filter uses it). The default full build will contain it, but if you --disable-filters, libavutil will no longer integrate it. Ah, and before I forget; we are kind of in a hurry since this is meant to avoid some ABI issues in the next release. So if you want to review it, please do it quickly. Thanks, From u at pkh.me Sat Aug 2 23:34:07 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Sat, 2 Aug 2014 23:34:07 +0200 Subject: [FFmpeg-devel] [PATCH 1/5] avutil: add pixelutils API In-Reply-To: <1407015251-10660-1-git-send-email-u@pkh.me> References: <1407015251-10660-1-git-send-email-u@pkh.me> Message-ID: <1407015251-10660-2-git-send-email-u@pkh.me> --- configure | 2 + doc/APIchanges | 3 + libavutil/Makefile | 3 + libavutil/pixelutils.c | 142 ++++++++++++++++++++++++++++++++++++ libavutil/pixelutils.h | 52 ++++++++++++++ libavutil/version.h | 2 +- libavutil/x86/Makefile | 4 ++ libavutil/x86/pixelutils.asm | 155 ++++++++++++++++++++++++++++++++++++++++ libavutil/x86/pixelutils.h | 26 +++++++ libavutil/x86/pixelutils_init.c | 58 +++++++++++++++ tests/fate/libavutil.mak | 5 ++ tests/ref/fate/pixelutils | 15 ++++ 12 files changed, 466 insertions(+), 1 deletion(-) create mode 100644 libavutil/pixelutils.c create mode 100644 libavutil/pixelutils.h create mode 100644 libavutil/x86/pixelutils.asm create mode 100644 libavutil/x86/pixelutils.h create mode 100644 libavutil/x86/pixelutils_init.c create mode 100644 tests/ref/fate/pixelutils diff --git a/configure b/configure index 9c3af50..57edd1d 100755 --- a/configure +++ b/configure @@ -144,6 +144,7 @@ Component options: --disable-mdct disable MDCT code --disable-rdft disable RDFT code --disable-fft disable FFT code + --disable-pixelutils disable pixel utils in libavutil Hardware accelerators: --disable-dxva2 disable DXVA2 code [autodetect] @@ -1451,6 +1452,7 @@ SUBSYSTEM_LIST=" lsp lzo mdct + pixelutils network rdft " diff --git a/doc/APIchanges b/doc/APIchanges index abca377..69ca682 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2012-10-22 API changes, most recent first: +2014-08-02 - xxxxxxx - lavu 52.95.100 - pixelutils.h + Add pixelutils API with SAD functions + 2014-07-30 - ba3e331 - lavu 52.94.100 - frame.h Add av_frame_side_data_name() diff --git a/libavutil/Makefile b/libavutil/Makefile index 91751dc..d57a741 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -44,6 +44,7 @@ HEADERS = adler32.h \ opt.h \ parseutils.h \ pixdesc.h \ + pixelutils.h \ pixfmt.h \ random_seed.h \ replaygain.h \ @@ -113,6 +114,7 @@ OBJS = adler32.o \ opt.o \ parseutils.o \ pixdesc.o \ + pixelutils.o \ random_seed.o \ rational.o \ rc4.o \ @@ -170,6 +172,7 @@ TESTPROGS = adler32 \ pca \ parseutils \ pixdesc \ + pixelutils \ random_seed \ rational \ ripemd \ diff --git a/libavutil/pixelutils.c b/libavutil/pixelutils.c new file mode 100644 index 0000000..278aa80 --- /dev/null +++ b/libavutil/pixelutils.c @@ -0,0 +1,142 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "common.h" +#include "pixelutils.h" + +#if CONFIG_PIXELUTILS + +#include "x86/pixelutils.h" + +static av_always_inline int sad_wxh(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2, + int w, int h) +{ + int x, y, sum = 0; + + for (y = 0; y < h; y++) { + for (x = 0; x < w; x++) + sum += abs(src1[x] - src2[x]); + src1 += stride1; + src2 += stride2; + } + return sum; +} + +#define DECLARE_BLOCK_FUNCTIONS(size) \ +static int block_sad_##size##x##size##_c(const uint8_t *src1, ptrdiff_t stride1, \ + const uint8_t *src2, ptrdiff_t stride2) \ +{ \ + return sad_wxh(src1, stride1, src2, stride2, size, size); \ +} + +DECLARE_BLOCK_FUNCTIONS(2) +DECLARE_BLOCK_FUNCTIONS(4) +DECLARE_BLOCK_FUNCTIONS(8) +DECLARE_BLOCK_FUNCTIONS(16) + +static const av_pixelutils_sad_fn sad_c[] = { + block_sad_2x2_c, + block_sad_4x4_c, + block_sad_8x8_c, + block_sad_16x16_c, +}; + +#endif /* CONFIG_PIXELUTILS */ + +av_pixelutils_sad_fn av_pixelutils_get_sad_fn(int w_bits, int h_bits, int aligned, void *log_ctx) +{ +#if !CONFIG_PIXELUTILS + av_log(log_ctx, AV_LOG_ERROR, "pixelutils support is required " + "but libavutil is not compiled with it\n"); + return NULL; +#else + av_pixelutils_sad_fn sad[FF_ARRAY_ELEMS(sad_c)]; + + memcpy(sad, sad_c, sizeof(sad)); + + if (w_bits < 1 || w_bits > FF_ARRAY_ELEMS(sad) || + h_bits < 1 || h_bits > FF_ARRAY_ELEMS(sad)) + return NULL; + if (w_bits != h_bits) // only squared sad for now + return NULL; + +#if ARCH_X86 + ff_pixelutils_sad_init_x86(sad, aligned); +#endif + + return sad[w_bits - 1]; +#endif +} + +#ifdef TEST +#define W1 320 +#define H1 240 +#define W2 640 +#define H2 480 +int main(void) +{ + int i, a, ret = 0; + DECLARE_ALIGNED(32, uint32_t, buf1)[W1*H1]; + DECLARE_ALIGNED(32, uint32_t, buf2)[W2*H2]; + uint32_t state = 0; + + for (i = 0; i < W1*H1; i++) { + buf1[i] = state; + state = state * 1664525 + 1013904223; + } + + for (i = 0; i < W2*H2; i++) { + buf2[i] = state; + state = state * 1664525 + 1013904223; + } + + for (a = 0; a < 3; a++) { + const uint8_t *block1 = (const uint8_t *)buf1; + const uint8_t *block2 = (const uint8_t *)buf2; + + switch (a) { + case 0: + printf(":: src1 unaligned | src2 unaligned\n"); + block1++; + block2++; + break; + case 1: + printf(":: src1 aligned | src2 unaligned\n"); + block2++; + break; + case 2: + printf(":: src1 aligned | src2 aligned\n"); + break; + } + for (i = 1; i <= FF_ARRAY_ELEMS(sad_c); i++) { + av_pixelutils_sad_fn f_ref = sad_c[i - 1]; + av_pixelutils_sad_fn f_out = av_pixelutils_get_sad_fn(i, i, a, NULL); + const int out = f_out(block1, W1, block2, W2); + const int ref = f_ref(block1, W1, block2, W2); + printf("[%s] SAD %dx%d=%d ref=%d\n", + out == ref ? "OK" : "FAIL", 1< +#include +#include "common.h" + +/** + * Sum of abs(src1[x] - src2[x]) + */ +typedef int (*av_pixelutils_sad_fn)(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2); + +/** + * Get a potentially optimized pointer to a Sum-of-absolute-differences + * function (see the av_pixelutils_sad_fn prototype). + * + * @param w_bits 1< +;* Copyright (C) 2014 Cl?ment B?sch +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "x86util.asm" + +SECTION_TEXT + +;------------------------------------------------------------------------------- +; int ff_pixelutils_sad_8x8_mmx(const uint8_t *src1, ptrdiff_t stride1, +; const uint8_t *src2, ptrdiff_t stride2); +;------------------------------------------------------------------------------- +INIT_MMX mmx +cglobal pixelutils_sad_8x8, 4,4,0, src1, stride1, src2, stride2 + pxor m7, m7 + pxor m6, m6 +%rep 4 + mova m0, [src1q] + mova m2, [src1q + stride1q] + mova m1, [src2q] + mova m3, [src2q + stride2q] + psubusb m4, m0, m1 + psubusb m5, m2, m3 + psubusb m1, m0 + psubusb m3, m2 + por m1, m4 + por m3, m5 + punpcklbw m0, m1, m7 + punpcklbw m2, m3, m7 + punpckhbw m1, m7 + punpckhbw m3, m7 + paddw m0, m1 + paddw m2, m3 + paddw m0, m2 + paddw m6, m0 + lea src1q, [src1q + 2*stride1q] + lea src2q, [src2q + 2*stride2q] +%endrep + psrlq m0, m6, 32 + paddw m6, m0 + psrlq m0, m6, 16 + paddw m6, m0 + movd eax, m6 + movzx eax, ax + RET + +;------------------------------------------------------------------------------- +; int ff_pixelutils_sad_8x8_mmxext(const uint8_t *src1, ptrdiff_t stride1, +; const uint8_t *src2, ptrdiff_t stride2); +;------------------------------------------------------------------------------- +INIT_MMX mmxext +cglobal pixelutils_sad_8x8, 4,4,0, src1, stride1, src2, stride2 + pxor m2, m2 +%rep 4 + mova m0, [src1q] + mova m1, [src1q + stride1q] + psadbw m0, [src2q] + psadbw m1, [src2q + stride2q] + paddw m2, m0 + paddw m2, m1 + lea src1q, [src1q + 2*stride1q] + lea src2q, [src2q + 2*stride2q] +%endrep + movd eax, m2 + RET + +;------------------------------------------------------------------------------- +; int ff_pixelutils_sad_16x16_mmxext(const uint8_t *src1, ptrdiff_t stride1, +; const uint8_t *src2, ptrdiff_t stride2); +;------------------------------------------------------------------------------- +INIT_MMX mmxext +cglobal pixelutils_sad_16x16, 4,4,0, src1, stride1, src2, stride2 + pxor m2, m2 +%rep 16 + mova m0, [src1q] + mova m1, [src1q + 8] + psadbw m0, [src2q] + psadbw m1, [src2q + 8] + paddw m2, m0 + paddw m2, m1 + add src1q, stride1q + add src2q, stride2q +%endrep + movd eax, m2 + RET + +;------------------------------------------------------------------------------- +; int ff_pixelutils_sad_16x16_sse(const uint8_t *src1, ptrdiff_t stride1, +; const uint8_t *src2, ptrdiff_t stride2); +;------------------------------------------------------------------------------- +INIT_XMM sse2 +cglobal pixelutils_sad_16x16, 4,4,5, src1, stride1, src2, stride2 + pxor m4, m4 +%rep 8 + movu m0, [src1q] + movu m1, [src1q + stride1q] + movu m2, [src2q] + movu m3, [src2q + stride2q] + psadbw m0, m2 + psadbw m1, m3 + paddw m4, m0 + paddw m4, m1 + lea src1q, [src1q + 2*stride1q] + lea src2q, [src2q + 2*stride2q] +%endrep + movhlps m0, m4 + paddw m4, m0 + movd eax, m4 + RET + +;------------------------------------------------------------------------------- +; int ff_pixelutils_sad_[au]_16x16_sse(const uint8_t *src1, ptrdiff_t stride1, +; const uint8_t *src2, ptrdiff_t stride2); +;------------------------------------------------------------------------------- +%macro SAD_XMM_16x16 1 +INIT_XMM sse2 +cglobal pixelutils_sad_%1_16x16, 4,4,3, src1, stride1, src2, stride2 + pxor m2, m2 +%rep 8 + mov%1 m0, [src2q] + mov%1 m1, [src2q + stride2q] + psadbw m0, [src1q] + psadbw m1, [src1q + stride1q] + paddw m2, m0 + paddw m2, m1 + lea src1q, [src1q + 2*stride1q] + lea src2q, [src2q + 2*stride2q] +%endrep + movhlps m0, m2 + paddw m2, m0 + movd eax, m2 + RET +%endmacro + +SAD_XMM_16x16 a +SAD_XMM_16x16 u diff --git a/libavutil/x86/pixelutils.h b/libavutil/x86/pixelutils.h new file mode 100644 index 0000000..876cf46 --- /dev/null +++ b/libavutil/x86/pixelutils.h @@ -0,0 +1,26 @@ +/* + * This file is part of FFmpeg. + * + * 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 + */ + +#ifndef AVUTIL_X86_PIXELUTILS_H +#define AVUTIL_X86_PIXELUTILS_H + +#include "libavutil/pixelutils.h" + +void ff_pixelutils_sad_init_x86(av_pixelutils_sad_fn *sad, int aligned); + +#endif /* AVUTIL_X86_PIXELUTILS_H */ diff --git a/libavutil/x86/pixelutils_init.c b/libavutil/x86/pixelutils_init.c new file mode 100644 index 0000000..d600510 --- /dev/null +++ b/libavutil/x86/pixelutils_init.c @@ -0,0 +1,58 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#include "pixelutils.h" +#include "cpu.h" + +int ff_pixelutils_sad_8x8_mmx(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2); +int ff_pixelutils_sad_8x8_mmxext(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2); + +int ff_pixelutils_sad_16x16_mmxext(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2); +int ff_pixelutils_sad_16x16_sse2(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2); +int ff_pixelutils_sad_a_16x16_sse2(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2); +int ff_pixelutils_sad_u_16x16_sse2(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2); + +void ff_pixelutils_sad_init_x86(av_pixelutils_sad_fn *sad, int aligned) +{ + int cpu_flags = av_get_cpu_flags(); + + if (EXTERNAL_MMX(cpu_flags)) { + sad[2] = ff_pixelutils_sad_8x8_mmx; + } + + if (EXTERNAL_MMXEXT(cpu_flags)) { + sad[2] = ff_pixelutils_sad_8x8_mmxext; + sad[3] = ff_pixelutils_sad_16x16_mmxext; + } + + if (EXTERNAL_SSE2(cpu_flags)) { + switch (aligned) { + case 0: sad[3] = ff_pixelutils_sad_16x16_sse2; break; // src1 unaligned, src2 unaligned + case 1: sad[3] = ff_pixelutils_sad_u_16x16_sse2; break; // src1 aligned, src2 unaligned + case 2: sad[3] = ff_pixelutils_sad_a_16x16_sse2; break; // src1 aligned, src2 aligned + } + } +} diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak index 526ec16..68af50f 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -74,6 +74,10 @@ FATE_LIBAVUTIL += fate-parseutils fate-parseutils: libavutil/parseutils-test$(EXESUF) fate-parseutils: CMD = run libavutil/parseutils-test +FATE_LIBAVUTIL-$(CONFIG_PIXELUTILS) += fate-pixelutils +fate-pixelutils: libavutil/pixelutils-test$(EXESUF) +fate-pixelutils: CMD = run libavutil/pixelutils-test + FATE_LIBAVUTIL += fate-random_seed fate-random_seed: libavutil/random_seed-test$(EXESUF) fate-random_seed: CMD = run libavutil/random_seed-test @@ -99,5 +103,6 @@ FATE_LIBAVUTIL += fate-xtea fate-xtea: libavutil/xtea-test$(EXESUF) fate-xtea: CMD = run libavutil/xtea-test +FATE_LIBAVUTIL += $(FATE_LIBAVUTIL-yes) FATE-$(CONFIG_AVUTIL) += $(FATE_LIBAVUTIL) fate-libavutil: $(FATE_LIBAVUTIL) diff --git a/tests/ref/fate/pixelutils b/tests/ref/fate/pixelutils new file mode 100644 index 0000000..308285c --- /dev/null +++ b/tests/ref/fate/pixelutils @@ -0,0 +1,15 @@ +:: src1 unaligned | src2 unaligned +[OK] SAD 2x2=436 ref=436 +[OK] SAD 4x4=1232 ref=1232 +[OK] SAD 8x8=4906 ref=4906 +[OK] SAD 16x16=21601 ref=21601 +:: src1 aligned | src2 unaligned +[OK] SAD 2x2=280 ref=280 +[OK] SAD 4x4=1724 ref=1724 +[OK] SAD 8x8=5988 ref=5988 +[OK] SAD 16x16=22625 ref=22625 +:: src1 aligned | src2 aligned +[OK] SAD 2x2=366 ref=366 +[OK] SAD 4x4=1264 ref=1264 +[OK] SAD 8x8=4874 ref=4874 +[OK] SAD 16x16=21217 ref=21217 -- 2.0.2 From u at pkh.me Sat Aug 2 23:34:08 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Sat, 2 Aug 2014 23:34:08 +0200 Subject: [FFmpeg-devel] [PATCH 2/5] build: remove wrong avcodec dep in decimate In-Reply-To: <1407015251-10660-1-git-send-email-u@pkh.me> References: <1407015251-10660-1-git-send-email-u@pkh.me> Message-ID: <1407015251-10660-3-git-send-email-u@pkh.me> This was probably a mistake with mpdecimate. The decimate filter doesn't depend on avcodec. --- configure | 1 - 1 file changed, 1 deletion(-) diff --git a/configure b/configure index 57edd1d..5159f10 100755 --- a/configure +++ b/configure @@ -5241,7 +5241,6 @@ enabled amovie_filter && prepend avfilter_deps "avformat avcodec" enabled aresample_filter && prepend avfilter_deps "swresample" enabled asyncts_filter && prepend avfilter_deps "avresample" enabled atempo_filter && prepend avfilter_deps "avcodec" -enabled decimate_filter && prepend avfilter_deps "avcodec" enabled deshake_filter && prepend avfilter_deps "avcodec" enabled ebur128_filter && enabled swresample && prepend avfilter_deps "swresample" enabled elbg_filter && prepend avfilter_deps "avcodec" -- 2.0.2 From u at pkh.me Sat Aug 2 23:34:09 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Sat, 2 Aug 2014 23:34:09 +0200 Subject: [FFmpeg-devel] [PATCH 3/5] avfilter/deshake: remove avcodec dependency In-Reply-To: <1407015251-10660-1-git-send-email-u@pkh.me> References: <1407015251-10660-1-git-send-email-u@pkh.me> Message-ID: <1407015251-10660-4-git-send-email-u@pkh.me> --- configure | 4 +--- libavfilter/deshake.h | 5 ++--- libavfilter/vf_deshake.c | 20 ++++++++------------ 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/configure b/configure index 5159f10..bc187a5 100755 --- a/configure +++ b/configure @@ -2531,8 +2531,7 @@ cropdetect_filter_deps="gpl" dctdnoiz_filter_deps="avcodec" dctdnoiz_filter_select="dct" delogo_filter_deps="gpl" -deshake_filter_deps="avcodec" -deshake_filter_select="me_cmp" +deshake_filter_select="pixelutils" drawtext_filter_deps="libfreetype" ebur128_filter_deps="gpl" flite_filter_deps="libflite" @@ -5241,7 +5240,6 @@ enabled amovie_filter && prepend avfilter_deps "avformat avcodec" enabled aresample_filter && prepend avfilter_deps "swresample" enabled asyncts_filter && prepend avfilter_deps "avresample" enabled atempo_filter && prepend avfilter_deps "avcodec" -enabled deshake_filter && prepend avfilter_deps "avcodec" enabled ebur128_filter && enabled swresample && prepend avfilter_deps "swresample" enabled elbg_filter && prepend avfilter_deps "avcodec" enabled mcdeint_filter && prepend avfilter_deps "avcodec" diff --git a/libavfilter/deshake.h b/libavfilter/deshake.h index 615953c..f61ed80 100644 --- a/libavfilter/deshake.h +++ b/libavfilter/deshake.h @@ -24,8 +24,8 @@ #include "config.h" #include "avfilter.h" -#include "libavcodec/dsputil.h" #include "transform.h" +#include "libavutil/pixelutils.h" #if CONFIG_OPENCL #include "libavutil/opencl.h" #endif @@ -80,8 +80,7 @@ typedef struct { int blocksize; ///< Size of blocks to compare int contrast; ///< Contrast threshold int search; ///< Motion search method - AVCodecContext *avctx; - DSPContext c; ///< Context providing optimized SAD methods + av_pixelutils_sad_fn sad; ///< Sum of the absolute difference function Transform last; ///< Transform from last frame int refcount; ///< Number of reference frames (defines averaging window) FILE *fp; diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c index 50aa451..95a6c51 100644 --- a/libavfilter/vf_deshake.c +++ b/libavfilter/vf_deshake.c @@ -57,7 +57,6 @@ #include "libavutil/mem.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" -#include "libavcodec/dsputil.h" #include "deshake.h" #include "deshake_opencl.h" @@ -132,9 +131,8 @@ static void find_block_motion(DeshakeContext *deshake, uint8_t *src1, int smallest = INT_MAX; int tmp, tmp2; - #define CMP(i, j) deshake->c.sad[0](NULL, src1 + cy * stride + cx, \ - src2 + (j) * stride + (i), stride, \ - deshake->blocksize) + #define CMP(i, j) deshake->sad(src1 + cy * stride + cx, stride,\ + src2 + (j) * stride + (i), stride) if (deshake->search == EXHAUSTIVE) { // Compare every possible position - this is sloooow! @@ -201,7 +199,7 @@ static int block_contrast(uint8_t *src, int x, int y, int stride, int blocksize) int i, j, pos; for (i = 0; i <= blocksize * 2; i++) { - // We use a width of 16 here to match the libavcodec sad functions + // We use a width of 16 here to match the sad function for (j = 0; j <= 15; j++) { pos = (y - i) * stride + (x - j); if (src[pos] < lowest) @@ -263,7 +261,7 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2, pos = 0; // Find motion for every block and store the motion vector in the counts for (y = deshake->ry; y < height - deshake->ry - (deshake->blocksize * 2); y += deshake->blocksize * 2) { - // We use a width of 16 here to match the libavcodec sad functions + // We use a width of 16 here to match the sad function for (x = deshake->rx; x < width - deshake->rx - 16; x += 16) { // If the contrast is too low, just skip this block as it probably // won't be very useful to us. @@ -351,6 +349,10 @@ static av_cold int init(AVFilterContext *ctx) int ret; DeshakeContext *deshake = ctx->priv; + deshake->sad = av_pixelutils_get_sad_fn(4, 4, 1, deshake); // 16x16, 2nd source unaligned + if (!deshake->sad) + return AVERROR(EINVAL); + deshake->refcount = 20; // XXX: add to options? deshake->blocksize /= 2; deshake->blocksize = av_clip(deshake->blocksize, 4, 128); @@ -413,9 +415,6 @@ static int config_props(AVFilterLink *link) deshake->last.angle = 0; deshake->last.zoom = 0; - deshake->avctx = avcodec_alloc_context3(NULL); - avpriv_dsputil_init(&deshake->c, deshake->avctx); - return 0; } @@ -428,9 +427,6 @@ static av_cold void uninit(AVFilterContext *ctx) av_frame_free(&deshake->ref); if (deshake->fp) fclose(deshake->fp); - if (deshake->avctx) - avcodec_close(deshake->avctx); - av_freep(&deshake->avctx); } static int filter_frame(AVFilterLink *link, AVFrame *in) -- 2.0.2 From u at pkh.me Sat Aug 2 23:34:10 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Sat, 2 Aug 2014 23:34:10 +0200 Subject: [FFmpeg-devel] [PATCH 4/5] avfilter/mp_decimate: remove avcodec dependency In-Reply-To: <1407015251-10660-1-git-send-email-u@pkh.me> References: <1407015251-10660-1-git-send-email-u@pkh.me> Message-ID: <1407015251-10660-5-git-send-email-u@pkh.me> --- configure | 4 ++-- libavfilter/vf_mpdecimate.c | 36 ++++++++++++------------------------ 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/configure b/configure index bc187a5..210cafb 100755 --- a/configure +++ b/configure @@ -2549,8 +2549,8 @@ ladspa_filter_extralibs='$ldl' mcdeint_filter_deps="avcodec gpl" movie_filter_deps="avcodec avformat" mp_filter_deps="gpl avcodec swscale inline_asm" -mpdecimate_filter_deps="gpl avcodec" -mpdecimate_filter_select="me_cmp pixblockdsp" +mpdecimate_filter_deps="gpl" +mpdecimate_filter_select="pixelutils" mptestsrc_filter_deps="gpl" negate_filter_deps="lut_filter" perspective_filter_deps="gpl" diff --git a/libavfilter/vf_mpdecimate.c b/libavfilter/vf_mpdecimate.c index c667a9f..3ed9602 100644 --- a/libavfilter/vf_mpdecimate.c +++ b/libavfilter/vf_mpdecimate.c @@ -26,9 +26,8 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" +#include "libavutil/pixelutils.h" #include "libavutil/timestamp.h" -#include "libavcodec/dsputil.h" -#include "libavcodec/pixblockdsp.h" #include "avfilter.h" #include "internal.h" #include "formats.h" @@ -49,9 +48,7 @@ typedef struct { int hsub, vsub; ///< chroma subsampling values AVFrame *ref; ///< reference picture - DSPContext dspctx; ///< context providing optimized diff routines - PixblockDSPContext pdsp; - AVCodecContext *avctx; ///< codec context required for the DSPContext + av_pixelutils_sad_fn sad; ///< sum of absolute difference function } DecimateContext; #define OFFSET(x) offsetof(DecimateContext, x) @@ -72,25 +69,21 @@ AVFILTER_DEFINE_CLASS(mpdecimate); * Return 1 if the two planes are different, 0 otherwise. */ static int diff_planes(AVFilterContext *ctx, - uint8_t *cur, uint8_t *ref, int linesize, + uint8_t *cur, int cur_linesize, + uint8_t *ref, int ref_linesize, int w, int h) { DecimateContext *decimate = ctx->priv; - DSPContext *dspctx = &decimate->dspctx; - PixblockDSPContext *pdsp = &decimate->pdsp; int x, y; int d, c = 0; int t = (w/16)*(h/16)*decimate->frac; - int16_t block[8*8]; /* compute difference for blocks of 8x8 bytes */ for (y = 0; y < h-7; y += 4) { for (x = 8; x < w-7; x += 4) { - pdsp->diff_pixels(block, - cur+x+y*linesize, - ref+x+y*linesize, linesize); - d = dspctx->sum_abs_dctelem(block); + d = decimate->sad(cur + y*cur_linesize + x, cur_linesize, + ref + y*ref_linesize + x, ref_linesize); if (d > decimate->hi) return 1; if (d > decimate->lo) { @@ -124,7 +117,8 @@ static int decimate_frame(AVFilterContext *ctx, int vsub = plane == 1 || plane == 2 ? decimate->vsub : 0; int hsub = plane == 1 || plane == 2 ? decimate->hsub : 0; if (diff_planes(ctx, - cur->data[plane], ref->data[plane], ref->linesize[plane], + cur->data[plane], cur->linesize[plane], + ref->data[plane], ref->linesize[plane], FF_CEIL_RSHIFT(ref->width, hsub), FF_CEIL_RSHIFT(ref->height, vsub))) return 0; @@ -137,15 +131,13 @@ static av_cold int init(AVFilterContext *ctx) { DecimateContext *decimate = ctx->priv; + decimate->sad = av_pixelutils_get_sad_fn(3, 3, 0, decimate); // 8x8, not aligned on blocksize + if (!decimate->sad) + return AVERROR(EINVAL); + av_log(ctx, AV_LOG_VERBOSE, "max_drop_count:%d hi:%d lo:%d frac:%f\n", decimate->max_drop_count, decimate->hi, decimate->lo, decimate->frac); - decimate->avctx = avcodec_alloc_context3(NULL); - if (!decimate->avctx) - return AVERROR(ENOMEM); - avpriv_dsputil_init(&decimate->dspctx, decimate->avctx); - ff_pixblockdsp_init(&decimate->pdsp, decimate->avctx); - return 0; } @@ -153,10 +145,6 @@ static av_cold void uninit(AVFilterContext *ctx) { DecimateContext *decimate = ctx->priv; av_frame_free(&decimate->ref); - if (decimate->avctx) { - avcodec_close(decimate->avctx); - av_freep(&decimate->avctx); - } } static int query_formats(AVFilterContext *ctx) -- 2.0.2 From u at pkh.me Sat Aug 2 23:34:11 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Sat, 2 Aug 2014 23:34:11 +0200 Subject: [FFmpeg-devel] [PATCH 5/5] avfilter/select: remove optional avcodec dependency In-Reply-To: <1407015251-10660-1-git-send-email-u@pkh.me> References: <1407015251-10660-1-git-send-email-u@pkh.me> Message-ID: <1407015251-10660-6-git-send-email-u@pkh.me> --- configure | 1 + libavfilter/f_select.c | 50 ++++++++++++-------------------------------------- 2 files changed, 13 insertions(+), 38 deletions(-) diff --git a/configure b/configure index 210cafb..b9b1e3b 100755 --- a/configure +++ b/configure @@ -2564,6 +2564,7 @@ removelogo_filter_deps="avcodec avformat swscale" resample_filter_deps="avresample" sab_filter_deps="gpl swscale" scale_filter_deps="swscale" +select_filter_select="pixelutils" smartblur_filter_deps="gpl swscale" showspectrum_filter_deps="avcodec" showspectrum_filter_select="rdft" diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c index 8d2c860..d951b0f 100644 --- a/libavfilter/f_select.c +++ b/libavfilter/f_select.c @@ -28,16 +28,13 @@ #include "libavutil/fifo.h" #include "libavutil/internal.h" #include "libavutil/opt.h" +#include "libavutil/pixelutils.h" #include "avfilter.h" #include "audio.h" #include "formats.h" #include "internal.h" #include "video.h" -#if CONFIG_AVCODEC -#include "libavcodec/dsputil.h" -#endif - static const char *const var_names[] = { "TB", ///< timebase @@ -144,11 +141,8 @@ typedef struct SelectContext { AVExpr *expr; double var_values[VAR_VARS_NB]; int do_scene_detect; ///< 1 if the expression requires scene detection variables, 0 otherwise -#if CONFIG_AVCODEC - AVCodecContext *avctx; ///< codec context required for the DSPContext (scene detect only) - DSPContext c; ///< context providing optimized SAD methods (scene detect only) + av_pixelutils_sad_fn sad; ///< Sum of the absolute difference function (scene detect only) double prev_mafd; ///< previous MAFD (scene detect only) -#endif AVFrame *prev_picref; ///< previous frame (scene detect only) double select; int select_out; ///< mark the selected output pad index @@ -240,18 +234,14 @@ static int config_input(AVFilterLink *inlink) select->var_values[VAR_SAMPLE_RATE] = inlink->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN; -#if CONFIG_AVCODEC if (select->do_scene_detect) { - select->avctx = avcodec_alloc_context3(NULL); - if (!select->avctx) - return AVERROR(ENOMEM); - avpriv_dsputil_init(&select->c, select->avctx); + select->sad = av_pixelutils_get_sad_fn(3, 3, 2, select); // 8x8 both sources aligned + if (!select->sad) + return AVERROR(EINVAL); } -#endif return 0; } -#if CONFIG_AVCODEC static double get_scene_score(AVFilterContext *ctx, AVFrame *frame) { double ret = 0; @@ -259,24 +249,23 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *frame) AVFrame *prev_picref = select->prev_picref; if (prev_picref && - frame->height == prev_picref->height && - frame->width == prev_picref->width && - frame->linesize[0] == prev_picref->linesize[0]) { + frame->height == prev_picref->height && + frame->width == prev_picref->width) { int x, y, nb_sad = 0; int64_t sad = 0; double mafd, diff; uint8_t *p1 = frame->data[0]; uint8_t *p2 = prev_picref->data[0]; - const int linesize = frame->linesize[0]; + const int p1_linesize = frame->linesize[0]; + const int p2_linesize = prev_picref->linesize[0]; for (y = 0; y < frame->height - 8; y += 8) { for (x = 0; x < frame->width*3 - 8; x += 8) { - sad += select->c.sad[1](NULL, p1 + x, p2 + x, - linesize, 8); + sad += select->sad(p1 + x, p1_linesize, p2 + x, p2_linesize); nb_sad += 8 * 8; } - p1 += 8 * linesize; - p2 += 8 * linesize; + p1 += 8 * p1_linesize; + p2 += 8 * p2_linesize; } emms_c(); mafd = nb_sad ? (double)sad / nb_sad : 0; @@ -288,7 +277,6 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *frame) select->prev_picref = av_frame_clone(frame); return ret; } -#endif #define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d)) #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)) @@ -320,7 +308,6 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame) !frame->interlaced_frame ? INTERLACE_TYPE_P : frame->top_field_first ? INTERLACE_TYPE_T : INTERLACE_TYPE_B; select->var_values[VAR_PICT_TYPE] = frame->pict_type; -#if CONFIG_AVCODEC if (select->do_scene_detect) { char buf[32]; select->var_values[VAR_SCENE] = get_scene_score(ctx, frame); @@ -328,7 +315,6 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame) snprintf(buf, sizeof(buf), "%f", select->var_values[VAR_SCENE]); av_dict_set(avpriv_frame_get_metadatap(frame), "lavfi.scene_score", buf, 0); } -#endif break; } @@ -418,15 +404,9 @@ static av_cold void uninit(AVFilterContext *ctx) for (i = 0; i < ctx->nb_outputs; i++) av_freep(&ctx->output_pads[i].name); -#if CONFIG_AVCODEC if (select->do_scene_detect) { av_frame_free(&select->prev_picref); - if (select->avctx) { - avcodec_close(select->avctx); - av_freep(&select->avctx); - } } -#endif } static int query_formats(AVFilterContext *ctx) @@ -495,17 +475,11 @@ AVFILTER_DEFINE_CLASS(select); static av_cold int select_init(AVFilterContext *ctx) { - SelectContext *select = ctx->priv; int ret; if ((ret = init(ctx)) < 0) return ret; - if (select->do_scene_detect && !CONFIG_AVCODEC) { - av_log(ctx, AV_LOG_ERROR, "Scene detection is not available without libavcodec.\n"); - return AVERROR(EINVAL); - } - return 0; } -- 2.0.2 From u at pkh.me Sun Aug 3 00:00:22 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Sun, 3 Aug 2014 00:00:22 +0200 Subject: [FFmpeg-devel] [PATCH] libavformat/icecast.c Add Icecast protocol In-Reply-To: <1406536579-22310-1-git-send-email-epirat07@gmail.com> References: <20140723010618.GV4649@nb4> <1406536579-22310-1-git-send-email-epirat07@gmail.com> Message-ID: <20140802220022.GO10372@leki> On Mon, Jul 28, 2014 at 10:36:19AM +0200, epirat07 at gmail.com wrote: > From: ePirat > > Fix header. Note: you should put that under the --- below so it doesn't end up in the commit description. > --- > Add Icecast protocol, a convenience wrapper for the HTTP protocol > --- > Changelog | 3 + > configure | 1 + > doc/general.texi | 1 + > doc/protocols.texi | 42 ++++++++++ > libavformat/Makefile | 1 + > libavformat/allformats.c | 1 + > libavformat/icecast.c | 209 +++++++++++++++++++++++++++++++++++++++++++++++ > libavformat/version.h | 4 +- > 8 files changed, 260 insertions(+), 2 deletions(-) > create mode 100644 libavformat/icecast.c > [...] > diff --git a/libavformat/icecast.c b/libavformat/icecast.c > new file mode 100644 > index 0000000..77781b2 > --- /dev/null > +++ b/libavformat/icecast.c > @@ -0,0 +1,209 @@ > +/* > + * Icecast protocol for Libav Here it's for FFmpeg > + * Copyright (c) 2014 Marvin Scholz > + * > + * This file is part of FFmpeg. > + * > + * 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 > + */ > + > + [...] > +static int icecast_open(URLContext *h, const char *uri, int flags) > +{ > + IcecastContext *s = h->priv_data; > + > + // Dict to set options that we pass to the HTTP protocol > + AVDictionary *opt_dict = NULL; > + > + // URI part variables > + char h_url[1024], host[1024], auth[1024], path[1024]; > + char *user = NULL, *headers = NULL; > + int port, ret; > + struct AVBPrint bp; You can remove "struct" > + > + av_bprint_init(&bp, 0, 1); > + > + // Build header strings > + cat_header(&bp, "Ice-Name", s->name); > + cat_header(&bp, "Ice-Description", s->description); > + cat_header(&bp, "Ice-URL", s->url); > + cat_header(&bp, "Ice-Genre", s->genre); > + cat_header(&bp, "Ice-Public", s->public ? "1" : "0"); > + if (!av_bprint_is_complete(&bp)) { > + ret = AVERROR(ENOMEM); > + goto cleanup; > + } > + av_bprint_finalize(&bp, &headers); > + > + // Set options > + av_dict_set(&opt_dict, "method", s->legacy_icecast ? "SOURCE" : "PUT", 0); > + av_dict_set(&opt_dict, "auth_type", "basic", 0); > + av_dict_set(&opt_dict, "headers", headers, 0); > + if (NOT_EMPTY(s->content_type)) > + av_dict_set(&opt_dict, "content_type", s->content_type, 0); > + if (NOT_EMPTY(s->user_agent)) > + av_dict_set(&opt_dict, "user_agent", s->user_agent, 0); > + > + // Parse URI > + av_url_split(NULL, 0, auth, sizeof(auth), host, sizeof(host), > + &port, path, sizeof(path), uri); > + > + // Check for auth data in URI > + if (auth[0]) { > + char *sep = strchr(auth,':'); nitstyle: space after , > + if (sep) { > + *sep = 0; > + sep++; > + if (s->pass) { > + av_free(s->pass); > + av_log(h, AV_LOG_WARNING, "Overwriting -password with URI password!\n"); > + } > + s->pass = av_strdup(sep); > + } > + user = av_strdup(auth); > + } > + > + // Build new authstring > + snprintf(auth, sizeof(auth), > + "%s:%s", > + user ? user : DEFAULT_ICE_USER, > + s->pass ? s->pass : ""); > + > + // Check for mountpoint (path) > + if (!path[0] || strcmp(path, "/") == 0) { > + av_log(h, AV_LOG_ERROR, "No mountpoint (path) specified!\n"); > + ret = AVERROR(EIO); > + goto cleanup; > + } > + > + // Build new URI for passing to http protocol > + ff_url_join(h_url, sizeof(h_url), "http", auth, host, port, "%s", path); > + // Finally open http proto handler > + ret = ffurl_open(&s->hd, h_url, AVIO_FLAG_READ_WRITE, NULL, &opt_dict); > + > +cleanup: > + // Free variables pointless comment > + if (user) > + av_freep(&user); > + if (headers) > + av_freep(&headers); pointless ifs [...] Rest LGTM. Please send a rebased patch and I'll apply. -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From u at pkh.me Sun Aug 3 00:08:18 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Sun, 3 Aug 2014 00:08:18 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <6A11773B-CF55-4FA2-BB5E-B1C0EC728A2D@googlemail.com> References: <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> <6A121A20-D5E4-4481-9737-4CA601560451@googlemail.com> <6A11773B-CF55-4FA2-BB5E-B1C0EC728A2D@googlemail.com> Message-ID: <20140802220818.GP10372@leki> On Fri, Aug 01, 2014 at 06:47:38PM +0200, Daniel Oberhoff wrote: [...] > > Did you already explain if / how this filter is > > different from / better than the vignette filter? > > Its completely differen. Vignette modulates brightness, this one geometry, but I will mention it. > So this is a lens correction filter? Maybe rename "rectification" into "lens" or something (the name is kind of really generic). -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From u at pkh.me Sun Aug 3 00:09:20 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Sun, 3 Aug 2014 00:09:20 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <6A121A20-D5E4-4481-9737-4CA601560451@googlemail.com> References: <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> <6A121A20-D5E4-4481-9737-4CA601560451@googlemail.com> Message-ID: <20140802220920.GQ10372@leki> On Fri, Aug 01, 2014 at 01:08:58PM +0200, Daniel Oberhoff wrote: > > Am 01.08.2014 um 13:07 schrieb Carl Eugen Hoyos : > > > Daniel Oberhoff gmail.com> writes: > > > >> all work now, except vuy444p > > > > It's yuv444p > > oops :). > > And how about that test/data/fate/filter-pixfmts-rectification.rep file? Should I commit that? > This is your run results; the references should be in tests/ref/fate. -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From u at pkh.me Sun Aug 3 00:12:31 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Sun, 3 Aug 2014 00:12:31 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> Message-ID: <20140802221231.GR10372@leki> On Fri, Aug 01, 2014 at 12:56:42PM +0200, Daniel Oberhoff wrote: > > Am 01.08.2014 um 12:22 schrieb Cl?ment B?sch : > > > On Fri, Aug 01, 2014 at 12:13:22PM +0200, Daniel Oberhoff wrote: > >> > >> Am 29.07.2014 um 09:54 schrieb Carl Eugen Hoyos : > >> > >>> Daniel Oberhoff gmail.com> writes: > >>> > >>>> OBJS-$(CONFIG_ZOOMPAN_FILTER) += vf_zoompan.o > >>>> +OBJS-$(CONFIG_RECTIFICATION_FILTER) += vf_rectification.o > >>> > >>>> REGISTER_FILTER(ZOOMPAN, zoompan, vf); > >>>> + REGISTER_FILTER(RECTIFICATION, rectification, vf); > >>> > >>> Keep the alphabetic ordering please. > >>> > >> > >> Ok > >> > >>>> + AV_PIX_FMT_YUV410P, > >>>> + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, > >>>> + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, > >>>> + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, > >>>> + AV_PIX_FMT_NONE > >>> > >>> I have no idea what this filter does and since the > >>> most important format (yuv420p) is supported, this > >>> doesn't really matter but yuv410p and yuva444p are > >>> quite exotic formats, I would at least have > >>> expected yuv422p, yuva420p and yuv444p in the list. > >>> > >>> Did you test all above formats (at least the left row)? > >> > >> Added the one from your list that was missing. Can you suggest an easy way of testing all these formats? > >> > > > > > > add a format filter before yours in the filtergraph (-vf > > format=yuv410p,rectification ?) > > Ok, borders can be a bitt different, but otherwise all work now, except vuy444p, which ffmpeg reports as invalid. btw, how can I get the components of a given color in the colorspace? > > > If you want to add a FATE test (which would be really awesome), you can > > grep for "video_filter" in tests/fate/filter-video.mak (to test all pixel > > formats the filter supports), or just make a standard test with framecrc. > > > > [...] > > I did that by adding this: > > FATE_FILTER_PIXFMTS-$(CONFIG_RECTIFICATION_FILTER) += fate-filter-pixfmts-rectification > fate-filter-pixfmts-rectification: CMD = pixfmts "0.6:0.4:0.65:0.4" > > then I ran > > make fate-filter-pixfmts-rectification GEN=1 > > which made a file > > test/data/fate/filter-pixfmts-rectification.rep > This is the result of a normal run to be compared by with the reference which should have also been generated with the help of GEN=1 for your first run. The file(s) generated by GEN=1 need to be tracked. > do I check this in or not? > Of course you are supposed to check if the results make sense. Use make fate-filter-pixfmts-rectifications V=1 to see what's going on. > running > > make fate-filter-pixfmts-rectification GEN=1 > > runs fine? > Of course, it doesn't do the comparison, it generates the reference. > Best > > Daniel -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From michaelni at gmx.at Sun Aug 3 00:36:19 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 00:36:19 +0200 Subject: [FFmpeg-devel] [PATCH 1/5] avutil: add pixelutils API In-Reply-To: <1407015251-10660-2-git-send-email-u@pkh.me> References: <1407015251-10660-1-git-send-email-u@pkh.me> <1407015251-10660-2-git-send-email-u@pkh.me> Message-ID: <20140802223619.GW4649@nb4> On Sat, Aug 02, 2014 at 11:34:07PM +0200, Cl?ment B?sch wrote: > --- > configure | 2 + > doc/APIchanges | 3 + > libavutil/Makefile | 3 + > libavutil/pixelutils.c | 142 ++++++++++++++++++++++++++++++++++++ > libavutil/pixelutils.h | 52 ++++++++++++++ > libavutil/version.h | 2 +- > libavutil/x86/Makefile | 4 ++ > libavutil/x86/pixelutils.asm | 155 ++++++++++++++++++++++++++++++++++++++++ > libavutil/x86/pixelutils.h | 26 +++++++ > libavutil/x86/pixelutils_init.c | 58 +++++++++++++++ > tests/fate/libavutil.mak | 5 ++ > tests/ref/fate/pixelutils | 15 ++++ > 12 files changed, 466 insertions(+), 1 deletion(-) > create mode 100644 libavutil/pixelutils.c > create mode 100644 libavutil/pixelutils.h > create mode 100644 libavutil/x86/pixelutils.asm > create mode 100644 libavutil/x86/pixelutils.h > create mode 100644 libavutil/x86/pixelutils_init.c > create mode 100644 tests/ref/fate/pixelutils > > diff --git a/configure b/configure > index 9c3af50..57edd1d 100755 > --- a/configure > +++ b/configure > @@ -144,6 +144,7 @@ Component options: > --disable-mdct disable MDCT code > --disable-rdft disable RDFT code > --disable-fft disable FFT code > + --disable-pixelutils disable pixel utils in libavutil > > Hardware accelerators: > --disable-dxva2 disable DXVA2 code [autodetect] > @@ -1451,6 +1452,7 @@ SUBSYSTEM_LIST=" > lsp > lzo > mdct > + pixelutils > network > rdft > " > diff --git a/doc/APIchanges b/doc/APIchanges > index abca377..69ca682 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -15,6 +15,9 @@ libavutil: 2012-10-22 > > API changes, most recent first: > > +2014-08-02 - xxxxxxx - lavu 52.95.100 - pixelutils.h > + Add pixelutils API with SAD functions > + > 2014-07-30 - ba3e331 - lavu 52.94.100 - frame.h > Add av_frame_side_data_name() > > diff --git a/libavutil/Makefile b/libavutil/Makefile > index 91751dc..d57a741 100644 > --- a/libavutil/Makefile > +++ b/libavutil/Makefile > @@ -44,6 +44,7 @@ HEADERS = adler32.h \ > opt.h \ > parseutils.h \ > pixdesc.h \ > + pixelutils.h \ > pixfmt.h \ > random_seed.h \ > replaygain.h \ > @@ -113,6 +114,7 @@ OBJS = adler32.o \ > opt.o \ > parseutils.o \ > pixdesc.o \ > + pixelutils.o \ > random_seed.o \ > rational.o \ > rc4.o \ > @@ -170,6 +172,7 @@ TESTPROGS = adler32 \ > pca \ > parseutils \ > pixdesc \ > + pixelutils \ > random_seed \ > rational \ > ripemd \ > diff --git a/libavutil/pixelutils.c b/libavutil/pixelutils.c > new file mode 100644 > index 0000000..278aa80 > --- /dev/null > +++ b/libavutil/pixelutils.c > @@ -0,0 +1,142 @@ > +/* > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#include "config.h" > +#include "common.h" > +#include "pixelutils.h" > + > +#if CONFIG_PIXELUTILS > + > +#include "x86/pixelutils.h" > + > +static av_always_inline int sad_wxh(const uint8_t *src1, ptrdiff_t stride1, > + const uint8_t *src2, ptrdiff_t stride2, > + int w, int h) > +{ > + int x, y, sum = 0; > + > + for (y = 0; y < h; y++) { > + for (x = 0; x < w; x++) > + sum += abs(src1[x] - src2[x]); > + src1 += stride1; > + src2 += stride2; > + } > + return sum; > +} > + > +#define DECLARE_BLOCK_FUNCTIONS(size) \ > +static int block_sad_##size##x##size##_c(const uint8_t *src1, ptrdiff_t stride1, \ > + const uint8_t *src2, ptrdiff_t stride2) \ > +{ \ > + return sad_wxh(src1, stride1, src2, stride2, size, size); \ > +} > + > +DECLARE_BLOCK_FUNCTIONS(2) > +DECLARE_BLOCK_FUNCTIONS(4) > +DECLARE_BLOCK_FUNCTIONS(8) > +DECLARE_BLOCK_FUNCTIONS(16) > + > +static const av_pixelutils_sad_fn sad_c[] = { > + block_sad_2x2_c, > + block_sad_4x4_c, > + block_sad_8x8_c, > + block_sad_16x16_c, > +}; > + > +#endif /* CONFIG_PIXELUTILS */ > + > +av_pixelutils_sad_fn av_pixelutils_get_sad_fn(int w_bits, int h_bits, int aligned, void *log_ctx) > +{ > +#if !CONFIG_PIXELUTILS > + av_log(log_ctx, AV_LOG_ERROR, "pixelutils support is required " > + "but libavutil is not compiled with it\n"); > + return NULL; > +#else > + av_pixelutils_sad_fn sad[FF_ARRAY_ELEMS(sad_c)]; > + > + memcpy(sad, sad_c, sizeof(sad)); > + > + if (w_bits < 1 || w_bits > FF_ARRAY_ELEMS(sad) || > + h_bits < 1 || h_bits > FF_ARRAY_ELEMS(sad)) > + return NULL; > + if (w_bits != h_bits) // only squared sad for now > + return NULL; > + > +#if ARCH_X86 > + ff_pixelutils_sad_init_x86(sad, aligned); > +#endif > + > + return sad[w_bits - 1]; > +#endif > +} > + > +#ifdef TEST > +#define W1 320 > +#define H1 240 > +#define W2 640 > +#define H2 480 > +int main(void) > +{ > + int i, a, ret = 0; > + DECLARE_ALIGNED(32, uint32_t, buf1)[W1*H1]; > + DECLARE_ALIGNED(32, uint32_t, buf2)[W2*H2]; > + uint32_t state = 0; > + > + for (i = 0; i < W1*H1; i++) { > + buf1[i] = state; > + state = state * 1664525 + 1013904223; > + } > + > + for (i = 0; i < W2*H2; i++) { > + buf2[i] = state; > + state = state * 1664525 + 1013904223; > + } the code should in addition be tested with maximal and minimal difference cases [...] > +;------------------------------------------------------------------------------- > +; int ff_pixelutils_sad_[au]_16x16_sse(const uint8_t *src1, ptrdiff_t stride1, > +; const uint8_t *src2, ptrdiff_t stride2); > +;------------------------------------------------------------------------------- > +%macro SAD_XMM_16x16 1 > +INIT_XMM sse2 > +cglobal pixelutils_sad_%1_16x16, 4,4,3, src1, stride1, src2, stride2 > + pxor m2, m2 > +%rep 8 > + mov%1 m0, [src2q] > + mov%1 m1, [src2q + stride2q] > + psadbw m0, [src1q] > + psadbw m1, [src1q + stride1q] > + paddw m2, m0 > + paddw m2, m1 > + lea src1q, [src1q + 2*stride1q] > + lea src2q, [src2q + 2*stride2q] > +%endrep > + movhlps m0, m2 > + paddw m2, m0 > + movd eax, m2 > + RET > +%endmacro there are various improvments possible, though these should be in a seperate patch and not in gcc->yasm but the pxor can be avoided by lifting the first iteration out and using m2 as destination it might be faster to use 2 accumulator registers as that way both could execute with no dependancies on the other as you unroll the loop, addressing can be done with fewer instructions LGTM otherwise [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 3 00:37:30 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 00:37:30 +0200 Subject: [FFmpeg-devel] [PATCH 3/5] avfilter/deshake: remove avcodec dependency In-Reply-To: <1407015251-10660-4-git-send-email-u@pkh.me> References: <1407015251-10660-1-git-send-email-u@pkh.me> <1407015251-10660-4-git-send-email-u@pkh.me> Message-ID: <20140802223730.GX4649@nb4> On Sat, Aug 02, 2014 at 11:34:09PM +0200, Cl?ment B?sch wrote: > --- > configure | 4 +--- > libavfilter/deshake.h | 5 ++--- > libavfilter/vf_deshake.c | 20 ++++++++------------ > 3 files changed, 11 insertions(+), 18 deletions(-) > > diff --git a/configure b/configure > index 5159f10..bc187a5 100755 LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many things microsoft did are stupid, but not doing something just because microsoft did it is even more stupid. If everything ms did were stupid they would be bankrupt already. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From danieloberhoff at gmail.com Sun Aug 3 03:15:52 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Sun, 3 Aug 2014 03:15:52 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <20140802221231.GR10372@leki> References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> <20140802221231.GR10372@leki> Message-ID: <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> Am 03.08.2014 um 00:12 schrieb Cl?ment B?sch : > On Fri, Aug 01, 2014 at 12:56:42PM +0200, Daniel Oberhoff wrote: >> >> Am 01.08.2014 um 12:22 schrieb Cl?ment B?sch : >> >>> On Fri, Aug 01, 2014 at 12:13:22PM +0200, Daniel Oberhoff wrote: >>>> >>>> Am 29.07.2014 um 09:54 schrieb Carl Eugen Hoyos : >>>> >>>>> Daniel Oberhoff gmail.com> writes: >>>>> >>>>>> OBJS-$(CONFIG_ZOOMPAN_FILTER) += vf_zoompan.o >>>>>> +OBJS-$(CONFIG_RECTIFICATION_FILTER) += vf_rectification.o >>>>> >>>>>> REGISTER_FILTER(ZOOMPAN, zoompan, vf); >>>>>> + REGISTER_FILTER(RECTIFICATION, rectification, vf); >>>>> >>>>> Keep the alphabetic ordering please. >>>>> >>>> >>>> Ok >>>> >>>>>> + AV_PIX_FMT_YUV410P, >>>>>> + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, >>>>>> + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, >>>>>> + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, >>>>>> + AV_PIX_FMT_NONE >>>>> >>>>> I have no idea what this filter does and since the >>>>> most important format (yuv420p) is supported, this >>>>> doesn't really matter but yuv410p and yuva444p are >>>>> quite exotic formats, I would at least have >>>>> expected yuv422p, yuva420p and yuv444p in the list. >>>>> >>>>> Did you test all above formats (at least the left row)? >>>> >>>> Added the one from your list that was missing. Can you suggest an easy way of testing all these formats? >>>> >>> >>> >>> add a format filter before yours in the filtergraph (-vf >>> format=yuv410p,rectification ?) >> >> Ok, borders can be a bitt different, but otherwise all work now, except vuy444p, which ffmpeg reports as invalid. btw, how can I get the components of a given color in the colorspace? >> >>> If you want to add a FATE test (which would be really awesome), you can >>> grep for "video_filter" in tests/fate/filter-video.mak (to test all pixel >>> formats the filter supports), or just make a standard test with framecrc. >>> >>> [...] >> >> I did that by adding this: >> >> FATE_FILTER_PIXFMTS-$(CONFIG_RECTIFICATION_FILTER) += fate-filter-pixfmts-rectification >> fate-filter-pixfmts-rectification: CMD = pixfmts "0.6:0.4:0.65:0.4" >> >> then I ran >> >> make fate-filter-pixfmts-rectification GEN=1 >> >> which made a file >> >> test/data/fate/filter-pixfmts-rectification.rep >> > > This is the result of a normal run to be compared by with the reference > which should have also been generated with the help of GEN=1 for your > first run. The file(s) generated by GEN=1 need to be tracked. > >> do I check this in or not? >> > > Of course you are supposed to check if the results make sense. > > Use make fate-filter-pixfmts-rectifications V=1 to see what's going on. > >> running >> >> make fate-filter-pixfmts-rectification GEN=1 >> >> runs fine? >> > > Of course, it doesn't do the comparison, it generates the reference. > >> Best >> >> Daniel > > -- > Cl?ment B. > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel Alright, will get that cleaned up. Since I seem to have all consent I need to also change the license I will see that I get a new patch ready soon. Best and thanks for feedback! Daniel From jamrial at gmail.com Sun Aug 3 04:21:31 2014 From: jamrial at gmail.com (James Almer) Date: Sat, 2 Aug 2014 23:21:31 -0300 Subject: [FFmpeg-devel] [PATCH] x86/hevc_deblock: improve 8bit transpose store macros Message-ID: <1407032491-3873-1-git-send-email-jamrial@gmail.com> Up to four instructions less depending on function and instruction set. Signed-off-by: James Almer --- libavcodec/x86/hevc_deblock.asm | 70 +++++++++++++---------------------------- libavutil/x86/x86util.asm | 9 ++++++ 2 files changed, 31 insertions(+), 48 deletions(-) diff --git a/libavcodec/x86/hevc_deblock.asm b/libavcodec/x86/hevc_deblock.asm index 5951e86..89c0f9b 100644 --- a/libavcodec/x86/hevc_deblock.asm +++ b/libavcodec/x86/hevc_deblock.asm @@ -77,16 +77,10 @@ INIT_XMM sse2 ; in: 4 rows of 8 words in m0..m3 ; out: 8 rows of 4 bytes in %1..%8 %macro TRANSPOSE8x4B_STORE 8 - packuswb m0, m0 - packuswb m1, m1 - packuswb m2, m2 - packuswb m3, m3 - - punpcklbw m0, m1 - punpcklbw m2, m3 - - punpckhwd m6, m0, m2 - punpcklwd m0, m2 + packuswb m0, m2 + packuswb m1, m3 + SBUTTERFLY bw, 0, 1, 2 + SBUTTERFLY wd, 0, 1, 2 movd %1, m0 pshufd m0, m0, 0x39 @@ -96,13 +90,13 @@ INIT_XMM sse2 pshufd m0, m0, 0x39 movd %4, m0 - movd %5, m6 - pshufd m6, m6, 0x39 - movd %6, m6 - pshufd m6, m6, 0x39 - movd %7, m6 - pshufd m6, m6, 0x39 - movd %8, m6 + movd %5, m1 + pshufd m1, m1, 0x39 + movd %6, m1 + pshufd m1, m1, 0x39 + movd %7, m1 + pshufd m1, m1, 0x39 + movd %8, m1 %endmacro ; in: 8 rows of 4 words in %4..%11 @@ -204,40 +198,20 @@ INIT_XMM sse2 ; in: 8 rows of 8 words in m0..m8 ; out: 8 rows of 8 bytes in %1..%8 %macro TRANSPOSE8x8B_STORE 8 - packuswb m0, m0 - packuswb m1, m1 - packuswb m2, m2 - packuswb m3, m3 - packuswb m4, m4 - packuswb m5, m5 - packuswb m6, m6 - packuswb m7, m7 - - punpcklbw m0, m1 - punpcklbw m2, m3 - - punpckhwd m8, m0, m2 - punpcklwd m0, m2 - - punpcklbw m4, m5 - punpcklbw m6, m7 - - punpckhwd m9, m4, m6 - punpcklwd m4, m6 + packuswb m0, m4 + packuswb m1, m5 + packuswb m2, m6 + packuswb m3, m7 + TRANSPOSE2x4x4B 0, 1, 2, 3, 4 - punpckhdq m10, m0, m4; 2, 3 - punpckldq m0, m4; 0, 1 - - punpckldq m11, m8, m9; 4, 5 - punpckhdq m8, m9; 6, 7 movq %1, m0 movhps %2, m0 - movq %3, m10 - movhps %4, m10 - movq %5, m11 - movhps %6, m11 - movq %7, m8 - movhps %8, m8 + movq %3, m1 + movhps %4, m1 + movq %5, m2 + movhps %6, m2 + movq %7, m3 + movhps %8, m3 %endmacro ; in: 8 rows of 8 words in %1..%8 diff --git a/libavutil/x86/x86util.asm b/libavutil/x86/x86util.asm index 824e449..0d0ef07 100644 --- a/libavutil/x86/x86util.asm +++ b/libavutil/x86/x86util.asm @@ -69,6 +69,15 @@ SWAP %2, %3 %endmacro +%macro TRANSPOSE2x4x4B 5 + SBUTTERFLY bw, %1, %2, %5 + SBUTTERFLY bw, %3, %4, %5 + SBUTTERFLY wd, %1, %3, %5 + SBUTTERFLY wd, %2, %4, %5 + SBUTTERFLY dq, %1, %2, %5 + SBUTTERFLY dq, %3, %4, %5 +%endmacro + %macro TRANSPOSE2x4x4W 5 SBUTTERFLY wd, %1, %2, %5 SBUTTERFLY wd, %3, %4, %5 -- 1.8.5.5 From michaelni at gmx.at Sun Aug 3 05:14:42 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 05:14:42 +0200 Subject: [FFmpeg-devel] [PATCH] x86/hevc_deblock: improve 8bit transpose store macros In-Reply-To: <1407032491-3873-1-git-send-email-jamrial@gmail.com> References: <1407032491-3873-1-git-send-email-jamrial@gmail.com> Message-ID: <20140803031442.GY4649@nb4> On Sat, Aug 02, 2014 at 11:21:31PM -0300, James Almer wrote: > Up to four instructions less depending on function and instruction set. > > Signed-off-by: James Almer > --- > libavcodec/x86/hevc_deblock.asm | 70 +++++++++++++---------------------------- > libavutil/x86/x86util.asm | 9 ++++++ > 2 files changed, 31 insertions(+), 48 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From onemda at gmail.com Sun Aug 3 09:47:53 2014 From: onemda at gmail.com (Paul B Mahol) Date: Sun, 3 Aug 2014 09:47:53 +0200 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/takdec: move tmp declaration to where its used In-Reply-To: <1407008599-18700-1-git-send-email-michaelni@gmx.at> References: <1407008599-18700-1-git-send-email-michaelni@gmx.at> Message-ID: On Sat, Aug 2, 2014 at 9:43 PM, Michael Niedermayer wrote: > Makes the code a bit easier to read > > Signed-off-by: Michael Niedermayer > --- > libavcodec/takdec.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > ok From onemda at gmail.com Sun Aug 3 09:52:41 2014 From: onemda at gmail.com (Paul B Mahol) Date: Sun, 3 Aug 2014 09:52:41 +0200 Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/takdec: remove unused variable In-Reply-To: <1407008599-18700-2-git-send-email-michaelni@gmx.at> References: <1407008599-18700-1-git-send-email-michaelni@gmx.at> <1407008599-18700-2-git-send-email-michaelni@gmx.at> Message-ID: On Sat, Aug 2, 2014 at 9:43 PM, Michael Niedermayer wrote: > Found-by: CSA > Signed-off-by: Michael Niedermayer > --- > libavcodec/takdec.c | 1 - > 1 file changed, 1 deletion(-) > > ok From onemda at gmail.com Sun Aug 3 10:00:00 2014 From: onemda at gmail.com (Paul B Mahol) Date: Sun, 3 Aug 2014 10:00:00 +0200 Subject: [FFmpeg-devel] [PATCH] New p2p mode for showwaves filter In-Reply-To: <1406811045-10679-1-git-send-email-mrskman@gmail.com> References: <1406811045-10679-1-git-send-email-mrskman@gmail.com> Message-ID: On Thu, Jul 31, 2014 at 2:50 PM, mrskman wrote: > A few months ago I sent this patch and got some comments, which helped me > to understand how this filter works. Thank you for that and I'm sorry it > took me so long to reply. Here is a better version (atleast for me). > > Problem with the current mode=point is, you can get almost invisible wave > when you set higher resolution output or when there are high amplitudes > in audio stream. > > With this new mode additional points are drawn to make a line between > points and output is readable regardless of the resolution or amplitudes. > > Please review and comment. > > --- > doc/filters.texi | 3 +++ > libavfilter/avf_showwaves.c | 38 +++++++++++++++++++++++++++++++++----- > 2 files changed, 36 insertions(+), 5 deletions(-) > > diff --git a/doc/filters.texi b/doc/filters.texi > index a7919a3..145acbf 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -10698,6 +10698,9 @@ Draw a point for each sample. > > @item line > Draw a vertical line for each sample. > + > + at item p2p > +Draw a point for each sample and a line between them. > @end table > > Default value is @code{point}. > diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c > index 0b45bd0..48e61d1 100644 > --- a/libavfilter/avf_showwaves.c > +++ b/libavfilter/avf_showwaves.c > @@ -35,6 +35,7 @@ > enum ShowWavesMode { > MODE_POINT, > MODE_LINE, > + MODE_P2P, > MODE_NB, > }; > > @@ -43,6 +44,8 @@ typedef struct { > int w, h; > AVRational rate; > int buf_idx; > + int *buf_idy; /* y coordinate of previous sample for each channel > */ > + int nb_channels; > This change is not needed. > AVFrame *outpicref; > int req_fullfilled; > int n; > @@ -59,6 +62,7 @@ static const AVOption showwaves_options[] = { > { "mode", "select display mode", OFFSET(mode), AV_OPT_TYPE_INT, > {.i64=MODE_POINT}, 0, MODE_NB-1, FLAGS, "mode"}, > { "point", "draw a point for each sample", 0, AV_OPT_TYPE_CONST, > {.i64=MODE_POINT}, .flags=FLAGS, .unit="mode"}, > { "line", "draw a line for each sample", 0, AV_OPT_TYPE_CONST, > {.i64=MODE_LINE}, .flags=FLAGS, .unit="mode"}, > + { "p2p", "draw a line between samples", 0, AV_OPT_TYPE_CONST, > {.i64=MODE_P2P}, .flags=FLAGS, .unit="mode"}, > { "n", "set how many samples to show in the same point", > OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS }, > { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, > {.str = "25"}, 0, 0, FLAGS }, > { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, > {.str = "25"}, 0, 0, FLAGS }, > @@ -72,6 +76,8 @@ static av_cold void uninit(AVFilterContext *ctx) > ShowWavesContext *showwaves = ctx->priv; > > av_frame_free(&showwaves->outpicref); > + if (showwaves->buf_idy) > + av_freep(showwaves->buf_idy); > } > > static int query_formats(AVFilterContext *ctx) > @@ -110,6 +116,7 @@ static int query_formats(AVFilterContext *ctx) > > static int config_output(AVFilterLink *outlink) > { > + int i; > AVFilterContext *ctx = outlink->src; > AVFilterLink *inlink = ctx->inputs[0]; > ShowWavesContext *showwaves = ctx->priv; > @@ -117,7 +124,14 @@ static int config_output(AVFilterLink *outlink) > if (!showwaves->n) > showwaves->n = FFMAX(1, ((double)inlink->sample_rate / > (showwaves->w * av_q2d(showwaves->rate))) + 0.5); > > + showwaves->nb_channels = inlink->channels; > showwaves->buf_idx = 0; > + if (!(showwaves->buf_idy = av_malloc_array(showwaves->nb_channels, > 1))) { > + av_log(NULL, AV_LOG_ERROR, "Could not allocate showwaves > buffer\n"); > + return AVERROR(ENOMEM); > + } > + for (i = 0; i <= showwaves->nb_channels; i++) > + showwaves->buf_idy[i] = 0; > outlink->w = showwaves->w; > outlink->h = showwaves->h; > outlink->sample_aspect_ratio = (AVRational){1,1}; > @@ -133,12 +147,14 @@ static int config_output(AVFilterLink *outlink) > inline static int push_frame(AVFilterLink *outlink) > { > ShowWavesContext *showwaves = outlink->src->priv; > - int ret; > + int ret, i; > > if ((ret = ff_filter_frame(outlink, showwaves->outpicref)) >= 0) > showwaves->req_fullfilled = 1; > showwaves->outpicref = NULL; > showwaves->buf_idx = 0; > + for (i = 0; i <= showwaves->nb_channels; i++) > + showwaves->buf_idy[i] = 0; > return ret; > } > > @@ -169,10 +185,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *insamples) > AVFrame *outpicref = showwaves->outpicref; > int linesize = outpicref ? outpicref->linesize[0] : 0; > int16_t *p = (int16_t *)insamples->data[0]; > - int nb_channels = inlink->channels; > int i, j, k, h, ret = 0; > const int n = showwaves->n; > - const int x = 255 / (nb_channels * n); /* multiplication factor, > pre-computed to avoid in-loop divisions */ > + const int x = 255 / (showwaves->nb_channels * n); /* multiplication > factor, pre-computed to avoid in-loop divisions */ > > /* draw data in the buffer */ > for (i = 0; i < nb_samples; i++) { > @@ -184,14 +199,14 @@ static int filter_frame(AVFilterLink *inlink, > AVFrame *insamples) > outpicref->width = outlink->w; > outpicref->height = outlink->h; > outpicref->pts = insamples->pts + > - av_rescale_q((p - (int16_t > *)insamples->data[0]) / nb_channels, > + av_rescale_q((p - (int16_t > *)insamples->data[0]) / showwaves->nb_channels, > (AVRational){ 1, > inlink->sample_rate }, > outlink->time_base); > linesize = outpicref->linesize[0]; > for (j = 0; j < outlink->h; j++) > memset(outpicref->data[0] + j * linesize, 0, outlink->w); > } > - for (j = 0; j < nb_channels; j++) { > + for (j = 0; j < showwaves->nb_channels; j++) { > h = showwaves->h/2 - av_rescale(*p++, showwaves->h/2, > MAX_INT16); > switch (showwaves->mode) { > case MODE_POINT: > @@ -207,7 +222,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *insamples) > *(outpicref->data[0] + showwaves->buf_idx + k * > linesize) += x; > break; > } > + case MODE_P2P: > + if (h >= 0 && h < outlink->h) { > + *(outpicref->data[0] + showwaves->buf_idx + h * > linesize) += x; > + if (showwaves->buf_idy[j] && h != > showwaves->buf_idy[j]) { > + int start = showwaves->buf_idy[j], end = > av_clip(h, 0, outlink->h-1); > + if (start > end) FFSWAP(int16_t, start, end); > + for (k = start + 1; k < end; k++) > + *(outpicref->data[0] + showwaves->buf_idx + k > * linesize) += x; > + } > + } > + break; > } > + /* store current y coordinate for this channel */ > + showwaves->buf_idy[j] = h; > } > > showwaves->sample_count_mod++; > -- > 1.7.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > From stefasab at gmail.com Sun Aug 3 11:33:36 2014 From: stefasab at gmail.com (Stefano Sabatini) Date: Sun, 3 Aug 2014 11:33:36 +0200 Subject: [FFmpeg-devel] [PATCH] doc/ffserver: merge paragraph starting with "What happens next?" with previous one In-Reply-To: References: <1406990445-26221-1-git-send-email-stefasab@gmail.com> Message-ID: <20140803093336.GH26438@barisone> On date Saturday 2014-08-02 07:50:14 -0700, Timothy Gu encoded: > On Aug 2, 2014 7:40 AM, "Stefano Sabatini" wrote: > > > > The name of the paragraph sounded a bit silly, and its text is small so > > it's better to merge it with the previous paragraph. > > --- > > doc/ffserver.texi | 8 +++----- > > 1 file changed, 3 insertions(+), 5 deletions(-) > > OK. Applied, thanks. -- FFmpeg = Friendly & Fabulous Mastodontic Philosofic Epic Generator From michaelni at gmx.at Sun Aug 3 11:36:21 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 11:36:21 +0200 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/takdec: move tmp declaration to where its used In-Reply-To: References: <1407008599-18700-1-git-send-email-michaelni@gmx.at> Message-ID: <20140803093621.GZ4649@nb4> On Sun, Aug 03, 2014 at 09:47:53AM +0200, Paul B Mahol wrote: > On Sat, Aug 2, 2014 at 9:43 PM, Michael Niedermayer > wrote: > > > Makes the code a bit easier to read > > > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/takdec.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > ok applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 3 11:37:15 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 11:37:15 +0200 Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/takdec: remove unused variable In-Reply-To: References: <1407008599-18700-1-git-send-email-michaelni@gmx.at> <1407008599-18700-2-git-send-email-michaelni@gmx.at> Message-ID: <20140803093715.GA4649@nb4> On Sun, Aug 03, 2014 at 09:52:41AM +0200, Paul B Mahol wrote: > On Sat, Aug 2, 2014 at 9:43 PM, Michael Niedermayer > wrote: > > > Found-by: CSA > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/takdec.c | 1 - > > 1 file changed, 1 deletion(-) > > > > ok applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Asymptotically faster algorithms should always be preferred if you have asymptotical amounts of data -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 3 11:55:29 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 11:55:29 +0200 Subject: [FFmpeg-devel] [PATCH] ffserver: deprecate Port and BindAddress options in favor of HTTPPort and HTTPBindAddress In-Reply-To: <1406990453-26347-1-git-send-email-stefasab@gmail.com> References: <1406990453-26347-1-git-send-email-stefasab@gmail.com> Message-ID: <20140803095529.GB4649@nb4> On Sat, Aug 02, 2014 at 04:40:53PM +0200, Stefano Sabatini wrote: > The new option names are more explicit. > --- > doc/ffserver.conf | 4 ++-- > doc/ffserver.texi | 19 ++++++++++++++----- > ffserver.c | 10 +++++++--- > 3 files changed, 23 insertions(+), 10 deletions(-) agree but iam not ffserver maintainer [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Rewriting code that is poorly written but fully understood is good. Rewriting code that one doesnt understand is a sign that one is less smart then the original author, trying to rewrite it will not make it better. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From george at nsup.org Sun Aug 3 15:15:36 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 15:15:36 +0200 Subject: [FFmpeg-devel] [PATCH 1/5] lavfi: add filter metaframes infrastructure. Message-ID: <1407071740-23116-1-git-send-email-george@nsup.org> Metaframes are frames without data, identified by a negative format code, used to carry special conditions. They are sent only to filter that declare supporting them. The only metaframe for now is EOF; this mechanism augments the current mechanism based on request_frame() returning AVERROR_EOF, with the advantage that the EOF metaframe carries a timestamp. The API has also the advantage to work in push-only mode if all the filters in the chain support metaframes. The metaframes are a purely internal API and do not leak to the application. Signed-off-by: Nicolas George --- libavfilter/avfilter.c | 73 +++++++++++++++++++++++++++++++++++++++++++++----- libavfilter/internal.h | 34 +++++++++++++++++++++++ 2 files changed, 100 insertions(+), 7 deletions(-) TODO: find a way of forwarding the EOF, and hopefully the timestamp for filters that do not support metaframes. Possibly triggering a request_frame on filters that have exactly one output would help. diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 7b11467..d3fbe56 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -346,15 +346,16 @@ int ff_request_frame(AVFilterLink *link) ret = link->srcpad->request_frame(link); else if (link->src->inputs[0]) ret = ff_request_frame(link->src->inputs[0]); - if (ret == AVERROR_EOF && link->partial_buf) { - AVFrame *pbuf = link->partial_buf; - link->partial_buf = NULL; - ret = ff_filter_frame_framed(link, pbuf); - } if (ret < 0) { + if (!link->frame_requested) { + av_assert0(ret == AVERROR_EOF); + ret = 0; + } link->frame_requested = 0; - if (ret == AVERROR_EOF) - link->closed = 1; + if (ret == AVERROR_EOF) { + ret = ff_filter_link_close(link, AV_NOPTS_VALUE); + return ret < 0 ? ret : AVERROR_EOF; + } } else { av_assert0(!link->frame_requested || link->flags & FF_LINK_FLAG_REQUEST_LOOP); @@ -1132,10 +1133,52 @@ static int ff_filter_frame_needs_framing(AVFilterLink *link, AVFrame *frame) return ret; } +static int ff_filter_metaframe(AVFilterLink *link, AVFrame *frame) +{ + AVFrame *pbuf = link->partial_buf; + int ret = 0; + + if (pbuf) { + link->partial_buf = NULL; + if ((ret = ff_filter_frame_framed(link, pbuf)) < 0) + return ret; + } + + if ((link->dst->filter->flags & FF_FILTER_FLAG_SUPPORT_METAFRAMES)) { + ret = link->dstpad->filter_frame ? + link->dstpad->filter_frame(link, frame) : + default_filter_frame(link, frame); + if (ret < 0) + return ret; + } + + switch (frame->format) { + + case FF_METAFRAME_EOF: + link->closed = 1; + break; + + case 0: + case FF_METAFRAME_NOP: + /* Not implemented yet because not used either for now. + Caveat: if the same metaframe is forwarded to the next filter + and the next filter changes the type, the type change must not be + taken into account for the first link. */ + + default: + av_assert0(!"reached"); + } + + return ret; +} + int ff_filter_frame(AVFilterLink *link, AVFrame *frame) { FF_TPRINTF_START(NULL, filter_frame); ff_tlog_link(NULL, link, 1); ff_tlog(NULL, " "); ff_tlog_ref(NULL, frame, 1); + if (frame->format < -1) + return ff_filter_metaframe(link, frame); + /* Consistency checks */ if (link->type == AVMEDIA_TYPE_VIDEO) { if (strcmp(link->dst->filter->name, "scale")) { @@ -1162,6 +1205,22 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame) } } +int ff_filter_link_close(AVFilterLink *link, int64_t pts) +{ + AVFrame *frame; + int ret; + + if (link->closed) + return 0; + if (!(frame = av_frame_alloc())) + return AVERROR(ENOMEM); + frame->format = FF_METAFRAME_EOF; + frame->pts = pts; + ret = ff_filter_frame(link, frame); + av_frame_free(&frame); + return ret; +} + const AVClass *avfilter_get_class(void) { return &avfilter_class; diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 308b115..fbe603a 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -374,4 +374,38 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name); */ void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter); +/** + * The filter can accept metaframes. + * Metaframes are AVFrame structures with a negative format field. + * The framework will take default actions based on the metaframe type. + * The destination filter is allowed to reset the type to inhibit the + * default actions. + */ +#define FF_FILTER_FLAG_SUPPORT_METAFRAMES (1 << 24) + +/** + * Types of metaframes that can be passer to a filter. + */ +enum { + /** + * Do not do anything. + * Can be used by the destination filter to inhibit default handling. + */ + FF_METAFRAME_NOP = -1, + + /** + * The input has reached EOF. + * The pts field holds the timestamp of the end of the stream, + * therefore allowing to compute the duration of the last frame. + * The frame structure still belongs to the framework and must not be + * stored by the destination filter; it also may be incomplete. + */ + FF_METAFRAME_EOF = AVERROR_EOF, +}; + +/** + * Close the link by sending the EOF metaframes to the destination filter. + */ +int ff_filter_link_close(AVFilterLink *link, int64_t pts); + #endif /* AVFILTER_INTERNAL_H */ -- 2.0.1 From george at nsup.org Sun Aug 3 15:15:37 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 15:15:37 +0200 Subject: [FFmpeg-devel] [PATCH 2/5] lavfi/buffersrc: add add av_buffersrc_close(). In-Reply-To: <1407071740-23116-1-git-send-email-george@nsup.org> References: <1407071740-23116-1-git-send-email-george@nsup.org> Message-ID: <1407071740-23116-2-git-send-email-george@nsup.org> Also deprecate adding a NULL frame to mark EOF. TODO APIchanges entry, version bump. Signed-off-by: Nicolas George --- libavfilter/buffersrc.c | 40 ++++++++++++++++++++++++++++++---------- libavfilter/buffersrc.h | 15 +++++++++++++++ 2 files changed, 45 insertions(+), 10 deletions(-) Note: relying on the frame duration for the end timestamp would be fragile (no filters update it), and technically an API break. diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index 27d3db0..6d71587 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -63,6 +63,7 @@ typedef struct BufferSourceContext { char *channel_layout_str; int eof; + int64_t eof_pts; } BufferSourceContext; #define CHECK_VIDEO_PARAM_CHANGE(s, c, width, height, format)\ @@ -77,6 +78,27 @@ typedef struct BufferSourceContext { return AVERROR(EINVAL);\ } +static int push_if_flag(AVFilterContext *ctx, int flags) +{ + return (flags & AV_BUFFERSRC_FLAG_PUSH) ? + ctx->output_pads[0].request_frame(ctx->outputs[0]) : 0; +} + +int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, int flags) +{ + BufferSourceContext *s = ctx->priv; + + if (pts == AV_NOPTS_VALUE) { + av_log(ctx, AV_LOG_WARNING, "No EOF timestamp\n"); + /* FIXME use duration for audio */ + pts = av_rescale_q(ctx->outputs[0]->current_pts, + AV_TIME_BASE_Q, ctx->outputs[0]->time_base) + 1; + } + s->eof_pts = pts; + s->eof = 1; + return push_if_flag(ctx, flags); +} + int attribute_align_arg av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame) { return av_buffersrc_add_frame_flags(ctx, (AVFrame *)frame, @@ -125,8 +147,7 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx, s->nb_failed_requests = 0; if (!frame) { - s->eof = 1; - return 0; + return av_buffersrc_close(ctx, AV_NOPTS_VALUE, flags); } else if (s->eof) return AVERROR(EINVAL); @@ -177,11 +198,7 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx, return ret; } - if ((flags & AV_BUFFERSRC_FLAG_PUSH)) - if ((ret = ctx->output_pads[0].request_frame(ctx->outputs[0])) < 0) - return ret; - - return 0; + return push_if_flag(ctx, flags); } #if FF_API_AVFILTERBUFFER @@ -211,8 +228,7 @@ int av_buffersrc_add_ref(AVFilterContext *ctx, AVFilterBufferRef *buf, int ret = 0, planes, i; if (!buf) { - s->eof = 1; - return 0; + return av_buffersrc_close(ctx, AV_NOPTS_VALUE, flags); } else if (s->eof) return AVERROR(EINVAL); @@ -487,10 +503,14 @@ static int request_frame(AVFilterLink *link) { BufferSourceContext *c = link->src->priv; AVFrame *frame; + int ret; if (!av_fifo_size(c->fifo)) { - if (c->eof) + if (c->eof) { + if ((ret = ff_filter_link_close(link, c->eof_pts)) < 0) + return ret; return AVERROR_EOF; + } c->nb_failed_requests++; return AVERROR(EAGAIN); } diff --git a/libavfilter/buffersrc.h b/libavfilter/buffersrc.h index ea34c04..28ca545 100644 --- a/libavfilter/buffersrc.h +++ b/libavfilter/buffersrc.h @@ -145,6 +145,8 @@ int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame); * * @param buffer_src pointer to a buffer source context * @param frame a frame, or NULL to mark EOF + * (Using NULL to mark EOF is deprecated, use + * av_buffersrc_close() instead.) * @param flags a combination of AV_BUFFERSRC_FLAG_* * @return >= 0 in case of success, a negative AVERROR code * in case of failure @@ -154,6 +156,19 @@ int av_buffersrc_add_frame_flags(AVFilterContext *buffer_src, /** + * Close a buffer source. + * + * This cause EOF to be propagated along the filter graph. + * + * @param buffer_src pointer to a buffer source context + * @param pts the timestamp of the end of stream + * @param flags a combination of AV_BUFFERSRC_FLAG_* + * @return >= 0 in case of success, a negative AVERROR code + * in case of failure + */ +int av_buffersrc_close(AVFilterContext *buffer_src, int64_t pts, int flags); + +/** * @} */ -- 2.0.1 From george at nsup.org Sun Aug 3 15:15:38 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 15:15:38 +0200 Subject: [FFmpeg-devel] [PATCH 3/5] ffmpeg: use av_buffersrc_close(). In-Reply-To: <1407071740-23116-1-git-send-email-george@nsup.org> References: <1407071740-23116-1-git-send-email-george@nsup.org> Message-ID: <1407071740-23116-3-git-send-email-george@nsup.org> Signed-off-by: Nicolas George --- ffmpeg.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 1c1a559..3ac6620 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1741,12 +1741,9 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output) if (!*got_output || ret < 0) { if (!pkt->size) { + int64_t pts = av_rescale_q(ist->next_pts, AV_TIME_BASE_Q, ist->st->time_base); for (i = 0; i < ist->nb_filters; i++) -#if 1 - av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0); -#else - av_buffersrc_add_frame(ist->filters[i]->filter, NULL); -#endif + av_buffersrc_close(ist->filters[i]->filter, pts, 0); } return ret; } @@ -1894,12 +1891,9 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) if (!*got_output || ret < 0) { if (!pkt->size) { + int64_t pts = av_rescale_q(ist->next_pts, AV_TIME_BASE_Q, ist->st->time_base); for (i = 0; i < ist->nb_filters; i++) -#if 1 - av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0); -#else - av_buffersrc_add_frame(ist->filters[i]->filter, NULL); -#endif + av_buffersrc_close(ist->filters[i]->filter, pts, 0); } return ret; } -- 2.0.1 From george at nsup.org Sun Aug 3 15:15:39 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 15:15:39 +0200 Subject: [FFmpeg-devel] [PATCH 4/5] vf_fps: move flushing remaining frames in a separate function. In-Reply-To: <1407071740-23116-1-git-send-email-george@nsup.org> References: <1407071740-23116-1-git-send-email-george@nsup.org> Message-ID: <1407071740-23116-4-git-send-email-george@nsup.org> Also remove unused loop counter, rename obsolete "buf", and add a comment about a similar function. Signed-off-by: Nicolas George --- libavfilter/vf_fps.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c index a38633d..a3ad1bb 100644 --- a/libavfilter/vf_fps.c +++ b/libavfilter/vf_fps.c @@ -88,6 +88,7 @@ static av_cold int init(AVFilterContext *ctx) return 0; } +/* FIXME: misnommer, the frames are discarded, not flushed */ static void flush_fifo(AVFifoBuffer *fifo) { while (av_fifo_size(fifo)) { @@ -97,6 +98,24 @@ static void flush_fifo(AVFifoBuffer *fifo) } } +static int flush_fifo_to_out(AVFilterContext *ctx) +{ + FPSContext *s = ctx->priv; + AVFilterLink *outlink = ctx->outputs[0]; + AVFrame *frame; + int ret; + + while (av_fifo_size(s->fifo)) { + av_fifo_generic_read(s->fifo, &frame, sizeof(frame), NULL); + frame->pts = av_rescale_q(s->first_pts, ctx->inputs[0]->time_base, + outlink->time_base) + s->frames_out; + if ((ret = ff_filter_frame(outlink, frame)) < 0) + return ret; + s->frames_out++; + } + return 0; +} + static av_cold void uninit(AVFilterContext *ctx) { FPSContext *s = ctx->priv; @@ -133,23 +152,8 @@ static int request_frame(AVFilterLink *outlink) ret = ff_request_frame(ctx->inputs[0]); /* flush the fifo */ - if (ret == AVERROR_EOF && av_fifo_size(s->fifo)) { - int i; - for (i = 0; av_fifo_size(s->fifo); i++) { - AVFrame *buf; - - av_fifo_generic_read(s->fifo, &buf, sizeof(buf), NULL); - buf->pts = av_rescale_q(s->first_pts, ctx->inputs[0]->time_base, - outlink->time_base) + s->frames_out; - - if ((ret = ff_filter_frame(outlink, buf)) < 0) - return ret; - - s->frames_out++; - } - return 0; - } - + if (ret == AVERROR_EOF && av_fifo_size(s->fifo)) + return flush_fifo_to_out(ctx); return ret; } -- 2.0.1 From george at nsup.org Sun Aug 3 15:15:40 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 15:15:40 +0200 Subject: [FFmpeg-devel] [PATCH 5/5] lavfi/vf_fps: accept EOF timestamp. In-Reply-To: <1407071740-23116-1-git-send-email-george@nsup.org> References: <1407071740-23116-1-git-send-email-george@nsup.org> Message-ID: <1407071740-23116-5-git-send-email-george@nsup.org> This makes the FPS filter duplicate the last frame to take its duration into account, exactly like the other ones. Fix trac ticket #2674. Signed-off-by: Nicolas George --- libavfilter/vf_fps.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) Aded a ref to the trac ticket and fixed a corner case raised by it. Note that the whole logic of vf_fps is overly complex, but this is for another patch. diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c index a3ad1bb..5bf5bda 100644 --- a/libavfilter/vf_fps.c +++ b/libavfilter/vf_fps.c @@ -28,6 +28,7 @@ #include #include +#include "libavutil/avassert.h" #include "libavutil/common.h" #include "libavutil/fifo.h" #include "libavutil/mathematics.h" @@ -150,10 +151,8 @@ static int request_frame(AVFilterLink *outlink) while (ret >= 0 && s->frames_out == frames_out) ret = ff_request_frame(ctx->inputs[0]); - - /* flush the fifo */ - if (ret == AVERROR_EOF && av_fifo_size(s->fifo)) - return flush_fifo_to_out(ctx); + if (ret == AVERROR_EOF) + av_assert1(!av_fifo_size(s->fifo)); return ret; } @@ -161,6 +160,7 @@ static int write_to_fifo(AVFifoBuffer *fifo, AVFrame *buf) { int ret; + av_assert1(buf->format >= 0); if (!av_fifo_space(fifo) && (ret = av_fifo_realloc2(fifo, 2*av_fifo_size(fifo)))) { av_frame_free(&buf); @@ -198,6 +198,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf) } else { s->first_pts = buf->pts; } + } else if (buf->format < 0) { + return 0; } else { av_log(ctx, AV_LOG_WARNING, "Discarding initial frame(s) with no " "timestamp.\n"); @@ -207,8 +209,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf) return 0; } + if (buf->format < 0) { + if (buf->format != FF_METAFRAME_EOF) + return 0; + if (buf->pts == AV_NOPTS_VALUE) + return flush_fifo_to_out(ctx); + if (!av_fifo_size(s->fifo)) + return 0; + } + /* now wait for the next timestamp */ if (buf->pts == AV_NOPTS_VALUE || av_fifo_size(s->fifo) <= 0) { + av_assert1(buf->format >= 0); return write_to_fifo(s->fifo, buf); } @@ -226,10 +238,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf) av_fifo_generic_read(s->fifo, &tmp, sizeof(tmp), NULL); flush_fifo(s->fifo); - ret = write_to_fifo(s->fifo, tmp); - av_frame_free(&buf); - return ret; + if (buf->format >= 0) { + /* requeue last frame if not EOF */ + ret = write_to_fifo(s->fifo, tmp); + av_frame_free(&buf); + return ret; + } + return 0; } /* can output >= 1 frames */ @@ -268,7 +284,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf) } flush_fifo(s->fifo); - ret = write_to_fifo(s->fifo, buf); + ret = buf->format < 0 ? 0 : write_to_fifo(s->fifo, buf); return ret; } @@ -299,6 +315,7 @@ AVFilter ff_vf_fps = { .uninit = uninit, .priv_size = sizeof(FPSContext), .priv_class = &fps_class, + .flags = FF_FILTER_FLAG_SUPPORT_METAFRAMES, .inputs = avfilter_vf_fps_inputs, .outputs = avfilter_vf_fps_outputs, }; -- 2.0.1 From george at nsup.org Sun Aug 3 15:19:06 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 15:19:06 +0200 Subject: [FFmpeg-devel] [PATCH 1/4] lavfi: add filter metaframes infrastructure. In-Reply-To: <20140802152044.GE32146@barisone> References: <1406756689-27697-1-git-send-email-george@nsup.org> <20140802152044.GE32146@barisone> Message-ID: <20140803131906.GA18753@phare.normalesup.org> Le quintidi 15 thermidor, an CCXXII, Stefano Sabatini a ?crit?: > It shall probably execute the remaining part of the function even in > case of failure. I am not completely sure about that. AFAIK, we consider most filtering failures fatal at some point or another anyway. > I find this a bit confusing. Can you explain why the NOP metaframe is > needed? Depending on the type of the message and the default action taken, filters may need to inhibit the default action because they already did the work or changed something else somewhere that would conflict. I can remove that hunk and wait for something to actually use it if you prefer. > LGTM otherwise. Thanks to everyone for the reviews. New series posted. Regards, -- Nicolas George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 3 16:27:56 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 16:27:56 +0200 Subject: [FFmpeg-devel] Inconsistent UDP output packet size - patch In-Reply-To: References: Message-ID: <20140803142756.GC4649@nb4> On Tue, Jul 22, 2014 at 05:13:39PM +0600, Konstantin Shpinev wrote: > Following https://trac.ffmpeg.org/ticket/2748 > aviobuf.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > e26d95e9b0392d7b59a33700a9fe8ba7354cfd48 0001-fix-flush_buffer-in-aviobuf.c-to-produce-constant-pa.patch > From a9d25569645e4031cd789ddbf696baaf6918f9dc Mon Sep 17 00:00:00 2001 > From: Konstantin Shpinev > Date: Tue, 22 Jul 2014 17:06:07 +0600 > Subject: [PATCH] fix flush_buffer in aviobuf.c to produce constant packet > size, see https://trac.ffmpeg.org/ticket/2748 breaks fate --- ./tests/ref/lavf/mov 2014-08-02 22:37:50.706658076 +0200 +++ tests/data/fate/lavf-mov 2014-08-03 16:25:15.048007384 +0200 @@ -1,5 +1,5 @@ -a10d50f2679df92264e1fc21cb8be630 *./tests/data/lavf/lavf.mov -366449 ./tests/data/lavf/lavf.mov +7cee6e2ae88c286973ecda52d0bf05b5 *./tests/data/lavf/lavf.mov +396081 ./tests/data/lavf/lavf.mov ./tests/data/lavf/lavf.mov CRC=0xbb2b949b 6258f70f974e3c802e01d02ac33c7bbd *./tests/data/lavf/lavf.mov 357539 ./tests/data/lavf/lavf.mov -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam" -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From george at nsup.org Sun Aug 3 16:29:36 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 16:29:36 +0200 Subject: [FFmpeg-devel] [PATCH 1/2] lavfi/avf_showspectrum: set output frame rate. Message-ID: <1407076177-17543-1-git-send-email-george@nsup.org> Signed-off-by: Nicolas George --- libavfilter/avf_showspectrum.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index 4a4b4f4..e3ae6ea 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -246,6 +246,8 @@ static int config_output(AVFilterLink *outlink) if (s->xpos >= outlink->w) s->xpos = 0; + outlink->frame_rate = av_make_q(inlink->sample_rate, win_size); + s->combine_buffer = av_realloc_f(s->combine_buffer, outlink->h * 3, sizeof(*s->combine_buffer)); -- 2.0.1 From george at nsup.org Sun Aug 3 16:29:37 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 16:29:37 +0200 Subject: [FFmpeg-devel] [PATCH 2/2] lavfi/avf_showspectrum: fix output pts computation. In-Reply-To: <1407076177-17543-1-git-send-email-george@nsup.org> References: <1407076177-17543-1-git-send-email-george@nsup.org> Message-ID: <1407076177-17543-2-git-send-email-george@nsup.org> Signed-off-by: Nicolas George --- libavfilter/avf_showspectrum.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) These two patches fix a bunch of "non-monotonically" warnings/errors. diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index e3ae6ea..28db8b1 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -468,7 +468,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb } outpicref->pts = insamples->pts + - av_rescale_q(s->consumed, + av_rescale_q(s->consumed + add_samples - win_size, (AVRational){ 1, inlink->sample_rate }, outlink->time_base); ret = push_frame(outlink); -- 2.0.1 From george at nsup.org Sun Aug 3 16:44:28 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 16:44:28 +0200 Subject: [FFmpeg-devel] [PATCH] lavfi/avf_showspectrum: do not push the frame at EOF. Message-ID: <1407077068-16748-1-git-send-email-george@nsup.org> It is always identical to the last pushed frame. The samples in the last incomplete window were ignored, this is unchanged. Possible enhancement: pad the last incomplete window with silence. Signed-off-by: Nicolas George --- libavfilter/avf_showspectrum.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index 28db8b1..e925556 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -281,8 +281,6 @@ static int request_frame(AVFilterLink *outlink) ret = ff_request_frame(inlink); } while (!s->req_fullfilled && ret >= 0); - if (ret == AVERROR_EOF && s->outpicref) - push_frame(outlink); return ret; } -- 2.0.1 From george at nsup.org Sun Aug 3 16:59:25 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 16:59:25 +0200 Subject: [FFmpeg-devel] [PATCH] lavfi/avf_showspectrum: use automatic framing. Message-ID: <1407077965-16960-1-git-send-email-george@nsup.org> The framework can ensure that each input frame has exactly the correct number of samples, except the last one. Signed-off-by: Nicolas George --- libavfilter/avf_showspectrum.c | 47 +++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index e925556..b354571 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -55,8 +55,6 @@ typedef struct { RDFTContext *rdft; ///< Real Discrete Fourier Transform context int rdft_bits; ///< number of bits (RDFT window size = 1<rdft_data[i]) return AVERROR(ENOMEM); } - s->filled = 0; /* pre-calc windowing function */ s->window_func_lut = @@ -248,6 +245,9 @@ static int config_output(AVFilterLink *outlink) outlink->frame_rate = av_make_q(inlink->sample_rate, win_size); + inlink->min_samples = inlink->max_samples = inlink->partial_buf_size = + win_size; + s->combine_buffer = av_realloc_f(s->combine_buffer, outlink->h * 3, sizeof(*s->combine_buffer)); @@ -264,7 +264,6 @@ inline static int push_frame(AVFilterLink *outlink) s->xpos++; if (s->xpos >= outlink->w) s->xpos = 0; - s->filled = 0; s->req_fullfilled = 1; return ff_filter_frame(outlink, av_frame_clone(s->outpicref)); @@ -284,7 +283,7 @@ static int request_frame(AVFilterLink *outlink) return ret; } -static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb_samples) +static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples) { int ret; AVFilterContext *ctx = inlink->dst; @@ -297,26 +296,22 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb const int nb_freq = 1 << (s->rdft_bits - 1); const int win_size = nb_freq << 1; const double w = 1. / (sqrt(nb_freq) * 32768.); + int h = s->channel_height; /* channel height */ int ch, plane, n, y; - const int start = s->filled; - const int add_samples = FFMIN(win_size - start, nb_samples); + const int start = 0; + + av_assert0(insamples->nb_samples == win_size); /* fill RDFT input with the number of samples available */ for (ch = 0; ch < s->nb_display_channels; ch++) { const int16_t *p = (int16_t *)insamples->extended_data[ch]; - p += s->consumed; - for (n = 0; n < add_samples; n++) + for (n = 0; n < win_size; n++) s->rdft_data[ch][start + n] = p[n] * s->window_func_lut[start + n]; } - s->filled += add_samples; - /* complete RDFT window size? */ - if (s->filled == win_size) { - - /* channel height */ - int h = s->channel_height; + /* TODO reindent */ /* run RDFT on each samples set */ for (ch = 0; ch < s->nb_display_channels; ch++) @@ -465,32 +460,24 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb } } - outpicref->pts = insamples->pts + - av_rescale_q(s->consumed + add_samples - win_size, - (AVRational){ 1, inlink->sample_rate }, - outlink->time_base); + outpicref->pts = insamples->pts; ret = push_frame(outlink); if (ret < 0) return ret; - } - return add_samples; + return win_size; } static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) { AVFilterContext *ctx = inlink->dst; ShowSpectrumContext *s = ctx->priv; - int ret = 0, left_samples = insamples->nb_samples; + unsigned win_size = 1 << s->rdft_bits; + int ret = 0; - s->consumed = 0; - while (left_samples) { - int ret = plot_spectrum_column(inlink, insamples, left_samples); - if (ret < 0) - break; - s->consumed += ret; - left_samples -= ret; - } + av_assert0(insamples->nb_samples <= win_size); + if (insamples->nb_samples == win_size) + ret = plot_spectrum_column(inlink, insamples); av_frame_free(&insamples); return ret; -- 2.0.1 From danieloberhoff at gmail.com Sun Aug 3 17:39:38 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Sun, 3 Aug 2014 17:39:38 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> Message-ID: Am 03.08.2014 um 03:15 schrieb Daniel Oberhoff : > Am 03.08.2014 um 00:12 schrieb Cl?ment B?sch : > >> On Fri, Aug 01, 2014 at 12:56:42PM +0200, Daniel Oberhoff wrote: >>> >>> Am 01.08.2014 um 12:22 schrieb Cl?ment B?sch : >>> >>>> On Fri, Aug 01, 2014 at 12:13:22PM +0200, Daniel Oberhoff wrote: >>>>> >>>>> Am 29.07.2014 um 09:54 schrieb Carl Eugen Hoyos : >>>>> >>>>>> Daniel Oberhoff gmail.com> writes: >>>>>> >>>>>>> OBJS-$(CONFIG_ZOOMPAN_FILTER) += vf_zoompan.o >>>>>>> +OBJS-$(CONFIG_RECTIFICATION_FILTER) += vf_rectification.o >>>>>> >>>>>>> REGISTER_FILTER(ZOOMPAN, zoompan, vf); >>>>>>> + REGISTER_FILTER(RECTIFICATION, rectification, vf); >>>>>> >>>>>> Keep the alphabetic ordering please. >>>>>> >>>>> >>>>> Ok >>>>> >>>>>>> + AV_PIX_FMT_YUV410P, >>>>>>> + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, >>>>>>> + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, >>>>>>> + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, >>>>>>> + AV_PIX_FMT_NONE >>>>>> >>>>>> I have no idea what this filter does and since the >>>>>> most important format (yuv420p) is supported, this >>>>>> doesn't really matter but yuv410p and yuva444p are >>>>>> quite exotic formats, I would at least have >>>>>> expected yuv422p, yuva420p and yuv444p in the list. >>>>>> >>>>>> Did you test all above formats (at least the left row)? >>>>> >>>>> Added the one from your list that was missing. Can you suggest an easy way of testing all these formats? >>>>> >>>> >>>> >>>> add a format filter before yours in the filtergraph (-vf >>>> format=yuv410p,rectification ?) >>> >>> Ok, borders can be a bitt different, but otherwise all work now, except vuy444p, which ffmpeg reports as invalid. btw, how can I get the components of a given color in the colorspace? >>> >>>> If you want to add a FATE test (which would be really awesome), you can >>>> grep for "video_filter" in tests/fate/filter-video.mak (to test all pixel >>>> formats the filter supports), or just make a standard test with framecrc. >>>> >>>> [...] >>> >>> I did that by adding this: >>> >>> FATE_FILTER_PIXFMTS-$(CONFIG_RECTIFICATION_FILTER) += fate-filter-pixfmts-rectification >>> fate-filter-pixfmts-rectification: CMD = pixfmts "0.6:0.4:0.65:0.4" >>> >>> then I ran >>> >>> make fate-filter-pixfmts-rectification GEN=1 >>> >>> which made a file >>> >>> test/data/fate/filter-pixfmts-rectification.rep >>> >> >> This is the result of a normal run to be compared by with the reference >> which should have also been generated with the help of GEN=1 for your >> first run. The file(s) generated by GEN=1 need to be tracked. >> >>> do I check this in or not? >>> >> >> Of course you are supposed to check if the results make sense. >> >> Use make fate-filter-pixfmts-rectifications V=1 to see what's going on. >> >>> running >>> >>> make fate-filter-pixfmts-rectification GEN=1 >>> >>> runs fine? >>> >> >> Of course, it doesn't do the comparison, it generates the reference. >> >>> Best >>> >>> Daniel >> >> -- >> Cl?ment B. >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel at ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > Alright, will get that cleaned up. Since I seem to have all consent I need to also change the license I will see that I get a new patch ready soon. > > Best and thanks for feedback! > > Daniel Hello all, I updated the patch trying to incorporate all review feedback. I also got consent from the original author to put this filter under LGPL, and thus have it compiled in by default. I also conversed with Cyrille from Krita and he doesn?t see any more copyright issues, as at that point it boils down to the use of a well known algorithm, in a straight-forward implementation. Compared to the previous patch I renamed the filter to lenscorrection, since that is the name in the frei0r suite, and it will make using this instead of the frei0r one as easy as stating lenscorrection=... instead of frei0r=lenscorrection:... Last but not least I adapted the format list, inspected results on all formats, and supplied a fate test. Release notes and docs where also adapted. Please check if this is ok to push now. From dc552ae06a41725988250896327af2cceee1b812 Mon Sep 17 00:00:00 2001 From: Daniel Oberhoff Date: Mon, 28 Jul 2014 23:58:12 +0200 Subject: [PATCH] ported lenscorrection filter from frei0r --- Changelog | 2 +- doc/filters.texi | 36 +++++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/version.h | 4 +- libavfilter/vf_lenscorrection.c | 208 +++++++++++++++++++++++++++ tests/fate/filter-video.mak | 3 + tests/ref/fate/filter-pixfmts-lenscorrection | 8 ++ 8 files changed, 260 insertions(+), 3 deletions(-) create mode 100644 libavfilter/vf_lenscorrection.c create mode 100644 tests/ref/fate/filter-pixfmts-lenscorrection diff --git a/Changelog b/Changelog index 067f72a..3c1ee51 100644 --- a/Changelog +++ b/Changelog @@ -2,7 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. version : - +- ported lenscorrection filter from frei0r filter version 2.3: - AC3 fixed-point decoding diff --git a/doc/filters.texi b/doc/filters.texi index c5caa77..2af311a 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -5532,6 +5532,42 @@ kerndeint=map=1 @end example @end itemize + at section lenscorrection + +This filter can be used to correct for radial distortion as can result from the use +of wide angle lenses, and thereby re-rectify the image. To find the right parameters +one can use tools available for example as part of opencv or simply trial-and-error. +Note that effectively the same filter is available in the open-source tools Krita and +Digikam from the KDE project. +In contrast to the vignette filter, which can also be used to compensate lens errors, +this filter corrects the distortion of the image, whereas vignette corrects the +brightness distribution, so you may want to use both filters together in certain +cases, though you will have to take care of ordering, i.e. wether vignette should +be applied before or after lenscorrection. + +The filter accepts the following options: + + at table @option + at item cx +Relative x-coordinate of the focal point of the image, and thereby the center of the +distrortion. This value has a range [0,1] and is expressed as fractions of the image +width. + at item cy +Relative y-coordinate of the focal point of the image, and thereby the center of the +distrortion. This value has a range [0,1] and is expressed as fractions of the image +height. + at item k1 +Coefficient of the quadratic correction term. 0.5 means no correction. + at item k2 +Coefficient of the double quadratic correction term. 0.5 means no correction. + at end table + +The formula that generates the correction is: + +r_src = r_tgt * (1 + (k1 - 0.5) * (r_tgt/r_0)^2 + (k2 - 0.5) * (r_tgt/r_0)^4) + +where r_0 is halve of the image diagonal. + @anchor{lut3d} @section lut3d diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 0f54381..f74defa 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -162,6 +162,7 @@ OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o OBJS-$(CONFIG_PP_FILTER) += vf_pp.o OBJS-$(CONFIG_PSNR_FILTER) += vf_psnr.o dualinput.o framesync.o OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o +OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o OBJS-$(CONFIG_REMOVELOGO_FILTER) += bbox.o lswsutils.o lavfutils.o vf_removelogo.o OBJS-$(CONFIG_ROTATE_FILTER) += vf_rotate.o OBJS-$(CONFIG_SEPARATEFIELDS_FILTER) += vf_separatefields.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 1877557..b1d6ff5 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -156,6 +156,7 @@ void avfilter_register_all(void) REGISTER_FILTER(INTERLACE, interlace, vf); REGISTER_FILTER(INTERLEAVE, interleave, vf); REGISTER_FILTER(KERNDEINT, kerndeint, vf); + REGISTER_FILTER(LENSCORRECTION, lenscorrection, vf); REGISTER_FILTER(LUT3D, lut3d, vf); REGISTER_FILTER(LUT, lut, vf); REGISTER_FILTER(LUTRGB, lutrgb, vf); diff --git a/libavfilter/version.h b/libavfilter/version.h index 1a43dc5..47bac78 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -30,8 +30,8 @@ #include "libavutil/version.h" #define LIBAVFILTER_VERSION_MAJOR 4 -#define LIBAVFILTER_VERSION_MINOR 11 -#define LIBAVFILTER_VERSION_MICRO 102 +#define LIBAVFILTER_VERSION_MINOR 12 +#define LIBAVFILTER_VERSION_MICRO 100 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_lenscorrection.c b/libavfilter/vf_lenscorrection.c new file mode 100644 index 0000000..1aad94c --- /dev/null +++ b/libavfilter/vf_lenscorrection.c @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2014 Daniel Oberhoff + * Copyright (C) 2007 Richard Spindler (author of frei0r plugin from which this was derived) + * + * This file is part of FFmpeg. + * + * 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 + */ + +/** + * @file + * Lenscorrection filter, algorithm from the frei0r plugin with the same name +*/ +#include +#include + +#include "libavutil/opt.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/pixdesc.h" + +#include "avfilter.h" +#include "internal.h" +#include "video.h" + +typedef struct LenscorrectionCtx { + const AVClass* av_class; + unsigned int width; + unsigned int height; + int hsub, vsub; + int nb_planes; + double cx, cy, k1, k2; +} LenscorrectionCtx; + +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM +static const AVOption Lenscorrection_options[] = { + { "cx", "set relative center x", offsetof(LenscorrectionCtx, cx), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, + { "cy", "set relative center y", offsetof(LenscorrectionCtx, cy), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, + { "k1", "set quadratic distortion factor", offsetof(LenscorrectionCtx, k1), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, + { "k2", "set double quadratic distortion factor", offsetof(LenscorrectionCtx, k2), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(Lenscorrection); + +static av_cold int init(AVFilterContext *ctx) +{ + return 0; +} + +static av_cold void uninit(AVFilterContext *ctx) +{ +} + +typedef struct ThreadData { + AVFrame *in, *out; + float w, h; + int plane; + float xcenter, ycenter; + float k1, k2; +} ThreadData; + +static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs) +{ + ThreadData *td = (ThreadData*)arg; + AVFrame *in = td->in; + AVFrame *out = td->out; + + const float w = td->w, h = td->h; + const float xcenter = td->xcenter; + const float ycenter = td->ycenter; + const float r2inv = 4.0 / (w * w + h * h); + const float k1 = td->k1 - 0.5; + const float k2 = td->k2 - 0.5; + const int start = (h * job ) / nb_jobs; + const int end = (h * (job+1)) / nb_jobs; + const int plane = td->plane; + const int inlinesize = in->linesize[plane]; + const int outlinesize = out->linesize[plane]; + const uint8_t *indata = in->data[plane]; + uint8_t *outrow = out->data[plane] + start * outlinesize; + int i; + for (i = start; i < end; i++, outrow += outlinesize) { + const float off_y = i - ycenter; + const float off_y2 = off_y * off_y; + uint8_t *out = outrow; + int j; + for (j = 0; j < w; j++) { + const float off_x = j - xcenter; + const float r2 = (off_x * off_x + off_y2) * r2inv; + const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2; + const int x = xcenter + radius_mult * off_x + 0.5f; + const int y = ycenter + radius_mult * off_y + 0.5f; + const char isvalid = x > 0 && x < w - 1 && y > 0 && y < h - 1; + *out++ = isvalid ? indata[y * inlinesize + x] : 0; + } + } + return 0; +} + +static int query_formats(AVFilterContext *ctx) +{ + static enum PixelFormat pix_fmts[] = { + AV_PIX_FMT_YUV410P, + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, + AV_PIX_FMT_YUV422P, + AV_PIX_FMT_NONE + }; + + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); + return 0; +} + +static int config_props(AVFilterLink *outlink) +{ + AVFilterContext* ctx = outlink->src; + LenscorrectionCtx* rect = ctx->priv; + AVFilterLink *inlink = ctx->inputs[0]; + const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(inlink->format); + rect->hsub = pixdesc->log2_chroma_w; + rect->vsub = pixdesc->log2_chroma_h; + outlink->w = rect->width = inlink->w; + outlink->h = rect->height = inlink->h; + rect->nb_planes = av_pix_fmt_count_planes(inlink->format); + return 0; +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ + AVFilterContext *ctx = inlink->dst; + AVFilterLink *outlink = ctx->outputs[0]; + LenscorrectionCtx *rect = (LenscorrectionCtx*)ctx->priv; + AVFrame* out = ff_get_video_buffer(outlink, outlink->w, outlink->h); + int plane; + + if (!out) { + av_frame_free(&in); + return AVERROR(ENOMEM); + } + + av_frame_copy_props(out, in); + + for (plane = 0; plane < rect->nb_planes; ++plane) { + int hsub = plane == 1 || plane == 2 ? rect->hsub : 0; + int vsub = plane == 1 || plane == 2 ? rect->vsub : 0; + float hdiv = 1 << hsub; + float vdiv = 1 << vsub; + float w = rect->width / hdiv; + float h = rect->height / vdiv; + ThreadData td = { .in = in, .out = out, + .w = w, + .h = h, + .xcenter = rect->cx * w, + .ycenter = rect->cy * h, + .k1 = rect->k1, + .k2 = rect->k2, + .plane = plane}; + ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ctx->graph->nb_threads)); + } + + av_frame_free(&in); + return ff_filter_frame(outlink, out); +} + +static const AVFilterPad Lenscorrection_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = filter_frame, + }, + { NULL } +}; + +static const AVFilterPad Lenscorrection_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_props, + }, + { NULL } +}; + +AVFilter ff_vf_lenscorrection = { + .name = "lenscorrection", + .description = NULL_IF_CONFIG_SMALL("Rectify the image by correcting for lens distortion."), + .priv_size = sizeof(LenscorrectionCtx), + .init = init, + .uninit = uninit, + .query_formats = query_formats, + .inputs = Lenscorrection_inputs, + .outputs = Lenscorrection_outputs, + .priv_class = &Lenscorrection_class, + .flags = AVFILTER_FLAG_SLICE_THREADS, +}; + \ No newline at end of file diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index d87129b..cc5a71b 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -331,6 +331,9 @@ fate-filter-pixfmts-il: CMD = pixfmts "luma_mode=d:chroma_mode=d:alpha_mode=d FATE_FILTER_PIXFMTS-$(CONFIG_KERNDEINT_FILTER) += fate-filter-pixfmts-kerndeint fate-filter-pixfmts-kerndeint: CMD = pixfmts "" "tinterlace=interleave_top," +FATE_FILTER_PIXFMTS-$(CONFIG_LENSCORRECTION_FILTER) += fate-filter-pixfmts-lenscorrection +fate-filter-pixfmts-lenscorrection: CMD = pixfmts "0.6:0.4:0.65:0.4" + FATE_FILTER_PIXFMTS-$(CONFIG_LUT_FILTER) += fate-filter-pixfmts-lut fate-filter-pixfmts-lut: CMD = pixfmts "c0=2*val:c1=2*val:c2=val/2:c3=negval+40" diff --git a/tests/ref/fate/filter-pixfmts-lenscorrection b/tests/ref/fate/filter-pixfmts-lenscorrection new file mode 100644 index 0000000..18af6fb --- /dev/null +++ b/tests/ref/fate/filter-pixfmts-lenscorrection @@ -0,0 +1,8 @@ +yuv410p e7d59dbdb1afab7e2a8f770d563e28c4 +yuv420p bc45b4762d5271410ff825317c85af64 +yuv422p 5cce0c299322634d65e6b32c976e2c12 +yuv444p 03de9a93ab3045a523b234ea93f21c91 +yuva420p d1fa6735c4e7fbbf3a501cec1f0b4ac1 +yuva444p 713ddf5861d3df11c70a242a13c5e92e +yuvj420p 1d5cccaf4ef568ae9fa36f9a28e71c34 +yuvj444p aef1db29848e3b1dcaf4309255c38cbd -- 1.8.2 From onemda at gmail.com Sun Aug 3 18:38:56 2014 From: onemda at gmail.com (Paul B Mahol) Date: Sun, 3 Aug 2014 18:38:56 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> Message-ID: On Sun, Aug 3, 2014 at 5:39 PM, Daniel Oberhoff wrote: > > Am 03.08.2014 um 03:15 schrieb Daniel Oberhoff < > danieloberhoff at googlemail.com>: > > > Am 03.08.2014 um 00:12 schrieb Cl?ment B?sch : > > > >> On Fri, Aug 01, 2014 at 12:56:42PM +0200, Daniel Oberhoff wrote: > >>> > >>> Am 01.08.2014 um 12:22 schrieb Cl?ment B?sch : > >>> > >>>> On Fri, Aug 01, 2014 at 12:13:22PM +0200, Daniel Oberhoff wrote: > >>>>> > >>>>> Am 29.07.2014 um 09:54 schrieb Carl Eugen Hoyos : > >>>>> > >>>>>> Daniel Oberhoff gmail.com> writes: > >>>>>> > >>>>>>> OBJS-$(CONFIG_ZOOMPAN_FILTER) += vf_zoompan.o > >>>>>>> +OBJS-$(CONFIG_RECTIFICATION_FILTER) += vf_rectification.o > >>>>>> > >>>>>>> REGISTER_FILTER(ZOOMPAN, zoompan, vf); > >>>>>>> + REGISTER_FILTER(RECTIFICATION, rectification, vf); > >>>>>> > >>>>>> Keep the alphabetic ordering please. > >>>>>> > >>>>> > >>>>> Ok > >>>>> > >>>>>>> + AV_PIX_FMT_YUV410P, > >>>>>>> + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, > >>>>>>> + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, > >>>>>>> + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, > >>>>>>> + AV_PIX_FMT_NONE > >>>>>> > >>>>>> I have no idea what this filter does and since the > >>>>>> most important format (yuv420p) is supported, this > >>>>>> doesn't really matter but yuv410p and yuva444p are > >>>>>> quite exotic formats, I would at least have > >>>>>> expected yuv422p, yuva420p and yuv444p in the list. > >>>>>> > >>>>>> Did you test all above formats (at least the left row)? > >>>>> > >>>>> Added the one from your list that was missing. Can you suggest an > easy way of testing all these formats? > >>>>> > >>>> > >>>> > >>>> add a format filter before yours in the filtergraph (-vf > >>>> format=yuv410p,rectification ?) > >>> > >>> Ok, borders can be a bitt different, but otherwise all work now, > except vuy444p, which ffmpeg reports as invalid. btw, how can I get the > components of a given color in the colorspace? > >>> > >>>> If you want to add a FATE test (which would be really awesome), you > can > >>>> grep for "video_filter" in tests/fate/filter-video.mak (to test all > pixel > >>>> formats the filter supports), or just make a standard test with > framecrc. > >>>> > >>>> [...] > >>> > >>> I did that by adding this: > >>> > >>> FATE_FILTER_PIXFMTS-$(CONFIG_RECTIFICATION_FILTER) += > fate-filter-pixfmts-rectification > >>> fate-filter-pixfmts-rectification: CMD = pixfmts "0.6:0.4:0.65:0.4" > >>> > >>> then I ran > >>> > >>> make fate-filter-pixfmts-rectification GEN=1 > >>> > >>> which made a file > >>> > >>> test/data/fate/filter-pixfmts-rectification.rep > >>> > >> > >> This is the result of a normal run to be compared by with the reference > >> which should have also been generated with the help of GEN=1 for your > >> first run. The file(s) generated by GEN=1 need to be tracked. > >> > >>> do I check this in or not? > >>> > >> > >> Of course you are supposed to check if the results make sense. > >> > >> Use make fate-filter-pixfmts-rectifications V=1 to see what's going on. > >> > >>> running > >>> > >>> make fate-filter-pixfmts-rectification GEN=1 > >>> > >>> runs fine? > >>> > >> > >> Of course, it doesn't do the comparison, it generates the reference. > >> > >>> Best > >>> > >>> Daniel > >> > >> -- > >> Cl?ment B. > >> _______________________________________________ > >> ffmpeg-devel mailing list > >> ffmpeg-devel at ffmpeg.org > >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > Alright, will get that cleaned up. Since I seem to have all consent I > need to also change the license I will see that I get a new patch ready > soon. > > > > Best and thanks for feedback! > > > > Daniel > > Hello all, > > I updated the patch trying to incorporate all review feedback. I also got > consent from the original author to put this filter under LGPL, and thus > have it compiled in by default. I also conversed with Cyrille from Krita > and he doesn?t see any more copyright issues, as at that point it boils > down to the use of a well known algorithm, in a straight-forward > implementation. > > Compared to the previous patch I renamed the filter to lenscorrection, > since that is the name in the frei0r suite, and it will make using this > instead of the frei0r one as easy as stating > > lenscorrection=... > > instead of > > frei0r=lenscorrection:... > > Last but not least I adapted the format list, inspected results on all > formats, and supplied a fate test. Release notes and docs where also > adapted. Please check if this is ok to push now. > > From dc552ae06a41725988250896327af2cceee1b812 Mon Sep 17 00:00:00 2001 > From: Daniel Oberhoff > Date: Mon, 28 Jul 2014 23:58:12 +0200 > Subject: [PATCH] ported lenscorrection filter from frei0r > > --- > Changelog | 2 +- > doc/filters.texi | 36 +++++ > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/version.h | 4 +- > libavfilter/vf_lenscorrection.c | 208 > +++++++++++++++++++++++++++ > tests/fate/filter-video.mak | 3 + > tests/ref/fate/filter-pixfmts-lenscorrection | 8 ++ > 8 files changed, 260 insertions(+), 3 deletions(-) > create mode 100644 libavfilter/vf_lenscorrection.c > create mode 100644 tests/ref/fate/filter-pixfmts-lenscorrection > > > > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index 0f54381..f74defa 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -162,6 +162,7 @@ OBJS-$(CONFIG_PIXDESCTEST_FILTER) += > vf_pixdesctest.o > OBJS-$(CONFIG_PP_FILTER) += vf_pp.o > OBJS-$(CONFIG_PSNR_FILTER) += vf_psnr.o dualinput.o > framesync.o > OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o > +OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o > not in alphabetical order E, {.dbl=0.5}, 0, 1, .flags=FLAGS }, > + { "k1", "set quadratic distortion factor", > offsetof(LenscorrectionCtx, k1), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, > .flags=FLAGS }, > + { "k2", "set double quadratic distortion factor", > offsetof(LenscorrectionCtx, k2), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, > .flags=FLAGS }, > + { NULL } > +}; > + > +AVFILTER_DEFINE_CLASS(Lenscorrection); > + > +static av_cold int init(AVFilterContext *ctx) > +{ > + return 0; > +} > please remove this one, there is no point in having code that does nothing. > + > +static av_cold void uninit(AVFilterContext *ctx) > +{ > +} > + > ditto > +typedef struct ThreadData { > + AVFrame *in, *out; > + float w, h; > + int plane; > + float xcenter, ycenter; > + float k1, k2; > +} ThreadData; > + > +static int filter_slice(AVFilterContext *ctx, void *arg, int job, int > nb_jobs) > +{ > + ThreadData *td = (ThreadData*)arg; > + AVFrame *in = td->in; > + AVFrame *out = td->out; > + > + const float w = td->w, h = td->h; > + const float xcenter = td->xcenter; > + const float ycenter = td->ycenter; > + const float r2inv = 4.0 / (w * w + h * h); > + const float k1 = td->k1 - 0.5; > + const float k2 = td->k2 - 0.5; > + const int start = (h * job ) / nb_jobs; > + const int end = (h * (job+1)) / nb_jobs; > + const int plane = td->plane; > + const int inlinesize = in->linesize[plane]; > + const int outlinesize = out->linesize[plane]; > + const uint8_t *indata = in->data[plane]; > + uint8_t *outrow = out->data[plane] + start * outlinesize; > + int i; > + for (i = start; i < end; i++, outrow += outlinesize) { > + const float off_y = i - ycenter; > + const float off_y2 = off_y * off_y; > + uint8_t *out = outrow; > + int j; > + for (j = 0; j < w; j++) { > + const float off_x = j - xcenter; > + const float r2 = (off_x * off_x + off_y2) * r2inv; > + const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2; > + const int x = xcenter + radius_mult * off_x + 0.5f; > + const int y = ycenter + radius_mult * off_y + 0.5f; > + const char isvalid = x > 0 && x < w - 1 && y > 0 && y < h - 1; > + *out++ = isvalid ? indata[y * inlinesize + x] : 0; > + } > + } > + return 0; > +} > + > +static int query_formats(AVFilterContext *ctx) > +{ > + static enum PixelFormat pix_fmts[] = { > + AV_PIX_FMT_YUV410P, > + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, > + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, > + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, > + AV_PIX_FMT_YUV422P, > + AV_PIX_FMT_NONE > + }; > + > + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); > + return 0; > +} > + > +static int config_props(AVFilterLink *outlink) > +{ > + AVFilterContext* ctx = outlink->src; > + LenscorrectionCtx* rect = ctx->priv; > + AVFilterLink *inlink = ctx->inputs[0]; > + const AVPixFmtDescriptor *pixdesc = > av_pix_fmt_desc_get(inlink->format); > + rect->hsub = pixdesc->log2_chroma_w; > + rect->vsub = pixdesc->log2_chroma_h; > + outlink->w = rect->width = inlink->w; > + outlink->h = rect->height = inlink->h; > + rect->nb_planes = av_pix_fmt_count_planes(inlink->format); > + return 0; > +} > + > +static int filter_frame(AVFilterLink *inlink, AVFrame *in) > +{ > + AVFilterContext *ctx = inlink->dst; > + AVFilterLink *outlink = ctx->outputs[0]; > + LenscorrectionCtx *rect = (LenscorrectionCtx*)ctx->priv; > + AVFrame* out = ff_get_video_buffer(outlink, outlink->w, outlink->h); > + int plane; > + > + if (!out) { > + av_frame_free(&in); > + return AVERROR(ENOMEM); > + } > + > + av_frame_copy_props(out, in); > + > + for (plane = 0; plane < rect->nb_planes; ++plane) { > + int hsub = plane == 1 || plane == 2 ? rect->hsub : 0; > + int vsub = plane == 1 || plane == 2 ? rect->vsub : 0; > + float hdiv = 1 << hsub; > + float vdiv = 1 << vsub; > + float w = rect->width / hdiv; > + float h = rect->height / vdiv; > + ThreadData td = { .in = in, .out = out, > + .w = w, > + .h = h, > + .xcenter = rect->cx * w, > + .ycenter = rect->cy * h, > + .k1 = rect->k1, > + .k2 = rect->k2, > + .plane = plane}; > + ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, > ctx->graph->nb_threads)); > + } > + > + av_frame_free(&in); > + return ff_filter_frame(outlink, out); > +} > + > +static const AVFilterPad Lenscorrection_inputs[] = { > + { > + .name = "default", > + .type = AVMEDIA_TYPE_VIDEO, > + .filter_frame = filter_frame, > + }, > + { NULL } > +}; > + > +static const AVFilterPad Lenscorrection_outputs[] = { > + { > + .name = "default", > + .type = AVMEDIA_TYPE_VIDEO, > + .config_props = config_props, > + }, > + { NULL } > +}; > + > +AVFilter ff_vf_lenscorrection = { > + .name = "lenscorrection", > + .description = NULL_IF_CONFIG_SMALL("Rectify the image by > correcting for lens distortion."), > + .priv_size = sizeof(LenscorrectionCtx), > + .init = init, > + .uninit = uninit, > Please remove those 2 lines. > + .query_formats = query_formats, > + .inputs = Lenscorrection_inputs, > + .outputs = Lenscorrection_outputs, > + .priv_class = &Lenscorrection_class, > + .flags = AVFILTER_FLAG_SLICE_THREADS, > +}; > + > \ No newline at end of file > diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak > index d87129b..cc5a71b 100644 > --- a/tests/fate/filter-video.mak > +++ b/tests/fate/filter-video.mak > @@ -331,6 +331,9 @@ fate-filter-pixfmts-il: CMD = pixfmts > "luma_mode=d:chroma_mode=d:alpha_mode=d > FATE_FILTER_PIXFMTS-$(CONFIG_KERNDEINT_FILTER) += > fate-filter-pixfmts-kerndeint > fate-filter-pixfmts-kerndeint: CMD = pixfmts "" > "tinterlace=interleave_top," > > +FATE_FILTER_PIXFMTS-$(CONFIG_LENSCORRECTION_FILTER) += > fate-filter-pixfmts-lenscorrection > +fate-filter-pixfmts-lenscorrection: CMD = pixfmts "0.6:0.4:0.65:0.4" > + > FATE_FILTER_PIXFMTS-$(CONFIG_LUT_FILTER) += fate-filter-pixfmts-lut > fate-filter-pixfmts-lut: CMD = pixfmts > "c0=2*val:c1=2*val:c2=val/2:c3=negval+40" > > diff --git a/tests/ref/fate/filter-pixfmts-lenscorrection > b/tests/ref/fate/filter-pixfmts-lenscorrection > new file mode 100644 > index 0000000..18af6fb > --- /dev/null > +++ b/tests/ref/fate/filter-pixfmts-lenscorrection > @@ -0,0 +1,8 @@ > +yuv410p e7d59dbdb1afab7e2a8f770d563e28c4 > +yuv420p bc45b4762d5271410ff825317c85af64 > +yuv422p 5cce0c299322634d65e6b32c976e2c12 > +yuv444p 03de9a93ab3045a523b234ea93f21c91 > +yuva420p d1fa6735c4e7fbbf3a501cec1f0b4ac1 > +yuva444p 713ddf5861d3df11c70a242a13c5e92e > +yuvj420p 1d5cccaf4ef568ae9fa36f9a28e71c34 > +yuvj444p aef1db29848e3b1dcaf4309255c38cbd > -- > 1.8.2 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > From christophe.gisquet at gmail.com Sun Aug 3 18:39:38 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Sun, 3 Aug 2014 18:39:38 +0200 Subject: [FFmpeg-devel] [PATCH 1/4] libavcodec: new API for frame threading by step In-Reply-To: <20140728211530.GT4649@nb4> References: <1406142826-5980-1-git-send-email-christophe.gisquet@gmail.com> <1406142826-5980-2-git-send-email-christophe.gisquet@gmail.com> <20140728211530.GT4649@nb4> Message-ID: Hi, note: I'm using "step" throughout the patch because of the step function and what the causal part most often looks like. I have no idea for another less confusing wording. 2014-07-28 23:15 GMT+02:00 Michael Niedermayer : > maybe i misunderstand but the "progress[1] > y" check looks odd, > shouldnt progress[0] be updated to a larger value even if > progress[1] > y > ? Let's look at the following schema, that maybe should be added to the documentation: ___ p[0] p[1] ___| p[2] p(rogress)[0] and p[1] are the ordinates of the step. p[2] is the abscissa. This is stranger than needed because I wanted progress[0] to keep its meaning from previous API: - you can somewhat easily revert back to this previous API way of working - whether intentionally or erroneously, you can somewhat mix the 2 (eg wait using previous API while using reporting using new one); this is not a great benefit but I was wondering if in some cases you couldn't avoid operating the 2 (for hevc, wpp/slice threading in a frame and normal in another) I think this makes the meaning of progress[] less obvious, but it had some practicality at the time. > from ff_thread_await_progress3() > > + if (!progress || progress[0] >= y || > > + (progress[2] >= x && progress[1] >= y)) return; > > > i would have expected report to do: > > if (progress[1] <= y + step && progress[2] <= x) > update progress[1..2] > > but again, maybe iam missing something I'm not sure how much the previous explanation changes your understanding. I think you've been made fully aware by the comment in the code, but that step parameter is only useful for the x/y progress, and in a limited way. Sorry in advance if the following rationale is more confusing than anything else. The step parameter assumes square elements (blocks) are being decoded and advance the progress. _raster_end really does not care about the step: it just signals the end of the raster line, thus the progress is just flat (no step). The step parameter is only useful while in a step progress. Now, the one concern with the step progress API is when concurrent parts of a line are being decoded (think of a slice starting on this line). This may break if slice threading is also activated. The increment checking that uses the step tries to avoid this. But in some cases (several wpp threads), the progress is more like several staircases. Handling this would get out of hand and is less practical, so we are only dealing with one at a time. Nevertheless, when the raster line completes, the step progress on the following line may be well underway because of this, and the step increment check would force waiting for line completion, loosing any benefit of the API. So the step parameter can be used to both: - check the increment - immediately update progress on next line to allow some progress in it. > if progress[0] starts with 0 then this should be unneeded It's not always 0 if not enough attention is being paid by the user. Example with hevc: a block might have been completely in-loop-filtered, while the right neighbour isn't. In that case, a +/-4 pixels band around the top of the unfiltered neighbour can't used. If we are on the start of the image, this makes it -4. We can check this in the hevc code (clipping y position) but I thought it would simpler to handle it inside of the API. > also if the x and y step size is constant then one could use a > single variable based progress with > x_in_steps + y_in_steps * width_in_steps Yes, Donald mentioned this and so people could probably rewrite codecs to benefit from this finer granularity. My cursory look revealed nothing regarding vp8/9 but I may be wrong. However, I think it wouldn't allow the detail of the jumping position, though. Regarding the constant position, most likely, yes. A contrived counter-example are hevc post-filters that can be disabled on a slice-basis. Currently that doesn't matter, because we only look at the sps info, but it is possible to consider different steps depending on the frame etc. Overall, I don't think this new API is much future-proof, because the threading options in ffhevc are limited. I tried to start looking at vp9 but I realistically don't have that much time and will to come with a working version in that case. -- Christophe From danieloberhoff at gmail.com Sun Aug 3 18:43:18 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Sun, 3 Aug 2014 18:43:18 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> Message-ID: <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> Am 03.08.2014 um 18:38 schrieb Paul B Mahol : > On Sun, Aug 3, 2014 at 5:39 PM, Daniel Oberhoff > wrote: > >> >> Am 03.08.2014 um 03:15 schrieb Daniel Oberhoff < >> danieloberhoff at googlemail.com>: >> >>> Am 03.08.2014 um 00:12 schrieb Cl?ment B?sch : >>> >>>> On Fri, Aug 01, 2014 at 12:56:42PM +0200, Daniel Oberhoff wrote: >>>>> >>>>> Am 01.08.2014 um 12:22 schrieb Cl?ment B?sch : >>>>> >>>>>> On Fri, Aug 01, 2014 at 12:13:22PM +0200, Daniel Oberhoff wrote: >>>>>>> >>>>>>> Am 29.07.2014 um 09:54 schrieb Carl Eugen Hoyos : >>>>>>> >>>>>>>> Daniel Oberhoff gmail.com> writes: >>>>>>>> >>>>>>>>> OBJS-$(CONFIG_ZOOMPAN_FILTER) += vf_zoompan.o >>>>>>>>> +OBJS-$(CONFIG_RECTIFICATION_FILTER) += vf_rectification.o >>>>>>>> >>>>>>>>> REGISTER_FILTER(ZOOMPAN, zoompan, vf); >>>>>>>>> + REGISTER_FILTER(RECTIFICATION, rectification, vf); >>>>>>>> >>>>>>>> Keep the alphabetic ordering please. >>>>>>>> >>>>>>> >>>>>>> Ok >>>>>>> >>>>>>>>> + AV_PIX_FMT_YUV410P, >>>>>>>>> + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, >>>>>>>>> + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, >>>>>>>>> + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, >>>>>>>>> + AV_PIX_FMT_NONE >>>>>>>> >>>>>>>> I have no idea what this filter does and since the >>>>>>>> most important format (yuv420p) is supported, this >>>>>>>> doesn't really matter but yuv410p and yuva444p are >>>>>>>> quite exotic formats, I would at least have >>>>>>>> expected yuv422p, yuva420p and yuv444p in the list. >>>>>>>> >>>>>>>> Did you test all above formats (at least the left row)? >>>>>>> >>>>>>> Added the one from your list that was missing. Can you suggest an >> easy way of testing all these formats? >>>>>>> >>>>>> >>>>>> >>>>>> add a format filter before yours in the filtergraph (-vf >>>>>> format=yuv410p,rectification ?) >>>>> >>>>> Ok, borders can be a bitt different, but otherwise all work now, >> except vuy444p, which ffmpeg reports as invalid. btw, how can I get the >> components of a given color in the colorspace? >>>>> >>>>>> If you want to add a FATE test (which would be really awesome), you >> can >>>>>> grep for "video_filter" in tests/fate/filter-video.mak (to test all >> pixel >>>>>> formats the filter supports), or just make a standard test with >> framecrc. >>>>>> >>>>>> [...] >>>>> >>>>> I did that by adding this: >>>>> >>>>> FATE_FILTER_PIXFMTS-$(CONFIG_RECTIFICATION_FILTER) += >> fate-filter-pixfmts-rectification >>>>> fate-filter-pixfmts-rectification: CMD = pixfmts "0.6:0.4:0.65:0.4" >>>>> >>>>> then I ran >>>>> >>>>> make fate-filter-pixfmts-rectification GEN=1 >>>>> >>>>> which made a file >>>>> >>>>> test/data/fate/filter-pixfmts-rectification.rep >>>>> >>>> >>>> This is the result of a normal run to be compared by with the reference >>>> which should have also been generated with the help of GEN=1 for your >>>> first run. The file(s) generated by GEN=1 need to be tracked. >>>> >>>>> do I check this in or not? >>>>> >>>> >>>> Of course you are supposed to check if the results make sense. >>>> >>>> Use make fate-filter-pixfmts-rectifications V=1 to see what's going on. >>>> >>>>> running >>>>> >>>>> make fate-filter-pixfmts-rectification GEN=1 >>>>> >>>>> runs fine? >>>>> >>>> >>>> Of course, it doesn't do the comparison, it generates the reference. >>>> >>>>> Best >>>>> >>>>> Daniel >>>> >>>> -- >>>> Cl?ment B. >>>> _______________________________________________ >>>> ffmpeg-devel mailing list >>>> ffmpeg-devel at ffmpeg.org >>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >>> >>> Alright, will get that cleaned up. Since I seem to have all consent I >> need to also change the license I will see that I get a new patch ready >> soon. >>> >>> Best and thanks for feedback! >>> >>> Daniel >> >> Hello all, >> >> I updated the patch trying to incorporate all review feedback. I also got >> consent from the original author to put this filter under LGPL, and thus >> have it compiled in by default. I also conversed with Cyrille from Krita >> and he doesn?t see any more copyright issues, as at that point it boils >> down to the use of a well known algorithm, in a straight-forward >> implementation. >> >> Compared to the previous patch I renamed the filter to lenscorrection, >> since that is the name in the frei0r suite, and it will make using this >> instead of the frei0r one as easy as stating >> >> lenscorrection=... >> >> instead of >> >> frei0r=lenscorrection:... >> >> Last but not least I adapted the format list, inspected results on all >> formats, and supplied a fate test. Release notes and docs where also >> adapted. Please check if this is ok to push now. >> >> From dc552ae06a41725988250896327af2cceee1b812 Mon Sep 17 00:00:00 2001 >> From: Daniel Oberhoff >> Date: Mon, 28 Jul 2014 23:58:12 +0200 >> Subject: [PATCH] ported lenscorrection filter from frei0r >> >> --- >> Changelog | 2 +- >> doc/filters.texi | 36 +++++ >> libavfilter/Makefile | 1 + >> libavfilter/allfilters.c | 1 + >> libavfilter/version.h | 4 +- >> libavfilter/vf_lenscorrection.c | 208 >> +++++++++++++++++++++++++++ >> tests/fate/filter-video.mak | 3 + >> tests/ref/fate/filter-pixfmts-lenscorrection | 8 ++ >> 8 files changed, 260 insertions(+), 3 deletions(-) >> create mode 100644 libavfilter/vf_lenscorrection.c >> create mode 100644 tests/ref/fate/filter-pixfmts-lenscorrection >> >> >> >> diff --git a/libavfilter/Makefile b/libavfilter/Makefile >> index 0f54381..f74defa 100644 >> --- a/libavfilter/Makefile >> +++ b/libavfilter/Makefile >> @@ -162,6 +162,7 @@ OBJS-$(CONFIG_PIXDESCTEST_FILTER) += >> vf_pixdesctest.o >> OBJS-$(CONFIG_PP_FILTER) += vf_pp.o >> OBJS-$(CONFIG_PSNR_FILTER) += vf_psnr.o dualinput.o >> framesync.o >> OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o >> +OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o >> > > not in alphabetical order > > E, {.dbl=0.5}, 0, 1, .flags=FLAGS }, >> + { "k1", "set quadratic distortion factor", >> offsetof(LenscorrectionCtx, k1), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, >> .flags=FLAGS }, >> + { "k2", "set double quadratic distortion factor", >> offsetof(LenscorrectionCtx, k2), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, >> .flags=FLAGS }, >> + { NULL } >> +}; >> + >> +AVFILTER_DEFINE_CLASS(Lenscorrection); >> + >> +static av_cold int init(AVFilterContext *ctx) >> +{ >> + return 0; >> +} >> > > please remove this one, there is no point in having code that does nothing. > >> + >> +static av_cold void uninit(AVFilterContext *ctx) >> +{ >> +} >> + >> > > ditto > Done thanks! > > >> +typedef struct ThreadData { >> + AVFrame *in, *out; >> + float w, h; >> + int plane; >> + float xcenter, ycenter; >> + float k1, k2; >> +} ThreadData; >> + >> +static int filter_slice(AVFilterContext *ctx, void *arg, int job, int >> nb_jobs) >> +{ >> + ThreadData *td = (ThreadData*)arg; >> + AVFrame *in = td->in; >> + AVFrame *out = td->out; >> + >> + const float w = td->w, h = td->h; >> + const float xcenter = td->xcenter; >> + const float ycenter = td->ycenter; >> + const float r2inv = 4.0 / (w * w + h * h); >> + const float k1 = td->k1 - 0.5; >> + const float k2 = td->k2 - 0.5; >> + const int start = (h * job ) / nb_jobs; >> + const int end = (h * (job+1)) / nb_jobs; >> + const int plane = td->plane; >> + const int inlinesize = in->linesize[plane]; >> + const int outlinesize = out->linesize[plane]; >> + const uint8_t *indata = in->data[plane]; >> + uint8_t *outrow = out->data[plane] + start * outlinesize; >> + int i; >> + for (i = start; i < end; i++, outrow += outlinesize) { >> + const float off_y = i - ycenter; >> + const float off_y2 = off_y * off_y; >> + uint8_t *out = outrow; >> + int j; >> + for (j = 0; j < w; j++) { >> + const float off_x = j - xcenter; >> + const float r2 = (off_x * off_x + off_y2) * r2inv; >> + const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2; >> + const int x = xcenter + radius_mult * off_x + 0.5f; >> + const int y = ycenter + radius_mult * off_y + 0.5f; >> + const char isvalid = x > 0 && x < w - 1 && y > 0 && y < h - 1; >> + *out++ = isvalid ? indata[y * inlinesize + x] : 0; >> + } >> + } >> + return 0; >> +} >> + >> +static int query_formats(AVFilterContext *ctx) >> +{ >> + static enum PixelFormat pix_fmts[] = { >> + AV_PIX_FMT_YUV410P, >> + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, >> + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, >> + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, >> + AV_PIX_FMT_YUV422P, >> + AV_PIX_FMT_NONE >> + }; >> + >> + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); >> + return 0; >> +} >> + >> +static int config_props(AVFilterLink *outlink) >> +{ >> + AVFilterContext* ctx = outlink->src; >> + LenscorrectionCtx* rect = ctx->priv; >> + AVFilterLink *inlink = ctx->inputs[0]; >> + const AVPixFmtDescriptor *pixdesc = >> av_pix_fmt_desc_get(inlink->format); >> + rect->hsub = pixdesc->log2_chroma_w; >> + rect->vsub = pixdesc->log2_chroma_h; >> + outlink->w = rect->width = inlink->w; >> + outlink->h = rect->height = inlink->h; >> + rect->nb_planes = av_pix_fmt_count_planes(inlink->format); >> + return 0; >> +} >> + >> +static int filter_frame(AVFilterLink *inlink, AVFrame *in) >> +{ >> + AVFilterContext *ctx = inlink->dst; >> + AVFilterLink *outlink = ctx->outputs[0]; >> + LenscorrectionCtx *rect = (LenscorrectionCtx*)ctx->priv; >> + AVFrame* out = ff_get_video_buffer(outlink, outlink->w, outlink->h); >> + int plane; >> + >> + if (!out) { >> + av_frame_free(&in); >> + return AVERROR(ENOMEM); >> + } >> + >> + av_frame_copy_props(out, in); >> + >> + for (plane = 0; plane < rect->nb_planes; ++plane) { >> + int hsub = plane == 1 || plane == 2 ? rect->hsub : 0; >> + int vsub = plane == 1 || plane == 2 ? rect->vsub : 0; >> + float hdiv = 1 << hsub; >> + float vdiv = 1 << vsub; >> + float w = rect->width / hdiv; >> + float h = rect->height / vdiv; >> + ThreadData td = { .in = in, .out = out, >> + .w = w, >> + .h = h, >> + .xcenter = rect->cx * w, >> + .ycenter = rect->cy * h, >> + .k1 = rect->k1, >> + .k2 = rect->k2, >> + .plane = plane}; >> + ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, >> ctx->graph->nb_threads)); >> + } >> + >> + av_frame_free(&in); >> + return ff_filter_frame(outlink, out); >> +} >> + >> +static const AVFilterPad Lenscorrection_inputs[] = { >> + { >> + .name = "default", >> + .type = AVMEDIA_TYPE_VIDEO, >> + .filter_frame = filter_frame, >> + }, >> + { NULL } >> +}; >> + >> +static const AVFilterPad Lenscorrection_outputs[] = { >> + { >> + .name = "default", >> + .type = AVMEDIA_TYPE_VIDEO, >> + .config_props = config_props, >> + }, >> + { NULL } >> +}; >> + >> +AVFilter ff_vf_lenscorrection = { >> + .name = "lenscorrection", >> + .description = NULL_IF_CONFIG_SMALL("Rectify the image by >> correcting for lens distortion."), >> + .priv_size = sizeof(LenscorrectionCtx), >> + .init = init, >> + .uninit = uninit, >> > > Please remove those 2 lines. > > >> + .query_formats = query_formats, >> + .inputs = Lenscorrection_inputs, >> + .outputs = Lenscorrection_outputs, >> + .priv_class = &Lenscorrection_class, >> + .flags = AVFILTER_FLAG_SLICE_THREADS, >> +}; >> + >> \ No newline at end of file >> diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak >> index d87129b..cc5a71b 100644 >> --- a/tests/fate/filter-video.mak >> +++ b/tests/fate/filter-video.mak >> @@ -331,6 +331,9 @@ fate-filter-pixfmts-il: CMD = pixfmts >> "luma_mode=d:chroma_mode=d:alpha_mode=d >> FATE_FILTER_PIXFMTS-$(CONFIG_KERNDEINT_FILTER) += >> fate-filter-pixfmts-kerndeint >> fate-filter-pixfmts-kerndeint: CMD = pixfmts "" >> "tinterlace=interleave_top," >> >> +FATE_FILTER_PIXFMTS-$(CONFIG_LENSCORRECTION_FILTER) += >> fate-filter-pixfmts-lenscorrection >> +fate-filter-pixfmts-lenscorrection: CMD = pixfmts "0.6:0.4:0.65:0.4" >> + >> FATE_FILTER_PIXFMTS-$(CONFIG_LUT_FILTER) += fate-filter-pixfmts-lut >> fate-filter-pixfmts-lut: CMD = pixfmts >> "c0=2*val:c1=2*val:c2=val/2:c3=negval+40" >> >> diff --git a/tests/ref/fate/filter-pixfmts-lenscorrection >> b/tests/ref/fate/filter-pixfmts-lenscorrection >> new file mode 100644 >> index 0000000..18af6fb >> --- /dev/null >> +++ b/tests/ref/fate/filter-pixfmts-lenscorrection >> @@ -0,0 +1,8 @@ >> +yuv410p e7d59dbdb1afab7e2a8f770d563e28c4 >> +yuv420p bc45b4762d5271410ff825317c85af64 >> +yuv422p 5cce0c299322634d65e6b32c976e2c12 >> +yuv444p 03de9a93ab3045a523b234ea93f21c91 >> +yuva420p d1fa6735c4e7fbbf3a501cec1f0b4ac1 >> +yuva444p 713ddf5861d3df11c70a242a13c5e92e >> +yuvj420p 1d5cccaf4ef568ae9fa36f9a28e71c34 >> +yuvj444p aef1db29848e3b1dcaf4309255c38cbd >> -- >> 1.8.2 >> >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel at ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From christophe.gisquet at gmail.com Sun Aug 3 19:10:13 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Sun, 3 Aug 2014 19:10:13 +0200 Subject: [FFmpeg-devel] [PATCH 0/4] Exploit compile-time constant In-Reply-To: <20140802124846.GQ4649@nb4> References: <1406567848-6368-1-git-send-email-christophe.gisquet@gmail.com> <20140802124846.GQ4649@nb4> Message-ID: Hi, 2014-08-02 14:48 GMT+02:00 Michael Niedermayer : > is this for apply/push or just RFC/WIP ? in-between. I had expected Mickael Raulet to comment if he was seeing something not compatible with this. I think the bipred code is a bit more mature since Ronald comments (iirc), so premature optimization is probably a bit strong. Once Mickael is OK, then I'd agree with you about applying it. > you say "Premature optimization and overall not that useful." > i would tend to suggest to apply it as it improves speed ... I was saying this mostly because it doesn't really register overall: MC is around 20% in ffhevc for starters. > seems to fail with > libavcodec/x86/hevc_mc.asm:1258: error: (add:2) cannot reference symbol `MAX_PB_SIZE' in preprocessor That's actually the biggest beef I have with this patchset: MAX_PB_SIZE is a C and asm define, and the 2 need to be synchronized manually. I don't see how it could go beyond 64 (max block size in hevc), so the issue is rhetorical. I'm busy atm so I don't expect a new patchset soon. Best regards, -- Christophe From timothygu99 at gmail.com Sun Aug 3 19:11:04 2014 From: timothygu99 at gmail.com (Timothy Gu) Date: Sun, 03 Aug 2014 10:11:04 -0700 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <9125D41B-37F6-4B36-AF39-6EEB2FECC283@googlemail.com> <86A6C116-EB07-49A2-B1D3-64247396AEB3@googlemail.com> <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> Message-ID: <53DE6D28.8090903@gmail.com> On 08/03/2014 08:39 AM, Daniel Oberhoff wrote: > > Hello all, > > I updated the patch trying to incorporate all review feedback. I also got consent from the original author to put this filter under LGPL, and thus have it compiled in by default. I also conversed with Cyrille from Krita > and he doesn?t see any more copyright issues, as at that point it boils down to the use of a well known algorithm, in a straight-forward implementation. > > Compared to the previous patch I renamed the filter to lenscorrection, since that is the name in the frei0r suite, and it will make using this instead of the frei0r one as easy as stating > > lenscorrection=... > > instead of > > frei0r=lenscorrection:... > > Last but not least I adapted the format list, inspected results on all formats, and supplied a fate test. Release notes and docs where also adapted. Please check if this is ok to push now. > > From dc552ae06a41725988250896327af2cceee1b812 Mon Sep 17 00:00:00 2001 > From: Daniel Oberhoff > Date: Mon, 28 Jul 2014 23:58:12 +0200 > Subject: [PATCH] ported lenscorrection filter from frei0r avfilter: port lenscorrection filter from frei0r > > --- > Changelog | 2 +- > doc/filters.texi | 36 +++++ > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/version.h | 4 +- > libavfilter/vf_lenscorrection.c | 208 +++++++++++++++++++++++++++ > tests/fate/filter-video.mak | 3 + > tests/ref/fate/filter-pixfmts-lenscorrection | 8 ++ > 8 files changed, 260 insertions(+), 3 deletions(-) > create mode 100644 libavfilter/vf_lenscorrection.c > create mode 100644 tests/ref/fate/filter-pixfmts-lenscorrection If you would like to maintain this filter, you can choose to add your name to the MAINTAINERS file. > > diff --git a/Changelog b/Changelog > index 067f72a..3c1ee51 100644 > --- a/Changelog > +++ b/Changelog > @@ -2,7 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release, > releases are sorted from youngest to oldest. > > version : > - > +- ported lenscorrection filter from frei0r filter Just say frei0r and drop the "filter" > > version 2.3: > - AC3 fixed-point decoding > diff --git a/doc/filters.texi b/doc/filters.texi > index c5caa77..2af311a 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -5532,6 +5532,42 @@ kerndeint=map=1 > @end example > @end itemize > > + at section lenscorrection > + Add an one-line description here: Compensates for lens distortion. or Correct lens distortion. > +This filter can be used to correct for radial distortion as can result from the use > +of wide angle lenses, and thereby re-rectify the image. To find the right parameters > +one can use tools available for example as part of opencv or simply trial-and-error. OpenCV Can you offer some examples on how to find the right parameters? FFmpeg has support for libopencv. Can you use that? > +Note that effectively the same filter is available in the open-source tools Krita and > +Digikam from the KDE project. Add an empty line here to make the two paragraphs separate on the built documentation. > +In contrast to the vignette filter, which can also be used to compensate lens errors, Use @ref{vignette} here, and add @anchor{vignette} before @section vignette later in the file. > +this filter corrects the distortion of the image, whereas vignette corrects the > +brightness distribution, so you may want to use both filters together in certain > +cases, though you will have to take care of ordering, i.e. wether vignette should whether I also think you should probably use regular English and not filter names here, which makes the documentation more readable. So it's "vignetting" here, and "lens correction" below. > +be applied before or after lenscorrection. > + Add `@subsection Options` here. > +The filter accepts the following options: > + > + at table @option > + at item cx > +Relative x-coordinate of the focal point of the image, and thereby the center of the > +distrortion. This value has a range [0,1] and is expressed as fractions of the image > +width. > + at item cy > +Relative y-coordinate of the focal point of the image, and thereby the center of the > +distrortion. This value has a range [0,1] and is expressed as fractions of the image > +height. > + at item k1 > +Coefficient of the quadratic correction term. 0.5 means no correction. > + at item k2 > +Coefficient of the double quadratic correction term. 0.5 means no correction. > + at end table > + > +The formula that generates the correction is: > + > +r_src = r_tgt * (1 + (k1 - 0.5) * (r_tgt/r_0)^2 + (k2 - 0.5) * (r_tgt/r_0)^4) Please add @var{} to all of the variables, or, if you prefer, surround this block with @example and @end example. > + > +where r_0 is halve of the image diagonal. > + > @anchor{lut3d} > @section lut3d > > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index 0f54381..f74defa 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -162,6 +162,7 @@ OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o > OBJS-$(CONFIG_PP_FILTER) += vf_pp.o > OBJS-$(CONFIG_PSNR_FILTER) += vf_psnr.o dualinput.o framesync.o > OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o > +OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o > OBJS-$(CONFIG_REMOVELOGO_FILTER) += bbox.o lswsutils.o lavfutils.o vf_removelogo.o > OBJS-$(CONFIG_ROTATE_FILTER) += vf_rotate.o > OBJS-$(CONFIG_SEPARATEFIELDS_FILTER) += vf_separatefields.o > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c > index 1877557..b1d6ff5 100644 > --- a/libavfilter/allfilters.c > +++ b/libavfilter/allfilters.c > @@ -156,6 +156,7 @@ void avfilter_register_all(void) > REGISTER_FILTER(INTERLACE, interlace, vf); > REGISTER_FILTER(INTERLEAVE, interleave, vf); > REGISTER_FILTER(KERNDEINT, kerndeint, vf); > + REGISTER_FILTER(LENSCORRECTION, lenscorrection, vf); > REGISTER_FILTER(LUT3D, lut3d, vf); > REGISTER_FILTER(LUT, lut, vf); > REGISTER_FILTER(LUTRGB, lutrgb, vf); > diff --git a/libavfilter/version.h b/libavfilter/version.h > index 1a43dc5..47bac78 100644 > --- a/libavfilter/version.h > +++ b/libavfilter/version.h > @@ -30,8 +30,8 @@ > #include "libavutil/version.h" > > #define LIBAVFILTER_VERSION_MAJOR 4 > -#define LIBAVFILTER_VERSION_MINOR 11 > -#define LIBAVFILTER_VERSION_MICRO 102 > +#define LIBAVFILTER_VERSION_MINOR 12 > +#define LIBAVFILTER_VERSION_MICRO 100 > > #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ > LIBAVFILTER_VERSION_MINOR, \ > diff --git a/libavfilter/vf_lenscorrection.c b/libavfilter/vf_lenscorrection.c > new file mode 100644 > index 0000000..1aad94c > --- /dev/null > +++ b/libavfilter/vf_lenscorrection.c > @@ -0,0 +1,208 @@ > +/* > + * Copyright (c) 2014 Daniel Oberhoff > + * Copyright (C) 2007 Richard Spindler (author of frei0r plugin from which this was derived) Switch these two. > + * > + * This file is part of FFmpeg. > + * > + * 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 > + */ > + > +/** > + * @file > + * Lenscorrection filter, algorithm from the frei0r plugin with the same name > +*/ > +#include > +#include > + > +#include "libavutil/opt.h" > +#include "libavutil/intreadwrite.h" > +#include "libavutil/pixdesc.h" > + > +#include "avfilter.h" > +#include "internal.h" > +#include "video.h" > + > +typedef struct LenscorrectionCtx { > + const AVClass* av_class; > + unsigned int width; > + unsigned int height; > + int hsub, vsub; > + int nb_planes; > + double cx, cy, k1, k2; > +} LenscorrectionCtx; In FFmpeg, we indent by four spaces. > + > +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM > +static const AVOption Lenscorrection_options[] = { > + { "cx", "set relative center x", offsetof(LenscorrectionCtx, cx), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, > + { "cy", "set relative center y", offsetof(LenscorrectionCtx, cy), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, > + { "k1", "set quadratic distortion factor", offsetof(LenscorrectionCtx, k1), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, > + { "k2", "set double quadratic distortion factor", offsetof(LenscorrectionCtx, k2), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, You said 0.5 means no correction. Maybe use a saner default? > + { NULL } > +}; We usually use lower-case for names of AVOption arrays and other structures. So it's lenscorrection_options[]. > + > +AVFILTER_DEFINE_CLASS(Lenscorrection); here too > + > +static av_cold int init(AVFilterContext *ctx) > +{ > + return 0; > +} > + > +static av_cold void uninit(AVFilterContext *ctx) > +{ > +} As Paul said, drop these two. > + > +typedef struct ThreadData { > + AVFrame *in, *out; > + float w, h; > + int plane; > + float xcenter, ycenter; > + float k1, k2; > +} ThreadData; > + > +static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs) > +{ > + ThreadData *td = (ThreadData*)arg; > + AVFrame *in = td->in; > + AVFrame *out = td->out; > + > + const float w = td->w, h = td->h; > + const float xcenter = td->xcenter; > + const float ycenter = td->ycenter; > + const float r2inv = 4.0 / (w * w + h * h); > + const float k1 = td->k1 - 0.5; > + const float k2 = td->k2 - 0.5; > + const int start = (h * job ) / nb_jobs; > + const int end = (h * (job+1)) / nb_jobs; > + const int plane = td->plane; > + const int inlinesize = in->linesize[plane]; > + const int outlinesize = out->linesize[plane]; > + const uint8_t *indata = in->data[plane]; > + uint8_t *outrow = out->data[plane] + start * outlinesize; > + int i; > + for (i = start; i < end; i++, outrow += outlinesize) { > + const float off_y = i - ycenter; > + const float off_y2 = off_y * off_y; > + uint8_t *out = outrow; > + int j; > + for (j = 0; j < w; j++) { > + const float off_x = j - xcenter; > + const float r2 = (off_x * off_x + off_y2) * r2inv; > + const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2; > + const int x = xcenter + radius_mult * off_x + 0.5f; > + const int y = ycenter + radius_mult * off_y + 0.5f; > + const char isvalid = x > 0 && x < w - 1 && y > 0 && y < h - 1; > + *out++ = isvalid ? indata[y * inlinesize + x] : 0; > + } > + } > + return 0; > +} > + > +static int query_formats(AVFilterContext *ctx) > +{ > + static enum PixelFormat pix_fmts[] = { Use AVPixelFormat. PixelFormat is deprecated. > + AV_PIX_FMT_YUV410P, > + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, > + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, > + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, > + AV_PIX_FMT_YUV422P, > + AV_PIX_FMT_NONE > + }; > + > + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); > + return 0; > +} > + > +static int config_props(AVFilterLink *outlink) > +{ > + AVFilterContext* ctx = outlink->src; > + LenscorrectionCtx* rect = ctx->priv; We usually write * as attached to the variable name, which reduces ambiguity (int* a, b; vs. int *a, *b). So it's AVFilterContext *ctx = outlink->src; LenscorrectionCtx *rect = ctx->priv; > + AVFilterLink *inlink = ctx->inputs[0]; > + const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(inlink->format); > + rect->hsub = pixdesc->log2_chroma_w; > + rect->vsub = pixdesc->log2_chroma_h; > + outlink->w = rect->width = inlink->w; > + outlink->h = rect->height = inlink->h; > + rect->nb_planes = av_pix_fmt_count_planes(inlink->format); > + return 0; > +} > + > +static int filter_frame(AVFilterLink *inlink, AVFrame *in) > +{ > + AVFilterContext *ctx = inlink->dst; > + AVFilterLink *outlink = ctx->outputs[0]; > + LenscorrectionCtx *rect = (LenscorrectionCtx*)ctx->priv; > + AVFrame* out = ff_get_video_buffer(outlink, outlink->w, outlink->h); ditto > + int plane; > + > + if (!out) { > + av_frame_free(&in); > + return AVERROR(ENOMEM); > + } > + > + av_frame_copy_props(out, in); > + > + for (plane = 0; plane < rect->nb_planes; ++plane) { > + int hsub = plane == 1 || plane == 2 ? rect->hsub : 0; > + int vsub = plane == 1 || plane == 2 ? rect->vsub : 0; > + float hdiv = 1 << hsub; > + float vdiv = 1 << vsub; > + float w = rect->width / hdiv; > + float h = rect->height / vdiv; > + ThreadData td = { .in = in, .out = out, > + .w = w, > + .h = h, > + .xcenter = rect->cx * w, > + .ycenter = rect->cy * h, > + .k1 = rect->k1, > + .k2 = rect->k2, > + .plane = plane}; We usually write designated initializers like this: ThreadData td = { .in = in, .out = out, .w = w, .h = h, .xcenter = rect->cx * w, .ycenter = rect->cy * h, .k1 = rect->k1, .k2 = rect->k2, .plane = plane }; which makes it slightly more readable. > + ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ctx->graph->nb_threads)); > + } > + > + av_frame_free(&in); > + return ff_filter_frame(outlink, out); > +} > + > +static const AVFilterPad Lenscorrection_inputs[] = { > + { > + .name = "default", > + .type = AVMEDIA_TYPE_VIDEO, > + .filter_frame = filter_frame, > + }, > + { NULL } > +}; > + > +static const AVFilterPad Lenscorrection_outputs[] = { > + { > + .name = "default", > + .type = AVMEDIA_TYPE_VIDEO, > + .config_props = config_props, > + }, > + { NULL } > +}; capitalization of variable names > + > +AVFilter ff_vf_lenscorrection = { > + .name = "lenscorrection", > + .description = NULL_IF_CONFIG_SMALL("Rectify the image by correcting for lens distortion."), > + .priv_size = sizeof(LenscorrectionCtx), > + .init = init, > + .uninit = uninit, > + .query_formats = query_formats, > + .inputs = Lenscorrection_inputs, > + .outputs = Lenscorrection_outputs, > + .priv_class = &Lenscorrection_class, > + .flags = AVFILTER_FLAG_SLICE_THREADS, > +}; > + > \ No newline at end of file > diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak > index d87129b..cc5a71b 100644 > --- a/tests/fate/filter-video.mak > +++ b/tests/fate/filter-video.mak > @@ -331,6 +331,9 @@ fate-filter-pixfmts-il: CMD = pixfmts "luma_mode=d:chroma_mode=d:alpha_mode=d > FATE_FILTER_PIXFMTS-$(CONFIG_KERNDEINT_FILTER) += fate-filter-pixfmts-kerndeint > fate-filter-pixfmts-kerndeint: CMD = pixfmts "" "tinterlace=interleave_top," > > +FATE_FILTER_PIXFMTS-$(CONFIG_LENSCORRECTION_FILTER) += fate-filter-pixfmts-lenscorrection > +fate-filter-pixfmts-lenscorrection: CMD = pixfmts "0.6:0.4:0.65:0.4" > + > FATE_FILTER_PIXFMTS-$(CONFIG_LUT_FILTER) += fate-filter-pixfmts-lut > fate-filter-pixfmts-lut: CMD = pixfmts "c0=2*val:c1=2*val:c2=val/2:c3=negval+40" > > diff --git a/tests/ref/fate/filter-pixfmts-lenscorrection b/tests/ref/fate/filter-pixfmts-lenscorrection > new file mode 100644 > index 0000000..18af6fb > --- /dev/null > +++ b/tests/ref/fate/filter-pixfmts-lenscorrection > @@ -0,0 +1,8 @@ > +yuv410p e7d59dbdb1afab7e2a8f770d563e28c4 > +yuv420p bc45b4762d5271410ff825317c85af64 > +yuv422p 5cce0c299322634d65e6b32c976e2c12 > +yuv444p 03de9a93ab3045a523b234ea93f21c91 > +yuva420p d1fa6735c4e7fbbf3a501cec1f0b4ac1 > +yuva444p 713ddf5861d3df11c70a242a13c5e92e > +yuvj420p 1d5cccaf4ef568ae9fa36f9a28e71c34 > +yuvj444p aef1db29848e3b1dcaf4309255c38cbd > From george at nsup.org Sun Aug 3 19:31:43 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 19:31:43 +0200 Subject: [FFmpeg-devel] [PATCH] lavfi/avf_showspectrum: add full frame sliding mode. Message-ID: <1407087103-19078-1-git-send-email-george@nsup.org> Signed-off-by: Nicolas George --- doc/filters.texi | 15 +++++++++++-- libavfilter/avf_showspectrum.c | 50 +++++++++++++++++++++++++++--------------- 2 files changed, 45 insertions(+), 20 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index c5caa77..8739e84 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10589,8 +10589,19 @@ the "Video size" section in the ffmpeg-utils manual. Default value is @code{640x512}. @item slide -Specify if the spectrum should slide along the window. Default value is - at code{0}. +Specify how the spectrum should slide along the window. + +It accepts the following values: + at table @samp + at item replace +the samples start again on the left when they reach the right + at item scroll +the samples scroll from right to left + at item fullframe +frames are only produced when the samples reach the right + at end table + +Default value is @code{replace}. @item mode Specify display mode. diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index b354571..56759ff 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -38,6 +38,7 @@ enum DisplayMode { COMBINED, SEPARATE, NB_MODES }; enum DisplayScale { LINEAR, SQRT, CBRT, LOG, NB_SCALES }; enum ColorMode { CHANNEL, INTENSITY, NB_CLMODES }; enum WindowFunc { WFUNC_NONE, WFUNC_HANN, WFUNC_HAMMING, WFUNC_BLACKMAN, NB_WFUNC }; +enum SlideMode { REPLACE, SCROLL, FULLFRAME, NB_SLIDES }; typedef struct { const AVClass *class; @@ -66,7 +67,10 @@ typedef struct { static const AVOption showspectrum_options[] = { { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x512"}, 0, 0, FLAGS }, { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x512"}, 0, 0, FLAGS }, - { "slide", "set sliding mode", OFFSET(sliding), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, FLAGS }, + { "slide", "set sliding mode", OFFSET(sliding), AV_OPT_TYPE_INT, {.i64 = 0}, 0, NB_SLIDES, FLAGS, "slide" }, + { "replace", "replace old colums with new", 0, AV_OPT_TYPE_CONST, {.i64=REPLACE}, 0, 0, FLAGS, "slide" }, + { "scroll", "scroll from right to left", 0, AV_OPT_TYPE_CONST, {.i64=SCROLL}, 0, 0, FLAGS, "slide" }, + { "fullframe", "return full frames", 0, AV_OPT_TYPE_CONST, {.i64=FULLFRAME}, 0, 0, FLAGS, "slide" }, { "mode", "set channel display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=COMBINED}, COMBINED, NB_MODES-1, FLAGS, "mode" }, { "combined", "combined mode", 0, AV_OPT_TYPE_CONST, {.i64=COMBINED}, 0, 0, FLAGS, "mode" }, { "separate", "separate mode", 0, AV_OPT_TYPE_CONST, {.i64=SEPARATE}, 0, 0, FLAGS, "mode" }, @@ -244,6 +248,8 @@ static int config_output(AVFilterLink *outlink) s->xpos = 0; outlink->frame_rate = av_make_q(inlink->sample_rate, win_size); + if (s->sliding == FULLFRAME) + outlink->frame_rate.den *= outlink->w; inlink->min_samples = inlink->max_samples = inlink->partial_buf_size = win_size; @@ -257,27 +263,27 @@ static int config_output(AVFilterLink *outlink) return 0; } -inline static int push_frame(AVFilterLink *outlink) -{ - ShowSpectrumContext *s = outlink->src->priv; - - s->xpos++; - if (s->xpos >= outlink->w) - s->xpos = 0; - s->req_fullfilled = 1; - - return ff_filter_frame(outlink, av_frame_clone(s->outpicref)); -} - static int request_frame(AVFilterLink *outlink) { ShowSpectrumContext *s = outlink->src->priv; AVFilterLink *inlink = outlink->src->inputs[0]; + unsigned i; int ret; s->req_fullfilled = 0; do { ret = ff_request_frame(inlink); + if (ret == AVERROR_EOF && s->sliding == FULLFRAME && s->xpos > 0 && + s->outpicref) { + for (i = 0; i < outlink->h; i++) { + memset(s->outpicref->data[0] + i * s->outpicref->linesize[0] + s->xpos, 0, outlink->w - s->xpos); + memset(s->outpicref->data[1] + i * s->outpicref->linesize[1] + s->xpos, 128, outlink->w - s->xpos); + memset(s->outpicref->data[2] + i * s->outpicref->linesize[2] + s->xpos, 128, outlink->w - s->xpos); + } + ret = ff_filter_frame(outlink, s->outpicref); + s->outpicref = NULL; + s->req_fullfilled = 1; + } } while (!s->req_fullfilled && ret >= 0); return ret; @@ -440,7 +446,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples) } /* copy to output */ - if (s->sliding) { + if (s->sliding == SCROLL) { for (plane = 0; plane < 3; plane++) { for (y = 0; y < outlink->h; y++) { uint8_t *p = outpicref->data[plane] + @@ -460,10 +466,18 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples) } } - outpicref->pts = insamples->pts; - ret = push_frame(outlink); - if (ret < 0) - return ret; + if (s->sliding != FULLFRAME || s->xpos == 0) + outpicref->pts = insamples->pts; + + s->xpos++; + if (s->xpos >= outlink->w) + s->xpos = 0; + if (s->sliding != FULLFRAME || s->xpos == 0) { + s->req_fullfilled = 1; + ret = ff_filter_frame(outlink, av_frame_clone(s->outpicref)); + if (ret < 0) + return ret; + } return win_size; } -- 2.0.1 From george at nsup.org Sun Aug 3 19:51:00 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 19:51:00 +0200 Subject: [FFmpeg-devel] [PATCH] lavfi/avf_showspectrum: use automatic framing. In-Reply-To: <1407077965-16960-1-git-send-email-george@nsup.org> References: <1407077965-16960-1-git-send-email-george@nsup.org> Message-ID: <1407088260-19647-1-git-send-email-george@nsup.org> The framework can ensure that each input frame has exactly the correct number of samples, except the last one. Signed-off-by: Nicolas George --- libavfilter/avf_showspectrum.c | 48 +++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 31 deletions(-) Forgot to remove a variable that is no longer useful. diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index e925556..c59a4f6 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -55,8 +55,6 @@ typedef struct { RDFTContext *rdft; ///< Real Discrete Fourier Transform context int rdft_bits; ///< number of bits (RDFT window size = 1<rdft_data[i]) return AVERROR(ENOMEM); } - s->filled = 0; /* pre-calc windowing function */ s->window_func_lut = @@ -248,6 +245,9 @@ static int config_output(AVFilterLink *outlink) outlink->frame_rate = av_make_q(inlink->sample_rate, win_size); + inlink->min_samples = inlink->max_samples = inlink->partial_buf_size = + win_size; + s->combine_buffer = av_realloc_f(s->combine_buffer, outlink->h * 3, sizeof(*s->combine_buffer)); @@ -264,7 +264,6 @@ inline static int push_frame(AVFilterLink *outlink) s->xpos++; if (s->xpos >= outlink->w) s->xpos = 0; - s->filled = 0; s->req_fullfilled = 1; return ff_filter_frame(outlink, av_frame_clone(s->outpicref)); @@ -284,7 +283,7 @@ static int request_frame(AVFilterLink *outlink) return ret; } -static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb_samples) +static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples) { int ret; AVFilterContext *ctx = inlink->dst; @@ -297,26 +296,21 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb const int nb_freq = 1 << (s->rdft_bits - 1); const int win_size = nb_freq << 1; const double w = 1. / (sqrt(nb_freq) * 32768.); + int h = s->channel_height; /* channel height */ int ch, plane, n, y; - const int start = s->filled; - const int add_samples = FFMIN(win_size - start, nb_samples); + + av_assert0(insamples->nb_samples == win_size); /* fill RDFT input with the number of samples available */ for (ch = 0; ch < s->nb_display_channels; ch++) { const int16_t *p = (int16_t *)insamples->extended_data[ch]; - p += s->consumed; - for (n = 0; n < add_samples; n++) - s->rdft_data[ch][start + n] = p[n] * s->window_func_lut[start + n]; + for (n = 0; n < win_size; n++) + s->rdft_data[ch][n] = p[n] * s->window_func_lut[n]; } - s->filled += add_samples; - /* complete RDFT window size? */ - if (s->filled == win_size) { - - /* channel height */ - int h = s->channel_height; + /* TODO reindent */ /* run RDFT on each samples set */ for (ch = 0; ch < s->nb_display_channels; ch++) @@ -465,32 +459,24 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb } } - outpicref->pts = insamples->pts + - av_rescale_q(s->consumed + add_samples - win_size, - (AVRational){ 1, inlink->sample_rate }, - outlink->time_base); + outpicref->pts = insamples->pts; ret = push_frame(outlink); if (ret < 0) return ret; - } - return add_samples; + return win_size; } static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) { AVFilterContext *ctx = inlink->dst; ShowSpectrumContext *s = ctx->priv; - int ret = 0, left_samples = insamples->nb_samples; + unsigned win_size = 1 << s->rdft_bits; + int ret = 0; - s->consumed = 0; - while (left_samples) { - int ret = plot_spectrum_column(inlink, insamples, left_samples); - if (ret < 0) - break; - s->consumed += ret; - left_samples -= ret; - } + av_assert0(insamples->nb_samples <= win_size); + if (insamples->nb_samples == win_size) + ret = plot_spectrum_column(inlink, insamples); av_frame_free(&insamples); return ret; -- 2.0.1 From kierank at obe.tv Sun Aug 3 20:24:56 2014 From: kierank at obe.tv (Kieran Kunhya) Date: Sun, 3 Aug 2014 19:24:56 +0100 Subject: [FFmpeg-devel] [PATCHv3] Deprecate AFD field and add AFD as side-data Message-ID: <1407090297-5537-1-git-send-email-kierank@obe.tv> --- doc/APIchanges | 4 ++++ libavcodec/avcodec.h | 5 ++++- libavcodec/mpeg12dec.c | 20 +++++++++++++++++++- libavcodec/version.h | 5 ++++- libavfilter/vf_showinfo.c | 3 +++ libavutil/frame.h | 16 ++++++++++++++++ libavutil/version.h | 2 +- 7 files changed, 51 insertions(+), 4 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index fd202aa..e50768d 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,10 @@ libavutil: 2013-12-xx API changes, most recent first: +2014-07-xx - xxxxxxx - lavc 55.57.2 - avcodec.h +2014-07-xx - xxxxxxx - lavu 53.20.0 - frame.h + Deprecate AVCodecContext.dtg_active_format and use side-data instead + 2014-08-xx - xxxxxxx - lavc 55.57.1 - avcodec.h Deprecate unused FF_IDCT_IPP define and ipp avcodec option. Deprecate unused FF_DEBUG_PTS define and pts avcodec option. diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index dc8d57e..4261b46 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1503,6 +1503,7 @@ typedef struct AVCodecContext { */ int me_subpel_quality; +#if FF_API_AFD /** * DTG active format information (additional aspect ratio * information only used in DVB MPEG-2 transport streams) @@ -1510,8 +1511,9 @@ typedef struct AVCodecContext { * * - encoding: unused * - decoding: Set by decoder. + * @deprecated Deprecated in favour of AVSideData */ - int dtg_active_format; + attribute_deprecated int dtg_active_format; #define FF_DTG_AFD_SAME 8 #define FF_DTG_AFD_4_3 9 #define FF_DTG_AFD_16_9 10 @@ -1519,6 +1521,7 @@ typedef struct AVCodecContext { #define FF_DTG_AFD_4_3_SP_14_9 13 #define FF_DTG_AFD_16_9_SP_14_9 14 #define FF_DTG_AFD_SP_4_3 15 +#endif /** * maximum motion estimation search range in subpel units diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index aa98454..e36295d 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -54,6 +54,8 @@ typedef struct Mpeg1Context { int has_stereo3d; uint8_t *a53_caption; int a53_caption_size; + uint8_t afd; + int has_afd; int slice_count; int save_aspect_info; int save_width, save_height, save_progressive_seq; @@ -1631,6 +1633,18 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) *stereo = s1->stereo3d; s1->has_stereo3d = 0; } + + if (s1->has_afd) { + AVFrameSideData *sd = av_frame_new_side_data( + s->current_picture_ptr->f, AV_FRAME_DATA_AFD, + 1); + if (!sd) + return AVERROR(ENOMEM); + + sd->data = s1->afd; + s1->has_afd = 0; + } + if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME)) ff_thread_finish_setup(avctx); } else { // second field @@ -2221,6 +2235,7 @@ static void mpeg_decode_user_data(AVCodecContext *avctx, const uint8_t *p, int buf_size) { const uint8_t *buf_end = p + buf_size; + Mpeg1Context *s1 = avctx->priv_data; /* we parse the DTG active format information */ if (buf_end - p >= 5 && @@ -2234,7 +2249,11 @@ static void mpeg_decode_user_data(AVCodecContext *avctx, if (flags & 0x40) { if (buf_end - p < 1) return; +#if FF_API_AFD avctx->dtg_active_format = p[0] & 0x0f; +#endif + s1->has_afd = 1; + s1->afd = p[0] & 0x0f; } } else if (buf_end - p >= 6 && p[0] == 'J' && p[1] == 'P' && p[2] == '3' && p[3] == 'D' && @@ -2246,7 +2265,6 @@ static void mpeg_decode_user_data(AVCodecContext *avctx, S3D_video_format_type == 0x04 || S3D_video_format_type == 0x08 || S3D_video_format_type == 0x23) { - Mpeg1Context *s1 = avctx->priv_data; s1->has_stereo3d = 1; diff --git a/libavcodec/version.h b/libavcodec/version.h index cd35ae6..2c22adb 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -30,7 +30,7 @@ #define LIBAVCODEC_VERSION_MAJOR 55 #define LIBAVCODEC_VERSION_MINOR 57 -#define LIBAVCODEC_VERSION_MICRO 1 +#define LIBAVCODEC_VERSION_MICRO 2 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ @@ -147,5 +147,8 @@ #ifndef FF_API_CODEC_NAME #define FF_API_CODEC_NAME (LIBAVCODEC_VERSION_MAJOR < 57) #endif +#ifndef FF_API_AFD +#define FF_API_AFD (LIBAVCODEC_VERSION_MAJOR < 57) +#endif #endif /* AVCODEC_VERSION_H */ diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index cf90995..23af422 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -122,6 +122,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) av_log(ctx, AV_LOG_INFO, "displaymatrix: rotation of %.2f degrees", av_display_rotation_get((int32_t *)sd->data)); break; + case AV_FRAME_DATA_AFD: + av_log(ctx, AV_LOG_INFO, "afd: value of %u", sd->data[0]); + break; default: av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)", sd->type, sd->size); diff --git a/libavutil/frame.h b/libavutil/frame.h index b2159d3..14d6748 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -82,6 +82,22 @@ enum AVFrameSideDataType { * See libavutil/display.h for a detailed description of the data. */ AV_FRAME_DATA_DISPLAYMATRIX, + /** + * Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 + * using AVActiveFormatDescription enum + */ + AV_FRAME_DATA_AFD, +}; + +enum AVActiveFormatDescription +{ + AV_AFD_SAME = 8, + AV_AFD_4_3 = 9, + AV_AFD_16_9 = 10, + AV_AFD_14_9 = 11, + AV_AFD_4_3_SP_14_9 = 13, + AV_AFD_16_9_SP_14_9 = 14, + AV_AFD_SP_4_3 = 15 }; typedef struct AVFrameSideData { diff --git a/libavutil/version.h b/libavutil/version.h index e981948..820fdc6 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -54,7 +54,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 53 -#define LIBAVUTIL_VERSION_MINOR 19 +#define LIBAVUTIL_VERSION_MINOR 20 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 1.7.9.5 From george at nsup.org Sun Aug 3 20:40:36 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 20:40:36 +0200 Subject: [FFmpeg-devel] [PATCH] lavfi/avf_showspectrum: check RDFT contet init. Message-ID: <1407091236-20302-1-git-send-email-george@nsup.org> Fix a segfault with large window size. Signed-off-by: Nicolas George --- libavfilter/avf_showspectrum.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index 7bf3aab..764a000 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -177,6 +177,11 @@ static int config_output(AVFilterLink *outlink) av_rdft_end(s->rdft); s->rdft = av_rdft_init(rdft_bits, DFT_R2C); + if (!s->rdft) { + av_log(ctx, AV_LOG_ERROR, "Unable to allocate RDFT context. " + "Maybe window too high.\n"); + return AVERROR(EINVAL); + } s->rdft_bits = rdft_bits; /* RDFT buffers: x2 for each (display) channel buffer. -- 2.0.1 From timothygu99 at gmail.com Sun Aug 3 21:34:00 2014 From: timothygu99 at gmail.com (Timothy Gu) Date: Sun, 3 Aug 2014 12:34:00 -0700 Subject: [FFmpeg-devel] [PATCH] lavfi/avf_showspectrum: check RDFT contet init. In-Reply-To: <1407091236-20302-1-git-send-email-george@nsup.org> References: <1407091236-20302-1-git-send-email-george@nsup.org> Message-ID: On Sun, Aug 3, 2014 at 11:40 AM, Nicolas George wrote: > Fix a segfault with large window size. > > Signed-off-by: Nicolas George > --- > libavfilter/avf_showspectrum.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c > index 7bf3aab..764a000 100644 > --- a/libavfilter/avf_showspectrum.c > +++ b/libavfilter/avf_showspectrum.c > @@ -177,6 +177,11 @@ static int config_output(AVFilterLink *outlink) > > av_rdft_end(s->rdft); > s->rdft = av_rdft_init(rdft_bits, DFT_R2C); > + if (!s->rdft) { > + av_log(ctx, AV_LOG_ERROR, "Unable to allocate RDFT context. " > + "Maybe window too high.\n"); > + return AVERROR(EINVAL); ENOMEM? > + } > s->rdft_bits = rdft_bits; > > /* RDFT buffers: x2 for each (display) channel buffer. > -- > 2.0.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From michaelni at gmx.at Sun Aug 3 22:14:22 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 22:14:22 +0200 Subject: [FFmpeg-devel] [PATCH 4/5] vf_fps: move flushing remaining frames in a separate function. In-Reply-To: <1407071740-23116-4-git-send-email-george@nsup.org> References: <1407071740-23116-1-git-send-email-george@nsup.org> <1407071740-23116-4-git-send-email-george@nsup.org> Message-ID: <20140803201422.GD4649@nb4> On Sun, Aug 03, 2014 at 03:15:39PM +0200, Nicolas George wrote: > Also remove unused loop counter, rename obsolete "buf", > and add a comment about a similar function. > > Signed-off-by: Nicolas George LGTM thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 3 22:17:38 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 22:17:38 +0200 Subject: [FFmpeg-devel] [PATCH 5/5] lavfi/vf_fps: accept EOF timestamp. In-Reply-To: <1407071740-23116-5-git-send-email-george@nsup.org> References: <1407071740-23116-1-git-send-email-george@nsup.org> <1407071740-23116-5-git-send-email-george@nsup.org> Message-ID: <20140803201738.GE4649@nb4> On Sun, Aug 03, 2014 at 03:15:40PM +0200, Nicolas George wrote: > This makes the FPS filter duplicate the last frame to take > its duration into account, exactly like the other ones. > > Fix trac ticket #2674. > > Signed-off-by: Nicolas George > --- > libavfilter/vf_fps.c | 33 +++++++++++++++++++++++++-------- > 1 file changed, 25 insertions(+), 8 deletions(-) probably ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From u at pkh.me Sun Aug 3 22:27:21 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Sun, 3 Aug 2014 22:27:21 +0200 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: rewrite [f/i]dct Message-ID: <1407097641-26789-1-git-send-email-u@pkh.me> This removes the avcodec dependency and make the code almost twice as fast. More to come. The DCT factorization is based on "Fast and numerically stable algorithms for discrete cosine transforms" from Gerlind Plonkaa & Manfred Tasche (DOI: 10.1016/j.laa.2004.07.015). --- configure | 2 - libavfilter/vf_dctdnoiz.c | 328 +++++++++++++++++++++++++++++++++------------- 2 files changed, 240 insertions(+), 90 deletions(-) diff --git a/configure b/configure index 9c3af50..6196b2a 100755 --- a/configure +++ b/configure @@ -2526,8 +2526,6 @@ boxblur_filter_deps="gpl" bs2b_filter_deps="libbs2b" colormatrix_filter_deps="gpl" cropdetect_filter_deps="gpl" -dctdnoiz_filter_deps="avcodec" -dctdnoiz_filter_select="dct" delogo_filter_deps="gpl" deshake_filter_deps="avcodec" deshake_filter_select="me_cmp" diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c index 71b8536..6d24934 100644 --- a/libavfilter/vf_dctdnoiz.c +++ b/libavfilter/vf_dctdnoiz.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cl?ment B?sch + * Copyright (c) 2013-2014 Cl?ment B?sch * * This file is part of FFmpeg. * @@ -23,7 +23,6 @@ * @see http://www.ipol.im/pub/art/2011/ys-dct/ */ -#include "libavcodec/avfft.h" #include "libavutil/eval.h" #include "libavutil/opt.h" #include "drawutils.h" @@ -35,7 +34,7 @@ static const char *const var_names[] = { "c", NULL }; enum { VAR_C, VAR_VARS_NB }; -typedef struct { +typedef struct DCTdnoizContext { const AVClass *class; /* coefficient factor expression */ @@ -52,8 +51,9 @@ typedef struct { int p_linesize; // line sizes for color and weights int overlap; // number of block overlapping pixels int step; // block step increment (BSIZE - overlap) - DCTContext *dct, *idct; // DCT and inverse DCT contexts - float *block, *tmp_block; // two BSIZE x BSIZE block buffers + void (*filter_freq_func)(struct DCTdnoizContext *s, + const float *src, int src_linesize, + float *dst, int dst_linesize); } DCTdnoizContext; #define OFFSET(x) offsetof(DCTdnoizContext, x) @@ -69,66 +69,245 @@ static const AVOption dctdnoiz_options[] = { AVFILTER_DEFINE_CLASS(dctdnoiz); -static float *dct_block(DCTdnoizContext *ctx, const float *src, int src_linesize) +static void av_always_inline fdct16_1d(float *dst, const float *src, + int dst_stridea, int dst_strideb, + int src_stridea, int src_strideb) { - int x, y; - float *column; - - for (y = 0; y < BSIZE; y++) { - float *line = ctx->block; + int i; - memcpy(line, src, BSIZE * sizeof(*line)); - src += src_linesize; - av_dct_calc(ctx->dct, line); - - column = ctx->tmp_block + y; - column[0] = line[0] * (1. / sqrt(BSIZE)); - column += BSIZE; - for (x = 1; x < BSIZE; x++) { - *column = line[x] * sqrt(2. / BSIZE); - column += BSIZE; - } + for (i = 0; i < BSIZE; i++) { + const float x0_0 = src[ 0*src_stridea] + src[15*src_stridea]; + const float x0_1 = src[ 1*src_stridea] + src[14*src_stridea]; + const float x0_2 = src[ 2*src_stridea] + src[13*src_stridea]; + const float x0_3 = src[ 3*src_stridea] + src[12*src_stridea]; + const float x0_4 = src[ 4*src_stridea] + src[11*src_stridea]; + const float x0_5 = src[ 5*src_stridea] + src[10*src_stridea]; + const float x0_6 = src[ 6*src_stridea] + src[ 9*src_stridea]; + const float x0_7 = src[ 7*src_stridea] + src[ 8*src_stridea]; + const float x0_8 = src[ 0*src_stridea] - src[15*src_stridea]; + const float x0_9 = src[ 1*src_stridea] - src[14*src_stridea]; + const float x0_a = src[ 2*src_stridea] - src[13*src_stridea]; + const float x0_b = src[ 3*src_stridea] - src[12*src_stridea]; + const float x0_c = src[ 4*src_stridea] - src[11*src_stridea]; + const float x0_d = src[ 5*src_stridea] - src[10*src_stridea]; + const float x0_e = src[ 6*src_stridea] - src[ 9*src_stridea]; + const float x0_f = src[ 7*src_stridea] - src[ 8*src_stridea]; + const float x2_0 = x0_0 + x0_7; + const float x2_1 = x0_1 + x0_6; + const float x2_2 = x0_2 + x0_5; + const float x2_3 = x0_3 + x0_4; + const float x2_4 = x0_0 - x0_7; + const float x2_5 = x0_1 - x0_6; + const float x2_6 = x0_2 - x0_5; + const float x2_7 = x0_3 - x0_4; + const float x4_0 = x2_0 + x2_3; + const float x4_1 = x2_1 + x2_2; + const float x4_2 = x2_0 - x2_3; + const float x4_3 = x2_1 - x2_2; + const float x5_0 = x4_0 + x4_1; + const float x5_1 = x4_0 - x4_1; + const float x5_2 = 1.306562964876380*x4_2 + 0.541196100146197*x4_3; + const float x5_3 = 0.541196100146197*x4_2 - 1.306562964876380*x4_3; + const float x6_0 = 1.387039845322150*x2_4 + 0.275899379282943*x2_7; + const float x6_1 = 1.175875602419360*x2_5 + 0.785694958387102*x2_6; + const float x6_2 = -0.785694958387102*x2_5 + 1.175875602419360*x2_6; + const float x6_3 = 0.275899379282943*x2_4 - 1.387039845322150*x2_7; + const float x7_0 = x6_0 + x6_1; + const float x7_1 = x6_0 - x6_1; + const float x7_2 = x6_2 + x6_3; + const float x7_3 = x6_2 - x6_3; + const float x3_5 = 0.707106781186547*x7_1 - 0.707106781186547*x7_3; + const float x3_6 = 0.707106781186547*x7_1 + 0.707106781186547*x7_3; + const float x8_0 = 1.407403737526380*x0_8 + 0.138617169199091*x0_f; + const float x8_1 = 1.353318001174350*x0_9 + 0.410524527522357*x0_e; + const float x8_2 = 1.247225012986670*x0_a + 0.666655658477747*x0_d; + const float x8_3 = 1.093201867001760*x0_b + 0.897167586342636*x0_c; + const float x8_4 = -0.897167586342636*x0_b + 1.093201867001760*x0_c; + const float x8_5 = 0.666655658477747*x0_a - 1.247225012986670*x0_d; + const float x8_6 = -0.410524527522357*x0_9 + 1.353318001174350*x0_e; + const float x8_7 = 0.138617169199091*x0_8 - 1.407403737526380*x0_f; + const float xa_0 = x8_0 + x8_3; + const float xa_1 = x8_1 + x8_2; + const float xa_2 = x8_0 - x8_3; + const float xa_3 = x8_1 - x8_2; + const float xb_0 = xa_0 + xa_1; + const float xb_1 = xa_0 - xa_1; + const float xb_2 = 1.306562964876380*xa_2 + 0.541196100146197*xa_3; + const float xb_3 = 0.541196100146197*xa_2 - 1.306562964876380*xa_3; + const float xc_0 = x8_4 + x8_7; + const float xc_1 = x8_5 + x8_6; + const float xc_2 = x8_4 - x8_7; + const float xc_3 = x8_5 - x8_6; + const float xd_0 = xc_0 + xc_1; + const float xd_1 = xc_0 - xc_1; + const float xd_2 = 1.306562964876380*xc_2 + 0.541196100146197*xc_3; + const float xd_3 = 0.541196100146197*xc_2 - 1.306562964876380*xc_3; + const float x1_9 = 0.707106781186547*xb_2 - 0.707106781186547*xd_3; + const float x1_a = 0.707106781186547*xb_2 + 0.707106781186547*xd_3; + const float x1_b = 0.707106781186547*xb_1 + 0.707106781186547*xd_1; + const float x1_c = 0.707106781186547*xb_1 - 0.707106781186547*xd_1; + const float x1_d = 0.707106781186547*xb_3 - 0.707106781186547*xd_2; + const float x1_e = 0.707106781186547*xb_3 + 0.707106781186547*xd_2; + dst[ 0*dst_stridea] = 0.25*x5_0; + dst[ 1*dst_stridea] = 0.25*xb_0; + dst[ 2*dst_stridea] = 0.25*x7_0; + dst[ 3*dst_stridea] = 0.25*x1_9; + dst[ 4*dst_stridea] = 0.25*x5_2; + dst[ 5*dst_stridea] = 0.25*x1_a; + dst[ 6*dst_stridea] = 0.25*x3_5; + dst[ 7*dst_stridea] = 0.25*x1_b; + dst[ 8*dst_stridea] = 0.25*x5_1; + dst[ 9*dst_stridea] = 0.25*x1_c; + dst[10*dst_stridea] = 0.25*x3_6; + dst[11*dst_stridea] = 0.25*x1_d; + dst[12*dst_stridea] = 0.25*x5_3; + dst[13*dst_stridea] = 0.25*x1_e; + dst[14*dst_stridea] = 0.25*x7_2; + dst[15*dst_stridea] = 0.25*xd_0; + dst += dst_strideb; + src += src_strideb; } +} - column = ctx->tmp_block; - for (x = 0; x < BSIZE; x++) { - av_dct_calc(ctx->dct, column); - column[0] *= 1. / sqrt(BSIZE); - for (y = 1; y < BSIZE; y++) - column[y] *= sqrt(2. / BSIZE); - column += BSIZE; +static void av_always_inline idct16_1d(float *dst, const float *src, + int dst_stridea, int dst_strideb, + int src_stridea, int src_strideb, + int add) +{ + int i; + + for (i = 0; i < BSIZE; i++) { + const float x0_0 = 1.414213562373100*src[ 0*src_stridea]; + const float x0_1 = 1.407403737526380*src[ 1*src_stridea] + 0.138617169199091*src[15*src_stridea]; + const float x0_2 = 1.387039845322150*src[ 2*src_stridea] + 0.275899379282943*src[14*src_stridea]; + const float x0_3 = 1.353318001174350*src[ 3*src_stridea] + 0.410524527522357*src[13*src_stridea]; + const float x0_4 = 1.306562964876380*src[ 4*src_stridea] + 0.541196100146197*src[12*src_stridea]; + const float x0_5 = 1.247225012986670*src[ 5*src_stridea] + 0.666655658477747*src[11*src_stridea]; + const float x0_6 = 1.175875602419360*src[ 6*src_stridea] + 0.785694958387102*src[10*src_stridea]; + const float x0_7 = 1.093201867001760*src[ 7*src_stridea] + 0.897167586342636*src[ 9*src_stridea]; + const float x0_8 = 1.414213562373100*src[ 8*src_stridea]; + const float x0_9 = -0.897167586342636*src[ 7*src_stridea] + 1.093201867001760*src[ 9*src_stridea]; + const float x0_a = 0.785694958387102*src[ 6*src_stridea] - 1.175875602419360*src[10*src_stridea]; + const float x0_b = -0.666655658477747*src[ 5*src_stridea] + 1.247225012986670*src[11*src_stridea]; + const float x0_c = 0.541196100146197*src[ 4*src_stridea] - 1.306562964876380*src[12*src_stridea]; + const float x0_d = -0.410524527522357*src[ 3*src_stridea] + 1.353318001174350*src[13*src_stridea]; + const float x0_e = 0.275899379282943*src[ 2*src_stridea] - 1.387039845322150*src[14*src_stridea]; + const float x0_f = -0.138617169199091*src[ 1*src_stridea] + 1.407403737526380*src[15*src_stridea]; + const float x2_0 = x0_0 + x0_8; + const float x2_1 = x0_1 + x0_7; + const float x2_2 = x0_2 + x0_6; + const float x2_3 = x0_3 + x0_5; + const float x2_4 = 1.4142135623731*x0_4; + const float x2_5 = x0_0 - x0_8; + const float x2_6 = x0_1 - x0_7; + const float x2_7 = x0_2 - x0_6; + const float x2_8 = x0_3 - x0_5; + const float x4_0 = x2_0 + x2_4; + const float x4_1 = x2_1 + x2_3; + const float x4_2 = 1.4142135623731*x2_2; + const float x4_3 = x2_0 - x2_4; + const float x4_4 = x2_1 - x2_3; + const float x5_0 = 0.5*x4_0 + 0.707106781186548*x4_1 + 0.5*x4_2; + const float x5_1 = 0.707106781186548*x4_0 - 0.707106781186548*x4_2; + const float x5_2 = 0.5*x4_0 - 0.707106781186548*x4_1 + 0.5*x4_2; + const float x5_3 = 0.707106781186547*x4_3 + 0.707106781186547*x4_4; + const float x5_4 = 0.707106781186547*x4_3 - 0.707106781186547*x4_4; + const float x6_0 = 1.4142135623731*x2_5; + const float x6_1 = 1.30656296487638*x2_6 + 0.541196100146197*x2_8; + const float x6_2 = 1.4142135623731*x2_7; + const float x6_3 = -0.541196100146197*x2_6 + 1.30656296487638*x2_8; + const float x7_0 = 0.5*x6_0 + 0.707106781186548*x6_1 + 0.5*x6_2; + const float x7_1 = 0.707106781186548*x6_0 - 0.707106781186548*x6_2; + const float x7_2 = 0.5*x6_0 - 0.707106781186548*x6_1 + 0.5*x6_2; + const float x3_6 = 0.707106781186547*x7_1 - 0.707106781186547*x6_3; + const float x3_7 = 0.707106781186547*x7_1 + 0.707106781186547*x6_3; + const float x8_0 = 1.4142135623731*x0_c; + const float x8_1 = x0_b + x0_d; + const float x8_2 = x0_a + x0_e; + const float x8_3 = x0_9 + x0_f; + const float x8_4 = x0_9 - x0_f; + const float x8_5 = x0_a - x0_e; + const float x8_6 = x0_b - x0_d; + const float xa_0 = 1.4142135623731*x8_0; + const float xa_1 = 1.30656296487638*x8_1 + 0.541196100146197*x8_3; + const float xa_2 = 1.4142135623731*x8_2; + const float xa_3 = -0.541196100146197*x8_1 + 1.30656296487638*x8_3; + const float xb_0 = 0.5*xa_0 + 0.707106781186548*xa_1 + 0.5*xa_2; + const float xb_1 = 0.707106781186548*xa_0 - 0.707106781186548*xa_2; + const float xb_2 = 0.5*xa_0 - 0.707106781186548*xa_1 + 0.5*xa_2; + const float x9_1 = 0.707106781186547*xb_1 - 0.707106781186547*xa_3; + const float x9_2 = 0.707106781186547*xb_1 + 0.707106781186547*xa_3; + const float xc_0 = 1.4142135623731*x8_5; + const float xc_1 = x8_4 + x8_6; + const float xc_2 = x8_4 - x8_6; + const float xd_0 = 0.707106781186547*xc_0 + 0.707106781186547*xc_1; + const float xd_1 = 0.707106781186547*xc_0 - 0.707106781186547*xc_1; + const float x9_6 = -xd_1; + const float x1_b = -x9_1; + const float x1_f = -xb_2; + dst[ 0*dst_stridea] = (add ? dst[ 0*dst_stridea] : 0) + 0.353553390593274*x5_0; + dst[ 1*dst_stridea] = (add ? dst[ 1*dst_stridea] : 0) + 0.25*x7_0 - 0.25*x1_f; + dst[ 2*dst_stridea] = (add ? dst[ 2*dst_stridea] : 0) + 0.25*x7_0 + 0.25*x1_f; + dst[ 3*dst_stridea] = (add ? dst[ 3*dst_stridea] : 0) + 0.25*x5_3 + 0.25*x9_6; + dst[ 4*dst_stridea] = (add ? dst[ 4*dst_stridea] : 0) + 0.25*x5_3 - 0.25*x9_6; + dst[ 5*dst_stridea] = (add ? dst[ 5*dst_stridea] : 0) + 0.25*x3_6 - 0.25*x9_2; + dst[ 6*dst_stridea] = (add ? dst[ 6*dst_stridea] : 0) + 0.25*x3_6 + 0.25*x9_2; + dst[ 7*dst_stridea] = (add ? dst[ 7*dst_stridea] : 0) + 0.25*x5_1 + 0.25*xc_2; + dst[ 8*dst_stridea] = (add ? dst[ 8*dst_stridea] : 0) + 0.25*x5_1 - 0.25*xc_2; + dst[ 9*dst_stridea] = (add ? dst[ 9*dst_stridea] : 0) + 0.25*x3_7 - 0.25*x1_b; + dst[10*dst_stridea] = (add ? dst[10*dst_stridea] : 0) + 0.25*x3_7 + 0.25*x1_b; + dst[11*dst_stridea] = (add ? dst[11*dst_stridea] : 0) + 0.25*x5_4 + 0.25*xd_0; + dst[12*dst_stridea] = (add ? dst[12*dst_stridea] : 0) + 0.25*x5_4 - 0.25*xd_0; + dst[13*dst_stridea] = (add ? dst[13*dst_stridea] : 0) + 0.25*x7_2 - 0.25*xb_0; + dst[14*dst_stridea] = (add ? dst[14*dst_stridea] : 0) + 0.25*x7_2 + 0.25*xb_0; + dst[15*dst_stridea] = (add ? dst[15*dst_stridea] : 0) + 0.353553390593274*x5_2; + dst += dst_strideb; + src += src_strideb; } +} - for (y = 0; y < BSIZE; y++) - for (x = 0; x < BSIZE; x++) - ctx->block[y*BSIZE + x] = ctx->tmp_block[x*BSIZE + y]; +static av_always_inline void filter_freq(const float *src, int src_linesize, + float *dst, int dst_linesize, + AVExpr *expr, double *var_values, + int sigma_th) +{ + unsigned i; + DECLARE_ALIGNED(32, float, tmp_block1)[BSIZE * BSIZE]; + DECLARE_ALIGNED(32, float, tmp_block2)[BSIZE * BSIZE]; + + /* forward DCT */ + fdct16_1d(tmp_block1, src, 1, BSIZE, 1, src_linesize); + fdct16_1d(tmp_block2, tmp_block1, BSIZE, 1, BSIZE, 1); + + for (i = 0; i < BSIZE*BSIZE; i++) { + float *b = &tmp_block2[i]; + /* frequency filtering */ + if (expr) { + var_values[VAR_C] = FFABS(*b); + *b *= av_expr_eval(expr, var_values, NULL); + } else { + if (FFABS(*b) < sigma_th) + *b = 0; + } + } - return ctx->block; + /* inverse DCT */ + idct16_1d(tmp_block1, tmp_block2, 1, BSIZE, 1, BSIZE, 0); + idct16_1d(dst, tmp_block1, dst_linesize, 1, BSIZE, 1, 1); } -static void idct_block(DCTdnoizContext *ctx, float *dst, int dst_linesize) +static void filter_freq_sigma(DCTdnoizContext *s, + const float *src, int src_linesize, + float *dst, int dst_linesize) { - int x, y; - float *block = ctx->block; - float *tmp = ctx->tmp_block; - - for (y = 0; y < BSIZE; y++) { - block[0] *= sqrt(BSIZE); - for (x = 1; x < BSIZE; x++) - block[x] *= 1./sqrt(2. / BSIZE); - av_dct_calc(ctx->idct, block); - block += BSIZE; - } + filter_freq(src, src_linesize, dst, dst_linesize, NULL, NULL, s->th); +} - block = ctx->block; - for (y = 0; y < BSIZE; y++) { - tmp[0] = block[y] * sqrt(BSIZE); - for (x = 1; x < BSIZE; x++) - tmp[x] = block[x*BSIZE + y] * (1./sqrt(2. / BSIZE)); - av_dct_calc(ctx->idct, tmp); - for (x = 0; x < BSIZE; x++) - dst[x*dst_linesize + y] += tmp[x]; - } +static void filter_freq_expr(DCTdnoizContext *s, + const float *src, int src_linesize, + float *dst, int dst_linesize) +{ + filter_freq(src, src_linesize, dst, dst_linesize, s->expr, s->var_values, 0); } static int config_input(AVFilterLink *inlink) @@ -194,18 +373,13 @@ static av_cold int init(AVFilterContext *ctx) NULL, NULL, NULL, NULL, 0, ctx); if (ret < 0) return ret; + s->filter_freq_func = filter_freq_expr; + } else { + s->filter_freq_func = filter_freq_sigma; } s->th = s->sigma * 3.; s->step = BSIZE - s->overlap; - s->dct = av_dct_init(NBITS, DCT_II); - s->idct = av_dct_init(NBITS, DCT_III); - s->block = av_malloc(BSIZE * BSIZE * sizeof(*s->block)); - s->tmp_block = av_malloc(BSIZE * BSIZE * sizeof(*s->tmp_block)); - - if (!s->dct || !s->idct || !s->tmp_block || !s->block) - return AVERROR(ENOMEM); - return 0; } @@ -272,7 +446,7 @@ static void filter_plane(AVFilterContext *ctx, const float *src, int src_linesize, int w, int h) { - int x, y, bx, by; + int x, y; DCTdnoizContext *s = ctx->priv; float *dst0 = dst; const float *weights = s->weights; @@ -282,27 +456,9 @@ static void filter_plane(AVFilterContext *ctx, // block dct sums for (y = 0; y < h - BSIZE + 1; y += s->step) { - for (x = 0; x < w - BSIZE + 1; x += s->step) { - float *ftb = dct_block(s, src + x, src_linesize); - - if (s->expr) { - for (by = 0; by < BSIZE; by++) { - for (bx = 0; bx < BSIZE; bx++) { - s->var_values[VAR_C] = FFABS(*ftb); - *ftb++ *= av_expr_eval(s->expr, s->var_values, s); - } - } - } else { - for (by = 0; by < BSIZE; by++) { - for (bx = 0; bx < BSIZE; bx++) { - if (FFABS(*ftb) < s->th) - *ftb = 0; - ftb++; - } - } - } - idct_block(s, dst + x, dst_linesize); - } + for (x = 0; x < w - BSIZE + 1; x += s->step) + s->filter_freq_func(s, src + x, src_linesize, + dst + x, dst_linesize); src += s->step * src_linesize; dst += s->step * dst_linesize; } @@ -388,10 +544,6 @@ static av_cold void uninit(AVFilterContext *ctx) int i; DCTdnoizContext *s = ctx->priv; - av_dct_end(s->dct); - av_dct_end(s->idct); - av_free(s->block); - av_free(s->tmp_block); av_free(s->weights); for (i = 0; i < 2; i++) { av_free(s->cbuf[i][0]); -- 2.0.2 From u at pkh.me Sun Aug 3 22:36:52 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Sun, 3 Aug 2014 22:36:52 +0200 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: rewrite [f/i]dct In-Reply-To: <1407097641-26789-1-git-send-email-u@pkh.me> References: <1407097641-26789-1-git-send-email-u@pkh.me> Message-ID: <20140803203652.GS10372@leki> On Sun, Aug 03, 2014 at 10:27:21PM +0200, Cl?ment B?sch wrote: > This removes the avcodec dependency and make the code almost twice as > fast. More to come. > > The DCT factorization is based on "Fast and numerically stable > algorithms for discrete cosine transforms" from Gerlind Plonkaa & > Manfred Tasche (DOI: 10.1016/j.laa.2004.07.015). > --- > configure | 2 - > libavfilter/vf_dctdnoiz.c | 328 +++++++++++++++++++++++++++++++++------------- > 2 files changed, 240 insertions(+), 90 deletions(-) > BTW, for the details on the factorization: https://github.com/ubitux/dct I have a few more things planed to improve the performances; typically, moving from 16x16 to 8x8 with the previous dct made the code something like 6 or 7x faster, so I expect a similar gain with the new dct (I'll add a runtime user option for this). Also, the way color correction/decorrelation is implemented is kind of very stupid and thus slow, so I'll fix that as well. I would like to add tests, but the float are probably a no-go, but we probably have a threshold system in FATE for this? (FUZZ?). On a side note, I have an experiment with integer operations which worked with the previous DCT, so maybe that's a solution for FATE (although I'm uncertain about the performance gain and the precision loss). Last thing is the threading. While it will definitely helps for the simple sigma case, it will be a problem for the eval method. I guess I'll just ignore threading when that option is selected by the user. [...] -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From michaelni at gmx.at Sun Aug 3 22:46:58 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 22:46:58 +0200 Subject: [FFmpeg-devel] [PATCHv3] Deprecate AFD field and add AFD as side-data In-Reply-To: <1407090297-5537-1-git-send-email-kierank@obe.tv> References: <1407090297-5537-1-git-send-email-kierank@obe.tv> Message-ID: <20140803204658.GF4649@nb4> On Sun, Aug 03, 2014 at 07:24:56PM +0100, Kieran Kunhya wrote: > --- > doc/APIchanges | 4 ++++ > libavcodec/avcodec.h | 5 ++++- > libavcodec/mpeg12dec.c | 20 +++++++++++++++++++- > libavcodec/version.h | 5 ++++- > libavfilter/vf_showinfo.c | 3 +++ > libavutil/frame.h | 16 ++++++++++++++++ > libavutil/version.h | 2 +- > 7 files changed, 51 insertions(+), 4 deletions(-) [...] > @@ -1631,6 +1633,18 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) > *stereo = s1->stereo3d; > s1->has_stereo3d = 0; > } > + > + if (s1->has_afd) { > + AVFrameSideData *sd = av_frame_new_side_data( > + s->current_picture_ptr->f, AV_FRAME_DATA_AFD, > + 1); > + if (!sd) > + return AVERROR(ENOMEM); > + > + sd->data = s1->afd; this should be *(uint8_t*)sd->data = s1->afd; also in case you had this applied locally, this could have caused crashes in memory allocation functions like the one you talked about in relation to opus [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 3 22:49:39 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 22:49:39 +0200 Subject: [FFmpeg-devel] [PATCHv3] Deprecate AFD field and add AFD as side-data In-Reply-To: <20140803204658.GF4649@nb4> References: <1407090297-5537-1-git-send-email-kierank@obe.tv> <20140803204658.GF4649@nb4> Message-ID: <20140803204939.GG4649@nb4> On Sun, Aug 03, 2014 at 10:46:58PM +0200, Michael Niedermayer wrote: > On Sun, Aug 03, 2014 at 07:24:56PM +0100, Kieran Kunhya wrote: > > --- > > doc/APIchanges | 4 ++++ > > libavcodec/avcodec.h | 5 ++++- > > libavcodec/mpeg12dec.c | 20 +++++++++++++++++++- > > libavcodec/version.h | 5 ++++- > > libavfilter/vf_showinfo.c | 3 +++ > > libavutil/frame.h | 16 ++++++++++++++++ > > libavutil/version.h | 2 +- > > 7 files changed, 51 insertions(+), 4 deletions(-) > [...] > > @@ -1631,6 +1633,18 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) > > *stereo = s1->stereo3d; > > s1->has_stereo3d = 0; > > } > > + > > + if (s1->has_afd) { > > + AVFrameSideData *sd = av_frame_new_side_data( > > + s->current_picture_ptr->f, AV_FRAME_DATA_AFD, > > + 1); > > + if (!sd) > > + return AVERROR(ENOMEM); > > + > > > + sd->data = s1->afd; > > this should be > *(uint8_t*)sd->data = s1->afd; or simpler *sd->data = s1->afd; [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From george at nsup.org Sun Aug 3 22:57:53 2014 From: george at nsup.org (Nicolas George) Date: Sun, 3 Aug 2014 22:57:53 +0200 Subject: [FFmpeg-devel] [PATCH] lavfi/avf_showspectrum: check RDFT contet init. In-Reply-To: References: <1407091236-20302-1-git-send-email-george@nsup.org> Message-ID: <20140803205753.GA32378@phare.normalesup.org> Le sextidi 16 thermidor, an CCXXII, Timothy Gu a ?crit?: > > s->rdft = av_rdft_init(rdft_bits, DFT_R2C); > > + if (!s->rdft) { > > + av_log(ctx, AV_LOG_ERROR, "Unable to allocate RDFT context. " > > + "Maybe window too high.\n"); > > + return AVERROR(EINVAL); > ENOMEM? Ideally, av_rdft_init() would return a proper error code, but that is not the case. In practice, on modern operating systems, memory allocation for something that small will never fail. On the other hand, trying to init for an unsupported window size (<4 or >16) is a very obvious error. Therefore I believe EINVAL is more likely to reflect the actual error than ENOMEM. Regards, -- Nicolas George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From timothygu99 at gmail.com Sun Aug 3 22:59:25 2014 From: timothygu99 at gmail.com (Timothy Gu) Date: Sun, 3 Aug 2014 13:59:25 -0700 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: rewrite [f/i]dct In-Reply-To: <1407097641-26789-1-git-send-email-u@pkh.me> References: <1407097641-26789-1-git-send-email-u@pkh.me> Message-ID: On Aug 3, 2014 1:27 PM, "Cl?ment B?sch" wrote: > > This removes the avcodec dependency and make the code almost twice as > fast. More to come. > > The DCT factorization is based on "Fast and numerically stable > algorithms for discrete cosine transforms" from Gerlind Plonkaa & > Manfred Tasche (DOI: 10.1016/j.laa.2004.07.015). > --- > configure | 2 - > libavfilter/vf_dctdnoiz.c | 328 +++++++++++++++++++++++++++++++++------------- > 2 files changed, 240 insertions(+), 90 deletions(-) This change warrants a Changelog entry. > > diff --git a/configure b/configure > index 9c3af50..6196b2a 100755 > --- a/configure > +++ b/configure > @@ -2526,8 +2526,6 @@ boxblur_filter_deps="gpl" > bs2b_filter_deps="libbs2b" > colormatrix_filter_deps="gpl" > cropdetect_filter_deps="gpl" > -dctdnoiz_filter_deps="avcodec" > -dctdnoiz_filter_select="dct" > delogo_filter_deps="gpl" > deshake_filter_deps="avcodec" > deshake_filter_select="me_cmp" > diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c > index 71b8536..6d24934 100644 > --- a/libavfilter/vf_dctdnoiz.c > +++ b/libavfilter/vf_dctdnoiz.c > @@ -1,5 +1,5 @@ > /* > - * Copyright (c) 2013 Cl?ment B?sch > + * Copyright (c) 2013-2014 Cl?ment B?sch > * > * This file is part of FFmpeg. > * > @@ -23,7 +23,6 @@ > * @see http://www.ipol.im/pub/art/2011/ys-dct/ > */ > > -#include "libavcodec/avfft.h" > #include "libavutil/eval.h" > #include "libavutil/opt.h" > #include "drawutils.h" > @@ -35,7 +34,7 @@ > static const char *const var_names[] = { "c", NULL }; > enum { VAR_C, VAR_VARS_NB }; > > -typedef struct { > +typedef struct DCTdnoizContext { > const AVClass *class; > > /* coefficient factor expression */ > @@ -52,8 +51,9 @@ typedef struct { > int p_linesize; // line sizes for color and weights > int overlap; // number of block overlapping pixels > int step; // block step increment (BSIZE - overlap) > - DCTContext *dct, *idct; // DCT and inverse DCT contexts > - float *block, *tmp_block; // two BSIZE x BSIZE block buffers > + void (*filter_freq_func)(struct DCTdnoizContext *s, > + const float *src, int src_linesize, > + float *dst, int dst_linesize); > } DCTdnoizContext; > > #define OFFSET(x) offsetof(DCTdnoizContext, x) > @@ -69,66 +69,245 @@ static const AVOption dctdnoiz_options[] = { > > AVFILTER_DEFINE_CLASS(dctdnoiz); > > -static float *dct_block(DCTdnoizContext *ctx, const float *src, int src_linesize) > +static void av_always_inline fdct16_1d(float *dst, const float *src, > + int dst_stridea, int dst_strideb, > + int src_stridea, int src_strideb) > { > - int x, y; > - float *column; > - > - for (y = 0; y < BSIZE; y++) { > - float *line = ctx->block; > + int i; > > - memcpy(line, src, BSIZE * sizeof(*line)); > - src += src_linesize; > - av_dct_calc(ctx->dct, line); > - > - column = ctx->tmp_block + y; > - column[0] = line[0] * (1. / sqrt(BSIZE)); > - column += BSIZE; > - for (x = 1; x < BSIZE; x++) { > - *column = line[x] * sqrt(2. / BSIZE); > - column += BSIZE; > - } > + for (i = 0; i < BSIZE; i++) { > + const float x0_0 = src[ 0*src_stridea] + src[15*src_stridea]; > + const float x0_1 = src[ 1*src_stridea] + src[14*src_stridea]; > + const float x0_2 = src[ 2*src_stridea] + src[13*src_stridea]; > + const float x0_3 = src[ 3*src_stridea] + src[12*src_stridea]; > + const float x0_4 = src[ 4*src_stridea] + src[11*src_stridea]; > + const float x0_5 = src[ 5*src_stridea] + src[10*src_stridea]; > + const float x0_6 = src[ 6*src_stridea] + src[ 9*src_stridea]; > + const float x0_7 = src[ 7*src_stridea] + src[ 8*src_stridea]; > + const float x0_8 = src[ 0*src_stridea] - src[15*src_stridea]; > + const float x0_9 = src[ 1*src_stridea] - src[14*src_stridea]; > + const float x0_a = src[ 2*src_stridea] - src[13*src_stridea]; > + const float x0_b = src[ 3*src_stridea] - src[12*src_stridea]; > + const float x0_c = src[ 4*src_stridea] - src[11*src_stridea]; > + const float x0_d = src[ 5*src_stridea] - src[10*src_stridea]; > + const float x0_e = src[ 6*src_stridea] - src[ 9*src_stridea]; > + const float x0_f = src[ 7*src_stridea] - src[ 8*src_stridea]; > + const float x2_0 = x0_0 + x0_7; > + const float x2_1 = x0_1 + x0_6; > + const float x2_2 = x0_2 + x0_5; > + const float x2_3 = x0_3 + x0_4; > + const float x2_4 = x0_0 - x0_7; > + const float x2_5 = x0_1 - x0_6; > + const float x2_6 = x0_2 - x0_5; > + const float x2_7 = x0_3 - x0_4; > + const float x4_0 = x2_0 + x2_3; > + const float x4_1 = x2_1 + x2_2; > + const float x4_2 = x2_0 - x2_3; > + const float x4_3 = x2_1 - x2_2; > + const float x5_0 = x4_0 + x4_1; > + const float x5_1 = x4_0 - x4_1; > + const float x5_2 = 1.306562964876380*x4_2 + 0.541196100146197*x4_3; > + const float x5_3 = 0.541196100146197*x4_2 - 1.306562964876380*x4_3; > + const float x6_0 = 1.387039845322150*x2_4 + 0.275899379282943*x2_7; > + const float x6_1 = 1.175875602419360*x2_5 + 0.785694958387102*x2_6; > + const float x6_2 = -0.785694958387102*x2_5 + 1.175875602419360*x2_6; > + const float x6_3 = 0.275899379282943*x2_4 - 1.387039845322150*x2_7; > + const float x7_0 = x6_0 + x6_1; > + const float x7_1 = x6_0 - x6_1; > + const float x7_2 = x6_2 + x6_3; > + const float x7_3 = x6_2 - x6_3; > + const float x3_5 = 0.707106781186547*x7_1 - 0.707106781186547*x7_3; > + const float x3_6 = 0.707106781186547*x7_1 + 0.707106781186547*x7_3; > + const float x8_0 = 1.407403737526380*x0_8 + 0.138617169199091*x0_f; > + const float x8_1 = 1.353318001174350*x0_9 + 0.410524527522357*x0_e; > + const float x8_2 = 1.247225012986670*x0_a + 0.666655658477747*x0_d; > + const float x8_3 = 1.093201867001760*x0_b + 0.897167586342636*x0_c; > + const float x8_4 = -0.897167586342636*x0_b + 1.093201867001760*x0_c; > + const float x8_5 = 0.666655658477747*x0_a - 1.247225012986670*x0_d; > + const float x8_6 = -0.410524527522357*x0_9 + 1.353318001174350*x0_e; > + const float x8_7 = 0.138617169199091*x0_8 - 1.407403737526380*x0_f; > + const float xa_0 = x8_0 + x8_3; > + const float xa_1 = x8_1 + x8_2; > + const float xa_2 = x8_0 - x8_3; > + const float xa_3 = x8_1 - x8_2; > + const float xb_0 = xa_0 + xa_1; > + const float xb_1 = xa_0 - xa_1; > + const float xb_2 = 1.306562964876380*xa_2 + 0.541196100146197*xa_3; > + const float xb_3 = 0.541196100146197*xa_2 - 1.306562964876380*xa_3; > + const float xc_0 = x8_4 + x8_7; > + const float xc_1 = x8_5 + x8_6; > + const float xc_2 = x8_4 - x8_7; > + const float xc_3 = x8_5 - x8_6; > + const float xd_0 = xc_0 + xc_1; > + const float xd_1 = xc_0 - xc_1; > + const float xd_2 = 1.306562964876380*xc_2 + 0.541196100146197*xc_3; > + const float xd_3 = 0.541196100146197*xc_2 - 1.306562964876380*xc_3; > + const float x1_9 = 0.707106781186547*xb_2 - 0.707106781186547*xd_3; > + const float x1_a = 0.707106781186547*xb_2 + 0.707106781186547*xd_3; > + const float x1_b = 0.707106781186547*xb_1 + 0.707106781186547*xd_1; > + const float x1_c = 0.707106781186547*xb_1 - 0.707106781186547*xd_1; > + const float x1_d = 0.707106781186547*xb_3 - 0.707106781186547*xd_2; > + const float x1_e = 0.707106781186547*xb_3 + 0.707106781186547*xd_2; > + dst[ 0*dst_stridea] = 0.25*x5_0; > + dst[ 1*dst_stridea] = 0.25*xb_0; > + dst[ 2*dst_stridea] = 0.25*x7_0; > + dst[ 3*dst_stridea] = 0.25*x1_9; > + dst[ 4*dst_stridea] = 0.25*x5_2; > + dst[ 5*dst_stridea] = 0.25*x1_a; > + dst[ 6*dst_stridea] = 0.25*x3_5; > + dst[ 7*dst_stridea] = 0.25*x1_b; > + dst[ 8*dst_stridea] = 0.25*x5_1; > + dst[ 9*dst_stridea] = 0.25*x1_c; > + dst[10*dst_stridea] = 0.25*x3_6; > + dst[11*dst_stridea] = 0.25*x1_d; > + dst[12*dst_stridea] = 0.25*x5_3; > + dst[13*dst_stridea] = 0.25*x1_e; > + dst[14*dst_stridea] = 0.25*x7_2; > + dst[15*dst_stridea] = 0.25*xd_0; > + dst += dst_strideb; > + src += src_strideb; > } > +} > > - column = ctx->tmp_block; > - for (x = 0; x < BSIZE; x++) { > - av_dct_calc(ctx->dct, column); > - column[0] *= 1. / sqrt(BSIZE); > - for (y = 1; y < BSIZE; y++) > - column[y] *= sqrt(2. / BSIZE); > - column += BSIZE; > +static void av_always_inline idct16_1d(float *dst, const float *src, > + int dst_stridea, int dst_strideb, > + int src_stridea, int src_strideb, > + int add) > +{ > + int i; > + > + for (i = 0; i < BSIZE; i++) { > + const float x0_0 = 1.414213562373100*src[ 0*src_stridea]; > + const float x0_1 = 1.407403737526380*src[ 1*src_stridea] + 0.138617169199091*src[15*src_stridea]; > + const float x0_2 = 1.387039845322150*src[ 2*src_stridea] + 0.275899379282943*src[14*src_stridea]; > + const float x0_3 = 1.353318001174350*src[ 3*src_stridea] + 0.410524527522357*src[13*src_stridea]; > + const float x0_4 = 1.306562964876380*src[ 4*src_stridea] + 0.541196100146197*src[12*src_stridea]; > + const float x0_5 = 1.247225012986670*src[ 5*src_stridea] + 0.666655658477747*src[11*src_stridea]; > + const float x0_6 = 1.175875602419360*src[ 6*src_stridea] + 0.785694958387102*src[10*src_stridea]; > + const float x0_7 = 1.093201867001760*src[ 7*src_stridea] + 0.897167586342636*src[ 9*src_stridea]; > + const float x0_8 = 1.414213562373100*src[ 8*src_stridea]; > + const float x0_9 = -0.897167586342636*src[ 7*src_stridea] + 1.093201867001760*src[ 9*src_stridea]; > + const float x0_a = 0.785694958387102*src[ 6*src_stridea] - 1.175875602419360*src[10*src_stridea]; > + const float x0_b = -0.666655658477747*src[ 5*src_stridea] + 1.247225012986670*src[11*src_stridea]; > + const float x0_c = 0.541196100146197*src[ 4*src_stridea] - 1.306562964876380*src[12*src_stridea]; > + const float x0_d = -0.410524527522357*src[ 3*src_stridea] + 1.353318001174350*src[13*src_stridea]; > + const float x0_e = 0.275899379282943*src[ 2*src_stridea] - 1.387039845322150*src[14*src_stridea]; > + const float x0_f = -0.138617169199091*src[ 1*src_stridea] + 1.407403737526380*src[15*src_stridea]; > + const float x2_0 = x0_0 + x0_8; > + const float x2_1 = x0_1 + x0_7; > + const float x2_2 = x0_2 + x0_6; > + const float x2_3 = x0_3 + x0_5; > + const float x2_4 = 1.4142135623731*x0_4; > + const float x2_5 = x0_0 - x0_8; > + const float x2_6 = x0_1 - x0_7; > + const float x2_7 = x0_2 - x0_6; > + const float x2_8 = x0_3 - x0_5; > + const float x4_0 = x2_0 + x2_4; > + const float x4_1 = x2_1 + x2_3; > + const float x4_2 = 1.4142135623731*x2_2; > + const float x4_3 = x2_0 - x2_4; > + const float x4_4 = x2_1 - x2_3; > + const float x5_0 = 0.5*x4_0 + 0.707106781186548*x4_1 + 0.5*x4_2; > + const float x5_1 = 0.707106781186548*x4_0 - 0.707106781186548*x4_2; > + const float x5_2 = 0.5*x4_0 - 0.707106781186548*x4_1 + 0.5*x4_2; > + const float x5_3 = 0.707106781186547*x4_3 + 0.707106781186547*x4_4; > + const float x5_4 = 0.707106781186547*x4_3 - 0.707106781186547*x4_4; > + const float x6_0 = 1.4142135623731*x2_5; > + const float x6_1 = 1.30656296487638*x2_6 + 0.541196100146197*x2_8; > + const float x6_2 = 1.4142135623731*x2_7; > + const float x6_3 = -0.541196100146197*x2_6 + 1.30656296487638*x2_8; > + const float x7_0 = 0.5*x6_0 + 0.707106781186548*x6_1 + 0.5*x6_2; > + const float x7_1 = 0.707106781186548*x6_0 - 0.707106781186548*x6_2; > + const float x7_2 = 0.5*x6_0 - 0.707106781186548*x6_1 + 0.5*x6_2; > + const float x3_6 = 0.707106781186547*x7_1 - 0.707106781186547*x6_3; > + const float x3_7 = 0.707106781186547*x7_1 + 0.707106781186547*x6_3; > + const float x8_0 = 1.4142135623731*x0_c; > + const float x8_1 = x0_b + x0_d; > + const float x8_2 = x0_a + x0_e; > + const float x8_3 = x0_9 + x0_f; > + const float x8_4 = x0_9 - x0_f; > + const float x8_5 = x0_a - x0_e; > + const float x8_6 = x0_b - x0_d; > + const float xa_0 = 1.4142135623731*x8_0; > + const float xa_1 = 1.30656296487638*x8_1 + 0.541196100146197*x8_3; > + const float xa_2 = 1.4142135623731*x8_2; > + const float xa_3 = -0.541196100146197*x8_1 + 1.30656296487638*x8_3; > + const float xb_0 = 0.5*xa_0 + 0.707106781186548*xa_1 + 0.5*xa_2; > + const float xb_1 = 0.707106781186548*xa_0 - 0.707106781186548*xa_2; > + const float xb_2 = 0.5*xa_0 - 0.707106781186548*xa_1 + 0.5*xa_2; > + const float x9_1 = 0.707106781186547*xb_1 - 0.707106781186547*xa_3; > + const float x9_2 = 0.707106781186547*xb_1 + 0.707106781186547*xa_3; > + const float xc_0 = 1.4142135623731*x8_5; > + const float xc_1 = x8_4 + x8_6; > + const float xc_2 = x8_4 - x8_6; > + const float xd_0 = 0.707106781186547*xc_0 + 0.707106781186547*xc_1; > + const float xd_1 = 0.707106781186547*xc_0 - 0.707106781186547*xc_1; > + const float x9_6 = -xd_1; > + const float x1_b = -x9_1; > + const float x1_f = -xb_2; > + dst[ 0*dst_stridea] = (add ? dst[ 0*dst_stridea] : 0) + 0.353553390593274*x5_0; > + dst[ 1*dst_stridea] = (add ? dst[ 1*dst_stridea] : 0) + 0.25*x7_0 - 0.25*x1_f; > + dst[ 2*dst_stridea] = (add ? dst[ 2*dst_stridea] : 0) + 0.25*x7_0 + 0.25*x1_f; > + dst[ 3*dst_stridea] = (add ? dst[ 3*dst_stridea] : 0) + 0.25*x5_3 + 0.25*x9_6; > + dst[ 4*dst_stridea] = (add ? dst[ 4*dst_stridea] : 0) + 0.25*x5_3 - 0.25*x9_6; > + dst[ 5*dst_stridea] = (add ? dst[ 5*dst_stridea] : 0) + 0.25*x3_6 - 0.25*x9_2; > + dst[ 6*dst_stridea] = (add ? dst[ 6*dst_stridea] : 0) + 0.25*x3_6 + 0.25*x9_2; > + dst[ 7*dst_stridea] = (add ? dst[ 7*dst_stridea] : 0) + 0.25*x5_1 + 0.25*xc_2; > + dst[ 8*dst_stridea] = (add ? dst[ 8*dst_stridea] : 0) + 0.25*x5_1 - 0.25*xc_2; > + dst[ 9*dst_stridea] = (add ? dst[ 9*dst_stridea] : 0) + 0.25*x3_7 - 0.25*x1_b; > + dst[10*dst_stridea] = (add ? dst[10*dst_stridea] : 0) + 0.25*x3_7 + 0.25*x1_b; > + dst[11*dst_stridea] = (add ? dst[11*dst_stridea] : 0) + 0.25*x5_4 + 0.25*xd_0; > + dst[12*dst_stridea] = (add ? dst[12*dst_stridea] : 0) + 0.25*x5_4 - 0.25*xd_0; > + dst[13*dst_stridea] = (add ? dst[13*dst_stridea] : 0) + 0.25*x7_2 - 0.25*xb_0; > + dst[14*dst_stridea] = (add ? dst[14*dst_stridea] : 0) + 0.25*x7_2 + 0.25*xb_0; > + dst[15*dst_stridea] = (add ? dst[15*dst_stridea] : 0) + 0.353553390593274*x5_2; > + dst += dst_strideb; > + src += src_strideb; > } > +} > > - for (y = 0; y < BSIZE; y++) > - for (x = 0; x < BSIZE; x++) > - ctx->block[y*BSIZE + x] = ctx->tmp_block[x*BSIZE + y]; > +static av_always_inline void filter_freq(const float *src, int src_linesize, > + float *dst, int dst_linesize, > + AVExpr *expr, double *var_values, > + int sigma_th) > +{ > + unsigned i; > + DECLARE_ALIGNED(32, float, tmp_block1)[BSIZE * BSIZE]; > + DECLARE_ALIGNED(32, float, tmp_block2)[BSIZE * BSIZE]; > + > + /* forward DCT */ > + fdct16_1d(tmp_block1, src, 1, BSIZE, 1, src_linesize); > + fdct16_1d(tmp_block2, tmp_block1, BSIZE, 1, BSIZE, 1); > + > + for (i = 0; i < BSIZE*BSIZE; i++) { > + float *b = &tmp_block2[i]; > + /* frequency filtering */ > + if (expr) { > + var_values[VAR_C] = FFABS(*b); > + *b *= av_expr_eval(expr, var_values, NULL); > + } else { > + if (FFABS(*b) < sigma_th) > + *b = 0; > + } > + } > > - return ctx->block; > + /* inverse DCT */ > + idct16_1d(tmp_block1, tmp_block2, 1, BSIZE, 1, BSIZE, 0); > + idct16_1d(dst, tmp_block1, dst_linesize, 1, BSIZE, 1, 1); > } > > -static void idct_block(DCTdnoizContext *ctx, float *dst, int dst_linesize) > +static void filter_freq_sigma(DCTdnoizContext *s, > + const float *src, int src_linesize, > + float *dst, int dst_linesize) > { > - int x, y; > - float *block = ctx->block; > - float *tmp = ctx->tmp_block; > - > - for (y = 0; y < BSIZE; y++) { > - block[0] *= sqrt(BSIZE); > - for (x = 1; x < BSIZE; x++) > - block[x] *= 1./sqrt(2. / BSIZE); > - av_dct_calc(ctx->idct, block); > - block += BSIZE; > - } > + filter_freq(src, src_linesize, dst, dst_linesize, NULL, NULL, s->th); > +} > > - block = ctx->block; > - for (y = 0; y < BSIZE; y++) { > - tmp[0] = block[y] * sqrt(BSIZE); > - for (x = 1; x < BSIZE; x++) > - tmp[x] = block[x*BSIZE + y] * (1./sqrt(2. / BSIZE)); > - av_dct_calc(ctx->idct, tmp); > - for (x = 0; x < BSIZE; x++) > - dst[x*dst_linesize + y] += tmp[x]; > - } > +static void filter_freq_expr(DCTdnoizContext *s, > + const float *src, int src_linesize, > + float *dst, int dst_linesize) > +{ > + filter_freq(src, src_linesize, dst, dst_linesize, s->expr, s->var_values, 0); > } > > static int config_input(AVFilterLink *inlink) > @@ -194,18 +373,13 @@ static av_cold int init(AVFilterContext *ctx) > NULL, NULL, NULL, NULL, 0, ctx); > if (ret < 0) > return ret; > + s->filter_freq_func = filter_freq_expr; > + } else { > + s->filter_freq_func = filter_freq_sigma; > } Missing "if (s->expr)"? > > s->th = s->sigma * 3.; > s->step = BSIZE - s->overlap; > - s->dct = av_dct_init(NBITS, DCT_II); > - s->idct = av_dct_init(NBITS, DCT_III); > - s->block = av_malloc(BSIZE * BSIZE * sizeof(*s->block)); > - s->tmp_block = av_malloc(BSIZE * BSIZE * sizeof(*s->tmp_block)); > - > - if (!s->dct || !s->idct || !s->tmp_block || !s->block) > - return AVERROR(ENOMEM); > - > return 0; > } > > @@ -272,7 +446,7 @@ static void filter_plane(AVFilterContext *ctx, > const float *src, int src_linesize, > int w, int h) > { > - int x, y, bx, by; > + int x, y; > DCTdnoizContext *s = ctx->priv; > float *dst0 = dst; > const float *weights = s->weights; > @@ -282,27 +456,9 @@ static void filter_plane(AVFilterContext *ctx, > > // block dct sums > for (y = 0; y < h - BSIZE + 1; y += s->step) { > - for (x = 0; x < w - BSIZE + 1; x += s->step) { > - float *ftb = dct_block(s, src + x, src_linesize); > - > - if (s->expr) { > - for (by = 0; by < BSIZE; by++) { > - for (bx = 0; bx < BSIZE; bx++) { > - s->var_values[VAR_C] = FFABS(*ftb); > - *ftb++ *= av_expr_eval(s->expr, s->var_values, s); > - } > - } > - } else { > - for (by = 0; by < BSIZE; by++) { > - for (bx = 0; bx < BSIZE; bx++) { > - if (FFABS(*ftb) < s->th) > - *ftb = 0; > - ftb++; > - } > - } > - } > - idct_block(s, dst + x, dst_linesize); > - } > + for (x = 0; x < w - BSIZE + 1; x += s->step) > + s->filter_freq_func(s, src + x, src_linesize, > + dst + x, dst_linesize); > src += s->step * src_linesize; > dst += s->step * dst_linesize; > } > @@ -388,10 +544,6 @@ static av_cold void uninit(AVFilterContext *ctx) > int i; > DCTdnoizContext *s = ctx->priv; > > - av_dct_end(s->dct); > - av_dct_end(s->idct); > - av_free(s->block); > - av_free(s->tmp_block); > av_free(s->weights); > for (i = 0; i < 2; i++) { > av_free(s->cbuf[i][0]); > -- > 2.0.2 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From michaelni at gmx.at Sun Aug 3 23:10:54 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 23:10:54 +0200 Subject: [FFmpeg-devel] [PATCH] lavfi/avf_showspectrum: check RDFT contet init. In-Reply-To: <1407091236-20302-1-git-send-email-george@nsup.org> References: <1407091236-20302-1-git-send-email-george@nsup.org> Message-ID: <20140803211054.GH4649@nb4> On Sun, Aug 03, 2014 at 08:40:36PM +0200, Nicolas George wrote: > Fix a segfault with large window size. > > Signed-off-by: Nicolas George > --- > libavfilter/avf_showspectrum.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c > index 7bf3aab..764a000 100644 > --- a/libavfilter/avf_showspectrum.c > +++ b/libavfilter/avf_showspectrum.c > @@ -177,6 +177,11 @@ static int config_output(AVFilterLink *outlink) > > av_rdft_end(s->rdft); > s->rdft = av_rdft_init(rdft_bits, DFT_R2C); > + if (!s->rdft) { > + av_log(ctx, AV_LOG_ERROR, "Unable to allocate RDFT context. " > + "Maybe window too high.\n"); > + return AVERROR(EINVAL); > + } idependant of the exact error code LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 1 "Used only once" - "Some unspecified defect prevented a second use" "In good condition" - "Can be repaird by experienced expert" "As is" - "You wouldnt want it even if you were payed for it, if you knew ..." -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 3 23:44:33 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 23:44:33 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec/avdct: Add get_pixels() In-Reply-To: <1407006356-14253-1-git-send-email-michaelni@gmx.at> References: <1407006356-14253-1-git-send-email-michaelni@gmx.at> Message-ID: <20140803214433.GI4649@nb4> On Sat, Aug 02, 2014 at 09:05:56PM +0200, Michael Niedermayer wrote: > TODO: version bump, update libavfilters to use it > > Suggested-by: ubitux > Signed-off-by: Michael Niedermayer > --- > libavcodec/avdct.c | 9 +++++++++ > libavcodec/avdct.h | 4 ++++ > 2 files changed, 13 insertions(+) applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 1 "Used only once" - "Some unspecified defect prevented a second use" "In good condition" - "Can be repaird by experienced expert" "As is" - "You wouldnt want it even if you were payed for it, if you knew ..." -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From epirat07 at gmail.com Sun Aug 3 23:53:21 2014 From: epirat07 at gmail.com (Marvin Scholz) Date: Sun, 03 Aug 2014 23:53:21 +0200 Subject: [FFmpeg-devel] [PATCH] libavformat/icecast.c Add Icecast protocol In-Reply-To: <20140802220022.GO10372@leki> References: <20140723010618.GV4649@nb4> <1406536579-22310-1-git-send-email-epirat07@gmail.com> <20140802220022.GO10372@leki> Message-ID: <6C302C95-F0A0-4F29-8EA6-532469E9DBA8@gmail.com> >> + if (user) >> + av_freep(&user); >> + if (headers) >> + av_freep(&headers); > > pointless ifs I'm pretty sure I need it, since there are possible cases where these are not allocated and I can't free them. From michaelni at gmx.at Sun Aug 3 23:56:48 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 3 Aug 2014 23:56:48 +0200 Subject: [FFmpeg-devel] [PATCH] libavformat/icecast.c Add Icecast protocol In-Reply-To: <6C302C95-F0A0-4F29-8EA6-532469E9DBA8@gmail.com> References: <20140723010618.GV4649@nb4> <1406536579-22310-1-git-send-email-epirat07@gmail.com> <20140802220022.GO10372@leki> <6C302C95-F0A0-4F29-8EA6-532469E9DBA8@gmail.com> Message-ID: <20140803215648.GJ4649@nb4> On Sun, Aug 03, 2014 at 11:53:21PM +0200, Marvin Scholz wrote: > >>+ if (user) > >>+ av_freep(&user); > >>+ if (headers) > >>+ av_freep(&headers); > > > >pointless ifs > > I'm pretty sure I need it, since there are possible cases where > these are not allocated and I can't free them. av_freep() should be safe to be used with NULL [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB There will always be a question for which you do not know the correct answer. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From epirat07 at gmail.com Mon Aug 4 00:24:27 2014 From: epirat07 at gmail.com (Marvin Scholz) Date: Mon, 04 Aug 2014 00:24:27 +0200 Subject: [FFmpeg-devel] [PATCH] libavformat/icecast.c Add Icecast protocol In-Reply-To: <20140803215648.GJ4649@nb4> References: <20140723010618.GV4649@nb4> <1406536579-22310-1-git-send-email-epirat07@gmail.com> <20140802220022.GO10372@leki> <6C302C95-F0A0-4F29-8EA6-532469E9DBA8@gmail.com> <20140803215648.GJ4649@nb4> Message-ID: <8D9868C0-AC9E-4071-87CF-C9498F833F05@gmail.com> > av_freep() should be safe to be used with NULL Since av_freep takes a pointer I am nearly sure that it doesn't, at least I remember that I had some issues without the if's? But please correct me if I'm wrong. From michaelni at gmx.at Mon Aug 4 00:44:48 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 00:44:48 +0200 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: rewrite [f/i]dct In-Reply-To: <1407097641-26789-1-git-send-email-u@pkh.me> References: <1407097641-26789-1-git-send-email-u@pkh.me> Message-ID: <20140803224448.GK4649@nb4> On Sun, Aug 03, 2014 at 10:27:21PM +0200, Cl?ment B?sch wrote: > This removes the avcodec dependency and make the code almost twice as > fast. More to come. > > The DCT factorization is based on "Fast and numerically stable > algorithms for discrete cosine transforms" from Gerlind Plonkaa & > Manfred Tasche (DOI: 10.1016/j.laa.2004.07.015). > --- > configure | 2 - > libavfilter/vf_dctdnoiz.c | 328 +++++++++++++++++++++++++++++++++------------- > 2 files changed, 240 insertions(+), 90 deletions(-) > > diff --git a/configure b/configure > index 9c3af50..6196b2a 100755 > --- a/configure > +++ b/configure > @@ -2526,8 +2526,6 @@ boxblur_filter_deps="gpl" > bs2b_filter_deps="libbs2b" > colormatrix_filter_deps="gpl" > cropdetect_filter_deps="gpl" > -dctdnoiz_filter_deps="avcodec" > -dctdnoiz_filter_select="dct" > delogo_filter_deps="gpl" > deshake_filter_deps="avcodec" > deshake_filter_select="me_cmp" > diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c > index 71b8536..6d24934 100644 > --- a/libavfilter/vf_dctdnoiz.c > +++ b/libavfilter/vf_dctdnoiz.c > @@ -1,5 +1,5 @@ > /* > - * Copyright (c) 2013 Cl?ment B?sch > + * Copyright (c) 2013-2014 Cl?ment B?sch > * > * This file is part of FFmpeg. > * > @@ -23,7 +23,6 @@ > * @see http://www.ipol.im/pub/art/2011/ys-dct/ > */ > > -#include "libavcodec/avfft.h" > #include "libavutil/eval.h" > #include "libavutil/opt.h" > #include "drawutils.h" > @@ -35,7 +34,7 @@ > static const char *const var_names[] = { "c", NULL }; > enum { VAR_C, VAR_VARS_NB }; > > -typedef struct { > +typedef struct DCTdnoizContext { > const AVClass *class; > > /* coefficient factor expression */ > @@ -52,8 +51,9 @@ typedef struct { > int p_linesize; // line sizes for color and weights > int overlap; // number of block overlapping pixels > int step; // block step increment (BSIZE - overlap) > - DCTContext *dct, *idct; // DCT and inverse DCT contexts > - float *block, *tmp_block; // two BSIZE x BSIZE block buffers > + void (*filter_freq_func)(struct DCTdnoizContext *s, > + const float *src, int src_linesize, > + float *dst, int dst_linesize); > } DCTdnoizContext; > > #define OFFSET(x) offsetof(DCTdnoizContext, x) > @@ -69,66 +69,245 @@ static const AVOption dctdnoiz_options[] = { > > AVFILTER_DEFINE_CLASS(dctdnoiz); > > -static float *dct_block(DCTdnoizContext *ctx, const float *src, int src_linesize) > +static void av_always_inline fdct16_1d(float *dst, const float *src, > + int dst_stridea, int dst_strideb, > + int src_stridea, int src_strideb) > { > - int x, y; > - float *column; > - > - for (y = 0; y < BSIZE; y++) { > - float *line = ctx->block; > + int i; > > - memcpy(line, src, BSIZE * sizeof(*line)); > - src += src_linesize; > - av_dct_calc(ctx->dct, line); > - > - column = ctx->tmp_block + y; > - column[0] = line[0] * (1. / sqrt(BSIZE)); > - column += BSIZE; > - for (x = 1; x < BSIZE; x++) { > - *column = line[x] * sqrt(2. / BSIZE); > - column += BSIZE; > - } > + for (i = 0; i < BSIZE; i++) { > + const float x0_0 = src[ 0*src_stridea] + src[15*src_stridea]; > + const float x0_1 = src[ 1*src_stridea] + src[14*src_stridea]; > + const float x0_2 = src[ 2*src_stridea] + src[13*src_stridea]; > + const float x0_3 = src[ 3*src_stridea] + src[12*src_stridea]; > + const float x0_4 = src[ 4*src_stridea] + src[11*src_stridea]; > + const float x0_5 = src[ 5*src_stridea] + src[10*src_stridea]; > + const float x0_6 = src[ 6*src_stridea] + src[ 9*src_stridea]; > + const float x0_7 = src[ 7*src_stridea] + src[ 8*src_stridea]; > + const float x0_8 = src[ 0*src_stridea] - src[15*src_stridea]; > + const float x0_9 = src[ 1*src_stridea] - src[14*src_stridea]; > + const float x0_a = src[ 2*src_stridea] - src[13*src_stridea]; > + const float x0_b = src[ 3*src_stridea] - src[12*src_stridea]; > + const float x0_c = src[ 4*src_stridea] - src[11*src_stridea]; > + const float x0_d = src[ 5*src_stridea] - src[10*src_stridea]; > + const float x0_e = src[ 6*src_stridea] - src[ 9*src_stridea]; > + const float x0_f = src[ 7*src_stridea] - src[ 8*src_stridea]; > + const float x2_0 = x0_0 + x0_7; > + const float x2_1 = x0_1 + x0_6; > + const float x2_2 = x0_2 + x0_5; > + const float x2_3 = x0_3 + x0_4; > + const float x2_4 = x0_0 - x0_7; > + const float x2_5 = x0_1 - x0_6; > + const float x2_6 = x0_2 - x0_5; > + const float x2_7 = x0_3 - x0_4; > + const float x4_0 = x2_0 + x2_3; > + const float x4_1 = x2_1 + x2_2; > + const float x4_2 = x2_0 - x2_3; > + const float x4_3 = x2_1 - x2_2; > + const float x5_0 = x4_0 + x4_1; > + const float x5_1 = x4_0 - x4_1; > + const float x5_2 = 1.306562964876380*x4_2 + 0.541196100146197*x4_3; > + const float x5_3 = 0.541196100146197*x4_2 - 1.306562964876380*x4_3; > + const float x6_0 = 1.387039845322150*x2_4 + 0.275899379282943*x2_7; > + const float x6_1 = 1.175875602419360*x2_5 + 0.785694958387102*x2_6; > + const float x6_2 = -0.785694958387102*x2_5 + 1.175875602419360*x2_6; > + const float x6_3 = 0.275899379282943*x2_4 - 1.387039845322150*x2_7; > + const float x7_0 = x6_0 + x6_1; > + const float x7_1 = x6_0 - x6_1; > + const float x7_2 = x6_2 + x6_3; > + const float x7_3 = x6_2 - x6_3; > + const float x3_5 = 0.707106781186547*x7_1 - 0.707106781186547*x7_3; > + const float x3_6 = 0.707106781186547*x7_1 + 0.707106781186547*x7_3; > + const float x8_0 = 1.407403737526380*x0_8 + 0.138617169199091*x0_f; > + const float x8_1 = 1.353318001174350*x0_9 + 0.410524527522357*x0_e; > + const float x8_2 = 1.247225012986670*x0_a + 0.666655658477747*x0_d; > + const float x8_3 = 1.093201867001760*x0_b + 0.897167586342636*x0_c; > + const float x8_4 = -0.897167586342636*x0_b + 1.093201867001760*x0_c; > + const float x8_5 = 0.666655658477747*x0_a - 1.247225012986670*x0_d; > + const float x8_6 = -0.410524527522357*x0_9 + 1.353318001174350*x0_e; > + const float x8_7 = 0.138617169199091*x0_8 - 1.407403737526380*x0_f; > + const float xa_0 = x8_0 + x8_3; > + const float xa_1 = x8_1 + x8_2; > + const float xa_2 = x8_0 - x8_3; > + const float xa_3 = x8_1 - x8_2; > + const float xb_0 = xa_0 + xa_1; > + const float xb_1 = xa_0 - xa_1; > + const float xb_2 = 1.306562964876380*xa_2 + 0.541196100146197*xa_3; > + const float xb_3 = 0.541196100146197*xa_2 - 1.306562964876380*xa_3; > + const float xc_0 = x8_4 + x8_7; > + const float xc_1 = x8_5 + x8_6; > + const float xc_2 = x8_4 - x8_7; > + const float xc_3 = x8_5 - x8_6; > + const float xd_0 = xc_0 + xc_1; > + const float xd_1 = xc_0 - xc_1; > + const float xd_2 = 1.306562964876380*xc_2 + 0.541196100146197*xc_3; > + const float xd_3 = 0.541196100146197*xc_2 - 1.306562964876380*xc_3; > + const float x1_9 = 0.707106781186547*xb_2 - 0.707106781186547*xd_3; > + const float x1_a = 0.707106781186547*xb_2 + 0.707106781186547*xd_3; > + const float x1_b = 0.707106781186547*xb_1 + 0.707106781186547*xd_1; > + const float x1_c = 0.707106781186547*xb_1 - 0.707106781186547*xd_1; > + const float x1_d = 0.707106781186547*xb_3 - 0.707106781186547*xd_2; > + const float x1_e = 0.707106781186547*xb_3 + 0.707106781186547*xd_2; > + dst[ 0*dst_stridea] = 0.25*x5_0; > + dst[ 1*dst_stridea] = 0.25*xb_0; > + dst[ 2*dst_stridea] = 0.25*x7_0; > + dst[ 3*dst_stridea] = 0.25*x1_9; > + dst[ 4*dst_stridea] = 0.25*x5_2; > + dst[ 5*dst_stridea] = 0.25*x1_a; > + dst[ 6*dst_stridea] = 0.25*x3_5; > + dst[ 7*dst_stridea] = 0.25*x1_b; > + dst[ 8*dst_stridea] = 0.25*x5_1; > + dst[ 9*dst_stridea] = 0.25*x1_c; > + dst[10*dst_stridea] = 0.25*x3_6; > + dst[11*dst_stridea] = 0.25*x1_d; > + dst[12*dst_stridea] = 0.25*x5_3; > + dst[13*dst_stridea] = 0.25*x1_e; > + dst[14*dst_stridea] = 0.25*x7_2; > + dst[15*dst_stridea] = 0.25*xd_0; many of these multiplies look like they can be merged into other multiplies for example see: const float xd_2 = 1.306562964876380*xc_2 + 0.541196100146197*xc_3; const float xb_3 = 0.541196100146197*xa_2 - 1.306562964876380*xa_3; const float x1_d = 0.707106781186547*xb_3 - 0.707106781186547*xd_2; const float x1_e = 0.707106781186547*xb_3 + 0.707106781186547*xd_2; dst[11*dst_stridea] = 0.25*x1_d; dst[13*dst_stridea] = 0.25*x1_e; vs. const float xd_2 = (0.25*0.707106781186547*1.306562964876380)*xc_2 + (0.25*0.707106781186547*0.541196100146197)*xc_3; const float xb_3 = (0.25*0.707106781186547*0.541196100146197)*xa_2 - (0.25*0.707106781186547*1.306562964876380)*xa_3; dst[11*dst_stridea] = xb_3 - xd_2; dst[13*dst_stridea] = xb_3 + xd_2; [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is what and why we do it that matters, not just one of them. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 4 00:51:46 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 00:51:46 +0200 Subject: [FFmpeg-devel] [PATCH] libavformat/icecast.c Add Icecast protocol In-Reply-To: <8D9868C0-AC9E-4071-87CF-C9498F833F05@gmail.com> References: <20140723010618.GV4649@nb4> <1406536579-22310-1-git-send-email-epirat07@gmail.com> <20140802220022.GO10372@leki> <6C302C95-F0A0-4F29-8EA6-532469E9DBA8@gmail.com> <20140803215648.GJ4649@nb4> <8D9868C0-AC9E-4071-87CF-C9498F833F05@gmail.com> Message-ID: <20140803225146.GL4649@nb4> On Mon, Aug 04, 2014 at 12:24:27AM +0200, Marvin Scholz wrote: > >av_freep() should be safe to be used with NULL > > Since av_freep takes a pointer I am nearly sure that it doesn't, at > least I remember that I had some issues without the if's? But please > correct me if I'm wrong. in the quoted code you pass the address of a pointer to av_freep() the address of a pointer is never NULL. The check checks if the pointer is NULL, which is passed to free() POSIX, says about free() that "If ptr is a null pointer, no action shall occur." http://pubs.opengroup.org/onlinepubs/9699919799/functions/free.html ill make sure this is explicitly mentioned for av_freep() and not just av_free() [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB it is not once nor twice but times without number that the same ideas make their appearance in the world. -- Aristotle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 4 01:14:37 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 01:14:37 +0200 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: rewrite [f/i]dct In-Reply-To: <20140803224448.GK4649@nb4> References: <1407097641-26789-1-git-send-email-u@pkh.me> <20140803224448.GK4649@nb4> Message-ID: <20140803231437.GM4649@nb4> On Mon, Aug 04, 2014 at 12:44:48AM +0200, Michael Niedermayer wrote: > On Sun, Aug 03, 2014 at 10:27:21PM +0200, Cl?ment B?sch wrote: > > This removes the avcodec dependency and make the code almost twice as > > fast. More to come. > > > > The DCT factorization is based on "Fast and numerically stable > > algorithms for discrete cosine transforms" from Gerlind Plonkaa & > > Manfred Tasche (DOI: 10.1016/j.laa.2004.07.015). > > --- > > configure | 2 - > > libavfilter/vf_dctdnoiz.c | 328 +++++++++++++++++++++++++++++++++------------- > > 2 files changed, 240 insertions(+), 90 deletions(-) > > > > diff --git a/configure b/configure > > index 9c3af50..6196b2a 100755 > > --- a/configure > > +++ b/configure > > @@ -2526,8 +2526,6 @@ boxblur_filter_deps="gpl" > > bs2b_filter_deps="libbs2b" > > colormatrix_filter_deps="gpl" > > cropdetect_filter_deps="gpl" > > -dctdnoiz_filter_deps="avcodec" > > -dctdnoiz_filter_select="dct" > > delogo_filter_deps="gpl" > > deshake_filter_deps="avcodec" > > deshake_filter_select="me_cmp" > > diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c > > index 71b8536..6d24934 100644 > > --- a/libavfilter/vf_dctdnoiz.c > > +++ b/libavfilter/vf_dctdnoiz.c > > @@ -1,5 +1,5 @@ > > /* > > - * Copyright (c) 2013 Cl?ment B?sch > > + * Copyright (c) 2013-2014 Cl?ment B?sch > > * > > * This file is part of FFmpeg. > > * > > @@ -23,7 +23,6 @@ > > * @see http://www.ipol.im/pub/art/2011/ys-dct/ > > */ > > > > -#include "libavcodec/avfft.h" > > #include "libavutil/eval.h" > > #include "libavutil/opt.h" > > #include "drawutils.h" > > @@ -35,7 +34,7 @@ > > static const char *const var_names[] = { "c", NULL }; > > enum { VAR_C, VAR_VARS_NB }; > > > > -typedef struct { > > +typedef struct DCTdnoizContext { > > const AVClass *class; > > > > /* coefficient factor expression */ > > @@ -52,8 +51,9 @@ typedef struct { > > int p_linesize; // line sizes for color and weights > > int overlap; // number of block overlapping pixels > > int step; // block step increment (BSIZE - overlap) > > - DCTContext *dct, *idct; // DCT and inverse DCT contexts > > - float *block, *tmp_block; // two BSIZE x BSIZE block buffers > > + void (*filter_freq_func)(struct DCTdnoizContext *s, > > + const float *src, int src_linesize, > > + float *dst, int dst_linesize); > > } DCTdnoizContext; > > > > #define OFFSET(x) offsetof(DCTdnoizContext, x) > > @@ -69,66 +69,245 @@ static const AVOption dctdnoiz_options[] = { > > > > AVFILTER_DEFINE_CLASS(dctdnoiz); > > > > -static float *dct_block(DCTdnoizContext *ctx, const float *src, int src_linesize) > > +static void av_always_inline fdct16_1d(float *dst, const float *src, > > + int dst_stridea, int dst_strideb, > > + int src_stridea, int src_strideb) > > { > > - int x, y; > > - float *column; > > - > > - for (y = 0; y < BSIZE; y++) { > > - float *line = ctx->block; > > + int i; > > > > - memcpy(line, src, BSIZE * sizeof(*line)); > > - src += src_linesize; > > - av_dct_calc(ctx->dct, line); > > - > > - column = ctx->tmp_block + y; > > - column[0] = line[0] * (1. / sqrt(BSIZE)); > > - column += BSIZE; > > - for (x = 1; x < BSIZE; x++) { > > - *column = line[x] * sqrt(2. / BSIZE); > > - column += BSIZE; > > - } > > + for (i = 0; i < BSIZE; i++) { > > + const float x0_0 = src[ 0*src_stridea] + src[15*src_stridea]; > > + const float x0_1 = src[ 1*src_stridea] + src[14*src_stridea]; > > + const float x0_2 = src[ 2*src_stridea] + src[13*src_stridea]; > > + const float x0_3 = src[ 3*src_stridea] + src[12*src_stridea]; > > + const float x0_4 = src[ 4*src_stridea] + src[11*src_stridea]; > > + const float x0_5 = src[ 5*src_stridea] + src[10*src_stridea]; > > + const float x0_6 = src[ 6*src_stridea] + src[ 9*src_stridea]; > > + const float x0_7 = src[ 7*src_stridea] + src[ 8*src_stridea]; > > + const float x0_8 = src[ 0*src_stridea] - src[15*src_stridea]; > > + const float x0_9 = src[ 1*src_stridea] - src[14*src_stridea]; > > + const float x0_a = src[ 2*src_stridea] - src[13*src_stridea]; > > + const float x0_b = src[ 3*src_stridea] - src[12*src_stridea]; > > + const float x0_c = src[ 4*src_stridea] - src[11*src_stridea]; > > + const float x0_d = src[ 5*src_stridea] - src[10*src_stridea]; > > + const float x0_e = src[ 6*src_stridea] - src[ 9*src_stridea]; > > + const float x0_f = src[ 7*src_stridea] - src[ 8*src_stridea]; > > + const float x2_0 = x0_0 + x0_7; > > + const float x2_1 = x0_1 + x0_6; > > + const float x2_2 = x0_2 + x0_5; > > + const float x2_3 = x0_3 + x0_4; > > + const float x2_4 = x0_0 - x0_7; > > + const float x2_5 = x0_1 - x0_6; > > + const float x2_6 = x0_2 - x0_5; > > + const float x2_7 = x0_3 - x0_4; > > + const float x4_0 = x2_0 + x2_3; > > + const float x4_1 = x2_1 + x2_2; > > + const float x4_2 = x2_0 - x2_3; > > + const float x4_3 = x2_1 - x2_2; > > + const float x5_0 = x4_0 + x4_1; > > + const float x5_1 = x4_0 - x4_1; > > + const float x5_2 = 1.306562964876380*x4_2 + 0.541196100146197*x4_3; > > + const float x5_3 = 0.541196100146197*x4_2 - 1.306562964876380*x4_3; > > + const float x6_0 = 1.387039845322150*x2_4 + 0.275899379282943*x2_7; > > + const float x6_1 = 1.175875602419360*x2_5 + 0.785694958387102*x2_6; > > + const float x6_2 = -0.785694958387102*x2_5 + 1.175875602419360*x2_6; > > + const float x6_3 = 0.275899379282943*x2_4 - 1.387039845322150*x2_7; > > + const float x7_0 = x6_0 + x6_1; > > + const float x7_1 = x6_0 - x6_1; > > + const float x7_2 = x6_2 + x6_3; > > + const float x7_3 = x6_2 - x6_3; > > + const float x3_5 = 0.707106781186547*x7_1 - 0.707106781186547*x7_3; > > + const float x3_6 = 0.707106781186547*x7_1 + 0.707106781186547*x7_3; > > + const float x8_0 = 1.407403737526380*x0_8 + 0.138617169199091*x0_f; > > + const float x8_1 = 1.353318001174350*x0_9 + 0.410524527522357*x0_e; > > + const float x8_2 = 1.247225012986670*x0_a + 0.666655658477747*x0_d; > > + const float x8_3 = 1.093201867001760*x0_b + 0.897167586342636*x0_c; > > + const float x8_4 = -0.897167586342636*x0_b + 1.093201867001760*x0_c; > > + const float x8_5 = 0.666655658477747*x0_a - 1.247225012986670*x0_d; > > + const float x8_6 = -0.410524527522357*x0_9 + 1.353318001174350*x0_e; > > + const float x8_7 = 0.138617169199091*x0_8 - 1.407403737526380*x0_f; > > + const float xa_0 = x8_0 + x8_3; > > + const float xa_1 = x8_1 + x8_2; > > + const float xa_2 = x8_0 - x8_3; > > + const float xa_3 = x8_1 - x8_2; > > + const float xb_0 = xa_0 + xa_1; > > + const float xb_1 = xa_0 - xa_1; > > + const float xb_2 = 1.306562964876380*xa_2 + 0.541196100146197*xa_3; > > + const float xb_3 = 0.541196100146197*xa_2 - 1.306562964876380*xa_3; > > + const float xc_0 = x8_4 + x8_7; > > + const float xc_1 = x8_5 + x8_6; > > + const float xc_2 = x8_4 - x8_7; > > + const float xc_3 = x8_5 - x8_6; > > + const float xd_0 = xc_0 + xc_1; > > + const float xd_1 = xc_0 - xc_1; > > + const float xd_2 = 1.306562964876380*xc_2 + 0.541196100146197*xc_3; > > + const float xd_3 = 0.541196100146197*xc_2 - 1.306562964876380*xc_3; > > + const float x1_9 = 0.707106781186547*xb_2 - 0.707106781186547*xd_3; > > + const float x1_a = 0.707106781186547*xb_2 + 0.707106781186547*xd_3; > > + const float x1_b = 0.707106781186547*xb_1 + 0.707106781186547*xd_1; > > + const float x1_c = 0.707106781186547*xb_1 - 0.707106781186547*xd_1; > > + const float x1_d = 0.707106781186547*xb_3 - 0.707106781186547*xd_2; > > + const float x1_e = 0.707106781186547*xb_3 + 0.707106781186547*xd_2; > > + dst[ 0*dst_stridea] = 0.25*x5_0; > > + dst[ 1*dst_stridea] = 0.25*xb_0; > > + dst[ 2*dst_stridea] = 0.25*x7_0; > > + dst[ 3*dst_stridea] = 0.25*x1_9; > > + dst[ 4*dst_stridea] = 0.25*x5_2; > > + dst[ 5*dst_stridea] = 0.25*x1_a; > > + dst[ 6*dst_stridea] = 0.25*x3_5; > > + dst[ 7*dst_stridea] = 0.25*x1_b; > > + dst[ 8*dst_stridea] = 0.25*x5_1; > > + dst[ 9*dst_stridea] = 0.25*x1_c; > > + dst[10*dst_stridea] = 0.25*x3_6; > > + dst[11*dst_stridea] = 0.25*x1_d; > > + dst[12*dst_stridea] = 0.25*x5_3; > > + dst[13*dst_stridea] = 0.25*x1_e; > > + dst[14*dst_stridea] = 0.25*x7_2; > > + dst[15*dst_stridea] = 0.25*xd_0; > > many of these multiplies look like they can be merged into other > multiplies > > for example see: > > > const float xd_2 = 1.306562964876380*xc_2 + 0.541196100146197*xc_3; > const float xb_3 = 0.541196100146197*xa_2 - 1.306562964876380*xa_3; > const float x1_d = 0.707106781186547*xb_3 - 0.707106781186547*xd_2; > const float x1_e = 0.707106781186547*xb_3 + 0.707106781186547*xd_2; > dst[11*dst_stridea] = 0.25*x1_d; > dst[13*dst_stridea] = 0.25*x1_e; > > vs. > > const float xd_2 = (0.25*0.707106781186547*1.306562964876380)*xc_2 + (0.25*0.707106781186547*0.541196100146197)*xc_3; > const float xb_3 = (0.25*0.707106781186547*0.541196100146197)*xa_2 - (0.25*0.707106781186547*1.306562964876380)*xa_3; > dst[11*dst_stridea] = xb_3 - xd_2; > dst[13*dst_stridea] = xb_3 + xd_2; also more generally if you have 2 stages of butterflies each with 4 multiplies and 2 adds in each butterfly a----\-/--\---/----------a' X \ / b----/-\----------\---/--b' / \ \ / c----\-/--/---\----------c' X / \ d----/-\----------/---\--d' of additions the first stage can scale their output arbitrarily for free by changing the respective coefficients the second stage can use any scaled input for free by adjusting their coefficients similarly, this gives you 4 free parameters in the example above which can be choosen so as to make some coefficients trivial like +-1.0 this also works accorss 2D (I)DCTs or with other things before or after the (i)dct which can absorb such rescaling [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Rewriting code that is poorly written but fully understood is good. Rewriting code that one doesnt understand is a sign that one is less smart then the original author, trying to rewrite it will not make it better. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 4 01:57:55 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 01:57:55 +0200 Subject: [FFmpeg-devel] [PATCH 1/4] libavcodec: new API for frame threading by step In-Reply-To: References: <1406142826-5980-1-git-send-email-christophe.gisquet@gmail.com> <1406142826-5980-2-git-send-email-christophe.gisquet@gmail.com> <20140728211530.GT4649@nb4> Message-ID: <20140803235755.GN4649@nb4> On Sun, Aug 03, 2014 at 06:39:38PM +0200, Christophe Gisquet wrote: > Hi, > > note: I'm using "step" throughout the patch because of the step > function and what the causal part most often looks like. I have no > idea for another less confusing wording. > > 2014-07-28 23:15 GMT+02:00 Michael Niedermayer : > > maybe i misunderstand but the "progress[1] > y" check looks odd, > > shouldnt progress[0] be updated to a larger value even if > > progress[1] > y > > ? > > Let's look at the following schema, that maybe should be added to the > documentation: > ___ p[0] > p[1] ___| > p[2] > > p(rogress)[0] and p[1] are the ordinates of the step. p[2] is the abscissa. another way to vissualize the same thing is to consider 1) 0..p[2] 2) 0.......w .....| ......... p[1]_____| p[0]_________ that is two convex shapes, first a rectangle from (0,0) to (p[2], p[1]) and second the old "all above line" and consider them finished&available to be all points that are in either. I had based my suggestions of what how to update based on this vissualization [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 4 03:49:57 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 03:49:57 +0200 Subject: [FFmpeg-devel] [PATCH] fix tls/tcp protocol after a 302 move in https In-Reply-To: <20140802005710.GN4649@nb4> References: <20140801203727.00004837@mi.rr.com> <20140802005710.GN4649@nb4> Message-ID: <20140804014957.GO4649@nb4> On Sat, Aug 02, 2014 at 02:57:10AM +0200, Michael Niedermayer wrote: > On Fri, Aug 01, 2014 at 08:37:27PM -0400, compn wrote: > > patch from https://trac.ffmpeg.org/ticket/3824 > > > > -compn > > > diff --git a/libavformat/http.c b/libavformat/http.c > > index 33585b0..3dffaee 100644 > > --- a/libavformat/http.c > > +++ b/libavformat/http.c > > @@ -229,6 +229,7 @@ redo: > > memset(&s->auth_state, 0, sizeof(s->auth_state)); > > attempts = 0; > > location_changed = 0; > > + lower_proto = "tcp"; > > goto redo; > > } > > return 0; > > probably ok, iam not maintainer of http.c though > > who is the author of this change though (as you write "patch from") > ? > if its not you, please set the author of the commit correctly author fixed & applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From jamrial at gmail.com Mon Aug 4 04:53:38 2014 From: jamrial at gmail.com (James Almer) Date: Sun, 3 Aug 2014 23:53:38 -0300 Subject: [FFmpeg-devel] [PATCH 1/3] x86/hevc_mc: remove an unnecessary pxor Message-ID: <1407120820-3949-1-git-send-email-jamrial@gmail.com> Signed-off-by: James Almer --- libavcodec/x86/hevc_mc.asm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/x86/hevc_mc.asm b/libavcodec/x86/hevc_mc.asm index fc78062..a16b0ab 100644 --- a/libavcodec/x86/hevc_mc.asm +++ b/libavcodec/x86/hevc_mc.asm @@ -551,8 +551,7 @@ cglobal hevc_put_hevc_pel_pixels%1_%2, 5, 5, 3, dst, dststride, src, srcstride,h LOOP_END dst, dststride, src, srcstride RET -cglobal hevc_put_hevc_uni_pel_pixels%1_%2, 5, 5, 3, dst, dststride, src, srcstride,height - pxor m2, m2 +cglobal hevc_put_hevc_uni_pel_pixels%1_%2, 5, 5, 2, dst, dststride, src, srcstride,height .loop SIMPLE_LOAD %1, %2, srcq, m0 PEL_%2STORE%1 dstq, m0, m1 -- 1.8.5.5 From jamrial at gmail.com Mon Aug 4 04:53:39 2014 From: jamrial at gmail.com (James Almer) Date: Sun, 3 Aug 2014 23:53:39 -0300 Subject: [FFmpeg-devel] [PATCH 2/3] x86/ttadsp: remove an unnecessary mova In-Reply-To: <1407120820-3949-1-git-send-email-jamrial@gmail.com> References: <1407120820-3949-1-git-send-email-jamrial@gmail.com> Message-ID: <1407120820-3949-2-git-send-email-jamrial@gmail.com> Signed-off-by: James Almer --- libavcodec/x86/ttadsp.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/x86/ttadsp.asm b/libavcodec/x86/ttadsp.asm index 8346cab..8f48949 100644 --- a/libavcodec/x86/ttadsp.asm +++ b/libavcodec/x86/ttadsp.asm @@ -72,7 +72,7 @@ cglobal ttafilter_process_dec, 5,5,%2, qm, dx, dl, error, in, shift, round ; Using horizontal add (phaddd) seems to be slower than shuffling stuff around paddd m2, m3 ; int sum = filter->round + ; filter->dl[0] * filter->qm[0] + - punpckhqdq m3, m2, m2 ; filter->dl[1] * filter->qm[1] + + pshufd m3, m2, 0xe ; filter->dl[1] * filter->qm[1] + paddd m2, m3 ; filter->dl[2] * filter->qm[2] + ; filter->dl[3] * filter->qm[3] + movd m6, roundm ; filter->dl[4] * filter->qm[4] + -- 1.8.5.5 From jamrial at gmail.com Mon Aug 4 04:53:40 2014 From: jamrial at gmail.com (James Almer) Date: Sun, 3 Aug 2014 23:53:40 -0300 Subject: [FFmpeg-devel] [PATCH 3/3] x86/vp9lpf: use fewer instructions in SPLATB_MIX In-Reply-To: <1407120820-3949-1-git-send-email-jamrial@gmail.com> References: <1407120820-3949-1-git-send-email-jamrial@gmail.com> Message-ID: <1407120820-3949-3-git-send-email-jamrial@gmail.com> Signed-off-by: James Almer --- libavcodec/x86/vp9lpf.asm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/vp9lpf.asm b/libavcodec/x86/vp9lpf.asm index c5db0ca..def7d5a 100644 --- a/libavcodec/x86/vp9lpf.asm +++ b/libavcodec/x86/vp9lpf.asm @@ -302,9 +302,8 @@ SECTION .text pshufb %1, %2 %else punpcklbw %1, %1 - punpcklqdq %1, %1 - pshuflw %1, %1, 0 - pshufhw %1, %1, 0x55 + punpcklwd %1, %1 + punpckldq %1, %1 %endif %endmacro -- 1.8.5.5 From michaelni at gmx.at Mon Aug 4 06:14:17 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 06:14:17 +0200 Subject: [FFmpeg-devel] [PATCHv3] Deprecate AFD field and add AFD as side-data In-Reply-To: <20140803204939.GG4649@nb4> References: <1407090297-5537-1-git-send-email-kierank@obe.tv> <20140803204658.GF4649@nb4> <20140803204939.GG4649@nb4> Message-ID: <20140804041417.GP4649@nb4> On Sun, Aug 03, 2014 at 10:49:39PM +0200, Michael Niedermayer wrote: > On Sun, Aug 03, 2014 at 10:46:58PM +0200, Michael Niedermayer wrote: > > On Sun, Aug 03, 2014 at 07:24:56PM +0100, Kieran Kunhya wrote: > > > --- > > > doc/APIchanges | 4 ++++ > > > libavcodec/avcodec.h | 5 ++++- > > > libavcodec/mpeg12dec.c | 20 +++++++++++++++++++- > > > libavcodec/version.h | 5 ++++- > > > libavfilter/vf_showinfo.c | 3 +++ > > > libavutil/frame.h | 16 ++++++++++++++++ > > > libavutil/version.h | 2 +- > > > 7 files changed, 51 insertions(+), 4 deletions(-) > > [...] > > > @@ -1631,6 +1633,18 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) > > > *stereo = s1->stereo3d; > > > s1->has_stereo3d = 0; > > > } > > > + > > > + if (s1->has_afd) { > > > + AVFrameSideData *sd = av_frame_new_side_data( > > > + s->current_picture_ptr->f, AV_FRAME_DATA_AFD, > > > + 1); > > > + if (!sd) > > > + return AVERROR(ENOMEM); > > > + > > > > > + sd->data = s1->afd; > > > > this should be > > *(uint8_t*)sd->data = s1->afd; > > or simpler > *sd->data = s1->afd; applied with that fix merged the reformatted one thanks to all [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Observe your enemies, for they first find out your faults. -- Antisthenes -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From jamrial at gmail.com Mon Aug 4 06:18:46 2014 From: jamrial at gmail.com (James Almer) Date: Mon, 4 Aug 2014 01:18:46 -0300 Subject: [FFmpeg-devel] [PATCH] x86/hevc_mc: use fewer instructions in hevc_put_hevc_{uni, bi}_w[24]_{8, 10, 12} Message-ID: <1407125926-4151-1-git-send-email-jamrial@gmail.com> Signed-off-by: James Almer --- libavcodec/x86/hevc_mc.asm | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/libavcodec/x86/hevc_mc.asm b/libavcodec/x86/hevc_mc.asm index fc78062..3ef0149 100644 --- a/libavcodec/x86/hevc_mc.asm +++ b/libavcodec/x86/hevc_mc.asm @@ -1158,9 +1158,16 @@ cglobal hevc_put_hevc_uni_w%1_%2, 6, 6, 7, dst, dststride, src, srcstride, heigh %define SHIFT denomd %endif lea SHIFT, [SHIFT+14-%2] ; shift = 14 - bitd + denom +%if %1 <= 4 + pxor m1, m1 +%endif movd m2, wxm ; WX movd m4, SHIFT ; shift +%if %1 <= 4 + punpcklwd m2, m1 +%else punpcklwd m2, m2 +%endif dec SHIFT movdqu m5, [one_per_32] movd m6, SHIFT @@ -1177,6 +1184,13 @@ cglobal hevc_put_hevc_uni_w%1_%2, 6, 6, 7, dst, dststride, src, srcstride, heigh %endif .loop SIMPLE_LOAD %1, 10, srcq, m0 +%if %1 <= 4 + punpcklwd m0, m1 + pmaddwd m0, m2 + paddd m0, m5 + psrad m0, m4 + paddd m0, m3 +%else pmulhw m6, m0, m2 pmullw m0, m2 punpckhwd m1, m0, m6 @@ -1187,6 +1201,7 @@ cglobal hevc_put_hevc_uni_w%1_%2, 6, 6, 7, dst, dststride, src, srcstride, heigh psrad m1, m4 paddd m0, m3 paddd m1, m3 +%endif packusdw m0, m1 %if %2 == 8 packuswb m0, m0 @@ -1202,13 +1217,21 @@ cglobal hevc_put_hevc_uni_w%1_%2, 6, 6, 7, dst, dststride, src, srcstride, heigh cglobal hevc_put_hevc_bi_w%1_%2, 6, 7, 10, dst, dststride, src, srcstride, src2, src2stride, height, denom, wx0, wx1, ox0, ox1 mov r6d, denomm +%if %1 <= 4 + pxor m1, m1 +%endif movd m2, wx0m ; WX0 lea r6d, [r6d+14-%2] ; shift = 14 - bitd + denom movd m3, wx1m ; WX1 movd m0, r6d ; shift +%if %1 <= 4 + punpcklwd m2, m1 + punpcklwd m3, m1 +%else punpcklwd m2, m2 - inc r6d punpcklwd m3, m3 +%endif + inc r6d movd m5, r6d ; shift+1 pshufd m2, m2, 0 mov r6d, ox0m @@ -1226,6 +1249,15 @@ cglobal hevc_put_hevc_bi_w%1_%2, 6, 7, 10, dst, dststride, src, srcstride, src2, .loop SIMPLE_LOAD %1, 10, srcq, m0 SIMPLE_LOAD %1, 10, src2q, m8 +%if %1 <= 4 + punpcklwd m0, m1 + punpcklwd m8, m1 + pmaddwd m0, m3 + pmaddwd m8, m2 + paddd m0, m4 + paddd m0, m8 + psrad m0, m5 +%else pmulhw m6, m0, m3 pmullw m0, m3 pmulhw m7, m8, m2 @@ -1240,6 +1272,7 @@ cglobal hevc_put_hevc_bi_w%1_%2, 6, 7, 10, dst, dststride, src, srcstride, src2, paddd m1, m4 psrad m0, m5 psrad m1, m5 +%endif packusdw m0, m1 %if %2 == 8 packuswb m0, m0 -- 1.8.5.5 From onemda at gmail.com Mon Aug 4 09:11:46 2014 From: onemda at gmail.com (Paul B Mahol) Date: Mon, 4 Aug 2014 09:11:46 +0200 Subject: [FFmpeg-devel] [PATCH] lavfi/avf_showspectrum: use automatic framing. In-Reply-To: <1407088260-19647-1-git-send-email-george@nsup.org> References: <1407077965-16960-1-git-send-email-george@nsup.org> <1407088260-19647-1-git-send-email-george@nsup.org> Message-ID: On Sun, Aug 3, 2014 at 7:51 PM, Nicolas George wrote: > The framework can ensure that each input frame has exactly > the correct number of samples, except the last one. > > Signed-off-by: Nicolas George > --- > libavfilter/avf_showspectrum.c | 48 > +++++++++++++++--------------------------- > 1 file changed, 17 insertions(+), 31 deletions(-) > > lgtm From mrskman at gmail.com Mon Aug 4 09:24:25 2014 From: mrskman at gmail.com (mrskman) Date: Mon, 4 Aug 2014 09:24:25 +0200 Subject: [FFmpeg-devel] [PATCH] New p2p mode for showwaves filter In-Reply-To: References: Message-ID: <1407137065-14771-1-git-send-email-mrskman@gmail.com> New patch attached. Thank you. --- doc/filters.texi | 3 +++ libavfilter/avf_showwaves.c | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index a7919a3..145acbf 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10698,6 +10698,9 @@ Draw a point for each sample. @item line Draw a vertical line for each sample. + + at item p2p +Draw a point for each sample and a line between them. @end table Default value is @code{point}. diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c index 0b45bd0..e6158b2 100644 --- a/libavfilter/avf_showwaves.c +++ b/libavfilter/avf_showwaves.c @@ -35,6 +35,7 @@ enum ShowWavesMode { MODE_POINT, MODE_LINE, + MODE_P2P, MODE_NB, }; @@ -43,6 +44,7 @@ typedef struct { int w, h; AVRational rate; int buf_idx; + int *buf_idy; /* y coordinate of previous sample for each channel */ AVFrame *outpicref; int req_fullfilled; int n; @@ -59,6 +61,7 @@ static const AVOption showwaves_options[] = { { "mode", "select display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_POINT}, 0, MODE_NB-1, FLAGS, "mode"}, { "point", "draw a point for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_POINT}, .flags=FLAGS, .unit="mode"}, { "line", "draw a line for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_LINE}, .flags=FLAGS, .unit="mode"}, + { "p2p", "draw a line between samples", 0, AV_OPT_TYPE_CONST, {.i64=MODE_P2P}, .flags=FLAGS, .unit="mode"}, { "n", "set how many samples to show in the same point", OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS }, { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS }, { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS }, @@ -72,6 +75,8 @@ static av_cold void uninit(AVFilterContext *ctx) ShowWavesContext *showwaves = ctx->priv; av_frame_free(&showwaves->outpicref); + if (showwaves->buf_idy) + av_freep(showwaves->buf_idy); } static int query_formats(AVFilterContext *ctx) @@ -110,14 +115,22 @@ static int query_formats(AVFilterContext *ctx) static int config_output(AVFilterLink *outlink) { + int i; AVFilterContext *ctx = outlink->src; AVFilterLink *inlink = ctx->inputs[0]; ShowWavesContext *showwaves = ctx->priv; + int nb_channels = inlink->channels; if (!showwaves->n) showwaves->n = FFMAX(1, ((double)inlink->sample_rate / (showwaves->w * av_q2d(showwaves->rate))) + 0.5); showwaves->buf_idx = 0; + if (!(showwaves->buf_idy = av_malloc_array(nb_channels, 1))) { + av_log(NULL, AV_LOG_ERROR, "Could not allocate showwaves buffer\n"); + return AVERROR(ENOMEM); + } + for (i = 0; i <= nb_channels; i++) + showwaves->buf_idy[i] = 0; outlink->w = showwaves->w; outlink->h = showwaves->h; outlink->sample_aspect_ratio = (AVRational){1,1}; @@ -132,13 +145,18 @@ static int config_output(AVFilterLink *outlink) inline static int push_frame(AVFilterLink *outlink) { + AVFilterContext *ctx = outlink->src; + AVFilterLink *inlink = ctx->inputs[0]; ShowWavesContext *showwaves = outlink->src->priv; - int ret; + int nb_channels = inlink->channels; + int ret, i; if ((ret = ff_filter_frame(outlink, showwaves->outpicref)) >= 0) showwaves->req_fullfilled = 1; showwaves->outpicref = NULL; showwaves->buf_idx = 0; + for (i = 0; i <= nb_channels; i++) + showwaves->buf_idy[i] = 0; return ret; } @@ -207,7 +225,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) *(outpicref->data[0] + showwaves->buf_idx + k * linesize) += x; break; } + case MODE_P2P: + if (h >= 0 && h < outlink->h) { + *(outpicref->data[0] + showwaves->buf_idx + h * linesize) += x; + if (showwaves->buf_idy[j] && h != showwaves->buf_idy[j]) { + int start = showwaves->buf_idy[j], end = av_clip(h, 0, outlink->h-1); + if (start > end) FFSWAP(int16_t, start, end); + for (k = start + 1; k < end; k++) + *(outpicref->data[0] + showwaves->buf_idx + k * linesize) += x; + } + } + break; } + /* store current y coordinate for this channel */ + showwaves->buf_idy[j] = h; } showwaves->sample_count_mod++; -- 1.7.1 From onemda at gmail.com Mon Aug 4 09:34:57 2014 From: onemda at gmail.com (Paul B Mahol) Date: Mon, 4 Aug 2014 09:34:57 +0200 Subject: [FFmpeg-devel] [PATCH] New p2p mode for showwaves filter In-Reply-To: <1407137065-14771-1-git-send-email-mrskman@gmail.com> References: <1407137065-14771-1-git-send-email-mrskman@gmail.com> Message-ID: On Mon, Aug 4, 2014 at 9:24 AM, mrskman wrote: > New patch attached. > > Thank you. > > --- > doc/filters.texi | 3 +++ > libavfilter/avf_showwaves.c | 33 ++++++++++++++++++++++++++++++++- > 2 files changed, 35 insertions(+), 1 deletions(-) > > diff --git a/doc/filters.texi b/doc/filters.texi > index a7919a3..145acbf 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -10698,6 +10698,9 @@ Draw a point for each sample. > > @item line > Draw a vertical line for each sample. > + > + at item p2p > +Draw a point for each sample and a line between them. > @end table > > Default value is @code{point}. > diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c > index 0b45bd0..e6158b2 100644 > --- a/libavfilter/avf_showwaves.c > +++ b/libavfilter/avf_showwaves.c > @@ -35,6 +35,7 @@ > enum ShowWavesMode { > MODE_POINT, > MODE_LINE, > + MODE_P2P, > MODE_NB, > }; > > @@ -43,6 +44,7 @@ typedef struct { > int w, h; > AVRational rate; > int buf_idx; > + int *buf_idy; /* y coordinate of previous sample for each channel > */ > AVFrame *outpicref; > int req_fullfilled; > int n; > @@ -59,6 +61,7 @@ static const AVOption showwaves_options[] = { > { "mode", "select display mode", OFFSET(mode), AV_OPT_TYPE_INT, > {.i64=MODE_POINT}, 0, MODE_NB-1, FLAGS, "mode"}, > { "point", "draw a point for each sample", 0, AV_OPT_TYPE_CONST, > {.i64=MODE_POINT}, .flags=FLAGS, .unit="mode"}, > { "line", "draw a line for each sample", 0, AV_OPT_TYPE_CONST, > {.i64=MODE_LINE}, .flags=FLAGS, .unit="mode"}, > + { "p2p", "draw a line between samples", 0, AV_OPT_TYPE_CONST, > {.i64=MODE_P2P}, .flags=FLAGS, .unit="mode"}, > { "n", "set how many samples to show in the same point", > OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS }, > { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, > {.str = "25"}, 0, 0, FLAGS }, > { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, > {.str = "25"}, 0, 0, FLAGS }, > @@ -72,6 +75,8 @@ static av_cold void uninit(AVFilterContext *ctx) > ShowWavesContext *showwaves = ctx->priv; > > av_frame_free(&showwaves->outpicref); > + if (showwaves->buf_idy) > + av_freep(showwaves->buf_idy); > } > > static int query_formats(AVFilterContext *ctx) > @@ -110,14 +115,22 @@ static int query_formats(AVFilterContext *ctx) > > static int config_output(AVFilterLink *outlink) > { > + int i; > Could you put this one down where nb_channels is. > AVFilterContext *ctx = outlink->src; > AVFilterLink *inlink = ctx->inputs[0]; > ShowWavesContext *showwaves = ctx->priv; > + int nb_channels = inlink->channels; > > if (!showwaves->n) > showwaves->n = FFMAX(1, ((double)inlink->sample_rate / > (showwaves->w * av_q2d(showwaves->rate))) + 0.5); > > showwaves->buf_idx = 0; > + if (!(showwaves->buf_idy = av_malloc_array(nb_channels, 1))) { > Use calloc, or av_mallocz_array. > + av_log(NULL, AV_LOG_ERROR, "Could not allocate showwaves > buffer\n"); > This can use ctx : av_log(ctx,.. > + return AVERROR(ENOMEM); > + } > + for (i = 0; i <= nb_channels; i++) > + showwaves->buf_idy[i] = 0; > Not needed to manually do this if you use one of above mentioned functions. > outlink->w = showwaves->w; > outlink->h = showwaves->h; > outlink->sample_aspect_ratio = (AVRational){1,1}; > @@ -132,13 +145,18 @@ static int config_output(AVFilterLink *outlink) > > inline static int push_frame(AVFilterLink *outlink) > { > + AVFilterContext *ctx = outlink->src; > + AVFilterLink *inlink = ctx->inputs[0]; > ShowWavesContext *showwaves = outlink->src->priv; > - int ret; > + int nb_channels = inlink->channels; > + int ret, i; > > if ((ret = ff_filter_frame(outlink, showwaves->outpicref)) >= 0) > showwaves->req_fullfilled = 1; > showwaves->outpicref = NULL; > showwaves->buf_idx = 0; > + for (i = 0; i <= nb_channels; i++) > + showwaves->buf_idy[i] = 0; > return ret; > } > > @@ -207,7 +225,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *insamples) > *(outpicref->data[0] + showwaves->buf_idx + k * > linesize) += x; > break; > } > + case MODE_P2P: > + if (h >= 0 && h < outlink->h) { > + *(outpicref->data[0] + showwaves->buf_idx + h * > linesize) += x; > + if (showwaves->buf_idy[j] && h != > showwaves->buf_idy[j]) { > + int start = showwaves->buf_idy[j], end = > av_clip(h, 0, outlink->h-1); > + if (start > end) FFSWAP(int16_t, start, end); > FFSWAP.. should be on its own line + for (k = start + 1; k < end; k++) > + *(outpicref->data[0] + showwaves->buf_idx + k > * linesize) += x; > + } > + } > + break; > } > + /* store current y coordinate for this channel */ > + showwaves->buf_idy[j] = h; > } > > showwaves->sample_count_mod++; > -- > 1.7.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > From onemda at gmail.com Mon Aug 4 09:35:48 2014 From: onemda at gmail.com (Paul B Mahol) Date: Mon, 4 Aug 2014 09:35:48 +0200 Subject: [FFmpeg-devel] [PATCH] New p2p mode for showwaves filter In-Reply-To: References: <1407137065-14771-1-git-send-email-mrskman@gmail.com> Message-ID: On Mon, Aug 4, 2014 at 9:34 AM, Paul B Mahol wrote: > > > > On Mon, Aug 4, 2014 at 9:24 AM, mrskman wrote: > >> New patch attached. >> >> Thank you. >> >> --- >> doc/filters.texi | 3 +++ >> libavfilter/avf_showwaves.c | 33 ++++++++++++++++++++++++++++++++- >> 2 files changed, 35 insertions(+), 1 deletions(-) >> >> diff --git a/doc/filters.texi b/doc/filters.texi >> index a7919a3..145acbf 100644 >> --- a/doc/filters.texi >> +++ b/doc/filters.texi >> @@ -10698,6 +10698,9 @@ Draw a point for each sample. >> >> @item line >> Draw a vertical line for each sample. >> + >> + at item p2p >> +Draw a point for each sample and a line between them. >> @end table >> >> Default value is @code{point}. >> diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c >> index 0b45bd0..e6158b2 100644 >> --- a/libavfilter/avf_showwaves.c >> +++ b/libavfilter/avf_showwaves.c >> @@ -35,6 +35,7 @@ >> enum ShowWavesMode { >> MODE_POINT, >> MODE_LINE, >> + MODE_P2P, >> MODE_NB, >> }; >> >> @@ -43,6 +44,7 @@ typedef struct { >> int w, h; >> AVRational rate; >> int buf_idx; >> + int *buf_idy; /* y coordinate of previous sample for each channel >> */ >> AVFrame *outpicref; >> int req_fullfilled; >> int n; >> @@ -59,6 +61,7 @@ static const AVOption showwaves_options[] = { >> { "mode", "select display mode", OFFSET(mode), AV_OPT_TYPE_INT, >> {.i64=MODE_POINT}, 0, MODE_NB-1, FLAGS, "mode"}, >> { "point", "draw a point for each sample", 0, AV_OPT_TYPE_CONST, >> {.i64=MODE_POINT}, .flags=FLAGS, .unit="mode"}, >> { "line", "draw a line for each sample", 0, AV_OPT_TYPE_CONST, >> {.i64=MODE_LINE}, .flags=FLAGS, .unit="mode"}, >> + { "p2p", "draw a line between samples", 0, AV_OPT_TYPE_CONST, >> {.i64=MODE_P2P}, .flags=FLAGS, .unit="mode"}, >> { "n", "set how many samples to show in the same point", >> OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS }, >> { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, >> {.str = "25"}, 0, 0, FLAGS }, >> { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, >> {.str = "25"}, 0, 0, FLAGS }, >> @@ -72,6 +75,8 @@ static av_cold void uninit(AVFilterContext *ctx) >> ShowWavesContext *showwaves = ctx->priv; >> >> av_frame_free(&showwaves->outpicref); >> + if (showwaves->buf_idy) >> + av_freep(showwaves->buf_idy); >> } >> >> static int query_formats(AVFilterContext *ctx) >> @@ -110,14 +115,22 @@ static int query_formats(AVFilterContext *ctx) >> >> static int config_output(AVFilterLink *outlink) >> { >> + int i; >> > Could you put this one down where nb_channels is. > > >> AVFilterContext *ctx = outlink->src; >> AVFilterLink *inlink = ctx->inputs[0]; >> ShowWavesContext *showwaves = ctx->priv; >> + int nb_channels = inlink->channels; >> >> if (!showwaves->n) >> showwaves->n = FFMAX(1, ((double)inlink->sample_rate / >> (showwaves->w * av_q2d(showwaves->rate))) + 0.5); >> >> showwaves->buf_idx = 0; >> + if (!(showwaves->buf_idy = av_malloc_array(nb_channels, 1))) { >> > > Use calloc, or av_mallocz_array. > by calloc i mean av_calloc > > >> + av_log(NULL, AV_LOG_ERROR, "Could not allocate showwaves >> buffer\n"); >> > > This can use ctx : av_log(ctx,.. > > >> + return AVERROR(ENOMEM); >> + } >> + for (i = 0; i <= nb_channels; i++) >> + showwaves->buf_idy[i] = 0; >> > > Not needed to manually do this if you use one of above mentioned functions. > > >> outlink->w = showwaves->w; >> outlink->h = showwaves->h; >> outlink->sample_aspect_ratio = (AVRational){1,1}; >> @@ -132,13 +145,18 @@ static int config_output(AVFilterLink *outlink) >> >> inline static int push_frame(AVFilterLink *outlink) >> { >> + AVFilterContext *ctx = outlink->src; >> + AVFilterLink *inlink = ctx->inputs[0]; >> ShowWavesContext *showwaves = outlink->src->priv; >> - int ret; >> + int nb_channels = inlink->channels; >> + int ret, i; >> >> if ((ret = ff_filter_frame(outlink, showwaves->outpicref)) >= 0) >> showwaves->req_fullfilled = 1; >> showwaves->outpicref = NULL; >> showwaves->buf_idx = 0; >> + for (i = 0; i <= nb_channels; i++) >> + showwaves->buf_idy[i] = 0; >> return ret; >> } >> >> @@ -207,7 +225,20 @@ static int filter_frame(AVFilterLink *inlink, >> AVFrame *insamples) >> *(outpicref->data[0] + showwaves->buf_idx + k * >> linesize) += x; >> break; >> } >> + case MODE_P2P: >> + if (h >= 0 && h < outlink->h) { >> + *(outpicref->data[0] + showwaves->buf_idx + h * >> linesize) += x; >> + if (showwaves->buf_idy[j] && h != >> showwaves->buf_idy[j]) { >> + int start = showwaves->buf_idy[j], end = >> av_clip(h, 0, outlink->h-1); >> + if (start > end) FFSWAP(int16_t, start, end); >> > FFSWAP.. should be on its own line > > + for (k = start + 1; k < end; k++) >> + *(outpicref->data[0] + showwaves->buf_idx + >> k * linesize) += x; >> + } >> + } >> + break; >> } >> + /* store current y coordinate for this channel */ >> + showwaves->buf_idy[j] = h; >> } >> >> showwaves->sample_count_mod++; >> -- >> 1.7.1 >> >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel at ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > > From mraulet at gmail.com Mon Aug 4 10:27:44 2014 From: mraulet at gmail.com (=?UTF-8?Q?Micka=C3=ABl_Raulet?=) Date: Mon, 4 Aug 2014 10:27:44 +0200 Subject: [FFmpeg-devel] [PATCH 1/3] x86/hevc_mc: remove an unnecessary pxor In-Reply-To: <1407120820-3949-1-git-send-email-jamrial@gmail.com> References: <1407120820-3949-1-git-send-email-jamrial@gmail.com> Message-ID: Patch ok. Mickael Le lundi 4 ao?t 2014, James Almer a ?crit : > Signed-off-by: James Almer > > --- > libavcodec/x86/hevc_mc.asm | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/libavcodec/x86/hevc_mc.asm b/libavcodec/x86/hevc_mc.asm > index fc78062..a16b0ab 100644 > --- a/libavcodec/x86/hevc_mc.asm > +++ b/libavcodec/x86/hevc_mc.asm > @@ -551,8 +551,7 @@ cglobal hevc_put_hevc_pel_pixels%1_%2, 5, 5, 3, dst, > dststride, src, srcstride,h > LOOP_END dst, dststride, src, srcstride > RET > > -cglobal hevc_put_hevc_uni_pel_pixels%1_%2, 5, 5, 3, dst, dststride, src, > srcstride,height > - pxor m2, m2 > +cglobal hevc_put_hevc_uni_pel_pixels%1_%2, 5, 5, 2, dst, dststride, src, > srcstride,height > .loop > SIMPLE_LOAD %1, %2, srcq, m0 > PEL_%2STORE%1 dstq, m0, m1 > -- > 1.8.5.5 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > From christophe.gisquet at gmail.com Mon Aug 4 10:31:52 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Mon, 4 Aug 2014 10:31:52 +0200 Subject: [FFmpeg-devel] [PATCH 0/4] Exploit compile-time constant In-Reply-To: <20140802124846.GQ4649@nb4> References: <1406567848-6368-1-git-send-email-christophe.gisquet@gmail.com> <20140802124846.GQ4649@nb4> Message-ID: Hi, 2014-08-02 14:48 GMT+02:00 Michael Niedermayer : > seems to fail with > libavcodec/x86/hevc_mc.asm:1258: error: (add:2) cannot reference symbol `MAX_PB_SIZE' in preprocessor I forgot the initial patch when generating the patchset, that you can find here. I expect no changes for the others, so I didn't bother resending them/starting another thread. -- Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-x86-hevc_mc-assume-2nd-source-stride-is-64.patch Type: text/x-patch Size: 8498 bytes Desc: not available URL: From mrskman at gmail.com Mon Aug 4 11:40:47 2014 From: mrskman at gmail.com (mrskman) Date: Mon, 4 Aug 2014 11:40:47 +0200 Subject: [FFmpeg-devel] [PATCH] New p2p mode for showwaves filter In-Reply-To: References: Message-ID: <1407145247-27033-1-git-send-email-mrskman@gmail.com> New patch attached. Thank you. --- doc/filters.texi | 3 +++ libavfilter/avf_showwaves.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index a7919a3..145acbf 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10698,6 +10698,9 @@ Draw a point for each sample. @item line Draw a vertical line for each sample. + + at item p2p +Draw a point for each sample and a line between them. @end table Default value is @code{point}. diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c index 0b45bd0..e025663 100644 --- a/libavfilter/avf_showwaves.c +++ b/libavfilter/avf_showwaves.c @@ -35,6 +35,7 @@ enum ShowWavesMode { MODE_POINT, MODE_LINE, + MODE_P2P, MODE_NB, }; @@ -43,6 +44,7 @@ typedef struct { int w, h; AVRational rate; int buf_idx; + int16_t *buf_idy; /* y coordinate of previous sample for each channel */ AVFrame *outpicref; int req_fullfilled; int n; @@ -59,6 +61,7 @@ static const AVOption showwaves_options[] = { { "mode", "select display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_POINT}, 0, MODE_NB-1, FLAGS, "mode"}, { "point", "draw a point for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_POINT}, .flags=FLAGS, .unit="mode"}, { "line", "draw a line for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_LINE}, .flags=FLAGS, .unit="mode"}, + { "p2p", "draw a line between samples", 0, AV_OPT_TYPE_CONST, {.i64=MODE_P2P}, .flags=FLAGS, .unit="mode"}, { "n", "set how many samples to show in the same point", OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS }, { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS }, { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS }, @@ -72,6 +75,7 @@ static av_cold void uninit(AVFilterContext *ctx) ShowWavesContext *showwaves = ctx->priv; av_frame_free(&showwaves->outpicref); + av_freep(&showwaves->buf_idy); } static int query_formats(AVFilterContext *ctx) @@ -113,11 +117,16 @@ static int config_output(AVFilterLink *outlink) AVFilterContext *ctx = outlink->src; AVFilterLink *inlink = ctx->inputs[0]; ShowWavesContext *showwaves = ctx->priv; + int nb_channels = inlink->channels; if (!showwaves->n) showwaves->n = FFMAX(1, ((double)inlink->sample_rate / (showwaves->w * av_q2d(showwaves->rate))) + 0.5); showwaves->buf_idx = 0; + if (!(showwaves->buf_idy = av_mallocz_array(nb_channels, sizeof(*showwaves->buf_idy)))) { + av_log(ctx, AV_LOG_ERROR, "Could not allocate showwaves buffer\n"); + return AVERROR(ENOMEM); + } outlink->w = showwaves->w; outlink->h = showwaves->h; outlink->sample_aspect_ratio = (AVRational){1,1}; @@ -132,13 +141,18 @@ static int config_output(AVFilterLink *outlink) inline static int push_frame(AVFilterLink *outlink) { + AVFilterContext *ctx = outlink->src; + AVFilterLink *inlink = ctx->inputs[0]; ShowWavesContext *showwaves = outlink->src->priv; - int ret; + int nb_channels = inlink->channels; + int ret, i; if ((ret = ff_filter_frame(outlink, showwaves->outpicref)) >= 0) showwaves->req_fullfilled = 1; showwaves->outpicref = NULL; showwaves->buf_idx = 0; + for (i = 0; i <= nb_channels; i++) + showwaves->buf_idy[i] = 0; return ret; } @@ -207,7 +221,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) *(outpicref->data[0] + showwaves->buf_idx + k * linesize) += x; break; } + case MODE_P2P: + if (h >= 0 && h < outlink->h) { + *(outpicref->data[0] + showwaves->buf_idx + h * linesize) += x; + if (showwaves->buf_idy[j] && h != showwaves->buf_idy[j]) { + int start = showwaves->buf_idy[j], end = av_clip(h, 0, outlink->h-1); + if (start > end) + FFSWAP(int16_t, start, end); + for (k = start + 1; k < end; k++) + *(outpicref->data[0] + showwaves->buf_idx + k * linesize) += x; + } + } + break; } + /* store current y coordinate for this channel */ + showwaves->buf_idy[j] = h; } showwaves->sample_count_mod++; -- 1.7.1 From christophe.gisquet at gmail.com Mon Aug 4 12:32:05 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Mon, 4 Aug 2014 12:32:05 +0200 Subject: [FFmpeg-devel] [PATCH] x86/hevc_mc: use fewer instructions in hevc_put_hevc_{uni, bi}_w[24]_{8, 10, 12} In-Reply-To: <1407125926-4151-1-git-send-email-jamrial@gmail.com> References: <1407125926-4151-1-git-send-email-jamrial@gmail.com> Message-ID: Hi, 2014-08-04 6:18 GMT+02:00 James Almer : > Signed-off-by: James Almer Looks good to me. Tested on top of my patches, too. IIRC, this should be evaluated by the WP_ test sequences. On another hand, I expect to have little to no measurable impact, as this is weighted prediction for small PUs (4xH). -- Christophe From christophe.gisquet at gmail.com Mon Aug 4 12:38:28 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Mon, 4 Aug 2014 12:38:28 +0200 Subject: [FFmpeg-devel] [PATCH] x86: hevc_deblock: remove unnecessary masking Message-ID: Hi, the attached patch is a low-hanging fruit. I think the code using the computed values could be improved (eg you probably need half the GPRs to store results and you can probably shuffle more efficiently data), but this requires more effort. I'm mostly submitting it because it still applies, and I can't really spend more time on it. -- Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: 0008-x86-hevc_deblock-remove-unnecessary-masking.patch Type: text/x-patch Size: 1387 bytes Desc: not available URL: From michaelni at gmx.at Mon Aug 4 13:46:24 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 13:46:24 +0200 Subject: [FFmpeg-devel] [PATCH] libavformat/icecast.c Add Icecast protocol In-Reply-To: <20140803225146.GL4649@nb4> References: <20140723010618.GV4649@nb4> <1406536579-22310-1-git-send-email-epirat07@gmail.com> <20140802220022.GO10372@leki> <6C302C95-F0A0-4F29-8EA6-532469E9DBA8@gmail.com> <20140803215648.GJ4649@nb4> <8D9868C0-AC9E-4071-87CF-C9498F833F05@gmail.com> <20140803225146.GL4649@nb4> Message-ID: <20140804114624.GQ4649@nb4> Hi Marvin On Mon, Aug 04, 2014 at 12:51:46AM +0200, Michael Niedermayer wrote: > On Mon, Aug 04, 2014 at 12:24:27AM +0200, Marvin Scholz wrote: > > >av_freep() should be safe to be used with NULL > > > > Since av_freep takes a pointer I am nearly sure that it doesn't, at > > least I remember that I had some issues without the if's? But please > > correct me if I'm wrong. > > in the quoted code you pass the address of a pointer to av_freep() > the address of a pointer is never NULL. > The check checks if the pointer is NULL, which is passed to free() > POSIX, says about free() that > "If ptr is a null pointer, no action shall occur." > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/free.html > > ill make sure this is explicitly mentioned for av_freep() and not > just av_free() fixed the remaining nitpicks/comments and applied the patch If you want to maintain icecast, then please send a patch which adds yourself to MAINTAINERs Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 4 14:46:27 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 14:46:27 +0200 Subject: [FFmpeg-devel] [PATCH 1/3] x86/hevc_mc: remove an unnecessary pxor In-Reply-To: References: <1407120820-3949-1-git-send-email-jamrial@gmail.com> Message-ID: <20140804124627.GR4649@nb4> On Mon, Aug 04, 2014 at 10:27:44AM +0200, Micka?l Raulet wrote: > Patch ok. applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are too smart to engage in politics are punished by being governed by those who are dumber. -- Plato -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 4 15:04:34 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 15:04:34 +0200 Subject: [FFmpeg-devel] [PATCH] x86/hevc_mc: use fewer instructions in hevc_put_hevc_{uni, bi}_w[24]_{8, 10, 12} In-Reply-To: References: <1407125926-4151-1-git-send-email-jamrial@gmail.com> Message-ID: <20140804130434.GS4649@nb4> On Mon, Aug 04, 2014 at 12:32:05PM +0200, Christophe Gisquet wrote: > Hi, > > 2014-08-04 6:18 GMT+02:00 James Almer : > > Signed-off-by: James Almer > > Looks good to me. > > Tested on top of my patches, too. IIRC, this should be evaluated by > the WP_ test sequences. applied > > On another hand, I expect to have little to no measurable impact, as > this is weighted prediction for small PUs (4xH). id say, every bit helps thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 4 15:18:17 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 15:18:17 +0200 Subject: [FFmpeg-devel] [PATCH 0/4] Exploit compile-time constant In-Reply-To: References: <1406567848-6368-1-git-send-email-christophe.gisquet@gmail.com> <20140802124846.GQ4649@nb4> Message-ID: <20140804131817.GT4649@nb4> On Mon, Aug 04, 2014 at 10:31:52AM +0200, Christophe Gisquet wrote: > Hi, > > 2014-08-02 14:48 GMT+02:00 Michael Niedermayer : > > seems to fail with > > libavcodec/x86/hevc_mc.asm:1258: error: (add:2) cannot reference symbol `MAX_PB_SIZE' in preprocessor > > I forgot the initial patch when generating the patchset, that you can > find here. I expect no changes for the others, so I didn't bother > resending them/starting another thread. yes, builds & works fine now with that patch [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB What does censorship reveal? It reveals fear. -- Julian Assange -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 4 15:20:35 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 15:20:35 +0200 Subject: [FFmpeg-devel] [PATCH 0/4] Exploit compile-time constant In-Reply-To: References: <1406567848-6368-1-git-send-email-christophe.gisquet@gmail.com> <20140802124846.GQ4649@nb4> Message-ID: <20140804132035.GU4649@nb4> On Sun, Aug 03, 2014 at 07:10:13PM +0200, Christophe Gisquet wrote: > Hi, > > 2014-08-02 14:48 GMT+02:00 Michael Niedermayer : > > is this for apply/push or just RFC/WIP ? > > in-between. I had expected Mickael Raulet to comment if he was seeing > something not compatible with this. I think the bipred code is a bit > more mature since Ronald comments (iirc), so premature optimization is > probably a bit strong. Once Mickael is OK, then I'd agree with you > about applying it. cc-ing Mickael, so its not missed > > > you say "Premature optimization and overall not that useful." > > i would tend to suggest to apply it as it improves speed ... > > I was saying this mostly because it doesn't really register overall: > MC is around 20% in ffhevc for starters. [...] thanks -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 3 "Rare item" - "Common item with rare defect or maybe just a lie" "Professional" - "'Toy' made in china, not functional except as doorstop" "Experts will know" - "The seller hopes you are not an expert" -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From christophe.gisquet at gmail.com Mon Aug 4 15:25:00 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Mon, 4 Aug 2014 15:25:00 +0200 Subject: [FFmpeg-devel] [PATCH] x86/hevc_mc: use fewer instructions in hevc_put_hevc_{uni, bi}_w[24]_{8, 10, 12} In-Reply-To: <20140804130434.GS4649@nb4> References: <1407125926-4151-1-git-send-email-jamrial@gmail.com> <20140804130434.GS4649@nb4> Message-ID: 2014-08-04 15:04 GMT+02:00 Michael Niedermayer : >> On another hand, I expect to have little to no measurable impact, as >> this is weighted prediction for small PUs (4xH). > > id say, every bit helps Agreed. I meant: don't expect an easily benchmarkable difference. -- Christophe From rsbultje at gmail.com Mon Aug 4 15:27:34 2014 From: rsbultje at gmail.com (Ronald S. Bultje) Date: Mon, 4 Aug 2014 09:27:34 -0400 Subject: [FFmpeg-devel] [PATCH 3/3] x86/vp9lpf: use fewer instructions in SPLATB_MIX In-Reply-To: <1407120820-3949-3-git-send-email-jamrial@gmail.com> References: <1407120820-3949-1-git-send-email-jamrial@gmail.com> <1407120820-3949-3-git-send-email-jamrial@gmail.com> Message-ID: Hi, On Sun, Aug 3, 2014 at 10:53 PM, James Almer wrote: > Signed-off-by: James Almer > --- > libavcodec/x86/vp9lpf.asm | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/x86/vp9lpf.asm b/libavcodec/x86/vp9lpf.asm > index c5db0ca..def7d5a 100644 > --- a/libavcodec/x86/vp9lpf.asm > +++ b/libavcodec/x86/vp9lpf.asm > @@ -302,9 +302,8 @@ SECTION .text > pshufb %1, %2 > %else > punpcklbw %1, %1 > - punpcklqdq %1, %1 > - pshuflw %1, %1, 0 > - pshufhw %1, %1, 0x55 > + punpcklwd %1, %1 > + punpckldq %1, %1 Doesn't this miss the upper half of the register? Ronald From michaelni at gmx.at Mon Aug 4 17:08:21 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 17:08:21 +0200 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: rewrite [f/i]dct In-Reply-To: <20140803231437.GM4649@nb4> References: <1407097641-26789-1-git-send-email-u@pkh.me> <20140803224448.GK4649@nb4> <20140803231437.GM4649@nb4> Message-ID: <20140804150821.GV4649@nb4> On Mon, Aug 04, 2014 at 01:14:37AM +0200, Michael Niedermayer wrote: > On Mon, Aug 04, 2014 at 12:44:48AM +0200, Michael Niedermayer wrote: > > On Sun, Aug 03, 2014 at 10:27:21PM +0200, Cl?ment B?sch wrote: > > > This removes the avcodec dependency and make the code almost twice as > > > fast. More to come. > > > > > > The DCT factorization is based on "Fast and numerically stable > > > algorithms for discrete cosine transforms" from Gerlind Plonkaa & > > > Manfred Tasche (DOI: 10.1016/j.laa.2004.07.015). > > > --- > > > configure | 2 - > > > libavfilter/vf_dctdnoiz.c | 328 +++++++++++++++++++++++++++++++++------------- > > > 2 files changed, 240 insertions(+), 90 deletions(-) > > > > > > diff --git a/configure b/configure > > > index 9c3af50..6196b2a 100755 > > > --- a/configure > > > +++ b/configure > > > @@ -2526,8 +2526,6 @@ boxblur_filter_deps="gpl" > > > bs2b_filter_deps="libbs2b" > > > colormatrix_filter_deps="gpl" > > > cropdetect_filter_deps="gpl" > > > -dctdnoiz_filter_deps="avcodec" > > > -dctdnoiz_filter_select="dct" > > > delogo_filter_deps="gpl" > > > deshake_filter_deps="avcodec" > > > deshake_filter_select="me_cmp" > > > diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c > > > index 71b8536..6d24934 100644 > > > --- a/libavfilter/vf_dctdnoiz.c > > > +++ b/libavfilter/vf_dctdnoiz.c > > > @@ -1,5 +1,5 @@ > > > /* > > > - * Copyright (c) 2013 Cl?ment B?sch > > > + * Copyright (c) 2013-2014 Cl?ment B?sch > > > * > > > * This file is part of FFmpeg. > > > * > > > @@ -23,7 +23,6 @@ > > > * @see http://www.ipol.im/pub/art/2011/ys-dct/ > > > */ > > > > > > -#include "libavcodec/avfft.h" > > > #include "libavutil/eval.h" > > > #include "libavutil/opt.h" > > > #include "drawutils.h" > > > @@ -35,7 +34,7 @@ > > > static const char *const var_names[] = { "c", NULL }; > > > enum { VAR_C, VAR_VARS_NB }; > > > > > > -typedef struct { > > > +typedef struct DCTdnoizContext { > > > const AVClass *class; > > > > > > /* coefficient factor expression */ > > > @@ -52,8 +51,9 @@ typedef struct { > > > int p_linesize; // line sizes for color and weights > > > int overlap; // number of block overlapping pixels > > > int step; // block step increment (BSIZE - overlap) > > > - DCTContext *dct, *idct; // DCT and inverse DCT contexts > > > - float *block, *tmp_block; // two BSIZE x BSIZE block buffers > > > + void (*filter_freq_func)(struct DCTdnoizContext *s, > > > + const float *src, int src_linesize, > > > + float *dst, int dst_linesize); > > > } DCTdnoizContext; > > > > > > #define OFFSET(x) offsetof(DCTdnoizContext, x) > > > @@ -69,66 +69,245 @@ static const AVOption dctdnoiz_options[] = { > > > > > > AVFILTER_DEFINE_CLASS(dctdnoiz); > > > > > > -static float *dct_block(DCTdnoizContext *ctx, const float *src, int src_linesize) > > > +static void av_always_inline fdct16_1d(float *dst, const float *src, > > > + int dst_stridea, int dst_strideb, > > > + int src_stridea, int src_strideb) > > > { > > > - int x, y; > > > - float *column; > > > - > > > - for (y = 0; y < BSIZE; y++) { > > > - float *line = ctx->block; > > > + int i; > > > > > > - memcpy(line, src, BSIZE * sizeof(*line)); > > > - src += src_linesize; > > > - av_dct_calc(ctx->dct, line); > > > - > > > - column = ctx->tmp_block + y; > > > - column[0] = line[0] * (1. / sqrt(BSIZE)); > > > - column += BSIZE; > > > - for (x = 1; x < BSIZE; x++) { > > > - *column = line[x] * sqrt(2. / BSIZE); > > > - column += BSIZE; > > > - } > > > + for (i = 0; i < BSIZE; i++) { > > > + const float x0_0 = src[ 0*src_stridea] + src[15*src_stridea]; > > > + const float x0_1 = src[ 1*src_stridea] + src[14*src_stridea]; > > > + const float x0_2 = src[ 2*src_stridea] + src[13*src_stridea]; > > > + const float x0_3 = src[ 3*src_stridea] + src[12*src_stridea]; > > > + const float x0_4 = src[ 4*src_stridea] + src[11*src_stridea]; > > > + const float x0_5 = src[ 5*src_stridea] + src[10*src_stridea]; > > > + const float x0_6 = src[ 6*src_stridea] + src[ 9*src_stridea]; > > > + const float x0_7 = src[ 7*src_stridea] + src[ 8*src_stridea]; > > > + const float x0_8 = src[ 0*src_stridea] - src[15*src_stridea]; > > > + const float x0_9 = src[ 1*src_stridea] - src[14*src_stridea]; > > > + const float x0_a = src[ 2*src_stridea] - src[13*src_stridea]; > > > + const float x0_b = src[ 3*src_stridea] - src[12*src_stridea]; > > > + const float x0_c = src[ 4*src_stridea] - src[11*src_stridea]; > > > + const float x0_d = src[ 5*src_stridea] - src[10*src_stridea]; > > > + const float x0_e = src[ 6*src_stridea] - src[ 9*src_stridea]; > > > + const float x0_f = src[ 7*src_stridea] - src[ 8*src_stridea]; > > > + const float x2_0 = x0_0 + x0_7; > > > + const float x2_1 = x0_1 + x0_6; > > > + const float x2_2 = x0_2 + x0_5; > > > + const float x2_3 = x0_3 + x0_4; > > > + const float x2_4 = x0_0 - x0_7; > > > + const float x2_5 = x0_1 - x0_6; > > > + const float x2_6 = x0_2 - x0_5; > > > + const float x2_7 = x0_3 - x0_4; > > > + const float x4_0 = x2_0 + x2_3; > > > + const float x4_1 = x2_1 + x2_2; > > > + const float x4_2 = x2_0 - x2_3; > > > + const float x4_3 = x2_1 - x2_2; > > > + const float x5_0 = x4_0 + x4_1; > > > + const float x5_1 = x4_0 - x4_1; > > > + const float x5_2 = 1.306562964876380*x4_2 + 0.541196100146197*x4_3; > > > + const float x5_3 = 0.541196100146197*x4_2 - 1.306562964876380*x4_3; > > > + const float x6_0 = 1.387039845322150*x2_4 + 0.275899379282943*x2_7; > > > + const float x6_1 = 1.175875602419360*x2_5 + 0.785694958387102*x2_6; > > > + const float x6_2 = -0.785694958387102*x2_5 + 1.175875602419360*x2_6; > > > + const float x6_3 = 0.275899379282943*x2_4 - 1.387039845322150*x2_7; > > > + const float x7_0 = x6_0 + x6_1; > > > + const float x7_1 = x6_0 - x6_1; > > > + const float x7_2 = x6_2 + x6_3; > > > + const float x7_3 = x6_2 - x6_3; > > > + const float x3_5 = 0.707106781186547*x7_1 - 0.707106781186547*x7_3; > > > + const float x3_6 = 0.707106781186547*x7_1 + 0.707106781186547*x7_3; > > > + const float x8_0 = 1.407403737526380*x0_8 + 0.138617169199091*x0_f; > > > + const float x8_1 = 1.353318001174350*x0_9 + 0.410524527522357*x0_e; > > > + const float x8_2 = 1.247225012986670*x0_a + 0.666655658477747*x0_d; > > > + const float x8_3 = 1.093201867001760*x0_b + 0.897167586342636*x0_c; > > > + const float x8_4 = -0.897167586342636*x0_b + 1.093201867001760*x0_c; > > > + const float x8_5 = 0.666655658477747*x0_a - 1.247225012986670*x0_d; > > > + const float x8_6 = -0.410524527522357*x0_9 + 1.353318001174350*x0_e; > > > + const float x8_7 = 0.138617169199091*x0_8 - 1.407403737526380*x0_f; > > > + const float xa_0 = x8_0 + x8_3; > > > + const float xa_1 = x8_1 + x8_2; > > > + const float xa_2 = x8_0 - x8_3; > > > + const float xa_3 = x8_1 - x8_2; > > > + const float xb_0 = xa_0 + xa_1; > > > + const float xb_1 = xa_0 - xa_1; > > > + const float xb_2 = 1.306562964876380*xa_2 + 0.541196100146197*xa_3; > > > + const float xb_3 = 0.541196100146197*xa_2 - 1.306562964876380*xa_3; > > > + const float xc_0 = x8_4 + x8_7; > > > + const float xc_1 = x8_5 + x8_6; > > > + const float xc_2 = x8_4 - x8_7; > > > + const float xc_3 = x8_5 - x8_6; > > > + const float xd_0 = xc_0 + xc_1; > > > + const float xd_1 = xc_0 - xc_1; > > > + const float xd_2 = 1.306562964876380*xc_2 + 0.541196100146197*xc_3; > > > + const float xd_3 = 0.541196100146197*xc_2 - 1.306562964876380*xc_3; > > > + const float x1_9 = 0.707106781186547*xb_2 - 0.707106781186547*xd_3; > > > + const float x1_a = 0.707106781186547*xb_2 + 0.707106781186547*xd_3; > > > + const float x1_b = 0.707106781186547*xb_1 + 0.707106781186547*xd_1; > > > + const float x1_c = 0.707106781186547*xb_1 - 0.707106781186547*xd_1; > > > + const float x1_d = 0.707106781186547*xb_3 - 0.707106781186547*xd_2; > > > + const float x1_e = 0.707106781186547*xb_3 + 0.707106781186547*xd_2; > > > + dst[ 0*dst_stridea] = 0.25*x5_0; > > > + dst[ 1*dst_stridea] = 0.25*xb_0; > > > + dst[ 2*dst_stridea] = 0.25*x7_0; > > > + dst[ 3*dst_stridea] = 0.25*x1_9; > > > + dst[ 4*dst_stridea] = 0.25*x5_2; > > > + dst[ 5*dst_stridea] = 0.25*x1_a; > > > + dst[ 6*dst_stridea] = 0.25*x3_5; > > > + dst[ 7*dst_stridea] = 0.25*x1_b; > > > + dst[ 8*dst_stridea] = 0.25*x5_1; > > > + dst[ 9*dst_stridea] = 0.25*x1_c; > > > + dst[10*dst_stridea] = 0.25*x3_6; > > > + dst[11*dst_stridea] = 0.25*x1_d; > > > + dst[12*dst_stridea] = 0.25*x5_3; > > > + dst[13*dst_stridea] = 0.25*x1_e; > > > + dst[14*dst_stridea] = 0.25*x7_2; > > > + dst[15*dst_stridea] = 0.25*xd_0; > > > > many of these multiplies look like they can be merged into other > > multiplies > > > > for example see: > > > > > > const float xd_2 = 1.306562964876380*xc_2 + 0.541196100146197*xc_3; > > const float xb_3 = 0.541196100146197*xa_2 - 1.306562964876380*xa_3; > > const float x1_d = 0.707106781186547*xb_3 - 0.707106781186547*xd_2; > > const float x1_e = 0.707106781186547*xb_3 + 0.707106781186547*xd_2; > > dst[11*dst_stridea] = 0.25*x1_d; > > dst[13*dst_stridea] = 0.25*x1_e; > > > > vs. > > > > const float xd_2 = (0.25*0.707106781186547*1.306562964876380)*xc_2 + (0.25*0.707106781186547*0.541196100146197)*xc_3; > > const float xb_3 = (0.25*0.707106781186547*0.541196100146197)*xa_2 - (0.25*0.707106781186547*1.306562964876380)*xa_3; > > dst[11*dst_stridea] = xb_3 - xd_2; > > dst[13*dst_stridea] = xb_3 + xd_2; > > also more generally > if you have 2 stages of butterflies each with 4 multiplies and 2 adds > in each butterfly > > a----\-/--\---/----------a' > X \ / > b----/-\----------\---/--b' > / \ \ / > c----\-/--/---\----------c' > X / \ > d----/-\----------/---\--d' > > > of additions > the first stage can scale their output arbitrarily for free by > changing the respective coefficients > the second stage can use any scaled input for free by adjusting their > coefficients similarly, this gives you 4 free parameters in the > example above which can be > choosen so as to make some coefficients trivial like +-1.0 > this also works accorss 2D (I)DCTs or with other things before or > after the (i)dct which can absorb such rescaling also i suggest that the patch is applied before time is spend optimizing it further, also the moving around of multiplies can probably affect numerical stability if overdone [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws. -- Plato -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From rsbultje at gmail.com Mon Aug 4 17:17:29 2014 From: rsbultje at gmail.com (Ronald S. Bultje) Date: Mon, 4 Aug 2014 11:17:29 -0400 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: rewrite [f/i]dct In-Reply-To: <1407097641-26789-1-git-send-email-u@pkh.me> References: <1407097641-26789-1-git-send-email-u@pkh.me> Message-ID: Hi, On Sun, Aug 3, 2014 at 4:27 PM, Cl?ment B?sch wrote: > This removes the avcodec dependency and make the code almost twice as > fast. More to come. > > The DCT factorization is based on "Fast and numerically stable > algorithms for discrete cosine transforms" from Gerlind Plonkaa & > Manfred Tasche (DOI: 10.1016/j.laa.2004.07.015). I have no comments on the patch itself, but can you explain why we're re-implementing a custom f/idct rather than using the one provided in lavcodec? It seems to me that going from fixedpoint/simd'ed to float/c would be slower, not faster, so there must be more to this patch than what I'm getting from it... Ronald From u at pkh.me Mon Aug 4 17:42:12 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Mon, 4 Aug 2014 17:42:12 +0200 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: rewrite [f/i]dct In-Reply-To: References: <1407097641-26789-1-git-send-email-u@pkh.me> Message-ID: <20140804154212.GU10372@leki> On Mon, Aug 04, 2014 at 11:17:29AM -0400, Ronald S. Bultje wrote: > Hi, > > On Sun, Aug 3, 2014 at 4:27 PM, Cl?ment B?sch wrote: > > > This removes the avcodec dependency and make the code almost twice as > > fast. More to come. > > > > The DCT factorization is based on "Fast and numerically stable > > algorithms for discrete cosine transforms" from Gerlind Plonkaa & > > Manfred Tasche (DOI: 10.1016/j.laa.2004.07.015). > > > I have no comments on the patch itself, but can you explain why we're > re-implementing a custom f/idct rather than using the one provided in > lavcodec? It seems to me that going from fixedpoint/simd'ed to float/c > would be slower, not faster, so there must be more to this patch than what > I'm getting from it... > OK so as said in private, I didn't find an accurate (not wrongly "JPEG" like I originally said) 16x16 DCT in libavcodec. You suggested to use the HEVC or VP9 DCT. That's indeed one solution, but we currently have only IDCT for those (AFAIK), and I needed a float implementation. Now I also like the idea of implementing a specific [F/I]DCT for the filter and not something codec specific, where the accuracy might have been adjusted for very specific cases/environment. The algorithm I followed is supposed to be very stable numerically (and it indeed looks like so according to my tests), and still propose a nice optimized factorization form. Basically, it looked like to me like a really good trade-off between speed and ideal DCT. > Ronald -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From rsbultje at gmail.com Mon Aug 4 17:44:43 2014 From: rsbultje at gmail.com (Ronald S. Bultje) Date: Mon, 4 Aug 2014 11:44:43 -0400 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: rewrite [f/i]dct In-Reply-To: <20140804154212.GU10372@leki> References: <1407097641-26789-1-git-send-email-u@pkh.me> <20140804154212.GU10372@leki> Message-ID: Hi, On Mon, Aug 4, 2014 at 11:42 AM, Cl?ment B?sch wrote: > On Mon, Aug 04, 2014 at 11:17:29AM -0400, Ronald S. Bultje wrote: > > Hi, > > > > On Sun, Aug 3, 2014 at 4:27 PM, Cl?ment B?sch wrote: > > > > > This removes the avcodec dependency and make the code almost twice as > > > fast. More to come. > > > > > > The DCT factorization is based on "Fast and numerically stable > > > algorithms for discrete cosine transforms" from Gerlind Plonkaa & > > > Manfred Tasche (DOI: 10.1016/j.laa.2004.07.015). > > > > > > I have no comments on the patch itself, but can you explain why we're > > re-implementing a custom f/idct rather than using the one provided in > > lavcodec? It seems to me that going from fixedpoint/simd'ed to float/c > > would be slower, not faster, so there must be more to this patch than > what > > I'm getting from it... > > > > OK so as said in private, I didn't find an accurate (not wrongly "JPEG" > like I originally said) 16x16 DCT in libavcodec. > > You suggested to use the HEVC or VP9 DCT. That's indeed one solution, but > we currently have only IDCT for those (AFAIK), and I needed a float > implementation. You mean forward. idct is inverse, fdct is forward, such that idct(fdct(data[][])) =~ data[][]. You can use the forward transforms provided in libvpx (for vp9) or x265 (hevc), they're quite precise, and already optimized. Ronald From michaelni at gmx.at Mon Aug 4 17:53:37 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 17:53:37 +0200 Subject: [FFmpeg-devel] [PATCH] x86: hevc_deblock: remove unnecessary masking In-Reply-To: References: Message-ID: <20140804155337.GW4649@nb4> On Mon, Aug 04, 2014 at 12:38:28PM +0200, Christophe Gisquet wrote: > Hi, > > the attached patch is a low-hanging fruit. > > I think the code using the computed values could be improved (eg you > probably need half the GPRs to store results and you can probably > shuffle more efficiently data), but this requires more effort. > > I'm mostly submitting it because it still applies, and I can't really > spend more time on it. > > -- > Christophe > hevc_deblock.asm | 4 ---- > 1 file changed, 4 deletions(-) > 2b7b65f4d59200e87cbe4d0d1c318c4889c2e141 0008-x86-hevc_deblock-remove-unnecessary-masking.patch > From 57819727586c186bfea733a8f06eead22ac6a1f2 Mon Sep 17 00:00:00 2001 > From: Christophe Gisquet > Date: Wed, 23 Jul 2014 23:21:20 +0200 > Subject: [PATCH 08/13] x86: hevc_deblock: remove unnecessary masking > > The unpacks/shuffles later on makes it unnecessary. applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I know you won't believe me, but the highest form of Human Excellence is to question oneself and others. -- Socrates -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From u at pkh.me Mon Aug 4 17:59:22 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Mon, 4 Aug 2014 17:59:22 +0200 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: rewrite [f/i]dct In-Reply-To: References: <1407097641-26789-1-git-send-email-u@pkh.me> <20140804154212.GU10372@leki> Message-ID: <20140804155922.GV10372@leki> On Mon, Aug 04, 2014 at 11:44:43AM -0400, Ronald S. Bultje wrote: > Hi, > > On Mon, Aug 4, 2014 at 11:42 AM, Cl?ment B?sch wrote: > > > On Mon, Aug 04, 2014 at 11:17:29AM -0400, Ronald S. Bultje wrote: > > > Hi, > > > > > > On Sun, Aug 3, 2014 at 4:27 PM, Cl?ment B?sch wrote: > > > > > > > This removes the avcodec dependency and make the code almost twice as > > > > fast. More to come. > > > > > > > > The DCT factorization is based on "Fast and numerically stable > > > > algorithms for discrete cosine transforms" from Gerlind Plonkaa & > > > > Manfred Tasche (DOI: 10.1016/j.laa.2004.07.015). > > > > > > > > > I have no comments on the patch itself, but can you explain why we're > > > re-implementing a custom f/idct rather than using the one provided in > > > lavcodec? It seems to me that going from fixedpoint/simd'ed to float/c > > > would be slower, not faster, so there must be more to this patch than > > what > > > I'm getting from it... > > > > > > > OK so as said in private, I didn't find an accurate (not wrongly "JPEG" > > like I originally said) 16x16 DCT in libavcodec. > > > > You suggested to use the HEVC or VP9 DCT. That's indeed one solution, but > > we currently have only IDCT for those (AFAIK), and I needed a float > > implementation. > > > You mean forward. idct is inverse, fdct is forward, such that > idct(fdct(data[][])) =~ data[][]. Yeah sure I meant we have only the IDCT and I also needed the FDCT. The "float implementation" was another point. > You can use the forward transforms > provided in libvpx (for vp9) or x265 (hevc), they're quite precise, and > already optimized. Yeah so basically I would have to maintain that port instead of my implementation, which doesn't look ideal either (the point of using an existing code in FFmpeg is that its maintenance would have been shared). Also, in order to use them, it would make sense to port the whole filter to fixed point. And unfortunately between the IDCT-average part and the DCT 3x3 for color [de]correlation, I wasn't really confident to do that regarding the accuracy (which you definitely wants for a non real-time denoiser) > > Ronald -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From rsbultje at gmail.com Mon Aug 4 18:09:12 2014 From: rsbultje at gmail.com (Ronald S. Bultje) Date: Mon, 4 Aug 2014 12:09:12 -0400 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: rewrite [f/i]dct In-Reply-To: <20140804155922.GV10372@leki> References: <1407097641-26789-1-git-send-email-u@pkh.me> <20140804154212.GU10372@leki> <20140804155922.GV10372@leki> Message-ID: Hi, On Mon, Aug 4, 2014 at 11:59 AM, Cl?ment B?sch wrote: > On Mon, Aug 04, 2014 at 11:44:43AM -0400, Ronald S. Bultje wrote: > > Hi, > > > > On Mon, Aug 4, 2014 at 11:42 AM, Cl?ment B?sch wrote: > > > > > On Mon, Aug 04, 2014 at 11:17:29AM -0400, Ronald S. Bultje wrote: > > > > Hi, > > > > > > > > On Sun, Aug 3, 2014 at 4:27 PM, Cl?ment B?sch wrote: > > > > > > > > > This removes the avcodec dependency and make the code almost twice > as > > > > > fast. More to come. > > > > > > > > > > The DCT factorization is based on "Fast and numerically stable > > > > > algorithms for discrete cosine transforms" from Gerlind Plonkaa & > > > > > Manfred Tasche (DOI: 10.1016/j.laa.2004.07.015). > > > > > > > > > > > > I have no comments on the patch itself, but can you explain why we're > > > > re-implementing a custom f/idct rather than using the one provided in > > > > lavcodec? It seems to me that going from fixedpoint/simd'ed to > float/c > > > > would be slower, not faster, so there must be more to this patch than > > > what > > > > I'm getting from it... > > > > > > > > > > OK so as said in private, I didn't find an accurate (not wrongly "JPEG" > > > like I originally said) 16x16 DCT in libavcodec. > > > > > > You suggested to use the HEVC or VP9 DCT. That's indeed one solution, > but > > > we currently have only IDCT for those (AFAIK), and I needed a float > > > implementation. > > > > > > You mean forward. idct is inverse, fdct is forward, such that > > idct(fdct(data[][])) =~ data[][]. > > Yeah sure I meant we have only the IDCT and I also needed the FDCT. The > "float implementation" was another point. > > > You can use the forward transforms > > provided in libvpx (for vp9) or x265 (hevc), they're quite precise, and > > already optimized. > > Yeah so basically I would have to maintain that port instead of my > implementation, which doesn't look ideal either (the point of using an > existing code in FFmpeg is that its maintenance would have been shared). Right, but it means one half (idct) is fully shared, with optimizations etc. - and only one half is unshared-but-forked-with-optimizations. Whereas right now, it's fully unshared and unoptimized... I agree the 3x3 makes it a little more tricky, so do whatever you feel is right; we don't want to have to convert datatypes 4x just so we can fit an integer fdct/idct pair between an otherwise full float chain. If the overall ultimate goal is for everything to be int, it makes sense, but I don't know what the plan is. Ronald From jamrial at gmail.com Mon Aug 4 18:17:28 2014 From: jamrial at gmail.com (James Almer) Date: Mon, 04 Aug 2014 13:17:28 -0300 Subject: [FFmpeg-devel] [PATCH 3/3] x86/vp9lpf: use fewer instructions in SPLATB_MIX In-Reply-To: References: <1407120820-3949-1-git-send-email-jamrial@gmail.com> <1407120820-3949-3-git-send-email-jamrial@gmail.com> Message-ID: <53DFB218.8060307@gmail.com> On 04/08/14 10:27 AM, Ronald S. Bultje wrote: > Hi, > > > On Sun, Aug 3, 2014 at 10:53 PM, James Almer wrote: > >> Signed-off-by: James Almer >> --- >> libavcodec/x86/vp9lpf.asm | 5 ++--- >> 1 file changed, 2 insertions(+), 3 deletions(-) >> >> diff --git a/libavcodec/x86/vp9lpf.asm b/libavcodec/x86/vp9lpf.asm >> index c5db0ca..def7d5a 100644 >> --- a/libavcodec/x86/vp9lpf.asm >> +++ b/libavcodec/x86/vp9lpf.asm >> @@ -302,9 +302,8 @@ SECTION .text >> pshufb %1, %2 >> %else >> punpcklbw %1, %1 >> - punpcklqdq %1, %1 >> - pshuflw %1, %1, 0 >> - pshufhw %1, %1, 0x55 >> + punpcklwd %1, %1 >> + punpckldq %1, %1 > > > Doesn't this miss the upper half of the register? > > Ronald Using the example above the macro ..............AB (start value) punpcklbw ............AABB punpcklwd ........AAAABBBB punpckldq AAAAAAAABBBBBBBB From vittorio.giovara at gmail.com Sun Aug 3 21:30:06 2014 From: vittorio.giovara at gmail.com (Vittorio Giovara) Date: Sun, 3 Aug 2014 20:30:06 +0100 Subject: [FFmpeg-devel] [libav-devel] [PATCHv3] Deprecate AFD field and add AFD as side-data In-Reply-To: <1407090297-5537-1-git-send-email-kierank@obe.tv> References: <1407090297-5537-1-git-send-email-kierank@obe.tv> Message-ID: On Sun, Aug 3, 2014 at 7:24 PM, Kieran Kunhya wrote: > --- > doc/APIchanges | 4 ++++ > libavcodec/avcodec.h | 5 ++++- > libavcodec/mpeg12dec.c | 20 +++++++++++++++++++- > libavcodec/version.h | 5 ++++- > libavfilter/vf_showinfo.c | 3 +++ > libavutil/frame.h | 16 ++++++++++++++++ > libavutil/version.h | 2 +- > 7 files changed, 51 insertions(+), 4 deletions(-) > Looks good, I'll amend a few k&r before pushing, thanks! -- Vittorio From michaelni at gmx.at Mon Aug 4 18:23:31 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 4 Aug 2014 18:23:31 +0200 Subject: [FFmpeg-devel] [PATCH] avformat/util: change av_find_default_stream_index() to use a score based system In-Reply-To: <1406924965-2288-1-git-send-email-michaelni@gmx.at> References: <1406924965-2288-1-git-send-email-michaelni@gmx.at> Message-ID: <20140804162331.GY4649@nb4> On Fri, Aug 01, 2014 at 10:29:25PM +0200, Michael Niedermayer wrote: > Disfavor video streams with unknown resolution and no packets > Fixes seeking in audio-only-speex.flv > > Signed-off-by: Michael Niedermayer > --- > libavformat/utils.c | 20 ++++++++++++++------ > 1 file changed, 14 insertions(+), 6 deletions(-) applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The worst form of inequality is to try to make unequal things equal. -- Aristotle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From nfxjfg at googlemail.com Mon Aug 4 18:26:02 2014 From: nfxjfg at googlemail.com (wm4) Date: Mon, 4 Aug 2014 18:26:02 +0200 Subject: [FFmpeg-devel] [PATCH 2/5] lavfi/buffersrc: add add av_buffersrc_close(). In-Reply-To: <1407071740-23116-2-git-send-email-george@nsup.org> References: <1407071740-23116-1-git-send-email-george@nsup.org> <1407071740-23116-2-git-send-email-george@nsup.org> Message-ID: <20140804182602.44a391c3@debian> On Sun, 3 Aug 2014 15:15:37 +0200 Nicolas George wrote: > diff --git a/libavfilter/buffersrc.h b/libavfilter/buffersrc.h > index ea34c04..28ca545 100644 > --- a/libavfilter/buffersrc.h > +++ b/libavfilter/buffersrc.h > @@ -145,6 +145,8 @@ int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame); > * > * @param buffer_src pointer to a buffer source context > * @param frame a frame, or NULL to mark EOF > + * (Using NULL to mark EOF is deprecated, use > + * av_buffersrc_close() instead.) > * @param flags a combination of AV_BUFFERSRC_FLAG_* > * @return >= 0 in case of success, a negative AVERROR code > * in case of failure Please make clear that even though it's "deprecated", these semantics won't ever get removed from the API. From rsbultje at gmail.com Mon Aug 4 18:20:37 2014 From: rsbultje at gmail.com (Ronald S. Bultje) Date: Mon, 4 Aug 2014 12:20:37 -0400 Subject: [FFmpeg-devel] [PATCH 3/3] x86/vp9lpf: use fewer instructions in SPLATB_MIX In-Reply-To: <53DFB218.8060307@gmail.com> References: <1407120820-3949-1-git-send-email-jamrial@gmail.com> <1407120820-3949-3-git-send-email-jamrial@gmail.com> <53DFB218.8060307@gmail.com> Message-ID: Hi, On Mon, Aug 4, 2014 at 12:17 PM, James Almer wrote: > On 04/08/14 10:27 AM, Ronald S. Bultje wrote: > > Hi, > > > > > > On Sun, Aug 3, 2014 at 10:53 PM, James Almer wrote: > > > >> Signed-off-by: James Almer > >> --- > >> libavcodec/x86/vp9lpf.asm | 5 ++--- > >> 1 file changed, 2 insertions(+), 3 deletions(-) > >> > >> diff --git a/libavcodec/x86/vp9lpf.asm b/libavcodec/x86/vp9lpf.asm > >> index c5db0ca..def7d5a 100644 > >> --- a/libavcodec/x86/vp9lpf.asm > >> +++ b/libavcodec/x86/vp9lpf.asm > >> @@ -302,9 +302,8 @@ SECTION .text > >> pshufb %1, %2 > >> %else > >> punpcklbw %1, %1 > >> - punpcklqdq %1, %1 > >> - pshuflw %1, %1, 0 > >> - pshufhw %1, %1, 0x55 > >> + punpcklwd %1, %1 > >> + punpckldq %1, %1 > > > > > > Doesn't this miss the upper half of the register? > > > > Ronald > > Using the example above the macro > > ..............AB (start value) > punpcklbw > ............AABB > punpcklwd > ........AAAABBBB > punpckldq > AAAAAAAABBBBBBBB Oh I see not a byte-splat, my bad, sorry please ignore my comment. Ronald From christophe.gisquet at gmail.com Mon Aug 4 18:46:17 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Mon, 4 Aug 2014 18:46:17 +0200 Subject: [FFmpeg-devel] [PATCH 3/4] hevcdsp: remove more instances of compile-time-fixed parameters In-Reply-To: <1406567848-6368-4-git-send-email-christophe.gisquet@gmail.com> References: <1406567848-6368-1-git-send-email-christophe.gisquet@gmail.com> <1406567848-6368-4-git-send-email-christophe.gisquet@gmail.com> Message-ID: 2014-07-28 19:17 GMT+02:00 Christophe Gisquet : > --- > libavcodec/hevc.c | 8 +++---- > libavcodec/hevcdsp.h | 8 +++---- > libavcodec/hevcdsp_template.c | 56 +++++++++++++++++++++---------------------- > libavcodec/x86/hevc_mc.asm | 18 +++++++------- > libavcodec/x86/hevcdsp.h | 6 ++--- > libavcodec/x86/hevcdsp_init.c | 12 +++++----- > 6 files changed, 54 insertions(+), 54 deletions(-) Update patch with a warning fixed and cleaned an asm macro. -- Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: 0003-hevcdsp-remove-more-instances-of-compile-time-fixed-.patch Type: text/x-patch Size: 32759 bytes Desc: not available URL: From u at pkh.me Mon Aug 4 19:03:07 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Mon, 4 Aug 2014 19:03:07 +0200 Subject: [FFmpeg-devel] [PATCH 3/3] x86/vp9lpf: use fewer instructions in SPLATB_MIX In-Reply-To: <1407120820-3949-3-git-send-email-jamrial@gmail.com> References: <1407120820-3949-1-git-send-email-jamrial@gmail.com> <1407120820-3949-3-git-send-email-jamrial@gmail.com> Message-ID: <20140804170307.GW10372@leki> On Sun, Aug 03, 2014 at 11:53:40PM -0300, James Almer wrote: > Signed-off-by: James Almer > --- > libavcodec/x86/vp9lpf.asm | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/x86/vp9lpf.asm b/libavcodec/x86/vp9lpf.asm > index c5db0ca..def7d5a 100644 > --- a/libavcodec/x86/vp9lpf.asm > +++ b/libavcodec/x86/vp9lpf.asm > @@ -302,9 +302,8 @@ SECTION .text > pshufb %1, %2 > %else > punpcklbw %1, %1 > - punpcklqdq %1, %1 > - pshuflw %1, %1, 0 > - pshufhw %1, %1, 0x55 > + punpcklwd %1, %1 > + punpckldq %1, %1 IIRC I based this on what I found in x86util.asm:SPLATW; would that apply there as well? -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From jamrial at gmail.com Mon Aug 4 19:35:14 2014 From: jamrial at gmail.com (James Almer) Date: Mon, 04 Aug 2014 14:35:14 -0300 Subject: [FFmpeg-devel] [PATCH 3/3] x86/vp9lpf: use fewer instructions in SPLATB_MIX In-Reply-To: <20140804170307.GW10372@leki> References: <1407120820-3949-1-git-send-email-jamrial@gmail.com> <1407120820-3949-3-git-send-email-jamrial@gmail.com> <20140804170307.GW10372@leki> Message-ID: <53DFC452.4080704@gmail.com> On 04/08/14 2:03 PM, Cl?ment B?sch wrote: > On Sun, Aug 03, 2014 at 11:53:40PM -0300, James Almer wrote: >> Signed-off-by: James Almer >> --- >> libavcodec/x86/vp9lpf.asm | 5 ++--- >> 1 file changed, 2 insertions(+), 3 deletions(-) >> >> diff --git a/libavcodec/x86/vp9lpf.asm b/libavcodec/x86/vp9lpf.asm >> index c5db0ca..def7d5a 100644 >> --- a/libavcodec/x86/vp9lpf.asm >> +++ b/libavcodec/x86/vp9lpf.asm >> @@ -302,9 +302,8 @@ SECTION .text >> pshufb %1, %2 >> %else >> punpcklbw %1, %1 >> - punpcklqdq %1, %1 >> - pshuflw %1, %1, 0 >> - pshufhw %1, %1, 0x55 >> + punpcklwd %1, %1 >> + punpckldq %1, %1 > > IIRC I based this on what I found in x86util.asm:SPLATW; would that apply > there as well? No, SPLATW splats a word to the entire register whereas this splats one byte to the lower half of the register and another to the upper half. The code above turns AB into AAAAAAAABBBBBBBB while SPLATW (with implied 0 as third argument) should output ABABABABABABABAB. From gisle at snirklasjon.no Mon Aug 4 19:58:52 2014 From: gisle at snirklasjon.no (=?ISO-8859-1?Q?Gisle_S=E6lensminde?=) Date: Mon, 04 Aug 2014 19:58:52 +0200 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support Message-ID: <53DFC9DC.1050207@snirklasjon.no> I'm trying to add support for closed captions in ffmpeg, namely cea608 and cea708. Unlike normal subtitles, these are embedded in the video frames themselves rather than a separate track or file. As a first step I try to write bitstreams filters for extraction and inserting closed captions into h.264 and mpeg2 videos. For cea608, I use .scc files to represent the cea608 data. Later an interpreter and producer of scc files can be made as a subtitle codec. I have already written a cea 608 tools for my employer, but that is in python, so not suitable for inclusion in ffmpeg, so this will be a new implementation. I'm currently writing the extraction filter and I had hoped that I could use it as a filter with parameters as follows. ffmpeg -i vid_with_cc.ts -acodec copy -vcodec copy -bsf cea680_extract?scc=out.scc -f null /dev/null This is not possible, since bitstream filters don't have parameters. The main problems can be summarized as follows: - The lack of parameters means that I don't have a way to specify where to store the .scc file. How can I do that? - I can't find a way to get out the timestamps (pts and dts) in a bitstream filter. The cea 608 and 708 data is stored in pts order in the frames, so I need to reorder the data before writing them to file. Also, the scc files have timestamps, so I need timestamps for that too. I can only find the timebase in AVCodecContext, and the AVFormatContext or AVPacket is not passed in to the bitstream filter. The AVPacket is a deprecated field, but it is NULL, so of no use. Is there something I have overlooked here? I may be missing something, and it is of cause possible that the bitstream filter approch is misguided, but as far as I can tell, that is the best option. Does anyone have a clear idea of how this should be done? -Gisle From h.leppkes at gmail.com Mon Aug 4 20:19:38 2014 From: h.leppkes at gmail.com (Hendrik Leppkes) Date: Mon, 4 Aug 2014 20:19:38 +0200 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: <53DFC9DC.1050207@snirklasjon.no> References: <53DFC9DC.1050207@snirklasjon.no> Message-ID: Am 04.08.2014 19:59 schrieb "Gisle S?lensminde" : > > I'm trying to add support for closed captions in ffmpeg, namely cea608 and > cea708. Unlike normal subtitles, these are embedded in the video frames > themselves rather than a separate track or file. As a first step I try to write > bitstreams filters for extraction and inserting closed captions into h.264 and > mpeg2 videos. For cea608, I use .scc files to represent the cea608 data. > Later an interpreter and producer of scc files can be made as a subtitle > codec. > > I have already written a cea 608 tools for my employer, but that is in > python, so not suitable for inclusion in ffmpeg, so this will be a > new implementation. > > I'm currently writing the extraction filter and I had hoped that I could use > it as a filter with parameters as follows. > > ffmpeg -i vid_with_cc.ts -acodec copy -vcodec copy -bsf cea680_extract?scc=out.scc -f null /dev/null > > This is not possible, since bitstream filters don't have parameters. The main > problems can be summarized as follows: > > - The lack of parameters means that I don't have a way to specify where to store > the .scc file. How can I do that? > > - I can't find a way to get out the timestamps (pts and dts) in a bitstream > filter. The cea 608 and 708 data is stored in pts order in the frames, so > I need to reorder the data before writing them to file. Also, the scc files > have timestamps, so I need timestamps for that too. I can only find the > timebase in AVCodecContext, and the AVFormatContext or AVPacket is not passed > in to the bitstream filter. The AVPacket is a deprecated field, but it is > NULL, so of no use. Is there something I have overlooked here? > > I may be missing something, and it is of cause possible that the bitstream filter > approch is misguided, but as far as I can tell, that is the best option. Does anyone > have a clear idea of how this should be done? > > -Gisle > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel Its probably a better idea to export the CC data during video decoding as side data, like the mpeg2 decoder already does today. That way you get it reordered and with timestamps, but of course it means you need to perform decoding. I have a patch flying around for h264 that does this. I could send it soon. - Hendrik From Reimar.Doeffinger at gmx.de Mon Aug 4 20:47:37 2014 From: Reimar.Doeffinger at gmx.de (Reimar =?iso-8859-1?Q?D=F6ffinger?=) Date: Mon, 4 Aug 2014 20:47:37 +0200 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: References: <53DFC9DC.1050207@snirklasjon.no> Message-ID: <20140804184737.GB13487@reimardoeffinger.de> On Mon, Aug 04, 2014 at 08:19:38PM +0200, Hendrik Leppkes wrote: > Am 04.08.2014 19:59 schrieb "Gisle S?lensminde" : > > > > I'm trying to add support for closed captions in ffmpeg, namely cea608 and > > cea708. Unlike normal subtitles, these are embedded in the video frames > > themselves rather than a separate track or file. As a first step I try to > write > > bitstreams filters for extraction and inserting closed captions into > h.264 and > > mpeg2 videos. For cea608, I use .scc files to represent the cea608 data. > > Later an interpreter and producer of scc files can be made as a subtitle > > codec. > > > > I have already written a cea 608 tools for my employer, but that is in > > python, so not suitable for inclusion in ffmpeg, so this will be a > > new implementation. > > > > I'm currently writing the extraction filter and I had hoped that I could > use > > it as a filter with parameters as follows. > > > > ffmpeg -i vid_with_cc.ts -acodec copy -vcodec copy -bsf > cea680_extract?scc=out.scc -f null /dev/null > > > > This is not possible, since bitstream filters don't have parameters. The > main > > problems can be summarized as follows: > > > > - The lack of parameters means that I don't have a way to specify where > to store > > the .scc file. How can I do that? > > > > - I can't find a way to get out the timestamps (pts and dts) in a > bitstream > > filter. The cea 608 and 708 data is stored in pts order in the frames, > so > > I need to reorder the data before writing them to file. Also, the scc > files > > have timestamps, so I need timestamps for that too. I can only find the > > timebase in AVCodecContext, and the AVFormatContext or AVPacket is not > passed > > in to the bitstream filter. The AVPacket is a deprecated field, but it > is > > NULL, so of no use. Is there something I have overlooked here? > > > > I may be missing something, and it is of cause possible that the > bitstream filter > > approch is misguided, but as far as I can tell, that is the best option. > Does anyone > > have a clear idea of how this should be done? > > > Its probably a better idea to export the CC data during video decoding as > side data, like the mpeg2 decoder already does today. That way you get it > reordered and with timestamps, but of course it means you need to perform > decoding. It's also fairly silly, since it means you have to decode the video just to get the subtitle stream! And as far as I can tell if you want to remux but with separate subtitle stream that would even mean that you have to re-encode the video for no good reason. A _good_ (but complex/quite some effort) solution would be for the AVParser to extract it (optionally even removing it from the video frames?) and create a proper subtitle stream. From nfxjfg at googlemail.com Mon Aug 4 20:51:57 2014 From: nfxjfg at googlemail.com (wm4) Date: Mon, 4 Aug 2014 20:51:57 +0200 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: <20140804184737.GB13487@reimardoeffinger.de> References: <53DFC9DC.1050207@snirklasjon.no> <20140804184737.GB13487@reimardoeffinger.de> Message-ID: <20140804205157.655ee474@debian> On Mon, 4 Aug 2014 20:47:37 +0200 Reimar D?ffinger wrote: > On Mon, Aug 04, 2014 at 08:19:38PM +0200, Hendrik Leppkes wrote: > > Am 04.08.2014 19:59 schrieb "Gisle S?lensminde" : > > > > > > I'm trying to add support for closed captions in ffmpeg, namely cea608 and > > > cea708. Unlike normal subtitles, these are embedded in the video frames > > > themselves rather than a separate track or file. As a first step I try to > > write > > > bitstreams filters for extraction and inserting closed captions into > > h.264 and > > > mpeg2 videos. For cea608, I use .scc files to represent the cea608 data. > > > Later an interpreter and producer of scc files can be made as a subtitle > > > codec. > > > > > > I have already written a cea 608 tools for my employer, but that is in > > > python, so not suitable for inclusion in ffmpeg, so this will be a > > > new implementation. > > > > > > I'm currently writing the extraction filter and I had hoped that I could > > use > > > it as a filter with parameters as follows. > > > > > > ffmpeg -i vid_with_cc.ts -acodec copy -vcodec copy -bsf > > cea680_extract?scc=out.scc -f null /dev/null > > > > > > This is not possible, since bitstream filters don't have parameters. The > > main > > > problems can be summarized as follows: > > > > > > - The lack of parameters means that I don't have a way to specify where > > to store > > > the .scc file. How can I do that? > > > > > > - I can't find a way to get out the timestamps (pts and dts) in a > > bitstream > > > filter. The cea 608 and 708 data is stored in pts order in the frames, > > so > > > I need to reorder the data before writing them to file. Also, the scc > > files > > > have timestamps, so I need timestamps for that too. I can only find the > > > timebase in AVCodecContext, and the AVFormatContext or AVPacket is not > > passed > > > in to the bitstream filter. The AVPacket is a deprecated field, but it > > is > > > NULL, so of no use. Is there something I have overlooked here? > > > > > > I may be missing something, and it is of cause possible that the > > bitstream filter > > > approch is misguided, but as far as I can tell, that is the best option. > > Does anyone > > > have a clear idea of how this should be done? > > > > > Its probably a better idea to export the CC data during video decoding as > > side data, like the mpeg2 decoder already does today. That way you get it > > reordered and with timestamps, but of course it means you need to perform > > decoding. > > It's also fairly silly, since it means you have to decode the video just > to get the subtitle stream! And as far as I can tell if you want to remux > but with separate subtitle stream that would even mean that you have to > re-encode the video for no good reason. > A _good_ (but complex/quite some effort) solution would be for the > AVParser to extract it (optionally even removing it from the video frames?) > and create a proper subtitle stream. Isn't the problem with this that CC data needs to be reordered like the video frames? That's AFAIK why it was made video frame side-data, instead of extracting it with a parser. From kierank at obe.tv Mon Aug 4 21:04:39 2014 From: kierank at obe.tv (Kieran Kunhya) Date: Mon, 4 Aug 2014 20:04:39 +0100 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: <20140804184737.GB13487@reimardoeffinger.de> References: <53DFC9DC.1050207@snirklasjon.no> <20140804184737.GB13487@reimardoeffinger.de> Message-ID: > And as far as I can tell if you want to remux > but with separate subtitle stream that would even mean that you have to > re-encode the video for no good reason. You can just swap out the caption data. It's guaranteed to be CBR anyway. From Reimar.Doeffinger at gmx.de Mon Aug 4 21:11:02 2014 From: Reimar.Doeffinger at gmx.de (Reimar =?iso-8859-1?Q?D=F6ffinger?=) Date: Mon, 4 Aug 2014 21:11:02 +0200 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: References: <53DFC9DC.1050207@snirklasjon.no> <20140804184737.GB13487@reimardoeffinger.de> Message-ID: <20140804191102.GA18638@reimardoeffinger.de> On Mon, Aug 04, 2014 at 08:04:39PM +0100, Kieran Kunhya wrote: > > And as far as I can tell if you want to remux > > but with separate subtitle stream that would even mean that you have to > > re-encode the video for no good reason. > > You can just swap out the caption data. It's guaranteed to be CBR anyway. Uh, no. The point is to get the CC data out you need to decode. Now that you have the video decoded, if you want to mux it you have to encode it again. Though maybe it's possible to somehow use the same input stream twice as input in FFmpeg and copy it once (for muxing) and decode it once (to get the CC data). From bernd.kuhls at t-online.de Mon Aug 4 21:12:29 2014 From: bernd.kuhls at t-online.de (Bernd Kuhls) Date: Mon, 4 Aug 2014 21:12:29 +0200 Subject: [FFmpeg-devel] [PATCH 1/1] Fix compile error on bfin. Message-ID: <1407179549-18101-1-git-send-email-bernd.kuhls@t-online.de> After the removal of all Blackfin architecture optimizations in http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b55d3bbeed375f7b74442c4dd274d116a3e3d2e1 some includes were left behind leading to a compile error: CC libavformat/adtsenc.o In file included from ./libavcodec/get_bits.h:35, from ./libavcodec/ac3_parser.h:27, from libavformat/ac3dec.c:23: ./libavcodec/mathops.h:43:29: error: bfin/mathops.h: No such file or directory This compile error was found by buildroot autobuild system: http://autobuild.buildroot.net/results/ae0/ae056f267e907091d09d2a1546d6f1ae02fa23b9/ Signed-off-by: Bernd Kuhls --- libavcodec/mathops.h | 2 -- libavutil/bswap.h | 2 -- libavutil/timer.h | 2 -- 3 files changed, 6 deletions(-) diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index b0e48d8..87fca0c 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -39,8 +39,6 @@ extern const uint8_t ff_zigzag_direct[64]; # include "arm/mathops.h" #elif ARCH_AVR32 # include "avr32/mathops.h" -#elif ARCH_BFIN -# include "bfin/mathops.h" #elif ARCH_MIPS # include "mips/mathops.h" #elif ARCH_PPC diff --git a/libavutil/bswap.h b/libavutil/bswap.h index f38e1de..91cb795 100644 --- a/libavutil/bswap.h +++ b/libavutil/bswap.h @@ -40,8 +40,6 @@ # include "arm/bswap.h" #elif ARCH_AVR32 # include "avr32/bswap.h" -#elif ARCH_BFIN -# include "bfin/bswap.h" #elif ARCH_SH4 # include "sh4/bswap.h" #elif ARCH_X86 diff --git a/libavutil/timer.h b/libavutil/timer.h index 3fff77f..13a3c8c 100644 --- a/libavutil/timer.h +++ b/libavutil/timer.h @@ -40,8 +40,6 @@ #if ARCH_ARM # include "arm/timer.h" -#elif ARCH_BFIN -# include "bfin/timer.h" #elif ARCH_PPC # include "ppc/timer.h" #elif ARCH_X86 -- 1.7.10.4 From Reimar.Doeffinger at gmx.de Mon Aug 4 21:12:39 2014 From: Reimar.Doeffinger at gmx.de (Reimar =?iso-8859-1?Q?D=F6ffinger?=) Date: Mon, 4 Aug 2014 21:12:39 +0200 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: <20140804205157.655ee474@debian> References: <53DFC9DC.1050207@snirklasjon.no> <20140804184737.GB13487@reimardoeffinger.de> <20140804205157.655ee474@debian> Message-ID: <20140804191239.GB18638@reimardoeffinger.de> On Mon, Aug 04, 2014 at 08:51:57PM +0200, wm4 wrote: > On Mon, 4 Aug 2014 20:47:37 +0200 > Reimar D?ffinger wrote: > > > On Mon, Aug 04, 2014 at 08:19:38PM +0200, Hendrik Leppkes wrote: > > > Am 04.08.2014 19:59 schrieb "Gisle S?lensminde" : > > > > > > > > I'm trying to add support for closed captions in ffmpeg, namely cea608 and > > > > cea708. Unlike normal subtitles, these are embedded in the video frames > > > > themselves rather than a separate track or file. As a first step I try to > > > write > > > > bitstreams filters for extraction and inserting closed captions into > > > h.264 and > > > > mpeg2 videos. For cea608, I use .scc files to represent the cea608 data. > > > > Later an interpreter and producer of scc files can be made as a subtitle > > > > codec. > > > > > > > > I have already written a cea 608 tools for my employer, but that is in > > > > python, so not suitable for inclusion in ffmpeg, so this will be a > > > > new implementation. > > > > > > > > I'm currently writing the extraction filter and I had hoped that I could > > > use > > > > it as a filter with parameters as follows. > > > > > > > > ffmpeg -i vid_with_cc.ts -acodec copy -vcodec copy -bsf > > > cea680_extract?scc=out.scc -f null /dev/null > > > > > > > > This is not possible, since bitstream filters don't have parameters. The > > > main > > > > problems can be summarized as follows: > > > > > > > > - The lack of parameters means that I don't have a way to specify where > > > to store > > > > the .scc file. How can I do that? > > > > > > > > - I can't find a way to get out the timestamps (pts and dts) in a > > > bitstream > > > > filter. The cea 608 and 708 data is stored in pts order in the frames, > > > so > > > > I need to reorder the data before writing them to file. Also, the scc > > > files > > > > have timestamps, so I need timestamps for that too. I can only find the > > > > timebase in AVCodecContext, and the AVFormatContext or AVPacket is not > > > passed > > > > in to the bitstream filter. The AVPacket is a deprecated field, but it > > > is > > > > NULL, so of no use. Is there something I have overlooked here? > > > > > > > > I may be missing something, and it is of cause possible that the > > > bitstream filter > > > > approch is misguided, but as far as I can tell, that is the best option. > > > Does anyone > > > > have a clear idea of how this should be done? > > > > > > > Its probably a better idea to export the CC data during video decoding as > > > side data, like the mpeg2 decoder already does today. That way you get it > > > reordered and with timestamps, but of course it means you need to perform > > > decoding. > > > > It's also fairly silly, since it means you have to decode the video just > > to get the subtitle stream! And as far as I can tell if you want to remux > > but with separate subtitle stream that would even mean that you have to > > re-encode the video for no good reason. > > A _good_ (but complex/quite some effort) solution would be for the > > AVParser to extract it (optionally even removing it from the video frames?) > > and create a proper subtitle stream. > > Isn't the problem with this that CC data needs to be reordered like the > video frames? That's AFAIK why it was made video frame side-data, > instead of extracting it with a parser. Yes, that's one of the things that make it complex to implement. But the parser certainly has all the information to do the reordering. It still is the only proper solution, its simplicity is the only thing that makes the current hack acceptable. And I can't see how it could be called anything but a hack. From kierank at obe.tv Mon Aug 4 21:18:11 2014 From: kierank at obe.tv (Kieran Kunhya) Date: Mon, 4 Aug 2014 20:18:11 +0100 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: <20140804191102.GA18638@reimardoeffinger.de> References: <53DFC9DC.1050207@snirklasjon.no> <20140804184737.GB13487@reimardoeffinger.de> <20140804191102.GA18638@reimardoeffinger.de> Message-ID: > Uh, no. > The point is to get the CC data out you need to decode. > Now that you have the video decoded, if you want to mux it you have > to encode it again. Whether you decode the video or not is unrelated to your ability to replace the SEI and replace the captions. You'd still need to know the reordering though. Unless you are talking about mov which is the only container that has a special closed captions stream. > Yes, that's one of the things that make it complex to implement. > But the parser certainly has all the information to do the reordering. It would have to do some low-level parsing to handle complex b-frame patterns. VLC uses a guessed B-frame pattern and as a result is not frame accurate. From bernd.kuhls at t-online.de Mon Aug 4 21:25:12 2014 From: bernd.kuhls at t-online.de (Bernd Kuhls) Date: Mon, 04 Aug 2014 21:25:12 +0200 Subject: [FFmpeg-devel] [PATCH 1/2] avutil/libm: Replace macro based fminf() by function References: <1402065736-24164-1-git-send-email-michaelni@gmx.at> Message-ID: Michael Niedermayer wrote in news:1402065736-24164-1-git- send-email-michaelni at gmx.at: > libavutil/libm.h | 5 ++++- Hi, the current code in libm.h breaks compilation when the libc does not provide fminf, which is the case for uClibc. Here you will find a patch fixing the problem for me, although the problem should maybe be fixed in a different way: http://git.buildroot.net/buildroot/tree/package/ffmpeg/ffmpeg-0001- fminf.patch For background discussion please look here: http://thread.gmane.org/gmane.comp.lib.uclibc.buildroot/90973/focus=90994 Regards, Bernd From gisle at snirklasjon.no Mon Aug 4 21:35:02 2014 From: gisle at snirklasjon.no (=?ISO-8859-1?Q?Gisle_S=E6lensminde?=) Date: Mon, 04 Aug 2014 21:35:02 +0200 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: <20140804191102.GA18638@reimardoeffinger.de> References: <53DFC9DC.1050207@snirklasjon.no> <20140804184737.GB13487@reimardoeffinger.de> <20140804191102.GA18638@reimardoeffinger.de> Message-ID: <53DFE066.2050602@snirklasjon.no> Den 04. aug. 2014 21:11, skrev Reimar D?ffinger: > On Mon, Aug 04, 2014 at 08:04:39PM +0100, Kieran Kunhya wrote: >>> And as far as I can tell if you want to remux >>> but with separate subtitle stream that would even mean that you have to >>> re-encode the video for no good reason. >> You can just swap out the caption data. It's guaranteed to be CBR anyway. > Uh, no. > The point is to get the CC data out you need to decode. > Now that you have the video decoded, if you want to mux it you have > to encode it again. > Though maybe it's possible to somehow use the same input stream twice as > input in FFmpeg and copy it once (for muxing) and decode it once (to get > the CC data). My current work in progress uses a bitstream filter and implements a partial parser for h.264 and mpeg2 frames. This is not all that much code, since most of the datastructures can be ignored. It also havce the advantage that the closed caption stuff can be kept in a separate module, and not mixed into the decoders. The decoder approch would also not work for insertion of closed captions (for h.264 that would be x264, and I can't see that CC has a place there really). I'm uncertain enough that I would prefere to here the opinion here before submitting a patch. As far as I can see it now: Bitstream filter: Pro: - Modular, the CC code can be kept separate. - Less complex code Cons: Need for features that I can't see is present in the bitstream filters: - As far as I can see -no support for timestamps (PTS), required for reordering and timestams in the output file - No support for arguments to bitstream filters (unlike audio and video filters) Decoder: Pro: - Parser already present. Easy to insert extraction code on the right spots Cons: - Less modular, CC code mixed with decoding code. - Does not easily extend to encoders/insertion. - Parameters (for input files)? > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From nfxjfg at googlemail.com Mon Aug 4 21:39:55 2014 From: nfxjfg at googlemail.com (wm4) Date: Mon, 4 Aug 2014 21:39:55 +0200 Subject: [FFmpeg-devel] [PATCH 1/2] avutil/libm: Replace macro based fminf() by function In-Reply-To: References: <1402065736-24164-1-git-send-email-michaelni@gmx.at> Message-ID: <20140804213955.42443190@debian> On Mon, 04 Aug 2014 21:25:12 +0200 Bernd Kuhls wrote: > Michael Niedermayer wrote in news:1402065736-24164-1-git- > send-email-michaelni at gmx.at: > > > libavutil/libm.h | 5 ++++- > > Hi, > > the current code in libm.h breaks compilation when the libc does not provide > fminf, which is the case for uClibc. Here you will find a patch fixing the > problem for me, although the problem should maybe be fixed in a different > way: > > http://git.buildroot.net/buildroot/tree/package/ffmpeg/ffmpeg-0001- > fminf.patch > > For background discussion please look here: > http://thread.gmane.org/gmane.comp.lib.uclibc.buildroot/90973/focus=90994 > > Regards, Bernd the problem is obviously that uclibc provides a fminf prorotype, but no implementation. Obviously this breaks any application that attempts to detect fminf, and provides its own fallback if it doesn't appear to exist. Why do you think ffmpeg should be patched for this, and not uclibc? From kierank at obe.tv Mon Aug 4 21:48:51 2014 From: kierank at obe.tv (Kieran Kunhya) Date: Mon, 4 Aug 2014 20:48:51 +0100 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: <53DFE066.2050602@snirklasjon.no> References: <53DFC9DC.1050207@snirklasjon.no> <20140804184737.GB13487@reimardoeffinger.de> <20140804191102.GA18638@reimardoeffinger.de> <53DFE066.2050602@snirklasjon.no> Message-ID: > into the decoders. The decoder approch would also not work for insertion of > closed captions (for h.264 that would be x264, and I can't see that CC has a > place there really). I'm uncertain enough that I would prefere to here the > opinion here before submitting a patch. As far as I can see it now: It would work with x264 actually because x264 could read the side data from an AVFrame. See how it's done here: https://github.com/kierank/obe-vod/blob/master/input/scc.c You will have problems making sure the input to x264 is cfr however. Kieran From Reimar.Doeffinger at gmx.de Mon Aug 4 21:58:58 2014 From: Reimar.Doeffinger at gmx.de (Reimar =?iso-8859-1?Q?D=F6ffinger?=) Date: Mon, 4 Aug 2014 21:58:58 +0200 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: <53DFE066.2050602@snirklasjon.no> References: <53DFC9DC.1050207@snirklasjon.no> <20140804184737.GB13487@reimardoeffinger.de> <20140804191102.GA18638@reimardoeffinger.de> <53DFE066.2050602@snirklasjon.no> Message-ID: <20140804195858.GA21901@reimardoeffinger.de> On Mon, Aug 04, 2014 at 09:35:02PM +0200, Gisle S?lensminde wrote: > Bitstream filter: > > Pro: > > - Modular, the CC code can be kept separate. > - Less complex code > > Cons: > > Need for features that I can't see is present in the bitstream filters: > - As far as I can see -no support for timestamps (PTS), required for > reordering and timestams in the output file > - No support for arguments to bitstream filters (unlike audio and video > filters) > > Decoder: > > Pro: > > - Parser already present. Easy to insert extraction code on the right spots > > Cons: > > - Less modular, CC code mixed with decoding code. > - Does not easily extend to encoders/insertion. > - Parameters (for input files)? *scratches head* I wonder now if you misunderstood or if you discarded the variant I pointed out due to effort/complexity? Demuxer+Parser/Muxer: Pro: - Parsing is often done in demuxer anyway - Appears as proper subtitle stream - Same usage whether you want to mux into/demux from MPEG-TS or formats saving CC data separately like MOV and WTV - Works without requiring decode/encode Con: - Needs reordering code in demuxer/parser - Needs extra signalling code from parser to demuxer (probably) - Custom code for partially rewriting frames in the muxer needed for MPEG containers - Generally a good bit more of complexity. From thilo.borgmann at mail.de Mon Aug 4 22:10:12 2014 From: thilo.borgmann at mail.de (Thilo Borgmann) Date: Mon, 04 Aug 2014 22:10:12 +0200 Subject: [FFmpeg-devel] [PATCH] lavd/avfoundation: Add device category. Message-ID: <53DFE8A4.4030602@mail.de> Hi, as reported by David Favor, the AVFoundation device is not yet listed by "ffmpeg -devices". This patch fixes that. Please Apply. -Thilo -------------- next part -------------- >From c76b7ce3a2bceb13d273212ec7b5d3142691b24a Mon Sep 17 00:00:00 2001 From: Thilo Borgmann Date: Mon, 4 Aug 2014 22:06:59 +0200 Subject: [PATCH] lavd/avfoundation: Add device category. --- libavdevice/avfoundation.m | 1 + 1 file changed, 1 insertion(+) diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m index 74d7811..4ac50a0 100644 --- a/libavdevice/avfoundation.m +++ b/libavdevice/avfoundation.m @@ -451,6 +451,7 @@ static const AVClass avf_class = { .item_name = av_default_item_name, .option = options, .version = LIBAVUTIL_VERSION_INT, + .category = AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT, }; AVInputFormat ff_avfoundation_demuxer = { -- 1.8.3.2 From thilo.borgmann at mail.de Mon Aug 4 22:13:18 2014 From: thilo.borgmann at mail.de (Thilo Borgmann) Date: Mon, 04 Aug 2014 22:13:18 +0200 Subject: [FFmpeg-devel] Mac/OSX question about clang + avfoundation + indev support In-Reply-To: <53DBB06D.9030307@davidfavor.com> References: <53DBB06D.9030307@davidfavor.com> Message-ID: <53DFE95E.10205@mail.de> > [...] > David-Favor-iMac# ffmpeg -devices > ffmpeg version 2.3.1-2014-08-01-65165-g229a1e8 Copyright (c) 2000-2014 the > FFmpeg developers > built on Aug 1 2014 10:13:00 with Apple LLVM version 5.1 (clang-503.0.40) > (based on LLVM 3.4svn) > configuration: --cc=/usr/bin/clang --prefix=/david-favor-tools/osx-10.9 > --mandir=/david-favor-tools/osx-10.9/share/man --enable-gpl --enable-yasm > --arch=x86_64 --enable-version3 --enable-pthreads --enable-shared > --disable-static --disable-debug > --extra-cflags='-I/david-favor-tools/osx-10.9/include -I/opt/local/include > -I/usr/local/include -I/usr/include' > --extra-ldflags='-Wl,-rpath,/david-favor-tools/osx-10.9/lib > -Wl,-rpath,/opt/local/lib -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/lib > -L/david-favor-tools/osx-10.9/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib' > --enable-ffplay --enable-ffprobe --enable-ffserver --enable-indev=qtkit > --enable-indev=avfoundation --enable-runtime-cpudetect --enable-nonfree > --enable-zlib --enable-bzlib --enable-openssl --enable-gnutls --enable-swscale > --enable-avfilter --enable-avresample --enable-postproc --enable-vda > --enable-libfribidi --enable-libmp3lame --enable-libfaac --enable-libfdk_aac > --enable-libvpx --enable-libtheora --enable-libvorbis --enable-libxvid > --enable-libopus --enable-libopenjpeg --enable-libschroedinger --enable-libspeex > --enable-libbluray --enable-libx264 --enable-libx265 --enable-postproc > --enable-frei0r --enable-libopencore-amrnb --enable-fontconfig > --enable-libfreetype --enable-libmodplug --enable-libass > libavutil 52. 94.100 / 52. 94.100 > libavcodec 55. 71.100 / 55. 71.100 > libavformat 55. 50.100 / 55. 50.100 > libavdevice 55. 13.102 / 55. 13.102 > libavfilter 4. 11.102 / 4. 11.102 > libavresample 1. 3. 0 / 1. 3. 0 > libswscale 2. 6.100 / 2. 6.100 > libswresample 0. 19.100 / 0. 19.100 > libpostproc 52. 3.100 / 52. 3.100 > Devices: > D. = Demuxing supported > .E = Muxing supported > -- > D lavfi Libavfilter virtual input device > D qtkit QTKit input device > E sdl SDL output device > E xv XV (XVideo) output device I can reproduce that with the same clang version and current HEAD. I have just posted a patch to fix that. For the gcc problems I cannot tell, except that it might not be able to compile the Apple API-headers. This is an issue for some compilers but nothing we can fix afaik. Thanks for reporting! -Thilo From gisle at snirklasjon.no Mon Aug 4 22:16:25 2014 From: gisle at snirklasjon.no (=?ISO-8859-1?Q?Gisle_S=E6lensminde?=) Date: Mon, 04 Aug 2014 22:16:25 +0200 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: <20140804195858.GA21901@reimardoeffinger.de> References: <53DFC9DC.1050207@snirklasjon.no> <20140804184737.GB13487@reimardoeffinger.de> <20140804191102.GA18638@reimardoeffinger.de> <53DFE066.2050602@snirklasjon.no> <20140804195858.GA21901@reimardoeffinger.de> Message-ID: <53DFEA19.5010500@snirklasjon.no> Den 04. aug. 2014 21:58, skrev Reimar D?ffinger: > *scratches head* I wonder now if you misunderstood or if you discarded > the variant I pointed out due to effort/complexity? Or because I don't know all the parts of the ffmpeg code well enough. Since both you and others has suggested that this is a good way to do it, I will look into it and see how it can be done. Thanks for your answers. -Gisle From u at pkh.me Mon Aug 4 22:22:03 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Mon, 4 Aug 2014 22:22:03 +0200 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: rewrite [f/i]dct In-Reply-To: References: <1407097641-26789-1-git-send-email-u@pkh.me> Message-ID: <20140804202203.GX10372@leki> On Sun, Aug 03, 2014 at 01:59:25PM -0700, Timothy Gu wrote: > On Aug 3, 2014 1:27 PM, "Cl?ment B?sch" wrote: > > > > This removes the avcodec dependency and make the code almost twice as > > fast. More to come. > > > > The DCT factorization is based on "Fast and numerically stable > > algorithms for discrete cosine transforms" from Gerlind Plonkaa & > > Manfred Tasche (DOI: 10.1016/j.laa.2004.07.015). > > --- > > configure | 2 - > > libavfilter/vf_dctdnoiz.c | 328 > +++++++++++++++++++++++++++++++++------------- > > 2 files changed, 240 insertions(+), 90 deletions(-) > > This change warrants a Changelog entry. > Not yet; I'd like to fully optimize it first. [...] > > static int config_input(AVFilterLink *inlink) > > @@ -194,18 +373,13 @@ static av_cold int init(AVFilterContext *ctx) > > NULL, NULL, NULL, NULL, 0, ctx); > > if (ret < 0) > > return ret; > > > + s->filter_freq_func = filter_freq_expr; > > + } else { > > + s->filter_freq_func = filter_freq_sigma; > > } > > Missing "if (s->expr)"? > You mean error checking? That should be handled by ret < 0 [...] -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From Reimar.Doeffinger at gmx.de Mon Aug 4 22:24:08 2014 From: Reimar.Doeffinger at gmx.de (Reimar =?iso-8859-1?Q?D=F6ffinger?=) Date: Mon, 4 Aug 2014 22:24:08 +0200 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: <53DFEA19.5010500@snirklasjon.no> References: <53DFC9DC.1050207@snirklasjon.no> <20140804184737.GB13487@reimardoeffinger.de> <20140804191102.GA18638@reimardoeffinger.de> <53DFE066.2050602@snirklasjon.no> <20140804195858.GA21901@reimardoeffinger.de> <53DFEA19.5010500@snirklasjon.no> Message-ID: <20140804202408.GA23952@reimardoeffinger.de> On Mon, Aug 04, 2014 at 10:16:25PM +0200, Gisle S?lensminde wrote: > Den 04. aug. 2014 21:58, skrev Reimar D?ffinger: > >*scratches head* I wonder now if you misunderstood or if you discarded the > >variant I pointed out due to effort/complexity? > > Or because I don't know all the parts of the ffmpeg code well enough. I grouped that under "misunderstood" :) > Since both you and others has suggested that this is a good way to do it, I > will look into it and see how it can be done. Thanks for your answers. It would be very welcome (at least by me). But, I have to say that it will lead down a path with lots of unknowns and risks. So while I'd be really happy for you to work in this direction, I think I should be so fair to say there's a risk that you might decide to give up on it in the end and then have to do one of the other approaches anyway. Regards, Reimar From michaelni at gmx.at Tue Aug 5 01:42:23 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Tue, 5 Aug 2014 01:42:23 +0200 Subject: [FFmpeg-devel] [PATCH] lavd/avfoundation: Add device category. In-Reply-To: <53DFE8A4.4030602@mail.de> References: <53DFE8A4.4030602@mail.de> Message-ID: <20140804234223.GZ4649@nb4> On Mon, Aug 04, 2014 at 10:10:12PM +0200, Thilo Borgmann wrote: > Hi, > > as reported by David Favor, the AVFoundation device is not yet listed by "ffmpeg > -devices". > > This patch fixes that. Please Apply. > > -Thilo > avfoundation.m | 1 + > 1 file changed, 1 insertion(+) > 62f49fcb277d0f6dc77f0eaee75f544d41116f7a 0001-lavd-avfoundation-Add-device-category.patch > From c76b7ce3a2bceb13d273212ec7b5d3142691b24a Mon Sep 17 00:00:00 2001 > From: Thilo Borgmann > Date: Mon, 4 Aug 2014 22:06:59 +0200 > Subject: [PATCH] lavd/avfoundation: Add device category. applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB You can kill me, but you cannot change the truth. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Tue Aug 5 02:04:34 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Tue, 5 Aug 2014 02:04:34 +0200 Subject: [FFmpeg-devel] [PATCH 1/1] Fix compile error on bfin. In-Reply-To: <1407179549-18101-1-git-send-email-bernd.kuhls@t-online.de> References: <1407179549-18101-1-git-send-email-bernd.kuhls@t-online.de> Message-ID: <20140805000434.GA4649@nb4> On Mon, Aug 04, 2014 at 09:12:29PM +0200, Bernd Kuhls wrote: > After the removal of all Blackfin architecture optimizations in > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b55d3bbeed375f7b74442c4dd274d116a3e3d2e1 > some includes were left behind leading to a compile error: > > CC libavformat/adtsenc.o > In file included from ./libavcodec/get_bits.h:35, > from ./libavcodec/ac3_parser.h:27, > from libavformat/ac3dec.c:23: > ./libavcodec/mathops.h:43:29: error: bfin/mathops.h: No such file or directory > > This compile error was found by buildroot autobuild system: > http://autobuild.buildroot.net/results/ae0/ae056f267e907091d09d2a1546d6f1ae02fa23b9/ > > Signed-off-by: Bernd Kuhls > --- > libavcodec/mathops.h | 2 -- > libavutil/bswap.h | 2 -- > libavutil/timer.h | 2 -- > 3 files changed, 6 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the very wise cannot see all ends. -- Gandalf -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Tue Aug 5 03:00:27 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Tue, 5 Aug 2014 03:00:27 +0200 Subject: [FFmpeg-devel] [PATCH 3/3] x86/vp9lpf: use fewer instructions in SPLATB_MIX In-Reply-To: <1407120820-3949-3-git-send-email-jamrial@gmail.com> References: <1407120820-3949-1-git-send-email-jamrial@gmail.com> <1407120820-3949-3-git-send-email-jamrial@gmail.com> Message-ID: <20140805010027.GB4649@nb4> On Sun, Aug 03, 2014 at 11:53:40PM -0300, James Almer wrote: > Signed-off-by: James Almer > --- > libavcodec/x86/vp9lpf.asm | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have never wished to cater to the crowd; for what I know they do not approve, and what they approve I do not know. -- Epicurus -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From onemda at gmail.com Tue Aug 5 08:13:18 2014 From: onemda at gmail.com (Paul B Mahol) Date: Tue, 5 Aug 2014 08:13:18 +0200 Subject: [FFmpeg-devel] [PATCH] New p2p mode for showwaves filter In-Reply-To: <1407145247-27033-1-git-send-email-mrskman@gmail.com> References: <1407145247-27033-1-git-send-email-mrskman@gmail.com> Message-ID: On Mon, Aug 4, 2014 at 11:40 AM, mrskman wrote: > New patch attached. > > Thank you. > > --- > doc/filters.texi | 3 +++ > libavfilter/avf_showwaves.c | 30 +++++++++++++++++++++++++++++- > 2 files changed, 32 insertions(+), 1 deletions(-) lgtm From michaelni at gmx.at Tue Aug 5 14:22:58 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Tue, 5 Aug 2014 14:22:58 +0200 Subject: [FFmpeg-devel] [PATCH] New p2p mode for showwaves filter In-Reply-To: References: <1407145247-27033-1-git-send-email-mrskman@gmail.com> Message-ID: <20140805122258.GC4649@nb4> On Tue, Aug 05, 2014 at 08:13:18AM +0200, Paul B Mahol wrote: > On Mon, Aug 4, 2014 at 11:40 AM, mrskman wrote: > > > New patch attached. > > > > Thank you. > > > > --- > > doc/filters.texi | 3 +++ > > libavfilter/avf_showwaves.c | 30 +++++++++++++++++++++++++++++- > > 2 files changed, 32 insertions(+), 1 deletions(-) > > > lgtm applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From u at pkh.me Tue Aug 5 16:23:14 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Tue, 5 Aug 2014 16:23:14 +0200 Subject: [FFmpeg-devel] [PATCH] [RFC] avcodec: export MB information in frame side data In-Reply-To: <20140721235146.GO4649@nb4> References: <1405523187-7024-1-git-send-email-u@pkh.me> <20140721235146.GO4649@nb4> Message-ID: <20140805142314.GA10372@leki> On Tue, Jul 22, 2014 at 01:51:46AM +0200, Michael Niedermayer wrote: [...] > > +typedef struct AVMBInfo_MB { > > > + int8_t source; /* -1/+1 XXX: set exact relative ref frame instead of "direction" */ > > i suspect this is too small for long term references Would signed 16-bit enough? > > > > + uint32_t type; /* how much codec specific can this be? */ > > + uint8_t w, h; > > + uint16_t src_x, src_y; > > + uint16_t dst_x, dst_y; > > +} AVMBInfo_MB; > > as side data this is not optimal as it depends on native endianness > making exchange of side data over the network or serialization > into file storage more difficult Any better suggestion that side-data? > > also QP, intra prediction mode, ... is missing > Shouldn't we have QP in a separate side-data type? Intrapred information isn't coded in the type (which is present in AVMBInfo_MB)? -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From nfxjfg at googlemail.com Tue Aug 5 16:27:53 2014 From: nfxjfg at googlemail.com (wm4) Date: Tue, 5 Aug 2014 16:27:53 +0200 Subject: [FFmpeg-devel] [PATCH] [RFC] avcodec: export MB information in frame side data In-Reply-To: <20140721235146.GO4649@nb4> References: <1405523187-7024-1-git-send-email-u@pkh.me> <20140721235146.GO4649@nb4> Message-ID: <20140805162753.602f4f76@debian> On Tue, 22 Jul 2014 01:51:46 +0200 Michael Niedermayer wrote: > On Wed, Jul 16, 2014 at 05:06:27PM +0200, Cl?ment B?sch wrote: > > Also add an example exporting the MB information as a CSV stream. > > > > --- > > > > A bunch of questions stand: > > > > - Ideally the "source" for a given macroblock should be a specific > > reference to a future or paste frame (something like -4 or +2). > > Currently it's just ?1 depending on the direction. I don't see how I > > can extract that information. > > > > - how the MB "type" should be exported? Like, what "generic" type we > > need to expose for the users > > > > - Who is motivated to port -vismv & various other vis_* debug to a video > > filter? (The hard part will probably be writing its documentation...) > > > > (TODO: avcodec version bump & APIChanges entry at least) > > --- > [...] > > @@ -2109,6 +2129,93 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_ > > int *low_delay, > > int mb_width, int mb_height, int mb_stride, int quarter_sample) > > { > > + if ((avctx->flags2 & CODEC_FLAG2_SD_MB_INFO) && mbtype_table && motion_val[0]) { > > + const int shift = 1 + quarter_sample; > > + const int mv_sample_log2 = avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_SVQ3 ? 2 : 1; > > + const int mv_stride = (mb_width << mv_sample_log2) + > > + (avctx->codec->id == AV_CODEC_ID_H264 ? 0 : 1); > > + int mb_x, mb_y, mbcount = 0; > > + > > + /* width * height * directions * 4MB (4MB for IS_8x8) */ > > + AVMBInfo_MB *mbs = av_malloc_array(mb_width * mb_height, 2 * 4 * sizeof(AVMBInfo_MB)); > > + if (!mbs) > > + return; > > + > > + // TODO: refactor with the following code > > + for (mb_y = 0; mb_y < mb_height; mb_y++) { > > + for (mb_x = 0; mb_x < mb_width; mb_x++) { > > + int i, direction, mb_type = mbtype_table[mb_x + mb_y * mb_stride]; > > + for (direction = 0; direction < 2; direction++) { > > > > + if (direction == 0 && > > + pict->pict_type != AV_PICTURE_TYPE_B && > > + pict->pict_type != AV_PICTURE_TYPE_P) > > + continue; > > + if (direction == 1 && > > + pict->pict_type != AV_PICTURE_TYPE_B) > > + continue; > > + if (!USES_LIST(mb_type, direction)) > > + continue; > > these checks seems a bit redundant > > > [...] > > diff --git a/libavutil/mbinfo.h b/libavutil/mbinfo.h > > new file mode 100644 > > index 0000000..89538ba > > --- /dev/null > > +++ b/libavutil/mbinfo.h > > @@ -0,0 +1,32 @@ > > +/* > > + * This file is part of FFmpeg. > > + * > > + * 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 > > + */ > > + > > +#ifndef AVUTIL_MBINFO_H > > +#define AVUTIL_MBINFO_H > > + > > +#include > > + > > +typedef struct AVMBInfo_MB { > > > + int8_t source; /* -1/+1 XXX: set exact relative ref frame instead of "direction" */ > > i suspect this is too small for long term references > > > > + uint32_t type; /* how much codec specific can this be? */ > > + uint8_t w, h; > > + uint16_t src_x, src_y; > > + uint16_t dst_x, dst_y; > > +} AVMBInfo_MB; > > as side data this is not optimal as it depends on native endianness > making exchange of side data over the network or serialization > into file storage more difficult Note that there's a lot of side data now that uses native structs. And it is certainly less awkward to use than an "in memory bitstream", even if that should make serializing harder. (So what, you just need to write a serialization function once -if that is even a valid use case- but normal access is going to be much more common by users.) > also QP, intra prediction mode, ... is missing > > > [...] From xaiki at evilgiggle.com Tue Aug 5 16:49:59 2014 From: xaiki at evilgiggle.com (Niv Sardi) Date: Tue, 5 Aug 2014 11:49:59 -0300 Subject: [FFmpeg-devel] [recentering] Reintroducing FFmpeg to Debian In-Reply-To: <53D5895B.2090102@googlemail.com> References: <53D5895B.2090102@googlemail.com> Message-ID: I feel the debate is going a bit on a tangent in this thread, so I'd like to take an opportunity to recenter it a tad.? ?We have many issues that were risen in this thread, ? ?but ? I believe that the cut has to be made by the people that we have in special roles for; -security for security concerns, -release for release scheduling and required transitions and our many maintainers of multimedia related packages to know what they want to link their packages against ?? ?, and well, as it has been named, tech-ctte for technical matters that we can't resolve in -devel.? ?In few words? , ?this is how I understand? the core of Andreas' plan, and has motivated many technical decisions in the packaging. ?Many ? ?? sensible ? technical decisions that lead to a polite and correct way to go. Now, our main blocker to get onto the next steps Andreas has exposed with great detail in his original mail is that the package has been sitting in NEW for the last ?3? months. As people voiced their feelings, it seems the vast majority does not opposes having FFmpeg in experimental ??. So my point here is: ?Shouldn't we first get it in the archive ? ? how can we help speed?ing ? ? it out of NEW ? ?The current packaging is a 'low-conflict' one, it can be easily transitioned into replacing libav if that's what gets decided further down the line. Hence, I see no blocker? in getting it in. The licencing has an ancestor with libav, and the new files have been following the same inclusion pattern. So my guess is that the blocker may be packaging quality, as the sponsor, I have checked it, but maybe we can help reconfort ftpmasters with more eyes on it ? ?Thanks,? -- Niv From michaelni at gmx.at Tue Aug 5 17:03:27 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Tue, 5 Aug 2014 17:03:27 +0200 Subject: [FFmpeg-devel] [PATCH] avdevice/lavfi: Simplify non-AV stream check Message-ID: <1407251007-29170-1-git-send-email-michaelni@gmx.at> Fixes a clang warning Signed-off-by: Michael Niedermayer --- libavdevice/lavfi.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index f1c88ac..4cfe804 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -184,14 +184,6 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) FAIL(AVERROR(EINVAL)); } - /* is an audio or video output? */ - type = inout->filter_ctx->output_pads[inout->pad_idx].type; - if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) { - av_log(avctx, AV_LOG_ERROR, - "Output '%s' is not a video or audio output, not yet supported\n", inout->name); - FAIL(AVERROR(EINVAL)); - } - if (lavfi->stream_sink_map[stream_idx] != -1) { av_log(avctx, AV_LOG_ERROR, "An output with stream index %d was already specified\n", @@ -252,6 +244,10 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) AV_OPT_SEARCH_CHILDREN); if (ret < 0) goto end; + } else { + av_log(avctx, AV_LOG_ERROR, + "Output '%s' is not a video or audio output, not yet supported\n", inout->name); + FAIL(AVERROR(EINVAL)); } lavfi->sinks[i] = sink; -- 1.7.9.5 From michaelni at gmx.at Tue Aug 5 17:19:44 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Tue, 5 Aug 2014 17:19:44 +0200 Subject: [FFmpeg-devel] [PATCH] [RFC] avcodec: export MB information in frame side data In-Reply-To: <20140805162753.602f4f76@debian> References: <1405523187-7024-1-git-send-email-u@pkh.me> <20140721235146.GO4649@nb4> <20140805162753.602f4f76@debian> Message-ID: <20140805151944.GD4649@nb4> On Tue, Aug 05, 2014 at 04:27:53PM +0200, wm4 wrote: > On Tue, 22 Jul 2014 01:51:46 +0200 > Michael Niedermayer wrote: > > > On Wed, Jul 16, 2014 at 05:06:27PM +0200, Cl?ment B?sch wrote: > > > Also add an example exporting the MB information as a CSV stream. > > > > > > --- > > > > > > A bunch of questions stand: > > > > > > - Ideally the "source" for a given macroblock should be a specific > > > reference to a future or paste frame (something like -4 or +2). > > > Currently it's just ?1 depending on the direction. I don't see how I > > > can extract that information. > > > > > > - how the MB "type" should be exported? Like, what "generic" type we > > > need to expose for the users > > > > > > - Who is motivated to port -vismv & various other vis_* debug to a video > > > filter? (The hard part will probably be writing its documentation...) > > > > > > (TODO: avcodec version bump & APIChanges entry at least) > > > --- > > [...] > > > @@ -2109,6 +2129,93 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_ > > > int *low_delay, > > > int mb_width, int mb_height, int mb_stride, int quarter_sample) > > > { > > > + if ((avctx->flags2 & CODEC_FLAG2_SD_MB_INFO) && mbtype_table && motion_val[0]) { > > > + const int shift = 1 + quarter_sample; > > > + const int mv_sample_log2 = avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_SVQ3 ? 2 : 1; > > > + const int mv_stride = (mb_width << mv_sample_log2) + > > > + (avctx->codec->id == AV_CODEC_ID_H264 ? 0 : 1); > > > + int mb_x, mb_y, mbcount = 0; > > > + > > > + /* width * height * directions * 4MB (4MB for IS_8x8) */ > > > + AVMBInfo_MB *mbs = av_malloc_array(mb_width * mb_height, 2 * 4 * sizeof(AVMBInfo_MB)); > > > + if (!mbs) > > > + return; > > > + > > > + // TODO: refactor with the following code > > > + for (mb_y = 0; mb_y < mb_height; mb_y++) { > > > + for (mb_x = 0; mb_x < mb_width; mb_x++) { > > > + int i, direction, mb_type = mbtype_table[mb_x + mb_y * mb_stride]; > > > + for (direction = 0; direction < 2; direction++) { > > > > > > > + if (direction == 0 && > > > + pict->pict_type != AV_PICTURE_TYPE_B && > > > + pict->pict_type != AV_PICTURE_TYPE_P) > > > + continue; > > > + if (direction == 1 && > > > + pict->pict_type != AV_PICTURE_TYPE_B) > > > + continue; > > > + if (!USES_LIST(mb_type, direction)) > > > + continue; > > > > these checks seems a bit redundant > > > > > > [...] > > > diff --git a/libavutil/mbinfo.h b/libavutil/mbinfo.h > > > new file mode 100644 > > > index 0000000..89538ba > > > --- /dev/null > > > +++ b/libavutil/mbinfo.h > > > @@ -0,0 +1,32 @@ > > > +/* > > > + * This file is part of FFmpeg. > > > + * > > > + * 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 > > > + */ > > > + > > > +#ifndef AVUTIL_MBINFO_H > > > +#define AVUTIL_MBINFO_H > > > + > > > +#include > > > + > > > +typedef struct AVMBInfo_MB { > > > > > + int8_t source; /* -1/+1 XXX: set exact relative ref frame instead of "direction" */ > > > > i suspect this is too small for long term references > > > > > > > + uint32_t type; /* how much codec specific can this be? */ > > > + uint8_t w, h; > > > + uint16_t src_x, src_y; > > > + uint16_t dst_x, dst_y; > > > +} AVMBInfo_MB; > > > > as side data this is not optimal as it depends on native endianness > > making exchange of side data over the network or serialization > > into file storage more difficult > > Note that there's a lot of side data now that uses native structs. > > And it is certainly less awkward to use than an "in memory bitstream", > even if that should make serializing harder. (So what, you just need to > write a serialization function once -if that is even a valid use > case- but normal access is going to be much more common by users.) storing multimedia related data in files and transmitting over the net isnt a valid use case ? but on the main point of what you wrote i agree, native structs are more convenient, iam not objecting to one being used here [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Tue Aug 5 17:24:47 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Tue, 5 Aug 2014 17:24:47 +0200 Subject: [FFmpeg-devel] [PATCH] [RFC] avcodec: export MB information in frame side data In-Reply-To: <20140805142314.GA10372@leki> References: <1405523187-7024-1-git-send-email-u@pkh.me> <20140721235146.GO4649@nb4> <20140805142314.GA10372@leki> Message-ID: <20140805152447.GE4649@nb4> On Tue, Aug 05, 2014 at 04:23:14PM +0200, Cl?ment B?sch wrote: > On Tue, Jul 22, 2014 at 01:51:46AM +0200, Michael Niedermayer wrote: > [...] > > > +typedef struct AVMBInfo_MB { > > > > > + int8_t source; /* -1/+1 XXX: set exact relative ref frame instead of "direction" */ > > > > i suspect this is too small for long term references > > Would signed 16-bit enough? practically, probably theoretically, i dont know > > > > > > > > + uint32_t type; /* how much codec specific can this be? */ > > > + uint8_t w, h; > > > + uint16_t src_x, src_y; > > > + uint16_t dst_x, dst_y; > > > +} AVMBInfo_MB; > > > > as side data this is not optimal as it depends on native endianness > > making exchange of side data over the network or serialization > > into file storage more difficult > > Any better suggestion that side-data? probably not > > > > > also QP, intra prediction mode, ... is missing > > > > Shouldn't we have QP in a separate side-data type? thats possible too [..] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From u at pkh.me Tue Aug 5 21:13:24 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Tue, 5 Aug 2014 21:13:24 +0200 Subject: [FFmpeg-devel] [PATCH 1/5] avutil: add pixelutils API In-Reply-To: <20140802223619.GW4649@nb4> References: <1407015251-10660-1-git-send-email-u@pkh.me> <1407015251-10660-2-git-send-email-u@pkh.me> <20140802223619.GW4649@nb4> Message-ID: <20140805191324.GC10372@leki> On Sun, Aug 03, 2014 at 12:36:19AM +0200, Michael Niedermayer wrote: > On Sat, Aug 02, 2014 at 11:34:07PM +0200, Cl?ment B?sch wrote: [...] > > +#ifdef TEST > > +#define W1 320 > > +#define H1 240 > > +#define W2 640 > > +#define H2 480 > > +int main(void) > > +{ > > + int i, a, ret = 0; > > + DECLARE_ALIGNED(32, uint32_t, buf1)[W1*H1]; > > + DECLARE_ALIGNED(32, uint32_t, buf2)[W2*H2]; > > + uint32_t state = 0; > > + > > + for (i = 0; i < W1*H1; i++) { > > + buf1[i] = state; > > + state = state * 1664525 + 1013904223; > > + } > > + > > + for (i = 0; i < W2*H2; i++) { > > + buf2[i] = state; > > + state = state * 1664525 + 1013904223; > > + } > > the code should in addition be tested with maximal and minimal > difference cases > Tests added. > > [...] > > +;------------------------------------------------------------------------------- > > +; int ff_pixelutils_sad_[au]_16x16_sse(const uint8_t *src1, ptrdiff_t stride1, > > +; const uint8_t *src2, ptrdiff_t stride2); > > +;------------------------------------------------------------------------------- > > +%macro SAD_XMM_16x16 1 > > +INIT_XMM sse2 > > +cglobal pixelutils_sad_%1_16x16, 4,4,3, src1, stride1, src2, stride2 > > + pxor m2, m2 > > +%rep 8 > > + mov%1 m0, [src2q] > > + mov%1 m1, [src2q + stride2q] > > + psadbw m0, [src1q] > > + psadbw m1, [src1q + stride1q] > > + paddw m2, m0 > > + paddw m2, m1 > > + lea src1q, [src1q + 2*stride1q] > > + lea src2q, [src2q + 2*stride2q] > > +%endrep > > + movhlps m0, m2 > > + paddw m2, m0 > > + movd eax, m2 > > + RET > > +%endmacro > > there are various improvments possible, though these should be in > a seperate patch and not in gcc->yasm but > the pxor can be avoided by lifting the first iteration out and > using m2 as destination > > it might be faster to use 2 accumulator registers as that way both > could execute with no dependancies on the other > > as you unroll the loop, addressing can be done with fewer instructions > I left the ASM as is since it was kind of simple and parallel to the API itself; we can iterate from here with benchmarks > LGTM otherwise > Patchset applied, thanks [...] -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From cehoyos at ag.or.at Tue Aug 5 21:59:13 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Tue, 5 Aug 2014 21:59:13 +0200 Subject: [FFmpeg-devel] [PATCH]Do not select a default subtitle output stream with incorrect subtitle type In-Reply-To: <20140801080417.GE10372@leki> References: <201408010154.57991.cehoyos@ag.or.at> <20140801080417.GE10372@leki> Message-ID: <201408052159.13927.cehoyos@ag.or.at> On Friday 01 August 2014 10:04:17 am Cl?ment B?sch wrote: > On Fri, Aug 01, 2014 at 01:54:57AM +0200, Carl Eugen Hoyos wrote: > > When transcoding an input file with subtitles to mkv, ffmpeg by default > > tries to encode the subtitles even if the input contains bitmap > > subtitles. Attached patch should fix this issue reported in ticket #3819 > > (and before iirc). > > This patch currently does not work correctly for teletext input streams > > because no properties are defined for teletext, I suspect it should be > > (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB). In any case, this > > corner-case should not affect this patch imo. I worked around this by automatically mapping subtitles if no properties are set. > > + if (subtitle_codec_name || > > + > > avcodec_find_encoder(oc->oformat->subtitle_codec) && + > > > > avcodec_descriptor_get(avcodec_find_encoder(oc->oformat->subtitle_codec)- > >>id) && + > > avcodec_descriptor_get(input_streams[i]->st->codec->codec_id) && + > > > > avcodec_descriptor_get(avcodec_find_encoder(oc->oformat->subtitle_codec)- > >>id)->props & + > > avcodec_descriptor_get(input_streams[i]->st->codec->codec_id)->props & > > You have a scope opened here, please use 2 intermediate const to store the > 2 descriptor pointers, because it's currently unreadable. Slightly more readable version attached. > > > + (AV_CODEC_PROP_TEXT_SUB | > > AV_CODEC_PROP_BITMAP_SUB)) { + > > new_subtitle_stream(o, oc, i); > > + break; > > + } > > BTW, do we have an obvious warning nowadays if someone tries to map a > bitmap sub to a text one? I believe the warning is the reason for ticket #3819. In any case, this is orthoganal to this patch imo: The patch tries to cover automatic subtitle mapping (in the useless case), iiuc you (also) mean the case when a user specifies a subtitle encoder that will not work. Thank you, Carl Eugen -------------- next part -------------- diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 9604a6a..1962cf4 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -1870,8 +1870,27 @@ static int open_output_file(OptionsContext *o, const char *filename) if (!o->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || subtitle_codec_name)) { for (i = 0; i < nb_input_streams; i++) if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { - new_subtitle_stream(o, oc, i); - break; + AVCodecDescriptor const *input_descriptor = + avcodec_descriptor_get(input_streams[i]->st->codec->codec_id); + AVCodecDescriptor const *output_descriptor = NULL; + AVCodec const *output_codec = + avcodec_find_encoder(oc->oformat->subtitle_codec); + int input_props = 0, output_props = 0; + if (output_codec) + output_descriptor = avcodec_descriptor_get(output_codec->id); + if (input_descriptor) + input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); + if (output_descriptor) + output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); + if (subtitle_codec_name || + input_props & output_props || + // Map dvb teletext which has neither property to any output subtitle encoder + input_descriptor && output_descriptor && + (!input_descriptor->props || + !output_descriptor->props)) { + new_subtitle_stream(o, oc, i); + break; + } } } /* do something with data? */ From cehoyos at ag.or.at Tue Aug 5 22:28:38 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Tue, 5 Aug 2014 22:28:38 +0200 Subject: [FFmpeg-devel] [PATCH]Make loas probe more similar to mp3 probe Message-ID: <201408052228.38417.cehoyos@ag.or.at> Hi! Attached patch copies one line from mp3dec.c into loasdec.c to force probing more data and fixes ticket #3821. An alternative is to remove the offending line from mp3dec.c (it was added in 2006 or earlier). Please review, Carl Eugen -------------- next part -------------- diff --git a/libavformat/loasdec.c b/libavformat/loasdec.c index c41809b..26d37cb 100644 --- a/libavformat/loasdec.c +++ b/libavformat/loasdec.c @@ -61,6 +61,8 @@ static int loas_probe(AVProbeData *p) return AVPROBE_SCORE_EXTENSION; else if (max_frames >= 3) return AVPROBE_SCORE_EXTENSION / 2; + else if (max_frames>=1 && max_frames >= p->buf_size/10000) + return 1; else return 0; } From michaelni at gmx.at Wed Aug 6 01:16:56 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 01:16:56 +0200 Subject: [FFmpeg-devel] [PATCH] avutil/cpu: output cpu data to stdout Message-ID: <1407280616-9118-1-git-send-email-michaelni@gmx.at> Errors go to stderr, but the cpu stats are non error output for cputest This fixes echoing the cpu test results Signed-off-by: Michael Niedermayer --- libavutil/cpu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 03f89cb..47d6fcc 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -331,12 +331,12 @@ static void print_cpu_flags(int cpu_flags, const char *type) { int i; - fprintf(stderr, "cpu_flags(%s) = 0x%08X\n", type, cpu_flags); - fprintf(stderr, "cpu_flags_str(%s) =", type); + printf("cpu_flags(%s) = 0x%08X\n", type, cpu_flags); + printf("cpu_flags_str(%s) =", type); for (i = 0; cpu_flag_tab[i].flag; i++) if (cpu_flags & cpu_flag_tab[i].flag) - fprintf(stderr, " %s", cpu_flag_tab[i].name); - fprintf(stderr, "\n"); + printf(" %s", cpu_flag_tab[i].name); + printf("\n"); } @@ -382,7 +382,7 @@ int main(int argc, char **argv) print_cpu_flags(cpu_flags_raw, "raw"); print_cpu_flags(cpu_flags_eff, "effective"); - fprintf(stderr, "threads = %s (cpu_count = %d)\n", threads, cpu_count); + printf("threads = %s (cpu_count = %d)\n", threads, cpu_count); return 0; } -- 1.7.9.5 From michaelni at gmx.at Wed Aug 6 01:17:51 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 01:17:51 +0200 Subject: [FFmpeg-devel] [PATCH] tests/fate/libavutil: switch cpu-test back to runecho so its results are vissible Message-ID: <1407280671-10941-1-git-send-email-michaelni@gmx.at> (needs next commt too) Signed-off-by: Michael Niedermayer --- tests/fate/libavutil.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak index 9f676a8..579bdfb 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -31,7 +31,7 @@ fate-bprint: CMD = run libavutil/bprint-test FATE_LIBAVUTIL += fate-cpu fate-cpu: libavutil/cpu-test$(EXESUF) -fate-cpu: CMD = run libavutil/cpu-test $(CPUFLAGS:%=-c%) $(THREADS:%=-t%) +fate-cpu: CMD = runecho libavutil/cpu-test $(CPUFLAGS:%=-c%) $(THREADS:%=-t%) fate-cpu: REF = /dev/null FATE_LIBAVUTIL += fate-crc -- 1.7.9.5 From jamrial at gmail.com Wed Aug 6 01:43:58 2014 From: jamrial at gmail.com (James Almer) Date: Tue, 05 Aug 2014 20:43:58 -0300 Subject: [FFmpeg-devel] [PATCH] avutil/cpu: output cpu data to stdout In-Reply-To: <1407280616-9118-1-git-send-email-michaelni@gmx.at> References: <1407280616-9118-1-git-send-email-michaelni@gmx.at> Message-ID: <53E16C3E.3020807@gmail.com> On 05/08/14 8:16 PM, Michael Niedermayer wrote: > Errors go to stderr, but the cpu stats are non error output for cputest > > This fixes echoing the cpu test results > > Signed-off-by: Michael Niedermayer > --- > libavutil/cpu.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) LGTM From jamrial at gmail.com Wed Aug 6 01:44:16 2014 From: jamrial at gmail.com (James Almer) Date: Tue, 05 Aug 2014 20:44:16 -0300 Subject: [FFmpeg-devel] [PATCH] tests/fate/libavutil: switch cpu-test back to runecho so its results are vissible In-Reply-To: <1407280671-10941-1-git-send-email-michaelni@gmx.at> References: <1407280671-10941-1-git-send-email-michaelni@gmx.at> Message-ID: <53E16C50.9050905@gmail.com> On 05/08/14 8:17 PM, Michael Niedermayer wrote: > (needs next commt too) > > Signed-off-by: Michael Niedermayer > --- > tests/fate/libavutil.mak | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak > index 9f676a8..579bdfb 100644 > --- a/tests/fate/libavutil.mak > +++ b/tests/fate/libavutil.mak > @@ -31,7 +31,7 @@ fate-bprint: CMD = run libavutil/bprint-test > > FATE_LIBAVUTIL += fate-cpu > fate-cpu: libavutil/cpu-test$(EXESUF) > -fate-cpu: CMD = run libavutil/cpu-test $(CPUFLAGS:%=-c%) $(THREADS:%=-t%) > +fate-cpu: CMD = runecho libavutil/cpu-test $(CPUFLAGS:%=-c%) $(THREADS:%=-t%) > fate-cpu: REF = /dev/null > > FATE_LIBAVUTIL += fate-crc LGTM From michaelni at gmx.at Wed Aug 6 01:58:20 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 01:58:20 +0200 Subject: [FFmpeg-devel] [PATCH] tests/fate/libavutil: switch cpu-test back to runecho so its results are vissible In-Reply-To: <53E16C50.9050905@gmail.com> References: <1407280671-10941-1-git-send-email-michaelni@gmx.at> <53E16C50.9050905@gmail.com> Message-ID: <20140805235820.GF4649@nb4> On Tue, Aug 05, 2014 at 08:44:16PM -0300, James Almer wrote: > On 05/08/14 8:17 PM, Michael Niedermayer wrote: > > (needs next commt too) > > > > Signed-off-by: Michael Niedermayer > > --- > > tests/fate/libavutil.mak | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak > > index 9f676a8..579bdfb 100644 > > --- a/tests/fate/libavutil.mak > > +++ b/tests/fate/libavutil.mak > > @@ -31,7 +31,7 @@ fate-bprint: CMD = run libavutil/bprint-test > > > > FATE_LIBAVUTIL += fate-cpu > > fate-cpu: libavutil/cpu-test$(EXESUF) > > -fate-cpu: CMD = run libavutil/cpu-test $(CPUFLAGS:%=-c%) $(THREADS:%=-t%) > > +fate-cpu: CMD = runecho libavutil/cpu-test $(CPUFLAGS:%=-c%) $(THREADS:%=-t%) > > fate-cpu: REF = /dev/null > > > > FATE_LIBAVUTIL += fate-crc > > LGTM applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam" -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Wed Aug 6 02:08:19 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 02:08:19 +0200 Subject: [FFmpeg-devel] [PATCH] avutil/cpu: output cpu data to stdout In-Reply-To: <53E16C3E.3020807@gmail.com> References: <1407280616-9118-1-git-send-email-michaelni@gmx.at> <53E16C3E.3020807@gmail.com> Message-ID: <20140806000819.GG4649@nb4> On Tue, Aug 05, 2014 at 08:43:58PM -0300, James Almer wrote: > On 05/08/14 8:16 PM, Michael Niedermayer wrote: > > Errors go to stderr, but the cpu stats are non error output for cputest > > > > This fixes echoing the cpu test results > > > > Signed-off-by: Michael Niedermayer > > --- > > libavutil/cpu.c | 10 +++++----- > > 1 file changed, 5 insertions(+), 5 deletions(-) > > LGTM applied thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB There will always be a question for which you do not know the correct answer. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Wed Aug 6 02:24:48 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 02:24:48 +0200 Subject: [FFmpeg-devel] [PATCH]Make loas probe more similar to mp3 probe In-Reply-To: <201408052228.38417.cehoyos@ag.or.at> References: <201408052228.38417.cehoyos@ag.or.at> Message-ID: <20140806002448.GH4649@nb4> On Tue, Aug 05, 2014 at 10:28:38PM +0200, Carl Eugen Hoyos wrote: > Hi! > > Attached patch copies one line from mp3dec.c into loasdec.c to force probing > more data and fixes ticket #3821. An alternative is to remove the offending > line from mp3dec.c (it was added in 2006 or earlier). > > Please review, Carl Eugen > loasdec.c | 2 ++ > 1 file changed, 2 insertions(+) > eeb3dfd9137c0ff570d6c36e27f7c2989daad8da patchloas.diff > diff --git a/libavformat/loasdec.c b/libavformat/loasdec.c > index c41809b..26d37cb 100644 LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you think the mosad wants you dead since a long time then you are either wrong or dead since a long time. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From timothygu99 at gmail.com Wed Aug 6 02:59:15 2014 From: timothygu99 at gmail.com (Timothy Gu) Date: Tue, 5 Aug 2014 17:59:15 -0700 Subject: [FFmpeg-devel] [PATCH] transcode_aac: fix const return value Message-ID: <1407286755-3941-1-git-send-email-timothygu99@gmail.com> Fixes Trac #3613. Signed-off-by: Timothy Gu --- doc/examples/transcode_aac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c index bf0128f..cee447f 100644 --- a/doc/examples/transcode_aac.c +++ b/doc/examples/transcode_aac.c @@ -52,7 +52,7 @@ * @param error Error code to be converted * @return Corresponding error text (not thread-safe) */ -static char *const get_error_text(const int error) +static const char *get_error_text(const int error) { static char error_buffer[255]; av_strerror(error, error_buffer, sizeof(error_buffer)); -- 1.9.1 From michaelni at gmx.at Wed Aug 6 04:27:11 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 04:27:11 +0200 Subject: [FFmpeg-devel] [PATCH] transcode_aac: fix const return value In-Reply-To: <1407286755-3941-1-git-send-email-timothygu99@gmail.com> References: <1407286755-3941-1-git-send-email-timothygu99@gmail.com> Message-ID: <20140806022711.GI4649@nb4> On Tue, Aug 05, 2014 at 05:59:15PM -0700, Timothy Gu wrote: > Fixes Trac #3613. > > Signed-off-by: Timothy Gu > --- > doc/examples/transcode_aac.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are best at talking, realize last or never when they are wrong. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From christophe.gisquet at gmail.com Wed Aug 6 09:33:13 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Wed, 6 Aug 2014 09:33:13 +0200 Subject: [FFmpeg-devel] [PATCH] hevc_deblock: change tc type Message-ID: Hi, this patch is mostly cosmetical. I don't like seeing arrays passed to dsp functions being of a type whose length may not be fixed, though it's a small matter here. -- Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-hevc_deblock-change-tc-type.patch Type: text/x-patch Size: 7555 bytes Desc: not available URL: From christophe.gisquet at gmail.com Wed Aug 6 09:43:38 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Wed, 6 Aug 2014 07:43:38 +0000 Subject: [FFmpeg-devel] [PATCH 0/5] x86: share constants Message-ID: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> First patch is the biggest one, as it removes definitions that are intermingled, not used or triplicated, eg as found in the vp9 dsp code. A comment there mentions that sharing, but as it is as fast to do it than write this comment, maybe I'm missing something? Other patches are more contained. Christophe Gisquet (5): x86: vpx/h264/hevc/mpeg2: share constants x86: better share ff_pw_2 x86: dwt: better share constants x86: diracdsp: reuse constants x86: sbrdsp/fft: reuse ps_neg constant libavcodec/x86/constants.c | 9 +++++++-- libavcodec/x86/constants.h | 11 +++++++++-- libavcodec/x86/diracdsp_yasm.asm | 11 ++++++----- libavcodec/x86/dwt_yasm.asm | 9 +++++---- libavcodec/x86/fft.asm | 7 ++++--- libavcodec/x86/h264_intrapred_10bit.asm | 2 +- libavcodec/x86/hevc_deblock.asm | 2 +- libavcodec/x86/hpeldsp.asm | 3 ++- libavcodec/x86/inline_asm.h | 2 +- libavcodec/x86/sbrdsp.asm | 2 +- libavcodec/x86/vp8dsp.asm | 2 +- libavcodec/x86/vp9intrapred.asm | 8 ++++---- libavcodec/x86/vp9itxfm.asm | 9 +++++---- libavcodec/x86/vp9lpf.asm | 4 ++-- libavcodec/x86/vp9mc.asm | 3 +-- 15 files changed, 50 insertions(+), 34 deletions(-) -- 1.9.2.msysgit.0 From christophe.gisquet at gmail.com Wed Aug 6 09:43:39 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Wed, 6 Aug 2014 07:43:39 +0000 Subject: [FFmpeg-devel] [PATCH 1/5] x86: vpx/h264/hevc/mpeg2: share constants In-Reply-To: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> References: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> Message-ID: <1407311023-6484-2-git-send-email-christophe.gisquet@gmail.com> --- libavcodec/x86/constants.c | 5 +++++ libavcodec/x86/constants.h | 5 +++++ libavcodec/x86/h264_intrapred_10bit.asm | 2 +- libavcodec/x86/hevc_deblock.asm | 2 +- libavcodec/x86/hpeldsp.asm | 3 ++- libavcodec/x86/vp8dsp.asm | 2 +- libavcodec/x86/vp9intrapred.asm | 8 ++++---- libavcodec/x86/vp9itxfm.asm | 9 +++++---- libavcodec/x86/vp9lpf.asm | 4 ++-- libavcodec/x86/vp9mc.asm | 3 +-- 10 files changed, 27 insertions(+), 16 deletions(-) diff --git a/libavcodec/x86/constants.c b/libavcodec/x86/constants.c index 7608bb3..ee3f1a5 100644 --- a/libavcodec/x86/constants.c +++ b/libavcodec/x86/constants.c @@ -43,8 +43,13 @@ DECLARE_ALIGNED(16, const xmm_reg, ff_pw_64) = { 0x0040004000400040ULL, 0x004 DECLARE_ALIGNED(8, const uint64_t, ff_pw_96) = 0x0060006000600060ULL; DECLARE_ALIGNED(8, const uint64_t, ff_pw_128) = 0x0080008000800080ULL; DECLARE_ALIGNED(8, const uint64_t, ff_pw_255) = 0x00ff00ff00ff00ffULL; +DECLARE_ALIGNED(16, const xmm_reg, ff_pw_256) = { 0x0100010001000100ULL, 0x0100010001000100ULL }; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_512) = { 0x0200020002000200ULL, 0x0200020002000200ULL }; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_1019) = { 0x03FB03FB03FB03FBULL, 0x03FB03FB03FB03FBULL }; +DECLARE_ALIGNED(16, const xmm_reg, ff_pw_1024) = { 0x0400040004000400ULL, 0x0400040004000400ULL }; +DECLARE_ALIGNED(16, const xmm_reg, ff_pw_2048) = { 0x0800080008000800ULL, 0x0800080008000800ULL }; +DECLARE_ALIGNED(16, const xmm_reg, ff_pw_8192) = { 0x2000200020002000ULL, 0x2000200020002000ULL }; +DECLARE_ALIGNED(16, const xmm_reg, ff_pw_m1) = { 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL }; DECLARE_ALIGNED(16, const xmm_reg, ff_pb_0) = { 0x0000000000000000ULL, 0x0000000000000000ULL }; DECLARE_ALIGNED(32, const ymm_reg, ff_pb_1) = { 0x0101010101010101ULL, 0x0101010101010101ULL, diff --git a/libavcodec/x86/constants.h b/libavcodec/x86/constants.h index 3ebf171..4520515 100644 --- a/libavcodec/x86/constants.h +++ b/libavcodec/x86/constants.h @@ -43,6 +43,11 @@ extern const xmm_reg ff_pw_64; extern const uint64_t ff_pw_96; extern const uint64_t ff_pw_128; extern const uint64_t ff_pw_255; +extern const xmm_reg ff_pw_512; +extern const xmm_reg ff_pw_1024; +extern const xmm_reg ff_pw_2048; +extern const xmm_reg ff_pw_8192; +extern const xmm_reg ff_pw_m1; extern const ymm_reg ff_pb_1; extern const ymm_reg ff_pb_3; diff --git a/libavcodec/x86/h264_intrapred_10bit.asm b/libavcodec/x86/h264_intrapred_10bit.asm index 9dee577..b60a210 100644 --- a/libavcodec/x86/h264_intrapred_10bit.asm +++ b/libavcodec/x86/h264_intrapred_10bit.asm @@ -26,6 +26,7 @@ SECTION_RODATA +cextern pw_512 cextern pw_16 cextern pw_8 cextern pw_4 @@ -35,7 +36,6 @@ cextern pw_1 pw_m32101234: dw -3, -2, -1, 0, 1, 2, 3, 4 pw_m3: times 8 dw -3 pw_pixel_max: times 8 dw ((1 << 10)-1) -pw_512: times 8 dw 512 pd_17: times 4 dd 17 pd_16: times 4 dd 16 diff --git a/libavcodec/x86/hevc_deblock.asm b/libavcodec/x86/hevc_deblock.asm index 8f58916..f92cb2c 100644 --- a/libavcodec/x86/hevc_deblock.asm +++ b/libavcodec/x86/hevc_deblock.asm @@ -28,12 +28,12 @@ SECTION_RODATA pw_pixel_max_12: times 8 dw ((1 << 12)-1) pw_pixel_max_10: times 8 dw ((1 << 10)-1) -pw_m1: times 8 dw -1 pw_m2: times 8 dw -2 pd_1 : times 4 dd 1 cextern pw_4 cextern pw_8 +cextern pw_m1 SECTION .text INIT_XMM sse2 diff --git a/libavcodec/x86/hpeldsp.asm b/libavcodec/x86/hpeldsp.asm index a702b8b..2cef8e6 100644 --- a/libavcodec/x86/hpeldsp.asm +++ b/libavcodec/x86/hpeldsp.asm @@ -30,10 +30,11 @@ SECTION_RODATA cextern pb_1 cextern pw_2 -pw_8192: times 8 dw (1<<13) pb_interleave16: db 0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15 pb_interleave8: db 0, 4, 1, 5, 2, 6, 3, 7 +cextern pw_8192 + SECTION_TEXT ; void ff_put_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h) diff --git a/libavcodec/x86/vp8dsp.asm b/libavcodec/x86/vp8dsp.asm index 77cc2f3..538b3f4 100644 --- a/libavcodec/x86/vp8dsp.asm +++ b/libavcodec/x86/vp8dsp.asm @@ -143,13 +143,13 @@ filter_h6_shuf1: db 0, 5, 1, 6, 2, 7, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12 filter_h6_shuf2: db 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9 filter_h6_shuf3: db 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11 -pw_256: times 8 dw 256 pw_20091: times 4 dw 20091 pw_17734: times 4 dw 17734 cextern pw_3 cextern pw_4 cextern pw_64 +cextern pw_256 SECTION .text diff --git a/libavcodec/x86/vp9intrapred.asm b/libavcodec/x86/vp9intrapred.asm index 1d8d219..86b925a 100644 --- a/libavcodec/x86/vp9intrapred.asm +++ b/libavcodec/x86/vp9intrapred.asm @@ -33,11 +33,7 @@ SECTION_RODATA 32 pw_m256: times 16 dw -256 pw_m255: times 16 dw -255 -pw_512: times 8 dw 512 -pw_1024: times 8 dw 1024 -pw_2048: times 8 dw 2048 pw_4096: times 8 dw 4096 -pw_8192: times 8 dw 8192 pb_4x3_4x2_4x1_4x0: times 4 db 3 times 4 db 2 @@ -77,6 +73,10 @@ pb_15: times 16 db 15 cextern pb_1 cextern pb_3 +cextern pw_512 +cextern pw_1024 +cextern pw_2048 +cextern pw_8192 SECTION .text diff --git a/libavcodec/x86/vp9itxfm.asm b/libavcodec/x86/vp9itxfm.asm index 8087c2e..6cce0aa 100644 --- a/libavcodec/x86/vp9itxfm.asm +++ b/libavcodec/x86/vp9itxfm.asm @@ -66,10 +66,11 @@ pw_m5283_m15212: times 4 dw -5283, -15212 pw_13377x2: times 8 dw 13377*2 pd_8192: times 4 dd 8192 -pw_2048: times 8 dw 2048 -pw_1024: times 8 dw 1024 -pw_512: times 8 dw 512 -pw_m1: times 8 dw -1 + +cextern pw_512 +cextern pw_1024 +cextern pw_2048 +cextern pw_m1 SECTION .text diff --git a/libavcodec/x86/vp9lpf.asm b/libavcodec/x86/vp9lpf.asm index def7d5a..cb57a25 100644 --- a/libavcodec/x86/vp9lpf.asm +++ b/libavcodec/x86/vp9lpf.asm @@ -36,8 +36,8 @@ pb_81: times 16 db 0x81 pb_f8: times 16 db 0xf8 pb_fe: times 16 db 0xfe -pw_4: times 8 dw 4 -pw_8: times 8 dw 8 +cextern pw_4 +cextern pw_8 ; with mix functions, two 8-bit thresholds are stored in a 16-bit storage, ; the following mask is used to splat both in the same register diff --git a/libavcodec/x86/vp9mc.asm b/libavcodec/x86/vp9mc.asm index 7c2a38c..aa10001 100644 --- a/libavcodec/x86/vp9mc.asm +++ b/libavcodec/x86/vp9mc.asm @@ -24,8 +24,7 @@ SECTION_RODATA -; FIXME share with vp8dsp.asm -pw_256: times 8 dw 256 +cextern pw_256 %macro F8_TAPS 8 times 8 db %1, %2 -- 1.9.2.msysgit.0 From christophe.gisquet at gmail.com Wed Aug 6 09:43:40 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Wed, 6 Aug 2014 07:43:40 +0000 Subject: [FFmpeg-devel] [PATCH 2/5] x86: better share ff_pw_2 In-Reply-To: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> References: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> Message-ID: <1407311023-6484-3-git-send-email-christophe.gisquet@gmail.com> --- libavcodec/x86/constants.c | 2 -- libavcodec/x86/constants.h | 3 +-- libavcodec/x86/dwt_yasm.asm | 3 ++- libavcodec/x86/inline_asm.h | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/libavcodec/x86/constants.c b/libavcodec/x86/constants.c index ee3f1a5..bfb0ff3 100644 --- a/libavcodec/x86/constants.c +++ b/libavcodec/x86/constants.c @@ -22,8 +22,6 @@ #include "libavutil/x86/asm.h" // for xmm_reg #include "constants.h" -DECLARE_ALIGNED(8, const uint64_t, ff_wtwo) = 0x0002000200020002ULL; - DECLARE_ALIGNED(16, const xmm_reg, ff_pw_1) = { 0x0001000100010001ULL, 0x0001000100010001ULL }; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_2) = { 0x0002000200020002ULL, 0x0002000200020002ULL }; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_3) = { 0x0003000300030003ULL, 0x0003000300030003ULL }; diff --git a/libavcodec/x86/constants.h b/libavcodec/x86/constants.h index 4520515..c85a54e 100644 --- a/libavcodec/x86/constants.h +++ b/libavcodec/x86/constants.h @@ -25,8 +25,7 @@ #include "libavutil/x86/asm.h" -extern const uint64_t ff_wtwo; - +extern const xmm_reg ff_pw_2; extern const xmm_reg ff_pw_3; extern const xmm_reg ff_pw_4; extern const xmm_reg ff_pw_5; diff --git a/libavcodec/x86/dwt_yasm.asm b/libavcodec/x86/dwt_yasm.asm index 5253abc..1d8e793 100644 --- a/libavcodec/x86/dwt_yasm.asm +++ b/libavcodec/x86/dwt_yasm.asm @@ -23,11 +23,12 @@ SECTION_RODATA pw_1: times 8 dw 1 -pw_2: times 8 dw 2 pw_8: times 8 dw 8 pw_16: times 8 dw 16 pw_1991: times 4 dw 9,-1 +cextern pw_2 + section .text ; %1 -= (%2 + %3 + 2)>>2 %4 is pw_2 diff --git a/libavcodec/x86/inline_asm.h b/libavcodec/x86/inline_asm.h index c2f1bf0..3e65a76 100644 --- a/libavcodec/x86/inline_asm.h +++ b/libavcodec/x86/inline_asm.h @@ -37,7 +37,7 @@ "paddb %%"#regd", %%"#regd" \n\t" ::) #ifndef PIC -#define MOVQ_WTWO(regd) __asm__ volatile ("movq %0, %%"#regd" \n\t" :: "m"(ff_wtwo)) +#define MOVQ_WTWO(regd) __asm__ volatile ("movq %0, %%"#regd" \n\t" :: "m"(ff_pw_2)) #else // for shared library it's better to use this way for accessing constants // pcmpeqd -> -1 -- 1.9.2.msysgit.0 From christophe.gisquet at gmail.com Wed Aug 6 09:43:41 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Wed, 6 Aug 2014 07:43:41 +0000 Subject: [FFmpeg-devel] [PATCH 3/5] x86: dwt: better share constants In-Reply-To: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> References: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> Message-ID: <1407311023-6484-4-git-send-email-christophe.gisquet@gmail.com> --- libavcodec/x86/constants.h | 1 + libavcodec/x86/dwt_yasm.asm | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/constants.h b/libavcodec/x86/constants.h index c85a54e..f73a9f2 100644 --- a/libavcodec/x86/constants.h +++ b/libavcodec/x86/constants.h @@ -25,6 +25,7 @@ #include "libavutil/x86/asm.h" +extern const xmm_reg ff_pw_1; extern const xmm_reg ff_pw_2; extern const xmm_reg ff_pw_3; extern const xmm_reg ff_pw_4; diff --git a/libavcodec/x86/dwt_yasm.asm b/libavcodec/x86/dwt_yasm.asm index 1d8e793..658acc1 100644 --- a/libavcodec/x86/dwt_yasm.asm +++ b/libavcodec/x86/dwt_yasm.asm @@ -22,12 +22,12 @@ %include "libavutil/x86/x86util.asm" SECTION_RODATA -pw_1: times 8 dw 1 -pw_8: times 8 dw 8 -pw_16: times 8 dw 16 pw_1991: times 4 dw 9,-1 +cextern pw_1 cextern pw_2 +cextern pw_8 +cextern pw_16 section .text -- 1.9.2.msysgit.0 From christophe.gisquet at gmail.com Wed Aug 6 09:43:42 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Wed, 6 Aug 2014 07:43:42 +0000 Subject: [FFmpeg-devel] [PATCH 4/5] x86: diracdsp: reuse constants In-Reply-To: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> References: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> Message-ID: <1407311023-6484-5-git-send-email-christophe.gisquet@gmail.com> --- libavcodec/x86/diracdsp_yasm.asm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavcodec/x86/diracdsp_yasm.asm b/libavcodec/x86/diracdsp_yasm.asm index 3e9765b..d3cf9f1 100644 --- a/libavcodec/x86/diracdsp_yasm.asm +++ b/libavcodec/x86/diracdsp_yasm.asm @@ -21,11 +21,12 @@ %include "libavutil/x86/x86util.asm" SECTION_RODATA -pw_3: times 8 dw 3 pw_7: times 8 dw 7 -pw_16: times 8 dw 16 -pw_32: times 8 dw 32 -pb_128: times 16 db 128 + +cextern pw_3 +cextern pw_16 +cextern pw_32 +cextern pb_80 section .text @@ -131,7 +132,7 @@ cglobal dirac_hpel_filter_h_%1, 3,3,8, dst, src, width %macro PUT_RECT 1 ; void put_rect_clamped(uint8_t *dst, int dst_stride, int16_t *src, int src_stride, int width, int height) cglobal put_signed_rect_clamped_%1, 5,9,3, dst, dst_stride, src, src_stride, w, dst2, src2 - mova m0, [pb_128] + mova m0, [pb_80] add wd, (mmsize-1) and wd, ~(mmsize-1) -- 1.9.2.msysgit.0 From christophe.gisquet at gmail.com Wed Aug 6 09:43:43 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Wed, 6 Aug 2014 07:43:43 +0000 Subject: [FFmpeg-devel] [PATCH 5/5] x86: sbrdsp/fft: reuse ps_neg constant In-Reply-To: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> References: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> Message-ID: <1407311023-6484-6-git-send-email-christophe.gisquet@gmail.com> --- libavcodec/x86/constants.c | 2 ++ libavcodec/x86/constants.h | 2 ++ libavcodec/x86/fft.asm | 7 ++++--- libavcodec/x86/sbrdsp.asm | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libavcodec/x86/constants.c b/libavcodec/x86/constants.c index bfb0ff3..5d2c237 100644 --- a/libavcodec/x86/constants.c +++ b/libavcodec/x86/constants.c @@ -56,3 +56,5 @@ DECLARE_ALIGNED(32, const ymm_reg, ff_pb_3) = { 0x0303030303030303ULL, 0x030 0x0303030303030303ULL, 0x0303030303030303ULL }; DECLARE_ALIGNED(16, const xmm_reg, ff_pb_80) = { 0x8080808080808080ULL, 0x8080808080808080ULL }; DECLARE_ALIGNED(8, const uint64_t, ff_pb_FC) = 0xFCFCFCFCFCFCFCFCULL; + +DECLARE_ALIGNED(16, const xmm_reg, ff_ps_neg) = { 0x8000000080000000ULL, 0x8000000080000000ULL }; diff --git a/libavcodec/x86/constants.h b/libavcodec/x86/constants.h index f73a9f2..e75fff9 100644 --- a/libavcodec/x86/constants.h +++ b/libavcodec/x86/constants.h @@ -55,4 +55,6 @@ extern const xmm_reg ff_pb_80; extern const xmm_reg ff_pb_F8; extern const uint64_t ff_pb_FC; +extern const xmm_reg ff_ps_neg; + #endif /* AVCODEC_X86_CONSTANTS_H */ diff --git a/libavcodec/x86/fft.asm b/libavcodec/x86/fft.asm index cae404c..877997e 100644 --- a/libavcodec/x86/fft.asm +++ b/libavcodec/x86/fft.asm @@ -68,9 +68,10 @@ perm1: dd 0x00, 0x02, 0x03, 0x01, 0x03, 0x00, 0x02, 0x01 perm2: dd 0x00, 0x01, 0x02, 0x03, 0x01, 0x00, 0x02, 0x03 ps_p1p1m1p1root2: dd 1.0, 1.0, -1.0, 1.0, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2 ps_m1m1p1m1p1m1m1m1: dd 1<<31, 1<<31, 0, 1<<31, 0, 1<<31, 1<<31, 1<<31 -ps_m1m1m1m1: times 4 dd 1<<31 ps_m1p1: dd 1<<31, 0 +cextern ps_neg + %assign i 16 %rep 13 cextern cos_ %+ i @@ -685,7 +686,7 @@ cglobal imdct_calc, 3,5,3 mov r2, r3 sub r3, mmsize neg r2 - mova m2, [ps_m1m1m1m1] + mova m2, [ps_neg] .loop: %if mmsize == 8 PSWAPD m0, [r1 + r3] @@ -998,7 +999,7 @@ cglobal imdct_half, 3,12,8; FFTContext *s, FFTSample *output, const FFTSample *i sub r4, r3 %endif %if notcpuflag(3dnowext) && mmsize == 8 - movd m7, [ps_m1m1m1m1] + movd m7, [ps_neg] %endif .pre: %if ARCH_X86_64 == 0 diff --git a/libavcodec/x86/sbrdsp.asm b/libavcodec/x86/sbrdsp.asm index d556f27..6f2e4f4 100644 --- a/libavcodec/x86/sbrdsp.asm +++ b/libavcodec/x86/sbrdsp.asm @@ -25,13 +25,13 @@ SECTION_RODATA ; mask equivalent for multiply by -1.0 1.0 ps_mask times 2 dd 1<<31, 0 ps_mask2 times 2 dd 0, 1<<31 -ps_neg times 4 dd 1<<31 ps_noise0 times 2 dd 1.0, 0.0, ps_noise2 times 2 dd -1.0, 0.0 ps_noise13 dd 0.0, 1.0, 0.0, -1.0 dd 0.0, -1.0, 0.0, 1.0 dd 0.0, 1.0, 0.0, -1.0 cextern sbr_noise_table +cextern ps_neg SECTION_TEXT -- 1.9.2.msysgit.0 From mraulet at insa-rennes.fr Wed Aug 6 10:57:54 2014 From: mraulet at insa-rennes.fr (=?UTF-8?Q?Micka=C3=ABl_Raulet?=) Date: Wed, 6 Aug 2014 10:57:54 +0200 Subject: [FFmpeg-devel] [PATCH] hevc_deblock: change tc type In-Reply-To: References: Message-ID: Patch ok Mickael Le mercredi 6 ao?t 2014, Christophe Gisquet a ?crit : > Hi, > > this patch is mostly cosmetical. I don't like seeing arrays passed to > dsp functions being of a type whose length may not be fixed, though > it's a small matter here. > > -- > Christophe > From u at pkh.me Wed Aug 6 11:17:39 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Wed, 6 Aug 2014 11:17:39 +0200 Subject: [FFmpeg-devel] [PATCH] lavfi/avf_showspectrum: use automatic framing. In-Reply-To: <1407088260-19647-1-git-send-email-george@nsup.org> References: <1407077965-16960-1-git-send-email-george@nsup.org> <1407088260-19647-1-git-send-email-george@nsup.org> Message-ID: <20140806091739.GD10372@leki> On Sun, Aug 03, 2014 at 07:51:00PM +0200, Nicolas George wrote: > The framework can ensure that each input frame has exactly > the correct number of samples, except the last one. > > Signed-off-by: Nicolas George > --- > libavfilter/avf_showspectrum.c | 48 +++++++++++++++--------------------------- > 1 file changed, 17 insertions(+), 31 deletions(-) > > > Forgot to remove a variable that is no longer useful. > > > diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c > index e925556..c59a4f6 100644 > --- a/libavfilter/avf_showspectrum.c > +++ b/libavfilter/avf_showspectrum.c [...] > @@ -284,7 +283,7 @@ static int request_frame(AVFilterLink *outlink) > return ret; > } > > -static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb_samples) > +static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples) > { > int ret; > AVFilterContext *ctx = inlink->dst; > @@ -297,26 +296,21 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb > const int nb_freq = 1 << (s->rdft_bits - 1); > const int win_size = nb_freq << 1; > const double w = 1. / (sqrt(nb_freq) * 32768.); > + int h = s->channel_height; /* channel height */ I think we can guess that's the channel height without that comment [...] LGTM otherwise -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From u at pkh.me Wed Aug 6 11:19:56 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Wed, 6 Aug 2014 11:19:56 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec/avdct: Add get_pixels() In-Reply-To: <1407006356-14253-1-git-send-email-michaelni@gmx.at> References: <1407006356-14253-1-git-send-email-michaelni@gmx.at> Message-ID: <20140806091956.GE10372@leki> On Sat, Aug 02, 2014 at 09:05:56PM +0200, Michael Niedermayer wrote: > TODO: version bump, update libavfilters to use it > > Suggested-by: ubitux > Signed-off-by: Michael Niedermayer > --- > libavcodec/avdct.c | 9 +++++++++ > libavcodec/avdct.h | 4 ++++ > 2 files changed, 13 insertions(+) > > diff --git a/libavcodec/avdct.c b/libavcodec/avdct.c > index 58f4974..2521256 100644 > --- a/libavcodec/avdct.c > +++ b/libavcodec/avdct.c > @@ -21,6 +21,7 @@ > #include "avcodec.h" > #include "idctdsp.h" > #include "fdctdsp.h" > +#include "pixblockdsp.h" > #include "avdct.h" > > #define OFFSET(x) offsetof(AVDCT,x) > @@ -117,6 +118,14 @@ int avcodec_dct_init(AVDCT *dsp) > } > #endif > > +#if CONFIG_PIXBLOCKDSP > + { > + PixblockDSPContext pdsp; > + ff_pixblockdsp_init(&pdsp, avctx); > + COPY(pdsp, get_pixels); > + } > +#endif > + > avcodec_close(avctx); > av_free(avctx); > > diff --git a/libavcodec/avdct.h b/libavcodec/avdct.h > index 4c9d00f..4190203 100644 > --- a/libavcodec/avdct.h > +++ b/libavcodec/avdct.h > @@ -61,6 +61,10 @@ typedef struct AVDCT { > * must use AVOptions to set this field. > */ > int idct_algo; > + > + void (*get_pixels)(int16_t *block /* align 16 */, > + const uint8_t *pixels /* align 8 */, > + int line_size); We will sooner or later need a ptrdiff_t linesize here. Since it's public but only recently added I would suggest to make that change not to late. Also, a doxy could help. [...] -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From u at pkh.me Wed Aug 6 11:26:41 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Wed, 6 Aug 2014 11:26:41 +0200 Subject: [FFmpeg-devel] [PATCH] lavfi/avf_showspectrum: check RDFT contet init. In-Reply-To: <1407091236-20302-1-git-send-email-george@nsup.org> References: <1407091236-20302-1-git-send-email-george@nsup.org> Message-ID: <20140806092641.GF10372@leki> On Sun, Aug 03, 2014 at 08:40:36PM +0200, Nicolas George wrote: > Fix a segfault with large window size. > > Signed-off-by: Nicolas George > --- > libavfilter/avf_showspectrum.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c > index 7bf3aab..764a000 100644 > --- a/libavfilter/avf_showspectrum.c > +++ b/libavfilter/avf_showspectrum.c > @@ -177,6 +177,11 @@ static int config_output(AVFilterLink *outlink) > > av_rdft_end(s->rdft); > s->rdft = av_rdft_init(rdft_bits, DFT_R2C); > + if (!s->rdft) { > + av_log(ctx, AV_LOG_ERROR, "Unable to allocate RDFT context. " s/allocate/create/ > + "Maybe window too high.\n"); "The window height might be too high." > + return AVERROR(EINVAL); > + } LGTM otherwise [...] -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From u at pkh.me Wed Aug 6 11:31:50 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Wed, 6 Aug 2014 11:31:50 +0200 Subject: [FFmpeg-devel] [PATCH] lavfi/avf_showspectrum: add full frame sliding mode. In-Reply-To: <1407087103-19078-1-git-send-email-george@nsup.org> References: <1407087103-19078-1-git-send-email-george@nsup.org> Message-ID: <20140806093150.GG10372@leki> On Sun, Aug 03, 2014 at 07:31:43PM +0200, Nicolas George wrote: > Signed-off-by: Nicolas George > --- > doc/filters.texi | 15 +++++++++++-- > libavfilter/avf_showspectrum.c | 50 +++++++++++++++++++++++++++--------------- > 2 files changed, 45 insertions(+), 20 deletions(-) > Cool. I have a local patch to do something similar in showwaves. I'll try to submit it in a few days. > diff --git a/doc/filters.texi b/doc/filters.texi > index c5caa77..8739e84 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -10589,8 +10589,19 @@ the "Video size" section in the ffmpeg-utils manual. Default value is > @code{640x512}. > > @item slide > -Specify if the spectrum should slide along the window. Default value is > - at code{0}. > +Specify how the spectrum should slide along the window. > + > +It accepts the following values: > + at table @samp > + at item replace > +the samples start again on the left when they reach the right > + at item scroll > +the samples scroll from right to left > + at item fullframe > +frames are only produced when the samples reach the right > + at end table > + > +Default value is @code{replace}. > > @item mode > Specify display mode. > diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c > index b354571..56759ff 100644 > --- a/libavfilter/avf_showspectrum.c > +++ b/libavfilter/avf_showspectrum.c > @@ -38,6 +38,7 @@ enum DisplayMode { COMBINED, SEPARATE, NB_MODES }; > enum DisplayScale { LINEAR, SQRT, CBRT, LOG, NB_SCALES }; > enum ColorMode { CHANNEL, INTENSITY, NB_CLMODES }; > enum WindowFunc { WFUNC_NONE, WFUNC_HANN, WFUNC_HAMMING, WFUNC_BLACKMAN, NB_WFUNC }; > +enum SlideMode { REPLACE, SCROLL, FULLFRAME, NB_SLIDES }; > > typedef struct { > const AVClass *class; > @@ -66,7 +67,10 @@ typedef struct { > static const AVOption showspectrum_options[] = { > { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x512"}, 0, 0, FLAGS }, > { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x512"}, 0, 0, FLAGS }, > - { "slide", "set sliding mode", OFFSET(sliding), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, FLAGS }, > + { "slide", "set sliding mode", OFFSET(sliding), AV_OPT_TYPE_INT, {.i64 = 0}, 0, NB_SLIDES, FLAGS, "slide" }, > + { "replace", "replace old colums with new", 0, AV_OPT_TYPE_CONST, {.i64=REPLACE}, 0, 0, FLAGS, "slide" }, > + { "scroll", "scroll from right to left", 0, AV_OPT_TYPE_CONST, {.i64=SCROLL}, 0, 0, FLAGS, "slide" }, > + { "fullframe", "return full frames", 0, AV_OPT_TYPE_CONST, {.i64=FULLFRAME}, 0, 0, FLAGS, "slide" }, > { "mode", "set channel display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=COMBINED}, COMBINED, NB_MODES-1, FLAGS, "mode" }, > { "combined", "combined mode", 0, AV_OPT_TYPE_CONST, {.i64=COMBINED}, 0, 0, FLAGS, "mode" }, > { "separate", "separate mode", 0, AV_OPT_TYPE_CONST, {.i64=SEPARATE}, 0, 0, FLAGS, "mode" }, > @@ -244,6 +248,8 @@ static int config_output(AVFilterLink *outlink) > s->xpos = 0; > > outlink->frame_rate = av_make_q(inlink->sample_rate, win_size); > + if (s->sliding == FULLFRAME) > + outlink->frame_rate.den *= outlink->w; > > inlink->min_samples = inlink->max_samples = inlink->partial_buf_size = > win_size; > @@ -257,27 +263,27 @@ static int config_output(AVFilterLink *outlink) > return 0; > } > > -inline static int push_frame(AVFilterLink *outlink) > -{ > - ShowSpectrumContext *s = outlink->src->priv; > - > - s->xpos++; > - if (s->xpos >= outlink->w) > - s->xpos = 0; > - s->req_fullfilled = 1; > - > - return ff_filter_frame(outlink, av_frame_clone(s->outpicref)); > -} > - > static int request_frame(AVFilterLink *outlink) > { > ShowSpectrumContext *s = outlink->src->priv; > AVFilterLink *inlink = outlink->src->inputs[0]; > + unsigned i; > int ret; > > s->req_fullfilled = 0; > do { > ret = ff_request_frame(inlink); > + if (ret == AVERROR_EOF && s->sliding == FULLFRAME && s->xpos > 0 && > + s->outpicref) { > + for (i = 0; i < outlink->h; i++) { > + memset(s->outpicref->data[0] + i * s->outpicref->linesize[0] + s->xpos, 0, outlink->w - s->xpos); > + memset(s->outpicref->data[1] + i * s->outpicref->linesize[1] + s->xpos, 128, outlink->w - s->xpos); > + memset(s->outpicref->data[2] + i * s->outpicref->linesize[2] + s->xpos, 128, outlink->w - s->xpos); > + } > + ret = ff_filter_frame(outlink, s->outpicref); > + s->outpicref = NULL; > + s->req_fullfilled = 1; > + } > } while (!s->req_fullfilled && ret >= 0); > > return ret; > @@ -440,7 +446,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples) > } > > /* copy to output */ > - if (s->sliding) { > + if (s->sliding == SCROLL) { > for (plane = 0; plane < 3; plane++) { > for (y = 0; y < outlink->h; y++) { > uint8_t *p = outpicref->data[plane] + > @@ -460,10 +466,18 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples) > } > } > > - outpicref->pts = insamples->pts; > - ret = push_frame(outlink); > - if (ret < 0) > - return ret; > + if (s->sliding != FULLFRAME || s->xpos == 0) > + outpicref->pts = insamples->pts; > + > + s->xpos++; > + if (s->xpos >= outlink->w) > + s->xpos = 0; > + if (s->sliding != FULLFRAME || s->xpos == 0) { > + s->req_fullfilled = 1; > + ret = ff_filter_frame(outlink, av_frame_clone(s->outpicref)); > + if (ret < 0) > + return ret; > + } > > return win_size; LGTM -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From u at pkh.me Wed Aug 6 11:36:36 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Wed, 6 Aug 2014 11:36:36 +0200 Subject: [FFmpeg-devel] [PATCH] lavfi/avf_showspectrum: do not push the frame at EOF. In-Reply-To: <1407077068-16748-1-git-send-email-george@nsup.org> References: <1407077068-16748-1-git-send-email-george@nsup.org> Message-ID: <20140806093636.GH10372@leki> On Sun, Aug 03, 2014 at 04:44:28PM +0200, Nicolas George wrote: > It is always identical to the last pushed frame. > The samples in the last incomplete window were ignored, > this is unchanged. > Possible enhancement: pad the last incomplete window with > silence. > Having min_samples=max_samples=N doesn't do that already? [...] -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From u at pkh.me Wed Aug 6 11:37:23 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Wed, 6 Aug 2014 11:37:23 +0200 Subject: [FFmpeg-devel] [PATCH 1/2] lavfi/avf_showspectrum: set output frame rate. In-Reply-To: <1407076177-17543-1-git-send-email-george@nsup.org> References: <1407076177-17543-1-git-send-email-george@nsup.org> Message-ID: <20140806093723.GI10372@leki> On Sun, Aug 03, 2014 at 04:29:36PM +0200, Nicolas George wrote: > Signed-off-by: Nicolas George > --- > libavfilter/avf_showspectrum.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c > index 4a4b4f4..e3ae6ea 100644 > --- a/libavfilter/avf_showspectrum.c > +++ b/libavfilter/avf_showspectrum.c > @@ -246,6 +246,8 @@ static int config_output(AVFilterLink *outlink) > if (s->xpos >= outlink->w) > s->xpos = 0; > > + outlink->frame_rate = av_make_q(inlink->sample_rate, win_size); > + > s->combine_buffer = > av_realloc_f(s->combine_buffer, outlink->h * 3, > sizeof(*s->combine_buffer)); OK May I ask what use-case this is fixing? -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From u at pkh.me Wed Aug 6 11:38:14 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Wed, 6 Aug 2014 11:38:14 +0200 Subject: [FFmpeg-devel] [PATCH 1/2] lavfi/avf_showspectrum: set output frame rate. In-Reply-To: <20140806093723.GI10372@leki> References: <1407076177-17543-1-git-send-email-george@nsup.org> <20140806093723.GI10372@leki> Message-ID: <20140806093814.GJ10372@leki> On Wed, Aug 06, 2014 at 11:37:23AM +0200, Cl?ment B?sch wrote: > On Sun, Aug 03, 2014 at 04:29:36PM +0200, Nicolas George wrote: > > Signed-off-by: Nicolas George > > --- > > libavfilter/avf_showspectrum.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c > > index 4a4b4f4..e3ae6ea 100644 > > --- a/libavfilter/avf_showspectrum.c > > +++ b/libavfilter/avf_showspectrum.c > > @@ -246,6 +246,8 @@ static int config_output(AVFilterLink *outlink) > > if (s->xpos >= outlink->w) > > s->xpos = 0; > > > > + outlink->frame_rate = av_make_q(inlink->sample_rate, win_size); > > + > > s->combine_buffer = > > av_realloc_f(s->combine_buffer, outlink->h * 3, > > sizeof(*s->combine_buffer)); > > OK > > May I ask what use-case this is fixing? > Missed the comment in your second patch, ignore this -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From u at pkh.me Wed Aug 6 12:12:33 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Wed, 6 Aug 2014 12:12:33 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> References: <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> Message-ID: <20140806101233.GM10372@leki> On Sun, Aug 03, 2014 at 06:43:18PM +0200, Daniel Oberhoff wrote: [...] > >> +static av_cold int init(AVFilterContext *ctx) > >> +{ > >> + return 0; > >> +} > >> > > > > please remove this one, there is no point in having code that does nothing. > > > >> + > >> +static av_cold void uninit(AVFilterContext *ctx) > >> +{ > >> +} > >> + > >> > > > > ditto > > > > Done thanks! > Did you forget to attach the latest version of the patch or I missed it somewhere in the thread? [...] -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From michaelni at gmx.at Wed Aug 6 12:44:39 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 12:44:39 +0200 Subject: [FFmpeg-devel] [PATCH] hevc_deblock: change tc type In-Reply-To: References: Message-ID: <20140806104439.GJ4649@nb4> On Wed, Aug 06, 2014 at 10:57:54AM +0200, Micka?l Raulet wrote: > Patch ok applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If a bugfix only changes things apparently unrelated to the bug with no further explanation, that is a good sign that the bugfix is wrong. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Wed Aug 6 19:33:53 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 19:33:53 +0200 Subject: [FFmpeg-devel] [PATCH 1/5] x86: vpx/h264/hevc/mpeg2: share constants In-Reply-To: <1407311023-6484-2-git-send-email-christophe.gisquet@gmail.com> References: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> <1407311023-6484-2-git-send-email-christophe.gisquet@gmail.com> Message-ID: <20140806173353.GA12391@nb4> On Wed, Aug 06, 2014 at 07:43:39AM +0000, Christophe Gisquet wrote: > --- > libavcodec/x86/constants.c | 5 +++++ > libavcodec/x86/constants.h | 5 +++++ > libavcodec/x86/h264_intrapred_10bit.asm | 2 +- > libavcodec/x86/hevc_deblock.asm | 2 +- > libavcodec/x86/hpeldsp.asm | 3 ++- > libavcodec/x86/vp8dsp.asm | 2 +- > libavcodec/x86/vp9intrapred.asm | 8 ++++---- > libavcodec/x86/vp9itxfm.asm | 9 +++++---- > libavcodec/x86/vp9lpf.asm | 4 ++-- > libavcodec/x86/vp9mc.asm | 3 +-- > 10 files changed, 27 insertions(+), 16 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No great genius has ever existed without some touch of madness. -- Aristotle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Wed Aug 6 19:34:24 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 19:34:24 +0200 Subject: [FFmpeg-devel] [PATCH 2/5] x86: better share ff_pw_2 In-Reply-To: <1407311023-6484-3-git-send-email-christophe.gisquet@gmail.com> References: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> <1407311023-6484-3-git-send-email-christophe.gisquet@gmail.com> Message-ID: <20140806173424.GB12391@nb4> On Wed, Aug 06, 2014 at 07:43:40AM +0000, Christophe Gisquet wrote: > --- > libavcodec/x86/constants.c | 2 -- > libavcodec/x86/constants.h | 3 +-- > libavcodec/x86/dwt_yasm.asm | 3 ++- > libavcodec/x86/inline_asm.h | 2 +- > 4 files changed, 4 insertions(+), 6 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No snowflake in an avalanche ever feels responsible. -- Voltaire -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Wed Aug 6 19:34:43 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 19:34:43 +0200 Subject: [FFmpeg-devel] [PATCH 3/5] x86: dwt: better share constants In-Reply-To: <1407311023-6484-4-git-send-email-christophe.gisquet@gmail.com> References: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> <1407311023-6484-4-git-send-email-christophe.gisquet@gmail.com> Message-ID: <20140806173443.GC12391@nb4> On Wed, Aug 06, 2014 at 07:43:41AM +0000, Christophe Gisquet wrote: > --- > libavcodec/x86/constants.h | 1 + > libavcodec/x86/dwt_yasm.asm | 6 +++--- > 2 files changed, 4 insertions(+), 3 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 1 "Used only once" - "Some unspecified defect prevented a second use" "In good condition" - "Can be repaird by experienced expert" "As is" - "You wouldnt want it even if you were payed for it, if you knew ..." -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Wed Aug 6 19:34:59 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 19:34:59 +0200 Subject: [FFmpeg-devel] [PATCH 4/5] x86: diracdsp: reuse constants In-Reply-To: <1407311023-6484-5-git-send-email-christophe.gisquet@gmail.com> References: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> <1407311023-6484-5-git-send-email-christophe.gisquet@gmail.com> Message-ID: <20140806173459.GD12391@nb4> On Wed, Aug 06, 2014 at 07:43:42AM +0000, Christophe Gisquet wrote: > --- > libavcodec/x86/diracdsp_yasm.asm | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws. -- Plato -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Wed Aug 6 19:35:17 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 19:35:17 +0200 Subject: [FFmpeg-devel] [PATCH 5/5] x86: sbrdsp/fft: reuse ps_neg constant In-Reply-To: <1407311023-6484-6-git-send-email-christophe.gisquet@gmail.com> References: <1407311023-6484-1-git-send-email-christophe.gisquet@gmail.com> <1407311023-6484-6-git-send-email-christophe.gisquet@gmail.com> Message-ID: <20140806173517.GE12391@nb4> On Wed, Aug 06, 2014 at 07:43:43AM +0000, Christophe Gisquet wrote: > --- > libavcodec/x86/constants.c | 2 ++ > libavcodec/x86/constants.h | 2 ++ > libavcodec/x86/fft.asm | 7 ++++--- > libavcodec/x86/sbrdsp.asm | 2 +- > 4 files changed, 9 insertions(+), 4 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have never wished to cater to the crowd; for what I know they do not approve, and what they approve I do not know. -- Epicurus -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From adrien.montfort at idol.io Wed Aug 6 14:23:33 2014 From: adrien.montfort at idol.io (Adrien Montfort) Date: Wed, 6 Aug 2014 14:23:33 +0200 Subject: [FFmpeg-devel] LFEScaleIndex larger than 127 is not implemented Message-ID: <2FB63A42-D26E-414A-8975-2283CC7D2CE4@idol.io> Hello, I?ve uploaded the file 664461_flac_16_44100_2.wav on ftp://upload.ffmpeg.org/incoming/. Here is my result when I run this command with latest ffmpeg version: $ ffmpeg -i 664461_flac_16_44100_2.wav -acodec libfdk_aac -vbr 3 -movflags faststart ffmpeg version N-44095-g6786848 Copyright (c) 2000-2014 the FFmpeg developers built on Aug 6 2014 13:33:31 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) configuration: --prefix=/usr/local/src --extra-cflags=-I/usr/local/src/include --extra-ldflags=-L/usr/local/src/lib --bindir=/usr/local/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libfaac --enable-nonfree --enable-x11grab libavutil 52. 98.100 / 52. 98.100 libavcodec 55. 72.101 / 55. 72.101 libavformat 55. 51.101 / 55. 51.101 libavdevice 55. 13.102 / 55. 13.102 libavfilter 4. 11.102 / 4. 11.102 libswscale 2. 6.100 / 2. 6.100 libswresample 0. 19.100 / 0. 19.100 libpostproc 52. 3.100 / 52. 3.100 Trailing options were found on the commandline. [dca @ 0x35474e0] Not a valid DCA frame [dca @ 0x35474e0] Invalid LFE value: 0 Last message repeated 1 times [dca @ 0x35474e0] LFEScaleIndex larger than 127 is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented. [dca @ 0x35474e0] If you want to help, upload a sample of this file to ftp://upload.ffmpeg.org/incoming/ and contact the ffmpeg-devel mailing list. (ffmpeg-devel at ffmpeg.org) [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] Invalid bit allocation index [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] LFEScaleIndex larger than 127 is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented. [dca @ 0x35474e0] If you want to help, upload a sample of this file to ftp://upload.ffmpeg.org/incoming/ and contact the ffmpeg-devel mailing list. (ffmpeg-devel at ffmpeg.org) [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] ERROR: block code look-up failed [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] Invalid bit allocation index [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] LFEScaleIndex larger than 127 is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented. [dca @ 0x35474e0] If you want to help, upload a sample of this file to ftp://upload.ffmpeg.org/incoming/ and contact the ffmpeg-devel mailing list. (ffmpeg-devel at ffmpeg.org) [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] ERROR: block code look-up failed [dca @ 0x35474e0] error decoding block Last message repeated 1 times [dca @ 0x35474e0] Invalid bit allocation index [dca @ 0x35474e0] error decoding block Last message repeated 1 times [dca @ 0x35474e0] ERROR: block code look-up failed [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] Invalid LFE value: 0 [dca @ 0x35474e0] ERROR: block code look-up failed [dca @ 0x35474e0] error decoding block Last message repeated 1 times [dca @ 0x35474e0] ERROR: block code look-up failed [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] ERROR: block code look-up failed [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] Invalid bit allocation index [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] ERROR: block code look-up failed [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] Invalid bit allocation index [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] LFEScaleIndex larger than 127 is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented. [dca @ 0x35474e0] If you want to help, upload a sample of this file to ftp://upload.ffmpeg.org/incoming/ and contact the ffmpeg-devel mailing list. (ffmpeg-devel at ffmpeg.org) [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] Didn't get subframe DSYNC [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] Invalid LFE value: 0 [dca @ 0x35474e0] error decoding block Last message repeated 1 times [dca @ 0x35474e0] ERROR: block code look-up failed [dca @ 0x35474e0] error decoding block Last message repeated 1 times [dca @ 0x35474e0] Didn't get subframe DSYNC [dca @ 0x35474e0] error decoding block [dca @ 0x35474e0] Invalid LFE value: 0 [dca @ 0x35474e0] ERROR: block code look-up failed [dca @ 0x35474e0] error decoding block [wav @ 0x3546b40] decoding for stream 0 failed [wav @ 0x3546b40] Could not find codec parameters for stream 0 (Audio: dts ([1][0][0][0] / 0x0001), 12000 Hz, 2 channels, fltp, 96 kb/s): no decodable DTS frames Consider increasing the value for the 'analyzeduration' and 'probesize' options 664461_flac_16_44100_2.wav: could not find codec parameters Guessed Channel Layout for Input Stream #0.0 : stereo Input #0, wav, from '664461_flac_16_44100_2.wav': Duration: 00:03:21.89, bitrate: 1411 kb/s Stream #0:0: Audio: dts ([1][0][0][0] / 0x0001), 12000 Hz, 2 channels, fltp, 96 kb/s At least one output file must be specified Thanks for you help --- Adrien Montfort | Developer IDOL - Independent Distribution On Line 21 rue du Faubourg St Antoine - B?timent F - 75011 PARIS + 33 (0)9 73 87 03 62 idol.io | Facebook From marek.fort at chyronhego.com Wed Aug 6 14:33:46 2014 From: marek.fort at chyronhego.com (Marek Fort) Date: Wed, 6 Aug 2014 14:33:46 +0200 Subject: [FFmpeg-devel] Patch - Mov decoder should read Avid's metadata for DNXHD codec Message-ID: Hi, I'd like to get this patch integrated. This allows to propagate AALP and ARES mov file atoms to DNxHD codec. Parsing AALP is essential for proper alpha channel decoding. This patch relates to this ticket https://trac.ffmpeg.org/ticket/3707 Thanks, Marek Fort -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Mov-decoder-should-read-Avid-s-metadata-for-DNXHD-co.patch Type: application/octet-stream Size: 2553 bytes Desc: not available URL: From pshirkey at boosthardware.com Wed Aug 6 20:58:01 2014 From: pshirkey at boosthardware.com (Patrick Shirkey) Date: Thu, 7 Aug 2014 04:58:01 +1000 (EST) Subject: [FFmpeg-devel] Embedded audio SoC supplier: audio player Message-ID: <59589.86.107.254.57.1407351481.squirrel@boosthardware.com> Hi, I'm looking for a supplier who can provide a turnkey or white label LOW COST linux compatible portable audio player. SoC embedded linux device. 10k - 150k units. Some hardware customisations may be required. Any company that is interested in quoting on this project please contact me directly to discuss the details. -- Patrick Shirkey Boost Hardware Ltd From cehoyos at ag.or.at Wed Aug 6 21:21:18 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Wed, 6 Aug 2014 21:21:18 +0200 Subject: [FFmpeg-devel] [PATCH]Make loas probe more similar to mp3 probe In-Reply-To: <201408052228.38417.cehoyos@ag.or.at> References: <201408052228.38417.cehoyos@ag.or.at> Message-ID: <201408062121.18822.cehoyos@ag.or.at> On Tuesday 05 August 2014 10:28:38 pm Carl Eugen Hoyos wrote: > Attached patch copies one line from mp3dec.c into loasdec.c to force > probing more data and fixes ticket #3821. An alternative is to remove > the offending line from mp3dec.c (it was added in 2006 or earlier). I was unhappy about the patch and iiuc the actual problem is that the first audio track is initially probed with a score of 25 as h263 and with a score of 1 as mp3. 1 is not enough (so if I disable the h263 probe the probe size is increased and loas is correctly detected) but the 25 are interpreted as the probe value of mp3. New patch attached. It stops set_codec_from_probe_data() from returning probe scores for streams that are not ignored (FFmpeg doesn't autodetect h263 in mpeg streams) but I suspect it would still lead to a failure if the audio data is initially detected as h264 with a score of 25 so a more correct fix is welcome. Please review, Carl Eugen -------------- next part -------------- diff --git a/libavformat/utils.c b/libavformat/utils.c index 6ebbe6c..558a141 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -265,7 +265,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, { "mpegvideo", AV_CODEC_ID_MPEG2VIDEO, AVMEDIA_TYPE_VIDEO }, { 0 } }; - int score; + int score, probed_score = 0; AVInputFormat *fmt = av_probe_input_format3(pd, 1, &score); if (fmt && st->request_probe <= score) { @@ -278,11 +278,12 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, if (!strcmp(fmt->name, fmt_id_type[i].name)) { st->codec->codec_id = fmt_id_type[i].id; st->codec->codec_type = fmt_id_type[i].type; + probed_score = score; break; } } } - return score; + return probed_score; } /************************************************************/ From cehoyos at ag.or.at Wed Aug 6 21:44:20 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Wed, 6 Aug 2014 19:44:20 +0000 (UTC) Subject: [FFmpeg-devel] LFEScaleIndex larger than 127 is not implemented References: <2FB63A42-D26E-414A-8975-2283CC7D2CE4@idol.io> Message-ID: Adrien Montfort idol.io> writes: > I?ve uploaded the file 664461_flac_16_44100_2.wav I have opened ticket #3830, thank you for the sample! Carl Eugen From cehoyos at ag.or.at Wed Aug 6 21:47:18 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Wed, 6 Aug 2014 19:47:18 +0000 (UTC) Subject: [FFmpeg-devel] Patch - Mov decoder should read Avid's metadata for DNXHD codec References: Message-ID: Marek Fort chyronhego.com> writes: > I'd like to get this patch integrated. Do I understand correctly that this patch does not fix actual decoding (but that it is a prerequisite)? Did you also implement decoding? Regarding the patch, I wondered if it wouldn't be simpler to just call mov_read_extradata() several times with different codec_ids. Carl Eugen From mindmark at gmail.com Wed Aug 6 22:25:07 2014 From: mindmark at gmail.com (Mark Reid) Date: Wed, 6 Aug 2014 13:25:07 -0700 Subject: [FFmpeg-devel] [PATCH] read reel_name metadata from tmcd atom Message-ID: <1407356708-17669-1-git-send-email-mindmark@gmail.com> Hi, This patch reads reel_name stored in the a tmcd atom in a quicktime mov files as documented here: https://developer.apple.com/library/mac/documentation/quicktime/qtff/QTFFChap3/qtff3.html/apple_ref/doc/uid/TP40000939-CH205-57409#//apple_ref/doc/uid/TP40000939-CH205-69831 Its called ???Source reference??? in those docs but I used the metadata key "reel_name" because thats what FFmbc calls it. Mark Reid (1): read reel_name metadata from tmcd atom libavformat/mov.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) -- 2.0.0 From mindmark at gmail.com Wed Aug 6 22:25:08 2014 From: mindmark at gmail.com (Mark Reid) Date: Wed, 6 Aug 2014 13:25:08 -0700 Subject: [FFmpeg-devel] [PATCH] read reel_name metadata from tmcd atom In-Reply-To: <1407356708-17669-1-git-send-email-mindmark@gmail.com> References: <1407356708-17669-1-git-send-email-mindmark@gmail.com> Message-ID: <1407356708-17669-2-git-send-email-mindmark@gmail.com> --- libavformat/mov.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index ab85918..fb8d1fe 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1529,6 +1529,26 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb, st->codec->flags2 |= CODEC_FLAG2_DROP_FRAME_TIMECODE; st->codec->time_base.den = st->codec->extradata[16]; /* number of frame */ st->codec->time_base.num = 1; + if (size > 26) { + uint32_t len = AV_RB32(st->codec->extradata + 18); /* name atom length */ + uint32_t format = AV_RB32(st->codec->extradata + 22); + if (format == AV_RB32("name") && size >= 18 + len) { + uint16_t str_size = AV_RB16(st->codec->extradata + 26); /* string length */ + char *reel_name = av_malloc(str_size + 1); + if (!reel_name) + return AVERROR(ENOMEM); + memcpy(reel_name, st->codec->extradata + 30, str_size); + reel_name[str_size] = 0; /* Add null terminator */ + /* don't add reel_name if emtpy string */ + if (strcmp(reel_name, "") == 0) { + av_free(reel_name); + } + else + { + av_dict_set(&st->metadata, "reel_name", reel_name, AV_DICT_DONT_STRDUP_VAL); + } + } + } } } else { /* other codec type, just skip (rtp, mp4s ...) */ -- 2.0.0 From michaelni at gmx.at Wed Aug 6 23:32:56 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 23:32:56 +0200 Subject: [FFmpeg-devel] LFEScaleIndex larger than 127 is not implemented In-Reply-To: <2FB63A42-D26E-414A-8975-2283CC7D2CE4@idol.io> References: <2FB63A42-D26E-414A-8975-2283CC7D2CE4@idol.io> Message-ID: <20140806213256.GF12391@nb4> Hi On Wed, Aug 06, 2014 at 02:23:33PM +0200, Adrien Montfort wrote: > Hello, > > I?ve uploaded the file 664461_flac_16_44100_2.wav on ftp://upload.ffmpeg.org/incoming/. > Here is my result when I run this command with latest ffmpeg version: > > $ ffmpeg -i 664461_flac_16_44100_2.wav -acodec libfdk_aac -vbr 3 -movflags faststart fixed thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam" -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Wed Aug 6 23:46:58 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Wed, 6 Aug 2014 23:46:58 +0200 Subject: [FFmpeg-devel] [PATCH]Make loas probe more similar to mp3 probe In-Reply-To: <201408062121.18822.cehoyos@ag.or.at> References: <201408052228.38417.cehoyos@ag.or.at> <201408062121.18822.cehoyos@ag.or.at> Message-ID: <20140806214658.GH12391@nb4> On Wed, Aug 06, 2014 at 09:21:18PM +0200, Carl Eugen Hoyos wrote: > On Tuesday 05 August 2014 10:28:38 pm Carl Eugen Hoyos wrote: > > Attached patch copies one line from mp3dec.c into loasdec.c to force > > probing more data and fixes ticket #3821. An alternative is to remove > > the offending line from mp3dec.c (it was added in 2006 or earlier). > > I was unhappy about the patch and iiuc the actual problem is that the > first audio track is initially probed with a score of 25 as h263 and > with a score of 1 as mp3. 1 is not enough (so if I disable the h263 > probe the probe size is increased and loas is correctly detected) but > the 25 are interpreted as the probe value of mp3. > > New patch attached. It stops set_codec_from_probe_data() from > returning probe scores for streams that are not ignored (FFmpeg > doesn't autodetect h263 in mpeg streams) but I suspect it would > still lead to a failure if the audio data is initially detected > as h264 with a score of 25 so a more correct fix is welcome. > > Please review, Carl Eugen > utils.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > 8d7baf722f3b826ed2fc87e0fa227b3f94ffb2b7 patchprobe.diff > diff --git a/libavformat/utils.c b/libavformat/utils.c > index 6ebbe6c..558a141 100644 should be ok too [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The greatest way to live with honor in this world is to be what we pretend to be. -- Socrates -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Thu Aug 7 00:00:03 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 00:00:03 +0200 Subject: [FFmpeg-devel] [PATCH] read reel_name metadata from tmcd atom In-Reply-To: <1407356708-17669-2-git-send-email-mindmark@gmail.com> References: <1407356708-17669-1-git-send-email-mindmark@gmail.com> <1407356708-17669-2-git-send-email-mindmark@gmail.com> Message-ID: <20140806220003.GI12391@nb4> On Wed, Aug 06, 2014 at 01:25:08PM -0700, Mark Reid wrote: > --- > libavformat/mov.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) do you have a sample / testcase that you can share ? > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index ab85918..fb8d1fe 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -1529,6 +1529,26 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb, > st->codec->flags2 |= CODEC_FLAG2_DROP_FRAME_TIMECODE; > st->codec->time_base.den = st->codec->extradata[16]; /* number of frame */ > st->codec->time_base.num = 1; > + if (size > 26) { > + uint32_t len = AV_RB32(st->codec->extradata + 18); /* name atom length */ > + uint32_t format = AV_RB32(st->codec->extradata + 22); > + if (format == AV_RB32("name") && size >= 18 + len) { 18 + len can overflow > + uint16_t str_size = AV_RB16(st->codec->extradata + 26); /* string length */ > + char *reel_name = av_malloc(str_size + 1); > + if (!reel_name) > + return AVERROR(ENOMEM); > + memcpy(reel_name, st->codec->extradata + 30, str_size); this accesses extradata + 30, but the check is just for 26 > + reel_name[str_size] = 0; /* Add null terminator */ > + /* don't add reel_name if emtpy string */ > + if (strcmp(reel_name, "") == 0) { *reel_name == 0 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From jamrial at gmail.com Thu Aug 7 00:07:59 2014 From: jamrial at gmail.com (James Almer) Date: Wed, 6 Aug 2014 19:07:59 -0300 Subject: [FFmpeg-devel] [PATCH] libavcodec/rawdec: remove old ff_find_pix_fmt() function Message-ID: <1407362879-3618-1-git-send-email-jamrial@gmail.com> It's been dead code for more than a year Signed-off-by: James Almer --- libavcodec/libavcodec.v | 1 - libavcodec/raw.h | 4 +--- libavcodec/rawdec.c | 7 ------- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/libavcodec/libavcodec.v b/libavcodec/libavcodec.v index b4bd2c8..76e29f2 100644 --- a/libavcodec/libavcodec.v +++ b/libavcodec/libavcodec.v @@ -3,7 +3,6 @@ LIBAVCODEC_$MAJOR { #deprecated, remove after next bump audio_resample; audio_resample_close; - ff_find_pix_fmt; ff_framenum_to_drop_timecode; ff_framenum_to_smtpe_timecode; ff_raw_pix_fmt_tags; diff --git a/libavcodec/raw.h b/libavcodec/raw.h index a417993..1812825 100644 --- a/libavcodec/raw.h +++ b/libavcodec/raw.h @@ -36,9 +36,7 @@ typedef struct PixelFormatTag { } PixelFormatTag; extern av_export const PixelFormatTag ff_raw_pix_fmt_tags[]; -#if LIBAVCODEC_VERSION_MAJOR < 55 -enum AVPixelFormat ff_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc); -#endif + enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc); extern av_export const PixelFormatTag avpriv_pix_fmt_bps_avi[]; diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index ee1f397..305c13e 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -62,13 +62,6 @@ static const AVClass rawdec_class = { .version = LIBAVUTIL_VERSION_INT, }; -#if LIBAVCODEC_VERSION_MAJOR < 55 -enum AVPixelFormat ff_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc) -{ - return avpriv_find_pix_fmt(tags, fourcc); -} -#endif - static av_cold int raw_init_decoder(AVCodecContext *avctx) { RawVideoContext *context = avctx->priv_data; -- 1.8.5.5 From danieloberhoff at gmail.com Thu Aug 7 00:15:17 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Thu, 7 Aug 2014 00:15:17 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <20140806101233.GM10372@leki> References: <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> Message-ID: Am 06.08.2014 um 12:12 schrieb Cl?ment B?sch : > On Sun, Aug 03, 2014 at 06:43:18PM +0200, Daniel Oberhoff wrote: > [...] >>>> +static av_cold int init(AVFilterContext *ctx) >>>> +{ >>>> + return 0; >>>> +} >>>> >>> >>> please remove this one, there is no point in having code that does nothing. >>> >>>> + >>>> +static av_cold void uninit(AVFilterContext *ctx) >>>> +{ >>>> +} >>>> + >>>> >>> >>> ditto >>> >> >> Done thanks! >> > > Did you forget to attach the latest version of the patch or I missed it > somewhere in the thread? Sorry, think that day I wanted to add something else before resubmit, and then lost the time. Here also with changes suggested by timothy. Note that the parametrization is now traditional (i.e. k1 and k2 are zero-based, as for example in the opencv documentation about calibration). From b798b95eb2f9ec4043b2407970d351cc31dd9e6a Mon Sep 17 00:00:00 2001 From: Daniel Oberhoff Date: Mon, 28 Jul 2014 23:58:12 +0200 Subject: [PATCH] avfilter: ported lenscorrection filter from frei0r --- Changelog | 2 +- MAINTAINERS | 1 + doc/filters.texi | 46 +++++++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/version.h | 4 +- libavfilter/vf_lenscorrection.c | 199 +++++++++++++++++++++++++++ tests/fate/filter-video.mak | 3 + tests/ref/fate/filter-pixfmts-lenscorrection | 8 ++ 9 files changed, 262 insertions(+), 3 deletions(-) create mode 100644 libavfilter/vf_lenscorrection.c create mode 100644 tests/ref/fate/filter-pixfmts-lenscorrection diff --git a/Changelog b/Changelog index 25dd210..79393ce 100644 --- a/Changelog +++ b/Changelog @@ -3,7 +3,7 @@ releases are sorted from youngest to oldest. version : - Icecast protocol - +- ported lenscorrection filter from frei0r filter version 2.3: - AC3 fixed-point decoding diff --git a/MAINTAINERS b/MAINTAINERS index c383d3f..6948e22 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -354,6 +354,7 @@ Filters: vf_histogram.c Paul B Mahol vf_hqx.c Cl?ment B?sch vf_il.c Paul B Mahol + vf_lenscorrection.c Daniel Oberhoff vf_mergeplanes.c Paul B Mahol vf_psnr.c Paul B Mahol vf_scale.c Michael Niedermayer diff --git a/doc/filters.texi b/doc/filters.texi index 86feebc..c4888d3 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -5532,6 +5532,51 @@ kerndeint=map=1 @end example @end itemize + at section lenscorrection + +Correct radial lens distortion + +This filter can be used to correct for radial distortion as can result from the use +of wide angle lenses, and thereby re-rectify the image. To find the right parameters +one can use tools available for example as part of opencv or simply trial-and-error. +To use opencv use the calibration sample (under samples/cpp) from the opencv sources +and extract the k1 and k2 coefficients from the resulting matrix. + +Note that effectively the same filter is available in the open-source tools Krita and +Digikam from the KDE project. + +In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors, +this filter corrects the distortion of the image, whereas @ref{vignette} corrects the +brightness distribution, so you may want to use both filters together in certain +cases, though you will have to take care of ordering, i.e. whether vignetting should +be applied before or after lens correction. + + at subsection Options + +The filter accepts the following options: + + at table @option + at item cx +Relative x-coordinate of the focal point of the image, and thereby the center of the +distrortion. This value has a range [0,1] and is expressed as fractions of the image +width. + at item cy +Relative y-coordinate of the focal point of the image, and thereby the center of the +distrortion. This value has a range [0,1] and is expressed as fractions of the image +height. + at item k1 +Coefficient of the quadratic correction term. 0.5 means no correction. + at item k2 +Coefficient of the double quadratic correction term. 0.5 means no correction. + at end table + +The formula that generates the correction is: + + at var{r_src} = @var{r_tgt} * (1 + @var{k1} * (@var{r_tgt} / @var{r_0})^2 + @var{k2} * (@var{r_tgt} / @var{r_0})^4) + +where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the +distances from the focal point in the source and target images, respectively. + @anchor{lut3d} @section lut3d @@ -8744,6 +8789,7 @@ For example, to vertically flip a video with @command{ffmpeg}: ffmpeg -i in.avi -vf "vflip" out.avi @end example + at anchor{vignette} @section vignette Make or reverse a natural vignetting effect. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 0f54381..e9c8456 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -138,6 +138,7 @@ OBJS-$(CONFIG_IL_FILTER) += vf_il.o OBJS-$(CONFIG_INTERLACE_FILTER) += vf_interlace.o OBJS-$(CONFIG_INTERLEAVE_FILTER) += f_interleave.o OBJS-$(CONFIG_KERNDEINT_FILTER) += vf_kerndeint.o +OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o OBJS-$(CONFIG_LUT3D_FILTER) += vf_lut3d.o OBJS-$(CONFIG_LUT_FILTER) += vf_lut.o OBJS-$(CONFIG_LUTRGB_FILTER) += vf_lut.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 1877557..b1d6ff5 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -156,6 +156,7 @@ void avfilter_register_all(void) REGISTER_FILTER(INTERLACE, interlace, vf); REGISTER_FILTER(INTERLEAVE, interleave, vf); REGISTER_FILTER(KERNDEINT, kerndeint, vf); + REGISTER_FILTER(LENSCORRECTION, lenscorrection, vf); REGISTER_FILTER(LUT3D, lut3d, vf); REGISTER_FILTER(LUT, lut, vf); REGISTER_FILTER(LUTRGB, lutrgb, vf); diff --git a/libavfilter/version.h b/libavfilter/version.h index 1a43dc5..47bac78 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -30,8 +30,8 @@ #include "libavutil/version.h" #define LIBAVFILTER_VERSION_MAJOR 4 -#define LIBAVFILTER_VERSION_MINOR 11 -#define LIBAVFILTER_VERSION_MICRO 102 +#define LIBAVFILTER_VERSION_MINOR 12 +#define LIBAVFILTER_VERSION_MICRO 100 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_lenscorrection.c b/libavfilter/vf_lenscorrection.c new file mode 100644 index 0000000..c2346db --- /dev/null +++ b/libavfilter/vf_lenscorrection.c @@ -0,0 +1,199 @@ +/* + * Copyright (C) 2007 Richard Spindler (author of frei0r plugin from which this was derived) + * Copyright (C) 2014 Daniel Oberhoff + * + * This file is part of FFmpeg. + * + * 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 + */ + +/** + * @file + * Lenscorrection filter, algorithm from the frei0r plugin with the same name +*/ +#include +#include + +#include "libavutil/opt.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/pixdesc.h" + +#include "avfilter.h" +#include "internal.h" +#include "video.h" + +typedef struct LenscorrectionCtx { + const AVClass *av_class; + unsigned int width; + unsigned int height; + int hsub, vsub; + int nb_planes; + double cx, cy, k1, k2; +} LenscorrectionCtx; + +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM +static const AVOption lenscorrection_options[] = { + { "cx", "set relative center x", offsetof(LenscorrectionCtx, cx), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, + { "cy", "set relative center y", offsetof(LenscorrectionCtx, cy), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, + { "k1", "set quadratic distortion factor", offsetof(LenscorrectionCtx, k1), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, .flags=FLAGS }, + { "k2", "set double quadratic distortion factor", offsetof(LenscorrectionCtx, k2), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, .flags=FLAGS }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(lenscorrection); + +typedef struct ThreadData { + AVFrame *in, *out; + float w, h; + int plane; + float xcenter, ycenter; + float k1, k2; +} ThreadData; + +static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs) +{ + ThreadData *td = (ThreadData*)arg; + AVFrame *in = td->in; + AVFrame *out = td->out; + + const float w = td->w, h = td->h; + const float xcenter = td->xcenter; + const float ycenter = td->ycenter; + const float r2inv = 4.0 / (w * w + h * h); + const float k1 = td->k1; + const float k2 = td->k2; + const int start = (h * job ) / nb_jobs; + const int end = (h * (job+1)) / nb_jobs; + const int plane = td->plane; + const int inlinesize = in->linesize[plane]; + const int outlinesize = out->linesize[plane]; + const uint8_t *indata = in->data[plane]; + uint8_t *outrow = out->data[plane] + start * outlinesize; + int i; + for (i = start; i < end; i++, outrow += outlinesize) { + const float off_y = i - ycenter; + const float off_y2 = off_y * off_y; + uint8_t *out = outrow; + int j; + for (j = 0; j < w; j++) { + const float off_x = j - xcenter; + const float r2 = (off_x * off_x + off_y2) * r2inv; + const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2; + const int x = xcenter + radius_mult * off_x + 0.5f; + const int y = ycenter + radius_mult * off_y + 0.5f; + const char isvalid = x > 0 && x < w - 1 && y > 0 && y < h - 1; + *out++ = isvalid ? indata[y * inlinesize + x] : 0; + } + } + return 0; +} + +static int query_formats(AVFilterContext *ctx) +{ + static enum AVPixelFormat pix_fmts[] = { + AV_PIX_FMT_YUV410P, + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, + AV_PIX_FMT_YUV422P, + AV_PIX_FMT_NONE + }; + + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); + return 0; +} + +static int config_props(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + LenscorrectionCtx *rect = ctx->priv; + AVFilterLink *inlink = ctx->inputs[0]; + const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(inlink->format); + rect->hsub = pixdesc->log2_chroma_w; + rect->vsub = pixdesc->log2_chroma_h; + outlink->w = rect->width = inlink->w; + outlink->h = rect->height = inlink->h; + rect->nb_planes = av_pix_fmt_count_planes(inlink->format); + return 0; +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ + AVFilterContext *ctx = inlink->dst; + AVFilterLink *outlink = ctx->outputs[0]; + LenscorrectionCtx *rect = (LenscorrectionCtx*)ctx->priv; + AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h); + int plane; + + if (!out) { + av_frame_free(&in); + return AVERROR(ENOMEM); + } + + av_frame_copy_props(out, in); + + for (plane = 0; plane < rect->nb_planes; ++plane) { + int hsub = plane == 1 || plane == 2 ? rect->hsub : 0; + int vsub = plane == 1 || plane == 2 ? rect->vsub : 0; + float hdiv = 1 << hsub; + float vdiv = 1 << vsub; + float w = rect->width / hdiv; + float h = rect->height / vdiv; + ThreadData td = { + .in = in, + .out = out, + .w = w, + .h = h, + .xcenter = rect->cx * w, + .ycenter = rect->cy * h, + .k1 = rect->k1, + .k2 = rect->k2, + .plane = plane}; + ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ctx->graph->nb_threads)); + } + + av_frame_free(&in); + return ff_filter_frame(outlink, out); +} + +static const AVFilterPad lenscorrection_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = filter_frame, + }, + { NULL } +}; + +static const AVFilterPad lenscorrection_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_props, + }, + { NULL } +}; + +AVFilter ff_vf_lenscorrection = { + .name = "lenscorrection", + .description = NULL_IF_CONFIG_SMALL("Rectify the image by correcting for lens distortion."), + .priv_size = sizeof(LenscorrectionCtx), + .query_formats = query_formats, + .inputs = lenscorrection_inputs, + .outputs = lenscorrection_outputs, + .priv_class = &lenscorrection_class, + .flags = AVFILTER_FLAG_SLICE_THREADS, +}; + \ No newline at end of file diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 053f3e7..f08edf6 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -333,6 +333,9 @@ fate-filter-pixfmts-il: CMD = pixfmts "luma_mode=d:chroma_mode=d:alpha_mode=d FATE_FILTER_PIXFMTS-$(CONFIG_KERNDEINT_FILTER) += fate-filter-pixfmts-kerndeint fate-filter-pixfmts-kerndeint: CMD = pixfmts "" "tinterlace=interleave_top," +FATE_FILTER_PIXFMTS-$(CONFIG_LENSCORRECTION_FILTER) += fate-filter-pixfmts-lenscorrection +fate-filter-pixfmts-lenscorrection: CMD = pixfmts "0.6:0.4:0.65:0.4" + FATE_FILTER_PIXFMTS-$(CONFIG_LUT_FILTER) += fate-filter-pixfmts-lut fate-filter-pixfmts-lut: CMD = pixfmts "c0=2*val:c1=2*val:c2=val/2:c3=negval+40" diff --git a/tests/ref/fate/filter-pixfmts-lenscorrection b/tests/ref/fate/filter-pixfmts-lenscorrection new file mode 100644 index 0000000..18af6fb --- /dev/null +++ b/tests/ref/fate/filter-pixfmts-lenscorrection @@ -0,0 +1,8 @@ +yuv410p e7d59dbdb1afab7e2a8f770d563e28c4 +yuv420p bc45b4762d5271410ff825317c85af64 +yuv422p 5cce0c299322634d65e6b32c976e2c12 +yuv444p 03de9a93ab3045a523b234ea93f21c91 +yuva420p d1fa6735c4e7fbbf3a501cec1f0b4ac1 +yuva444p 713ddf5861d3df11c70a242a13c5e92e +yuvj420p 1d5cccaf4ef568ae9fa36f9a28e71c34 +yuvj444p aef1db29848e3b1dcaf4309255c38cbd -- 1.8.2 From mindmark at gmail.com Thu Aug 7 00:29:04 2014 From: mindmark at gmail.com (Mark Reid) Date: Wed, 6 Aug 2014 15:29:04 -0700 Subject: [FFmpeg-devel] [PATCH] read reel_name metadata from tmcd atom In-Reply-To: <20140806220003.GI12391@nb4> References: <1407356708-17669-1-git-send-email-mindmark@gmail.com> <1407356708-17669-2-git-send-email-mindmark@gmail.com> <20140806220003.GI12391@nb4> Message-ID: Thanks for the quick feed back! I attached a small sample file, the media was generated with Davinci Resolve. On Wed, Aug 6, 2014 at 3:00 PM, Michael Niedermayer wrote: > On Wed, Aug 06, 2014 at 01:25:08PM -0700, Mark Reid wrote: > > --- > > libavformat/mov.c | 20 ++++++++++++++++++++ > > 1 file changed, 20 insertions(+) > > do you have a sample / testcase that you can share ? > > > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > index ab85918..fb8d1fe 100644 > > --- a/libavformat/mov.c > > +++ b/libavformat/mov.c > > @@ -1529,6 +1529,26 @@ static int mov_parse_stsd_data(MOVContext *c, > AVIOContext *pb, > > st->codec->flags2 |= CODEC_FLAG2_DROP_FRAME_TIMECODE; > > st->codec->time_base.den = st->codec->extradata[16]; /* > number of frame */ > > st->codec->time_base.num = 1; > > + if (size > 26) { > > + uint32_t len = AV_RB32(st->codec->extradata + 18); /* > name atom length */ > > + uint32_t format = AV_RB32(st->codec->extradata + 22); > > > + if (format == AV_RB32("name") && size >= 18 + len) { > > 18 + len can overflow > > > > + uint16_t str_size = AV_RB16(st->codec->extradata + > 26); /* string length */ > > + char *reel_name = av_malloc(str_size + 1); > > + if (!reel_name) > > + return AVERROR(ENOMEM); > > + memcpy(reel_name, st->codec->extradata + 30, > str_size); > > this accesses extradata + 30, but the check is just for 26 > > > > + reel_name[str_size] = 0; /* Add null terminator */ > > + /* don't add reel_name if emtpy string */ > > > + if (strcmp(reel_name, "") == 0) { > > *reel_name == 0 > > [...] > > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Avoid a single point of failure, be that a person or equipment. > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > -------------- next part -------------- A non-text attachment was scrubbed... Name: example_reel_name.mov Type: video/quicktime Size: 30045 bytes Desc: not available URL: From michaelni at gmx.at Thu Aug 7 00:48:03 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 00:48:03 +0200 Subject: [FFmpeg-devel] [PATCH] read reel_name metadata from tmcd atom In-Reply-To: References: <1407356708-17669-1-git-send-email-mindmark@gmail.com> <1407356708-17669-2-git-send-email-mindmark@gmail.com> <20140806220003.GI12391@nb4> Message-ID: <20140806224803.GJ12391@nb4> On Wed, Aug 06, 2014 at 03:29:04PM -0700, Mark Reid wrote: > Thanks for the quick feed back! I attached a small sample file, the media > was generated with Davinci Resolve. thanks did you see the patch comments below ? you didnt reply to them so i had the feeling you missed them, just want to make sure you dont miss them and each waits on the other deadlocking patch review ;) no hurry with resubmitting > > > On Wed, Aug 6, 2014 at 3:00 PM, Michael Niedermayer > wrote: > > > On Wed, Aug 06, 2014 at 01:25:08PM -0700, Mark Reid wrote: > > > --- > > > libavformat/mov.c | 20 ++++++++++++++++++++ > > > 1 file changed, 20 insertions(+) > > > > do you have a sample / testcase that you can share ? > > > > > > > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > > index ab85918..fb8d1fe 100644 > > > --- a/libavformat/mov.c > > > +++ b/libavformat/mov.c > > > @@ -1529,6 +1529,26 @@ static int mov_parse_stsd_data(MOVContext *c, > > AVIOContext *pb, > > > st->codec->flags2 |= CODEC_FLAG2_DROP_FRAME_TIMECODE; > > > st->codec->time_base.den = st->codec->extradata[16]; /* > > number of frame */ > > > st->codec->time_base.num = 1; > > > + if (size > 26) { > > > + uint32_t len = AV_RB32(st->codec->extradata + 18); /* > > name atom length */ > > > + uint32_t format = AV_RB32(st->codec->extradata + 22); > > > > > + if (format == AV_RB32("name") && size >= 18 + len) { > > > > 18 + len can overflow > > > > > > > + uint16_t str_size = AV_RB16(st->codec->extradata + > > 26); /* string length */ > > > + char *reel_name = av_malloc(str_size + 1); > > > + if (!reel_name) > > > + return AVERROR(ENOMEM); > > > + memcpy(reel_name, st->codec->extradata + 30, > > str_size); > > > > this accesses extradata + 30, but the check is just for 26 > > > > > > > + reel_name[str_size] = 0; /* Add null terminator */ > > > + /* don't add reel_name if emtpy string */ > > > > > + if (strcmp(reel_name, "") == 0) { > > > > *reel_name == 0 > > > > [...] > > > > -- > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > > > Avoid a single point of failure, be that a person or equipment. > > > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel at ffmpeg.org > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Thu Aug 7 01:12:32 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 01:12:32 +0200 Subject: [FFmpeg-devel] [PATCH] libavcodec/rawdec: remove old ff_find_pix_fmt() function In-Reply-To: <1407362879-3618-1-git-send-email-jamrial@gmail.com> References: <1407362879-3618-1-git-send-email-jamrial@gmail.com> Message-ID: <20140806231232.GK12391@nb4> On Wed, Aug 06, 2014 at 07:07:59PM -0300, James Almer wrote: > It's been dead code for more than a year > > Signed-off-by: James Almer > --- > libavcodec/libavcodec.v | 1 - > libavcodec/raw.h | 4 +--- > libavcodec/rawdec.c | 7 ------- > 3 files changed, 1 insertion(+), 11 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 3 "Rare item" - "Common item with rare defect or maybe just a lie" "Professional" - "'Toy' made in china, not functional except as doorstop" "Experts will know" - "The seller hopes you are not an expert" -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From mindmark at gmail.com Thu Aug 7 01:37:06 2014 From: mindmark at gmail.com (Mark Reid) Date: Wed, 6 Aug 2014 16:37:06 -0700 Subject: [FFmpeg-devel] [PATCH] read reel_name metadata from tmcd atom In-Reply-To: <20140806224803.GJ12391@nb4> References: <1407356708-17669-1-git-send-email-mindmark@gmail.com> <1407356708-17669-2-git-send-email-mindmark@gmail.com> <20140806220003.GI12391@nb4> <20140806224803.GJ12391@nb4> Message-ID: opps sorry, yes I saw patch the patch comments :) I'll work on another patch with those things fixed! On Wed, Aug 6, 2014 at 3:48 PM, Michael Niedermayer wrote: > On Wed, Aug 06, 2014 at 03:29:04PM -0700, Mark Reid wrote: > > Thanks for the quick feed back! I attached a small sample file, the media > > was generated with Davinci Resolve. > > > thanks > did you see the patch comments below ? > you didnt reply to them so i had the feeling you missed them, just > want to make sure you dont miss them and each waits on the other > deadlocking patch review ;) > no hurry with resubmitting > > > > > > > > On Wed, Aug 6, 2014 at 3:00 PM, Michael Niedermayer > > wrote: > > > > > On Wed, Aug 06, 2014 at 01:25:08PM -0700, Mark Reid wrote: > > > > --- > > > > libavformat/mov.c | 20 ++++++++++++++++++++ > > > > 1 file changed, 20 insertions(+) > > > > > > do you have a sample / testcase that you can share ? > > > > > > > > > > > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > > > index ab85918..fb8d1fe 100644 > > > > --- a/libavformat/mov.c > > > > +++ b/libavformat/mov.c > > > > @@ -1529,6 +1529,26 @@ static int mov_parse_stsd_data(MOVContext *c, > > > AVIOContext *pb, > > > > st->codec->flags2 |= > CODEC_FLAG2_DROP_FRAME_TIMECODE; > > > > st->codec->time_base.den = st->codec->extradata[16]; /* > > > number of frame */ > > > > st->codec->time_base.num = 1; > > > > + if (size > 26) { > > > > + uint32_t len = AV_RB32(st->codec->extradata + 18); > /* > > > name atom length */ > > > > + uint32_t format = AV_RB32(st->codec->extradata + > 22); > > > > > > > + if (format == AV_RB32("name") && size >= 18 + len) { > > > > > > 18 + len can overflow > > > > > > > > > > + uint16_t str_size = > AV_RB16(st->codec->extradata + > > > 26); /* string length */ > > > > + char *reel_name = av_malloc(str_size + 1); > > > > + if (!reel_name) > > > > + return AVERROR(ENOMEM); > > > > + memcpy(reel_name, st->codec->extradata + 30, > > > str_size); > > > > > > this accesses extradata + 30, but the check is just for 26 > > > > > > > > > > + reel_name[str_size] = 0; /* Add null terminator > */ > > > > + /* don't add reel_name if emtpy string */ > > > > > > > + if (strcmp(reel_name, "") == 0) { > > > > > > *reel_name == 0 > > > > > > [...] > > > > > > -- > > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > > > > > Avoid a single point of failure, be that a person or equipment. > > > > > > _______________________________________________ > > > ffmpeg-devel mailing list > > > ffmpeg-devel at ffmpeg.org > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > > > > > > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel at ffmpeg.org > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > I am the wisest man alive, for I know one thing, and that is that I know > nothing. -- Socrates > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > From lukasz.m.luki2 at gmail.com Thu Aug 7 01:58:55 2014 From: lukasz.m.luki2 at gmail.com (Lukasz Marek) Date: Thu, 7 Aug 2014 01:58:55 +0200 Subject: [FFmpeg-devel] [PATCH 1/3] lavd/pulse_audio_dec: use default source when no input provided Message-ID: <1407369537-25633-1-git-send-email-lukasz.m.luki2@gmail.com> PulseAudio expilitly requires name of the source. This patch makes it use default source when not provided. It simplifies programistic use. Signed-off-by: Lukasz Marek --- libavdevice/pulse_audio_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavdevice/pulse_audio_dec.c b/libavdevice/pulse_audio_dec.c index 01ff6d1..a7b0e5d 100644 --- a/libavdevice/pulse_audio_dec.c +++ b/libavdevice/pulse_audio_dec.c @@ -154,7 +154,7 @@ static av_cold int pulse_read_header(AVFormatContext *s) attr.fragsize = pd->fragment_size; - if (strcmp(s->filename, "default")) + if (s->filename[0] != '\0' && strcmp(s->filename, "default")) device = s->filename; if (!(pd->mainloop = pa_threaded_mainloop_new())) { -- 1.9.1 From lukasz.m.luki2 at gmail.com Thu Aug 7 01:58:56 2014 From: lukasz.m.luki2 at gmail.com (Lukasz Marek) Date: Thu, 7 Aug 2014 01:58:56 +0200 Subject: [FFmpeg-devel] [PATCH 2/3] lavu/log: add device category macros In-Reply-To: <1407369537-25633-1-git-send-email-lukasz.m.luki2@gmail.com> References: <1407369537-25633-1-git-send-email-lukasz.m.luki2@gmail.com> Message-ID: <1407369537-25633-2-git-send-email-lukasz.m.luki2@gmail.com> --- libavutil/log.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavutil/log.h b/libavutil/log.h index a6a07e0..e1ff09b 100644 --- a/libavutil/log.h +++ b/libavutil/log.h @@ -46,6 +46,16 @@ typedef enum { AV_CLASS_CATEGORY_NB, ///< not part of ABI/API }AVClassCategory; +#define AV_IS_INPUT_DEVICE(category) \ + (((category) == AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT) || \ + ((category) == AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT) || \ + ((category) == AV_CLASS_CATEGORY_DEVICE_INPUT)) + +#define AV_IS_OUTPUT_DEVICE(category) \ + (((category) == AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT) || \ + ((category) == AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT) || \ + ((category) == AV_CLASS_CATEGORY_DEVICE_OUTPUT)) + struct AVOptionRanges; /** -- 1.9.1 From lukasz.m.luki2 at gmail.com Thu Aug 7 01:58:57 2014 From: lukasz.m.luki2 at gmail.com (Lukasz Marek) Date: Thu, 7 Aug 2014 01:58:57 +0200 Subject: [FFmpeg-devel] [PATCH 3/3] opts: add list device sources/sinks options In-Reply-To: <1407369537-25633-1-git-send-email-lukasz.m.luki2@gmail.com> References: <1407369537-25633-1-git-send-email-lukasz.m.luki2@gmail.com> Message-ID: <1407369537-25633-3-git-send-email-lukasz.m.luki2@gmail.com> Allows to list sources/sinks of the devices that implement that functionality. Signed-off-by: Lukasz Marek --- cmdutils.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++ cmdutils.h | 12 +++++++ cmdutils_common_opts.h | 6 ++++ 3 files changed, 107 insertions(+) diff --git a/cmdutils.c b/cmdutils.c index 67bb66e..defcf0a 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -2050,3 +2050,92 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) } return array; } + + +int show_sources(void *optctx, const char *opt, const char *arg) +{ +#if CONFIG_AVDEVICE + AVDeviceInfoList *device_list = NULL; + AVFormatContext *dev = NULL; + AVInputFormat *fmt; + int ret, i; + + if (!arg) { + printf("Device name is missing.\n"); + return AVERROR(EINVAL); + } + + fmt = av_find_input_format(arg); + if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category)) { + printf("No such device: %s\n", arg); + return AVERROR(EINVAL); + } + + if ((ret = avformat_open_input(&dev, NULL, fmt, NULL)) < 0) { + printf("Cannot open device: %s\n", arg); + goto fail; + } + + if ((ret = avdevice_list_devices(dev, &device_list)) < 0) { + printf("Cannot list devices\n"); + goto fail; + } + printf("Audo-detected sinks for %s:\n", arg); + for (i = 0; i < device_list->nb_devices; i++) { + printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ", + device_list->devices[i]->device_name, device_list->devices[i]->device_description); + } + + fail: + avdevice_free_list_devices(&device_list); + avformat_close_input(&dev); + return ret; +#else + printf("Configured without libavdevice\n"); + return AVERROR(ENOSYS); +#endif +} + +int show_sinks(void *optctx, const char *opt, const char *arg) +{ +#if CONFIG_AVDEVICE + AVDeviceInfoList *device_list = NULL; + AVFormatContext *dev = NULL; + AVOutputFormat *fmt; + int ret, i; + + if (!arg) { + printf("Device name is missing.\n"); + return AVERROR(EINVAL); + } + + fmt = av_guess_format(arg, NULL, NULL); + if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category)) { + printf("No such device: %s\n", arg); + return AVERROR(EINVAL); + } + + if ((ret = avformat_alloc_output_context2(&dev, fmt, NULL, NULL)) < 0) { + printf("Cannot open device: %s\n", arg); + goto fail; + } + + if ((ret = avdevice_list_devices(dev, &device_list)) < 0) { + printf("Cannot list devices\n"); + goto fail; + } + printf("Audo-detected sinks for %s:\n", arg); + for (i = 0; i < device_list->nb_devices; i++) { + printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ", + device_list->devices[i]->device_name, device_list->devices[i]->device_description); + } + + fail: + avdevice_free_list_devices(&device_list); + avformat_close_input(&dev); + return ret; +#else + printf("Configured without libavdevice\n"); + return AVERROR(ENOSYS); +#endif +} diff --git a/cmdutils.h b/cmdutils.h index 76d11a5..cb34876 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -444,6 +444,18 @@ int show_formats(void *optctx, const char *opt, const char *arg); int show_devices(void *optctx, const char *opt, const char *arg); /** + * Print a listing containing audodetected sinks of the output device. + * Device name must be passed as an argument. + */ +int show_sinks(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing audodetected sources of the input device. + * Device name must be passed as an argument. + */ +int show_sources(void *optctx, const char *opt, const char *arg); + +/** * Print a listing containing all the codecs supported by the * program. * This option processing function does not utilize the arguments. diff --git a/cmdutils_common_opts.h b/cmdutils_common_opts.h index 49b5180..758dac1 100644 --- a/cmdutils_common_opts.h +++ b/cmdutils_common_opts.h @@ -27,3 +27,9 @@ { "opencl_bench", OPT_EXIT, {.func_arg = opt_opencl_bench}, "run benchmark on all OpenCL devices and show results" }, { "opencl_options", HAS_ARG, {.func_arg = opt_opencl}, "set OpenCL environment options" }, #endif +#if CONFIG_AVDEVICE + { "sources" , OPT_EXIT | HAS_ARG, { .func_arg = show_sources }, + "list sources of the input device", "device" }, + { "sinks" , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks }, + "list sinks of the output device", "device" }, +#endif -- 1.9.1 From jamrial at gmail.com Thu Aug 7 01:59:56 2014 From: jamrial at gmail.com (James Almer) Date: Wed, 6 Aug 2014 20:59:56 -0300 Subject: [FFmpeg-devel] [PATCH] lavf/mpegts: rename ff_mpegts_parse_*() to avpriv_mpegts_parse_*() Message-ID: <1407369596-3906-1-git-send-email-jamrial@gmail.com> The were wrongly being exported and used by libavdevice Signed-off-by: James Almer --- libavdevice/iec61883.c | 8 ++++---- libavformat/mpegts.c | 26 ++++++++++++++++++++++---- libavformat/mpegts.h | 7 +++++++ libavformat/rtpdec_mpegts.c | 12 ++++++------ libavformat/rtsp.c | 8 ++++---- libavformat/version.h | 2 +- 6 files changed, 44 insertions(+), 19 deletions(-) diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c index 401c3dd..6d5ec4a 100644 --- a/libavdevice/iec61883.c +++ b/libavdevice/iec61883.c @@ -216,8 +216,8 @@ static int iec61883_parse_queue_hdv(struct iec61883_data *dv, AVPacket *pkt) while (dv->queue_first) { packet = dv->queue_first; - size = ff_mpegts_parse_packet(dv->mpeg_demux, pkt, packet->buf, - packet->len); + size = avpriv_mpegts_parse_packet(dv->mpeg_demux, pkt, packet->buf, + packet->len); dv->queue_first = packet->next; av_free(packet->buf); av_free(packet); @@ -356,7 +356,7 @@ static int iec61883_read_header(AVFormatContext *context) avformat_new_stream(context, NULL); - dv->mpeg_demux = ff_mpegts_parse_open(context); + dv->mpeg_demux = avpriv_mpegts_parse_open(context); if (!dv->mpeg_demux) goto fail; @@ -447,7 +447,7 @@ static int iec61883_close(AVFormatContext *context) if (dv->type == IEC61883_HDV) { iec61883_mpeg2_recv_stop(dv->iec61883_mpeg2); iec61883_mpeg2_close(dv->iec61883_mpeg2); - ff_mpegts_parse_close(dv->mpeg_demux); + avpriv_mpegts_parse_close(dv->mpeg_demux); } else { iec61883_dv_fb_stop(dv->iec61883_dv); iec61883_dv_fb_close(dv->iec61883_dv); diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 405cade..55816de 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2625,7 +2625,7 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index, /**************************************************************/ /* parsing functions - called from other demuxers such as RTP */ -MpegTSContext *ff_mpegts_parse_open(AVFormatContext *s) +MpegTSContext *avpriv_mpegts_parse_open(AVFormatContext *s) { MpegTSContext *ts; @@ -2644,8 +2644,8 @@ MpegTSContext *ff_mpegts_parse_open(AVFormatContext *s) /* return the consumed length if a packet was output, or -1 if no * packet is output */ -int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, - const uint8_t *buf, int len) +int avpriv_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, + const uint8_t *buf, int len) { int len1; @@ -2669,12 +2669,30 @@ int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, return len1 - len; } -void ff_mpegts_parse_close(MpegTSContext *ts) +void avpriv_mpegts_parse_close(MpegTSContext *ts) { mpegts_free(ts); av_free(ts); } +#if LIBAVFORMAT_VERSION_MAJOR < 56 +MpegTSContext *ff_mpegts_parse_open(AVFormatContext *s) +{ + return avpriv_mpegts_parse_open(s); +} + +int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, + const uint8_t *buf, int len) +{ + return avpriv_mpegts_parse_packet(ts, pkt, buf, len); +} + +void ff_mpegts_parse_close(MpegTSContext *ts) +{ + return avpriv_mpegts_parse_close(ts); +} +#endif + AVInputFormat ff_mpegts_demuxer = { .name = "mpegts", .long_name = NULL_IF_CONFIG_SMALL("MPEG-TS (MPEG-2 Transport Stream)"), diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h index 50a0259..1cd1ba1 100644 --- a/libavformat/mpegts.h +++ b/libavformat/mpegts.h @@ -63,10 +63,17 @@ typedef struct MpegTSContext MpegTSContext; +MpegTSContext *avpriv_mpegts_parse_open(AVFormatContext *s); +int avpriv_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, + const uint8_t *buf, int len); +void avpriv_mpegts_parse_close(MpegTSContext *ts); + +#if LIBAVFORMAT_VERSION_MAJOR < 56 MpegTSContext *ff_mpegts_parse_open(AVFormatContext *s); int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len); void ff_mpegts_parse_close(MpegTSContext *ts); +#endif typedef struct SLConfigDescr { int use_au_start; diff --git a/libavformat/rtpdec_mpegts.c b/libavformat/rtpdec_mpegts.c index 5b851c4..0c2b717 100644 --- a/libavformat/rtpdec_mpegts.c +++ b/libavformat/rtpdec_mpegts.c @@ -40,14 +40,14 @@ static void mpegts_free_context(PayloadContext *data) if (!data) return; if (data->ts) - ff_mpegts_parse_close(data->ts); + avpriv_mpegts_parse_close(data->ts); av_free(data); } static av_cold int mpegts_init(AVFormatContext *ctx, int st_index, PayloadContext *data) { - data->ts = ff_mpegts_parse_open(ctx); + data->ts = avpriv_mpegts_parse_open(ctx); if (!data->ts) return AVERROR(ENOMEM); return 0; @@ -72,8 +72,8 @@ static int mpegts_handle_packet(AVFormatContext *ctx, PayloadContext *data, if (!buf) { if (data->read_buf_index >= data->read_buf_size) return AVERROR(EAGAIN); - ret = ff_mpegts_parse_packet(data->ts, pkt, data->buf + data->read_buf_index, - data->read_buf_size - data->read_buf_index); + ret = avpriv_mpegts_parse_packet(data->ts, pkt, data->buf + data->read_buf_index, + data->read_buf_size - data->read_buf_index); if (ret < 0) return AVERROR(EAGAIN); data->read_buf_index += ret; @@ -83,8 +83,8 @@ static int mpegts_handle_packet(AVFormatContext *ctx, PayloadContext *data, return 0; } - ret = ff_mpegts_parse_packet(data->ts, pkt, buf, len); - /* The only error that can be returned from ff_mpegts_parse_packet + ret = avpriv_mpegts_parse_packet(data->ts, pkt, buf, len); + /* The only error that can be returned from avpriv_mpegts_parse_packet * is "no more data to return from the provided buffer", so return * AVERROR(EAGAIN) for all errors */ if (ret < 0) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 5212dde..ce4763e 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -439,7 +439,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, /* no corresponding stream */ if (rt->transport == RTSP_TRANSPORT_RAW) { if (!rt->ts && CONFIG_RTPDEC) - rt->ts = ff_mpegts_parse_open(s); + rt->ts = avpriv_mpegts_parse_open(s); } else { RTPDynamicProtocolHandler *handler; handler = ff_rtp_handler_find_by_id( @@ -728,7 +728,7 @@ void ff_rtsp_close_streams(AVFormatContext *s) avformat_close_input(&rt->asf_ctx); } if (rt->ts && CONFIG_RTPDEC) - ff_mpegts_parse_close(rt->ts); + avpriv_mpegts_parse_close(rt->ts); av_free(rt->p); av_free(rt->recvbuf); } @@ -1977,7 +1977,7 @@ int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt) } else if (rt->transport == RTSP_TRANSPORT_RTP) { ret = ff_rtp_parse_packet(rt->cur_transport_priv, pkt, NULL, 0); } else if (rt->ts && CONFIG_RTPDEC) { - ret = ff_mpegts_parse_packet(rt->ts, pkt, rt->recvbuf + rt->recvbuf_pos, rt->recvbuf_len - rt->recvbuf_pos); + ret = avpriv_mpegts_parse_packet(rt->ts, pkt, rt->recvbuf + rt->recvbuf_pos, rt->recvbuf_len - rt->recvbuf_pos); if (ret >= 0) { rt->recvbuf_pos += ret; ret = rt->recvbuf_pos < rt->recvbuf_len; @@ -2116,7 +2116,7 @@ redo: } } } else if (rt->ts && CONFIG_RTPDEC) { - ret = ff_mpegts_parse_packet(rt->ts, pkt, rt->recvbuf, len); + ret = avpriv_mpegts_parse_packet(rt->ts, pkt, rt->recvbuf, len); if (ret >= 0) { if (ret < len) { rt->recvbuf_len = len; diff --git a/libavformat/version.h b/libavformat/version.h index 9a1c40c..82f2eac 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,7 @@ #define LIBAVFORMAT_VERSION_MAJOR 55 -#define LIBAVFORMAT_VERSION_MINOR 51 +#define LIBAVFORMAT_VERSION_MINOR 52 #define LIBAVFORMAT_VERSION_MICRO 101 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ -- 1.8.5.5 From jamrial at gmail.com Thu Aug 7 03:14:42 2014 From: jamrial at gmail.com (James Almer) Date: Wed, 6 Aug 2014 22:14:42 -0300 Subject: [FFmpeg-devel] [PATCH] avcodec/raw: add avpriv_get_raw_pix_fmt_tags() Message-ID: <1407374082-4076-1-git-send-email-jamrial@gmail.com> Used to expose ff_raw_pix_fmt_tags[] to other libav* libraries Signed-off-by: James Almer --- libavcodec/raw.c | 5 +++++ libavcodec/raw.h | 6 ++++++ libavdevice/dshow.c | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libavcodec/raw.c b/libavcodec/raw.c index 56c4a6b..62ad338 100644 --- a/libavcodec/raw.c +++ b/libavcodec/raw.c @@ -224,6 +224,11 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { AV_PIX_FMT_NONE, 0 }, }; +const struct PixelFormatTag *avpriv_get_raw_pix_fmt_tags(void) +{ + return ff_raw_pix_fmt_tags; +} + unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt) { const PixelFormatTag *tags = ff_raw_pix_fmt_tags; diff --git a/libavcodec/raw.h b/libavcodec/raw.h index 1812825..a79b851 100644 --- a/libavcodec/raw.h +++ b/libavcodec/raw.h @@ -35,7 +35,13 @@ typedef struct PixelFormatTag { unsigned int fourcc; } PixelFormatTag; +#if LIBAVCODEC_VERSION_MAJOR < 56 extern av_export const PixelFormatTag ff_raw_pix_fmt_tags[]; +#else +extern const PixelFormatTag ff_raw_pix_fmt_tags[]; // exposed through avpriv_get_raw_pix_fmt_tags() +#endif + +const struct PixelFormatTag *avpriv_get_raw_pix_fmt_tags(void); enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc); diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index adf36a7..e10ae4c 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -74,6 +74,7 @@ struct dshow_ctx { static enum AVPixelFormat dshow_pixfmt(DWORD biCompression, WORD biBitCount) { + const PixelFormatTag *tags = avpriv_get_raw_pix_fmt_tags(); switch(biCompression) { case BI_BITFIELDS: case BI_RGB: @@ -92,7 +93,7 @@ static enum AVPixelFormat dshow_pixfmt(DWORD biCompression, WORD biBitCount) return AV_PIX_FMT_0RGB32; } } - return avpriv_find_pix_fmt(ff_raw_pix_fmt_tags, biCompression); // all others + return avpriv_find_pix_fmt(tags, biCompression); // all others } static int -- 1.8.5.5 From michaelni at gmx.at Thu Aug 7 04:29:16 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 04:29:16 +0200 Subject: [FFmpeg-devel] [PATCH] lavf/mpegts: rename ff_mpegts_parse_*() to avpriv_mpegts_parse_*() In-Reply-To: <1407369596-3906-1-git-send-email-jamrial@gmail.com> References: <1407369596-3906-1-git-send-email-jamrial@gmail.com> Message-ID: <20140807022916.GL12391@nb4> On Wed, Aug 06, 2014 at 08:59:56PM -0300, James Almer wrote: > The were wrongly being exported and used by libavdevice > > Signed-off-by: James Almer > --- > libavdevice/iec61883.c | 8 ++++---- > libavformat/mpegts.c | 26 ++++++++++++++++++++++---- > libavformat/mpegts.h | 7 +++++++ > libavformat/rtpdec_mpegts.c | 12 ++++++------ > libavformat/rtsp.c | 8 ++++---- > libavformat/version.h | 2 +- > 6 files changed, 44 insertions(+), 19 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From jamrial at gmail.com Thu Aug 7 05:43:03 2014 From: jamrial at gmail.com (James Almer) Date: Thu, 7 Aug 2014 00:43:03 -0300 Subject: [FFmpeg-devel] [PATCH] lavd/dshow: use av_codec_get_id() Message-ID: <1407382983-4329-1-git-send-email-jamrial@gmail.com> ff_codec_get_id() is a lavf internal function Signed-off-by: James Almer --- libavdevice/dshow.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index adf36a7..cd509fc 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -352,6 +352,7 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype, VIDEO_STREAM_CONFIG_CAPS *vcaps = caps; BITMAPINFOHEADER *bih; int64_t *fr; + const AVCodecTag *const tags[] = { avformat_get_riff_video_tags(), NULL }; #if DSHOWDEBUG ff_print_VIDEO_STREAM_CONFIG_CAPS(vcaps); #endif @@ -369,7 +370,7 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype, if (!pformat_set) { enum AVPixelFormat pix_fmt = dshow_pixfmt(bih->biCompression, bih->biBitCount); if (pix_fmt == AV_PIX_FMT_NONE) { - enum AVCodecID codec_id = ff_codec_get_id(avformat_get_riff_video_tags(), bih->biCompression); + enum AVCodecID codec_id = av_codec_get_id(tags, bih->biCompression); AVCodec *codec = avcodec_find_decoder(codec_id); if (codec_id == AV_CODEC_ID_NONE || !codec) { av_log(avctx, AV_LOG_INFO, " unknown compression type 0x%X", (int) bih->biCompression); @@ -387,7 +388,7 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype, continue; } if (ctx->video_codec_id != AV_CODEC_ID_RAWVIDEO) { - if (ctx->video_codec_id != ff_codec_get_id(avformat_get_riff_video_tags(), bih->biCompression)) + if (ctx->video_codec_id != av_codec_get_id(tags, bih->biCompression)) goto next; } if (ctx->pixel_format != AV_PIX_FMT_NONE && @@ -780,7 +781,8 @@ dshow_add_device(AVFormatContext *avctx, codec->color_range = AVCOL_RANGE_MPEG; // just in case it needs this... } if (codec->pix_fmt == AV_PIX_FMT_NONE) { - codec->codec_id = ff_codec_get_id(avformat_get_riff_video_tags(), bih->biCompression); + const AVCodecTag *const tags[] = { avformat_get_riff_video_tags(), NULL }; + codec->codec_id = av_codec_get_id(tags, bih->biCompression); if (codec->codec_id == AV_CODEC_ID_NONE) { av_log(avctx, AV_LOG_ERROR, "Unknown compression type. " "Please report type 0x%X.\n", (int) bih->biCompression); -- 1.8.5.5 From jamrial at gmail.com Thu Aug 7 06:22:48 2014 From: jamrial at gmail.com (James Almer) Date: Thu, 7 Aug 2014 01:22:48 -0300 Subject: [FFmpeg-devel] [PATCH] avcodec/raw: add avpriv_get_raw_pix_fmt_tags() In-Reply-To: <1407374082-4076-1-git-send-email-jamrial@gmail.com> References: <1407374082-4076-1-git-send-email-jamrial@gmail.com> Message-ID: <1407385368-13716-1-git-send-email-jamrial@gmail.com> Used to expose ff_raw_pix_fmt_tags[] to other libav* libraries Signed-off-by: James Almer --- libavcodec/raw.c | 5 +++++ libavcodec/raw.h | 6 ++++++ libavdevice/dshow.c | 2 +- libavformat/utils.c | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/libavcodec/raw.c b/libavcodec/raw.c index 56c4a6b..62ad338 100644 --- a/libavcodec/raw.c +++ b/libavcodec/raw.c @@ -224,6 +224,11 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { AV_PIX_FMT_NONE, 0 }, }; +const struct PixelFormatTag *avpriv_get_raw_pix_fmt_tags(void) +{ + return ff_raw_pix_fmt_tags; +} + unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt) { const PixelFormatTag *tags = ff_raw_pix_fmt_tags; diff --git a/libavcodec/raw.h b/libavcodec/raw.h index 1812825..a79b851 100644 --- a/libavcodec/raw.h +++ b/libavcodec/raw.h @@ -35,7 +35,13 @@ typedef struct PixelFormatTag { unsigned int fourcc; } PixelFormatTag; +#if LIBAVCODEC_VERSION_MAJOR < 56 extern av_export const PixelFormatTag ff_raw_pix_fmt_tags[]; +#else +extern const PixelFormatTag ff_raw_pix_fmt_tags[]; // exposed through avpriv_get_raw_pix_fmt_tags() +#endif + +const struct PixelFormatTag *avpriv_get_raw_pix_fmt_tags(void); enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc); diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index adf36a7..2c098d4 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -92,7 +92,7 @@ static enum AVPixelFormat dshow_pixfmt(DWORD biCompression, WORD biBitCount) return AV_PIX_FMT_0RGB32; } } - return avpriv_find_pix_fmt(ff_raw_pix_fmt_tags, biCompression); // all others + return avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), biCompression); // all others } static int diff --git a/libavformat/utils.c b/libavformat/utils.c index 6ebbe6c..643433f 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3275,7 +3275,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (st->codec->codec_id == AV_CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_coded_sample) { uint32_t tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt); - if (avpriv_find_pix_fmt(ff_raw_pix_fmt_tags, tag) == st->codec->pix_fmt) + if (avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), tag) == st->codec->pix_fmt) st->codec->codec_tag= tag; } -- 1.8.5.5 From jamrial at gmail.com Thu Aug 7 07:12:45 2014 From: jamrial at gmail.com (James Almer) Date: Thu, 7 Aug 2014 02:12:45 -0300 Subject: [FFmpeg-devel] [PATCH 1/2] lavc: remove nonexistent functions from the version file Message-ID: <1407388366-14138-1-git-send-email-jamrial@gmail.com> Signed-off-by: James Almer --- The rest should *really* be removed on the next bump libavcodec/libavcodec.v | 7 ------- 1 file changed, 7 deletions(-) diff --git a/libavcodec/libavcodec.v b/libavcodec/libavcodec.v index 76e29f2..be74cb3 100644 --- a/libavcodec/libavcodec.v +++ b/libavcodec/libavcodec.v @@ -3,10 +3,7 @@ LIBAVCODEC_$MAJOR { #deprecated, remove after next bump audio_resample; audio_resample_close; - ff_framenum_to_drop_timecode; - ff_framenum_to_smtpe_timecode; ff_raw_pix_fmt_tags; - ff_init_smtpe_timecode; ff_fft*; ff_mdct*; ff_dct*; @@ -15,11 +12,7 @@ LIBAVCODEC_$MAJOR { ff_simple_idct*; ff_aanscales; ff_faan*; - ff_mmx_idct; ff_fdct*; - fdct_ifast; - j_rev_dct; - ff_mmxext_idct; ff_idct_xvid*; ff_jpeg_fdct*; ff_dnxhd_get_cid_table; -- 1.8.5.5 From jamrial at gmail.com Thu Aug 7 07:12:46 2014 From: jamrial at gmail.com (James Almer) Date: Thu, 7 Aug 2014 02:12:46 -0300 Subject: [FFmpeg-devel] [PATCH 2/2] lavf: remove nonexistent functions from the version file In-Reply-To: <1407388366-14138-1-git-send-email-jamrial@gmail.com> References: <1407388366-14138-1-git-send-email-jamrial@gmail.com> Message-ID: <1407388366-14138-2-git-send-email-jamrial@gmail.com> Signed-off-by: James Almer --- The rest (at least those not used by ffprobe/ffplay/ffmpeg) should *really* be removed on the next bump libavformat/libavformat.v | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/libavformat/libavformat.v b/libavformat/libavformat.v index 0b47668..6ae6445 100644 --- a/libavformat/libavformat.v +++ b/libavformat/libavformat.v @@ -3,9 +3,6 @@ LIBAVFORMAT_$MAJOR { #FIXME those are for ffserver ff_inet_aton; ff_socket_nonblock; - ffm_set_write_index; - ffm_read_write_index; - ffm_write_write_index; ff_mpegts_parse_close; ff_mpegts_parse_open; ff_mpegts_parse_packet; @@ -21,17 +18,9 @@ LIBAVFORMAT_$MAJOR { ffurl_size; ffurl_write; ffurl_protocol_next; - url_open; - url_close; - url_write; #those are deprecated, remove on next bump url_*; - ff_timefilter_destroy; - ff_timefilter_new; - ff_timefilter_update; - ff_timefilter_reset; get_*; - put_*; ff_codec_get_id; local: *; }; -- 1.8.5.5 From cehoyos at ag.or.at Thu Aug 7 10:23:38 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Thu, 7 Aug 2014 10:23:38 +0200 Subject: [FFmpeg-devel] [PATCH]Do not mux invalid hevc into transport streams Message-ID: <201408071023.38521.cehoyos@ag.or.at> Hi! Attached patch checks if the hevc stream contains a startcode when muxed into transport streams. Please review, Carl Eugen -------------- next part -------------- diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index c286249..4259318 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -1157,6 +1157,18 @@ int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPack return 0; } +static int check_hevc_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt) +{ + if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) { + if (!st->nb_frames) { + av_log(s, AV_LOG_ERROR, "HEVC bitstream malformed, no startcode found\n"); + return AVERROR_PATCHWELCOME; + } + av_log(s, AV_LOG_WARNING, "HEVC bitstream error, startcode missing\n"); + } + return 0; +} + static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt) { AVStream *st = s->streams[pkt->stream_index]; @@ -1252,6 +1264,10 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt) ts_st->amux->pb = NULL; buf = data; } + } else if (st->codec->codec_id == AV_CODEC_ID_HEVC) { + int ret = check_hevc_startcode(s, st, pkt); + if (ret < 0) + return ret; } if (pkt->dts != AV_NOPTS_VALUE) { From danieloberhoff at gmail.com Thu Aug 7 10:38:03 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Thu, 7 Aug 2014 10:38:03 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> Message-ID: Hello, Did anyone get my last mail? Wrote it last night and it shows up on my mailing host too, but somehow not in the list archives... Best On Thu, Aug 7, 2014 at 12:15 AM, Daniel Oberhoff wrote: > > Am 06.08.2014 um 12:12 schrieb Cl?ment B?sch : > > > On Sun, Aug 03, 2014 at 06:43:18PM +0200, Daniel Oberhoff wrote: > > [...] > >>>> +static av_cold int init(AVFilterContext *ctx) > >>>> +{ > >>>> + return 0; > >>>> +} > >>>> > >>> > >>> please remove this one, there is no point in having code that does > nothing. > >>> > >>>> + > >>>> +static av_cold void uninit(AVFilterContext *ctx) > >>>> +{ > >>>> +} > >>>> + > >>>> > >>> > >>> ditto > >>> > >> > >> Done thanks! > >> > > > > Did you forget to attach the latest version of the patch or I missed it > > somewhere in the thread? > > Sorry, think that day I wanted to add something else before resubmit, and > then lost the time. > > Here also with changes suggested by timothy. Note that the parametrization > is now traditional > (i.e. k1 and k2 are zero-based, as for example in the opencv documentation > about calibration). > > From b798b95eb2f9ec4043b2407970d351cc31dd9e6a Mon Sep 17 00:00:00 2001 > From: Daniel Oberhoff > Date: Mon, 28 Jul 2014 23:58:12 +0200 > Subject: [PATCH] avfilter: ported lenscorrection filter from frei0r > > --- > Changelog | 2 +- > MAINTAINERS | 1 + > doc/filters.texi | 46 +++++++ > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/version.h | 4 +- > libavfilter/vf_lenscorrection.c | 199 > +++++++++++++++++++++++++++ > tests/fate/filter-video.mak | 3 + > tests/ref/fate/filter-pixfmts-lenscorrection | 8 ++ > 9 files changed, 262 insertions(+), 3 deletions(-) > create mode 100644 libavfilter/vf_lenscorrection.c > create mode 100644 tests/ref/fate/filter-pixfmts-lenscorrection > > diff --git a/Changelog b/Changelog > index 25dd210..79393ce 100644 > --- a/Changelog > +++ b/Changelog > @@ -3,7 +3,7 @@ releases are sorted from youngest to oldest. > > version : > - Icecast protocol > - > +- ported lenscorrection filter from frei0r filter > > version 2.3: > - AC3 fixed-point decoding > diff --git a/MAINTAINERS b/MAINTAINERS > index c383d3f..6948e22 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -354,6 +354,7 @@ Filters: > vf_histogram.c Paul B Mahol > vf_hqx.c Cl?ment B?sch > vf_il.c Paul B Mahol > + vf_lenscorrection.c Daniel Oberhoff > vf_mergeplanes.c Paul B Mahol > vf_psnr.c Paul B Mahol > vf_scale.c Michael Niedermayer > diff --git a/doc/filters.texi b/doc/filters.texi > index 86feebc..c4888d3 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -5532,6 +5532,51 @@ kerndeint=map=1 > @end example > @end itemize > > + at section lenscorrection > + > +Correct radial lens distortion > + > +This filter can be used to correct for radial distortion as can result > from the use > +of wide angle lenses, and thereby re-rectify the image. To find the right > parameters > +one can use tools available for example as part of opencv or simply > trial-and-error. > +To use opencv use the calibration sample (under samples/cpp) from the > opencv sources > +and extract the k1 and k2 coefficients from the resulting matrix. > + > +Note that effectively the same filter is available in the open-source > tools Krita and > +Digikam from the KDE project. > + > +In contrast to the @ref{vignette} filter, which can also be used to > compensate lens errors, > +this filter corrects the distortion of the image, whereas @ref{vignette} > corrects the > +brightness distribution, so you may want to use both filters together in > certain > +cases, though you will have to take care of ordering, i.e. whether > vignetting should > +be applied before or after lens correction. > + > + at subsection Options > + > +The filter accepts the following options: > + > + at table @option > + at item cx > +Relative x-coordinate of the focal point of the image, and thereby the > center of the > +distrortion. This value has a range [0,1] and is expressed as fractions > of the image > +width. > + at item cy > +Relative y-coordinate of the focal point of the image, and thereby the > center of the > +distrortion. This value has a range [0,1] and is expressed as fractions > of the image > +height. > + at item k1 > +Coefficient of the quadratic correction term. 0.5 means no correction. > + at item k2 > +Coefficient of the double quadratic correction term. 0.5 means no > correction. > + at end table > + > +The formula that generates the correction is: > + > + at var{r_src} = @var{r_tgt} * (1 + @var{k1} * (@var{r_tgt} / @var{r_0})^2 + > @var{k2} * (@var{r_tgt} / @var{r_0})^4) > + > +where @var{r_0} is halve of the image diagonal and @var{r_src} and > @var{r_tgt} are the > +distances from the focal point in the source and target images, > respectively. > + > @anchor{lut3d} > @section lut3d > > @@ -8744,6 +8789,7 @@ For example, to vertically flip a video with > @command{ffmpeg}: > ffmpeg -i in.avi -vf "vflip" out.avi > @end example > > + at anchor{vignette} > @section vignette > > Make or reverse a natural vignetting effect. > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index 0f54381..e9c8456 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -138,6 +138,7 @@ OBJS-$(CONFIG_IL_FILTER) += vf_il.o > OBJS-$(CONFIG_INTERLACE_FILTER) += vf_interlace.o > OBJS-$(CONFIG_INTERLEAVE_FILTER) += f_interleave.o > OBJS-$(CONFIG_KERNDEINT_FILTER) += vf_kerndeint.o > +OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o > OBJS-$(CONFIG_LUT3D_FILTER) += vf_lut3d.o > OBJS-$(CONFIG_LUT_FILTER) += vf_lut.o > OBJS-$(CONFIG_LUTRGB_FILTER) += vf_lut.o > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c > index 1877557..b1d6ff5 100644 > --- a/libavfilter/allfilters.c > +++ b/libavfilter/allfilters.c > @@ -156,6 +156,7 @@ void avfilter_register_all(void) > REGISTER_FILTER(INTERLACE, interlace, vf); > REGISTER_FILTER(INTERLEAVE, interleave, vf); > REGISTER_FILTER(KERNDEINT, kerndeint, vf); > + REGISTER_FILTER(LENSCORRECTION, lenscorrection, vf); > REGISTER_FILTER(LUT3D, lut3d, vf); > REGISTER_FILTER(LUT, lut, vf); > REGISTER_FILTER(LUTRGB, lutrgb, vf); > diff --git a/libavfilter/version.h b/libavfilter/version.h > index 1a43dc5..47bac78 100644 > --- a/libavfilter/version.h > +++ b/libavfilter/version.h > @@ -30,8 +30,8 @@ > #include "libavutil/version.h" > > #define LIBAVFILTER_VERSION_MAJOR 4 > -#define LIBAVFILTER_VERSION_MINOR 11 > -#define LIBAVFILTER_VERSION_MICRO 102 > +#define LIBAVFILTER_VERSION_MINOR 12 > +#define LIBAVFILTER_VERSION_MICRO 100 > > #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, > \ > LIBAVFILTER_VERSION_MINOR, > \ > diff --git a/libavfilter/vf_lenscorrection.c > b/libavfilter/vf_lenscorrection.c > new file mode 100644 > index 0000000..c2346db > --- /dev/null > +++ b/libavfilter/vf_lenscorrection.c > @@ -0,0 +1,199 @@ > +/* > + * Copyright (C) 2007 Richard Spindler (author of frei0r plugin from > which this was derived) > + * Copyright (C) 2014 Daniel Oberhoff > + * > + * This file is part of FFmpeg. > + * > + * 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 > + */ > + > +/** > + * @file > + * Lenscorrection filter, algorithm from the frei0r plugin with the same > name > +*/ > +#include > +#include > + > +#include "libavutil/opt.h" > +#include "libavutil/intreadwrite.h" > +#include "libavutil/pixdesc.h" > + > +#include "avfilter.h" > +#include "internal.h" > +#include "video.h" > + > +typedef struct LenscorrectionCtx { > + const AVClass *av_class; > + unsigned int width; > + unsigned int height; > + int hsub, vsub; > + int nb_planes; > + double cx, cy, k1, k2; > +} LenscorrectionCtx; > + > +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM > +static const AVOption lenscorrection_options[] = { > + { "cx", "set relative center x", offsetof(LenscorrectionCtx, cx), > AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, > + { "cy", "set relative center y", offsetof(LenscorrectionCtx, cy), > AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, > + { "k1", "set quadratic distortion factor", > offsetof(LenscorrectionCtx, k1), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, > .flags=FLAGS }, > + { "k2", "set double quadratic distortion factor", > offsetof(LenscorrectionCtx, k2), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, > .flags=FLAGS }, > + { NULL } > +}; > + > +AVFILTER_DEFINE_CLASS(lenscorrection); > + > +typedef struct ThreadData { > + AVFrame *in, *out; > + float w, h; > + int plane; > + float xcenter, ycenter; > + float k1, k2; > +} ThreadData; > + > +static int filter_slice(AVFilterContext *ctx, void *arg, int job, int > nb_jobs) > +{ > + ThreadData *td = (ThreadData*)arg; > + AVFrame *in = td->in; > + AVFrame *out = td->out; > + > + const float w = td->w, h = td->h; > + const float xcenter = td->xcenter; > + const float ycenter = td->ycenter; > + const float r2inv = 4.0 / (w * w + h * h); > + const float k1 = td->k1; > + const float k2 = td->k2; > + const int start = (h * job ) / nb_jobs; > + const int end = (h * (job+1)) / nb_jobs; > + const int plane = td->plane; > + const int inlinesize = in->linesize[plane]; > + const int outlinesize = out->linesize[plane]; > + const uint8_t *indata = in->data[plane]; > + uint8_t *outrow = out->data[plane] + start * outlinesize; > + int i; > + for (i = start; i < end; i++, outrow += outlinesize) { > + const float off_y = i - ycenter; > + const float off_y2 = off_y * off_y; > + uint8_t *out = outrow; > + int j; > + for (j = 0; j < w; j++) { > + const float off_x = j - xcenter; > + const float r2 = (off_x * off_x + off_y2) * r2inv; > + const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2; > + const int x = xcenter + radius_mult * off_x + 0.5f; > + const int y = ycenter + radius_mult * off_y + 0.5f; > + const char isvalid = x > 0 && x < w - 1 && y > 0 && y < h - 1; > + *out++ = isvalid ? indata[y * inlinesize + x] : 0; > + } > + } > + return 0; > +} > + > +static int query_formats(AVFilterContext *ctx) > +{ > + static enum AVPixelFormat pix_fmts[] = { > + AV_PIX_FMT_YUV410P, > + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, > + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, > + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P, > + AV_PIX_FMT_YUV422P, > + AV_PIX_FMT_NONE > + }; > + > + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); > + return 0; > +} > + > +static int config_props(AVFilterLink *outlink) > +{ > + AVFilterContext *ctx = outlink->src; > + LenscorrectionCtx *rect = ctx->priv; > + AVFilterLink *inlink = ctx->inputs[0]; > + const AVPixFmtDescriptor *pixdesc = > av_pix_fmt_desc_get(inlink->format); > + rect->hsub = pixdesc->log2_chroma_w; > + rect->vsub = pixdesc->log2_chroma_h; > + outlink->w = rect->width = inlink->w; > + outlink->h = rect->height = inlink->h; > + rect->nb_planes = av_pix_fmt_count_planes(inlink->format); > + return 0; > +} > + > +static int filter_frame(AVFilterLink *inlink, AVFrame *in) > +{ > + AVFilterContext *ctx = inlink->dst; > + AVFilterLink *outlink = ctx->outputs[0]; > + LenscorrectionCtx *rect = (LenscorrectionCtx*)ctx->priv; > + AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h); > + int plane; > + > + if (!out) { > + av_frame_free(&in); > + return AVERROR(ENOMEM); > + } > + > + av_frame_copy_props(out, in); > + > + for (plane = 0; plane < rect->nb_planes; ++plane) { > + int hsub = plane == 1 || plane == 2 ? rect->hsub : 0; > + int vsub = plane == 1 || plane == 2 ? rect->vsub : 0; > + float hdiv = 1 << hsub; > + float vdiv = 1 << vsub; > + float w = rect->width / hdiv; > + float h = rect->height / vdiv; > + ThreadData td = { > + .in = in, > + .out = out, > + .w = w, > + .h = h, > + .xcenter = rect->cx * w, > + .ycenter = rect->cy * h, > + .k1 = rect->k1, > + .k2 = rect->k2, > + .plane = plane}; > + ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, > ctx->graph->nb_threads)); > + } > + > + av_frame_free(&in); > + return ff_filter_frame(outlink, out); > +} > + > +static const AVFilterPad lenscorrection_inputs[] = { > + { > + .name = "default", > + .type = AVMEDIA_TYPE_VIDEO, > + .filter_frame = filter_frame, > + }, > + { NULL } > +}; > + > +static const AVFilterPad lenscorrection_outputs[] = { > + { > + .name = "default", > + .type = AVMEDIA_TYPE_VIDEO, > + .config_props = config_props, > + }, > + { NULL } > +}; > + > +AVFilter ff_vf_lenscorrection = { > + .name = "lenscorrection", > + .description = NULL_IF_CONFIG_SMALL("Rectify the image by > correcting for lens distortion."), > + .priv_size = sizeof(LenscorrectionCtx), > + .query_formats = query_formats, > + .inputs = lenscorrection_inputs, > + .outputs = lenscorrection_outputs, > + .priv_class = &lenscorrection_class, > + .flags = AVFILTER_FLAG_SLICE_THREADS, > +}; > + > \ No newline at end of file > diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak > index 053f3e7..f08edf6 100644 > --- a/tests/fate/filter-video.mak > +++ b/tests/fate/filter-video.mak > @@ -333,6 +333,9 @@ fate-filter-pixfmts-il: CMD = pixfmts > "luma_mode=d:chroma_mode=d:alpha_mode=d > FATE_FILTER_PIXFMTS-$(CONFIG_KERNDEINT_FILTER) += > fate-filter-pixfmts-kerndeint > fate-filter-pixfmts-kerndeint: CMD = pixfmts "" > "tinterlace=interleave_top," > > +FATE_FILTER_PIXFMTS-$(CONFIG_LENSCORRECTION_FILTER) += > fate-filter-pixfmts-lenscorrection > +fate-filter-pixfmts-lenscorrection: CMD = pixfmts "0.6:0.4:0.65:0.4" > + > FATE_FILTER_PIXFMTS-$(CONFIG_LUT_FILTER) += fate-filter-pixfmts-lut > fate-filter-pixfmts-lut: CMD = pixfmts > "c0=2*val:c1=2*val:c2=val/2:c3=negval+40" > > diff --git a/tests/ref/fate/filter-pixfmts-lenscorrection > b/tests/ref/fate/filter-pixfmts-lenscorrection > new file mode 100644 > index 0000000..18af6fb > --- /dev/null > +++ b/tests/ref/fate/filter-pixfmts-lenscorrection > @@ -0,0 +1,8 @@ > +yuv410p e7d59dbdb1afab7e2a8f770d563e28c4 > +yuv420p bc45b4762d5271410ff825317c85af64 > +yuv422p 5cce0c299322634d65e6b32c976e2c12 > +yuv444p 03de9a93ab3045a523b234ea93f21c91 > +yuva420p d1fa6735c4e7fbbf3a501cec1f0b4ac1 > +yuva444p 713ddf5861d3df11c70a242a13c5e92e > +yuvj420p 1d5cccaf4ef568ae9fa36f9a28e71c34 > +yuvj444p aef1db29848e3b1dcaf4309255c38cbd > -- > 1.8.2 > > From u at pkh.me Thu Aug 7 10:41:19 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Thu, 7 Aug 2014 10:41:19 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <20140801102233.GG10372@leki> <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> Message-ID: <20140807084119.GB19534@leki> On Thu, Aug 07, 2014 at 10:38:03AM +0200, Daniel Oberhoff wrote: > Hello, > > Did anyone get my last mail? Wrote it last night and it shows up on my > mailing host too, but somehow not in the list archives... > Seems it's here: http://ffmpeg.org/pipermail/ffmpeg-devel/2014-August/160764.html [...] -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From marek.fort at chyronhego.com Thu Aug 7 11:20:23 2014 From: marek.fort at chyronhego.com (Marek Fort) Date: Thu, 7 Aug 2014 11:20:23 +0200 Subject: [FFmpeg-devel] XMP in mov files Message-ID: Hi, I'd like to integrate this patch. It adds a support for reading/writing XMP data in mov file format. The patch is made according to XMP SPECIFICATION PART 3 - STORAGE IN FILES ch. 1.2.4.1 Placement of XMP. Spec available here: http://www.adobe.com/devnet/xmp.html The XMP is stored under "xmp" key in ffmpeg format context's metadata. I could not find any other code in ffmpeg dealing with XMP so I made this key. Any future XMP support should use the same key. Thank you, Marek Fort -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Reading-writing-XMP-metadata-in-mov-container.patch Type: application/octet-stream Size: 2200 bytes Desc: not available URL: From Nedeljko.Babic at imgtec.com Thu Aug 7 11:51:36 2014 From: Nedeljko.Babic at imgtec.com (Nedeljko Babic) Date: Thu, 7 Aug 2014 09:51:36 +0000 Subject: [FFmpeg-devel] [PATCH 02/14] libavcodec: Implementation of AAC_fixed_decoder (LC-module) [2/5] In-Reply-To: <20140801190850.GA4224@reimardoeffinger.de> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> <1406901200-4862-3-git-send-email-nedeljko.babic@imgtec.com>, <20140801190850.GA4224@reimardoeffinger.de> Message-ID: Thanks on your review, >On Fri, Aug 01, 2014 at 03:53:08PM +0200, Nedeljko Babic wrote: >> +#if !defined(_AAC_FLOAT_EMU_) >> +#define _AAC_FLOAT_EMU_ > >That is not out usual style >1) We use #ifndef >2) Identifiers starting with _ + upper case letter are reserved by POSIX >and never should be used >3) The naming convention is like e.g. AVCODEC_AAC_FLOAT_EMU_H > This file will be removed. Instead float_emu_tab.c and float_emu.h will be used. >> +static const uint8_t ff_log2_tab[256] = { > >One with the same name exists in libavutil, I am not sure that is a good >idea. > The one from the libavutil will be used instead of this one. >> +static int divTable[128] = { > >These and the following ones seem to lack "const". > The versions from float_emu_tab.c will be used and they do have "const" >> + Q30(0.9999999995), Q30(0.9922480620), Q30(0.9846153846), Q30(0.9770992366), > >I'm a bit unsure btw. if this makes more sense than coding the converted >numbers. >It feels like it combines the disadvantages, since it neither avoids >code duplication with the float tables nor does it compiler/architecture >dependence completely (I think). > I am not sure what disadvantages are combined (there is no code duplication for example), but since only advantage is in that it can be seen what fixed point representation is used, the values will be hard coded in hex format. >> +static av_always_inline av_const int av_log2_c_emu(unsigned int v) > >Since this duplicates existing code it definitely should have a comment. >Also if performance is the reason there is a question whether we should >at least internally have libavutil provide it instead, to at least avoid >duplication. >Though to be honest on most architectures the solution to it being slow >should be to provide a ASM version. > The version from intmath.h will be used so no code duplication will occur. >> +static av_always_inline aac_float_t int2float(const int x, const int exp) > >Those "const" are kind of pointless IMHO. > You are correct and they will be removed. >> + aac_float_t ret; >> + int nz; >> + >> + if (x == 0) >> + { >> + ret.mant = 0; >> + ret.expo = 0; >> + } >> + else >> + { >> + ret.expo = exp; >> + ret.mant = x; >> + nz = 29 - av_log2_c_emu(FFABS(ret.mant)); >> + ret.mant <<= nz; >> + ret.expo -= nz; > >nz is only used here, so it should be declared here. >Also >int nz = 29 - av_log2_c_emu(FFABS(x)); Since ISO C90 forbids mixing declarations and code, warnings will be generated if nz is declared here. On the other hand, it can (and will) be declared at the start of the else block. >ret.expo = exp - nz; >ret.mant = x << nz; >seems more readable to me. > Ok. It will be changed. >> +static av_always_inline aac_float_t float_add(aac_float_t a, aac_float_t b) >> +{ >> + int diff, nz; >> + int expa = a.expo; >> + int expb = b.expo; >> + int manta = a.mant; >> + int mantb = b.mant; > >I don't think those local copies are a good idea, at least for >readability. > Ok. This will be changed. >> + if (manta == 0) >> + return b; >> + >> + if (mantb == 0) >> + return a; >> + >> + diff = expa - expb; >> + if (diff < 0) // expa < expb >> + { >> + diff = -diff; >> + if (diff >= 31) >> + manta = 0; >> + else if (diff != 0) >> + manta >>= diff; >> + expa = expb; >> + } >> + else // expa >= expb >> + { >> + if (diff >= 31) >> + mantb = 0; >> + else if (diff != 0) >> + mantb >>= diff; >> + } >> + >> + manta = manta + mantb; >> + if (manta == 0) >> + expa = 0; >> + else >> + { >> + nz = 30 - av_log2_c_emu(FFABS(manta)); >> + manta <<= nz; >> + manta >>= 1; >> + expa -= (nz-1); >> + } > >I think this needs a good thinking over. >If diff was calculated first, the >= 31/ <= -31 checks >could be combined with the checks for 0. diff is calculated right after checking if mantissas are zero. Mantissas are checked first because if they are zero, it is a waste of time to do other calculations. On the other hand, I am not sure what would be gain in combining >= 31/ <= -31 checks with the checks for 0 (for diff). >In the upper if, diff can obviously not be 0, You are correct and != 0 check will be removed here. >also the != 0 check can certainly only make performance worse. I agree with this in if part, since it is not needed as you pointed out, but this check is needed in the else part. >For all functions, I think there should be a look at what rounding >mode they end up using in the end and document that. >This one looks like round to 0. > This is rounding to 0. It can be changed to rounding to nearest without loss in precision. Do you suggest that we should make comment like: /* Rounding to zero used */ for every function? >> +static av_always_inline aac_float_t float_sub(aac_float_t a, aac_float_t b) > >Why would this need a whole separate implementation instead >of changing the sign of b and calling add? > Because there could be overhead because of function call if function is not inlined. On the other hand I guess that gain is insignificant (or there is no gain if function is inlined) and this will be done by calling add as you suggested. >> +static av_always_inline aac_float_t float_mul(aac_float_t a, aac_float_t b) >> +{ >> + aac_float_t res; >> + int mant; >> + int expa = a.expo; >> + int expb = b.expo; >> + long long accu; >> + >> + expa = expa + expb; >> + accu = (long long)a.mant * b.mant; > >I'd suggest using types like int64_t. > Will be done. >> + mant = (int)((accu + 0x20000000) >> 30); > >This suddenly seems to use round-to-nearest-away as rounding mode/ > Yes it is. >> + if (mant == 0) >> + expa = 0; >> + else if (mant < 536870912 && mant > -536870912) >> + { > >These constants would be vastly more readable in hex. > Will be converted. >> + mant <<= 1; >> + expa = expa - 1; > >expa--; > Will be changed. >> + if (mantb != 0) >> + { >> + iB = float_recip(b); >> + // newton iteration to double precision >> + tmp = float_sub(FLOAT_1, float_mul(b, iB)); >> + iB = float_add(iB, float_mul(iB, tmp)); >> + res = float_mul(a, iB); >> + } >> + else >> + { >> + res.mant = 1; >> + res.expo = 2147483647; > >Hexadecimal would be nicer. >Also, this seems to be the only function so far that handles >infinity correctly. >I have some doubts of the value of that, as long as it is the only one. >If there's a particular reason why it only needs to be supported here, >that should be documented. > Only division by zero can create infinity, so it is addressed only here. >> +static av_always_inline int float_gt(aac_float_t a, aac_float_t b) >> +{ >> + int expa = a.expo; >> + int expb = b.expo; >> + int manta = a.mant; >> + int mantb = b.mant; >> + >> + if (manta == 0) >> + expa = 0x80000000; >> + >> + if (mantb == 0) >> + expb = 0x80000000; >> + >> + if (expa > expb) >> + return 1; >> + else if (expa < expb) >> + return 0; >> + else // expa == expb >> + { >> + if (manta > mantb) >> + return 1; >> + else >> + return 0; >> + } > >Does this actually work? >The expa/expb assignment seems to invoke undefined behaviour by itself, >but then it also seems to just not handle negative numbers, at least >not if the exponent differs?!? Functions in this file are made for use in the implementation of AAC fixed point decoder. This particular function is used only for calculating gain in aacsbr, so it doesn't need to handle negative numbers. On the other hand, I realize that this should be documented and will be in the next patch.. >I decided to rather skip reviewing the rest. > >> +++ b/libavcodec/float_emu.h > >That seems like the same file once more. > >> +++ b/libavcodec/float_emu_tab.c > >And these tables seem familiar, too.> - Nedeljko From Nedeljko.Babic at imgtec.com Thu Aug 7 12:05:49 2014 From: Nedeljko.Babic at imgtec.com (Nedeljko Babic) Date: Thu, 7 Aug 2014 10:05:49 +0000 Subject: [FFmpeg-devel] [PATCH 06/14] libavcodec: Implementation of AAC_fixed_decoder (SBR-module) [1/4] In-Reply-To: <20140801191520.GB4224@reimardoeffinger.de> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> <1406901200-4862-7-git-send-email-nedeljko.babic@imgtec.com>, <20140801191520.GB4224@reimardoeffinger.de> Message-ID: > On Fri, Aug 01, 2014 at 03:53:12PM +0200, Nedeljko Babic wrote: > > From: Djordje Pesut > > > > Move the existing code to a new template file. > > If code was only moved (I have not checked), I don't think > adding your copyright is appropriate. In this patch code was only moved to a new file, but in the patch after the next one code for fixed point implementation was added in this file. From michaelni at gmx.at Thu Aug 7 12:48:36 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 12:48:36 +0200 Subject: [FFmpeg-devel] [PATCH]Do not select a default subtitle output stream with incorrect subtitle type In-Reply-To: <201408052159.13927.cehoyos@ag.or.at> References: <201408010154.57991.cehoyos@ag.or.at> <20140801080417.GE10372@leki> <201408052159.13927.cehoyos@ag.or.at> Message-ID: <20140807104836.GM12391@nb4> On Tue, Aug 05, 2014 at 09:59:13PM +0200, Carl Eugen Hoyos wrote: > On Friday 01 August 2014 10:04:17 am Cl?ment B?sch wrote: > > On Fri, Aug 01, 2014 at 01:54:57AM +0200, Carl Eugen Hoyos wrote: > > > When transcoding an input file with subtitles to mkv, ffmpeg by default > > > tries to encode the subtitles even if the input contains bitmap > > > subtitles. Attached patch should fix this issue reported in ticket #3819 > > > (and before iirc). > > > > This patch currently does not work correctly for teletext input streams > > > because no properties are defined for teletext, I suspect it should be > > > (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB). In any case, this > > > corner-case should not affect this patch imo. > > I worked around this by automatically mapping subtitles if no properties > are set. > > > > + if (subtitle_codec_name || > > > + > > > avcodec_find_encoder(oc->oformat->subtitle_codec) && + > > > > > > avcodec_descriptor_get(avcodec_find_encoder(oc->oformat->subtitle_codec)- > > >>id) && + > > > avcodec_descriptor_get(input_streams[i]->st->codec->codec_id) && + > > > > > > avcodec_descriptor_get(avcodec_find_encoder(oc->oformat->subtitle_codec)- > > >>id)->props & + > > > avcodec_descriptor_get(input_streams[i]->st->codec->codec_id)->props & > > > > You have a scope opened here, please use 2 intermediate const to store the > > 2 descriptor pointers, because it's currently unreadable. > > Slightly more readable version attached. > > > > > > + (AV_CODEC_PROP_TEXT_SUB | > > > AV_CODEC_PROP_BITMAP_SUB)) { + > > > new_subtitle_stream(o, oc, i); > > > + break; > > > + } > > > > BTW, do we have an obvious warning nowadays if someone tries to map a > > bitmap sub to a text one? > > I believe the warning is the reason for ticket #3819. > In any case, this is orthoganal to this patch imo: The patch tries > to cover automatic subtitle mapping (in the useless case), iiuc > you (also) mean the case when a user specifies a subtitle encoder > that will not work. > > Thank you, Carl Eugen > ffmpeg_opt.c | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) > 977bbbc7d31d57d206f9fdfb9d73c35388f97a84 patchdefaultsub2.diff > diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c > index 9604a6a..1962cf4 100644 > --- a/ffmpeg_opt.c > +++ b/ffmpeg_opt.c > @@ -1870,8 +1870,27 @@ static int open_output_file(OptionsContext *o, const char *filename) > if (!o->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || subtitle_codec_name)) { > for (i = 0; i < nb_input_streams; i++) > if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { > - new_subtitle_stream(o, oc, i); > - break; > + AVCodecDescriptor const *input_descriptor = > + avcodec_descriptor_get(input_streams[i]->st->codec->codec_id); > + AVCodecDescriptor const *output_descriptor = NULL; > + AVCodec const *output_codec = > + avcodec_find_encoder(oc->oformat->subtitle_codec); > + int input_props = 0, output_props = 0; > + if (output_codec) > + output_descriptor = avcodec_descriptor_get(output_codec->id); > + if (input_descriptor) > + input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); > + if (output_descriptor) > + output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); > + if (subtitle_codec_name || > + input_props & output_props || > + // Map dvb teletext which has neither property to any output subtitle encoder > + input_descriptor && output_descriptor && > + (!input_descriptor->props || > + !output_descriptor->props)) { > + new_subtitle_stream(o, oc, i); > + break; > + } should be ok but why does dvb teletext not have a TEXT/BITMAP prop ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 3 "Rare item" - "Common item with rare defect or maybe just a lie" "Professional" - "'Toy' made in china, not functional except as doorstop" "Experts will know" - "The seller hopes you are not an expert" -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Thu Aug 7 13:02:27 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 13:02:27 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec/raw: add avpriv_get_raw_pix_fmt_tags() In-Reply-To: <1407385368-13716-1-git-send-email-jamrial@gmail.com> References: <1407374082-4076-1-git-send-email-jamrial@gmail.com> <1407385368-13716-1-git-send-email-jamrial@gmail.com> Message-ID: <20140807110227.GN12391@nb4> On Thu, Aug 07, 2014 at 01:22:48AM -0300, James Almer wrote: > Used to expose ff_raw_pix_fmt_tags[] to other libav* libraries > > Signed-off-by: James Almer > --- > libavcodec/raw.c | 5 +++++ > libavcodec/raw.h | 6 ++++++ > libavdevice/dshow.c | 2 +- > libavformat/utils.c | 2 +- > 4 files changed, 13 insertions(+), 2 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is dangerous to be right in matters on which the established authorities are wrong. -- Voltaire -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Thu Aug 7 13:17:58 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 13:17:58 +0200 Subject: [FFmpeg-devel] [PATCH] lavd/dshow: use av_codec_get_id() In-Reply-To: <1407382983-4329-1-git-send-email-jamrial@gmail.com> References: <1407382983-4329-1-git-send-email-jamrial@gmail.com> Message-ID: <20140807111758.GO12391@nb4> On Thu, Aug 07, 2014 at 12:43:03AM -0300, James Almer wrote: > ff_codec_get_id() is a lavf internal function > > Signed-off-by: James Almer > --- > libavdevice/dshow.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No great genius has ever existed without some touch of madness. -- Aristotle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From cehoyos at ag.or.at Thu Aug 7 13:22:22 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Thu, 7 Aug 2014 11:22:22 +0000 (UTC) Subject: [FFmpeg-devel] [PATCH]Do not select a default subtitle output stream with incorrect subtitle type References: <201408010154.57991.cehoyos@ag.or.at> <20140801080417.GE10372@leki> <201408052159.13927.cehoyos@ag.or.at> <20140807104836.GM12391@nb4> Message-ID: Michael Niedermayer gmx.at> writes: > should be ok Please merge from github. > but why does dvb teletext not have a TEXT/BITMAP prop ? I believe this would break avcodec_decode_subtitle2() which sets the format depending on the properties. This should be fixed but I don't know the relevant code and it would not necessarily change my patch. Carl Eugen From michaelni at gmx.at Thu Aug 7 13:34:19 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 13:34:19 +0200 Subject: [FFmpeg-devel] [PATCH 1/2] lavc: remove nonexistent functions from the version file In-Reply-To: <1407388366-14138-1-git-send-email-jamrial@gmail.com> References: <1407388366-14138-1-git-send-email-jamrial@gmail.com> Message-ID: <20140807113419.GP12391@nb4> On Thu, Aug 07, 2014 at 02:12:45AM -0300, James Almer wrote: > Signed-off-by: James Almer > --- > The rest should *really* be removed on the next bump applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Complexity theory is the science of finding the exact solution to an approximation. Benchmarking OTOH is finding an approximation of the exact -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Thu Aug 7 13:43:12 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 13:43:12 +0200 Subject: [FFmpeg-devel] [PATCH 2/2] lavf: remove nonexistent functions from the version file In-Reply-To: <1407388366-14138-2-git-send-email-jamrial@gmail.com> References: <1407388366-14138-1-git-send-email-jamrial@gmail.com> <1407388366-14138-2-git-send-email-jamrial@gmail.com> Message-ID: <20140807114312.GQ12391@nb4> On Thu, Aug 07, 2014 at 02:12:46AM -0300, James Almer wrote: > Signed-off-by: James Almer > --- > The rest (at least those not used by ffprobe/ffplay/ffmpeg) should *really* be > removed on the next bump > > libavformat/libavformat.v | 11 ----------- > 1 file changed, 11 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 1 "Used only once" - "Some unspecified defect prevented a second use" "In good condition" - "Can be repaird by experienced expert" "As is" - "You wouldnt want it even if you were payed for it, if you knew ..." -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From cehoyos at ag.or.at Thu Aug 7 14:02:33 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Thu, 7 Aug 2014 14:02:33 +0200 Subject: [FFmpeg-devel] [PATCH]Make subtitle properties code in lavc more robust Message-ID: <201408071402.33313.cehoyos@ag.or.at> Hi! Attached patch should allow to set the teletext decoder properties to (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB). Please comment, Carl Eugen -------------- next part -------------- diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 6071380..3db2a1c 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1595,7 +1595,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code "supported with subtitles codecs\n"); ret = AVERROR(EINVAL); goto free_and_end; - } else if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) { + } else if ( avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB + && ~avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB) { av_log(avctx, AV_LOG_WARNING, "Codec '%s' is bitmap-based, " "subtitles character encoding will be ignored\n", avctx->codec_descriptor->name); @@ -2676,9 +2677,11 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, av_free_packet(&pkt_recoded); } - if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) + if ( avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB + && ~avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB) sub->format = 0; - else if (avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB) + else if ( avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB + && ~avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) sub->format = 1; avctx->internal->pkt = NULL; } From michaelni at gmx.at Thu Aug 7 14:38:35 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 14:38:35 +0200 Subject: [FFmpeg-devel] [PATCH]Make subtitle properties code in lavc more robust In-Reply-To: <201408071402.33313.cehoyos@ag.or.at> References: <201408071402.33313.cehoyos@ag.or.at> Message-ID: <20140807123835.GR12391@nb4> On Thu, Aug 07, 2014 at 02:02:33PM +0200, Carl Eugen Hoyos wrote: > Hi! > > Attached patch should allow to set the teletext decoder properties to > (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB). > > Please comment, Carl Eugen > utils.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > b3b889684d63d8f371f521ebd6f9730ba9c84376 patchsubtitleprops.diff > diff --git a/libavcodec/utils.c b/libavcodec/utils.c should be ok -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Thu Aug 7 14:50:43 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 14:50:43 +0200 Subject: [FFmpeg-devel] [PATCH]Do not select a default subtitle output stream with incorrect subtitle type In-Reply-To: References: <201408010154.57991.cehoyos@ag.or.at> <20140801080417.GE10372@leki> <201408052159.13927.cehoyos@ag.or.at> <20140807104836.GM12391@nb4> Message-ID: <20140807125043.GS12391@nb4> On Thu, Aug 07, 2014 at 11:22:22AM +0000, Carl Eugen Hoyos wrote: > Michael Niedermayer gmx.at> writes: > > > should be ok > > Please merge from github. merged thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Old school: Use the lowest level language in which you can solve the problem conveniently. New school: Use the highest level language in which the latest supercomputer can solve the problem without the user falling asleep waiting. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Thu Aug 7 15:04:15 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 15:04:15 +0200 Subject: [FFmpeg-devel] [PATCH 2/3] lavu/log: add device category macros In-Reply-To: <1407369537-25633-2-git-send-email-lukasz.m.luki2@gmail.com> References: <1407369537-25633-1-git-send-email-lukasz.m.luki2@gmail.com> <1407369537-25633-2-git-send-email-lukasz.m.luki2@gmail.com> Message-ID: <20140807130415.GT12391@nb4> On Thu, Aug 07, 2014 at 01:58:56AM +0200, Lukasz Marek wrote: > --- > libavutil/log.h | 10 ++++++++++ > 1 file changed, 10 insertions(+) should be ok unless someone has a better idea [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No human being will ever know the Truth, for even if they happen to say it by chance, they would not even known they had done so. -- Xenophanes -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Thu Aug 7 15:36:48 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 15:36:48 +0200 Subject: [FFmpeg-devel] [PATCH 1/3] lavd/pulse_audio_dec: use default source when no input provided In-Reply-To: <1407369537-25633-1-git-send-email-lukasz.m.luki2@gmail.com> References: <1407369537-25633-1-git-send-email-lukasz.m.luki2@gmail.com> Message-ID: <20140807133648.GU12391@nb4> On Thu, Aug 07, 2014 at 01:58:55AM +0200, Lukasz Marek wrote: > PulseAudio expilitly requires name of the source. > This patch makes it use default source when not provided. > It simplifies programistic use. > > Signed-off-by: Lukasz Marek > --- > libavdevice/pulse_audio_dec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Its not that you shouldnt use gotos but rather that you should write readable code and code with gotos often but not always is less readable -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Thu Aug 7 15:37:28 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 15:37:28 +0200 Subject: [FFmpeg-devel] XMP in mov files In-Reply-To: References: Message-ID: <20140807133728.GV12391@nb4> On Thu, Aug 07, 2014 at 11:20:23AM +0200, Marek Fort wrote: > Hi, > > I'd like to integrate this patch. > > It adds a support for reading/writing XMP data in mov file format. > > The patch is made according to XMP SPECIFICATION PART 3 - STORAGE IN FILES > ch. 1.2.4.1 Placement of XMP. Spec available here: > http://www.adobe.com/devnet/xmp.html > > The XMP is stored under "xmp" key in ffmpeg format context's metadata. I > could not find any other code in ffmpeg dealing with XMP so I made this > key. Any future XMP support should use the same key. > > Thank you, > Marek Fort > mov.c | 2 ++ > movenc.c | 21 +++++++++++++++++++++ > 2 files changed, 23 insertions(+) > 077e36e58e292b22304cf2dc394c82bad161377e 0001-Reading-writing-XMP-metadata-in-mov-container.patch > From 1575ffdb270cb110944e432c5ed16e6ae0260b74 Mon Sep 17 00:00:00 2001 > From: Marek Fort > Date: Wed, 6 Aug 2014 16:48:21 +0200 > Subject: [PATCH] Reading/writing XMP metadata in mov container. do you have a testcase/sample you can share ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB What does censorship reveal? It reveals fear. -- Julian Assange -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Thu Aug 7 15:46:07 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 15:46:07 +0200 Subject: [FFmpeg-devel] [PATCH] avdevice/lavfi: Simplify non-AV stream check In-Reply-To: <1407251007-29170-1-git-send-email-michaelni@gmx.at> References: <1407251007-29170-1-git-send-email-michaelni@gmx.at> Message-ID: <20140807134607.GW12391@nb4> On Tue, Aug 05, 2014 at 05:03:27PM +0200, Michael Niedermayer wrote: > Fixes a clang warning > Signed-off-by: Michael Niedermayer > --- > libavdevice/lavfi.c | 12 ++++-------- > 1 file changed, 4 insertions(+), 8 deletions(-) applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam" -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From marek.fort at chyronhego.com Thu Aug 7 16:19:15 2014 From: marek.fort at chyronhego.com (Marek Fort) Date: Thu, 7 Aug 2014 16:19:15 +0200 Subject: [FFmpeg-devel] XMP in mov files In-Reply-To: <20140807133728.GV12391@nb4> References: <20140807133728.GV12391@nb4> Message-ID: Yes, here is one: http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket3707/Untitled_dnhd.mov On 7 August 2014 15:37, Michael Niedermayer wrote: > On Thu, Aug 07, 2014 at 11:20:23AM +0200, Marek Fort wrote: > > Hi, > > > > I'd like to integrate this patch. > > > > It adds a support for reading/writing XMP data in mov file format. > > > > The patch is made according to XMP SPECIFICATION PART 3 - STORAGE IN > FILES > > ch. 1.2.4.1 Placement of XMP. Spec available here: > > http://www.adobe.com/devnet/xmp.html > > > > The XMP is stored under "xmp" key in ffmpeg format context's metadata. I > > could not find any other code in ffmpeg dealing with XMP so I made this > > key. Any future XMP support should use the same key. > > > > Thank you, > > Marek Fort > > > mov.c | 2 ++ > > movenc.c | 21 +++++++++++++++++++++ > > 2 files changed, 23 insertions(+) > > 077e36e58e292b22304cf2dc394c82bad161377e > 0001-Reading-writing-XMP-metadata-in-mov-container.patch > > From 1575ffdb270cb110944e432c5ed16e6ae0260b74 Mon Sep 17 00:00:00 2001 > > From: Marek Fort > > Date: Wed, 6 Aug 2014 16:48:21 +0200 > > Subject: [PATCH] Reading/writing XMP metadata in mov container. > > do you have a testcase/sample you can share ? > > [...] > > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > What does censorship reveal? It reveals fear. -- Julian Assange > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > -- *Marek Fort* *| Head of Development* *Hego Czech s.r.o.* *- *Zilkova 11, CZ-621 00 Brno, Czech Republic Tel.+420 603 52 10 50 - www.chyronhego.com From krueger at lesspain.de Thu Aug 7 16:52:43 2014 From: krueger at lesspain.de (=?UTF-8?Q?Robert_Kr=C3=BCger?=) Date: Thu, 7 Aug 2014 16:52:43 +0200 Subject: [FFmpeg-devel] Stereo channel layout mapping Message-ID: Hi, could someone explain, what the difference between those two is and when to use which one? #define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT) #define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT) E.g. when I extract metadata and want to use that as a basis to display the channel info to a user in a UI it is a bit surprising to display "Front left" and "Front right" for the channels of a plain stereo file. I can handle that case manually but it would be nice to understand the rationale behind it. Regards, Robert From michaelni at gmx.at Thu Aug 7 18:49:55 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 18:49:55 +0200 Subject: [FFmpeg-devel] [PATCH] avutil: turn arm setend into a cpuflag Message-ID: <1407430195-28921-1-git-send-email-michaelni@gmx.at> this allows disabling and enabling it it also prevents crashes if vfpv3 and neon are disabled which previously would have enabled the flag Signed-off-by: Michael Niedermayer --- configure | 3 +++ libavutil/arm/cpu.c | 9 ++++++++- libavutil/arm/cpu.h | 7 +------ libavutil/cpu.c | 2 ++ libavutil/cpu.h | 1 + 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 1b14730..069078e 100755 --- a/configure +++ b/configure @@ -1527,6 +1527,7 @@ ARCH_EXT_LIST_ARM=" neon vfp vfpv3 + setend " ARCH_EXT_LIST_MIPS=" @@ -1953,6 +1954,7 @@ neon_deps_any="aarch64 arm" intrinsics_neon_deps="neon" vfp_deps_any="aarch64 arm" vfpv3_deps="vfp" +setend_deps="arm" map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM @@ -4423,6 +4425,7 @@ EOF enabled neon && check_insn neon 'vadd.i16 q0, q0, q0' enabled vfp && check_insn vfp 'fadds s0, s0, s0' enabled vfpv3 && check_insn vfpv3 'vmov.f32 s0, #1.0' + enabled setend && check_insn setend 'setend be' [ $target_os = linux ] || [ $target_os = android ] || map 'enabled_any ${v}_external ${v}_inline || disable $v' \ diff --git a/libavutil/arm/cpu.c b/libavutil/arm/cpu.c index f6cf338..f1683e8 100644 --- a/libavutil/arm/cpu.c +++ b/libavutil/arm/cpu.c @@ -128,6 +128,12 @@ int ff_get_cpu_flags_arm(void) trickle down. */ if (flags & (AV_CPU_FLAG_VFPV3 | AV_CPU_FLAG_NEON)) flags |= AV_CPU_FLAG_ARMV6T2; + else + /* Some functions use the 'setend' instruction which is deprecated on ARMv8 + * and serializing on some ARMv7 cores. This ensures such functions + * are only enabled on ARMv6. */ + flags |= AV_CPU_FLAG_SETEND; + if (flags & AV_CPU_FLAG_ARMV6T2) flags |= AV_CPU_FLAG_ARMV6; @@ -143,7 +149,8 @@ int ff_get_cpu_flags_arm(void) AV_CPU_FLAG_ARMV6T2 * HAVE_ARMV6T2 | AV_CPU_FLAG_VFP * HAVE_VFP | AV_CPU_FLAG_VFPV3 * HAVE_VFPV3 | - AV_CPU_FLAG_NEON * HAVE_NEON; + AV_CPU_FLAG_NEON * HAVE_NEON | + AV_CPU_FLAG_SETEND * !(HAVE_NEON | HAVE_VFPV3); } #endif diff --git a/libavutil/arm/cpu.h b/libavutil/arm/cpu.h index f056a91..9b3b6ff 100644 --- a/libavutil/arm/cpu.h +++ b/libavutil/arm/cpu.h @@ -29,11 +29,6 @@ #define have_vfp(flags) CPUEXT(flags, VFP) #define have_vfpv3(flags) CPUEXT(flags, VFPV3) #define have_neon(flags) CPUEXT(flags, NEON) - -/* Some functions use the 'setend' instruction which is deprecated on ARMv8 - * and serializing on some ARMv7 cores. This macro ensures such functions - * are only enabled on ARMv6. */ -#define have_setend(flags) \ - (have_armv6(flags) && !(have_vfpv3(flags) || have_neon(flags))) +#define have_setend(flags) CPUEXT(flags, SETEND) #endif /* AVUTIL_ARM_CPU_H */ diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 1cd0522..53c1227 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -225,6 +225,7 @@ int av_parse_cpu_caps(unsigned *flags, const char *s) { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" }, { "vfpv3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFPV3 }, .unit = "flags" }, { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" }, + { "setend", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SETEND }, .unit = "flags" }, #elif ARCH_AARCH64 { "armv8", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV8 }, .unit = "flags" }, { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" }, @@ -303,6 +304,7 @@ static const struct { { AV_CPU_FLAG_VFP, "vfp" }, { AV_CPU_FLAG_VFPV3, "vfpv3" }, { AV_CPU_FLAG_NEON, "neon" }, + { AV_CPU_FLAG_SETEND, "setend" }, #elif ARCH_PPC { AV_CPU_FLAG_ALTIVEC, "altivec" }, #elif ARCH_X86 diff --git a/libavutil/cpu.h b/libavutil/cpu.h index 8ff14d3..277e489 100644 --- a/libavutil/cpu.h +++ b/libavutil/cpu.h @@ -64,6 +64,7 @@ #define AV_CPU_FLAG_VFPV3 (1 << 4) #define AV_CPU_FLAG_NEON (1 << 5) #define AV_CPU_FLAG_ARMV8 (1 << 6) +#define AV_CPU_FLAG_SETEND (1 <<16) /** * Return the flags which specify extensions supported by the CPU. -- 1.7.9.5 From mindmark at gmail.com Thu Aug 7 19:20:35 2014 From: mindmark at gmail.com (Mark Reid) Date: Thu, 7 Aug 2014 10:20:35 -0700 Subject: [FFmpeg-devel] [PATCH v2] read reel_name metadata from tmcd atom Message-ID: <1407432036-95391-1-git-send-email-mindmark@gmail.com> Changes since v1: * corrected overflow issues on extradata size checking * added additional size check before malloc * removed strcmp Mark Reid (1): read reel_name metadata from tmcd atom libavformat/mov.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) -- 2.0.0 From mindmark at gmail.com Thu Aug 7 19:20:36 2014 From: mindmark at gmail.com (Mark Reid) Date: Thu, 7 Aug 2014 10:20:36 -0700 Subject: [FFmpeg-devel] [PATCH v2] read reel_name metadata from tmcd atom In-Reply-To: <1407432036-95391-1-git-send-email-mindmark@gmail.com> References: <1407432036-95391-1-git-send-email-mindmark@gmail.com> Message-ID: <1407432036-95391-2-git-send-email-mindmark@gmail.com> --- libavformat/mov.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index ab85918..afdb9b0 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1529,6 +1529,26 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb, st->codec->flags2 |= CODEC_FLAG2_DROP_FRAME_TIMECODE; st->codec->time_base.den = st->codec->extradata[16]; /* number of frame */ st->codec->time_base.num = 1; + if (size > 30) { + uint32_t len = AV_RB32(st->codec->extradata + 18); /* name atom length */ + uint32_t format = AV_RB32(st->codec->extradata + 22); + if (format == AV_RB32("name") && (int64_t)size >= (int64_t)len + 18) { + uint16_t str_size = AV_RB16(st->codec->extradata + 26); /* string length */ + if (str_size > 0 && size >= (int)str_size + 26) { + char *reel_name = av_malloc(str_size + 1); + if (!reel_name) + return AVERROR(ENOMEM); + memcpy(reel_name, st->codec->extradata + 30, str_size); + reel_name[str_size] = 0; /* Add null terminator */ + /* don't add reel_name if emtpy string */ + if (*reel_name == 0) { + av_free(reel_name); + } else { + av_dict_set(&st->metadata, "reel_name", reel_name, AV_DICT_DONT_STRDUP_VAL); + } + } + } + } } } else { /* other codec type, just skip (rtp, mp4s ...) */ -- 2.0.0 From cus at passwd.hu Thu Aug 7 19:44:32 2014 From: cus at passwd.hu (Marton Balint) Date: Thu, 7 Aug 2014 19:44:32 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH]Make subtitle properties code in lavc more robust In-Reply-To: <201408071402.33313.cehoyos@ag.or.at> References: <201408071402.33313.cehoyos@ag.or.at> Message-ID: On Thu, 7 Aug 2014, Carl Eugen Hoyos wrote: > Hi! > > Attached patch should allow to set the teletext decoder properties to > (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB). > At the moment, the documentation states that if a property of this kind is set, then the decoder will provide subtitles with the given type. That will not be true for teletext, because it will only provide one format. The bitmap or the ass representation, not both. So before applying this patch, I think we should decide what these properties mean exactly... Regards, Marton From michaelni at gmx.at Thu Aug 7 19:45:17 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 19:45:17 +0200 Subject: [FFmpeg-devel] XMP in mov files In-Reply-To: References: <20140807133728.GV12391@nb4> Message-ID: <20140807174517.GX12391@nb4> On Thu, Aug 07, 2014 at 04:19:15PM +0200, Marek Fort wrote: > Yes, here is one: > > http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket3707/Untitled_dnhd.mov ok, seems to work, patch applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The bravest are surely those who have the clearest vision of what is before them, glory and danger alike, and yet notwithstanding go out to meet it. -- Thucydides -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From u at pkh.me Thu Aug 7 20:06:41 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Thu, 7 Aug 2014 20:06:41 +0200 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: rewrite [f/i]dct In-Reply-To: <20140804150821.GV4649@nb4> References: <1407097641-26789-1-git-send-email-u@pkh.me> <20140803224448.GK4649@nb4> <20140803231437.GM4649@nb4> <20140804150821.GV4649@nb4> Message-ID: <20140807180640.GA3994@leki> On Mon, Aug 04, 2014 at 05:08:21PM +0200, Michael Niedermayer wrote: [...] > > > > + const float xd_2 = 1.306562964876380*xc_2 + 0.541196100146197*xc_3; > > > > + const float xd_3 = 0.541196100146197*xc_2 - 1.306562964876380*xc_3; > > > > + const float x1_9 = 0.707106781186547*xb_2 - 0.707106781186547*xd_3; > > > > + const float x1_a = 0.707106781186547*xb_2 + 0.707106781186547*xd_3; > > > > + const float x1_b = 0.707106781186547*xb_1 + 0.707106781186547*xd_1; > > > > + const float x1_c = 0.707106781186547*xb_1 - 0.707106781186547*xd_1; > > > > + const float x1_d = 0.707106781186547*xb_3 - 0.707106781186547*xd_2; > > > > + const float x1_e = 0.707106781186547*xb_3 + 0.707106781186547*xd_2; > > > > + dst[ 0*dst_stridea] = 0.25*x5_0; > > > > + dst[ 1*dst_stridea] = 0.25*xb_0; > > > > + dst[ 2*dst_stridea] = 0.25*x7_0; > > > > + dst[ 3*dst_stridea] = 0.25*x1_9; > > > > + dst[ 4*dst_stridea] = 0.25*x5_2; > > > > + dst[ 5*dst_stridea] = 0.25*x1_a; > > > > + dst[ 6*dst_stridea] = 0.25*x3_5; > > > > + dst[ 7*dst_stridea] = 0.25*x1_b; > > > > + dst[ 8*dst_stridea] = 0.25*x5_1; > > > > + dst[ 9*dst_stridea] = 0.25*x1_c; > > > > + dst[10*dst_stridea] = 0.25*x3_6; > > > > + dst[11*dst_stridea] = 0.25*x1_d; > > > > + dst[12*dst_stridea] = 0.25*x5_3; > > > > + dst[13*dst_stridea] = 0.25*x1_e; > > > > + dst[14*dst_stridea] = 0.25*x7_2; > > > > + dst[15*dst_stridea] = 0.25*xd_0; > > > > > > many of these multiplies look like they can be merged into other > > > multiplies > > > > > > for example see: > > > > > > > > > const float xd_2 = 1.306562964876380*xc_2 + 0.541196100146197*xc_3; > > > const float xb_3 = 0.541196100146197*xa_2 - 1.306562964876380*xa_3; > > > const float x1_d = 0.707106781186547*xb_3 - 0.707106781186547*xd_2; > > > const float x1_e = 0.707106781186547*xb_3 + 0.707106781186547*xd_2; > > > dst[11*dst_stridea] = 0.25*x1_d; > > > dst[13*dst_stridea] = 0.25*x1_e; > > > > > > vs. > > > > > > const float xd_2 = (0.25*0.707106781186547*1.306562964876380)*xc_2 + (0.25*0.707106781186547*0.541196100146197)*xc_3; > > > const float xb_3 = (0.25*0.707106781186547*0.541196100146197)*xa_2 - (0.25*0.707106781186547*1.306562964876380)*xa_3; > > > dst[11*dst_stridea] = xb_3 - xd_2; > > > dst[13*dst_stridea] = xb_3 + xd_2; > > > > also more generally > > if you have 2 stages of butterflies each with 4 multiplies and 2 adds > > in each butterfly > > > > a----\-/--\---/----------a' > > X \ / > > b----/-\----------\---/--b' > > / \ \ / > > c----\-/--/---\----------c' > > X / \ > > d----/-\----------/---\--d' > > > > > > of additions > > the first stage can scale their output arbitrarily for free by > > changing the respective coefficients > > the second stage can use any scaled input for free by adjusting their > > coefficients similarly, this gives you 4 free parameters in the > > example above which can be > > choosen so as to make some coefficients trivial like +-1.0 > > this also works accorss 2D (I)DCTs or with other things before or > > after the (i)dct which can absorb such rescaling > > also i suggest that the patch is applied before time is > spend optimizing it further, > also the moving around of multiplies can probably affect numerical > stability if overdone I factorized obvious cases as you suggested. I also made the generated code more readable. Further optimizations are postponed. Applied, thanks! -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From jajdorkster at gmail.com Thu Aug 7 02:29:40 2014 From: jajdorkster at gmail.com (Justin Jacobs) Date: Wed, 6 Aug 2014 20:29:40 -0400 Subject: [FFmpeg-devel] [PATCH] NULL-check Matroska chapters when reading header Message-ID: I have a Matroska file that contains a broken chapter (end time is before start time) that caused any ffmpeg-linked program to crash when accessing it. I've attached a patch that fixes the crash. Also, here is the backtrace of the crash for reference: (gdb) backtrace #0 av_dict_set (pm=0x20, key=0x7ffff0bd14ef "title", value=0x7fffd80107e0 "The End", flags=0) at libavutil/dict.c:71 #1 0x00007ffff0b0e220 in matroska_read_header (s=0x20) at libavformat/matroskadec.c:2164 #2 0x00007ffff0b9b233 in avformat_open_input (ps=0x7fffe00c1a08, filename=, fmt=, options=0x0) at libavformat/utils.c:599 #3 0x00007ffff5fc9c32 in ffmpegthumbnailer::MovieDecoder::initialize(std::string const&) () from /usr/lib/libffmpegthumbnailer.so.4 #4 0x00007ffff5fcd50f in ffmpegthumbnailer::VideoThumbnailer::generateThumbnail(std::string const&, ffmpegthumbnailer::ImageWriter&, AVFormatContext*) () from /usr/lib/libffmpegthumbnailer.so.4 #5 0x00007ffff5fcd911 in ffmpegthumbnailer::VideoThumbnailer::generateThumbnail(std::string const&, ThumbnailerImageTypeEnum, std::string const&, AVFormatContext*) () from /usr/lib/libffmpegthumbnailer.so.4 #6 0x00007ffff5fce636 in video_thumbnailer_generate_thumbnail_to_file () from /usr/lib/libffmpegthumbnailer.so.4 #7 0x00000000004314e5 in ?? () #8 0x00000000004319a0 in ?? () #9 0x000000000042221f in ?? () #10 0x00000000004310bb in ?? () #11 0x0000000000430dd0 in ?? () #12 0x00007ffff644ec95 in ?? () from /usr/lib/libglib-2.0.so.0 #13 0x00007ffff5766124 in start_thread () from /usr/lib/libpthread.so.0 #14 0x00007ffff549a4bd in clone () from /usr/lib/libc.so.6 Thanks, Justin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-NULL-check-Matroska-chapters-when-reading-header.patch Type: text/x-patch Size: 1101 bytes Desc: not available URL: From jamrial at gmail.com Thu Aug 7 22:12:40 2014 From: jamrial at gmail.com (James Almer) Date: Thu, 7 Aug 2014 17:12:40 -0300 Subject: [FFmpeg-devel] [PATCH 1/2] lavf/avio: rename url_feof() to avio_feof() Message-ID: <1407442361-4104-1-git-send-email-jamrial@gmail.com> It's a public function and should use the avio_ namespace Signed-off-by: James Almer --- I'm scheduling the removal to lavf 57 since libav is about to force a bump. doc/APIchanges | 3 +++ libavformat/avio.h | 7 +++++++ libavformat/aviobuf.c | 9 ++++++++- libavformat/libavformat.v | 2 +- libavformat/version.h | 5 ++++- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 4774f96..9bcd916 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2012-10-22 API changes, most recent first: +2014-08-xx - xxxxxxx - lavf 55.53.100 - avio.h + Add avio_feof() and deprecate url_feof(). + 2014-08-xx - xxxxxxx - lsws 2.1.3 - swscale.h sws_getContext is not going to be removed in the future. diff --git a/libavformat/avio.h b/libavformat/avio.h index e607df5..1aa3602 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -276,7 +276,14 @@ int64_t avio_size(AVIOContext *s); * feof() equivalent for AVIOContext. * @return non zero if and only if end of file */ +int avio_feof(AVIOContext *s); +#if FF_API_URL_FEOF +/** + * @deprecated use avio_feof() + */ +attribute_deprecated int url_feof(AVIOContext *s); +#endif /** @warning currently size is limited */ int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3); diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index c7e9203..946f249 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -292,7 +292,7 @@ int64_t avio_size(AVIOContext *s) return size; } -int url_feof(AVIOContext *s) +int avio_feof(AVIOContext *s) { if(!s) return 0; @@ -303,6 +303,13 @@ int url_feof(AVIOContext *s) return s->eof_reached; } +#if FF_API_URL_FEOF +int url_feof(AVIOContext *s) +{ + return avio_feof(s); +} +#endif + void avio_wl32(AVIOContext *s, unsigned int val) { avio_w8(s, (uint8_t) val ); diff --git a/libavformat/libavformat.v b/libavformat/libavformat.v index 6ae6445..8243994 100644 --- a/libavformat/libavformat.v +++ b/libavformat/libavformat.v @@ -19,7 +19,7 @@ LIBAVFORMAT_$MAJOR { ffurl_write; ffurl_protocol_next; #those are deprecated, remove on next bump - url_*; + url_feof; get_*; ff_codec_get_id; local: *; diff --git a/libavformat/version.h b/libavformat/version.h index ffa9f87..a10e14e 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,7 @@ #define LIBAVFORMAT_VERSION_MAJOR 55 -#define LIBAVFORMAT_VERSION_MINOR 52 +#define LIBAVFORMAT_VERSION_MINOR 53 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ @@ -61,6 +61,9 @@ #ifndef FF_API_LAVF_CODEC_TB #define FF_API_LAVF_CODEC_TB (LIBAVFORMAT_VERSION_MAJOR < 57) #endif +#ifndef FF_API_URL_FEOF +#define FF_API_URL_FEOF (LIBAVFORMAT_VERSION_MAJOR < 57) +#endif #ifndef FF_API_ALLOC_OUTPUT_CONTEXT #define FF_API_ALLOC_OUTPUT_CONTEXT (LIBAVFORMAT_VERSION_MAJOR < 56) -- 1.8.5.5 From jamrial at gmail.com Thu Aug 7 22:12:41 2014 From: jamrial at gmail.com (James Almer) Date: Thu, 7 Aug 2014 17:12:41 -0300 Subject: [FFmpeg-devel] [PATCH 2/2] replace calls to url_feof() with avio_feof() In-Reply-To: <1407442361-4104-1-git-send-email-jamrial@gmail.com> References: <1407442361-4104-1-git-send-email-jamrial@gmail.com> Message-ID: <1407442361-4104-2-git-send-email-jamrial@gmail.com> Signed-off-by: James Almer --- ffplay.c | 4 ++-- libavformat/4xm.c | 2 +- libavformat/adp.c | 2 +- libavformat/aiffdec.c | 2 +- libavformat/amr.c | 2 +- libavformat/anm.c | 2 +- libavformat/ape.c | 2 +- libavformat/aqtitledec.c | 2 +- libavformat/asfdec.c | 16 ++++++++-------- libavformat/astdec.c | 2 +- libavformat/avidec.c | 12 ++++++------ libavformat/bethsoftvid.c | 2 +- libavformat/bfi.c | 4 ++-- libavformat/bintext.c | 2 +- libavformat/bit.c | 2 +- libavformat/brstm.c | 4 ++-- libavformat/cafdec.c | 6 +++--- libavformat/cdxl.c | 2 +- libavformat/dauddec.c | 2 +- libavformat/dsicin.c | 2 +- libavformat/dtshddec.c | 2 +- libavformat/dv.c | 2 +- libavformat/dxa.c | 4 ++-- libavformat/electronicarts.c | 4 ++-- libavformat/ffmdec.c | 4 ++-- libavformat/ffmetadec.c | 4 ++-- libavformat/filmstripdec.c | 2 +- libavformat/flacdec.c | 2 +- libavformat/flvdec.c | 2 +- libavformat/gifdec.c | 6 +++--- libavformat/gxf.c | 4 ++-- libavformat/hls.c | 4 ++-- libavformat/hlsproto.c | 2 +- libavformat/idcin.c | 2 +- libavformat/idroqdec.c | 2 +- libavformat/iff.c | 2 +- libavformat/img2dec.c | 2 +- libavformat/ipmovie.c | 6 +++--- libavformat/jacosubdec.c | 2 +- libavformat/jvdec.c | 2 +- libavformat/lrcdec.c | 4 ++-- libavformat/lvfdec.c | 4 ++-- libavformat/lxfdec.c | 2 +- libavformat/matroskadec.c | 4 ++-- libavformat/mgsts.c | 2 +- libavformat/microdvddec.c | 2 +- libavformat/mlvdec.c | 2 +- libavformat/mmf.c | 2 +- libavformat/mov.c | 6 +++--- libavformat/mpc8.c | 4 ++-- libavformat/mpeg.c | 6 +++--- libavformat/mpegts.c | 2 +- libavformat/mpl2dec.c | 2 +- libavformat/mpsubdec.c | 2 +- libavformat/msnwc_tcp.c | 4 ++-- libavformat/mxfdec.c | 8 ++++---- libavformat/mxg.c | 2 +- libavformat/ncdec.c | 2 +- libavformat/nistspheredec.c | 2 +- libavformat/nsvdec.c | 12 ++++++------ libavformat/nutdec.c | 4 ++-- libavformat/nuv.c | 8 ++++---- libavformat/oggdec.c | 2 +- libavformat/paf.c | 2 +- libavformat/pjsdec.c | 2 +- libavformat/pmpdec.c | 4 ++-- libavformat/psxstr.c | 2 +- libavformat/qcp.c | 2 +- libavformat/realtextdec.c | 2 +- libavformat/redspark.c | 2 +- libavformat/riffdec.c | 2 +- libavformat/rmdec.c | 6 +++--- libavformat/rpl.c | 2 +- libavformat/rsd.c | 2 +- libavformat/samidec.c | 2 +- libavformat/smacker.c | 2 +- libavformat/smjpegdec.c | 4 ++-- libavformat/smush.c | 4 ++-- libavformat/sol.c | 2 +- libavformat/spdifdec.c | 2 +- libavformat/srtdec.c | 2 +- libavformat/subviewer1dec.c | 2 +- libavformat/subviewerdec.c | 2 +- libavformat/swfdec.c | 2 +- libavformat/takdec.c | 2 +- libavformat/tmv.c | 2 +- libavformat/tty.c | 2 +- libavformat/txd.c | 2 +- libavformat/vc1test.c | 2 +- libavformat/vivo.c | 6 +++--- libavformat/vplayerdec.c | 2 +- libavformat/vqf.c | 2 +- libavformat/wavdec.c | 10 +++++----- libavformat/wc3movie.c | 4 ++-- libavformat/wtvdec.c | 10 +++++----- libavformat/wvdec.c | 2 +- 96 files changed, 160 insertions(+), 160 deletions(-) diff --git a/ffplay.c b/ffplay.c index af0e199..e1e4ccc 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2824,7 +2824,7 @@ static int read_thread(void *arg) av_freep(&opts); if (ic->pb) - ic->pb->eof_reached = 0; // FIXME hack, ffplay maybe should not use url_feof() to test for the end + ic->pb->eof_reached = 0; // FIXME hack, ffplay maybe should not use avio_feof() to test for the end if (seek_by_bytes < 0) seek_by_bytes = !!(ic->iformat->flags & AVFMT_TS_DISCONT) && strcmp("ogg", ic->iformat->name); @@ -3013,7 +3013,7 @@ static int read_thread(void *arg) } ret = av_read_frame(ic, pkt); if (ret < 0) { - if (ret == AVERROR_EOF || url_feof(ic->pb)) + if (ret == AVERROR_EOF || avio_feof(ic->pb)) eof = 1; if (ic->pb && ic->pb->error) break; diff --git a/libavformat/4xm.c b/libavformat/4xm.c index 0b4ddfa..daf389d 100644 --- a/libavformat/4xm.c +++ b/libavformat/4xm.c @@ -293,7 +293,7 @@ static int fourxm_read_packet(AVFormatContext *s, return ret; fourcc_tag = AV_RL32(&header[0]); size = AV_RL32(&header[4]); - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR(EIO); switch (fourcc_tag) { case LIST_TAG: diff --git a/libavformat/adp.c b/libavformat/adp.c index 08a4225..8a3661a 100644 --- a/libavformat/adp.c +++ b/libavformat/adp.c @@ -71,7 +71,7 @@ static int adp_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size = 1024; - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR_EOF; ret = av_get_packet(s->pb, pkt, size); diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index 7accec4..91ef2a4 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -58,7 +58,7 @@ static int get_tag(AVIOContext *pb, uint32_t * tag) { int size; - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR(EIO); *tag = avio_rl32(pb); diff --git a/libavformat/amr.c b/libavformat/amr.c index 24d5ce0..8f44de1 100644 --- a/libavformat/amr.c +++ b/libavformat/amr.c @@ -117,7 +117,7 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt) int64_t pos = avio_tell(s->pb); AMRContext *amr = s->priv_data; - if (url_feof(s->pb)) { + if (avio_feof(s->pb)) { return AVERROR(EIO); } diff --git a/libavformat/anm.c b/libavformat/anm.c index 1c58575..5196cb8 100644 --- a/libavformat/anm.c +++ b/libavformat/anm.c @@ -175,7 +175,7 @@ static int read_packet(AVFormatContext *s, Page *p; int tmp, record_size; - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR(EIO); if (anm->page < 0) diff --git a/libavformat/ape.c b/libavformat/ape.c index d5a786a..fafc1df 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -389,7 +389,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt) APEContext *ape = s->priv_data; uint32_t extra_size = 8; - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR_EOF; if (ape->currentframe >= ape->totalframes) return AVERROR_EOF; diff --git a/libavformat/aqtitledec.c b/libavformat/aqtitledec.c index 810f95b..9508766 100644 --- a/libavformat/aqtitledec.c +++ b/libavformat/aqtitledec.c @@ -61,7 +61,7 @@ static int aqt_read_header(AVFormatContext *s) st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codec->codec_id = AV_CODEC_ID_TEXT; - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { char line[4096]; int len = ff_get_line(s->pb, line, sizeof(line)); diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 978b956..5fc293e 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -785,7 +785,7 @@ static int asf_read_header(AVFormatContext *s) continue; } else if (!ff_guidcmp(&g, &ff_asf_marker_header)) { asf_read_marker(s, gsize); - } else if (url_feof(pb)) { + } else if (avio_feof(pb)) { return AVERROR_EOF; } else { if (!s->keylen) { @@ -822,7 +822,7 @@ static int asf_read_header(AVFormatContext *s) avio_rl64(pb); avio_r8(pb); avio_r8(pb); - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; asf->data_offset = avio_tell(pb); asf->packet_size_left = 0; @@ -922,20 +922,20 @@ static int asf_get_packet(AVFormatContext *s, AVIOContext *pb) * the stream. */ if (pb->error == AVERROR(EAGAIN)) return AVERROR(EAGAIN); - if (!url_feof(pb)) + if (!avio_feof(pb)) av_log(s, AV_LOG_ERROR, "ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb)); } if ((c & 0x8f) == 0x82) { if (d || e) { - if (!url_feof(pb)) + if (!avio_feof(pb)) av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n"); return AVERROR_INVALIDDATA; } c = avio_r8(pb); d = avio_r8(pb); rsize += 3; - } else if(!url_feof(pb)) { + } else if(!avio_feof(pb)) { avio_seek(pb, -1, SEEK_CUR); // FIXME } @@ -1126,7 +1126,7 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt) ASFStream *asf_st = 0; for (;;) { int ret; - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; if (asf->packet_size_left < FRAME_HEADER_SIZE || asf->packet_segments < 1 && asf->packet_time_start == 0) { @@ -1494,7 +1494,7 @@ static int asf_build_simple_index(AVFormatContext *s, int stream_index) * skip them until the simple index object is reached */ while (ff_guidcmp(&g, &ff_asf_simple_index_header)) { int64_t gsize = avio_rl64(s->pb); - if (gsize < 24 || url_feof(s->pb)) { + if (gsize < 24 || avio_feof(s->pb)) { goto end; } avio_skip(s->pb, gsize - 24); @@ -1532,7 +1532,7 @@ static int asf_build_simple_index(AVFormatContext *s, int stream_index) asf->index_read = ict > 1; } end: -// if (url_feof(s->pb)) { +// if (avio_feof(s->pb)) { // ret = 0; // } avio_seek(s->pb, current_pos, SEEK_SET); diff --git a/libavformat/astdec.c b/libavformat/astdec.c index 3fa26dc..92c208d 100644 --- a/libavformat/astdec.c +++ b/libavformat/astdec.c @@ -84,7 +84,7 @@ static int ast_read_packet(AVFormatContext *s, AVPacket *pkt) int64_t pos; int ret; - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR_EOF; pos = avio_tell(s->pb); diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 8c70649..5b260e2 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -219,7 +219,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num) #ifdef DEBUG_SEEK av_log(s, AV_LOG_ERROR, "pos:%"PRId64", len:%X\n", pos, len); #endif - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_INVALIDDATA; if (last_pos == pos || pos == base - 8) @@ -237,7 +237,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num) avio_rl32(pb); /* size */ duration = avio_rl32(pb); - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_INVALIDDATA; pos = avio_tell(pb); @@ -492,7 +492,7 @@ static int avi_read_header(AVFormatContext *s) codec_type = -1; frame_period = 0; for (;;) { - if (url_feof(pb)) + if (avio_feof(pb)) goto fail; tag = avio_rl32(pb); size = avio_rl32(pb); @@ -1111,7 +1111,7 @@ static int avi_sync(AVFormatContext *s, int exit_early) start_sync: memset(d, -1, sizeof(d)); - for (i = sync = avio_tell(pb); !url_feof(pb); i++) { + for (i = sync = avio_tell(pb); !avio_feof(pb); i++) { int j; for (j = 0; j < 7; j++) @@ -1506,7 +1506,7 @@ static int avi_read_idx1(AVFormatContext *s, int size) /* Read the entries and sort them in each stream component. */ for (i = 0; i < nb_index_entries; i++) { - if (url_feof(pb)) + if (avio_feof(pb)) return -1; tag = avio_rl32(pb); @@ -1662,7 +1662,7 @@ static int avi_load_index(AVFormatContext *s) for (;;) { tag = avio_rl32(pb); size = avio_rl32(pb); - if (url_feof(pb)) + if (avio_feof(pb)) break; next = avio_tell(pb) + size + (size & 1); diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c index 6b84b79..c98ff14 100644 --- a/libavformat/bethsoftvid.c +++ b/libavformat/bethsoftvid.c @@ -213,7 +213,7 @@ static int vid_read_packet(AVFormatContext *s, int audio_length; int ret_value; - if(vid->is_finished || url_feof(pb)) + if(vid->is_finished || avio_feof(pb)) return AVERROR_EOF; block_type = avio_r8(pb); diff --git a/libavformat/bfi.c b/libavformat/bfi.c index b65a582..cc7f494 100644 --- a/libavformat/bfi.c +++ b/libavformat/bfi.c @@ -116,7 +116,7 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt) BFIContext *bfi = s->priv_data; AVIOContext *pb = s->pb; int ret, audio_offset, video_offset, chunk_size, audio_size = 0; - if (bfi->nframes == 0 || url_feof(pb)) { + if (bfi->nframes == 0 || avio_feof(pb)) { return AVERROR_EOF; } @@ -124,7 +124,7 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt) if (!bfi->avflag) { uint32_t state = 0; while(state != MKTAG('S','A','V','I')){ - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR(EIO); state = 256*state + avio_r8(pb); } diff --git a/libavformat/bintext.c b/libavformat/bintext.c index d50a8d9..217ea49 100644 --- a/libavformat/bintext.c +++ b/libavformat/bintext.c @@ -310,7 +310,7 @@ static int read_packet(AVFormatContext *s, return AVERROR(EIO); bin->fsize = -1; /* done */ } else if (!bin->fsize) { - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR(EIO); if (av_get_packet(s->pb, pkt, bin->chars_per_frame) < 0) return AVERROR(EIO); diff --git a/libavformat/bit.c b/libavformat/bit.c index 0be471a..7b807b9 100644 --- a/libavformat/bit.c +++ b/libavformat/bit.c @@ -76,7 +76,7 @@ static int read_packet(AVFormatContext *s, int i, j, ret; int64_t pos= avio_tell(pb); - if(url_feof(pb)) + if(avio_feof(pb)) return AVERROR_EOF; avio_rl16(pb); // sync word diff --git a/libavformat/brstm.c b/libavformat/brstm.c index 8e4dae6..19a4a2a 100644 --- a/libavformat/brstm.c +++ b/libavformat/brstm.c @@ -181,7 +181,7 @@ static int read_header(AVFormatContext *s) } avio_skip(s->pb, size - (avio_tell(s->pb) - pos)); - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { chunk = avio_rl32(s->pb); size = avio_rb32(s->pb); if (size < 8) { @@ -244,7 +244,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) uint32_t samples, size; int ret; - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR_EOF; b->current_block++; if (b->current_block == b->block_count) { diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index a8edbca..c797e20 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -241,7 +241,7 @@ static int read_header(AVFormatContext *s) /* parse each chunk */ found_data = 0; - while (!url_feof(pb)) { + while (!avio_feof(pb)) { /* stop at data chunk if seeking is not supported or data chunk size is unknown */ @@ -251,7 +251,7 @@ static int read_header(AVFormatContext *s) tag = avio_rb32(pb); size = avio_rb64(pb); pos = avio_tell(pb); - if (url_feof(pb)) + if (avio_feof(pb)) break; switch (tag) { @@ -339,7 +339,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) int res, pkt_size = 0, pkt_frames = 0; int64_t left = CAF_MAX_PKT_SIZE; - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; /* don't read past end of data chunk */ diff --git a/libavformat/cdxl.c b/libavformat/cdxl.c index ab8a846..e3e379a 100644 --- a/libavformat/cdxl.c +++ b/libavformat/cdxl.c @@ -110,7 +110,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt) int64_t pos; int ret; - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; pos = avio_tell(pb); diff --git a/libavformat/dauddec.c b/libavformat/dauddec.c index 30d1200..f6e7491 100644 --- a/libavformat/dauddec.c +++ b/libavformat/dauddec.c @@ -41,7 +41,7 @@ static int daud_header(AVFormatContext *s) { static int daud_packet(AVFormatContext *s, AVPacket *pkt) { AVIOContext *pb = s->pb; int ret, size; - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR(EIO); size = avio_rb16(pb); avio_rb16(pb); // unknown diff --git a/libavformat/dsicin.c b/libavformat/dsicin.c index 4a54680..4b5a934 100644 --- a/libavformat/dsicin.c +++ b/libavformat/dsicin.c @@ -150,7 +150,7 @@ static int cin_read_frame_header(CinDemuxContext *cin, AVIOContext *pb) { hdr->video_frame_size = avio_rl32(pb); hdr->audio_frame_size = avio_rl32(pb); - if (url_feof(pb) || pb->error) + if (avio_feof(pb) || pb->error) return AVERROR(EIO); if (avio_rl32(pb) != 0xAA55AA55) diff --git a/libavformat/dtshddec.c b/libavformat/dtshddec.c index 55c4ca6..0fd0304 100644 --- a/libavformat/dtshddec.c +++ b/libavformat/dtshddec.c @@ -64,7 +64,7 @@ static int dtshd_read_header(AVFormatContext *s) st->codec->codec_id = AV_CODEC_ID_DTS; st->need_parsing = AVSTREAM_PARSE_FULL_RAW; - while (!url_feof(pb)) { + while (!avio_feof(pb)) { chunk_type = avio_rb64(pb); chunk_size = avio_rb64(pb); diff --git a/libavformat/dv.c b/libavformat/dv.c index 1e15c08..1030d51 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -504,7 +504,7 @@ static int dv_read_header(AVFormatContext *s) state = avio_rb32(s->pb); while ((state & 0xffffff7f) != 0x1f07003f) { - if (url_feof(s->pb)) { + if (avio_feof(s->pb)) { av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n"); return -1; } diff --git a/libavformat/dxa.c b/libavformat/dxa.c index ea5b4f7..6ad1c9f 100644 --- a/libavformat/dxa.c +++ b/libavformat/dxa.c @@ -112,7 +112,7 @@ static int dxa_read_header(AVFormatContext *s) if (ast->codec->sample_rate > 0) avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate); // find 'data' chunk - while(avio_tell(pb) < c->vidpos && !url_feof(pb)){ + while(avio_tell(pb) < c->vidpos && !avio_feof(pb)){ tag = avio_rl32(pb); fsize = avio_rl32(pb); if(tag == MKTAG('d', 'a', 't', 'a')) break; @@ -170,7 +170,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt) return 0; } avio_seek(s->pb, c->vidpos, SEEK_SET); - while(!url_feof(s->pb) && c->frames){ + while(!avio_feof(s->pb) && c->frames){ if ((ret = avio_read(s->pb, buf, 4)) != 4) { av_log(s, AV_LOG_ERROR, "failed reading chunk type\n"); return ret < 0 ? ret : AVERROR_INVALIDDATA; diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c index 1acaa14..515b70f 100644 --- a/libavformat/electronicarts.c +++ b/libavformat/electronicarts.c @@ -109,7 +109,7 @@ static int process_audio_header_elements(AVFormatContext *s) ea->sample_rate = -1; ea->num_channels = 1; - while (!url_feof(pb) && in_header) { + while (!avio_feof(pb) && in_header) { int in_subheader; uint8_t byte; byte = avio_r8(pb); @@ -118,7 +118,7 @@ static int process_audio_header_elements(AVFormatContext *s) case 0xFD: av_log(s, AV_LOG_DEBUG, "entered audio subheader\n"); in_subheader = 1; - while (!url_feof(pb) && in_subheader) { + while (!avio_feof(pb) && in_subheader) { uint8_t subbyte; subbyte = avio_r8(pb); diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index d296ca7..f8fee2f 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -63,7 +63,7 @@ static int ffm_resync(AVFormatContext *s, int state) { av_log(s, AV_LOG_ERROR, "resyncing\n"); while (state != PACKET_ID) { - if (url_feof(s->pb)) { + if (avio_feof(s->pb)) { av_log(s, AV_LOG_ERROR, "cannot find FFM syncword\n"); return -1; } @@ -250,7 +250,7 @@ static int ffm2_read_header(AVFormatContext *s) ffm->file_size = (UINT64_C(1) << 63) - 1; } - while(!url_feof(pb)) { + while(!avio_feof(pb)) { unsigned id = avio_rb32(pb); unsigned size = avio_rb32(pb); int64_t next = avio_tell(pb) + size; diff --git a/libavformat/ffmetadec.c b/libavformat/ffmetadec.c index 19c14e4..e4e9dda 100644 --- a/libavformat/ffmetadec.c +++ b/libavformat/ffmetadec.c @@ -50,7 +50,7 @@ static void get_line(AVIOContext *s, uint8_t *buf, int size) buf[i++] = c; } buf[i] = 0; - } while (!url_feof(s) && (buf[0] == ';' || buf[0] == '#' || buf[0] == 0)); + } while (!avio_feof(s) && (buf[0] == ';' || buf[0] == '#' || buf[0] == 0)); } static AVChapter *read_chapter(AVFormatContext *s) @@ -128,7 +128,7 @@ static int read_header(AVFormatContext *s) AVDictionary **m = &s->metadata; uint8_t line[1024]; - while(!url_feof(s->pb)) { + while(!avio_feof(s->pb)) { get_line(s->pb, line, sizeof(line)); if (!memcmp(line, ID_STREAM, strlen(ID_STREAM))) { diff --git a/libavformat/filmstripdec.c b/libavformat/filmstripdec.c index 1cd1a48..abc5f66 100644 --- a/libavformat/filmstripdec.c +++ b/libavformat/filmstripdec.c @@ -80,7 +80,7 @@ static int read_packet(AVFormatContext *s, FilmstripDemuxContext *film = s->priv_data; AVStream *st = s->streams[0]; - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR(EIO); pkt->dts = avio_tell(s->pb) / (st->codec->width * (st->codec->height + film->leading) * 4); pkt->size = av_get_packet(s->pb, pkt, st->codec->width * st->codec->height * 4); diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index d601c75..c4f9d86 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -49,7 +49,7 @@ static int flac_read_header(AVFormatContext *s) } /* process metadata blocks */ - while (!url_feof(s->pb) && !metadata_last) { + while (!avio_feof(s->pb) && !metadata_last) { avio_read(s->pb, header, 4); flac_parse_block_header(header, &metadata_last, &metadata_type, &metadata_size); diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 72833de..4dc341b 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -779,7 +779,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) dts = avio_rb24(s->pb); dts |= avio_r8(s->pb) << 24; av_dlog(s, "type:%d, size:%d, dts:%"PRId64" pos:%"PRId64"\n", type, size, dts, avio_tell(s->pb)); - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR_EOF; avio_skip(s->pb, 3); /* stream id, always 0 */ flags = 0; diff --git a/libavformat/gifdec.c b/libavformat/gifdec.c index 2981bca..7db5a27 100644 --- a/libavformat/gifdec.c +++ b/libavformat/gifdec.c @@ -84,7 +84,7 @@ static int resync(AVIOContext *pb) int b = avio_r8(pb); if (b != gif87a_sig[i] && b != gif89a_sig[i]) i = -(b != 'G'); - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; } return 0; @@ -234,7 +234,7 @@ parse_keyframe: ret = AVERROR_EOF; } - while (GIF_TRAILER != (block_label = avio_r8(pb)) && !url_feof(pb)) { + while (GIF_TRAILER != (block_label = avio_r8(pb)) && !avio_feof(pb)) { if (block_label == GIF_EXTENSION_INTRODUCER) { if ((ret = gif_read_ext (s)) < 0 ) goto resync; @@ -299,7 +299,7 @@ resync: if ((ret >= 0 && !frame_parsed) || ret == AVERROR_EOF) { /* This might happen when there is no image block * between extension blocks and GIF_TRAILER or EOF */ - if (!gdc->ignore_loop && (block_label == GIF_TRAILER || url_feof(pb)) + if (!gdc->ignore_loop && (block_label == GIF_TRAILER || avio_feof(pb)) && (gdc->total_iter < 0 || ++gdc->iter_count < gdc->total_iter)) return avio_seek(pb, 0, SEEK_SET); return AVERROR_EOF; diff --git a/libavformat/gxf.c b/libavformat/gxf.c index 479a8fb..6c624f0 100644 --- a/libavformat/gxf.c +++ b/libavformat/gxf.c @@ -442,7 +442,7 @@ static int gxf_header(AVFormatContext *s) { #define READ_ONE() \ { \ - if (!max_interval-- || url_feof(pb)) \ + if (!max_interval-- || avio_feof(pb)) \ goto out; \ tmp = tmp << 8 | avio_r8(pb); \ } @@ -504,7 +504,7 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) { int field_nr, field_info, skip = 0; int stream_index; if (!parse_packet_header(pb, &pkt_type, &pkt_len)) { - if (!url_feof(pb)) + if (!avio_feof(pb)) av_log(s, AV_LOG_ERROR, "sync lost\n"); return -1; } diff --git a/libavformat/hls.c b/libavformat/hls.c index 3897723..2ea62c6 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -541,7 +541,7 @@ static int parse_playlist(HLSContext *c, const char *url, pls->finished = 0; pls->type = PLS_TYPE_UNSPECIFIED; } - while (!url_feof(in)) { + while (!avio_feof(in)) { read_chomp_line(in, line, sizeof(line)); if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) { is_variant = 1; @@ -1532,7 +1532,7 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt) AVRational tb; ret = av_read_frame(pls->ctx, &pls->pkt); if (ret < 0) { - if (!url_feof(&pls->pb) && ret != AVERROR_EOF) + if (!avio_feof(&pls->pb) && ret != AVERROR_EOF) return ret; reset_packet(&pls->pkt); break; diff --git a/libavformat/hlsproto.c b/libavformat/hlsproto.c index f6fcbe5..e607c10 100644 --- a/libavformat/hlsproto.c +++ b/libavformat/hlsproto.c @@ -126,7 +126,7 @@ static int parse_playlist(URLContext *h, const char *url) free_segment_list(s); s->finished = 0; - while (!url_feof(in)) { + while (!avio_feof(in)) { read_chomp_line(in, line, sizeof(line)); if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) { struct variant_info info = {{0}}; diff --git a/libavformat/idcin.c b/libavformat/idcin.c index cc25fb0..b2623e8 100644 --- a/libavformat/idcin.c +++ b/libavformat/idcin.c @@ -262,7 +262,7 @@ static int idcin_read_packet(AVFormatContext *s, unsigned char palette_buffer[768]; uint32_t palette[256]; - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return s->pb->error ? s->pb->error : AVERROR_EOF; if (idcin->next_chunk_is_video) { diff --git a/libavformat/idroqdec.c b/libavformat/idroqdec.c index 8cdd72e..db678d6 100644 --- a/libavformat/idroqdec.c +++ b/libavformat/idroqdec.c @@ -106,7 +106,7 @@ static int roq_read_packet(AVFormatContext *s, while (!packet_read) { - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR(EIO); /* get the next chunk preamble */ diff --git a/libavformat/iff.c b/libavformat/iff.c index 2a06331..a46bc92 100644 --- a/libavformat/iff.c +++ b/libavformat/iff.c @@ -363,7 +363,7 @@ static int iff_read_header(AVFormatContext *s) iff->maud_bits = -1; iff->maud_compression = -1; - while(!url_feof(pb)) { + while(!avio_feof(pb)) { uint64_t orig_pos; int res; const char *metadata_tag = NULL; diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index cf51c0b..259f90b 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -419,7 +419,7 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) infer_size(&codec->width, &codec->height, size[0]); } else { f[0] = s1->pb; - if (url_feof(f[0])) + if (avio_feof(f[0])) return AVERROR(EIO); if (s->frame_size > 0) { size[0] = s->frame_size; diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c index 4a766ef..aa8f543 100644 --- a/libavformat/ipmovie.c +++ b/libavformat/ipmovie.c @@ -237,7 +237,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, return chunk_type; /* read the next chunk, wherever the file happens to be pointing */ - if (url_feof(pb)) + if (avio_feof(pb)) return CHUNK_EOF; if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) != CHUNK_PREAMBLE_SIZE) @@ -283,7 +283,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, while ((chunk_size > 0) && (chunk_type != CHUNK_BAD)) { /* read the next chunk, wherever the file happens to be pointing */ - if (url_feof(pb)) { + if (avio_feof(pb)) { chunk_type = CHUNK_EOF; break; } @@ -555,7 +555,7 @@ static int ipmovie_read_header(AVFormatContext *s) while (memcmp(signature_buffer, signature, sizeof(signature))) { memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1); signature_buffer[sizeof(signature_buffer) - 1] = avio_r8(pb); - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; } /* initialize private context members */ diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c index e77ab40..9a28870 100644 --- a/libavformat/jacosubdec.c +++ b/libavformat/jacosubdec.c @@ -174,7 +174,7 @@ static int jacosub_read_header(AVFormatContext *s) av_bprint_init(&header, 1024+FF_INPUT_BUFFER_PADDING_SIZE, 4096); - while (!url_feof(pb)) { + while (!avio_feof(pb)) { int cmd_len; const char *p = line; int64_t pos = avio_tell(pb); diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c index eab450d..21eb14d 100644 --- a/libavformat/jvdec.c +++ b/libavformat/jvdec.c @@ -166,7 +166,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) AVIOContext *pb = s->pb; AVStream *ast = s->streams[0]; - while (!url_feof(s->pb) && jv->pts < ast->nb_index_entries) { + while (!avio_feof(s->pb) && jv->pts < ast->nb_index_entries) { const AVIndexEntry *e = ast->index_entries + jv->pts; const JVFrame *jvf = jv->frames + jv->pts; diff --git a/libavformat/lrcdec.c b/libavformat/lrcdec.c index 3b02e34..df61853 100644 --- a/libavformat/lrcdec.c +++ b/libavformat/lrcdec.c @@ -104,7 +104,7 @@ static int64_t read_line(AVBPrint *buf, AVIOContext *pb) int64_t pos = avio_tell(pb); av_bprint_clear(buf); - while(!url_feof(pb)) { + while(!avio_feof(pb)) { int c = avio_r8(pb); if(c != '\r') { av_bprint_chars(buf, c, 1); @@ -169,7 +169,7 @@ static int lrc_read_header(AVFormatContext *s) st->codec->codec_id = AV_CODEC_ID_TEXT; av_bprint_init(&line, 0, AV_BPRINT_SIZE_UNLIMITED); - while(!url_feof(s->pb)) { + while(!avio_feof(s->pb)) { int64_t pos = read_line(&line, s->pb); int64_t header_offset = find_header(line.str); if(header_offset >= 0) { diff --git a/libavformat/lvfdec.c b/libavformat/lvfdec.c index 1ff67c8..81aec59 100644 --- a/libavformat/lvfdec.c +++ b/libavformat/lvfdec.c @@ -51,7 +51,7 @@ static int lvf_read_header(AVFormatContext *s) avio_skip(s->pb, 1012); - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { id = avio_rl32(s->pb); size = avio_rl32(s->pb); next_offset = avio_tell(s->pb) + size; @@ -108,7 +108,7 @@ static int lvf_read_packet(AVFormatContext *s, AVPacket *pkt) int ret, is_video = 0; pos = avio_tell(s->pb); - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { id = avio_rl32(s->pb); size = avio_rl32(s->pb); diff --git a/libavformat/lxfdec.c b/libavformat/lxfdec.c index 19f7f27..11d6da5 100644 --- a/libavformat/lxfdec.c +++ b/libavformat/lxfdec.c @@ -92,7 +92,7 @@ static int sync(AVFormatContext *s, uint8_t *header) return ret < 0 ? ret : AVERROR_EOF; while (memcmp(buf, LXF_IDENT, LXF_IDENT_LENGTH)) { - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR_EOF; memmove(buf, &buf[1], LXF_IDENT_LENGTH-1); diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 50b75e7..dbec9ee 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -654,7 +654,7 @@ static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos) id = avio_rb32(pb); // try to find a toplevel element - while (!url_feof(pb)) { + while (!avio_feof(pb)) { if (id == MATROSKA_ID_INFO || id == MATROSKA_ID_TRACKS || id == MATROSKA_ID_CUES || id == MATROSKA_ID_TAGS || id == MATROSKA_ID_SEEKHEAD || id == MATROSKA_ID_ATTACHMENTS || @@ -707,7 +707,7 @@ static int ebml_read_num(MatroskaDemuxContext *matroska, AVIOContext *pb, * use it safely here to catch EOS. */ if (!(total = avio_r8(pb))) { /* we might encounter EOS here */ - if (!url_feof(pb)) { + if (!avio_feof(pb)) { int64_t pos = avio_tell(pb); av_log(matroska->ctx, AV_LOG_ERROR, "Read error at pos. %"PRIu64" (0x%"PRIx64")\n", diff --git a/libavformat/mgsts.c b/libavformat/mgsts.c index dec6bfc..8cbc952 100644 --- a/libavformat/mgsts.c +++ b/libavformat/mgsts.c @@ -74,7 +74,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) uint32_t chunk_size, payload_size; int ret; - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; avio_skip(pb, 4); diff --git a/libavformat/microdvddec.c b/libavformat/microdvddec.c index 49d2b68..ce3433c 100644 --- a/libavformat/microdvddec.c +++ b/libavformat/microdvddec.c @@ -88,7 +88,7 @@ static int microdvd_read_header(AVFormatContext *s) if (!st) return AVERROR(ENOMEM); - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { char *p; AVPacket *sub; int64_t pos = avio_tell(s->pb); diff --git a/libavformat/mlvdec.c b/libavformat/mlvdec.c index a980ed6..0ed1bfa 100644 --- a/libavformat/mlvdec.c +++ b/libavformat/mlvdec.c @@ -126,7 +126,7 @@ static int scan_file(AVFormatContext *avctx, AVStream *vst, AVStream *ast, int f MlvContext *mlv = avctx->priv_data; AVIOContext *pb = mlv->pb[file]; int ret; - while (!url_feof(pb)) { + while (!avio_feof(pb)) { int type; unsigned int size; type = avio_rl32(pb); diff --git a/libavformat/mmf.c b/libavformat/mmf.c index a023dd6..f557eeb 100644 --- a/libavformat/mmf.c +++ b/libavformat/mmf.c @@ -286,7 +286,7 @@ static int mmf_read_packet(AVFormatContext *s, AVPacket *pkt) left = mmf->data_end - avio_tell(s->pb); size = FFMIN(left, MAX_SIZE); - if (url_feof(s->pb) || size <= 0) + if (avio_feof(s->pb) || size <= 0) return AVERROR_EOF; ret = av_get_packet(s->pb, pkt, size); diff --git a/libavformat/mov.c b/libavformat/mov.c index 57977f3..05ca7c5 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -485,7 +485,7 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom) avio_skip(pb, 16); for (type = 0; type != -1 && avio_tell(pb) < next; ) { - if(url_feof(pb)) + if(avio_feof(pb)) return AVERROR_EOF; type = avio_rb16(pb); len = avio_rb16(pb); @@ -3153,7 +3153,7 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (atom.size < 0) atom.size = INT64_MAX; - while (total_size + 8 <= atom.size && !url_feof(pb)) { + while (total_size + 8 <= atom.size && !avio_feof(pb)) { int (*parse)(MOVContext*, AVIOContext*, MOVAtom) = NULL; a.size = atom.size; a.type=0; @@ -3701,7 +3701,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) avio_seek(s->pb, mov->next_root_atom, SEEK_SET); mov->next_root_atom = 0; if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || - url_feof(s->pb)) + avio_feof(s->pb)) return AVERROR_EOF; av_dlog(s, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb)); goto retry; diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c index b32bc9c..a15dc25 100644 --- a/libavformat/mpc8.c +++ b/libavformat/mpc8.c @@ -220,7 +220,7 @@ static int mpc8_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; } - while(!url_feof(pb)){ + while(!avio_feof(pb)){ pos = avio_tell(pb); mpc8_get_chunk_header(pb, &tag, &size); if(tag == TAG_STREAMHDR) @@ -275,7 +275,7 @@ static int mpc8_read_packet(AVFormatContext *s, AVPacket *pkt) int tag; int64_t pos, size; - while(!url_feof(s->pb)){ + while(!avio_feof(s->pb)){ pos = avio_tell(s->pb); /* don't return bogus packets with the ape tag data */ diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index c53bab3..056db2e 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -168,7 +168,7 @@ static int find_next_start_code(AVIOContext *pb, int *size_ptr, state = *header_state; n = *size_ptr; while (n > 0) { - if (url_feof(pb)) + if (avio_feof(pb)) break; v = avio_r8(pb); n--; @@ -246,7 +246,7 @@ redo: startcode = find_next_start_code(s->pb, &size, &m->header_state); last_sync = avio_tell(s->pb); if (startcode < 0) { - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR_EOF; // FIXME we should remember header_state return AVERROR(EAGAIN); @@ -702,7 +702,7 @@ static int vobsub_read_header(AVFormatContext *s) } av_bprint_init(&header, 0, AV_BPRINT_SIZE_UNLIMITED); - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { char line[MAX_LINE_SIZE]; int len = ff_get_line(s->pb, line, sizeof(line)); diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 2b18695..a2456a3 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2192,7 +2192,7 @@ static int mpegts_resync(AVFormatContext *s) for (i = 0; i < MAX_RESYNC_SIZE; i++) { c = avio_r8(pb); - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; if (c == 0x47) { avio_seek(pb, -1, SEEK_CUR); diff --git a/libavformat/mpl2dec.c b/libavformat/mpl2dec.c index 17b302d..260b7be 100644 --- a/libavformat/mpl2dec.c +++ b/libavformat/mpl2dec.c @@ -83,7 +83,7 @@ static int mpl2_read_header(AVFormatContext *s) st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codec->codec_id = AV_CODEC_ID_MPL2; - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { char line[4096]; char *p = line; const int64_t pos = avio_tell(s->pb); diff --git a/libavformat/mpsubdec.c b/libavformat/mpsubdec.c index c5bdcdb..eddc594 100644 --- a/libavformat/mpsubdec.c +++ b/libavformat/mpsubdec.c @@ -63,7 +63,7 @@ static int mpsub_read_header(AVFormatContext *s) av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED); - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { char line[1024]; float start, duration; int fps, len = ff_get_line(s->pb, line, sizeof(line)); diff --git a/libavformat/msnwc_tcp.c b/libavformat/msnwc_tcp.c index 0ac1c30..60225af 100644 --- a/libavformat/msnwc_tcp.c +++ b/libavformat/msnwc_tcp.c @@ -89,9 +89,9 @@ static int msnwc_tcp_read_header(AVFormatContext *ctx) /* Some files start with "connected\r\n\r\n". * So skip until we find the first byte of struct size */ - while(avio_r8(pb) != HEADER_SIZE && !url_feof(pb)); + while(avio_r8(pb) != HEADER_SIZE && !avio_feof(pb)); - if(url_feof(pb)) { + if(avio_feof(pb)) { av_log(ctx, AV_LOG_ERROR, "Could not find valid start.\n"); return -1; } diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 467d184..2fc1ce0 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -284,7 +284,7 @@ static int64_t klv_decode_ber_length(AVIOContext *pb) static int mxf_read_sync(AVIOContext *pb, const uint8_t *key, unsigned size) { int i, b; - for (i = 0; i < size && !url_feof(pb); i++) { + for (i = 0; i < size && !avio_feof(pb); i++) { b = avio_r8(pb); if (b == key[0]) i = 0; @@ -1874,7 +1874,7 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadF if (!ctx) return AVERROR(ENOMEM); - while (avio_tell(pb) + 4 < klv_end && !url_feof(pb)) { + while (avio_tell(pb) + 4 < klv_end && !avio_feof(pb)) { int ret; int tag = avio_rb16(pb); int size = avio_rb16(pb); /* KLV specified by 0x53 */ @@ -2122,7 +2122,7 @@ static int mxf_read_header(AVFormatContext *s) mxf_read_random_index_pack(s); - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { const MXFMetadataReadTableEntry *metadata; if (avio_tell(s->pb) == last_pos) { av_log(mxf->fc, AV_LOG_ERROR, "MXF structure loop detected\n"); @@ -2450,7 +2450,7 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt) skip: avio_skip(s->pb, klv.length); } - return url_feof(s->pb) ? AVERROR_EOF : ret; + return avio_feof(s->pb) ? AVERROR_EOF : ret; } static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt) diff --git a/libavformat/mxg.c b/libavformat/mxg.c index b2b5b86..34977b8 100644 --- a/libavformat/mxg.c +++ b/libavformat/mxg.c @@ -136,7 +136,7 @@ static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt) uint8_t *startmarker_ptr, *end, *search_end, marker; MXGContext *mxg = s->priv_data; - while (!url_feof(s->pb) && !s->pb->error){ + while (!avio_feof(s->pb) && !s->pb->error){ if (mxg->cache_size <= OVERREAD_SIZE) { /* update internal buffer */ ret = mxg_update_cache(s, DEFAULT_PACKET_SIZE + OVERREAD_SIZE); diff --git a/libavformat/ncdec.c b/libavformat/ncdec.c index 8cb7ed4..062899f 100644 --- a/libavformat/ncdec.c +++ b/libavformat/ncdec.c @@ -67,7 +67,7 @@ static int nc_read_packet(AVFormatContext *s, AVPacket *pkt) uint32_t state=-1; while (state != NC_VIDEO_FLAG) { - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR(EIO); state = (state<<8) + avio_r8(s->pb); } diff --git a/libavformat/nistspheredec.c b/libavformat/nistspheredec.c index 2c96686..2f17f9e 100644 --- a/libavformat/nistspheredec.c +++ b/libavformat/nistspheredec.c @@ -51,7 +51,7 @@ static int nist_read_header(AVFormatContext *s) if (header_size <= 0) return AVERROR_INVALIDDATA; - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { ff_get_line(s->pb, buffer, sizeof(buffer)); if (avio_tell(s->pb) >= header_size) diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index e1fcfee..926e88e 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -232,7 +232,7 @@ static int nsv_resync(AVFormatContext *s) //nsv->state = NSV_UNSYNC; for (i = 0; i < NSV_MAX_RESYNC; i++) { - if (url_feof(pb)) { + if (avio_feof(pb)) { av_dlog(s, "NSV EOF\n"); nsv->state = NSV_UNSYNC; return -1; @@ -299,7 +299,7 @@ static int nsv_parse_NSVf_header(AVFormatContext *s) table_entries_used = avio_rl32(pb); av_dlog(s, "NSV NSVf info-strings size: %d, table entries: %d, bis %d\n", strings_size, table_entries, table_entries_used); - if (url_feof(pb)) + if (avio_feof(pb)) return -1; av_dlog(s, "NSV got header; filepos %"PRId64"\n", avio_tell(pb)); @@ -336,7 +336,7 @@ static int nsv_parse_NSVf_header(AVFormatContext *s) } av_free(strings); } - if (url_feof(pb)) + if (avio_feof(pb)) return -1; av_dlog(s, "NSV got infos; filepos %"PRId64"\n", avio_tell(pb)); @@ -368,7 +368,7 @@ static int nsv_parse_NSVf_header(AVFormatContext *s) avio_seek(pb, nsv->base_offset + size, SEEK_SET); /* required for dumbdriving-271.nsv (2 extra bytes) */ - if (url_feof(pb)) + if (avio_feof(pb)) return -1; nsv->state = NSV_HAS_READ_NSVF; return 0; @@ -546,7 +546,7 @@ static int nsv_read_chunk(AVFormatContext *s, int fill_header) return 0; //-1; /* hey! eat what you've in your plate first! */ null_chunk_retry: - if (url_feof(pb)) + if (avio_feof(pb)) return -1; for (i = 0; i < NSV_MAX_RESYNC_TRIES && nsv->state < NSV_FOUND_NSVS && !err; i++) @@ -581,7 +581,7 @@ null_chunk_retry: vsize -= auxsize + sizeof(uint16_t) + sizeof(uint32_t); /* that's becoming braindead */ } - if (url_feof(pb)) + if (avio_feof(pb)) return -1; if (!vsize && !asize) { nsv->state = NSV_UNSYNC; diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 8a4fe4c..c4ab409 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -146,7 +146,7 @@ static uint64_t find_any_startcode(AVIOContext *bc, int64_t pos) /* Note, this may fail if the stream is not seekable, but that should * not matter, as in this case we simply start where we currently are */ avio_seek(bc, pos, SEEK_SET); - while (!url_feof(bc)) { + while (!avio_feof(bc)) { state = (state << 8) | avio_r8(bc); if ((state >> 56) != 'N') continue; @@ -1056,7 +1056,7 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt) pos -= 8; } else { frame_code = avio_r8(bc); - if (url_feof(bc)) + if (avio_feof(bc)) return AVERROR_EOF; if (frame_code == 'N') { tmp = frame_code; diff --git a/libavformat/nuv.c b/libavformat/nuv.c index 2c02de1..e7f0eea 100644 --- a/libavformat/nuv.c +++ b/libavformat/nuv.c @@ -72,7 +72,7 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst, if (!vst && !myth) return 1; // no codec data needed - while (!url_feof(pb)) { + while (!avio_feof(pb)) { int size, subtype; frametype = avio_r8(pb); @@ -236,7 +236,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) nuv_frametype frametype; int ret, size; - while (!url_feof(pb)) { + while (!avio_feof(pb)) { int copyhdrsize = ctx->rtjpg_video ? HDRSIZE : 0; uint64_t pos = avio_tell(pb); @@ -309,7 +309,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) static int nuv_resync(AVFormatContext *s, int64_t pos_limit) { AVIOContext *pb = s->pb; uint32_t tag = 0; - while(!url_feof(pb) && avio_tell(pb) < pos_limit) { + while(!avio_feof(pb) && avio_tell(pb) < pos_limit) { tag = (tag << 8) | avio_r8(pb); if (tag == MKBETAG('R','T','j','j') && (tag = avio_rb32(pb)) == MKBETAG('j','j','j','j') && @@ -339,7 +339,7 @@ static int64_t nuv_read_dts(AVFormatContext *s, int stream_index, if (!nuv_resync(s, pos_limit)) return AV_NOPTS_VALUE; - while (!url_feof(pb) && avio_tell(pb) < pos_limit) { + while (!avio_feof(pb) && avio_tell(pb) < pos_limit) { if (avio_read(pb, hdr, HDRSIZE) < HDRSIZE) return AV_NOPTS_VALUE; frametype = hdr[0]; diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index f7d00c1..dcead1c 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -331,7 +331,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid) c = avio_r8(bc); - if (url_feof(bc)) + if (avio_feof(bc)) return AVERROR_EOF; sync[sp++ & 3] = c; diff --git a/libavformat/paf.c b/libavformat/paf.c index 88a274f..618994c 100644 --- a/libavformat/paf.c +++ b/libavformat/paf.c @@ -199,7 +199,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) if (p->current_frame >= p->nb_frames) return AVERROR_EOF; - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; if (p->got_audio) { diff --git a/libavformat/pjsdec.c b/libavformat/pjsdec.c index 6f5db37..5129b70 100644 --- a/libavformat/pjsdec.c +++ b/libavformat/pjsdec.c @@ -73,7 +73,7 @@ static int pjs_read_header(AVFormatContext *s) st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codec->codec_id = AV_CODEC_ID_PJS; - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { char line[4096]; char *p = line; const int64_t pos = avio_tell(s->pb); diff --git a/libavformat/pmpdec.c b/libavformat/pmpdec.c index d032837..ec966b3 100644 --- a/libavformat/pmpdec.c +++ b/libavformat/pmpdec.c @@ -97,7 +97,7 @@ static int pmp_header(AVFormatContext *s) for (i = 0; i < index_cnt; i++) { uint32_t size = avio_rl32(pb); int flags = size & 1 ? AVINDEX_KEYFRAME : 0; - if (url_feof(pb)) { + if (avio_feof(pb)) { av_log(s, AV_LOG_FATAL, "Encountered EOF while reading index.\n"); return AVERROR_INVALIDDATA; } @@ -133,7 +133,7 @@ static int pmp_packet(AVFormatContext *s, AVPacket *pkt) int ret = 0; int i; - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; if (pmp->cur_stream == 0) { int num_packets; diff --git a/libavformat/psxstr.c b/libavformat/psxstr.c index 5efcadf..dc49170 100644 --- a/libavformat/psxstr.c +++ b/libavformat/psxstr.c @@ -292,7 +292,7 @@ FF_ENABLE_DEPRECATION_WARNINGS break; } - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR(EIO); } } diff --git a/libavformat/qcp.c b/libavformat/qcp.c index 1ef86fe..4d42197 100644 --- a/libavformat/qcp.c +++ b/libavformat/qcp.c @@ -139,7 +139,7 @@ static int qcp_read_packet(AVFormatContext *s, AVPacket *pkt) QCPContext *c = s->priv_data; unsigned int chunk_size, tag; - while(!url_feof(pb)) { + while(!avio_feof(pb)) { if (c->data_size) { int pkt_size, ret, mode = avio_r8(pb); diff --git a/libavformat/realtextdec.c b/libavformat/realtextdec.c index 5e4981a..e1225d5 100644 --- a/libavformat/realtextdec.c +++ b/libavformat/realtextdec.c @@ -72,7 +72,7 @@ static int realtext_read_header(AVFormatContext *s) av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED); - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { AVPacket *sub; const int64_t pos = avio_tell(s->pb) - (c != 0); int n = ff_smil_extract_next_chunk(s->pb, &buf, &c); diff --git a/libavformat/redspark.c b/libavformat/redspark.c index 6d4c8c5..13a7b37 100644 --- a/libavformat/redspark.c +++ b/libavformat/redspark.c @@ -143,7 +143,7 @@ static int redspark_read_packet(AVFormatContext *s, AVPacket *pkt) uint32_t size = 8 * codec->channels; int ret; - if (url_feof(s->pb) || redspark->samples_count == s->streams[0]->duration) + if (avio_feof(s->pb) || redspark->samples_count == s->streams[0]->duration) return AVERROR_EOF; ret = av_get_packet(s->pb, pkt, size); diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c index 48c9a94..09fee9d 100644 --- a/libavformat/riffdec.c +++ b/libavformat/riffdec.c @@ -191,7 +191,7 @@ int ff_read_riff_info(AVFormatContext *s, int64_t size) chunk_code = avio_rl32(pb); chunk_size = avio_rl32(pb); - if (url_feof(pb)) { + if (avio_feof(pb)) { if (chunk_code || chunk_size) { av_log(s, AV_LOG_WARNING, "INFO subchunk truncated\n"); return AVERROR_INVALIDDATA; diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 36764ee..f53ab8c 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -494,7 +494,7 @@ static int rm_read_header(AVFormatContext *s) avio_skip(pb, tag_size - 8); for(;;) { - if (url_feof(pb)) + if (avio_feof(pb)) return -1; tag = avio_rl32(pb); tag_size = avio_rb32(pb); @@ -601,7 +601,7 @@ static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_ AVStream *st; uint32_t state=0xFFFFFFFF; - while(!url_feof(pb)){ + while(!avio_feof(pb)){ int len, num, i; *pos= avio_tell(pb) - 3; if(rm->remaining_len > 0){ @@ -953,7 +953,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) st = s->streams[i]; } - if(len<0 || url_feof(s->pb)) + if(len<0 || avio_feof(s->pb)) return AVERROR(EIO); res = ff_rm_parse_packet (s, s->pb, st, st->priv_data, len, pkt, diff --git a/libavformat/rpl.c b/libavformat/rpl.c index 46a5796..c1229e8 100644 --- a/libavformat/rpl.c +++ b/libavformat/rpl.c @@ -60,7 +60,7 @@ static int read_line(AVIOContext * pb, char* line, int bufsize) break; if (b == '\n') { line[i] = '\0'; - return url_feof(pb) ? -1 : 0; + return avio_feof(pb) ? -1 : 0; } line[i] = b; } diff --git a/libavformat/rsd.c b/libavformat/rsd.c index b6f1686..bb2f3bc 100644 --- a/libavformat/rsd.c +++ b/libavformat/rsd.c @@ -137,7 +137,7 @@ static int rsd_read_packet(AVFormatContext *s, AVPacket *pkt) AVCodecContext *codec = s->streams[0]->codec; int ret, size = 1024; - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR_EOF; if (codec->codec_id == AV_CODEC_ID_ADPCM_IMA_RAD) diff --git a/libavformat/samidec.c b/libavformat/samidec.c index 2eaee6f..1a12eca 100644 --- a/libavformat/samidec.c +++ b/libavformat/samidec.c @@ -62,7 +62,7 @@ static int sami_read_header(AVFormatContext *s) av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED); av_bprint_init(&hdr_buf, 0, AV_BPRINT_SIZE_UNLIMITED); - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { AVPacket *sub; const int64_t pos = avio_tell(s->pb) - (c != 0); int is_sync, n = ff_smil_extract_next_chunk(s->pb, &buf, &c); diff --git a/libavformat/smacker.c b/libavformat/smacker.c index 46215ee..284cdc1 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -257,7 +257,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) int frame_size = 0; int palchange = 0; - if (url_feof(s->pb) || smk->cur_frame >= smk->frames) + if (avio_feof(s->pb) || smk->cur_frame >= smk->frames) return AVERROR_EOF; /* if we demuxed all streams, pass another frame */ diff --git a/libavformat/smjpegdec.c b/libavformat/smjpegdec.c index e4c7a9b..99ca2ff 100644 --- a/libavformat/smjpegdec.c +++ b/libavformat/smjpegdec.c @@ -58,7 +58,7 @@ static int smjpeg_read_header(AVFormatContext *s) duration = avio_rb32(pb); // in msec - while (!url_feof(pb)) { + while (!avio_feof(pb)) { htype = avio_rl32(pb); switch (htype) { case SMJPEG_TXT: @@ -141,7 +141,7 @@ static int smjpeg_read_packet(AVFormatContext *s, AVPacket *pkt) int64_t pos; int ret; - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR_EOF; pos = avio_tell(s->pb); dtype = avio_rl32(s->pb); diff --git a/libavformat/smush.c b/libavformat/smush.c index a33d509..abb6989 100644 --- a/libavformat/smush.c +++ b/libavformat/smush.c @@ -102,7 +102,7 @@ static int smush_read_header(AVFormatContext *ctx) while (!got_audio && ((read + 8) < size)) { uint32_t sig, chunk_size; - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; sig = avio_rb32(pb); @@ -196,7 +196,7 @@ static int smush_read_packet(AVFormatContext *ctx, AVPacket *pkt) while (!done) { uint32_t sig, size; - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; sig = avio_rb32(pb); diff --git a/libavformat/sol.c b/libavformat/sol.c index 77c754a..27d3551 100644 --- a/libavformat/sol.c +++ b/libavformat/sol.c @@ -131,7 +131,7 @@ static int sol_read_packet(AVFormatContext *s, { int ret; - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR(EIO); ret= av_get_packet(s->pb, pkt, MAX_SIZE); if (ret < 0) diff --git a/libavformat/spdifdec.c b/libavformat/spdifdec.c index 7da16c9..7c04afa 100644 --- a/libavformat/spdifdec.c +++ b/libavformat/spdifdec.c @@ -176,7 +176,7 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt) while (state != (AV_BSWAP16C(SYNCWORD1) << 16 | AV_BSWAP16C(SYNCWORD2))) { state = (state << 8) | avio_r8(pb); - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; } diff --git a/libavformat/srtdec.c b/libavformat/srtdec.c index 7f911bd..53182cd 100644 --- a/libavformat/srtdec.c +++ b/libavformat/srtdec.c @@ -88,7 +88,7 @@ static int srt_read_header(AVFormatContext *s) av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED); - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { ff_subtitles_read_chunk(s->pb, &buf); if (buf.len) { diff --git a/libavformat/subviewer1dec.c b/libavformat/subviewer1dec.c index 1b831b7..6b38533 100644 --- a/libavformat/subviewer1dec.c +++ b/libavformat/subviewer1dec.c @@ -53,7 +53,7 @@ static int subviewer1_read_header(AVFormatContext *s) st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codec->codec_id = AV_CODEC_ID_SUBVIEWER1; - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { char line[4096]; int len = ff_get_line(s->pb, line, sizeof(line)); int hh, mm, ss; diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c index 9e645d2..f1b0fdf 100644 --- a/libavformat/subviewerdec.c +++ b/libavformat/subviewerdec.c @@ -84,7 +84,7 @@ static int subviewer_read_header(AVFormatContext *s) av_bprint_init(&header, 0, AV_BPRINT_SIZE_UNLIMITED); - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { char line[2048]; int64_t pos = 0; int len = ff_get_line(s->pb, line, sizeof(line)); diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c index c95b18e..0f78b17 100644 --- a/libavformat/swfdec.c +++ b/libavformat/swfdec.c @@ -39,7 +39,7 @@ static int get_swf_tag(AVIOContext *pb, int *len_ptr) { int tag, len; - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; tag = avio_rl16(pb); diff --git a/libavformat/takdec.c b/libavformat/takdec.c index 4888a77..3eb1a8e 100644 --- a/libavformat/takdec.c +++ b/libavformat/takdec.c @@ -68,7 +68,7 @@ static int tak_read_header(AVFormatContext *s) return 0; } - while (!url_feof(pb)) { + while (!avio_feof(pb)) { enum TAKMetaDataType type; int size; diff --git a/libavformat/tmv.c b/libavformat/tmv.c index 8be4dbf..ad172f4 100644 --- a/libavformat/tmv.c +++ b/libavformat/tmv.c @@ -154,7 +154,7 @@ static int tmv_read_packet(AVFormatContext *s, AVPacket *pkt) int ret, pkt_size = tmv->stream_index ? tmv->audio_chunk_size : tmv->video_chunk_size; - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; ret = av_get_packet(pb, pkt, pkt_size); diff --git a/libavformat/tty.c b/libavformat/tty.c index 3afb9b2..909b550 100644 --- a/libavformat/tty.c +++ b/libavformat/tty.c @@ -113,7 +113,7 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt) TtyDemuxContext *s = avctx->priv_data; int n; - if (url_feof(avctx->pb)) + if (avio_feof(avctx->pb)) return AVERROR_EOF; n = s->chars_per_frame; diff --git a/libavformat/txd.c b/libavformat/txd.c index 400f2cc..cac37d5 100644 --- a/libavformat/txd.c +++ b/libavformat/txd.c @@ -63,7 +63,7 @@ next_chunk: chunk_size = avio_rl32(pb); marker = avio_rl32(pb); - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR_EOF; if (marker != TXD_MARKER && marker != TXD_MARKER2) { av_log(s, AV_LOG_ERROR, "marker does not match\n"); diff --git a/libavformat/vc1test.c b/libavformat/vc1test.c index e924666..3afe398 100644 --- a/libavformat/vc1test.c +++ b/libavformat/vc1test.c @@ -91,7 +91,7 @@ static int vc1t_read_packet(AVFormatContext *s, int keyframe = 0; uint32_t pts; - if(url_feof(pb)) + if(avio_feof(pb)) return AVERROR(EIO); frame_size = avio_rl24(pb); diff --git a/libavformat/vivo.c b/libavformat/vivo.c index e0a1814..7287379 100644 --- a/libavformat/vivo.c +++ b/libavformat/vivo.c @@ -75,7 +75,7 @@ static int vivo_get_packet_header(AVFormatContext *s) AVIOContext *pb = s->pb; unsigned c, get_length = 0; - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; c = avio_r8(pb); @@ -250,7 +250,7 @@ static int vivo_read_packet(AVFormatContext *s, AVPacket *pkt) restart: - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; switch (vivo->type) { @@ -281,7 +281,7 @@ restart: while (vivo->sequence == old_sequence && (((vivo->type - 1) >> 1) == ((old_type - 1) >> 1))) { - if (url_feof(pb)) { + if (avio_feof(pb)) { ret = AVERROR_EOF; break; } diff --git a/libavformat/vplayerdec.c b/libavformat/vplayerdec.c index 73a48db..619ccfd 100644 --- a/libavformat/vplayerdec.c +++ b/libavformat/vplayerdec.c @@ -65,7 +65,7 @@ static int vplayer_read_header(AVFormatContext *s) st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codec->codec_id = AV_CODEC_ID_VPLAYER; - while (!url_feof(s->pb)) { + while (!avio_feof(s->pb)) { char line[4096]; char *p = line; const int64_t pos = avio_tell(s->pb); diff --git a/libavformat/vqf.c b/libavformat/vqf.c index 74c7f5f..d1ea0b4 100644 --- a/libavformat/vqf.c +++ b/libavformat/vqf.c @@ -166,7 +166,7 @@ static int vqf_read_header(AVFormatContext *s) header_size -= len; - } while (header_size >= 0 && !url_feof(s->pb)); + } while (header_size >= 0 && !avio_feof(s->pb)); switch (rate_flag) { case -1: diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index 1d77402..7e0d5f4 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -82,7 +82,7 @@ static int64_t find_tag(WAVDemuxContext * wav, AVIOContext *pb, uint32_t tag1) int64_t size; for (;;) { - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; size = next_tag(pb, &tag); if (tag == tag1) @@ -291,7 +291,7 @@ static int wav_read_header(AVFormatContext *s) size = next_tag(pb, &tag); next_tag_ofs = avio_tell(pb) + size; - if (url_feof(pb)) + if (avio_feof(pb)) break; switch (tag) { @@ -434,7 +434,7 @@ static int64_t find_guid(AVIOContext *pb, const uint8_t guid1[16]) uint8_t guid[16]; int64_t size; - while (!url_feof(pb)) { + while (!avio_feof(pb)) { avio_read(pb, guid, 16); size = avio_rl64(pb); if (size <= 24) @@ -652,7 +652,7 @@ static int w64_read_header(AVFormatContext *s) if (!st) return AVERROR(ENOMEM); - while (!url_feof(pb)) { + while (!avio_feof(pb)) { if (avio_read(pb, guid, 16) != 16) break; size = avio_rl64(pb); @@ -692,7 +692,7 @@ static int w64_read_header(AVFormatContext *s) for (i = 0; i < count; i++) { char chunk_key[5], *value; - if (url_feof(pb) || (cur = avio_tell(pb)) < 0 || cur > end - 8 /* = tag + size */) + if (avio_feof(pb) || (cur = avio_tell(pb)) < 0 || cur > end - 8 /* = tag + size */) break; chunk_key[4] = 0; diff --git a/libavformat/wc3movie.c b/libavformat/wc3movie.c index 408c050..a60f128 100644 --- a/libavformat/wc3movie.c +++ b/libavformat/wc3movie.c @@ -159,7 +159,7 @@ static int wc3_read_header(AVFormatContext *s) fourcc_tag = avio_rl32(pb); /* chunk sizes are 16-bit aligned */ size = (avio_rb32(pb) + 1) & (~1); - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR(EIO); } while (fourcc_tag != BRCH_TAG); @@ -211,7 +211,7 @@ static int wc3_read_packet(AVFormatContext *s, fourcc_tag = avio_rl32(pb); /* chunk sizes are 16-bit aligned */ size = (avio_rb32(pb) + 1) & (~1); - if (url_feof(pb)) + if (avio_feof(pb)) return AVERROR(EIO); switch (fourcc_tag) { diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index cfdc555..c70057c 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -76,7 +76,7 @@ static int wtvfile_read_packet(void *opaque, uint8_t *buf, int buf_size) if (wf->error || pb->error) return -1; - if (wf->position >= wf->length || url_feof(pb)) + if (wf->position >= wf->length || avio_feof(pb)) return 0; buf_size = FFMIN(buf_size, wf->length - wf->position); @@ -533,7 +533,7 @@ static void parse_legacy_attrib(AVFormatContext *s, AVIOContext *pb) { ff_asf_guid guid; int length, type; - while(!url_feof(pb)) { + while(!avio_feof(pb)) { char key[1024]; ff_get_guid(pb, &guid); type = avio_rl32(pb); @@ -761,7 +761,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p { WtvContext *wtv = s->priv_data; AVIOContext *pb = wtv->pb; - while (!url_feof(pb)) { + while (!avio_feof(pb)) { ff_asf_guid g; int len, sid, consumed; @@ -981,7 +981,7 @@ static int read_header(AVFormatContext *s) while(1) { uint64_t timestamp = avio_rl64(pb); uint64_t frame_nb = avio_rl64(pb); - if (url_feof(pb)) + if (avio_feof(pb)) break; ff_add_index_entry(&wtv->index_entries, &wtv->nb_index_entries, &wtv->index_entries_allocated_size, 0, timestamp, frame_nb, 0, AVINDEX_KEYFRAME); @@ -995,7 +995,7 @@ static int read_header(AVFormatContext *s) while (1) { uint64_t frame_nb = avio_rl64(pb); uint64_t position = avio_rl64(pb); - if (url_feof(pb)) + if (avio_feof(pb)) break; for (i = wtv->nb_index_entries - 1; i >= 0; i--) { AVIndexEntry *e = wtv->index_entries + i; diff --git a/libavformat/wvdec.c b/libavformat/wvdec.c index 4eaec40..5a8d9c7 100644 --- a/libavformat/wvdec.c +++ b/libavformat/wvdec.c @@ -260,7 +260,7 @@ static int wv_read_packet(AVFormatContext *s, AVPacket *pkt) int64_t pos; uint32_t block_samples; - if (url_feof(s->pb)) + if (avio_feof(s->pb)) return AVERROR_EOF; if (wc->block_parsed) { if ((ret = wv_read_block_header(s, s->pb)) < 0) -- 1.8.5.5 From Reimar.Doeffinger at gmx.de Thu Aug 7 22:12:49 2014 From: Reimar.Doeffinger at gmx.de (Reimar =?iso-8859-1?Q?D=F6ffinger?=) Date: Thu, 7 Aug 2014 22:12:49 +0200 Subject: [FFmpeg-devel] [PATCH 02/14] libavcodec: Implementation of AAC_fixed_decoder (LC-module) [2/5] In-Reply-To: References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> <1406901200-4862-3-git-send-email-nedeljko.babic@imgtec.com> <20140801190850.GA4224@reimardoeffinger.de> Message-ID: <20140807201249.GC6490@reimardoeffinger.de> On Thu, Aug 07, 2014 at 09:51:36AM +0000, Nedeljko Babic wrote: > >> + Q30(0.9999999995), Q30(0.9922480620), Q30(0.9846153846), Q30(0.9770992366), > > > >I'm a bit unsure btw. if this makes more sense than coding the converted > >numbers. > >It feels like it combines the disadvantages, since it neither avoids > >code duplication with the float tables nor does it compiler/architecture > >dependence completely (I think). > > > > I am not sure what disadvantages are combined (there is no code duplication for example), I assumed the same tables might already exist somewhere, but I might just misunderstand. > but since only advantage is in that it can be seen what fixed point representation is used, > the values will be hard coded in hex format. To be honest, I flagged this more as a point of discussion. In some ways, this variant is more "readable/verifiable", but on the other hand bit-exact decoding between compilers/platforms would be even nicer. Yet again, it might be a purely theoretical issue. > >> + aac_float_t ret; > >> + int nz; > >> + > >> + if (x == 0) > >> + { > >> + ret.mant = 0; > >> + ret.expo = 0; > >> + } > >> + else > >> + { > >> + ret.expo = exp; > >> + ret.mant = x; > >> + nz = 29 - av_log2_c_emu(FFABS(ret.mant)); > >> + ret.mant <<= nz; > >> + ret.expo -= nz; > > > >nz is only used here, so it should be declared here. > >Also > >int nz = 29 - av_log2_c_emu(FFABS(x)); > > Since ISO C90 forbids mixing declarations and code, warnings will be generated if nz is declared here. > On the other hand, it can (and will) be declared at the start of the else block. Yes, I meant at the start of the else block by "here", though with my proposed change that will also be the first use :) > >> + if (manta == 0) > >> + return b; > >> + > >> + if (mantb == 0) > >> + return a; > >> + > >> + diff = expa - expb; > >> + if (diff < 0) // expa < expb > >> + { > >> + diff = -diff; > >> + if (diff >= 31) > >> + manta = 0; > >> + else if (diff != 0) > >> + manta >>= diff; > >> + expa = expb; > >> + } > >> + else // expa >= expb > >> + { > >> + if (diff >= 31) > >> + mantb = 0; > >> + else if (diff != 0) > >> + mantb >>= diff; > >> + } > >> + > >> + manta = manta + mantb; > >> + if (manta == 0) > >> + expa = 0; > >> + else > >> + { > >> + nz = 30 - av_log2_c_emu(FFABS(manta)); > >> + manta <<= nz; > >> + manta >>= 1; > >> + expa -= (nz-1); > >> + } > > > >I think this needs a good thinking over. > >If diff was calculated first, the >= 31/ <= -31 checks > >could be combined with the checks for 0. > > diff is calculated right after checking if mantissas are zero. > Mantissas are checked first because if they are zero, > it is a waste of time to do other calculations. > > On the other hand, I am not sure what would be gain in combining > >= 31/ <= -31 checks with the checks for 0 (for diff). As far as I can tell, if the difference is <= 31 we will always return either a or b, i.e. whether one is at least 31 exponents smaller or it is 0 is the same thing. Assuming I understood the code right, I guess you can also just replace > >> + if (diff >= 31) > >> + manta = 0; by > >> + if (diff >= 31) > >> + return b; Though the question is whether it's more important performance wise to optimize the case where one operand is 0 or to reduce the number of branches. Or it might not matter at all. But I admit I haven't looked at it closely enough to be 100% sure about any of this, thus the statement that I believe someone needs to think through this code once more, because I strongly suspect it's needlessly confusing and slow. > >also the != 0 check can certainly only make performance worse. > > I agree with this in if part, since it is not needed as you pointed out, > but this check is needed in the else part. If the statement is if (s != 0) a >>= s; how can the if _ever_ be _needed_ for correctness? a >>= 0 is a NOP, so no need to explicitly skip it for s == 0. > >For all functions, I think there should be a look at what rounding > >mode they end up using in the end and document that. > >This one looks like round to 0. > > > > This is rounding to 0. It can be changed to rounding to nearest without loss in precision. > > Do you suggest that we should make comment like: > /* Rounding to zero used */ > for every function? Well, if every function used round to zero that, it should be written once e.g. at the top of the file. However that does not seem to be the case. Ideally, I think there should be a statement that all functions unless otherwise stated use round to 0 for simplicity. In addition, for those using a different rounding this should be documented. > >> +static av_always_inline aac_float_t float_sub(aac_float_t a, aac_float_t b) > > > >Why would this need a whole separate implementation instead > >of changing the sign of b and calling add? > > > > Because there could be overhead because of function call if function is not inlined. > On the other hand I guess that gain is insignificant (or there is no gain if function > is inlined) and this will be done by calling add as you suggested. The functions are av_always_inline, so I think we may assume that they will be inlined and when they are not tell people to live with the performance or find a better compiler. Or possibly do the brute-force method of using a macro. > >> + mant = (int)((accu + 0x20000000) >> 30); > > > >This suddenly seems to use round-to-nearest-away as rounding mode/ > > > > Yes it is. I pointed it out because switching rounding mode without documenting the reason makes the code a bit hard to read, and even harder to optimize because nobody knows whether there is a specific reason why round to nearest is used or if it could just be removed for slightly better performance. > >> + if (mantb != 0) > >> + { > >> + iB = float_recip(b); > >> + // newton iteration to double precision > >> + tmp = float_sub(FLOAT_1, float_mul(b, iB)); > >> + iB = float_add(iB, float_mul(iB, tmp)); > >> + res = float_mul(a, iB); > >> + } > >> + else > >> + { > >> + res.mant = 1; > >> + res.expo = 2147483647; > > > >Hexadecimal would be nicer. > >Also, this seems to be the only function so far that handles > >infinity correctly. > >I have some doubts of the value of that, as long as it is the only one. > >If there's a particular reason why it only needs to be supported here, > >that should be documented. > > Only division by zero can create infinity, so it is addressed only here. Sure, only it can create infinity from non-infinity inputs. But what happens then? If you now use the result of a division with an add it won't quite work right in case it was an infinity as far as I can tell. At least not IEEE-style if it's (-1/0)+(1/0). So either you have to assume that a division will always be the last operation ever done or supporting infinity here is kind of pointless unless you support it anywhere as input at least. Maybe inf will actually work in a kind of reasonable (but not IEEE-compliant) way in the other functions, but it's not clear to me anyone tested that. > >> +static av_always_inline int float_gt(aac_float_t a, aac_float_t b) > >> +{ > >> + int expa = a.expo; > >> + int expb = b.expo; > >> + int manta = a.mant; > >> + int mantb = b.mant; > >> + > >> + if (manta == 0) > >> + expa = 0x80000000; > >> + > >> + if (mantb == 0) > >> + expb = 0x80000000; > >> + > >> + if (expa > expb) > >> + return 1; > >> + else if (expa < expb) > >> + return 0; > >> + else // expa == expb > >> + { > >> + if (manta > mantb) > >> + return 1; > >> + else > >> + return 0; > >> + } > > > >Does this actually work? > >The expa/expb assignment seems to invoke undefined behaviour by itself, > >but then it also seems to just not handle negative numbers, at least > >not if the exponent differs?!? > > Functions in this file are made for use in the implementation of AAC fixed point decoder. > This particular function is used only for calculating gain in aacsbr, so it doesn't need > to handle negative numbers. Ok, but then I still don't understand why the exp redirection. if (manta == 0) return 0; (if a is 0, then it can't be greater) if (mantb == 0) return 1; (if a is not 0, but b is 0, then a is greater) And the rest can also be simplified to e.g. just these 3 lines: if (expa > expb) return 1; if (expa < expb) return 0; return manta > mantb; From cehoyos at ag.or.at Thu Aug 7 22:39:05 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Thu, 7 Aug 2014 20:39:05 +0000 (UTC) Subject: [FFmpeg-devel] [PATCH]Make subtitle properties code in lavc more robust References: <201408071402.33313.cehoyos@ag.or.at> Message-ID: Marton Balint passwd.hu> writes: > So before applying this patch, I think we should decide > what these properties mean exactly... I have no opinion on this, just wanted to show why (imo) libzvbi cannot currently have other properties. Carl Eugen From michaelni at gmx.at Thu Aug 7 23:53:56 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Thu, 7 Aug 2014 23:53:56 +0200 Subject: [FFmpeg-devel] [PATCH v2] read reel_name metadata from tmcd atom In-Reply-To: <1407432036-95391-2-git-send-email-mindmark@gmail.com> References: <1407432036-95391-1-git-send-email-mindmark@gmail.com> <1407432036-95391-2-git-send-email-mindmark@gmail.com> Message-ID: <20140807215356.GY12391@nb4> On Thu, Aug 07, 2014 at 10:20:36AM -0700, Mark Reid wrote: > --- > libavformat/mov.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Fri Aug 8 01:53:13 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 8 Aug 2014 01:53:13 +0200 Subject: [FFmpeg-devel] [PATCH 1/2] lavf/avio: rename url_feof() to avio_feof() In-Reply-To: <1407442361-4104-1-git-send-email-jamrial@gmail.com> References: <1407442361-4104-1-git-send-email-jamrial@gmail.com> Message-ID: <20140807235313.GZ12391@nb4> On Thu, Aug 07, 2014 at 05:12:40PM -0300, James Almer wrote: > It's a public function and should use the avio_ namespace > > Signed-off-by: James Almer > --- > I'm scheduling the removal to lavf 57 since libav is about to force a bump. applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB There will always be a question for which you do not know the correct answer. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Fri Aug 8 01:53:39 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 8 Aug 2014 01:53:39 +0200 Subject: [FFmpeg-devel] [PATCH 2/2] replace calls to url_feof() with avio_feof() In-Reply-To: <1407442361-4104-2-git-send-email-jamrial@gmail.com> References: <1407442361-4104-1-git-send-email-jamrial@gmail.com> <1407442361-4104-2-git-send-email-jamrial@gmail.com> Message-ID: <20140807235339.GA12391@nb4> On Thu, Aug 07, 2014 at 05:12:41PM -0300, James Almer wrote: > Signed-off-by: James Almer > --- > ffplay.c | 4 ++-- > libavformat/4xm.c | 2 +- > libavformat/adp.c | 2 +- > libavformat/aiffdec.c | 2 +- > libavformat/amr.c | 2 +- > libavformat/anm.c | 2 +- > libavformat/ape.c | 2 +- > libavformat/aqtitledec.c | 2 +- > libavformat/asfdec.c | 16 ++++++++-------- > libavformat/astdec.c | 2 +- > libavformat/avidec.c | 12 ++++++------ > libavformat/bethsoftvid.c | 2 +- > libavformat/bfi.c | 4 ++-- > libavformat/bintext.c | 2 +- > libavformat/bit.c | 2 +- > libavformat/brstm.c | 4 ++-- > libavformat/cafdec.c | 6 +++--- > libavformat/cdxl.c | 2 +- > libavformat/dauddec.c | 2 +- > libavformat/dsicin.c | 2 +- > libavformat/dtshddec.c | 2 +- > libavformat/dv.c | 2 +- > libavformat/dxa.c | 4 ++-- > libavformat/electronicarts.c | 4 ++-- > libavformat/ffmdec.c | 4 ++-- > libavformat/ffmetadec.c | 4 ++-- > libavformat/filmstripdec.c | 2 +- > libavformat/flacdec.c | 2 +- > libavformat/flvdec.c | 2 +- > libavformat/gifdec.c | 6 +++--- > libavformat/gxf.c | 4 ++-- > libavformat/hls.c | 4 ++-- > libavformat/hlsproto.c | 2 +- > libavformat/idcin.c | 2 +- > libavformat/idroqdec.c | 2 +- > libavformat/iff.c | 2 +- > libavformat/img2dec.c | 2 +- > libavformat/ipmovie.c | 6 +++--- > libavformat/jacosubdec.c | 2 +- > libavformat/jvdec.c | 2 +- > libavformat/lrcdec.c | 4 ++-- > libavformat/lvfdec.c | 4 ++-- > libavformat/lxfdec.c | 2 +- > libavformat/matroskadec.c | 4 ++-- > libavformat/mgsts.c | 2 +- > libavformat/microdvddec.c | 2 +- > libavformat/mlvdec.c | 2 +- > libavformat/mmf.c | 2 +- > libavformat/mov.c | 6 +++--- > libavformat/mpc8.c | 4 ++-- > libavformat/mpeg.c | 6 +++--- > libavformat/mpegts.c | 2 +- > libavformat/mpl2dec.c | 2 +- > libavformat/mpsubdec.c | 2 +- > libavformat/msnwc_tcp.c | 4 ++-- > libavformat/mxfdec.c | 8 ++++---- > libavformat/mxg.c | 2 +- > libavformat/ncdec.c | 2 +- > libavformat/nistspheredec.c | 2 +- > libavformat/nsvdec.c | 12 ++++++------ > libavformat/nutdec.c | 4 ++-- > libavformat/nuv.c | 8 ++++---- > libavformat/oggdec.c | 2 +- > libavformat/paf.c | 2 +- > libavformat/pjsdec.c | 2 +- > libavformat/pmpdec.c | 4 ++-- > libavformat/psxstr.c | 2 +- > libavformat/qcp.c | 2 +- > libavformat/realtextdec.c | 2 +- > libavformat/redspark.c | 2 +- > libavformat/riffdec.c | 2 +- > libavformat/rmdec.c | 6 +++--- > libavformat/rpl.c | 2 +- > libavformat/rsd.c | 2 +- > libavformat/samidec.c | 2 +- > libavformat/smacker.c | 2 +- > libavformat/smjpegdec.c | 4 ++-- > libavformat/smush.c | 4 ++-- > libavformat/sol.c | 2 +- > libavformat/spdifdec.c | 2 +- > libavformat/srtdec.c | 2 +- > libavformat/subviewer1dec.c | 2 +- > libavformat/subviewerdec.c | 2 +- > libavformat/swfdec.c | 2 +- > libavformat/takdec.c | 2 +- > libavformat/tmv.c | 2 +- > libavformat/tty.c | 2 +- > libavformat/txd.c | 2 +- > libavformat/vc1test.c | 2 +- > libavformat/vivo.c | 6 +++--- > libavformat/vplayerdec.c | 2 +- > libavformat/vqf.c | 2 +- > libavformat/wavdec.c | 10 +++++----- > libavformat/wc3movie.c | 4 ++-- > libavformat/wtvdec.c | 10 +++++----- > libavformat/wvdec.c | 2 +- > 96 files changed, 160 insertions(+), 160 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Rewriting code that is poorly written but fully understood is good. Rewriting code that one doesnt understand is a sign that one is less smart then the original author, trying to rewrite it will not make it better. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Fri Aug 8 02:31:23 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 8 Aug 2014 02:31:23 +0200 Subject: [FFmpeg-devel] Stereo channel layout mapping In-Reply-To: References: Message-ID: <20140808003123.GB12391@nb4> On Thu, Aug 07, 2014 at 04:52:43PM +0200, Robert Kr?ger wrote: > Hi, > > could someone explain, what the difference between those two is and > when to use which one? > > #define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT) > #define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT) if you have a file with 2 channels these would likely be AV_CH_LAYOUT_STEREO if you have a file with 5.1 that in addition have 2 channels for stereo playback equipment then that would have 8 channels and use AV_CH_LAYOUT_STEREO_DOWNMIX + whatever else for 5.1 > > E.g. when I extract metadata and want to use that as a basis to > display the channel info to a user in a UI it is a bit surprising to > display "Front left" and "Front right" for the channels of a plain > stereo file. I can handle that case manually but it would be nice to > understand the rationale behind it. > > Regards, > > Robert > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The bravest are surely those who have the clearest vision of what is before them, glory and danger alike, and yet notwithstanding go out to meet it. -- Thucydides -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Fri Aug 8 03:32:04 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 8 Aug 2014 03:32:04 +0200 Subject: [FFmpeg-devel] FFmpeg and OPW In-Reply-To: <20140801011631.GJ4649@nb4> References: <20140801011631.GJ4649@nb4> Message-ID: <20140808013204.GC12391@nb4> Hi all On Fri, Aug 01, 2014 at 03:16:31AM +0200, Michael Niedermayer wrote: > Hi all > > OPW (Outreach Program for Women) is twice per year (compared to google > summer of code which is just once a year) > > FFmpeg can participate in the next round but we need to fund at least > 1 intern/student (6250 USD) for that. OPW is not run by a large > corporation with deep pockets. > > Thus my mail here, if you are/represent a company or know one who does > and who uses and benefits from FFmpeg, and has the financial resources, > please consider to donate or ask/forward this mail. > > Why should you donate? > Well the money will be used to fund a intern working on and improving > FFmpeg. (assuming there will be a intern who wants to work on FFmpeg > in OPW) 1 week passed, 3 weeks left Companies and individuals sofar have donated 105 USD to our ffmpeg-opw account. Thanks to the donators for their support of the FFmpeg free software community! Note, we do need at a minimum 6250 USD Thanks! [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Concerning the gods, I have no means of knowing whether they exist or not or of what sort they may be, because of the obscurity of the subject, and the brevity of human life -- Protagoras -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From onemda at gmail.com Fri Aug 8 11:28:00 2014 From: onemda at gmail.com (Paul B Mahol) Date: Fri, 8 Aug 2014 11:28:00 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <6021A548-6BF2-4A49-A50A-33EB50F7E053@googlemail.com> <20140801102233.GG10372@leki> <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> Message-ID: On 8/7/14, Daniel Oberhoff wrote: > > Am 06.08.2014 um 12:12 schrieb Clement Boesch : > >> On Sun, Aug 03, 2014 at 06:43:18PM +0200, Daniel Oberhoff wrote: >> [...] >>>>> +static av_cold int init(AVFilterContext *ctx) >>>>> +{ >>>>> + return 0; >>>>> +} >>>>> >>>> >>>> please remove this one, there is no point in having code that does >>>> nothing. >>>> >>>>> + >>>>> +static av_cold void uninit(AVFilterContext *ctx) >>>>> +{ >>>>> +} >>>>> + >>>>> >>>> >>>> ditto >>>> >>> >>> Done thanks! >>> >> >> Did you forget to attach the latest version of the patch or I missed it >> somewhere in the thread? > > Sorry, think that day I wanted to add something else before resubmit, and > then lost the time. > > Here also with changes suggested by timothy. Note that the parametrization > is now traditional > (i.e. k1 and k2 are zero-based, as for example in the opencv documentation > about calibration). > > From b798b95eb2f9ec4043b2407970d351cc31dd9e6a Mon Sep 17 00:00:00 2001 > From: Daniel Oberhoff > Date: Mon, 28 Jul 2014 23:58:12 +0200 > Subject: [PATCH] avfilter: ported lenscorrection filter from frei0r > > --- > Changelog | 2 +- > MAINTAINERS | 1 + > doc/filters.texi | 46 +++++++ > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/version.h | 4 +- > libavfilter/vf_lenscorrection.c | 199 > +++++++++++++++++++++++++++ > tests/fate/filter-video.mak | 3 + > tests/ref/fate/filter-pixfmts-lenscorrection | 8 ++ > 9 files changed, 262 insertions(+), 3 deletions(-) > create mode 100644 libavfilter/vf_lenscorrection.c > create mode 100644 tests/ref/fate/filter-pixfmts-lenscorrection > probably ok From michaelni at gmx.at Fri Aug 8 12:10:19 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 8 Aug 2014 12:10:19 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <20140801102233.GG10372@leki> <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> Message-ID: <20140808101019.GD12391@nb4> On Thu, Aug 07, 2014 at 12:15:17AM +0200, Daniel Oberhoff wrote: > > Am 06.08.2014 um 12:12 schrieb Cl?ment B?sch : > > > On Sun, Aug 03, 2014 at 06:43:18PM +0200, Daniel Oberhoff wrote: > > [...] > >>>> +static av_cold int init(AVFilterContext *ctx) > >>>> +{ > >>>> + return 0; > >>>> +} > >>>> > >>> > >>> please remove this one, there is no point in having code that does nothing. > >>> > >>>> + > >>>> +static av_cold void uninit(AVFilterContext *ctx) > >>>> +{ > >>>> +} > >>>> + > >>>> > >>> > >>> ditto > >>> > >> > >> Done thanks! > >> > > > > Did you forget to attach the latest version of the patch or I missed it > > somewhere in the thread? > > Sorry, think that day I wanted to add something else before resubmit, and then lost the time. > > Here also with changes suggested by timothy. Note that the parametrization is now traditional > (i.e. k1 and k2 are zero-based, as for example in the opencv documentation about calibration). > > From b798b95eb2f9ec4043b2407970d351cc31dd9e6a Mon Sep 17 00:00:00 2001 > From: Daniel Oberhoff > Date: Mon, 28 Jul 2014 23:58:12 +0200 > Subject: [PATCH] avfilter: ported lenscorrection filter from frei0r > > --- > Changelog | 2 +- > MAINTAINERS | 1 + > doc/filters.texi | 46 +++++++ > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/version.h | 4 +- > libavfilter/vf_lenscorrection.c | 199 +++++++++++++++++++++++++++ > tests/fate/filter-video.mak | 3 + > tests/ref/fate/filter-pixfmts-lenscorrection | 8 ++ > 9 files changed, 262 insertions(+), 3 deletions(-) > create mode 100644 libavfilter/vf_lenscorrection.c > create mode 100644 tests/ref/fate/filter-pixfmts-lenscorrection > This is missing a "Signed-off-by" from you > diff --git a/Changelog b/Changelog > index 25dd210..79393ce 100644 > --- a/Changelog > +++ b/Changelog > @@ -3,7 +3,7 @@ releases are sorted from youngest to oldest. > > version : > - Icecast protocol > - > +- ported lenscorrection filter from frei0r filter > > version 2.3: > - AC3 fixed-point decoding > diff --git a/MAINTAINERS b/MAINTAINERS > index c383d3f..6948e22 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -354,6 +354,7 @@ Filters: > vf_histogram.c Paul B Mahol > vf_hqx.c Cl?ment B?sch > vf_il.c Paul B Mahol > + vf_lenscorrection.c Daniel Oberhoff > vf_mergeplanes.c Paul B Mahol > vf_psnr.c Paul B Mahol > vf_scale.c Michael Niedermayer > diff --git a/doc/filters.texi b/doc/filters.texi > index 86feebc..c4888d3 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -5532,6 +5532,51 @@ kerndeint=map=1 > @end example > @end itemize > > + at section lenscorrection > + > +Correct radial lens distortion > + > +This filter can be used to correct for radial distortion as can result from the use > +of wide angle lenses, and thereby re-rectify the image. To find the right parameters > +one can use tools available for example as part of opencv or simply trial-and-error. > +To use opencv use the calibration sample (under samples/cpp) from the opencv sources > +and extract the k1 and k2 coefficients from the resulting matrix. > + > +Note that effectively the same filter is available in the open-source tools Krita and > +Digikam from the KDE project. > + > +In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors, > +this filter corrects the distortion of the image, whereas @ref{vignette} corrects the > +brightness distribution, so you may want to use both filters together in certain > +cases, though you will have to take care of ordering, i.e. whether vignetting should > +be applied before or after lens correction. > + > + at subsection Options > + > +The filter accepts the following options: > + > + at table @option > + at item cx > +Relative x-coordinate of the focal point of the image, and thereby the center of the > +distrortion. This value has a range [0,1] and is expressed as fractions of the image > +width. > + at item cy > +Relative y-coordinate of the focal point of the image, and thereby the center of the > +distrortion. This value has a range [0,1] and is expressed as fractions of the image > +height. > + at item k1 > +Coefficient of the quadratic correction term. 0.5 means no correction. > + at item k2 > +Coefficient of the double quadratic correction term. 0.5 means no correction. > + at end table > + > +The formula that generates the correction is: > + > + at var{r_src} = @var{r_tgt} * (1 + @var{k1} * (@var{r_tgt} / @var{r_0})^2 + @var{k2} * (@var{r_tgt} / @var{r_0})^4) > + > +where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the > +distances from the focal point in the source and target images, respectively. > + > @anchor{lut3d} > @section lut3d > > @@ -8744,6 +8789,7 @@ For example, to vertically flip a video with @command{ffmpeg}: > ffmpeg -i in.avi -vf "vflip" out.avi > @end example > > + at anchor{vignette} > @section vignette > > Make or reverse a natural vignetting effect. > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index 0f54381..e9c8456 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -138,6 +138,7 @@ OBJS-$(CONFIG_IL_FILTER) += vf_il.o > OBJS-$(CONFIG_INTERLACE_FILTER) += vf_interlace.o > OBJS-$(CONFIG_INTERLEAVE_FILTER) += f_interleave.o > OBJS-$(CONFIG_KERNDEINT_FILTER) += vf_kerndeint.o > +OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o > OBJS-$(CONFIG_LUT3D_FILTER) += vf_lut3d.o > OBJS-$(CONFIG_LUT_FILTER) += vf_lut.o > OBJS-$(CONFIG_LUTRGB_FILTER) += vf_lut.o > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c > index 1877557..b1d6ff5 100644 > --- a/libavfilter/allfilters.c > +++ b/libavfilter/allfilters.c > @@ -156,6 +156,7 @@ void avfilter_register_all(void) > REGISTER_FILTER(INTERLACE, interlace, vf); > REGISTER_FILTER(INTERLEAVE, interleave, vf); > REGISTER_FILTER(KERNDEINT, kerndeint, vf); > + REGISTER_FILTER(LENSCORRECTION, lenscorrection, vf); > REGISTER_FILTER(LUT3D, lut3d, vf); > REGISTER_FILTER(LUT, lut, vf); > REGISTER_FILTER(LUTRGB, lutrgb, vf); > diff --git a/libavfilter/version.h b/libavfilter/version.h > index 1a43dc5..47bac78 100644 > --- a/libavfilter/version.h > +++ b/libavfilter/version.h > @@ -30,8 +30,8 @@ > #include "libavutil/version.h" > > #define LIBAVFILTER_VERSION_MAJOR 4 > -#define LIBAVFILTER_VERSION_MINOR 11 > -#define LIBAVFILTER_VERSION_MICRO 102 > +#define LIBAVFILTER_VERSION_MINOR 12 > +#define LIBAVFILTER_VERSION_MICRO 100 > > #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ > LIBAVFILTER_VERSION_MINOR, \ > diff --git a/libavfilter/vf_lenscorrection.c b/libavfilter/vf_lenscorrection.c > new file mode 100644 > index 0000000..c2346db > --- /dev/null > +++ b/libavfilter/vf_lenscorrection.c > @@ -0,0 +1,199 @@ > +/* > + * Copyright (C) 2007 Richard Spindler (author of frei0r plugin from which this was derived) > + * Copyright (C) 2014 Daniel Oberhoff > + * > + * This file is part of FFmpeg. > + * > + * 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 > + */ > + > +/** > + * @file > + * Lenscorrection filter, algorithm from the frei0r plugin with the same name > +*/ > +#include > +#include > + > +#include "libavutil/opt.h" > +#include "libavutil/intreadwrite.h" > +#include "libavutil/pixdesc.h" > + > +#include "avfilter.h" > +#include "internal.h" > +#include "video.h" > + > +typedef struct LenscorrectionCtx { > + const AVClass *av_class; > + unsigned int width; > + unsigned int height; > + int hsub, vsub; > + int nb_planes; > + double cx, cy, k1, k2; > +} LenscorrectionCtx; > + > +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM > +static const AVOption lenscorrection_options[] = { > + { "cx", "set relative center x", offsetof(LenscorrectionCtx, cx), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, > + { "cy", "set relative center y", offsetof(LenscorrectionCtx, cy), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, > + { "k1", "set quadratic distortion factor", offsetof(LenscorrectionCtx, k1), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, .flags=FLAGS }, > + { "k2", "set double quadratic distortion factor", offsetof(LenscorrectionCtx, k2), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, .flags=FLAGS }, > + { NULL } > +}; > + > +AVFILTER_DEFINE_CLASS(lenscorrection); > + > +typedef struct ThreadData { > + AVFrame *in, *out; > + float w, h; > + int plane; > + float xcenter, ycenter; > + float k1, k2; > +} ThreadData; > + > +static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs) > +{ > + ThreadData *td = (ThreadData*)arg; > + AVFrame *in = td->in; > + AVFrame *out = td->out; > + > + const float w = td->w, h = td->h; > + const float xcenter = td->xcenter; > + const float ycenter = td->ycenter; > + const float r2inv = 4.0 / (w * w + h * h); > + const float k1 = td->k1; > + const float k2 = td->k2; > + const int start = (h * job ) / nb_jobs; > + const int end = (h * (job+1)) / nb_jobs; > + const int plane = td->plane; > + const int inlinesize = in->linesize[plane]; > + const int outlinesize = out->linesize[plane]; > + const uint8_t *indata = in->data[plane]; > + uint8_t *outrow = out->data[plane] + start * outlinesize; > + int i; > + for (i = start; i < end; i++, outrow += outlinesize) { > + const float off_y = i - ycenter; > + const float off_y2 = off_y * off_y; > + uint8_t *out = outrow; > + int j; > + for (j = 0; j < w; j++) { > + const float off_x = j - xcenter; > + const float r2 = (off_x * off_x + off_y2) * r2inv; > + const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2; > + const int x = xcenter + radius_mult * off_x + 0.5f; > + const int y = ycenter + radius_mult * off_y + 0.5f; > + const char isvalid = x > 0 && x < w - 1 && y > 0 && y < h - 1; > + *out++ = isvalid ? indata[y * inlinesize + x] : 0; IMHO "nearest neighbour" resampling isnt a reasonable choice, if thats the only choice the user has. also md5 based regression tests and extensive use of floats are unlikely to work together, different architectures/platforms or even compiler versions might give you different results [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I know you won't believe me, but the highest form of Human Excellence is to question oneself and others. -- Socrates -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From marek.fort at chyronhego.com Fri Aug 8 12:54:41 2014 From: marek.fort at chyronhego.com (Marek Fort) Date: Fri, 8 Aug 2014 12:54:41 +0200 Subject: [FFmpeg-devel] Patch - Mov decoder should read Avid's metadata for DNXHD codec In-Reply-To: References: Message-ID: Hi, new patch attached. It is a simplified version. It does the same job as the older/longer one. I'd like to get this patch integrated. Thank you, Marek Fort On 6 August 2014 14:33, Marek Fort wrote: > Hi, > > I'd like to get this patch integrated. > This allows to propagate AALP and ARES mov file atoms to DNxHD codec. > Parsing AALP is essential for proper alpha channel decoding. > > This patch relates to this ticket https://trac.ffmpeg.org/ticket/3707 > > Thanks, > Marek Fort > > -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Mov-decoder-reads-Avid-s-metadata-for-DNXHD.patch Type: application/octet-stream Size: 1030 bytes Desc: not available URL: From alikizil at gmail.com Fri Aug 8 12:54:04 2014 From: alikizil at gmail.com (Ali KIZIL) Date: Fri, 8 Aug 2014 10:54:04 +0000 (UTC) Subject: [FFmpeg-devel] Test Result Message-ID: Yestday, I got the latest snaphot from GIT and tested the case. On a CBR test, if outpur bandwidth rate is high, some decoders/TS analyze SWs give PCR accuracy and repetition error (very rare). Example: ffmpeg -i pipe -aspect 16:9 -fflags +genpts -vcodec libx264 -preset ultrafast -vb 25000k -minrate 25000k -maxrate 25000k -bufsize 2500k -muxrate 27000k - tune stillimage -qmin 20 -pix_fmt yuv420p -vbsf h264_mp4toannexb -strict experimental -acodec libfdk_aac -ab 128k -flush_packets 0 -f mpegts 'udp://225.2.1.1:1234?pkt_size=1316' This works fine. Time to time on some decoders (like Ericsson) make black frame. But no PCR error. ffmpeg -i pipe -aspect 16:9 -fflags +genpts -vcodec libx264 -preset ultrafast -vb 50000k -minrate 50000k -maxrate 50000k -bufsize 10000k -muxrate 54000k - tune stillimage -qmin 20 -pix_fmt yuv420p -vbsf h264_mp4toannexb -strict experimental -acodec libfdk_aac -ab 128k -flush_packets 0 -f mpegts 'udp://225.2.1.1:1234?pkt_size=1316' In this case, it reports PCR accuracy and repetition error and decoders gives alarm as well. BR, From krueger at lesspain.de Fri Aug 8 14:36:46 2014 From: krueger at lesspain.de (=?UTF-8?Q?Robert_Kr=C3=BCger?=) Date: Fri, 8 Aug 2014 14:36:46 +0200 Subject: [FFmpeg-devel] Stereo channel layout mapping In-Reply-To: <20140808003123.GB12391@nb4> References: <20140808003123.GB12391@nb4> Message-ID: On Fri, Aug 8, 2014 at 2:31 AM, Michael Niedermayer wrote: > On Thu, Aug 07, 2014 at 04:52:43PM +0200, Robert Kr?ger wrote: >> Hi, >> >> could someone explain, what the difference between those two is and >> when to use which one? >> >> #define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT) >> #define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT) > > if you have a file with 2 channels these would likely be AV_CH_LAYOUT_STEREO > > if you have a file with 5.1 that in addition have 2 channels for > stereo playback equipment then that would have 8 channels and use > AV_CH_LAYOUT_STEREO_DOWNMIX + whatever else for 5.1 Are you actually talking about having one track with 8 channels with this layout? It's beginning to make sense now. Thanks for the feedback, Robert From james.darnley at gmail.com Fri Aug 8 16:30:57 2014 From: james.darnley at gmail.com (James Darnley) Date: Fri, 08 Aug 2014 16:30:57 +0200 Subject: [FFmpeg-devel] [PATCH 1/4] lavc/flacenc: add sse4 version of the 16-bit lpc encoder In-Reply-To: <20140720234852.GK4649@nb4> References: <1394625786-4732-1-git-send-email-james.darnley@gmail.com> <20140314230108.GK8929@nb4> <53CC4377.7080507@gmail.com> <20140720234852.GK4649@nb4> Message-ID: <53E4DF21.5060102@gmail.com> On 2014-07-21 01:48, Michael Niedermayer wrote: > On Mon, Jul 21, 2014 at 12:32:23AM +0200, James Darnley wrote: >> On 2014-03-15 00:01, Michael Niedermayer wrote: >>> On Wed, Mar 12, 2014 at 01:03:03PM +0100, James Darnley wrote: >>>> +; Is it worth looping correctly over the first samples? The most that ever need >>>> +; to be copied is 32 so we might as well just unroll the loop and do all 32. >>> >>> implementations should not make assumtations on their use except >>> what is documented in the API >>> or the other way around >>> if some limitation is always true and you want to write an >>> implementation that takes advantage of the limitation for optimization >>> then this limitation should be documented in the API first >>> (in this case of FLACDSPContext / lpc_encode) >> >> So... I've been bored lately and thought I'd come back to this. I've >> got a changed version which copies these samples in a loop. You can see >> the changes in these two links: >> >>> https://gitorious.org/ffmpeg/jdarnley-ffmpeg/commit/9604911fbbe864cd0f670bdad47e7c5c2e83dc02 >>> https://gitorious.org/ffmpeg/jdarnley-ffmpeg/commit/837879d34100113105f099996ac67085d9c86396 >> >> These two are just about the same but apply to 16 and 32-bit. >> >> Should I try to measure the difference between the two? Or should I >> just submit one version, possibly with suitable documentation? > > fastest is best, and docs must match implementation but docs can be > changed for internal API Testing showed no reliable difference. To be specific: the new code, when measured, showed a runtime decrease of about 0.2% (+/- 0.2), yet the function took a little more time to run (also with a similarly large error). Having done this I will submit the patches again using the old code but with some small changes and documentation of its limits. I will also add some further documentation about the C code because its unrolled function (used in the not CONFIG_SMALL case) also assumes a maximum order of 32. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 618 bytes Desc: OpenPGP digital signature URL: From Nedeljko.Babic at imgtec.com Fri Aug 8 16:36:07 2014 From: Nedeljko.Babic at imgtec.com (Nedeljko Babic) Date: Fri, 8 Aug 2014 14:36:07 +0000 Subject: [FFmpeg-devel] [PATCH 02/14] libavcodec: Implementation of AAC_fixed_decoder (LC-module) [2/5] In-Reply-To: <20140807201249.GC6490@reimardoeffinger.de> References: <1406901200-4862-1-git-send-email-nedeljko.babic@imgtec.com> <1406901200-4862-3-git-send-email-nedeljko.babic@imgtec.com> <20140801190850.GA4224@reimardoeffinger.de> , <20140807201249.GC6490@reimardoeffinger.de> Message-ID: I agree with most of your suggestions and they will be incorporated in the next patch. Thanks again on your review. - Nedeljko ________________________________________ Od: ffmpeg-devel-bounces at ffmpeg.org [ffmpeg-devel-bounces at ffmpeg.org] u ime korisnika Reimar D?ffinger [Reimar.Doeffinger at gmx.de] Poslato: 7. avgust 2014 22:12 Za: FFmpeg development discussions and patches Tema: Re: [FFmpeg-devel] [PATCH 02/14] libavcodec: Implementation of AAC_fixed_decoder (LC-module) [2/5] On Thu, Aug 07, 2014 at 09:51:36AM +0000, Nedeljko Babic wrote: > >> + Q30(0.9999999995), Q30(0.9922480620), Q30(0.9846153846), Q30(0.9770992366), > > > >I'm a bit unsure btw. if this makes more sense than coding the converted > >numbers. > >It feels like it combines the disadvantages, since it neither avoids > >code duplication with the float tables nor does it compiler/architecture > >dependence completely (I think). > > > > I am not sure what disadvantages are combined (there is no code duplication for example), I assumed the same tables might already exist somewhere, but I might just misunderstand. > but since only advantage is in that it can be seen what fixed point representation is used, > the values will be hard coded in hex format. To be honest, I flagged this more as a point of discussion. In some ways, this variant is more "readable/verifiable", but on the other hand bit-exact decoding between compilers/platforms would be even nicer. Yet again, it might be a purely theoretical issue. > >> + aac_float_t ret; > >> + int nz; > >> + > >> + if (x == 0) > >> + { > >> + ret.mant = 0; > >> + ret.expo = 0; > >> + } > >> + else > >> + { > >> + ret.expo = exp; > >> + ret.mant = x; > >> + nz = 29 - av_log2_c_emu(FFABS(ret.mant)); > >> + ret.mant <<= nz; > >> + ret.expo -= nz; > > > >nz is only used here, so it should be declared here. > >Also > >int nz = 29 - av_log2_c_emu(FFABS(x)); > > Since ISO C90 forbids mixing declarations and code, warnings will be generated if nz is declared here. > On the other hand, it can (and will) be declared at the start of the else block. Yes, I meant at the start of the else block by "here", though with my proposed change that will also be the first use :) > >> + if (manta == 0) > >> + return b; > >> + > >> + if (mantb == 0) > >> + return a; > >> + > >> + diff = expa - expb; > >> + if (diff < 0) // expa < expb > >> + { > >> + diff = -diff; > >> + if (diff >= 31) > >> + manta = 0; > >> + else if (diff != 0) > >> + manta >>= diff; > >> + expa = expb; > >> + } > >> + else // expa >= expb > >> + { > >> + if (diff >= 31) > >> + mantb = 0; > >> + else if (diff != 0) > >> + mantb >>= diff; > >> + } > >> + > >> + manta = manta + mantb; > >> + if (manta == 0) > >> + expa = 0; > >> + else > >> + { > >> + nz = 30 - av_log2_c_emu(FFABS(manta)); > >> + manta <<= nz; > >> + manta >>= 1; > >> + expa -= (nz-1); > >> + } > > > >I think this needs a good thinking over. > >If diff was calculated first, the >= 31/ <= -31 checks > >could be combined with the checks for 0. > > diff is calculated right after checking if mantissas are zero. > Mantissas are checked first because if they are zero, > it is a waste of time to do other calculations. > > On the other hand, I am not sure what would be gain in combining > >= 31/ <= -31 checks with the checks for 0 (for diff). As far as I can tell, if the difference is <= 31 we will always return either a or b, i.e. whether one is at least 31 exponents smaller or it is 0 is the same thing. Assuming I understood the code right, I guess you can also just replace > >> + if (diff >= 31) > >> + manta = 0; by > >> + if (diff >= 31) > >> + return b; Though the question is whether it's more important performance wise to optimize the case where one operand is 0 or to reduce the number of branches. Or it might not matter at all. But I admit I haven't looked at it closely enough to be 100% sure about any of this, thus the statement that I believe someone needs to think through this code once more, because I strongly suspect it's needlessly confusing and slow. > >also the != 0 check can certainly only make performance worse. > > I agree with this in if part, since it is not needed as you pointed out, > but this check is needed in the else part. If the statement is if (s != 0) a >>= s; how can the if _ever_ be _needed_ for correctness? a >>= 0 is a NOP, so no need to explicitly skip it for s == 0. > >For all functions, I think there should be a look at what rounding > >mode they end up using in the end and document that. > >This one looks like round to 0. > > > > This is rounding to 0. It can be changed to rounding to nearest without loss in precision. > > Do you suggest that we should make comment like: > /* Rounding to zero used */ > for every function? Well, if every function used round to zero that, it should be written once e.g. at the top of the file. However that does not seem to be the case. Ideally, I think there should be a statement that all functions unless otherwise stated use round to 0 for simplicity. In addition, for those using a different rounding this should be documented. > >> +static av_always_inline aac_float_t float_sub(aac_float_t a, aac_float_t b) > > > >Why would this need a whole separate implementation instead > >of changing the sign of b and calling add? > > > > Because there could be overhead because of function call if function is not inlined. > On the other hand I guess that gain is insignificant (or there is no gain if function > is inlined) and this will be done by calling add as you suggested. The functions are av_always_inline, so I think we may assume that they will be inlined and when they are not tell people to live with the performance or find a better compiler. Or possibly do the brute-force method of using a macro. > >> + mant = (int)((accu + 0x20000000) >> 30); > > > >This suddenly seems to use round-to-nearest-away as rounding mode/ > > > > Yes it is. I pointed it out because switching rounding mode without documenting the reason makes the code a bit hard to read, and even harder to optimize because nobody knows whether there is a specific reason why round to nearest is used or if it could just be removed for slightly better performance. > >> + if (mantb != 0) > >> + { > >> + iB = float_recip(b); > >> + // newton iteration to double precision > >> + tmp = float_sub(FLOAT_1, float_mul(b, iB)); > >> + iB = float_add(iB, float_mul(iB, tmp)); > >> + res = float_mul(a, iB); > >> + } > >> + else > >> + { > >> + res.mant = 1; > >> + res.expo = 2147483647; > > > >Hexadecimal would be nicer. > >Also, this seems to be the only function so far that handles > >infinity correctly. > >I have some doubts of the value of that, as long as it is the only one. > >If there's a particular reason why it only needs to be supported here, > >that should be documented. > > Only division by zero can create infinity, so it is addressed only here. Sure, only it can create infinity from non-infinity inputs. But what happens then? If you now use the result of a division with an add it won't quite work right in case it was an infinity as far as I can tell. At least not IEEE-style if it's (-1/0)+(1/0). So either you have to assume that a division will always be the last operation ever done or supporting infinity here is kind of pointless unless you support it anywhere as input at least. Maybe inf will actually work in a kind of reasonable (but not IEEE-compliant) way in the other functions, but it's not clear to me anyone tested that. > >> +static av_always_inline int float_gt(aac_float_t a, aac_float_t b) > >> +{ > >> + int expa = a.expo; > >> + int expb = b.expo; > >> + int manta = a.mant; > >> + int mantb = b.mant; > >> + > >> + if (manta == 0) > >> + expa = 0x80000000; > >> + > >> + if (mantb == 0) > >> + expb = 0x80000000; > >> + > >> + if (expa > expb) > >> + return 1; > >> + else if (expa < expb) > >> + return 0; > >> + else // expa == expb > >> + { > >> + if (manta > mantb) > >> + return 1; > >> + else > >> + return 0; > >> + } > > > >Does this actually work? > >The expa/expb assignment seems to invoke undefined behaviour by itself, > >but then it also seems to just not handle negative numbers, at least > >not if the exponent differs?!? > > Functions in this file are made for use in the implementation of AAC fixed point decoder. > This particular function is used only for calculating gain in aacsbr, so it doesn't need > to handle negative numbers. Ok, but then I still don't understand why the exp redirection. if (manta == 0) return 0; (if a is 0, then it can't be greater) if (mantb == 0) return 1; (if a is not 0, but b is 0, then a is greater) And the rest can also be simplified to e.g. just these 3 lines: if (expa > expb) return 1; if (expa < expb) return 0; return manta > mantb; _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel at ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From mfcc64 at gmail.com Fri Aug 8 16:58:35 2014 From: mfcc64 at gmail.com (Muhammad Faiz) Date: Fri, 8 Aug 2014 21:58:35 +0700 Subject: [FFmpeg-devel] [PATCH] avfilter/showcqt: add features Message-ID: add tlength option with frequency and timeclamp variable volume option with frequency and timeclamp variable, and a_weighting, b_weighting, c_weighting function thank's -------------- next part -------------- --- doc/filters.texi | 42 +++++++++++++++++++++-- libavfilter/avf_showcqt.c | 87 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 119 insertions(+), 10 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index f59926a..e0759fc 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10515,8 +10515,34 @@ The filter accepts the following options: @table @option @item volume -Specify the transform volume (multiplier). Acceptable value is [1.0, 100.0]. -Default value is @code{16.0}. +Specify transform volume (multiplier) expression. The expression can contain +variables: + at table @option + at item frequency, freq, f +the frequency where transform is evaluated + at item timeclamp, tc +value of timeclamp option + at end table +and functions: + at table @option + at item a_weighting(f) +A-weighting of equal loudness + at item b_weighting(f) +B-weighting of equal loudness + at item c_weighting(f) +C-weighting of equal loudness + at end table +Default value is @code{16}. + + at item tlength +Specify transform length expression. The expression can contain variables: + at table @option + at item frequency, freq, f +the frequency where transform is evaluated + at item timeclamp, tc +value of timeclamp option + at end table +Default value is @code{384/f*tc/(384/f+tc)}. @item timeclamp Specify the transform timeclamp. At low frequency, there is trade-off between @@ -10587,6 +10613,18 @@ ffplay -f lavfi 'aevalsrc=0.1*sin(2*PI*55*t)+0.1*sin(4*PI*55*t)+0.1*sin(6*PI*55* asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]' @end example + at item +B-weighting of equal loudness + at example +volume=16*b_weighting(f) + at end example + + at item +Lower Q factor + at example +tlength=100/f*tc/(100/f+tc) + at end example + @end itemize @section showspectrum diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c index 60e8129..012362b 100644 --- a/libavfilter/avf_showcqt.c +++ b/libavfilter/avf_showcqt.c @@ -26,6 +26,7 @@ #include "libavutil/xga_font_data.h" #include "libavutil/qsort.h" #include "libavutil/time.h" +#include "libavutil/eval.h" #include "avfilter.h" #include "internal.h" @@ -49,6 +50,10 @@ #define SPECTOGRAM_START (VIDEO_HEIGHT-SPECTOGRAM_HEIGHT) #define BASE_FREQ 20.051392800492 #define COEFF_CLAMP 1.0e-4 +#define TLENGTH_MIN 0.001 +#define TLENGTH_DEFAULT "384/f*tc/(384/f+tc)" +#define VOLUME_MIN 1e-10 +#define VOLUME_MAX 100.0 typedef struct { FFTSample value; @@ -75,7 +80,8 @@ typedef struct { int fft_bits; int req_fullfilled; int remaining_fill; - double volume; + char *tlength; + char *volume; double timeclamp; /* lower timeclamp, time-accurate, higher timeclamp, freq-accurate (at low freq)*/ float coeffclamp; /* lower coeffclamp, more precise, higher coeffclamp, faster */ int fullhd; /* if true, output video is at full HD resolution, otherwise it will be halved */ @@ -88,7 +94,8 @@ typedef struct { #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM static const AVOption showcqt_options[] = { - { "volume", "set volume", OFFSET(volume), AV_OPT_TYPE_DOUBLE, { .dbl = 16 }, 0.1, 100, FLAGS }, + { "volume", "set volume", OFFSET(volume), AV_OPT_TYPE_STRING, { .str = "16" }, CHAR_MIN, CHAR_MAX, FLAGS }, + { "tlength", "set transform length", OFFSET(tlength), AV_OPT_TYPE_STRING, { .str = TLENGTH_DEFAULT }, CHAR_MIN, CHAR_MAX, FLAGS }, { "timeclamp", "set timeclamp", OFFSET(timeclamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.17 }, 0.1, 1.0, FLAGS }, { "coeffclamp", "set coeffclamp", OFFSET(coeffclamp), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, 0.1, 10, FLAGS }, { "gamma", "set gamma", OFFSET(gamma), AV_OPT_TYPE_FLOAT, { .dbl = 3 }, 1, 7, FLAGS }, @@ -246,6 +253,28 @@ static void load_freetype_font(AVFilterContext *ctx) } #endif +static double a_weighting(void *p, double f) +{ + double ret = 12200.0*12200.0 * (f*f*f*f); + ret /= (f*f + 20.6*20.6) * (f*f + 12200.0*12200.0) * + sqrt((f*f + 107.7*107.7) * (f*f + 737.9*737.9)); + return ret; +} + +static double b_weighting(void *p, double f) +{ + double ret = 12200.0*12200.0 * (f*f*f); + ret /= (f*f + 20.6*20.6) * (f*f + 12200.0*12200.0) * sqrt(f*f + 158.5*158.5); + return ret; +} + +static double c_weighting(void *p, double f) +{ + double ret = 12200.0*12200.0 * (f*f); + ret /= (f*f + 20.6*20.6) * (f*f + 12200.0*12200.0); + return ret; +} + static inline int qsort_sparsecoeff(const SparseCoeff *a, const SparseCoeff *b) { if (fabsf(a->value) >= fabsf(b->value)) @@ -259,7 +288,11 @@ static int config_output(AVFilterLink *outlink) AVFilterContext *ctx = outlink->src; AVFilterLink *inlink = ctx->inputs[0]; ShowCQTContext *s = ctx->priv; - int fft_len, k, x, y; + AVExpr *tlength_expr, *volume_expr; + static const char * const expr_vars[] = { "timeclamp", "tc", "frequency", "freq", "f", NULL }; + static const char * const expr_func_names[] = { "a_weighting", "b_weighting", "c_weighting", NULL }; + static double (* const expr_funcs[])(void *, double) = { a_weighting, b_weighting, c_weighting, NULL }; + int fft_len, k, x, y, ret; int num_coeffs = 0; int rate = inlink->sample_rate; double max_len = rate * (double) s->timeclamp; @@ -307,12 +340,22 @@ static int config_output(AVFilterLink *outlink) av_log(ctx, AV_LOG_INFO, "Calculating spectral kernel, please wait\n"); start_time = av_gettime_relative(); + ret = av_expr_parse(&tlength_expr, s->tlength, expr_vars, NULL, NULL, NULL, NULL, 0, ctx); + if (ret < 0) + return ret; + ret = av_expr_parse(&volume_expr, s->volume, expr_vars, expr_func_names, + expr_funcs, NULL, NULL, 0, ctx); + if (ret < 0) { + av_expr_free(tlength_expr); + return ret; + } for (k = 0; k < VIDEO_WIDTH; k++) { int hlen = fft_len >> 1; float total = 0; float partial = 0; double freq = BASE_FREQ * exp2(k * (1.0/192.0)); - double tlen = rate * (24.0 * 16.0) /freq; + double tlen, tlength, volume; + double expr_vars_val[] = { s->timeclamp, s->timeclamp, freq, freq, freq, 0 }; /* a window function from Albert H. Nuttall, * "Some Windows with Very Good Sidelobe Behavior" * -93.32 dB peak sidelobe and 18 dB/octave asymptotic decay @@ -324,10 +367,33 @@ static int config_output(AVFilterLink *outlink) double sv_step, cv_step, sv, cv; double sw_step, cw_step, sw, cw, w; - tlen = tlen * max_len / (tlen + max_len); + tlength = av_expr_eval(tlength_expr, expr_vars_val, NULL); + if (isnan(tlength)) { + av_log(ctx, AV_LOG_WARNING, "at freq %g: tlength is nan, setting it to %g\n", freq, s->timeclamp); + tlength = s->timeclamp; + } else if (tlength < TLENGTH_MIN) { + av_log(ctx, AV_LOG_WARNING, "at freq %g: tlength is %g, setting it to %g\n", freq, tlength, TLENGTH_MIN); + tlength = TLENGTH_MIN; + } else if (tlength > s->timeclamp) { + av_log(ctx, AV_LOG_WARNING, "at freq %g: tlength is %g, setting it to %g\n", freq, tlength, s->timeclamp); + tlength = s->timeclamp; + } + + volume = FFABS(av_expr_eval(volume_expr, expr_vars_val, NULL)); + if (isnan(volume)) { + av_log(ctx, AV_LOG_WARNING, "at freq %g: volume is nan, setting it to 0\n", freq); + volume = VOLUME_MIN; + } else if (volume < VOLUME_MIN) { + volume = VOLUME_MIN; + } else if (volume > VOLUME_MAX) { + av_log(ctx, AV_LOG_WARNING, "at freq %g: volume is %g, setting it to %g\n", freq, volume, VOLUME_MAX); + volume = VOLUME_MAX; + } + + tlen = tlength * rate; s->fft_data[0].re = 0; s->fft_data[0].im = 0; - s->fft_data[hlen].re = (1.0 + a1 + a2 + a3) * (1.0/tlen) * s->volume * (1.0/fft_len); + s->fft_data[hlen].re = (1.0 + a1 + a2 + a3) * (1.0/tlen) * volume * (1.0/fft_len); s->fft_data[hlen].im = 0; sv_step = sv = sin(2.0*M_PI*freq*(1.0/rate)); cv_step = cv = cos(2.0*M_PI*freq*(1.0/rate)); @@ -341,7 +407,7 @@ static int config_output(AVFilterLink *outlink) cw2 = cw * cw - sw * sw; sw2 = cw * sw + sw * cw; cw3 = cw * cw2 - sw * sw2; - w = (1.0 + a1 * cw + a2 * cw2 + a3 * cw3) * (1.0/tlen) * s->volume * (1.0/fft_len); + w = (1.0 + a1 * cw + a2 * cw2 + a3 * cw3) * (1.0/tlen) * volume * (1.0/fft_len); s->fft_data[hlen + x].re = w * cv; s->fft_data[hlen + x].im = w * sv; s->fft_data[hlen - x].re = s->fft_data[hlen + x].re; @@ -378,14 +444,19 @@ static int config_output(AVFilterLink *outlink) s->coeffs_len[k] = fft_len - x; num_coeffs += s->coeffs_len[k]; s->coeffs[k] = av_malloc_array(s->coeffs_len[k], sizeof(*s->coeffs[k])); - if (!s->coeffs[k]) + if (!s->coeffs[k]) { + av_expr_free(volume_expr); + av_expr_free(tlength_expr); return AVERROR(ENOMEM); + } for (y = 0; y < s->coeffs_len[k]; y++) s->coeffs[k][y] = s->coeff_sort[x+y]; break; } } } + av_expr_free(volume_expr); + av_expr_free(tlength_expr); end_time = av_gettime_relative(); av_log(ctx, AV_LOG_INFO, "Elapsed time %.6f s (fft_len=%u, num_coeffs=%u)\n", 1e-6 * (end_time-start_time), fft_len, num_coeffs); -- 1.8.3.1 From michaelni at gmx.at Fri Aug 8 18:36:57 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 8 Aug 2014 18:36:57 +0200 Subject: [FFmpeg-devel] Patch - Mov decoder should read Avid's metadata for DNXHD codec In-Reply-To: References: Message-ID: <20140808163657.GE12391@nb4> On Fri, Aug 08, 2014 at 12:54:41PM +0200, Marek Fort wrote: > Hi, > > new patch attached. > It is a simplified version. It does the same job as the older/longer one. > > I'd like to get this patch integrated. > > Thank you, > Marek Fort > > > On 6 August 2014 14:33, Marek Fort wrote: > > > Hi, > > > > I'd like to get this patch integrated. > > This allows to propagate AALP and ARES mov file atoms to DNxHD codec. > > Parsing AALP is essential for proper alpha channel decoding. > > > > This patch relates to this ticket https://trac.ffmpeg.org/ticket/3707 > > > > Thanks, > > Marek Fort > > > > > mov.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > 891e2d38bf3822d7f49d66974ea75bb192cffe7e 0001-Mov-decoder-reads-Avid-s-metadata-for-DNXHD.patch > From cd542af22af77bc75c909d96d12dcbcfbeadbe1a Mon Sep 17 00:00:00 2001 > From: Marek Fort > Date: Thu, 7 Aug 2014 14:27:19 +0200 > Subject: [PATCH] Mov decoder reads Avid's metadata for DNXHD codec. > Especially atom AALP is necessary to properly decode alpha channel. Blocking > ticket #3707 patch applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Fri Aug 8 18:51:40 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 8 Aug 2014 18:51:40 +0200 Subject: [FFmpeg-devel] [PATCH] avfilter/showcqt: add features In-Reply-To: References: Message-ID: <20140808165140.GF12391@nb4> On Fri, Aug 08, 2014 at 09:58:35PM +0700, Muhammad Faiz wrote: > add tlength option with frequency and timeclamp variable > volume option with frequency and timeclamp variable, > and a_weighting, b_weighting, c_weighting function > > thank's > > --- > doc/filters.texi | 42 +++++++++++++++++++++-- > libavfilter/avf_showcqt.c | 87 ++++++++++++++++++++++++++++++++++++++++++----- > 2 files changed, 119 insertions(+), 10 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is what and why we do it that matters, not just one of them. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From mindmark at gmail.com Fri Aug 8 19:37:05 2014 From: mindmark at gmail.com (Mark Reid) Date: Fri, 8 Aug 2014 10:37:05 -0700 Subject: [FFmpeg-devel] [PATCH] write reel_name metadata to tmcd atom Message-ID: <1407519426-72919-1-git-send-email-mindmark@gmail.com> hi, My last patch added read support, now this on adds write support for reel names in tcmd atoms, as documented here: https://developer.apple.com/library/mac/documentation/quicktime/qtff/QTFFChap3/qtff3.html/apple_ref/doc/uid/TP40000939-CH205-57409#//apple_ref/doc/uid/TP40000939-CH205-69831 The docs refer to this as "Source reference" but I used the metadata key "reel_name" because thats what FFmbc calls it. This might also help address ticket#3753. I tried to keep the patch very minimal. Currently, the reel name is only written if both timecode and the metadata are added to a specific stream. example usage: ffmpeg -f lavfi -i testsrc -t 1 -timecode 01:00:00:00 -metadata:s:v:0 reel_name=ABCD123 OUTPUT.mov ffprobe OUTPUT.mov Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mov': Metadata: major_brand : qt minor_version : 512 compatible_brands: qt encoder : Lavf55.52.100 Duration: 00:00:01.00, start: 0.000000, bitrate: 399 kb/s Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 387 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default) Metadata: handler_name : DataHandler encoder : Lavc55.73.101 mpeg4 timecode : 01:00:00:00 Stream #0:1(eng): Data: none (tmcd / 0x64636D74), 0 kb/s Metadata: handler_name : DataHandler reel_name : ABCD123 timecode : 01:00:00:00 Mark Reid (1): write reel_name metadata to tmcd atom libavformat/movenc.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) -- 2.0.0 From mindmark at gmail.com Fri Aug 8 19:37:06 2014 From: mindmark at gmail.com (Mark Reid) Date: Fri, 8 Aug 2014 10:37:06 -0700 Subject: [FFmpeg-devel] [PATCH] write reel_name metadata to tmcd atom In-Reply-To: <1407519426-72919-1-git-send-email-mindmark@gmail.com> References: <1407519426-72919-1-git-send-email-mindmark@gmail.com> Message-ID: <1407519426-72919-2-git-send-email-mindmark@gmail.com> --- libavformat/movenc.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 86dbe7f..fe4413c 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1340,6 +1340,16 @@ static int mov_write_rtp_tag(AVIOContext *pb, MOVTrack *track) return update_size(pb, pos); } +static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack *track, const char *reel_name){ + int64_t pos = avio_tell(pb); + avio_wb32(pb, 0); /* size */ + ffio_wfourcc(pb, "name"); /* Data format */ + avio_wb16(pb, strlen(reel_name)); /* string size */ + avio_wb16(pb, track->language); /* langcode */ + avio_write(pb, reel_name, strlen(reel_name)); /* reel name */ + return update_size(pb,pos); +} + static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track) { int64_t pos = avio_tell(pb); @@ -1361,8 +1371,16 @@ static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, track->timescale); /* Timescale */ avio_wb32(pb, frame_duration); /* Frame duration */ avio_w8(pb, nb_frames); /* Number of frames */ - avio_wb24(pb, 0); /* Reserved */ - /* TODO: source reference string */ + avio_w8(pb, 0); /* Reserved */ + + AVDictionaryEntry *t = NULL; + if (track->st) + t = av_dict_get(track->st->metadata, "reel_name", NULL, 0); + + if (t && utf8len(t->value)) + mov_write_source_reference_tag(pb, track, t->value); + else + avio_wb16(pb, 0); /* zero size */ #else avio_wb32(pb, 0); /* size */ @@ -3808,6 +3826,9 @@ static int mov_create_timecode_track(AVFormatContext *s, int index, int src_inde track->timescale = mov->tracks[src_index].timescale; if (tc.flags & AV_TIMECODE_FLAG_DROPFRAME) track->timecode_flags |= MOV_TIMECODE_FLAG_DROPFRAME; + + /* set st to src_st for metadata access*/ + track->st = src_st; /* encode context: tmcd data stream */ track->enc = avcodec_alloc_context3(NULL); -- 2.0.0 From michaelni at gmx.at Fri Aug 8 20:09:18 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 8 Aug 2014 20:09:18 +0200 Subject: [FFmpeg-devel] [PATCH] NULL-check Matroska chapters when reading header In-Reply-To: References: Message-ID: <20140808180918.GG12391@nb4> On Wed, Aug 06, 2014 at 08:29:40PM -0400, Justin Jacobs wrote: > I have a Matroska file that contains a broken chapter (end time is before > start time) that caused any ffmpeg-linked program to crash when accessing > it. I've attached a patch that fixes the crash. Also, here is the backtrace > of the crash for reference: can you share the problematic file ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB While the State exists there can be no freedom; when there is freedom there will be no State. -- Vladimir Lenin -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Fri Aug 8 21:13:40 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Fri, 8 Aug 2014 21:13:40 +0200 Subject: [FFmpeg-devel] [PATCH] NULL-check Matroska chapters when reading header In-Reply-To: References: Message-ID: <20140808191340.GH12391@nb4> On Wed, Aug 06, 2014 at 08:29:40PM -0400, Justin Jacobs wrote: > I have a Matroska file that contains a broken chapter (end time is before > start time) that caused any ffmpeg-linked program to crash when accessing > it. I've attached a patch that fixes the crash. Also, here is the backtrace > of the crash for reference: > > (gdb) backtrace > #0 av_dict_set (pm=0x20, key=0x7ffff0bd14ef "title", value=0x7fffd80107e0 > "The End", flags=0) at libavutil/dict.c:71 > #1 0x00007ffff0b0e220 in matroska_read_header (s=0x20) at > libavformat/matroskadec.c:2164 > #2 0x00007ffff0b9b233 in avformat_open_input (ps=0x7fffe00c1a08, > filename=, fmt=, options=0x0) at > libavformat/utils.c:599 > #3 0x00007ffff5fc9c32 in > ffmpegthumbnailer::MovieDecoder::initialize(std::string const&) () from > /usr/lib/libffmpegthumbnailer.so.4 > #4 0x00007ffff5fcd50f in > ffmpegthumbnailer::VideoThumbnailer::generateThumbnail(std::string const&, > ffmpegthumbnailer::ImageWriter&, AVFormatContext*) () > from /usr/lib/libffmpegthumbnailer.so.4 > #5 0x00007ffff5fcd911 in > ffmpegthumbnailer::VideoThumbnailer::generateThumbnail(std::string const&, > ThumbnailerImageTypeEnum, std::string const&, AVFormatContext*) () > from /usr/lib/libffmpegthumbnailer.so.4 > #6 0x00007ffff5fce636 in video_thumbnailer_generate_thumbnail_to_file () > from /usr/lib/libffmpegthumbnailer.so.4 > #7 0x00000000004314e5 in ?? () > #8 0x00000000004319a0 in ?? () > #9 0x000000000042221f in ?? () > #10 0x00000000004310bb in ?? () > #11 0x0000000000430dd0 in ?? () > #12 0x00007ffff644ec95 in ?? () from /usr/lib/libglib-2.0.so.0 > #13 0x00007ffff5766124 in start_thread () from /usr/lib/libpthread.so.0 > #14 0x00007ffff549a4bd in clone () from /usr/lib/libc.so.6 > > Thanks, > Justin > matroskadec.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > b726d6b840582eee4f2503dc6c2d4a0a3a06ccfa 0001-NULL-check-Matroska-chapters-when-reading-header.patch > From 14c4bcd96e6677c93b730faf0b4bf296e12bfd79 Mon Sep 17 00:00:00 2001 > From: Justin Jacobs > Date: Wed, 6 Aug 2014 20:04:38 -0400 > Subject: [PATCH] NULL-check Matroska chapters when reading header patch applied note, iam still interrested in a testcase/file! thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB During times of universal deceit, telling the truth becomes a revolutionary act. -- George Orwell -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From alessio at debian.org Fri Aug 8 16:06:20 2014 From: alessio at debian.org (Alessio Treglia) Date: Fri, 8 Aug 2014 15:06:20 +0100 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140808111329.GI15420@smurf.noris.de> References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> Message-ID: Hi, On Fri, Aug 8, 2014 at 12:13 PM, Matthias Urlichs wrote: > That leaves the question of the "official" opinion of the libav > maintainers (pkg-multimedia-maintainers at lists.alioth.debian.org). > Did none of them write anything in "defense" of libav, or have I simply > missed it? > > IMHO the best idea at this point would be to toss out libav, and rebuild > the rdeps with ffmpeg. Now, before it's too late for jessie. This is an eminently bad idea. As I said before, it's too late for Jessie already. Many Jessie's multimedia framework and packages have been developed and QA'd with libav. We've spent a lot of time over the past months talking to upstreams, forwarding them our patches and make sure their programs and libraries work with libav. We've spent ***months*** in making the whole thing work, and dropping libav in favour of FFmpeg at this point, roughly few weeks from the freeze deadline, would be definitely insane. Cheers. -- Alessio Treglia | www.alessiotreglia.com Debian Developer | alessio at debian.org Ubuntu Core Developer | quadrispro at ubuntu.com 0416 0004 A827 6E40 BB98 90FB E8A4 8AE5 311D 765A From matthias at urlichs.de Fri Aug 8 13:13:29 2014 From: matthias at urlichs.de (Matthias Urlichs) Date: Fri, 8 Aug 2014 13:13:29 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <53D64E31.9060701@googlemail.com> References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> Message-ID: <20140808111329.GI15420@smurf.noris.de> Hi, Andreas Cadhalpun: > Once FFmpeg is back in the archive, it'll be easy to reintroduce MPlayer. It > has been removed from sid, since it fails to build against Libav, but it > builds fine against FFmpeg. > (It uses some of the features only provided by FFmpeg.) > Yet another reason why solely depending on libav is a bad idea. That leaves the question of the "official" opinion of the libav maintainers (pkg-multimedia-maintainers at lists.alioth.debian.org). Did none of them write anything in "defense" of libav, or have I simply missed it? IMHO the best idea at this point would be to toss out libav, and rebuild the rdeps with ffmpeg. Now, before it's too late for jessie. -- -- Matthias Urlichs From matthias at urlichs.de Fri Aug 8 21:22:38 2014 From: matthias at urlichs.de (Matthias Urlichs) Date: Fri, 8 Aug 2014 21:22:38 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> Message-ID: <20140808192238.GJ15420@smurf.noris.de> Hi, Alessio Treglia: > We've spent a lot of time over the past months talking to upstreams, > forwarding them our patches and make sure their programs and libraries > work with libav. > We've spent ***months*** in making the whole thing work, and dropping > libav in favour of FFmpeg at this point, roughly few weeks from the > freeze deadline, would be definitely insane. > Yes, that work might be "wasted". But I don't think that it's a good idea to base the decision of whether or not X is better for Debian on the fact that somebody did a lot of work for Y instead. Yes, the freeze is not that far away. But frankly, how much effort would it be to switch now? As far as I can tell from this discussion, the answer is "not a whole lot". The bulk of ffmpeg/libav's reverse dependencies is just a simple binNMU away, and as the libraries seem to be co-installable we don't even need a big transition. We'd also benefit from the fact that Upstream tends to use FFmpeg. I'd hate to report some intractable codec bug which Upstream closes with an "it works with FFmpeg" comment -- what would you recommend me to do in that situation, next year -- install the ffmpeg libs from Experimental and rebuild the offender? -- -- Matthias Urlichs From hlszl1983 at 163.com Fri Aug 8 11:08:46 2014 From: hlszl1983 at 163.com (hlszl1983 at 163.com) Date: Fri, 8 Aug 2014 17:08:46 +0800 Subject: [FFmpeg-devel] A patch for gdigrab function Message-ID: <2014080817084593695941@163.com> hi, all I'm using gdigrab feature on windows, and found that the count of gdi objects owned by ffmpeg.exe increasing endlessly... Here is the patch, can someone commit it? ---------------------------------------------- diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c index bccfef2..e2bed14 100644 --- a/libavdevice/gdigrab.c +++ b/libavdevice/gdigrab.c @@ -451,6 +451,10 @@ static void paint_mouse_pointer(AVFormatContext *s1, struct gdigrab *gdigrab) icon = CopyCursor(LoadCursor(NULL, IDC_ARROW)); } + /*Remarks + *GetIconInfo creates bitmaps for the hbmMask and hbmColor members of ICONINFO. + *The calling application must manage these bitmaps and delete them when they are no longer necessary. + */ if (!GetIconInfo(icon, &info)) { CURSOR_ERROR("Could not get icon info"); goto icon_error; @@ -481,6 +485,10 @@ static void paint_mouse_pointer(AVFormatContext *s1, struct gdigrab *gdigrab) } icon_error: + if (info.hbmMask) + DeleteObject(info.hbmMask); + if(info.hbmColor) + DeleteObject(info.hbmColor); if (icon) DestroyCursor(icon); } else { hlszl1983 at 163.com From md at Linux.IT Fri Aug 8 14:25:01 2014 From: md at Linux.IT (Marco d'Itri) Date: Fri, 8 Aug 2014 14:25:01 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140808111329.GI15420@smurf.noris.de> References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> Message-ID: <20140808122501.GB31166@bongo.bofh.it> On Aug 08, Matthias Urlichs wrote: > IMHO the best idea at this point would be to toss out libav, and rebuild > the rdeps with ffmpeg. Now, before it's too late for jessie. Agreed. The interested parties should really raise this with the CTTE ASAP. -- ciao, Marco -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 648 bytes Desc: Digital signature URL: From cehoyos at ag.or.at Fri Aug 8 22:25:54 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Fri, 8 Aug 2014 20:25:54 +0000 (UTC) Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> Message-ID: Alessio Treglia debian.org> writes: > Many Jessie's multimedia framework and packages > have been developed and QA'd with libav. Could you name one framework or package that does not work with FFmpeg (or does not have less bugs with FFmpeg than with avconv libraries)? I have never tested GStreamer myself but several users reported that it compiles with FFmpeg and that using FFmpeg fixed their issues. Carl Eugen From nfxjfg at googlemail.com Sat Aug 9 01:11:45 2014 From: nfxjfg at googlemail.com (wm4) Date: Sat, 9 Aug 2014 01:11:45 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> Message-ID: <20140809011145.6b548c7c@debian> On Fri, 8 Aug 2014 15:06:20 +0100 Alessio Treglia wrote: > Hi, > > On Fri, Aug 8, 2014 at 12:13 PM, Matthias Urlichs wrote: > > That leaves the question of the "official" opinion of the libav > > maintainers (pkg-multimedia-maintainers at lists.alioth.debian.org). > > Did none of them write anything in "defense" of libav, or have I simply > > missed it? > > > > IMHO the best idea at this point would be to toss out libav, and rebuild > > the rdeps with ffmpeg. Now, before it's too late for jessie. > > This is an eminently bad idea. As I said before, it's too late for > Jessie already. > > Many Jessie's multimedia framework and packages have been developed > and QA'd with libav. > > We've spent a lot of time over the past months talking to upstreams, > forwarding them our patches and make sure their programs and libraries > work with libav. > We've spent ***months*** in making the whole thing work, and dropping > libav in favour of FFmpeg at this point, roughly few weeks from the > freeze deadline, would be definitely insane. I'm very interested in why packages would work with Libav, but not with FFmpeg. I know for a fact that FFmpeg API is more compatible in general (deprecated functionality is generally kept longer than in Libav, not all API Libav removed is removed from FFmpeg). And also, FFmpeg's API is a superset of Libav. So it could happen that a project doesn't work with Libav because it uses FFmpeg-exclusive API, but not the other way around. The only real incompatibilities I know are: - avfilter_graph_parse() function signature (can be fixed with some ifdeffery) - libavresample disabled by default (FFmpeg being trapped by their own bullshit, wonderful) Also, if does happen that software written for Libav works with the latest Libav release, but not the latest FFmpeg release. This is simply because Libav doesn't release as often, which increases the likelihood that this project didn't update to newer APIs yet. But since Libav 10 was released relatively recently, and Libav 11 is planned to be API-compatible, that should not be an issue currently. From kierank at obe.tv Sat Aug 9 02:45:22 2014 From: kierank at obe.tv (Kieran Kunhya) Date: Sat, 9 Aug 2014 01:45:22 +0100 Subject: [FFmpeg-devel] [PATCH] h264: Move AFD to side data to match MPEG-2 Message-ID: <1407545122-10766-1-git-send-email-kierank@obe.tv> --- libavcodec/h264.c | 11 +++++++++++ libavcodec/h264.h | 6 ++++++ libavcodec/h264_sei.c | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 8fa35c7..e77b633 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -883,6 +883,17 @@ static void decode_postinit(H264Context *h, int setup_finished) h->sei_vflip, h->sei_hflip); } + if (h->afd_present) { + AVFrameSideData *sd = + av_frame_new_side_data(&cur->f, + AV_FRAME_DATA_AFD, 1); + if (!sd) + return; + + *sd->data = h->afd; + h->afd_present = 0; + } + cur->mmco_reset = h->mmco_reset; h->mmco_reset = 0; diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 5ec4f0c..b7e7b04 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -682,6 +682,12 @@ typedef struct H264Context { int sei_hflip, sei_vflip; /** + * AFD + */ + int afd_present; + uint8_t afd; + + /** * Bit set of clock types for fields/frames in picture timing SEI message. * For each found ct_type, appropriate bit is set (e.g., bit 1 for * interlaced). diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index aa889b8..2d0212d 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -132,7 +132,13 @@ static int decode_user_data_itu_t_t35(H264Context *h, int size) return -1; skip_bits(&h->gb, 4); dtg_active_format = get_bits(&h->gb, 4); +#if FF_API_AFD +FF_DISABLE_DEPRECATION_WARNINGS h->avctx->dtg_active_format = dtg_active_format; +FF_ENABLE_DEPRECATION_WARNINGS +#endif /* FF_API_AFD */ + h->afd_present = 1; + h->afd = dtg_active_format; } else { skip_bits(&h->gb, 6); } -- 1.7.9.5 From dr at jones.dk Fri Aug 8 23:03:47 2014 From: dr at jones.dk (Jonas Smedegaard) Date: Fri, 08 Aug 2014 23:03:47 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140808192238.GJ15420@smurf.noris.de> References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> Message-ID: <20140808210347.3970.12508@bastian.jones.dk> Quoting Matthias Urlichs (2014-08-08 21:22:38) > Alessio Treglia: >> We've spent a lot of time over the past months talking to upstreams, >> forwarding them our patches and make sure their programs and >> libraries work with libav. >> We've spent ***months*** in making the whole thing work, and dropping >> libav in favour of FFmpeg at this point, roughly few weeks from the >> freeze deadline, would be definitely insane. >> > Yes, that work might be "wasted". But I don't think that it's a good > idea to base the decision of whether or not X is better for Debian on > the fact that somebody did a lot of work for Y instead. > > Yes, the freeze is not that far away. But frankly, how much effort > would it be to switch now? As far as I can tell from this discussion, > the answer is "not a whole lot". The bulk of ffmpeg/libav's reverse > dependencies is just a simple binNMU away, and as the libraries seem > to be co-installable we don't even need a big transition. > > We'd also benefit from the fact that Upstream tends to use FFmpeg. I'd > hate to report some intractable codec bug which Upstream closes with > an "it works with FFmpeg" comment -- what would you recommend me to do > in that situation, next year -- install the ffmpeg libs from > Experimental and rebuild the offender? I would recommend you to take into account who is actually going to maintain this in Debian. Perhaps those who've maintained libav in the past will loose interest if switching to FFmpeg (or that it will attract others who are far better at it or maintenance becomes much easier, but I doubt that). Just please distinguish between those in this thread telling what they do themselves and those (bogusly!) dictating others to do stuff. - Jonas -- * Jonas Smedegaard - idealist & Internet-arkitekt * Tlf.: +45 40843136 Website: http://dr.jones.dk/ [x] quote me freely [ ] ask before reusing [ ] keep private -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 949 bytes Desc: signature URL: From michaelni at gmx.at Sat Aug 9 03:32:22 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 9 Aug 2014 03:32:22 +0200 Subject: [FFmpeg-devel] [PATCH] write reel_name metadata to tmcd atom In-Reply-To: <1407519426-72919-2-git-send-email-mindmark@gmail.com> References: <1407519426-72919-1-git-send-email-mindmark@gmail.com> <1407519426-72919-2-git-send-email-mindmark@gmail.com> Message-ID: <20140809013222.GI12391@nb4> On Fri, Aug 08, 2014 at 10:37:06AM -0700, Mark Reid wrote: > --- > libavformat/movenc.c | 25 +++++++++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Rewriting code that is poorly written but fully understood is good. Rewriting code that one doesnt understand is a sign that one is less smart then the original author, trying to rewrite it will not make it better. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sat Aug 9 03:35:07 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 9 Aug 2014 03:35:07 +0200 Subject: [FFmpeg-devel] [PATCH] write reel_name metadata to tmcd atom In-Reply-To: <1407519426-72919-2-git-send-email-mindmark@gmail.com> References: <1407519426-72919-1-git-send-email-mindmark@gmail.com> <1407519426-72919-2-git-send-email-mindmark@gmail.com> Message-ID: <20140809013507.GJ12391@nb4> On Fri, Aug 08, 2014 at 10:37:06AM -0700, Mark Reid wrote: > --- > libavformat/movenc.c | 25 +++++++++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > index 86dbe7f..fe4413c 100644 > --- a/libavformat/movenc.c > +++ b/libavformat/movenc.c > @@ -1340,6 +1340,16 @@ static int mov_write_rtp_tag(AVIOContext *pb, MOVTrack *track) > return update_size(pb, pos); > } > > +static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack *track, const char *reel_name){ > + int64_t pos = avio_tell(pb); > + avio_wb32(pb, 0); /* size */ > + ffio_wfourcc(pb, "name"); /* Data format */ > + avio_wb16(pb, strlen(reel_name)); /* string size */ forgot but strictly speaking this requires a check on the strlen fitting in 16bit can you send a patch added a check with appropriate action ? thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the very wise cannot see all ends. -- Gandalf -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From jyavenard at gmail.com Sat Aug 9 03:46:40 2014 From: jyavenard at gmail.com (Jean-Yves Avenard) Date: Sat, 9 Aug 2014 11:46:40 +1000 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140808210347.3970.12508@bastian.jones.dk> References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> Message-ID: Hi. Only going to reply to some of the misinformation provided in the post from Reinhard Tartler (https://lists.debian.org/debian-devel/2014/08/msg00160.html) For the background: I am the de-facto maintainer of the MythTV's FFmpeg fork. > To the best of my knowledge, there are only two high-profile projects > that play hardball to require FFmpeg: Mplayer and mythtv. Neither of > those do that (again to the best of my knowledge) mainly because of > technical but rather very political reasons. The case of mplayer has > been elaborated extensively in > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732159#79 (see the > following "discussion" with Reimar - my conclusion from that is while > technically possible, nobody wants to make mplayer work with Libav - > and that's why it was removed, not because of the FFmpeg dependency). > For Mythtv I can only say that they didn't even bother engaging any > discussion. MythTV has always used its own internal fork of FFmpeg. I have been involved in this project for close to a decade, and not once during that time has MythTV been using a system libav*. What political reasons are you referring to? We were syncing against FFmpeg against before their childish fight started, we continued syncing against FFmpeg after that. No more no less. One of the core developer of LibAV is Janne Grunau, who was also a MythTV developer. He stopped being an active member of MythTV due to lack of time. MythTV do not work against stock FFmpeg and never will. We run a heavily modified version of FFmpeg, you can call it a fork. In particular, we use our own mpeg-ts demuxer, we support things like MHEG, DVB/ATSC/Teletext subtitles that FFmpeg do not. We have attempted for many years to get our changes merged in FFmpeg but gave up. You say MythTV didn't bother engaging any discussions? what discussions are you referring to ? I certainly have never been contacted by either teams. What I can recall however is me submitting an issue to both FFmpeg and LibAV trac. The problem was dismissed in LibAV and fixed within a couple of days in FFmpeg. LibAV had decided to totally remove some core APIs that we make use of (in this case it was fast mpeg decoding used by our commercial detection system). FFmpeg re-introduced it at our demand. FFmpeg also have kept the old VDPAU decoding API, LibAV removed it. As such, it is easier for us to sync against FFmpeg than it is against LibAV. I call this technical reasons. there's nothing political into it. FFmpeg cherry-pick or merge any changes occurring in LibAV in a matter of days. So by syncing against FFmpeg we enjoy the best of both worlds. To end this message: I fail to see how debian's decision on which version of FFmpeg or LibAV would have any impact on MythTV, we use neither From nfxjfg at googlemail.com Sat Aug 9 03:57:52 2014 From: nfxjfg at googlemail.com (wm4) Date: Sat, 9 Aug 2014 03:57:52 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> Message-ID: <20140809035752.26134092@debian> On Sat, 9 Aug 2014 11:46:40 +1000 Jean-Yves Avenard wrote: > MythTV do not work against stock FFmpeg and never will. We run a > heavily modified version of FFmpeg, you can call it a fork. > In particular, we use our own mpeg-ts demuxer, we support things like > MHEG, DVB/ATSC/Teletext subtitles that FFmpeg do not. > We have attempted for many years to get our changes merged in FFmpeg > but gave up. Off-topic, but: it might be easier nowadays? The strangest things that are not even related to video decoding are getting merged - surely it's possible to merge things such as teletext. From jyavenard at gmail.com Sat Aug 9 04:40:59 2014 From: jyavenard at gmail.com (Jean-Yves Avenard) Date: Sat, 9 Aug 2014 12:40:59 +1000 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian Message-ID: Hi On 9 August 2014 11:57, wm4 wrote: > On Sat, 9 Aug 2014 11:46:40 +1000 > Off-topic, but: it might be easier nowadays? > > The strangest things that are not even related to video decoding are > getting merged - surely it's possible to merge things such as teletext. In all honesty, we spent months trying to get our changes merge over the course of 10+ years... There's unfortunately a time where one gives up. This is the core reason why we started to maintain our own fork. We have now limited our changes to the bare minimum, and things have diverged greatly since. Backporting our changes to our mpegts demuxer would be significant work. And unfortunately, we are all very time constrained these days (and me even more so as I've started a new job at Mozilla) From tempn at mi.rr.com Sat Aug 9 07:28:05 2014 From: tempn at mi.rr.com (compn) Date: Sat, 9 Aug 2014 01:28:05 -0400 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: <53DFC9DC.1050207@snirklasjon.no> References: <53DFC9DC.1050207@snirklasjon.no> Message-ID: <20140809012805.00007dbf@mi.rr.com> On Mon, 04 Aug 2014 19:58:52 +0200 Gisle S?lensminde wrote: > I'm trying to add support for closed captions in ffmpeg, namely > cea608 and cea708. mythtv fork of ffmpeg has this support already. maybe we can port it (along with some other changes)? https://code.mythtv.org/trac/browser http://sprunge.us/HCKZ libavcodec/mpeg12dec.c // CEA-708/608 support libavcodec/mpegvideo.c // CEA-708/608 support libavutil/frame.c // CEA-708/608 AVFrame members addition -compn From nfxjfg at googlemail.com Sat Aug 9 07:50:41 2014 From: nfxjfg at googlemail.com (wm4) Date: Sat, 9 Aug 2014 07:50:41 +0200 Subject: [FFmpeg-devel] [RFC] Implementation of closed caption support In-Reply-To: <20140809012805.00007dbf@mi.rr.com> References: <53DFC9DC.1050207@snirklasjon.no> <20140809012805.00007dbf@mi.rr.com> Message-ID: <20140809075041.0421ecfc@debian> On Sat, 9 Aug 2014 01:28:05 -0400 compn wrote: > On Mon, 04 Aug 2014 19:58:52 +0200 > Gisle S?lensminde wrote: > > > I'm trying to add support for closed captions in ffmpeg, namely > > cea608 and cea708. > > mythtv fork of ffmpeg has this support already. maybe we can port it > (along with some other changes)? > > https://code.mythtv.org/trac/browser > > http://sprunge.us/HCKZ > > libavcodec/mpeg12dec.c // CEA-708/608 support > libavcodec/mpegvideo.c // CEA-708/608 support > libavutil/frame.c // CEA-708/608 AVFrame members addition > Diff for your entertainment: http://sprunge.us/gTcY From pb at das-werkstatt.com Sat Aug 9 10:57:55 2014 From: pb at das-werkstatt.com (Peter B.) Date: Sat, 09 Aug 2014 10:57:55 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140808192238.GJ15420@smurf.noris.de> References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> Message-ID: <53E5E293.3060709@das-werkstatt.com> On 08/08/2014 09:22 PM, Matthias Urlichs wrote: > We'd also benefit from the fact that Upstream tends to use FFmpeg. I'd > hate to report some intractable codec bug which Upstream closes with > an "it works with FFmpeg" comment Oh, btw, just a few days ago, that's exactly what happened on kdenlive [1]. A developer posted the following statement on an issue which is open for more than 1.5 years now: [quote] Confirm this is a libav problem, use builds with ffmpeg or wait debian (&derivatives) to bring ffmpeg back [/quote] Just thought this might fit here... Regards, Pb == References: [1] http://www.kdenlive.org/mantis/view.php?id=2943#c10195 From michaelni at gmx.at Sat Aug 9 14:56:19 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sat, 9 Aug 2014 14:56:19 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec/options_table: leave xvidmmx AVOption in place Message-ID: <1407588979-10668-1-git-send-email-michaelni@gmx.at> Also mark it as deprecated through its help text Signed-off-by: Michael Niedermayer --- libavcodec/options_table.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 1c73aff..2e9dfa0 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -224,9 +224,7 @@ static const AVOption avcodec_options[] = { {"ipp", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_IPP }, INT_MIN, INT_MAX, V|E|D, "idct"}, #endif /* FF_API_UNUSED_MEMBERS */ {"xvid", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_XVID }, INT_MIN, INT_MAX, V|E|D, "idct"}, -#if FF_API_IDCT_XVIDMMX -{"xvidmmx", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_XVID }, INT_MIN, INT_MAX, V|E|D, "idct"}, -#endif /* FF_API_IDCT_XVIDMMX */ +{"xvidmmx", "deprecated, for compatibility only", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_XVID }, INT_MIN, INT_MAX, V|E|D, "idct"}, {"faani", "floating point AAN IDCT", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_FAAN }, INT_MIN, INT_MAX, V|D|E, "idct"}, {"simpleauto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEAUTO }, INT_MIN, INT_MAX, V|E|D, "idct"}, {"slice_count", NULL, OFFSET(slice_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, -- 1.7.9.5 From matthias at urlichs.de Sat Aug 9 09:03:17 2014 From: matthias at urlichs.de (Matthias Urlichs) Date: Sat, 9 Aug 2014 09:03:17 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> Message-ID: <20140809070317.GL1627@smurf.noris.de> Hi, Jean-Yves Avenard: > We have attempted for many years to get our changes merged in FFmpeg > but gave up. > It might be a good idea to restart this effort. > To end this message: I fail to see how debian's decision on which > version of FFmpeg or LibAV would have any impact on MythTV, we use > neither Most forks cause additional work which, in the long term, is better spent elsewhere. The ffmpeg/libav split is ample proof of that; in an ideal world, you wouldn't need the mythtv fork either. Debian's position is that we _really_ want to avoid having multiple copies of essentially the same code in the archive; it's additional work for the security team (if they even know about the copies), needlessly eats memory when the two are in use simultaneously, and causes no end of trouble when a plug-in is linked against copy A while the main code (or another plugin) uses copy B (unless everybody is very careful WRT symbol versioning). -- -- Matthias Urlichs From kierank at obe.tv Sat Aug 9 19:26:19 2014 From: kierank at obe.tv (Kieran Kunhya) Date: Sat, 9 Aug 2014 18:26:19 +0100 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140809070317.GL1627@smurf.noris.de> References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> Message-ID: > Most forks cause additional work which, in the long term, is better spent > elsewhere. The ffmpeg/libav split is ample proof of that; in an ideal > world, you wouldn't need the mythtv fork either. > > Debian's position is that we _really_ want to avoid having multiple copies > of essentially the same code in the archive; it's additional work for the > security team (if they even know about the copies), needlessly eats memory > when the two are in use simultaneously, and causes no end of trouble when a > plug-in is linked against copy A while the main code (or another plugin) > uses copy B (unless everybody is very careful WRT symbol versioning). The reality is that in the current state of affairs static linking is the *only* way you are guaranteed to have the features you expect and avoid ABI mismatches. It's very complicated when your users complain about bugs in an underlying library that is either too old on a system or the wrong flavour of the fork. Then your users have to rebuild a massive dependency chain to fix that bug or hope for the best in the future. We also use a fork specifically to work around very wasteful calculations in libswscale during 10-bit chroma conversion that involve multiplying a pixel by a 2^n value with 32-bit precision and then shifting that value down by n back to 16-bit precision (achieving nothing). The fix breaks other codepaths that we don't use but the performance gain is big enough to warrant a fork. FWIW I think debian should also enable libavresample. This code has been proven to be more robust internally and was designed by a larger group instead of libswresample which was basically one person (and literally appeared in git out of nowhere). Kieran From andreas.cadhalpun at googlemail.com Sat Aug 9 20:25:09 2014 From: andreas.cadhalpun at googlemail.com (Andreas Cadhalpun) Date: Sat, 09 Aug 2014 20:25:09 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> Message-ID: <53E66785.4020703@googlemail.com> Hi Kieran, On 09.08.2014 19:26, Kieran Kunhya wrote: > The reality is that in the current state of affairs static linking is > the *only* way you are guaranteed to have the features you expect and > avoid ABI mismatches. It's very complicated when your users complain > about bugs in an underlying library that is either too old on a system > or the wrong flavour of the fork. Then your users have to rebuild a > massive dependency chain to fix that bug or hope for the best in the > future. I can understand that statically linking is easier from an upstream point of view, but it has important disadvantages for a distribution such as Debian and thus should be avoided if possible. It is also the responsibility of a distribution to make sure that there are no ABI mismatches or similar problems. > We also use a fork specifically to work around very wasteful > calculations in libswscale during 10-bit chroma conversion that > involve multiplying a pixel by a 2^n value with 32-bit precision and > then shifting that value down by n back to 16-bit precision (achieving > nothing). The fix breaks other codepaths that we don't use but the > performance gain is big enough to warrant a fork. Can you provide a commit/diff/link for reference? The way you describe it makes it appear as if these calculations are needed sometimes, but not always. If so, there should be away to teach libswscale to only do these calculations if they are necessary. > FWIW I think debian should also enable libavresample. This code has > been proven to be more robust internally and was designed by a larger > group instead of libswresample which was basically one person (and > literally appeared in git out of nowhere). FWIW I already enabled libavresample in the Debian FFmpeg package for compatibility reasons [1]. Still I would be interested in any proof of libavresample being 'more robust internally'. Best regards, Andreas 1: https://anonscm.debian.org/cgit/collab-maint/ffmpeg.git/commit/?id=e6d32135ec5ada648465aba8d4daad58b86ff8d0 From kierank at obe.tv Sat Aug 9 20:35:57 2014 From: kierank at obe.tv (Kieran Kunhya) Date: Sat, 9 Aug 2014 19:35:57 +0100 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <53E66785.4020703@googlemail.com> References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <53E66785.4020703@googlemail.com> Message-ID: On 9 August 2014 19:25, Andreas Cadhalpun wrote: > I can understand that statically linking is easier from an upstream point of > view, but it has important disadvantages for a distribution such as Debian > and thus should be avoided if possible. > It is also the responsibility of a distribution to make sure that there are > no ABI mismatches or similar problems. I'm not saying Debian should do that - just that it is sometimes worthwhile for people like myself and mythtv to do so. > Can you provide a commit/diff/link for reference? > The way you describe it makes it appear as if these calculations are needed > sometimes, but not always. If so, there should be away to teach libswscale > to only do these calculations if they are necessary. I hacked it in: https://github.com/kierank/ffmpeg-obe/commit/5a354020872bec61bea6be7604ec8809af463021 I made it a bit cleaner later but still ugly overall. Kieran From danieloberhoff at gmail.com Sat Aug 9 22:41:51 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Sat, 9 Aug 2014 22:41:51 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <20140808101019.GD12391@nb4> References: <20140801102233.GG10372@leki> <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> <20140808101019.GD12391@nb4> Message-ID: <189C1715-453C-4DC3-A5C4-75FFA1799163@googlemail.com> Am 08.08.2014 um 12:10 schrieb Michael Niedermayer : > On Thu, Aug 07, 2014 at 12:15:17AM +0200, Daniel Oberhoff wrote: >> >> Am 06.08.2014 um 12:12 schrieb Cl?ment B?sch : >> >>> On Sun, Aug 03, 2014 at 06:43:18PM +0200, Daniel Oberhoff wrote: >>> [...] >>>>>> +static av_cold int init(AVFilterContext *ctx) >>>>>> +{ >>>>>> + return 0; >>>>>> +} >>>>>> >>>>> >>>>> please remove this one, there is no point in having code that does nothing. >>>>> >>>>>> + >>>>>> +static av_cold void uninit(AVFilterContext *ctx) >>>>>> +{ >>>>>> +} >>>>>> + >>>>>> >>>>> >>>>> ditto >>>>> >>>> >>>> Done thanks! >>>> >>> >>> Did you forget to attach the latest version of the patch or I missed it >>> somewhere in the thread? >> >> Sorry, think that day I wanted to add something else before resubmit, and then lost the time. >> >> Here also with changes suggested by timothy. Note that the parametrization is now traditional >> (i.e. k1 and k2 are zero-based, as for example in the opencv documentation about calibration). >> >> From b798b95eb2f9ec4043b2407970d351cc31dd9e6a Mon Sep 17 00:00:00 2001 >> From: Daniel Oberhoff >> Date: Mon, 28 Jul 2014 23:58:12 +0200 >> Subject: [PATCH] avfilter: ported lenscorrection filter from frei0r >> >> --- >> Changelog | 2 +- >> MAINTAINERS | 1 + >> doc/filters.texi | 46 +++++++ >> libavfilter/Makefile | 1 + >> libavfilter/allfilters.c | 1 + >> libavfilter/version.h | 4 +- >> libavfilter/vf_lenscorrection.c | 199 +++++++++++++++++++++++++++ >> tests/fate/filter-video.mak | 3 + >> tests/ref/fate/filter-pixfmts-lenscorrection | 8 ++ >> 9 files changed, 262 insertions(+), 3 deletions(-) >> create mode 100644 libavfilter/vf_lenscorrection.c >> create mode 100644 tests/ref/fate/filter-pixfmts-lenscorrection >> > > This is missing a "Signed-off-by" from you So I what do I write there? >> diff --git a/Changelog b/Changelog >> index 25dd210..79393ce 100644 >> --- a/Changelog >> +++ b/Changelog >> @@ -3,7 +3,7 @@ releases are sorted from youngest to oldest. >> >> version : >> - Icecast protocol >> - >> +- ported lenscorrection filter from frei0r filter >> >> version 2.3: >> - AC3 fixed-point decoding >> diff --git a/MAINTAINERS b/MAINTAINERS >> index c383d3f..6948e22 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -354,6 +354,7 @@ Filters: >> vf_histogram.c Paul B Mahol >> vf_hqx.c Cl?ment B?sch >> vf_il.c Paul B Mahol >> + vf_lenscorrection.c Daniel Oberhoff >> vf_mergeplanes.c Paul B Mahol >> vf_psnr.c Paul B Mahol >> vf_scale.c Michael Niedermayer >> diff --git a/doc/filters.texi b/doc/filters.texi >> index 86feebc..c4888d3 100644 >> --- a/doc/filters.texi >> +++ b/doc/filters.texi >> @@ -5532,6 +5532,51 @@ kerndeint=map=1 >> @end example >> @end itemize >> >> + at section lenscorrection >> + >> +Correct radial lens distortion >> + >> +This filter can be used to correct for radial distortion as can result from the use >> +of wide angle lenses, and thereby re-rectify the image. To find the right parameters >> +one can use tools available for example as part of opencv or simply trial-and-error. >> +To use opencv use the calibration sample (under samples/cpp) from the opencv sources >> +and extract the k1 and k2 coefficients from the resulting matrix. >> + >> +Note that effectively the same filter is available in the open-source tools Krita and >> +Digikam from the KDE project. >> + >> +In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors, >> +this filter corrects the distortion of the image, whereas @ref{vignette} corrects the >> +brightness distribution, so you may want to use both filters together in certain >> +cases, though you will have to take care of ordering, i.e. whether vignetting should >> +be applied before or after lens correction. >> + >> + at subsection Options >> + >> +The filter accepts the following options: >> + >> + at table @option >> + at item cx >> +Relative x-coordinate of the focal point of the image, and thereby the center of the >> +distrortion. This value has a range [0,1] and is expressed as fractions of the image >> +width. >> + at item cy >> +Relative y-coordinate of the focal point of the image, and thereby the center of the >> +distrortion. This value has a range [0,1] and is expressed as fractions of the image >> +height. >> + at item k1 >> +Coefficient of the quadratic correction term. 0.5 means no correction. >> + at item k2 >> +Coefficient of the double quadratic correction term. 0.5 means no correction. >> + at end table >> + >> +The formula that generates the correction is: >> + >> + at var{r_src} = @var{r_tgt} * (1 + @var{k1} * (@var{r_tgt} / @var{r_0})^2 + @var{k2} * (@var{r_tgt} / @var{r_0})^4) >> + >> +where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the >> +distances from the focal point in the source and target images, respectively. >> + >> @anchor{lut3d} >> @section lut3d >> >> @@ -8744,6 +8789,7 @@ For example, to vertically flip a video with @command{ffmpeg}: >> ffmpeg -i in.avi -vf "vflip" out.avi >> @end example >> >> + at anchor{vignette} >> @section vignette >> >> Make or reverse a natural vignetting effect. >> diff --git a/libavfilter/Makefile b/libavfilter/Makefile >> index 0f54381..e9c8456 100644 >> --- a/libavfilter/Makefile >> +++ b/libavfilter/Makefile >> @@ -138,6 +138,7 @@ OBJS-$(CONFIG_IL_FILTER) += vf_il.o >> OBJS-$(CONFIG_INTERLACE_FILTER) += vf_interlace.o >> OBJS-$(CONFIG_INTERLEAVE_FILTER) += f_interleave.o >> OBJS-$(CONFIG_KERNDEINT_FILTER) += vf_kerndeint.o >> +OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o >> OBJS-$(CONFIG_LUT3D_FILTER) += vf_lut3d.o >> OBJS-$(CONFIG_LUT_FILTER) += vf_lut.o >> OBJS-$(CONFIG_LUTRGB_FILTER) += vf_lut.o >> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c >> index 1877557..b1d6ff5 100644 >> --- a/libavfilter/allfilters.c >> +++ b/libavfilter/allfilters.c >> @@ -156,6 +156,7 @@ void avfilter_register_all(void) >> REGISTER_FILTER(INTERLACE, interlace, vf); >> REGISTER_FILTER(INTERLEAVE, interleave, vf); >> REGISTER_FILTER(KERNDEINT, kerndeint, vf); >> + REGISTER_FILTER(LENSCORRECTION, lenscorrection, vf); >> REGISTER_FILTER(LUT3D, lut3d, vf); >> REGISTER_FILTER(LUT, lut, vf); >> REGISTER_FILTER(LUTRGB, lutrgb, vf); >> diff --git a/libavfilter/version.h b/libavfilter/version.h >> index 1a43dc5..47bac78 100644 >> --- a/libavfilter/version.h >> +++ b/libavfilter/version.h >> @@ -30,8 +30,8 @@ >> #include "libavutil/version.h" >> >> #define LIBAVFILTER_VERSION_MAJOR 4 >> -#define LIBAVFILTER_VERSION_MINOR 11 >> -#define LIBAVFILTER_VERSION_MICRO 102 >> +#define LIBAVFILTER_VERSION_MINOR 12 >> +#define LIBAVFILTER_VERSION_MICRO 100 >> >> #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ >> LIBAVFILTER_VERSION_MINOR, \ >> diff --git a/libavfilter/vf_lenscorrection.c b/libavfilter/vf_lenscorrection.c >> new file mode 100644 >> index 0000000..c2346db >> --- /dev/null >> +++ b/libavfilter/vf_lenscorrection.c >> @@ -0,0 +1,199 @@ >> +/* >> + * Copyright (C) 2007 Richard Spindler (author of frei0r plugin from which this was derived) >> + * Copyright (C) 2014 Daniel Oberhoff >> + * >> + * This file is part of FFmpeg. >> + * >> + * 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 >> + */ >> + >> +/** >> + * @file >> + * Lenscorrection filter, algorithm from the frei0r plugin with the same name >> +*/ >> +#include >> +#include >> + >> +#include "libavutil/opt.h" >> +#include "libavutil/intreadwrite.h" >> +#include "libavutil/pixdesc.h" >> + >> +#include "avfilter.h" >> +#include "internal.h" >> +#include "video.h" >> + >> +typedef struct LenscorrectionCtx { >> + const AVClass *av_class; >> + unsigned int width; >> + unsigned int height; >> + int hsub, vsub; >> + int nb_planes; >> + double cx, cy, k1, k2; >> +} LenscorrectionCtx; >> + >> +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM >> +static const AVOption lenscorrection_options[] = { >> + { "cx", "set relative center x", offsetof(LenscorrectionCtx, cx), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, >> + { "cy", "set relative center y", offsetof(LenscorrectionCtx, cy), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, >> + { "k1", "set quadratic distortion factor", offsetof(LenscorrectionCtx, k1), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, .flags=FLAGS }, >> + { "k2", "set double quadratic distortion factor", offsetof(LenscorrectionCtx, k2), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, .flags=FLAGS }, >> + { NULL } >> +}; >> + >> +AVFILTER_DEFINE_CLASS(lenscorrection); >> + >> +typedef struct ThreadData { >> + AVFrame *in, *out; >> + float w, h; >> + int plane; >> + float xcenter, ycenter; >> + float k1, k2; >> +} ThreadData; >> + >> +static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs) >> +{ >> + ThreadData *td = (ThreadData*)arg; >> + AVFrame *in = td->in; >> + AVFrame *out = td->out; >> + >> + const float w = td->w, h = td->h; >> + const float xcenter = td->xcenter; >> + const float ycenter = td->ycenter; >> + const float r2inv = 4.0 / (w * w + h * h); >> + const float k1 = td->k1; >> + const float k2 = td->k2; >> + const int start = (h * job ) / nb_jobs; >> + const int end = (h * (job+1)) / nb_jobs; >> + const int plane = td->plane; >> + const int inlinesize = in->linesize[plane]; >> + const int outlinesize = out->linesize[plane]; >> + const uint8_t *indata = in->data[plane]; >> + uint8_t *outrow = out->data[plane] + start * outlinesize; >> + int i; >> + for (i = start; i < end; i++, outrow += outlinesize) { >> + const float off_y = i - ycenter; >> + const float off_y2 = off_y * off_y; >> + uint8_t *out = outrow; >> + int j; >> + for (j = 0; j < w; j++) { >> + const float off_x = j - xcenter; >> + const float r2 = (off_x * off_x + off_y2) * r2inv; >> + const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2; >> + const int x = xcenter + radius_mult * off_x + 0.5f; >> + const int y = ycenter + radius_mult * off_y + 0.5f; >> + const char isvalid = x > 0 && x < w - 1 && y > 0 && y < h - 1; > >> + *out++ = isvalid ? indata[y * inlinesize + x] : 0; > > IMHO "nearest neighbour" resampling isnt a reasonable choice, if > thats the only choice the user has. So you want me to add other methods? I found nearest neighbor sufficient for our needs and using other methods seemed to slow the code down too much for us, but if you think the filter is unfit for ffmpeg otherwise I will add other methods. Up to what order would you say resampling options are required? > also md5 based regression tests and extensive use of floats are > unlikely to work together, different architectures/platforms or even > compiler versions might give you different results Sounds reasonable, so should I remove the tests then? Best Daniel From jamrial at gmail.com Sun Aug 10 02:04:32 2014 From: jamrial at gmail.com (James Almer) Date: Sat, 9 Aug 2014 21:04:32 -0300 Subject: [FFmpeg-devel] [PATCH 1/4] lavc: stop exporting internal functions and tables Message-ID: <1407629075-13514-1-git-send-email-jamrial@gmail.com> Signed-off-by: James Almer --- libavcodec/libavcodec.v | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/libavcodec/libavcodec.v b/libavcodec/libavcodec.v index be74cb3..c923cd3 100644 --- a/libavcodec/libavcodec.v +++ b/libavcodec/libavcodec.v @@ -3,23 +3,5 @@ LIBAVCODEC_$MAJOR { #deprecated, remove after next bump audio_resample; audio_resample_close; - ff_raw_pix_fmt_tags; - ff_fft*; - ff_mdct*; - ff_dct*; - ff_rdft*; - ff_prores_idct_put_10_sse2; - ff_simple_idct*; - ff_aanscales; - ff_faan*; - ff_fdct*; - ff_idct_xvid*; - ff_jpeg_fdct*; - ff_dnxhd_get_cid_table; - ff_dnxhd_cid_table; - ff_idctdsp_init; - ff_fdctdsp_init; - ff_pixblockdsp_init; - ff_me_cmp_init; local: *; }; -- 1.8.5.5 From jamrial at gmail.com Sun Aug 10 02:04:33 2014 From: jamrial at gmail.com (James Almer) Date: Sat, 9 Aug 2014 21:04:33 -0300 Subject: [FFmpeg-devel] [PATCH 2/4] lavf: stop exporting internal functions In-Reply-To: <1407629075-13514-1-git-send-email-jamrial@gmail.com> References: <1407629075-13514-1-git-send-email-jamrial@gmail.com> Message-ID: <1407629075-13514-2-git-send-email-jamrial@gmail.com> Except for those currently used by ffserver. Signed-off-by: James Almer --- libavformat/libavformat.v | 9 --------- 1 file changed, 9 deletions(-) diff --git a/libavformat/libavformat.v b/libavformat/libavformat.v index 8243994..a00a309 100644 --- a/libavformat/libavformat.v +++ b/libavformat/libavformat.v @@ -3,9 +3,6 @@ LIBAVFORMAT_$MAJOR { #FIXME those are for ffserver ff_inet_aton; ff_socket_nonblock; - ff_mpegts_parse_close; - ff_mpegts_parse_open; - ff_mpegts_parse_packet; ff_rtsp_parse_line; ff_rtp_get_local_rtp_port; ff_rtp_get_local_rtcp_port; @@ -13,14 +10,8 @@ LIBAVFORMAT_$MAJOR { ffio_set_buf_size; ffurl_close; ffurl_open; - ffurl_read_complete; - ffurl_seek; - ffurl_size; ffurl_write; - ffurl_protocol_next; #those are deprecated, remove on next bump url_feof; - get_*; - ff_codec_get_id; local: *; }; -- 1.8.5.5 From jamrial at gmail.com Sun Aug 10 02:04:34 2014 From: jamrial at gmail.com (James Almer) Date: Sat, 9 Aug 2014 21:04:34 -0300 Subject: [FFmpeg-devel] [PATCH 3/4] lavfi: stop exporting internal functions In-Reply-To: <1407629075-13514-1-git-send-email-jamrial@gmail.com> References: <1407629075-13514-1-git-send-email-jamrial@gmail.com> Message-ID: <1407629075-13514-3-git-send-email-jamrial@gmail.com> Signed-off-by: James Almer --- libavfilter/libavfilter.v | 1 - 1 file changed, 1 deletion(-) diff --git a/libavfilter/libavfilter.v b/libavfilter/libavfilter.v index a3d33a3..83e8887 100644 --- a/libavfilter/libavfilter.v +++ b/libavfilter/libavfilter.v @@ -1,5 +1,4 @@ LIBAVFILTER_$MAJOR { global: avfilter_*; av_*; - ff_default_query_formats; local: *; }; -- 1.8.5.5 From jamrial at gmail.com Sun Aug 10 02:04:35 2014 From: jamrial at gmail.com (James Almer) Date: Sat, 9 Aug 2014 21:04:35 -0300 Subject: [FFmpeg-devel] [PATCH 4/4] lavu: stop exporting internal functions In-Reply-To: <1407629075-13514-1-git-send-email-jamrial@gmail.com> References: <1407629075-13514-1-git-send-email-jamrial@gmail.com> Message-ID: <1407629075-13514-4-git-send-email-jamrial@gmail.com> Signed-off-by: James Almer --- libavutil/libavutil.v | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/libavutil.v b/libavutil/libavutil.v index eb16ae1..e9f04cb 100644 --- a/libavutil/libavutil.v +++ b/libavutil/libavutil.v @@ -1,4 +1,4 @@ LIBAVUTIL_$MAJOR { - global: av*; ff_*; + global: av*; local: *; }; -- 1.8.5.5 From jamrial at gmail.com Sun Aug 10 02:53:33 2014 From: jamrial at gmail.com (James Almer) Date: Sat, 9 Aug 2014 21:53:33 -0300 Subject: [FFmpeg-devel] [PATCH] tools/fourcc2pixfmt: use avpriv_get_raw_pix_fmt_tags() Message-ID: <1407632013-13918-1-git-send-email-jamrial@gmail.com> lavc doesn't export ff_raw_pix_fmt_tags[] anymore. Signed-off-by: James Almer --- tools/fourcc2pixfmt.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/fourcc2pixfmt.c b/tools/fourcc2pixfmt.c index 1cfdf6a..625f531 100644 --- a/tools/fourcc2pixfmt.c +++ b/tools/fourcc2pixfmt.c @@ -47,14 +47,14 @@ static void usage(void) "-h print this help\n"); } -static void print_pix_fmt_fourccs(enum AVPixelFormat pix_fmt, char sep) +static void print_pix_fmt_fourccs(enum AVPixelFormat pix_fmt, const PixelFormatTag *pix_fmt_tags, char sep) { int i; - for (i = 0; ff_raw_pix_fmt_tags[i].pix_fmt != AV_PIX_FMT_NONE; i++) { - if (ff_raw_pix_fmt_tags[i].pix_fmt == pix_fmt) { + for (i = 0; pix_fmt_tags[i].pix_fmt != AV_PIX_FMT_NONE; i++) { + if (pix_fmt_tags[i].pix_fmt == pix_fmt) { char buf[32]; - av_get_codec_tag_string(buf, sizeof(buf), ff_raw_pix_fmt_tags[i].fourcc); + av_get_codec_tag_string(buf, sizeof(buf), pix_fmt_tags[i].fourcc); printf("%s%c", buf, sep); } } @@ -63,6 +63,7 @@ static void print_pix_fmt_fourccs(enum AVPixelFormat pix_fmt, char sep) int main(int argc, char **argv) { int i, list_fourcc_pix_fmt = 0, list_pix_fmt_fourccs = 0; + const PixelFormatTag *pix_fmt_tags = avpriv_get_raw_pix_fmt_tags(); const char *pix_fmt_name = NULL; char c; @@ -92,10 +93,10 @@ int main(int argc, char **argv) } if (list_fourcc_pix_fmt) { - for (i = 0; ff_raw_pix_fmt_tags[i].pix_fmt != AV_PIX_FMT_NONE; i++) { + for (i = 0; pix_fmt_tags[i].pix_fmt != AV_PIX_FMT_NONE; i++) { char buf[32]; - av_get_codec_tag_string(buf, sizeof(buf), ff_raw_pix_fmt_tags[i].fourcc); - printf("%s: %s\n", buf, av_get_pix_fmt_name(ff_raw_pix_fmt_tags[i].pix_fmt)); + av_get_codec_tag_string(buf, sizeof(buf), pix_fmt_tags[i].fourcc); + printf("%s: %s\n", buf, av_get_pix_fmt_name(pix_fmt_tags[i].pix_fmt)); } } @@ -105,7 +106,7 @@ int main(int argc, char **argv) if (!pix_desc->name || pix_desc->flags & AV_PIX_FMT_FLAG_HWACCEL) continue; printf("%s: ", pix_desc->name); - print_pix_fmt_fourccs(i, ' '); + print_pix_fmt_fourccs(i, pix_fmt_tags, ' '); printf("\n"); } } @@ -116,7 +117,7 @@ int main(int argc, char **argv) fprintf(stderr, "Invalid pixel format selected '%s'\n", pix_fmt_name); return 1; } - print_pix_fmt_fourccs(pix_fmt, '\n'); + print_pix_fmt_fourccs(pix_fmt, pix_fmt_tags, '\n'); } return 0; -- 1.8.5.5 From jamrial at gmail.com Sun Aug 10 03:01:46 2014 From: jamrial at gmail.com (James Almer) Date: Sat, 9 Aug 2014 22:01:46 -0300 Subject: [FFmpeg-devel] [PATCH 1/2] lavc/raw: remove obsolete ff_raw_pix_fmt_tags cruft Message-ID: <1407632507-14003-1-git-send-email-jamrial@gmail.com> Signed-off-by: James Almer --- libavcodec/raw.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavcodec/raw.h b/libavcodec/raw.h index a79b851..24bf4cc 100644 --- a/libavcodec/raw.h +++ b/libavcodec/raw.h @@ -35,11 +35,7 @@ typedef struct PixelFormatTag { unsigned int fourcc; } PixelFormatTag; -#if LIBAVCODEC_VERSION_MAJOR < 56 -extern av_export const PixelFormatTag ff_raw_pix_fmt_tags[]; -#else extern const PixelFormatTag ff_raw_pix_fmt_tags[]; // exposed through avpriv_get_raw_pix_fmt_tags() -#endif const struct PixelFormatTag *avpriv_get_raw_pix_fmt_tags(void); -- 1.8.5.5 From jamrial at gmail.com Sun Aug 10 03:01:47 2014 From: jamrial at gmail.com (James Almer) Date: Sat, 9 Aug 2014 22:01:47 -0300 Subject: [FFmpeg-devel] [PATCH 2/2] lavf/mpegts: remove obsolete ff_mpegts_parse_* cruft In-Reply-To: <1407632507-14003-1-git-send-email-jamrial@gmail.com> References: <1407632507-14003-1-git-send-email-jamrial@gmail.com> Message-ID: <1407632507-14003-2-git-send-email-jamrial@gmail.com> Signed-off-by: James Almer --- libavformat/mpegts.c | 18 ------------------ libavformat/mpegts.h | 7 ------- 2 files changed, 25 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index a2456a3..d2a2531 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2675,24 +2675,6 @@ void avpriv_mpegts_parse_close(MpegTSContext *ts) av_free(ts); } -#if LIBAVFORMAT_VERSION_MAJOR < 56 -MpegTSContext *ff_mpegts_parse_open(AVFormatContext *s) -{ - return avpriv_mpegts_parse_open(s); -} - -int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, - const uint8_t *buf, int len) -{ - return avpriv_mpegts_parse_packet(ts, pkt, buf, len); -} - -void ff_mpegts_parse_close(MpegTSContext *ts) -{ - avpriv_mpegts_parse_close(ts); -} -#endif - AVInputFormat ff_mpegts_demuxer = { .name = "mpegts", .long_name = NULL_IF_CONFIG_SMALL("MPEG-TS (MPEG-2 Transport Stream)"), diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h index 1cd1ba1..84f3098 100644 --- a/libavformat/mpegts.h +++ b/libavformat/mpegts.h @@ -68,13 +68,6 @@ int avpriv_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len); void avpriv_mpegts_parse_close(MpegTSContext *ts); -#if LIBAVFORMAT_VERSION_MAJOR < 56 -MpegTSContext *ff_mpegts_parse_open(AVFormatContext *s); -int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, - const uint8_t *buf, int len); -void ff_mpegts_parse_close(MpegTSContext *ts); -#endif - typedef struct SLConfigDescr { int use_au_start; int use_au_end; -- 1.8.5.5 From michaelni at gmx.at Sun Aug 10 05:02:31 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 05:02:31 +0200 Subject: [FFmpeg-devel] [PATCH 3/4] lavfi: stop exporting internal functions In-Reply-To: <1407629075-13514-3-git-send-email-jamrial@gmail.com> References: <1407629075-13514-1-git-send-email-jamrial@gmail.com> <1407629075-13514-3-git-send-email-jamrial@gmail.com> Message-ID: <20140810030231.GL12391@nb4> On Sat, Aug 09, 2014 at 09:04:34PM -0300, James Almer wrote: > Signed-off-by: James Almer > --- > libavfilter/libavfilter.v | 1 - > 1 file changed, 1 deletion(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 10 05:02:52 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 05:02:52 +0200 Subject: [FFmpeg-devel] [PATCH] tools/fourcc2pixfmt: use avpriv_get_raw_pix_fmt_tags() In-Reply-To: <1407632013-13918-1-git-send-email-jamrial@gmail.com> References: <1407632013-13918-1-git-send-email-jamrial@gmail.com> Message-ID: <20140810030252.GM12391@nb4> On Sat, Aug 09, 2014 at 09:53:33PM -0300, James Almer wrote: > lavc doesn't export ff_raw_pix_fmt_tags[] anymore. > > Signed-off-by: James Almer > --- > tools/fourcc2pixfmt.c | 19 ++++++++++--------- > 1 file changed, 10 insertions(+), 9 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The educated differ from the uneducated as much as the living from the dead. -- Aristotle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From kierank at obe.tv Sun Aug 10 05:17:09 2014 From: kierank at obe.tv (Kieran Kunhya) Date: Sun, 10 Aug 2014 04:17:09 +0100 Subject: [FFmpeg-devel] [PATCH] avcodec: Instruct users to align buffers to 32-byte. Message-ID: <1407640629-30026-1-git-send-email-kierank@obe.tv> The Opus decoder in particular uses optimised float_dsp functions that expect 32-byte alignment --- libavcodec/avcodec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 93aad35..5cbc175 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1880,7 +1880,7 @@ typedef struct AVCodecContext { * avcodec_default_get_buffer() instead of providing buffers allocated by * some other means. * - * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't + * AVFrame.data[] should be 32-byte-aligned unless the CPU doesn't * need it. avcodec_default_get_buffer() aligns the output buffer properly, * but if get_buffer() is overridden then alignment considerations should * be taken into account. -- 1.7.9.5 From jamrial at gmail.com Sun Aug 10 07:24:01 2014 From: jamrial at gmail.com (James Almer) Date: Sun, 10 Aug 2014 02:24:01 -0300 Subject: [FFmpeg-devel] [PATCH] x86/dca: remove unused header Message-ID: <1407648241-29525-1-git-send-email-jamrial@gmail.com> Signed-off-by: James Almer --- libavcodec/x86/dca.h | 60 ---------------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 libavcodec/x86/dca.h diff --git a/libavcodec/x86/dca.h b/libavcodec/x86/dca.h deleted file mode 100644 index c9be50d..0000000 --- a/libavcodec/x86/dca.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2012-2014 Christophe Gisquet - * - * This file is part of FFmpeg. - * - * 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 - */ - -#ifndef AVCODEC_X86_DCA_H -#define AVCODEC_X86_DCA_H - -#include "config.h" - -#if ARCH_X86_64 && HAVE_SSE2_INLINE -# include "libavutil/x86/asm.h" -# include "libavutil/mem.h" -#include "libavcodec/dcadsp.h" - -# define int8x8_fmul_int32 int8x8_fmul_int32 -static inline void int8x8_fmul_int32(av_unused DCADSPContext *dsp, - float *dst, const int8_t *src, int scale) -{ - DECLARE_ALIGNED(16, static const uint32_t, inverse16) = 0x3D800000; - __asm__ volatile ( - "cvtsi2ss %2, %%xmm0 \n\t" - "mulss %3, %%xmm0 \n\t" - "movq (%1), %%xmm1 \n\t" - "punpcklbw %%xmm1, %%xmm1 \n\t" - "movaps %%xmm1, %%xmm2 \n\t" - "punpcklwd %%xmm1, %%xmm1 \n\t" - "punpckhwd %%xmm2, %%xmm2 \n\t" - "psrad $24, %%xmm1 \n\t" - "psrad $24, %%xmm2 \n\t" - "shufps $0, %%xmm0, %%xmm0 \n\t" - "cvtdq2ps %%xmm1, %%xmm1 \n\t" - "cvtdq2ps %%xmm2, %%xmm2 \n\t" - "mulps %%xmm0, %%xmm1 \n\t" - "mulps %%xmm0, %%xmm2 \n\t" - "movaps %%xmm1, 0(%0) \n\t" - "movaps %%xmm2, 16(%0) \n\t" - :: "r"(dst), "r"(src), "m"(scale), "m"(inverse16) - XMM_CLOBBERS_ONLY("xmm0", "xmm1", "xmm2") - ); -} - -#endif /* ARCH_X86_64 && HAVE_SSE2_INLINE */ - -#endif /* AVCODEC_X86_DCA_H */ -- 1.8.5.5 From jyavenard at gmail.com Sun Aug 10 07:50:28 2014 From: jyavenard at gmail.com (Jean-Yves Avenard) Date: Sun, 10 Aug 2014 15:50:28 +1000 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140809070317.GL1627@smurf.noris.de> References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> Message-ID: On 9 August 2014 17:03, Matthias Urlichs wrote: > Most forks cause additional work which, in the long term, is better spent > elsewhere. The ffmpeg/libav split is ample proof of that; in an ideal > world, you wouldn't need the mythtv fork either. > > Debian's position is that we _really_ want to avoid having multiple copies > of essentially the same code in the archive; it's additional work for the > security team (if they even know about the copies), needlessly eats memory > when the two are in use simultaneously, and causes no end of trouble when a > plug-in is linked against copy A while the main code (or another plugin) > uses copy B (unless everybody is very careful WRT symbol versioning). I beg to differ. What would be a massive amount of waste, both in time and resources, would be to have a project such as MythTV having to handle multiple versions of a dependency. Especially one such as libav* where the API changes often, and more often than not in a totally incompatible manner from one API to the next. Including rename of constants (code enums id for example). You would have to keep your own headers (like what Firefox/Mozilla is doing) and have multiple code paths only adding to the difficulty of proper coverage testing... Keeping your own static version is the only reasonable approach. As far as naming and conflicts, I don't see what the problem is unless it's improperly packaged, or for example when the packagers decide that they know better than the original authors and start to do weird thing, modify the code as they wish. That's where the issues are most of the time. Sounds familiar ? :) From jyavenard at gmail.com Sun Aug 10 10:48:35 2014 From: jyavenard at gmail.com (Jean-Yves Avenard) Date: Sun, 10 Aug 2014 18:48:35 +1000 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140810070126.GR1627@smurf.noris.de> References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <20140810070126.GR1627@smurf.noris.de> Message-ID: Hi On 10 August 2014 17:01, Matthias Urlichs wrote: > Hi, > > > IMHO it's reasonable to expect core APIs to be upwards-compatible and keep > deprecated interfaces around for another release or two. > Then it becomes unreasonable for a piece of software to be compatible with multiple version of the same library, and support all of those. When a used come to use complaining that something is broken, that a file doesn't play or what else. It's a moot point trying to expect them to understand that the issue is due to a 3rd party library. MythTV aimed to be an appliance-like application. You install it and you forget about it. From jyavenard at gmail.com Sun Aug 10 11:14:50 2014 From: jyavenard at gmail.com (Jean-Yves Avenard) Date: Sun, 10 Aug 2014 19:14:50 +1000 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <20140810070126.GR1627@smurf.noris.de> Message-ID: On 10 August 2014 18:53, Andrew Kelley wrote: > IMO it's not worth the effort to support multiple versions of the same > library. If you want to use an old library, use an old version of the > software. In our case, we have very long release cycles. Usually only once a year at best. We have users on virtually all platforms. We can't assume the OS/distribution it will be running on will have the library we're hoping for. In the perfect world, sure all platforms would all be running the same versions of a given lib at a given time... In practice it never happens. From christophe.gisquet at gmail.com Sun Aug 10 11:59:08 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Sun, 10 Aug 2014 11:59:08 +0200 Subject: [FFmpeg-devel] [PATCH] hevc: fix incorrect sao buffer size Message-ID: This fixes ticket #3839. -- Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-hevc-fix-incorrect-sao-buffer-size.patch Type: text/x-patch Size: 1286 bytes Desc: not available URL: From christophe.gisquet at gmail.com Sun Aug 10 12:04:03 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Sun, 10 Aug 2014 12:04:03 +0200 Subject: [FFmpeg-devel] [PATCH] hevc_ps: verify P/T/L information Message-ID: Hi, the attached patch is a half-baked attempt at checking the input. I suspect there are a lot of places where little to no validation is performed anyway. Maybe it would be wise to mark hevc as experimental for now ? -- Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-hevc_ps-verify-P-T-L-information.patch Type: text/x-patch Size: 3903 bytes Desc: not available URL: From christophe.gisquet at gmail.com Sun Aug 10 12:09:44 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Sun, 10 Aug 2014 12:09:44 +0200 Subject: [FFmpeg-devel] [PATCH] hevc: fix incorrect sao buffer size In-Reply-To: References: Message-ID: Hi, 2014-08-10 11:59 GMT+02:00 Christophe Gisquet : > This fixes ticket #3839. By the way, not completely sure, but that is probably exploitable (I am not a security expert): - indicate large cropping in the header; this will cause an overrun of probably (max_ctb_size-1) lines (ie ~118KB for a 1920x??? sequence) - the memcpy will then copy data past the buffer for the aforementioned overrun; - if the stream uses icpm, you can put arbitrary data in the stream if I'm not mistaken. -- Christophe From michaelni at gmx.at Sun Aug 10 12:10:36 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 12:10:36 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec: Instruct users to align buffers to 32-byte. In-Reply-To: <1407640629-30026-1-git-send-email-kierank@obe.tv> References: <1407640629-30026-1-git-send-email-kierank@obe.tv> Message-ID: <20140810101036.GN12391@nb4> On Sun, Aug 10, 2014 at 04:17:09AM +0100, Kieran Kunhya wrote: > The Opus decoder in particular uses optimised float_dsp functions that expect 32-byte alignment > --- > libavcodec/avcodec.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > index 93aad35..5cbc175 100644 > --- a/libavcodec/avcodec.h > +++ b/libavcodec/avcodec.h > @@ -1880,7 +1880,7 @@ typedef struct AVCodecContext { > * avcodec_default_get_buffer() instead of providing buffers allocated by > * some other means. > * > - * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't > + * AVFrame.data[] should be 32-byte-aligned unless the CPU doesn't > * need it. avcodec_default_get_buffer() aligns the output buffer properly, > * but if get_buffer() is overridden then alignment considerations should > * be taken into account. either something like this, or the affected dsp functions could be given support to handle unaligned parameters Iam fine with either, its mostly a question what the people prefer. supporting <32byte aligned might require some changes though [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 10 12:37:01 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 12:37:01 +0200 Subject: [FFmpeg-devel] [PATCH] hevc: fix incorrect sao buffer size In-Reply-To: References: Message-ID: <20140810103701.GO12391@nb4> On Sun, Aug 10, 2014 at 11:59:08AM +0200, Christophe Gisquet wrote: > This fixes ticket #3839. > > -- > Christophe > hevc.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > c80c52a6aacdb596af7c66a961a5887c4cdfb348 0001-hevc-fix-incorrect-sao-buffer-size.patch > From 3745a3b611159f6a373785b67cbc92d4b36af44b Mon Sep 17 00:00:00 2001 > From: Christophe Gisquet > Date: Sun, 10 Aug 2014 11:43:12 +0200 > Subject: [PATCH] hevc: fix incorrect sao buffer size > > It previously used the output, cropped size, causing overreads/writes. > > Fixes ticket #3839. applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is what and why we do it that matters, not just one of them. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From nfxjfg at googlemail.com Sun Aug 10 13:19:15 2014 From: nfxjfg at googlemail.com (wm4) Date: Sun, 10 Aug 2014 13:19:15 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <53E66785.4020703@googlemail.com> References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <53E66785.4020703@googlemail.com> Message-ID: <20140810131915.501eba7f@debian> On Sat, 09 Aug 2014 20:25:09 +0200 Andreas Cadhalpun wrote: > Hi Kieran, > > On 09.08.2014 19:26, Kieran Kunhya wrote: > > The reality is that in the current state of affairs static linking is > > the *only* way you are guaranteed to have the features you expect and > > avoid ABI mismatches. It's very complicated when your users complain > > about bugs in an underlying library that is either too old on a system > > or the wrong flavour of the fork. Then your users have to rebuild a > > massive dependency chain to fix that bug or hope for the best in the > > future. > > I can understand that statically linking is easier from an upstream > point of view, but it has important disadvantages for a distribution > such as Debian and thus should be avoided if possible. > It is also the responsibility of a distribution to make sure that there > are no ABI mismatches or similar problems. > > > We also use a fork specifically to work around very wasteful > > calculations in libswscale during 10-bit chroma conversion that > > involve multiplying a pixel by a 2^n value with 32-bit precision and > > then shifting that value down by n back to 16-bit precision (achieving > > nothing). The fix breaks other codepaths that we don't use but the > > performance gain is big enough to warrant a fork. > > Can you provide a commit/diff/link for reference? > The way you describe it makes it appear as if these calculations are > needed sometimes, but not always. If so, there should be away to teach > libswscale to only do these calculations if they are necessary. > > > FWIW I think debian should also enable libavresample. This code has > > been proven to be more robust internally and was designed by a larger > > group instead of libswresample which was basically one person (and > > literally appeared in git out of nowhere). > > FWIW I already enabled libavresample in the Debian FFmpeg package for > compatibility reasons [1]. That's pretty nice! Maybe now people don't have to deal with two extremely similar yet slightly different resampling libraries. It really takes the cake when you try making your software work with both FFmpeg and Libav. Unfortunately, FFmpeg vehemently resists against enabling lavr by default. > Still I would be interested in any proof of libavresample being 'more > robust internally'. > > Best regards, > Andreas > > 1: > https://anonscm.debian.org/cgit/collab-maint/ffmpeg.git/commit/?id=e6d32135ec5ada648465aba8d4daad58b86ff8d0 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From george at nsup.org Sun Aug 10 13:25:03 2014 From: george at nsup.org (Nicolas George) Date: Sun, 10 Aug 2014 13:25:03 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140810131915.501eba7f@debian> References: <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <53E66785.4020703@googlemail.com> <20140810131915.501eba7f@debian> Message-ID: <20140810112503.GA6168@phare.normalesup.org> Le tridi 23 thermidor, an CCXXII, wm4 a ?crit?: > Unfortunately, FFmpeg vehemently resists against enabling lavr by > default. If someone cared enough, they would be making their case: posting benchmarks, listing features present in each library but absent in the other, comparing the APIs to see which one is most convenient for which task, etc. Regards, -- Nicolas George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nfxjfg at googlemail.com Sun Aug 10 13:29:22 2014 From: nfxjfg at googlemail.com (wm4) Date: Sun, 10 Aug 2014 13:29:22 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140810112503.GA6168@phare.normalesup.org> References: <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <53E66785.4020703@googlemail.com> <20140810131915.501eba7f@debian> <20140810112503.GA6168@phare.normalesup.org> Message-ID: <20140810132922.18fde62b@debian> On Sun, 10 Aug 2014 13:25:03 +0200 Nicolas George wrote: > Le tridi 23 thermidor, an CCXXII, wm4 a ?crit?: > > Unfortunately, FFmpeg vehemently resists against enabling lavr by > > default. > > If someone cared enough, they would be making their case: posting > benchmarks, listing features present in each library but absent in the > other, comparing the APIs to see which one is most convenient for which > task, etc. You seem to be under the impression that this matters. I don't want to have to develop for two slightly similar but different APIs, the end. And I don't want anyone else having to do that either. You're welcome to add a lavr API wrapper to swr, or to merge swr features into lavr, or to convince Libav to pick up swr in favor of lavr - just don't torture me with your API wars, OK? From george at nsup.org Sun Aug 10 13:38:06 2014 From: george at nsup.org (Nicolas George) Date: Sun, 10 Aug 2014 13:38:06 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140810132922.18fde62b@debian> References: <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <53E66785.4020703@googlemail.com> <20140810131915.501eba7f@debian> <20140810112503.GA6168@phare.normalesup.org> <20140810132922.18fde62b@debian> Message-ID: <20140810113806.GA8711@phare.normalesup.org> Le tridi 23 thermidor, an CCXXII, wm4 a ?crit?: > You seem to be under the impression that this matters. That is the only thing that matters in FFmpeg: people work on what they consider important. > I don't want to have to develop for two slightly similar but > different APIs, the end. And I don't want anyone else having to do that > either. > > You're welcome to add a lavr API wrapper to swr, or to merge swr > features into lavr, or to convince Libav to pick up swr in favor of > lavr - just don't torture me with your API wars, OK? You demand a lot, but nobody has a duty to meet your demands. Yes, the situation with the two resampling libraries is bad for users, but it will only be resolved if someone who cares about it does the job. I do not. And as with the rest of FFmpeg, technical arguments will decide the course of the project. If you were to prove that lavr is superior to lswr, it would certainly be adopted. But nothing will happen if nobody steps in. Regards, -- Nicolas George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 10 14:04:02 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 14:04:02 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140810113806.GA8711@phare.normalesup.org> References: <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <53E66785.4020703@googlemail.com> <20140810131915.501eba7f@debian> <20140810112503.GA6168@phare.normalesup.org> <20140810132922.18fde62b@debian> <20140810113806.GA8711@phare.normalesup.org> Message-ID: <20140810120402.GP12391@nb4> On Sun, Aug 10, 2014 at 01:38:06PM +0200, Nicolas George wrote: > Le tridi 23 thermidor, an CCXXII, wm4 a ?crit?: > > You seem to be under the impression that this matters. > > That is the only thing that matters in FFmpeg: people work on what they > consider important. > > > I don't want to have to develop for two slightly similar but > > different APIs, the end. And I don't want anyone else having to do that > > either. > > > > You're welcome to add a lavr API wrapper to swr, or to merge swr > > features into lavr, or to convince Libav to pick up swr in favor of > > lavr - just don't torture me with your API wars, OK? > > You demand a lot, but nobody has a duty to meet your demands. > > Yes, the situation with the two resampling libraries is bad for users, but > it will only be resolved if someone who cares about it does the job. I do > not. And as with the rest of FFmpeg, technical arguments will decide the > course of the project. If you were to prove that lavr is superior to lswr, > it would certainly be adopted. > > But nothing will happen if nobody steps in. theres another aspect that was mentioned on IRC but i belive not the ML. swr is easy to maintain for us, we can change it in any way if we need to. avr is maintained by libav and if we need or want major changes thats not nearly so easy. also while there are some very loud advocates pushing for avr none of them has volunteered to maintain avr or provide security support for it.This makes the suggestion to use avr quite dishonest IMO. I definitively will not maintain avr, its just a fork of my swr code and iam happy to merge improvments back into swr. and while some may claim theres no such thing as the need for a avr maintainer in ffmpeg. trying to build ffmpeg with avr and trying the avr regression tests will show that it simply doesnt work that way. So i would suggest that we all work together and pull on the same string in the same direction and work on swr. That also includes all the libav developers, everyone of them is welcome without exception to work on swr, if they feel its lacking something that avr has, patches, pull requests or direct commits are welcome! If API users feel that swr is not similar enough to avr, some API wraper to provide the avr API from a swr implemetation is welcome [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 10 14:38:17 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 14:38:17 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> Message-ID: <20140810123817.GQ12391@nb4> On Sat, Aug 09, 2014 at 06:26:19PM +0100, Kieran Kunhya wrote: [...] > ... and was designed by a larger > group instead of libswresample which was basically one person (and > literally appeared in git out of nowhere). For the record: $ git shortlog libswresample/ | grep '^[^ ]' Alexander Strasser (1): Andreas Cadhalpun (1): Andrew Wason (1): Carl Eugen Hoyos (4): Cl?ment B?sch (45): Derek Buitenhuis (1): Hendrik Leppkes (1): James Almer (19): Justin Ruggles (4): Lou Logan (2): Mans Rullgard (3): Martin Storsj? (1): Marton Balint (2): Matt Oliver (2): Michael Niedermayer (308): Nicolas George (8): Paul B Mahol (4): Reimar D?ffinger (3): Rob Sykes (7): Ronald S. Bultje (15): Stefano Sabatini (6): Timothy Gu (10): jamal (2): $ git shortlog libavresample/ | grep '^[^ ]' Anton Khirnov (25): Derek Buitenhuis (2): Diego Biurrun (22): Hendrik Leppkes (1): James Almer (2): Janne Grunau (5): John Stebbins (2): Justin Ruggles (71): Luca Barbato (1): Mans Rullgard (4): Martin Storsj? (6): Michael Niedermayer (97): Peter Meerwald (1): Reimar D?ffinger (2): Ronald S. Bultje (2): Thilo Borgmann (1): Tim Walker (2): [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No great genius has ever existed without some touch of madness. -- Aristotle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From rsbultje at gmail.com Sun Aug 10 14:42:27 2014 From: rsbultje at gmail.com (Ronald S. Bultje) Date: Sun, 10 Aug 2014 08:42:27 -0400 Subject: [FFmpeg-devel] [PATCH] hevc_ps: verify P/T/L information In-Reply-To: References: Message-ID: Hi, On Sun, Aug 10, 2014 at 6:04 AM, Christophe Gisquet < christophe.gisquet at gmail.com> wrote: > Hi, > > the attached patch is a half-baked attempt at checking the input. I > suspect there are a lot of places where little to no validation is > performed anyway. > > Maybe it would be wise to mark hevc as experimental for now ? Are we using the checked bitstream reader? If we are, we're fine already... If not, maybe we should, because let's be honest, getbits is only in headers, so it's not particularly performance-sensitive. Ronald From kierank at obe.tv Sun Aug 10 14:53:00 2014 From: kierank at obe.tv (Kieran Kunhya) Date: Sun, 10 Aug 2014 13:53:00 +0100 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140810123817.GQ12391@nb4> References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <20140810123817.GQ12391@nb4> Message-ID: On 10 August 2014 13:38, Michael Niedermayer wrote: > On Sat, Aug 09, 2014 at 06:26:19PM +0100, Kieran Kunhya wrote: > [...] > >> ... and was designed by a larger >> group instead of libswresample which was basically one person (and >> literally appeared in git out of nowhere). http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=b5875b91113a0f3de6ad61e9ff8b74b81de94760 There was no mailing list discussion and initial bugs had to be discussed on ffmpeg-cvs. It appeared out of nowhere and there was no discussion about the API. Many of the contributors were cleaning the inline asm up or various other fixes or had worked on the original resample code. The comparison you make is highly misleading. On the other hand libavresample was developed by consensus and the API discussed beforehand. From cehoyos at ag.or.at Sun Aug 10 15:09:48 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Sun, 10 Aug 2014 15:09:48 +0200 Subject: [FFmpeg-devel] [PATCH]Fix valgrind output when reading aliaspix images Message-ID: <201408101509.48114.cehoyos@ag.or.at> Hi! Attached patch fixes a warning here that valgrind produces when reading the aliaspix fate samples. Please review, Carl Eugen -------------- next part -------------- diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index b9a1bcf..d70fc75 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -395,7 +395,7 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) } if (codec->codec_id == AV_CODEC_ID_NONE) { - AVProbeData pd; + AVProbeData pd = { 0 }; AVInputFormat *ifmt; uint8_t header[PROBE_BUF_MIN + AVPROBE_PADDING_SIZE]; int ret; From christophe.gisquet at gmail.com Sun Aug 10 15:16:23 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Sun, 10 Aug 2014 15:16:23 +0200 Subject: [FFmpeg-devel] [PATCH] hevc_ps: verify P/T/L information In-Reply-To: References: Message-ID: Hi, 2014-08-10 14:42 GMT+02:00 Ronald S. Bultje : > Are we using the checked bitstream reader? If we are, we're fine already... I think we are. On the other hand, it seems the top caller, ff_hevc_decode_nal_vps, is never checking if we have read past the bitstream end. Shouldn't this be checked at the very end? Hitting the bitstream end yet not reporting invalid data at some point looks weird to me. So, I'm just not sure this always yields vps/sps/... info, so catching it might be good. On the other hand, this doesn't help catching bugs in the code elsewhere. > If not, maybe we should, because let's be honest, getbits is only in > headers, so it's not particularly performance-sensitive. And this is high-level syntax (think sps), so indeed. -- Christophe From christophe.gisquet at gmail.com Sun Aug 10 15:18:26 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Sun, 10 Aug 2014 15:18:26 +0200 Subject: [FFmpeg-devel] [PATCH] hevc_mvs: set candidate availabilities Message-ID: The patch fixes overreads (and crashes) introduced in 3ad04608. -- Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-hevc_mvs-set-candidate-availabilities.patch Type: text/x-patch Size: 1789 bytes Desc: not available URL: From onemda at gmail.com Sun Aug 10 15:32:39 2014 From: onemda at gmail.com (Paul B Mahol) Date: Sun, 10 Aug 2014 15:32:39 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <189C1715-453C-4DC3-A5C4-75FFA1799163@googlemail.com> References: <20140801102233.GG10372@leki> <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> <20140808101019.GD12391@nb4> <189C1715-453C-4DC3-A5C4-75FFA1799163@googlemail.com> Message-ID: On 8/9/14, Daniel Oberhoff wrote: > > Am 08.08.2014 um 12:10 schrieb Michael Niedermayer : > >> On Thu, Aug 07, 2014 at 12:15:17AM +0200, Daniel Oberhoff wrote: >>> >>> Am 06.08.2014 um 12:12 schrieb Clement Boesch : >>> >>>> On Sun, Aug 03, 2014 at 06:43:18PM +0200, Daniel Oberhoff wrote: >>>> [...] >>>>>>> +static av_cold int init(AVFilterContext *ctx) >>>>>>> +{ >>>>>>> + return 0; >>>>>>> +} >>>>>>> >>>>>> >>>>>> please remove this one, there is no point in having code that does >>>>>> nothing. >>>>>> >>>>>>> + >>>>>>> +static av_cold void uninit(AVFilterContext *ctx) >>>>>>> +{ >>>>>>> +} >>>>>>> + >>>>>>> >>>>>> >>>>>> ditto >>>>>> >>>>> >>>>> Done thanks! >>>>> >>>> >>>> Did you forget to attach the latest version of the patch or I missed it >>>> somewhere in the thread? >>> >>> Sorry, think that day I wanted to add something else before resubmit, and >>> then lost the time. >>> >>> Here also with changes suggested by timothy. Note that the >>> parametrization is now traditional >>> (i.e. k1 and k2 are zero-based, as for example in the opencv >>> documentation about calibration). >>> >>> From b798b95eb2f9ec4043b2407970d351cc31dd9e6a Mon Sep 17 00:00:00 2001 >>> From: Daniel Oberhoff >>> Date: Mon, 28 Jul 2014 23:58:12 +0200 >>> Subject: [PATCH] avfilter: ported lenscorrection filter from frei0r >>> >>> --- >>> Changelog | 2 +- >>> MAINTAINERS | 1 + >>> doc/filters.texi | 46 +++++++ >>> libavfilter/Makefile | 1 + >>> libavfilter/allfilters.c | 1 + >>> libavfilter/version.h | 4 +- >>> libavfilter/vf_lenscorrection.c | 199 >>> +++++++++++++++++++++++++++ >>> tests/fate/filter-video.mak | 3 + >>> tests/ref/fate/filter-pixfmts-lenscorrection | 8 ++ >>> 9 files changed, 262 insertions(+), 3 deletions(-) >>> create mode 100644 libavfilter/vf_lenscorrection.c >>> create mode 100644 tests/ref/fate/filter-pixfmts-lenscorrection >>> >> >> This is missing a "Signed-off-by" from you > > So I what do I write there? That is usually automatically done by git itself when you "git format-patch". > >>> diff --git a/Changelog b/Changelog >>> index 25dd210..79393ce 100644 >>> --- a/Changelog >>> +++ b/Changelog >>> @@ -3,7 +3,7 @@ releases are sorted from youngest to oldest. >>> >>> version : >>> - Icecast protocol >>> - >>> +- ported lenscorrection filter from frei0r filter >>> >>> version 2.3: >>> - AC3 fixed-point decoding >>> diff --git a/MAINTAINERS b/MAINTAINERS >>> index c383d3f..6948e22 100644 >>> --- a/MAINTAINERS >>> +++ b/MAINTAINERS >>> @@ -354,6 +354,7 @@ Filters: >>> vf_histogram.c Paul B Mahol >>> vf_hqx.c Clement Boesch >>> vf_il.c Paul B Mahol >>> + vf_lenscorrection.c Daniel Oberhoff >>> vf_mergeplanes.c Paul B Mahol >>> vf_psnr.c Paul B Mahol >>> vf_scale.c Michael Niedermayer >>> diff --git a/doc/filters.texi b/doc/filters.texi >>> index 86feebc..c4888d3 100644 >>> --- a/doc/filters.texi >>> +++ b/doc/filters.texi >>> @@ -5532,6 +5532,51 @@ kerndeint=map=1 >>> @end example >>> @end itemize >>> >>> + at section lenscorrection >>> + >>> +Correct radial lens distortion >>> + >>> +This filter can be used to correct for radial distortion as can result >>> from the use >>> +of wide angle lenses, and thereby re-rectify the image. To find the >>> right parameters >>> +one can use tools available for example as part of opencv or simply >>> trial-and-error. >>> +To use opencv use the calibration sample (under samples/cpp) from the >>> opencv sources >>> +and extract the k1 and k2 coefficients from the resulting matrix. >>> + >>> +Note that effectively the same filter is available in the open-source >>> tools Krita and >>> +Digikam from the KDE project. >>> + >>> +In contrast to the @ref{vignette} filter, which can also be used to >>> compensate lens errors, >>> +this filter corrects the distortion of the image, whereas @ref{vignette} >>> corrects the >>> +brightness distribution, so you may want to use both filters together in >>> certain >>> +cases, though you will have to take care of ordering, i.e. whether >>> vignetting should >>> +be applied before or after lens correction. >>> + >>> + at subsection Options >>> + >>> +The filter accepts the following options: >>> + >>> + at table @option >>> + at item cx >>> +Relative x-coordinate of the focal point of the image, and thereby the >>> center of the >>> +distrortion. This value has a range [0,1] and is expressed as fractions >>> of the image >>> +width. >>> + at item cy >>> +Relative y-coordinate of the focal point of the image, and thereby the >>> center of the >>> +distrortion. This value has a range [0,1] and is expressed as fractions >>> of the image >>> +height. >>> + at item k1 >>> +Coefficient of the quadratic correction term. 0.5 means no correction. >>> + at item k2 >>> +Coefficient of the double quadratic correction term. 0.5 means no >>> correction. >>> + at end table >>> + >>> +The formula that generates the correction is: >>> + >>> + at var{r_src} = @var{r_tgt} * (1 + @var{k1} * (@var{r_tgt} / @var{r_0})^2 >>> + @var{k2} * (@var{r_tgt} / @var{r_0})^4) >>> + >>> +where @var{r_0} is halve of the image diagonal and @var{r_src} and >>> @var{r_tgt} are the >>> +distances from the focal point in the source and target images, >>> respectively. >>> + >>> @anchor{lut3d} >>> @section lut3d >>> >>> @@ -8744,6 +8789,7 @@ For example, to vertically flip a video with >>> @command{ffmpeg}: >>> ffmpeg -i in.avi -vf "vflip" out.avi >>> @end example >>> >>> + at anchor{vignette} >>> @section vignette >>> >>> Make or reverse a natural vignetting effect. >>> diff --git a/libavfilter/Makefile b/libavfilter/Makefile >>> index 0f54381..e9c8456 100644 >>> --- a/libavfilter/Makefile >>> +++ b/libavfilter/Makefile >>> @@ -138,6 +138,7 @@ OBJS-$(CONFIG_IL_FILTER) += >>> vf_il.o >>> OBJS-$(CONFIG_INTERLACE_FILTER) += vf_interlace.o >>> OBJS-$(CONFIG_INTERLEAVE_FILTER) += f_interleave.o >>> OBJS-$(CONFIG_KERNDEINT_FILTER) += vf_kerndeint.o >>> +OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o >>> OBJS-$(CONFIG_LUT3D_FILTER) += vf_lut3d.o >>> OBJS-$(CONFIG_LUT_FILTER) += vf_lut.o >>> OBJS-$(CONFIG_LUTRGB_FILTER) += vf_lut.o >>> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c >>> index 1877557..b1d6ff5 100644 >>> --- a/libavfilter/allfilters.c >>> +++ b/libavfilter/allfilters.c >>> @@ -156,6 +156,7 @@ void avfilter_register_all(void) >>> REGISTER_FILTER(INTERLACE, interlace, vf); >>> REGISTER_FILTER(INTERLEAVE, interleave, vf); >>> REGISTER_FILTER(KERNDEINT, kerndeint, vf); >>> + REGISTER_FILTER(LENSCORRECTION, lenscorrection, vf); >>> REGISTER_FILTER(LUT3D, lut3d, vf); >>> REGISTER_FILTER(LUT, lut, vf); >>> REGISTER_FILTER(LUTRGB, lutrgb, vf); >>> diff --git a/libavfilter/version.h b/libavfilter/version.h >>> index 1a43dc5..47bac78 100644 >>> --- a/libavfilter/version.h >>> +++ b/libavfilter/version.h >>> @@ -30,8 +30,8 @@ >>> #include "libavutil/version.h" >>> >>> #define LIBAVFILTER_VERSION_MAJOR 4 >>> -#define LIBAVFILTER_VERSION_MINOR 11 >>> -#define LIBAVFILTER_VERSION_MICRO 102 >>> +#define LIBAVFILTER_VERSION_MINOR 12 >>> +#define LIBAVFILTER_VERSION_MICRO 100 >>> >>> #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, >>> \ >>> LIBAVFILTER_VERSION_MINOR, >>> \ >>> diff --git a/libavfilter/vf_lenscorrection.c >>> b/libavfilter/vf_lenscorrection.c >>> new file mode 100644 >>> index 0000000..c2346db >>> --- /dev/null >>> +++ b/libavfilter/vf_lenscorrection.c >>> @@ -0,0 +1,199 @@ >>> +/* >>> + * Copyright (C) 2007 Richard Spindler (author of frei0r plugin from >>> which this was derived) >>> + * Copyright (C) 2014 Daniel Oberhoff >>> + * >>> + * This file is part of FFmpeg. >>> + * >>> + * 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 >>> + */ >>> + >>> +/** >>> + * @file >>> + * Lenscorrection filter, algorithm from the frei0r plugin with the same >>> name >>> +*/ >>> +#include >>> +#include >>> + >>> +#include "libavutil/opt.h" >>> +#include "libavutil/intreadwrite.h" >>> +#include "libavutil/pixdesc.h" >>> + >>> +#include "avfilter.h" >>> +#include "internal.h" >>> +#include "video.h" >>> + >>> +typedef struct LenscorrectionCtx { >>> + const AVClass *av_class; >>> + unsigned int width; >>> + unsigned int height; >>> + int hsub, vsub; >>> + int nb_planes; >>> + double cx, cy, k1, k2; >>> +} LenscorrectionCtx; >>> + >>> +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM >>> +static const AVOption lenscorrection_options[] = { >>> + { "cx", "set relative center x", offsetof(LenscorrectionCtx, >>> cx), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, >>> + { "cy", "set relative center y", offsetof(LenscorrectionCtx, >>> cy), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS }, >>> + { "k1", "set quadratic distortion factor", >>> offsetof(LenscorrectionCtx, k1), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, >>> .flags=FLAGS }, >>> + { "k2", "set double quadratic distortion factor", >>> offsetof(LenscorrectionCtx, k2), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, >>> .flags=FLAGS }, >>> + { NULL } >>> +}; >>> + >>> +AVFILTER_DEFINE_CLASS(lenscorrection); >>> + >>> +typedef struct ThreadData { >>> + AVFrame *in, *out; >>> + float w, h; >>> + int plane; >>> + float xcenter, ycenter; >>> + float k1, k2; >>> +} ThreadData; >>> + >>> +static int filter_slice(AVFilterContext *ctx, void *arg, int job, int >>> nb_jobs) >>> +{ >>> + ThreadData *td = (ThreadData*)arg; >>> + AVFrame *in = td->in; >>> + AVFrame *out = td->out; >>> + >>> + const float w = td->w, h = td->h; >>> + const float xcenter = td->xcenter; >>> + const float ycenter = td->ycenter; >>> + const float r2inv = 4.0 / (w * w + h * h); >>> + const float k1 = td->k1; >>> + const float k2 = td->k2; >>> + const int start = (h * job ) / nb_jobs; >>> + const int end = (h * (job+1)) / nb_jobs; >>> + const int plane = td->plane; >>> + const int inlinesize = in->linesize[plane]; >>> + const int outlinesize = out->linesize[plane]; >>> + const uint8_t *indata = in->data[plane]; >>> + uint8_t *outrow = out->data[plane] + start * outlinesize; >>> + int i; >>> + for (i = start; i < end; i++, outrow += outlinesize) { >>> + const float off_y = i - ycenter; >>> + const float off_y2 = off_y * off_y; >>> + uint8_t *out = outrow; >>> + int j; >>> + for (j = 0; j < w; j++) { >>> + const float off_x = j - xcenter; >>> + const float r2 = (off_x * off_x + off_y2) * r2inv; >>> + const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2; >>> + const int x = xcenter + radius_mult * off_x + 0.5f; >>> + const int y = ycenter + radius_mult * off_y + 0.5f; >>> + const char isvalid = x > 0 && x < w - 1 && y > 0 && y < h - >>> 1; >> >>> + *out++ = isvalid ? indata[y * inlinesize + x] : 0; >> >> IMHO "nearest neighbour" resampling isnt a reasonable choice, if >> thats the only choice the user has. > > So you want me to add other methods? I found nearest neighbor sufficient for > our needs and using other methods seemed to slow the code down too much for > us, but if you think the filter is unfit for ffmpeg otherwise I will add > other methods. Up to what order would you say resampling options are > required? It is not mandatory(but it would be nice) to add other methods to have this filter included into libavfilter. > >> also md5 based regression tests and extensive use of floats are >> unlikely to work together, different architectures/platforms or even >> compiler versions might give you different results > > Sounds reasonable, so should I remove the tests then? Yes. From george at nsup.org Sun Aug 10 15:36:04 2014 From: george at nsup.org (Nicolas George) Date: Sun, 10 Aug 2014 15:36:04 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> <20140808101019.GD12391@nb4> <189C1715-453C-4DC3-A5C4-75FFA1799163@googlemail.com> Message-ID: <20140810133603.GA1193@phare.normalesup.org> Le tridi 23 thermidor, an CCXXII, Paul B Mahol a ?crit?: > It is not mandatory(but it would be nice) to add other methods to have > this filter included into libavfilter. Is it really a good idea? We would end up with various interpolation / anti-aliasing algorithms implemented in each filter that needs it, none of them with the same set of architecture optimizations and each with its own set of bugs and misfeatures. Until someone comes up with a really satisfactory solution, I believe the simple solution of suggesting users to upscale before the filter and downscale after, using the optimized lswr scalers, is better. Regards, -- Nicolas George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From danieloberhoff at gmail.com Sun Aug 10 15:43:29 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Sun, 10 Aug 2014 15:43:29 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <20140810133603.GA1193@phare.normalesup.org> References: <20140802221231.GR10372@leki> <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> <20140808101019.GD12391@nb4> <189C1715-453C-4DC3-A5C4-75FFA1799163@googlemail.com> <20140810133603.GA1193@phare.normalesup.org> Message-ID: Von meinem iPhone gesendet > Am 10.08.2014 um 15:36 schrieb Nicolas George : > > Le tridi 23 thermidor, an CCXXII, Paul B Mahol a ?crit : >> It is not mandatory(but it would be nice) to add other methods to have >> this filter included into libavfilter. > > Is it really a good idea? We would end up with various interpolation / > anti-aliasing algorithms implemented in each filter that needs it, none of > them with the same set of architecture optimizations and each with its own > set of bugs and misfeatures. > > Until someone comes up with a really satisfactory solution, I believe the > simple solution of suggesting users to upscale before the filter and > downscale after, using the optimized lswr scalers, is better. Well, i could factor out the resampling from the Rotary filter and put it into a header accessible by both, would that be ok? From george at nsup.org Sun Aug 10 15:46:05 2014 From: george at nsup.org (Nicolas George) Date: Sun, 10 Aug 2014 15:46:05 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: References: <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> <20140808101019.GD12391@nb4> <189C1715-453C-4DC3-A5C4-75FFA1799163@googlemail.com> <20140810133603.GA1193@phare.normalesup.org> Message-ID: <20140810134605.GA2875@phare.normalesup.org> Le tridi 23 thermidor, an CCXXII, Daniel Oberhoff a ?crit?: > Well, i could factor out the resampling from the Rotary filter and put it > into a header accessible by both, would that be ok? Common code to do the work would of course be appreciated, but what I was saying is that, in my opinion, you can focus on getting the filter integrated as is, without interpolation / anti-aliasing. Enhancements and code sharing can come later. Regards, -- Nicolas George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 10 15:48:56 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 15:48:56 +0200 Subject: [FFmpeg-devel] [PATCH] hevc_ps: verify P/T/L information In-Reply-To: References: Message-ID: <20140810134856.GR12391@nb4> On Sun, Aug 10, 2014 at 03:16:23PM +0200, Christophe Gisquet wrote: > Hi, > > 2014-08-10 14:42 GMT+02:00 Ronald S. Bultje : > > Are we using the checked bitstream reader? If we are, we're fine already... > > I think we are. On the other hand, it seems the top caller, > ff_hevc_decode_nal_vps, is never checking if we have read past the > bitstream end. Shouldn't this be checked at the very end? Hitting the > bitstream end yet not reporting invalid data at some point looks weird > to me. > > So, I'm just not sure this always yields vps/sps/... info, so catching > it might be good. On the other hand, this doesn't help catching bugs > in the code elsewhere. > > > If not, maybe we should, because let's be honest, getbits is only in > > headers, so it's not particularly performance-sensitive. > > And this is high-level syntax (think sps), so indeed. agree with all should i apply the patch or apply something else ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From danieloberhoff at gmail.com Sun Aug 10 16:13:19 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Sun, 10 Aug 2014 16:13:19 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <20140810134605.GA2875@phare.normalesup.org> References: <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> <20140808101019.GD12391@nb4> <189C1715-453C-4DC3-A5C4-75FFA1799163@googlemail.com> <20140810133603.GA1193@phare.normalesup.org> <20140810134605.GA2875@phare.normalesup.org> Message-ID: Von meinem iPhone gesendet > Am 10.08.2014 um 15:46 schrieb Nicolas George : > > Le tridi 23 thermidor, an CCXXII, Daniel Oberhoff a ?crit : >> Well, i could factor out the resampling from the Rotary filter and put it >> into a header accessible by both, would that be ok? > > Common code to do the work would of course be appreciated, but what I was > saying is that, in my opinion, you can focus on getting the filter > integrated as is, without interpolation / anti-aliasing. Enhancements and > code sharing can come later. What i was just about to suggest :). So i will push now and if i get round to do the refactoring. From matthias at urlichs.de Sun Aug 10 09:01:26 2014 From: matthias at urlichs.de (Matthias Urlichs) Date: Sun, 10 Aug 2014 09:01:26 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> Message-ID: <20140810070126.GR1627@smurf.noris.de> Hi, Jean-Yves Avenard: > Including rename of constants (code enums id for example). Another nail in libav's coffin, then. IMHO it's reasonable to expect core APIs to be upwards-compatible and keep deprecated interfaces around for another release or two. > Keeping your own static version is the only reasonable approach. That may be OK on Windows. However, a proper Linux distribution is supposed to be an integrated whole and not a haphazard collection of programs, each bringing along their own copy of core libraries and their own un- or semi-fixed security problems. -- -- Matthias Urlichs From superjoe30 at gmail.com Sun Aug 10 09:25:33 2014 From: superjoe30 at gmail.com (Andrew Kelley) Date: Sun, 10 Aug 2014 00:25:33 -0700 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140810070126.GR1627@smurf.noris.de> References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <20140810070126.GR1627@smurf.noris.de> Message-ID: On Sun, Aug 10, 2014 at 12:01 AM, Matthias Urlichs wrote: > Jean-Yves Avenard: > > Including rename of constants (code enums id for example). > > Another nail in libav's coffin, then. > > IMHO it's reasonable to expect core APIs to be upwards-compatible and keep > deprecated interfaces around for another release or two. High quality libraries must iterate on their API. Especially for a library trying to solve such a complex problem as audio and video encoding and decoding for every codec and format. It is unreasonable to expect no incompatible changes. Also both ffmpeg and libav codebases have a lot of legacy cruft. Libav is making a more concentrated effort at improving this, and the evolving API is a side-effect of that. From matthias at urlichs.de Sun Aug 10 09:43:03 2014 From: matthias at urlichs.de (Matthias Urlichs) Date: Sun, 10 Aug 2014 09:43:03 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: References: <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <20140810070126.GR1627@smurf.noris.de> Message-ID: <20140810074303.GB1898@smurf.noris.de> Hi, Andrew Kelley: > It is unreasonable to expect no incompatible changes. When somebody renames constants, a compatibility #ifdef or two is not too much to ask, IMHO. > Libav is making a more concentrated effort at improving this, > and the evolving API is a side-effect of that. That begs the question whether they're still essentially the same library, i.e. whether it's at all reasonable to expect code built using FFmpeg to work with libav. Consequently, Debian should at least include it, even if it really _is_ too late to switch (which I'm not conviced of). -- -- Matthias Urlichs From superjoe30 at gmail.com Sun Aug 10 10:53:10 2014 From: superjoe30 at gmail.com (Andrew Kelley) Date: Sun, 10 Aug 2014 01:53:10 -0700 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <20140810070126.GR1627@smurf.noris.de> Message-ID: On Sun, Aug 10, 2014 at 1:48 AM, Jean-Yves Avenard wrote: > Then it becomes unreasonable for a piece of software to be compatible > with multiple version of the same library, and support all of those. > IMO it's not worth the effort to support multiple versions of the same library. If you want to use an old library, use an old version of the software. From michaelni at gmx.at Sun Aug 10 17:00:23 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 17:00:23 +0200 Subject: [FFmpeg-devel] [PATCH]Fix valgrind output when reading aliaspix images In-Reply-To: <201408101509.48114.cehoyos@ag.or.at> References: <201408101509.48114.cehoyos@ag.or.at> Message-ID: <20140810150023.GS12391@nb4> On Sun, Aug 10, 2014 at 03:09:48PM +0200, Carl Eugen Hoyos wrote: > Hi! > > Attached patch fixes a warning here that valgrind produces when reading the > aliaspix fate samples. > > Please review, Carl Eugen > img2dec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > 326527b2b3c49a26675b9b2a6ea41ef949f3a7d6 patchpixprobe.diff LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is dangerous to be right in matters on which the established authorities are wrong. -- Voltaire -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 10 17:29:11 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 17:29:11 +0200 Subject: [FFmpeg-devel] [PATCH] hevc_mvs: set candidate availabilities In-Reply-To: References: Message-ID: <20140810152911.GT12391@nb4> On Sun, Aug 10, 2014 at 03:18:26PM +0200, Christophe Gisquet wrote: > The patch fixes overreads (and crashes) introduced in 3ad04608. > > -- > Christophe > hevc_mvs.c | 20 +++++++++++--------- > 1 file changed, 11 insertions(+), 9 deletions(-) > 3cad460e327446b29ab1623c9b5c5f9b0c2ba008 0001-hevc_mvs-set-candidate-availabilities.patch > From adfac6472b015e162988e2e2208e95cc87248be2 Mon Sep 17 00:00:00 2001 > From: Christophe Gisquet > Date: Sun, 10 Aug 2014 15:02:36 +0200 > Subject: [PATCH] hevc_mvs: set candidate availabilities > > They might be left uninitialized otherwise since 3ad04608. > > Fixes ticket #3840. > > Found-by: Carl Eugen Hoyos > Reported-by: Piotr Bandurski applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness enter who devote themselves to the Knowledge alone. -- Isha Upanishad -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 10 17:30:43 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 17:30:43 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec/options_table: leave xvidmmx AVOption in place In-Reply-To: <1407588979-10668-1-git-send-email-michaelni@gmx.at> References: <1407588979-10668-1-git-send-email-michaelni@gmx.at> Message-ID: <20140810153043.GU12391@nb4> On Sat, Aug 09, 2014 at 02:56:19PM +0200, Michael Niedermayer wrote: > Also mark it as deprecated through its help text > > Signed-off-by: Michael Niedermayer > --- > libavcodec/options_table.h | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Old school: Use the lowest level language in which you can solve the problem conveniently. New school: Use the highest level language in which the latest supercomputer can solve the problem without the user falling asleep waiting. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 10 17:50:13 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 17:50:13 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <20140810133603.GA1193@phare.normalesup.org> References: <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> <20140808101019.GD12391@nb4> <189C1715-453C-4DC3-A5C4-75FFA1799163@googlemail.com> <20140810133603.GA1193@phare.normalesup.org> Message-ID: <20140810155013.GV12391@nb4> On Sun, Aug 10, 2014 at 03:36:04PM +0200, Nicolas George wrote: > Le tridi 23 thermidor, an CCXXII, Paul B Mahol a ?crit?: > > It is not mandatory(but it would be nice) to add other methods to have > > this filter included into libavfilter. > > Is it really a good idea? We would end up with various interpolation / > anti-aliasing algorithms implemented in each filter that needs it, none of > them with the same set of architecture optimizations and each with its own > set of bugs and misfeatures. > > Until someone comes up with a really satisfactory solution, I believe the > simple solution of suggesting users to upscale before the filter and > downscale after, using the optimized lswr scalers, is better. thats not practical a 1024x768 image would need to be upscaled to 262144x196608 to get 8bit precission from a nearest neighbor resampler as basis also see vf_perspective.c which supports bilinear and bicubic interpolation, these surely could be shared and exist already. of course we could push it with just nearest neighbor and work on that later, but i dont think only nearest neighbor and leaving it at that is a reasonable choice, its too poor quality wise [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the very wise cannot see all ends. -- Gandalf -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From mraulet at gmail.com Sun Aug 10 17:57:48 2014 From: mraulet at gmail.com (=?iso-8859-1?Q?Micka=EBl_Raulet?=) Date: Sun, 10 Aug 2014 17:57:48 +0200 Subject: [FFmpeg-devel] [PATCH] hevc_ps: verify P/T/L information In-Reply-To: References: Message-ID: Hi Le 10 ao?t 2014 ? 15:16, Christophe Gisquet a ?crit : > Hi, > > 2014-08-10 14:42 GMT+02:00 Ronald S. Bultje : >> Are we using the checked bitstream reader? If we are, we're fine already... > > I think we are. On the other hand, it seems the top caller, > ff_hevc_decode_nal_vps, is never checking if we have read past the > bitstream end. Shouldn't this be checked at the very end? Hitting the > bitstream end yet not reporting invalid data at some point looks weird > to me. > information from the vps is not used for the time being. and yes we are using the checked bitstream reader. we rely on the AVC cabac engine. > So, I'm just not sure this always yields vps/sps/... info, so catching > it might be good. On the other hand, this doesn't help catching bugs > in the code elsewhere. > >> If not, maybe we should, because let's be honest, getbits is only in >> headers, so it's not particularly performance-sensitive. > > And this is high-level syntax (think sps), so indeed. They are some missing checks in the PSes but I think most of them are there. Micka?l From mraulet at gmail.com Sun Aug 10 17:58:19 2014 From: mraulet at gmail.com (=?iso-8859-1?Q?Micka=EBl_Raulet?=) Date: Sun, 10 Aug 2014 17:58:19 +0200 Subject: [FFmpeg-devel] [PATCH] hevc_ps: verify P/T/L information In-Reply-To: <20140810134856.GR12391@nb4> References: <20140810134856.GR12391@nb4> Message-ID: <17A6CA62-D9F2-4CD4-A38B-FDBFCD87D235@gmail.com> Hi Le 10 ao?t 2014 ? 15:48, Michael Niedermayer a ?crit : > On Sun, Aug 10, 2014 at 03:16:23PM +0200, Christophe Gisquet wrote: >> Hi, >> >> 2014-08-10 14:42 GMT+02:00 Ronald S. Bultje : >>> Are we using the checked bitstream reader? If we are, we're fine already... >> >> I think we are. On the other hand, it seems the top caller, >> ff_hevc_decode_nal_vps, is never checking if we have read past the >> bitstream end. Shouldn't this be checked at the very end? Hitting the >> bitstream end yet not reporting invalid data at some point looks weird >> to me. >> >> So, I'm just not sure this always yields vps/sps/... info, so catching >> it might be good. On the other hand, this doesn't help catching bugs >> in the code elsewhere. >> >>> If not, maybe we should, because let's be honest, getbits is only in >>> headers, so it's not particularly performance-sensitive. >> >> And this is high-level syntax (think sps), so indeed. > > agree with all > > should i apply the patch or apply something else ? > This can be applied. Micka?l From nfxjfg at googlemail.com Sun Aug 10 18:12:41 2014 From: nfxjfg at googlemail.com (wm4) Date: Sun, 10 Aug 2014 18:12:41 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: <20140810074303.GB1898@smurf.noris.de> References: <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <20140810070126.GR1627@smurf.noris.de> <20140810074303.GB1898@smurf.noris.de> Message-ID: <20140810181241.286d19fa@debian> On Sun, 10 Aug 2014 09:43:03 +0200 Matthias Urlichs wrote: > Hi, > > Andrew Kelley: > > It is unreasonable to expect no incompatible changes. > > When somebody renames constants, a compatibility #ifdef or two is not too > much to ask, IMHO. AFAIK such a thing existed, but it's possible that they weren't kept around long enough. > > Libav is making a more concentrated effort at improving this, > > and the evolving API is a side-effect of that. > > That begs the question whether they're still essentially the same library, > i.e. whether it's at all reasonable to expect code built using FFmpeg to > work with libav. Consequently, Debian should at least include it, even > if it really _is_ too late to switch (which I'm not conviced of). > Huh? FFmpeg merges all API changes from Libav. For the record, many changes Libav does are _good_. From michaelni at gmx.at Sun Aug 10 18:16:31 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 18:16:31 +0200 Subject: [FFmpeg-devel] [PATCH] hevc_ps: verify P/T/L information In-Reply-To: <17A6CA62-D9F2-4CD4-A38B-FDBFCD87D235@gmail.com> References: <20140810134856.GR12391@nb4> <17A6CA62-D9F2-4CD4-A38B-FDBFCD87D235@gmail.com> Message-ID: <20140810161631.GW12391@nb4> On Sun, Aug 10, 2014 at 05:58:19PM +0200, Micka?l Raulet wrote: > Hi > Le 10 ao?t 2014 ? 15:48, Michael Niedermayer a ?crit : > > > On Sun, Aug 10, 2014 at 03:16:23PM +0200, Christophe Gisquet wrote: > >> Hi, > >> > >> 2014-08-10 14:42 GMT+02:00 Ronald S. Bultje : > >>> Are we using the checked bitstream reader? If we are, we're fine already... > >> > >> I think we are. On the other hand, it seems the top caller, > >> ff_hevc_decode_nal_vps, is never checking if we have read past the > >> bitstream end. Shouldn't this be checked at the very end? Hitting the > >> bitstream end yet not reporting invalid data at some point looks weird > >> to me. > >> > >> So, I'm just not sure this always yields vps/sps/... info, so catching > >> it might be good. On the other hand, this doesn't help catching bugs > >> in the code elsewhere. > >> > >>> If not, maybe we should, because let's be honest, getbits is only in > >>> headers, so it's not particularly performance-sensitive. > >> > >> And this is high-level syntax (think sps), so indeed. > > > > agree with all > > > > should i apply the patch or apply something else ? > > > > This can be applied. applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The educated differ from the uneducated as much as the living from the dead. -- Aristotle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From george at nsup.org Sun Aug 10 18:48:22 2014 From: george at nsup.org (Nicolas George) Date: Sun, 10 Aug 2014 18:48:22 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <20140810155013.GV12391@nb4> References: <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> <20140808101019.GD12391@nb4> <189C1715-453C-4DC3-A5C4-75FFA1799163@googlemail.com> <20140810133603.GA1193@phare.normalesup.org> <20140810155013.GV12391@nb4> Message-ID: <20140810164822.GA32577@phare.normalesup.org> Le tridi 23 thermidor, an CCXXII, Michael Niedermayer a ?crit?: > thats not practical > a 1024x768 image would need to be upscaled to 262144x196608 to get > 8bit precission from a nearest neighbor resampler as basis I am not sure this makes sense. Scaling is already an approximation, and without gamma correction, it certainly does not yield 8?bits precision. I believe in most cases, 2? or 4? upscaling would look plenty good enough for most cases. > also see vf_perspective.c which supports bilinear and bicubic > interpolation, these surely could be shared and exist already. > > of course we could push it with just nearest neighbor and work on that > later, but i dont think only nearest neighbor and leaving it at that > is a reasonable choice, its too poor quality wise Certainly, we want that all filters that need it eventually get interpolation code that produces nice-looking images, is optimized and configurable. Preparing the framework for that is a worthy endeavour, and should be done, as much as possible, before introducing new filters that require it. But right now we have a filter that is ready for integration with nearest interpolation: surely it is better to merge it now rather than having it wait in someone's private tree while we bikeshed the common interpolation API. Is it not? Regards, -- Nicolas George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From cehoyos at ag.or.at Sun Aug 10 19:23:33 2014 From: cehoyos at ag.or.at (Carl Eugen Hoyos) Date: Sun, 10 Aug 2014 19:23:33 +0200 Subject: [FFmpeg-devel] [PATCH]Remove panscan information in av_frame_copy_props() if resolution changes Message-ID: <201408101923.33606.cehoyos@ag.or.at> Hi! Attached is a new variant of "[RFC]Remove panscan side data in filters that change the resolution". I don't know how to correctly set the information based on the resolution change, as-is this patch works around ticket #3750 (a regression). Please comment, Carl Eugen -------------- next part -------------- diff --git a/libavutil/frame.c b/libavutil/frame.c index 67a7d3e..38c0e5c 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -492,6 +492,9 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src) for (i = 0; i < src->nb_side_data; i++) { const AVFrameSideData *sd_src = src->side_data[i]; + if ( sd_src->type == AV_FRAME_DATA_PANSCAN + && (src->width != dst->width || src->height != dst->height)) + continue; AVFrameSideData *sd_dst = av_frame_new_side_data(dst, sd_src->type, sd_src->size); if (!sd_dst) { From christophe.gisquet at gmail.com Sun Aug 10 19:34:17 2014 From: christophe.gisquet at gmail.com (Christophe Gisquet) Date: Sun, 10 Aug 2014 19:34:17 +0200 Subject: [FFmpeg-devel] [PATCH] hevc: do generic validation of bitstream Message-ID: Hi, the patch tries to validate these high-level syntax elements. Unfortunately, it causes fuzzing to be less efficient, eg with the sequence from ticket #3840 where no frame are decoded. -- Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-hevc-do-generic-validation-of-bitstream.patch Type: text/x-patch Size: 2309 bytes Desc: not available URL: From danieloberhoff at gmail.com Sun Aug 10 20:36:37 2014 From: danieloberhoff at gmail.com (Daniel Oberhoff) Date: Sun, 10 Aug 2014 20:36:37 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <20140810155013.GV12391@nb4> References: <197C874A-EBBF-4517-ABA7-2C9905E7347B@googlemail.com> <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> <20140808101019.GD12391@nb4> <189C1715-453C-4DC3-A5C4-75FFA1799163@googlemail.com> <20140810133603.GA1193@phare.normalesup.org> <20140810155013.GV12391@nb4> Message-ID: <38A69FEF-DC57-4A95-A90A-EF121EA139F3@googlemail.com> Von meinem iPhone gesendet > Am 10.08.2014 um 17:50 schrieb Michael Niedermayer : > >> On Sun, Aug 10, 2014 at 03:36:04PM +0200, Nicolas George wrote: >> Le tridi 23 thermidor, an CCXXII, Paul B Mahol a ?crit : >>> It is not mandatory(but it would be nice) to add other methods to have >>> this filter included into libavfilter. >> >> Is it really a good idea? We would end up with various interpolation / >> anti-aliasing algorithms implemented in each filter that needs it, none of >> them with the same set of architecture optimizations and each with its own >> set of bugs and misfeatures. > >> Until someone comes up with a really satisfactory solution, I believe the >> simple solution of suggesting users to upscale before the filter and >> downscale after, using the optimized lswr scalers, is better. > > thats not practical > a 1024x768 image would need to be upscaled to 262144x196608 to get > 8bit precission from a nearest neighbor resampler as basis > > also see vf_perspective.c which supports bilinear and bicubic > interpolation, these surely could be shared and exist already. > > of course we could push it with just nearest neighbor and work on that > later, but i dont think only nearest neighbor and leaving it at that > is a reasonable choice, its too poor quality wise I would like to push now, and try to generate a refactoring patch possibly within the week. > [...] > > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Many that live deserve death. And some that die deserve life. Can you give > it to them? Then do not be too eager to deal out death in judgement. For > even the very wise cannot see all ends. -- Gandalf > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From mindmark at gmail.com Sun Aug 10 20:37:02 2014 From: mindmark at gmail.com (Mark Reid) Date: Sun, 10 Aug 2014 11:37:02 -0700 Subject: [FFmpeg-devel] [PATCH] write reel_name metadata to tmcd atom In-Reply-To: <20140809013507.GJ12391@nb4> References: <1407519426-72919-1-git-send-email-mindmark@gmail.com> <1407519426-72919-2-git-send-email-mindmark@gmail.com> <20140809013507.GJ12391@nb4> Message-ID: On Fri, Aug 8, 2014 at 6:35 PM, Michael Niedermayer wrote: > On Fri, Aug 08, 2014 at 10:37:06AM -0700, Mark Reid wrote: > > --- > > libavformat/movenc.c | 25 +++++++++++++++++++++++-- > > 1 file changed, 23 insertions(+), 2 deletions(-) > > > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > > index 86dbe7f..fe4413c 100644 > > --- a/libavformat/movenc.c > > +++ b/libavformat/movenc.c > > @@ -1340,6 +1340,16 @@ static int mov_write_rtp_tag(AVIOContext *pb, > MOVTrack *track) > > return update_size(pb, pos); > > } > > > > +static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack > *track, const char *reel_name){ > > + int64_t pos = avio_tell(pb); > > + avio_wb32(pb, 0); /* size */ > > + ffio_wfourcc(pb, "name"); /* Data format */ > > > + avio_wb16(pb, strlen(reel_name)); /* string size */ > > forgot but strictly speaking this requires a check on the strlen > fitting in 16bit > > can you send a patch added a check with appropriate action ? > okay, I'll send a patch that adds a check and fixes this. > > thanks > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Many that live deserve death. And some that die deserve life. Can you give > it to them? Then do not be too eager to deal out death in judgement. For > even the very wise cannot see all ends. -- Gandalf > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > From mindmark at gmail.com Sun Aug 10 21:01:33 2014 From: mindmark at gmail.com (Mark Reid) Date: Sun, 10 Aug 2014 12:01:33 -0700 Subject: [FFmpeg-devel] [PATCH] check that reel_name length doesn't exceed UINT16_MAX Message-ID: <1407697293-98712-1-git-send-email-mindmark@gmail.com> --- libavformat/movenc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 6a38e89..85fb2e8 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1340,13 +1340,21 @@ static int mov_write_rtp_tag(AVIOContext *pb, MOVTrack *track) return update_size(pb, pos); } -static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack *track, const char *reel_name){ +static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack *track, const char *reel_name) +{ + uint64_t str_size =strlen(reel_name); + if (str_size >= UINT16_MAX){ + av_log(NULL, AV_LOG_ERROR, "reel_name length %llu is too large\n", str_size); + avio_wb16(pb, 0); + return AVERROR(EINVAL); + } + int64_t pos = avio_tell(pb); avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "name"); /* Data format */ - avio_wb16(pb, strlen(reel_name)); /* string size */ + avio_wb16(pb, str_size); /* string size */ avio_wb16(pb, track->language); /* langcode */ - avio_write(pb, reel_name, strlen(reel_name)); /* reel name */ + avio_write(pb, reel_name, str_size); /* reel name */ return update_size(pb,pos); } -- 2.0.0 From michaelni at gmx.at Sun Aug 10 21:20:52 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 21:20:52 +0200 Subject: [FFmpeg-devel] [PATCH]Remove panscan information in av_frame_copy_props() if resolution changes In-Reply-To: <201408101923.33606.cehoyos@ag.or.at> References: <201408101923.33606.cehoyos@ag.or.at> Message-ID: <20140810192052.GX12391@nb4> On Sun, Aug 10, 2014 at 07:23:33PM +0200, Carl Eugen Hoyos wrote: > Hi! > > Attached is a new variant of "[RFC]Remove panscan side data in filters that > change the resolution". I don't know how to correctly set the information > based on the resolution change, as-is this patch works around ticket #3750 (a > regression). > > Please comment, Carl Eugen > frame.c | 3 +++ > 1 file changed, 3 insertions(+) > 636352467d85130c294f2383161cc5d0034ec58e patchpanscan2.diff > diff --git a/libavutil/frame.c b/libavutil/frame.c > index 67a7d3e..38c0e5c 100644 > --- a/libavutil/frame.c > +++ b/libavutil/frame.c > @@ -492,6 +492,9 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src) > > for (i = 0; i < src->nb_side_data; i++) { > const AVFrameSideData *sd_src = src->side_data[i]; > + if ( sd_src->type == AV_FRAME_DATA_PANSCAN > + && (src->width != dst->width || src->height != dst->height)) > + continue; > AVFrameSideData *sd_dst = av_frame_new_side_data(dst, sd_src->type, > sd_src->size); LGTM but please dont mix declarations and statements [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB it is not once nor twice but times without number that the same ideas make their appearance in the world. -- Aristotle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Sun Aug 10 21:37:41 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Sun, 10 Aug 2014 21:37:41 +0200 Subject: [FFmpeg-devel] [PATCH] check that reel_name length doesn't exceed UINT16_MAX In-Reply-To: <1407697293-98712-1-git-send-email-mindmark@gmail.com> References: <1407697293-98712-1-git-send-email-mindmark@gmail.com> Message-ID: <20140810193741.GY12391@nb4> On Sun, Aug 10, 2014 at 12:01:33PM -0700, Mark Reid wrote: > --- > libavformat/movenc.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam" -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From cus at passwd.hu Sun Aug 10 21:46:06 2014 From: cus at passwd.hu (Marton Balint) Date: Sun, 10 Aug 2014 21:46:06 +0200 Subject: [FFmpeg-devel] [PATCH] mpegts: always parse pcr Message-ID: <1407699966-16290-1-git-send-email-cus@passwd.hu> Previously pcr transmitted without payload but as part of the video stream was not parsed. Signed-off-by: Marton Balint --- libavformat/mpegts.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index a2456a3..6e400a6 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2073,16 +2073,18 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) } } - if (!has_payload && tss->type != MPEGTS_PCR) - return 0; p = packet + 4; if (has_adaptation) { + int64_t pcr_h; + int pcr_l; + if (parse_pcr(&pcr_h, &pcr_l, packet) == 0) + tss->last_pcr = pcr_h * 300 + pcr_l; /* skip adaptation field */ p += p[0] + 1; } /* if past the end of packet, ignore */ p_end = packet + TS_PACKET_SIZE; - if (p > p_end || (p == p_end && tss->type != MPEGTS_PCR)) + if (p >= p_end || !has_payload) return 0; pos = avio_tell(ts->stream->pb); @@ -2135,10 +2137,6 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) } else { int ret; - int64_t pcr_h; - int pcr_l; - if (parse_pcr(&pcr_h, &pcr_l, packet) == 0) - tss->last_pcr = pcr_h * 300 + pcr_l; // Note: The position here points actually behind the current packet. if (tss->type == MPEGTS_PES) { if ((ret = tss->u.pes_filter.pes_cb(tss, p, p_end - p, is_start, -- 1.8.4.5 From u at pkh.me Sun Aug 10 22:09:02 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Sun, 10 Aug 2014 22:09:02 +0200 Subject: [FFmpeg-devel] [PATCH] avfilter/dctdnoiz: add slice threading Message-ID: <1407701342-32738-1-git-send-email-u@pkh.me> --- I have one or two little things to cleanup after this but I think I'm mostly done. The filter is now usable from a performance point of view (not for real-time, but it doesn't decades to process a normal sized image anymore): Stream #0:0: Video: png, rgb24, 1445x1080, 25 tbr, 25 tbn, 25 tbc ./ffmpeg-2.3 -i in.png -vf dctdnoiz=15 -f null - 38.34s user 0.01s system 98% cpu 39.124 total ./ffmpeg -i in.png -vf dctdnoiz=15 -f null - 5.06s user 0.02s system 621% cpu 0.817 total I will mention this stuff in the Changelog when this is accepted. Ideally, I'd really love to have a FATE test, but I see no such thing as "threshold" video tests for avfilter in FATE in order to support float-based filters. Another solution as already is to make dctdnoiz integer-only but I'm not planing to do that anytime soon. --- libavfilter/vf_dctdnoiz.c | 114 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 84 insertions(+), 30 deletions(-) diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c index fe1c5d7..a9017b1 100644 --- a/libavfilter/vf_dctdnoiz.c +++ b/libavfilter/vf_dctdnoiz.c @@ -36,18 +36,22 @@ static const char *const var_names[] = { "c", NULL }; enum { VAR_C, VAR_VARS_NB }; +#define MAX_THREADS 8 + typedef struct DCTdnoizContext { const AVClass *class; /* coefficient factor expression */ char *expr_str; - AVExpr *expr; - double var_values[VAR_VARS_NB]; + AVExpr *expr[MAX_THREADS]; + double var_values[MAX_THREADS][VAR_VARS_NB]; + int nb_threads; int pr_width, pr_height; // width and height to process float sigma; // used when no expression are st float th; // threshold (3*sigma) float *cbuf[2][3]; // two planar rgb color buffers + float *slices[MAX_THREADS]; // slices buffers (1 slice buffer per thread) float *weights; // dct coeff are cumulated with overlapping; these values are used for averaging int p_linesize; // line sizes for color and weights int overlap; // number of block overlapping pixels @@ -56,7 +60,8 @@ typedef struct DCTdnoizContext { int bsize; // block size, 1<th); \ } \ \ static void filter_freq_expr_##bsize(DCTdnoizContext *s, \ const float *src, int src_linesize, \ - float *dst, int dst_linesize) \ + float *dst, int dst_linesize, int thread_id) \ { \ - filter_freq_##bsize(src, src_linesize, dst, dst_linesize, s->expr, s->var_values, 0); \ + filter_freq_##bsize(src, src_linesize, dst, dst_linesize, \ + s->expr[thread_id], s->var_values[thread_id], 0); \ } DEF_FILTER_FREQ_FUNCS(8) @@ -475,7 +481,7 @@ static int config_input(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; DCTdnoizContext *s = ctx->priv; - int i, x, y, bx, by, linesize, *iweights; + int i, x, y, bx, by, linesize, *iweights, max_slice_h, slice_h; const int bsize = 1 << s->n; switch (inlink->format) { @@ -500,6 +506,11 @@ static int config_input(AVFilterLink *inlink) av_log(ctx, AV_LOG_WARNING, "The last %d vertical pixels won't be denoised\n", inlink->h - s->pr_height); + max_slice_h = s->pr_height / ((s->bsize - 1) * 2); + s->nb_threads = FFMIN3(MAX_THREADS, ctx->graph->nb_threads, max_slice_h); + av_log(ctx, AV_LOG_DEBUG, "threads: [max=%d hmax=%d user=%d] => %d\n", + MAX_THREADS, max_slice_h, ctx->graph->nb_threads, s->nb_threads); + s->p_linesize = linesize = FFALIGN(s->pr_width, 32); for (i = 0; i < 2; i++) { s->cbuf[i][0] = av_malloc(linesize * s->pr_height * sizeof(*s->cbuf[i][0])); @@ -509,6 +520,27 @@ static int config_input(AVFilterLink *inlink) return AVERROR(ENOMEM); } + /* eval expressions are probably not thread safe when the eval internal + * state can be changed (typically through load & store operations) */ + if (s->expr_str) { + for (i = 0; i < s->nb_threads; i++) { + int ret = av_expr_parse(&s->expr[i], s->expr_str, var_names, + NULL, NULL, NULL, NULL, 0, ctx); + if (ret < 0) + return ret; + } + } + + /* each slice will need to (pre & re)process the top and bottom block of + * the previous one in in addition to its processing area. This is because + * each pixel is averaged by all the surrounding blocks */ + slice_h = (int)ceilf(s->pr_height / s->nb_threads) + (s->bsize - 1) * 2; + for (i = 0; i < s->nb_threads; i++) { + s->slices[i] = av_malloc_array(linesize, slice_h * sizeof(*s->slices[i])); + if (!s->slices[i]) + return AVERROR(ENOMEM); + } + s->weights = av_malloc(s->pr_height * linesize * sizeof(*s->weights)); if (!s->weights) return AVERROR(ENOMEM); @@ -544,10 +576,6 @@ static av_cold int init(AVFilterContext *ctx) } if (s->expr_str) { - int ret = av_expr_parse(&s->expr, s->expr_str, var_names, - NULL, NULL, NULL, NULL, 0, ctx); - if (ret < 0) - return ret; switch (s->n) { case 3: s->filter_freq_func = filter_freq_expr_8; break; case 4: s->filter_freq_func = filter_freq_expr_16; break; @@ -576,36 +604,56 @@ static int query_formats(AVFilterContext *ctx) return 0; } -static void filter_plane(AVFilterContext *ctx, - float *dst, int dst_linesize, - const float *src, int src_linesize, - int w, int h) +typedef struct ThreadData { + float *src, *dst; +} ThreadData; + +static int filter_slice(AVFilterContext *ctx, + void *arg, int jobnr, int nb_jobs) { int x, y; DCTdnoizContext *s = ctx->priv; - float *dst0 = dst; - const float *weights = s->weights; + const ThreadData *td = arg; + const int w = s->pr_width; + const int h = s->pr_height; + const int slice_start = (h * jobnr ) / nb_jobs; + const int slice_end = (h * (jobnr+1)) / nb_jobs; + const int slice_start_ctx = FFMAX(slice_start - s->bsize + 1, 0); + const int slice_end_ctx = FFMIN(slice_end, h - s->bsize + 1); + const int slice_h = slice_end_ctx - slice_start_ctx; + const int src_linesize = s->p_linesize; + const int dst_linesize = s->p_linesize; + const int slice_linesize = s->p_linesize; + float *dst; + const float *src = td->src + slice_start_ctx * src_linesize; + const float *weights = s->weights + slice_start * dst_linesize; + float *slice = s->slices[jobnr]; // reset block sums - memset(dst, 0, h * dst_linesize * sizeof(*dst)); + memset(slice, 0, (slice_h + s->bsize - 1) * dst_linesize * sizeof(*slice)); // block dct sums - for (y = 0; y < h - s->bsize + 1; y += s->step) { + for (y = 0; y < slice_h; y += s->step) { for (x = 0; x < w - s->bsize + 1; x += s->step) s->filter_freq_func(s, src + x, src_linesize, - dst + x, dst_linesize); + slice + x, slice_linesize, + jobnr); src += s->step * src_linesize; - dst += s->step * dst_linesize; + slice += s->step * slice_linesize; } // average blocks - dst = dst0; - for (y = 0; y < h; y++) { + slice = s->slices[jobnr] + (slice_start - slice_start_ctx) * slice_linesize; + dst = td->dst + slice_start * dst_linesize; + for (y = slice_start; y < slice_end; y++) { for (x = 0; x < w; x++) - dst[x] *= weights[x]; + dst[x] = slice[x] * weights[x]; + slice += slice_linesize; dst += dst_linesize; weights += dst_linesize; } + + return 0; } static int filter_frame(AVFilterLink *inlink, AVFrame *in) @@ -632,10 +680,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) s->color_decorrelation(s->cbuf[0], s->p_linesize, in->data[0], in->linesize[0], s->pr_width, s->pr_height); - for (plane = 0; plane < 3; plane++) - filter_plane(ctx, s->cbuf[1][plane], s->p_linesize, - s->cbuf[0][plane], s->p_linesize, - s->pr_width, s->pr_height); + for (plane = 0; plane < 3; plane++) { + ThreadData td = { + .src = s->cbuf[0][plane], + .dst = s->cbuf[1][plane], + }; + ctx->internal->execute(ctx, filter_slice, &td, NULL, s->nb_threads); + } s->color_correlation(out->data[0], out->linesize[0], s->cbuf[1], s->p_linesize, s->pr_width, s->pr_height); @@ -687,7 +738,10 @@ static av_cold void uninit(AVFilterContext *ctx) av_free(s->cbuf[i][1]); av_free(s->cbuf[i][2]); } - av_expr_free(s->expr); + for (i = 0; i < s->nb_threads; i++) { + av_free(s->slices[i]); + av_expr_free(s->expr[i]); + } } static const AVFilterPad dctdnoiz_inputs[] = { @@ -718,5 +772,5 @@ AVFilter ff_vf_dctdnoiz = { .inputs = dctdnoiz_inputs, .outputs = dctdnoiz_outputs, .priv_class = &dctdnoiz_class, - .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, + .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, }; -- 2.0.2 From andreas.cadhalpun at googlemail.com Sun Aug 10 23:02:52 2014 From: andreas.cadhalpun at googlemail.com (Andreas Cadhalpun) Date: Sun, 10 Aug 2014 23:02:52 +0200 Subject: [FFmpeg-devel] Reintroducing FFmpeg to Debian In-Reply-To: References: <53D5895B.2090102@googlemail.com> <53D64E31.9060701@googlemail.com> <20140808111329.GI15420@smurf.noris.de> <20140808192238.GJ15420@smurf.noris.de> <20140808210347.3970.12508@bastian.jones.dk> <20140809070317.GL1627@smurf.noris.de> <20140810070126.GR1627@smurf.noris.de> Message-ID: <53E7DDFC.4090803@googlemail.com> Hi Reinhard, On 10.08.2014 15:10, Reinhard Tartler wrote: > On Sun, Aug 10, 2014 at 3:01 AM, Matthias Urlichs wrote: >> IMHO it's reasonable to expect core APIs to be upwards-compatible and keep >> deprecated interfaces around for another release or two. > > This is exactly what Libav is doing: The deprecation process for > symbols, APIs, enums, etc. takes *years*, because so many software > packages in Debian and else where use them, and it is so believably > painful to change them. Just have a look at the last two Libav > transitions, and the massive amount of patches it took to get packages > fixed and eventually to get Debian to the new Libav release. > > Now enter FFmpeg. FFmpeg also has a deprecation process and keeps deprecated features around longer than Libav. For example, avcodec_encode_video, av_close_input_file and avcodec_decode_audio3 are still present in FFmpeg, but already removed from Libav. > FFmpeg has a significant higher release frequency, (it seems to me > about every 3-4 months), so that you would get a deprecation cycle > that is considerably less than a year. The deprecation cycle is not related to the release frequency, as many FFmpeg release are API/ABI backwards compatible with the previous one. > In practice, the deprecation > cycle more or less seems to match Libav's cycle, because at least > right now, FFmpeg tracks Libav's API. If that were not the case (and > I promise you FFmpeg would stop tracking Libav as soon as it replaces > Libav in Debian), I can almost guarantee [1] you that FFmpeg would > very much prefer to resume to the deprecation cycle the project > before: None, i.e., every piece of software is expected to keep up > with FFmpeg's master branch for reasons Jean-Yves outlines. I think you won't be able to keep that promise, because it wouldn't make much sense to stop merging changes from Libav (especially, if they are useful) after doing it for such a long time. Even in the unlikely event that this might happen, there is no reason to change the handling of deprecations. > [1] at least statements such as > https://ffmpeg.org/pipermail/ffmpeg-devel/2014-August/160876.html > strongly suggest this (at least if you have followed the > libavresample/libswresample mess). I'm understanding this mail differently: What Michael is explaining is that it is more difficult for FFmpeg to change things in libavresample than in libswresample, because Libav is unlikely to merge back changes, but FFmpeg tries to be compatible with Libav. In reality, there hasn't been any backwards incompatible change in libswresample (still soversion 0), but there has been one in libavresample (now at soversion 1). >>> Keeping your own static version is the only reasonable approach. >> >> That may be OK on Windows. However, a proper Linux distribution is supposed >> to be an integrated whole and not a haphazard collection of programs, each >> bringing along their own copy of core libraries and their own un- or >> semi-fixed security problems. >> > > BTW Jean-Yves outlines an approach that used to be very common on the > past: Pick some particular snapshot of FFmpeg and maintain that in a > downstream project, and expect users to use that because it is too > much effort to keep up with FFmpeg's release frequency. It is easy to 'keep up' with releases that are API/ABI compatible, which many FFmpeg releases are. One doesn't even have to recompile dependent programs (if they are not buggy), one can just install the new version of the libraries. > Prominent > examples of projects that did this (and actually, still do) include > xine-lib, mplayer, xbmc, and many more. This lead exactly to the mess > I was talking about in my previous email: dozens of embedded > code-copies that were accepted into the Debian archive. As you must know, xine-lib and xbmc are - and mplayer was - compiled against the system version of Libav in Debian. > Over many years, I've spearheaded a significant effort in Debian with > packaging and in upstream with introducing a release culture in FFmpeg > (as release manager) to get to somewhat same release frequencies, so > that downstream projects at least had a chance to agree on common > versions of FFmpeg. At the time of the split, I was worried that this > work would have been in vain. It appears your work has not have been in vain, as FFmpeg's current release culture takes into account that any backwards incompatible API change means a lot of work for everyone using it. I believe this is handled now much better than in the times before the 0.5 release. If you are unhappy with how the releases are managed in FFmpeg, you can always send your concerns to ffmpeg-devel (and I think you still have commit rights for FFmpeg's git repository as well). > Considering that most active developers > of FFmpeg at that time (which coincidentally supported my approach to > release management and frequency) joined what is now known as Libav, I > continued my work as upstream release manager in Libav, because I > consider Libav as much more suited for Debian than FFmpeg. Today, I > still firmly believe that this was the right move for Debian as a > project. Conversely, I firmly believe, that the absence of FFmpeg from the archive is bad for Debian's users. The reasons for that can be found in my initial mail in this thread. > I do strongly believe that projects that require people to use FFmpeg > actually mean to use their own private fork (cf. the mythtv debacle), As far as I know, MythTV is the only example for a program that cannot be compiled with a system version of FFmpeg and instead uses its own fork. > and given the amount of packages in Debian, it would significantly > much more effort to "port" (or "patch" as Andreas is phrasing it) them > to some common version of FFmpeg than doing what we are doing now: As I explained in my initial mail in this thread [1], most of these patches are only necessary for switching the packages to pkg-config to detect the FFmpeg linker flags. If the FFmpeg in Debian would use the upstream library names, i.e. the same as Libav, these patches would not be necessary. One still can avoid soname clashes by using the --enable-raise-major configure option and thus bumping all major soversion by 100, but this is not done in order to not use the same namespace that Libav in Debian currently uses and because some programs (I only know of vlc) check for a maximum version of the libraries. There are only a few other changes necessary, and most of them are also needed for Libav 10 (or even totally unrelated to FFmpeg/Libav). For the benefit of everyone, here is a comprehensive list of those: * acoustid-fingerprinter: Still uses CodecID in a codepath not used, when compiled against Libav. * bino: Currently fails to build due to a gettext version mismatch [2]. * dvswitch: Still uses CodecID (and also avcodec_encode_video, but that is still present in FFmpeg.) [3] * ffdiaporama: The libav10.patch introduces incompatible API (avfilter_graph_parse). * k3b: Still uses CodecID (and also av_close_input_file and avcodec_decode_audio3, but these are still present in FFmpeg.) Therefore the FFmpeg plugin has been disabled. [4] * libextractor: Misses build-dependencies for the FFmpeg plugin. [5] * miro: Still uses CodecID (and also fails to build with Libav 10). [6] * mplayer2: MP_INPUT_BUFFER_PADDING_SIZE has to be increased to 32, because FFmpeg needs 32-byte padding. * netgen: Still uses CodecID, av_get_pict_type_char, avcodec_alloc_context and avcodec_open, but the linking with libav libraries has been disabled, see [7]. * renpy: Still uses AVCODEC_MAX_AUDIO_FRAME_SIZE in a codepath not used, when compiled against Libav. * xbmc: The '--enable-libav-compat' needs to be removed, when compiling against FFmpeg. * zoneminder: Misses a build-dependency on libgcrypt11-dev. [8] As you seem to not believe me, I'm going to send all the patches to the BTS, so that everyone can judge the amount of work for themselves. > Making sure they work with the version of Libav's libavcodec.so > implementation. This seems like more work, because, for example, I don't know about any patches fixing the problems XMBC has with Libav and they don't seem to be straightforward to fix. > This thread has shown a couple of examples that > support this argument: Mythtv, but also mplayer that claims to work > with a system libavcodec.so, which is true as long as it matches the > version that is was built against. MythTV shows nothing, because it uses its own fork and MPlayer works fine with a system FFmpeg. There is no need to recompile it, except for a major soversion bump, unless it has bugs I don't know about. Do you know of such bugs? I'm using a version of MPlayer compiled against FFmpeg 2.2 with the FFmpeg libraries from 2.3 and it works for me. > This is what makes mplayer so hard > to package, and was ultimately the reason why I requested mplayer's > removal (which is more than ironic, given that back then, I fought > with ftp-master for many years to get it included into Debian in the > first place). I have read MPlayer's removal bug and it shows clearly that the only reason for its removal was, that it can't be compiled with Libav and upstream is not interested in working on this, because of the missing features in Libav. > On a related note: Most Libav developers are very tired of the > constant flamewars and defamation attempts that arises from FFmpeg. I'm also very tired of flamewars in general and happy that this discussion hasn't become one. > Over years, Libav tries to convinced everyone by providing usable > software releases. That didn't succeed very well, at least not for me and all the other people for which Libav doesn't work correctly. > Nevertheless, this particular debate is very > worrisome: The silence from the Libav camp seems to not to be taken as > consent. Quite the contrary is true. Do you want to say here, that there are many people preferring Libav, who haven't participated in this discussion? This might or might not be true, but I would welcome anyone, who makes a technical argument. > How to proceed from here? TBH, I'm not sure. Ideally, both projects > would find some common ground and "just merge" (however that would > technically look like). Indeed, that would be the ideal solution, ... > However, this very debate within Debian shows > that this is unlikely to happen anytime soon: There is way to much > disagreement on very fundamental questions that require agreement > within a free software project, and the hostile and aggressive tone > the majority of participants in this debate exhibit does not help with > making progress on that front either. ... but I'm also under the impression that there is still too much bad blood between both upstreams for this to happen. On 10.08.2014 16:18, Reinhard Tartler wrote: > On Fri, Aug 8, 2014 at 2:06 PM, Andreas Cadhalpun > wrote: >> It would be nice, if you could also spent some time thinking about >> the possibility of having both FFmpeg and Libav in Debian. > > Please believe me that I did spend a lot of time thinking about this. > I firmly do not think that this is a reasonable approach. Please see > my other email on debian-devel as explanation. To me it seems your other mail (above) doesn't mention the possibility of having both, only: "FFmpeg would stop tracking Libav as soon as it replaces Libav in Debian" But if you are opposed to having both and also opposed to letting FFmpeg replace Libav, it seems that it will be impossible to get a consensus here. Therefore the technical committee will have to decide between: a) having both FFmpeg and Libav in Debian b) only having FFmpeg in Debian c) only having Libav in Debian As I haven't seen any convincing technical argument for only having Libav, I doubt the technical committee's decision will be c). Best regards, Andreas 1: I'm getting tired of this phrase... 2: https://bugs.debian.org/757280 3: https://bugs.debian.org/747868 4: https://bugs.debian.org/739312 5: https://bugs.debian.org/755810 6: https://bugs.debian.org/748861 7: https://bugs.debian.org/751344 8: https://bugs.debian.org/745819 From timothygu99 at gmail.com Mon Aug 11 00:02:32 2014 From: timothygu99 at gmail.com (Timothy Gu) Date: Sun, 10 Aug 2014 15:02:32 -0700 Subject: [FFmpeg-devel] [PATCH] check that reel_name length doesn't exceed UINT16_MAX In-Reply-To: <1407697293-98712-1-git-send-email-mindmark@gmail.com> References: <1407697293-98712-1-git-send-email-mindmark@gmail.com> Message-ID: On Sun, Aug 10, 2014 at 12:01 PM, Mark Reid wrote: > --- > libavformat/movenc.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > index 6a38e89..85fb2e8 100644 > --- a/libavformat/movenc.c > +++ b/libavformat/movenc.c > @@ -1340,13 +1340,21 @@ static int mov_write_rtp_tag(AVIOContext *pb, MOVTrack *track) > return update_size(pb, pos); > } > > -static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack *track, const char *reel_name){ > +static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack *track, const char *reel_name) > +{ > + uint64_t str_size =strlen(reel_name); > + if (str_size >= UINT16_MAX){ > + av_log(NULL, AV_LOG_ERROR, "reel_name length %llu is too large\n", str_size); Shouldn't llu be PRIu64? > + avio_wb16(pb, 0); > + return AVERROR(EINVAL); > + } > + > int64_t pos = avio_tell(pb); > avio_wb32(pb, 0); /* size */ > ffio_wfourcc(pb, "name"); /* Data format */ > - avio_wb16(pb, strlen(reel_name)); /* string size */ > + avio_wb16(pb, str_size); /* string size */ > avio_wb16(pb, track->language); /* langcode */ > - avio_write(pb, reel_name, strlen(reel_name)); /* reel name */ > + avio_write(pb, reel_name, str_size); /* reel name */ > return update_size(pb,pos); > } > > -- > 2.0.0 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel at ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From michaelni at gmx.at Mon Aug 11 00:10:07 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 11 Aug 2014 00:10:07 +0200 Subject: [FFmpeg-devel] [PATCH] check that reel_name length doesn't exceed UINT16_MAX In-Reply-To: References: <1407697293-98712-1-git-send-email-mindmark@gmail.com> Message-ID: <20140810221007.GZ12391@nb4> On Sun, Aug 10, 2014 at 03:02:32PM -0700, Timothy Gu wrote: > On Sun, Aug 10, 2014 at 12:01 PM, Mark Reid wrote: > > --- > > libavformat/movenc.c | 14 +++++++++++--- > > 1 file changed, 11 insertions(+), 3 deletions(-) > > > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > > index 6a38e89..85fb2e8 100644 > > --- a/libavformat/movenc.c > > +++ b/libavformat/movenc.c > > @@ -1340,13 +1340,21 @@ static int mov_write_rtp_tag(AVIOContext *pb, MOVTrack *track) > > return update_size(pb, pos); > > } > > > > -static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack *track, const char *reel_name){ > > +static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack *track, const char *reel_name) > > +{ > > + uint64_t str_size =strlen(reel_name); > > + if (str_size >= UINT16_MAX){ > > > + av_log(NULL, AV_LOG_ERROR, "reel_name length %llu is too large\n", str_size); > > Shouldn't llu be PRIu64? yes, fixed sorry i had missed it [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No great genius has ever existed without some touch of madness. -- Aristotle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 11 00:20:42 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 11 Aug 2014 00:20:42 +0200 Subject: [FFmpeg-devel] rectification filter In-Reply-To: <38A69FEF-DC57-4A95-A90A-EF121EA139F3@googlemail.com> References: <1380A22A-1FDF-418E-8682-016C301E9142@googlemail.com> <20140806101233.GM10372@leki> <20140808101019.GD12391@nb4> <189C1715-453C-4DC3-A5C4-75FFA1799163@googlemail.com> <20140810133603.GA1193@phare.normalesup.org> <20140810155013.GV12391@nb4> <38A69FEF-DC57-4A95-A90A-EF121EA139F3@googlemail.com> Message-ID: <20140810222042.GA12391@nb4> On Sun, Aug 10, 2014 at 08:36:37PM +0200, Daniel Oberhoff wrote: > > > Von meinem iPhone gesendet > > > Am 10.08.2014 um 17:50 schrieb Michael Niedermayer : > > > >> On Sun, Aug 10, 2014 at 03:36:04PM +0200, Nicolas George wrote: > >> Le tridi 23 thermidor, an CCXXII, Paul B Mahol a ?crit : > >>> It is not mandatory(but it would be nice) to add other methods to have > >>> this filter included into libavfilter. > >> > >> Is it really a good idea? We would end up with various interpolation / > >> anti-aliasing algorithms implemented in each filter that needs it, none of > >> them with the same set of architecture optimizations and each with its own > >> set of bugs and misfeatures. > > > >> Until someone comes up with a really satisfactory solution, I believe the > >> simple solution of suggesting users to upscale before the filter and > >> downscale after, using the optimized lswr scalers, is better. > > > > thats not practical > > a 1024x768 image would need to be upscaled to 262144x196608 to get > > 8bit precission from a nearest neighbor resampler as basis > > > > also see vf_perspective.c which supports bilinear and bicubic > > interpolation, these surely could be shared and exist already. > > > > of course we could push it with just nearest neighbor and work on that > > later, but i dont think only nearest neighbor and leaving it at that > > is a reasonable choice, its too poor quality wise > > I would like to push now, and try to generate a refactoring patch possibly within the week. sure, feel free to push and send a pull request, or if you prefer i can allso apply the patch if you post the latest verision Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From ikalvachev at gmail.com Mon Aug 11 01:23:47 2014 From: ikalvachev at gmail.com (Ivan Kalvachev) Date: Mon, 11 Aug 2014 02:23:47 +0300 Subject: [FFmpeg-devel] [RFC][PATCH] Allow include files to be installed into subdirectory Message-ID: The patch is inspired by something I read in the Debian discussion. Libav and FFmpeg could be installed side by side without conflicts in the libraries, thanks to using additional suffixes. However development/include files are still conflicting, so I thought of a simple configure hack to give more control to FFmpeg. With this patch you can do `./configure --extra-incdir="/ffmpeg" ` , as result the header files would be installed in "/usr/local/include/ffmpeg" e.g. "/usr/local/include/ffmpeg/libavcodec/avcodec.h" ... The change is reflected in the pkgconfig files too. Since applications that link to libraries with addition suffixes should be using pkgconfig, they would be using the correct header includes automatically. I did just a rudimentary test and I couldn't spot anything wrong. Please test it before inclusion. As for the future, it might be good idea next major release (e.g. 3.0) to have the $prefix/include/ffmpeg as default include path (for non-comapt build). Best Regards Ivan Kalvachev iive -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Implement-extra-incdir-SUFFIX.patch Type: text/x-diff Size: 1510 bytes Desc: not available URL: From michaelni at gmx.at Mon Aug 11 01:49:19 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 11 Aug 2014 01:49:19 +0200 Subject: [FFmpeg-devel] [PATCH] swresample: Add AVFrame based API Message-ID: <1407714559-14297-1-git-send-email-michaelni@gmx.at> From: Luca Barbato TODO:bump Signed-off-by: Michael Niedermayer --- libswresample/Makefile | 1 + libswresample/swresample.h | 61 +++++++++++++++ libswresample/swresample_frame.c | 158 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 220 insertions(+) create mode 100644 libswresample/swresample_frame.c diff --git a/libswresample/Makefile b/libswresample/Makefile index 75c6535..120ee33 100644 --- a/libswresample/Makefile +++ b/libswresample/Makefile @@ -13,6 +13,7 @@ OBJS = audioconvert.o \ resample.o \ resample_dsp.o \ swresample.o \ + swresample_frame.o \ OBJS-$(CONFIG_LIBSOXR) += soxr_resample.o OBJS-$(CONFIG_SHARED) += log2_tab.o diff --git a/libswresample/swresample.h b/libswresample/swresample.h index 4b8b045..687891b 100644 --- a/libswresample/swresample.h +++ b/libswresample/swresample.h @@ -121,6 +121,7 @@ */ #include +#include "libavutil/frame.h" #include "libavutil/samplefmt.h" #include "libswresample/version.h" @@ -467,6 +468,66 @@ const char *swresample_license(void); /** * @} + * + * @name AVFrame based API + * @{ + */ + +/** + * Convert the samples in the input AVFrame and write them to the output AVFrame. + * + * Input and output AVFrames must have channel_layout, sample_rate and format set. + * + * If the output AVFrame does not have the data pointers allocated the nb_samples + * field will be set using av_frame_get_buffer() + * is called to allocate the frame. + * + * The output AVFrame can be NULL or have fewer allocated samples than required. + * In this case, any remaining samples not written to the output will be added + * to an internal FIFO buffer, to be returned at the next call to this function + * or to swr_convert() or to swr_convert_frame(). + * + * If converting sample rate, there may be data remaining in the internal + * resampling delay buffer. swr_get_delay() tells the number of + * remaining samples. To get this data as output, call this function or + * swr_convert() with NULL input. + * + * If the SwrContext configuration does not match the output and + * input AVFrame settings the conversion does not take place and depending on + * which AVFrame is not matching AVERROR_OUTPUT_CHANGED, AVERROR_INPUT_CHANGED + * or AVERROR_OUTPUT_CHANGED|AVERROR_INPUT_CHANGED is returned. + * + * @see swr_delay() + * @see swr_convert() + * @see swr_get_delay() + * + * @param swr audio resample context + * @param output output AVFrame + * @param input input AVFrame + * @return 0 on success, AVERROR on failure or nonmatching + * configuration. + */ +int swr_convert_frame(SwrContext *swr, + AVFrame *output, AVFrame *input); + +/** + * Configure or reconfigure the SwrContext using the information + * provided by the AVFrames. + * + * The original resampling context is reset even on failure. + * The function calls swr_close() internally if the context is open. + * + * @see swr_close(); + * + * @param swr audio resample context + * @param output output AVFrame + * @param input input AVFrame + * @return 0 on success, AVERROR on failure. + */ +int swr_config_by_frames(SwrContext *swr, AVFrame *out, AVFrame *in); + +/** + * @} * @} */ diff --git a/libswresample/swresample_frame.c b/libswresample/swresample_frame.c new file mode 100644 index 0000000..1b23433 --- /dev/null +++ b/libswresample/swresample_frame.c @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2014 Luca Barbato + * Copyright (c) 2014 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "swresample_internal.h" +#include "libavutil/frame.h" +#include "libavutil/opt.h" + +int swr_config_by_frames(SwrContext *s, AVFrame *out, AVFrame *in) +{ + swr_close(s); + + if (in) { + if (av_opt_set_int(s, "icl", in->channel_layout, 0) < 0) + goto fail; + if (av_opt_set_int(s, "isf", in->format, 0) < 0) + goto fail; + if (av_opt_set_int(s, "isr", in->sample_rate, 0) < 0) + goto fail; + } + + if (out) { + if (av_opt_set_int(s, "ocl", out->channel_layout, 0) < 0) + goto fail; + if (av_opt_set_int(s, "osf", out->format, 0) < 0) + goto fail; + if (av_opt_set_int(s, "osr", out->sample_rate, 0) < 0) + goto fail; + } + + return 0; +fail: + av_log(s, AV_LOG_ERROR, "Failed to set option\n"); + return AVERROR(EINVAL); +} + +static int config_changed(SwrContext *s, + AVFrame *out, AVFrame *in) +{ + int ret = 0; + + if (in) { + if (s->in_ch_layout != in->channel_layout || + s->in_sample_rate != in->sample_rate || + s->in_sample_fmt != in->format) { + ret |= AVERROR_INPUT_CHANGED; + } + } + + if (out) { + if (s->out_ch_layout != out->channel_layout || + s->out_sample_rate != out->sample_rate || + s->out_sample_fmt != out->format) { + ret |= AVERROR_OUTPUT_CHANGED; + } + } + + return ret; +} + +static inline int convert_frame(SwrContext *s, + AVFrame *out, AVFrame *in) +{ + int ret; + uint8_t **out_data = NULL; + const uint8_t **in_data = NULL; + int out_nb_samples = 0, in_nb_samples = 0; + + if (out) { + out_data = out->extended_data; + out_nb_samples = out->nb_samples; + } + + if (in) { + in_data = (const uint8_t **)in->extended_data; + in_nb_samples = in->nb_samples; + } + + ret = swr_convert(s, out_data, out_nb_samples, in_data, in_nb_samples); + + if (ret < 0) { + if (out) + out->nb_samples = 0; + return ret; + } + + if (out) + out->nb_samples = ret; + + return 0; +} + +static inline int available_samples(AVFrame *out) +{ + int bytes_per_sample = av_get_bytes_per_sample(out->format); + int samples = out->linesize[0] / bytes_per_sample; + + if (av_sample_fmt_is_planar(out->format)) { + return samples; + } else { + int channels = av_get_channel_layout_nb_channels(out->channel_layout); + return samples / channels; + } +} + +int swr_convert_frame(SwrContext *s, + AVFrame *out, AVFrame *in) +{ + int ret, setup = 0; + + if (!swr_is_initialized(s)) { + if ((ret = swr_config_by_frames(s, out, in)) < 0) + return ret; + if ((ret = swr_init(s)) < 0) + return ret; + setup = 1; + } else { + // return as is or reconfigure for input changes? + if ((ret = config_changed(s, out, in))) + return ret; + } + + if (out) { + if (!out->linesize[0]) { + out->nb_samples = swr_get_delay(s, s->out_sample_rate) + + in->nb_samples*(int64_t)s->out_sample_rate / s->in_sample_rate + + 3; + if ((ret = av_frame_get_buffer(out, 0)) < 0) { + if (setup) + swr_close(s); + return ret; + } + } else { + if (!out->nb_samples) + out->nb_samples = available_samples(out); + } + } + + return convert_frame(s, out, in); +} + -- 1.7.9.5 From rsbultje at gmail.com Mon Aug 11 02:04:56 2014 From: rsbultje at gmail.com (Ronald S. Bultje) Date: Sun, 10 Aug 2014 20:04:56 -0400 Subject: [FFmpeg-devel] [PATCH] hevc: add missing comma in log message. Message-ID: <1407715496-48160-1-git-send-email-rsbultje@gmail.com> --- libavcodec/hevc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c index cc36f97..985b013 100644 --- a/libavcodec/hevc.c +++ b/libavcodec/hevc.c @@ -2280,7 +2280,7 @@ static int hls_nal_unit(HEVCContext *s) return AVERROR_INVALIDDATA; av_log(s->avctx, AV_LOG_DEBUG, - "nal_unit_type: %d, nuh_layer_id: %dtemporal_id: %d\n", + "nal_unit_type: %d, nuh_layer_id: %d, temporal_id: %d\n", s->nal_unit_type, nuh_layer_id, s->temporal_id); return nuh_layer_id == 0; -- 1.8.5.5 From michaelni at gmx.at Mon Aug 11 02:33:50 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 11 Aug 2014 02:33:50 +0200 Subject: [FFmpeg-devel] [PATCH] hevc: add missing comma in log message. In-Reply-To: <1407715496-48160-1-git-send-email-rsbultje@gmail.com> References: <1407715496-48160-1-git-send-email-rsbultje@gmail.com> Message-ID: <20140811003350.GB12391@nb4> On Sun, Aug 10, 2014 at 08:04:56PM -0400, Ronald S. Bultje wrote: > --- > libavcodec/hevc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Observe your enemies, for they first find out your faults. -- Antisthenes -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 11 03:05:40 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 11 Aug 2014 03:05:40 +0200 Subject: [FFmpeg-devel] [PATCH] hevc: do generic validation of bitstream In-Reply-To: References: Message-ID: <20140811010540.GC12391@nb4> On Sun, Aug 10, 2014 at 07:34:17PM +0200, Christophe Gisquet wrote: > Hi, > > the patch tries to validate these high-level syntax elements. > Unfortunately, it causes fuzzing to be less efficient, eg with the > sequence from ticket #3840 where no frame are decoded. > > -- > Christophe > hevc.c | 6 ++++++ > hevc_ps.c | 18 ++++++++++++++++++ > 2 files changed, 24 insertions(+) > a7187fc5c6c1fe29607fe2f836248f98eb4a51b8 0001-hevc-do-generic-validation-of-bitstream.patch > From 6b60cf2968099fa4395e1e3120ab66d95d4c8709 Mon Sep 17 00:00:00 2001 > From: Christophe Gisquet > Date: Sun, 10 Aug 2014 19:22:06 +0200 > Subject: [PATCH] hevc: do generic validation of bitstream > > After finishing parsing VPS/SPS/PPS/slice header, check remaining bits, > and if an overconsumption occurred, report invalid data. applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Complexity theory is the science of finding the exact solution to an approximation. Benchmarking OTOH is finding an approximation of the exact -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From jamrial at gmail.com Mon Aug 11 04:05:13 2014 From: jamrial at gmail.com (James Almer) Date: Sun, 10 Aug 2014 23:05:13 -0300 Subject: [FFmpeg-devel] [PATCH] swresample: Add AVFrame based API In-Reply-To: <1407714559-14297-1-git-send-email-michaelni@gmx.at> References: <1407714559-14297-1-git-send-email-michaelni@gmx.at> Message-ID: <53E824D9.7060505@gmail.com> On 10/08/14 8:49 PM, Michael Niedermayer wrote: > From: Luca Barbato > > TODO:bump APIChanges entry as well > > Signed-off-by: Michael Niedermayer > --- > libswresample/Makefile | 1 + > libswresample/swresample.h | 61 +++++++++++++++ > libswresample/swresample_frame.c | 158 ++++++++++++++++++++++++++++++++++++++ > 3 files changed, 220 insertions(+) > create mode 100644 libswresample/swresample_frame.c > > diff --git a/libswresample/Makefile b/libswresample/Makefile > index 75c6535..120ee33 100644 > --- a/libswresample/Makefile > +++ b/libswresample/Makefile > @@ -13,6 +13,7 @@ OBJS = audioconvert.o \ > resample.o \ > resample_dsp.o \ > swresample.o \ > + swresample_frame.o \ > > OBJS-$(CONFIG_LIBSOXR) += soxr_resample.o > OBJS-$(CONFIG_SHARED) += log2_tab.o > diff --git a/libswresample/swresample.h b/libswresample/swresample.h > index 4b8b045..687891b 100644 > --- a/libswresample/swresample.h > +++ b/libswresample/swresample.h > @@ -121,6 +121,7 @@ > */ > > #include > +#include "libavutil/frame.h" > #include "libavutil/samplefmt.h" > > #include "libswresample/version.h" > @@ -467,6 +468,66 @@ const char *swresample_license(void); > > /** > * @} > + * > + * @name AVFrame based API > + * @{ > + */ > + > +/** > + * Convert the samples in the input AVFrame and write them to the output AVFrame. > + * > + * Input and output AVFrames must have channel_layout, sample_rate and format set. > + * > + * If the output AVFrame does not have the data pointers allocated the nb_samples > + * field will be set using av_frame_get_buffer() > + * is called to allocate the frame. > + * > + * The output AVFrame can be NULL or have fewer allocated samples than required. > + * In this case, any remaining samples not written to the output will be added > + * to an internal FIFO buffer, to be returned at the next call to this function > + * or to swr_convert() or to swr_convert_frame(). > + * > + * If converting sample rate, there may be data remaining in the internal > + * resampling delay buffer. swr_get_delay() tells the number of > + * remaining samples. To get this data as output, call this function or > + * swr_convert() with NULL input. > + * > + * If the SwrContext configuration does not match the output and > + * input AVFrame settings the conversion does not take place and depending on > + * which AVFrame is not matching AVERROR_OUTPUT_CHANGED, AVERROR_INPUT_CHANGED > + * or AVERROR_OUTPUT_CHANGED|AVERROR_INPUT_CHANGED is returned. > + * > + * @see swr_delay() > + * @see swr_convert() > + * @see swr_get_delay() > + * > + * @param swr audio resample context > + * @param output output AVFrame > + * @param input input AVFrame > + * @return 0 on success, AVERROR on failure or nonmatching > + * configuration. > + */ > +int swr_convert_frame(SwrContext *swr, > + AVFrame *output, AVFrame *input); > + > +/** > + * Configure or reconfigure the SwrContext using the information > + * provided by the AVFrames. > + * > + * The original resampling context is reset even on failure. > + * The function calls swr_close() internally if the context is open. > + * > + * @see swr_close(); > + * > + * @param swr audio resample context > + * @param output output AVFrame > + * @param input input AVFrame > + * @return 0 on success, AVERROR on failure. > + */ > +int swr_config_by_frames(SwrContext *swr, AVFrame *out, AVFrame *in); Maybe swr_config_frame()? From michaelni at gmx.at Mon Aug 11 05:18:32 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 11 Aug 2014 05:18:32 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec: add C xvid IDCT support Message-ID: <1407727112-14083-1-git-send-email-michaelni@gmx.at> From: Pascal Massimino Thanks to Pascal Massimino and Michael Militzer for permission to use under LGPL Signed-off-by: Michael Niedermayer --- libavcodec/Makefile | 2 +- libavcodec/xvid_c_idct.c | 335 ++++++++++++++++++++++++++++++++++++++++++++++ libavcodec/xvididct.c | 60 +++++++++ libavcodec/xvididct.h | 2 + 4 files changed, 398 insertions(+), 1 deletion(-) create mode 100644 libavcodec/xvid_c_idct.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 6873439..55b7b02 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -325,7 +325,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o -OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o +OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o xvid_c_idct.o OBJS-$(CONFIG_MPL2_DECODER) += mpl2dec.o ass.o OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o OBJS-$(CONFIG_MSMPEG4V2_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o diff --git a/libavcodec/xvid_c_idct.c b/libavcodec/xvid_c_idct.c new file mode 100644 index 0000000..b15fb8e --- /dev/null +++ b/libavcodec/xvid_c_idct.c @@ -0,0 +1,335 @@ +/***************************************************************************** + * + * XVID MPEG-4 VIDEO CODEC + * - Inverse DCT - + * + * Copyright (C) 2006-2011 Xvid Solutions GmbH + * + * This file is part of FFmpeg. + * + * 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 + * + * $Id$ + * + ****************************************************************************/ + +/* + * Authors: Skal + * + * Walken IDCT + * Alternative idct implementations for decoding compatibility + * + * NOTE: this "C" version is not the original one, + * but is modified to yield the same error profile + * than the MMX version. + * + ************************************************************************/ + +#include "xvididct.h" + + +#define XVID_DSP_CLIP_255(x) ( ((x)&~255) ? ((-(x)) >> (8*sizeof((x))-1))&0xff : (x) ) + +#define ROW_SHIFT 11 +#define COL_SHIFT 6 + +// #define FIX(x) (int)((x) * (1<> ROW_SHIFT; + In[1] = (a1 + b1) >> ROW_SHIFT; + In[2] = (a2 + b2) >> ROW_SHIFT; + In[3] = (a3 + b3) >> ROW_SHIFT; + In[4] = (a3 - b3) >> ROW_SHIFT; + In[5] = (a2 - b2) >> ROW_SHIFT; + In[6] = (a1 - b1) >> ROW_SHIFT; + In[7] = (a0 - b0) >> ROW_SHIFT; + } + else + { + const int a0 = K >> ROW_SHIFT; + if (a0) { + In[0] = In[1] = In[2] = In[3] = + In[4] = In[5] = In[6] = In[7] = a0; + } + else return 0; + } + } + else if (!(Left|Right)) + { + const int a0 = (Rnd + C4*(In[0]+In[4])) >> ROW_SHIFT; + const int a1 = (Rnd + C4*(In[0]-In[4])) >> ROW_SHIFT; + + In[0] = a0; + In[3] = a0; + In[4] = a0; + In[7] = a0; + In[1] = a1; + In[2] = a1; + In[5] = a1; + In[6] = a1; + } + else + { + const int K = C4*In[0] + Rnd; + const int a0 = K + C2*In[2] + C4*In[4] + C6*In[6]; + const int a1 = K + C6*In[2] - C4*In[4] - C2*In[6]; + const int a2 = K - C6*In[2] - C4*In[4] + C2*In[6]; + const int a3 = K - C2*In[2] + C4*In[4] - C6*In[6]; + + const int b0 = C1*In[1] + C3*In[3] + C5*In[5] + C7*In[7]; + const int b1 = C3*In[1] - C7*In[3] - C1*In[5] - C5*In[7]; + const int b2 = C5*In[1] - C1*In[3] + C7*In[5] + C3*In[7]; + const int b3 = C7*In[1] - C5*In[3] + C3*In[5] - C1*In[7]; + + In[0] = (a0 + b0) >> ROW_SHIFT; + In[1] = (a1 + b1) >> ROW_SHIFT; + In[2] = (a2 + b2) >> ROW_SHIFT; + In[3] = (a3 + b3) >> ROW_SHIFT; + In[4] = (a3 - b3) >> ROW_SHIFT; + In[5] = (a2 - b2) >> ROW_SHIFT; + In[6] = (a1 - b1) >> ROW_SHIFT; + In[7] = (a0 - b0) >> ROW_SHIFT; + } + return 1; +} + +#define Tan1 0x32ec +#define Tan2 0x6a0a +#define Tan3 0xab0e +#define Sqrt2 0x5a82 + +#define MULT(c,x, n) ( ((c) * (x)) >> (n) ) +// 12b version => #define MULT(c,x, n) ( (((c)>>3) * (x)) >> ((n)-3) ) +// 12b zero-testing version: + +#define BUTF(a, b, tmp) \ + (tmp) = (a)+(b); \ + (b) = (a)-(b); \ + (a) = (tmp) + +#define LOAD_BUTF(m1, m2, a, b, tmp, S) \ + (m1) = (S)[(a)] + (S)[(b)]; \ + (m2) = (S)[(a)] - (S)[(b)] + +static void Idct_Col_8(short * const In) +{ + int mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7, Spill; + + // odd + + mm4 = (int)In[7*8]; + mm5 = (int)In[5*8]; + mm6 = (int)In[3*8]; + mm7 = (int)In[1*8]; + + mm0 = MULT(Tan1, mm4, 16) + mm7; + mm1 = MULT(Tan1, mm7, 16) - mm4; + mm2 = MULT(Tan3, mm5, 16) + mm6; + mm3 = MULT(Tan3, mm6, 16) - mm5; + + mm7 = mm0 + mm2; + mm4 = mm1 - mm3; + mm0 = mm0 - mm2; + mm1 = mm1 + mm3; + mm6 = mm0 + mm1; + mm5 = mm0 - mm1; + mm5 = 2*MULT(Sqrt2, mm5, 16); // 2*sqrt2 + mm6 = 2*MULT(Sqrt2, mm6, 16); // Watch out: precision loss but done to match + // the pmulhw used in mmx/sse versions + + // even + + mm1 = (int)In[2*8]; + mm2 = (int)In[6*8]; + mm3 = MULT(Tan2,mm2, 16) + mm1; + mm2 = MULT(Tan2,mm1, 16) - mm2; + + LOAD_BUTF(mm0, mm1, 0*8, 4*8, Spill, In); + + BUTF(mm0, mm3, Spill); + BUTF(mm0, mm7, Spill); + In[8*0] = (int16_t) (mm0 >> COL_SHIFT); + In[8*7] = (int16_t) (mm7 >> COL_SHIFT); + BUTF(mm3, mm4, mm0); + In[8*3] = (int16_t) (mm3 >> COL_SHIFT); + In[8*4] = (int16_t) (mm4 >> COL_SHIFT); + + BUTF(mm1, mm2, mm0); + BUTF(mm1, mm6, mm0); + In[8*1] = (int16_t) (mm1 >> COL_SHIFT); + In[8*6] = (int16_t) (mm6 >> COL_SHIFT); + BUTF(mm2, mm5, mm0); + In[8*2] = (int16_t) (mm2 >> COL_SHIFT); + In[8*5] = (int16_t) (mm5 >> COL_SHIFT); +} + +static void Idct_Col_4(short * const In) +{ + int mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7, Spill; + + // odd + + mm0 = (int)In[1*8]; + mm2 = (int)In[3*8]; + + mm1 = MULT(Tan1, mm0, 16); + mm3 = MULT(Tan3, mm2, 16); + + mm7 = mm0 + mm2; + mm4 = mm1 - mm3; + mm0 = mm0 - mm2; + mm1 = mm1 + mm3; + mm6 = mm0 + mm1; + mm5 = mm0 - mm1; + mm6 = 2*MULT(Sqrt2, mm6, 16); // 2*sqrt2 + mm5 = 2*MULT(Sqrt2, mm5, 16); + + // even + + mm0 = mm1 = (int)In[0*8]; + mm3 = (int)In[2*8]; + mm2 = MULT(Tan2,mm3, 16); + + BUTF(mm0, mm3, Spill); + BUTF(mm0, mm7, Spill); + In[8*0] = (int16_t) (mm0 >> COL_SHIFT); + In[8*7] = (int16_t) (mm7 >> COL_SHIFT); + BUTF(mm3, mm4, mm0); + In[8*3] = (int16_t) (mm3 >> COL_SHIFT); + In[8*4] = (int16_t) (mm4 >> COL_SHIFT); + + BUTF(mm1, mm2, mm0); + BUTF(mm1, mm6, mm0); + In[8*1] = (int16_t) (mm1 >> COL_SHIFT); + In[8*6] = (int16_t) (mm6 >> COL_SHIFT); + BUTF(mm2, mm5, mm0); + In[8*2] = (int16_t) (mm2 >> COL_SHIFT); + In[8*5] = (int16_t) (mm5 >> COL_SHIFT); +} + +static void Idct_Col_3(short * const In) +{ + int mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7, Spill; + + // odd + + mm7 = (int)In[1*8]; + mm4 = MULT(Tan1, mm7, 16); + + mm6 = mm7 + mm4; + mm5 = mm7 - mm4; + mm6 = 2*MULT(Sqrt2, mm6, 16); // 2*sqrt2 + mm5 = 2*MULT(Sqrt2, mm5, 16); + + // even + + mm0 = mm1 = (int)In[0*8]; + mm3 = (int)In[2*8]; + mm2 = MULT(Tan2,mm3, 16); + + BUTF(mm0, mm3, Spill); + BUTF(mm0, mm7, Spill); + In[8*0] = (int16_t) (mm0 >> COL_SHIFT); + In[8*7] = (int16_t) (mm7 >> COL_SHIFT); + BUTF(mm3, mm4, mm0); + In[8*3] = (int16_t) (mm3 >> COL_SHIFT); + In[8*4] = (int16_t) (mm4 >> COL_SHIFT); + + BUTF(mm1, mm2, mm0); + BUTF(mm1, mm6, mm0); + In[8*1] = (int16_t) (mm1 >> COL_SHIFT); + In[8*6] = (int16_t) (mm6 >> COL_SHIFT); + BUTF(mm2, mm5, mm0); + In[8*2] = (int16_t) (mm2 >> COL_SHIFT); + In[8*5] = (int16_t) (mm5 >> COL_SHIFT); +} + +#undef Tan1 +#undef Tan2 +#undef Tan3 +#undef Sqrt2 + +#undef ROW_SHIFT +#undef COL_SHIFT + +////////////////////////////////////////////////////////// + +void ff_idct_xvid(int16_t *const In) +{ + int i, Rows = 0x07; + + Idct_Row(In + 0*8, Tab04, Rnd0); + Idct_Row(In + 1*8, Tab17, Rnd1); + Idct_Row(In + 2*8, Tab26, Rnd2); + if (Idct_Row(In + 3*8, Tab35, Rnd3)) Rows |= 0x08; + if (Idct_Row(In + 4*8, Tab04, Rnd4)) Rows |= 0x10; + if (Idct_Row(In + 5*8, Tab35, Rnd5)) Rows |= 0x20; + if (Idct_Row(In + 6*8, Tab26, Rnd6)) Rows |= 0x40; + if (Idct_Row(In + 7*8, Tab17, Rnd7)) Rows |= 0x80; + + if (Rows&0xf0) { + for(i=0; i<8; i++) + Idct_Col_8(In + i); + } + else if (Rows&0x08) { + for(i=0; i<8; i++) + Idct_Col_4(In + i); + } + else { + for(i=0; i<8; i++) + Idct_Col_3(In + i); + } +} diff --git a/libavcodec/xvididct.c b/libavcodec/xvididct.c index 8645af4..9b07518 100644 --- a/libavcodec/xvididct.c +++ b/libavcodec/xvididct.c @@ -22,6 +22,59 @@ #include "idctdsp.h" #include "xvididct.h" +static void put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, + int line_size) +{ + int i; + + /* read the pixels */ + for (i = 0; i < 8; i++) { + pixels[0] = av_clip_uint8(block[0]); + pixels[1] = av_clip_uint8(block[1]); + pixels[2] = av_clip_uint8(block[2]); + pixels[3] = av_clip_uint8(block[3]); + pixels[4] = av_clip_uint8(block[4]); + pixels[5] = av_clip_uint8(block[5]); + pixels[6] = av_clip_uint8(block[6]); + pixels[7] = av_clip_uint8(block[7]); + + pixels += line_size; + block += 8; + } +} + +static void add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, + int line_size) +{ + int i; + + /* read the pixels */ + for (i = 0; i < 8; i++) { + pixels[0] = av_clip_uint8(pixels[0] + block[0]); + pixels[1] = av_clip_uint8(pixels[1] + block[1]); + pixels[2] = av_clip_uint8(pixels[2] + block[2]); + pixels[3] = av_clip_uint8(pixels[3] + block[3]); + pixels[4] = av_clip_uint8(pixels[4] + block[4]); + pixels[5] = av_clip_uint8(pixels[5] + block[5]); + pixels[6] = av_clip_uint8(pixels[6] + block[6]); + pixels[7] = av_clip_uint8(pixels[7] + block[7]); + pixels += line_size; + block += 8; + } +} + +static void idct_xvid_put(uint8_t *dest, int line_size, int16_t *block) +{ + ff_idct_xvid(block); + put_pixels_clamped_c(block, dest, line_size); +} + +static void idct_xvid_add(uint8_t *dest, int line_size, int16_t *block) +{ + ff_idct_xvid(block); + add_pixels_clamped_c(block, dest, line_size); +} + av_cold void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx) { const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; @@ -31,6 +84,13 @@ av_cold void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx) avctx->idct_algo == FF_IDCT_XVID)) return; + if (avctx->idct_algo == FF_IDCT_XVID) { + c->idct_put = idct_xvid_put; + c->idct_add = idct_xvid_add; + c->idct = ff_idct_xvid; + c->perm_type = FF_IDCT_PERM_NONE; + } + if (ARCH_X86) ff_xvididct_init_x86(c); diff --git a/libavcodec/xvididct.h b/libavcodec/xvididct.h index 6678329..1b95cb7 100644 --- a/libavcodec/xvididct.h +++ b/libavcodec/xvididct.h @@ -26,4 +26,6 @@ void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx); void ff_xvididct_init_x86(IDCTDSPContext *c); +void ff_idct_xvid(int16_t *const In); + #endif /* AVCODEC_XVIDIDCT_H */ -- 1.7.9.5 From jamrial at gmail.com Mon Aug 11 05:36:56 2014 From: jamrial at gmail.com (James Almer) Date: Mon, 11 Aug 2014 00:36:56 -0300 Subject: [FFmpeg-devel] [PATCH] avcodec: add C xvid IDCT support In-Reply-To: <1407727112-14083-1-git-send-email-michaelni@gmx.at> References: <1407727112-14083-1-git-send-email-michaelni@gmx.at> Message-ID: <53E83A58.6070706@gmail.com> On 11/08/14 12:18 AM, Michael Niedermayer wrote: > From: Pascal Massimino > > Thanks to Pascal Massimino and Michael Militzer for permission to use under LGPL > Signed-off-by: Michael Niedermayer > --- > libavcodec/Makefile | 2 +- > libavcodec/xvid_c_idct.c | 335 ++++++++++++++++++++++++++++++++++++++++++++++ > libavcodec/xvididct.c | 60 +++++++++ > libavcodec/xvididct.h | 2 + > 4 files changed, 398 insertions(+), 1 deletion(-) > create mode 100644 libavcodec/xvid_c_idct.c > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 6873439..55b7b02 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -325,7 +325,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o > OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o > OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o > OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o > -OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o > +OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o xvid_c_idct.o > OBJS-$(CONFIG_MPL2_DECODER) += mpl2dec.o ass.o > OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o > OBJS-$(CONFIG_MSMPEG4V2_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o > diff --git a/libavcodec/xvid_c_idct.c b/libavcodec/xvid_c_idct.c > new file mode 100644 > index 0000000..b15fb8e > --- /dev/null > +++ b/libavcodec/xvid_c_idct.c > @@ -0,0 +1,335 @@ > +/***************************************************************************** > + * > + * XVID MPEG-4 VIDEO CODEC > + * - Inverse DCT - > + * > + * Copyright (C) 2006-2011 Xvid Solutions GmbH > + * > + * This file is part of FFmpeg. > + * > + * 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 > + * > + * $Id$ > + * > + ****************************************************************************/ > + > +/* > + * Authors: Skal > + * > + * Walken IDCT > + * Alternative idct implementations for decoding compatibility > + * > + * NOTE: this "C" version is not the original one, > + * but is modified to yield the same error profile > + * than the MMX version. > + * > + ************************************************************************/ Is a separate file really necessary? The above copyright could be copied to xvididct.c just fine. It's all lgpl code. [...] > diff --git a/libavcodec/xvididct.c b/libavcodec/xvididct.c > index 8645af4..9b07518 100644 > --- a/libavcodec/xvididct.c > +++ b/libavcodec/xvididct.c > @@ -22,6 +22,59 @@ > #include "idctdsp.h" > #include "xvididct.h" > > +static void put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, > + int line_size) > +{ > + int i; > + > + /* read the pixels */ > + for (i = 0; i < 8; i++) { > + pixels[0] = av_clip_uint8(block[0]); > + pixels[1] = av_clip_uint8(block[1]); > + pixels[2] = av_clip_uint8(block[2]); > + pixels[3] = av_clip_uint8(block[3]); > + pixels[4] = av_clip_uint8(block[4]); > + pixels[5] = av_clip_uint8(block[5]); > + pixels[6] = av_clip_uint8(block[6]); > + pixels[7] = av_clip_uint8(block[7]); > + > + pixels += line_size; > + block += 8; > + } > +} > + > +static void add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, > + int line_size) > +{ > + int i; > + > + /* read the pixels */ > + for (i = 0; i < 8; i++) { > + pixels[0] = av_clip_uint8(pixels[0] + block[0]); > + pixels[1] = av_clip_uint8(pixels[1] + block[1]); > + pixels[2] = av_clip_uint8(pixels[2] + block[2]); > + pixels[3] = av_clip_uint8(pixels[3] + block[3]); > + pixels[4] = av_clip_uint8(pixels[4] + block[4]); > + pixels[5] = av_clip_uint8(pixels[5] + block[5]); > + pixels[6] = av_clip_uint8(pixels[6] + block[6]); > + pixels[7] = av_clip_uint8(pixels[7] + block[7]); > + pixels += line_size; > + block += 8; > + } > +} Why the code duplication? These two functions are exact copies of the ones in idctdsp. You could share the latter and use them here instead. > + > +static void idct_xvid_put(uint8_t *dest, int line_size, int16_t *block) > +{ > + ff_idct_xvid(block); > + put_pixels_clamped_c(block, dest, line_size); > +} > + > +static void idct_xvid_add(uint8_t *dest, int line_size, int16_t *block) > +{ > + ff_idct_xvid(block); > + add_pixels_clamped_c(block, dest, line_size); > +} > + > av_cold void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx) > { > const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; > @@ -31,6 +84,13 @@ av_cold void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx) > avctx->idct_algo == FF_IDCT_XVID)) > return; > > + if (avctx->idct_algo == FF_IDCT_XVID) { > + c->idct_put = idct_xvid_put; > + c->idct_add = idct_xvid_add; > + c->idct = ff_idct_xvid; > + c->perm_type = FF_IDCT_PERM_NONE; > + } > + > if (ARCH_X86) > ff_xvididct_init_x86(c); > > diff --git a/libavcodec/xvididct.h b/libavcodec/xvididct.h > index 6678329..1b95cb7 100644 > --- a/libavcodec/xvididct.h > +++ b/libavcodec/xvididct.h > @@ -26,4 +26,6 @@ void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx); > > void ff_xvididct_init_x86(IDCTDSPContext *c); > > +void ff_idct_xvid(int16_t *const In); > + > #endif /* AVCODEC_XVIDIDCT_H */ > From jamrial at gmail.com Mon Aug 11 07:23:03 2014 From: jamrial at gmail.com (James Almer) Date: Mon, 11 Aug 2014 02:23:03 -0300 Subject: [FFmpeg-devel] [PATCH 1/4] lavc: stop exporting internal functions and tables In-Reply-To: <1407629075-13514-1-git-send-email-jamrial@gmail.com> References: <1407629075-13514-1-git-send-email-jamrial@gmail.com> Message-ID: <53E85337.5050705@gmail.com> On 09/08/14 9:04 PM, James Almer wrote: > Signed-off-by: James Almer > --- > libavcodec/libavcodec.v | 18 ------------------ > 1 file changed, 18 deletions(-) > > diff --git a/libavcodec/libavcodec.v b/libavcodec/libavcodec.v > index be74cb3..c923cd3 100644 > --- a/libavcodec/libavcodec.v > +++ b/libavcodec/libavcodec.v > @@ -3,23 +3,5 @@ LIBAVCODEC_$MAJOR { > #deprecated, remove after next bump > audio_resample; > audio_resample_close; > - ff_raw_pix_fmt_tags; > - ff_fft*; > - ff_mdct*; > - ff_dct*; > - ff_rdft*; > - ff_prores_idct_put_10_sse2; > - ff_simple_idct*; > - ff_aanscales; > - ff_faan*; > - ff_fdct*; > - ff_idct_xvid*; > - ff_jpeg_fdct*; > - ff_dnxhd_get_cid_table; > - ff_dnxhd_cid_table; > - ff_idctdsp_init; > - ff_fdctdsp_init; > - ff_pixblockdsp_init; > - ff_me_cmp_init; > local: *; > }; Ping for patchset. From u at pkh.me Mon Aug 11 07:44:25 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Mon, 11 Aug 2014 07:44:25 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec: add C xvid IDCT support In-Reply-To: <1407727112-14083-1-git-send-email-michaelni@gmx.at> References: <1407727112-14083-1-git-send-email-michaelni@gmx.at> Message-ID: <20140811054425.GB15763@leki> On Mon, Aug 11, 2014 at 05:18:32AM +0200, Michael Niedermayer wrote: > From: Pascal Massimino > > Thanks to Pascal Massimino and Michael Militzer for permission to use under LGPL > Signed-off-by: Michael Niedermayer > --- > libavcodec/Makefile | 2 +- > libavcodec/xvid_c_idct.c | 335 ++++++++++++++++++++++++++++++++++++++++++++++ > libavcodec/xvididct.c | 60 +++++++++ > libavcodec/xvididct.h | 2 + > 4 files changed, 398 insertions(+), 1 deletion(-) > create mode 100644 libavcodec/xvid_c_idct.c > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 6873439..55b7b02 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -325,7 +325,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o > OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o > OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o > OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o > -OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o > +OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o xvid_c_idct.o > OBJS-$(CONFIG_MPL2_DECODER) += mpl2dec.o ass.o > OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o > OBJS-$(CONFIG_MSMPEG4V2_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o > diff --git a/libavcodec/xvid_c_idct.c b/libavcodec/xvid_c_idct.c > new file mode 100644 > index 0000000..b15fb8e > --- /dev/null > +++ b/libavcodec/xvid_c_idct.c > @@ -0,0 +1,335 @@ > +/***************************************************************************** > + * > + * XVID MPEG-4 VIDEO CODEC > + * - Inverse DCT - > + * > + * Copyright (C) 2006-2011 Xvid Solutions GmbH > + * > + * This file is part of FFmpeg. > + * > + * 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 > + * > + * $Id$ > + * No meaning in FFmpeg/git > + ****************************************************************************/ > + > +/* > + * Authors: Skal > + * > + * Walken IDCT > + * Alternative idct implementations for decoding compatibility > + * > + * NOTE: this "C" version is not the original one, > + * but is modified to yield the same error profile > + * than the MMX version. > + * > + ************************************************************************/ > + /** * @file * Walken IDCT * Alternative idct implementations for decoding compatibility * * @author Skal * @note this "C" version is not the original one, but is modified to * yield the same error profile than the MMX version. */ > +#include "xvididct.h" > + > + > +#define XVID_DSP_CLIP_255(x) ( ((x)&~255) ? ((-(x)) >> (8*sizeof((x))-1))&0xff : (x) ) Looks unused > + > +#define ROW_SHIFT 11 > +#define COL_SHIFT 6 > + > +// #define FIX(x) (int)((x) * (1< +#define Rnd0 65536 // 1<<(COL_SHIFT+ROW_SHIFT-1); > +#define Rnd1 3597 // FIX (1.75683487303); > +#define Rnd2 2260 // FIX (1.10355339059); > +#define Rnd3 1203 // FIX (0.587788325588); > +#define Rnd4 0 > +#define Rnd5 120 // FIX (0.058658283817); > +#define Rnd6 512 // FIX (0.25); > +#define Rnd7 512 // FIX (0.25); > +#undef FIX Mot defined > + > +static const int Tab04[] = { 22725, 21407, 19266, 16384, 12873, 8867, 4520 }; > +static const int Tab17[] = { 31521, 29692, 26722, 22725, 17855, 12299, 6270 }; > +static const int Tab26[] = { 29692, 27969, 25172, 21407, 16819, 11585, 5906 }; > +static const int Tab35[] = { 26722, 25172, 22654, 19266, 15137, 10426, 5315 }; > + > +static int Idct_Row(short * In, const int * const Tab, int Rnd) > +{ > + const int C1 = Tab[0]; > + const int C2 = Tab[1]; > + const int C3 = Tab[2]; > + const int C4 = Tab[3]; > + const int C5 = Tab[4]; > + const int C6 = Tab[5]; > + const int C7 = Tab[6]; > + > + const int Right = In[5]|In[6]|In[7]; > + const int Left = In[1]|In[2]|In[3]; > + if (!(Right | In[4])) > + { > + const int K = C4*In[0] + Rnd; > + if (Left) > + { If you could fix the style and indent to match FFmpeg one a little that would be great. [...] > +static void idct_xvid_put(uint8_t *dest, int line_size, int16_t *block) > +{ > + ff_idct_xvid(block); > + put_pixels_clamped_c(block, dest, line_size); > +} > + > +static void idct_xvid_add(uint8_t *dest, int line_size, int16_t *block) > +{ > + ff_idct_xvid(block); > + add_pixels_clamped_c(block, dest, line_size); > +} > + So the function takes a destination buffer but still destroys the input block? > av_cold void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx) > { > const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; > @@ -31,6 +84,13 @@ av_cold void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx) > avctx->idct_algo == FF_IDCT_XVID)) > return; > > + if (avctx->idct_algo == FF_IDCT_XVID) { > + c->idct_put = idct_xvid_put; > + c->idct_add = idct_xvid_add; > + c->idct = ff_idct_xvid; > + c->perm_type = FF_IDCT_PERM_NONE; > + } > + > if (ARCH_X86) > ff_xvididct_init_x86(c); > > diff --git a/libavcodec/xvididct.h b/libavcodec/xvididct.h > index 6678329..1b95cb7 100644 > --- a/libavcodec/xvididct.h > +++ b/libavcodec/xvididct.h > @@ -26,4 +26,6 @@ void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx); > > void ff_xvididct_init_x86(IDCTDSPContext *c); > > +void ff_idct_xvid(int16_t *const In); ... looks like misleading const [...] -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From u at pkh.me Mon Aug 11 10:02:54 2014 From: u at pkh.me (=?utf-8?B?Q2zDqW1lbnQgQsWTc2No?=) Date: Mon, 11 Aug 2014 10:02:54 +0200 Subject: [FFmpeg-devel] [PATCH] swresample: Add AVFrame based API In-Reply-To: <1407714559-14297-1-git-send-email-michaelni@gmx.at> References: <1407714559-14297-1-git-send-email-michaelni@gmx.at> Message-ID: <20140811080254.GC15763@leki> On Mon, Aug 11, 2014 at 01:49:19AM +0200, Michael Niedermayer wrote: > From: Luca Barbato > > TODO:bump > > Signed-off-by: Michael Niedermayer > --- > libswresample/Makefile | 1 + > libswresample/swresample.h | 61 +++++++++++++++ > libswresample/swresample_frame.c | 158 ++++++++++++++++++++++++++++++++++++++ > 3 files changed, 220 insertions(+) > create mode 100644 libswresample/swresample_frame.c > [...] > +/** > + * Convert the samples in the input AVFrame and write them to the output AVFrame. > + * > + * Input and output AVFrames must have channel_layout, sample_rate and format set. > + * > + * If the output AVFrame does not have the data pointers allocated the nb_samples > + * field will be set using av_frame_get_buffer() > + * is called to allocate the frame. > + * > + * The output AVFrame can be NULL or have fewer allocated samples than required. > + * In this case, any remaining samples not written to the output will be added > + * to an internal FIFO buffer, to be returned at the next call to this function > + * or to swr_convert() or to swr_convert_frame(). > + * > + * If converting sample rate, there may be data remaining in the internal > + * resampling delay buffer. swr_get_delay() tells the number of > + * remaining samples. To get this data as output, call this function or > + * swr_convert() with NULL input. > + * > + * If the SwrContext configuration does not match the output and > + * input AVFrame settings the conversion does not take place and depending on > + * which AVFrame is not matching AVERROR_OUTPUT_CHANGED, AVERROR_INPUT_CHANGED > + * or AVERROR_OUTPUT_CHANGED|AVERROR_INPUT_CHANGED is returned. > + * > + * @see swr_delay() > + * @see swr_convert() > + * @see swr_get_delay() > + * > + * @param swr audio resample context > + * @param output output AVFrame > + * @param input input AVFrame > + * @return 0 on success, AVERROR on failure or nonmatching > + * configuration. > + */ > +int swr_convert_frame(SwrContext *swr, > + AVFrame *output, AVFrame *input); > + Is it possible to have input AVFrame const or it needs to increment references or something? [...] -- Cl?ment B. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From kierank at obe.tv Mon Aug 11 10:25:20 2014 From: kierank at obe.tv (Kieran Kunhya) Date: Mon, 11 Aug 2014 09:25:20 +0100 Subject: [FFmpeg-devel] [PATCH] swresample: Add AVFrame based API In-Reply-To: <1407714559-14297-1-git-send-email-michaelni@gmx.at> References: <1407714559-14297-1-git-send-email-michaelni@gmx.at> Message-ID: On 11 August 2014 00:49, Michael Niedermayer wrote: > From: Luca Barbato Clearly this is Luca's patch but rewritten by you for swr so you should say "Based on patch from Luca for avresample" or similar. IANAL but this is quite dubious from a copyright perspective. From james.darnley at gmail.com Mon Aug 11 10:56:11 2014 From: james.darnley at gmail.com (James Darnley) Date: Mon, 11 Aug 2014 10:56:11 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec: add C xvid IDCT support In-Reply-To: <20140811054425.GB15763@leki> References: <1407727112-14083-1-git-send-email-michaelni@gmx.at> <20140811054425.GB15763@leki> Message-ID: <53E8852B.6010804@gmail.com> On 2014-08-11 07:44, Cl?ment B?sch wrote: > /** > * @file > * Walken IDCT > * Alternative idct implementations for decoding compatibility > * > * @author Skal > * @note this "C" version is not the original one, but is modified to > * yield the same error profile than the MMX version. A minor grammar nit: yield the same error profile *as* the MMX version. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 618 bytes Desc: OpenPGP digital signature URL: From lingjiujianke at gmail.com Mon Aug 11 11:39:37 2014 From: lingjiujianke at gmail.com (Steven Liu) Date: Mon, 11 Aug 2014 17:39:37 +0800 Subject: [FFmpeg-devel] [PATCH] delete the old segment file from hls list Message-ID: Hi Guys, The FFmpeg hls module can make m3u8 and ts, but it dosen't delete the old ts segment file. If always run this module, the disk will full, so this patch can fix the problem. When update the segment list m3u8 file, it will delete the ts segment out range from the list file. before use this patch: [root at localhost ffmpeg]# ls *.ts *.m3u8 a0.ts a10.ts a11.ts a12.ts a13.ts a14.ts a15.ts a16.ts a17.ts a18.ts a19.ts a1.ts a20.ts a2.ts a3.ts a4.ts a5.ts a6.ts a7.ts a8.ts a9.ts a.m3u8 [root at localhost ffmpeg]# cat a.m3u8 #EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:11 #EXT-X-MEDIA-SEQUENCE:16 #EXTINF:10.427075, a16.ts #EXTINF:10.427075, a17.ts #EXTINF:10.427075, a18.ts #EXTINF:10.427075, a19.ts #EXTINF:3.670330, a20.ts #EXT-X-ENDLIST [root at localhost ffmpeg]# after use this patch: [root at localhost ffmpeg]# ls *.ts *.m3u8 a10.ts a11.ts a12.ts a13.ts a9.ts a.m3u8 [root at localhost ffmpeg]# cat a.m3u8 #EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:11 #EXT-X-MEDIA-SEQUENCE:9 #EXTINF:10.427075, a9.ts #EXTINF:10.427075, a10.ts #EXTINF:10.427075, a11.ts #EXTINF:10.427075, a12.ts #EXTINF:2.335665, a13.ts #EXT-X-ENDLIST [root at localhost ffmpeg]# ------------------------------------------- The patch context: when update the hls m3u8 list, the old file is not unlinked this patch can do this operation Signed-off-by: Steven Liu --- libavformat/hlsenc.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 11f1e5b..2ee0970 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -30,6 +30,10 @@ #include "avformat.h" #include "internal.h" +#if HAVE_UNISTD_H +#include +#endif + typedef struct HLSSegment { char filename[1024]; @@ -115,6 +119,7 @@ static int hls_append_segment(HLSContext *hls, double duration) if (hls->max_nb_segments && hls->nb_entries >= hls->max_nb_segments) { en = hls->segments; hls->segments = en->next; + unlink(en->filename); av_free(en); } else hls->nb_entries++; -- 1.7.1 From michaelni at gmx.at Mon Aug 11 12:34:37 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 11 Aug 2014 12:34:37 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec: add C xvid IDCT support In-Reply-To: <20140811054425.GB15763@leki> References: <1407727112-14083-1-git-send-email-michaelni@gmx.at> <20140811054425.GB15763@leki> Message-ID: <20140811103437.GD12391@nb4> On Mon, Aug 11, 2014 at 07:44:25AM +0200, Cl?ment B?sch wrote: > On Mon, Aug 11, 2014 at 05:18:32AM +0200, Michael Niedermayer wrote: > > From: Pascal Massimino > > > > Thanks to Pascal Massimino and Michael Militzer for permission to use under LGPL > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/Makefile | 2 +- > > libavcodec/xvid_c_idct.c | 335 ++++++++++++++++++++++++++++++++++++++++++++++ > > libavcodec/xvididct.c | 60 +++++++++ > > libavcodec/xvididct.h | 2 + > > 4 files changed, 398 insertions(+), 1 deletion(-) > > create mode 100644 libavcodec/xvid_c_idct.c > > > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > > index 6873439..55b7b02 100644 > > --- a/libavcodec/Makefile > > +++ b/libavcodec/Makefile > > @@ -325,7 +325,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o > > OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o > > OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o > > OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o > > -OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o > > +OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o xvid_c_idct.o > > OBJS-$(CONFIG_MPL2_DECODER) += mpl2dec.o ass.o > > OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o > > OBJS-$(CONFIG_MSMPEG4V2_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o > > diff --git a/libavcodec/xvid_c_idct.c b/libavcodec/xvid_c_idct.c > > new file mode 100644 > > index 0000000..b15fb8e > > --- /dev/null > > +++ b/libavcodec/xvid_c_idct.c > > @@ -0,0 +1,335 @@ > > +/***************************************************************************** > > + * > > + * XVID MPEG-4 VIDEO CODEC > > + * - Inverse DCT - > > + * > > + * Copyright (C) 2006-2011 Xvid Solutions GmbH > > + * > > + * This file is part of FFmpeg. > > + * > > + * 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 > > + * > > > + * $Id$ > > + * > > No meaning in FFmpeg/git removed > > > + ****************************************************************************/ > > + > > +/* > > + * Authors: Skal > > + * > > + * Walken IDCT > > + * Alternative idct implementations for decoding compatibility > > + * > > + * NOTE: this "C" version is not the original one, > > + * but is modified to yield the same error profile > > + * than the MMX version. > > + * > > + ************************************************************************/ > > + > > /** > * @file > * Walken IDCT > * Alternative idct implementations for decoding compatibility > * > * @author Skal > * @note this "C" version is not the original one, but is modified to > * yield the same error profile than the MMX version. > */ ok copy and pasted that in > > > +#include "xvididct.h" > > + > > > + > > +#define XVID_DSP_CLIP_255(x) ( ((x)&~255) ? ((-(x)) >> (8*sizeof((x))-1))&0xff : (x) ) > > Looks unused > > > + > > +#define ROW_SHIFT 11 > > +#define COL_SHIFT 6 > > + > > +// #define FIX(x) (int)((x) * (1< > +#define Rnd0 65536 // 1<<(COL_SHIFT+ROW_SHIFT-1); > > +#define Rnd1 3597 // FIX (1.75683487303); > > +#define Rnd2 2260 // FIX (1.10355339059); > > +#define Rnd3 1203 // FIX (0.587788325588); > > +#define Rnd4 0 > > +#define Rnd5 120 // FIX (0.058658283817); > > +#define Rnd6 512 // FIX (0.25); > > +#define Rnd7 512 // FIX (0.25); > > > +#undef FIX > > Mot defined Ill submit a patch to xvid about these, if they are accepted ill merge them in our version > > > + > > +static const int Tab04[] = { 22725, 21407, 19266, 16384, 12873, 8867, 4520 }; > > +static const int Tab17[] = { 31521, 29692, 26722, 22725, 17855, 12299, 6270 }; > > +static const int Tab26[] = { 29692, 27969, 25172, 21407, 16819, 11585, 5906 }; > > +static const int Tab35[] = { 26722, 25172, 22654, 19266, 15137, 10426, 5315 }; > > + > > +static int Idct_Row(short * In, const int * const Tab, int Rnd) > > +{ > > + const int C1 = Tab[0]; > > + const int C2 = Tab[1]; > > + const int C3 = Tab[2]; > > + const int C4 = Tab[3]; > > + const int C5 = Tab[4]; > > + const int C6 = Tab[5]; > > + const int C7 = Tab[6]; > > + > > + const int Right = In[5]|In[6]|In[7]; > > + const int Left = In[1]|In[2]|In[3]; > > > + if (!(Right | In[4])) > > + { > > + const int K = C4*In[0] + Rnd; > > + if (Left) > > + { > > If you could fix the style and indent to match FFmpeg one a little that > would be great. no, i cant the file is from xvid, iam not going to fork the file and maintain such fork because of whitespaces. Or OTOH hope that we wont want to replace it by a future version from xvid one day ... If someone else volunteers to maintain a reformated version, that sure is fine with me i dont object at all but i can just offer to maintain a largely unchanged version. > > [...] > > +static void idct_xvid_put(uint8_t *dest, int line_size, int16_t *block) > > +{ > > + ff_idct_xvid(block); > > + put_pixels_clamped_c(block, dest, line_size); > > +} > > + > > +static void idct_xvid_add(uint8_t *dest, int line_size, int16_t *block) > > +{ > > + ff_idct_xvid(block); > > + add_pixels_clamped_c(block, dest, line_size); > > +} > > + > > So the function takes a destination buffer but still destroys the input block? yes > > > av_cold void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx) > > { > > const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; > > @@ -31,6 +84,13 @@ av_cold void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx) > > avctx->idct_algo == FF_IDCT_XVID)) > > return; > > > > + if (avctx->idct_algo == FF_IDCT_XVID) { > > + c->idct_put = idct_xvid_put; > > + c->idct_add = idct_xvid_add; > > + c->idct = ff_idct_xvid; > > + c->perm_type = FF_IDCT_PERM_NONE; > > + } > > + > > if (ARCH_X86) > > ff_xvididct_init_x86(c); > > > > diff --git a/libavcodec/xvididct.h b/libavcodec/xvididct.h > > index 6678329..1b95cb7 100644 > > --- a/libavcodec/xvididct.h > > +++ b/libavcodec/xvididct.h > > @@ -26,4 +26,6 @@ void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx); > > > > void ff_xvididct_init_x86(IDCTDSPContext *c); > > > > > +void ff_idct_xvid(int16_t *const In); > > ... looks like misleading const thats how the idct functions in xvid are, is there a problem with it? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 11 12:39:17 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 11 Aug 2014 12:39:17 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec: add C xvid IDCT support In-Reply-To: <53E8852B.6010804@gmail.com> References: <1407727112-14083-1-git-send-email-michaelni@gmx.at> <20140811054425.GB15763@leki> <53E8852B.6010804@gmail.com> Message-ID: <20140811103917.GE12391@nb4> On Mon, Aug 11, 2014 at 10:56:11AM +0200, James Darnley wrote: > On 2014-08-11 07:44, Cl?ment B?sch wrote: > > /** > > * @file > > * Walken IDCT > > * Alternative idct implementations for decoding compatibility > > * > > * @author Skal > > * @note this "C" version is not the original one, but is modified to > > * yield the same error profile than the MMX version. > > A minor grammar nit: > > yield the same error profile *as* the MMX version. ill submit a patch for that as well [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 1 "Used only once" - "Some unspecified defect prevented a second use" "In good condition" - "Can be repaird by experienced expert" "As is" - "You wouldnt want it even if you were payed for it, if you knew ..." -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From james.darnley at gmail.com Mon Aug 11 12:43:12 2014 From: james.darnley at gmail.com (James Darnley) Date: Mon, 11 Aug 2014 12:43:12 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec: add C xvid IDCT support In-Reply-To: <20140811103917.GE12391@nb4> References: <1407727112-14083-1-git-send-email-michaelni@gmx.at> <20140811054425.GB15763@leki> <53E8852B.6010804@gmail.com> <20140811103917.GE12391@nb4> Message-ID: <53E89E40.1080101@gmail.com> On 2014-08-11 12:39, Michael Niedermayer wrote: > On Mon, Aug 11, 2014 at 10:56:11AM +0200, James Darnley wrote: >> On 2014-08-11 07:44, Cl?ment B?sch wrote: >>> /** >>> * @file >>> * Walken IDCT >>> * Alternative idct implementations for decoding compatibility >>> * >>> * @author Skal >>> * @note this "C" version is not the original one, but is modified to >>> * yield the same error profile than the MMX version. >> >> A minor grammar nit: >> >> yield the same error profile *as* the MMX version. > > ill submit a patch for that as well Sorry, I didn't realize that this was just copied from the xvid original. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 618 bytes Desc: OpenPGP digital signature URL: From michaelni at gmx.at Mon Aug 11 13:09:14 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 11 Aug 2014 13:09:14 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec: add C xvid IDCT support In-Reply-To: <53E83A58.6070706@gmail.com> References: <1407727112-14083-1-git-send-email-michaelni@gmx.at> <53E83A58.6070706@gmail.com> Message-ID: <20140811110914.GF12391@nb4> On Mon, Aug 11, 2014 at 12:36:56AM -0300, James Almer wrote: > On 11/08/14 12:18 AM, Michael Niedermayer wrote: > > From: Pascal Massimino > > > > Thanks to Pascal Massimino and Michael Militzer for permission to use under LGPL > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/Makefile | 2 +- > > libavcodec/xvid_c_idct.c | 335 ++++++++++++++++++++++++++++++++++++++++++++++ > > libavcodec/xvididct.c | 60 +++++++++ > > libavcodec/xvididct.h | 2 + > > 4 files changed, 398 insertions(+), 1 deletion(-) > > create mode 100644 libavcodec/xvid_c_idct.c > > > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > > index 6873439..55b7b02 100644 > > --- a/libavcodec/Makefile > > +++ b/libavcodec/Makefile > > @@ -325,7 +325,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o > > OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o > > OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o > > OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o > > -OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o > > +OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o xvid_c_idct.o > > OBJS-$(CONFIG_MPL2_DECODER) += mpl2dec.o ass.o > > OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o > > OBJS-$(CONFIG_MSMPEG4V2_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o > > diff --git a/libavcodec/xvid_c_idct.c b/libavcodec/xvid_c_idct.c > > new file mode 100644 > > index 0000000..b15fb8e > > --- /dev/null > > +++ b/libavcodec/xvid_c_idct.c > > @@ -0,0 +1,335 @@ > > +/***************************************************************************** > > + * > > + * XVID MPEG-4 VIDEO CODEC > > + * - Inverse DCT - > > + * > > + * Copyright (C) 2006-2011 Xvid Solutions GmbH > > + * > > + * This file is part of FFmpeg. > > + * > > + * 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 > > + * > > + * $Id$ > > + * > > + ****************************************************************************/ > > + > > +/* > > + * Authors: Skal > > + * > > + * Walken IDCT > > + * Alternative idct implementations for decoding compatibility > > + * > > + * NOTE: this "C" version is not the original one, > > + * but is modified to yield the same error profile > > + * than the MMX version. > > + * > > + ************************************************************************/ > > Is a separate file really necessary? The above copyright could be copied to xvididct.c just fine. > It's all lgpl code. a seperate file is not neccessary but may make future syncing with xvid easier > > [...] > > > diff --git a/libavcodec/xvididct.c b/libavcodec/xvididct.c > > index 8645af4..9b07518 100644 > > --- a/libavcodec/xvididct.c > > +++ b/libavcodec/xvididct.c > > @@ -22,6 +22,59 @@ > > #include "idctdsp.h" > > #include "xvididct.h" > > > > +static void put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, > > + int line_size) > > +{ > > + int i; > > + > > + /* read the pixels */ > > + for (i = 0; i < 8; i++) { > > + pixels[0] = av_clip_uint8(block[0]); > > + pixels[1] = av_clip_uint8(block[1]); > > + pixels[2] = av_clip_uint8(block[2]); > > + pixels[3] = av_clip_uint8(block[3]); > > + pixels[4] = av_clip_uint8(block[4]); > > + pixels[5] = av_clip_uint8(block[5]); > > + pixels[6] = av_clip_uint8(block[6]); > > + pixels[7] = av_clip_uint8(block[7]); > > + > > + pixels += line_size; > > + block += 8; > > + } > > +} > > + > > +static void add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, > > + int line_size) > > +{ > > + int i; > > + > > + /* read the pixels */ > > + for (i = 0; i < 8; i++) { > > + pixels[0] = av_clip_uint8(pixels[0] + block[0]); > > + pixels[1] = av_clip_uint8(pixels[1] + block[1]); > > + pixels[2] = av_clip_uint8(pixels[2] + block[2]); > > + pixels[3] = av_clip_uint8(pixels[3] + block[3]); > > + pixels[4] = av_clip_uint8(pixels[4] + block[4]); > > + pixels[5] = av_clip_uint8(pixels[5] + block[5]); > > + pixels[6] = av_clip_uint8(pixels[6] + block[6]); > > + pixels[7] = av_clip_uint8(pixels[7] + block[7]); > > + pixels += line_size; > > + block += 8; > > + } > > +} > > Why the code duplication? These two functions are exact copies of the ones in idctdsp. > You could share the latter and use them here instead. fixed [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I know you won't believe me, but the highest form of Human Excellence is to question oneself and others. -- Socrates -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 11 13:45:05 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 11 Aug 2014 13:45:05 +0200 Subject: [FFmpeg-devel] [PATCH 1/4] lavc: stop exporting internal functions and tables In-Reply-To: <1407629075-13514-1-git-send-email-jamrial@gmail.com> References: <1407629075-13514-1-git-send-email-jamrial@gmail.com> Message-ID: <20140811114505.GG12391@nb4> On Sat, Aug 09, 2014 at 09:04:32PM -0300, James Almer wrote: > Signed-off-by: James Almer > --- > libavcodec/libavcodec.v | 18 ------------------ > 1 file changed, 18 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Asymptotically faster algorithms should always be preferred if you have asymptotical amounts of data -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 11 14:11:28 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 11 Aug 2014 14:11:28 +0200 Subject: [FFmpeg-devel] [PATCH 1/2] lavc/raw: remove obsolete ff_raw_pix_fmt_tags cruft In-Reply-To: <1407632507-14003-1-git-send-email-jamrial@gmail.com> References: <1407632507-14003-1-git-send-email-jamrial@gmail.com> Message-ID: <20140811121128.GH12391@nb4> On Sat, Aug 09, 2014 at 10:01:46PM -0300, James Almer wrote: > Signed-off-by: James Almer > --- > libavcodec/raw.h | 4 ---- > 1 file changed, 4 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB You can kill me, but you cannot change the truth. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From michaelni at gmx.at Mon Aug 11 14:11:43 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 11 Aug 2014 14:11:43 +0200 Subject: [FFmpeg-devel] [PATCH 2/2] lavf/mpegts: remove obsolete ff_mpegts_parse_* cruft In-Reply-To: <1407632507-14003-2-git-send-email-jamrial@gmail.com> References: <1407632507-14003-1-git-send-email-jamrial@gmail.com> <1407632507-14003-2-git-send-email-jamrial@gmail.com> Message-ID: <20140811121143.GI12391@nb4> On Sat, Aug 09, 2014 at 10:01:47PM -0300, James Almer wrote: > Signed-off-by: James Almer > --- > libavformat/mpegts.c | 18 ------------------ > libavformat/mpegts.h | 7 ------- > 2 files changed, 25 deletions(-) applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB While the State exists there can be no freedom; when there is freedom there will be no State. -- Vladimir Lenin -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From ce.mohammad.alsaleh at gmail.com Mon Aug 11 14:15:45 2014 From: ce.mohammad.alsaleh at gmail.com (Mohammad Alsaleh) Date: Mon, 11 Aug 2014 15:15:45 +0300 Subject: [FFmpeg-devel] [PATCH] avformat/metadata: Implement AVFMT_FLAG_NO_META_CONV Message-ID: <1407759345-29100-1-git-send-email-CE.Mohammad.AlSaleh@gmail.com> Decoders/parsers run ff_metadata_conv() unconditionally. This makes it impossible to retrieve or keep original metadata field names. If one wishes to skip ff_metadata_conv() calls at the decoding/parsing stage. This patch implements AVFMT_FLAG_NO_META_CONV which is set by the decoding fflag opt parameter 'nometaconv'. Signed-off-by: Mohammad Alsaleh --- doc/APIchanges | 3 +++ doc/formats.texi | 2 ++ libavformat/asfdec.c | 3 ++- libavformat/avformat.h | 1 + libavformat/id3v2.c | 17 ++++++++++++----- libavformat/matroskadec.c | 4 +++- libavformat/metadata.c | 4 ++++ libavformat/oggparsevorbis.c | 3 ++- libavformat/options_table.h | 1 + libavformat/version.h | 2 +- libavformat/wtvdec.c | 3 ++- 11 files changed, 33 insertions(+), 10 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index b7961ae..854563a 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2014-08-09 API changes, most recent first: +2014-08-xx - xxxxxxx - lavf 56.1.100 - avformat.h + Add AVFMT_FLAG_NO_META_CONV. + 2014-04-xx - xxxxxxx - lavr 2.1.0 - avresample.h Add avresample_convert_frame() and avresample_config(). diff --git a/doc/formats.texi b/doc/formats.texi index 027510e..92c079d 100644 --- a/doc/formats.texi +++ b/doc/formats.texi @@ -51,6 +51,8 @@ Discard corrupted frames. Try to interleave output packets by DTS. @item keepside Do not merge side data. + at item nometaconv +Skip conversion of metadata field names. @item latm Enable RTP MP4A-LATM payload. @item nobuffer diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 5fc293e..13c7806 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -862,7 +862,8 @@ static int asf_read_header(AVFormatContext *s) } } - ff_metadata_conv(&s->metadata, NULL, ff_asf_metadata_conv); + if (!(s->flags & AVFMT_FLAG_NO_META_CONV)) + ff_metadata_conv(&s->metadata, NULL, ff_asf_metadata_conv); return 0; } diff --git a/libavformat/avformat.h b/libavformat/avformat.h index a4f7ed7..12fba94 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1287,6 +1287,7 @@ typedef struct AVFormatContext { #define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down) #define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted) #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Don't merge side data but keep it separate. +#define AVFMT_FLAG_NO_META_CONV 0x80000 ///< Skip conversion of metadata field names. /** * @deprecated deprecated in favor of probesize2 diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index fb89e83..c2bcbe0 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -574,8 +574,11 @@ static void read_chapter(AVFormatContext *s, AVIOContext *pb, int len, char *tta len -= taglen; } - ff_metadata_conv(&chapter->metadata, NULL, ff_id3v2_34_metadata_conv); - ff_metadata_conv(&chapter->metadata, NULL, ff_id3v2_4_metadata_conv); + if (!(s->flags & AVFMT_FLAG_NO_META_CONV)) { + ff_metadata_conv(&chapter->metadata, NULL, ff_id3v2_34_metadata_conv); + ff_metadata_conv(&chapter->metadata, NULL, ff_id3v2_4_metadata_conv); + } + end: av_free(dst); } @@ -916,9 +919,13 @@ static void id3v2_read_internal(AVIOContext *pb, AVDictionary **metadata, avio_seek(pb, off, SEEK_SET); } } while (found_header); - ff_metadata_conv(metadata, NULL, ff_id3v2_34_metadata_conv); - ff_metadata_conv(metadata, NULL, id3v2_2_metadata_conv); - ff_metadata_conv(metadata, NULL, ff_id3v2_4_metadata_conv); + + if (!(s->flags & AVFMT_FLAG_NO_META_CONV)) { + ff_metadata_conv(metadata, NULL, ff_id3v2_34_metadata_conv); + ff_metadata_conv(metadata, NULL, id3v2_2_metadata_conv); + ff_metadata_conv(metadata, NULL, ff_id3v2_4_metadata_conv); + } + merge_date(metadata); } diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 31ee456..347dbcd 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1377,7 +1377,9 @@ static void matroska_convert_tag(AVFormatContext *s, EbmlList *list, matroska_convert_tag(s, &tags[i].sub, metadata, key); } } - ff_metadata_conv(metadata, NULL, ff_mkv_metadata_conv); + + if (!(s->flags & AVFMT_FLAG_NO_META_CONV)) + ff_metadata_conv(metadata, NULL, ff_mkv_metadata_conv); } static void matroska_convert_tags(AVFormatContext *s) diff --git a/libavformat/metadata.c b/libavformat/metadata.c index b9b6de7..bba7af7 100644 --- a/libavformat/metadata.c +++ b/libavformat/metadata.c @@ -60,6 +60,10 @@ void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv, const AVMetadataConv *s_conv) { int i; + + if (s_conv && (ctx->flags & AVFMT_FLAG_NO_META_CONV)) + return; + ff_metadata_conv(&ctx->metadata, d_conv, s_conv); for (i=0; inb_streams ; i++) ff_metadata_conv(&ctx->streams [i]->metadata, d_conv, s_conv); diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c index 8103d9d..17f0dd2 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -176,7 +176,8 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m, av_log(as, AV_LOG_INFO, "truncated comment header, %i comments not found\n", n); - ff_metadata_conv(m, NULL, ff_vorbiscomment_metadata_conv); + if (!(as->flags & AVFMT_FLAG_NO_META_CONV)) + ff_metadata_conv(m, NULL, ff_vorbiscomment_metadata_conv); return 0; } diff --git a/libavformat/options_table.h b/libavformat/options_table.h index 94cd65c..24ec130 100644 --- a/libavformat/options_table.h +++ b/libavformat/options_table.h @@ -49,6 +49,7 @@ static const AVOption avformat_options[] = { {"discardcorrupt", "discard corrupted frames", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"}, {"sortdts", "try to interleave outputted packets by dts", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, "fflags"}, {"keepside", "don't merge side data", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_KEEP_SIDE_DATA }, INT_MIN, INT_MAX, D, "fflags"}, +{"nometaconv", "skip conversion of metadata field names", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_NO_META_CONV }, INT_MIN, INT_MAX, D, "fflags"}, {"latm", "enable RTP MP4A-LATM payload", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_MP4A_LATM }, INT_MIN, INT_MAX, E, "fflags"}, {"nobuffer", "reduce the latency introduced by optional buffering", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_NOBUFFER }, 0, INT_MAX, D, "fflags"}, {"seek2any", "allow seeking to non-keyframes on demuxer level when supported", OFFSET(seek2any), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, D}, diff --git a/libavformat/version.h b/libavformat/version.h index 1cbb889..c09bd88 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -30,7 +30,7 @@ #include "libavutil/version.h" #define LIBAVFORMAT_VERSION_MAJOR 56 -#define LIBAVFORMAT_VERSION_MINOR 0 +#define LIBAVFORMAT_VERSION_MINOR 1 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index c70057c..644f0a2 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -549,7 +549,8 @@ static void parse_legacy_attrib(AVFormatContext *s, AVIOContext *pb) get_tag(s, pb, key, type, length); } - ff_metadata_conv(&s->metadata, NULL, ff_asf_metadata_conv); + if (!(s->flags & AVFMT_FLAG_NO_META_CONV)) + ff_metadata_conv(&s->metadata, NULL, ff_asf_metadata_conv); } /** -- 2.0.4 From michaelni at gmx.at Mon Aug 11 14:30:46 2014 From: michaelni at gmx.at (Michael Niedermayer) Date: Mon, 11 Aug 2014 14:30:46 +0200 Subject: [FFmpeg-devel] [PATCH 2/4] lavf: stop exporting internal functions In-Reply-To: <1407629075-13514-2-git-send-email-jamrial@gmail.com> References: <1407629075-13514-1-git-send-email-jamrial@gmail.com> <1407629075-13514-2-git-send-email-jamrial@gmail.com> Message-ID: <20140811123046.GJ12391@nb4> On Sat, Aug 09, 2014 at 09:04:33PM -0300, James Almer wrote: > Except for those currently used by ffserver. > > Signed-off-by: James Almer > --- > libavformat/libavformat.v | 9 --------- > 1 file changed, 9 deletions(-) mostly applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Opposition brings concord. Out of discord comes the fairest harmony. -- Heraclitus -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: From u at pkh.me Mon Aug 11 15:22:59 2014 From: u at pkh.me (=?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?=) Date: Mon, 11 Aug 2014 15:22:59 +0200 Subject: [FFmpeg-devel] [PATCH] avcodec: export motion vectors in frame side data on demand Message-ID: <1407763379-31570-1-git-send-email-u@pkh.me> From: Cl?ment B?sch The reasoning behind this addition is that various third party applications are interested in getting some motion information out of a video "for free" when it is available. It was considered to export other information as well (such as the intra information about the block, or the quantization) but the structure might have ended up into a half full-generic, half full of codec specific cruft. If more information is necessary, it should either be added in the "flags" field of the AVExportedMV structure, or in another side-data. This commit also includes an example exporting them in a CSV stream. --- TODO: avcodec version bump & APIChanges entry --- .gitignore | 1 + configure | 2 + doc/Makefile | 1 + doc/codecs.texi | 3 + doc/examples/Makefile | 1 + doc/examples/extract_mvs.c | 185 +++++++++++++++++++++++++++++++++++++++++++++ libavcodec/avcodec.h | 1 + libavcodec/mpegvideo.c | 102 ++++++++++++++++++++++++- libavcodec/options_table.h | 1 + libavutil/frame.h | 6 ++ libavutil/mvinfo.h | 49 ++++++++++++ 11 files changed, 351 insertions(+), 1 deletion(-) create mode 100644 doc/examples/extract_mvs.c create mode 100644 libavutil/mvinfo.h diff --git a/.gitignore b/.gitignore index cb370bb..480fbe0 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ /doc/examples/avio_reading /doc/examples/decoding_encoding /doc/examples/demuxing_decoding +/doc/examples/extract_mvs /doc/examples/filter_audio /doc/examples/filtering_audio /doc/examples/filtering_video diff --git a/configure b/configure index 0ac6132..a93fc06 100755 --- a/configure +++ b/configure @@ -1306,6 +1306,7 @@ EXAMPLE_LIST=" avio_reading_example decoding_encoding_example demuxing_decoding_example + extract_mvs_example filter_audio_example filtering_audio_example filtering_video_example @@ -2586,6 +2587,7 @@ zoompan_filter_deps="swscale" avio_reading="avformat avcodec avutil" avcodec_example_deps="avcodec avutil" demuxing_decoding_example_deps="avcodec avformat avutil" +extract_mvs_example_deps="avcodec avformat avutil" filter_audio_example_deps="avfilter avutil" filtering_audio_example_deps="avfilter avcodec avformat avutil" filtering_video_example_deps="avfilter avcodec avformat avutil" diff --git a/doc/Makefile b/doc/Makefile index 99f588a..2fb9058 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -39,6 +39,7 @@ DOCS = $(DOCS-yes) DOC_EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading DOC_EXAMPLES-$(CONFIG_AVCODEC_EXAMPLE) += avcodec DOC_EXAMPLES-$(CONFIG_DEMUXING_DECODING_EXAMPLE) += demuxing_decoding +DOC_EXAMPLES-$(CONFIG_EXTRACT_MVS_EXAMPLE) += extract_mvs DOC_EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE) += filter_audio DOC_EXAMPLES-$(CONFIG_FILTERING_AUDIO_EXAMPLE) += filtering_audio DOC_EXAMPLES-$(CONFIG_FILTERING_VIDEO_EXAMPLE) += filtering_video diff --git a/doc/codecs.texi b/doc/codecs.texi index 1160e5d..7aaa229 100644 --- a/doc/codecs.texi +++ b/doc/codecs.texi @@ -797,6 +797,9 @@ Frame data might be split into multiple chunks. Show all frames before the first keyframe. @item skiprd Deprecated, use mpegvideo private options instead. + at item export_mvs +Export motion vectors into frame side-data (see @code{AV_FRAME_DATA_MV_INFO}) +for codecs that support it. See also @file{doc/examples/export_mvs.c}. @end table @item error @var{integer} (@emph{encoding,video}) diff --git a/doc/examples/Makefile b/doc/examples/Makefile index 03c7021..07251fe 100644 --- a/doc/examples/Makefile +++ b/doc/examples/Makefile @@ -14,6 +14,7 @@ LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS) EXAMPLES= avio_reading \ decoding_encoding \ demuxing_decoding \ + extract_mvs \ filtering_video \ filtering_audio \ metadata \ diff --git a/doc/examples/extract_mvs.c b/doc/examples/extract_mvs.c new file mode 100644 index 0000000..69f76cd --- /dev/null +++ b/doc/examples/extract_mvs.c @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2012 Stefano Sabatini + * Copyright (c) 2014 Cl?ment B?sch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +static AVFormatContext *fmt_ctx = NULL; +static AVCodecContext *video_dec_ctx = NULL; +static AVStream *video_stream = NULL; +static const char *src_filename = NULL; + +static int video_stream_idx = -1; +static AVFrame *frame = NULL; +static AVPacket pkt; +static int video_frame_count = 0; + +static int decode_packet(int *got_frame, int cached) +{ + int decoded = pkt.size; + + *got_frame = 0; + + if (pkt.stream_index == video_stream_idx) { + int ret = avcodec_decode_video2(video_dec_ctx, frame, got_frame, &pkt); + if (ret < 0) { + fprintf(stderr, "Error decoding video frame (%s)\n", av_err2str(ret)); + return ret; + } + + if (*got_frame) { + int i; + AVFrameSideData *sd; + + video_frame_count++; + sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MV_INFO); + if (sd) { + const AVExportedMV *mvs = (const AVExportedMV *)sd->data; + for (i = 0; i < sd->size / sizeof(*mvs); i++) { + const AVExportedMV *mv = &mvs[i]; + printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%016x\n", + video_frame_count, mv->source, + mv->w, mv->h, mv->src_x, mv->src_y, + mv->dst_x, mv->dst_y, mv->flags); + } + } + } + } + + return decoded; +} + +static int open_codec_context(int *stream_idx, + AVFormatContext *fmt_ctx, enum AVMediaType type) +{ + int ret; + AVStream *st; + AVCodecContext *dec_ctx = NULL; + AVCodec *dec = NULL; + AVDictionary *opts = NULL; + + ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0); + if (ret < 0) { + fprintf(stderr, "Could not find %s stream in input file '%s'\n", + av_get_media_type_string(type), src_filename); + return ret; + } else { + *stream_idx = ret; + st = fmt_ctx->streams[*stream_idx]; + + /* find decoder for the stream */ + dec_ctx = st->codec; + dec = avcodec_find_decoder(dec_ctx->codec_id); + if (!dec) { + fprintf(stderr, "Failed to find %s codec\n", + av_get_media_type_string(type)); + return AVERROR(EINVAL); + } + + /* Init the video decoder */ + av_dict_set(&opts, "flags2", "+export_mvs", 0); + if ((ret = avcodec_open2(dec_ctx, dec, &opts)) < 0) { + fprintf(stderr, "Failed to open %s codec\n", + av_get_media_type_string(type)); + return ret; + } + } + + return 0; +} + +int main(int argc, char **argv) +{ + int ret = 0, got_frame; + + if (argc != 2) { + fprintf(stderr, "Usage: %s