Re: [FFmpeg-devel] [PATCH] avfilter: align data frame when needed
On Fri, May 5, 2017 at 1:01 PM, Muhammad Faiz wrote: > This should fix Ticket6349. > Since 383057f8e744efeaaa3648a59bc577b25b055835, framequeue may > generate unaligned frame data. > > Signed-off-by: Muhammad Faiz > --- > libavfilter/avfilter.c | 26 +- > 1 file changed, 25 insertions(+), 1 deletion(-) > > diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c > index 08b86b0..504f5c6 100644 > --- a/libavfilter/avfilter.c > +++ b/libavfilter/avfilter.c > @@ -1192,7 +1192,31 @@ static int take_samples(AVFilterLink *link, unsigned > min, unsigned max, > av_assert1(samples_ready(link, link->min_samples)); > frame0 = frame = ff_framequeue_peek(&link->fifo, 0); > if (frame->nb_samples >= min && frame->nb_samples < max) { > -*rframe = ff_framequeue_take(&link->fifo); > +int align = 32; > +if (!((align - 1) & (intptr_t)frame->data[0])) { > +*rframe = ff_framequeue_take(&link->fifo); > +return 0; > +} > + > +buf = ff_get_audio_buffer(link, frame->nb_samples); > +if (!buf) > +return AVERROR(ENOMEM); > + > +ret = av_frame_copy_props(buf, frame); > +if (ret < 0) { > +av_frame_free(&buf); > +return ret; > +} > + > +ret = av_frame_copy(buf, frame); > +if (ret < 0) { > +av_frame_free(&buf); > +return ret; > +} > + > +frame = ff_framequeue_take(&link->fifo); > +av_frame_free(&frame); > +*rframe = buf; > return 0; > } > nb_frames = 0; > -- > 2.9.3 > Is it ok to push this? Thank's. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: align data frame when needed
L'octidi 18 floréal, an CCXXV, Muhammad Faiz a écrit : > Is it ok to push this? Of course not. How would it be ok to push a partial fix when a complete one is being discussed? Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavc/aarch64/simple_idct: separate macro arguments with commas
Le 2 mai 2017 12:01 PM, "Benoit Fouet" a écrit : Hi, On 28/04/2017 21:58, Matthieu Bouron wrote: > Untested: fixes ticket #6324. > --- > libavcodec/aarch64/simple_idct_neon.S | 12 ++-- > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/libavcodec/aarch64/simple_idct_neon.S b/libavcodec/aarch64/simple_idct_neon.S > index 52273420f9..d31f72a609 100644 > --- a/libavcodec/aarch64/simple_idct_neon.S > +++ b/libavcodec/aarch64/simple_idct_neon.S > @@ -61,19 +61,19 @@ endconst > br x10 > .endm > > -.macro smull1 a b c > +.macro smull1 a, b, c > smull \a, \b, \c > .endm > > -.macro smlal1 a b c > +.macro smlal1 a, b, c > smlal \a, \b, \c > .endm > > -.macro smlsl1 a b c > +.macro smlsl1 a, b, c > smlsl \a, \b, \c > .endm > > -.macro idct_col4_top y1 y2 y3 y4 i l > +.macro idct_col4_top y1, y2, y3, y4, i, l > smull\i v7.4S, \y3\().\l, z2 > smull\i v16.4S, \y3\().\l, z6 > smull\i v17.4S, \y2\().\l, z1 > @@ -91,7 +91,7 @@ endconst > smlsl\i v6.4S, \y4\().\l, z5 > .endm > > -.macro idct_row4_neon y1 y2 y3 y4 pass > +.macro idct_row4_neon y1, y2, y3, y4, pass > ld1 {\y1\().2D-\y2\().2D}, [x2], #32 > moviv23.4S, #1<<2, lsl #8 > orr v5.16B, \y1\().16B, \y2\().16B > @@ -153,7 +153,7 @@ endconst > trn2\y4\().4S, v17.4S, v19.4S > .endm > > -.macro declare_idct_col4_neon i l > +.macro declare_idct_col4_neon i, l > function idct_col4_neon\i > dup v23.4H, z4c > .if \i == 1 Sounds sane, but shouldn't we be doing this for all instances of multiple arguments macros without commas? Sure, I may have missed some. I will work again on this patch on Tuesday as I will have access to an apple machine (and hopefully fix the build without gas-preprocessor). Sorry for the delay, Matthieu Thanks -- Ben ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] lavu/frame: add av_frame_realign().
On Sat, 6 May 2017, Nicolas George wrote: Le septidi 17 floréal, an CCXXV, Muhammad Faiz a écrit : As far as I know. No new features can go to release branch. Or maybe I'm wrong. As I said, if this is the only issue, then it is not: just copy-paste av_frame_realign() at the two places where it will be needed and make it static. But really, I do not care much what happens in releases. I will fight to the end to prevent short-term workarounds to be introduced in the master branch when a correct fix is so easy, but for the releases branches, do what you want. Only do not expect my help for the ugly way. I suggest the following: As the av_frame_realign API is useful on its own without any framework, I suggest we implement that. Once the implementation is complete we can backport it to 3.3 with the avpriv prefix and without bumping version numbers. In the 3.3 branch the regression can be fixed (old behaviour can be restored) by calling avpriv_frame_align in the frame queue. In the master branch, if no consensus is reached, or discussion/work on the alignment framework stalls, a vote can be made to either 1) enforce the aligment in the frame queue or 2) enforce the aligment in parts of the code we know regressed (libmp3, af_volume) Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] lavu/frame: add av_frame_realign().
On Sat, 6 May 2017, Nicolas George wrote: TODO Actual implementation. Signed-off-by: Nicolas George --- libavutil/frame.h | 9 + 1 file changed, 9 insertions(+) Here is a proposal for actually fixing the alignment problems that are all over the place in the current code base. Note that it is only a design proposal, all the actual implementation is missing. I do not want to waste my time implementing if the design is to be bikeshedded to death. diff --git a/libavutil/frame.h b/libavutil/frame.h index 4d8c1bed4f..162ea0716c 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -746,6 +746,15 @@ void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type); const char *av_frame_side_data_name(enum AVFrameSideDataType type); /** + * Realign the data pointers of a frame. + * Make sure all frame data pointers have the alignment lower bits cleared, + * i.e. are a multiple of 1<=0 for success or an AVERROR code. I suggest to return 1 if an actual alignment (with deep copy) happened. + */ +int av_frame_realign(AVFrame *frame, unsigned align); + +/** * @} */ Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] lavu/frame: add av_frame_realign().
Hi, On Sun, May 7, 2017 at 7:34 AM, Marton Balint wrote: > > On Sat, 6 May 2017, Nicolas George wrote: > > Le septidi 17 floréal, an CCXXV, Muhammad Faiz a écrit : >> >>> As far as I know. No new features can go to release branch. >>> Or maybe I'm wrong. >>> >> >> As I said, if this is the only issue, then it is not: just copy-paste >> av_frame_realign() at the two places where it will be needed and make it >> static. >> >> But really, I do not care much what happens in releases. I will fight to >> the end to prevent short-term workarounds to be introduced in the master >> branch when a correct fix is so easy, but for the releases branches, do >> what you want. Only do not expect my help for the ugly way. >> > > I suggest the following: > > As the av_frame_realign API is useful on its own without any framework, I > suggest we implement that. > > Once the implementation is complete we can backport it to 3.3 with the > avpriv prefix and without bumping version numbers. > > In the 3.3 branch the regression can be fixed (old behaviour can be > restored) by calling avpriv_frame_align in the frame queue. > > In the master branch, if no consensus is reached, or discussion/work on > the alignment framework stalls, a vote can be made to either > 1) enforce the aligment in the frame queue or > 2) enforce the aligment in parts of the code we know regressed (libmp3, > af_volume) My understanding from what Nicolas said is that the goal is to have higher-level code (utils.c-level, e.g. the callers of filter() or encode_frame() or get_buffer() inside decode_frame()) call this for every input frame going back to a caller with higher alignment requirements than the input frame (possibly with a one-time warning)? Ronald ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] lavu/frame: add av_frame_realign().
L'octidi 18 floréal, an CCXXV, Ronald S. Bultje a écrit : > My understanding from what Nicolas said is that the goal is to have > higher-level code (utils.c-level, e.g. the callers of filter() or > encode_frame() or get_buffer() inside decode_frame()) call this for every > input frame going back to a caller with higher alignment requirements than ^^ > the input frame (possibly with a one-time warning)? I think you should have written "callee" here. Apart from that, this is exactly that, thanks. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] lavu/frame: add av_frame_realign().
L'octidi 18 floréal, an CCXXV, Marton Balint a écrit : > As the av_frame_realign API is useful on its own without any framework, I > suggest we implement that. > > Once the implementation is complete we can backport it to 3.3 with the > avpriv prefix and without bumping version numbers. > > In the 3.3 branch the regression can be fixed (old behaviour can be > restored) by calling avpriv_frame_align in the frame queue. You mean do that even before the discussion about the complete fix in master is finished? I can live with that. A small nit: since the avpriv_frame_realign() would be called from only one file, at most two, it would be simpler and cleaner to put it there as a static function than adding yet another function in the avpriv namespace. Also, depending on the time it takes for the discussion to finish (IIRC, only Hendrik had an objection to the principle), it may be more convenient to keep the branch as close as possible to master. > In the master branch, if no consensus is reached, or discussion/work on the > alignment framework stalls, a vote can be made to either > 1) enforce the aligment in the frame queue or > 2) enforce the aligment in parts of the code we know regressed (libmp3, > af_volume) Ronald explained, I will do so again with different words to make the point: My plan is to call av_frame_realign() in libavcodec/encode.c just before the calls to encoder->encode2() and encoder->send_frame() because these are the functions that need alignment. In other words, call it in the last place of the code path that is common to all encoders. For filters, I think the correct place is before the end of ff_inlink_consume_frame() and ff_inlink_consume_samples(). Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavfi/avfiltergraph: only return EOF in avfilter_graph_request_oldest if all sinks EOFed
Le septidi 17 floréal, an CCXXV, Marton Balint a écrit : > Fixes a regression introduced in 32c59a115d3cc757676b5384a5ea44b5a7a7b872, > becoming effective in 912969a33e313c57c906e87a7e2367b78a2160f4. > > Fixes trimmed output of > ffmpeg -f lavfi -i "sine=d=0.01" -f lavfi -i "sine=d=1" -filter_complex > "[0:a]anull[a1];[1:a]anull[a2]" -map "[a1]" -f null none -map "[a2]" -f > framecrc - > --- > libavfilter/avfiltergraph.c | 9 ++--- > 1 file changed, 6 insertions(+), 3 deletions(-) LGTM, thanks for finding that. Out of curiosity, how did you arrive to a graph with buffersc and buffersink connected directly? Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: align data frame when needed
On 5/7/2017 5:33 AM, Nicolas George wrote: > L'octidi 18 floréal, an CCXXV, Muhammad Faiz a écrit : >> Is it ok to push this? > > Of course not. How would it be ok to push a partial fix when a complete > one is being discussed? > > Regards, Will that complete fix be ready and be backport-enabled (AKA, no new API) in the coming days? Because if not, then this patch here will have to be committed for 3.3.1 to at least deal with some of the failures. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: align data frame when needed
L'octidi 18 floréal, an CCXXV, James Almer a écrit : > Will that complete fix be ready and be backport-enabled (AKA, no new > API) in the coming days? It can. Right now, I am waiting for a comment from Hendrik, who seemed to have objections on the principle but that I hope to have convinced. After that, the coding is quite straightforward. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: align data frame when needed
On 5/7/2017 10:18 AM, Nicolas George wrote: > L'octidi 18 floréal, an CCXXV, James Almer a écrit : >> Will that complete fix be ready and be backport-enabled (AKA, no new >> API) in the coming days? > > It can. Right now, I am waiting for a comment from Hendrik, who seemed > to have objections on the principle but that I hope to have convinced. > After that, the coding is quite straightforward. > > Regards, Alright, thank you. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavfi/avfiltergraph: only return EOF in avfilter_graph_request_oldest if all sinks EOFed
On Sun, 7 May 2017, Nicolas George wrote: Le septidi 17 floréal, an CCXXV, Marton Balint a écrit : Fixes a regression introduced in 32c59a115d3cc757676b5384a5ea44b5a7a7b872, becoming effective in 912969a33e313c57c906e87a7e2367b78a2160f4. Fixes trimmed output of ffmpeg -f lavfi -i "sine=d=0.01" -f lavfi -i "sine=d=1" -filter_complex "[0:a]anull[a1];[1:a]anull[a2]" -map "[a1]" -f null none -map "[a2]" -f framecrc - --- libavfilter/avfiltergraph.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) LGTM, thanks for finding that. Out of curiosity, how did you arrive to a graph with buffersc and buffersink connected directly? The original command and filter graph which I used when I hit this bug was quite complex and was operating on a real file, I had to come up with a simplified version to make debugging easier. Obviously you can replace anull with any audio filter and still experience the trimmed output. Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] lavu/frame: add av_frame_realign().
On Sun, May 7, 2017 at 6:34 PM, Marton Balint wrote: > > On Sat, 6 May 2017, Nicolas George wrote: > >> Le septidi 17 floréal, an CCXXV, Muhammad Faiz a écrit : >>> >>> As far as I know. No new features can go to release branch. >>> Or maybe I'm wrong. >> >> >> As I said, if this is the only issue, then it is not: just copy-paste >> av_frame_realign() at the two places where it will be needed and make it >> static. >> >> But really, I do not care much what happens in releases. I will fight to >> the end to prevent short-term workarounds to be introduced in the master >> branch when a correct fix is so easy, but for the releases branches, do >> what you want. Only do not expect my help for the ugly way. > > > I suggest the following: > > As the av_frame_realign API is useful on its own without any framework, I > suggest we implement that. > > Once the implementation is complete we can backport it to 3.3 with the > avpriv prefix and without bumping version numbers. > > In the 3.3 branch the regression can be fixed (old behaviour can be > restored) by calling avpriv_frame_align in the frame queue. Inside libavfilter, we need something like ff_inlink_frame_align because of ff_get_buffer problem. This is fortunate because we don't need to call av_frame_realign at all. > > In the master branch, if no consensus is reached, or discussion/work on the > alignment framework stalls, a vote can be made to either > 1) enforce the aligment in the frame queue or > 2) enforce the aligment in parts of the code we know regressed (libmp3, > af_volume) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] lavu/frame: add av_frame_realign().
L'octidi 18 floréal, an CCXXV, Marton Balint a écrit : > I suggest to return 1 if an actual alignment (with deep copy) happened. Actually, as Muhammad just pointed and as I noticed a few minutes ago, we can not use the same function from lavfi and lavc, due to the get_buffer issue. I propose the attached patch to factor the alignment check (notice it is slightly more complex than in Muhammad's patch, because it takes care of all cases and not just the mp3lame crash). The realignment functions will look like: int ff_frame_realign(AVFrame *frame, unsigned align) { if (ff_frame_check_align(frame, align)) return 0; specific_get_buffer(frame); } If we were not so much in a rush, I would propose a solution to avoid the copy-paste, but it can wait for later. Regards, -- Nicolas George From 3dacd6fa2aa86b31b73edda83f995b841e1d57b5 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Sat, 6 May 2017 10:56:33 +0200 Subject: [PATCH 1/3] lavu/frame: add av_frame_check_align(). TODO APIchanges and minor bump. Signed-off-by: Nicolas George --- libavutil/frame.c | 18 ++ libavutil/frame.h | 8 2 files changed, 26 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index dd12c5549c..cb6e334833 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -777,3 +777,21 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type) } return NULL; } + +int av_frame_check_align(AVFrame *frame, unsigned align) +{ +unsigned mask = (1 << align) - 1; +unsigned i; +int ret; + +av_assert1(align < 16); +for (i = 0; i < AV_NUM_DATA_POINTERS; i++) +if (((intptr_t)frame->data[i] & mask)) +return 0; +if (!frame->extended_data || frame->extended_data == frame->data) +return 1; +for (i = AV_NUM_DATA_POINTERS; i < frame->channels; i++) +if (((intptr_t)frame->extended_data[i] & mask)) +return 0; +return 1; +} diff --git a/libavutil/frame.h b/libavutil/frame.h index 4d8c1bed4f..f6ff807404 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -746,6 +746,14 @@ void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type); const char *av_frame_side_data_name(enum AVFrameSideDataType type); /** + * Check if the data pointers of a frame are aligned enough. + * Test if all frame data pointers have the alignment lower bits cleared, + * i.e. are a multiple of 1<0 if aligned, 0 if not + */ +int av_frame_check_align(AVFrame *frame, unsigned align); + +/** * @} */ -- 2.11.0 signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] lavu/frame: add av_frame_realign().
On Sun, May 7, 2017 at 1:34 PM, Marton Balint wrote: > > On Sat, 6 May 2017, Nicolas George wrote: > >> Le septidi 17 floréal, an CCXXV, Muhammad Faiz a écrit : >>> >>> As far as I know. No new features can go to release branch. >>> Or maybe I'm wrong. >> >> >> As I said, if this is the only issue, then it is not: just copy-paste >> av_frame_realign() at the two places where it will be needed and make it >> static. >> >> But really, I do not care much what happens in releases. I will fight to >> the end to prevent short-term workarounds to be introduced in the master >> branch when a correct fix is so easy, but for the releases branches, do >> what you want. Only do not expect my help for the ugly way. > > > I suggest the following: > > As the av_frame_realign API is useful on its own without any framework, I > suggest we implement that. > > Once the implementation is complete we can backport it to 3.3 with the > avpriv prefix and without bumping version numbers. > > In the 3.3 branch the regression can be fixed (old behaviour can be > restored) by calling avpriv_frame_align in the frame queue. > > In the master branch, if no consensus is reached, or discussion/work on the > alignment framework stalls, a vote can be made to either > 1) enforce the aligment in the frame queue or > 2) enforce the aligment in parts of the code we know regressed (libmp3, > af_volume) > Introducing avpriv API is still a bad thing for a release branch - avpriv is ultimately public ABI and having 3.3 and master diverge in ABI right away would be bad. IMHO just add a fix local to avfilter and make it re-align the frame queue to resolve the regression at hand in the release. - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/3] lavc: add a framework to fix alignment problems.
On Sat, May 6, 2017 at 8:34 PM, Nicolas George wrote: > > Encouraging the applications to be aware of the issue for performances > reasons is a good thing. > > Forcing them to do so when it is not convenient, on pain of crash, when > it can be done for them just as easily, not so much. > >> There is no particular reason we can't make the framework check the >> alignment and re-align if required to the maximum CPU value (with a >> loud warning, perhaps), but I don't think a per-codec or per-filter >> alignment value is very practical. > > If the framework does the realigning, doing it per-codec or per-filter > is almost free. And someone really smart said that "since re-aligning > can be extremely expensive" it "should be avoided at all cost if > possible", doing the realigning only if the codecs needs it is really > the right thing to do. > One of my main concerns is that FATE will not actually be testing any of this (otherwise it would be crashing right now), and as such it can (and we all know, will) lead to subtle bugs that only occur with certain callers on certain platforms. This is usually not a very good situation to be in. Ronald suggested on IRC that the only parts suffering from this are the ASM DSP components, and we should just make checkasm tests for all of them and let checkasm test the alignment they claim to support, but alas this won't be done for months, if not years. There is potentially nothing wrong with supporting per-codec values in the framework, but setting them to something lower then the global alignment (ie. 32-byte) should only be done if we have sufficient automated testing to ensure this value is and remains correct. - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] lavu/frame: add av_frame_realign().
On Sun, May 7, 2017 at 1:47 PM, Ronald S. Bultje wrote: > Hi, > > On Sun, May 7, 2017 at 7:34 AM, Marton Balint wrote: > >> >> On Sat, 6 May 2017, Nicolas George wrote: >> >> Le septidi 17 floréal, an CCXXV, Muhammad Faiz a écrit : >>> As far as I know. No new features can go to release branch. Or maybe I'm wrong. >>> >>> As I said, if this is the only issue, then it is not: just copy-paste >>> av_frame_realign() at the two places where it will be needed and make it >>> static. >>> >>> But really, I do not care much what happens in releases. I will fight to >>> the end to prevent short-term workarounds to be introduced in the master >>> branch when a correct fix is so easy, but for the releases branches, do >>> what you want. Only do not expect my help for the ugly way. >>> >> >> I suggest the following: >> >> As the av_frame_realign API is useful on its own without any framework, I >> suggest we implement that. >> >> Once the implementation is complete we can backport it to 3.3 with the >> avpriv prefix and without bumping version numbers. >> >> In the 3.3 branch the regression can be fixed (old behaviour can be >> restored) by calling avpriv_frame_align in the frame queue. >> >> In the master branch, if no consensus is reached, or discussion/work on >> the alignment framework stalls, a vote can be made to either >> 1) enforce the aligment in the frame queue or >> 2) enforce the aligment in parts of the code we know regressed (libmp3, >> af_volume) > > > My understanding from what Nicolas said is that the goal is to have > higher-level code (utils.c-level, e.g. the callers of filter() or > encode_frame() or get_buffer() inside decode_frame()) call this for every > input frame going back to a caller with higher alignment requirements than > the input frame (possibly with a one-time warning)? > Just for the record, we can't do this with get_buffer, the entire point of this callback is to get a fully user-controlled buffer into a decoder. Anyone implementing this function needs to be absolutely aware of alignment and stride requirements, and for this function it is even documented already (although docs can always be expanded to make everything clearer). This entire concept currently applies to raw input data only, ie. input to avfilter, encoders, and maybe even swscale and swresample (although those may already have checks somewhere) - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/matroskadec: fix resource leak
2017-05-05 20:20 GMT+08:00 wm4 : > On Sat, 6 May 2017 04:06:03 +0800 > Steven Liu wrote: > > > Fixes Coverity CID: 1405453 > > > > Signed-off-by: Steven Liu > > --- > > libavformat/matroskadec.c |1 + > > 1 files changed, 1 insertions(+), 0 deletions(-) > > > > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c > > index 9e2c9bd..5282ef7 100644 > > --- a/libavformat/matroskadec.c > > +++ b/libavformat/matroskadec.c > > @@ -3893,6 +3893,7 @@ static int webm_dash_manifest_cues(AVFormatContext > *s, int64_t init_range) > > "%" PRId64, s->streams[0]->index_entries[ > i].timestamp); > > if (ret <= 0 || (ret == 20 && i == s->streams[0]->nb_index_entries > - 1)) { > > av_log(s, AV_LOG_ERROR, "timestamp too long.\n"); > > +av_free(buf); > > return AVERROR_INVALIDDATA; > > } > > end += ret; > > LGTM > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > Applied! Thanks ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/aacdec_template: Do not decode 2nd PCE if it will lead to failure
On Mon, Apr 10, 2017 at 03:27:38AM +0200, Michael Niedermayer wrote: > Fixes: out of array read > Fixes: 1072/clusterfuzz-testcase-6456688074817536 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/aacdec_template.c | 14 -- > 1 file changed, 12 insertions(+), 2 deletions(-) applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you drop bombs on a foreign country and kill a hundred thousand innocent people, expect your government to call the consequence "unprovoked inhuman terrorist attacks" and use it to justify dropping more bombs and killing more people. The technology changed, the idea is old. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/3] lavc: add a framework to fix alignment problems.
Hi, On Sun, May 7, 2017 at 11:15 AM, Hendrik Leppkes wrote: > Ronald suggested on IRC that the only parts suffering from this are > the ASM DSP components, and we should just make checkasm tests for all > of them and let checkasm test the alignment they claim to support, but > alas this won't be done for months, if not years. This really isn't that complicated once we get the general design and goals explicitly documented. We test all kind of crazy stuff in checkasm, like xmm register clobbering. This is just another strange thing that can be done in generic code. We just need to decide what is OK so we know what to test. Ronald ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] lavu/frame: add av_frame_realign().
Hi, On Sun, May 7, 2017 at 7:50 AM, Nicolas George wrote: > L'octidi 18 floréal, an CCXXV, Ronald S. Bultje a écrit : > > My understanding from what Nicolas said is that the goal is to have > > higher-level code (utils.c-level, e.g. the callers of filter() or > > encode_frame() or get_buffer() inside decode_frame()) call this for every > > input frame going back to a caller with higher alignment requirements > than > ^^ > > the input frame (possibly with a one-time warning)? > > I think you should have written "callee" here. Indeed, my bad. Apart from that, this is exactly that, thanks. OK, I think I agree with that design in principle. Hendrik is also right that it wouldn't be called after the get_buffer() user callback to _make_ the buffer aligned, but rather just to check that the buffer _is_ aligned. (If it isn't aligned, we would probably return an error from get_buffer.) Ronald ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Fixed problems with QuickSync (QSV) interlaced video encoding
Please disregard this patch--I'm submitting two new patches that have already been reviewed and applied to libav. Aaron Levinson On 4/13/2017 11:36 PM, Aaron Levinson wrote: From da3899b24ad89b4788a3b8191d53b26f5eec328e Mon Sep 17 00:00:00 2001 From: Aaron Levinson Date: Thu, 13 Apr 2017 23:12:30 -0700 Subject: [PATCH] Fixed problems with QuickSync (QSV) interlaced video encoding Purpose: Fixed problems with QuickSync (QSV) interlaced video encoding that were introduced in revision 1f26a23 on Oct. 31, 2016 (qsv: Merge libav implementation, at https://github.com/FFmpeg/FFmpeg/commit/1f26a231bb065276cd80ce02957c759f3197edfa#diff-7d84a34d58597bb7aa4b8239dca1f9f8). As a result of the qsv libav merge, when attempting to encode interlaced video, it doesn't work and instead results in a bunch of incompatible video parameter errors. Comments: -- qsvenc.c / .h: a) Added code back in to set PicStruct appropriately based on whether or not interlaced or progressive video is being encoded. Also reintroduced the related code to set the height alignment. The height alignment code was also enhanced slightly (compared to the version in 3.2.4) to properly handle progressive video when the HEVC encoder is used. The elimination of this code is the main reason why interlaced video encoding stopped working. b) Reintroduced code to call MFXVideoENCODE_Query() after calling init_video_param(). This isn't strictly required to fix the interlaced video encoding issue, but it represents a generally good practice to make sure that one is working with the right parameter values. --- libavcodec/qsvenc.c | 33 + libavcodec/qsvenc.h | 1 + 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 9c385a7..24ac390 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -358,6 +358,9 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) return AVERROR_BUG; q->param.mfx.CodecId = ret; +// TODO: detect version of MFX--if the minor version is greater than +// or equal to 19, then can use the same alignment settings as H.264 +// for HEVC q->width_align = avctx->codec_id == AV_CODEC_ID_HEVC ? 32 : 16; if (avctx->level > 0) @@ -381,20 +384,34 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) ff_qsv_map_pixfmt(sw_format, &q->param.mfx.FrameInfo.FourCC); -q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, q->width_align); -q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, 32); q->param.mfx.FrameInfo.CropX = 0; q->param.mfx.FrameInfo.CropY = 0; q->param.mfx.FrameInfo.CropW = avctx->width; q->param.mfx.FrameInfo.CropH = avctx->height; q->param.mfx.FrameInfo.AspectRatioW = avctx->sample_aspect_ratio.num; q->param.mfx.FrameInfo.AspectRatioH = avctx->sample_aspect_ratio.den; -q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; q->param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420; q->param.mfx.FrameInfo.BitDepthLuma = desc->comp[0].depth; q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth; q->param.mfx.FrameInfo.Shift = desc->comp[0].depth > 8; +q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, q->width_align); +if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { +// it is important that PicStruct be setup correctly from the +// start--otherwise, encoding doesn't work and results in a bunch +// of incompatible video parameter errors +q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF; +// height alignment always must be 32 for interlaced video +q->height_align = 32; +} else { +q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; +// for progressive video, the height should be aligned to 16 for +// H.264. For HEVC, depending on the version of MFX, it should be +// either 32 or 16. The lower number is better if possible. +q->height_align = avctx->codec_id == AV_CODEC_ID_HEVC ? 32 : 16; +} +q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, q->height_align); + if (avctx->hw_frames_ctx) { AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx; @@ -740,10 +757,18 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) if (ret < 0) return ret; +ret = MFXVideoENCODE_Query(q->session, &q->param, &q->param); +if (ret == MFX_WRN_PARTIAL_ACCELERATION) { +av_log(avctx, AV_LOG_WARNING, "Encoder will work with partial HW acceleration\n"); +} else if (ret < 0) { +return ff_qsv_print_error(avctx, ret, + "Error querying encoder params"); +} + re
[FFmpeg-devel] [PATCH 1/2] qsvenc: Use MFXVideoENCODE_Query() to update the parameters
From 2882d77d76805e74fe139f6763f91c39746bebaf Mon Sep 17 00:00:00 2001 From: Aaron Levinson Date: Fri, 5 May 2017 18:49:57 -0700 Subject: [PATCH 1/2] qsvenc: Use MFXVideoENCODE_Query() to update the parameters Purpose: Fill out the default/unset parameters with ones actually in use. Note: Matches the current MediaSDK example code. This code used to be present in ffmpeg and was eliminated in revision 1f26a23 on Oct. 31, 2016 (qsv: Merge libav implementation, at https://github.com/FFmpeg/FFmpeg/commit/1f26a231bb065276cd80ce02957c759f3197edfa#diff-7d84a34d58597bb7aa4b8239dca1f9f8). Already applied to libav. Reviewed-by: Luca Barbato (cherry picked from commit b22094d74901fb3ac203c8322f8d84aded470bfb) Signed-off-by: Mark Thompson Signed-off-by: Aaron Levinson --- libavcodec/qsvenc.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 9c385a79d8..68d4f5edd0 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -740,10 +740,18 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) if (ret < 0) return ret; +ret = MFXVideoENCODE_Query(q->session, &q->param, &q->param); +if (ret == MFX_WRN_PARTIAL_ACCELERATION) { +av_log(avctx, AV_LOG_WARNING, "Encoder will work with partial HW acceleration\n"); +} else if (ret < 0) { +return ff_qsv_print_error(avctx, ret, + "Error querying encoder params"); +} + ret = MFXVideoENCODE_QueryIOSurf(q->session, &q->param, &q->req); if (ret < 0) return ff_qsv_print_error(avctx, ret, - "Error querying the encoding parameters"); + "Error querying (IOSurf) the encoding parameters"); if (opaque_alloc) { ret = qsv_init_opaque_alloc(avctx, q); -- 2.12.2.windows.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/2] qsvenc: Make sure the interlaced encoding works
From 30eb78bac7bd92b0c085ba6873341e8319072acc Mon Sep 17 00:00:00 2001 From: Aaron Levinson Date: Fri, 5 May 2017 21:31:30 -0700 Subject: [PATCH 2/2] qsvenc: Make sure the interlaced encoding works Purpose: qsvenc: make sure that interlaced encoding works. Also, reduce the vertical alignment constraint when possible to reduce memory usage. Note: Most of this code used to be present in ffmpeg and was eliminated in revision 1f26a23 on Oct. 31, 2016 (qsv: Merge libav implementation, at https://github.com/FFmpeg/FFmpeg/commit/1f26a231bb065276cd80ce02957c759f3197 edfa#diff-7d84a34d58597bb7aa4b8239dca1f9f8). Already applied to libav. Reviewed-by: Luca Barbato (cherry picked from commit 8fd8f91e47f33cd82371a97ac81afc476144964f) Signed-off-by: Mark Thompson Signed-off-by: Aaron Levinson --- libavcodec/qsvenc.c | 29 +++-- libavcodec/qsvenc.h | 1 + 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 68d4f5edd0..57bc83a47f 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -358,8 +358,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) return AVERROR_BUG; q->param.mfx.CodecId = ret; -q->width_align = avctx->codec_id == AV_CODEC_ID_HEVC ? 32 : 16; - if (avctx->level > 0) q->param.mfx.CodecLevel = avctx->level; @@ -381,20 +379,39 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) ff_qsv_map_pixfmt(sw_format, &q->param.mfx.FrameInfo.FourCC); -q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, q->width_align); -q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, 32); q->param.mfx.FrameInfo.CropX = 0; q->param.mfx.FrameInfo.CropY = 0; q->param.mfx.FrameInfo.CropW = avctx->width; q->param.mfx.FrameInfo.CropH = avctx->height; q->param.mfx.FrameInfo.AspectRatioW = avctx->sample_aspect_ratio.num; q->param.mfx.FrameInfo.AspectRatioH = avctx->sample_aspect_ratio.den; -q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; q->param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420; q->param.mfx.FrameInfo.BitDepthLuma = desc->comp[0].depth; q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth; q->param.mfx.FrameInfo.Shift = desc->comp[0].depth > 8; +// TODO: detect version of MFX--if the minor version is greater than +// or equal to 19, then can use the same alignment settings as H.264 +// for HEVC +q->width_align = avctx->codec_id == AV_CODEC_ID_HEVC ? 32 : 16; +q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, q->width_align); + +if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { +// it is important that PicStruct be setup correctly from the +// start--otherwise, encoding doesn't work and results in a bunch +// of incompatible video parameter errors +q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF; +// height alignment always must be 32 for interlaced video +q->height_align = 32; +} else { +q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; +// for progressive video, the height should be aligned to 16 for +// H.264. For HEVC, depending on the version of MFX, it should be +// either 32 or 16. The lower number is better if possible. +q->height_align = avctx->codec_id == AV_CODEC_ID_HEVC ? 32 : 16; +} +q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, q->height_align); + if (avctx->hw_frames_ctx) { AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx; @@ -898,7 +915,7 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame, } else { /* make a copy if the input is not padded as libmfx requires */ if (frame->height & 31 || frame->linesize[0] & (q->width_align - 1)) { -qf->frame->height = FFALIGN(frame->height, 32); +qf->frame->height = FFALIGN(frame->height, q->height_align); qf->frame->width = FFALIGN(frame->width, q->width_align); ret = ff_get_buffer(q->avctx, qf->frame, AV_GET_BUFFER_FLAG_REF); diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 361d9333d8..12e3444b75 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -84,6 +84,7 @@ typedef struct QSVEncContext { int packet_size; int width_align; +int height_align; mfxVideoParam param; mfxFrameAllocRequest req; -- 2.12.2.windows.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavfi/avfiltergraph: only return EOF in avfilter_graph_request_oldest if all sinks EOFed
On Sun, 7 May 2017, Marton Balint wrote: On Sun, 7 May 2017, Nicolas George wrote: Le septidi 17 floréal, an CCXXV, Marton Balint a écrit : Fixes a regression introduced in 32c59a115d3cc757676b5384a5ea44b5a7a7b872, becoming effective in 912969a33e313c57c906e87a7e2367b78a2160f4. Fixes trimmed output of ffmpeg -f lavfi -i "sine=d=0.01" -f lavfi -i "sine=d=1" -filter_complex "[0:a]anull[a1];[1:a]anull[a2]" -map "[a1]" -f null none -map "[a2]" -f framecrc - --- libavfilter/avfiltergraph.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) LGTM, thanks for finding that. Out of curiosity, how did you arrive to a graph with buffersc and buffersink connected directly? The original command and filter graph which I used when I hit this bug was quite complex and was operating on a real file, I had to come up with a simplified version to make debugging easier. Obviously you can replace anull with any audio filter and still experience the trimmed output. Pushed and backported to 3.3. Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] ffmpeg: check for unconnected outputs
On Sat, 6 May 2017, James Almer wrote: On 5/2/2017 8:06 PM, wm4 wrote: Fixes e.g.: ffmpeg -f lavfi -i testsrc -f lavfi -i testsrc -filter_complex "[0:v][1:v]psnr[out]" -f null none This should be backported to release/3.3 before 3.3.1 is tagged. Done. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] ffmpeg: check for unconnected outputs
On 5/7/2017 3:02 PM, Marton Balint wrote: > > On Sat, 6 May 2017, James Almer wrote: > >> On 5/2/2017 8:06 PM, wm4 wrote: >>> Fixes e.g.: >>> >>> ffmpeg -f lavfi -i testsrc -f lavfi -i testsrc -filter_complex >>> "[0:v][1:v]psnr[out]" -f null none >> >> This should be backported to release/3.3 before 3.3.1 is tagged. > > Done. Thanks! ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Made minor changes to get the decklink avdevice code to build using Visual C++
On Fri, 5 May 2017, Aaron Levinson wrote: On 5/5/2017 4:57 PM, Marton Balint wrote: On Fri, 5 May 2017, Aaron Levinson wrote: On 4/16/2017 4:11 PM, Aaron Levinson wrote: On 4/15/2017 6:13 AM, Aaron Levinson wrote: On 4/15/2017 4:19 AM, Marton Balint wrote: On Thu, 13 Apr 2017, Aaron Levinson wrote: On 4/13/2017 1:23 PM, Hendrik Leppkes wrote: [...] Ping, and in addition, I've provided a new patch below since the original won't apply anymore. I've also adjusted the patch text a little bit. The original patch went through a few different reviews. These changes are necessary to get the decklink code to build using MSVC on Windows. Thanks, Aaron Levinson [...] case PTS_SRC_WALLCLOCK: -pts = av_rescale_q(wallclock, AV_TIME_BASE_Q, time_base); +{ +/* MSVC does not support compound literals like AV_TIME_BASE_Q + * in C++ code (compiler error C4576) */ +// pts = av_rescale_q(wallclock, AV_TIME_BASE_Q, time_base); I'd rather remove the old code, i see no point in keeping it as a comment. Done--new patch with this change follows at the end. [...] The decklink part seems fine otherwise, maybe you should get an ACK from Hendrik for the configure part, which I have no opinion about. Hendrik already reviewed the configure changes last month, and the configure part of the patch went through three iterations till it was determined that it was adequate, although it wouldn't hurt to have another look since then. Ok, will apply this tomorrow. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avfilter: add arbitrary audio FIR filter
Signed-off-by: Paul B Mahol --- configure| 2 + doc/filters.texi | 30 +++ libavfilter/Makefile | 1 + libavfilter/af_afir.c| 541 +++ libavfilter/allfilters.c | 1 + 5 files changed, 575 insertions(+) create mode 100644 libavfilter/af_afir.c diff --git a/configure b/configure index b3cb5b0..0d83c6a 100755 --- a/configure +++ b/configure @@ -3078,6 +3078,8 @@ unix_protocol_select="network" # filters afftfilt_filter_deps="avcodec" afftfilt_filter_select="fft" +afir_filter_deps="avcodec" +afir_filter_select="fft" amovie_filter_deps="avcodec avformat" aresample_filter_deps="swresample" ass_filter_deps="libass" diff --git a/doc/filters.texi b/doc/filters.texi index 119e747..7b6a67b 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -878,6 +878,36 @@ afftfilt="1-clip((b/nb)*b,0,1)" @end example @end itemize +@section afir + +Apply an Arbitary Frequency Impulse Response filter. + +This filter uses second stream as FIR coefficients. +If second stream holds single channel, it will be used +for all input channels in first stream, otherwise +number of channels in second stream must be same as +number of channels in first stream. + +It accepts the following parameters: + +@table @option +@item dry +Set dry gain. This sets input gain. + +@item wet +Set wet gain. This sets final output gain. + +@item envelope +How much to fade out Impulse Response to the end. + +@item length +Set Impulse Response filter length. Default is 1, which means whole IR is processed. + +@item auto +Enable auto gain calculation of Impulse Response coefficients. +By default is enabled. +@end table + @anchor{aformat} @section aformat diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 66c36e4..c797eb5 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -38,6 +38,7 @@ OBJS-$(CONFIG_AEMPHASIS_FILTER) += af_aemphasis.o OBJS-$(CONFIG_AEVAL_FILTER) += aeval.o OBJS-$(CONFIG_AFADE_FILTER) += af_afade.o OBJS-$(CONFIG_AFFTFILT_FILTER) += af_afftfilt.o window_func.o +OBJS-$(CONFIG_AFIR_FILTER) += af_afir.o OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o OBJS-$(CONFIG_AGATE_FILTER) += af_agate.o OBJS-$(CONFIG_AINTERLEAVE_FILTER)+= f_interleave.o diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c new file mode 100644 index 000..7f0afce --- /dev/null +++ b/libavfilter/af_afir.c @@ -0,0 +1,541 @@ +/* + * Copyright (c) 2017 Paul B Mahol + * + * 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 + * An arbitrary audio FIR filter + */ + +#include "libavutil/audio_fifo.h" +#include "libavutil/common.h" +#include "libavutil/opt.h" +#include "libavcodec/avfft.h" + +#include "audio.h" +#include "avfilter.h" +#include "formats.h" +#include "internal.h" + +#define MAX_IR_DURATION 30 + +typedef struct AudioFIRContext { +const AVClass *class; + +float wet_gain; +float dry_gain; +float envelope; +float length; +int auto_gain; + +float gain; + +int eof_coeffs; +int have_coeffs; +int nb_coeffs; +int nb_taps; +int part_size; +int nb_partitions; +int nb_channels; +int ir_length; +int fft_length; +int nb_coef_channels; +int one2many; +int nb_samples; +int want_skip; +int need_padding; + +RDFTContext **rdft, **irdft; +float **sum; +float **block; +FFTComplex **coeff; + +AVAudioFifo *fifo[2]; +AVFrame *in[2]; +AVFrame *buffer; +int64_t pts; +int index; +} AudioFIRContext; + +static int fir_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) +{ +AudioFIRContext *s = ctx->priv; +const FFTComplex *coeff = s->coeff[ch * !s->one2many]; +const float *src = (const float *)s->in[0]->extended_data[ch]; +int index1 = (s->index + 1) % 3; +int index2 = (s->index + 2) % 3; +float *block = s->block[ch]; +float *sum = s->sum[ch]; +AVFrame *out = arg; +float *dst; +int n, i; + +memset(sum, 0, sizeof(*sum) * s->fft_length); +memset(block, 0, sizeof(*block) * s->fft_length); +for (n = 0; n < s->nb_samples; n++) { +block[s-
Re: [FFmpeg-devel] [PATCH 2/3] lavc: add a framework to fix alignment problems.
On Sun, May 7, 2017 at 7:17 PM, Ronald S. Bultje wrote: > Hi, > > On Sun, May 7, 2017 at 11:15 AM, Hendrik Leppkes > wrote: > >> Ronald suggested on IRC that the only parts suffering from this are >> the ASM DSP components, and we should just make checkasm tests for all >> of them and let checkasm test the alignment they claim to support, but >> alas this won't be done for months, if not years. > > > This really isn't that complicated once we get the general design and goals > explicitly documented. > > We test all kind of crazy stuff in checkasm, like xmm register clobbering. > This is just another strange thing that can be done in generic code. We > just need to decide what is OK so we know what to test. > I'm not worried about checkasm perfoming the test, but all DSP components actually having tests. - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] videotoolbox: add hwcontext support
Are you also planning to change ffmpeg_videotoolbox.c? See below for more comments. Aaron Levinson On 5/2/2017 8:26 PM, wm4 wrote: This adds tons of code for no other benefit than making VideoToolbox support conform with the new hwaccel API (using hw_device_ctx and hw_frames_ctx). Since VideoToolbox decoding does not actually require the user to allocate frames, the new code does mostly nothing. One benefit is that ffmpeg_videotoolbox.c can be dropped once generic hwaccel support for ffmpeg.c is merged from Libav. Does not consider VDA or VideoToolbox encoding. Fun fact: the frame transfer functions are copied from vaapi, as the mapping makes copying generic boilerplate. Mapping itself is not exported by the VT code, because I don't know how to test. TODO: API bumps --- doc/APIchanges | 8 ++ libavcodec/vda_vt_internal.h | 7 ++ libavcodec/videotoolbox.c | 186 ++-- libavutil/Makefile | 3 + libavutil/hwcontext.c | 3 + libavutil/hwcontext.h | 1 + libavutil/hwcontext_internal.h | 1 + libavutil/hwcontext_videotoolbox.c | 243 + libavutil/hwcontext_videotoolbox.h | 54 + 9 files changed, 496 insertions(+), 10 deletions(-) create mode 100644 libavutil/hwcontext_videotoolbox.c create mode 100644 libavutil/hwcontext_videotoolbox.h diff --git a/doc/APIchanges b/doc/APIchanges index fcd3423d58..71f5563f03 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,14 @@ libavutil: 2015-08-28 Note that the APIchanges part prevents the entire patch from applying, but that's to be expected. API changes, most recent first: +2017-05-03 - xx - lavc 57.xx.100 - avcodec.h + VideoToolbox hardware accelerated decoding now supports the new hwaccel API, + which can create the decoder context and allocate hardware frame automatically. + See AVCodecContext.hw_device_ctx and AVCodecContext.hw_frames_ctx. I'd change the first sentence as follows: "VideoToolbox hardware-accelerated decoding now supports the new hwaccel API, which can create the decoder context and allocate hardware frames automatically." Changes are "hardware accelerated" -> "hardware-accelerated" and "hardware frame automatically" -> "hardware frames automatically". + +2017-05-03 - xx - lavu 57.xx.100 - hwcontext.h + Add AV_HWDEVICE_TYPE_VIDEOTOOLBOX and implementation. + 2017-04-11 - 8378466507 - lavu 55.61.100 - avstring.h Add av_strireplace(). diff --git a/libavcodec/vda_vt_internal.h b/libavcodec/vda_vt_internal.h index 9ff63ccc52..e55a813899 100644 --- a/libavcodec/vda_vt_internal.h +++ b/libavcodec/vda_vt_internal.h @@ -40,6 +40,13 @@ typedef struct VTContext { // The core video buffer CVImageBufferRefframe; + +// Current dummy frames context (depends on exact CVImageBufferRef params). +struct AVBufferRef *cached_hw_frames_ctx; + +// Non-NULL if the new hwaccel API is used. This is only a separate struct +// to ease compatibility with the old API. +struct AVVideotoolboxContext *vt_ctx; } VTContext; int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame); diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 67adad53ed..910ac25ea7 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -23,11 +23,13 @@ #include "config.h" #if CONFIG_VIDEOTOOLBOX # include "videotoolbox.h" +# include "libavutil/hwcontext_videotoolbox.h" #else # include "vda.h" #endif #include "vda_vt_internal.h" #include "libavutil/avutil.h" +#include "libavutil/hwcontext.h" #include "bytestream.h" #include "h264dec.h" #include "mpegvideo.h" @@ -188,6 +190,79 @@ int ff_videotoolbox_uninit(AVCodecContext *avctx) } #if CONFIG_VIDEOTOOLBOX +// Return the AVVideotoolboxContext that matters currently. Where it comes from +// depends on the API used. +static AVVideotoolboxContext *videotoolbox_get_context(AVCodecContext *avctx) +{ +// Somewhat tricky because the API user can call av_videotoolbox_default_free() +// at any time. Comment will make more sense if "API" is dropped from the sentence. +if (avctx->internal && avctx->internal->hwaccel_priv_data) { +VTContext *vtctx = avctx->internal->hwaccel_priv_data; +if (vtctx->vt_ctx) +return vtctx->vt_ctx; +} From your comment, and your answers to my questions on IRC, it is clear that these various checks are only needed for the case that av_videotoolbox_default_free() may be called after the codec is closed. However, this situation isn't relevant for most of the functions in your patch that call videotoolbox_get_content(). I suggest moving this check into videotoolbox_default_free() (which would replace the call to videotoolbox_get_context() there). If that's done, then videotoolbox_get_context() can be implemented as: VTContext *vtctx
Re: [FFmpeg-devel] [PATCH 2/3] lavc: add a framework to fix alignment problems.
Hi, On Sun, May 7, 2017 at 2:55 PM, Hendrik Leppkes wrote: > On Sun, May 7, 2017 at 7:17 PM, Ronald S. Bultje > wrote: > > Hi, > > > > On Sun, May 7, 2017 at 11:15 AM, Hendrik Leppkes > > wrote: > > > >> Ronald suggested on IRC that the only parts suffering from this are > >> the ASM DSP components, and we should just make checkasm tests for all > >> of them and let checkasm test the alignment they claim to support, but > >> alas this won't be done for months, if not years. > > > > > > This really isn't that complicated once we get the general design and > goals > > explicitly documented. > > > > We test all kind of crazy stuff in checkasm, like xmm register > clobbering. > > This is just another strange thing that can be done in generic code. We > > just need to decide what is OK so we know what to test. > > > > I'm not worried about checkasm perfoming the test, but all DSP > components actually having tests. Test coverage in general is a fair point, we can work on that... Ronald ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] tests/fate/fifo-muxer: update fifo-muxer dependencies
On 5/4/17, Tobias Rapp wrote: > Fixes fate when configured with --disable-network. > --- > tests/fate/fifo-muxer.mak | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tests/fate/fifo-muxer.mak b/tests/fate/fifo-muxer.mak > index ef8b3b3..9c13954 100644 > --- a/tests/fate/fifo-muxer.mak > +++ b/tests/fate/fifo-muxer.mak > @@ -13,7 +13,7 @@ FATE_SAMPLES_FIFO_MUXER-$(call ALLYES, FIFO_MUXER, > WAV_DEMUXER) += fate-fifo-mux > > fate-fifo-muxer-tst: libavformat/tests/fifo_muxer$(EXESUF) > fate-fifo-muxer-tst: CMD = run libavformat/tests/fifo_muxer$(EXESUF) > -FATE_FIFO_MUXER-$(CONFIG_FIFO_MUXER) += fate-fifo-muxer-tst > +FATE_FIFO_MUXER-$(call ALLYES, FIFO_MUXER NETWORK) += fate-fifo-muxer-tst > > FATE_SAMPLES_FFMPEG += $(FATE_SAMPLES_FIFO_MUXER-yes) > FATE_FFMPEG += $(FATE_FIFO_MUXER-yes) > -- > 2.7.4 LGTM ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avformat/hlsenc: fix memleak
fix memleak bug, when all the process is normal, just free old_filename Signed-off-by: Steven Liu --- libavformat/hlsenc.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 221089c..d62d5b8 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1559,6 +1559,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) av_free(old_filename); return ret; } + +av_free(old_filename); } ret = ff_write_chained(oc, stream_index, pkt, s, 0); -- 1.7.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] lavd/alsa: fixes ALSA resource leak on closing the PCM handle
By avoiding thread race condition (CAS-ing with null handle) --- libavdevice/alsa.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c index 1bbff30..81187ab 100644 --- a/libavdevice/alsa.c +++ b/libavdevice/alsa.c @@ -30,6 +30,7 @@ #include #include "avdevice.h" +#include "libavutil/atomic.h" #include "libavutil/avassert.h" #include "libavutil/channel_layout.h" @@ -299,13 +300,14 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode, av_cold int ff_alsa_close(AVFormatContext *s1) { AlsaData *s = s1->priv_data; +snd_pcm_t *h = avpriv_atomic_ptr_cas((void* volatile *)&s->h, s->h, 0); -snd_pcm_nonblock(s->h, 0); -snd_pcm_drain(s->h); +snd_pcm_nonblock(h, 0); +snd_pcm_drain(h); av_freep(&s->reorder_buf); if (CONFIG_ALSA_INDEV) ff_timefilter_destroy(s->timefilter); -snd_pcm_close(s->h); +snd_pcm_close(h); return 0; } ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavd/alsa: fixes ALSA resource leak on closing the PCM handle
On 5/8/2017 1:09 AM, Takayuki 'January June' Suwa wrote: > By avoiding thread race condition (CAS-ing with null handle) > > --- > libavdevice/alsa.c | 8 +--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c > index 1bbff30..81187ab 100644 > --- a/libavdevice/alsa.c > +++ b/libavdevice/alsa.c > @@ -30,6 +30,7 @@ > > #include > #include "avdevice.h" > +#include "libavutil/atomic.h" > #include "libavutil/avassert.h" > #include "libavutil/channel_layout.h" > > @@ -299,13 +300,14 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, > snd_pcm_stream_t mode, > av_cold int ff_alsa_close(AVFormatContext *s1) > { > AlsaData *s = s1->priv_data; > +snd_pcm_t *h = avpriv_atomic_ptr_cas((void* volatile *)&s->h, s->h, 0); The libavutil/atomics wrappers are going to be removed soon once all code is finally ported. You should instead use C11 atomics for this. > > -snd_pcm_nonblock(s->h, 0); > -snd_pcm_drain(s->h); > +snd_pcm_nonblock(h, 0); > +snd_pcm_drain(h); > av_freep(&s->reorder_buf); > if (CONFIG_ALSA_INDEV) > ff_timefilter_destroy(s->timefilter); > -snd_pcm_close(s->h); > +snd_pcm_close(h); > return 0; > } > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/7] lavf/segment: add option to segment by chapter
--- doc/muxers.texi | 6 + libavformat/segment.c | 65 +++ libavformat/version.h | 2 +- 3 files changed, 67 insertions(+), 6 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 0866142..b80bc68 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1521,6 +1521,12 @@ This option specifies to start a new segment whenever a reference stream key frame is found and the sequential number (starting from 0) of the frame is greater or equal to the next value in the list. +@item segment_chapters @var{1|0} +Split each chapter into its own segment. Metadata from the chapters +will be written to the corresponding segments. If this option is selected +and the filename contains tokens in the format @code{$varname$}, they +will be replaced by the corresponding metadata values. + @item segment_wrap @var{limit} Wrap around segment index once it reaches @var{limit}. diff --git a/libavformat/segment.c b/libavformat/segment.c index 8ec3653..8575d32 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -108,6 +108,8 @@ typedef struct SegmentContext { int frame_count; ///< total number of reference frames int segment_frame_count; ///< number of reference frames in the segment +int split_chapters;///< split on chapter markers + int64_t time_delta; int individual_header_trailer; /**< Set by a private option. */ int write_header_trailer; /**< Set by a private option. */ @@ -188,6 +190,43 @@ static int segment_mux_init(AVFormatContext *s) return 0; } +static int replace_variables(AVFormatContext *oc) +{ +char name[sizeof(oc->filename)]; +char *p = name; +char *out = oc->filename; +strncpy(name, oc->filename, sizeof(name)); +while (*p) { +char c = *p++; +if (c == '$') { +if (*p == '$') { +p++; +goto append; +} else { +int len; +const char *val; +const AVDictionaryEntry *e; +int end = strcspn(p, "$"); +if (p[end] == '\0') +continue; +p[end] = '\0'; +e = av_dict_get(oc->metadata, p, NULL, 0); +val = e ? e->value : "(unknown)"; +len = strlen(val); +strncpy(out, val, oc->filename + sizeof(oc->filename) - 1 - out); +out = FFMIN(oc->filename + sizeof(oc->filename) - 1, out + len); +p += end + 1; +} +} else { +append: +if (out - oc->filename < sizeof(oc->filename) - 1) +*out++ = c; +} +} +*out = '\0'; +return 0; +} + static int set_segment_filename(AVFormatContext *s) { SegmentContext *seg = s->priv_data; @@ -212,6 +251,9 @@ static int set_segment_filename(AVFormatContext *s) return AVERROR(EINVAL); } +if (seg->split_chapters) +replace_variables(oc); + /* copy modified name in list entry */ size = strlen(av_basename(oc->filename)) + 1; if (seg->entry_prefix) @@ -238,6 +280,8 @@ static int segment_start(AVFormatContext *s, int write_header) if ((err = segment_mux_init(s)) < 0) return err; oc = seg->avf; +if (seg->split_chapters && seg->segment_count < s->nb_chapters && (err = av_dict_copy(&oc->metadata, s->chapters[seg->segment_count]->metadata, 0)) < 0) +return err; } seg->segment_idx++; @@ -661,10 +705,14 @@ static int seg_init(AVFormatContext *s) "you can use output_ts_offset instead of it\n"); } -if (!!seg->time_str + !!seg->times_str + !!seg->frames_str > 1) { +if (seg->segment_idx < 0) +seg->segment_idx = seg->split_chapters; + +if (!!seg->time_str + !!seg->times_str + !!seg->frames_str + !!seg->split_chapters > 1) { av_log(s, AV_LOG_ERROR, - "segment_time, segment_times, and segment_frames options " - "are mutually exclusive, select just one of them\n"); + "segment_time, segment_times, segment_frames, and " + "segment_chapters options are mutually exclusive; " + "select just one of them\n"); return AVERROR(EINVAL); } @@ -674,7 +722,7 @@ static int seg_init(AVFormatContext *s) } else if (seg->frames_str) { if ((ret = parse_frames(s, &seg->frames, &seg->nb_frames, seg->frames_str)) < 0) return ret; -} else { +} else if (!seg->split_chapters) { /* set default value if not specified */ if (!seg->time_str) seg->time_str = av_strdup("2"); @@ -741,6 +789,9 @@ static int seg_init(AVFormatContext *s) if ((ret = segment_mux_init(s)) < 0) return ret; +if (seg->split_chapters && s->nb_chapters && (ret = av_dict_copy(&seg->avf->metadata, s->chapters[0]->metadata, 0)) < 0) +return ret; +
[FFmpeg-devel] [PATCH 5/7] lavf/flacenc: support writing attached pictures
--- libavformat/flacenc.c | 271 +++--- 1 file changed, 236 insertions(+), 35 deletions(-) diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index b894f9e..9bb4947 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -21,10 +21,13 @@ #include "libavutil/channel_layout.h" #include "libavutil/opt.h" +#include "libavutil/pixdesc.h" #include "libavcodec/flac.h" #include "avformat.h" #include "avio_internal.h" #include "flacenc.h" +#include "id3v2.h" +#include "internal.h" #include "vorbiscomment.h" #include "libavcodec/bytestream.h" @@ -33,8 +36,16 @@ typedef struct FlacMuxerContext { const AVClass *class; int write_header; +int audio_stream_idx; +AVPacket *pics; +int nb_pics, waiting_pics; +/* audio packets are queued here until we get all the attached pictures */ +AVPacketList *queue, *queue_end; + /* updated streaminfo sent by the encoder at the end */ uint8_t *streaminfo; + +unsigned attached_types; } FlacMuxerContext; static int flac_write_block_padding(AVIOContext *pb, unsigned int n_padding_bytes, @@ -74,31 +85,149 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m, return 0; } -static int flac_write_header(struct AVFormatContext *s) +static int flac_write_picture(struct AVFormatContext *s, AVPacket *pkt) { -int ret; -int padding = s->metadata_header_padding; -AVCodecParameters *par = s->streams[0]->codecpar; -FlacMuxerContext *c = s->priv_data; - -if (!c->write_header) +FlacMuxerContext *c = s->priv_data; +AVIOContext *pb = s->pb; +const AVPixFmtDescriptor *pixdesc; +const CodecMime *mime = ff_id3v2_mime_tags; +AVDictionaryEntry *e; +const char *mimetype = NULL, *desc = ""; +const AVStream *st = s->streams[pkt->stream_index]; +int i, mimelen, desclen, type = 0; + +if (!pkt->data) return 0; -if (s->nb_streams > 1) { -av_log(s, AV_LOG_ERROR, "only one stream is supported\n"); +while (mime->id != AV_CODEC_ID_NONE) { +if (mime->id == st->codecpar->codec_id) { +mimetype = mime->str; +break; +} +mime++; +} +if (!mimetype) { +av_log(s, AV_LOG_ERROR, "No mimetype is known for stream %d, cannot " + "write an attached picture.\n", st->index); return AVERROR(EINVAL); } -if (par->codec_id != AV_CODEC_ID_FLAC) { -av_log(s, AV_LOG_ERROR, "unsupported codec\n"); +mimelen = strlen(mimetype); + +/* get the picture type */ +e = av_dict_get(st->metadata, "comment", NULL, 0); +for (i = 0; e && i < FF_ARRAY_ELEMS(ff_id3v2_picture_types); i++) { +if (!av_strcasecmp(e->value, ff_id3v2_picture_types[i])) { +type = i; +break; +} +} + +if (c->attached_types & (1 << type)) { +av_log(s, AV_LOG_ERROR, "Duplicate attachment for type '%s'\n", ff_id3v2_picture_types[type]); return AVERROR(EINVAL); } +c->attached_types |= (1 << type); + +/* get the description */ +if ((e = av_dict_get(st->metadata, "title", NULL, 0))) +desc = e->value; +desclen = strlen(desc); + +avio_w8(pb, 0x06); +avio_wb24(pb, 4 + 4 + mimelen + 4 + desclen + 4 + 4 + 4 + 4 + 4 + pkt->size); + +avio_wb32(pb, type); + +avio_wb32(pb, mimelen); +avio_write(pb, mimetype, mimelen); + +avio_wb32(pb, desclen); +avio_write(pb, desc, desclen); + +avio_wb32(pb, st->codecpar->width); +avio_wb32(pb, st->codecpar->height); +if ((pixdesc = av_pix_fmt_desc_get(st->codecpar->format))) +avio_wb32(pb, av_get_bits_per_pixel(pixdesc)); +else +avio_wb32(pb, 0); +avio_wb32(pb, 0); + +avio_wb32(pb, pkt->size); +avio_write(pb, pkt->data, pkt->size); +return 0; +} + +static int flac_finish_header(struct AVFormatContext *s) +{ +FlacMuxerContext *c = s->priv_data; +int i, ret, padding = s->metadata_header_padding; if (padding < 0) padding = 8192; /* The FLAC specification states that 24 bits are used to represent the * size of a metadata block so we must clip this value to 2^24-1. */ padding = av_clip_uintp2(padding, 24); +for (i = 0; i < c->nb_pics; i++) { +ret = flac_write_picture(s, &c->pics[i]); +if (ret) +return ret; +} + +ret = flac_write_block_comment(s->pb, &s->metadata, !padding, + s->flags & AVFMT_FLAG_BITEXACT); +if (ret) +return ret; + +/* The command line flac encoder defaults to placing a seekpoint + * every 10s. So one might add padding to allow that later + * but there seems to be no simple way to get the duration here. + * So just add the amount requested by the user. */ +if (padding) +flac_write_block_padding(s->pb, padding, 1); + +return 0; +} + +static int flac_write_header(struct AVFor
[FFmpeg-devel] [PATCH 4/7] lavf/segment: write attached pictures to all segments by default
--- doc/muxers.texi | 4 libavformat/segment.c | 24 libavformat/version.h | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index b80bc68..3707d05 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1559,6 +1559,10 @@ argument must be a time duration specification, and defaults to 0. If enabled, write an empty segment if there are no packets during the period a segment would usually span. Otherwise, the segment will be filled with the next packet written. Defaults to @code{0}. + +@item dup_attached_pics @var{1|0} +If enabled, attached-picture packets will be written to all segments, rather +than only the first. Defaults to @code{1}. @end table @subsection Examples diff --git a/libavformat/segment.c b/libavformat/segment.c index 9c6ce73..0b9089c 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -121,6 +121,7 @@ typedef struct SegmentContext { int reference_stream_index; int break_non_keyframes; int write_empty; +int dup_attached_pics; int use_rename; char temp_list_filename[1024]; @@ -128,6 +129,8 @@ typedef struct SegmentContext { SegmentListEntry cur_entry; SegmentListEntry *segment_list_entries; SegmentListEntry *segment_list_entries_end; + +AVPacket *attached_pics; } SegmentContext; static void print_csv_escaped_str(AVIOContext *ctx, const char *str) @@ -303,6 +306,7 @@ static int segment_start(AVFormatContext *s, int write_header) av_opt_set(oc->priv_data, "mpegts_flags", "+resend_headers", 0); if (write_header) { +int i; AVDictionary *options = NULL; av_dict_copy(&options, seg->format_options, 0); av_dict_set(&options, "fflags", "-autobsf", 0); @@ -310,6 +314,13 @@ static int segment_start(AVFormatContext *s, int write_header) av_dict_free(&options); if (err < 0) return err; +for (i = 0; i < s->nb_streams; i++) { +if (seg->dup_attached_pics && +s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC && +seg->attached_pics[i].data) { +av_write_frame(oc, &seg->attached_pics[i]); +} +} } seg->segment_frame_count = 0; @@ -682,6 +693,12 @@ static void seg_free(AVFormatContext *s) ff_format_io_close(seg->avf, &seg->list_pb); avformat_free_context(seg->avf); seg->avf = NULL; +if (seg->attached_pics) { +int i; +for (i = 0; i < s->nb_streams; i++) +av_packet_unref(&seg->attached_pics[i]); +av_freep(&seg->attached_pics); +} } static int seg_init(AVFormatContext *s) @@ -842,6 +859,9 @@ static int seg_init(AVFormatContext *s) avpriv_set_pts_info(outer_st, inner_st->pts_wrap_bits, inner_st->time_base.num, inner_st->time_base.den); } +if (seg->dup_attached_pics && !(seg->attached_pics = av_calloc(s->nb_streams, sizeof(AVPacket +return AVERROR(ENOMEM); + if (oc->avoid_negative_ts > 0 && s->avoid_negative_ts < 0) s->avoid_negative_ts = 1; @@ -907,6 +927,9 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt) if (!seg->avf || !seg->avf->pb) return AVERROR(EINVAL); +if (seg->dup_attached_pics && st->disposition & AV_DISPOSITION_ATTACHED_PIC) +av_copy_packet(&seg->attached_pics[pkt->stream_index], pkt); + calc_times: if (seg->times) { end_pts = seg->segment_count < seg->nb_times ? @@ -1113,6 +1136,7 @@ static const AVOption options[] = { { "reset_timestamps", "reset timestamps at the begin of each segment", OFFSET(reset_timestamps), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E }, { "initial_offset", "set initial timestamp offset", OFFSET(initial_offset), AV_OPT_TYPE_DURATION, {.i64 = 0}, -INT64_MAX, INT64_MAX, E }, { "write_empty_segments", "allow writing empty 'filler' segments", OFFSET(write_empty), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E }, +{ "dup_attached_pics", "write attached pictures to all segments", OFFSET(dup_attached_pics), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, E }, { NULL }, }; diff --git a/libavformat/version.h b/libavformat/version.h index 645a226..910e348 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -33,7 +33,7 @@ // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 57 #define LIBAVFORMAT_VERSION_MINOR 73 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MICRO 102 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ -- 2.6.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 3/7] lavf/segment: copy stream dispositions in output
--- libavformat/segment.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/segment.c b/libavformat/segment.c index 8575d32..9c6ce73 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -184,6 +184,7 @@ static int segment_mux_init(AVFormatContext *s) } st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio; st->time_base = s->streams[i]->time_base; +st->disposition = s->streams[i]->disposition; av_dict_copy(&st->metadata, s->streams[i]->metadata, 0); } -- 2.6.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 6/7] lavf/flacenc: avoid buffer overread with unexpected extradata sizes
--- libavformat/flacenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index 9bb4947..b8800cc 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -315,7 +315,7 @@ static int flac_write_trailer(struct AVFormatContext *s) if (!c->write_header || !streaminfo) return 0; -if (pb->seekable & AVIO_SEEKABLE_NORMAL) { +if (pb->seekable & AVIO_SEEKABLE_NORMAL && (c->streaminfo || s->streams[0]->codecpar->extradata_size == FLAC_STREAMINFO_SIZE)) { /* rewrite the STREAMINFO header block data */ file_size = avio_tell(pb); avio_seek(pb, 8, SEEK_SET); -- 2.6.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/7] lavf: add cue sheet demuxer
--- Changelog| 2 + doc/demuxers.texi| 8 ++ libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/cuedec.c | 207 +++ libavformat/version.h| 4 +- 6 files changed, 221 insertions(+), 2 deletions(-) create mode 100644 libavformat/cuedec.c diff --git a/Changelog b/Changelog index 0787bea..3e2776d 100644 --- a/Changelog +++ b/Changelog @@ -8,6 +8,8 @@ version : - pixscope video filter - oscilloscope video filter - config.log and other configuration files moved into ffbuild/ directory +- Cue sheet demuxer + version 3.3: - CrystalHD decoder moved to new decode API diff --git a/doc/demuxers.texi b/doc/demuxers.texi index 29a23d4..7ea4f27 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -244,6 +244,14 @@ file subdir/file-2.wav @end example @end itemize +@section cue + +Cue sheet demuxer. + +This demuxer reads a cue sheet (text file) and exports its track listing in +the form of AVChapters. Packet data is read from the file listed in the sheet. +To override the path the packet data is read from, use the @code{url} option. + @section flv, live_flv Adobe Flash Video Format demuxer. diff --git a/libavformat/Makefile b/libavformat/Makefile index 4e169fd..d4c8b3b 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -130,6 +130,7 @@ OBJS-$(CONFIG_CDXL_DEMUXER) += cdxl.o OBJS-$(CONFIG_CINE_DEMUXER) += cinedec.o OBJS-$(CONFIG_CONCAT_DEMUXER)+= concatdec.o OBJS-$(CONFIG_CRC_MUXER) += crcenc.o +OBJS-$(CONFIG_CUE_DEMUXER) += cuedec.o OBJS-$(CONFIG_DATA_DEMUXER) += rawdec.o OBJS-$(CONFIG_DATA_MUXER)+= rawenc.o OBJS-$(CONFIG_DASH_MUXER)+= dashenc.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 09e62c3..ad29a8c 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -96,6 +96,7 @@ static void register_all(void) REGISTER_DEMUXER (CINE, cine); REGISTER_DEMUXER (CONCAT, concat); REGISTER_MUXER (CRC, crc); +REGISTER_DEMUXER (CUE, cue); REGISTER_MUXER (DASH, dash); REGISTER_MUXDEMUX(DATA, data); REGISTER_MUXDEMUX(DAUD, daud); diff --git a/libavformat/cuedec.c b/libavformat/cuedec.c new file mode 100644 index 000..b177a26 --- /dev/null +++ b/libavformat/cuedec.c @@ -0,0 +1,207 @@ +/* + * Cue sheet demuxer + * Copyright (c) 2016 The FFmpeg Project + * + * 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 + * Cue sheet demuxer + * @author Rodger Combs + */ + +#include "avformat.h" +#include "internal.h" +#include "subtitles.h" +#include "url.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/avstring.h" +#include "libavutil/opt.h" + +typedef struct CueDemuxContext { +AVClass *class; +char *url; +AVFormatContext *avf; +} CueDemuxContext; + +static int cue_probe(AVProbeData *p) +{ +const unsigned char *ptr = p->buf; + +if (AV_RB24(ptr) == 0xEFBBBF) +ptr += 3; /* skip UTF-8 BOM */ +while (*ptr && strncmp(ptr, "FILE ", 5)) +ptr += ff_subtitles_next_line(ptr); +if (!strncmp(ptr, "FILE ", 5)) +return AVPROBE_SCORE_MAX - 5; +return 0; +} + +static char *get_token(char *in) +{ +char *end; +while (av_isspace(*in)) +in++; +if (*in == '"') { +in++; +end = in + strcspn(in, "\"\n\t\r"); +} else { +end = in + strcspn(in, " \n\t\r"); +} +*end = '\0'; +return in; +} + +static int cue_read_header(AVFormatContext *s) +{ +int ret, i; +CueDemuxContext *cue = s->priv_data; +char line[4096], *ptr; +AVDictionary **meta = &s->metadata; +AVChapter *chap = NULL; +while (ff_get_line(s->pb, line, sizeof(line))) { +ptr = line; +if (AV_RB24(ptr) == 0xEFBBBF) +ptr += 3; /* skip UTF-8 BOM */ +while (*ptr == ' ' || *ptr == '\t') +ptr++; +if (!strncmp(ptr, "REM ", 4)) { +char *end = ptr + strcspn(ptr, "\r\n"); +*end = '\0'; +av_log(s, AV_LOG_INFO, "Comment: \"%s\"\n", ptr + 4); +
[FFmpeg-devel] [PATCH 7/7] lavf/flacenc: generate timestamps internally
--- libavformat/flacenc.c | 88 +-- 1 file changed, 85 insertions(+), 3 deletions(-) diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index b8800cc..0e948ac 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -30,6 +30,7 @@ #include "internal.h" #include "vorbiscomment.h" #include "libavcodec/bytestream.h" +#include "libavutil/crc.h" typedef struct FlacMuxerContext { @@ -46,6 +47,9 @@ typedef struct FlacMuxerContext { uint8_t *streaminfo; unsigned attached_types; + +uint64_t samples; +unsigned last_bs; } FlacMuxerContext; static int flac_write_block_padding(AVIOContext *pb, unsigned int n_padding_bytes, @@ -256,11 +260,17 @@ static int flac_write_header(struct AVFormatContext *s) return ret; } +static const int32_t blocksize_table[16] = { + 0,192, 576<<0, 576<<1, 576<<2, 576<<3, 0, 0, +256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7 +}; + static int flac_write_audio_packet(struct AVFormatContext *s, AVPacket *pkt) { FlacMuxerContext *c = s->priv_data; uint8_t *streaminfo; int streaminfo_size; +char header[16]; /* check for updated streaminfo */ streaminfo = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, @@ -274,8 +284,77 @@ static int flac_write_audio_packet(struct AVFormatContext *s, AVPacket *pkt) memcpy(c->streaminfo, streaminfo, FLAC_STREAMINFO_SIZE); } -if (pkt->size) -avio_write(s->pb, pkt->data, pkt->size); +if (pkt->size) { +uint8_t tmp; +uint64_t pts = c->samples; +int offset = 5; +int headerlen = 4; +int bscode, bs; +int crc; +if (pkt->size < FLAC_MIN_FRAME_SIZE) +return AVERROR_INVALIDDATA; +memcpy(header, pkt->data, 4); +if (pkt->pts == AV_NOPTS_VALUE) +pts = 0; +if ((pkt->data[4] & 0xC0) == 0xC0) +offset += ff_clz((unsigned char)~pkt->data[4]) - 25; +else if (pkt->data[4] & 0x80) +return AVERROR_INVALIDDATA; +if (pkt->size <= offset + 1) +return AVERROR_INVALIDDATA; + +bscode = (unsigned char)header[2] >> 4; +bs = blocksize_table[bscode]; +if (bscode == 0) +return AVERROR_INVALIDDATA; +if (bscode == 6) { +if (pkt->size <= offset + 1) +return AVERROR_INVALIDDATA; +bs = pkt->data[offset] + 1; +} else if (bscode == 7) { +if (pkt->size <= offset + 2) +return AVERROR_INVALIDDATA; +bs = AV_RB16(&pkt->data[offset]) + 1; +} +if ((header[1] & 1) == 0) +pts /= c->last_bs ? c->last_bs : bs; + +c->last_bs = bs; + +c->samples += bs; + +PUT_UTF8(pts, tmp, header[headerlen++] = tmp;) +if (headerlen > 11) +return AVERROR_INVALIDDATA; +if ((bscode & 0xE) == 0x6) +header[headerlen++] = pkt->data[offset++]; +if (pkt->size <= offset + 1) +return AVERROR_INVALIDDATA; +if (bscode == 0x7) +header[headerlen++] = pkt->data[offset++]; +if (pkt->size <= offset + 1) +return AVERROR_INVALIDDATA; +if ((header[2] & 0xC) == 0xC) { +header[headerlen++] = pkt->data[offset++]; +if (pkt->size <= offset + 1) +return AVERROR_INVALIDDATA; +if ((header[2] & 0x3) == 0x3) +return AVERROR_INVALIDDATA; +else if (header[2] & 0x3) { +header[headerlen++] = pkt->data[offset++]; +if (pkt->size <= offset + 1) +return AVERROR_INVALIDDATA; +} +} +header[headerlen] = av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, header, headerlen); +headerlen++; offset++; +crc = av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, header, headerlen); +if (pkt->size < offset + 3) +return AVERROR_INVALIDDATA; +avio_write(s->pb, header, headerlen); +avio_write(s->pb, pkt->data + offset, pkt->size - offset - 2); +avio_wl16(s->pb, av_crc(av_crc_get_table(AV_CRC_16_ANSI), crc, pkt->data + offset, pkt->size - offset - 2)); +} return 0; } @@ -319,7 +398,10 @@ static int flac_write_trailer(struct AVFormatContext *s) /* rewrite the STREAMINFO header block data */ file_size = avio_tell(pb); avio_seek(pb, 8, SEEK_SET); -avio_write(pb, streaminfo, FLAC_STREAMINFO_SIZE); +avio_write(pb, streaminfo, 13); +avio_w8(pb, (streaminfo[13] & 0xF0) | ((c->samples >> 32) & 0xF)); +avio_wb32(pb, c->samples); +avio_write(pb, streaminfo + 18, FLAC_STREAMINFO_SIZE - 18); avio_seek(pb, file_size, SEEK_SET); avio_flush(pb); } else { -- 2.6.4 ___ ffmpeg-devel mailing list ffmpeg-devel
[FFmpeg-devel] [PATCH 3/3] lavc: add a librsvg rasterization library wrapper
Enables rendering of SVG images. This is possible since SVG images still contain and specify the dimensions in pixels to which they've been drawn to and thus enable browsers to display them without any external data. Users can still override and generate images with arbitrary resolutions. Signed-off-by: Rostislav Pehlivanov --- configure | 4 ++ libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/librsvgdec.c | 127 4 files changed, 133 insertions(+) create mode 100644 libavcodec/librsvgdec.c diff --git a/configure b/configure index 2e1786a6fc..4f20d177a5 100755 --- a/configure +++ b/configure @@ -245,6 +245,7 @@ External library support: --enable-libopenmpt enable decoding tracked files via libopenmpt [no] --enable-libopus enable Opus de/encoding via libopus [no] --enable-libpulseenable Pulseaudio input via libpulse [no] + --enable-librsvg enable SVG rasterization via librsvg [no] --enable-librubberband enable rubberband needed for rubberband filter [no] --enable-librtmp enable RTMP[E] support via librtmp [no] --enable-libschroedinger enable Dirac de/encoding via libschroedinger [no] @@ -1557,6 +1558,7 @@ EXTERNAL_LIBRARY_LIST=" libopenmpt libopus libpulse +librsvg librtmp libschroedinger libshine @@ -2867,6 +2869,7 @@ libopenmpt_demuxer_deps="libopenmpt" libopus_decoder_deps="libopus" libopus_encoder_deps="libopus" libopus_encoder_select="audio_frame_queue" +librsvg_decoder_deps="librsvg" libschroedinger_decoder_deps="libschroedinger" libschroedinger_encoder_deps="libschroedinger" libshine_encoder_deps="libshine" @@ -5819,6 +5822,7 @@ enabled libopus && { } } enabled libpulse && require_pkg_config libpulse pulse/pulseaudio.h pa_context_new +enabled librsvg && require_pkg_config librsvg-2.0 librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket enabled librubberband && require_pkg_config "rubberband >= 1.8.1" rubberband/rubberband-c.h rubberband_new enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init diff --git a/libavcodec/Makefile b/libavcodec/Makefile index b5c8cc1f98..5829063ee8 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -550,6 +550,7 @@ OBJS-$(CONFIG_SUBVIEWER1_DECODER) += textdec.o ass.o OBJS-$(CONFIG_SUBVIEWER_DECODER) += subviewerdec.o ass.o OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o +OBJS-$(CONFIG_LIBRSVG_DECODER) += librsvgdec.o OBJS-$(CONFIG_SVQ1_DECODER)+= svq1dec.o svq1.o svq13.o h263data.o OBJS-$(CONFIG_SVQ1_ENCODER)+= svq1enc.o svq1.o h263data.o \ h263.o ituh263enc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 7fcc26f2c1..425a32c924 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -319,6 +319,7 @@ static void register_all(void) REGISTER_DECODER(SPEEDHQ, speedhq); REGISTER_DECODER(SRGC, srgc); REGISTER_ENCDEC (SUNRAST, sunrast); +REGISTER_DECODER(LIBRSVG, librsvg); REGISTER_ENCDEC (SVQ1, svq1); REGISTER_DECODER(SVQ3, svq3); REGISTER_ENCDEC (TARGA, targa); diff --git a/libavcodec/librsvgdec.c b/libavcodec/librsvgdec.c new file mode 100644 index 00..29b771c5a3 --- /dev/null +++ b/libavcodec/librsvgdec.c @@ -0,0 +1,127 @@ +/* + * Librsvg rasterization wrapper + * Copyright (c) 2017 Rostislav Pehlivanov + * + * 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 "avcodec.h" +#include "internal.h" +#include "libavutil/opt.h" +#include "librsvg-2.0/librsvg/rsvg.h" + +typedef struct LibRSVGContext { +AVClass *class; + +int width; +int height; +int keep_ar; +} LibRSVGContext; + +static int librsvg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt) +{ +int ret; +LibRSVGContext *s = avctx->priv_data; +AVFrame *frame = data; + +Rs
[FFmpeg-devel] [PATCH 1/3] lavc: add codec ID and description for SVG
Signed-off-by: Rostislav Pehlivanov --- libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 8 2 files changed, 9 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 35df4f6ced..4bbe5179b4 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -445,6 +445,7 @@ enum AVCodecID { AV_CODEC_ID_BITPACKED, AV_CODEC_ID_MSCC, AV_CODEC_ID_SRGC, +AV_CODEC_ID_SVG, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 2d28f840af..8fb157cc5f 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -170,6 +170,14 @@ static const AVCodecDescriptor codec_descriptors[] = { .props = AV_CODEC_PROP_LOSSY, }, { +.id= AV_CODEC_ID_SVG, +.type = AVMEDIA_TYPE_VIDEO, +.name = "svq", +.long_name = NULL_IF_CONFIG_SMALL("Scalable Vector Graphics"), +.props = AV_CODEC_PROP_LOSSLESS, +.mime_types= MT("image/svg+xml"), +}, +{ .id= AV_CODEC_ID_SVQ1, .type = AVMEDIA_TYPE_VIDEO, .name = "svq1", -- 2.13.0.rc1.294.g07d810a77f ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/3] img2dec: add support for piped SVG demuxing
Only checks the extension and MIME type, since determining whether a file is SVG is difficult since they're just XML files. Signed-off-by: Rostislav Pehlivanov --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/img2dec.c| 20 3 files changed, 22 insertions(+) diff --git a/libavformat/Makefile b/libavformat/Makefile index 4e169fdce5..bfba0c1cb4 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -237,6 +237,7 @@ OBJS-$(CONFIG_IMAGE_PPM_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_PSD_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_QDRAW_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_SGI_PIPE_DEMUXER) += img2dec.o img2.o +OBJS-$(CONFIG_IMAGE_SVG_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_TIFF_PIPE_DEMUXER)+= img2dec.o img2.o OBJS-$(CONFIG_IMAGE_WEBP_PIPE_DEMUXER)+= img2dec.o img2.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 09e62c3cfc..62661d14a4 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -369,6 +369,7 @@ static void register_all(void) REGISTER_DEMUXER (IMAGE_PSD_PIPE,image_psd_pipe); REGISTER_DEMUXER (IMAGE_QDRAW_PIPE, image_qdraw_pipe); REGISTER_DEMUXER (IMAGE_SGI_PIPE,image_sgi_pipe); +REGISTER_DEMUXER (IMAGE_SVG_PIPE,image_svg_pipe); REGISTER_DEMUXER (IMAGE_SUNRAST_PIPE,image_sunrast_pipe); REGISTER_DEMUXER (IMAGE_TIFF_PIPE, image_tiff_pipe); REGISTER_DEMUXER (IMAGE_WEBP_PIPE, image_webp_pipe); diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index b454071168..1d532e9343 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -971,6 +971,26 @@ AVInputFormat ff_image_ ## imgname ## _pipe_demuxer = {\ .raw_codec_id = codecid,\ }; +static const AVClass svg_class = { +.class_name = "svg demuxer", +.item_name = av_default_item_name, +.option = ff_img_options, +.version= LIBAVUTIL_VERSION_INT, +}; + +AVInputFormat ff_image_svg_pipe_demuxer = { +.name = "svg_pipe", +.long_name = NULL_IF_CONFIG_SMALL("piped svg sequence"), +.priv_data_size = sizeof(VideoDemuxData), +.read_header= ff_img_read_header, +.read_packet= ff_img_read_packet, +.priv_class = &svg_class, +.mime_type = "image/svg+xml", +.extensions = "svg,svgz", +.flags = AVFMT_GENERIC_INDEX, +.raw_codec_id = AV_CODEC_ID_SVG, +}; + IMAGEAUTO_DEMUXER(bmp, AV_CODEC_ID_BMP) IMAGEAUTO_DEMUXER(dds, AV_CODEC_ID_DDS) IMAGEAUTO_DEMUXER(dpx, AV_CODEC_ID_DPX) -- 2.13.0.rc1.294.g07d810a77f ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/dcaenc: Initial implementation of ADPCM encoding for DCA encoder
On 6 May 2017 at 11:47, Даниил Чередник wrote: > Tiny fix: missed inline attr. > > On Thu, May 4, 2017 at 1:17 AM, Даниил Чередник > wrote: > > > All notices were fixed. Also I found issue with uninitialized subband > > buffer - fixed. New patch attached. > > > > On Wed, May 3, 2017 at 7:49 AM, Rostislav Pehlivanov < > atomnu...@gmail.com> > > wrote: > > > >> On 2 May 2017 at 22:53, Даниил Чередник > wrote: > >> > >> > Hi. > >> > > >> > This patch introduces initial implementation of subband ADPCM encoding > >> for > >> > DCA codec. > >> > > >> > Some results: > >> > > >> > sample: > >> > > >> > https://yadi.sk/d/B_3sVskM3HZiWK - original > >> > > >> > https://yadi.sk/d/7CK47Nt63HZiWf - without adpcm > >> > > >> > https://yadi.sk/d/25q1JDV93HZiWq - with adpcm > >> > > >> > chirp tone: > >> > > >> > https://yadi.sk/i/tZKHoJ1d3HZk4c > >> > > >> > Right now this feature is disabled by default. But it is ready to try > >> > using -dca_adpcm 1 option. > >> > > >> > There are some issues, should be solved before enabling this feature > by > >> > default: > >> > > >> > 1. Speed up: I am trying to find best filter in each subband. But with > >> real > >> > signal, usually only few subbands has significant prediction gain. The > >> idea > >> > is try to analyze FFT spectrum (which is already calculated), to check > >> is > >> > particular subband looks like tonal or noise. If subband is noise like > >> - do > >> > not try to find best LPC predictor. > >> > > >> > 2. Modify psychoacoustic to use prediction gain for bit allocation. > >> Right > >> > now ADPCM encoded block can get some extra bits. > >> > > >> > 3. Tuning the prediction gain threshold. > >> > > >> > > >> > Thank you. > >> > -- > >> > Daniil Cherednik > >> > > >> > ___ > >> > ffmpeg-devel mailing list > >> > ffmpeg-devel@ffmpeg.org > >> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >> > > >> > > >> >+static int64_t calc_corr(const int32_t *x, int len, int j, int k) > >> > >> Add inline attrib? Seems appropriate here. > >> > >> > >> >+for (n = 0; n < len; n++) { > >> >+s += MUL64(x[n-j], x[n-k]); > >> >+} > >> > >> For loops with 1 line we leave the brackets out. > >> > >> > >> >+for (i = 0; i <= DCA_ADPCM_COEFFS; i++) { > >> >+for (j = i; j <= DCA_ADPCM_COEFFS; j++) { > >> >+corr[k++] = calc_corr(in+4, len, i, j); > >> >+} > >> >+} > >> > >> Same > >> > >> > >> >+for (i = 0; i < len + DCA_ADPCM_COEFFS; i++) { > >> >+max |= FFABS(in[i]); > >> >+} > >> > >> Same > >> > >> > >> >for (ch = 0; ch < c->fullband_channels; ch++) { > >> >+for (band = 0; band < 32; band++) { > >> >+if (c->prediction_mode[ch][band] >= 0) { > >> >+quantize_adpcm_subband(c, ch, band); > >> >+} > >> >+} > >> >+} > >> > >> Same > >> > >> > >> >+for (ch = 0; ch < c->fullband_channels; ch++) { > >> >+for (band = 0; band < 32; band++) { > >> >+if (c->prediction_mode[ch][band] == -1) { > >> >+for (sample = 0; sample < SUBBAND_SAMPLES; sample++) { > >> >+c->quantized[ch][band][sample] = > >> quantize_value(c->subband[ch][band][sample], c->quant[ch][band]); > >> >+} > >> >+} > >> >+} > >> >+} > >> > >> Same, 4 whole whitespace lines added here. > >> > >> > >> >+if (c->bitrate_index == 3) { > >> >+step_size = ff_dca_lossless_quant[c->abits[ch][band]]; > >> >+} else { > >> >+step_size = ff_dca_lossy_quant[c->abits[ch][band]]; > >> >+} > >> > >> Same > >> > >> > >> >for (;;) { > >> > >> while (1) { > >> > >> >+if (i++ == last_pos) > >> >+break; > >> > >> Better yet remove the infinite loop and just use a normal for () loop. > >> > >> > >> >+static inline void ff_dca_core_dequantize(int32_t *output, const > int32_t > >> *input, > >> >+ int32_t step_size, int32_t scale, int > >> residual, int len) > >> > >> Fix second line's alignment. > >> > >> > >> >+struct premultiplied_coeffs { > >> >+int32_t aa[10]; > >> >+}; > >> > >> I think it would be simpler to just use int32_t premultiplied_coeffs[10] > >> instead of a struct. > >> > >> > >> Apart from these style issues patch looks fine. I'll be able to test it > in > >> a day. > >> ___ > >> ffmpeg-devel mailing list > >> ffmpeg-devel@ffmpeg.org > >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >> > > > > > > > > -- > > Daniil Cherednik > > > > > > -- > Daniil Cherednik > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > Tested, there's a difference though looking at the spectrum is the only way to see it. The encoder only supports bitrates higher than ~251kbps which isn't enough to really make a big difference. Tried to reduce it but the bit allo
Re: [FFmpeg-devel] [PATCH] avfilter: add arbitrary audio FIR filter
On Mon, May 8, 2017 at 1:22 AM, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > configure| 2 + > doc/filters.texi | 30 +++ > libavfilter/Makefile | 1 + > libavfilter/af_afir.c| 541 > +++ > libavfilter/allfilters.c | 1 + > 5 files changed, 575 insertions(+) > create mode 100644 libavfilter/af_afir.c > > diff --git a/configure b/configure > index b3cb5b0..0d83c6a 100755 > --- a/configure > +++ b/configure > @@ -3078,6 +3078,8 @@ unix_protocol_select="network" > # filters > afftfilt_filter_deps="avcodec" > afftfilt_filter_select="fft" > +afir_filter_deps="avcodec" > +afir_filter_select="fft" > amovie_filter_deps="avcodec avformat" > aresample_filter_deps="swresample" > ass_filter_deps="libass" > diff --git a/doc/filters.texi b/doc/filters.texi > index 119e747..7b6a67b 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -878,6 +878,36 @@ afftfilt="1-clip((b/nb)*b,0,1)" > @end example > @end itemize > > +@section afir > + > +Apply an Arbitary Frequency Impulse Response filter. > + > +This filter uses second stream as FIR coefficients. > +If second stream holds single channel, it will be used > +for all input channels in first stream, otherwise > +number of channels in second stream must be same as > +number of channels in first stream. > + > +It accepts the following parameters: > + > +@table @option > +@item dry > +Set dry gain. This sets input gain. > + > +@item wet > +Set wet gain. This sets final output gain. > + > +@item envelope > +How much to fade out Impulse Response to the end. > + > +@item length > +Set Impulse Response filter length. Default is 1, which means whole IR is > processed. > + > +@item auto > +Enable auto gain calculation of Impulse Response coefficients. > +By default is enabled. > +@end table > + Probably, these options aren't required if algo is correct. > @anchor{aformat} > @section aformat > > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index 66c36e4..c797eb5 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -38,6 +38,7 @@ OBJS-$(CONFIG_AEMPHASIS_FILTER) += > af_aemphasis.o > OBJS-$(CONFIG_AEVAL_FILTER) += aeval.o > OBJS-$(CONFIG_AFADE_FILTER) += af_afade.o > OBJS-$(CONFIG_AFFTFILT_FILTER) += af_afftfilt.o window_func.o > +OBJS-$(CONFIG_AFIR_FILTER) += af_afir.o > OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o > OBJS-$(CONFIG_AGATE_FILTER) += af_agate.o > OBJS-$(CONFIG_AINTERLEAVE_FILTER)+= f_interleave.o > diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c > new file mode 100644 > index 000..7f0afce > --- /dev/null > +++ b/libavfilter/af_afir.c > @@ -0,0 +1,541 @@ > +/* > + * Copyright (c) 2017 Paul B Mahol > + * > + * 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 > + * An arbitrary audio FIR filter > + */ > + > +#include "libavutil/audio_fifo.h" > +#include "libavutil/common.h" > +#include "libavutil/opt.h" > +#include "libavcodec/avfft.h" > + > +#include "audio.h" > +#include "avfilter.h" > +#include "formats.h" > +#include "internal.h" > + > +#define MAX_IR_DURATION 30 > + > +typedef struct AudioFIRContext { > +const AVClass *class; > + > +float wet_gain; > +float dry_gain; > +float envelope; > +float length; > +int auto_gain; > + > +float gain; > + > +int eof_coeffs; > +int have_coeffs; > +int nb_coeffs; > +int nb_taps; > +int part_size; > +int nb_partitions; > +int nb_channels; > +int ir_length; > +int fft_length; > +int nb_coef_channels; > +int one2many; > +int nb_samples; > +int want_skip; > +int need_padding; > + > +RDFTContext **rdft, **irdft; > +float **sum; > +float **block; > +FFTComplex **coeff; > + > +AVAudioFifo *fifo[2]; > +AVFrame *in[2]; > +AVFrame *buffer; > +int64_t pts; > +int index; > +} AudioFIRContext; > + > +static int fir_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) > +{ > +AudioFIRContext *s = ctx->priv; > +const FFTComplex *coeff = s->coeff[ch * !s->