[FFmpeg-devel] [PATCH] trailing padding
Patches attached, ffmpeg.c should really not ignore initial padding and trailing padding. From 6fc1c0dfcfe5203355423d658f21a8f6c7cbfe83 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 12 Jan 2023 09:56:57 +0100 Subject: [PATCH 1/2] avformat/dtshddec: also read trailing padding in samples Signed-off-by: Paul B Mahol --- libavformat/dtshddec.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/dtshddec.c b/libavformat/dtshddec.c index edd02b4561..a3dea0668f 100644 --- a/libavformat/dtshddec.c +++ b/libavformat/dtshddec.c @@ -55,7 +55,7 @@ static int dtshd_read_header(AVFormatContext *s) DTSHDDemuxContext *dtshd = s->priv_data; AVIOContext *pb = s->pb; uint64_t chunk_type, chunk_size; -int64_t duration, data_start; +int64_t duration, orig_nb_samples, data_start; AVStream *st; int ret; char *value; @@ -103,9 +103,12 @@ static int dtshd_read_header(AVFormatContext *s) duration = avio_rb32(pb); // num_frames duration *= avio_rb16(pb); // samples_per_frames st->duration = duration; -avio_skip(pb, 5); +orig_nb_samples = avio_rb32(pb); +orig_nb_samples <<= 8; +orig_nb_samples |= avio_r8(pb); st->codecpar->ch_layout.nb_channels = ff_dca_count_chs_for_mask(avio_rb16(pb)); st->codecpar->initial_padding = avio_rb16(pb); +st->codecpar->trailing_padding = FFMAX(st->duration - orig_nb_samples - st->codecpar->initial_padding, 0); avio_skip(pb, chunk_size - 21); break; case FILEINFO: -- 2.37.2 From 65df8c3945445c0bf80e947b02ef57df7ee34bb5 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 12 Jan 2023 10:07:15 +0100 Subject: [PATCH 2/2] fftools/ffprobe: show trailing_padding too Signed-off-by: Paul B Mahol --- fftools/ffprobe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index c18aee9846..30b786d074 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -3055,6 +3055,7 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id)); print_int("initial_padding", par->initial_padding); +print_int("trailing_padding", par->trailing_padding); break; case AVMEDIA_TYPE_SUBTITLE: -- 2.37.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libswresample: avoid s16p internal processing format
On 1/8/23, Michael Niedermayer wrote: > On Fri, Jan 06, 2023 at 07:04:59PM +0100, Paul B Mahol wrote: >> On Fri, Jan 6, 2023 at 7:01 PM Paul B Mahol wrote: >> >> > >> > >> > On Fri, Jan 6, 2023 at 6:25 PM Michael Niedermayer >> > >> > wrote: >> > >> >> On Thu, Jan 05, 2023 at 11:08:25PM +0100, Paul B Mahol wrote: >> >> > On Thu, Jan 5, 2023 at 9:53 PM Michael Niedermayer < >> >> mich...@niedermayer.cc> >> >> > wrote: >> >> > >> >> > > On Thu, Jan 05, 2023 at 01:44:10PM +0100, Paul B Mahol wrote: >> >> > > > Patch attached. >> >> > > >> >> > > > swresample.c |3 ++- >> >> > > > 1 file changed, 2 insertions(+), 1 deletion(-) >> >> > > > eee7a0685b44aa867562138a2e2437ecb8844612 >> >> > > 0001-libswresample-swresample-avoid-s16p-internal-transfe.patch >> >> > > > From 9c4cd60e2dd41cf98d693c8251f4cfade0807073 Mon Sep 17 >> >> > > > 00:00:00 >> >> 2001 >> >> > > > From: Paul B Mahol >> >> > > > Date: Thu, 5 Jan 2023 13:40:12 +0100 >> >> > > > Subject: [PATCH] libswresample/swresample: avoid s16p internal >> >> transfer >> >> > > format >> >> > > > >> >> > > > Instead use float one by default for sample rate conversions. >> >> > > > The s16p internal transfer format produces visible and hearable >> >> > > > quantization artifacts. >> >> > > >> >> > > When does this occur and why? >> >> > > >> >> > >> >> > It occurs always. Just compare output with 16bit and >> >> > int32/float/double. >> >> > Look at other people report on internet. >> >> > Look at src.infinitewave.ca >> >> >> >> src.infinitewave.ca uses 32bit none of what it shows should touch the >> >> codepath >> >> you change. >> >> >> >> if we look at src.infinitewave.ca for swr we see 2 types of artifacts >> >> 1. Aliassing which is at maybe -120db with the actual signal at 0db >> >>i would like to see some evidence that a human can hear this >> >> >> > >> > For s16p<->s16p it is much lower, around -78dB thus this patch. >> > >> > Also for others and reports for swr its is lower than exact -120dB >> > >> > >> > 2. Reflection and attenuation at the transition frequency >> >> With linear filters there is a tradeof between attenuation of the >> >> passband, reflection of frequencies beyond, latency and so on >> >> You can have a perfect sharp cutoff with no attenuation and no >> >> refelection >> >> that requires a infinitly long filter. And while this looks best in >> >> this >> >> frequency plot, does it actually sound best ? If you can hear -120db >> >> signals you surely would then also hear the ringing long before a >> >> gunshot >> >> from such long filter. >> >> >> > >> One can always change linear FIR to be min phase FIR kernel. > > I certainly would welcome a wider range of filters in swr, if you want to > add > any low delay sinc approximation or in fact i would welcome any filter > you want to add. There is that afdelaysrc filter patch on ML to add FIR coefficient generation for fractional delay audio filter that can be also used as a interpolation FIR filter. And to me it seems better at same number of taps than already used/available ones in soxr and swr. Also I have done prototype of resampling filter using afir filter via custom filters in filtergraph and it operates at similar speeds like soxr (in these very non optimized approach) and providing better/wider frequency output at highest band. > > thx > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > The real ebay dictionary, page 1 > "Used only once"- "Some unspecified defect prevented a second use" > "In good condition" - "Can be repaird by experienced expert" > "As is" - "You wouldnt want it even if you were payed for it, if you knew > ..." > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/6] avcodec/sgidec: do not forget the number of components in read_uncompressed_sgi()
On Thu, Jan 12, 2023 at 01:02:57AM +0100, Andreas Rheinhardt wrote: > Michael Niedermayer: > > Fixes: out of array access > > Fixes: > > 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SGI_fuzzer-6704753329700864 > > Fixes: > > 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SGI_fuzzer-6683986844057600 > > Fixes: > > 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SGI_fuzzer-6697387691474944 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/sgidec.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c > > index 6ff2ee97f6..92083f23de 100644 > > --- a/libavcodec/sgidec.c > > +++ b/libavcodec/sgidec.c > > @@ -159,7 +159,7 @@ static int read_uncompressed_sgi(uint8_t *const out[4], > > const ptrdiff_t stride[4 > > unsigned rowsize = width * bytes_per_channel; > > > > /* Test buffer size. */ > > -if (rowsize * (int64_t)height > bytestream2_get_bytes_left(g)) > > +if (rowsize * (int64_t)height * nb_components > > > bytestream2_get_bytes_left(g)) > > return AVERROR_INVALIDDATA; > > > > for (unsigned z = 0; z < nb_components; z++) { > > LGTM. (Sorry for having forgotten this in > ce4713ea731b9deb0440abe8d8a2a41d2957efc5.) will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Concerning the gods, I have no means of knowing whether they exist or not or of what sort they may be, because of the obscurity of the subject, and the brevity of human life -- Protagoras signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 5/6] avcodec/bonk: Avoid undefined overflow in quant
On Wed, Jan 11, 2023 at 10:06:44PM +0100, Paul B Mahol wrote: > On 1/11/23, Michael Niedermayer wrote: > > Fixes: signed integer overflow: -2889074 * 2048 cannot be represented in > > type 'int' > > Fixes: > > 51363/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BONK_fuzzer-5660734784143360 > > Fixes: > > 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BONK_fuzzer-6617680050520064 > > Fixes: > > 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BONK_fuzzer-6743951854141440 > > > > No check is done for the overflow as this was rejected in last review, see > > the ML > > > > Note: the 2nd and 3rd testcase was assigned by ossfuzz to a unrelated theora > > issue (48567) > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/bonk.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavcodec/bonk.c b/libavcodec/bonk.c > > index 5d736b1563..9e176d5477 100644 > > --- a/libavcodec/bonk.c > > +++ b/libavcodec/bonk.c > > @@ -356,7 +356,7 @@ static int bonk_decode(AVCodecContext *avctx, AVFrame > > *frame, > > sample++; > > } > > > > -sample[0] = predictor_calc_error(s->k, state, s->n_taps, > > s->input_samples[i] * quant); > > +sample[0] = predictor_calc_error(s->k, state, s->n_taps, > > s->input_samples[i] * (unsigned)quant); > > sample++; > > } > > > > -- > > 2.17.1 > > > > LGTM will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 6/6] avcodec/bonk: Check ntaps against buffer size
On Wed, Jan 11, 2023 at 10:06:19PM +0100, Paul B Mahol wrote: > On 1/11/23, Michael Niedermayer wrote: > > Fixes: out of array read > > Fixes: > > 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BONK_fuzzer-6739246658748416 > > > > Note: This issue was assigned to a unrelated theora bug > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/bonk.c | 4 > > 1 file changed, 4 insertions(+) > > > > diff --git a/libavcodec/bonk.c b/libavcodec/bonk.c > > index 9e176d5477..061cc69a58 100644 > > --- a/libavcodec/bonk.c > > +++ b/libavcodec/bonk.c > > @@ -101,6 +101,10 @@ static av_cold int bonk_init(AVCodecContext *avctx) > > s->samples_per_packet = AV_RL16(avctx->extradata + 15); > > if (!s->samples_per_packet) > > return AVERROR(EINVAL); > > + > > +if (s->down_sampling * s->samples_per_packet < s->n_taps) > > +return AVERROR_INVALIDDATA; > > + > > s->max_framesize = s->samples_per_packet * avctx->ch_layout.nb_channels > > * s->down_sampling * 16LL; > > if (s->max_framesize > (INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE) / 8) > > return AVERROR_INVALIDDATA; > > -- > > 2.17.1 > > LGTM will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/6] avcodec/utils: allocate a line more for VC1 and WMV3
On Thu, Jan 12, 2023 at 08:38:08AM +0100, Andreas Rheinhardt wrote: > Michael Niedermayer: > > Fixes: out of array read on 32bit > > Fixes: > > 54857/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5840588224462848 > > > > The chroma MC code reads over the currently allocated frame. > > Alternative fixes would be allocating a few bytes more at the end instead > > of a whole > > line extra or to adjust the threshold where the edge emu code is activated > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/utils.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/libavcodec/utils.c b/libavcodec/utils.c > > index 2b63a498b9..1aa0a05a31 100644 > > --- a/libavcodec/utils.c > > +++ b/libavcodec/utils.c > > @@ -321,6 +321,7 @@ void avcodec_align_dimensions2(AVCodecContext *s, int > > *width, int *height, > > *width = FFALIGN(*width, w_align); > > *height = FFALIGN(*height, h_align); > > if (s->codec_id == AV_CODEC_ID_H264 || s->lowres || > > +s->codec_id == AV_CODEC_ID_VC1 || s->codec_id == AV_CODEC_ID_WMV3 > > || > > s->codec_id == AV_CODEC_ID_VP5 || s->codec_id == AV_CODEC_ID_VP6 > > || > > s->codec_id == AV_CODEC_ID_VP6F || s->codec_id == AV_CODEC_ID_VP6A > > ) { > > Does this only happen on 32bit systems? If so, why? Id have to double check, some of the issues in this set where 32bit specific some not But the x86 codepath has special cases i think for non interpolated cases while the C path which was used in the issue does not. A check could also be added to the C path to not read the next line whan not needed the patch is just folllowing what h264 does thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is what and why we do it that matters, not just one of them. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libswresample: avoid s16p internal processing format
On Sun, Jan 08, 2023 at 04:18:44PM +0100, Paul B Mahol wrote: > On 1/8/23, Michael Niedermayer wrote: > > On Fri, Jan 06, 2023 at 07:01:06PM +0100, Paul B Mahol wrote: > >> On Fri, Jan 6, 2023 at 6:25 PM Michael Niedermayer > >> > >> wrote: > >> > >> > On Thu, Jan 05, 2023 at 11:08:25PM +0100, Paul B Mahol wrote: > >> > > On Thu, Jan 5, 2023 at 9:53 PM Michael Niedermayer < > >> > mich...@niedermayer.cc> > >> > > wrote: > >> > > > >> > > > On Thu, Jan 05, 2023 at 01:44:10PM +0100, Paul B Mahol wrote: > >> > > > > Patch attached. > >> > > > > >> > > > > swresample.c |3 ++- > >> > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > >> > > > > eee7a0685b44aa867562138a2e2437ecb8844612 > >> > > > 0001-libswresample-swresample-avoid-s16p-internal-transfe.patch > >> > > > > From 9c4cd60e2dd41cf98d693c8251f4cfade0807073 Mon Sep 17 00:00:00 > >> > 2001 > >> > > > > From: Paul B Mahol > >> > > > > Date: Thu, 5 Jan 2023 13:40:12 +0100 > >> > > > > Subject: [PATCH] libswresample/swresample: avoid s16p internal > >> > transfer > >> > > > format > >> > > > > > >> > > > > Instead use float one by default for sample rate conversions. > >> > > > > The s16p internal transfer format produces visible and hearable > >> > > > > quantization artifacts. > >> > > > > >> > > > When does this occur and why? > >> > > > > >> > > > >> > > It occurs always. Just compare output with 16bit and > >> > > int32/float/double. > >> > > Look at other people report on internet. > >> > > Look at src.infinitewave.ca > >> > > >> > src.infinitewave.ca uses 32bit none of what it shows should touch the > >> > codepath > >> > you change. > >> > > >> > if we look at src.infinitewave.ca for swr we see 2 types of artifacts > >> > 1. Aliassing which is at maybe -120db with the actual signal at 0db > >> >i would like to see some evidence that a human can hear this > >> > > >> > >> For s16p<->s16p it is much lower, around -78dB thus this patch. > > > > ok but you pointed to the website that apparently uses >=32bit if i trust > > what they write. > > And even if they test this i cannot use that website to replicate the issue > > and the fix > > If one use pure 16bit processing sweep results are even worse. > > Just resample using fltp/dblp/s32p and s16p and compare (it does not > matter what, just not simple sine constant frequencies waves) > > The s16p result is much worse and contains huge quantization noises. > > They are not that obviously easy to hear, but are there, and > difference is > -80dB for dithered 16bit input. > > You can generate and display sweep with/out resampling all with > ffmpeg/ffplay.ffplay -f lavfi -i > aevalsrc="sin(PI*t*t*t*100):s=96000",aresample=44100:tsf=s16p,showspectrum=scale=log:color=cool:overlap=0:fps=25:drange=96:legend=1 > > Play with tsf=values and drange=[96-150] > So, for 16bit input, drange=96 and tsf=s16p looks fine, but that web > pages shows bad results, ok, i see the issue, thanks [...] > >> How so? > >> I really doubt that this patch do that. > > > > I could be missing something but > > int_sample_fmt is set to before 16bit and afterwards 32bit > > and alot of things are using this: > > set_audiodata_fmt(&s->postin, s->int_sample_fmt); > > set_audiodata_fmt(&s->midbuf, s->int_sample_fmt); > > set_audiodata_fmt(&s->preout, s->int_sample_fmt); > > > > rematrix seems using these > > swri_rematrix(s, preout, midbuf, out_count, preout==out); > > ... > > swri_rematrix(s, midbuf, postin, in_count, midbuf==out); > > > > so i assumed that this patch makes a difference for it. Again i could be > > missing > > something > > Yes, but only if sample rates differ the fltp is used instead of s16p > for resampling. yes, i misread the patch so, i do agree that flt is a better default for resampling s16->s16 on modern hw using 16bit coeffs seems an optimization at the wrong place the patch breaks fate though also, i suggest to leave the s16p if either input or output is s8 teh default change is ok, if it doesnt cause bitexactness issues, otherwise it also needs to be done conditional on bitexact flag As a note, if someone is interrested, it should be possible to improve the quantization noise by using some more fancy noise shaping when building the coefficients. That would not reduce the quantization noise but it would spread it out so it would be less audible and vissible. Though thats only really usefull if one actually did hear it. thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Whats the most studid thing your enemy could do ? Blow himself up Whats the most studid thing you could do ? Give up your rights and freedom because your enemy blew himself up. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with s
Re: [FFmpeg-devel] [PATCH] libswresample: avoid s16p internal processing format
On Thu, Jan 12, 2023 at 03:20:06PM +0100, Paul B Mahol wrote: > On 1/8/23, Michael Niedermayer wrote: > > On Fri, Jan 06, 2023 at 07:04:59PM +0100, Paul B Mahol wrote: > >> On Fri, Jan 6, 2023 at 7:01 PM Paul B Mahol wrote: > >> > >> > > >> > > >> > On Fri, Jan 6, 2023 at 6:25 PM Michael Niedermayer > >> > > >> > wrote: > >> > > >> >> On Thu, Jan 05, 2023 at 11:08:25PM +0100, Paul B Mahol wrote: > >> >> > On Thu, Jan 5, 2023 at 9:53 PM Michael Niedermayer < > >> >> mich...@niedermayer.cc> > >> >> > wrote: > >> >> > > >> >> > > On Thu, Jan 05, 2023 at 01:44:10PM +0100, Paul B Mahol wrote: > >> >> > > > Patch attached. > >> >> > > > >> >> > > > swresample.c |3 ++- > >> >> > > > 1 file changed, 2 insertions(+), 1 deletion(-) > >> >> > > > eee7a0685b44aa867562138a2e2437ecb8844612 > >> >> > > 0001-libswresample-swresample-avoid-s16p-internal-transfe.patch > >> >> > > > From 9c4cd60e2dd41cf98d693c8251f4cfade0807073 Mon Sep 17 > >> >> > > > 00:00:00 > >> >> 2001 > >> >> > > > From: Paul B Mahol > >> >> > > > Date: Thu, 5 Jan 2023 13:40:12 +0100 > >> >> > > > Subject: [PATCH] libswresample/swresample: avoid s16p internal > >> >> transfer > >> >> > > format > >> >> > > > > >> >> > > > Instead use float one by default for sample rate conversions. > >> >> > > > The s16p internal transfer format produces visible and hearable > >> >> > > > quantization artifacts. > >> >> > > > >> >> > > When does this occur and why? > >> >> > > > >> >> > > >> >> > It occurs always. Just compare output with 16bit and > >> >> > int32/float/double. > >> >> > Look at other people report on internet. > >> >> > Look at src.infinitewave.ca > >> >> > >> >> src.infinitewave.ca uses 32bit none of what it shows should touch the > >> >> codepath > >> >> you change. > >> >> > >> >> if we look at src.infinitewave.ca for swr we see 2 types of artifacts > >> >> 1. Aliassing which is at maybe -120db with the actual signal at 0db > >> >>i would like to see some evidence that a human can hear this > >> >> > >> > > >> > For s16p<->s16p it is much lower, around -78dB thus this patch. > >> > > >> > Also for others and reports for swr its is lower than exact -120dB > >> > > >> > > >> > 2. Reflection and attenuation at the transition frequency > >> >> With linear filters there is a tradeof between attenuation of the > >> >> passband, reflection of frequencies beyond, latency and so on > >> >> You can have a perfect sharp cutoff with no attenuation and no > >> >> refelection > >> >> that requires a infinitly long filter. And while this looks best in > >> >> this > >> >> frequency plot, does it actually sound best ? If you can hear -120db > >> >> signals you surely would then also hear the ringing long before a > >> >> gunshot > >> >> from such long filter. > >> >> > >> > > >> One can always change linear FIR to be min phase FIR kernel. > > > > I certainly would welcome a wider range of filters in swr, if you want to > > add > > any low delay sinc approximation or in fact i would welcome any filter > > you want to add. > > There is that afdelaysrc filter patch on ML to add FIR coefficient > generation for fractional delay audio filter that can be also used as > a interpolation FIR filter. And to me it seems better at same number > of taps than already used/available ones in soxr and swr. Please add improvments into swr, if you have any! > > Also I have done prototype of resampling filter using afir filter via > custom filters in filtergraph and it operates at similar speeds like > soxr (in these very non optimized approach) and providing better/wider > frequency output at highest band. Can it be added into swr ? thx [...] -- 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: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime
Le 10/01/2023 à 16:45, Paul B Mahol a écrit : > On 1/10/23, Jeffrey CHAPUIS wrote: >> Hello, >> I decided to continue on a simpler path without 'reset/reset_count', it was >> only to experiment anyway, 'limit' is the main goal. >> 'limit' is added to the metadata to control that the result is associated to >> a change at runtime, it's after scaling with bitdetph but that's not really >> a problem (at least for me, we can always store the parameter before any >> alteration). >> >>> +if (!strcmp(cmd, "limit")) { >>> +if (s->limit < 1.0) >>> +s->limit *= (1 << s->bitdepth) - 1; >>> +s->frame_nb = s->reset_count; >>> +} >> Should i remove the if statement here ? or keep it for future change >> eventually. > > Split variables, keep one variable settable by user and unchanged by filter. > >> >> Notes I didn't think about? >> >> Thunderbird altered the patch somehow (remove empty new lines), it's edited >> manually. > > Attach patch instead. > > > Avoid using strcmp to check for this variable change, instead check > with previous and new value in process function. >Here is part of the updated patch, 'limit' exposed in metadata/log is now >coherent with init(). >Like 'limit/limit_user' is of type float, i've used what's done in >av_dict_set_int() to print it as float. >Compare 's->limit_user' and 's->limit' to check for a change instead of >'strcmp'. >Is there anything to adjust ? Forgot to update ref file for fate (full patch attached).From 54758760603a0f976b59bd6f56ceb0d5f70f795c Mon Sep 17 00:00:00 2001 From: Ashyni Date: Mon, 9 Jan 2023 18:45:41 +0100 Subject: [PATCH] avfilter/vf_cropdetect: add ability to change limit at runtime fix: https://trac.ffmpeg.org/ticket/9851 Signed-off-by: Ashyni --- doc/filters.texi | 12 + libavfilter/vf_cropdetect.c| 37 +++-- tests/ref/fate/filter-metadata-cropdetect | 60 +++--- tests/ref/fate/filter-metadata-cropdetect1 | 14 ++--- tests/ref/fate/filter-metadata-cropdetect2 | 14 ++--- 5 files changed, 89 insertions(+), 48 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 9c3233914..0fc562409 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10560,6 +10560,18 @@ ffmpeg -flags2 +export_mvs -i file.mp4 -vf cropdetect=mode=mvedges,metadata=mode @end example @end itemize +@subsection Commands + +This filter supports the following commands: +@table @option +@item limit + +The command accepts the same syntax of the corresponding option. + +If the specified expression is not valid, it is kept at its current +value. +@end table + @anchor{cue} @section cue diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c index 7e985fb27..cabb386d8 100644 --- a/libavfilter/vf_cropdetect.c +++ b/libavfilter/vf_cropdetect.c @@ -39,6 +39,7 @@ typedef struct CropDetectContext { const AVClass *class; int x1, y1, x2, y2; float limit; +float limit_user; int round; int skip; int reset_count; @@ -48,6 +49,7 @@ typedef struct CropDetectContext { int mode; int window_size; int mv_threshold; +int bitdepth; float low, high; uint8_t low_u8, high_u8; uint8_t *filterbuf; @@ -207,8 +209,10 @@ static int config_input(AVFilterLink *inlink) av_image_fill_max_pixsteps(s->max_pixsteps, NULL, desc); +s->bitdepth = desc->comp[0].depth; +s->limit_user = s->limit; if (s->limit < 1.0) -s->limit *= (1 << desc->comp[0].depth) - 1; +s->limit *= (1 << s->bitdepth) - 1; s->x1 = inlink->w - 1; s->y1 = inlink->h - 1; @@ -244,6 +248,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) AVDictionary **metadata; int outliers, last_y; int limit = lrint(s->limit); +char limit_str[22]; const int inw = inlink->w; const int inh = inlink->h; @@ -423,21 +428,44 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) SET_META("lavfi.cropdetect.x", x); SET_META("lavfi.cropdetect.y", y); +snprintf(limit_str, sizeof(limit_str), "%f", s->limit_user); +av_dict_set(metadata, "lavfi.cropdetect.limit", limit_str, 0); + av_log(ctx, AV_LOG_INFO, - "x1:%d x2:%d y1:%d y2:%d w:%d h:%d x:%d y:%d pts:%"PRId64" t:%f crop=%d:%d:%d:%d\n", + "x1:%d x2:%d y1:%d y2:%d w:%d h:%d x:%d y:%d pts:%"PRId64" t:%f limit:%f crop=%d:%d:%d:%d\n", s->x1, s->x2, s->y1, s->y2, w, h, x, y, frame->pts, frame->pts == AV_NOPTS_VALUE ? -1 : frame->pts * av_q2d(inlink->time_base), - w, h, x, y); + s->limit_user, w, h, x, y); } return ff_filter_frame(inlink->dst->outputs[0], frame); } +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, + char *res, int res_len, int flags) +{ +CropDetectContext *s = ctx->priv; +int ret; +
Re: [FFmpeg-devel] [PATCH] libswresample: avoid s16p internal processing format
On 1/12/23, Michael Niedermayer wrote: > On Thu, Jan 12, 2023 at 03:20:06PM +0100, Paul B Mahol wrote: >> On 1/8/23, Michael Niedermayer wrote: >> > On Fri, Jan 06, 2023 at 07:04:59PM +0100, Paul B Mahol wrote: >> >> On Fri, Jan 6, 2023 at 7:01 PM Paul B Mahol wrote: >> >> >> >> > >> >> > >> >> > On Fri, Jan 6, 2023 at 6:25 PM Michael Niedermayer >> >> > >> >> > wrote: >> >> > >> >> >> On Thu, Jan 05, 2023 at 11:08:25PM +0100, Paul B Mahol wrote: >> >> >> > On Thu, Jan 5, 2023 at 9:53 PM Michael Niedermayer < >> >> >> mich...@niedermayer.cc> >> >> >> > wrote: >> >> >> > >> >> >> > > On Thu, Jan 05, 2023 at 01:44:10PM +0100, Paul B Mahol wrote: >> >> >> > > > Patch attached. >> >> >> > > >> >> >> > > > swresample.c |3 ++- >> >> >> > > > 1 file changed, 2 insertions(+), 1 deletion(-) >> >> >> > > > eee7a0685b44aa867562138a2e2437ecb8844612 >> >> >> > > 0001-libswresample-swresample-avoid-s16p-internal-transfe.patch >> >> >> > > > From 9c4cd60e2dd41cf98d693c8251f4cfade0807073 Mon Sep 17 >> >> >> > > > 00:00:00 >> >> >> 2001 >> >> >> > > > From: Paul B Mahol >> >> >> > > > Date: Thu, 5 Jan 2023 13:40:12 +0100 >> >> >> > > > Subject: [PATCH] libswresample/swresample: avoid s16p >> >> >> > > > internal >> >> >> transfer >> >> >> > > format >> >> >> > > > >> >> >> > > > Instead use float one by default for sample rate conversions. >> >> >> > > > The s16p internal transfer format produces visible and >> >> >> > > > hearable >> >> >> > > > quantization artifacts. >> >> >> > > >> >> >> > > When does this occur and why? >> >> >> > > >> >> >> > >> >> >> > It occurs always. Just compare output with 16bit and >> >> >> > int32/float/double. >> >> >> > Look at other people report on internet. >> >> >> > Look at src.infinitewave.ca >> >> >> >> >> >> src.infinitewave.ca uses 32bit none of what it shows should touch >> >> >> the >> >> >> codepath >> >> >> you change. >> >> >> >> >> >> if we look at src.infinitewave.ca for swr we see 2 types of >> >> >> artifacts >> >> >> 1. Aliassing which is at maybe -120db with the actual signal at 0db >> >> >>i would like to see some evidence that a human can hear this >> >> >> >> >> > >> >> > For s16p<->s16p it is much lower, around -78dB thus this patch. >> >> > >> >> > Also for others and reports for swr its is lower than exact -120dB >> >> > >> >> > >> >> > 2. Reflection and attenuation at the transition frequency >> >> >> With linear filters there is a tradeof between attenuation of the >> >> >> passband, reflection of frequencies beyond, latency and so on >> >> >> You can have a perfect sharp cutoff with no attenuation and no >> >> >> refelection >> >> >> that requires a infinitly long filter. And while this looks best in >> >> >> this >> >> >> frequency plot, does it actually sound best ? If you can hear >> >> >> -120db >> >> >> signals you surely would then also hear the ringing long before a >> >> >> gunshot >> >> >> from such long filter. >> >> >> >> >> > >> >> One can always change linear FIR to be min phase FIR kernel. >> > >> > I certainly would welcome a wider range of filters in swr, if you want >> > to >> > add >> > any low delay sinc approximation or in fact i would welcome any filter >> > you want to add. >> >> There is that afdelaysrc filter patch on ML to add FIR coefficient >> generation for fractional delay audio filter that can be also used as >> a interpolation FIR filter. And to me it seems better at same number >> of taps than already used/available ones in soxr and swr. > > Please add improvments into swr, if you have any! > > >> >> Also I have done prototype of resampling filter using afir filter via >> custom filters in filtergraph and it operates at similar speeds like >> soxr (in these very non optimized approach) and providing better/wider >> frequency output at highest band. > > Can it be added into swr ? It will use libavutil/tx.h for convolution. But I need first to research more and write actual code that does out/in sample rate ratio factorization and do lot of benchmarks comparing normal ratios with very big ones and make sure that approach is always faster than swr/soxr and at same time providing better/same quality. Also need to add min phase version of filter and compare what performance/latency it can bring at all. > > thx > > [...] > > -- > 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. > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/teeproto: setup max_packet_size
From: Zhao Zhili It's the minimum of all child protocols max_packet_size. Can be used like this: ffmpeg -re -i cctv.mp4 -c copy -f mpegts \ -protocol_whitelist 'tee,file,udp' \ 'tee:out.ts|udp://127.0.0.1:?pkt_size=1316' Signed-off-by: Zhao Zhili --- libavformat/teeproto.c | 12 1 file changed, 12 insertions(+) diff --git a/libavformat/teeproto.c b/libavformat/teeproto.c index e532bc7750..dca97a6741 100644 --- a/libavformat/teeproto.c +++ b/libavformat/teeproto.c @@ -131,6 +131,18 @@ loop_fail: h->is_streamed |= c->child[i].url_context->is_streamed; } +h->max_packet_size = 0; +for (i = 0; i < c->child_count; i++) { +int max = c->child[i].url_context->max_packet_size; +if (!max) +continue; + +if (!h->max_packet_size) +h->max_packet_size = max; +else if (h->max_packet_size > max) +h->max_packet_size = max; +} + return 0; fail: tee_close(h); -- 2.34.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 0/8] add fd protocol
Le keskiviikkona 11. tammikuuta 2023, 10.52.08 EET Paul B Mahol a écrit : > > Sorry for the break, I’m trying to figure out how to make it compatible > > with Windows. > > Is this even portable? If you build FFmpeg correctly, so that all the FFmpeg libraries and the application code share the same instance of the same CRT, yes. That is to say, you can use POSIX-style file descriptors. Whether it is of any practical usefulness is more questionable, as those file descriptors are not passed from parent to child processes -- Реми Дёни-Курмон http://www.remlab.net/ ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] avformat/movenc: Add loop parameter to animated AVIF
On Fri, Jan 6, 2023 at 1:45 AM "zhilizhao(赵志立)" wrote: > > > > > On Jan 6, 2023, at 01:34, Vignesh Venkatasubramanian > > wrote: > > > > On Thu, Jan 5, 2023 at 1:45 AM "zhilizhao(赵志立)" > > wrote: > >> > >> > >> > >>> On Jan 5, 2023, at 06:16, Vignesh Venkatasubramanian > >>> wrote: > >>> > >>> The HEIF specification permits specifying the looping behavior of > >>> animated sequences by using the EditList (elst) box. The track > >>> duration will be set to the total duration of all the loops (or > >>> infinite) and the duration of a single loop will be set in the edit > >>> list box. > >>> > >>> The default behavior is to loop infinitely. > >>> > >>> Compliance verification: > >>> * This was added in libavif recently [1] and the files produced by > >>> ffmpeg after this change have EditList boxes similar to the ones > >>> produced by libavif (and avifdec is able to parse the loop count as > >>> intended). > >>> * ComplianceWarden is ok with the produced files. > >>> * Chrome is able to play back the produced files. > >>> > >>> Signed-off-by: Vignesh Venkatasubramanian > >>> --- > >>> libavformat/movenc.c | 35 +++ > >>> libavformat/movenc.h | 1 + > >>> 2 files changed, 32 insertions(+), 4 deletions(-) > >>> > >>> diff --git a/libavformat/movenc.c b/libavformat/movenc.c > >>> index 36c76f7f60..8d31317838 100644 > >>> --- a/libavformat/movenc.c > >>> +++ b/libavformat/movenc.c > >>> @@ -3287,7 +3287,7 @@ static int mov_write_tkhd_tag(AVIOContext *pb, > >>> MOVMuxContext *mov, > >>>int64_t duration = av_rescale_rnd(calc_pts_duration(mov, track), > >>> mov->movie_timescale, > >>> track->timescale, > >>> AV_ROUND_UP); > >>> -int version = duration < INT32_MAX ? 0 : 1; > >>> +int version; > >>>int flags = MOV_TKHD_FLAG_IN_MOVIE; > >>>int group = 0; > >>> > >>> @@ -3295,6 +3295,14 @@ static int mov_write_tkhd_tag(AVIOContext *pb, > >>> MOVMuxContext *mov, > >>>size_t display_matrix_size; > >>>int i; > >>> > >>> +if (mov->mode == MODE_AVIF) > >>> +if (!mov->avif_loop_count) > >>> +duration = INT64_MAX; > >>> +else > >>> +duration *= mov->avif_loop_count; > >>> + > >>> + version = duration < INT32_MAX ? 0 : 1; > >>> + > >>>if (st) { > >>>if (mov->per_stream_grouping) > >>>group = st->index; > >>> @@ -3414,7 +3422,10 @@ static int mov_write_tapt_tag(AVIOContext *pb, > >>> MOVTrack *track) > >>>return update_size(pb, pos); > >>> } > >>> > >>> -// This box seems important for the psp playback ... without it the > >>> movie seems to hang > >>> +// This box is written in the following cases: > >>> +// * Seems important for the psp playback. Without it the movie seems > >>> to hang. > >>> +// * Used for specifying the looping behavior of animated AVIF (as > >>> specified > >>> +// in Section 9.6 of the HEIF specification ISO/IEC 23008-12). > >>> static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, > >>> MOVTrack *track) > >>> { > >>> @@ -3425,6 +3436,7 @@ static int mov_write_edts_tag(AVIOContext *pb, > >>> MOVMuxContext *mov, > >>>int entry_size, entry_count, size; > >>>int64_t delay, start_ct = track->start_cts; > >>>int64_t start_dts = track->start_dts; > >>> +int flags = 0; > >>> > >>>if (track->entry) { > >>>if (start_dts != track->cluster[0].dts || start_ct != > >>> track->cluster[0].cts) { > >>> @@ -3440,6 +3452,17 @@ static int mov_write_edts_tag(AVIOContext *pb, > >>> MOVMuxContext *mov, > >>> > >>>delay = av_rescale_rnd(start_dts + start_ct, mov->movie_timescale, > >>> track->timescale, AV_ROUND_DOWN); > >>> + > >>> +if (mov->mode == MODE_AVIF) { > >>> +delay = 0; > >>> +// Section 9.6.3 of ISO/IEC 23008-12: flags specifies repetition > >>> of the > >>> +// edit list as follows: (flags & 1) equal to 0 specifies that > >>> the edit > >>> +// list is not repeated, while (flags & 1) equal to 1 specifies > >>> that the > >>> +// edit list is repeated. > >>> +flags = mov->avif_loop_count != 1; > >>> +start_ct = 0; > >>> +} > >>> + > >>>version |= delay < INT32_MAX ? 0 : 1; > >>> > >>>entry_size = (version == 1) ? 20 : 12; > >>> @@ -3452,7 +3475,7 @@ static int mov_write_edts_tag(AVIOContext *pb, > >>> MOVMuxContext *mov, > >>>avio_wb32(pb, size - 8); > >>>ffio_wfourcc(pb, "elst"); > >>>avio_w8(pb, version); > >>> -avio_wb24(pb, 0); /* flags */ > >>> +avio_wb24(pb, flags); /* flags */ > >>> > >>>avio_wb32(pb, entry_count); > >>>if (delay > 0) { /* add an empty edit to delay presentation */ > >>> @@ -3469,7 +3492,7 @@ static int mov_write_edts_tag(AVIOContext *pb, > >>> MOVMuxContext *mov, > >>>avio_wb32(pb, -1); > >>>} > >>>avio_wb32(pb, 0x0001)
Re: [FFmpeg-devel] [PATCH] libswresample: avoid s16p internal processing format
On Thu, Jan 12, 2023 at 05:09:18PM +0100, Paul B Mahol wrote: > On 1/12/23, Michael Niedermayer wrote: > > On Thu, Jan 12, 2023 at 03:20:06PM +0100, Paul B Mahol wrote: > >> On 1/8/23, Michael Niedermayer wrote: > >> > On Fri, Jan 06, 2023 at 07:04:59PM +0100, Paul B Mahol wrote: > >> >> On Fri, Jan 6, 2023 at 7:01 PM Paul B Mahol wrote: > >> >> > >> >> > > >> >> > > >> >> > On Fri, Jan 6, 2023 at 6:25 PM Michael Niedermayer > >> >> > > >> >> > wrote: > >> >> > > >> >> >> On Thu, Jan 05, 2023 at 11:08:25PM +0100, Paul B Mahol wrote: > >> >> >> > On Thu, Jan 5, 2023 at 9:53 PM Michael Niedermayer < > >> >> >> mich...@niedermayer.cc> > >> >> >> > wrote: > >> >> >> > > >> >> >> > > On Thu, Jan 05, 2023 at 01:44:10PM +0100, Paul B Mahol wrote: > >> >> >> > > > Patch attached. > >> >> >> > > > >> >> >> > > > swresample.c |3 ++- > >> >> >> > > > 1 file changed, 2 insertions(+), 1 deletion(-) > >> >> >> > > > eee7a0685b44aa867562138a2e2437ecb8844612 > >> >> >> > > 0001-libswresample-swresample-avoid-s16p-internal-transfe.patch > >> >> >> > > > From 9c4cd60e2dd41cf98d693c8251f4cfade0807073 Mon Sep 17 > >> >> >> > > > 00:00:00 > >> >> >> 2001 > >> >> >> > > > From: Paul B Mahol > >> >> >> > > > Date: Thu, 5 Jan 2023 13:40:12 +0100 > >> >> >> > > > Subject: [PATCH] libswresample/swresample: avoid s16p > >> >> >> > > > internal > >> >> >> transfer > >> >> >> > > format > >> >> >> > > > > >> >> >> > > > Instead use float one by default for sample rate conversions. > >> >> >> > > > The s16p internal transfer format produces visible and > >> >> >> > > > hearable > >> >> >> > > > quantization artifacts. > >> >> >> > > > >> >> >> > > When does this occur and why? > >> >> >> > > > >> >> >> > > >> >> >> > It occurs always. Just compare output with 16bit and > >> >> >> > int32/float/double. > >> >> >> > Look at other people report on internet. > >> >> >> > Look at src.infinitewave.ca > >> >> >> > >> >> >> src.infinitewave.ca uses 32bit none of what it shows should touch > >> >> >> the > >> >> >> codepath > >> >> >> you change. > >> >> >> > >> >> >> if we look at src.infinitewave.ca for swr we see 2 types of > >> >> >> artifacts > >> >> >> 1. Aliassing which is at maybe -120db with the actual signal at 0db > >> >> >>i would like to see some evidence that a human can hear this > >> >> >> > >> >> > > >> >> > For s16p<->s16p it is much lower, around -78dB thus this patch. > >> >> > > >> >> > Also for others and reports for swr its is lower than exact -120dB > >> >> > > >> >> > > >> >> > 2. Reflection and attenuation at the transition frequency > >> >> >> With linear filters there is a tradeof between attenuation of the > >> >> >> passband, reflection of frequencies beyond, latency and so on > >> >> >> You can have a perfect sharp cutoff with no attenuation and no > >> >> >> refelection > >> >> >> that requires a infinitly long filter. And while this looks best in > >> >> >> this > >> >> >> frequency plot, does it actually sound best ? If you can hear > >> >> >> -120db > >> >> >> signals you surely would then also hear the ringing long before a > >> >> >> gunshot > >> >> >> from such long filter. > >> >> >> > >> >> > > >> >> One can always change linear FIR to be min phase FIR kernel. > >> > > >> > I certainly would welcome a wider range of filters in swr, if you want > >> > to > >> > add > >> > any low delay sinc approximation or in fact i would welcome any filter > >> > you want to add. > >> > >> There is that afdelaysrc filter patch on ML to add FIR coefficient > >> generation for fractional delay audio filter that can be also used as > >> a interpolation FIR filter. And to me it seems better at same number > >> of taps than already used/available ones in soxr and swr. > > > > Please add improvments into swr, if you have any! > > > > > >> > >> Also I have done prototype of resampling filter using afir filter via > >> custom filters in filtergraph and it operates at similar speeds like > >> soxr (in these very non optimized approach) and providing better/wider > >> frequency output at highest band. > > > > Can it be added into swr ? > > It will use libavutil/tx.h for convolution. ok of course > > But I need first to research more and write actual code that does > out/in sample rate ratio factorization and do lot of benchmarks > comparing normal ratios with very big ones and make sure that approach > is always faster than swr/soxr and at same time providing better/same > quality. > Also need to add min phase version of filter and compare what > performance/latency it can bring at all. thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Its not that you shouldnt use gotos but rather that you should write readable code and code with gotos often but not always is less readable signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscr
[FFmpeg-devel] [PATCH 2/2] avformat/movenc: Add loop parameter to animated AVIF
The HEIF specification permits specifying the looping behavior of animated sequences by using the EditList (elst) box. The track duration will be set to the total duration of all the loops (or infinite) and the duration of a single loop will be set in the edit list box. The default behavior is to loop infinitely. Compliance verification: * This was added in libavif recently [1] and the files produced by ffmpeg after this change have EditList boxes similar to the ones produced by libavif (and avifdec is able to parse the loop count as intended). * ComplianceWarden is ok with the produced files. * Chrome is able to play back the produced files. [1] https://github.com/AOMediaCodec/libavif/commit/4d2776a3af53ae1aefdaed463b75ba12fd9cf8c2 Signed-off-by: Vignesh Venkatasubramanian --- libavformat/movenc.c | 35 +++ libavformat/movenc.h | 1 + 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 36c76f7f60..8d31317838 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -3287,7 +3287,7 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov, int64_t duration = av_rescale_rnd(calc_pts_duration(mov, track), mov->movie_timescale, track->timescale, AV_ROUND_UP); -int version = duration < INT32_MAX ? 0 : 1; +int version; int flags = MOV_TKHD_FLAG_IN_MOVIE; int group = 0; @@ -3295,6 +3295,14 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov, size_t display_matrix_size; int i; +if (mov->mode == MODE_AVIF) +if (!mov->avif_loop_count) +duration = INT64_MAX; +else +duration *= mov->avif_loop_count; + + version = duration < INT32_MAX ? 0 : 1; + if (st) { if (mov->per_stream_grouping) group = st->index; @@ -3414,7 +3422,10 @@ static int mov_write_tapt_tag(AVIOContext *pb, MOVTrack *track) return update_size(pb, pos); } -// This box seems important for the psp playback ... without it the movie seems to hang +// This box is written in the following cases: +// * Seems important for the psp playback. Without it the movie seems to hang. +// * Used for specifying the looping behavior of animated AVIF (as specified +// in Section 9.6 of the HEIF specification ISO/IEC 23008-12). static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track) { @@ -3425,6 +3436,7 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, int entry_size, entry_count, size; int64_t delay, start_ct = track->start_cts; int64_t start_dts = track->start_dts; +int flags = 0; if (track->entry) { if (start_dts != track->cluster[0].dts || start_ct != track->cluster[0].cts) { @@ -3440,6 +3452,17 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, delay = av_rescale_rnd(start_dts + start_ct, mov->movie_timescale, track->timescale, AV_ROUND_DOWN); + +if (mov->mode == MODE_AVIF) { +delay = 0; +// Section 9.6.3 of ISO/IEC 23008-12: flags specifies repetition of the +// edit list as follows: (flags & 1) equal to 0 specifies that the edit +// list is not repeated, while (flags & 1) equal to 1 specifies that the +// edit list is repeated. +flags = mov->avif_loop_count != 1; +start_ct = 0; +} + version |= delay < INT32_MAX ? 0 : 1; entry_size = (version == 1) ? 20 : 12; @@ -3452,7 +3475,7 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, avio_wb32(pb, size - 8); ffio_wfourcc(pb, "elst"); avio_w8(pb, version); -avio_wb24(pb, 0); /* flags */ +avio_wb24(pb, flags); /* flags */ avio_wb32(pb, entry_count); if (delay > 0) { /* add an empty edit to delay presentation */ @@ -3469,7 +3492,7 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, avio_wb32(pb, -1); } avio_wb32(pb, 0x0001); -} else { +} else if (mov->mode != MODE_AVIF) { /* Avoid accidentally ending up with start_ct = -1 which has got a * special meaning. Normally start_ct should end up positive or zero * here, but use FFMIN in case dts is a small positive integer @@ -3670,6 +3693,9 @@ static int mov_write_trak_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext "Not writing any edit list even though one would have been required\n"); } +if (mov->is_animated_avif) +mov_write_edts_tag(pb, mov, track); + if (track->tref_tag) mov_write_tref_tag(pb, track); @@ -7761,6 +7787,7 @@ static const AVCodecTag codec_f4v_tags[] = { static const AVOption avif_options[] = { { "movie_timescale", "set movie timescale", offsetof(MOVMuxC
[FFmpeg-devel] [PATCH 1/2] avcodec/ac3dec: don't export Matrix Encoding side data when no such info is coded
No point inserting the side data to all frames just to say there's no coded matrix encoding. Signed-off-by: James Almer --- libavcodec/ac3dec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 0b120e6140..7a84f3c85d 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1819,7 +1819,8 @@ skip: break; } } -if ((ret = ff_side_data_update_matrix_encoding(frame, matrix_encoding)) < 0) +if (matrix_encoding != AV_MATRIX_ENCODING_NONE && +(ret = ff_side_data_update_matrix_encoding(frame, matrix_encoding)) < 0) return ret; /* AVDownmixInfo */ -- 2.39.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avcodec/ac3dec: export downmix info side data only when no downmix is done by the decoder
Same as with Matrix Encoding, add a check to ensure the decoder is not doing a downmix of its own. Signed-off-by: James Almer --- libavcodec/ac3dec.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 7a84f3c85d..722a1028b7 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1824,7 +1824,11 @@ skip: return ret; /* AVDownmixInfo */ -if ((downmix_info = av_downmix_info_update_side_data(frame))) { +if (s->channel_mode == (s->output_mode & ~AC3_OUTPUT_LFEON)) { +downmix_info = av_downmix_info_update_side_data(frame); +if (!downmix_info) +return AVERROR(ENOMEM); + switch (s->preferred_downmix) { case AC3_DMIXMOD_LTRT: downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_LTRT; @@ -1847,8 +1851,7 @@ skip: downmix_info->lfe_mix_level = gain_levels_lfe[s->lfe_mix_level]; else downmix_info->lfe_mix_level = 0.0; // -inf dB -} else -return AVERROR(ENOMEM); +} *got_frame_ptr = 1; -- 2.39.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/5] avcodec/wbmpdec: use remaining size not whole size
Fixes: out of array access Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WBMP_fuzzer-6652634692190208 Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WBMP_fuzzer-6653703453278208 Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WBMP_fuzzer-6668020758216704 Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WBMP_fuzzer-6684749875249152 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/wbmpdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/wbmpdec.c b/libavcodec/wbmpdec.c index 9638b55b94..8b105bc135 100644 --- a/libavcodec/wbmpdec.c +++ b/libavcodec/wbmpdec.c @@ -72,7 +72,7 @@ static int wbmp_decode_frame(AVCodecContext *avctx, AVFrame *p, if (p->linesize[0] == (width + 7) / 8) bytestream2_get_buffer(&gb, p->data[0], height * ((width + 7) / 8)); else -readbits(p->data[0], width, height, p->linesize[0], gb.buffer, gb.buffer_end - gb.buffer_start); +readbits(p->data[0], width, height, p->linesize[0], gb.buffer, gb.buffer_end - gb.buffer); p->key_frame = 1; p->pict_type = AV_PICTURE_TYPE_I; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/5] avcodec/xpmdec: Check size before allocation to avoid truncation
Fixes:OOM Fixes:out of array access (no testcase) Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XPM_fuzzer-6573323838685184 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/xpmdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c index ff1f51dd32..504cc47d8f 100644 --- a/libavcodec/xpmdec.c +++ b/libavcodec/xpmdec.c @@ -356,6 +356,9 @@ static int xpm_decode_frame(AVCodecContext *avctx, AVFrame *p, size *= 4; +if (size > SIZE_MAX) +return AVERROR(ENOMEM); + ptr += mod_strcspn(ptr, ",") + 1; if (end - ptr < 1) return AVERROR_INVALIDDATA; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/5] avcodec/012v: Order operations for odd size handling
Fixes: out of array access Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZERO12V_fuzzer-6714182078955520.fuzz Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZERO12V_fuzzer-6698145212137472.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/012v.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/012v.c b/libavcodec/012v.c index 2d89a86b98..f0197cd8f9 100644 --- a/libavcodec/012v.c +++ b/libavcodec/012v.c @@ -131,8 +131,8 @@ static int zero12v_decode_frame(AVCodecContext *avctx, AVFrame *pic, u = x/2 + (uint16_t *)(pic->data[1] + line * pic->linesize[1]); v = x/2 + (uint16_t *)(pic->data[2] + line * pic->linesize[2]); memcpy(y, y_temp, sizeof(*y) * (width - x)); -memcpy(u, u_temp, sizeof(*u) * (width - x + 1) / 2); -memcpy(v, v_temp, sizeof(*v) * (width - x + 1) / 2); +memcpy(u, u_temp, sizeof(*u) * ((width - x + 1) / 2)); +memcpy(v, v_temp, sizeof(*v) * ((width - x + 1) / 2)); } line_end += stride; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/5] avcodec/motionpixels: Mask pixels to valid values
Fixes: out of array access Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOTIONPIXELS_fuzzer-672420335220 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/motionpixels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index 4141c5a495..a947ca05de 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -185,7 +185,7 @@ static YuvPixel mp_get_yuv_from_rgb(MotionPixelsContext *mp, int x, int y) int color; color = *(uint16_t *)&mp->frame->data[0][y * mp->frame->linesize[0] + x * 2]; -return mp_rgb_yuv_table[color]; +return mp_rgb_yuv_table[color & 0x7FFF]; } static void mp_set_rgb_from_yuv(MotionPixelsContext *mp, int x, int y, const YuvPixel *p) -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/5] avcodec/sonic: avoid integer overflow on quantization parameter
Fixes: signed integer overflow: -1094995529 * 16 cannot be represented in type 'int' Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-6681622236233728 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/sonic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index 77bdb418a7..95ac2b1a96 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -1013,7 +1013,7 @@ static int sonic_decode_frame(AVCodecContext *avctx, AVFrame *frame, if (s->lossless) quant = 1; else -quant = get_symbol(&c, state, 0) * SAMPLE_FACTOR; +quant = get_symbol(&c, state, 0) * (unsigned)SAMPLE_FACTOR; //av_log(NULL, AV_LOG_INFO, "quant: %d\n", quant); -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/5] avcodec/xpmdec: Check size before allocation to avoid truncation
On 1/12/2023 9:01 PM, Michael Niedermayer wrote: Fixes:OOM Fixes:out of array access (no testcase) Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XPM_fuzzer-6573323838685184 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/xpmdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c index ff1f51dd32..504cc47d8f 100644 --- a/libavcodec/xpmdec.c +++ b/libavcodec/xpmdec.c @@ -356,6 +356,9 @@ static int xpm_decode_frame(AVCodecContext *avctx, AVFrame *p, size *= 4; +if (size > SIZE_MAX) +return AVERROR(ENOMEM); Maybe check for (size > SIZE_MAX / 4) before the multiplication above instead. + ptr += mod_strcspn(ptr, ",") + 1; if (end - ptr < 1) return AVERROR_INVALIDDATA; ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 0/8] add fd protocol
> On Jan 13, 2023, at 03:13, Rémi Denis-Courmont wrote: > > Le keskiviikkona 11. tammikuuta 2023, 10.52.08 EET Paul B Mahol a écrit : >>> Sorry for the break, I’m trying to figure out how to make it compatible >>> with Windows. >> >> Is this even portable? > > If you build FFmpeg correctly, so that all the FFmpeg libraries and the > application code share the same instance of the same CRT, yes. That is to > say, > you can use POSIX-style file descriptors. > > Whether it is of any practical usefulness is more questionable, as those file > descriptors are not passed from parent to child processes When an app requests a media file, Android system provides it as a file descriptor over IPC for security. Users may find other usecases. > > -- > Реми Дёни-Курмон > http://www.remlab.net/ > > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] lavfi/vaapi: remove duplicated code
From: Haihao Xiang Add a ff_ function to handle mulitple pipeline parameters. No functional changes. Signed-off-by: Haihao Xiang --- libavfilter/vaapi_vpp.c| 90 libavfilter/vaapi_vpp.h| 5 ++ libavfilter/vf_overlay_vaapi.c | 122 +++-- 3 files changed, 77 insertions(+), 140 deletions(-) diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c index 1610df4c85..a323dab8b8 100644 --- a/libavfilter/vaapi_vpp.c +++ b/libavfilter/vaapi_vpp.c @@ -588,17 +588,53 @@ int ff_vaapi_vpp_make_param_buffers(AVFilterContext *avctx, return 0; } +static int vaapi_vpp_render_single_pipeline_buffer(AVFilterContext *avctx, + VAProcPipelineParameterBuffer *params, + VABufferID *params_id) +{ +VAAPIVPPContext *ctx = avctx->priv; +VAStatus vas; -int ff_vaapi_vpp_render_picture(AVFilterContext *avctx, -VAProcPipelineParameterBuffer *params, -AVFrame *output_frame) +vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context, + VAProcPipelineParameterBufferType, + sizeof(*params), 1, params, params_id); +if (vas != VA_STATUS_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Failed to create parameter buffer: " + "%d (%s).\n", vas, vaErrorStr(vas)); +*params_id = VA_INVALID_ID; + +return AVERROR(EIO); +} +av_log(avctx, AV_LOG_DEBUG, "Pipeline parameter buffer is %#x.\n", *params_id); + +vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context, params_id, 1); +if (vas != VA_STATUS_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Failed to render parameter buffer: " + "%d (%s).\n", vas, vaErrorStr(vas)); +return AVERROR(EIO); +} + +return 0; +} + +int ff_vaapi_vpp_render_pictures(AVFilterContext *avctx, + VAProcPipelineParameterBuffer *params_list, + int cout, + AVFrame *output_frame) { VAAPIVPPContext *ctx = avctx->priv; VASurfaceID output_surface; -VABufferID params_id; +VABufferID *params_ids; VAStatus vas; int err; +params_ids = (VABufferID *)av_malloc_array(cout, sizeof(VABufferID)); +if (!params_ids) +return AVERROR(ENOMEM); + +for (int i = 0; i < cout; i++) +params_ids[i] = VA_INVALID_ID; + output_surface = (VASurfaceID)(uintptr_t)output_frame->data[3]; vas = vaBeginPicture(ctx->hwctx->display, @@ -610,25 +646,10 @@ int ff_vaapi_vpp_render_picture(AVFilterContext *avctx, goto fail; } -vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context, - VAProcPipelineParameterBufferType, - sizeof(*params), 1, params, ¶ms_id); -if (vas != VA_STATUS_SUCCESS) { -av_log(avctx, AV_LOG_ERROR, "Failed to create parameter buffer: " - "%d (%s).\n", vas, vaErrorStr(vas)); -err = AVERROR(EIO); -goto fail_after_begin; -} -av_log(avctx, AV_LOG_DEBUG, "Pipeline parameter buffer is %#x.\n", - params_id); - -vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context, - ¶ms_id, 1); -if (vas != VA_STATUS_SUCCESS) { -av_log(avctx, AV_LOG_ERROR, "Failed to render parameter buffer: " - "%d (%s).\n", vas, vaErrorStr(vas)); -err = AVERROR(EIO); -goto fail_after_begin; +for (int i = 0; i < cout; i++) { +err = vaapi_vpp_render_single_pipeline_buffer(avctx, ¶ms_list[i], ¶ms_ids[i]); +if (err) +goto fail_after_begin; } vas = vaEndPicture(ctx->hwctx->display, ctx->va_context); @@ -641,14 +662,17 @@ int ff_vaapi_vpp_render_picture(AVFilterContext *avctx, if (CONFIG_VAAPI_1 || ctx->hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) { -vas = vaDestroyBuffer(ctx->hwctx->display, params_id); -if (vas != VA_STATUS_SUCCESS) { -av_log(avctx, AV_LOG_ERROR, "Failed to free parameter buffer: " - "%d (%s).\n", vas, vaErrorStr(vas)); -// And ignore. +for (int i = 0; i < cout && params_ids[i] != VA_INVALID_ID; i++) { +vas = vaDestroyBuffer(ctx->hwctx->display, params_ids[i]); +if (vas != VA_STATUS_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Failed to free parameter buffer: " + "%d (%s).\n", vas, vaErrorStr(vas)); +// And ignore. +} } } +av_freep(¶ms_ids); return 0; // We want to make sure that if vaBeginPicture has been called, we also @@ -656,13 +680,21 @@ int ff_vaapi_vpp_render_picture(AVFilterContext *avctx, // do something else nasty, but once we're in this
[FFmpeg-devel] [PATCH 2/2] lavfi/overlay_vaapi: remove unnecessary code
From: Haihao Xiang VA-API filter is not required. Signed-off-by: Haihao Xiang --- libavfilter/vf_overlay_vaapi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c index 79cf66d068..16d1e0e211 100644 --- a/libavfilter/vf_overlay_vaapi.c +++ b/libavfilter/vf_overlay_vaapi.c @@ -208,9 +208,6 @@ static int overlay_vaapi_blend(FFFrameSync *fs) .height = output->height, }; -params[0].filters = &vpp_ctx->filter_buffers[0]; -params[0].num_filters = vpp_ctx->nb_filter_buffers; - params[0].output_region = &output_region; params[0].output_background_color = VAAPI_VPP_BACKGROUND_BLACK; -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] avformat/movenc: Add loop parameter to animated AVIF
> On Jan 13, 2023, at 04:45, Vignesh Venkatasubramanian > wrote: > > The HEIF specification permits specifying the looping behavior of > animated sequences by using the EditList (elst) box. The track > duration will be set to the total duration of all the loops (or > infinite) and the duration of a single loop will be set in the edit > list box. > > The default behavior is to loop infinitely. > > Compliance verification: > * This was added in libavif recently [1] and the files produced by > ffmpeg after this change have EditList boxes similar to the ones > produced by libavif (and avifdec is able to parse the loop count as > intended). > * ComplianceWarden is ok with the produced files. > * Chrome is able to play back the produced files. > > [1] > https://github.com/AOMediaCodec/libavif/commit/4d2776a3af53ae1aefdaed463b75ba12fd9cf8c2 Pushed. Please use [PATCH v2] next time. It isn’t clear whether it’s the same version as another patch or not, until diffed manually. > > Signed-off-by: Vignesh Venkatasubramanian > --- > libavformat/movenc.c | 35 +++ > libavformat/movenc.h | 1 + > 2 files changed, 32 insertions(+), 4 deletions(-) > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > index 36c76f7f60..8d31317838 100644 > --- a/libavformat/movenc.c > +++ b/libavformat/movenc.c > @@ -3287,7 +3287,7 @@ static int mov_write_tkhd_tag(AVIOContext *pb, > MOVMuxContext *mov, > int64_t duration = av_rescale_rnd(calc_pts_duration(mov, track), > mov->movie_timescale, track->timescale, > AV_ROUND_UP); > -int version = duration < INT32_MAX ? 0 : 1; > +int version; > int flags = MOV_TKHD_FLAG_IN_MOVIE; > int group = 0; > > @@ -3295,6 +3295,14 @@ static int mov_write_tkhd_tag(AVIOContext *pb, > MOVMuxContext *mov, > size_t display_matrix_size; > int i; > > +if (mov->mode == MODE_AVIF) > +if (!mov->avif_loop_count) > +duration = INT64_MAX; > +else > +duration *= mov->avif_loop_count; > + > + version = duration < INT32_MAX ? 0 : 1; > + > if (st) { > if (mov->per_stream_grouping) > group = st->index; > @@ -3414,7 +3422,10 @@ static int mov_write_tapt_tag(AVIOContext *pb, > MOVTrack *track) > return update_size(pb, pos); > } > > -// This box seems important for the psp playback ... without it the movie > seems to hang > +// This box is written in the following cases: > +// * Seems important for the psp playback. Without it the movie seems to > hang. > +// * Used for specifying the looping behavior of animated AVIF (as > specified > +// in Section 9.6 of the HEIF specification ISO/IEC 23008-12). > static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, > MOVTrack *track) > { > @@ -3425,6 +3436,7 @@ static int mov_write_edts_tag(AVIOContext *pb, > MOVMuxContext *mov, > int entry_size, entry_count, size; > int64_t delay, start_ct = track->start_cts; > int64_t start_dts = track->start_dts; > +int flags = 0; > > if (track->entry) { > if (start_dts != track->cluster[0].dts || start_ct != > track->cluster[0].cts) { > @@ -3440,6 +3452,17 @@ static int mov_write_edts_tag(AVIOContext *pb, > MOVMuxContext *mov, > > delay = av_rescale_rnd(start_dts + start_ct, mov->movie_timescale, >track->timescale, AV_ROUND_DOWN); > + > +if (mov->mode == MODE_AVIF) { > +delay = 0; > +// Section 9.6.3 of ISO/IEC 23008-12: flags specifies repetition of > the > +// edit list as follows: (flags & 1) equal to 0 specifies that the > edit > +// list is not repeated, while (flags & 1) equal to 1 specifies that > the > +// edit list is repeated. > +flags = mov->avif_loop_count != 1; > +start_ct = 0; > +} > + > version |= delay < INT32_MAX ? 0 : 1; > > entry_size = (version == 1) ? 20 : 12; > @@ -3452,7 +3475,7 @@ static int mov_write_edts_tag(AVIOContext *pb, > MOVMuxContext *mov, > avio_wb32(pb, size - 8); > ffio_wfourcc(pb, "elst"); > avio_w8(pb, version); > -avio_wb24(pb, 0); /* flags */ > +avio_wb24(pb, flags); /* flags */ > > avio_wb32(pb, entry_count); > if (delay > 0) { /* add an empty edit to delay presentation */ > @@ -3469,7 +3492,7 @@ static int mov_write_edts_tag(AVIOContext *pb, > MOVMuxContext *mov, > avio_wb32(pb, -1); > } > avio_wb32(pb, 0x0001); > -} else { > +} else if (mov->mode != MODE_AVIF) { > /* Avoid accidentally ending up with start_ct = -1 which has got a > * special meaning. Normally start_ct should end up positive or zero > * here, but use FFMIN in case dts is a small positive integer > @@ -3670,6 +3693,9 @@ static int mov_write_trak_tag(AVFormatContext *s, > AVIOContext *pb, MOVMuxContext >
Re: [FFmpeg-devel] [PATCH v6 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file
Basel Sayeh 于2023年1月7日周六 08:22写道: > > V6: > - Removed the const for filename in "hls_delete_file" to >fix compilation warnings > > - Removed the unnecessary calls to ff_format_io_close >this patch introduced in hls_delete_file and in >dashenc_delete_file > > V1-V5: > hls_delete_file and dashenc_delete_file functions open a > new HTTP connection regardless of the http_persistent value, > So change their behaviour to keep http connections open > if http_persistent is set > > > Signed-off-by: Basel Sayeh > --- > libavformat/hlsenc.c | 17 +++-- > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c > index a86fc8907f..39df9becc7 100644 > --- a/libavformat/hlsenc.c > +++ b/libavformat/hlsenc.c > @@ -252,6 +252,7 @@ typedef struct HLSContext { > int http_persistent; > AVIOContext *m3u8_out; > AVIOContext *sub_m3u8_out; > +AVIOContext *http_delete; > int64_t timeout; > int ignore_io_errors; > char *headers; > @@ -565,19 +566,22 @@ static void reflush_dynbuf(VariantStream *vs, int > *range_length) > #endif > > static int hls_delete_file(HLSContext *hls, AVFormatContext *avf, > - const char *path, const char *proto) > + char *path, const char *proto) > { > if (hls->method || (proto && !av_strcasecmp(proto, "http"))) { > AVDictionary *opt = NULL; > -AVIOContext *out = NULL; > int ret; > + > set_http_options(avf, &opt, hls); > av_dict_set(&opt, "method", "DELETE", 0); > -ret = avf->io_open(avf, &out, path, AVIO_FLAG_WRITE, &opt); > + > +ret = hlsenc_io_open(avf, &hls->http_delete, path, &opt); > av_dict_free(&opt); > if (ret < 0) > return hls->ignore_io_errors ? 1 : ret; > -ff_format_io_close(avf, &out); > + > +//Nothing to write > +hlsenc_io_close(avf, &hls->http_delete, path); > } else if (unlink(path) < 0) { > av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n", > path, strerror(errno)); > @@ -662,7 +666,7 @@ static int hls_delete_old_segments(AVFormatContext *s, > HLSContext *hls, > } > > proto = avio_find_protocol_name(s->url); > -if (ret = hls_delete_file(hls, vs->avf, path.str, proto)) > +if (ret = hls_delete_file(hls, s, path.str, proto)) > goto fail; > > if ((segment->sub_filename[0] != '\0')) { > @@ -679,7 +683,7 @@ static int hls_delete_old_segments(AVFormatContext *s, > HLSContext *hls, > goto fail; > } > > -if (ret = hls_delete_file(hls, vs->vtt_avf, path.str, proto)) > +if (ret = hls_delete_file(hls, s, path.str, proto)) > goto fail; > } > av_bprint_clear(&path); > @@ -2707,6 +2711,7 @@ static void hls_deinit(AVFormatContext *s) > > ff_format_io_close(s, &hls->m3u8_out); > ff_format_io_close(s, &hls->sub_m3u8_out); > +ff_format_io_close(s, &hls->http_delete); > av_freep(&hls->key_basename); > av_freep(&hls->var_streams); > av_freep(&hls->cc_streams); > -- > 2.30.2 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". Patchset pushed Thanks Steven ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/ac3dec: don't export Matrix Encoding side data when no such info is coded
James Almer: > No point inserting the side data to all frames just to say there's no > coded matrix encoding. > > Signed-off-by: James Almer > --- > libavcodec/ac3dec.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c > index 0b120e6140..7a84f3c85d 100644 > --- a/libavcodec/ac3dec.c > +++ b/libavcodec/ac3dec.c > @@ -1819,7 +1819,8 @@ skip: > break; > } > } > -if ((ret = ff_side_data_update_matrix_encoding(frame, matrix_encoding)) > < 0) > +if (matrix_encoding != AV_MATRIX_ENCODING_NONE && > +(ret = ff_side_data_update_matrix_encoding(frame, matrix_encoding)) > < 0) > return ret; > > /* AVDownmixInfo */ If the preceding frame had a nontrivial matrix encoding, will users think that the matrix encoding from the last frame still persists? - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".