Re: [FFmpeg-devel] [PATCH v3] avformat/hlsenc: deprecate hls_wrap option
2017-02-09 19:10 GMT+08:00 Steven Liu : > When user use the hls_wrap, there have many problem: > 1. some platform refersh the old but usefull segment > 2. CDN(Content Delivery Network) Deliver HLS not friendly > > The hls_wrap is used to wrap segments for use little space, > now user can use hls_list_size and hls_flags delete_segments > instead it. > > Reviewed-by: Michael Niedermayer > Reviewed-by: Carl Eugen Hoyos > Signed-off-by: Steven Liu > --- > doc/muxers.texi | 5 ++--- > libavformat/hlsenc.c | 26 +- > libavformat/version.h | 4 > 3 files changed, 31 insertions(+), 4 deletions(-) > > diff --git a/doc/muxers.texi b/doc/muxers.texi > index cb875a4..c00e296 100644 > --- a/doc/muxers.texi > +++ b/doc/muxers.texi > @@ -441,9 +441,8 @@ parameters. Values containing @code{:} special > characters must be > escaped. > > @item hls_wrap @var{wrap} > -Set the number after which the segment filename number (the number > -specified in each segment file) wraps. If set to 0 the number will be > -never wrapped. Default value is 0. > +This is a deprecated option, you can use @code {hls_list_size} > +and @code{hls_flags delete_segments} instead it > > This option is useful to avoid to fill the disk with many segment > files, and limits the maximum number of segment files written to disk > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c > index 17d4fe4..4076ccd 100644 > --- a/libavformat/hlsenc.c > +++ b/libavformat/hlsenc.c > @@ -101,7 +101,9 @@ typedef struct HLSContext { > float time;// Set by a private option. > float init_time; // Set by a private option. > int max_nb_segments; // Set by a private option. > +#if FF_API_HLS_WRAP > int wrap; // Set by a private option. > +#endif > uint32_t flags;// enum HLSFlags > uint32_t pl_type; // enum PlaylistType > char *segment_filename; > @@ -566,7 +568,11 @@ static int hls_append_segment(struct AVFormatContext > *s, HLSContext *hls, double > hls->initial_prog_date_time += en->duration; > hls->segments = en->next; > if (en && hls->flags & HLS_DELETE_SEGMENTS && > +#if FF_API_HLS_WRAP > !(hls->flags & HLS_SINGLE_FILE || hls->wrap)) { > +#else > +!(hls->flags & HLS_SINGLE_FILE)) { > +#endif > en->next = hls->old_segments; > hls->old_segments = en; > if ((ret = hls_delete_old_segments(hls)) < 0) > @@ -834,7 +840,11 @@ static int hls_start(AVFormatContext *s) >sizeof(vtt_oc->filename)); > } else if (c->max_seg_size > 0) { > if (replace_int_data_in_filename(oc->filename, > sizeof(oc->filename), > +#if FF_API_HLS_WRAP > c->basename, 'd', c->wrap ? c->sequence % c->wrap : > c->sequence) < 1) { > +#else > +c->basename, 'd', c->sequence) < 1) { > +#endif > av_log(oc, AV_LOG_ERROR, "Invalid segment filename > template '%s', you can try to use -use_localtime 1 with it\n", c->basename); > return AVERROR(EINVAL); > } > @@ -853,7 +863,11 @@ static int hls_start(AVFormatContext *s) > if (!filename) > return AVERROR(ENOMEM); > if (replace_int_data_in_filename(oc->filename, > sizeof(oc->filename), > +#if FF_API_HLS_WRAP > filename, 'd', c->wrap ? c->sequence % c->wrap : > c->sequence) < 1) { > +#else > +filename, 'd', c->sequence) < 1) { > +#endif > av_log(c, AV_LOG_ERROR, > "Invalid second level segment filename > template '%s', " > "you can try to remove > second_level_segment_index flag\n", > @@ -910,13 +924,21 @@ static int hls_start(AVFormatContext *s) > av_free(fn_copy); > } > } else if (replace_int_data_in_filename(oc->filename, > sizeof(oc->filename), > +#if FF_API_HLS_WRAP > c->basename, 'd', c->wrap ? c->sequence % c->wrap : > c->sequence) < 1) { > +#else > + c->basename, 'd', c->sequence) < 1) { > +#endif > av_log(oc, AV_LOG_ERROR, "Invalid segment filename template > '%s' you can try to use -use_localtime 1 with it\n", c->basename); > return AVERROR(EINVAL); > } > if( c->vtt_basename) { > if (replace_int_data_in_filename(vtt_oc->filename, > sizeof(vtt_oc->filename), > +#if FF_API_HLS_WRAP > c->vtt_basename, 'd', c->wrap ? c->sequence % c->wrap : > c->sequence) < 1) { > +#else > +c->vtt_basename, 'd', c->sequence) < 1) { > +#endif > av_log(vtt_oc, AV_LOG_ERROR, "Invalid segment filename > template '%s'\n", c->vtt_basename); > return AVERROR(EINVAL); > } > @@ -1421,7 +1443,9 @@ static const AVOption options[] = { > {"hls_list_size", "set maximum number of playlis
Re: [FFmpeg-devel] [RFC] ffmpeg security
2017-02-11 11:14 GMT+08:00 Michael Niedermayer : > On Fri, Feb 10, 2017 at 04:43:17PM -0300, James Almer wrote: > > On 2/10/2017 4:03 PM, Michael Niedermayer wrote: > > > Hi community > > > > > > what do you prefer about the ffmpeg-security alias ? > > > in no particular order > > > > > > Should everyone on the alias be listed in MAINTAINERs under a > > > ffmpeg-security point? > > > > I'd say yes. From a transparency PoV, people should know who will > > get access to such reports. > > > > > > > > Should for everyone who is on the alias a reason be listed in > > > MAINTAINERs why (s)he is on the alias ? > > > > IMO, there's no need for this. Read below. > > > > > > > > > Should everyone on the alias have a reason beyond curiousity to be > > > on the alias? (that is a reason that clearly benefits FFmpeg) > > > > Yes, it should be about intending to fix reports and/or review fixes > > made by others. Curiosity alone is not enough at all. > > ok > > We have 938 open bugs on trac > We have 84 open bugs on trac that contain the keyword "regression" > We have 55 open coverity issues > We have 475 patches on patchwork needing some action, either having > their status updated if its wrong or needing review/apply/reject > > someone wanting to review patches can do that > someone wanting to fix issues can do that > > We have no open security issues on the ffmpeg-security alias, we have > no patches that need a review, in fact i think we have had no patch > there this year yet. (not countig ones referenced from ffmpeg-devel) > > So one wanting to review patches or fix issues shouldnt really have > much desire on ffmpeg-security. > > We can add more people to it, but what does that fix? > Shouldnt we rather try to find someone to fix the regressions on trac > or go over the patches on patchwork ? > I saw "连一汉" sometime report some security issue and fixed by Michael. I think we need a ffmpeg-security to report security issue and review patch in it. And i can join to fix it :) > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > The worst form of inequality is to try to make unequal things equal. > -- Aristotle > > ___ > 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] [RFC] ffmpeg security
On Fri, Feb 10, 2017 at 04:43:17PM -0300, James Almer wrote: > On 2/10/2017 4:03 PM, Michael Niedermayer wrote: > > Hi community > > > > what do you prefer about the ffmpeg-security alias ? > > in no particular order > > > > Should everyone on the alias be listed in MAINTAINERs under a > > ffmpeg-security point? > > I'd say yes. From a transparency PoV, people should know who will > get access to such reports. > > > > > Should for everyone who is on the alias a reason be listed in > > MAINTAINERs why (s)he is on the alias ? > > IMO, there's no need for this. Read below. > > > > > Should everyone on the alias have a reason beyond curiousity to be > > on the alias? (that is a reason that clearly benefits FFmpeg) > > Yes, it should be about intending to fix reports and/or review fixes > made by others. Curiosity alone is not enough at all. ok We have 938 open bugs on trac We have 84 open bugs on trac that contain the keyword "regression" We have 55 open coverity issues We have 475 patches on patchwork needing some action, either having their status updated if its wrong or needing review/apply/reject someone wanting to review patches can do that someone wanting to fix issues can do that We have no open security issues on the ffmpeg-security alias, we have no patches that need a review, in fact i think we have had no patch there this year yet. (not countig ones referenced from ffmpeg-devel) So one wanting to review patches or fix issues shouldnt really have much desire on ffmpeg-security. We can add more people to it, but what does that fix? Shouldnt we rather try to find someone to fix the regressions on trac or go over the patches on patchwork ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The worst form of inequality is to try to make unequal things equal. -- Aristotle signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] fate: add WavPack muxer test
On 2/10/2017 10:18 PM, Michael Niedermayer wrote: > On Fri, Feb 10, 2017 at 07:52:11PM -0300, James Almer wrote: >> Signed-off-by: James Almer >> --- >> tests/fate/avformat.mak | 1 + >> tests/lavf-regression.sh | 4 >> tests/ref/lavf/wv| 3 +++ >> 3 files changed, 8 insertions(+) >> create mode 100644 tests/ref/lavf/wv > > tested on linux32/64/mingw32/64, arm/mips qemu Pushed, thanks. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] h264: Correctly initialize interlaced_frame if tff is set
On Fri, Feb 10, 2017 at 05:21:00PM -0500, Vittorio Giovara wrote: > In particular cases, it is possible to initialize top_field_first > but not interlaced_frame. Make sure to correctly tag a frame > as interlaced when this happens. > > Signed-off-by: Vittorio Giovara > --- > Please CC. > Vittorio > > libavcodec/h264_slice.c | 13 - > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c > index 91a3b25..eeb5202 100644 > --- a/libavcodec/h264_slice.c > +++ b/libavcodec/h264_slice.c > @@ -1174,20 +1174,23 @@ static int h264_export_frame_props(H264Context *h) > > if (cur->field_poc[0] != cur->field_poc[1]) { > /* Derive top_field_first from field pocs. */ > -cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1]; > +cur->f->interlaced_frame = > +cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1]; this looks like it would set interlaced_frame = 0 if cur->field_poc[0] > cur->field_poc[1]; also, do you have a sample that is affected by this ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Breaking DRM is a little like attempting to break through a door even though the window is wide open and the only thing in the house is a bunch of things you dont want and which you would get tomorrow for free anyway signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 2/5] imdct15: rename to mdct15 and add a forward transform
On 11 February 2017 at 01:22, James Almer wrote: > On 2/10/2017 9:25 PM, Rostislav Pehlivanov wrote: > > Handles strides (needed for Opus transients), does pre-reindexing and > folding > > without needing a copy. > > > > Signed-off-by: Rostislav Pehlivanov > > --- > > configure| 6 +- > > libavcodec/Makefile | 2 +- > > libavcodec/aac.h | 4 +- > > libavcodec/aacdec.c | 2 +- > > libavcodec/aacdec_template.c | 4 +- > > libavcodec/mdct15.c | 335 ++ > + > > libavcodec/mdct15.h | 70 + > > libavcodec/opus_celt.c | 10 +- > > 8 files changed, 419 insertions(+), 14 deletions(-) > > create mode 100644 libavcodec/mdct15.c > > create mode 100644 libavcodec/mdct15.h > > Forgot to do "git rm libavcodec/imdct15.*"? > > > diff --git a/libavcodec/mdct15.h b/libavcodec/mdct15.h > > new file mode 100644 > > index 00..2a503e5996 > > --- /dev/null > > +++ b/libavcodec/mdct15.h > > @@ -0,0 +1,70 @@ > > +/* > > + * 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 > > + */ > > + > > +#ifndef AVCODEC_MDCT15_H > > +#define AVCODEC_MDCT15_H > > + > > +#include > > + > > +#include "fft.h" > > + > > +typedef struct MDCT15Context { > > +int fft_n; > > +int len2; > > +int len4; > > +int inverse; > > +int *pfa_prereindex; > > +int *pfa_postreindex; > > + > > +FFTContext ptwo_fft; > > + > > +FFTComplex *tmp; > > + > > +FFTComplex *twiddle_exptab; > > + > > +/* 0 - 18: fft15 twiddles, 19 - 20: fft5 twiddles */ > > +FFTComplex exptab[21]; > > + > > +/** > > + * Calculate a full 2N -> N MDCT > > + */ > > +void (*mdct)(struct MDCT15Context *s, float *dst, const float *src, > ptrdiff_t stride); > > + > > +/** > > + * Calculate the middle half of the iMDCT > > + */ > > +void (*imdct_half)(struct MDCT15Context *s, float *dst, const float > *src, > > + ptrdiff_t src_stride, float scale); > > +} MDCT15Context; > > + > > +/** > > + * Init an (i)MDCT of the length 2 * 15 * (2^N) > > + */ > > +int ff_mdct15_init(MDCT15Context **ps, int inverse, int N, double > scale); > > + > > +/** > > + * Frees a context > > + */ > > +void ff_mdct15_uninit(MDCT15Context **ps); > > + > > + > > +void ff_mdct15_init_aarch64(MDCT15Context *s); > > This seems like a remnant of old code. > > Yep, it is, changed locally to delete ff_mdct15_init_aarch64(). ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 2/5] imdct15: rename to mdct15 and add a forward transform
On 11 February 2017 at 01:26, Rostislav Pehlivanov wrote: > > > On 11 February 2017 at 01:22, James Almer wrote: > >> On 2/10/2017 9:25 PM, Rostislav Pehlivanov wrote: >> > Handles strides (needed for Opus transients), does pre-reindexing and >> folding >> > without needing a copy. >> > >> > Signed-off-by: Rostislav Pehlivanov >> > --- >> > configure| 6 +- >> > libavcodec/Makefile | 2 +- >> > libavcodec/aac.h | 4 +- >> > libavcodec/aacdec.c | 2 +- >> > libavcodec/aacdec_template.c | 4 +- >> > libavcodec/mdct15.c | 335 ++ >> + >> > libavcodec/mdct15.h | 70 + >> > libavcodec/opus_celt.c | 10 +- >> > 8 files changed, 419 insertions(+), 14 deletions(-) >> > create mode 100644 libavcodec/mdct15.c >> > create mode 100644 libavcodec/mdct15.h >> >> Forgot to do "git rm libavcodec/imdct15.*"? >> >> > diff --git a/libavcodec/mdct15.h b/libavcodec/mdct15.h >> > new file mode 100644 >> > index 00..2a503e5996 >> > --- /dev/null >> > +++ b/libavcodec/mdct15.h >> > @@ -0,0 +1,70 @@ >> > +/* >> > + * 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 >> > + */ >> > + >> > +#ifndef AVCODEC_MDCT15_H >> > +#define AVCODEC_MDCT15_H >> > + >> > +#include >> > + >> > +#include "fft.h" >> > + >> > +typedef struct MDCT15Context { >> > +int fft_n; >> > +int len2; >> > +int len4; >> > +int inverse; >> > +int *pfa_prereindex; >> > +int *pfa_postreindex; >> > + >> > +FFTContext ptwo_fft; >> > + >> > +FFTComplex *tmp; >> > + >> > +FFTComplex *twiddle_exptab; >> > + >> > +/* 0 - 18: fft15 twiddles, 19 - 20: fft5 twiddles */ >> > +FFTComplex exptab[21]; >> > + >> > +/** >> > + * Calculate a full 2N -> N MDCT >> > + */ >> > +void (*mdct)(struct MDCT15Context *s, float *dst, const float >> *src, ptrdiff_t stride); >> > + >> > +/** >> > + * Calculate the middle half of the iMDCT >> > + */ >> > +void (*imdct_half)(struct MDCT15Context *s, float *dst, const >> float *src, >> > + ptrdiff_t src_stride, float scale); >> > +} MDCT15Context; >> > + >> > +/** >> > + * Init an (i)MDCT of the length 2 * 15 * (2^N) >> > + */ >> > +int ff_mdct15_init(MDCT15Context **ps, int inverse, int N, double >> scale); >> > + >> > +/** >> > + * Frees a context >> > + */ >> > +void ff_mdct15_uninit(MDCT15Context **ps); >> > + >> > + >> > +void ff_mdct15_init_aarch64(MDCT15Context *s); >> >> This seems like a remnant of old code. >> >> > Yep, it is, changed locally to delete ff_mdct15_init_aarch64(). > Nevermind, I saw what you meant. Added that change and removed the imdct15.c/.h I've attached the new patch. From 42fcb6c47ca2eaf50405a865ee2639fa5ebdc4c9 Mon Sep 17 00:00:00 2001 From: Rostislav Pehlivanov Date: Wed, 1 Feb 2017 03:13:06 + Subject: [PATCH] imdct15: rename to mdct15 and add a forward transform Handles strides (needed for Opus transients), does pre-reindexing and folding without needing a copy. Signed-off-by: Rostislav Pehlivanov --- configure | 6 +-- libavcodec/Makefile| 2 +- libavcodec/aac.h | 4 +- libavcodec/aacdec.c| 2 +- libavcodec/aacdec_template.c | 4 +- libavcodec/{imdct15.c => mdct15.c} | 90 +++--- libavcodec/{imdct15.h => mdct15.h} | 28 +++- libavcodec/opus_celt.c | 10 ++--- 8 files changed, 105 insertions(+), 41 deletions(-) rename libavcodec/{imdct15.c => mdct15.c} (73%) rename libavcodec/{imdct15.h => mdct15.h} (66%) diff --git a/configure b/configure index 72b86bc407..a7cd3a2244 100755 --- a/configure +++ b/configure @@ -2107,7 +2107,7 @@ CONFIG_EXTRA=" huffyuvencdsp idctdsp iirfilter -imdct15 +mdct15 intrax8 iso_media ividsp @@ -2349,7 +2349,7 @@ vc1dsp_select="h264chroma qpeldsp startcode" rdft_select="fft" # decoders / encoders -aac_decoder_select="imdct15 mdct sinewin" +aac_decoder_select="mdct15 mdct sinewin" aac_fixed_decoder_select="mdct sinewin" aa
Re: [FFmpeg-devel] [PATCH] doc: add-muxers-demuxers-list-option
On Fri, Feb 10, 2017 at 05:16:52PM +0530, Mulvya V wrote: > Hi, > > Attached patch will document the options to list demuxers and muxers > > Regards, > Mulvya > demuxers.texi|5 +++-- > ffmpeg.texi |2 +- > fftools-common-opts.texi |6 ++ > muxers.texi |5 +++-- > 4 files changed, 13 insertions(+), 5 deletions(-) > d601322251e5edd096ef8583c91ef265e3857e67 > 0001-Add-muxers-demuxers-list-option.patch > From cace223de644906a19a9931b0678584d4eef5c0a Mon Sep 17 00:00:00 2001 > From: Mulvya > Date: Fri, 10 Feb 2017 17:10:14 +0530 > Subject: [PATCH] Add muxers/demuxers list option applied thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 2/5] imdct15: rename to mdct15 and add a forward transform
On 2/10/2017 9:25 PM, Rostislav Pehlivanov wrote: > Handles strides (needed for Opus transients), does pre-reindexing and folding > without needing a copy. > > Signed-off-by: Rostislav Pehlivanov > --- > configure| 6 +- > libavcodec/Makefile | 2 +- > libavcodec/aac.h | 4 +- > libavcodec/aacdec.c | 2 +- > libavcodec/aacdec_template.c | 4 +- > libavcodec/mdct15.c | 335 > +++ > libavcodec/mdct15.h | 70 + > libavcodec/opus_celt.c | 10 +- > 8 files changed, 419 insertions(+), 14 deletions(-) > create mode 100644 libavcodec/mdct15.c > create mode 100644 libavcodec/mdct15.h Forgot to do "git rm libavcodec/imdct15.*"? > diff --git a/libavcodec/mdct15.h b/libavcodec/mdct15.h > new file mode 100644 > index 00..2a503e5996 > --- /dev/null > +++ b/libavcodec/mdct15.h > @@ -0,0 +1,70 @@ > +/* > + * 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 > + */ > + > +#ifndef AVCODEC_MDCT15_H > +#define AVCODEC_MDCT15_H > + > +#include > + > +#include "fft.h" > + > +typedef struct MDCT15Context { > +int fft_n; > +int len2; > +int len4; > +int inverse; > +int *pfa_prereindex; > +int *pfa_postreindex; > + > +FFTContext ptwo_fft; > + > +FFTComplex *tmp; > + > +FFTComplex *twiddle_exptab; > + > +/* 0 - 18: fft15 twiddles, 19 - 20: fft5 twiddles */ > +FFTComplex exptab[21]; > + > +/** > + * Calculate a full 2N -> N MDCT > + */ > +void (*mdct)(struct MDCT15Context *s, float *dst, const float *src, > ptrdiff_t stride); > + > +/** > + * Calculate the middle half of the iMDCT > + */ > +void (*imdct_half)(struct MDCT15Context *s, float *dst, const float *src, > + ptrdiff_t src_stride, float scale); > +} MDCT15Context; > + > +/** > + * Init an (i)MDCT of the length 2 * 15 * (2^N) > + */ > +int ff_mdct15_init(MDCT15Context **ps, int inverse, int N, double scale); > + > +/** > + * Frees a context > + */ > +void ff_mdct15_uninit(MDCT15Context **ps); > + > + > +void ff_mdct15_init_aarch64(MDCT15Context *s); This seems like a remnant of old code. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] fate: add WavPack muxer test
On Fri, Feb 10, 2017 at 07:52:11PM -0300, James Almer wrote: > Signed-off-by: James Almer > --- > tests/fate/avformat.mak | 1 + > tests/lavf-regression.sh | 4 > tests/ref/lavf/wv| 3 +++ > 3 files changed, 8 insertions(+) > create mode 100644 tests/ref/lavf/wv tested on linux32/64/mingw32/64, arm/mips qemu [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 4/5] opus_celt: rename structures to better names and reorganize them
This is meant to be applied on top of my previous patch which split PVQ into celt_pvq.c and made opus_celt.h Essentially nothing has been changed other than renaming CeltFrame to CeltBlock (CeltFrame had absolutely nothing at all to do with a frame) and CeltContext to CeltFrame. 3 variables have been put in CeltFrame as they make more sense there rather than being passed around as arguments. The coefficients have been moved to the CeltBlock structure (why the hell were they in CeltContext and not in CeltFrame??). Now the encoder would be able to use the exact context the decoder uses (plus a couple of extra fields in there). FATE passes, no slowdowns, etc. Signed-off-by: Rostislav Pehlivanov --- libavcodec/opus.h | 22 +- libavcodec/opus_celt.c | 722 - libavcodec/opus_celt.h | 89 +++--- libavcodec/opus_pvq.c | 50 ++-- libavcodec/opus_pvq.h | 2 +- libavcodec/opusdec.c | 7 +- libavcodec/opustab.c | 4 + libavcodec/opustab.h | 4 + 8 files changed, 458 insertions(+), 442 deletions(-) diff --git a/libavcodec/opus.h b/libavcodec/opus.h index be042497ea..c3cbaec35d 100644 --- a/libavcodec/opus.h +++ b/libavcodec/opus.h @@ -62,7 +62,9 @@ static const uint8_t opus_default_extradata[30] = { enum OpusMode { OPUS_MODE_SILK, OPUS_MODE_HYBRID, -OPUS_MODE_CELT +OPUS_MODE_CELT, + +OPUS_MODE_NB }; enum OpusBandwidth { @@ -70,12 +72,14 @@ enum OpusBandwidth { OPUS_BANDWIDTH_MEDIUMBAND, OPUS_BANDWIDTH_WIDEBAND, OPUS_BANDWIDTH_SUPERWIDEBAND, -OPUS_BANDWIDTH_FULLBAND +OPUS_BANDWIDTH_FULLBAND, + +OPUS_BANDWITH_NB }; typedef struct SilkContext SilkContext; -typedef struct CeltContext CeltContext; +typedef struct CeltFrame CeltFrame; typedef struct OpusPacket { int packet_size;/**< packet size */ @@ -100,7 +104,7 @@ typedef struct OpusStreamContext { OpusRangeCoder rc; OpusRangeCoder redundancy_rc; SilkContext *silk; -CeltContext *celt; +CeltFrame *celt; AVFloatDSPContext *fdsp; float silk_buf[2][960]; @@ -185,14 +189,4 @@ int ff_silk_decode_superframe(SilkContext *s, OpusRangeCoder *rc, enum OpusBandwidth bandwidth, int coded_channels, int duration_ms); -int ff_celt_init(AVCodecContext *avctx, CeltContext **s, int output_channels); - -void ff_celt_free(CeltContext **s); - -void ff_celt_flush(CeltContext *s); - -int ff_celt_decode_frame(CeltContext *s, OpusRangeCoder *rc, - float **output, int coded_channels, int frame_size, - int startband, int endband); - #endif /* AVCODEC_OPUS_H */ diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c index 71ef8965e2..af3c100e6e 100644 --- a/libavcodec/opus_celt.c +++ b/libavcodec/opus_celt.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2012 Andrew D'Addesio * Copyright (c) 2013-2014 Mozilla Corporation + * Copyright (c) 2016 Rostislav Pehlivanov * * This file is part of FFmpeg. * @@ -28,7 +29,7 @@ #include "opustab.h" #include "opus_pvq.h" -static void celt_decode_coarse_energy(CeltContext *s, OpusRangeCoder *rc) +static void celt_decode_coarse_energy(CeltFrame *f, OpusRangeCoder *rc) { int i, j; float prev[2] = {0}; @@ -38,29 +39,29 @@ static void celt_decode_coarse_energy(CeltContext *s, OpusRangeCoder *rc) /* use the 2D z-transform to apply prediction in both */ /* the time domain (alpha) and the frequency domain (beta) */ -if (opus_rc_tell(rc)+3 <= s->framebits && ff_opus_rc_dec_log(rc, 3)) { +if (opus_rc_tell(rc)+3 <= f->framebits && ff_opus_rc_dec_log(rc, 3)) { /* intra frame */ alpha = 0; beta = 1.0f - 4915.0f/32768.0f; -model = ff_celt_coarse_energy_dist[s->duration][1]; +model = ff_celt_coarse_energy_dist[f->size][1]; } else { -alpha = ff_celt_alpha_coef[s->duration]; -beta = 1.0f - ff_celt_beta_coef[s->duration]; -model = ff_celt_coarse_energy_dist[s->duration][0]; +alpha = ff_celt_alpha_coef[f->size]; +beta = 1.0f - ff_celt_beta_coef[f->size]; +model = ff_celt_coarse_energy_dist[f->size][0]; } for (i = 0; i < CELT_MAX_BANDS; i++) { -for (j = 0; j < s->coded_channels; j++) { -CeltFrame *frame = &s->frame[j]; +for (j = 0; j < f->channels; j++) { +CeltBlock *block = &f->block[j]; float value; int available; -if (i < s->startband || i >= s->endband) { -frame->energy[i] = 0.0; +if (i < f->start_band || i >= f->end_band) { +block->energy[i] = 0.0; continue; } -available = s->framebits - opus_rc_tell(rc); +available = f->framebits - opus_rc_tell(rc); if (available >= 15) { /* decode using a Laplace distribution */
[FFmpeg-devel] [PATCH v2 3/5] opus_celt: move quantization and band decoding to opus_pvq.c
A huge amount can be reused by the encoder, as the only thing which needs to be done would be to add a 10 line celt_icwrsi, a wrapper around it (celt_alg_quant) and templating the ff_celt_decode_band to replace entropy decoding functions with entropy encoding. There is no performance loss but in fact a performance gain of around 6% which is caused by the compiler being able to optimize the decoding more efficiently. Signed-off-by: Rostislav Pehlivanov --- libavcodec/Makefile| 2 +- libavcodec/opus.h | 10 - libavcodec/opus_celt.c | 828 + libavcodec/opus_celt.h | 133 libavcodec/opus_pvq.c | 729 +++ libavcodec/opus_pvq.h | 35 +++ 6 files changed, 909 insertions(+), 828 deletions(-) create mode 100644 libavcodec/opus_celt.h create mode 100644 libavcodec/opus_pvq.c create mode 100644 libavcodec/opus_pvq.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 89a27a000e..c61fd7e259 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -439,7 +439,7 @@ OBJS-$(CONFIG_NELLYMOSER_ENCODER) += nellymoserenc.o nellymoser.o OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o OBJS-$(CONFIG_ON2AVC_DECODER) += on2avc.o on2avcdata.o OBJS-$(CONFIG_OPUS_DECODER)+= opusdec.o opus.o opus_celt.o opus_rc.o \ - opus_silk.o opustab.o vorbis_data.o + opus_pvq.o opus_silk.o opustab.o vorbis_data.o OBJS-$(CONFIG_PAF_AUDIO_DECODER) += pafaudio.o OBJS-$(CONFIG_PAF_VIDEO_DECODER) += pafvideo.o OBJS-$(CONFIG_PAM_DECODER) += pnmdec.o pnm.o diff --git a/libavcodec/opus.h b/libavcodec/opus.h index 2c3d63a7a2..be042497ea 100644 --- a/libavcodec/opus.h +++ b/libavcodec/opus.h @@ -43,16 +43,6 @@ #define CELT_MAX_LOG_BLOCKS 3 #define CELT_MAX_FRAME_SIZE (CELT_SHORT_BLOCKSIZE * (1 << CELT_MAX_LOG_BLOCKS)) #define CELT_MAX_BANDS 21 -#define CELT_VECTORS 11 -#define CELT_ALLOC_STEPS 6 -#define CELT_FINE_OFFSET 21 -#define CELT_MAX_FINE_BITS 8 -#define CELT_NORM_SCALE 16384 -#define CELT_QTHETA_OFFSET 4 -#define CELT_QTHETA_OFFSET_TWOPHASE 16 -#define CELT_DEEMPH_COEFF0.85000610f -#define CELT_POSTFILTER_MINPERIOD15 -#define CELT_ENERGY_SILENCE (-28.0f) #define SILK_HISTORY 322 #define SILK_MAX_LPC 16 diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c index a0f018e664..71ef8965e2 100644 --- a/libavcodec/opus_celt.c +++ b/libavcodec/opus_celt.c @@ -24,109 +24,9 @@ * Opus CELT decoder */ -#include - -#include "libavutil/float_dsp.h" -#include "libavutil/libm.h" - -#include "mdct15.h" -#include "opus.h" +#include "opus_celt.h" #include "opustab.h" - -enum CeltSpread { -CELT_SPREAD_NONE, -CELT_SPREAD_LIGHT, -CELT_SPREAD_NORMAL, -CELT_SPREAD_AGGRESSIVE -}; - -typedef struct CeltFrame { -float energy[CELT_MAX_BANDS]; -float prev_energy[2][CELT_MAX_BANDS]; - -uint8_t collapse_masks[CELT_MAX_BANDS]; - -/* buffer for mdct output + postfilter */ -DECLARE_ALIGNED(32, float, buf)[2048]; - -/* postfilter parameters */ -int pf_period_new; -float pf_gains_new[3]; -int pf_period; -float pf_gains[3]; -int pf_period_old; -float pf_gains_old[3]; - -float deemph_coeff; -} CeltFrame; - -struct CeltContext { -// constant values that do not change during context lifetime -AVCodecContext*avctx; -MDCT15Context *imdct[4]; -AVFloatDSPContext *dsp; -int output_channels; - -// values that have inter-frame effect and must be reset on flush -CeltFrame frame[2]; -uint32_t seed; -int flushed; - -// values that only affect a single frame -int coded_channels; -int framebits; -int duration; - -/* number of iMDCT blocks in the frame */ -int blocks; -/* size of each block */ -int blocksize; - -int startband; -int endband; -int codedbands; - -int anticollapse_bit; - -int intensitystereo; -int dualstereo; -enum CeltSpread spread; - -int remaining; -int remaining2; -int fine_bits[CELT_MAX_BANDS]; -int fine_priority[CELT_MAX_BANDS]; -int pulses [CELT_MAX_BANDS]; -int tf_change[CELT_MAX_BANDS]; - -DECLARE_ALIGNED(32, float, coeffs)[2][CELT_MAX_FRAME_SIZE]; -DECLARE_ALIGNED(32, float, scratch)[22 * 8]; // MAX(ff_celt_freq_range) * 1<> 13; -x = (32767-x) + ROUND_MUL16(x, (-7651 + ROUND_MUL16(x, (8277 + ROUND_MUL16(-626, x); -return 1+x; -} - -static inline int celt_log2tan(int isin, int icos) -{ -int lc, ls; -lc = opus_ilog(icos); -ls = opus_ilog(isin); -icos <<= 15 - lc; -isin <<= 15 - ls; -return (ls << 11) - (lc << 11) + - ROUND_MUL16(isin, ROUND_MUL16(isin, -259
[FFmpeg-devel] [PATCH v2 2/5] imdct15: rename to mdct15 and add a forward transform
Handles strides (needed for Opus transients), does pre-reindexing and folding without needing a copy. Signed-off-by: Rostislav Pehlivanov --- configure| 6 +- libavcodec/Makefile | 2 +- libavcodec/aac.h | 4 +- libavcodec/aacdec.c | 2 +- libavcodec/aacdec_template.c | 4 +- libavcodec/mdct15.c | 335 +++ libavcodec/mdct15.h | 70 + libavcodec/opus_celt.c | 10 +- 8 files changed, 419 insertions(+), 14 deletions(-) create mode 100644 libavcodec/mdct15.c create mode 100644 libavcodec/mdct15.h diff --git a/configure b/configure index 72b86bc407..a7cd3a2244 100755 --- a/configure +++ b/configure @@ -2107,7 +2107,7 @@ CONFIG_EXTRA=" huffyuvencdsp idctdsp iirfilter -imdct15 +mdct15 intrax8 iso_media ividsp @@ -2349,7 +2349,7 @@ vc1dsp_select="h264chroma qpeldsp startcode" rdft_select="fft" # decoders / encoders -aac_decoder_select="imdct15 mdct sinewin" +aac_decoder_select="mdct15 mdct sinewin" aac_fixed_decoder_select="mdct sinewin" aac_encoder_select="audio_frame_queue iirfilter lpc mdct sinewin" aac_latm_decoder_select="aac_decoder aac_latm_parser" @@ -2491,7 +2491,7 @@ nellymoser_encoder_select="audio_frame_queue mdct sinewin" nuv_decoder_select="idctdsp lzo" on2avc_decoder_select="mdct" opus_decoder_deps="swresample" -opus_decoder_select="imdct15" +opus_decoder_select="mdct15" png_decoder_select="zlib" png_encoder_select="llvidencdsp zlib" prores_decoder_select="blockdsp idctdsp" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index c4e108665d..89a27a000e 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -84,7 +84,7 @@ OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o OBJS-$(CONFIG_HUFFYUVENCDSP) += huffyuvencdsp.o OBJS-$(CONFIG_IDCTDSP) += idctdsp.o simple_idct.o jrevdct.o OBJS-$(CONFIG_IIRFILTER) += iirfilter.o -OBJS-$(CONFIG_IMDCT15) += imdct15.o +OBJS-$(CONFIG_MDCT15) += mdct15.o OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o OBJS-$(CONFIG_IVIDSP) += ivi_dsp.o OBJS-$(CONFIG_JNI) += ffjni.o jni.o diff --git a/libavcodec/aac.h b/libavcodec/aac.h index b1f4aa74f0..97a2df6b86 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -36,7 +36,7 @@ #include "libavutil/fixed_dsp.h" #include "avcodec.h" #if !USE_FIXED -#include "imdct15.h" +#include "mdct15.h" #endif #include "fft.h" #include "mpeg4audio.h" @@ -327,7 +327,7 @@ struct AACContext { #if USE_FIXED AVFixedDSPContext *fdsp; #else -IMDCT15Context *mdct480; +MDCT15Context *mdct480; AVFloatDSPContext *fdsp; #endif /* USE_FIXED */ int random_state; diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index ee9b4eb45f..1a10c121b9 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -42,7 +42,7 @@ #include "internal.h" #include "get_bits.h" #include "fft.h" -#include "imdct15.h" +#include "mdct15.h" #include "lpc.h" #include "kbdwin.h" #include "sinewin.h" diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 83e9fb55ba..0bfd66 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -1185,7 +1185,7 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) AAC_RENAME_32(ff_mdct_init)(&ac->mdct_small, 8, 1, 1.0 / RANGE15(128.0)); AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ltp, 11, 0, RANGE15(-2.0)); #if !USE_FIXED -ret = ff_imdct15_init(&ac->mdct480, 5); +ret = ff_mdct15_init(&ac->mdct480, 1, 5, -1.0f); if (ret < 0) return ret; #endif @@ -3192,7 +3192,7 @@ static av_cold int aac_decode_close(AVCodecContext *avctx) ff_mdct_end(&ac->mdct_ld); ff_mdct_end(&ac->mdct_ltp); #if !USE_FIXED -ff_imdct15_uninit(&ac->mdct480); +ff_mdct15_uninit(&ac->mdct480); #endif av_freep(&ac->fdsp); return 0; diff --git a/libavcodec/mdct15.c b/libavcodec/mdct15.c new file mode 100644 index 00..a6bea2d469 --- /dev/null +++ b/libavcodec/mdct15.c @@ -0,0 +1,335 @@ +/* + * Copyright (c) 2013-2014 Mozilla Corporation + * 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 Frank
[FFmpeg-devel] [PATCH v2 1/5] opus_rc: add entropy encoding functions
Mostly used the RFC document, the decoding functions and the reference encoder's implmenentation as a reference. Signed-off-by: Rostislav Pehlivanov --- libavcodec/opus_rc.c | 182 ++- libavcodec/opus_rc.h | 35 -- 2 files changed, 212 insertions(+), 5 deletions(-) diff --git a/libavcodec/opus_rc.c b/libavcodec/opus_rc.c index b0e72f6ffe..85268bd284 100644 --- a/libavcodec/opus_rc.c +++ b/libavcodec/opus_rc.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2012 Andrew D'Addesio * Copyright (c) 2013-2014 Mozilla Corporation - * Copyright (c) 2016 Rostislav Pehlivanov + * Copyright (c) 2017 Rostislav Pehlivanov * * This file is part of FFmpeg. * @@ -29,6 +29,21 @@ #define OPUS_RC_BOT (OPUS_RC_TOP >> OPUS_RC_SYM) #define OPUS_RC_SHIFT (OPUS_RC_BITS - OPUS_RC_SYM - 1) +static av_always_inline void opus_rc_enc_carryout(OpusRangeCoder *rc, int cbuf) +{ +const int cb = cbuf >> OPUS_RC_SYM, mb = (OPUS_RC_CEIL + cb) & OPUS_RC_CEIL; +if (cbuf == OPUS_RC_CEIL) { +rc->ext++; +return; +} +rc->rng_cur[0] = rc->rem + cb; +rc->rng_cur += (rc->rem >= 0); +for (; rc->ext > 0; rc->ext--) +*rc->rng_cur++ = mb; +av_assert0(rc->rng_cur < rc->rb.position); +rc->rem = cbuf & OPUS_RC_CEIL; /* Propagate */ +} + static av_always_inline void opus_rc_dec_normalize(OpusRangeCoder *rc) { while (rc->range <= OPUS_RC_BOT) { @@ -38,6 +53,16 @@ static av_always_inline void opus_rc_dec_normalize(OpusRangeCoder *rc) } } +static av_always_inline void opus_rc_enc_normalize(OpusRangeCoder *rc) +{ +while (rc->range <= OPUS_RC_BOT) { +opus_rc_enc_carryout(rc, rc->value >> OPUS_RC_SHIFT); +rc->value = (rc->value << OPUS_RC_SYM) & (OPUS_RC_TOP - 1); +rc->range <<= OPUS_RC_SYM; +rc->total_bits += OPUS_RC_SYM; +} +} + static av_always_inline void opus_rc_dec_update(OpusRangeCoder *rc, uint32_t scale, uint32_t low, uint32_t high, uint32_t total) @@ -48,6 +73,20 @@ static av_always_inline void opus_rc_dec_update(OpusRangeCoder *rc, uint32_t sca opus_rc_dec_normalize(rc); } +/* Main encoding function, this needs to go fast */ +static av_always_inline void opus_rc_enc_update(OpusRangeCoder *rc, uint32_t b, uint32_t p, +uint32_t p_tot, const int ptwo) +{ +uint32_t rscaled, cnd = !!b; +if (ptwo) /* Whole function is inlined so hopefully branch is optimized out */ +rscaled = rc->range >> ff_log2(p_tot); +else +rscaled = rc->range/p_tot; +rc->value +=cnd*(rc->range - rscaled*(p_tot - b)); +rc->range = (!cnd)*(rc->range - rscaled*(p_tot - p)) + cnd*rscaled*(p - b); +opus_rc_enc_normalize(rc); +} + uint32_t ff_opus_rc_dec_cdf(OpusRangeCoder *rc, const uint16_t *cdf) { unsigned int k, scale, total, symbol, low, high; @@ -67,6 +106,11 @@ uint32_t ff_opus_rc_dec_cdf(OpusRangeCoder *rc, const uint16_t *cdf) return k; } +void ff_opus_rc_enc_cdf(OpusRangeCoder *rc, int val, const uint16_t *cdf) +{ +opus_rc_enc_update(rc, cdf[val], cdf[val + 1], cdf[0], 1); +} + uint32_t ff_opus_rc_dec_log(OpusRangeCoder *rc, uint32_t bits) { uint32_t k, scale; @@ -84,6 +128,12 @@ uint32_t ff_opus_rc_dec_log(OpusRangeCoder *rc, uint32_t bits) return k; } +void ff_opus_rc_enc_log(OpusRangeCoder *rc, int val, uint32_t bits) +{ +bits = (1 << bits) - 1; +opus_rc_enc_update(rc, (!!val)*bits, bits + !!val, bits + 1, 1); +} + /** * CELT: read 1-25 raw bits at the end of the frame, backwards byte-wise */ @@ -106,6 +156,27 @@ uint32_t ff_opus_rc_get_raw(OpusRangeCoder *rc, uint32_t count) } /** + * CELT: write 0 - 31 bits to the rawbits buffer + */ +void ff_opus_rc_put_raw(OpusRangeCoder *rc, uint32_t val, uint32_t count) +{ +const int to_write = FFMIN(32 - rc->rb.cachelen, count); + +rc->total_bits += count; +rc->rb.cacheval |= av_mod_uintp2(val, to_write) << rc->rb.cachelen; +rc->rb.cachelen = (rc->rb.cachelen + to_write) % 32; + +if (!rc->rb.cachelen && count) { +AV_WB32(rc->rb.position, rc->rb.cacheval); +rc->rb.bytes+= 4; +rc->rb.position -= 4; +rc->rb.cachelen = count - to_write; +rc->rb.cacheval = av_mod_uintp2(val >> to_write, rc->rb.cachelen); +av_assert0(rc->rng_cur < rc->rb.position); +} +} + +/** * CELT: read a uniform distribution */ uint32_t ff_opus_rc_dec_uint(OpusRangeCoder *rc, uint32_t size) @@ -127,6 +198,16 @@ uint32_t ff_opus_rc_dec_uint(OpusRangeCoder *rc, uint32_t size) return k; } +/** + * CELT: write a uniformly distributed integer + */ +void ff_opus_rc_enc_uint(OpusRangeCoder *rc, uint32_t val, uint32_t size) +{ +const int ps = FFMAX(opus_ilog(size - 1) - 8, 0); +opus_rc_enc_update(rc, val >> ps, (val >> ps) + 1, ((size - 1) >> ps) + 1
[FFmpeg-devel] [PATCH v2 0/5] A native Opus encoder
This series of commits implements a native Opus encoder. This is v2 of the patchset, the changes are: - The forward MDCT doesn't need a third buffer and can handle the full set of sizes the init function allows - The encoder has a new faster than libopus and more accurate PVQ search algorithm and can now handle transients properly. Rostislav Pehlivanov (5): opus_rc: add entropy encoding functions imdct15: rename to mdct15 and add a forward transform opus_celt: move quantization and band decoding to opus_pvq.c opus_celt: rename structures to better names and reorganize them opus: add a native Opus encoder configure|7 +- libavcodec/Makefile |5 +- libavcodec/aac.h |4 +- libavcodec/aacdec.c |2 +- libavcodec/aacdec_template.c |4 +- libavcodec/allcodecs.c |2 +- libavcodec/mdct15.c | 335 + libavcodec/mdct15.h | 70 ++ libavcodec/opus.h| 32 +- libavcodec/opus_celt.c | 1540 ++ libavcodec/opus_celt.h | 164 + libavcodec/opus_pvq.c| 1157 +++ libavcodec/opus_pvq.h| 41 ++ libavcodec/opus_rc.c | 182 - libavcodec/opus_rc.h | 35 +- libavcodec/opusdec.c |7 +- libavcodec/opusenc.c | 1128 +++ libavcodec/opustab.c |4 + libavcodec/opustab.h |4 + 19 files changed, 3506 insertions(+), 1217 deletions(-) create mode 100644 libavcodec/mdct15.c create mode 100644 libavcodec/mdct15.h create mode 100644 libavcodec/opus_celt.h create mode 100644 libavcodec/opus_pvq.c create mode 100644 libavcodec/opus_pvq.h create mode 100644 libavcodec/opusenc.c -- 2.11.0.483.g087da7b7c ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 5/5] opus: add a native Opus encoder
This marks the first time anyone has written an Opus encoder without using any libopus code. The aim of the encoder is to prove how far the format can go by writing the craziest encoder for it. Right now the encoder's basic, it only supports CBR encoding, however internally every single feature the CELT layer has is implemented (except the pitch pre-filter which needs to work well with the rest of whatever gets implemented). Psychoacoustic and rate control systems are under development. The encoder takes in frames of 120 samples and depending on the value of opus_delay the plan is to use the extra buffered frames as lookahead. Right now the encoder will pick the nearest largest legal frame size and won't use the lookahead, but that'll change once there's a psychoacoustic system. Even though its a pretty basic encoder its already outperforming any other native encoder FFmpeg has by a huge amount. The PVQ search algorithm is faster and more accurate than libopus's algorithm so the encoder's performance is close to that of libopus at zero complexity (libopus has more SIMD). The algorithm might be ported to libopus or other codecs using PVQ in the future. The encoder still has a few minor bugs, like desyncs at ultra low bitrates (below 9kbps with 20ms frames). Signed-off-by: Rostislav Pehlivanov --- configure |1 + libavcodec/Makefile|1 + libavcodec/allcodecs.c |2 +- libavcodec/opus_celt.h | 16 + libavcodec/opus_pvq.c | 444 ++- libavcodec/opus_pvq.h |6 + libavcodec/opusenc.c | 1128 7 files changed, 1589 insertions(+), 9 deletions(-) create mode 100644 libavcodec/opusenc.c diff --git a/configure b/configure index a7cd3a2244..2f761c39c2 100755 --- a/configure +++ b/configure @@ -2492,6 +2492,7 @@ nuv_decoder_select="idctdsp lzo" on2avc_decoder_select="mdct" opus_decoder_deps="swresample" opus_decoder_select="mdct15" +opus_encoder_select="audio_frame_queue audiodsp mdct15" png_decoder_select="zlib" png_encoder_select="llvidencdsp zlib" prores_decoder_select="blockdsp idctdsp" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index c61fd7e259..0af1d52b4f 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -440,6 +440,7 @@ OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o OBJS-$(CONFIG_ON2AVC_DECODER) += on2avc.o on2avcdata.o OBJS-$(CONFIG_OPUS_DECODER)+= opusdec.o opus.o opus_celt.o opus_rc.o \ opus_pvq.o opus_silk.o opustab.o vorbis_data.o +OBJS-$(CONFIG_OPUS_ENCODER)+= opusenc.o opus_rc.o opustab.o opus_pvq.o OBJS-$(CONFIG_PAF_AUDIO_DECODER) += pafaudio.o OBJS-$(CONFIG_PAF_VIDEO_DECODER) += pafvideo.o OBJS-$(CONFIG_PAM_DECODER) += pnmdec.o pnm.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 4d9a98374b..6e48e02b4f 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -446,7 +446,7 @@ void avcodec_register_all(void) REGISTER_DECODER(MPC8, mpc8); REGISTER_ENCDEC (NELLYMOSER,nellymoser); REGISTER_DECODER(ON2AVC,on2avc); -REGISTER_DECODER(OPUS, opus); +REGISTER_ENCDEC (OPUS, opus); REGISTER_DECODER(PAF_AUDIO, paf_audio); REGISTER_DECODER(QCELP, qcelp); REGISTER_DECODER(QDM2, qdm2); diff --git a/libavcodec/opus_celt.h b/libavcodec/opus_celt.h index 7b46a5116b..23c20891cd 100644 --- a/libavcodec/opus_celt.h +++ b/libavcodec/opus_celt.h @@ -61,14 +61,23 @@ enum CeltBlockSize { typedef struct CeltBlock { float energy[CELT_MAX_BANDS]; +float lin_energy[CELT_MAX_BANDS]; +float error_energy[CELT_MAX_BANDS]; float prev_energy[2][CELT_MAX_BANDS]; uint8_t collapse_masks[CELT_MAX_BANDS]; +int band_bins[CELT_MAX_BANDS]; /* MDCT bins per band */ +float *band_coeffs[CELT_MAX_BANDS]; + /* buffer for mdct output + postfilter */ DECLARE_ALIGNED(32, float, buf)[2048]; DECLARE_ALIGNED(32, float, coeffs)[CELT_MAX_FRAME_SIZE]; +/* Used by the encoder */ +DECLARE_ALIGNED(32, float, overlap)[120]; +DECLARE_ALIGNED(32, float, samples)[CELT_MAX_FRAME_SIZE]; + /* postfilter parameters */ int pf_period_new; float pf_gains_new[3]; @@ -94,6 +103,12 @@ struct CeltFrame { int end_band; int coded_bands; int transient; +int intra; +int pfilter; +int skip_band_floor; +int tf_select; +int alloc_trim; +int alloc_boost[CELT_MAX_BANDS]; int blocks;/* number of iMDCT blocks in the frame, depends on transient */ int blocksize; /* size of each block */ int silence; /* Frame is filled with silence */ @@ -109,6 +124,7 @@ struct CeltFrame { int framebits; int remaining; int remaining2; +int caps [CELT_MAX_BANDS]; int fine_bits[CELT_MAX_BANDS]; int fine
Re: [FFmpeg-devel] [PATCH 1/3] spherical: Add tiled equirectangular type and projection-specific properties
On Fri, Feb 10, 2017 at 04:11:43PM -0500, Vittorio Giovara wrote: > Signed-off-by: Vittorio Giovara > --- > This should help not losing details over muxing and allows > callers to get additional information in a clean manner. > > Please keep me in CC. > Vittorio > > doc/APIchanges| 5 + > ffprobe.c | 11 -- > libavformat/dump.c| 10 + > libavutil/spherical.h | 56 > +++ > libavutil/version.h | 2 +- > 5 files changed, 81 insertions(+), 3 deletions(-) breaks fate --- ./tests/ref/fate/matroska-spherical-mono2017-02-10 23:43:51.993432371 +0100 +++ tests/data/fate/matroska-spherical-mono 2017-02-11 00:24:10.297483318 +0100 @@ -7,7 +7,7 @@ [/SIDE_DATA] [SIDE_DATA] side_data_type=Spherical Mapping -side_data_size=16 +side_data_size=56 projection=equirectangular yaw=45 pitch=30 Test matroska-spherical-mono failed. Look at tests/data/fate/matroska-spherical-mono.err for details. make: *** [fate-matroska-spherical-mono] Error 1 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] movenc: add support for track names in ISML manifests
This enables having multiple tracks of the same type which would be treated as different things by the media server (as opposed to different bit rate versions of the same track). According to the smooth streaming specification, just setting the systemLanguage tag is not enough to note that a track with the same attributes differs from another one. --- libavformat/movenc.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index a58b6a4..a286210 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -3645,6 +3645,7 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat MOVTrack *track = &mov->tracks[i]; const char *type; int track_id = track->track_id; +char track_name_buf[32] = { 0 }; AVStream *st = track->st; AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0); @@ -3670,6 +3671,23 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat param_write_int(pb, "systemBitrate", manifest_bit_rate); param_write_int(pb, "trackID", track_id); param_write_string(pb, "systemLanguage", lang ? lang->value : "und"); + +/* Build track name piece by piece: */ +/* 1. track type */ +av_strlcat(track_name_buf, type, sizeof(track_name_buf)); +/* 2. track language, if available */ +if (lang) +av_strlcatf(track_name_buf, sizeof(track_name_buf), +"_%s", lang->value); +/* 3. special type suffix */ +/* "_cc" = closed captions, "_ad" = audio_description */ +if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED) +av_strlcat(track_name_buf, "_cc", sizeof(track_name_buf)); +else if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED) +av_strlcat(track_name_buf, "_ad", sizeof(track_name_buf)); + +param_write_string(pb, "trackName", track_name_buf); + if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) { if (track->par->codec_id == AV_CODEC_ID_H264) { uint8_t *ptr; -- 2.9.3 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] fate: add WavPack muxer test
Signed-off-by: James Almer --- tests/fate/avformat.mak | 1 + tests/lavf-regression.sh | 4 tests/ref/lavf/wv| 3 +++ 3 files changed, 8 insertions(+) create mode 100644 tests/ref/lavf/wv diff --git a/tests/fate/avformat.mak b/tests/fate/avformat.mak index 0a3800b0ea..10702ec8e2 100644 --- a/tests/fate/avformat.mak +++ b/tests/fate/avformat.mak @@ -54,6 +54,7 @@ FATE_LAVF-$(call ENCDEC, PCM_S16LE, WAV) += wav_peak FATE_LAVF-$(call ENCDEC, PCM_S16LE, WAV)+= wav_peak_only FATE_LAVF-$(call ENCMUX, PCM_S16LE, W64)+= w64 FATE_LAVF-$(call ENCDEC, MP2, WTV)+= wtv +FATE_LAVF-$(call ENCDEC, WAVPACK, WV) += wv FATE_LAVF-$(call ENCDEC, XBM, IMAGE2) += xbm FATE_LAVF-$(call ENCDEC, XWD, IMAGE2) += xwd FATE_LAVF-$(CONFIG_YUV4MPEGPIPE_MUXER) += yuv4mpeg diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh index 12954d5044..eda40f25db 100755 --- a/tests/lavf-regression.sh +++ b/tests/lavf-regression.sh @@ -386,6 +386,10 @@ if [ -n "$do_w64" ] ; then do_audio_only w64 fi +if [ -n "$do_wv" ] ; then +do_audio_only wv +fi + # pix_fmt conversions if [ -n "$do_pixfmt" ] ; then diff --git a/tests/ref/lavf/wv b/tests/ref/lavf/wv new file mode 100644 index 00..323c5df6d5 --- /dev/null +++ b/tests/ref/lavf/wv @@ -0,0 +1,3 @@ +47d9a381d9c3f99b8b059f3b17f1dc11 *./tests/data/lavf/lavf.wv +59560 ./tests/data/lavf/lavf.wv +./tests/data/lavf/lavf.wv CRC=0x3a1da17e -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] h264: Correctly initialize interlaced_frame if tff is set
In particular cases, it is possible to initialize top_field_first but not interlaced_frame. Make sure to correctly tag a frame as interlaced when this happens. Signed-off-by: Vittorio Giovara --- Please CC. Vittorio libavcodec/h264_slice.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 91a3b25..eeb5202 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1174,20 +1174,23 @@ static int h264_export_frame_props(H264Context *h) if (cur->field_poc[0] != cur->field_poc[1]) { /* Derive top_field_first from field pocs. */ -cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1]; +cur->f->interlaced_frame = +cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1]; } else { if (sps->pic_struct_present_flag) { /* Use picture timing SEI information. Even if it is a * information of a past frame, better than nothing. */ if (h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM || -h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP) -cur->f->top_field_first = 1; -else +h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP) { +cur->f->interlaced_frame = +cur->f->top_field_first = 1; +} else cur->f->top_field_first = 0; } else if (cur->f->interlaced_frame) { /* Default to top field first when pic_struct_present_flag * is not set but interlaced frame detected */ -cur->f->top_field_first = 1; +cur->f->interlaced_frame = +cur->f->top_field_first = 1; } else { /* Most likely progressive */ cur->f->top_field_first = 0; -- 2.10.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/9] ffmpeg: do packet ts rescaling in write_packet()
On Fri, Feb 10, 2017 at 01:35:34PM +0100, wm4 wrote: > From: Anton Khirnov > > This will be useful in the following commit, after which the muxer > timebase is not always available when encoding. > > This merges Libav commit 3e265ca. It was previously skipped. > > There is a minor change with setting the mux_timebase field only after > the muxer's write_header function has been called, because it can > readjust the timebase. > > Includes a minor merge fix by Mark Thompson. > > Signed-off-by: wm4 > --- > ffmpeg.c | 39 ++- > ffmpeg.h | 2 ++ > 2 files changed, 24 insertions(+), 17 deletions(-) Is this intended to result in no changes ? ./ffmpeg -ss 15 -i ~/tickets/1332/Starship_Troopers.vob -scodec dvbsub -vcodec copy -t 4 -r 24000/1001 -an aaa.ts differs from before and after this patch [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam" signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 3/3] mkv: Export bounds and padding from spherical metadata
--- Although quite math-heavy, I saw little value in having a single parsing function, and since it requires stream or demuxer specific information I preferred to keep the two separate. Please keep me in CC. Vittorio libavformat/matroskadec.c | 34 +- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 7223e94..dc1cd62 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1913,15 +1913,32 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track) AVSphericalMapping *spherical; enum AVSphericalProjection projection; size_t spherical_size; +size_t l, t, r, b; +size_t padding = 0; int ret; +GetByteContext gb; + +bytestream2_init(&gb, track->video.projection.private.data, + track->video.projection.private.size); switch (track->video.projection.type) { case MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR: -projection = AV_SPHERICAL_EQUIRECTANGULAR; +if (track->video.projection.private.size == 0) +projection = AV_SPHERICAL_EQUIRECTANGULAR; +else { +projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE; +bytestream2_skip(&gb, 4); // version + flags +t = bytestream2_get_be32(&gb); +b = bytestream2_get_be32(&gb); +l = bytestream2_get_be32(&gb); +r = bytestream2_get_be32(&gb); +} break; case MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP: if (track->video.projection.private.size < 4) return AVERROR_INVALIDDATA; +bytestream2_skip(&gb, 4); // layout +padding = bytestream2_get_be32(&gb); projection = AV_SPHERICAL_CUBEMAP; break; default: @@ -1937,6 +1954,21 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track) spherical->pitch = (int32_t)(track->video.projection.pitch * (1 << 16)); spherical->roll = (int32_t)(track->video.projection.roll * (1 << 16)); +spherical->padding = padding; + +if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) { +/* conversion from 0.32 coordinates to pixels */ +uint32_t max_coord = (uint32_t) -1; +size_t orig_width = (size_t) track->video.pixel_width * max_coord / (max_coord - r - l); +size_t orig_height = (size_t) track->video.pixel_height * max_coord / (max_coord - b - t); + +/* add a (max_coord - 1) to round up integer division */ +spherical->left_bound = (orig_width * l + max_coord - 1) / max_coord; +spherical->top_bound= (orig_height * t + max_coord - 1) / max_coord; +spherical->right_bound = orig_width - track->video.pixel_width - spherical->left_bound; +spherical->bottom_bound = orig_height - track->video.pixel_height - spherical->top_bound; +} + ret = av_stream_add_side_data(st, AV_PKT_DATA_SPHERICAL, (uint8_t *)spherical, spherical_size); if (ret < 0) { -- 2.10.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 3/3] avformat/apetag: reorder some code to improve readability
On 2/10/2017 6:24 PM, Paul B Mahol wrote: > On 2/10/17, James Almer wrote: >> This way it's clear the size field accounts for the footer length plus every >> tag entry, but not the header. >> >> Signed-off-by: James Almer >> --- >> libavformat/apetag.c | 12 ++-- >> 1 file changed, 6 insertions(+), 6 deletions(-) >> >> diff --git a/libavformat/apetag.c b/libavformat/apetag.c >> index b23f8cdd1f..cdc602e1a9 100644 >> --- a/libavformat/apetag.c >> +++ b/libavformat/apetag.c >> @@ -192,10 +192,6 @@ int ff_ape_write_tag(AVFormatContext *s) >> if ((ret = avio_open_dyn_buf(&dyn_bc)) < 0) >> goto end; >> >> -// flags >> -avio_wl32(dyn_bc, APE_TAG_FLAG_CONTAINS_HEADER | >> APE_TAG_FLAG_IS_HEADER); >> -ffio_fill(dyn_bc, 0, 8); // reserved >> - >> ff_standardize_creation_time(s); >> while ((e = av_dict_get(s->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) { >> int val_len; >> @@ -218,7 +214,7 @@ int ff_ape_write_tag(AVFormatContext *s) >> size = avio_close_dyn_buf(dyn_bc, &dyn_buf); >> if (size <= 0) >> goto end; >> -size += 20; >> +size += APE_TAG_FOOTER_BYTES; >> >> // header >> avio_write(s->pb, "APETAGEX", 8); // id >> @@ -226,7 +222,11 @@ int ff_ape_write_tag(AVFormatContext *s) >> avio_wl32(s->pb, size); >> avio_wl32(s->pb, count); >> >> -avio_write(s->pb, dyn_buf, size - 20); >> +// flags >> +avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | >> APE_TAG_FLAG_IS_HEADER); >> +ffio_fill(s->pb, 0, 8); // reserved >> + >> +avio_write(s->pb, dyn_buf, size - APE_TAG_FOOTER_BYTES); >> >> // footer >> avio_write(s->pb, "APETAGEX", 8); // id >> -- >> 2.11.0 >> >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > > lgtm Pushed. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avformat/apetag: account for header size if present when returning the start position
On 2/10/2017 6:23 PM, Paul B Mahol wrote: > On 2/10/17, James Almer wrote: >> The size field in the header/footer accounts for the entire APE tag >> structure except the 32 bytes from header, for compatibility with >> APEv1. >> >> Signed-off-by: James Almer >> --- >> libavformat/apetag.c | 6 +- >> libavformat/apetag.h | 1 + >> 2 files changed, 6 insertions(+), 1 deletion(-) >> > > probably ok Pushed. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3 v2] avformat/apetag: fix flag value to signal footer presence
On 2/10/2017 6:20 PM, Paul B Mahol wrote: > On 2/10/17, James Almer wrote: >> According to the spec[1], a value of 0 means the footer is present and a >> value >> of 1 means it's absent, the exact opposite of header presence flag where 1 >> means present and 0 absent. >> The reason for this is compatibility with APEv1 tags, where there's no >> header, >> footer presence was mandatory for all files, and the flags field was a >> zeroed >> reserved field. >> >> [1] http://wiki.hydrogenaud.io/index.php?title=Ape_Tags_Flags >> >> Signed-off-by: James Almer >> --- >> v2 changes: Added missing fate test update. >> >> Files already created are obviously wrong, but fortunately having the flag >> mistakenly reporting there's no footer is harmless in APEv2 tags stored at >> the end of the file (The only kind we can read and write), since footer is >> mandatory in those and no and such software really bothers looking at the >> flag. >> >> I renamed the constant just to have it as reference, or until someone feels >> like adding support for APEv2 tags at the beginning of a file, where footer >> becomes optional. >> >> libavformat/apetag.c | 7 +++ >> tests/ref/lavf/tta | 2 +- >> 2 files changed, 4 insertions(+), 5 deletions(-) >> >> diff --git a/libavformat/apetag.c b/libavformat/apetag.c >> index 08e80f4aa3..a05b32d9e5 100644 >> --- a/libavformat/apetag.c >> +++ b/libavformat/apetag.c >> @@ -30,7 +30,7 @@ >> #include "internal.h" >> >> #define APE_TAG_FLAG_CONTAINS_HEADER (1 << 31) >> -#define APE_TAG_FLAG_CONTAINS_FOOTER (1 << 30) >> +#define APE_TAG_FLAG_LACKS_FOOTER (1 << 30) >> #define APE_TAG_FLAG_IS_HEADER(1 << 29) >> #define APE_TAG_FLAG_IS_BINARY(1 << 1) >> >> @@ -189,8 +189,7 @@ int ff_ape_write_tag(AVFormatContext *s) >> goto end; >> >> // flags >> -avio_wl32(dyn_bc, APE_TAG_FLAG_CONTAINS_HEADER | >> APE_TAG_FLAG_CONTAINS_FOOTER | >> - APE_TAG_FLAG_IS_HEADER); >> +avio_wl32(dyn_bc, APE_TAG_FLAG_CONTAINS_HEADER | >> APE_TAG_FLAG_IS_HEADER); >> ffio_fill(dyn_bc, 0, 8); // reserved >> >> ff_standardize_creation_time(s); >> @@ -232,7 +231,7 @@ int ff_ape_write_tag(AVFormatContext *s) >> avio_wl32(s->pb, count);// tag count >> >> // flags >> -avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | >> APE_TAG_FLAG_CONTAINS_FOOTER); >> +avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER); >> ffio_fill(s->pb, 0, 8); // reserved >> >> end: >> diff --git a/tests/ref/lavf/tta b/tests/ref/lavf/tta >> index 745e8d21bd..d86d097e3d 100644 >> --- a/tests/ref/lavf/tta >> +++ b/tests/ref/lavf/tta >> @@ -1,3 +1,3 @@ >> -f2721d06704ac43d89fdd25835b43598 *./tests/data/lavf/lavf.tta >> +d86c5cccb2554143d34d1786ab460a31 *./tests/data/lavf/lavf.tta >> 43200 ./tests/data/lavf/lavf.tta >> ./tests/data/lavf/lavf.tta CRC=0x3a1da17e >> -- >> 2.11.0 >> >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > > probably ok Pushed, thanks. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 3/3] avformat/apetag: reorder some code to improve readability
On 2/10/17, James Almer wrote: > This way it's clear the size field accounts for the footer length plus every > tag entry, but not the header. > > Signed-off-by: James Almer > --- > libavformat/apetag.c | 12 ++-- > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/libavformat/apetag.c b/libavformat/apetag.c > index b23f8cdd1f..cdc602e1a9 100644 > --- a/libavformat/apetag.c > +++ b/libavformat/apetag.c > @@ -192,10 +192,6 @@ int ff_ape_write_tag(AVFormatContext *s) > if ((ret = avio_open_dyn_buf(&dyn_bc)) < 0) > goto end; > > -// flags > -avio_wl32(dyn_bc, APE_TAG_FLAG_CONTAINS_HEADER | > APE_TAG_FLAG_IS_HEADER); > -ffio_fill(dyn_bc, 0, 8); // reserved > - > ff_standardize_creation_time(s); > while ((e = av_dict_get(s->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) { > int val_len; > @@ -218,7 +214,7 @@ int ff_ape_write_tag(AVFormatContext *s) > size = avio_close_dyn_buf(dyn_bc, &dyn_buf); > if (size <= 0) > goto end; > -size += 20; > +size += APE_TAG_FOOTER_BYTES; > > // header > avio_write(s->pb, "APETAGEX", 8); // id > @@ -226,7 +222,11 @@ int ff_ape_write_tag(AVFormatContext *s) > avio_wl32(s->pb, size); > avio_wl32(s->pb, count); > > -avio_write(s->pb, dyn_buf, size - 20); > +// flags > +avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | > APE_TAG_FLAG_IS_HEADER); > +ffio_fill(s->pb, 0, 8); // reserved > + > +avio_write(s->pb, dyn_buf, size - APE_TAG_FOOTER_BYTES); > > // footer > avio_write(s->pb, "APETAGEX", 8); // id > -- > 2.11.0 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > lgtm ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avformat/apetag: account for header size if present when returning the start position
On 2/10/17, James Almer wrote: > The size field in the header/footer accounts for the entire APE tag > structure except the 32 bytes from header, for compatibility with > APEv1. > > Signed-off-by: James Almer > --- > libavformat/apetag.c | 6 +- > libavformat/apetag.h | 1 + > 2 files changed, 6 insertions(+), 1 deletion(-) > probably ok ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3 v2] avformat/apetag: fix flag value to signal footer presence
On 2/10/17, James Almer wrote: > According to the spec[1], a value of 0 means the footer is present and a > value > of 1 means it's absent, the exact opposite of header presence flag where 1 > means present and 0 absent. > The reason for this is compatibility with APEv1 tags, where there's no > header, > footer presence was mandatory for all files, and the flags field was a > zeroed > reserved field. > > [1] http://wiki.hydrogenaud.io/index.php?title=Ape_Tags_Flags > > Signed-off-by: James Almer > --- > v2 changes: Added missing fate test update. > > Files already created are obviously wrong, but fortunately having the flag > mistakenly reporting there's no footer is harmless in APEv2 tags stored at > the end of the file (The only kind we can read and write), since footer is > mandatory in those and no and such software really bothers looking at the > flag. > > I renamed the constant just to have it as reference, or until someone feels > like adding support for APEv2 tags at the beginning of a file, where footer > becomes optional. > > libavformat/apetag.c | 7 +++ > tests/ref/lavf/tta | 2 +- > 2 files changed, 4 insertions(+), 5 deletions(-) > > diff --git a/libavformat/apetag.c b/libavformat/apetag.c > index 08e80f4aa3..a05b32d9e5 100644 > --- a/libavformat/apetag.c > +++ b/libavformat/apetag.c > @@ -30,7 +30,7 @@ > #include "internal.h" > > #define APE_TAG_FLAG_CONTAINS_HEADER (1 << 31) > -#define APE_TAG_FLAG_CONTAINS_FOOTER (1 << 30) > +#define APE_TAG_FLAG_LACKS_FOOTER (1 << 30) > #define APE_TAG_FLAG_IS_HEADER(1 << 29) > #define APE_TAG_FLAG_IS_BINARY(1 << 1) > > @@ -189,8 +189,7 @@ int ff_ape_write_tag(AVFormatContext *s) > goto end; > > // flags > -avio_wl32(dyn_bc, APE_TAG_FLAG_CONTAINS_HEADER | > APE_TAG_FLAG_CONTAINS_FOOTER | > - APE_TAG_FLAG_IS_HEADER); > +avio_wl32(dyn_bc, APE_TAG_FLAG_CONTAINS_HEADER | > APE_TAG_FLAG_IS_HEADER); > ffio_fill(dyn_bc, 0, 8); // reserved > > ff_standardize_creation_time(s); > @@ -232,7 +231,7 @@ int ff_ape_write_tag(AVFormatContext *s) > avio_wl32(s->pb, count);// tag count > > // flags > -avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | > APE_TAG_FLAG_CONTAINS_FOOTER); > +avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER); > ffio_fill(s->pb, 0, 8); // reserved > > end: > diff --git a/tests/ref/lavf/tta b/tests/ref/lavf/tta > index 745e8d21bd..d86d097e3d 100644 > --- a/tests/ref/lavf/tta > +++ b/tests/ref/lavf/tta > @@ -1,3 +1,3 @@ > -f2721d06704ac43d89fdd25835b43598 *./tests/data/lavf/lavf.tta > +d86c5cccb2554143d34d1786ab460a31 *./tests/data/lavf/lavf.tta > 43200 ./tests/data/lavf/lavf.tta > ./tests/data/lavf/lavf.tta CRC=0x3a1da17e > -- > 2.11.0 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > probably ok ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/3] mov: Export bounds and padding from spherical metadata
Update the fate test as needed. --- Please keep me in CC. Vittorio libavformat/mov.c | 46 ++- tests/ref/fate/mov-spherical-mono | 8 +-- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index ca49786..a8900c1 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4625,6 +4625,8 @@ static int mov_read_sv3d(MOVContext *c, AVIOContext *pb, MOVAtom atom) MOVStreamContext *sc; int size; int32_t yaw, pitch, roll; +size_t l, t, r, b; +size_t padding = 0; uint32_t tag; enum AVSphericalProjection projection; @@ -4686,9 +4688,17 @@ static int mov_read_sv3d(MOVContext *c, AVIOContext *pb, MOVAtom atom) switch (tag) { case MKTAG('c','b','m','p'): projection = AV_SPHERICAL_CUBEMAP; +padding = avio_rb32(pb); break; case MKTAG('e','q','u','i'): -projection = AV_SPHERICAL_EQUIRECTANGULAR; +t = avio_rb32(pb); +b = avio_rb32(pb); +l = avio_rb32(pb); +r = avio_rb32(pb); +if (l || t || r || b) +projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE; +else +projection = AV_SPHERICAL_EQUIRECTANGULAR; break; default: av_log(c->fc, AV_LOG_ERROR, "Unknown projection type\n"); @@ -4705,6 +4715,20 @@ static int mov_read_sv3d(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->spherical->pitch = pitch; sc->spherical->roll = roll; +sc->spherical->padding = padding; + +if (projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) { +/* conversion from 0.32 coordinates to pixels */ +uint32_t max_coord = (uint32_t) -1; +size_t orig_width = (size_t) sc->width * max_coord / (max_coord - r - l); +size_t orig_height = (size_t) sc->height * max_coord / (max_coord - b - t); + +/* add a (max_coord - 1) to round up integer division */ +sc->spherical->left_bound = (orig_width * l + max_coord - 1) / max_coord; +sc->spherical->top_bound= (orig_height * t + max_coord - 1) / max_coord; +sc->spherical->right_bound = orig_width - sc->width - sc->spherical->left_bound; +sc->spherical->bottom_bound = orig_height - sc->height - sc->spherical->top_bound; +} return 0; } @@ -4763,6 +4787,26 @@ static int mov_parse_uuid_spherical(MOVStreamContext *sc, AVIOContext *pb, size_ val = av_stristr(buffer, ""); if (val) sc->spherical->roll = strtol(val, NULL, 10) * (1 << 16); + +/* tiling */ +val = av_stristr(buffer, ""); +if (val) +sc->spherical->left_bound = strtol(val, NULL, 10); +val = av_stristr(buffer, ""); +if (val) +sc->spherical->top_bound = strtol(val, NULL, 10); +val = av_stristr(buffer, ""); +if (val) +sc->spherical->right_bound = +sc->width - sc->spherical->left_bound - strtol(val, NULL, 10); +val = av_stristr(buffer, ""); +if (val) +sc->spherical->bottom_bound = +sc->height - sc->spherical->top_bound - strtol(val, NULL, 10); + +if (sc->spherical->left_bound || sc->spherical->top_bound || +sc->spherical->right_bound || sc->spherical->bottom_bound) +sc->spherical->projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE; } out: diff --git a/tests/ref/fate/mov-spherical-mono b/tests/ref/fate/mov-spherical-mono index 9f4b4f8..a1365c4 100644 --- a/tests/ref/fate/mov-spherical-mono +++ b/tests/ref/fate/mov-spherical-mono @@ -7,8 +7,12 @@ inverted=0 [/SIDE_DATA] [SIDE_DATA] side_data_type=Spherical Mapping -side_data_size=16 -projection=equirectangular +side_data_size=56 +projection=tiled equirectangular +left_bound=148 +top_bound=73 +right_bound=147 +bottom_bound=72 yaw=45 pitch=30 roll=15 -- 2.10.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/3] spherical: Add tiled equirectangular type and projection-specific properties
Signed-off-by: Vittorio Giovara --- This should help not losing details over muxing and allows callers to get additional information in a clean manner. Please keep me in CC. Vittorio doc/APIchanges| 5 + ffprobe.c | 11 -- libavformat/dump.c| 10 + libavutil/spherical.h | 56 +++ libavutil/version.h | 2 +- 5 files changed, 81 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 8bca71e..8268295 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,11 @@ libavutil: 2015-08-28 API changes, most recent first: +2017-02-10 - xxx - lavu 55.47.100 / 55.31.0 - spherical.h + Add AV_SPHERICAL_EQUIRECTANGULAR_TILE, and projection-specific properties + (left_bound, top_bound, right_bound, bottom_bound, padding) to + AVSphericalMapping. + 2017-01-31 - xxx - lavu 55.46.100 / 55.20.0 - cpu.h Add AV_CPU_FLAG_SSSE3SLOW. diff --git a/ffprobe.c b/ffprobe.c index 046f080..dafac56 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -1788,9 +1788,16 @@ static void print_pkt_side_data(WriterContext *w, const AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data; if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR) print_str("projection", "equirectangular"); -else if (spherical->projection == AV_SPHERICAL_CUBEMAP) +else if (spherical->projection == AV_SPHERICAL_CUBEMAP) { print_str("projection", "cubemap"); -else +print_int("padding", spherical->padding); +} else if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) { +print_str("projection", "tiled equirectangular"); +print_int("left_bound", spherical->left_bound); +print_int("top_bound", spherical->top_bound); +print_int("right_bound", spherical->right_bound); +print_int("bottom_bound", spherical->bottom_bound); +} else print_str("projection", "unknown"); print_int("yaw", (double) spherical->yaw / (1 << 16)); diff --git a/libavformat/dump.c b/libavformat/dump.c index d9aa3af..6fbbd5a 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -357,6 +357,8 @@ static void dump_spherical(void *ctx, AVPacketSideData *sd) av_log(ctx, AV_LOG_INFO, "equirectangular "); else if (spherical->projection == AV_SPHERICAL_CUBEMAP) av_log(ctx, AV_LOG_INFO, "cubemap "); +else if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) +av_log(ctx, AV_LOG_INFO, "tiled equirectangular "); else { av_log(ctx, AV_LOG_WARNING, "unknown"); return; @@ -366,6 +368,14 @@ static void dump_spherical(void *ctx, AVPacketSideData *sd) pitch = ((double)spherical->pitch) / (1 << 16); roll = ((double)spherical->roll) / (1 << 16); av_log(ctx, AV_LOG_INFO, "(%f/%f/%f) ", yaw, pitch, roll); + +if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) { +av_log(ctx, AV_LOG_INFO, "[%zu, %zu, %zu, %zu] ", + spherical->left_bound, spherical->top_bound, + spherical->right_bound, spherical->bottom_bound); +} else if (spherical->projection == AV_SPHERICAL_CUBEMAP) { +av_log(ctx, AV_LOG_INFO, "[pad %zu] ", spherical->padding); +} } static void dump_sidedata(void *ctx, AVStream *st, const char *indent) diff --git a/libavutil/spherical.h b/libavutil/spherical.h index eeda625..0cfd0d9 100644 --- a/libavutil/spherical.h +++ b/libavutil/spherical.h @@ -63,6 +63,13 @@ enum AVSphericalProjection { * to the back. */ AV_SPHERICAL_CUBEMAP, + +/** + * Video represents a portion of a sphere mapped on a flat surface + * using equirectangular projection. The @ref bounding fields indicate + * the position of the current video in a larger surface. + */ +AV_SPHERICAL_EQUIRECTANGULAR_TILE, }; /** @@ -122,6 +129,55 @@ typedef struct AVSphericalMapping { /** * @} */ + +/** + * @name Bounding rectangle + * @anchor bounding + * @{ + * These fields indicate the location of the current tile, and where + * it should be mapped relative to the original surface. + * + * @code{.unparsed} + * ++--+ + * ||top_bound | + * |++ | + * | left_bound |tile| | + * +<-->||<--->+right_bound + * |++ | + * || | + * |bottom_bound| | + * ++--+ + * @endcode + * + * If needed, the original video surface dimensions can be derived + * by adding the current stream or frame size to the related bounds, + * like in the following example: + * +
[FFmpeg-devel] [PATCH 3/3] avformat/apetag: reorder some code to improve readability
This way it's clear the size field accounts for the footer length plus every tag entry, but not the header. Signed-off-by: James Almer --- libavformat/apetag.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/apetag.c b/libavformat/apetag.c index b23f8cdd1f..cdc602e1a9 100644 --- a/libavformat/apetag.c +++ b/libavformat/apetag.c @@ -192,10 +192,6 @@ int ff_ape_write_tag(AVFormatContext *s) if ((ret = avio_open_dyn_buf(&dyn_bc)) < 0) goto end; -// flags -avio_wl32(dyn_bc, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_IS_HEADER); -ffio_fill(dyn_bc, 0, 8); // reserved - ff_standardize_creation_time(s); while ((e = av_dict_get(s->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) { int val_len; @@ -218,7 +214,7 @@ int ff_ape_write_tag(AVFormatContext *s) size = avio_close_dyn_buf(dyn_bc, &dyn_buf); if (size <= 0) goto end; -size += 20; +size += APE_TAG_FOOTER_BYTES; // header avio_write(s->pb, "APETAGEX", 8); // id @@ -226,7 +222,11 @@ int ff_ape_write_tag(AVFormatContext *s) avio_wl32(s->pb, size); avio_wl32(s->pb, count); -avio_write(s->pb, dyn_buf, size - 20); +// flags +avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_IS_HEADER); +ffio_fill(s->pb, 0, 8); // reserved + +avio_write(s->pb, dyn_buf, size - APE_TAG_FOOTER_BYTES); // footer avio_write(s->pb, "APETAGEX", 8); // id -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/3 v2] avformat/apetag: fix flag value to signal footer presence
According to the spec[1], a value of 0 means the footer is present and a value of 1 means it's absent, the exact opposite of header presence flag where 1 means present and 0 absent. The reason for this is compatibility with APEv1 tags, where there's no header, footer presence was mandatory for all files, and the flags field was a zeroed reserved field. [1] http://wiki.hydrogenaud.io/index.php?title=Ape_Tags_Flags Signed-off-by: James Almer --- v2 changes: Added missing fate test update. Files already created are obviously wrong, but fortunately having the flag mistakenly reporting there's no footer is harmless in APEv2 tags stored at the end of the file (The only kind we can read and write), since footer is mandatory in those and no and such software really bothers looking at the flag. I renamed the constant just to have it as reference, or until someone feels like adding support for APEv2 tags at the beginning of a file, where footer becomes optional. libavformat/apetag.c | 7 +++ tests/ref/lavf/tta | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libavformat/apetag.c b/libavformat/apetag.c index 08e80f4aa3..a05b32d9e5 100644 --- a/libavformat/apetag.c +++ b/libavformat/apetag.c @@ -30,7 +30,7 @@ #include "internal.h" #define APE_TAG_FLAG_CONTAINS_HEADER (1 << 31) -#define APE_TAG_FLAG_CONTAINS_FOOTER (1 << 30) +#define APE_TAG_FLAG_LACKS_FOOTER (1 << 30) #define APE_TAG_FLAG_IS_HEADER(1 << 29) #define APE_TAG_FLAG_IS_BINARY(1 << 1) @@ -189,8 +189,7 @@ int ff_ape_write_tag(AVFormatContext *s) goto end; // flags -avio_wl32(dyn_bc, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_CONTAINS_FOOTER | - APE_TAG_FLAG_IS_HEADER); +avio_wl32(dyn_bc, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_IS_HEADER); ffio_fill(dyn_bc, 0, 8); // reserved ff_standardize_creation_time(s); @@ -232,7 +231,7 @@ int ff_ape_write_tag(AVFormatContext *s) avio_wl32(s->pb, count);// tag count // flags -avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_CONTAINS_FOOTER); +avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER); ffio_fill(s->pb, 0, 8); // reserved end: diff --git a/tests/ref/lavf/tta b/tests/ref/lavf/tta index 745e8d21bd..d86d097e3d 100644 --- a/tests/ref/lavf/tta +++ b/tests/ref/lavf/tta @@ -1,3 +1,3 @@ -f2721d06704ac43d89fdd25835b43598 *./tests/data/lavf/lavf.tta +d86c5cccb2554143d34d1786ab460a31 *./tests/data/lavf/lavf.tta 43200 ./tests/data/lavf/lavf.tta ./tests/data/lavf/lavf.tta CRC=0x3a1da17e -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] MAINTAINERS: Add ffmpeg-security alias members
Iam listing the reason for each, this is mostly my oppinion and i didnt ask most if they agree with the listed reason to be listed with their name, so its largly my oppinion. Which is why i will remove the reasons before pushing i just added them to be transparent on this but as said its mostly my oppinion, i just talked with ubitux and noone else ... Signed-off-by: Michael Niedermayer --- MAINTAINERS | 5 + 1 file changed, 5 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 80721e183d..39339d620d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -60,6 +60,11 @@ mailing lists Baptiste Coudurier, Lou Logan Google+ Paul B Mahol, Michael Niedermayer, Alexander Strasser Twitter Lou Logan, Reynaldo H. Verdejo Pinochet Launchpad Timothy Gu +ffmpeg-security Andreas Cadhalpun (keeping debian/ubuntu packages secure, activly works on security) +Carl Eugen Hoyos (keeping track of every bug, testing, finding wrongly listed CVEs) +Clément Bœsch (fix security issues in code i maintain) +Michael Niedermayer (fixing most reported issues) +Reimar Doeffinger (root admin able to fix issues on the server, occasional patch reviews) libavutil -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [RFC] ffmpeg security
On 2/10/2017 4:03 PM, Michael Niedermayer wrote: > Hi community > > what do you prefer about the ffmpeg-security alias ? > in no particular order > > Should everyone on the alias be listed in MAINTAINERs under a > ffmpeg-security point? I'd say yes. From a transparency PoV, people should know who will get access to such reports. > > Should for everyone who is on the alias a reason be listed in > MAINTAINERs why (s)he is on the alias ? IMO, there's no need for this. Read below. > > Should everyone on the alias have a reason beyond curiousity to be > on the alias? (that is a reason that clearly benefits FFmpeg) Yes, it should be about intending to fix reports and/or review fixes made by others. Curiosity alone is not enough at all. > > Should everyone on the alias be a FFmpeg maintainer? They should be trust worthy, active and ideally long standing contributors. We have a few such people that don't "maintain" anything, as far as having an entry in MAINTAINERS goes or implicitly maintaining some specific part of the codebase, so that shouldn't be a requirement. Of course, inaccuracies in that file should be fixed. Anyone implicitly maintaining some module should add themselves to it. > > Should everyone on the alias be a FFmpeg supporter? > (For example not bad-mouthing the project) If by bad-mouthing you mean something like ill intended defamation then sure, that's not acceptable. People however often voice their frustration towards pretty much anything, so I don't agree that should be a blocker at all. Doubt many people would survive a google search for public irc or email logs in that regard. The amount of not-so-kind words as consequence of some questionable chunk of code is probably big. > > Should everyone on the alias be required to make a good effort to act > in the best interrest of FFmpeg in relation to ffmpeg security ? If the requirement to get in is intending to fix reports or review fixes for said reports, then they are IMO already acting in the best interest of the project. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [RFC] ffmpeg security
Hi community what do you prefer about the ffmpeg-security alias ? in no particular order Should everyone on the alias be listed in MAINTAINERs under a ffmpeg-security point? Should for everyone who is on the alias a reason be listed in MAINTAINERs why (s)he is on the alias ? Should everyone on the alias have a reason beyond curiousity to be on the alias? (that is a reason that clearly benefits FFmpeg) Should everyone on the alias be a FFmpeg maintainer? Should everyone on the alias be a FFmpeg supporter? (For example not bad-mouthing the project) Should everyone on the alias be required to make a good effort to act in the best interrest of FFmpeg in relation to ffmpeg security ? -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Awnsering whenever a program halts or runs forever is On a turing machine, in general impossible (turings halting problem). On any real computer, always possible as a real computer has a finite number of states N, and will either halt in less than N cycles or never halt. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] libopus: decode ambisonics with non-diegetic sources
Hi all, The attached patch allows libavcodec/opus to decode ambisonics with non-diegetic stereo stream in an ogg/opus container, as is being added in this IETF standards draft [1]. Please let me know if there are any concerns. Thanks, Felicia [1] https://tools.ietf.org/html/draft-ietf-codec-ambisonics-01#section-3.1 From 0798655323605d44d4f75e48fbfc940be0ba7423 Mon Sep 17 00:00:00 2001 From: Felicia Date: Mon, 6 Feb 2017 15:49:36 -0800 Subject: [PATCH] libopus: decode ambisonics with non-diegetic sources Channel mapping 2 additionally supports a non-diegetic stereo track appended to the end of a full-order ambisonics signal, such that the total channel count is either (n + 1) ^ 2, or (n + 1) ^ 2 + 2 where n is the ambisonics order --- libavcodec/opus.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/opus.c b/libavcodec/opus.c index 1eeb92c5bd..07e70fd7a4 100644 --- a/libavcodec/opus.c +++ b/libavcodec/opus.c @@ -373,10 +373,12 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx, channel_reorder = channel_reorder_vorbis; } else if (map_type == 2) { int ambisonic_order = ff_sqrt(channels) - 1; -if (channels != (ambisonic_order + 1) * (ambisonic_order + 1)) { +if (channels != ((ambisonic_order + 1) * (ambisonic_order + 1)) && +channels != ((ambisonic_order + 1) * (ambisonic_order + 1) + 2)) { av_log(avctx, AV_LOG_ERROR, "Channel mapping 2 is only specified for channel counts" - " which can be written as (n + 1)^2 for nonnegative integer n\n"); + " which can be written as (n + 1)^2 or (n + 1)^2 + 2" + " for nonnegative integer n\n"); return AVERROR_INVALIDDATA; } layout = 0; -- 2.11.0.483.g087da7b7c-goog ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/2] avformat/apetag: fix flag value to signal footer presence
According to the spec[1], a value of 0 means the footer is present and a value of 1 means it's absent, the exact opposite of header presence flag where 1 means present and 0 absent. The reason for this is compatibility with APEv1 tags, where there's no header, footer presence was mandatory for all files, and the flags field was a zeroed reserved field. [1] http://wiki.hydrogenaud.io/index.php?title=Ape_Tags_Flags Signed-off-by: James Almer --- Files already created are obviously wrong, but fortunately having the flag mistakenly reporting there's no footer is harmless in APEv2 tags stored at the end of the file (The only kind we can read and write), since footer is mandatory in those and no and such software really bothers looking at the flag. I renamed the constant just to have it as reference, or until someone feels like adding support for APEv2 tags at the beginning of a file, where footer becomes optional. libavformat/apetag.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavformat/apetag.c b/libavformat/apetag.c index 08e80f4aa3..a05b32d9e5 100644 --- a/libavformat/apetag.c +++ b/libavformat/apetag.c @@ -30,7 +30,7 @@ #include "internal.h" #define APE_TAG_FLAG_CONTAINS_HEADER (1 << 31) -#define APE_TAG_FLAG_CONTAINS_FOOTER (1 << 30) +#define APE_TAG_FLAG_LACKS_FOOTER (1 << 30) #define APE_TAG_FLAG_IS_HEADER(1 << 29) #define APE_TAG_FLAG_IS_BINARY(1 << 1) @@ -189,8 +189,7 @@ int ff_ape_write_tag(AVFormatContext *s) goto end; // flags -avio_wl32(dyn_bc, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_CONTAINS_FOOTER | - APE_TAG_FLAG_IS_HEADER); +avio_wl32(dyn_bc, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_IS_HEADER); ffio_fill(dyn_bc, 0, 8); // reserved ff_standardize_creation_time(s); @@ -232,7 +231,7 @@ int ff_ape_write_tag(AVFormatContext *s) avio_wl32(s->pb, count);// tag count // flags -avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_CONTAINS_FOOTER); +avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER); ffio_fill(s->pb, 0, 8); // reserved end: -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/2] avformat/apetag: account for header size if present when returning the start position
The size field in the header/footer accounts for the entire APE tag structure except the 32 bytes from header, for compatibility with APEv1. Signed-off-by: James Almer --- libavformat/apetag.c | 6 +- libavformat/apetag.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/apetag.c b/libavformat/apetag.c index a05b32d9e5..b23f8cdd1f 100644 --- a/libavformat/apetag.c +++ b/libavformat/apetag.c @@ -150,7 +150,6 @@ int64_t ff_ape_parse_tag(AVFormatContext *s) av_log(s, AV_LOG_ERROR, "Invalid tag size %"PRIu32".\n", tag_bytes); return 0; } -tag_start = file_size - tag_bytes - APE_TAG_FOOTER_BYTES; fields = avio_rl32(pb);/* number of fields */ if (fields > 65536) { @@ -166,6 +165,11 @@ int64_t ff_ape_parse_tag(AVFormatContext *s) avio_seek(pb, file_size - tag_bytes, SEEK_SET); +if (val & APE_TAG_FLAG_CONTAINS_HEADER) +tag_bytes += APE_TAG_HEADER_BYTES; + +tag_start = file_size - tag_bytes; + for (i=0; ihttp://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v5] Added Turing codec interface for ffmpeg
On Fri, 10 Feb 2017 15:48:55 + Saverio Blasi wrote: > > You probably shouldn't update options_buffer_size before the reallocation > > actually succeeded. (Probably doesn't matter with the current code, but for > > robustness...) > This is now addressed. > > > Still not sure why there's at least 1 redundant field (s which is redundant > > with buffer_filled). > Truly s can be inferred from buffer_filled, but for readability and debugging > purposes it is convenient to maintain both.s helps in keeping track of the > current position within the options buffer. Can't really agree with this - redundant fields have the tendency to become inconsistent, and if you use those fields for debugging it will get even harder. > > Not sure why this isn't just done by add_option. > This cannot be done inside add_option, because at the time of adding each > option it is difficult to know how many options are passed to command line > and consequently allocate argv You don't know how long the "concatenated" option string is either. And "concatenating" the options just to parse them back into single options in finalize_options seems more work than just growing the argv array. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v6] - Added Turing codec interface for ffmpeg
On Fri, 10 Feb 2017 15:37:09 + Saverio Blasi wrote: > - This patch contains the changes to interface the Turing codec > (http://turingcodec.org/) with ffmpeg. The patch was modified to address the > comments in the review as follows: > - Added a pkg-config file to list all dependencies required by libturing. > This should address the issue pointed out by Hendrik Leppkes on Fri 18/11/2016 > - As per suggestions of wm4, two functions (add_option and > finalise_options) have been created. The former appends new options while the > latter sets up the argv array of pointers to char* accordingly. add_option > re-allocates the buffer for options using av_realloc > - Additionally, both these functions handle the errors in case the memory > wasn't allocated correctly > - malloc|free|realloc have been substituted with their corresponding > av_{malloc|free|realloc} version > - Check on bit-depth has been removed since the ffmpeg already casts the > right pix_fmt and bit depth > - pix_fmts is now set in ff_libturing_encoder as in h264dec.c. > - Changed usage of av_free with av_freep and fixed calls to free arrays > - Added brackets to all if and for statements > - Avoid repetition of code to free arrays in case of failure to initialise > the libturing encoder > - Some fixes to address the review from wm4 and Mark Thompson received on > Wed 08/02/2017 > --- > LICENSE.md | 1 + > configure | 5 + > libavcodec/Makefile| 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/libturing.c | 320 > + > 5 files changed, 328 insertions(+) > create mode 100644 libavcodec/libturing.c > OK I guess. Could be further beautified, but I'm ok with the current state. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add FM Screen Capture Codec decoder
On 2/10/17, Carl Eugen Hoyos wrote: > 2017-02-10 16:14 GMT+01:00 Paul B Mahol : > >> +case 32: avctx->pix_fmt = AV_PIX_FMT_BGRA; break; > > Do you have a 32bit sample? > I would have expected that screen capture codecs do not > support alpha. It supports alpha via VirtualDub just fine. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add FM Screen Capture Codec decoder
2017-02-10 16:14 GMT+01:00 Paul B Mahol : > +case 32: avctx->pix_fmt = AV_PIX_FMT_BGRA; break; Do you have a 32bit sample? I would have expected that screen capture codecs do not support alpha. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v6] - Added Turing codec interface for ffmpeg
On 2/10/17, Saverio Blasi wrote: > - This patch contains the changes to interface the Turing codec > (http://turingcodec.org/) with ffmpeg. The patch was modified to address the > comments in the review as follows: > - Added a pkg-config file to list all dependencies required by libturing. > This should address the issue pointed out by Hendrik Leppkes on Fri > 18/11/2016 > - As per suggestions of wm4, two functions (add_option and > finalise_options) have been created. The former appends new options while > the latter sets up the argv array of pointers to char* accordingly. > add_option re-allocates the buffer for options using av_realloc > - Additionally, both these functions handle the errors in case the memory > wasn't allocated correctly > - malloc|free|realloc have been substituted with their corresponding > av_{malloc|free|realloc} version > - Check on bit-depth has been removed since the ffmpeg already casts the > right pix_fmt and bit depth > - pix_fmts is now set in ff_libturing_encoder as in h264dec.c. > - Changed usage of av_free with av_freep and fixed calls to free arrays > - Added brackets to all if and for statements > - Avoid repetition of code to free arrays in case of failure to initialise > the libturing encoder > - Some fixes to address the review from wm4 and Mark Thompson received on > Wed 08/02/2017 > --- > LICENSE.md | 1 + > configure | 5 + > libavcodec/Makefile| 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/libturing.c | 320 > + > 5 files changed, 328 insertions(+) > create mode 100644 libavcodec/libturing.c > [...] > +static const AVOption options[] = { > +{ "turing-params", "configure additional turing encoder parameters", > offsetof(libturingEncodeContext, options), AV_OPT_TYPE_STRING,{ 0 }, 0, 0, > AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > +{ NULL } > +}; > + > +static const AVClass class = { > +.class_name = "libturing", > +.item_name = av_default_item_name, > +.option = options, > +.version = LIBAVUTIL_VERSION_INT, Vertical indentation please. > +}; > + > +AVCodec ff_libturing_encoder = { > +.name = "libturing", > +.long_name = NULL_IF_CONFIG_SMALL("libturing HEVC"), > +.type = AVMEDIA_TYPE_VIDEO, > +.id = AV_CODEC_ID_HEVC, > +.init = libturing_encode_init, > +.encode2 = libturing_encode_frame, > +.close = libturing_encode_close, > +.priv_data_size = sizeof(libturingEncodeContext), > +.priv_class = &class, > +.capabilities = AV_CODEC_CAP_DELAY, > +.pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUV420P10, > AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE}, Vertical indentation please. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v5] Added Turing codec interface for ffmpeg
> You probably shouldn't update options_buffer_size before the reallocation > actually succeeded. (Probably doesn't matter with the current code, but for > robustness...) This is now addressed. > Still not sure why there's at least 1 redundant field (s which is redundant > with buffer_filled). Truly s can be inferred from buffer_filled, but for readability and debugging purposes it is convenient to maintain both.s helps in keeping track of the current position within the options buffer. > Not sure why this isn't just done by add_option. This cannot be done inside add_option, because at the time of adding each option it is difficult to know how many options are passed to command line and consequently allocate argv > Why do this extra check, instead of applying the internal values after the > user options? (Assuming redundant options overwrite previous option values in > libturing.) While at the moment the behaviour of libturing is as you describe (overwriting redundant options with the last specified value) we would prefer to keep the interface transparent to this, in case we decide to change the behaviour of libturing in the future. We have slightly changed the log that is produced in case a redundant option is passed to clarify that the passed value is ignored. > I think you should use av_mallocz to ensure the padding is cleared. This is now done -Original Message- From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of wm4 Sent: 08 February 2017 09:28 To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH v5] Added Turing codec interface for ffmpeg On Wed, 8 Feb 2017 08:41:56 + Saverio Blasi wrote: > - This patch contains the changes to interface the Turing codec > (http://turingcodec.org/) with ffmpeg. The patch was modified to address the > comments in the review as follows: > - Added a pkg-config file to list all dependencies required by libturing. > This should address the issue pointed out by Hendrik Leppkes on Fri 18/11/2016 > - As per suggestions of wm4, two functions (add_option and > finalise_options) have been created. The former appends new options while the > latter sets up the argv array of pointers to char* accordingly. add_option > re-allocates the buffer for options using av_realloc > - Additionally, both these functions handle the errors in case the memory > wasn't allocated correctly > - malloc|free|realloc have been substituted with their corresponding > av_{malloc|free|realloc} version > - Check on bit-depth has been removed since the ffmpeg already casts the > right pix_fmt and bit depth > - pix_fmts is now set in ff_libturing_encoder as in h264dec.c. > - Added av_freep to release the allocated memory > - Added brackets to single-line operators > --- > LICENSE.md | 1 + > configure | 5 + > libavcodec/Makefile| 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/libturing.c | 320 > + > 5 files changed, 328 insertions(+) > create mode 100644 libavcodec/libturing.c The patch seems mostly ok, some minor comments below. > +static av_cold int add_option(const char* current_option, > +optionContext* option_ctx) { > +int option_length = strlen(current_option); > +char *temp_ptr; > +if (option_ctx->buffer_filled + option_length + 1 > > option_ctx->options_buffer_size) { > +option_ctx->options_buffer_size += option_length + 1; You probably shouldn't update options_buffer_size before the reallocation actually succeeded. (Probably doesn't matter with the current code, but for robustness...) > +temp_ptr = av_realloc(option_ctx->options, > option_ctx->options_buffer_size); > +if (temp_ptr == NULL) { > +return AVERROR(ENOMEM); > +} > +option_ctx->options = temp_ptr; > +option_ctx->s = option_ctx->options + option_ctx->buffer_filled; > +} > +strcpy(option_ctx->s, current_option); > +option_ctx->s += 1 + option_length; > +option_ctx->options_added++; > +option_ctx->buffer_filled += option_length + 1; > +return 0; > +} Still not sure why there's at least 1 redundant field (s which is redundant with buffer_filled). Using memcpy might be slightly nicer than strcpy, because everyone hates strcpy. But it looks correct anyway. > + > +static av_cold int finalise_options(optionContext* option_ctx) { > +if (option_ctx->options_added) { > +char *p; > +option_ctx->argv = av_malloc(option_ctx->options_added * > sizeof(char*)); > +if (option_ctx->argv == NULL) { > +return AVERROR(ENOMEM); > +} > +p = option_ctx->options; > +for(int option_idx=0; option_idxoptions_added; > option_idx++) { > +option_ctx->argv[option_idx] = p; > +p += strlen(p) + 1; > +} > +} > +return 0; > +} Not sure why this isn't just done by add_option. > + >
[FFmpeg-devel] [PATCH v6] - Added Turing codec interface for ffmpeg
- This patch contains the changes to interface the Turing codec (http://turingcodec.org/) with ffmpeg. The patch was modified to address the comments in the review as follows: - Added a pkg-config file to list all dependencies required by libturing. This should address the issue pointed out by Hendrik Leppkes on Fri 18/11/2016 - As per suggestions of wm4, two functions (add_option and finalise_options) have been created. The former appends new options while the latter sets up the argv array of pointers to char* accordingly. add_option re-allocates the buffer for options using av_realloc - Additionally, both these functions handle the errors in case the memory wasn't allocated correctly - malloc|free|realloc have been substituted with their corresponding av_{malloc|free|realloc} version - Check on bit-depth has been removed since the ffmpeg already casts the right pix_fmt and bit depth - pix_fmts is now set in ff_libturing_encoder as in h264dec.c. - Changed usage of av_free with av_freep and fixed calls to free arrays - Added brackets to all if and for statements - Avoid repetition of code to free arrays in case of failure to initialise the libturing encoder - Some fixes to address the review from wm4 and Mark Thompson received on Wed 08/02/2017 --- LICENSE.md | 1 + configure | 5 + libavcodec/Makefile| 1 + libavcodec/allcodecs.c | 1 + libavcodec/libturing.c | 320 + 5 files changed, 328 insertions(+) create mode 100644 libavcodec/libturing.c diff --git a/LICENSE.md b/LICENSE.md index 640633c..86e5371 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -85,6 +85,7 @@ The following libraries are under GPL: - frei0r - libcdio - librubberband +- libturing - libvidstab - libx264 - libx265 diff --git a/configure b/configure index 7154142..a27cb8b 100755 --- a/configure +++ b/configure @@ -255,6 +255,7 @@ External library support: --enable-libssh enable SFTP protocol via libssh [no] --enable-libtesseractenable Tesseract, needed for ocr filter [no] --enable-libtheora enable Theora encoding via libtheora [no] + --enable-libturing enable H.265/HEVC encoding via libturing [no] --enable-libtwolame enable MP2 encoding via libtwolame [no] --enable-libv4l2 enable libv4l2/v4l-utils [no] --enable-libvidstab enable video stabilization using vid.stab [no] @@ -1562,6 +1563,7 @@ EXTERNAL_LIBRARY_LIST=" libssh libtesseract libtheora +libturing libtwolame libv4l2 libvidstab @@ -2858,6 +2860,7 @@ libspeex_decoder_deps="libspeex" libspeex_encoder_deps="libspeex" libspeex_encoder_select="audio_frame_queue" libtheora_encoder_deps="libtheora" +libturing_encoder_deps="libturing" libtwolame_encoder_deps="libtwolame" libvo_amrwbenc_encoder_deps="libvo_amrwbenc" libvorbis_decoder_deps="libvorbis" @@ -5131,6 +5134,7 @@ die_license_disabled gpl frei0r die_license_disabled gpl libcdio die_license_disabled gpl librubberband die_license_disabled gpl libsmbclient +die_license_disabled gpl libturing die_license_disabled gpl libvidstab die_license_disabled gpl libx264 die_license_disabled gpl libx265 @@ -5789,6 +5793,7 @@ enabled libssh&& require_pkg_config libssh libssh/sftp.h sftp_init enabled libspeex && require_pkg_config speex speex/speex.h speex_decoder_init -lspeex enabled libtesseract && require_pkg_config tesseract tesseract/capi.h TessBaseAPICreate enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg +enabled libturing && require_pkg_config libturing turing.h turing_version enabled libtwolame&& require libtwolame twolame.h twolame_init -ltwolame && { check_lib twolame.h twolame_encode_buffer_float32_interleaved -ltwolame || die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; } diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 43a6add..de5af1d 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -883,6 +883,7 @@ OBJS-$(CONFIG_LIBSHINE_ENCODER) += libshine.o OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o OBJS-$(CONFIG_LIBSPEEX_ENCODER) += libspeexenc.o OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o +OBJS-$(CONFIG_LIBTURING_ENCODER) += libturing.o OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o OBJS-$(CONFIG_LIBVORBIS_DECODER) += libvorbisdec.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index f92b2b7..f650591 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -615,6 +615,7 @@ void avcodec_register_all(void) REGISTER_ENCODER(LIBSHINE, libshine); REGISTER_ENCDEC (LIBSPEEX, libspeex); REGISTER_ENCODER(LI
Re: [FFmpeg-devel] [PATCH v5] Added Turing codec interface for ffmpeg
> 'U' < 'W' (the ones above in configure get the order right). This is now fixed. > It's now 2017. This is now fixed. > What is float.h being included for here? This redundant include is now removed. > Would it be possible to add a few more of the standard options here to avoid > some normal cases having to pass special libturing-only options? We would prefer to keep as many options as possible libturing-only, this would give us freedom to change the way such options are passed to libturing / used in the future without the need for changing the interface with ffmpeg. > Maybe VERBOSE rather than INFO? This is now changed. > This cleanup code is copied multiple times, maybe replace them all with a > single "fail" path at the end and goto it? This is now done in the new version of the patch. > You don't need this check, av_freep(&null_pointer) is explicitly valid. This unneeded check is now removed. > Setting AUTO_THREADS here probably isn't meaningful, there is no explicit > threading at all. This was removed from the new patch. -Original Message- From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Mark Thompson Sent: 08 February 2017 13:06 To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH v5] Added Turing codec interface for ffmpeg On 08/02/17 08:41, Saverio Blasi wrote: > - This patch contains the changes to interface the Turing codec > (http://turingcodec.org/) with ffmpeg. The patch was modified to address the > comments in the review as follows: > - Added a pkg-config file to list all dependencies required by libturing. > This should address the issue pointed out by Hendrik Leppkes on Fri 18/11/2016 > - As per suggestions of wm4, two functions (add_option and > finalise_options) have been created. The former appends new options while the > latter sets up the argv array of pointers to char* accordingly. add_option > re-allocates the buffer for options using av_realloc > - Additionally, both these functions handle the errors in case the memory > wasn't allocated correctly > - malloc|free|realloc have been substituted with their corresponding > av_{malloc|free|realloc} version > - Check on bit-depth has been removed since the ffmpeg already casts the > right pix_fmt and bit depth > - pix_fmts is now set in ff_libturing_encoder as in h264dec.c. > - Added av_freep to release the allocated memory > - Added brackets to single-line operators > --- > LICENSE.md | 1 + > configure | 5 + > libavcodec/Makefile| 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/libturing.c | 320 > + > 5 files changed, 328 insertions(+) > create mode 100644 libavcodec/libturing.c > > diff --git a/LICENSE.md b/LICENSE.md > index 640633c..86e5371 100644 > --- a/LICENSE.md > +++ b/LICENSE.md > @@ -85,6 +85,7 @@ The following libraries are under GPL: > - frei0r > - libcdio > - librubberband > +- libturing > - libvidstab > - libx264 > - libx265 > diff --git a/configure b/configure > index 7154142..a27cb8b 100755 > --- a/configure > +++ b/configure > @@ -255,6 +255,7 @@ External library support: >--enable-libssh enable SFTP protocol via libssh [no] >--enable-libtesseractenable Tesseract, needed for ocr filter [no] >--enable-libtheora enable Theora encoding via libtheora [no] > + --enable-libturing enable H.265/HEVC encoding via libturing [no] >--enable-libtwolame enable MP2 encoding via libtwolame [no] >--enable-libv4l2 enable libv4l2/v4l-utils [no] >--enable-libvidstab enable video stabilization using vid.stab [no] > @@ -1562,6 +1563,7 @@ EXTERNAL_LIBRARY_LIST=" > libssh > libtesseract > libtheora > +libturing > libtwolame > libv4l2 > libvidstab > @@ -2858,6 +2860,7 @@ libspeex_decoder_deps="libspeex" > libspeex_encoder_deps="libspeex" > libspeex_encoder_select="audio_frame_queue" > libtheora_encoder_deps="libtheora" > +libturing_encoder_deps="libturing" > libtwolame_encoder_deps="libtwolame" > libvo_amrwbenc_encoder_deps="libvo_amrwbenc" > libvorbis_decoder_deps="libvorbis" > @@ -5131,6 +5134,7 @@ die_license_disabled gpl frei0r > die_license_disabled gpl libcdio die_license_disabled gpl > librubberband die_license_disabled gpl libsmbclient > +die_license_disabled gpl libturing > die_license_disabled gpl libvidstab > die_license_disabled gpl libx264 > die_license_disabled gpl libx265 > @@ -5789,6 +5793,7 @@ enabled libssh&& require_pkg_config libssh > libssh/sftp.h sftp_init > enabled libspeex && require_pkg_config speex speex/speex.h > speex_decoder_init -lspeex > enabled libtesseract && require_pkg_config tesseract tesseract/capi.h > TessBaseAPICreate > enabled libtheora && require libtheora theora/theoraenc.h > th_info_init -ltheoraenc -ltheoradec -logg > +enabled libturing && requi
[FFmpeg-devel] [PATCH] avcodec: add FM Screen Capture Codec decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 7 + libavcodec/fmvc.c | 629 libavformat/riff.c | 1 + 6 files changed, 640 insertions(+) create mode 100644 libavcodec/fmvc.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 4765e9c..f0b2aa3 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -290,6 +290,7 @@ OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o OBJS-$(CONFIG_FLASHSV2_ENCODER)+= flashsv2enc.o OBJS-$(CONFIG_FLASHSV2_DECODER)+= flashsv.o OBJS-$(CONFIG_FLIC_DECODER)+= flicvideo.o +OBJS-$(CONFIG_FMVC_DECODER)+= fmvc.o OBJS-$(CONFIG_FOURXM_DECODER) += 4xm.o OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o OBJS-$(CONFIG_FRWU_DECODER)+= frwu.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index f92b2b7..10fd61c 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -192,6 +192,7 @@ void avcodec_register_all(void) REGISTER_ENCDEC (FLASHSV2, flashsv2); REGISTER_DECODER(FLIC, flic); REGISTER_ENCDEC (FLV, flv); +REGISTER_DECODER(FMVC, fmvc); REGISTER_DECODER(FOURXM,fourxm); REGISTER_DECODER(FRAPS, fraps); REGISTER_DECODER(FRWU, frwu); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 1e681e9..724e246 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -414,6 +414,7 @@ enum AVCodecID { AV_CODEC_ID_PSD, AV_CODEC_ID_PIXLET, AV_CODEC_ID_SPEEDHQ, +AV_CODEC_ID_FMVC, /* 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 09d3c48..cb3debd 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1353,6 +1353,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Apple Pixlet"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_FMVC, +.type = AVMEDIA_TYPE_VIDEO, +.name = "fmvc", +.long_name = NULL_IF_CONFIG_SMALL("FM Screen Capture Codec"), +.props = AV_CODEC_PROP_LOSSLESS, +}, /* image codecs */ { diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c new file mode 100644 index 000..1c6d9ae --- /dev/null +++ b/libavcodec/fmvc.c @@ -0,0 +1,629 @@ +/* + * FM Screen Capture Codec decoder + * + * 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 + */ + +#include +#include +#include + +#include "avcodec.h" +#include "bytestream.h" +#include "internal.h" + +#define BLOCK_HEIGHT 112u +#define BLOCK_WIDTH 84u + +typedef struct InterBlock { +int w, h; +int size; +int xor; +} InterBlock; + +typedef struct FMVCContext { +GetByteContext gb; +PutByteContext pb; +uint8_t*buffer; +size_t buffer_size; +uint8_t*pbuffer; +size_t pbuffer_size; +int stride; +int bpp; +int yb, xb; +InterBlock *blocks; +int nb_blocks; +} FMVCContext; + +static int decode_type2(GetByteContext *gb, PutByteContext *pb) +{ +unsigned repeat = 0, first = 1, opcode; +int i, len, pos; + +while (bytestream2_get_bytes_left(gb) > 0) { +GetByteContext gbc; + +while (bytestream2_get_bytes_left(gb) > 0) { +if (first) { +first = 0; +if (bytestream2_peek_byte(gb) > 17) { +len = bytestream2_get_byte(gb) - 17; +if (len < 4) { +do { +bytestream2_put_byte(pb, bytestream2_get_byte(gb)); +--len; +} while (len); +opcode = bytestream2_peek_byte(gb); +continue; +} else { +do { +
Re: [FFmpeg-devel] [PATCH 0/9] Merge lazy filter initialization in ffmpeg CLI
On Fri, Feb 10, 2017 at 03:22:28PM +0100, Michael Niedermayer wrote: > On Fri, Feb 10, 2017 at 03:15:29PM +0100, Michael Niedermayer wrote: > > On Fri, Feb 10, 2017 at 01:35:32PM +0100, wm4 wrote: > > > These patches merge the previously skipped Libav commits, which made > > > avconv lazily initialize libavfilter graphs. This means the filters > > > are initialized with the actual output format, instead of whatever > > > libavformat reports. > > > > > > It's a prerequisite to making hardware decoding support saner, as > > > hardware decoders will output a different pixfmt than the software > > > format reported by libavformat. This can be seen on ffmpeg_qsv.c, > > > which doesn't lose any functionality, even though half of the code > > > is removed. > > > > > > There are some differences in how ffmpeg.c and avconv.c filter-flow > > > works. Also, avconv.c doesn't have sub2video. Relatively intrusive > > > changes were required. > > > > > > The status of cuvid is unknown, but work in progress. > > > > > > Anton Khirnov (4): > > > ffmpeg: do packet ts rescaling in write_packet() > > > ffmpeg: init filtergraphs only after we have a frame on each input > > > ffmpeg: move flushing the queued frames to configure_filtergraph() > > > ffmpeg: restructure sending EOF to filters > > > > > > Timo Rothenpieler (3): > > > ffmpeg_cuvid: adapt for recent filter graph initialization changes > > > avcodec/cuvid: add format mismatch debug logs > > > avcodec/cuvid: update hw_frames_ctx reference after get_format call > > > > > > wm4 (2): > > > ffmpeg: make sure packets put into the muxing FIFO are refcounted > > > ffmpeg: fix printing of filter input/output names > > > > This patchset breaks > > ./ffmpeg -i Voting_Machine.wmv test.avi > > > > http://data.onas.ru/fun-clips/Voting_Machine.wmv > > > > didnt bisect which patch causes it > > heres another example: > > ./ffmpeg -i ~/tickets/4329/bogus_video.mp4 -vframes 5 -vf crop=720:404 > out.mov > ./ffplay out.mov > before this patchset out.mov had an audio stream sample seems to be here: http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4329/ [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness enter who devote themselves to the Knowledge alone. -- Isha Upanishad signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 0/9] Merge lazy filter initialization in ffmpeg CLI
On Fri, Feb 10, 2017 at 03:15:29PM +0100, Michael Niedermayer wrote: > On Fri, Feb 10, 2017 at 01:35:32PM +0100, wm4 wrote: > > These patches merge the previously skipped Libav commits, which made > > avconv lazily initialize libavfilter graphs. This means the filters > > are initialized with the actual output format, instead of whatever > > libavformat reports. > > > > It's a prerequisite to making hardware decoding support saner, as > > hardware decoders will output a different pixfmt than the software > > format reported by libavformat. This can be seen on ffmpeg_qsv.c, > > which doesn't lose any functionality, even though half of the code > > is removed. > > > > There are some differences in how ffmpeg.c and avconv.c filter-flow > > works. Also, avconv.c doesn't have sub2video. Relatively intrusive > > changes were required. > > > > The status of cuvid is unknown, but work in progress. > > > > Anton Khirnov (4): > > ffmpeg: do packet ts rescaling in write_packet() > > ffmpeg: init filtergraphs only after we have a frame on each input > > ffmpeg: move flushing the queued frames to configure_filtergraph() > > ffmpeg: restructure sending EOF to filters > > > > Timo Rothenpieler (3): > > ffmpeg_cuvid: adapt for recent filter graph initialization changes > > avcodec/cuvid: add format mismatch debug logs > > avcodec/cuvid: update hw_frames_ctx reference after get_format call > > > > wm4 (2): > > ffmpeg: make sure packets put into the muxing FIFO are refcounted > > ffmpeg: fix printing of filter input/output names > > This patchset breaks > ./ffmpeg -i Voting_Machine.wmv test.avi > > http://data.onas.ru/fun-clips/Voting_Machine.wmv > > didnt bisect which patch causes it heres another example: ./ffmpeg -i ~/tickets/4329/bogus_video.mp4 -vframes 5 -vf crop=720:404 out.mov ./ffplay out.mov before this patchset out.mov had an audio stream [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If a bugfix only changes things apparently unrelated to the bug with no further explanation, that is a good sign that the bugfix is wrong. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 0/9] Merge lazy filter initialization in ffmpeg CLI
On Fri, Feb 10, 2017 at 01:35:32PM +0100, wm4 wrote: > These patches merge the previously skipped Libav commits, which made > avconv lazily initialize libavfilter graphs. This means the filters > are initialized with the actual output format, instead of whatever > libavformat reports. > > It's a prerequisite to making hardware decoding support saner, as > hardware decoders will output a different pixfmt than the software > format reported by libavformat. This can be seen on ffmpeg_qsv.c, > which doesn't lose any functionality, even though half of the code > is removed. > > There are some differences in how ffmpeg.c and avconv.c filter-flow > works. Also, avconv.c doesn't have sub2video. Relatively intrusive > changes were required. > > The status of cuvid is unknown, but work in progress. > > Anton Khirnov (4): > ffmpeg: do packet ts rescaling in write_packet() > ffmpeg: init filtergraphs only after we have a frame on each input > ffmpeg: move flushing the queued frames to configure_filtergraph() > ffmpeg: restructure sending EOF to filters > > Timo Rothenpieler (3): > ffmpeg_cuvid: adapt for recent filter graph initialization changes > avcodec/cuvid: add format mismatch debug logs > avcodec/cuvid: update hw_frames_ctx reference after get_format call > > wm4 (2): > ffmpeg: make sure packets put into the muxing FIFO are refcounted > ffmpeg: fix printing of filter input/output names This patchset breaks ./ffmpeg -i Voting_Machine.wmv test.avi http://data.onas.ru/fun-clips/Voting_Machine.wmv didnt bisect which patch causes it [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The greatest way to live with honor in this world is to be what we pretend to be. -- Socrates signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 0/9] Merge lazy filter initialization in ffmpeg CLI
On Fri, 10 Feb 2017 13:55:39 +0100 Timo Rothenpieler wrote: > Am 10.02.2017 um 13:35 schrieb wm4: > > These patches merge the previously skipped Libav commits, which made > > avconv lazily initialize libavfilter graphs. This means the filters > > are initialized with the actual output format, instead of whatever > > libavformat reports. > > > > It's a prerequisite to making hardware decoding support saner, as > > hardware decoders will output a different pixfmt than the software > > format reported by libavformat. This can be seen on ffmpeg_qsv.c, > > which doesn't lose any functionality, even though half of the code > > is removed. > > > > There are some differences in how ffmpeg.c and avconv.c filter-flow > > works. Also, avconv.c doesn't have sub2video. Relatively intrusive > > changes were required. > > > > The status of cuvid is unknown, but work in progress. > > cuvid itself works. A chain with h264_cuvid -> hwdownload,format=nv12 -> > libx264/nvenc works fine. > Nvenc by itself also still works as usual. > It's just that for some unknown reason direct hw transcoding from > h264_cuvid to nvenc results in nvenc reporting an out of memory error > when encoding the first frame. > I went through all variables I could think of by now, and everything > seems to be in order. So current idea is that nvenc doesn't like being > initialized after cuvid, which doesn't really make sense, but I'll keep > investigating. I want to add that the same with qsv works just fine, which makes this even more strange. I'd argue for fixing this "later" after the merge. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 0/9] Merge lazy filter initialization in ffmpeg CLI
Am 10.02.2017 um 13:35 schrieb wm4: > These patches merge the previously skipped Libav commits, which made > avconv lazily initialize libavfilter graphs. This means the filters > are initialized with the actual output format, instead of whatever > libavformat reports. > > It's a prerequisite to making hardware decoding support saner, as > hardware decoders will output a different pixfmt than the software > format reported by libavformat. This can be seen on ffmpeg_qsv.c, > which doesn't lose any functionality, even though half of the code > is removed. > > There are some differences in how ffmpeg.c and avconv.c filter-flow > works. Also, avconv.c doesn't have sub2video. Relatively intrusive > changes were required. > > The status of cuvid is unknown, but work in progress. cuvid itself works. A chain with h264_cuvid -> hwdownload,format=nv12 -> libx264/nvenc works fine. Nvenc by itself also still works as usual. It's just that for some unknown reason direct hw transcoding from h264_cuvid to nvenc results in nvenc reporting an out of memory error when encoding the first frame. I went through all variables I could think of by now, and everything seems to be in order. So current idea is that nvenc doesn't like being initialized after cuvid, which doesn't really make sense, but I'll keep investigating. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 9/9] avcodec/cuvid: update hw_frames_ctx reference after get_format call
From: Timo Rothenpieler --- libavcodec/cuvid.c | 13 + 1 file changed, 13 insertions(+) diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c index 6091d81d3b..463c0dbf49 100644 --- a/libavcodec/cuvid.c +++ b/libavcodec/cuvid.c @@ -136,6 +136,19 @@ static int CUDAAPI cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* form return 0; } +// Update our hwframe ctx, as the get_format callback might have refreshed it! +if (avctx->hw_frames_ctx) { +av_buffer_unref(&ctx->hwframe); + +ctx->hwframe = av_buffer_ref(avctx->hw_frames_ctx); +if (!ctx->hwframe) { +ctx->internal_error = AVERROR(ENOMEM); +return 0; +} + +hwframe_ctx = (AVHWFramesContext*)ctx->hwframe->data; +} + av_log(avctx, AV_LOG_VERBOSE, "Formats: Original: %s | HW: %s | SW: %s\n", av_get_pix_fmt_name(avctx->pix_fmt), av_get_pix_fmt_name(surface_fmt), -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 8/9] avcodec/cuvid: add format mismatch debug logs
From: Timo Rothenpieler --- libavcodec/cuvid.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c index 9b35476f2a..6091d81d3b 100644 --- a/libavcodec/cuvid.c +++ b/libavcodec/cuvid.c @@ -193,6 +193,11 @@ static int CUDAAPI cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* form hwframe_ctx->format != AV_PIX_FMT_CUDA || hwframe_ctx->sw_format != avctx->sw_pix_fmt)) { av_log(avctx, AV_LOG_ERROR, "AVHWFramesContext is already initialized with incompatible parameters\n"); +av_log(avctx, AV_LOG_DEBUG, "width: %d <-> %d\n", hwframe_ctx->width, avctx->width); +av_log(avctx, AV_LOG_DEBUG, "height: %d <-> %d\n", hwframe_ctx->height, avctx->height); +av_log(avctx, AV_LOG_DEBUG, "format: %s <-> cuda\n", av_get_pix_fmt_name(hwframe_ctx->format)); +av_log(avctx, AV_LOG_DEBUG, "sw_format: %s <-> %s\n", + av_get_pix_fmt_name(hwframe_ctx->sw_format), av_get_pix_fmt_name(avctx->sw_pix_fmt)); ctx->internal_error = AVERROR(EINVAL); return 0; } -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 4/9] ffmpeg: fix printing of filter input/output names
Broken by the previous Libav commit (even in Libav, thus a separate commit). Signed-off-by: wm4 --- ffmpeg_filter.c | 44 +--- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c index 8490f4a455..f21a8c85f8 100644 --- a/ffmpeg_filter.c +++ b/ffmpeg_filter.c @@ -230,6 +230,25 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) return 0; } +static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in) +{ +AVFilterContext *ctx = inout->filter_ctx; +AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads; +int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs; +AVIOContext *pb; +uint8_t *res = NULL; + +if (avio_open_dyn_buf(&pb) < 0) +exit_program(1); + +avio_printf(pb, "%s", ctx->filter->name); +if (nb_pads > 1) +avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx)); +avio_w8(pb, 0); +avio_close_dyn_buf(pb, &res); +return res; +} + static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) { InputStream *ist = NULL; @@ -300,6 +319,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) fg->inputs[fg->nb_inputs - 1]->graph = fg; fg->inputs[fg->nb_inputs - 1]->format = -1; fg->inputs[fg->nb_inputs - 1]->type = ist->st->codecpar->codec_type; +fg->inputs[fg->nb_inputs - 1]->name = describe_filter_link(fg, in, 1); fg->inputs[fg->nb_inputs - 1]->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*)); if (!fg->inputs[fg->nb_inputs - 1]->frame_queue) @@ -338,6 +358,7 @@ int init_complex_filtergraph(FilterGraph *fg) fg->outputs[fg->nb_outputs - 1]->out_tmp = cur; fg->outputs[fg->nb_outputs - 1]->type= avfilter_pad_get_type(cur->filter_ctx->output_pads, cur->pad_idx); +fg->outputs[fg->nb_outputs - 1]->name = describe_filter_link(fg, cur, 0); cur = cur->next; fg->outputs[fg->nb_outputs - 1]->out_tmp->next = NULL; } @@ -643,28 +664,8 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, return 0; } -#define DESCRIBE_FILTER_LINK(f, inout, in) \ -{ \ -AVFilterContext *ctx = inout->filter_ctx; \ -AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads; \ -int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs; \ -AVIOContext *pb; \ - \ -if (avio_open_dyn_buf(&pb) < 0)\ -exit_program(1); \ - \ -avio_printf(pb, "%s", ctx->filter->name); \ -if (nb_pads > 1) \ -avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx));\ -avio_w8(pb, 0);\ -avio_close_dyn_buf(pb, &f->name); \ -} - int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out) { -av_freep(&ofilter->name); -DESCRIBE_FILTER_LINK(ofilter, out, 0); - if (!ofilter->ost) { av_log(NULL, AV_LOG_FATAL, "Filter %s has an unconnected output\n", ofilter->name); exit_program(1); @@ -970,9 +971,6 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, static int configure_input_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in) { -av_freep(&ifilter->name); -DESCRIBE_FILTER_LINK(ifilter, in, 1); - if (!ifilter->ist->dec) { av_log(NULL, AV_LOG_ERROR, "No decoder for stream #%d:%d, filtering impossible\n", -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 5/9] ffmpeg: move flushing the queued frames to configure_filtergraph()
From: Anton Khirnov This is a more appropriate place for it, and will also be useful in the following commit. This merges Libav commit d2e56cf. It was previously skipped. Signed-off-by: wm4 --- ffmpeg.c| 11 --- ffmpeg_filter.c | 11 +++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index a3d36a76a7..f816808489 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2137,17 +2137,6 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) av_log(NULL, AV_LOG_ERROR, "Error reinitializing filters!\n"); return ret; } - -for (i = 0; i < fg->nb_inputs; i++) { -while (av_fifo_size(fg->inputs[i]->frame_queue)) { -AVFrame *tmp; -av_fifo_generic_read(fg->inputs[i]->frame_queue, &tmp, sizeof(tmp), NULL); -ret = av_buffersrc_add_frame(fg->inputs[i]->filter, tmp); -av_frame_free(&tmp); -if (ret < 0) -return ret; -} -} } ret = av_buffersrc_add_frame(ifilter->filter, frame); diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c index f21a8c85f8..4d9a4e2eb8 100644 --- a/ffmpeg_filter.c +++ b/ffmpeg_filter.c @@ -1117,6 +1117,17 @@ int configure_filtergraph(FilterGraph *fg) ost->enc_ctx->frame_size); } +for (i = 0; i < fg->nb_inputs; i++) { +while (av_fifo_size(fg->inputs[i]->frame_queue)) { +AVFrame *tmp; +av_fifo_generic_read(fg->inputs[i]->frame_queue, &tmp, sizeof(tmp), NULL); +ret = av_buffersrc_add_frame(fg->inputs[i]->filter, tmp); +av_frame_free(&tmp); +if (ret < 0) +return ret; +} +} + return 0; } -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 6/9] ffmpeg: restructure sending EOF to filters
From: Anton Khirnov Be more careful when an input stream encounters EOF when its filtergraph has not been configured yet. The current code would immediately mark the corresponding output streams as finished, while there may still be buffered frames waiting for frames to appear on other filtergraph inputs. This should fix the random FATE failures for complex filtergraph tests after a3a0230a9870b9018dc7415ae5872784d524cfe5 This merges Libav commit 94ebf55. It was previously skipped. This is the last filter init related Libav commit that was skipped, so this also removes the commits from doc/libav-merge.txt. Signed-off-by: wm4 --- doc/libav-merge.txt | 1 - ffmpeg.c| 43 --- ffmpeg.h| 2 ++ ffmpeg_filter.c | 9 + 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/doc/libav-merge.txt b/doc/libav-merge.txt index 23b48d1e2b..39d846f8fc 100644 --- a/doc/libav-merge.txt +++ b/doc/libav-merge.txt @@ -95,7 +95,6 @@ Stuff that didn't reach the codebase: - 0cef06df0 checkasm: add HEVC MC tests - e7078e842 hevcdsp: add x86 SIMD for MC - QSV scaling filter (62c58c5) -- ffmpeg.c filter init decoupling (3e265ca,a3a0230,d2e56cf,94ebf55) Collateral damage that needs work locally: -- diff --git a/ffmpeg.c b/ffmpeg.c index f816808489..97d0946b6b 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2148,6 +2148,34 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) return 0; } +static int ifilter_send_eof(InputFilter *ifilter) +{ +int i, j, ret; + +ifilter->eof = 1; + +if (ifilter->filter) { +ret = av_buffersrc_add_frame(ifilter->filter, NULL); +if (ret < 0) +return ret; +} else { +// the filtergraph was never configured +FilterGraph *fg = ifilter->graph; +for (i = 0; i < fg->nb_inputs; i++) +if (!fg->inputs[i]->eof) +break; +if (i == fg->nb_inputs) { +// All the input streams have finished without the filtergraph +// ever being configured. +// Mark the output streams as finished. +for (j = 0; j < fg->nb_outputs; j++) +finish_output_stream(fg->outputs[j]->ost); +} +} + +return 0; +} + // This does not quite work like avcodec_decode_audio4/avcodec_decode_video2. // There is the following difference: if you got a frame, you must call // it again with pkt=NULL. pkt==NULL is treated differently from pkt.size==0 @@ -2449,18 +2477,11 @@ out: static int send_filter_eof(InputStream *ist) { -int i, j, ret; +int i, ret; for (i = 0; i < ist->nb_filters; i++) { -if (ist->filters[i]->filter) { -ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL); -if (ret < 0) -return ret; -} else { -// the filtergraph was never configured -FilterGraph *fg = ist->filters[i]->graph; -for (j = 0; j < fg->nb_outputs; j++) -finish_output_stream(fg->outputs[j]->ost); -} +ret = ifilter_send_eof(ist->filters[i]); +if (ret < 0) +return ret; } return 0; } diff --git a/ffmpeg.h b/ffmpeg.h index 11ad15b04e..7a807e1ab9 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -248,6 +248,8 @@ typedef struct InputFilter { uint64_t channel_layout; AVBufferRef *hw_frames_ctx; + +int eof; } InputFilter; typedef struct OutputFilter { diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c index 4d9a4e2eb8..816c906c7e 100644 --- a/ffmpeg_filter.c +++ b/ffmpeg_filter.c @@ -1128,6 +1128,15 @@ int configure_filtergraph(FilterGraph *fg) } } +/* send the EOFs for the finished inputs */ +for (i = 0; i < fg->nb_inputs; i++) { +if (fg->inputs[i]->eof) { +ret = av_buffersrc_add_frame(fg->inputs[i]->filter, NULL); +if (ret < 0) +return ret; +} +} + return 0; } -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 3/9] ffmpeg: init filtergraphs only after we have a frame on each input
From: Anton Khirnov This makes sure the actual stream parameters are used, which is important mainly for hardware decoding+filtering cases, which would previously require various weird workarounds to handle the fact that a fake software graph has to be constructed, but never used. This should also improve behaviour in rare cases where avformat_find_stream_info() does not provide accurate information. This merges Libav commit a3a0230. It was previously skipped. The vp8-size-change gives different result, because now the size of the first frame is used. libavformat reported the size of the largest frame for some reason. The exr tests now use the sample aspect ratio of the first frame. For some reason libavformat determines 0/1 as aspect ratio, while the decoder returns the correct one. The ffm and mxf tests change the field_order values. I'm assuming another libavformat/decoding mismatch. Signed-off-by: wm4 --- ffmpeg.c | 284 - ffmpeg.h | 15 +- ffmpeg_cuvid.c | 1 - ffmpeg_filter.c| 48 ++-- ffmpeg_opt.c | 44 ffmpeg_qsv.c | 82 -- .../fate/exr-rgb-scanline-pxr24-half-uint32-13x9 | 2 +- .../fate/exr-rgba-scanline-float-half-b44-12x8-l1 | 2 +- .../fate/exr-rgba-scanline-float-half-b44-12x8-l2 | 2 +- .../fate/exr-rgba-scanline-float-half-b44-13x9-l1 | 2 +- .../fate/exr-rgba-scanline-float-half-b44-13x9-l2 | 2 +- .../fate/exr-rgba-scanline-float-half-b44a-12x8-l1 | 2 +- .../fate/exr-rgba-scanline-float-half-b44a-12x8-l2 | 2 +- .../fate/exr-rgba-scanline-float-half-b44a-13x9-l1 | 2 +- .../fate/exr-rgba-scanline-float-half-b44a-13x9-l2 | 2 +- tests/ref/fate/vp8-size-change | 62 ++--- tests/ref/lavf/ffm | 2 +- tests/ref/lavf/mxf | 6 +- 18 files changed, 225 insertions(+), 337 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 8b829beb34..a3d36a76a7 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -472,6 +472,13 @@ static void ffmpeg_cleanup(int ret) FilterGraph *fg = filtergraphs[i]; avfilter_graph_free(&fg->graph); for (j = 0; j < fg->nb_inputs; j++) { +while (av_fifo_size(fg->inputs[j]->frame_queue)) { +AVFrame *frame; +av_fifo_generic_read(fg->inputs[j]->frame_queue, &frame, + sizeof(frame), NULL); +av_frame_free(&frame); +} +av_fifo_free(fg->inputs[j]->frame_queue); av_buffer_unref(&fg->inputs[j]->hw_frames_ctx); av_freep(&fg->inputs[j]->name); av_freep(&fg->inputs[j]); @@ -1377,6 +1384,8 @@ static void do_video_stats(OutputStream *ost, int frame_size) } } +static int init_output_stream(OutputStream *ost, char *error, int error_len); + static void finish_output_stream(OutputStream *ost) { OutputFile *of = output_files[ost->file_index]; @@ -1409,10 +1418,20 @@ static int reap_filters(int flush) AVCodecContext *enc = ost->enc_ctx; int ret = 0; -if (!ost->filter) +if (!ost->filter || !ost->filter->graph->graph) continue; filter = ost->filter->filter; +if (!ost->initialized) { +char error[1024]; +ret = init_output_stream(ost, error, sizeof(error)); +if (ret < 0) { +av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n", + ost->file_index, ost->index, error); +exit_program(1); +} +} + if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) { return AVERROR(ENOMEM); } @@ -2044,6 +2063,102 @@ static void check_decode_result(InputStream *ist, int *got_output, int ret) } } +// Filters can be configured only if the formats of all inputs are known. +static int ifilter_has_all_input_formats(FilterGraph *fg) +{ +int i; +for (i = 0; i < fg->nb_inputs; i++) { +if (fg->inputs[i]->format < 0 && (fg->inputs[i]->type == AVMEDIA_TYPE_AUDIO || + fg->inputs[i]->type == AVMEDIA_TYPE_VIDEO)) +return 0; +} +return 1; +} + +static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) +{ +FilterGraph *fg = ifilter->graph; +int need_reinit, ret, i; + +/* determine if the parameters for this input changed */ +need_reinit = ifilter->format != frame->format; +if (!!ifilter->hw_frames_ctx != !!frame->hw_frames_ctx || +(ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data)) +need_reinit = 1; + +switch (ifilter->ist->st->codecpar->codec_type) { +
[FFmpeg-devel] [PATCH 7/9] ffmpeg_cuvid: adapt for recent filter graph initialization changes
From: Timo Rothenpieler --- ffmpeg.c | 13 -- ffmpeg.h | 1 - ffmpeg_cuvid.c | 141 - 3 files changed, 30 insertions(+), 125 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 97d0946b6b..eeb3d210b0 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3491,19 +3491,6 @@ static int transcode_init(void) input_streams[j + ifile->ist_index]->start = av_gettime_relative(); } -/* hwaccel transcoding */ -for (i = 0; i < nb_output_streams; i++) { -ost = output_streams[i]; - -if (!ost->stream_copy) { - -#if CONFIG_CUVID -if (cuvid_transcode_init(ost)) -exit_program(1); -#endif -} -} - /* init input streams */ for (i = 0; i < nb_input_streams; i++) if ((ret = init_input_stream(i, error, sizeof(error))) < 0) { diff --git a/ffmpeg.h b/ffmpeg.h index 7a807e1ab9..6ede1dcd7b 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -646,6 +646,5 @@ int qsv_init(AVCodecContext *s); int vaapi_decode_init(AVCodecContext *avctx); int vaapi_device_init(const char *device); int cuvid_init(AVCodecContext *s); -int cuvid_transcode_init(OutputStream *ost); #endif /* FFMPEG_H */ diff --git a/ffmpeg_cuvid.c b/ffmpeg_cuvid.c index 46540795d4..3ff3b40f17 100644 --- a/ffmpeg_cuvid.c +++ b/ffmpeg_cuvid.c @@ -17,138 +17,57 @@ */ #include "libavutil/hwcontext.h" +#include "libavutil/pixdesc.h" #include "ffmpeg.h" -typedef struct CUVIDContext { -AVBufferRef *hw_frames_ctx; -} CUVIDContext; - static void cuvid_uninit(AVCodecContext *avctx) { -InputStream *ist = avctx->opaque; -CUVIDContext *ctx = ist->hwaccel_ctx; - -if (ctx) { -av_buffer_unref(&ctx->hw_frames_ctx); -av_freep(&ctx); -} - +InputStream *ist = avctx->opaque; av_buffer_unref(&ist->hw_frames_ctx); - -ist->hwaccel_ctx = 0; -ist->hwaccel_uninit = 0; } int cuvid_init(AVCodecContext *avctx) { -InputStream *ist = avctx->opaque; -CUVIDContext *ctx = ist->hwaccel_ctx; - -av_log(NULL, AV_LOG_TRACE, "Initializing cuvid hwaccel\n"); - -if (!ctx) { -av_log(NULL, AV_LOG_ERROR, "CUVID transcoding is not initialized. " - "-hwaccel cuvid should only be used for one-to-one CUVID transcoding " - "with no (software) filters.\n"); -return AVERROR(EINVAL); -} - -return 0; -} - -int cuvid_transcode_init(OutputStream *ost) -{ -InputStream *ist; -const enum AVPixelFormat *pix_fmt; -AVHWFramesContext *hwframe_ctx; -AVBufferRef *device_ref = NULL; -CUVIDContext *ctx = NULL; -int ret = 0; - -av_log(NULL, AV_LOG_TRACE, "Initializing cuvid transcoding\n"); +InputStream *ist = avctx->opaque; +AVHWFramesContext *frames_ctx; +int ret; -if (ost->source_index < 0) -return 0; +av_log(avctx, AV_LOG_VERBOSE, "Initializing cuvid hwaccel\n"); -ist = input_streams[ost->source_index]; - -/* check if the encoder supports CUVID */ -if (!ost->enc->pix_fmts) -goto cancel; -for (pix_fmt = ost->enc->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++) -if (*pix_fmt == AV_PIX_FMT_CUDA) -break; -if (*pix_fmt == AV_PIX_FMT_NONE) -goto cancel; - -/* check if the decoder supports CUVID */ -if (ist->hwaccel_id != HWACCEL_CUVID || !ist->dec || !ist->dec->pix_fmts) -goto cancel; -for (pix_fmt = ist->dec->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++) -if (*pix_fmt == AV_PIX_FMT_CUDA) -break; -if (*pix_fmt == AV_PIX_FMT_NONE) -goto cancel; - -av_log(NULL, AV_LOG_VERBOSE, "Setting up CUVID transcoding\n"); - -if (ist->hwaccel_ctx) { -ctx = ist->hwaccel_ctx; -} else { -ctx = av_mallocz(sizeof(*ctx)); -if (!ctx) { -ret = AVERROR(ENOMEM); -goto error; +if (!hw_device_ctx) { +ret = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_CUDA, + ist->hwaccel_device, NULL, 0); +if (ret < 0) { +av_log(avctx, AV_LOG_ERROR, "Error creating a CUDA device\n"); +return ret; } } -if (!ctx->hw_frames_ctx) { -ret = av_hwdevice_ctx_create(&device_ref, AV_HWDEVICE_TYPE_CUDA, - ist->hwaccel_device, NULL, 0); -if (ret < 0) -goto error; +av_buffer_unref(&ist->hw_frames_ctx); +ist->hw_frames_ctx = av_hwframe_ctx_alloc(hw_device_ctx); +if (!ist->hw_frames_ctx) { +av_log(avctx, AV_LOG_ERROR, "Error creating a CUDA frames context\n"); +return AVERROR(ENOMEM); +} -ctx->hw_frames_ctx = av_hwframe_ctx_alloc(device_ref); -if (!ctx->hw_frames_ctx) { -av_log(NULL, AV_LOG_ERROR, "av_hwframe_ctx_alloc failed\n"); -ret = AVERROR(ENOMEM); -goto error; -} -av_buffer_unref(&device_ref
[FFmpeg-devel] [PATCH 2/9] ffmpeg: do packet ts rescaling in write_packet()
From: Anton Khirnov This will be useful in the following commit, after which the muxer timebase is not always available when encoding. This merges Libav commit 3e265ca. It was previously skipped. There is a minor change with setting the mux_timebase field only after the muxer's write_header function has been called, because it can readjust the timebase. Includes a minor merge fix by Mark Thompson. Signed-off-by: wm4 --- ffmpeg.c | 39 ++- ffmpeg.h | 2 ++ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 913c18d92b..8b829beb34 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -713,7 +713,7 @@ static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost) if (pkt->duration > 0) av_log(NULL, AV_LOG_WARNING, "Overriding packet duration by frame rate, this should not happen\n"); pkt->duration = av_rescale_q(1, av_inv_q(ost->frame_rate), - ost->st->time_base); + ost->mux_timebase); } } @@ -759,6 +759,8 @@ static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost) pkt->stream_index = ost->index; +av_packet_rescale_ts(pkt, ost->mux_timebase, ost->st->time_base); + if (debug_ts) { av_log(NULL, AV_LOG_INFO, "muxer <- type:%s " "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s size:%d\n", @@ -907,13 +909,13 @@ static void do_audio_out(OutputFile *of, OutputStream *ost, update_benchmark("encode_audio %d.%d", ost->file_index, ost->index); -av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base); +av_packet_rescale_ts(&pkt, enc->time_base, ost->mux_timebase); if (debug_ts) { av_log(NULL, AV_LOG_INFO, "encoder -> type:audio " "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n", - av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base), - av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base)); + av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &enc->time_base), + av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &enc->time_base)); } output_packet(of, &pkt, ost); @@ -993,8 +995,8 @@ static void do_subtitle_out(OutputFile *of, av_init_packet(&pkt); pkt.data = subtitle_out; pkt.size = subtitle_out_size; -pkt.pts = av_rescale_q(sub->pts, AV_TIME_BASE_Q, ost->st->time_base); -pkt.duration = av_rescale_q(sub->end_display_time, (AVRational){ 1, 1000 }, ost->st->time_base); +pkt.pts = av_rescale_q(sub->pts, AV_TIME_BASE_Q, ost->mux_timebase); +pkt.duration = av_rescale_q(sub->end_display_time, (AVRational){ 1, 1000 }, ost->mux_timebase); if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) { /* XXX: the pts correction is handled here. Maybe handling it in the codec would be better */ @@ -1187,7 +1189,7 @@ static void do_video_out(OutputFile *of, mux_par->field_order = AV_FIELD_PROGRESSIVE; pkt.data = (uint8_t *)in_picture; pkt.size = sizeof(AVPicture); -pkt.pts= av_rescale_q(in_picture->pts, enc->time_base, ost->st->time_base); +pkt.pts= av_rescale_q(in_picture->pts, enc->time_base, ost->mux_timebase); pkt.flags |= AV_PKT_FLAG_KEY; output_packet(of, &pkt, ost); @@ -1283,13 +1285,13 @@ static void do_video_out(OutputFile *of, if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & AV_CODEC_CAP_DELAY)) pkt.pts = ost->sync_opts; -av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base); +av_packet_rescale_ts(&pkt, enc->time_base, ost->mux_timebase); if (debug_ts) { av_log(NULL, AV_LOG_INFO, "encoder -> type:video " "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n", -av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base), -av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base)); +av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->mux_timebase), +av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->mux_timebase)); } frame_size = pkt.size; @@ -1862,8 +1864,8 @@ static void flush_encoders(void) av_packet_unref(&pkt); continue; } -av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base); pkt_size = pkt.size; +av_packet_rescale_ts(&pkt, enc->time_base, ost->mux_timebase); output_packet(of, &pkt, ost); if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename) { d
[FFmpeg-devel] [PATCH 1/9] ffmpeg: make sure packets put into the muxing FIFO are refcounted
Some callers (like do_subtitle_out()) call this with an AVPacket that is not refcounted. This can cause undefined behavior. Calling av_packet_move_ref() does not make a packet refcounted if it isn't yet. (And it can't be made to, because it always succeeds, and can't return ENOMEM.) Call av_packet_ref() instead to make sure it's refcounted. I couldn't find a case that is fixed by this with the current code. But it will fix the fate-pva-demux test with the later patches applied. Signed-off-by: wm4 --- ffmpeg.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 06570c0dd0..913c18d92b 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -654,7 +654,7 @@ static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost) int ret; if (!of->header_written) { -AVPacket tmp_pkt; +AVPacket tmp_pkt = {0}; /* the muxer is not initialized yet, buffer the packet */ if (!av_fifo_space(ost->muxing_queue)) { int new_size = FFMIN(2 * av_fifo_size(ost->muxing_queue), @@ -669,8 +669,11 @@ static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost) if (ret < 0) exit_program(1); } -av_packet_move_ref(&tmp_pkt, pkt); +ret = av_packet_ref(&tmp_pkt, pkt); +if (ret < 0) +exit_program(1); av_fifo_generic_write(ost->muxing_queue, &tmp_pkt, sizeof(tmp_pkt), NULL); +av_packet_unref(pkt); return; } -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 0/9] Merge lazy filter initialization in ffmpeg CLI
These patches merge the previously skipped Libav commits, which made avconv lazily initialize libavfilter graphs. This means the filters are initialized with the actual output format, instead of whatever libavformat reports. It's a prerequisite to making hardware decoding support saner, as hardware decoders will output a different pixfmt than the software format reported by libavformat. This can be seen on ffmpeg_qsv.c, which doesn't lose any functionality, even though half of the code is removed. There are some differences in how ffmpeg.c and avconv.c filter-flow works. Also, avconv.c doesn't have sub2video. Relatively intrusive changes were required. The status of cuvid is unknown, but work in progress. Anton Khirnov (4): ffmpeg: do packet ts rescaling in write_packet() ffmpeg: init filtergraphs only after we have a frame on each input ffmpeg: move flushing the queued frames to configure_filtergraph() ffmpeg: restructure sending EOF to filters Timo Rothenpieler (3): ffmpeg_cuvid: adapt for recent filter graph initialization changes avcodec/cuvid: add format mismatch debug logs avcodec/cuvid: update hw_frames_ctx reference after get_format call wm4 (2): ffmpeg: make sure packets put into the muxing FIFO are refcounted ffmpeg: fix printing of filter input/output names doc/libav-merge.txt| 1 - ffmpeg.c | 347 - ffmpeg.h | 20 +- ffmpeg_cuvid.c | 142 ++--- ffmpeg_filter.c| 112 +++ ffmpeg_opt.c | 44 --- ffmpeg_qsv.c | 82 - libavcodec/cuvid.c | 18 ++ .../fate/exr-rgb-scanline-pxr24-half-uint32-13x9 | 2 +- .../fate/exr-rgba-scanline-float-half-b44-12x8-l1 | 2 +- .../fate/exr-rgba-scanline-float-half-b44-12x8-l2 | 2 +- .../fate/exr-rgba-scanline-float-half-b44-13x9-l1 | 2 +- .../fate/exr-rgba-scanline-float-half-b44-13x9-l2 | 2 +- .../fate/exr-rgba-scanline-float-half-b44a-12x8-l1 | 2 +- .../fate/exr-rgba-scanline-float-half-b44a-12x8-l2 | 2 +- .../fate/exr-rgba-scanline-float-half-b44a-13x9-l1 | 2 +- .../fate/exr-rgba-scanline-float-half-b44a-13x9-l2 | 2 +- tests/ref/fate/vp8-size-change | 62 ++-- tests/ref/lavf/ffm | 2 +- tests/ref/lavf/mxf | 6 +- 20 files changed, 352 insertions(+), 502 deletions(-) -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] doc: add-muxers-demuxers-list-option
Hi, Attached patch will document the options to list demuxers and muxers Regards, Mulvya 0001-Add-muxers-demuxers-list-option.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Avoid heap allocation wraps and OOB in mov_read_{senc, saiz, udta_string}()
On Thu, Feb 09, 2017 at 04:03:57PM -0800, Matthew Wolenetz wrote: > I've separated and updated the mov_read_{senc,saiz}() patch, attached. > It avoids allocation wraps in those two functions. applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The misfortune of the wise is better than the prosperity of the fool. -- Epicurus signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Avoid heap allocation wraps and OOB in mov_read_{senc, saiz, udta_string}()
On Wed, Feb 08, 2017 at 03:48:19PM -0800, Matthew Wolenetz wrote: > I've separated and updated the mov_read_udta_string() patch, attached. > It prevents accessing MOVContext.meta_keys[0] in that method. That array is > 1-based. applied thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No great genius has ever existed without some touch of madness. -- Aristotle signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel