[FFmpeg-devel] How to improve GPU command to improve picture quality is the same as CPU transcoding quality
Hi: I use this command # ffmpeg -r 24 -i vbox4071__B4I0335_211922.JPG -pix_fmt yuv444p -r 24 -f yuv4mpegpipe - 2>/dev/null|x265 --crf 16 -o 265-1/vbox4071__B4I0335_211922.265 - --y4m Then i want to use gpu command ffmpeg -r 24 -i vbox4071__B4I0335_211922.JPG -pix_fmt yuv444p -r 24 -f yuv4mpegpipe - 2>/dev/null | ffmpeg -i - -c:v hevc_nvenc -crf 16 -f hevc 265-1/vbox4071__B4I0335_211922.265 But i got the picture quality is very low from gpu compare with cpu; How to improve GPU command to improve picture quality is the same as CPU transcoding quality? Thanks; ___ 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] lavfi: add new iteration API
On 4/16/20, Josh Allmann wrote: > On Tue, 14 Apr 2020 at 01:53, Josh de Kock wrote: >> >> Hi, >> >> On Mon, Apr 13, 2020, at 10:32 PM, Josh Allmann wrote: >> > Hi, >> > >> > On Sat, 24 Mar 2018 at 14:40, Josh de Kock wrote: >> > > >> > > Signed-off-by: Josh de Kock >> > > --- >> > > configure| 29 +- >> > > doc/APIchanges | 4 + >> > > doc/writing_filters.txt | 6 +- >> > > libavfilter/allfilters.c | 823 >> > > +-- >> > > libavfilter/avfilter.c | 50 +-- >> > > libavfilter/avfilter.h | 29 +- >> > > libavfilter/version.h| 3 + >> > > 7 files changed, 489 insertions(+), 455 deletions(-) >> > > >> > >> > This is a couple years too late, but wanted to drop a note that this >> > particular API change was breaking : it made avfilter_register a >> > no-op. The consequence is that it's much more difficult to maintain >> > filters out-of-tree; preserving the old behavior without changes to >> > user code requires a special build of ffmpeg that has the filter >> > configured/compiled in. The recommended workaround of using >> > avfilter_graph_alloc_filter requires more effort to wire the filter in >> > explicitly. It also doesn't allow for conveniences such as using >> > avfilter_graph_parse, since there doesn't seem to be a way to make >> > filters accessible via avfilter_get_by_name outside of ffmpeg compile >> > time. >> > >> > If there is another workaround that I'm missing, please let me know, >> > or if there's some deeper rationale for the decision to disable this >> > feature. >> >> This was actually an intentional change, there was some trouble with how >> external codecs/filters/etc should be handled. >> >> Since this was an unsupported use-case which was quite sensitive to ABI >> the >> change was there to explicitly prevent people (ab)using the API like this. >> It >> was also to prepare for potentially a new API to implement this in a >> proper >> fashion (but as you can see this was never completed). >> >> I did begin working on this again a little while back but due to an >> unfortunate >> data-loss I will have to start from scratch to continue working on it >> (yes, yes >> 'where's your backup?' I know). It's likely to be something I will be >> working >> on in the future since I will be doing FFmpeg stuff again soon. >> >> There is also the discussion of 'do we want this?' from a more ideological >> perspective which we will have to re-discuss, maybe something like >> gstreamer is >> more suited for the majority of the use-cases (?). >> > > Thanks for the explanation Josh. For what it's worth, count me as > being at least one API user for which out-of-tree filter capability > would be very helpful. (And to preempt some other reactions, "use > gstreamer" is not really helpful for us either...) > You must know that out of tree filters will never be supported. > Josh > ___ > 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".
Re: [FFmpeg-devel] [PATCH v3] lavfi: add new iteration API
On Thu, Apr 16, 2020, at 10:44, Paul B Mahol wrote: > > Thanks for the explanation Josh. For what it's worth, count me as > > being at least one API user for which out-of-tree filter capability > > would be very helpful. (And to preempt some other reactions, "use > > gstreamer" is not really helpful for us either...) > > You must know that out of tree filters will never be supported. Why? -- Jean-Baptiste Kempf - President +33 672 704 734 ___ 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] Query regarding codec parsers
On Mon, Apr 13, 2020 at 11:00 PM Carl Eugen Hoyos wrote: > > Am Mo., 13. Apr. 2020 um 17:27 Uhr schrieb Gautam Ramakrishnan > : > > > > On Sun, Mar 29, 2020 at 8:34 PM Carl Eugen Hoyos wrote: > > > > > > Am So., 29. März 2020 um 16:45 Uhr schrieb Gautam Ramakrishnan > > > : > > > > > > > > > What exactly does a parser do and how is it different from a > > > > > > decoder? > > > > > > I am unable to understand the exact use case of a parser. > > > > > > > > > > Try the following: > > > > > $ cat 1.jpg 2.jpg | ffmpeg -i -f null - > > > > > (Is expected to decode two frames as can be seen in the console > > > > > output, > > > > > also works for example with png) > > > > > > > > > > $ cat 1.j2k 2.j2k | ffmpeg -i - -f null - > > > > > Will only decode one frame because there is no parser to split the > > > > > input. > > > > > > > > > So does it basically try to find the SOC marker and EOC markers and > > > > split the streams into frames? > > > > > > Basically, yes. > > > Look at existing parsers in libavcodec/*parser* (or git grep > > > AVCodecParser), > > > especially the jpeg parser. > > > Would working on a parser be a good idea now? > > Either that or you look at ticket #4681 (no idea how difficult this is). > > Carl Eugen > ___ > 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". Hi, I thought I'll start with the parser first. I went through the BMP and JPEG parsers and needed some more clarification. So, each frame could either be a JPEG2000 file or a JPEG2000 codestream. The parse function must be able to find the end of the file/codestream and return the location of it. Is my understanding correct? -- - Gautam | ___ 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] How to improve GPU command to improve picture quality is the same as CPU transcoding quality
Please ask user questions on the respective user mailing list. ___ 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] [GSOC] libavfilter/vf_colorconstancy.c : Adding weighted greyedge
> > As Michael noted, please resend without broken like feeds. I can't read > most of the diff the way it is now. > > Sorry but I could not understand what broken by newlines mean. Can you explain a little bit further? > Documentation update missing (and eventually changelog). > Is this documentation supposed to be different from the autogenerated one for the functions that I have placed? > > +#if CONFIG_WEIGHTED_GREYEDGE_FILTER > Shouldn't sections of your code also be disabled if this is not set, > not only the options? And intermingled with #if CONFIG_GREYEDGE_FILTER? > > The specific parts of the code activated based on the filter name, and if the filter is not set, wouldn't it be impossible to call that filter? Also git send-email is not working for some reason and I am always stuck on the same SMTP error, so I have attached the patch updated based on the suggestions. Please point out any mistakes I may have made as I do not have much experience in submitting work through patches. Regards, Yatendra Singh. From c19098133770e4ed59372d8f57fdc871723ac52c Mon Sep 17 00:00:00 2001 From: Yatendra Singh Date: Thu, 16 Apr 2020 18:22:55 +0530 Subject: [PATCH] libavfilter/vf_colorconstancy.c : Adding weighted greyedge Signed-off-by: Yatendra Singh --- libavfilter/Makefile| 1 + libavfilter/allfilters.c| 1 + libavfilter/vf_colorconstancy.c | 265 +++- 3 files changed, 232 insertions(+), 35 deletions(-) diff --git a/libavfilter/Makefile b/libavfilter/Makefile index ecbc628868..ba546c32b0 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -448,6 +448,7 @@ OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync.o OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o OBJS-$(CONFIG_WAVEFORM_FILTER) += vf_waveform.o OBJS-$(CONFIG_WEAVE_FILTER) += vf_weave.o +OBJS-$(CONFIG_WEIGHTED_GREYEDGE_FILTER) += vf_colorconstancy.o OBJS-$(CONFIG_XBR_FILTER)+= vf_xbr.o OBJS-$(CONFIG_XFADE_FILTER) += vf_xfade.o OBJS-$(CONFIG_XFADE_OPENCL_FILTER) += vf_xfade_opencl.o opencl.o opencl/xfade.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index fb32bef788..da2adbed21 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -427,6 +427,7 @@ extern AVFilter ff_vf_vstack; extern AVFilter ff_vf_w3fdif; extern AVFilter ff_vf_waveform; extern AVFilter ff_vf_weave; +extern AVFilter ff_vf_weighted_greyedge; extern AVFilter ff_vf_xbr; extern AVFilter ff_vf_xfade; extern AVFilter ff_vf_xfade_opencl; diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c index eae62204b5..27a2fc264e 100644 --- a/libavfilter/vf_colorconstancy.c +++ b/libavfilter/vf_colorconstancy.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2018 Mina Sami + * Copyright (c) 2020 Yatendra Singh * * This file is part of FFmpeg. * @@ -26,6 +27,14 @@ * * @cite * J. van de Weijer, Th. Gevers, A. Gijsenij "Edge-Based Color Constancy". + * + * @cite + * J. van de Weijer, Th. Gevers, and J. Geusebroek, + * “Edge and corner detection by photometric quasi-invariants”. + * + * @cite + * A. Gijsenij, Th. Gevers, J. van de Weijer, + * "Improving Color Constancy by Photometric Edge Weighting". */ #include "libavutil/imgutils.h" @@ -40,8 +49,10 @@ #include #define GREY_EDGE "greyedge" +#define WEIGHTED_GREY_EDGE "weighted_greyedge" #define SQRT3 1.73205080757 +#define NORAMAL_WHITE 1/SQRT3 #define NUM_PLANES3 #define MAX_DIFF_ORD 2 @@ -83,6 +94,11 @@ typedef struct ColorConstancyContext { int planeheight[4]; int planewidth[4]; +double min_err; +int max_iters; + +double *weight_info[2]; + int filtersize; double *gauss[MAX_DIFF_ORD+1]; @@ -552,32 +568,6 @@ static void normalize_light(double *light) } } -/** - * Redirects to corresponding algorithm estimation function and performs normalization - * after estimation. - * - * @param ctx the filter context. - * @param in frame to perfrom estimation on. - * - * @return 0 in case of success, a negative value corresponding to an - * AVERROR code in case of failure. - */ -static int illumination_estimation(AVFilterContext *ctx, AVFrame *in) -{ -ColorConstancyContext *s = ctx->priv; -int ret; - -ret = filter_grey_edge(ctx, in); - -av_log(ctx, AV_LOG_DEBUG, "Estimated illumination= %f %f %f\n", - s->white[0], s->white[1], s->white[2]); -normalize_light(s->white); -av_log(ctx, AV_LOG_DEBUG, "Estimated illumination after normalization= %f %f %f\n", - s->white[0], s->white[1], s->white[2]); - -return ret; -} - /** * Performs simple correction via diagonal transformation model. * @@ -634,6 +624,162 @@ static void chromatic_adaptation(AVFilterContext *ctx, AVFrame *in, AVFrame *out ctx->internal->execute(ctx, diagonal_transformation, &td, NULL, nb_jobs); } +/** + * Slice function for weig
[FFmpeg-devel] [PATCH v9 2/2] avformat: add demuxer for Pro Pinball Series' Soundbanks
Signed-off-by: Zane van Iperen --- Changelog| 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/pp_bnk.c | 293 +++ libavformat/version.h| 2 +- 5 files changed, 297 insertions(+), 1 deletion(-) create mode 100644 libavformat/pp_bnk.c diff --git a/Changelog b/Changelog index 3a87ceb259..536a6b0568 100644 --- a/Changelog +++ b/Changelog @@ -59,6 +59,7 @@ version : - mv30 decoder - Expanded styling support for 3GPP Timed Text Subtitles (movtext) - Cunning Developments ADPCM decoder +- Pro Pinball Series Soundbank demuxer version 4.2: diff --git a/libavformat/Makefile b/libavformat/Makefile index d4bed3c113..b744eb69b2 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -428,6 +428,7 @@ OBJS-$(CONFIG_PCM_VIDC_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_VIDC_MUXER)+= pcmenc.o rawenc.o OBJS-$(CONFIG_PJS_DEMUXER) += pjsdec.o subtitles.o OBJS-$(CONFIG_PMP_DEMUXER) += pmpdec.o +OBJS-$(CONFIG_PP_BNK_DEMUXER)+= pp_bnk.o OBJS-$(CONFIG_PVA_DEMUXER) += pva.o OBJS-$(CONFIG_PVF_DEMUXER) += pvfdec.o pcm.o OBJS-$(CONFIG_QCP_DEMUXER) += qcp.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 39d2c352f5..3919c9e4c1 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -341,6 +341,7 @@ extern AVInputFormat ff_pcm_u8_demuxer; extern AVOutputFormat ff_pcm_u8_muxer; extern AVInputFormat ff_pjs_demuxer; extern AVInputFormat ff_pmp_demuxer; +extern AVInputFormat ff_pp_bnk_demuxer; extern AVOutputFormat ff_psp_muxer; extern AVInputFormat ff_pva_demuxer; extern AVInputFormat ff_pvf_demuxer; diff --git a/libavformat/pp_bnk.c b/libavformat/pp_bnk.c new file mode 100644 index 00..f67f04b699 --- /dev/null +++ b/libavformat/pp_bnk.c @@ -0,0 +1,293 @@ +/* + * Pro Pinball Series Soundbank (44c, 22c, 11c, 5c) demuxer. + * + * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include "avformat.h" +#include "internal.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/avassert.h" +#include "libavutil/internal.h" + +#define PP_BNK_MAX_READ_SIZE4096 +#define PP_BNK_FILE_HEADER_SIZE 20 +#define PP_BNK_TRACK_SIZE 20 + +typedef struct PPBnkHeader { +uint32_tbank_id;/*< Bank ID, useless for our purposes. */ +uint32_tsample_rate;/*< Sample rate of the contained tracks. */ +uint32_talways1;/*< Unknown, always seems to be 1. */ +uint32_ttrack_count;/*< Number of tracks in the file. */ +uint32_tflags; /*< Flags. */ +} PPBnkHeader; + +typedef struct PPBnkTrack { +uint32_tid; /*< Track ID. Usually track[i].id == track[i-1].id + 1, but not always */ +uint32_tsize; /*< Size of the data in bytes. */ +uint32_tsample_rate;/*< Sample rate. */ +uint32_talways1_1; /*< Unknown, always seems to be 1. */ +uint32_talways1_2; /*< Unknown, always seems to be 1. */ +} PPBnkTrack; + +typedef struct PPBnkCtxTrack { +int64_t data_offset; +uint32_tdata_size; +} PPBnkCtxTrack; + +typedef struct PPBnkCtx { +int track_count; +PPBnkCtxTrack *tracks; +uint32_tcurrent_track; +uint32_tbytes_read; +} PPBnkCtx; + +enum { +PP_BNK_FLAG_PERSIST = (1 << 0), /*< This is a large file, keep in memory. */ +PP_BNK_FLAG_MUSIC = (1 << 1), /*< This is music. */ +PP_BNK_FLAG_MASK= (PP_BNK_FLAG_PERSIST | PP_BNK_FLAG_MUSIC) +}; + +static void pp_bnk_parse_header(PPBnkHeader *hdr, const uint8_t *buf) +{ +hdr->bank_id= AV_RL32(buf + 0); +hdr->sample_rate= AV_RL32(buf + 4); +hdr->always1= AV_RL32(buf + 8); +hdr->track_count= AV_RL32(buf + 12); +hdr->flags = AV_RL32(buf + 16); +} + +static void pp_bnk_parse_track(PPBnkTrack *trk, const uint8_t *buf) +{ +trk->id = AV_RL32(buf + 0); +trk->size = AV_RL32(buf + 4); +trk->sample_rate= AV_RL32(buf + 8); +
[FFmpeg-devel] [PATCH v9 1/2] avcodec: add support for Cunning Developments' ADPCM
Signed-off-by: Zane van Iperen --- Changelog | 1 + doc/general.texi| 1 + libavcodec/Makefile | 1 + libavcodec/adpcm.c | 34 ++ libavcodec/adpcm_data.c | 13 + libavcodec/adpcm_data.h | 2 ++ libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 +++ libavcodec/codec_id.h | 1 + libavcodec/version.h| 2 +- 10 files changed, 62 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 6dfe750d81..3a87ceb259 100644 --- a/Changelog +++ b/Changelog @@ -58,6 +58,7 @@ version : - switch from AvxSynth to AviSynth+ on Linux - mv30 decoder - Expanded styling support for 3GPP Timed Text Subtitles (movtext) +- Cunning Developments ADPCM decoder version 4.2: diff --git a/doc/general.texi b/doc/general.texi index 4adcc9e742..4aaf506e56 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1102,6 +1102,7 @@ following image formats are supported: @item ADPCM G.726@tab X @tab X @item ADPCM IMA AMV @tab @tab X @tab Used in AMV files +@item ADPCM IMA Cunning Developments @tab @tab X @item ADPCM IMA Electronic Arts EACS @tab @tab X @item ADPCM IMA Electronic Arts SEAD @tab @tab X @item ADPCM IMA Funcom @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 1970ff027f..3be65bd43c 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -843,6 +843,7 @@ OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_ALP_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_APM_DECODER) += adpcm.o adpcm_data.o +OBJS-$(CONFIG_ADPCM_IMA_CUNNING_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_DK3_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER) += adpcm.o adpcm_data.o diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index ee18875579..d5169fa444 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -16,6 +16,7 @@ * Simon & Schuster Interactive ADPCM decoder by Zane van Iperen (z...@zanevaniperen.com) * Ubisoft ADPCM decoder by Zane van Iperen (z...@zanevaniperen.com) * High Voltage Software ALP decoder by Zane van Iperen (z...@zanevaniperen.com) + * Cunning Developments decoder by Zane van Iperen (z...@zanevaniperen.com) * * This file is part of FFmpeg. * @@ -109,6 +110,9 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) unsigned int max_channels = 2; switch(avctx->codec->id) { +case AV_CODEC_ID_ADPCM_IMA_CUNNING: +max_channels = 1; +break; case AV_CODEC_ID_ADPCM_DTK: case AV_CODEC_ID_ADPCM_EA: min_channels = 2; @@ -325,6 +329,26 @@ static inline int16_t adpcm_ima_mtf_expand_nibble(ADPCMChannelStatus *c, int nib return (int16_t)c->predictor; } +static inline int16_t adpcm_ima_cunning_expand_nibble(ADPCMChannelStatus *c, int8_t nibble) +{ +int step_index; +int predictor; +int step; + +nibble = sign_extend(nibble & 0xF, 4); + +step = ff_adpcm_ima_cunning_step_table[c->step_index]; +step_index = c->step_index + ff_adpcm_ima_cunning_index_table[abs(nibble)]; +step_index = av_clip(step_index, 0, 60); + +predictor = c->predictor + step * nibble; + +c->predictor = av_clip_int16(predictor); +c->step_index = step_index; + +return c->predictor; +} + static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitContext *gb, int bps) { int nibble, step_index, predictor, sign, delta, diff, step, shift; @@ -713,6 +737,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, /* simple 4-bit adpcm */ case AV_CODEC_ID_ADPCM_CT: case AV_CODEC_ID_ADPCM_IMA_APC: +case AV_CODEC_ID_ADPCM_IMA_CUNNING: case AV_CODEC_ID_ADPCM_IMA_EA_SEAD: case AV_CODEC_ID_ADPCM_IMA_OKI: case AV_CODEC_ID_ADPCM_IMA_WS: @@ -1304,6 +1329,14 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, samples += avctx->channels; } break; +case AV_CODEC_ID_ADPCM_IMA_CUNNING: +av_assert0(frame->nb_samples == buf_size * 2); +while (bytestream2_get_bytes_left(&gb) > 0) { +int v = bytestream2_get_byteu(&gb); +*samples++ = adpcm_ima_cunning_expand_nibble(&c->status[0], v & 0x0F); +*samples++ = adpcm_ima_cunning_expand_nibble(&c->status[0], v >> 4); +} +break; case AV_CODEC_ID_ADPCM_IMA_OKI: while (bytestream2_get_bytes_left(&gb) > 0) { int v = bytestream2_get_byteu(&gb); @@ -2053,6 +2086,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS, sample_fmts_s16p, adpcm_ea_xas, ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16, adpcm_ima_amv, "ADPCM IMA AMV"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_I
[FFmpeg-devel] [PATCH v9 0/2] Pro Pinball Series Soundbank demuxer + decoder.
Adds support for the soundbank files used by the Pro Pinball series of games. v9: [6] - Rebase after codec_id.h changes - style fixes - Fix an uninitialised variable read v8: [5] - change "goto done" to a return + "goto fail" - Handle truncated files - Fix potential byte counter desync v7: [4] - Fix empty lines - Use av_malloc_array() instead of av_reallocp_array() - Replace multiple av_freep()'s with a goto - Minor comment cleanups - Ask for a sample if unexpected header values are found v6: [3] - fix tools/probetest failure v5: - add probe function - add flag #define's v4: [2] - fix adpcm index table type v3: [1] - fix potential memory leak if read_header() fails - fix a buffer overread - attempt seek before updating state - remove unneeded check - naming fixes v2: - Add sanity checks in header fields - Formatting and comment fixes - Change the struct names to match the files [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/258672.html [2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/258918.html [3]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259278.html [4]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/259864.html [5]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/259863.html [6]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/260706.html Zane van Iperen (2): avcodec: add support for Cunning Developments' ADPCM avformat: add demuxer for Pro Pinball Series' Soundbanks Changelog| 2 + doc/general.texi | 1 + libavcodec/Makefile | 1 + libavcodec/adpcm.c | 34 + libavcodec/adpcm_data.c | 13 ++ libavcodec/adpcm_data.h | 2 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 + libavcodec/codec_id.h| 1 + libavcodec/version.h | 2 +- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/pp_bnk.c | 293 +++ libavformat/version.h| 2 +- 14 files changed, 359 insertions(+), 2 deletions(-) create mode 100644 libavformat/pp_bnk.c -- 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] avfilter/af_astats: measure noise floor
Signed-off-by: Paul B Mahol --- doc/filters.texi| 5 +++ libavfilter/af_astats.c | 80 - 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index 856d8ae6ac..985f9b7970 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -2329,6 +2329,7 @@ RMS_trough Crest_factor Flat_factor Peak_count +Noise_floor Bit_depth Dynamic_range Zero_crossings @@ -2351,6 +2352,7 @@ RMS_peak RMS_trough Flat_factor Peak_count +Noise_floor Bit_depth Number_of_samples Number_of_NaNs @@ -2422,6 +2424,9 @@ Flatness (i.e. consecutive samples with the same value) of the signal at its pea Number of occasions (not the number of samples) that the signal attained either @var{Min level} or @var{Max level}. +@item Noise floor dB +Minimum local peak measured in dBFS over a short window. + @item Bit depth Overall bit depth of audio. Number of bits used for each sample. diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c index 7707f3158d..75ca4f193f 100644 --- a/libavfilter/af_astats.c +++ b/libavfilter/af_astats.c @@ -27,6 +27,9 @@ #include "avfilter.h" #include "internal.h" +#define HISTOGRAM_SIZE 8192 +#define HISTOGRAM_MAX (HISTOGRAM_SIZE-1) + #define MEASURE_ALL UINT_MAX #define MEASURE_NONE 0 @@ -52,6 +55,7 @@ #define MEASURE_NUMBER_OF_NANS (1 << 19) #define MEASURE_NUMBER_OF_INFS (1 << 20) #define MEASURE_NUMBER_OF_DENORMALS (1 << 21) +#define MEASURE_NOISE_FLOOR (1 << 22) #define MEASURE_MINMAXPEAK (MEASURE_MIN_LEVEL | MEASURE_MAX_LEVEL | MEASURE_PEAK_LEVEL) @@ -75,6 +79,11 @@ typedef struct ChannelStats { uint64_t nb_nans; uint64_t nb_infs; uint64_t nb_denormals; +double *win_samples; +unsigned histogram[HISTOGRAM_SIZE]; +int win_pos; +int max_index; +double noise_floor; } ChannelStats; typedef struct AudioStatsContext { @@ -122,6 +131,7 @@ static const AVOption astats_options[] = { { "Dynamic_range" , "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_DYNAMIC_RANGE }, 0, 0, FLAGS, "measure" }, { "Zero_crossings", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_ZERO_CROSSINGS }, 0, 0, FLAGS, "measure" }, { "Zero_crossings_rate" , "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_ZERO_CROSSINGS_RATE }, 0, 0, FLAGS, "measure" }, + { "Noise_floor" , "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_NOISE_FLOOR }, 0, 0, FLAGS, "measure" }, { "Number_of_samples" , "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_NUMBER_OF_SAMPLES }, 0, 0, FLAGS, "measure" }, { "Number_of_NaNs", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_NUMBER_OF_NANS }, 0, 0, FLAGS, "measure" }, { "Number_of_Infs", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_NUMBER_OF_INFS }, 0, 0, FLAGS, "measure" }, @@ -197,6 +207,10 @@ static void reset_stats(AudioStatsContext *s) p->nb_infs = 0; p->nb_denormals = 0; p->last = NAN; +p->noise_floor = NAN; +p->win_pos = 0; +memset(p->win_samples, 0, s->tc_samples * sizeof(*p->win_samples)); +memset(p->histogram, 0, sizeof(p->histogram)); } } @@ -207,9 +221,19 @@ static int config_output(AVFilterLink *outlink) s->chstats = av_calloc(sizeof(*s->chstats), outlink->channels); if (!s->chstats) return AVERROR(ENOMEM); + +s->tc_samples = 5 * s->time_constant * outlink->sample_rate + .5; s->nb_channels = outlink->channels; + +for (int i = 0; i < s->nb_channels; i++) { +ChannelStats *p = &s->chstats[i]; + +p->win_samples = av_calloc(s->tc_samples, sizeof(*p->win_samples)); +if (!p->win_samples) +return AVERROR(ENOMEM); +} + s->mult = exp((-1 / s->time_constant / outlink->sample_rate)); -s->tc_samples = 5 * s->time_constant * outlink->sample_rate + .5; s->nb_frames = 0; s->maxbitdepth = av_get_bytes_per_sample(outlink->format) * 8; s->is_double = outlink->format == AV_SAMPLE_FMT_DBL || @@ -249,6 +273,9 @@ static inline void update_minmax(AudioStatsContext *s, ChannelStats *p, double d static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d, double nd, int64_t i) { +double drop; +int index; + if (d < p->min) { p->min = d; p->nmin = nd; @@ -296,6 +323,38 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d, p->mask |= i; p->imask &= i; +drop = p->win_samples[p->win_pos]; +p->win_samples[p->win_pos] = nd; +index = av_clip(FFABS(nd) * HISTOGRAM_MAX, 0, HISTOGRAM_MAX); +p->max_index = FFMAX(p->max_index, index); +p->histogram[index]++; +if (!isnan(p->noise_floor)) +p->histogram[av_clip(FFABS(drop) * HISTOGRAM_MAX, 0, HISTOGRAM_MAX)]--; +p->wi
[FFmpeg-devel] [PATCH 3/3] lavc/pgs_frame_split_bsf: add bsf to split PGS segments
Requried to remux mkv to m2ts --- libavcodec/Makefile | 1 + libavcodec/bitstream_filters.c | 1 + libavcodec/pgs_frame_split_bsf.c | 176 +++ 3 files changed, 178 insertions(+) create mode 100644 libavcodec/pgs_frame_split_bsf.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 13909faabf..948aee0252 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1120,6 +1120,7 @@ OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)+= vp9_raw_reorder_bsf.o OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF) += vp9_superframe_split_bsf.o OBJS-$(CONFIG_PGS_FRAME_MERGE_BSF)+= pgs_frame_merge_bsf.o +OBJS-$(CONFIG_PGS_FRAME_SPLIT_BSF)+= pgs_frame_split_bsf.o # thread libraries OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c index 138f6dd7ad..5422392e11 100644 --- a/libavcodec/bitstream_filters.c +++ b/libavcodec/bitstream_filters.c @@ -59,6 +59,7 @@ extern const AVBitStreamFilter ff_vp9_raw_reorder_bsf; extern const AVBitStreamFilter ff_vp9_superframe_bsf; extern const AVBitStreamFilter ff_vp9_superframe_split_bsf; extern const AVBitStreamFilter ff_pgs_frame_merge_bsf; +extern const AVBitStreamFilter ff_pgs_frame_split_bsf; #include "libavcodec/bsf_list.c" diff --git a/libavcodec/pgs_frame_split_bsf.c b/libavcodec/pgs_frame_split_bsf.c new file mode 100644 index 00..c983f6acf5 --- /dev/null +++ b/libavcodec/pgs_frame_split_bsf.c @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2020 John Stebbins + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * This bitstream filter splits PGS subtitle packets into packets containing + * just one segment. + * + * Packets already containing only one segment will be passed through + * unchanged. + */ + +#include "avcodec.h" +#include "bsf.h" +#include "libavutil/intreadwrite.h" + +enum PGSSegmentType { +PALETTE_SEGMENT = 0x14, +OBJECT_SEGMENT = 0x15, +PRESENTATION_SEGMENT = 0x16, +WINDOW_SEGMENT = 0x17, +DISPLAY_SEGMENT = 0x80, +}; + +typedef struct PGSSplitContext { +AVPacket *in; +} PGSSplitContext; + +static int frame_split_filter(AVBSFContext *bsf, AVPacket *out) +{ +PGSSplitContext *ctx = bsf->priv_data; +AVPacket *in = ctx->in; +int i, ret; +uint8_t segment_type; +uint16_t segment_len; +int split = !!in->data; + +if (!in->data) { +ret = ff_bsf_get_packet_ref(bsf, in); +if (ret < 0) +return ret; +} +if (!in->size) { +av_packet_unref(in); +return AVERROR(EAGAIN); +} + +// Validate packet data +i = 0; +while (i < in->size) { +segment_type = in->data[i]; +segment_len = AV_RB16(in->data + i + 1) + 3; +i += segment_len; +} +if (i != in->size) { +av_log(bsf, AV_LOG_WARNING, "Failed to parse PGS segments.\n"); +av_packet_move_ref(out, in); +return 0; +} + +segment_type = in->data[0]; +segment_len = AV_RB16(in->data + 1) + 3; +if (split || segment_len < in->size) { // Split +int64_t ts_delta, dts; + +ret = av_packet_ref(out, in); +if (ret < 0) +goto fail; +out->size = segment_len; +in->data += segment_len; +in->size -= segment_len; + +// Update PTS/DTS, Stagger timestamps by 3ms +ts_delta = 270; // Assume 90khz tick if no time_base_in +if (bsf->time_base_in.num && bsf->time_base_in.den) +ts_delta = bsf->time_base_in.den / bsf->time_base_in.num / 333; +if (ts_delta == 0) +ts_delta = 1; + +// Compute DTS, it's the same for all packets that carry it +// Assuming input PTS/DTS come from original presentation_segment +if (in->dts <= in->pts - 2 * ts_delta && +in->dts != AV_NOPTS_VALUE) +dts = in->dts; +else if (in->pts != AV_NOPTS_VALUE) +dts = in->pts - 2 * ts_delta; + +switch (segment_type) { +case DISPLAY_SEGMENT: +if (in->pts != AV_NOPTS_VALUE) +out->pts = in->pts - ts_delta; +
[FFmpeg-devel] [PATCH 1/3] lavc/pgs_frame_merge_bsf: add bsf to merge PGS segments
Required to remux m2ts to mkv --- libavcodec/Makefile | 1 + libavcodec/bitstream_filters.c | 1 + libavcodec/pgs_frame_merge_bsf.c | 152 +++ 3 files changed, 154 insertions(+) create mode 100644 libavcodec/pgs_frame_merge_bsf.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index c1c9a44f2b..13909faabf 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1119,6 +1119,7 @@ OBJS-$(CONFIG_VP9_METADATA_BSF) += vp9_metadata_bsf.o OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)+= vp9_raw_reorder_bsf.o OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF) += vp9_superframe_split_bsf.o +OBJS-$(CONFIG_PGS_FRAME_MERGE_BSF)+= pgs_frame_merge_bsf.o # thread libraries OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c index 6b5ffe4d70..138f6dd7ad 100644 --- a/libavcodec/bitstream_filters.c +++ b/libavcodec/bitstream_filters.c @@ -58,6 +58,7 @@ extern const AVBitStreamFilter ff_vp9_metadata_bsf; extern const AVBitStreamFilter ff_vp9_raw_reorder_bsf; extern const AVBitStreamFilter ff_vp9_superframe_bsf; extern const AVBitStreamFilter ff_vp9_superframe_split_bsf; +extern const AVBitStreamFilter ff_pgs_frame_merge_bsf; #include "libavcodec/bsf_list.c" diff --git a/libavcodec/pgs_frame_merge_bsf.c b/libavcodec/pgs_frame_merge_bsf.c new file mode 100644 index 00..4b8061d4e1 --- /dev/null +++ b/libavcodec/pgs_frame_merge_bsf.c @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2020 John Stebbins + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * This bitstream filter merges PGS subtitle packets containing incomplete + * set of segments into a single packet + * + * Packets already containing a complete set of segments will be passed through + * unchanged. + */ + +#include "avcodec.h" +#include "bsf.h" +#include "libavutil/intreadwrite.h" + +enum PGSSegmentType { +PALETTE_SEGMENT = 0x14, +OBJECT_SEGMENT = 0x15, +PRESENTATION_SEGMENT = 0x16, +WINDOW_SEGMENT = 0x17, +DISPLAY_SEGMENT = 0x80, +}; + +typedef struct PGSMergeContext { +AVPacket *buffer_pkt, *in; +} PGSMergeContext; + +static void frame_merge_flush(AVBSFContext *bsf) +{ +PGSMergeContext *ctx = bsf->priv_data; + +av_packet_unref(ctx->in); +av_packet_unref(ctx->buffer_pkt); +} + +static int frame_merge_filter(AVBSFContext *bsf, AVPacket *out) +{ +PGSMergeContext *ctx = bsf->priv_data; +AVPacket *in = ctx->in, *pkt = ctx->buffer_pkt; +int ret, i, size, pos, display = 0; +uint8_t segment_type; +uint16_t segment_len; + +if (!in->data) { +ret = ff_bsf_get_packet_ref(bsf, in); +if (ret < 0) +return ret; +} +if (!in->size) { +av_packet_unref(in); +return AVERROR(EAGAIN); +} + +// Validate packet data and find display_end segment +size = in->size; +i = 0; +while (i < in->size) { +segment_type = in->data[i]; +segment_len = AV_RB16(in->data + i + 1) + 3; +if (segment_type == DISPLAY_SEGMENT) { +size = display = i + segment_len; +break; +} +if (segment_type == PRESENTATION_SEGMENT) { +av_packet_copy_props(pkt, in); +pkt->pts = in->pts; +pkt->dts = in->dts; +} +i += segment_len; +} +if ((!display && i != in->size) || size > in->size) { +av_log(ctx, AV_LOG_WARNING, "Failed to parse PGS segments.\n"); +// force output what we have +display = size = in->size;; +} + +pos = pkt->size; +ret = av_grow_packet(pkt, size); +if (ret < 0) +goto fail; +memcpy(pkt->data + pos, in->data, size); + +if (size == in->size) +av_packet_unref(in); +else { +in->data += size; +in->size -= size; +} + +if (display) { +av_packet_move_ref(out, pkt); +av_packet_copy_props(pkt, out); +return 0; +} +return AVERROR(EAGAIN); + +fail: +frame_merge_flush(bsf); +return ret; +} + +static int frame_merge_init(AVBSFContext *bsf) +{ +PGSMergeContext *c
[FFmpeg-devel] [PATCH 2/3] lavf/matroskaenc: add PGS merge to auto bsf list
PGS segments must be merged to one packet for muxing to mkv --- libavformat/matroskaenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 060e8b7816..6d88fcd784 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2658,6 +2658,8 @@ static int mkv_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt) ret = ff_stream_add_bitstream_filter(st, "aac_adtstoasc", NULL); } else if (st->codecpar->codec_id == AV_CODEC_ID_VP9) { ret = ff_stream_add_bitstream_filter(st, "vp9_superframe", NULL); +} else if (st->codecpar->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE) { +ret = ff_stream_add_bitstream_filter(st, "pgs_frame_merge", NULL); } return ret; -- 2.25.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 v1] avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet
Sorry, forgot to reply to that. Limin Wang (12020-04-04): > the md5 framecrc is generated by libavformat/tests/movenc.c, I have no > clue how the movenc testing work and how to get the real input to check why > the frame isn't bitexact as I haven't see any subtitle track. Well, check: re-run the test manually, change it to have an actual output, examine the file. The possibilities are many. But tests are there for a reason. If a patch changes the output of tests, then we cannot accept it unless somebody did examine the changes very carefully and confirmed they are for the best. Ideally, an explanation of the changes goes in the commit message. Regards, -- Nicolas George 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".
[FFmpeg-devel] [PATCH 1/4] lavfi/formats: add ff_formats_pixdesc_filter().
Signed-off-by: Nicolas George --- libavfilter/formats.c | 41 + libavfilter/formats.h | 10 ++ 2 files changed, 51 insertions(+) I need it in new code. diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 33c64668a0..784f604483 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -373,6 +373,47 @@ const int64_t avfilter_all_channel_layouts[] = { -1 }; +int ff_formats_pixdesc_filter(AVFilterFormats **rfmts, unsigned want, unsigned rej) +{ +unsigned nb_formats, fmt, flags; +AVFilterFormats *formats = NULL; + +while (1) { +nb_formats = 0; +for (fmt = 0;; fmt++) { +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); +if (!desc) +break; +flags = desc->flags; +if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL) && +!(desc->flags & AV_PIX_FMT_FLAG_PLANAR) && +(desc->log2_chroma_w || desc->log2_chroma_h)) +flags |= FF_PIX_FMT_FLAG_SW_FLAT_SUB; +if ((flags & (want | rej)) != want) +continue; +if (formats) +formats->formats[nb_formats] = fmt; +nb_formats++; +} +if (formats) { +av_assert0(formats->nb_formats == nb_formats); +*rfmts = formats; +return 0; +} +formats = av_mallocz(sizeof(*formats)); +if (!formats) +return AVERROR(ENOMEM); +formats->nb_formats = nb_formats; +if (nb_formats) { +formats->formats = av_malloc_array(nb_formats, sizeof(*formats->formats)); +if (!formats->formats) { +av_freep(&formats); +return AVERROR(ENOMEM); +} +} +} +} + // AVFilterFormats *avfilter_make_all_channel_layouts(void) // { // return avfilter_make_format64_list(avfilter_all_channel_layouts); diff --git a/libavfilter/formats.h b/libavfilter/formats.h index 870809b5a0..cc588f30d8 100644 --- a/libavfilter/formats.h +++ b/libavfilter/formats.h @@ -221,6 +221,16 @@ int ff_add_format(AVFilterFormats **avff, int64_t fmt); av_warn_unused_result AVFilterFormats *ff_all_formats(enum AVMediaType type); +/** + * Construct a formats list containing all pixel formats with certain + * properties + */ +av_warn_unused_result +int ff_formats_pixdesc_filter(AVFilterFormats **rfmts, unsigned want, unsigned rej); + +//* format is software, non-planar with sub-sampling +#define FF_PIX_FMT_FLAG_SW_FLAT_SUB (1 << 24) + /** * Construct a formats list containing all planar sample formats. */ -- 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".
[FFmpeg-devel] [PATCH 2/4] lavfi/vf_crop: use ff_formats_pixdesc_filter().
Signed-off-by: Nicolas George --- libavfilter/vf_crop.c | 21 - 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index 502defd0a5..3d5cb95f78 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -94,24 +94,11 @@ typedef struct CropContext { static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; -int fmt, ret; - -for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) { -const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); -if (desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) -continue; -if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { -// Not usable if there is any subsampling but the format is -// not planar (e.g. YUYV422). -if ((desc->log2_chroma_w || desc->log2_chroma_h) && -!(desc->flags & AV_PIX_FMT_FLAG_PLANAR)) -continue; -} -ret = ff_add_format(&formats, fmt); -if (ret < 0) -return ret; -} +int ret; +ret = ff_formats_pixdesc_filter(&formats, 0, AV_PIX_FMT_FLAG_BITSTREAM | FF_PIX_FMT_FLAG_SW_FLAT_SUB); +if (ret < 0) +return ret; return ff_set_common_formats(ctx, formats); } -- 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".
[FFmpeg-devel] [PATCH 4/4] lavfi/tests/formats: reindent.
Signed-off-by: Nicolas George --- libavfilter/tests/formats.c | 136 ++-- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/libavfilter/tests/formats.c b/libavfilter/tests/formats.c index d8b8079ef6..ee497f3b90 100644 --- a/libavfilter/tests/formats.c +++ b/libavfilter/tests/formats.c @@ -23,74 +23,74 @@ #undef printf const int64_t avfilter_all_channel_layouts[] = { -AV_CH_FRONT_CENTER, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY, -AV_CH_FRONT_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_BACK_CENTER, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER, -AV_CH_FRONT_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_BACK_CENTER|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CE
[FFmpeg-devel] [PATCH 3/4] lavfi/formats: remove dead code.
Move the contents of all_channel_layouts.inc directly into libavfilter/tests/formats.c. Signed-off-by: Nicolas George --- libavfilter/all_channel_layouts.inc | 68 --- libavfilter/formats.c | 10 libavfilter/tests/formats.c | 72 + 3 files changed, 72 insertions(+), 78 deletions(-) delete mode 100644 libavfilter/all_channel_layouts.inc diff --git a/libavfilter/all_channel_layouts.inc b/libavfilter/all_channel_layouts.inc deleted file mode 100644 index 878e1f5f8e..00 --- a/libavfilter/all_channel_layouts.inc +++ /dev/null @@ -1,68 +0,0 @@ -AV_CH_FRONT_CENTER, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY, -AV_CH_FRONT_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_BACK_CENTER, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER, -AV_CH_FRONT_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY|AV_CH_BACK_CENTER|AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT, -AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT|AV
Re: [FFmpeg-devel] [PATCH] avfilter/af_astats: measure noise floor
On 4/16/20, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > doc/filters.texi| 5 +++ > libavfilter/af_astats.c | 80 - > 2 files changed, 84 insertions(+), 1 deletion(-) > Will apply. ___ 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: add maskedthreshold filter
On 4/15/20, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > doc/filters.texi | 15 ++ > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/vf_maskedthreshold.c | 298 +++ > 4 files changed, 315 insertions(+) > create mode 100644 libavfilter/vf_maskedthreshold.c > Will apply. ___ 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: add tmedian filter
On 4/13/20, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > doc/filters.texi | 19 +++ > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/vf_xmedian.c | 108 +-- > 4 files changed, 124 insertions(+), 5 deletions(-) > Will apply. ___ 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/af_astats: measure noise floor
On 16/04/2020 17:11, Paul B Mahol wrote: > Will apply. Please wait more than an hour and a half. Timezones exist. - Derek ___ 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/4] lavfi/formats: add ff_formats_pixdesc_filter().
On 16/04/2020 16:28, Nicolas George wrote: > Signed-off-by: Nicolas George > --- > libavfilter/formats.c | 41 + > libavfilter/formats.h | 10 ++ > 2 files changed, 51 insertions(+) (Just a commnt out of curiosity.) Are there more filters than vf_crop that this is intended to be used on? - Derek ___ 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/4] avcodec: move avcodec_flush_buffers from decode.c to utils.c
On Tue, 10 Mar 2020 16:33:41 -0300 James Almer wrote: > > I can withdraw this patch (And remove the relevant chunks from the > following two) if this function was effectively not meant for > encoders. Also maybe poke Timo regarding nvenc flushing, to see why > it is needed and if there's an alternative. I've pushed the change to formalise the encoder flush semantics, so this should be good to apply now. --phil ___ 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: add tmedian filter
On 16/04/2020 17:10, Paul B Mahol wrote: > Will apply. Your behavior here is still unacceptable. You have dismissed or ignore both comments without any given reason. - Derek ___ 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/4] lavfi/formats: add ff_formats_pixdesc_filter().
Derek Buitenhuis (12020-04-16): > (Just a commnt out of curiosity.) > > Are there more filters than vf_crop that this is intended to be used on? I said: >> I need it in new code. It is to be a filter that has constraints similar to vf_crop. But also, ff_all_formats() can be implemented in terms of this function, which makes it more efficient (there was an old thread about this). Also, I just checked: all these filters do a similar thing in their query_formats() function, which means this should have been done years ago. I don't intend to change them all, anybody can do it. vf_boxblur.c vf_copy.c vf_detelecine.c vf_fieldhint.c vf_fieldorder.c vf_hflip.c vf_hwdownload.c vf_il.c vf_mix.c vf_noise.c vf_stack.c vf_swaprect.c vf_swapuv.c vf_telecine.c vf_transpose.c vf_weave.c Regards, -- Nicolas George 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: add tmedian filter
On 4/16/20, Derek Buitenhuis wrote: > On 16/04/2020 17:10, Paul B Mahol wrote: >> Will apply. > > Your behavior here is still unacceptable. You have dismissed or ignore > both comments without any given reason. I gave reason. They are either complicated or very slow. ___ 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/4] avcodec: move avcodec_flush_buffers from decode.c to utils.c
On 4/16/2020 1:26 PM, Philip Langdale wrote: > On Tue, 10 Mar 2020 16:33:41 -0300 > James Almer wrote: >> >> I can withdraw this patch (And remove the relevant chunks from the >> following two) if this function was effectively not meant for >> encoders. Also maybe poke Timo regarding nvenc flushing, to see why >> it is needed and if there's an alternative. > > I've pushed the change to formalise the encoder flush semantics, so > this should be good to apply now. All encoders were ported, so yes, it could be pushed. But i wonder if this should go in after 4.3 is tagged rather than now. I'd like this to have some months of testing in master before making it into a release. Unless 4.3 is months away, in which case i'll just push it now. ___ 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: add tmedian filter
Paul B Mahol (12020-04-16): > I gave reason. They are either complicated or very slow. I am sorry, but re-reading your answers, I do not see reasons, I see terse answers that show you can't be bothered to even consider the suggestion. This is not how a collaboration project works. If there are remarks about a patch, the discussion must go on until everybody involved is satisfied. People being discouraged of discussing is not the same thing. Which brings to the painful question: When somebody doesn't work well with the project, including frequently setting very shorts ultimatums to push patches without reviews or bypassing comments, should they keep their commit rights? -- Nicolas George 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: add tmedian filter
On 4/16/20, Nicolas George wrote: > Paul B Mahol (12020-04-16): >> I gave reason. They are either complicated or very slow. > > I am sorry, but re-reading your answers, I do not see reasons, I see > terse answers that show you can't be bothered to even consider the > suggestion. > > This is not how a collaboration project works. If there are remarks > about a patch, the discussion must go on until everybody involved is > satisfied. People being discouraged of discussing is not the same thing. > > Which brings to the painful question: > > When somebody doesn't work well with the project, including frequently > setting very shorts ultimatums to push patches without reviews or > bypassing comments, should they keep their commit rights? > Why we should listen to your requests? Who you are to demand changes to code? I'm not bypassing comments, I just state that they are immature, like yours. ___ 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] avcodec: add a WebP parser
On Mon, Apr 13, 2020 at 5:58 PM James Almer wrote: > > Based on code from the BMP parser. > > Addresses ticket #8574 > > Signed-off-by: James Almer > --- > libavcodec/Makefile | 1 + > libavcodec/parsers.c | 1 + > libavcodec/webp_parser.c | 112 +++ > 3 files changed, 114 insertions(+) > create mode 100644 libavcodec/webp_parser.c > lgtm. ___ 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/mv30: remove unused table elements
ok, please apply. On 4/12/20, Peter Ross wrote: > --- > libavcodec/mv30.c | 16 > 1 file changed, 16 deletions(-) > > diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c > index ffa04ac493..6e25ed647b 100644 > --- a/libavcodec/mv30.c > +++ b/libavcodec/mv30.c > @@ -86,14 +86,6 @@ static const uint8_t luma_tab[] = { > 25, 31, 42, 48, 58, 72, 81, 75, > 38, 46, 54, 61, 71, 84, 88, 85, > 50, 61, 65, 68, 79, 78, 86, 91, > -12, 12, 16, 18, 20, 30, 40, 45, > -12, 12, 16, 18, 30, 40, 45, 50, > -16, 16, 20, 30, 40, 45, 50, 55, > -18, 18, 35, 40, 45, 50, 55, 60, > -20, 30, 40, 45, 50, 55, 60, 65, > -30, 40, 45, 50, 55, 60, 65, 70, > -40, 45, 50, 55, 60, 65, 70, 75, > -45, 50, 55, 60, 65, 70, 75, 80, > }; > > static const uint8_t chroma_tab[] = { > @@ -105,14 +97,6 @@ static const uint8_t chroma_tab[] = { > 99, 99, 99, 99, 99, 99, 99, 99, > 99, 99, 99, 99, 99, 99, 99, 99, > 99, 99, 99, 99, 99, 99, 99, 99, > -12, 16, 20, 24, 28, 36, 40, 44, > -16, 20, 24, 28, 36, 40, 44, 50, > -20, 24, 28, 36, 40, 44, 50, 60, > -24, 28, 36, 40, 44, 50, 60, 80, > -28, 36, 40, 44, 50, 60, 80, 99, > -36, 40, 44, 50, 60, 80, 99, 99, > -40, 44, 50, 60, 80, 99, 99, 99, > -44, 50, 60, 80, 99, 99, 99, 99, > }; > > static const uint8_t zigzag[] = { > -- > 2.20.1 > > -- Peter > (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) > ___ 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] avcodec: add a WebP parser
On 4/16/2020 2:29 PM, James Zern wrote: > On Mon, Apr 13, 2020 at 5:58 PM James Almer wrote: >> >> Based on code from the BMP parser. >> >> Addresses ticket #8574 >> >> Signed-off-by: James Almer >> --- >> libavcodec/Makefile | 1 + >> libavcodec/parsers.c | 1 + >> libavcodec/webp_parser.c | 112 +++ >> 3 files changed, 114 insertions(+) >> create mode 100644 libavcodec/webp_parser.c >> > > lgtm. Applied, thanks. ___ 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 v2] ffmpeg: allow full range of dts_delta_threshold
On Wed, Apr 15, 2020 at 11:07:05PM +0530, Gyan Doshi wrote: > > > On 15-04-2020 10:39 pm, Michael Niedermayer wrote: > >On Wed, Apr 15, 2020 at 05:29:06PM +0530, Gyan Doshi wrote: > >> > >>On 15-04-2020 05:03 pm, Michael Niedermayer wrote: > >>>On Wed, Apr 15, 2020 at 10:55:47AM +0530, Gyan Doshi wrote: > On 15-04-2020 01:33 am, Michael Niedermayer wrote: > >On Tue, Apr 14, 2020 at 02:48:47PM +0530, Gyan Doshi wrote: > >>For inputs from demuxers with AVFMT_TS_DISCONT flag, > >>the existing condition, > >> > >> delta < -1LL*dts_delta_threshold*AV_TIME_BASE > >> > >>is rendered superflous due to the fixed threshold in > >> > >>pkt_dts + AV_TIME_BASE/10 < FFMAX(ist->pts, ist->dts) > >> > >>This prevents users from setting a high threshold to > >>avoid discontinuity correction due to errant timestamps. > >> > >>Now, the maximum of the two thresholds is used. > >> > >>fate-mpeg4-resolution-change call changed to preserve existing > >>timestamp correction by ffmpeg.c > >>--- > >>Tested with multiple satellite MPEG-TS inputs. > >> > >> fftools/ffmpeg.c | 2 +- > >> tests/fate/mpeg4.mak | 2 +- > >> 2 files changed, 2 insertions(+), 2 deletions(-) > >breaks: > >./ffmpeg -i 'concat:angels.mpg|angels.mpg' -vsync 0 file.avi > > > >... > >frame= 24 fps=0.0 q=12.5 Lsize= 215kB time=00:00:07.50 bitrate= > >234.7kbits/s speed=75.5x > >video:84kB audio:110kB subtitle:0kB other streams:0kB global headers:0kB > >muxing overhead: 10.697786% > > > >vs. > > > >... > >[avi @ 0x5601caccc180] Non-monotonous DTS in output stream 0:1; > >previous: 219, current: 86; changing to 220. This may result in > >incorrect timestamps in the output file. > >[avi @ 0x5601caccc180] Non-monotonous DTS in output stream 0:1; > >previous: 220, current: 87; changing to 221. This may result in > >incorrect timestamps in the output file. > >[avi @ 0x5601caccc180] Non-monotonous DTS in output stream 0:1; > >previous: 221, current: 88; changing to 222. This may result in > >incorrect timestamps in the output file. > >[avi @ 0x5601caccc180] Non-monotonous DTS in output stream 0:1; > >previous: 222, current: 89; changing to 223. This may result in > >incorrect timestamps in the output file. > >[avi @ 0x5601caccc180] Non-monotonous DTS in output stream 0:1; > >previous: 223, current: 90; changing to 224. This may result in > >incorrect timestamps in the output file. > >[avi @ 0x5601caccc180] Non-monotonous DTS in output stream 0:1; > >previous: 224, current: 91; changing to 225. This may result in > >incorrect timestamps in the output file. > >[mpeg4 @ 0x5601cac87540] Invalid pts (72) <= last (83) > >Video encoding failed > Yes, if the input includes a mid-stream dts reset of gap less than the > default value of dts_delta_threshold then timestamps won't be made > continuous. Default value is 10 seconds but till now it wasn't enforced > for > negative jumps, so your command worked. With this change, user will have > to > set it manually if they expect smaller jumps. > >>>Negative jumps should always be a discontinuity more or less. > >>>What are you trying to fix exactly ? > >>> > >>>is this about bitstream errors in the timestamps ? > >>Yes. This is when there's a backward jump in one of the streams due to > >>corruption in the input and that leads to a new ts_offset. This new offset > >>when applied to other streams with error-free timestamps leads to async as > >>well as muxing errors due to (now) increased interval in the muxing queue. > >>dts_delta_threshold (in combination with filtering) should allow to prevent > >>these offset adjustments at the cost of filtering out or adjusting a few > >>packets, but the existing check prevents that by making 'delta < > >>-1LL*dts_delta_threshold*AV_TIME_BASE' irrelevant . With this patch, the > >>user can set a threshold and avoid unwanted offset adjustments due to > >>negative jumps. > >iam still not sure we talk about the same thing > >if there is corruption in the timestamp field then on average > >the timestamp delta will be large and a threshold will not work > >in seperating that reliably from discontinuities. > > > >to detect / filter such issues looking at more than just the next > >timestamp would be needed > >as in > >5,6,7,79861 you dont know if this is > >5,6,7,79861,79862,79863 > >or > >5,6,7,79861,9,10, > >without seeing the next values > > Right. So I'm talking about scenarios where the user *knows* that the input > is supposed to be > > 85006,85007,85008,85009,...95443,0,1,2,3,4,5... > > but is received as > > 85006,85007,24104,85009...95443,0,1,2,14131,4,5... > > Without this patch, user can set a threshold to ignore 2,14131 but not > 85007,24104. dts_delta_threshold is not there for detecting bitstream
Re: [FFmpeg-devel] [PATCH 1/4] lavfi/formats: add ff_formats_pixdesc_filter().
On 16/04/2020 17:48, Nicolas George wrote: > Derek Buitenhuis (12020-04-16): >> (Just a commnt out of curiosity.) >> >> Are there more filters than vf_crop that this is intended to be used on? > > I said: > >>> I need it in new code. It wasn't clear to me what 'new code' entailed here, at the time. > It is to be a filter that has constraints similar to vf_crop. > > But also, ff_all_formats() can be implemented in terms of this function, > which makes it more efficient (there was an old thread about this). > > Also, I just checked: all these filters do a similar thing in their > query_formats() function, which means this should have been done years > ago. I don't intend to change them all, anybody can do it. > > vf_boxblur.c > vf_copy.c > vf_detelecine.c > vf_fieldhint.c > vf_fieldorder.c > vf_hflip.c > vf_hwdownload.c > vf_il.c > vf_mix.c > vf_noise.c > vf_stack.c > vf_swaprect.c > vf_swapuv.c > vf_telecine.c > vf_transpose.c > vf_weave.c Thanks for the info! - Derek ___ 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: add tmedian filter
On 16/04/2020 18:23, Paul B Mahol wrote: > Why we should listen to your requests? Who you are to demand changes to code? > > I'm not bypassing comments, I just state that they are immature, like yours. That the FFmpeg community continues to put up with this sort of behavior, more often than no remaining entirely silent, aside from a few people, really does speak volumes. Not much has changed since 2016. - Derek ___ 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: add tmedian filter
On 4/16/20, Derek Buitenhuis wrote: > On 16/04/2020 18:23, Paul B Mahol wrote: >> Why we should listen to your requests? Who you are to demand changes to >> code? >> >> I'm not bypassing comments, I just state that they are immature, like >> yours. > > That the FFmpeg community continues to put up with this sort > of behavior, more often than no remaining entirely silent, aside from > a few people, really does speak volumes. Not much has changed since 2016. > Yes, you are judge, jury and lawyer at same time. ___ 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] lavfi: add new iteration API
On Wed, Apr 15, 2020 at 03:00:32PM -0700, Josh Allmann wrote: > On Tue, 14 Apr 2020 at 01:53, Josh de Kock wrote: > > > > Hi, > > > > On Mon, Apr 13, 2020, at 10:32 PM, Josh Allmann wrote: > > > Hi, > > > > > > On Sat, 24 Mar 2018 at 14:40, Josh de Kock wrote: > > > > > > > > Signed-off-by: Josh de Kock > > > > --- > > > > configure| 29 +- > > > > doc/APIchanges | 4 + > > > > doc/writing_filters.txt | 6 +- > > > > libavfilter/allfilters.c | 823 > > > > +-- > > > > libavfilter/avfilter.c | 50 +-- > > > > libavfilter/avfilter.h | 29 +- > > > > libavfilter/version.h| 3 + > > > > 7 files changed, 489 insertions(+), 455 deletions(-) > > > > > > > > > > This is a couple years too late, but wanted to drop a note that this > > > particular API change was breaking : it made avfilter_register a > > > no-op. The consequence is that it's much more difficult to maintain > > > filters out-of-tree; preserving the old behavior without changes to > > > user code requires a special build of ffmpeg that has the filter > > > configured/compiled in. The recommended workaround of using > > > avfilter_graph_alloc_filter requires more effort to wire the filter in > > > explicitly. It also doesn't allow for conveniences such as using > > > avfilter_graph_parse, since there doesn't seem to be a way to make > > > filters accessible via avfilter_get_by_name outside of ffmpeg compile > > > time. > > > > > > If there is another workaround that I'm missing, please let me know, > > > or if there's some deeper rationale for the decision to disable this > > > feature. > > > > This was actually an intentional change, there was some trouble with how > > external codecs/filters/etc should be handled. > > > > Since this was an unsupported use-case which was quite sensitive to ABI the > > change was there to explicitly prevent people (ab)using the API like this. > > It > > was also to prepare for potentially a new API to implement this in a proper > > fashion (but as you can see this was never completed). > > > > I did begin working on this again a little while back but due to an > > unfortunate > > data-loss I will have to start from scratch to continue working on it (yes, > > yes > > 'where's your backup?' I know). It's likely to be something I will be > > working > > on in the future since I will be doing FFmpeg stuff again soon. > > > > There is also the discussion of 'do we want this?' from a more ideological > > perspective which we will have to re-discuss, maybe something like > > gstreamer is > > more suited for the majority of the use-cases (?). > > > > Thanks for the explanation Josh. For what it's worth, count me as > being at least one API user for which out-of-tree filter capability > would be very helpful. (And to preempt some other reactions, "use > gstreamer" is not really helpful for us either...) I also would be in favor of some out of tree filter support. Let me explain why Some real ideas i was toying around: Some video source to simulate N body gravitational interaction and another idea was one to simulate the spread of an epidemic amongth points moving around ... Iam not sure these things would belong in-tree And as things are, if anyone works on anything like such filters which are not generic multimedia filters. They run the risk to get their work rejected "doesnt belong in FFmpeg" and then that has no reasonable place to go. For me at least that risk has been a factor in moving some random ideas about writing one or another filter down my todo and rather work on something else With "out of tree filter" support one would know that filters which are outside the scope of multimedia would have a place to go. I think its also in the spirit of open source ... Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator 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 v8 1/2] avcodec: add support for Cunning Developments' ADPCM
On Thu, Apr 16, 2020 at 03:54:01AM +, Zane van Iperen wrote: > On Wed, 15 Apr 2020 19:31:44 +0200 > "Michael Niedermayer" wrote: > > > On Tue, Apr 07, 2020 at 10:48:58AM +, Zane van Iperen wrote: > > > Signed-off-by: Zane van Iperen > > > --- > > > Changelog | 1 + > > > doc/general.texi| 1 + > > > libavcodec/Makefile | 1 + > > > libavcodec/adpcm.c | 33 + > > > libavcodec/adpcm_data.c | 13 + > > > libavcodec/adpcm_data.h | 2 ++ > > > libavcodec/allcodecs.c | 1 + > > > libavcodec/avcodec.h| 1 + > > > libavcodec/codec_desc.c | 7 +++ > > > libavcodec/version.h| 4 ++-- > > > 10 files changed, 62 insertions(+), 2 deletions(-) > > > > this doesnt apply anymore > > > > Yeah, I've rebased upon the latest master, will submit as a v9 tonight. > > > > > +predictor = c->predictor + (step * nibble); > > > > unneeded () > > > > Removed. > > > > > > + > > > +c->predictor = av_clip_int16(predictor); > > > +c->step_index = step_index; > > > + > > > +return (int16_t)c->predictor; > > > > unneeded cast > > > > Removed. > > > > @@ -1304,6 +1329,13 @@ static int adpcm_decode_frame(AVCodecContext > > > *avctx, void *data, samples += avctx->channels; > > > } > > > break; > > > +case AV_CODEC_ID_ADPCM_IMA_CUNNING: > > > +while (bytestream2_get_bytes_left(&gb) > 0) { > > > +int v = bytestream2_get_byteu(&gb); > > > +*samples++ = > > > adpcm_ima_cunning_expand_nibble(&c->status[0], v & 0x0F); > > > +*samples++ = > > > adpcm_ima_cunning_expand_nibble(&c->status[0], v >> 4); > > > +} > > > +break; > > > > i would add an av_assert to ensure the samples array is large enough > > and the code seting it stays in sync. And also so the reader knows at > > a glance that this is ok with only a check on the input size > > > > So, something like this? > av_assert0(frame->nb_samples == buf_size * 2); as the loop runs bytestream2_get_bytes_left(&gb) iterations the check should be between that and nb_samples i think thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The worst form of inequality is to try to make unequal things equal. -- Aristotle 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".
[FFmpeg-devel] [PATCH 1/2] lavu: add av_gcd_q().
TODO APIchanges and minor bump. Signed-off-by: Nicolas George --- libavutil/rational.c | 9 + libavutil/rational.h | 6 ++ 2 files changed, 15 insertions(+) This one too, I need for the code I am writing. And lavfi/avf_concat could use it too to choose a better time base. diff --git a/libavutil/rational.c b/libavutil/rational.c index 35ee08877f..eb148ddb12 100644 --- a/libavutil/rational.c +++ b/libavutil/rational.c @@ -182,3 +182,12 @@ uint32_t av_q2intfloat(AVRational q) { return sign<<31 | (150-shift)<<23 | (n - (1<<23)); } + +AVRational av_gcd_q(AVRational a, AVRational b, int max_den, AVRational def) +{ +int64_t gcd, lcm; + +gcd = av_gcd(a.den, b.den); +lcm = (a.den / gcd) * b.den; +return lcm < max_den ? av_make_q(av_gcd(a.num, b.num), lcm) : def; +} diff --git a/libavutil/rational.h b/libavutil/rational.h index 5c6b67b4e9..cbb08a0baf 100644 --- a/libavutil/rational.h +++ b/libavutil/rational.h @@ -207,6 +207,12 @@ int av_find_nearest_q_idx(AVRational q, const AVRational* q_list); */ uint32_t av_q2intfloat(AVRational q); +/** + * Return the best rational so that a and b are multiple of it. + * If the resulting denominator is larger than max_den, return def. + */ +AVRational av_gcd_q(AVRational a, AVRational b, int max_den, AVRational def); + /** * @} */ -- 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".
[FFmpeg-devel] [PATCH 2/2] lavfi/framesync: use av_gcd_q().
Signed-off-by: Nicolas George --- libavfilter/framesync.c | 13 ++--- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c index bc95f7d904..26e5219d1b 100644 --- a/libavfilter/framesync.c +++ b/libavfilter/framesync.c @@ -142,17 +142,8 @@ int ff_framesync_configure(FFFrameSync *fs) for (i = 0; i < fs->nb_in; i++) { if (fs->in[i].sync) { if (fs->time_base.num) { -gcd = av_gcd(fs->time_base.den, fs->in[i].time_base.den); -lcm = (fs->time_base.den / gcd) * fs->in[i].time_base.den; -if (lcm < AV_TIME_BASE / 2) { -fs->time_base.den = lcm; -fs->time_base.num = av_gcd(fs->time_base.num, - fs->in[i].time_base.num); -} else { -fs->time_base.num = 1; -fs->time_base.den = AV_TIME_BASE; -break; -} +fs->time_base = av_gcd_q(fs->time_base, fs->in[i].time_base, + AV_TIME_BASE / 2, AV_TIME_BASE_Q); } else { fs->time_base = fs->in[i].time_base; } -- 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 v3] lavfi: add new iteration API
Michael Niedermayer: > On Wed, Apr 15, 2020 at 03:00:32PM -0700, Josh Allmann wrote: >> On Tue, 14 Apr 2020 at 01:53, Josh de Kock wrote: >>> >>> Hi, >>> >>> On Mon, Apr 13, 2020, at 10:32 PM, Josh Allmann wrote: Hi, On Sat, 24 Mar 2018 at 14:40, Josh de Kock wrote: > > Signed-off-by: Josh de Kock > --- > configure| 29 +- > doc/APIchanges | 4 + > doc/writing_filters.txt | 6 +- > libavfilter/allfilters.c | 823 > +-- > libavfilter/avfilter.c | 50 +-- > libavfilter/avfilter.h | 29 +- > libavfilter/version.h| 3 + > 7 files changed, 489 insertions(+), 455 deletions(-) > This is a couple years too late, but wanted to drop a note that this particular API change was breaking : it made avfilter_register a no-op. The consequence is that it's much more difficult to maintain filters out-of-tree; preserving the old behavior without changes to user code requires a special build of ffmpeg that has the filter configured/compiled in. The recommended workaround of using avfilter_graph_alloc_filter requires more effort to wire the filter in explicitly. It also doesn't allow for conveniences such as using avfilter_graph_parse, since there doesn't seem to be a way to make filters accessible via avfilter_get_by_name outside of ffmpeg compile time. If there is another workaround that I'm missing, please let me know, or if there's some deeper rationale for the decision to disable this feature. >>> >>> This was actually an intentional change, there was some trouble with how >>> external codecs/filters/etc should be handled. >>> >>> Since this was an unsupported use-case which was quite sensitive to ABI the >>> change was there to explicitly prevent people (ab)using the API like this. >>> It >>> was also to prepare for potentially a new API to implement this in a proper >>> fashion (but as you can see this was never completed). >>> >>> I did begin working on this again a little while back but due to an >>> unfortunate >>> data-loss I will have to start from scratch to continue working on it (yes, >>> yes >>> 'where's your backup?' I know). It's likely to be something I will be >>> working >>> on in the future since I will be doing FFmpeg stuff again soon. >>> >>> There is also the discussion of 'do we want this?' from a more ideological >>> perspective which we will have to re-discuss, maybe something like >>> gstreamer is >>> more suited for the majority of the use-cases (?). >>> >> >> Thanks for the explanation Josh. For what it's worth, count me as >> being at least one API user for which out-of-tree filter capability >> would be very helpful. (And to preempt some other reactions, "use >> gstreamer" is not really helpful for us either...) > > I also would be in favor of some out of tree filter support. > Let me explain why > Some real ideas i was toying around: > Some video source to simulate N body gravitational interaction and > another idea was one to simulate the spread of an epidemic amongth > points moving around ... > > Iam not sure these things would belong in-tree > And as things are, if anyone works on anything like such filters which > are not generic multimedia filters. They run the risk to get their work > rejected "doesnt belong in FFmpeg" and then that has no reasonable place > to go. > For me at least that risk has been a factor in moving some random ideas about > writing one or another filter down my todo and rather work on something else > > With "out of tree filter" support one would know that filters which are > outside the scope of multimedia would have a place to go. > I think its also in the spirit of open source ... > How would one create these out-of-tree filters without using internal API and without extending the public API for this (thereby hindering development generally)? E.g. all those function pointers in AVFilter (and lots of other similar structures) are internal API and would be made public in some way to support this. - 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".
Re: [FFmpeg-devel] [PATCH v3] lavfi: add new iteration API
Andreas Rheinhardt (12020-04-16): > How would one create these out-of-tree filters without using internal > API and without extending the public API for this (thereby hindering > development generally)? E.g. all those function pointers in AVFilter > (and lots of other similar structures) are internal API and would be > made public in some way to support this. The internal API is quite complex and moving because we want filters to be able to do a lot of things very efficiently. If we limit the features offered to out-of-tree filters and accept suboptimal performance, it is reasonably easy to offer them a simple API that would not hinder development. Regards, -- Nicolas George 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 2/2] lavfi/framesync: use av_gcd_q().
Nicolas George: > Signed-off-by: Nicolas George > --- > libavfilter/framesync.c | 13 ++--- > 1 file changed, 2 insertions(+), 11 deletions(-) > > diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c > index bc95f7d904..26e5219d1b 100644 > --- a/libavfilter/framesync.c > +++ b/libavfilter/framesync.c > @@ -142,17 +142,8 @@ int ff_framesync_configure(FFFrameSync *fs) > for (i = 0; i < fs->nb_in; i++) { > if (fs->in[i].sync) { > if (fs->time_base.num) { > -gcd = av_gcd(fs->time_base.den, fs->in[i].time_base.den); > -lcm = (fs->time_base.den / gcd) * > fs->in[i].time_base.den; > -if (lcm < AV_TIME_BASE / 2) { > -fs->time_base.den = lcm; > -fs->time_base.num = av_gcd(fs->time_base.num, > - fs->in[i].time_base.num); > -} else { > -fs->time_base.num = 1; > -fs->time_base.den = AV_TIME_BASE; > -break; > -} > +fs->time_base = av_gcd_q(fs->time_base, > fs->in[i].time_base, > + AV_TIME_BASE / 2, > AV_TIME_BASE_Q); > } else { > fs->time_base = fs->in[i].time_base; > } > lcm is now unused, so should be removed with this commit. (I'm not commenting on the actual merits of the patch.) - Andreas PS: Thanks to Andriy for adding the functionality to patchwork to check whether a patch introduces new compiler warnings. This has been found this way. ___ 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] avformat/mux: Make uncoded frames av_packet_unref() compatible
On Tue, 14 Apr 2020, Nicolas George wrote: Andreas Rheinhardt (12020-04-12): Currently uncoded frames (i.e. packets whose data actually points to an AVFrame) are not refcounted. As a consequence, calling av_packet_unref() on them will not free them, but may simply make sure that they leak by losing the pointer to the frame. This commit changes this by actually making uncoded frames refcounted. In order not to rely on sizeof(AVFrame) (which is not part of the public API and so must not be used here in libavformat) the packet's data is changed to a (padded) buffer containing just a pointer to an AVFrame. Said buffer is owned by an AVBuffer with a custom free function that frees the frame as well as the buffer. Thereby the pointer/the AVBuffer owns the AVFrame. Said ownership can actually be transferred by copying and resetting the pointer, as might happen when actually writing the uncoded frames in AVOutputFormat.write_uncoded_frame() (although currently no muxer makes use of this possibility). This makes packets containing uncoded frames compatible with av_packet_unref(). This already has three advantages in interleaved mode: 1. If an error happens at the preparatory steps (before the packet is put into the interleavement queue), the frame is properly freed. 2. If the trailer is never written, the frames still in the interleavement queue will now be properly freed by ff_packet_list_free(). 3. The custom code for moving the packet to the packet list in ff_interleave_add_packet() can be removed. It will also simplify fixing further memleaks in future commits. Suggested-by: Marton Balint Signed-off-by: Andreas Rheinhardt --- How embarrassing! The earlier version forgot to check the allocation. I am confused: does it not make unwrapped frames behave exactly the same as wrapped frames? There is a slight difference, for WRAPPED_AVFRAME packets the AVFrame is stored in the data, for uncoded_frames packets only a pointer to AVFrame is stored in data. AFAIU, Marton intends to remove all this code, and I think he is right, because it was a hack. Yes, but full removal can only happen at the next bump, so until that this should be fixed. Also this patchset has been delayed for a very long time now, I really like to see it applied as soon as possible, even if we further change uncoded_frames support later or around the time of the API bump. Thanks, Marton ___ 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] avformat/mux: Make uncoded frames av_packet_unref() compatible
Marton Balint (12020-04-16): > Yes, but full removal can only happen at the next bump, so until that this > should be fixed. Also this patchset has been delayed for a very long time > now, I really like to see it applied as soon as possible, even if we further > change uncoded_frames support later or around the time of the API bump. Ok, no objection from me. Regards, -- Nicolas George 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 2/2] lavfi/framesync: use av_gcd_q().
Andreas Rheinhardt (12020-04-16): > lcm is now unused, so should be removed with this commit. > (I'm not commenting on the actual merits of the patch.) Indeed. I updated the patch, it now contains an extra hunk: @@ -117,7 +117,6 @@ static void framesync_sync_level_update(FFFrameSync *fs) int ff_framesync_configure(FFFrameSync *fs) { unsigned i; -int64_t gcd, lcm; if (!fs->opt_repeatlast || fs->opt_eof_action == EOF_ACTION_PASS) { fs->opt_repeatlast = 0; And I think I can dispense with re-sending it. > PS: Thanks to Andriy for adding the functionality to patchwork to check > whether a patch introduces new compiler warnings. This has been found > this way. It is useful indeed. But I should have spotted it. Thanks. Regards, -- Nicolas George 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".
[FFmpeg-devel] [PATCH] lavfi: add untile filter.
Signed-off-by: Nicolas George --- doc/filters.texi | 34 ++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_untile.c | 198 +++ tests/fate/filter-video.mak | 3 + tests/ref/fate/filter-untile | 13 +++ 6 files changed, 250 insertions(+) create mode 100644 libavfilter/vf_untile.c create mode 100644 tests/ref/fate/filter-untile diff --git a/doc/filters.texi b/doc/filters.texi index a4f99ef376..3f08b8805c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -18071,10 +18071,13 @@ ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png @end example @end itemize +@anchor{tile} @section tile Tile several successive frames together. +The @ref{untile} filter can do the reverse. + The filter accepts the following options: @table @option @@ -18839,6 +18842,37 @@ unsharp=7:7:-2:7:7:-2 @end example @end itemize +@anchor{untile} +@section untile + +Decompose a video made of tiled images into the individual images. + +The frame rate of the output video is the frame rate of the input video +multiplied by the number of tiles. + +This filter does the reverse of @ref{tile}. + +The filter accepts the following options: + +@table @option + +@item layout +Set the grid size (i.e. the number of lines and columns). For the syntax of +this option, check the +@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}. +@end table + +@subsection Examples + +@itemize +@item +Produce a 1-second video from a still image file made of 25 frames stacked +vertically, like an analogic film reel: +@example +ffmpeg -r 1 -i image.jpg -vf untile=1x25 movie.mkv +@end example +@end itemize + @section uspp Apply ultra slow/simple postprocessing filter that compresses and decompresses diff --git a/libavfilter/Makefile b/libavfilter/Makefile index ecbc628868..82e2991f7a 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -432,6 +432,7 @@ OBJS-$(CONFIG_UNPREMULTIPLY_FILTER) += vf_premultiply.o framesync.o OBJS-$(CONFIG_UNSHARP_FILTER)+= vf_unsharp.o OBJS-$(CONFIG_UNSHARP_OPENCL_FILTER) += vf_unsharp_opencl.o opencl.o \ opencl/unsharp.o +OBJS-$(CONFIG_UNTILE_FILTER) += vf_untile.o OBJS-$(CONFIG_USPP_FILTER) += vf_uspp.o OBJS-$(CONFIG_V360_FILTER) += vf_v360.o OBJS-$(CONFIG_VAGUEDENOISER_FILTER) += vf_vaguedenoiser.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index fb32bef788..31711d35c7 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -411,6 +411,7 @@ extern AVFilter ff_vf_trim; extern AVFilter ff_vf_unpremultiply; extern AVFilter ff_vf_unsharp; extern AVFilter ff_vf_unsharp_opencl; +extern AVFilter ff_vf_untile; extern AVFilter ff_vf_uspp; extern AVFilter ff_vf_v360; extern AVFilter ff_vf_vaguedenoiser; diff --git a/libavfilter/vf_untile.c b/libavfilter/vf_untile.c new file mode 100644 index 00..9a2eb24901 --- /dev/null +++ b/libavfilter/vf_untile.c @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2020 Nicolas George + * + * 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 "libavutil/imgutils.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "avfilter.h" +#include "formats.h" +#include "filters.h" + +typedef struct UntileContext { +const AVClass *class; +unsigned w, h; +unsigned current; +unsigned nb_frames; +AVFrame *frame; +const AVPixFmtDescriptor *desc; +int64_t dpts, pts; +int max_step[4]; +} UntileContext; + +#define OFFSET(x) offsetof(UntileContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption untile_options[] = { +{ "layout", "set grid size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, +{.str = "6x5"}, 0, 0, FLAGS }, +{ NULL } +}; + +AVFILTER_DEFINE_CLASS(untile); + +static av_cold int init(AVFilterContext *ctx) +{ +UntileContext *s = ctx->priv; + +if (s->w > UINT_MAX / s->h) { +av_log(ctx, AV_LOG_ERROR, "Tile size %ux%u is insane.\n", + s->w, s->h); +return AVERROR(EINVAL); +} +s->nb_frames =
Re: [FFmpeg-devel] [PATCH 5/6] avformat/mux: Don't modify packets we don't own
On Sat, 11 Apr 2020, Andreas Rheinhardt wrote: The documentation of av_write_frame() explicitly states that the function doesn't take ownership of the packets sent to it; while av_write_frame() does not directly unreference the packets after having written them, it nevertheless modifies the packet in various ways: 1. The timestamps might be modified either by prepare_input_packet() or compute_muxer_pkt_fields(). 2. If a bitstream filter gets applied, it takes ownership of the reference and the side-data in the packet sent to it. In case of do_packet_auto_bsf(), the end result is that the returned packet contains the output of the last bsf in the chain. If an error happens, a blank packet will be returned; a packet may also simply not lead to any output (vp9_superframe). This also implies that side data needs to be really copied and can't be shared with the input packet. The method choosen here minimizes copying of data: When the input isn't refcounted and no bitstream filter is applied, the packet's data will not be copied. Notice that packets that contain uncoded frames are exempt from this because these packets are not owned by and returned to the user. This also moves unreferencing the packets containing uncoded frames to av_write_frame() in the noninterleaved codepath; in the interleaved codepath, these packets are already freed in av_interleaved_write_frame(), so that unreferencing the packets in write_uncoded_frame_internal() is no longer needed. It has been removed. Signed-off-by: Andreas Rheinhardt --- I was actually surprised when I realized how freeing uncoded frames in the noninterleaved codepath could be left to av_write_frame(). libavformat/mux.c | 48 +++ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/libavformat/mux.c b/libavformat/mux.c index cae9f42d11..48c0d4cd5f 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -874,11 +874,12 @@ static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) { return 1; } -int av_write_frame(AVFormatContext *s, AVPacket *pkt) +int av_write_frame(AVFormatContext *s, AVPacket *in) { +AVPacket local_pkt, *pkt = &local_pkt; int ret; -if (!pkt) { +if (!in) { if (s->oformat->flags & AVFMT_ALLOW_FLUSH) { ret = s->oformat->write_packet(s, NULL); flush_if_needed(s); @@ -889,22 +890,49 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt) return 1; } +if (in->flags & AV_PKT_FLAG_UNCODED_FRAME) { +pkt = in; +} else { +/* We don't own in, so we have to make sure not to modify it. + * The following avoids copying in's data unnecessarily. + * Copying side data is unavoidable as a bitstream filter + * may change it, e.g. free it on errors. */ +pkt->buf = NULL; +pkt->data = in->data; +pkt->size = in->size; +ret = av_packet_copy_props(pkt, in); +if (ret < 0) +return ret; +if (in->buf) { +pkt->buf = av_buffer_ref(in->buf); +if (!pkt->buf) { +ret = AVERROR(ENOMEM); +goto fail; +} +} +} + ret = prepare_input_packet(s, pkt); if (ret < 0) -return ret; +goto fail; ret = do_packet_auto_bsf(s, pkt); if (ret <= 0) -return ret; +goto fail; #if FF_API_COMPUTE_PKT_FIELDS2 && FF_API_LAVF_AVCTX ret = compute_muxer_pkt_fields(s, s->streams[pkt->stream_index], pkt); if (ret < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) -return ret; +goto fail; #endif -return write_packet(s, pkt); +ret = write_packet(s, pkt); + +fail: +// Uncoded frames using the noninterleaved codepath are freed here This comment does not seem accurate. Pkt must always be unrefed here, not only for the uncoded_frames (where it happens to be == in), or I miss something? If not, then I'd just simply remove this comment. Otherwise looks good. I checked the other patches in the series they all look good as well. Thanks, Marton +av_packet_unref(pkt); +return ret; } #define CHUNK_START 0x1000 @@ -1319,7 +1347,6 @@ static int write_uncoded_frame_internal(AVFormatContext *s, int stream_index, AVFrame *frame, int interleaved) { AVPacket pkt, *pktp; -int ret; av_assert0(s->oformat); if (!s->oformat->write_uncoded_frame) { @@ -1349,11 +1376,8 @@ static int write_uncoded_frame_internal(AVFormatContext *s, int stream_index, pkt.flags |= AV_PKT_FLAG_UNCODED_FRAME; } -ret = interleaved ? av_interleaved_write_frame(s, pktp) : -av_write_frame(s, pktp); -if (pktp) -av_packet_unref(pktp); -return ret; +return interleaved ? av_interleaved_write_frame(s, pktp) : + av_write_frame(s, pktp); } int av_write_uncoded_frame(AVFormatContext *s, int stream_index, -
Re: [FFmpeg-devel] [PATCH 1/3] lavc/pgs_frame_merge_bsf: add bsf to merge PGS segments
John Stebbins: > Required to remux m2ts to mkv > --- > libavcodec/Makefile | 1 + > libavcodec/bitstream_filters.c | 1 + > libavcodec/pgs_frame_merge_bsf.c | 152 +++ Missing version bump. > 3 files changed, 154 insertions(+) > create mode 100644 libavcodec/pgs_frame_merge_bsf.c > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index c1c9a44f2b..13909faabf 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1119,6 +1119,7 @@ OBJS-$(CONFIG_VP9_METADATA_BSF) += > vp9_metadata_bsf.o > OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)+= vp9_raw_reorder_bsf.o > OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o > OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF) += vp9_superframe_split_bsf.o > +OBJS-$(CONFIG_PGS_FRAME_MERGE_BSF)+= pgs_frame_merge_bsf.o Not sorted alphabetically. > > # thread libraries > OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o > diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c > index 6b5ffe4d70..138f6dd7ad 100644 > --- a/libavcodec/bitstream_filters.c > +++ b/libavcodec/bitstream_filters.c > @@ -58,6 +58,7 @@ extern const AVBitStreamFilter ff_vp9_metadata_bsf; > extern const AVBitStreamFilter ff_vp9_raw_reorder_bsf; > extern const AVBitStreamFilter ff_vp9_superframe_bsf; > extern const AVBitStreamFilter ff_vp9_superframe_split_bsf; > +extern const AVBitStreamFilter ff_pgs_frame_merge_bsf; Not sorted alphabetically. > > #include "libavcodec/bsf_list.c" > > diff --git a/libavcodec/pgs_frame_merge_bsf.c > b/libavcodec/pgs_frame_merge_bsf.c > new file mode 100644 > index 00..4b8061d4e1 > --- /dev/null > +++ b/libavcodec/pgs_frame_merge_bsf.c > @@ -0,0 +1,152 @@ > +/* > + * Copyright (c) 2020 John Stebbins > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > + */ > + > +/** > + * @file > + * This bitstream filter merges PGS subtitle packets containing incomplete > + * set of segments into a single packet > + * > + * Packets already containing a complete set of segments will be passed > through > + * unchanged. > + */ > + > +#include "avcodec.h" > +#include "bsf.h" > +#include "libavutil/intreadwrite.h" > + > +enum PGSSegmentType { > +PALETTE_SEGMENT = 0x14, > +OBJECT_SEGMENT = 0x15, > +PRESENTATION_SEGMENT = 0x16, > +WINDOW_SEGMENT = 0x17, > +DISPLAY_SEGMENT = 0x80, > +}; > + > +typedef struct PGSMergeContext { > +AVPacket *buffer_pkt, *in; > +} PGSMergeContext; > + > +static void frame_merge_flush(AVBSFContext *bsf) > +{ > +PGSMergeContext *ctx = bsf->priv_data; > + > +av_packet_unref(ctx->in); > +av_packet_unref(ctx->buffer_pkt); > +} > + > +static int frame_merge_filter(AVBSFContext *bsf, AVPacket *out) > +{ > +PGSMergeContext *ctx = bsf->priv_data; > +AVPacket *in = ctx->in, *pkt = ctx->buffer_pkt; > +int ret, i, size, pos, display = 0; > +uint8_t segment_type; > +uint16_t segment_len; > + > +if (!in->data) { > +ret = ff_bsf_get_packet_ref(bsf, in); > +if (ret < 0) > +return ret; > +} > +if (!in->size) { > +av_packet_unref(in); > +return AVERROR(EAGAIN); > +} > + > +// Validate packet data and find display_end segment > +size = in->size; > +i = 0; > +while (i < in->size) { > +segment_type = in->data[i]; > +segment_len = AV_RB16(in->data + i + 1) + 3; 1. This code only requires the input packet to be padded as reading segment_len is not guaranteed to be part of your packet. I have no problem with that, yet you should add a comment about it. 2. Both segment_type and segment_len could be made local variable of this loop. 3. The type of segment_len is wrong. There might be an uint16_t overflow in the calculation. (Or more precisely: the calculation is done after the usual integer promotions have been applied (i.e. the addition is performed after promoting to int) and the conversion from int -> uint16_t might not be lossless.) > +if (segment_type == DISPLAY_SEGMENT) { > +size = display = i + segment_len; 4. You could increment i before this check (and omit the incrementing below). It will increase
Re: [FFmpeg-devel] [PATCH v2] avutil/log: update text requesting samples
On Mon, 13 Apr 2020, Marton Balint wrote: On Mon, 13 Apr 2020, Carl Eugen Hoyos wrote: Am Mo., 13. Apr. 2020 um 02:19 Uhr schrieb Marton Balint : On Mon, 13 Apr 2020, Carl Eugen Hoyos wrote: > Am Mo., 13. Apr. 2020 um 00:45 Uhr schrieb Marton Balint : >> >> Signed-off-by: Marton Balint >> --- >> libavutil/log.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/libavutil/log.c b/libavutil/log.c >> index 8d4945249e..965dbca5e1 100644 >> --- a/libavutil/log.c >> +++ b/libavutil/log.c >> @@ -466,9 +466,9 @@ static void missing_feature_sample(int sample, void *avc, const char *msg, >> "occurs, it means that your file has a feature which has not " >> "been implemented.\n"); >> if (sample) >> -av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample " >> - "of this file to ftp://upload.ffmpeg.org/incoming/ " >> - "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n"); >> +av_log(avc, AV_LOG_WARNING, "If you want to help, contact " >> + "ffmpeg-devel@ffmpeg.org and if requested upload a sample " >> + "of this file to https://streams.videolan.org/upload/\n";); > > Uploading a sample is of course much more important than sending an email, > so this makes the patch significantly worse imo. You wrote that we typically ask for samples we already have. So why aks for uploading them first? Even if we already have 99% of such samples (we certainly don't), I would consider getting the remaining 1% of highest importance. So you want to keep the text as is and only change ftp://upload.ffmpeg.org/incoming/ to https://streams.videolan.org/upload/ right? Right? If not, then please propose alternate text. Thanks, Marton ___ 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] avformat/mux: Make uncoded frames av_packet_unref() compatible
Marton Balint: > > > On Tue, 14 Apr 2020, Nicolas George wrote: > >> Andreas Rheinhardt (12020-04-12): >>> Currently uncoded frames (i.e. packets whose data actually points to an >>> AVFrame) are not refcounted. As a consequence, calling av_packet_unref() >>> on them will not free them, but may simply make sure that they leak by >>> losing the pointer to the frame. >>> >>> This commit changes this by actually making uncoded frames refcounted. >>> In order not to rely on sizeof(AVFrame) (which is not part of the public >>> API and so must not be used here in libavformat) the packet's data is >>> changed to a (padded) buffer containing just a pointer to an AVFrame. >>> Said buffer is owned by an AVBuffer with a custom free function that >>> frees the frame as well as the buffer. Thereby the pointer/the AVBuffer >>> owns the AVFrame. >>> >>> Said ownership can actually be transferred by copying and resetting >>> the pointer, as might happen when actually writing the uncoded frames >>> in AVOutputFormat.write_uncoded_frame() (although currently no muxer >>> makes use of this possibility). >>> >>> This makes packets containing uncoded frames compatible with >>> av_packet_unref(). This already has three advantages in interleaved >>> mode: >>> 1. If an error happens at the preparatory steps (before the packet is >>> put into the interleavement queue), the frame is properly freed. >>> 2. If the trailer is never written, the frames still in the >>> interleavement queue will now be properly freed by >>> ff_packet_list_free(). >>> 3. The custom code for moving the packet to the packet list in >>> ff_interleave_add_packet() can be removed. >>> >>> It will also simplify fixing further memleaks in future commits. >>> >>> Suggested-by: Marton Balint >>> Signed-off-by: Andreas Rheinhardt >>> --- >>> How embarrassing! The earlier version forgot to check the allocation. >> >> I am confused: does it not make unwrapped frames behave exactly the same >> as wrapped frames? > > There is a slight difference, for WRAPPED_AVFRAME packets the AVFrame is > stored in the data, for uncoded_frames packets only a pointer to AVFrame > is stored in data. > >> >> AFAIU, Marton intends to remove all this code, and I think he is right, >> because it was a hack. > > Yes, but full removal can only happen at the next bump, so until that > this should be fixed. Yes (and actually it can only be removed after a deprecation period which (if honoured) would postpone the removal by another major version bump). And the way it is done here means that the rest of the code is pretty much shielded from uncoded frames, so that you won't have to think "do I need to treat uncoded frames specially here?" in your patchset. > Also this patchset has been delayed for a very > long time now, I really like to see it applied as soon as possible, even > if we further change uncoded_frames support later or around the time of > the API bump. > So is anyone against me applying this? If not, I'll apply it tomorrow. - 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".
Re: [FFmpeg-devel] [PATCH 5/6] avformat/mux: Don't modify packets we don't own
Marton Balint: > > > On Sat, 11 Apr 2020, Andreas Rheinhardt wrote: > >> The documentation of av_write_frame() explicitly states that the function >> doesn't take ownership of the packets sent to it; while av_write_frame() >> does not directly unreference the packets after having written them, it >> nevertheless modifies the packet in various ways: >> 1. The timestamps might be modified either by prepare_input_packet() or >> compute_muxer_pkt_fields(). >> 2. If a bitstream filter gets applied, it takes ownership of the >> reference and the side-data in the packet sent to it. >> In case of do_packet_auto_bsf(), the end result is that the returned >> packet >> contains the output of the last bsf in the chain. If an error happens, >> a blank packet will be returned; a packet may also simply not lead to >> any output (vp9_superframe). >> This also implies that side data needs to be really copied and can't be >> shared with the input packet. >> The method choosen here minimizes copying of data: When the input isn't >> refcounted and no bitstream filter is applied, the packet's data will >> not be copied. >> >> Notice that packets that contain uncoded frames are exempt from this >> because these packets are not owned by and returned to the user. This >> also moves unreferencing the packets containing uncoded frames to >> av_write_frame() in the noninterleaved codepath; in the interleaved >> codepath, these packets are already freed in >> av_interleaved_write_frame(), >> so that unreferencing the packets in write_uncoded_frame_internal() is >> no longer needed. It has been removed. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> I was actually surprised when I realized how freeing uncoded frames in >> the noninterleaved codepath could be left to av_write_frame(). >> >> libavformat/mux.c | 48 +++ >> 1 file changed, 36 insertions(+), 12 deletions(-) >> >> diff --git a/libavformat/mux.c b/libavformat/mux.c >> index cae9f42d11..48c0d4cd5f 100644 >> --- a/libavformat/mux.c >> +++ b/libavformat/mux.c >> @@ -874,11 +874,12 @@ static int do_packet_auto_bsf(AVFormatContext >> *s, AVPacket *pkt) { >> return 1; >> } >> >> -int av_write_frame(AVFormatContext *s, AVPacket *pkt) >> +int av_write_frame(AVFormatContext *s, AVPacket *in) >> { >> + AVPacket local_pkt, *pkt = &local_pkt; >> int ret; >> >> - if (!pkt) { >> + if (!in) { >> if (s->oformat->flags & AVFMT_ALLOW_FLUSH) { >> ret = s->oformat->write_packet(s, NULL); >> flush_if_needed(s); >> @@ -889,22 +890,49 @@ int av_write_frame(AVFormatContext *s, AVPacket >> *pkt) >> return 1; >> } >> >> + if (in->flags & AV_PKT_FLAG_UNCODED_FRAME) { >> + pkt = in; >> + } else { >> + /* We don't own in, so we have to make sure not to modify it. >> + * The following avoids copying in's data unnecessarily. >> + * Copying side data is unavoidable as a bitstream filter >> + * may change it, e.g. free it on errors. */ >> + pkt->buf = NULL; >> + pkt->data = in->data; >> + pkt->size = in->size; >> + ret = av_packet_copy_props(pkt, in); >> + if (ret < 0) >> + return ret; >> + if (in->buf) { >> + pkt->buf = av_buffer_ref(in->buf); >> + if (!pkt->buf) { >> + ret = AVERROR(ENOMEM); >> + goto fail; >> + } >> + } >> + } >> + >> ret = prepare_input_packet(s, pkt); >> if (ret < 0) >> - return ret; >> + goto fail; >> >> ret = do_packet_auto_bsf(s, pkt); >> if (ret <= 0) >> - return ret; >> + goto fail; >> >> #if FF_API_COMPUTE_PKT_FIELDS2 && FF_API_LAVF_AVCTX >> ret = compute_muxer_pkt_fields(s, s->streams[pkt->stream_index], >> pkt); >> >> if (ret < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) >> - return ret; >> + goto fail; >> #endif >> >> - return write_packet(s, pkt); >> + ret = write_packet(s, pkt); >> + >> +fail: >> + // Uncoded frames using the noninterleaved codepath are freed here > > This comment does not seem accurate. Pkt must always be unrefed here, > not only for the uncoded_frames (where it happens to be == in), or I > miss something? If not, then I'd just simply remove this comment. Of course ordinary packets need to be unreferenced here, too; but I thought that someone reading and potentially changing av_write_frame() is already aware of that. But they might not be aware of the fact that (contrary to the usual behaviour of av_write_frame()) some packets not created in av_write_frame() are unreferenced there, hence this comment. - 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".
Re: [FFmpeg-devel] [PATCH v2] avutil/log: update text requesting samples
Am Mo., 13. Apr. 2020 um 11:03 Uhr schrieb Marton Balint : > > > > On Mon, 13 Apr 2020, Carl Eugen Hoyos wrote: > > > Am Mo., 13. Apr. 2020 um 02:19 Uhr schrieb Marton Balint : > >> > >> > >> > >> On Mon, 13 Apr 2020, Carl Eugen Hoyos wrote: > >> > >> > Am Mo., 13. Apr. 2020 um 00:45 Uhr schrieb Marton Balint > >> > : > >> >> > >> >> Signed-off-by: Marton Balint > >> >> --- > >> >> libavutil/log.c | 6 +++--- > >> >> 1 file changed, 3 insertions(+), 3 deletions(-) > >> >> > >> >> diff --git a/libavutil/log.c b/libavutil/log.c > >> >> index 8d4945249e..965dbca5e1 100644 > >> >> --- a/libavutil/log.c > >> >> +++ b/libavutil/log.c > >> >> @@ -466,9 +466,9 @@ static void missing_feature_sample(int sample, void > >> >> *avc, const char *msg, > >> >> "occurs, it means that your file has a feature which has > >> >> not " > >> >> "been implemented.\n"); > >> >> if (sample) > >> >> -av_log(avc, AV_LOG_WARNING, "If you want to help, upload a > >> >> sample " > >> >> - "of this file to ftp://upload.ffmpeg.org/incoming/ " > >> >> - "and contact the ffmpeg-devel mailing list. > >> >> (ffmpeg-devel@ffmpeg.org)\n"); > >> >> +av_log(avc, AV_LOG_WARNING, "If you want to help, contact " > >> >> + "ffmpeg-devel@ffmpeg.org and if requested upload a > >> >> sample " > >> >> + "of this file to > >> >> https://streams.videolan.org/upload/\n";); > >> > > >> > Uploading a sample is of course much more important than sending an > >> > email, > >> > so this makes the patch significantly worse imo. > >> > >> You wrote that we typically ask for samples we already have. So why > >> aks for uploading them first? > > > > Even if we already have 99% of such samples (we certainly don't), I > > would consider getting the remaining 1% of highest importance. > > So you want to keep the text as is and only change > ftp://upload.ffmpeg.org/incoming/ to https://streams.videolan.org/upload/ > right? Yes, please. Sorry for missing your mail. Carl Eugen ___ 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] avformat/mux: Don't modify packets we don't own
On Thu, 16 Apr 2020, Andreas Rheinhardt wrote: Marton Balint: On Sat, 11 Apr 2020, Andreas Rheinhardt wrote: The documentation of av_write_frame() explicitly states that the function doesn't take ownership of the packets sent to it; while av_write_frame() does not directly unreference the packets after having written them, it nevertheless modifies the packet in various ways: 1. The timestamps might be modified either by prepare_input_packet() or compute_muxer_pkt_fields(). 2. If a bitstream filter gets applied, it takes ownership of the reference and the side-data in the packet sent to it. In case of do_packet_auto_bsf(), the end result is that the returned packet contains the output of the last bsf in the chain. If an error happens, a blank packet will be returned; a packet may also simply not lead to any output (vp9_superframe). This also implies that side data needs to be really copied and can't be shared with the input packet. The method choosen here minimizes copying of data: When the input isn't refcounted and no bitstream filter is applied, the packet's data will not be copied. Notice that packets that contain uncoded frames are exempt from this because these packets are not owned by and returned to the user. This also moves unreferencing the packets containing uncoded frames to av_write_frame() in the noninterleaved codepath; in the interleaved codepath, these packets are already freed in av_interleaved_write_frame(), so that unreferencing the packets in write_uncoded_frame_internal() is no longer needed. It has been removed. Signed-off-by: Andreas Rheinhardt --- I was actually surprised when I realized how freeing uncoded frames in the noninterleaved codepath could be left to av_write_frame(). libavformat/mux.c | 48 +++ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/libavformat/mux.c b/libavformat/mux.c index cae9f42d11..48c0d4cd5f 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -874,11 +874,12 @@ static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) { return 1; } -int av_write_frame(AVFormatContext *s, AVPacket *pkt) +int av_write_frame(AVFormatContext *s, AVPacket *in) { + AVPacket local_pkt, *pkt = &local_pkt; int ret; - if (!pkt) { + if (!in) { if (s->oformat->flags & AVFMT_ALLOW_FLUSH) { ret = s->oformat->write_packet(s, NULL); flush_if_needed(s); @@ -889,22 +890,49 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt) return 1; } + if (in->flags & AV_PKT_FLAG_UNCODED_FRAME) { + pkt = in; + } else { + /* We don't own in, so we have to make sure not to modify it. + * The following avoids copying in's data unnecessarily. + * Copying side data is unavoidable as a bitstream filter + * may change it, e.g. free it on errors. */ + pkt->buf = NULL; + pkt->data = in->data; + pkt->size = in->size; + ret = av_packet_copy_props(pkt, in); + if (ret < 0) + return ret; + if (in->buf) { + pkt->buf = av_buffer_ref(in->buf); + if (!pkt->buf) { + ret = AVERROR(ENOMEM); + goto fail; + } + } + } + ret = prepare_input_packet(s, pkt); if (ret < 0) - return ret; + goto fail; ret = do_packet_auto_bsf(s, pkt); if (ret <= 0) - return ret; + goto fail; #if FF_API_COMPUTE_PKT_FIELDS2 && FF_API_LAVF_AVCTX ret = compute_muxer_pkt_fields(s, s->streams[pkt->stream_index], pkt); if (ret < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) - return ret; + goto fail; #endif - return write_packet(s, pkt); + ret = write_packet(s, pkt); + +fail: + // Uncoded frames using the noninterleaved codepath are freed here This comment does not seem accurate. Pkt must always be unrefed here, not only for the uncoded_frames (where it happens to be == in), or I miss something? If not, then I'd just simply remove this comment. Of course ordinary packets need to be unreferenced here, too; but I thought that someone reading and potentially changing av_write_frame() is already aware of that. But they might not be aware of the fact that (contrary to the usual behaviour of av_write_frame()) some packets not created in av_write_frame() are unreferenced there, hence this comment. Wow, that really confused me :) Then write something like: uncoded frames are *also* freed here. Thanks, Marton ___ 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/4] avformat/mpegtsenc: use standard pids for m2ts
On Mon, 13 Apr 2020, Petri Hintukainen wrote: pe, 2020-04-10 kello 21:44 +0200, Marton Balint kirjoitti: Signed-off-by: Marton Balint --- doc/muxers.texi | 6 -- libavformat/mpegts.h| 10 ++ libavformat/mpegtsenc.c | 44 +++- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 4b6ffaaf58..c7caf52ff4 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1630,11 +1630,13 @@ Advanced Codec Digital HDTV service. @item mpegts_pmt_start_pid @var{integer} Set the first PID for PMTs. Default is @code{0x1000}, minimum is @code{0x0020}, -maximum is @code{0x1ffa}. +maximum is @code{0x1ffa}. This option has no effect in m2ts mode where the PMT +PID is fixed @code{0x0100}. @item mpegts_start_pid @var{integer} Set the first PID for elementary streams. Default is @code{0x0100}, minimum is -@code{0x0020}, maximum is @code{0x1ffa}. +@code{0x0020}, maximum is @code{0x1ffa}. This option has no effect in m2ts mode +where the elementary stream PIDs are fixed. @item mpegts_m2ts_mode @var{boolean} Enable m2ts mode if set to @code{1}. Default value is @code{-1} which diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h index 86a3eba4e2..f9a7e27564 100644 --- a/libavformat/mpegts.h +++ b/libavformat/mpegts.h @@ -65,6 +65,16 @@ * streams and other data tables */ #define NULL_PID0x1FFF /* Null packet (used for fixed bandwidth padding) */ +/* m2ts pids */ +#define M2TS_PMT_PID 0x0100 +#define M2TS_PCR_PID 0x1001 +#define M2TS_VIDEO_PID0x1011 +#define M2TS_AUDIO_START_PID 0x1100 +#define M2TS_PGSSUB_START_PID 0x1200 +#define M2TS_TEXTSUB_START_PID0x1800 M2TS_TEXTSUB_PID ? Ok. +#define M2TS_SECONDARY_AUDIO_START_PID0x1A00 +#define M2TS_SECONDARY_VIDEO_START_PID0x1B00 These two are not used ? Yes, these are only here for completeness for now. Maybe some AV_DISPOSITION flag can be used in the future to signal secondaries, so they can be muxed as secondary streams. +/* table ids */ #define PAT_TID 0x00 /* Program Association section */ #define CAT_TID 0x01 /* Conditional Access section */ diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index ccb631d746..5e71a0b6f8 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -94,6 +94,10 @@ typedef struct MpegTSWrite { int pmt_start_pid; int start_pid; int m2ts_mode; +int m2ts_video_pid; +int m2ts_audio_pid; +int m2ts_pgssub_pid; +int m2ts_textsub_pid; int pcr_period_ms; #define MPEGTS_FLAG_REEMIT_PAT_PMT 0x01 @@ -860,6 +864,14 @@ static int mpegts_init(AVFormatContext *s) } } +ts->m2ts_video_pid = M2TS_VIDEO_PID; +ts->m2ts_audio_pid = M2TS_AUDIO_START_PID; +ts->m2ts_pgssub_pid = M2TS_PGSSUB_START_PID; +ts->m2ts_textsub_pid = M2TS_TEXTSUB_START_PID; + +if (ts->m2ts_mode) +ts->pmt_start_pid = M2TS_PMT_PID; + if (s->max_delay < 0) /* Not set by the caller */ s->max_delay = 0; @@ -923,7 +935,37 @@ static int mpegts_init(AVFormatContext *s) /* MPEG pid values < 16 are reserved. Applications which set st->id in * this range are assigned a calculated pid. */ if (st->id < 16) { -ts_st->pid = ts->start_pid + i; +if (ts->m2ts_mode) { +switch (st->codecpar->codec_type) { +case AVMEDIA_TYPE_VIDEO: +ts_st->pid = ts->m2ts_video_pid++; +break; +case AVMEDIA_TYPE_AUDIO: +ts_st->pid = ts->m2ts_audio_pid++; +break; +case AVMEDIA_TYPE_SUBTITLE: +switch (st->codecpar->codec_id) { +case AV_CODEC_ID_HDMV_PGS_SUBTITLE: +ts_st->pid = ts->m2ts_pgssub_pid++; +break; +case AV_CODEC_ID_HDMV_TEXT_SUBTITLE: +ts_st->pid = ts->m2ts_textsub_pid++; +break; +} +break; +} +if (ts->m2ts_video_pid > M2TS_VIDEO_PID + 1 || +ts->m2ts_audio_pid > M2TS_AUDIO_START_PID + 32 || +ts->m2ts_pgssub_pid > M2TS_PGSSUB_START_PID + 32 || +ts->m2ts_textsub_pid > M2TS_TEXTSUB_START_PID + 32 || There can be only one text subtitle stream (pid 0x1800). In BluRay, text subtitles are stored in separate .m2ts files. There shouldn't be any other streams in the same mux. Indeed, thanks. I'll limit auto PID assignment to 1 streams. Regards, Marton +ts_st->pid < 16) { +av_log(s, AV_LOG_ERROR, "Cannot automatically assign PID for stream %d\n", st->index); +ret = AVERROR(EINVAL); +
[FFmpeg-devel] [PATCH v2 1/4] avformat/mpegtsenc: use standard pids for m2ts
Signed-off-by: Marton Balint --- doc/muxers.texi | 6 -- libavformat/mpegts.h| 10 ++ libavformat/mpegtsenc.c | 44 +++- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index e5b8debcb3..b3b8fe162e 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1633,11 +1633,13 @@ Advanced Codec Digital HDTV service. @item mpegts_pmt_start_pid @var{integer} Set the first PID for PMTs. Default is @code{0x1000}, minimum is @code{0x0020}, -maximum is @code{0x1ffa}. +maximum is @code{0x1ffa}. This option has no effect in m2ts mode where the PMT +PID is fixed @code{0x0100}. @item mpegts_start_pid @var{integer} Set the first PID for elementary streams. Default is @code{0x0100}, minimum is -@code{0x0020}, maximum is @code{0x1ffa}. +@code{0x0020}, maximum is @code{0x1ffa}. This option has no effect in m2ts mode +where the elementary stream PIDs are fixed. @item mpegts_m2ts_mode @var{boolean} Enable m2ts mode if set to @code{1}. Default value is @code{-1} which diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h index 86a3eba4e2..059b693f07 100644 --- a/libavformat/mpegts.h +++ b/libavformat/mpegts.h @@ -65,6 +65,16 @@ * streams and other data tables */ #define NULL_PID0x1FFF /* Null packet (used for fixed bandwidth padding) */ +/* m2ts pids */ +#define M2TS_PMT_PID 0x0100 +#define M2TS_PCR_PID 0x1001 +#define M2TS_VIDEO_PID0x1011 +#define M2TS_AUDIO_START_PID 0x1100 +#define M2TS_PGSSUB_START_PID 0x1200 +#define M2TS_TEXTSUB_PID 0x1800 +#define M2TS_SECONDARY_AUDIO_START_PID0x1A00 +#define M2TS_SECONDARY_VIDEO_START_PID0x1B00 + /* table ids */ #define PAT_TID 0x00 /* Program Association section */ #define CAT_TID 0x01 /* Conditional Access section */ diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index ccb631d746..bee996ad49 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -94,6 +94,10 @@ typedef struct MpegTSWrite { int pmt_start_pid; int start_pid; int m2ts_mode; +int m2ts_video_pid; +int m2ts_audio_pid; +int m2ts_pgssub_pid; +int m2ts_textsub_pid; int pcr_period_ms; #define MPEGTS_FLAG_REEMIT_PAT_PMT 0x01 @@ -860,6 +864,14 @@ static int mpegts_init(AVFormatContext *s) } } +ts->m2ts_video_pid = M2TS_VIDEO_PID; +ts->m2ts_audio_pid = M2TS_AUDIO_START_PID; +ts->m2ts_pgssub_pid = M2TS_PGSSUB_START_PID; +ts->m2ts_textsub_pid = M2TS_TEXTSUB_PID; + +if (ts->m2ts_mode) +ts->pmt_start_pid = M2TS_PMT_PID; + if (s->max_delay < 0) /* Not set by the caller */ s->max_delay = 0; @@ -923,7 +935,37 @@ static int mpegts_init(AVFormatContext *s) /* MPEG pid values < 16 are reserved. Applications which set st->id in * this range are assigned a calculated pid. */ if (st->id < 16) { -ts_st->pid = ts->start_pid + i; +if (ts->m2ts_mode) { +switch (st->codecpar->codec_type) { +case AVMEDIA_TYPE_VIDEO: +ts_st->pid = ts->m2ts_video_pid++; +break; +case AVMEDIA_TYPE_AUDIO: +ts_st->pid = ts->m2ts_audio_pid++; +break; +case AVMEDIA_TYPE_SUBTITLE: +switch (st->codecpar->codec_id) { +case AV_CODEC_ID_HDMV_PGS_SUBTITLE: +ts_st->pid = ts->m2ts_pgssub_pid++; +break; +case AV_CODEC_ID_HDMV_TEXT_SUBTITLE: +ts_st->pid = ts->m2ts_textsub_pid++; +break; +} +break; +} +if (ts->m2ts_video_pid > M2TS_VIDEO_PID + 1 || +ts->m2ts_audio_pid > M2TS_AUDIO_START_PID + 32 || +ts->m2ts_pgssub_pid > M2TS_PGSSUB_START_PID + 32 || +ts->m2ts_textsub_pid > M2TS_TEXTSUB_PID + 1|| +ts_st->pid < 16) { +av_log(s, AV_LOG_ERROR, "Cannot automatically assign PID for stream %d\n", st->index); +ret = AVERROR(EINVAL); +goto fail; +} +} else { +ts_st->pid = ts->start_pid + i; +} } else { ts_st->pid = st->id; } -- 2.16.4 ___ 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] Query regarding codec parsers
Am Do., 16. Apr. 2020 um 12:24 Uhr schrieb Gautam Ramakrishnan : > > On Mon, Apr 13, 2020 at 11:00 PM Carl Eugen Hoyos wrote: > > > > Am Mo., 13. Apr. 2020 um 17:27 Uhr schrieb Gautam Ramakrishnan > > : > > > > > > On Sun, Mar 29, 2020 at 8:34 PM Carl Eugen Hoyos > > > wrote: > > > > > > > > Am So., 29. März 2020 um 16:45 Uhr schrieb Gautam Ramakrishnan > > > > : > > > > > > > > > > > What exactly does a parser do and how is it different from a > > > > > > > decoder? > > > > > > > I am unable to understand the exact use case of a parser. > > > > > > > > > > > > Try the following: > > > > > > $ cat 1.jpg 2.jpg | ffmpeg -i -f null - > > > > > > (Is expected to decode two frames as can be seen in the console > > > > > > output, > > > > > > also works for example with png) > > > > > > > > > > > > $ cat 1.j2k 2.j2k | ffmpeg -i - -f null - > > > > > > Will only decode one frame because there is no parser to split the > > > > > > input. > > > > > > > > > > > So does it basically try to find the SOC marker and EOC markers and > > > > > split the streams into frames? > > > > > > > > Basically, yes. > > > > Look at existing parsers in libavcodec/*parser* (or git grep > > > > AVCodecParser), > > > > especially the jpeg parser. > > > > > Would working on a parser be a good idea now? > > > > Either that or you look at ticket #4681 (no idea how difficult this is). > I thought I'll start with the parser first. > I went through the BMP and JPEG parsers and needed some more clarification. > So, each frame could either be a JPEG2000 file or a JPEG2000 codestream. > The parse function must be able to find the end of the file/codestream > and return the location of it. Is my understanding correct? It is supposed to find the end of the first and the beginning of the second frame in above example, see what the jpg parser does. Carl Eugen ___ 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 v2 2/3] avdevice/opengl: add support of wrapped avframe codec
On Tue, 14 Apr 2020, Nicolas George wrote: Marton Balint (12020-04-11): Also change the default to that. Signed-off-by: Marton Balint --- libavdevice/opengl_enc.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) No objection. Thanks. Thanks, applied. Regards, Marton ___ 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 v2 1/3] avdevice/xv: add support of wrapped avframe codec
On Tue, 14 Apr 2020, Nicolas George wrote: Marton Balint (12020-04-11): Also change the default to that. Signed-off-by: Marton Balint --- libavdevice/xv.c | 22 ++ 1 file changed, 14 insertions(+), 8 deletions(-) No objection. Thanks. Thanks, applied. Regards, Marton ___ 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 v2] avutil/log: update text requesting samples
On Thu, 16 Apr 2020, Carl Eugen Hoyos wrote: Am Mo., 13. Apr. 2020 um 11:03 Uhr schrieb Marton Balint : On Mon, 13 Apr 2020, Carl Eugen Hoyos wrote: > Am Mo., 13. Apr. 2020 um 02:19 Uhr schrieb Marton Balint : >> >> >> >> On Mon, 13 Apr 2020, Carl Eugen Hoyos wrote: >> >> > Am Mo., 13. Apr. 2020 um 00:45 Uhr schrieb Marton Balint : >> >> >> >> Signed-off-by: Marton Balint >> >> --- >> >> libavutil/log.c | 6 +++--- >> >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> >> >> diff --git a/libavutil/log.c b/libavutil/log.c >> >> index 8d4945249e..965dbca5e1 100644 >> >> --- a/libavutil/log.c >> >> +++ b/libavutil/log.c >> >> @@ -466,9 +466,9 @@ static void missing_feature_sample(int sample, void *avc, const char *msg, >> >> "occurs, it means that your file has a feature which has not " >> >> "been implemented.\n"); >> >> if (sample) >> >> -av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample " >> >> - "of this file to ftp://upload.ffmpeg.org/incoming/ " >> >> - "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n"); >> >> +av_log(avc, AV_LOG_WARNING, "If you want to help, contact " >> >> + "ffmpeg-devel@ffmpeg.org and if requested upload a sample " >> >> + "of this file to https://streams.videolan.org/upload/\n";); >> > >> > Uploading a sample is of course much more important than sending an email, >> > so this makes the patch significantly worse imo. >> >> You wrote that we typically ask for samples we already have. So why >> aks for uploading them first? > > Even if we already have 99% of such samples (we certainly don't), I > would consider getting the remaining 1% of highest importance. So you want to keep the text as is and only change ftp://upload.ffmpeg.org/incoming/ to https://streams.videolan.org/upload/ right? Yes, please. Ok, pushed the patch changing that text only. Thanks, Marton ___ 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] [FFmpeg-cvslog] avutil/log: update text requesting samples
Am Fr., 17. Apr. 2020 um 00:14 Uhr schrieb Marton Balint : > > ffmpeg | branch: master | Marton Balint | Fri Apr 17 > 00:04:47 2020 +0200| [d1e52e396b8aa778bd8d12bf25864beca0937d0a] | committer: > Marton Balint > > avutil/log: update text requesting samples > > Signed-off-by: Marton Balint > > > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d1e52e396b8aa778bd8d12bf25864beca0937d0a > --- > > libavutil/log.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavutil/log.c b/libavutil/log.c > index 8d4945249e..66defa9c42 100644 > --- a/libavutil/log.c > +++ b/libavutil/log.c > @@ -467,7 +467,7 @@ static void missing_feature_sample(int sample, void *avc, > const char *msg, > "been implemented.\n"); > if (sample) > av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample " > - "of this file to ftp://upload.ffmpeg.org/incoming/ " > + "of this file to https://streams.videolan.org/upload/ " Thank you, the change was overdue, this will help users! Carl Eugen ___ 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/bsf: use simplified algorithm for bsf_list chained filtering
On Fri, 10 Apr 2020, Andreas Rheinhardt wrote: Marton Balint: On Thu, 9 Apr 2020, Andreas Rheinhardt wrote: Marton Balint: Based on the one in ffmpeg.c and it is not using an extra flush_idx variable. Signed-off-by: Marton Balint --- libavcodec/bsf.c | 64 ++-- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c index 7b96183e64..b9fc771a88 100644 --- a/libavcodec/bsf.c +++ b/libavcodec/bsf.c @@ -18,6 +18,7 @@ #include +#include "libavutil/avassert.h" #include "libavutil/log.h" #include "libavutil/mem.h" #include "libavutil/opt.h" @@ -266,7 +267,6 @@ typedef struct BSFListContext { int nb_bsfs; unsigned idx; // index of currently processed BSF - unsigned flushed_idx; // index of BSF being flushed char * item_name; } BSFListContext; @@ -304,57 +304,43 @@ fail: static int bsf_list_filter(AVBSFContext *bsf, AVPacket *out) { BSFListContext *lst = bsf->priv_data; - int ret; + int ret, eof = 0; if (!lst->nb_bsfs) return ff_bsf_get_packet_ref(bsf, out); while (1) { - if (lst->idx > lst->flushed_idx) { + /* get a packet from the previous filter up the chain */ + if (lst->idx) ret = av_bsf_receive_packet(lst->bsfs[lst->idx-1], out); - if (ret == AVERROR(EAGAIN)) { - /* no more packets from idx-1, try with previous */ - lst->idx--; - continue; - } else if (ret == AVERROR_EOF) { - /* filter idx-1 is done, continue with idx...nb_bsfs */ - lst->flushed_idx = lst->idx; - continue; Is it just me or did this continue make no sense at all? It claims to continue with idx...nb_bsf, yet it actually tried to get a new packet via ff_bsf_get_packet_ref(). Agreed, seems like a bug of the old code. - }else if (ret < 0) { - /* filtering error */ - break; - } - } else { + else ret = ff_bsf_get_packet_ref(bsf, out); - if (ret == AVERROR_EOF) { - lst->idx = lst->flushed_idx; - } else if (ret < 0) - break; - } + if (ret == AVERROR(EAGAIN)) { + if (!lst->idx) + return ret; + lst->idx--; + continue; + } else if (ret == AVERROR_EOF) { + eof = 1; + } else if (ret < 0) + return ret; If you return here, the chain may not be completely drained (e.g. bsf 0 may still have packets ready to be output even if bsf 1 returned an error while filtering a packet obtained from bsf 0) and despite this error, the caller is responsible (according to the doc of av_bsf_send/receive_packet) to drain the chain completely before sending new packets. I don't see an issue, bsf 0 will be drained on a subsequent call to bsf_list_filter. In particular, if you use this in mux.c, you will have to keep calling av_bsf_receive_packet() until the chain is drained even when the bsf returns an error or when a write error occurs and you have to do this even on AV_EF_EXPLODE. (Otherwise there might be a situation where the next packet to be written can't even be sent to the chain because it is not drained.) How else could it work? You call av_bsf_receive_packet() until you get AVERROR(EAGAIN) or AVERROR_EOF, as the doc of av_bsf_receive_packet() says. If you get an other error, it is up to you to decice, either ignore it and retry draining or report it to the user (it seems we only do this if AV_EF_EXPLODE is set). I wanted to stress this point because your earlier code [1] was different than what I have just sketched. It did not completely drain the bsf list on errors and therefore had the possibility to completely ignore a packet: Consider the following scenario: One has a list of two bsfs and the first packet can create multiple output packets out of the first input packets. Imagine the second bsf returns an error when it is fed the first of these. Then write_packets_common() would exit without having drained the first filter (if it returns an error or not depends upon AV_EF_EXPLODE). When the caller sends the next packet, auto_bsf_receive_packet() would first try to drain the first bsf. If the second bsf now errors out again, write_packets_common() returns without having tried to send the new packet. (The code in ffmpeg.c is buggy in this regard.) I see one problem only, that you can't differentiate between a permanent and a temporary av_bsf_receive_packet() error, so a badly written bsf can get you and infinite loop by its filter call always returning an error, if you decide to ignore BSF errors. Yes. Hopefully we don't have such rogue bitstream filters. - Andreas PS: I forgot to mention something in the first answer: Good job at simplifying this function. I plan to apply this patch soon.
Re: [FFmpeg-devel] [FFmpeg-cvslog] avutil/log: update text requesting samples
On 4/16/2020 7:15 PM, Carl Eugen Hoyos wrote: > Am Fr., 17. Apr. 2020 um 00:14 Uhr schrieb Marton Balint : >> >> ffmpeg | branch: master | Marton Balint | Fri Apr 17 >> 00:04:47 2020 +0200| [d1e52e396b8aa778bd8d12bf25864beca0937d0a] | committer: >> Marton Balint >> >> avutil/log: update text requesting samples >> >> Signed-off-by: Marton Balint >> >>> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d1e52e396b8aa778bd8d12bf25864beca0937d0a >> --- >> >> libavutil/log.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/libavutil/log.c b/libavutil/log.c >> index 8d4945249e..66defa9c42 100644 >> --- a/libavutil/log.c >> +++ b/libavutil/log.c >> @@ -467,7 +467,7 @@ static void missing_feature_sample(int sample, void >> *avc, const char *msg, >> "been implemented.\n"); >> if (sample) >> av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample " >> - "of this file to ftp://upload.ffmpeg.org/incoming/ " >> + "of this file to https://streams.videolan.org/upload/ " > > Thank you, the change was overdue, this will help users! > > Carl Eugen Maybe this should this be backported? Plenty of users will only get to use distro provided releases, and it would be nice if they get to see this too. ___ 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] fftools/ffmpeg_opt: Check attachment filesize
On Wed, Apr 15, 2020 at 11:06:13PM +0200, Andreas Rheinhardt wrote: > The data of an attachment file is put into an AVCodecParameter's > extradata. The corresponding size field has type int, yet there was no > check for the size to fit into an int. As a consequence, it was possible > to create extradata with negative size (by using a big enough max_alloc). > > Other errors were also possible: If SIZE_MAX < INT64_MAX (e.g. on 32bit > systems) then the file size might be truncated before the allocation; > and avio_read() takes an int, too, so one would not have read as much > as one desired. > > Furthermore, the extradata is now padded as is required. > > Signed-off-by: Andreas Rheinhardt > --- > fftools/ffmpeg_opt.c | 6 -- > 1 file changed, 4 insertions(+), 2 deletions(-) LGTM thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is dangerous to be right in matters on which the established authorities are wrong. -- 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/3] lavc/pgs_frame_merge_bsf: add bsf to merge PGS segments
On Thu, 2020-04-16 at 22:39 +0200, Andreas Rheinhardt wrote: > John Stebbins: > > Required to remux m2ts to mkv > > --- > > libavcodec/Makefile | 1 + > > libavcodec/bitstream_filters.c | 1 + > > libavcodec/pgs_frame_merge_bsf.c | 152 > > +++ > > Missing version bump. > > > 3 files changed, 154 insertions(+) > > create mode 100644 libavcodec/pgs_frame_merge_bsf.c > > > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > > index c1c9a44f2b..13909faabf 100644 > > --- a/libavcodec/Makefile > > +++ b/libavcodec/Makefile > > @@ -1119,6 +1119,7 @@ OBJS-$(CONFIG_VP9_METADATA_BSF) += > > vp9_metadata_bsf.o > > OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)+= vp9_raw_reorder_bsf.o > > OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o > > OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF) += > > vp9_superframe_split_bsf.o > > +OBJS-$(CONFIG_PGS_FRAME_MERGE_BSF)+= pgs_frame_merge_bsf.o > > Not sorted alphabetically. Will do. I didn't notice they were sorted. > > > > # thread libraries > > OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o > > diff --git a/libavcodec/bitstream_filters.c > > b/libavcodec/bitstream_filters.c > > index 6b5ffe4d70..138f6dd7ad 100644 > > --- a/libavcodec/bitstream_filters.c > > +++ b/libavcodec/bitstream_filters.c > > @@ -58,6 +58,7 @@ extern const AVBitStreamFilter > > ff_vp9_metadata_bsf; > > extern const AVBitStreamFilter ff_vp9_raw_reorder_bsf; > > extern const AVBitStreamFilter ff_vp9_superframe_bsf; > > extern const AVBitStreamFilter ff_vp9_superframe_split_bsf; > > +extern const AVBitStreamFilter ff_pgs_frame_merge_bsf; > > Not sorted alphabetically. ditto > > > > > #include "libavcodec/bsf_list.c" > > > > diff --git a/libavcodec/pgs_frame_merge_bsf.c > > b/libavcodec/pgs_frame_merge_bsf.c > > new file mode 100644 > > index 00..4b8061d4e1 > > --- /dev/null > > +++ b/libavcodec/pgs_frame_merge_bsf.c > > @@ -0,0 +1,152 @@ > > +/* > > + * Copyright (c) 2020 John Stebbins > > + * > > + * This file is part of FFmpeg. > > + * > > + * FFmpeg is free software; you can redistribute it and/or > > + * modify it under the terms of the GNU Lesser General Public > > + * License as published by the Free Software Foundation; either > > + * version 2.1 of the License, or (at your option) any later > > version. > > + * > > + * FFmpeg is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > GNU > > + * Lesser General Public License for more details. > > + * > > + * You should have received a copy of the GNU Lesser General > > Public > > + * License along with FFmpeg; if not, write to the Free Software > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > > 02110-1301 USA > > + */ > > + > > +/** > > + * @file > > + * This bitstream filter merges PGS subtitle packets containing > > incomplete > > + * set of segments into a single packet > > + * > > + * Packets already containing a complete set of segments will be > > passed through > > + * unchanged. > > + */ > > + > > +#include "avcodec.h" > > +#include "bsf.h" > > +#include "libavutil/intreadwrite.h" > > + > > +enum PGSSegmentType { > > +PALETTE_SEGMENT = 0x14, > > +OBJECT_SEGMENT = 0x15, > > +PRESENTATION_SEGMENT = 0x16, > > +WINDOW_SEGMENT = 0x17, > > +DISPLAY_SEGMENT = 0x80, > > +}; > > + > > +typedef struct PGSMergeContext { > > +AVPacket *buffer_pkt, *in; > > +} PGSMergeContext; > > + > > +static void frame_merge_flush(AVBSFContext *bsf) > > +{ > > +PGSMergeContext *ctx = bsf->priv_data; > > + > > +av_packet_unref(ctx->in); > > +av_packet_unref(ctx->buffer_pkt); > > +} > > + > > +static int frame_merge_filter(AVBSFContext *bsf, AVPacket *out) > > +{ > > +PGSMergeContext *ctx = bsf->priv_data; > > +AVPacket *in = ctx->in, *pkt = ctx->buffer_pkt; > > +int ret, i, size, pos, display = 0; > > +uint8_t segment_type; > > +uint16_t segment_len; > > + > > +if (!in->data) { > > +ret = ff_bsf_get_packet_ref(bsf, in); > > +if (ret < 0) > > +return ret; > > +} > > +if (!in->size) { > > +av_packet_unref(in); > > +return AVERROR(EAGAIN); > > +} > > + > > +// Validate packet data and find display_end segment > > +size = in->size; > > +i = 0; > > +while (i < in->size) { > > +segment_type = in->data[i]; > > +segment_len = AV_RB16(in->data + i + 1) + 3; > > 1. This code only requires the input packet to be padded as reading > segment_len is not guaranteed to be part of your packet. I have no > problem with that, yet you should add a comment about it. Oops, I did not intend to read past the end of the packet. I'll fix that. > 2. Both segment_type and segment_len could be made local variable of > this loop. Will do > 3. The
[FFmpeg-devel] [PATCH 1/3] lavc/pgs_frame_merge_bsf: add bsf to merge PGS segments
Required to remux m2ts to mkv --- libavcodec/Makefile | 1 + libavcodec/bitstream_filters.c | 1 + libavcodec/pgs_frame_merge_bsf.c | 164 +++ 3 files changed, 166 insertions(+) create mode 100644 libavcodec/pgs_frame_merge_bsf.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index c1c9a44f2b..c7d8fbebaa 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1110,6 +1110,7 @@ OBJS-$(CONFIG_MP3_HEADER_DECOMPRESS_BSF) += mp3_header_decompress_bsf.o \ OBJS-$(CONFIG_MPEG2_METADATA_BSF) += mpeg2_metadata_bsf.o OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o OBJS-$(CONFIG_NULL_BSF) += null_bsf.o +OBJS-$(CONFIG_PGS_FRAME_MERGE_BSF)+= pgs_frame_merge_bsf.o OBJS-$(CONFIG_PRORES_METADATA_BSF)+= prores_metadata_bsf.o OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += remove_extradata_bsf.o OBJS-$(CONFIG_TEXT2MOVSUB_BSF)+= movsub_bsf.o diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c index 6b5ffe4d70..92619225f0 100644 --- a/libavcodec/bitstream_filters.c +++ b/libavcodec/bitstream_filters.c @@ -49,6 +49,7 @@ extern const AVBitStreamFilter ff_mpeg4_unpack_bframes_bsf; extern const AVBitStreamFilter ff_mov2textsub_bsf; extern const AVBitStreamFilter ff_noise_bsf; extern const AVBitStreamFilter ff_null_bsf; +extern const AVBitStreamFilter ff_pgs_frame_merge_bsf; extern const AVBitStreamFilter ff_prores_metadata_bsf; extern const AVBitStreamFilter ff_remove_extradata_bsf; extern const AVBitStreamFilter ff_text2movsub_bsf; diff --git a/libavcodec/pgs_frame_merge_bsf.c b/libavcodec/pgs_frame_merge_bsf.c new file mode 100644 index 00..d1bb3a60c2 --- /dev/null +++ b/libavcodec/pgs_frame_merge_bsf.c @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2020 John Stebbins + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * This bitstream filter merges PGS subtitle packets containing incomplete + * set of segments into a single packet + * + * Packets already containing a complete set of segments will be passed through + * unchanged. + */ + +#include "avcodec.h" +#include "bsf.h" +#include "libavutil/intreadwrite.h" + +enum PGSSegmentType { +PALETTE_SEGMENT = 0x14, +OBJECT_SEGMENT = 0x15, +PRESENTATION_SEGMENT = 0x16, +WINDOW_SEGMENT = 0x17, +DISPLAY_SEGMENT = 0x80, +}; + +typedef struct PGSMergeContext { +AVPacket *buffer_pkt, *in; +int presentation_found; +} PGSMergeContext; + +static void frame_merge_flush(AVBSFContext *bsf) +{ +PGSMergeContext *ctx = bsf->priv_data; + +av_packet_unref(ctx->in); +av_packet_unref(ctx->buffer_pkt); +} + +static int frame_merge_filter(AVBSFContext *bsf, AVPacket *out) +{ +PGSMergeContext *ctx = bsf->priv_data; +AVPacket *in = ctx->in, *pkt = ctx->buffer_pkt; +int ret, i, size, pos, display = 0; + +if (!in->data) { +ret = ff_bsf_get_packet_ref(bsf, in); +if (ret < 0) +return ret; +} +if (!in->size) { +av_packet_unref(in); +return AVERROR(EAGAIN); +} + +// Validate packet data and find display_end segment +size = in->size; +i = 0; +while (i + 3 <= in->size) { +uint8_t segment_type; +int segment_len; + +segment_type = in->data[i]; +segment_len = AV_RB16(in->data + i + 1) + 3; +if (i + segment_len > in->size) // Invalid data +break; +if (segment_type == PRESENTATION_SEGMENT && !ctx->presentation_found) { +int object_count; +ctx->presentation_found = 1; +ret = av_packet_copy_props(pkt, in); +if (ret < 0) +goto fail; +object_count = in->data[i + 13]; +pkt->flags = !!object_count * AV_PKT_FLAG_KEY; +} +i += segment_len; +if (segment_type == DISPLAY_SEGMENT) { +size = display = i; +break; +} +} +if (display && pkt->size == 0 && size == in->size) { // passthrough +av_packet_move_ref(out, in); +return 0; +} +if ((!display && i != in->size) || size > in->size) { +av_log(bsf, AV_LOG_WARNING, "Failed to parse PGS segments.\n");
Re: [FFmpeg-devel] [PATCH 1/3] lavc/pgs_frame_merge_bsf: add bsf to merge PGS segments
On Thu, 2020-04-16 at 16:57 -0600, John Stebbins wrote: > Required to remux m2ts to mkv > --- > libavcodec/Makefile | 1 + > libavcodec/bitstream_filters.c | 1 + > libavcodec/pgs_frame_merge_bsf.c | 164 > +++ > 3 files changed, 166 insertions(+) > create mode 100644 libavcodec/pgs_frame_merge_bsf.c > Ugh! I forgot the version bump. Will get on that... > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index c1c9a44f2b..c7d8fbebaa 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1110,6 +1110,7 @@ OBJS-$(CONFIG_MP3_HEADER_DECOMPRESS_BSF) += > mp3_header_decompress_bsf.o \ > OBJS-$(CONFIG_MPEG2_METADATA_BSF) += mpeg2_metadata_bsf.o > OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o > OBJS-$(CONFIG_NULL_BSF) += null_bsf.o > +OBJS-$(CONFIG_PGS_FRAME_MERGE_BSF)+= pgs_frame_merge_bsf.o > OBJS-$(CONFIG_PRORES_METADATA_BSF)+= prores_metadata_bsf.o > OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += remove_extradata_bsf.o > OBJS-$(CONFIG_TEXT2MOVSUB_BSF)+= movsub_bsf.o > diff --git a/libavcodec/bitstream_filters.c > b/libavcodec/bitstream_filters.c > index 6b5ffe4d70..92619225f0 100644 > --- a/libavcodec/bitstream_filters.c > +++ b/libavcodec/bitstream_filters.c > @@ -49,6 +49,7 @@ extern const AVBitStreamFilter > ff_mpeg4_unpack_bframes_bsf; > extern const AVBitStreamFilter ff_mov2textsub_bsf; > extern const AVBitStreamFilter ff_noise_bsf; > extern const AVBitStreamFilter ff_null_bsf; > +extern const AVBitStreamFilter ff_pgs_frame_merge_bsf; > extern const AVBitStreamFilter ff_prores_metadata_bsf; > extern const AVBitStreamFilter ff_remove_extradata_bsf; > extern const AVBitStreamFilter ff_text2movsub_bsf; > diff --git a/libavcodec/pgs_frame_merge_bsf.c > b/libavcodec/pgs_frame_merge_bsf.c > new file mode 100644 > index 00..d1bb3a60c2 > --- /dev/null > +++ b/libavcodec/pgs_frame_merge_bsf.c > @@ -0,0 +1,164 @@ > +/* > + * Copyright (c) 2020 John Stebbins > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later > version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > 02110-1301 USA > + */ > + > +/** > + * @file > + * This bitstream filter merges PGS subtitle packets containing > incomplete > + * set of segments into a single packet > + * > + * Packets already containing a complete set of segments will be > passed through > + * unchanged. > + */ > + > +#include "avcodec.h" > +#include "bsf.h" > +#include "libavutil/intreadwrite.h" > + > +enum PGSSegmentType { > +PALETTE_SEGMENT = 0x14, > +OBJECT_SEGMENT = 0x15, > +PRESENTATION_SEGMENT = 0x16, > +WINDOW_SEGMENT = 0x17, > +DISPLAY_SEGMENT = 0x80, > +}; > + > +typedef struct PGSMergeContext { > +AVPacket *buffer_pkt, *in; > +int presentation_found; > +} PGSMergeContext; > + > +static void frame_merge_flush(AVBSFContext *bsf) > +{ > +PGSMergeContext *ctx = bsf->priv_data; > + > +av_packet_unref(ctx->in); > +av_packet_unref(ctx->buffer_pkt); > +} > + > +static int frame_merge_filter(AVBSFContext *bsf, AVPacket *out) > +{ > +PGSMergeContext *ctx = bsf->priv_data; > +AVPacket *in = ctx->in, *pkt = ctx->buffer_pkt; > +int ret, i, size, pos, display = 0; > + > +if (!in->data) { > +ret = ff_bsf_get_packet_ref(bsf, in); > +if (ret < 0) > +return ret; > +} > +if (!in->size) { > +av_packet_unref(in); > +return AVERROR(EAGAIN); > +} > + > +// Validate packet data and find display_end segment > +size = in->size; > +i = 0; > +while (i + 3 <= in->size) { > +uint8_t segment_type; > +int segment_len; > + > +segment_type = in->data[i]; > +segment_len = AV_RB16(in->data + i + 1) + 3; > +if (i + segment_len > in->size) // Invalid data > +break; > +if (segment_type == PRESENTATION_SEGMENT && !ctx- > >presentation_found) { > +int object_count; > +ctx->presentation_found = 1; > +ret = av_packet_copy_props(pkt, in); > +if (ret < 0) > +goto fail; > +object_count = in->data[i + 13]; > +pkt->flags = !!object_count * AV_PKT_FLAG_KEY; > +} > +i += segment_len
Re: [FFmpeg-devel] [PATCH 1/3] lavc/pgs_frame_merge_bsf: add bsf to merge PGS segments
On Thu, 2020-04-16 at 15:59 -0700, John Stebbins wrote: > On Thu, 2020-04-16 at 16:57 -0600, John Stebbins wrote: > > Required to remux m2ts to mkv > > --- > > libavcodec/Makefile | 1 + > > libavcodec/bitstream_filters.c | 1 + > > libavcodec/pgs_frame_merge_bsf.c | 164 > > +++ > > 3 files changed, 166 insertions(+) > > create mode 100644 libavcodec/pgs_frame_merge_bsf.c > > > > Ugh! I forgot the version bump. Will get on that... A question about this. I have 2 bsf submitted for review. Should I just do a separate patch that updates the minor version once. Or do you require it to be bumped with each change separately? > > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > > index c1c9a44f2b..c7d8fbebaa 100644 > > --- a/libavcodec/Makefile > > +++ b/libavcodec/Makefile > > @@ -1110,6 +1110,7 @@ OBJS-$(CONFIG_MP3_HEADER_DECOMPRESS_BSF) += > > mp3_header_decompress_bsf.o \ > > OBJS-$(CONFIG_MPEG2_METADATA_BSF) += mpeg2_metadata_bsf.o > > OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o > > OBJS-$(CONFIG_NULL_BSF) += null_bsf.o > > +OBJS-$(CONFIG_PGS_FRAME_MERGE_BSF)+= pgs_frame_merge_bsf.o > > OBJS-$(CONFIG_PRORES_METADATA_BSF)+= prores_metadata_bsf.o > > OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += > > remove_extradata_bsf.o > > OBJS-$(CONFIG_TEXT2MOVSUB_BSF)+= movsub_bsf.o > > diff --git a/libavcodec/bitstream_filters.c > > b/libavcodec/bitstream_filters.c > > index 6b5ffe4d70..92619225f0 100644 > > --- a/libavcodec/bitstream_filters.c > > +++ b/libavcodec/bitstream_filters.c > > @@ -49,6 +49,7 @@ extern const AVBitStreamFilter > > ff_mpeg4_unpack_bframes_bsf; > > extern const AVBitStreamFilter ff_mov2textsub_bsf; > > extern const AVBitStreamFilter ff_noise_bsf; > > extern const AVBitStreamFilter ff_null_bsf; > > +extern const AVBitStreamFilter ff_pgs_frame_merge_bsf; > > extern const AVBitStreamFilter ff_prores_metadata_bsf; > > extern const AVBitStreamFilter ff_remove_extradata_bsf; > > extern const AVBitStreamFilter ff_text2movsub_bsf; > > diff --git a/libavcodec/pgs_frame_merge_bsf.c > > b/libavcodec/pgs_frame_merge_bsf.c > > new file mode 100644 > > index 00..d1bb3a60c2 > > --- /dev/null > > +++ b/libavcodec/pgs_frame_merge_bsf.c > > @@ -0,0 +1,164 @@ > > +/* > > + * Copyright (c) 2020 John Stebbins > > + * > > + * This file is part of FFmpeg. > > + * > > + * FFmpeg is free software; you can redistribute it and/or > > + * modify it under the terms of the GNU Lesser General Public > > + * License as published by the Free Software Foundation; either > > + * version 2.1 of the License, or (at your option) any later > > version. > > + * > > + * FFmpeg is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > GNU > > + * Lesser General Public License for more details. > > + * > > + * You should have received a copy of the GNU Lesser General > > Public > > + * License along with FFmpeg; if not, write to the Free Software > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > > 02110-1301 USA > > + */ > > + > > +/** > > + * @file > > + * This bitstream filter merges PGS subtitle packets containing > > incomplete > > + * set of segments into a single packet > > + * > > + * Packets already containing a complete set of segments will be > > passed through > > + * unchanged. > > + */ > > + > > +#include "avcodec.h" > > +#include "bsf.h" > > +#include "libavutil/intreadwrite.h" > > + > > +enum PGSSegmentType { > > +PALETTE_SEGMENT = 0x14, > > +OBJECT_SEGMENT = 0x15, > > +PRESENTATION_SEGMENT = 0x16, > > +WINDOW_SEGMENT = 0x17, > > +DISPLAY_SEGMENT = 0x80, > > +}; > > + > > +typedef struct PGSMergeContext { > > +AVPacket *buffer_pkt, *in; > > +int presentation_found; > > +} PGSMergeContext; > > + > > +static void frame_merge_flush(AVBSFContext *bsf) > > +{ > > +PGSMergeContext *ctx = bsf->priv_data; > > + > > +av_packet_unref(ctx->in); > > +av_packet_unref(ctx->buffer_pkt); > > +} > > + > > +static int frame_merge_filter(AVBSFContext *bsf, AVPacket *out) > > +{ > > +PGSMergeContext *ctx = bsf->priv_data; > > +AVPacket *in = ctx->in, *pkt = ctx->buffer_pkt; > > +int ret, i, size, pos, display = 0; > > + > > +if (!in->data) { > > +ret = ff_bsf_get_packet_ref(bsf, in); > > +if (ret < 0) > > +return ret; > > +} > > +if (!in->size) { > > +av_packet_unref(in); > > +return AVERROR(EAGAIN); > > +} > > + > > +// Validate packet data and find display_end segment > > +size = in->size; > > +i = 0; > > +while (i + 3 <= in->size) { > > +uint8_t segment_type; > > +int segment_len; > > + > > +segment_type = in->data[i]; > > +segment_len = AV_RB16(in-
[FFmpeg-devel] [PATCH] libavcodec/libx264: fix reference frame computation based on level
Hell, can someone please review this patch? It fixes a wrong reference frame computation problem when using parameters such as "-level 31" instead of "-level 3.1". From 9f9dcb3cceebb360468fea762b01780f65764a47 Mon Sep 17 00:00:00 2001 From: Josh Brewster Date: Thu, 16 Apr 2020 22:50:29 +0200 Subject: [PATCH] libavcodec/libx264: fix reference frame computation based on level The current implementation allows passing levels to libavcodec as integers (such as "31" instead of "3.1"). However, in this case, the maximum reference frame value per level was ignored because libavcodec converted the string to 310 instead of 31. This commit changes the way levels are converted to int from strings, following an algoritm similar to that of x264 (currently defined in common/base.c). Signed-off-by: Josh Brewster --- libavcodec/libx264.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index a08fe0ce76..1149f2d668 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -701,11 +701,14 @@ FF_ENABLE_DEPRECATION_WARNINGS if (!strcmp(x4->level, "1b")) { level_id = 9; -} else if (strlen(x4->level) <= 3){ +} else if (av_strtod(x4->level, NULL) < 7){ level_id = av_strtod(x4->level, &tail) * 10 + 0.5; if (*tail) level_id = -1; } +else { +level_id = av_strtod(x4->level, NULL); +} if (level_id <= 0) av_log(avctx, AV_LOG_WARNING, "Failed to parse level\n"); -- 2.26.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".
Re: [FFmpeg-devel] [PATCH v8 1/2] avcodec: add support for Cunning Developments' ADPCM
On Thu, 16 Apr 2020 21:37:54 +0200 "Michael Niedermayer" wrote: > > > > @@ -1304,6 +1329,13 @@ static int > > > > adpcm_decode_frame(AVCodecContext *avctx, void *data, samples > > > > += avctx->channels; } > > > > break; > > > > +case AV_CODEC_ID_ADPCM_IMA_CUNNING: > > > > +while (bytestream2_get_bytes_left(&gb) > 0) { > > > > +int v = bytestream2_get_byteu(&gb); > > > > +*samples++ = > > > > adpcm_ima_cunning_expand_nibble(&c->status[0], v & 0x0F); > > > > +*samples++ = > > > > adpcm_ima_cunning_expand_nibble(&c->status[0], v >> 4); > > > > +} > > > > +break; > > > > > > i would add an av_assert to ensure the samples array is large > > > enough and the code seting it stays in sync. And also so the > > > reader knows at a glance that this is ok with only a check on the > > > input size > > > > So, something like this? > > av_assert0(frame->nb_samples == buf_size * 2); > > as the loop runs bytestream2_get_bytes_left(&gb) iterations > the check should be between that and nb_samples i think In that case, would it just be better to change the while() to a for()? Same thing, but it shows the samples/nb_samples relationship. for (n = 0; n < nb_samples / 2; n++) {} There's a few other decoders that use the same while() I did originally, so it might be worth changing them too. ___ 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] fftools/ffmpeg_opt: Check attachment filesize
Michael Niedermayer: > On Wed, Apr 15, 2020 at 11:06:13PM +0200, Andreas Rheinhardt wrote: >> The data of an attachment file is put into an AVCodecParameter's >> extradata. The corresponding size field has type int, yet there was no >> check for the size to fit into an int. As a consequence, it was possible >> to create extradata with negative size (by using a big enough max_alloc). >> >> Other errors were also possible: If SIZE_MAX < INT64_MAX (e.g. on 32bit >> systems) then the file size might be truncated before the allocation; >> and avio_read() takes an int, too, so one would not have read as much >> as one desired. >> >> Furthermore, the extradata is now padded as is required. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> fftools/ffmpeg_opt.c | 6 -- >> 1 file changed, 4 insertions(+), 2 deletions(-) > > LGTM > > thx > > [...] > Applied, thanks. - 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".
[FFmpeg-devel] [PATCH 5/5] avformat/matroskaenc: Remove limit on the number of tracks
The Matroska file format has practically no limit on the number of tracks (the current limit is 2^56 - 1); yet because they are encoded in a variable length format in (Simple)Blocks this muxer has simply imposed a limit on the number of tracks in order to ensure that they can always be written on one byte in order to simplify the muxing process. This commit removes said limit. Also, zero is an invalid TrackNumber, so disallow this value in the dash_track_number option. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 34 +- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 92cd819312..fcca4c2e87 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -93,6 +93,7 @@ typedef struct mkv_track { int has_cue; uint64_tuid; unsignedtrack_num; +int track_num_size; int sample_rate; int64_t sample_rate_offset; int64_t last_timestamp; @@ -105,10 +106,6 @@ typedef struct mkv_track { #define MODE_MATROSKAv2 0x01 #define MODE_WEBM 0x02 -/** Maximum number of tracks allowed in a Matroska file (with track numbers in - * range 1 to 126 (inclusive) */ -#define MAX_TRACKS 126 - typedef struct MatroskaMuxContext { const AVClass *class; int mode; @@ -1905,9 +1902,9 @@ static int mkv_write_header(AVFormatContext *s) return 0; } -static int mkv_blockgroup_size(int pkt_size) +static int mkv_blockgroup_size(int pkt_size, int track_num_size) { -int size = pkt_size + 4; +int size = pkt_size + track_num_size + 3; size += ebml_length_size(size); size += 2; // EBML ID for block and block duration size += 9; // max size of block duration incl. length field @@ -2047,9 +2044,8 @@ static int mkv_write_block(AVFormatContext *s, AVIOContext *pb, } put_ebml_id(pb, blockid); -put_ebml_length(pb, size + 4, 0); -// this assumes stream_index is less than 126 -avio_w8(pb, 0x80 | track_number); +put_ebml_length(pb, size + track->track_num_size + 3, 0); +put_ebml_num(pb, track_number, track->track_num_size); avio_wb16(pb, ts - mkv->cluster_pts); avio_w8(pb, (blockid == MATROSKA_ID_SIMPLEBLOCK && keyframe) ? (1 << 7) : 0); avio_write(pb, data + offset, size); @@ -2112,11 +2108,12 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *p size, pkt->pts, pkt->dts, pkt->duration, avio_tell(pb), mkv->cluster_pos, track->track_num, 1); -blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(size)); +blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, + mkv_blockgroup_size(size, track->track_num_size)); put_ebml_id(pb, MATROSKA_ID_BLOCK); -put_ebml_length(pb, size + 4, 0); -avio_w8(pb, 0x80 | track->track_num); // this assumes track_num is less than 126 +put_ebml_length(pb, size + track->track_num_size + 3, 0); +put_ebml_num(pb, track->track_num, track->track_num_size); avio_wb16(pb, ts - mkv->cluster_pts); avio_w8(pb, flags); avio_printf(pb, "%.*s\n%.*s\n%.*s", id_size, id, settings_size, settings, pkt->size, pkt->data); @@ -2290,7 +2287,8 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_ duration = mkv_write_vtt_blocks(s, pb, pkt); } else { ebml_master blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, - mkv_blockgroup_size(pkt->size)); + mkv_blockgroup_size(pkt->size, + track->track_num_size)); #if FF_API_CONVERGENCE_DURATION FF_DISABLE_DEPRECATION_WARNINGS @@ -2652,13 +2650,7 @@ static int mkv_init(struct AVFormatContext *s) nb_tracks++; track->track_num = mkv->is_dash ? mkv->dash_track_number : nb_tracks; -} - -if (nb_tracks > MAX_TRACKS) { -av_log(s, AV_LOG_ERROR, - "%u > "AV_STRINGIFY(MAX_TRACKS)" tracks (excluding attachments)" - " not supported for muxing in Matroska\n", nb_tracks); -return AVERROR(EINVAL); +track->track_num_size = ebml_num_size(track->track_num); } return 0; @@ -2716,7 +2708,7 @@ static const AVOption options[] = { { "cluster_size_limit", "Store at most the provided amount of bytes in a cluster. ", OFFSET(cluster_size_limit), AV_OPT_TYPE_INT , { .i64 = -1 }, -1, INT_MAX, FLAGS }, { "cluster_time_limit", "Store at most the provided number of milliseconds in a cluster.", OFFSET(cluster_time_limit), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MA
[FFmpeg-devel] [PATCH 3/5] avformat/matroskaenc: Rename functions to better reflect what they do
EBML uses variable length integers both for the EBML IDs as well as for the EBML lengths; Matroska also uses them for the TrackNumber in (Simple)Blocks and for the lengths of laces when EBML lacing is used. When encoding EBML lengths, certain encodings have a special meaning, namely that the element has an unknown length. This is not so when encoding general EBML variable length integers. Yet the functions called ebml_num_size() and put_ebml_num() had this special meaning hardcoded, i.e. they are there to write EBML lengths and not general EBML numbers. So rename them. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 53 --- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 407920172d..7cea813dc0 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -190,30 +190,31 @@ static void put_ebml_size_unknown(AVIOContext *pb, int bytes) } /** - * Calculate how many bytes are needed to represent a given number in EBML. + * Calculate how many bytes are needed to represent the length field + * of an EBML element whose payload has a given length. */ -static int ebml_num_size(uint64_t num) +static int ebml_length_size(uint64_t length) { int bytes = 0; -num++; +length++; do { bytes++; -} while (num >>= 7); +} while (length >>= 7); return bytes; } /** - * Write a number in EBML variable length format. + * Write a length as EBML variable length integer. * * @param bytes The number of bytes that need to be used to write the number. * If zero, the minimal number of bytes will be used. */ -static void put_ebml_num(AVIOContext *pb, uint64_t num, int bytes) +static void put_ebml_length(AVIOContext *pb, uint64_t length, int bytes) { -int i, needed_bytes = ebml_num_size(num); +int i, needed_bytes = ebml_length_size(length); // sizes larger than this are currently undefined in EBML -av_assert0(num < (1ULL << 56) - 1); +av_assert0(length < (1ULL << 56) - 1); if (bytes == 0) bytes = needed_bytes; @@ -221,9 +222,9 @@ static void put_ebml_num(AVIOContext *pb, uint64_t num, int bytes) // the bytes that we ought to use. av_assert0(bytes >= needed_bytes); -num |= 1ULL << bytes * 7; +length |= 1ULL << bytes * 7; for (i = bytes - 1; i >= 0; i--) -avio_w8(pb, (uint8_t)(num >> i * 8)); +avio_w8(pb, (uint8_t)(length >> i * 8)); } /** @@ -232,7 +233,7 @@ static void put_ebml_num(AVIOContext *pb, uint64_t num, int bytes) static void put_ebml_uid(AVIOContext *pb, uint32_t elementid, uint64_t uid) { put_ebml_id(pb, elementid); -put_ebml_num(pb, 8, 0); +put_ebml_length(pb, 8, 0); avio_wb64(pb, uid); } @@ -244,7 +245,7 @@ static void put_ebml_uint(AVIOContext *pb, uint32_t elementid, uint64_t val) bytes++; put_ebml_id(pb, elementid); -put_ebml_num(pb, bytes, 0); +put_ebml_length(pb, bytes, 0); for (i = bytes - 1; i >= 0; i--) avio_w8(pb, (uint8_t)(val >> i * 8)); } @@ -257,7 +258,7 @@ static void put_ebml_sint(AVIOContext *pb, uint32_t elementid, int64_t val) while (tmp>>=8) bytes++; put_ebml_id(pb, elementid); -put_ebml_num(pb, bytes, 0); +put_ebml_length(pb, bytes, 0); for (i = bytes - 1; i >= 0; i--) avio_w8(pb, (uint8_t)(val >> i * 8)); } @@ -265,7 +266,7 @@ static void put_ebml_sint(AVIOContext *pb, uint32_t elementid, int64_t val) static void put_ebml_float(AVIOContext *pb, uint32_t elementid, double val) { put_ebml_id(pb, elementid); -put_ebml_num(pb, 8, 0); +put_ebml_length(pb, 8, 0); avio_wb64(pb, av_double2int(val)); } @@ -273,7 +274,7 @@ static void put_ebml_binary(AVIOContext *pb, uint32_t elementid, const void *buf, int size) { put_ebml_id(pb, elementid); -put_ebml_num(pb, size, 0); +put_ebml_length(pb, size, 0); avio_write(pb, buf, size); } @@ -299,10 +300,10 @@ static void put_ebml_void(AVIOContext *pb, int size) // size if possible, 1 byte otherwise if (size < 10) { size -= 2; -put_ebml_num(pb, size, 0); +put_ebml_length(pb, size, 0); } else { size -= 9; -put_ebml_num(pb, size, 8); +put_ebml_length(pb, size, 8); } ffio_fill(pb, 0, size); } @@ -310,7 +311,7 @@ static void put_ebml_void(AVIOContext *pb, int size) static ebml_master start_ebml_master(AVIOContext *pb, uint32_t elementid, uint64_t expectedsize) { -int bytes = expectedsize ? ebml_num_size(expectedsize) : 8; +int bytes = expectedsize ? ebml_length_size(expectedsize) : 8; put_ebml_id(pb, elementid); put_ebml_size_unknown(pb, bytes); @@ -323,7 +324,7 @@ static void end_ebml_master(AVIOContext *pb, ebml_master master) if (avio_seek(pb, master.pos - master.
[FFmpeg-devel] [PATCH 4/5] avformat/matroskaenc: Refactor writing EBML lengths
This commit factors the ability to write ordinary EBML numbers out of the functions for writing EBML lengths. This is in preparation for future commits. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 36 ++-- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 7cea813dc0..92cd819312 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -190,19 +190,38 @@ static void put_ebml_size_unknown(AVIOContext *pb, int bytes) } /** - * Calculate how many bytes are needed to represent the length field - * of an EBML element whose payload has a given length. + * Returns how many bytes are needed to represent a number + * as EBML variable length integer. */ -static int ebml_length_size(uint64_t length) +static int ebml_num_size(uint64_t num) { int bytes = 0; -length++; do { bytes++; -} while (length >>= 7); +} while (num >>= 7); return bytes; } +/** + * Calculate how many bytes are needed to represent the length field + * of an EBML element whose payload has a given length. + */ +static int ebml_length_size(uint64_t length) +{ +return ebml_num_size(length + 1); +} + +/** + * Write a number as EBML variable length integer on `bytes` bytes. + * `bytes` is taken literally without checking. + */ +static void put_ebml_num(AVIOContext *pb, uint64_t num, int bytes) +{ +num |= 1ULL << bytes * 7; +for (int i = bytes - 1; i >= 0; i--) +avio_w8(pb, (uint8_t)(num >> i * 8)); +} + /** * Write a length as EBML variable length integer. * @@ -211,7 +230,7 @@ static int ebml_length_size(uint64_t length) */ static void put_ebml_length(AVIOContext *pb, uint64_t length, int bytes) { -int i, needed_bytes = ebml_length_size(length); +int needed_bytes = ebml_length_size(length); // sizes larger than this are currently undefined in EBML av_assert0(length < (1ULL << 56) - 1); @@ -221,10 +240,7 @@ static void put_ebml_length(AVIOContext *pb, uint64_t length, int bytes) // The bytes needed to write the given size must not exceed // the bytes that we ought to use. av_assert0(bytes >= needed_bytes); - -length |= 1ULL << bytes * 7; -for (i = bytes - 1; i >= 0; i--) -avio_w8(pb, (uint8_t)(length >> i * 8)); +put_ebml_num(pb, length, bytes); } /** -- 2.20.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] avcodec/ass: explicitly set ScaledBorderAndShadow
Patch attached. Currently ffmpeg does not set the 'ScaledBorderAndShadow' header for ASS subtitles. This currently leads to inconsistent behaviour depending on the renderer(see https://github.com/libass/libass/issues/287#issuecomment-338654103) Although libass will probably change the default to match *VSFilter soon, it is imho still a good idea to set this explicitly. Scaling the fontsize but not the bordersize with the viewport is inconsistent and probably confusing. Explicitly setting this header to "yes" is also the default in Aegisub (ASS authoring tool) since 2007. https://github.com/TypesettingTools/Aegisub/commit/5269a2e2a1e1dab7aaf4ddde4055c8637cd413d4 >From 51deab727958c5d64ae526f67063cdf141a01d46 Mon Sep 17 00:00:00 2001 From: Oneric Date: Fri, 17 Apr 2020 00:38:53 +0200 Subject: [PATCH] avcodec/ass: explicitly set ScaledBorderAndShadow --- libavcodec/ass.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/ass.c b/libavcodec/ass.c index 7c26e3fd6d..627741936a 100644 --- a/libavcodec/ass.c +++ b/libavcodec/ass.c @@ -40,6 +40,7 @@ int ff_ass_subtitle_header_full(AVCodecContext *avctx, "ScriptType: v4.00+\r\n" "PlayResX: %d\r\n" "PlayResY: %d\r\n" + "ScaledBorderAndShadow: yes\r\n" "\r\n" "[V4+ Styles]\r\n" -- 2.20.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 1/2] avformat/flacenc: Only update streaminfo if it has changed
Andreas Rheinhardt: > An AVStream's codecpar is supposed to be filled by the caller before > avformat_write_header(); if the CodecParameters change, the caller > should signal this via packet side data, but not touch the AVStream's > codecpar. > > The FLAC muxer checks for packet side data containing updated extradata, > yet if nothing has arrived by the time the trailer is written, the > already written extradata is overwritten by the very same extradata > again, unless the output is unseekable, in which case a warning that the > FLAC header can't be rewritten is emitted. > > This commit changes this by only trying to rewrite the extradata if a > new streaminfo arrived via packet side data. Only then is a warning > emitted in case the output is unseekable. > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/flacenc.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c > index 1aae0c97e0..42c1efec54 100644 > --- a/libavformat/flacenc.c > +++ b/libavformat/flacenc.c > @@ -331,8 +331,6 @@ static int flac_write_trailer(struct AVFormatContext *s) > AVIOContext *pb = s->pb; > int64_t file_size; > FlacMuxerContext *c = s->priv_data; > -uint8_t *streaminfo = c->streaminfo ? c->streaminfo : > - > s->streams[c->audio_stream_idx]->codecpar->extradata; > > if (c->waiting_pics) { > av_log(s, AV_LOG_WARNING, "No packets were sent for some of the " > @@ -340,14 +338,14 @@ static int flac_write_trailer(struct AVFormatContext *s) > flac_queue_flush(s); > } > > -if (!c->write_header || !streaminfo) > +if (!c->write_header || !c->streaminfo) > return 0; > > if (pb->seekable & AVIO_SEEKABLE_NORMAL) { > /* rewrite the STREAMINFO header block data */ > file_size = avio_tell(pb); > avio_seek(pb, 8, SEEK_SET); > -avio_write(pb, streaminfo, FLAC_STREAMINFO_SIZE); > +avio_write(pb, c->streaminfo, FLAC_STREAMINFO_SIZE); > avio_seek(pb, file_size, SEEK_SET); > } else { > av_log(s, AV_LOG_WARNING, "unable to rewrite FLAC header.\n"); > Will apply this tomorrow if there are no objections. - 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".
Re: [FFmpeg-devel] [PATCH 1/3] lavc/pgs_frame_merge_bsf: add bsf to merge PGS segments
On 4/16/2020 8:06 PM, John Stebbins wrote: > On Thu, 2020-04-16 at 15:59 -0700, John Stebbins wrote: >> On Thu, 2020-04-16 at 16:57 -0600, John Stebbins wrote: >>> Required to remux m2ts to mkv >>> --- >>> libavcodec/Makefile | 1 + >>> libavcodec/bitstream_filters.c | 1 + >>> libavcodec/pgs_frame_merge_bsf.c | 164 >>> +++ >>> 3 files changed, 166 insertions(+) >>> create mode 100644 libavcodec/pgs_frame_merge_bsf.c >>> >> >> Ugh! I forgot the version bump. Will get on that... > > A question about this. I have 2 bsf submitted for review. Should I > just do a separate patch that updates the minor version once. Or do > you require it to be bumped with each change separately? If they will both go together, then a single bump is enough. ___ 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] avcodec/ass: explicitly set ScaledBorderAndShadow
On Fri, Apr 17, 2020 at 02:15:17 +0200, Oneric wrote: > From 51deab727958c5d64ae526f67063cdf141a01d46 Mon Sep 17 00:00:00 2001 > From: Oneric > Date: Fri, 17 Apr 2020 00:38:53 +0200 > Subject: [PATCH] avcodec/ass: explicitly set ScaledBorderAndShadow Sorry for the inconvenience, I missed a warning about FATE only running on asubset of samples. Attached is the revised patch also updating affected FATE samples. Hope I didn't miss anything this time. >From 74d3f6bd0189b0f4922404fccbefe95e1f01093d Mon Sep 17 00:00:00 2001 From: Oneric Date: Fri, 17 Apr 2020 00:38:53 +0200 Subject: [PATCH] avcodec/ass: explicitly set ScaledBorderAndShadow --- libavcodec/ass.c | 1 + tests/ref/fate/sub-aqtitle | 1 + tests/ref/fate/sub-cc| 1 + tests/ref/fate/sub-cc-realtime | 1 + tests/ref/fate/sub-cc-scte20 | 1 + tests/ref/fate/sub-charenc | 1 + tests/ref/fate/sub-jacosub | 1 + tests/ref/fate/sub-microdvd | 1 + tests/ref/fate/sub-movtext | 1 + tests/ref/fate/sub-mpl2 | 1 + tests/ref/fate/sub-mpsub | 1 + tests/ref/fate/sub-mpsub-frames | 1 + tests/ref/fate/sub-pjs | 1 + tests/ref/fate/sub-realtext | 1 + tests/ref/fate/sub-sami | 1 + tests/ref/fate/sub-sami2 | 1 + tests/ref/fate/sub-scc | 1 + tests/ref/fate/sub-srt | 1 + tests/ref/fate/sub-srt-badsyntax | 1 + tests/ref/fate/sub-stl | 1 + tests/ref/fate/sub-subviewer | 1 + tests/ref/fate/sub-subviewer1| 1 + tests/ref/fate/sub-vplayer | 1 + tests/ref/fate/sub-webvtt| 1 + tests/ref/fate/sub-webvtt2 | 1 + 25 files changed, 25 insertions(+) diff --git a/libavcodec/ass.c b/libavcodec/ass.c index 7c26e3fd6d..627741936a 100644 --- a/libavcodec/ass.c +++ b/libavcodec/ass.c @@ -40,6 +40,7 @@ int ff_ass_subtitle_header_full(AVCodecContext *avctx, "ScriptType: v4.00+\r\n" "PlayResX: %d\r\n" "PlayResY: %d\r\n" + "ScaledBorderAndShadow: yes\r\n" "\r\n" "[V4+ Styles]\r\n" diff --git a/tests/ref/fate/sub-aqtitle b/tests/ref/fate/sub-aqtitle index 87253c9a2d..af0c06d7c2 100644 --- a/tests/ref/fate/sub-aqtitle +++ b/tests/ref/fate/sub-aqtitle @@ -3,6 +3,7 @@ ScriptType: v4.00+ PlayResX: 384 PlayResY: 288 +ScaledBorderAndShadow: yes [V4+ Styles] Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding diff --git a/tests/ref/fate/sub-cc b/tests/ref/fate/sub-cc index 4cc02d1d17..2b30a35be0 100644 --- a/tests/ref/fate/sub-cc +++ b/tests/ref/fate/sub-cc @@ -3,6 +3,7 @@ ScriptType: v4.00+ PlayResX: 384 PlayResY: 288 +ScaledBorderAndShadow: yes [V4+ Styles] Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding diff --git a/tests/ref/fate/sub-cc-realtime b/tests/ref/fate/sub-cc-realtime index be800a4d29..5a95ff5cb7 100644 --- a/tests/ref/fate/sub-cc-realtime +++ b/tests/ref/fate/sub-cc-realtime @@ -3,6 +3,7 @@ ScriptType: v4.00+ PlayResX: 384 PlayResY: 288 +ScaledBorderAndShadow: yes [V4+ Styles] Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding diff --git a/tests/ref/fate/sub-cc-scte20 b/tests/ref/fate/sub-cc-scte20 index 71fc92bfc5..be28084887 100644 --- a/tests/ref/fate/sub-cc-scte20 +++ b/tests/ref/fate/sub-cc-scte20 @@ -3,6 +3,7 @@ ScriptType: v4.00+ PlayResX: 384 PlayResY: 288 +ScaledBorderAndShadow: yes [V4+ Styles] Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding diff --git a/tests/ref/fate/sub-charenc b/tests/ref/fate/sub-charenc index a056cd1092..4efacb073d 100644 --- a/tests/ref/fate/sub-charenc +++ b/tests/ref/fate/sub-charenc @@ -3,6 +3,7 @@ ScriptType: v4.00+ PlayResX: 384 PlayResY: 288 +ScaledBorderAndShadow: yes [V4+ Styles] Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding diff --git a/tests/ref/fate/sub-jacosub b/tests/ref/fate/sub-jacosub index 5f282cdcf6..b574dda54d 100644 --- a/tests/ref/fate/sub-jacosub +++ b/tests/ref/fate/sub-jacosub @@ -3,6 +3,7 @@ ScriptType: v4.00+ PlayResX: 384 PlayResY: 288 +ScaledBorderAndShadow: yes [V4+ Styles] Format: Name
[FFmpeg-devel] [PATCH] avformat/webvttdec: Remove write-only variable
Signed-off-by: Andreas Rheinhardt --- libavformat/webvttdec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/webvttdec.c b/libavformat/webvttdec.c index 52579c5ed2..6c4d5f6736 100644 --- a/libavformat/webvttdec.c +++ b/libavformat/webvttdec.c @@ -60,7 +60,7 @@ static int64_t read_ts(const char *s) static int webvtt_read_header(AVFormatContext *s) { WebVTTContext *webvtt = s->priv_data; -AVBPrint header, cue; +AVBPrint cue; int res = 0; AVStream *st = avformat_new_stream(s, NULL); @@ -71,7 +71,6 @@ static int webvtt_read_header(AVFormatContext *s) st->codecpar->codec_id = AV_CODEC_ID_WEBVTT; st->disposition |= webvtt->kind; -av_bprint_init(&header, 0, AV_BPRINT_SIZE_UNLIMITED); av_bprint_init(&cue,0, AV_BPRINT_SIZE_UNLIMITED); for (;;) { @@ -166,7 +165,6 @@ static int webvtt_read_header(AVFormatContext *s) end: av_bprint_finalize(&cue,NULL); -av_bprint_finalize(&header, NULL); return res; } -- 2.20.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] avformat/r3d: Remove write-only array
Signed-off-by: Andreas Rheinhardt --- libavformat/r3d.c | 20 +++- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/libavformat/r3d.c b/libavformat/r3d.c index 224bcf780d..7aa0c5a2c3 100644 --- a/libavformat/r3d.c +++ b/libavformat/r3d.c @@ -27,7 +27,6 @@ typedef struct R3DContext { unsigned video_offsets_count; -unsigned *video_offsets; unsigned rdvo_offset; int audio_channels; @@ -118,17 +117,14 @@ static int r3d_read_rdvo(AVFormatContext *s, Atom *atom) int i; r3d->video_offsets_count = (atom->size - 8) / 4; -r3d->video_offsets = av_malloc(atom->size); -if (!r3d->video_offsets) -return AVERROR(ENOMEM); for (i = 0; i < r3d->video_offsets_count; i++) { -r3d->video_offsets[i] = avio_rb32(s->pb); -if (!r3d->video_offsets[i]) { +unsigned video_offset = avio_rb32(s->pb); +if (!video_offset) { r3d->video_offsets_count = i; break; } -av_log(s, AV_LOG_TRACE, "video offset %d: %#x\n", i, r3d->video_offsets[i]); +av_log(s, AV_LOG_TRACE, "video offset %d: %#x\n", i, video_offset); } if (st->avg_frame_rate.num) @@ -400,15 +396,6 @@ static int r3d_seek(AVFormatContext *s, int stream_index, int64_t sample_time, i return 0; } -static int r3d_close(AVFormatContext *s) -{ -R3DContext *r3d = s->priv_data; - -av_freep(&r3d->video_offsets); - -return 0; -} - AVInputFormat ff_r3d_demuxer = { .name = "r3d", .long_name = NULL_IF_CONFIG_SMALL("REDCODE R3D"), @@ -416,6 +403,5 @@ AVInputFormat ff_r3d_demuxer = { .read_probe = r3d_probe, .read_header= r3d_read_header, .read_packet= r3d_read_packet, -.read_close = r3d_close, .read_seek = r3d_seek, }; -- 2.20.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 1/4] avcodec: move avcodec_flush_buffers from decode.c to utils.c
On Thu, 16 Apr 2020 14:07:49 -0300 James Almer wrote: > On 4/16/2020 1:26 PM, Philip Langdale wrote: > > On Tue, 10 Mar 2020 16:33:41 -0300 > > James Almer wrote: > >> > >> I can withdraw this patch (And remove the relevant chunks from the > >> following two) if this function was effectively not meant for > >> encoders. Also maybe poke Timo regarding nvenc flushing, to see why > >> it is needed and if there's an alternative. > > > > I've pushed the change to formalise the encoder flush semantics, so > > this should be good to apply now. > > All encoders were ported, so yes, it could be pushed. But i wonder if > this should go in after 4.3 is tagged rather than now. I'd like this > to have some months of testing in master before making it into a > release. > > Unless 4.3 is months away, in which case i'll just push it now. Ok. You'll have a better sense of 4.3 timing than me, so I'll defer to your judgement. --phil ___ 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/3] avcodec/qpeg: remove an unnecessary intermediary AVFrame
Decoding can be handled directly in the output frame. Signed-off-by: James Almer --- libavcodec/qpeg.c | 22 +- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index d4195c5f0b..3fde6381f2 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -30,7 +30,7 @@ typedef struct QpegContext{ AVCodecContext *avctx; -AVFrame *pic, *ref; +AVFrame *ref; uint32_t pal[256]; GetByteContext buffer; } QpegContext; @@ -267,7 +267,7 @@ static int decode_frame(AVCodecContext *avctx, { uint8_t ctable[128]; QpegContext * const a = avctx->priv_data; -AVFrame * const p = a->pic; +AVFrame * const p = data; AVFrame * const ref = a->ref; uint8_t* outdata; int delta, ret; @@ -281,9 +281,6 @@ static int decode_frame(AVCodecContext *avctx, bytestream2_init(&a->buffer, avpkt->data, avpkt->size); -av_frame_unref(ref); -av_frame_move_ref(ref, p); - if ((ret = ff_get_buffer(avctx, p, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; outdata = p->data[0]; @@ -307,7 +304,8 @@ static int decode_frame(AVCodecContext *avctx, } memcpy(p->data[1], a->pal, AVPALETTE_SIZE); -if ((ret = av_frame_ref(data, p)) < 0) +av_frame_unref(ref); +if ((ret = av_frame_ref(ref, p)) < 0) return ret; *got_frame = 1; @@ -320,6 +318,8 @@ static void decode_flush(AVCodecContext *avctx){ int i, pal_size; const uint8_t *pal_src; +av_frame_unref(a->ref); + pal_size = FFMIN(1024U, avctx->extradata_size); pal_src = avctx->extradata + avctx->extradata_size - pal_size; @@ -331,7 +331,6 @@ static av_cold int decode_end(AVCodecContext *avctx) { QpegContext * const a = avctx->priv_data; -av_frame_free(&a->pic); av_frame_free(&a->ref); return 0; @@ -343,14 +342,11 @@ static av_cold int decode_init(AVCodecContext *avctx){ a->avctx = avctx; avctx->pix_fmt= AV_PIX_FMT_PAL8; -decode_flush(avctx); - -a->pic = av_frame_alloc(); a->ref = av_frame_alloc(); -if (!a->pic || !a->ref) { -decode_end(avctx); +if (!a->ref) return AVERROR(ENOMEM); -} + +decode_flush(avctx); return 0; } -- 2.26.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/3] avcodec/qpeg: export missing frame properties
Signed-off-by: James Almer --- libavcodec/qpeg.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index 3fde6381f2..22afd9fa81 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -270,7 +270,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame * const p = data; AVFrame * const ref = a->ref; uint8_t* outdata; -int delta, ret; +int delta, intra, ret; int pal_size; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size); @@ -289,7 +289,8 @@ static int decode_frame(AVCodecContext *avctx, bytestream2_skip(&a->buffer, 1); delta = bytestream2_get_byte(&a->buffer); -if(delta == 0x10) { +intra = delta == 0x10; +if (intra) { qpeg_decode_intra(a, outdata, p->linesize[0], avctx->width, avctx->height); } else { qpeg_decode_inter(a, outdata, p->linesize[0], avctx->width, avctx->height, delta, ctable, ref->data[0]); @@ -308,6 +309,9 @@ static int decode_frame(AVCodecContext *avctx, if ((ret = av_frame_ref(ref, p)) < 0) return ret; +p->key_frame = intra; +p->pict_type = intra ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; + *got_frame = 1; return avpkt->size; -- 2.26.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 3/3] avcodec/qpeg: mark the init function as thread-safe
Signed-off-by: James Almer --- libavcodec/qpeg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index 22afd9fa81..cc3bfda4aa 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -366,4 +366,5 @@ AVCodec ff_qpeg_decoder = { .decode = decode_frame, .flush = decode_flush, .capabilities = AV_CODEC_CAP_DR1, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; -- 2.26.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".
Re: [FFmpeg-devel] Query regarding codec parsers
On Fri, Apr 17, 2020 at 3:28 AM Carl Eugen Hoyos wrote: > > Am Do., 16. Apr. 2020 um 12:24 Uhr schrieb Gautam Ramakrishnan > : > > > > On Mon, Apr 13, 2020 at 11:00 PM Carl Eugen Hoyos > > wrote: > > > > > > Am Mo., 13. Apr. 2020 um 17:27 Uhr schrieb Gautam Ramakrishnan > > > : > > > > > > > > On Sun, Mar 29, 2020 at 8:34 PM Carl Eugen Hoyos > > > > wrote: > > > > > > > > > > Am So., 29. März 2020 um 16:45 Uhr schrieb Gautam Ramakrishnan > > > > > : > > > > > > > > > > > > > What exactly does a parser do and how is it different from a > > > > > > > > decoder? > > > > > > > > I am unable to understand the exact use case of a parser. > > > > > > > > > > > > > > Try the following: > > > > > > > $ cat 1.jpg 2.jpg | ffmpeg -i -f null - > > > > > > > (Is expected to decode two frames as can be seen in the console > > > > > > > output, > > > > > > > also works for example with png) > > > > > > > > > > > > > > $ cat 1.j2k 2.j2k | ffmpeg -i - -f null - > > > > > > > Will only decode one frame because there is no parser to split the > > > > > > > input. > > > > > > > > > > > > > So does it basically try to find the SOC marker and EOC markers and > > > > > > split the streams into frames? > > > > > > > > > > Basically, yes. > > > > > Look at existing parsers in libavcodec/*parser* (or git grep > > > > > AVCodecParser), > > > > > especially the jpeg parser. > > > > > > > Would working on a parser be a good idea now? > > > > > > Either that or you look at ticket #4681 (no idea how difficult this is). > > > I thought I'll start with the parser first. > > I went through the BMP and JPEG parsers and needed some more clarification. > > So, each frame could either be a JPEG2000 file or a JPEG2000 codestream. > > The parse function must be able to find the end of the file/codestream > > and return the location of it. Is my understanding correct? > > It is supposed to find the end of the first and the beginning of the > second frame in above example, see what the jpg parser does. > > Carl Eugen > ___ > 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". Hi, My issue was I guess particular to JPEG2000. Should we consider each file as a frame, or could even a codestream constitute a frame? -- - Gautam | ___ 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 v1] avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet
On Thu, Apr 16, 2020 at 05:16:35PM +0200, Nicolas George wrote: > Sorry, forgot to reply to that. > > Limin Wang (12020-04-04): > > the md5 framecrc is generated by libavformat/tests/movenc.c, I have no > > clue how the movenc testing work and how to get the real input to check why > > the frame isn't bitexact as I haven't see any subtitle track. > > Well, check: re-run the test manually, change it to have an actual > output, examine the file. The possibilities are many. > > But tests are there for a reason. If a patch changes the output of > tests, then we cannot accept it unless somebody did examine the changes > very carefully and confirmed they are for the best. Ideally, an > explanation of the changes goes in the commit message. Thanks, it's difficult to examine how it works for the tests/movenc.c without any documenets. As I can't give good explanation for the md5 changed so I had to stop to update the patch. > > Regards, > > -- > Nicolas George > ___ > 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". -- Thanks, Limin Wang ___ 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] libavcodec/libx264: fix reference frame computation based on level
Hi, > From: ffmpeg-devel On Behalf Of > josh.brews...@protonmail.com > Sent: Friday, April 17, 2020 07:05 > To: ffmpeg-devel@ffmpeg.org > Subject: [FFmpeg-devel] [PATCH] libavcodec/libx264: fix reference frame > computation based on level > > Hell, can someone please review this patch? It fixes a wrong reference frame > computation problem when using parameters such as "-level 31" instead of > "-level 3.1". > > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c > index a08fe0ce76..1149f2d668 100644 > --- a/libavcodec/libx264.c > +++ b/libavcodec/libx264.c > @@ -701,11 +701,14 @@ FF_ENABLE_DEPRECATION_WARNINGS > > if (!strcmp(x4->level, "1b")) { > level_id = 9; > -} else if (strlen(x4->level) <= 3){ > +} else if (av_strtod(x4->level, NULL) < 7){ > level_id = av_strtod(x4->level, &tail) * 10 + 0.5; > if (*tail) > level_id = -1; > } > +else { Wrong coding style for "else", should be "} else {" > +level_id = av_strtod(x4->level, NULL); > +} > if (level_id <= 0) > av_log(avctx, AV_LOG_WARNING, "Failed to parse level\n"); This part of code of parsing level_id seems redundant, since PARSE_X264_OPT("level", level) has been called and did the same thing inside libx264, which converts x4->level to x4->params.i_level_idc correctly (equals 31), regardless of "-level 3.1 or level 31". Hence it would be better to use x4->params.i_level_idc directly. - Linjie ___ 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".