Re: [FFmpeg-devel] [PATCH v2] doc/encoders: Add all options for JPEG2000 encoder
Will apply. On 10-08-2020 10:14 pm, gautamr...@gmail.com wrote: From: Gautam Ramakrishnan This patch updates the documentation by adding all options for JPEG2000 encoder. --- doc/encoders.texi | 36 +++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index de0472e225..426baa8033 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1365,10 +1365,44 @@ can be selected with @code{-pred 1}. @subsection Options @table @option -@item format +@item format @var{integer} Can be set to either @code{j2k} or @code{jp2} (the default) that makes it possible to store non-rgb pix_fmts. +@item tile_width @var{integer} +Sets tile width. Default is 256. + +@item tile_height @var{integer} +Sets tile height. Default is 256. + +@item pred @var{integer} +Allows setting the DWT type +@table @option +@item dwt97int (Lossy) +@item dwt53 (Lossless) +@end table +Default is @code{dwt97int} + +@item sop @var{boolean} +Setting this to 1 will make the encoder to use SOP marker at the +start of every packet. Set to 0 by default. + +@item eph @var{boolean} +Setting this to 1 will make the encoder to use the EPH flag at the +end of every packet header. Set to 0 by default. + +@item prog @var{integer} +Sets the progression order to be used by the encoder. +Possible values are: +@table @option +@item lrcp +@item rlcp +@item rpcl +@item pcrl +@item cprl +@end table +Set to @code{lrcp} by default. + @end table @section librav1e ___ 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 v3] fate: av1dec, add test clip for low overhead obu
v3 changelist: add missed tests/ref/fate/av1-low-overhead-demux --- tests/fate/demux.mak | 3 +++ tests/ref/fate/av1-low-overhead-demux | 16 2 files changed, 19 insertions(+) create mode 100644 tests/ref/fate/av1-low-overhead-demux diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak index 9f3a6be276..763452a533 100644 --- a/tests/fate/demux.mak +++ b/tests/fate/demux.mak @@ -13,6 +13,9 @@ fate-aea-demux: CMD = crc -i $(TARGET_SAMPLES)/aea/chirp.aea -c:a copy FATE_SAMPLES_DEMUX-$(CONFIG_AV1_DEMUXER) += fate-av1-annexb-demux fate-av1-annexb-demux: CMD = framecrc -i $(TARGET_SAMPLES)/av1/annexb.obu -c:v copy +FATE_SAMPLES_DEMUX-$(CONFIG_AV1_DEMUXER) += fate-av1-low-overhead-demux +fate-av1-low-overhead-demux: CMD = framecrc -i $(TARGET_SAMPLES)/av1/low_overhead.obu -c:v copy + FATE_SAMPLES_DEMUX-$(CONFIG_AST_DEMUXER) += fate-ast fate-ast: CMD = crc -i $(TARGET_SAMPLES)/ast/demo11_02_partial.ast -c copy diff --git a/tests/ref/fate/av1-low-overhead-demux b/tests/ref/fate/av1-low-overhead-demux new file mode 100644 index 00..62635bba89 --- /dev/null +++ b/tests/ref/fate/av1-low-overhead-demux @@ -0,0 +1,16 @@ +#extradata 0: 13, 0x12ed043e +#tb 0: 1/120 +#media_type 0: video +#codec_id 0: av1 +#dimensions 0: 176x144 +#sar 0: 0/1 +0, 0, 0,48000, 9106, 0x09d4b5fe +0, 48000, 48000,48000,10218, 0xafe5dad1, F=0x0 +0, 96000, 96000,48000,5, 0x016200e5, F=0x0 +0, 144000, 144000,48000, 697, 0x96cb5a52, F=0x0 +0, 192000, 192000,48000,5, 0x015200d5, F=0x0 +0, 24, 24,48000, 2000, 0x34b2ea8e, F=0x0 +0, 288000, 288000,48000,5, 0x01920115, F=0x0 +0, 336000, 336000,48000, 836, 0x8a1b9294, F=0x0 +0, 384000, 384000,48000, 761, 0x407a72d4, F=0x0 +0, 432000, 432000,48000, 27, 0x4bde0706, F=0x0 -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v6] avdevice/xcbgrab: check return values of xcb query functions
On Sat, 08. Aug 09:55, Andriy Gelman wrote: > On Wed, 05. Aug 14:37, Moritz Barsnick wrote: > > On Mon, Jul 20, 2020 at 09:18:55 +0200, Alexander Strasser wrote: > > > On 2020-07-19 19:47 -0400, Andriy Gelman wrote: > > > > > > This check seems dead code. Looking at xcb sources, cursor is just > > > > > > an offset in > > > > > > memory from ci so I don't think it can be null here. > > > > > > But anyway, this part of the patch doesn't really have anything to do > > > > with > > > > ticket #7312, and should be in a separate patch. > > > > > > Yes, it's definitely something that was changed in this patch > > > at all. So it's better not to touch it in this patch. > > > > Okay, so I "fixed" dead code. You guys can remove the dead code > > yourselves then, if you like. ;-) > > > > New patch for the original issue attached, not touching the dead code. > > > > Thanks, > > Moritz > > > From e44b7f03354add2272a2739e04aafb38b7ce027f Mon Sep 17 00:00:00 2001 > > From: Moritz Barsnick > > Date: Wed, 5 Aug 2020 14:06:53 +0200 > > Subject: [PATCH] avdevice/xcbgrab: check return values of xcb query > > functions > > > > Fixes #7312, segmentation fault on close of X11 server > > > > xcb_query_pointer_reply() and xcb_get_geometry_reply() can return NULL > > if e.g. the X server closes or the connection is lost. This needs to > > be checked in order to cleanly exit, because the returned pointers are > > dereferenced later. > > > > Signed-off-by: Moritz Barsnick > > --- > > libavdevice/xcbgrab.c | 9 + > > 1 file changed, 9 insertions(+) > > > > diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c > > index 6f6b2dbf15..8ef2a30d02 100644 > > --- a/libavdevice/xcbgrab.c > > +++ b/libavdevice/xcbgrab.c > > @@ -425,7 +425,16 @@ static int xcbgrab_read_packet(AVFormatContext *s, > > AVPacket *pkt) > > pc = xcb_query_pointer(c->conn, c->screen->root); > > gc = xcb_get_geometry(c->conn, c->screen->root); > > p = xcb_query_pointer_reply(c->conn, pc, NULL); > > +if (!p) { > > +av_log(s, AV_LOG_ERROR, "Failed to query xcb pointer\n"); > > +return AVERROR_EXTERNAL; > > +} > > geo = xcb_get_geometry_reply(c->conn, gc, NULL); > > +if (!geo) { > > +av_log(s, AV_LOG_ERROR, "Failed to get xcb geometry\n"); > > +free(p); > > +return AVERROR_EXTERNAL; > > +} > > } > > > > if (c->follow_mouse && p->same_screen) > > -- > > 2.26.2 > > > > lgtm > Will apply this tomorrow if no one objects. -- Andriy ___ 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 2/3] avormat/av1dec: add low-overhead bitstream format
On 8/13/2020 11:45 PM, Xu, Guangxin wrote: >> Should be good with those trivial changes, so i can implement them and push >> if >> you don't want to send another revision. >> > Great! thanks for you kindly help on this and previous review. > Really appreciate it. Applied those changes, added missing version bump, Makefile and changelog entries, and pushed. ___ 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 2/3] avormat/av1dec: add low-overhead bitstream format
Hi Martin, Thanks for your detailed explaining. It's a good education to me. thanks > -Original Message- > From: ffmpeg-devel On Behalf Of Martin > Storsjö > Sent: Friday, August 14, 2020 3:25 AM > To: FFmpeg development discussions and patches > Subject: Re: [FFmpeg-devel] [PATCH v3 2/3] avormat/av1dec: add low- > overhead bitstream format > > On Thu, 13 Aug 2020, James Almer wrote: > > > On 8/13/2020 3:51 AM, Xu Guangxin wrote: > > >> + > >> +ret = obu_prefetch(s, header, MAX_OBU_HEADER_SIZE); > >> +if (!ret) > >> +return AVERROR(EOF); > > > > We use AVERROR_EOF rather than AVERROR(EOF) (Afair, it was done > > because EOF is not portable, but don't quote me on it). > > Actually, it's a more severe thing than that. > > AVERROR() is used for mapping an errno style error code, EINVAL etc, which can > be either positive or negative numbers depending on platforms, to the AVERROR > range (which is negative numbers). > > So AVERROR() actually is shorthand for ERRNO_CODE_TO_AVERROR(). On > platforms where errno codes are positive (most common modern platforms > except BeOS/Haiku, iirc), it's essentially defined as (-(x)). > > Now EOF isn't an errno error code, and is defined to be a negative value > (often - > 1). So if you do AVERROR(EOF) on a system where errno codes are positive, > AVERROR(EOF) evalues to +1, which most caller would identify as not an error > at all. > > TL;DR: AVERROR(EOF) is never correct. > > // Martin > > ___ > 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 2/3] avormat/av1dec: add low-overhead bitstream format
> Should be good with those trivial changes, so i can implement them and push if > you don't want to send another revision. > Great! thanks for you kindly help on this and previous review. Really appreciate it. > -Original Message- > From: ffmpeg-devel On Behalf Of James > Almer > Sent: Friday, August 14, 2020 3:11 AM > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH v3 2/3] avormat/av1dec: add low- > overhead bitstream format > > On 8/13/2020 3:51 AM, Xu Guangxin wrote: > > Hi James, > > thanks for your feedback, please help review it again. > > > > Changelist for v3: > > use av_fifo_* instead of homebrewed fifo operations > > obu_probe(), add padding obu to alllow list > > read_header(), use "const AVRational* framerate" instead of "AVRational > framerate" > > > > > > > > It's defined in Section 5.2, used by netflix. > > see http://download.opencontent.netflix.com/?prefix=AV1/Chimera/ > > --- > > configure| 1 + > > libavformat/allformats.c | 1 + > > libavformat/av1dec.c | 263 +++-- > -- > > 3 files changed, 242 insertions(+), 23 deletions(-) > > > > diff --git a/configure b/configure > > index 8de1afcb99..d4a1fea9ce 100755 > > --- a/configure > > +++ b/configure > > @@ -3331,6 +3331,7 @@ mxf_d10_muxer_select="mxf_muxer" > > mxf_opatom_muxer_select="mxf_muxer" > > nut_muxer_select="riffenc" > > nuv_demuxer_select="riffdec" > > +obu_demuxer_select="av1_frame_merge_bsf av1_parser" > > oga_muxer_select="ogg_muxer" > > ogg_demuxer_select="dirac_parse" > > ogv_muxer_select="ogg_muxer" > > diff --git a/libavformat/allformats.c b/libavformat/allformats.c index > > b7e59ae170..0aa9dd7198 100644 > > --- a/libavformat/allformats.c > > +++ b/libavformat/allformats.c > > @@ -293,6 +293,7 @@ extern AVOutputFormat ff_null_muxer; extern > > AVInputFormat ff_nut_demuxer; extern AVOutputFormat ff_nut_muxer; > > extern AVInputFormat ff_nuv_demuxer; > > +extern AVInputFormat ff_obu_demuxer; > > extern AVOutputFormat ff_oga_muxer; > > extern AVInputFormat ff_ogg_demuxer; extern AVOutputFormat > > ff_ogg_muxer; diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c > > index 1be2fac1c1..62cf5c31ea 100644 > > --- a/libavformat/av1dec.c > > +++ b/libavformat/av1dec.c > > @@ -22,6 +22,7 @@ > > #include "config.h" > > > > #include "libavutil/common.h" > > +#include "libavutil/fifo.h" > > #include "libavutil/opt.h" > > #include "libavcodec/av1_parse.h" > > #include "avformat.h" > > @@ -70,6 +71,25 @@ static int read_obu(const uint8_t *buf, int size, int64_t > *obu_size, int *type) > > return 0; > > } > > > > +//return < 0 if we need more data > > +static int get_score(int type, int *seq) { > > +switch (type) { > > +case AV1_OBU_SEQUENCE_HEADER: > > +*seq = 1; > > +return -1; > > +case AV1_OBU_FRAME: > > +case AV1_OBU_FRAME_HEADER: > > +return *seq ? AVPROBE_SCORE_EXTENSION + 1 : 0; > > +case AV1_OBU_METADATA: > > +case AV1_OBU_PADDING: > > +return -1; > > +default: > > +break; > > +} > > +return 0; > > +} > > + > > static int annexb_probe(const AVProbeData *p) { > > AVIOContext pb; > > @@ -123,19 +143,9 @@ static int annexb_probe(const AVProbeData *p) > > return 0; > > cnt += obu_unit_size; > > > > -switch (type) { > > -case AV1_OBU_SEQUENCE_HEADER: > > -seq = 1; > > -break; > > -case AV1_OBU_FRAME: > > -case AV1_OBU_FRAME_HEADER: > > -return seq ? AVPROBE_SCORE_EXTENSION + 1 : 0; > > -case AV1_OBU_TILE_GROUP: > > -case AV1_OBU_TEMPORAL_DELIMITER: > > -return 0; > > -default: > > -break; > > -} > > +ret = get_score(type, &seq); > > +if (ret >= 0) > > +return ret; > > > > temporal_unit_size -= obu_unit_size + ret; > > frame_unit_size -= obu_unit_size + ret; @@ -144,15 +154,14 @@ > > static int annexb_probe(const AVProbeData *p) > > return 0; > > } > > > > -static int annexb_read_header(AVFormatContext *s) > > +static int read_header(AVFormatContext *s, const AVRational > > +*framerate, AVBSFContext **bsf, void *logctx) > > { > > -AnnexBContext *c = s->priv_data; > > const AVBitStreamFilter *filter = > av_bsf_get_by_name("av1_frame_merge"); > > AVStream *st; > > int ret; > > > > if (!filter) { > > -av_log(c, AV_LOG_ERROR, "av1_frame_merge bitstream filter " > > +av_log(logctx, AV_LOG_ERROR, "av1_frame_merge bitstream filter " > > "not found. This is a bug, please report it.\n"); > > return AVERROR_BUG; > > } > > @@ -165,25 +174,32 @@ static int annexb_read_header(AVFormatContext > *s) > > st->codecpar->codec_id = AV_CODEC_ID_AV1; > > st->need_parsing = AVSTREAM_PARSE_HEADERS; > > > > -st->internal->avctx->framerate = c->framerate; > > +st->internal->
[FFmpeg-devel] [PATCH V2] dnn_backend_openvino.c: parse options in openvino backend
Signed-off-by: Guo, Yejun --- libavfilter/dnn/dnn_backend_openvino.c | 37 +- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index d343bf2..478e151 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -26,8 +26,14 @@ #include "dnn_backend_openvino.h" #include "libavformat/avio.h" #include "libavutil/avassert.h" +#include "libavutil/avstring.h" #include +typedef struct OVOptions{ +uint32_t batch_size; +uint32_t req_num; +} OVOptions; + typedef struct OVModel{ ie_core_t *core; ie_network_t *network; @@ -36,6 +42,7 @@ typedef struct OVModel{ ie_blob_t *input_blob; ie_blob_t **output_blobs; uint32_t nb_output; +OVOptions options; } OVModel; static DNNDataType precision_to_datatype(precision_e precision) @@ -50,6 +57,32 @@ static DNNDataType precision_to_datatype(precision_e precision) } } +static int parse_options_ov(OVOptions *to, const char *from) +{ +AVDictionary *dict = NULL; +AVDictionaryEntry *opt = NULL; +int err = av_dict_parse_string(&dict, from, "=", "&", 0); +if (err < 0) { +av_dict_free(&dict); +return err; +} + +opt = av_dict_get(dict, "nireq", opt, AV_DICT_MATCH_CASE); +if (opt != NULL) +to->req_num = atoi(opt->value); +else +to->req_num = 1; + +opt = av_dict_get(dict, "batch", opt, AV_DICT_MATCH_CASE); +if (opt != NULL) +to->batch_size = atoi(opt->value); +else +to->batch_size = 1; + +av_dict_free(&dict); +return 0; +} + static DNNReturnType get_input_ov(void *model, DNNData *input, const char *input_name) { OVModel *ov_model = (OVModel *)model; @@ -171,6 +204,9 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options) if (!ov_model) goto err; +model->options = options; +parse_options_ov(&ov_model->options, model->options); + status = ie_core_create("", &ov_model->core); if (status != OK) goto err; @@ -186,7 +222,6 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options) model->model = (void *)ov_model; model->set_input_output = &set_input_output_ov; model->get_input = &get_input_ov; -model->options = options; return model; -- 2.7.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] [PATCH v2 3/3] FATE: add fate test for minterpolate filter
On Thu, Aug 13, 2020 at 10:55:07PM +0200, Nicolas George wrote: > Hi. Replying to a very old patch already applied. > > lance.lmw...@gmail.com (12019-09-14): > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > tests/fate/filter-video.mak | 4 > > tests/ref/fate/filter-minterpolate-down | 6 ++ > > tests/ref/fate/filter-minterpolate-up | 15 +++ > > 3 files changed, 25 insertions(+) > > create mode 100644 tests/ref/fate/filter-minterpolate-down > > create mode 100644 tests/ref/fate/filter-minterpolate-up > > > > diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak > > index 0c6ee72..ab7b624 100644 > > --- a/tests/fate/filter-video.mak > > +++ b/tests/fate/filter-video.mak > > @@ -122,6 +122,10 @@ FATE_FILTER-$(call ALLYES, FRAMERATE_FILTER > > TESTSRC2_FILTER FORMAT_FILTER) += fa > > fate-filter-framerate-12bit-up: CMD = framecrc -lavfi > > testsrc2=r=50:d=1,format=pix_fmts=yuv422p12le,framerate=fps=60 -t 1 > > -pix_fmt yuv422p12le > > fate-filter-framerate-12bit-down: CMD = framecrc -lavfi > > testsrc2=r=60:d=1,format=pix_fmts=yuv422p12le,framerate=fps=50 -t 1 > > -pix_fmt yuv422p12le > > > > +FATE_FILTER-$(call ALLYES, MINTERPOLATE_FILTER TESTSRC2_FILTER) += > > fate-filter-minterpolate-up fate-filter-minterpolate-down > > > +fate-filter-minterpolate-up: CMD = framecrc -lavfi > > testsrc2=r=2:d=10,framerate=fps=10 -t 1 > > +fate-filter-minterpolate-down: CMD = framecrc -lavfi > > testsrc2=r=2:d=10,framerate=fps=1 -t 1 > > The patch says minterpolate, but the test is an exact copy of the > framerate test, and still testing framerate. Please fix. sorry, will fix it. > > Regards, > > -- > Nicolas George -- 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".
[FFmpeg-devel] [PATCH] FATE: fix copy & paste for minterpolate test
From: Limin Wang Reported-by: Nicolas George Signed-off-by: Limin Wang --- tests/fate/filter-video.mak | 4 ++-- tests/ref/fate/filter-minterpolate-up | 16 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 18fe4f7..d7f489e 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -123,8 +123,8 @@ fate-filter-framerate-12bit-up: CMD = framecrc -lavfi testsrc2=r=50:d=1,format=p fate-filter-framerate-12bit-down: CMD = framecrc -lavfi testsrc2=r=60:d=1,format=pix_fmts=yuv422p12le,framerate=fps=50 -t 1 -pix_fmt yuv422p12le FATE_FILTER-$(call ALLYES, MINTERPOLATE_FILTER TESTSRC2_FILTER) += fate-filter-minterpolate-up fate-filter-minterpolate-down -fate-filter-minterpolate-up: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=10 -t 1 -fate-filter-minterpolate-down: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=1 -t 1 +fate-filter-minterpolate-up: CMD = framecrc -lavfi testsrc2=r=2:d=10,minterpolate=fps=10 -t 1 +fate-filter-minterpolate-down: CMD = framecrc -lavfi testsrc2=r=2:d=10,minterpolate=fps=1 -t 1 FATE_FILTER_VSYNTH-$(CONFIG_BOXBLUR_FILTER) += fate-filter-boxblur fate-filter-boxblur: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf boxblur=2:1 diff --git a/tests/ref/fate/filter-minterpolate-up b/tests/ref/fate/filter-minterpolate-up index a276bf6..1862990 100644 --- a/tests/ref/fate/filter-minterpolate-up +++ b/tests/ref/fate/filter-minterpolate-up @@ -4,12 +4,12 @@ #dimensions 0: 320x240 #sar 0: 1/1 0, 0, 0,1, 115200, 0x3744b3ed -0, 1, 1,1, 115200, 0xec1fdfa0 -0, 2, 2,1, 115200, 0xa17f0d74 -0, 3, 3,1, 115200, 0xd72532a9 -0, 4, 4,1, 115200, 0x032e60f8 +0, 1, 1,1, 115200, 0xf54dba9a +0, 2, 2,1, 115200, 0xd0b30f49 +0, 3, 3,1, 115200, 0x61720dac +0, 4, 4,1, 115200, 0xb93a0baa 0, 5, 5,1, 115200, 0x6e318ba0 -0, 6, 6,1, 115200, 0x76018292 -0, 7, 7,1, 115200, 0x89e27599 -0, 8, 8,1, 115200, 0x68536eac -0, 9, 9,1, 115200, 0xc3ac62a8 +0, 6, 6,1, 115200, 0xbce5157a +0, 7, 7,1, 115200, 0xe16418a3 +0, 8, 8,1, 115200, 0xdd91079c +0, 9, 9,1, 115200, 0xdf69f73c -- 1.8.3.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 v4] avformat/libsrt: Close listen fd in listener mode
In listener mode the first fd is not closed when libsrt_close() is called because it is overwritten by the new accept fd. Added the listen_fd to the context to properly close it when libsrt_close() is called. Fixes trac ticket #8372 Signed-off-by: Nicolas Sugino --- libavformat/libsrt.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 4719ce0d4b..4025b24976 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -53,6 +53,7 @@ enum SRTMode { typedef struct SRTContext { const AVClass *class; int fd; +int listen_fd; int eid; int64_t rw_timeout; int64_t listen_timeout; @@ -362,7 +363,7 @@ static int libsrt_set_options_pre(URLContext *h, int fd) static int libsrt_setup(URLContext *h, const char *uri, int flags) { struct addrinfo hints = { 0 }, *ai, *cur_ai; -int port, fd = -1; +int port, fd = -1, listen_fd = -1; SRTContext *s = h->priv_data; const char *p; char buf[256]; @@ -439,6 +440,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) // multi-client if ((ret = libsrt_listen(s->eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, s->listen_timeout)) < 0) goto fail1; +listen_fd = fd; fd = ret; } else { if (s->mode == SRT_MODE_RENDEZVOUS) { @@ -471,6 +473,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) h->is_streamed = 1; s->fd = fd; +s->listen_fd = listen_fd; freeaddrinfo(ai); return 0; @@ -481,12 +484,16 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) cur_ai = cur_ai->ai_next; if (fd >= 0) srt_close(fd); +if (listen_fd >= 0) +srt_close(listen_fd); ret = 0; goto restart; } fail1: if (fd >= 0) srt_close(fd); +if (listen_fd >= 0) +srt_close(listen_fd); freeaddrinfo(ai); return ret; } @@ -676,6 +683,9 @@ static int libsrt_close(URLContext *h) srt_close(s->fd); +if (s->listen_fd >= 0) +srt_close(s->listen_fd); + srt_epoll_release(s->eid); srt_cleanup(); -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] dnn: fix build issue for tensorflow backend
> -Original Message- > From: ffmpeg-devel On Behalf Of Guo, > Yejun > Sent: 2020年8月13日 22:47 > To: ffmpeg-devel@ffmpeg.org > Subject: [FFmpeg-devel] [PATCH 1/2] dnn: fix build issue for tensorflow > backend > > Signed-off-by: Guo, Yejun > --- > libavfilter/dnn/dnn_backend_tf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavfilter/dnn/dnn_backend_tf.c > b/libavfilter/dnn/dnn_backend_tf.c > index 86da991..9099d2b 100644 > --- a/libavfilter/dnn/dnn_backend_tf.c > +++ b/libavfilter/dnn/dnn_backend_tf.c > @@ -490,7 +490,7 @@ static DNNReturnType load_native_model(TFModel > *tf_model, const char *model_file > DNNModel *native_model = NULL; > ConvolutionalNetwork *conv_network; > > -native_model = ff_dnn_load_model_native(model_filename); > +native_model = ff_dnn_load_model_native(model_filename, NULL); > if (!native_model){ > return DNN_ERROR; > } > -- I'll first push this patch now. For the 2/2 patch in this patch set, I'll send out v2 to add option's default setting. ___ 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] libavcodec/vp9: export motion vector to side data in vp9
--- libavcodec/vp9.c | 102 ++ libavcodec/vp9block.c | 2 + libavcodec/vp9dec.h | 3 ++ 3 files changed, 107 insertions(+) diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index fd0bab14a2..5289fb3099 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -35,6 +35,7 @@ #include "libavutil/avassert.h" #include "libavutil/pixdesc.h" #include "libavutil/video_enc_params.h" +#include "libavutil/motion_vector.h" #define VP9_SYNCCODE 0x498342 @@ -99,6 +100,7 @@ static void vp9_tile_data_free(VP9TileData *td) av_freep(&td->b_base); av_freep(&td->block_base); av_freep(&td->block_structure); +av_freep(&td->block_motion_vectors); } static void vp9_frame_unref(AVCodecContext *avctx, VP9Frame *f) @@ -334,6 +336,11 @@ static int update_block_buffers(AVCodecContext *avctx) if (!td->block_structure) return AVERROR(ENOMEM); } +if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS) { +td->block_motion_vectors = av_malloc_array(s->cols * s->rows, sizeof(*td->block_motion_vectors)); +if (!td->block_motion_vectors) +return AVERROR(ENOMEM); +} } else { for (i = 1; i < s->active_tile_cols; i++) vp9_tile_data_free(&s->td[i]); @@ -355,6 +362,11 @@ static int update_block_buffers(AVCodecContext *avctx) if (!s->td[i].block_structure) return AVERROR(ENOMEM); } +if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS) { +td->block_motion_vectors = av_malloc_array(s->cols * s->rows, sizeof(*td->block_motion_vectors)); +if (!td->block_motion_vectors) +return AVERROR(ENOMEM); +} } } s->block_alloc_using_2pass = s->s.frames[CUR_FRAME].uses_2pass; @@ -1548,6 +1560,92 @@ static int vp9_export_enc_params(VP9Context *s, VP9Frame *frame) return 0; } +static int add_mv(AVMotionVector *mb, int w, int h, + int dst_x, int dst_y, + int motion_x, int motion_y, int motion_scale, + int direction) +{ +mb->w = w; +mb->h = h; +mb->motion_x = motion_x; +mb->motion_y = motion_y; +mb->motion_scale = motion_scale; +mb->dst_x = dst_x; +mb->dst_y = dst_y; +mb->src_x = dst_x + motion_x / motion_scale; +mb->src_y = dst_y + motion_y / motion_scale; +mb->source = direction ? 1 : -1; +mb->flags = 0; // XXX: does mb_type contain extra information that could be exported here? +return 1; +} + +static int vp9_export_mv(AVCodecContext *avctx, AVFrame *frame) +{ +VP9Context *s = avctx->priv_data; +AVMotionVector *mvs = av_malloc_array(frame->width * frame->height, 2 * 4 * sizeof(AVMotionVector)); +if (!mvs) +return AVERROR(ENOMEM); + +unsigned int tile, nb_blocks = 0; +for (tile = 0; tile < s->active_tile_cols; tile++) { +nb_blocks += s->td[tile].nb_block_structure; +} + +if (nb_blocks) { +unsigned int block = 0; +unsigned int tile, block_tile; + +for (tile = 0; tile < s->active_tile_cols; tile++) { +VP9TileData *td = &s->td[tile]; + +for (block_tile = 0; block_tile < td->nb_block_structure; block_tile++) { +unsigned int row = td->block_structure[block_tile].row; +unsigned int col = td->block_structure[block_tile].col; +int w = 1 << (3 + td->block_structure[block_tile].block_size_idx_x); +int h = 1 << (3 + td->block_structure[block_tile].block_size_idx_y); +int src_x = col * 8; +int src_y = row * 8; +int motion_x, motion_y, dst_x, dst_y; +if (w >= 8 && h >= 8) { +for (int ref = 0; ref < 2; ref++) { +motion_x = td->block_motion_vectors[block_tile].mv[0][ref].x; +motion_y = td->block_motion_vectors[block_tile].mv[0][ref].y; +dst_x = src_x + w / 2; +dst_y = src_y + w / 2; +add_mv(mvs + block, w, h, dst_x, dst_y, motion_x, motion_y, 16, ref); +block++; +} +} else { +for (int b_idx = 0; b_idx < 4; b_idx++) { +for (int ref = 0; ref < 2; ref++) { +motion_x = td->block_motion_vectors[block_tile].mv[b_idx][ref].x; +motion_y = td->block_motion_vectors[block_tile].mv[b_idx][ref].y; +dst_x = src_x + (b_idx % 2 + 1) * w / 4; +dst_y = src_y + (b_idx / 2 + 1) * w / 4; +add_mv(mvs + block, w, h, dst_x, dst_y, motion_x, motion_y, 16, ref); +block++; +} +} +
[FFmpeg-devel] [PATCH] fftools/ffprobe: export venc params side data
Printing venc params in ffprobe makes it easier for program to parse the data via ffprobe json output --- fftools/ffprobe.c | 33 + 1 file changed, 33 insertions(+) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 5515e1b31b..b20bddc897 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -47,6 +47,7 @@ #include "libavutil/parseutils.h" #include "libavutil/timecode.h" #include "libavutil/timestamp.h" +#include "libavutil/video_enc_params.h" #include "libavdevice/avdevice.h" #include "libswscale/swscale.h" #include "libswresample/swresample.h" @@ -166,6 +167,8 @@ typedef enum { SECTION_ID_FRAME_TAGS, SECTION_ID_FRAME_SIDE_DATA_LIST, SECTION_ID_FRAME_SIDE_DATA, +SECTION_ID_FRAME_VENC_PARAMS_BLOCK_DATA_LIST, +SECTION_ID_FRAME_VENC_PARAMS_BLOCK_DATA, SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST, SECTION_ID_FRAME_SIDE_DATA_TIMECODE, SECTION_ID_FRAME_LOG, @@ -213,6 +216,8 @@ static struct section sections[] = { [SECTION_ID_FRAME_TAGS] = { SECTION_ID_FRAME_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "frame_tags" }, [SECTION_ID_FRAME_SIDE_DATA_LIST] ={ SECTION_ID_FRAME_SIDE_DATA_LIST, "side_data_list", SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_SIDE_DATA, -1 }, .element_name = "side_data", .unique_name = "frame_side_data_list" }, [SECTION_ID_FRAME_SIDE_DATA] = { SECTION_ID_FRAME_SIDE_DATA, "side_data", 0, { SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST, -1 } }, +[SECTION_ID_FRAME_VENC_PARAMS_BLOCK_DATA_LIST] ={ SECTION_ID_FRAME_VENC_PARAMS_BLOCK_DATA_LIST, "block_data_list", SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_VENC_PARAMS_BLOCK_DATA, -1 }, .element_name = "block_data", .unique_name = "frame_block_data_list"}, +[SECTION_ID_FRAME_VENC_PARAMS_BLOCK_DATA] = { SECTION_ID_FRAME_VENC_PARAMS_BLOCK_DATA, "block_data", 0, { -1 }, .show_all_entries = 1 }, [SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST] = { SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST, "timecodes", SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_SIDE_DATA_TIMECODE, -1 } }, [SECTION_ID_FRAME_SIDE_DATA_TIMECODE] = { SECTION_ID_FRAME_SIDE_DATA_TIMECODE, "timecode", 0, { -1 } }, [SECTION_ID_FRAME_LOGS] = { SECTION_ID_FRAME_LOGS, "logs", SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_LOG, -1 } }, @@ -2259,6 +2264,34 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, if (tag) print_str(tag->key, tag->value); print_int("size", sd->size); +} else if (sd->type == AV_FRAME_DATA_VIDEO_ENC_PARAMS) { +AVVideoEncParams *par = (AVVideoEncParams *) sd->data; +print_int("type", par->type); +print_int("qp", par->qp); +for (int plane = 0; plane < FF_ARRAY_ELEMS(par->delta_qp); plane++) +for (int acdc = 0; acdc < FF_ARRAY_ELEMS(par->delta_qp[plane]); acdc++) { +int delta_qp = par->delta_qp[plane][acdc]; +if (delta_qp) { +char buf[16]; +snprintf(buf, sizeof(buf), "delta_qp[%d][%d]", plane, acdc); +print_int(buf, delta_qp); +} +} +if (par->nb_blocks) { +print_int("nb_blocks", par->nb_blocks); +writer_print_section_header(w, SECTION_ID_FRAME_VENC_PARAMS_BLOCK_DATA_LIST); +for (int i = 0; i < par->nb_blocks; i++) { +AVVideoBlockParams *b = av_video_enc_params_block(par, i); +writer_print_section_header(w, SECTION_ID_FRAME_VENC_PARAMS_BLOCK_DATA); +print_int("src_x", b->src_x); +print_int("src_y", b->src_y); +print_int("width", b->w); +print_int("height", b->h); +print_int("delta_qp", b->delta_qp); +writer_print_section_footer(w); +} +writer_print_section_footer(w); +} } writer_print_section_footer(w); } -- 2.28.0.220.ged08abb693-goog ___ 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] avformat/libsrt: Close listen fd in listener mode
El jue., 13 ago. 2020 a las 3:56, Marton Balint () escribió: > > > > On Thu, 13 Aug 2020, Nicolas Sugino wrote: > > > In listener mode the first fd is not closed when libsrt_close() is called > > because it is overwritten by the new accept fd. > > Added the listen_fd to the context to properly close it when libsrt_close() > > is called. > > This fixes trac ticket #8372, right? Add a reference to it to the commit > message. > > > > > Signed-off-by: Nicolas Sugino > > --- > > libavformat/libsrt.c | 8 +++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c > > index 4719ce0d4b..02dab64e36 100644 > > --- a/libavformat/libsrt.c > > +++ b/libavformat/libsrt.c > > @@ -53,6 +53,7 @@ enum SRTMode { > > typedef struct SRTContext { > > const AVClass *class; > > int fd; > > +int listen_fd; > > int eid; > > int64_t rw_timeout; > > int64_t listen_timeout; > > @@ -362,7 +363,7 @@ static int libsrt_set_options_pre(URLContext *h, int fd) > > static int libsrt_setup(URLContext *h, const char *uri, int flags) > > { > > struct addrinfo hints = { 0 }, *ai, *cur_ai; > > -int port, fd = -1; > > +int port, fd = -1, listen_fd = -1; > > SRTContext *s = h->priv_data; > > const char *p; > > char buf[256]; > > @@ -439,6 +440,7 @@ static int libsrt_setup(URLContext *h, const char *uri, > > int flags) > > // multi-client > > if ((ret = libsrt_listen(s->eid, fd, cur_ai->ai_addr, > > cur_ai->ai_addrlen, h, s->listen_timeout)) < 0) > > goto fail1; > > +listen_fd = fd; > > fd = ret; > > } else { > > if (s->mode == SRT_MODE_RENDEZVOUS) { > > @@ -471,6 +473,7 @@ static int libsrt_setup(URLContext *h, const char *uri, > > int flags) > > > > h->is_streamed = 1; > > s->fd = fd; > > +s->listen_fd = listen_fd > -1 ? listen_fd : -1; > > Why not simply: > > s->listen_fd = listen_fd; > > Also note that listen_fd should also be cleaned up in both the failure > paths same way as fd is cleaned up now. > > > > > freeaddrinfo(ai); > > return 0; > > @@ -676,6 +679,9 @@ static int libsrt_close(URLContext *h) > > > > srt_close(s->fd); > > > > +if (s->listen_fd > -1) > > >= 0 to be consistent with other similar code. > > Thanks, > Marton > > > +srt_close(s->listen_fd); > > + > > srt_epoll_release(s->eid); > > > > srt_cleanup(); > > -- > > 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 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 for the comments, I've just sent a v2 including them ___ 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 v3] avformat/libsrt: Close listen fd in listener mode
In listener mode the first fd is not closed when libsrt_close() is called because it is overwritten by the new accept fd. Added the listen_fd to the context to properly close it when libsrt_close() is called. Fixes trac ticket #8372 Signed-off-by: Nicolas Sugino --- libavformat/libsrt.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 4719ce0d4b..f3fdfd1711 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -53,6 +53,7 @@ enum SRTMode { typedef struct SRTContext { const AVClass *class; int fd; +int listen_fd; int eid; int64_t rw_timeout; int64_t listen_timeout; @@ -362,7 +363,7 @@ static int libsrt_set_options_pre(URLContext *h, int fd) static int libsrt_setup(URLContext *h, const char *uri, int flags) { struct addrinfo hints = { 0 }, *ai, *cur_ai; -int port, fd = -1; +int port, fd = -1, listen_fd = -1; SRTContext *s = h->priv_data; const char *p; char buf[256]; @@ -439,6 +440,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) // multi-client if ((ret = libsrt_listen(s->eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, s->listen_timeout)) < 0) goto fail1; +listen_fd = fd; fd = ret; } else { if (s->mode == SRT_MODE_RENDEZVOUS) { @@ -471,6 +473,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) h->is_streamed = 1; s->fd = fd; +s->listen_fd = listen_fd; freeaddrinfo(ai); return 0; @@ -487,6 +490,8 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) fail1: if (fd >= 0) srt_close(fd); +if (listen_fd >= 0) +srt_close(fd); freeaddrinfo(ai); return ret; } @@ -676,6 +681,9 @@ static int libsrt_close(URLContext *h) srt_close(s->fd); +if (s->listen_fd >= 0) +srt_close(s->listen_fd); + srt_epoll_release(s->eid); srt_cleanup(); -- 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 v2] avformat/libsrt: Close listen fd in listener mode
In listener mode the first fd is not closed when libsrt_close() is called because it is overwritten by the new accept fd. Added the listen_fd to the context to properly close it when libsrt_close() is called. Fixes trac ticket #8372 Signed-off-by: Nicolas Sugino --- libavformat/libsrt.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 4719ce0d4b..f3fdfd1711 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -53,6 +53,7 @@ enum SRTMode { typedef struct SRTContext { const AVClass *class; int fd; +int listen_fd; int eid; int64_t rw_timeout; int64_t listen_timeout; @@ -362,7 +363,7 @@ static int libsrt_set_options_pre(URLContext *h, int fd) static int libsrt_setup(URLContext *h, const char *uri, int flags) { struct addrinfo hints = { 0 }, *ai, *cur_ai; -int port, fd = -1; +int port, fd = -1, listen_fd = -1; SRTContext *s = h->priv_data; const char *p; char buf[256]; @@ -439,6 +440,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) // multi-client if ((ret = libsrt_listen(s->eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, s->listen_timeout)) < 0) goto fail1; +listen_fd = fd; fd = ret; } else { if (s->mode == SRT_MODE_RENDEZVOUS) { @@ -471,6 +473,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) h->is_streamed = 1; s->fd = fd; +s->listen_fd = listen_fd; freeaddrinfo(ai); return 0; @@ -487,6 +490,8 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) fail1: if (fd >= 0) srt_close(fd); +if (listen_fd >= 0) +srt_close(fd); freeaddrinfo(ai); return ret; } @@ -676,6 +681,9 @@ static int libsrt_close(URLContext *h) srt_close(s->fd); +if (s->listen_fd >= 0) +srt_close(s->listen_fd); + srt_epoll_release(s->eid); srt_cleanup(); -- 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] [mov] See if mfra makes up the difference for an incomplete sidx.
A few popular sites have started generating MP4 files which have a sidx plus an mfra. The sidx accounts for all size except the mfra, so the old code did not mark the fragment index as complete. Instead we can just check if there's an mfra and if its size makes up the difference we can mark the index as complete. Fixes: https://crbug.com/1107130 Signed-off-by: Dale Curtis sidx_fix_v0.patch Description: Binary data ___ 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 v2 2/3] vaapi_encode: Rewrite slice/tile support
This precalculates all of the information we will need to define slice and tile positions at init time rather than rebuilding some of it with every slice. The control of tiles is generalised to match slices, so that arbitrary tile and slice layouts are possible within the constraint that slices can't cross tile boundaries (which comes from how VAAPI handles slices and tiles). Support for the EQUAL_MULTI_ROWS slice structure fits easily into this, so it is added at the same time. While doing that, try to be consistent about writing columns before rows everywhere. --- libavcodec/vaapi_encode.c | 553 libavcodec/vaapi_encode.h | 53 +-- libavcodec/vaapi_encode_h264.c | 3 +- libavcodec/vaapi_encode_h265.c | 14 +- libavcodec/vaapi_encode_mpeg2.c | 12 +- 5 files changed, 394 insertions(+), 241 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index b3a02459f1..bea48ca255 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -163,88 +163,6 @@ static int vaapi_encode_wait(AVCodecContext *avctx, return 0; } -static int vaapi_encode_make_row_slice(AVCodecContext *avctx, - VAAPIEncodePicture *pic) -{ -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeSlice *slice; -int i, rounding; - -for (i = 0; i < pic->nb_slices; i++) -pic->slices[i].row_size = ctx->slice_size; - -rounding = ctx->slice_block_rows - ctx->nb_slices * ctx->slice_size; -if (rounding > 0) { -// Place rounding error at top and bottom of frame. -av_assert0(rounding < pic->nb_slices); -// Some Intel drivers contain a bug where the encoder will fail -// if the last slice is smaller than the one before it. Since -// that's straightforward to avoid here, just do so. -if (rounding <= 2) { -for (i = 0; i < rounding; i++) -++pic->slices[i].row_size; -} else { -for (i = 0; i < (rounding + 1) / 2; i++) -++pic->slices[pic->nb_slices - i - 1].row_size; -for (i = 0; i < rounding / 2; i++) -++pic->slices[i].row_size; -} -} else if (rounding < 0) { -// Remove rounding error from last slice only. -av_assert0(rounding < ctx->slice_size); -pic->slices[pic->nb_slices - 1].row_size += rounding; -} - -for (i = 0; i < pic->nb_slices; i++) { -slice = &pic->slices[i]; -slice->index = i; -if (i == 0) { -slice->row_start = 0; -slice->block_start = 0; -} else { -const VAAPIEncodeSlice *prev = &pic->slices[i - 1]; -slice->row_start = prev->row_start + prev->row_size; -slice->block_start = prev->block_start + prev->block_size; -} -slice->block_size = slice->row_size * ctx->slice_block_cols; - -av_log(avctx, AV_LOG_DEBUG, "Slice %d: %d-%d (%d rows), " - "%d-%d (%d blocks).\n", i, slice->row_start, - slice->row_start + slice->row_size - 1, slice->row_size, - slice->block_start, slice->block_start + slice->block_size - 1, - slice->block_size); -} - -return 0; -} - -static int vaapi_encode_make_tile_slice(AVCodecContext *avctx, -VAAPIEncodePicture *pic) -{ -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeSlice *slice; -int i, j, index; - -for (i = 0; i < ctx->tile_cols; i++) { -for (j = 0; j < ctx->tile_rows; j++) { -index= j * ctx->tile_cols + i; -slice= &pic->slices[index]; -slice->index = index; - -pic->slices[index].block_start = ctx->col_bd[i] + - ctx->row_bd[j] * ctx->slice_block_cols; -pic->slices[index].block_size = ctx->row_height[j] * ctx->col_width[i]; - -av_log(avctx, AV_LOG_DEBUG, "Slice %2d: (%2d, %2d) start at: %4d " - "width:%2d height:%2d (%d blocks).\n", index, ctx->col_bd[i], - ctx->row_bd[j], slice->block_start, ctx->col_width[i], - ctx->row_height[j], slice->block_size); -} -} - -return 0; -} - static int vaapi_encode_issue(AVCodecContext *avctx, VAAPIEncodePicture *pic) { @@ -433,16 +351,17 @@ static int vaapi_encode_issue(AVCodecContext *avctx, err = AVERROR(ENOMEM); goto fail; } - -if (ctx->tile_rows && ctx->tile_cols) -vaapi_encode_make_tile_slice(avctx, pic); -else -vaapi_encode_make_row_slice(avctx, pic); } for (i = 0; i < pic->nb_slices; i++) { slice = &pic->slices[i]; +*slice = (VAAPIEncodeSlice) { +.index = i, +.block_start = ctx->slice_regions[i].block_start, +.b
[FFmpeg-devel] [PATCH v2 1/3] vaapi_encode_h265: Ensure that tile sizes conform to profile constraints
While libavcodec doesn't care about these constraints, the HM reference decoder does enforce them and other decoders may run into problems. --- libavcodec/vaapi_encode_h265.c | 35 +- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 316030914c..279d0ff1f7 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1105,7 +1105,7 @@ static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx) { VAAPIEncodeContext *ctx = avctx->priv_data; VAAPIEncodeH265Context *priv = avctx->priv_data; -int err; +int err, i; err = ff_cbs_init(&priv->cbc, AV_CODEC_ID_HEVC, avctx); if (err < 0) @@ -1143,6 +1143,39 @@ static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx) ctx->roi_quant_range = 51 + 6 * (ctx->profile->depth - 8); +// Ensure that tile sizes conform to profile constraints. +if (ctx->tile_cols > 1 || ctx->tile_rows > 1) { +if (ctx->surface_width < 256 || +ctx->surface_height < 64) { +// Special case to give a more helpful error message when +// tiles are not usable at all. +av_log(avctx, AV_LOG_ERROR, "The codec does not support " + "tiles at this resolution (%dx%d).\n", + avctx->width, avctx->height); +return AVERROR(EINVAL); +} +for (i = 0; i < ctx->tile_cols; i++) { +int width = ctx->tile_col_width[i] * ctx->slice_block_width; +if (width < 256) { +av_log(avctx, AV_LOG_ERROR, + "Tile column %d with width %d CTUs (%d pixels) " + "is too thin - consider using fewer tile columns.\n", + i, ctx->tile_col_width[i], width); +return AVERROR(EINVAL); +} +} +for (i = 0; i < ctx->tile_rows; i++) { +int height = ctx->tile_row_height[i] * ctx->slice_block_height; +if (height < 64) { +av_log(avctx, AV_LOG_ERROR, + "Tile row %d with height %d CTUs (%d pixels) " + "is too short - consider using fewer tile rows.\n", + i, ctx->tile_row_height[i], height); +return AVERROR(EINVAL); +} +} +} + return 0; } -- 2.28.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 v2 3/3] vaapi_encode_h265: Set tiles_fixed_structure_flag
We only make one PPS, so the tile structure necessarily fixed. --- libavcodec/vaapi_encode_h265.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index d2bcb8d3db..dbd8c77f6d 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -528,6 +528,7 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) vui->vui_hrd_parameters_present_flag = 0; vui->bitstream_restriction_flag= 1; +vui->tiles_fixed_structure_flag= 1; vui->motion_vectors_over_pic_boundaries_flag = 1; vui->restricted_ref_pic_lists_flag = 1; vui->max_bytes_per_pic_denom = 0; -- 2.28.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] libavformat/mpeg.c: Initialize the buffer uses to read the PTS.
Fixed an Use-of-uninitialized-value --- libavformat/mpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 265b2bd1ad..15a768e6e8 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -146,7 +146,7 @@ static int mpegps_read_header(AVFormatContext *s) static int64_t get_pts(AVIOContext *pb, int c) { -uint8_t buf[5]; +uint8_t buf[5] = {}; buf[0] = c < 0 ? avio_r8(pb) : c; avio_read(pb, buf + 1, 4); -- 2.28.0.220.ged08abb693-goog ___ 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] avfilter/formats: Simplify cleanup for ff_merge_* functions
Andreas Rheinhardt (12020-08-13): > Sure about that? The filter-framerate-up test fails (the output pixel > format is now YUV9 instead of I420) when I switch a and b in > MERGE_FORMATS if b->nb < a->nb. What you said seems to only apply to > sample rates, not format negotiations. Well, there is one aspect of the order that matters: if no stronger criterion applies and still several formats are possible, the first one will be selected. For most cases, it does not matter, because the input data will constrain the type, or possibly the output codec. But here, the input is testsrc2 and the output is framecrc, they support many formats. It could be a good idea to define some kind of "best" pixel formats when there is choice like that, but there is no urgency. More importantly, these test should be fixed to specify -pix_fmt and disable automatic conversions. I will try to have a look. 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 v2 3/3] FATE: add fate test for minterpolate filter
Hi. Replying to a very old patch already applied. lance.lmw...@gmail.com (12019-09-14): > From: Limin Wang > > Signed-off-by: Limin Wang > --- > tests/fate/filter-video.mak | 4 > tests/ref/fate/filter-minterpolate-down | 6 ++ > tests/ref/fate/filter-minterpolate-up | 15 +++ > 3 files changed, 25 insertions(+) > create mode 100644 tests/ref/fate/filter-minterpolate-down > create mode 100644 tests/ref/fate/filter-minterpolate-up > > diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak > index 0c6ee72..ab7b624 100644 > --- a/tests/fate/filter-video.mak > +++ b/tests/fate/filter-video.mak > @@ -122,6 +122,10 @@ FATE_FILTER-$(call ALLYES, FRAMERATE_FILTER > TESTSRC2_FILTER FORMAT_FILTER) += fa > fate-filter-framerate-12bit-up: CMD = framecrc -lavfi > testsrc2=r=50:d=1,format=pix_fmts=yuv422p12le,framerate=fps=60 -t 1 -pix_fmt > yuv422p12le > fate-filter-framerate-12bit-down: CMD = framecrc -lavfi > testsrc2=r=60:d=1,format=pix_fmts=yuv422p12le,framerate=fps=50 -t 1 -pix_fmt > yuv422p12le > > +FATE_FILTER-$(call ALLYES, MINTERPOLATE_FILTER TESTSRC2_FILTER) += > fate-filter-minterpolate-up fate-filter-minterpolate-down > +fate-filter-minterpolate-up: CMD = framecrc -lavfi > testsrc2=r=2:d=10,framerate=fps=10 -t 1 > +fate-filter-minterpolate-down: CMD = framecrc -lavfi > testsrc2=r=2:d=10,framerate=fps=1 -t 1 The patch says minterpolate, but the test is an exact copy of the framerate test, and still testing framerate. Please fix. 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] lavc/ratecontrol: Fix error logging for parsing and evaluation of rc_eq
On Wed, Aug 12, 2020 at 08:58:30PM +0200, Alexander Strasser wrote: > On 2020-08-09 14:56 +0200, Michael Niedermayer wrote: > > On Sun, Aug 09, 2020 at 02:24:34PM +0200, Alexander Strasser wrote: > > > > > > > > > Am 9. August 2020 12:56:53 MESZ schrieb Michael Niedermayer > > > : > > > >On Fri, Aug 07, 2020 at 11:26:58PM +0200, Alexander Strasser wrote: > > > >> Don't pass a potential NULL pointer to av_log, instead use a default > > > >> in the rc_eq AVOption definitions. Now the context variable always > > > >> holds a string; even if it's the default expression. > > > >> > > > >> Note this also fixes the evaluation error path, where a similar > > > >> av_log call references the rc_eq string from the context too. > > > >> > > > >> Signed-off-by: Alexander Strasser > > > >> --- > > > >> libavcodec/mpegvideo.h | 2 +- > > > >> libavcodec/ratecontrol.c | 3 +-- > > > >> libavcodec/snowenc.c | 2 +- > > > >> 3 files changed, 3 insertions(+), 4 deletions(-) > > > >> > > > >> diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h > > > >> index 29e692f245..d2515a3bbf 100644 > > > >> --- a/libavcodec/mpegvideo.h > > > >> +++ b/libavcodec/mpegvideo.h > > > >> @@ -637,7 +637,7 @@ FF_MPV_OPT_CMP_FUNC, \ > > > >>"defined in the section 'Expression Evaluation', the > > > >following functions are available: " > > > > \ > > > >>"bits2qp(bits), qp2bits(qp). Also the following constants > > > >are available: iTex pTex tex mv " > > > >\ > > > >>"fCode iCount mcVar var isI isP isB avgQP qComp avgIITex > > > >avgPITex avgPPTex avgBPTex avgTex.", > > > > \ > > > >> - > > > >FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, > > > >.flags = FF_MPV_OPT_FLAGS },\ > > > >> + > > > >FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, {.str = "tex^qComp" }, > > > >.flags = FF_MPV_OPT_FLAGS },\ > > > >> {"rc_init_cplx", "initial complexity for 1-pass encoding", > > > >FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, > > > >-FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ > > > >> {"rc_buf_aggressivity", "currently useless", > > > >FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 > > > >}, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ > > > >> {"border_mask", "increase the quantizer for macroblocks close to > > > >borders", FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 > > > >}, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS},\ > > > >> diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c > > > >> index 6b77ccd006..03513177f7 100644 > > > >> --- a/libavcodec/ratecontrol.c > > > >> +++ b/libavcodec/ratecontrol.c > > > >> @@ -515,8 +515,7 @@ av_cold int ff_rate_control_init(MpegEncContext > > > >*s) > > > >> s->avctx->rc_max_available_vbv_use = 1.0; > > > >> } > > > >> > > > >> -res = av_expr_parse(&rcc->rc_eq_eval, > > > >> -s->rc_eq ? s->rc_eq : "tex^qComp", > > > >> +res = av_expr_parse(&rcc->rc_eq_eval, s->rc_eq, > > > >> const_names, func1_names, func1, > > > >> NULL, NULL, 0, s->avctx); > > > > > > > >what happens if the user sets rc_eq explicitly to NULL ? > > > > > > Not sure which user you mean. > > > > lib user > > > > > If I'm not mistaken, a library user should not set it to NULL. Is it even > > > possible while respecting public API? > > > > if its not possible then the patch should be fine. I was just asking becasue > > thats the thing that would change if it can be set > > The rc_eq field was removed from AVCodecContext with the merge > commit bfab430856 and lives only inside private contexts these > days. > > Now I'm not 100% sure if there is a way to use av_opt API to set a > string type option's value to NULL. Though it would worry me if that > is possible, even for options that have a default string. > > If you know about that, I would be grateful to hear. Will see > if I can it try out myself too. One can probably do it (maybe with av_opt_ptr()) how realistic an issue this is, i dont know. For the future we should ensure though its clearly documented if NULL is valid for AV_OPT_TYPE_STRING because part of the issue here is i think its not clearly documented if this is allowed thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA 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 v4] avformat/mxfdec: Read video range from PictureDescriptor
On Thu, 13 Aug 2020, Tomas Härdin wrote: tor 2020-08-13 klockan 11:04 +0100 skrev Harry Mallon: Here is an updated patch (now hopefully going with correct email headers). It would be nice if in the future you either attach the patch or make the entire email the patch itself. I've had to trim these first couple of lines in each of the patches so far, after doing "git am" on the .mbox from saving your messages From 5866d0dc5536a6ea3f6a899c3d09f19df083c16a Mon Sep 17 00:00:00 2001 From: Harry Mallon Date: Wed, 12 Aug 2020 10:26:23 +0100 Subject: [PATCH v4] avformat/mxfdec: Read video range from PictureDescriptor * Capture black_ref, white_ref and color_range and recognise full and narrow range. Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 29 + tests/ref/fate/mxf-probe-dnxhd | 2 +- tests/ref/fate/mxf-probe-dv25 | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) Looks good to me. Running FATE atm, will push in a day if there are no objections. http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4328/01_Bad_Frame_2.24.mxf is not detected correctly for some reason. The MXF specs seems ambigous: Color Range is a Property, whose unsigned 32-bit integer value shall specify the number of distinct values allowed for color difference samples. So probably 2^depth color range should also be accepted as full range. 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".
[FFmpeg-devel] [PATCH] avformat/siff: Reject audio packets without audio stream
Fixes: Assertion failure Fixes: 24612/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6600899842277376.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/siff.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/siff.c b/libavformat/siff.c index f6815b2f26..60a867df14 100644 --- a/libavformat/siff.c +++ b/libavformat/siff.c @@ -201,6 +201,8 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt) if (c->curstrm == -1) { c->pktsize = avio_rl32(s->pb) - 4; c->flags = avio_rl16(s->pb); +if (c->flags & VB_HAS_AUDIO && !c->has_audio) +return AVERROR_INVALIDDATA; c->gmcsize = (c->flags & VB_HAS_GMC) ? 4 : 0; if (c->gmcsize) avio_read(s->pb, c->gmc, c->gmcsize); -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 2/3] avormat/av1dec: add low-overhead bitstream format
On Thu, 13 Aug 2020, James Almer wrote: On 8/13/2020 3:51 AM, Xu Guangxin wrote: + +ret = obu_prefetch(s, header, MAX_OBU_HEADER_SIZE); +if (!ret) +return AVERROR(EOF); We use AVERROR_EOF rather than AVERROR(EOF) (Afair, it was done because EOF is not portable, but don't quote me on it). Actually, it's a more severe thing than that. AVERROR() is used for mapping an errno style error code, EINVAL etc, which can be either positive or negative numbers depending on platforms, to the AVERROR range (which is negative numbers). So AVERROR() actually is shorthand for ERRNO_CODE_TO_AVERROR(). On platforms where errno codes are positive (most common modern platforms except BeOS/Haiku, iirc), it's essentially defined as (-(x)). Now EOF isn't an errno error code, and is defined to be a negative value (often -1). So if you do AVERROR(EOF) on a system where errno codes are positive, AVERROR(EOF) evalues to +1, which most caller would identify as not an error at all. TL;DR: AVERROR(EOF) is never correct. // Martin ___ 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 2/3] avormat/av1dec: add low-overhead bitstream format
On 8/13/2020 3:51 AM, Xu Guangxin wrote: > Hi James, > thanks for your feedback, please help review it again. > > Changelist for v3: > use av_fifo_* instead of homebrewed fifo operations > obu_probe(), add padding obu to alllow list > read_header(), use "const AVRational* framerate" instead of "AVRational > framerate" > > > > It's defined in Section 5.2, used by netflix. > see http://download.opencontent.netflix.com/?prefix=AV1/Chimera/ > --- > configure| 1 + > libavformat/allformats.c | 1 + > libavformat/av1dec.c | 263 +++ > 3 files changed, 242 insertions(+), 23 deletions(-) > > diff --git a/configure b/configure > index 8de1afcb99..d4a1fea9ce 100755 > --- a/configure > +++ b/configure > @@ -3331,6 +3331,7 @@ mxf_d10_muxer_select="mxf_muxer" > mxf_opatom_muxer_select="mxf_muxer" > nut_muxer_select="riffenc" > nuv_demuxer_select="riffdec" > +obu_demuxer_select="av1_frame_merge_bsf av1_parser" > oga_muxer_select="ogg_muxer" > ogg_demuxer_select="dirac_parse" > ogv_muxer_select="ogg_muxer" > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index b7e59ae170..0aa9dd7198 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -293,6 +293,7 @@ extern AVOutputFormat ff_null_muxer; > extern AVInputFormat ff_nut_demuxer; > extern AVOutputFormat ff_nut_muxer; > extern AVInputFormat ff_nuv_demuxer; > +extern AVInputFormat ff_obu_demuxer; > extern AVOutputFormat ff_oga_muxer; > extern AVInputFormat ff_ogg_demuxer; > extern AVOutputFormat ff_ogg_muxer; > diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c > index 1be2fac1c1..62cf5c31ea 100644 > --- a/libavformat/av1dec.c > +++ b/libavformat/av1dec.c > @@ -22,6 +22,7 @@ > #include "config.h" > > #include "libavutil/common.h" > +#include "libavutil/fifo.h" > #include "libavutil/opt.h" > #include "libavcodec/av1_parse.h" > #include "avformat.h" > @@ -70,6 +71,25 @@ static int read_obu(const uint8_t *buf, int size, int64_t > *obu_size, int *type) > return 0; > } > > +//return < 0 if we need more data > +static int get_score(int type, int *seq) > +{ > +switch (type) { > +case AV1_OBU_SEQUENCE_HEADER: > +*seq = 1; > +return -1; > +case AV1_OBU_FRAME: > +case AV1_OBU_FRAME_HEADER: > +return *seq ? AVPROBE_SCORE_EXTENSION + 1 : 0; > +case AV1_OBU_METADATA: > +case AV1_OBU_PADDING: > +return -1; > +default: > +break; > +} > +return 0; > +} > + > static int annexb_probe(const AVProbeData *p) > { > AVIOContext pb; > @@ -123,19 +143,9 @@ static int annexb_probe(const AVProbeData *p) > return 0; > cnt += obu_unit_size; > > -switch (type) { > -case AV1_OBU_SEQUENCE_HEADER: > -seq = 1; > -break; > -case AV1_OBU_FRAME: > -case AV1_OBU_FRAME_HEADER: > -return seq ? AVPROBE_SCORE_EXTENSION + 1 : 0; > -case AV1_OBU_TILE_GROUP: > -case AV1_OBU_TEMPORAL_DELIMITER: > -return 0; > -default: > -break; > -} > +ret = get_score(type, &seq); > +if (ret >= 0) > +return ret; > > temporal_unit_size -= obu_unit_size + ret; > frame_unit_size -= obu_unit_size + ret; > @@ -144,15 +154,14 @@ static int annexb_probe(const AVProbeData *p) > return 0; > } > > -static int annexb_read_header(AVFormatContext *s) > +static int read_header(AVFormatContext *s, const AVRational *framerate, > AVBSFContext **bsf, void *logctx) > { > -AnnexBContext *c = s->priv_data; > const AVBitStreamFilter *filter = av_bsf_get_by_name("av1_frame_merge"); > AVStream *st; > int ret; > > if (!filter) { > -av_log(c, AV_LOG_ERROR, "av1_frame_merge bitstream filter " > +av_log(logctx, AV_LOG_ERROR, "av1_frame_merge bitstream filter " > "not found. This is a bug, please report it.\n"); > return AVERROR_BUG; > } > @@ -165,25 +174,32 @@ static int annexb_read_header(AVFormatContext *s) > st->codecpar->codec_id = AV_CODEC_ID_AV1; > st->need_parsing = AVSTREAM_PARSE_HEADERS; > > -st->internal->avctx->framerate = c->framerate; > +st->internal->avctx->framerate = *framerate; > // taken from rawvideo demuxers > avpriv_set_pts_info(st, 64, 1, 120); > > -ret = av_bsf_alloc(filter, &c->bsf); > +ret = av_bsf_alloc(filter, bsf); > if (ret < 0) > return ret; > > -ret = avcodec_parameters_copy(c->bsf->par_in, st->codecpar); > +ret = avcodec_parameters_copy((*bsf)->par_in, st->codecpar); > if (ret < 0) { > -av_bsf_free(&c->bsf); > +av_bsf_free(bsf); > return ret; > } > > -ret = av_bsf_init(c->bsf); > +ret = av_bsf_init(*bsf); > if (ret < 0) > -av_bsf_free(&c->bsf); > +av_bsf_free(bsf); > > return ret; > + >
Re: [FFmpeg-devel] [PATCH 5/6] avfilter/formats: Simplify cleanup for ff_merge_* functions
Nicolas George: > Andreas Rheinhardt (12020-08-08): >> I was thinking about this part of the MERGE_FORMATS macro: >> >> for (i = 0; i < a->nb; i++) >> for (j = 0; j < b->nb; j++) >> if (a->fmts[i] == b->fmts[j]) { >> if(k >= FFMIN(a->nb, b->nb)){ >> av_log(NULL, AV_LOG_ERROR, "Duplicate formats in >> %s detected\n", __FUNCTION__); >> av_free(ret->fmts); >> av_free(ret); >> return NULL; >> } >> ret->fmts[k++] = a->fmts[i]; >> } >> >> Said check is not sufficient to ensure that there are no duplicates in >> ret->fmts, of course. It has been added in the merge commit 1cbf7fb4345 >> as an additional safety check to ensure that one does not write beyond >> the end of ret->fmts (it has FFMIN(a->nb, b->nb) entries). Yet this goal >> could also be achieved in a simpler way: If a->nb <= b->nb, one could >> simply rewrite the above to > > This is only a protection against internal bugs, since lists should not > contain duplicates in the first place. As such it should have been an > assert. If we no longer need it, it would probably be better to make a > conditional complete test for duplicates somewhere. > >> for (i = 0; i < a->nb; i++) >> for (j = 0; j < b->nb; j++) >> if (a->fmts[i] == b->fmts[j]) { >> ret->fmts[k++] = a->fmts[i]; >> break; >> } >> >> This ensures that every entry of a will end up at most once in ret. And >> if one were simply allowed to switch a and b, one could ensure a->nb <= >> b->nb easily. ff_merge_channel_layouts() already does something similar. > > I noticed something similar when refreshing my memory about this. > Indeed, breaking out of the loop when a match is found would make the > same guarantee, and a nice optimization for a quadratic algorithm. > > Now, I can confirm, the order of formats in the array is not relevant > for the rest of the negotiation. > Sure about that? The filter-framerate-up test fails (the output pixel format is now YUV9 instead of I420) when I switch a and b in MERGE_FORMATS if b->nb < a->nb. What you said seems to only apply to sample rates, not format negotiations. One can of course still avoid the allocations, if one is either willing to keep the bigger of the two formats buffers or if one reallocates the buffer to the correct (usually even smaller) size afterwards. I'll go with the latter. - 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] avcodec/dpx: Read alternative frame rate from television header
Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index b1833ed9ef..694deb27c5 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -216,10 +216,22 @@ static int decode_frame(AVCodecContext *avctx, else avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; +/* preferred frame rate from Motion-picture film header */ if (offset >= 1724 + 4) { buf = avpkt->data + 1724; i = read32(&buf, endian); -if(i) { +if(i && i != 0x) { +AVRational q = av_d2q(av_int2float(i), 4096); +if (q.num > 0 && q.den > 0) +avctx->framerate = q; +} +} + +/* alternative frame rate from television header */ +if (!(avctx->framerate.num && avctx->framerate.den) && offset >= 1940 + 4) { +buf = avpkt->data + 1940; +i = read32(&buf, endian); +if(i && i != 0x) { AVRational q = av_d2q(av_int2float(i), 4096); if (q.num > 0 && q.den > 0) avctx->framerate = q; -- 2.28.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] avcodec/cfhd: add x86 SIMD
Hi, patch attached. Please review and/or benchmark, especially .asm file. 0001-avcodec-cfhd-add-x86-SIMD.patch Description: Binary data ___ 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] avutil/opt: Restore NULL input handling to set_string_video_rate()
Hi Andreas, You're right - apologies. So in fact there was an exchange of one kind of undefined behaviour for another. Thanks Jack On Thu, Aug 6, 2020 at 1:52 PM Andreas Rheinhardt < andreas.rheinha...@gmail.com> wrote: > Jack Haughton: > > A NULL check in av_parse_video_rate() would certainly not be a bad idea. > It > > wouldn't (on its own) restore the NULL input robustness to > > set_string_video_rate() though, as any error value returned from > > av_parse_video_rate() would result in val being logged using %s, which is > > the whole problem that a500b975 was aiming to solve. > > > > av_parse_video_rate() is also called from a lot more places (most of > which > > already have an explicit NULL check immediately before the call), so > > changing the behaviour of that function by adding a NULL check > potentially > > has a lot more knock-on effects than simply restoring the previously > > existing robustness to set_string_video_rate(), which is also in keeping > > with the other av_parse_video_rate() callsites. > > > > You say that the caller 'should not' pass NULL to > set_string_video_rate(). > > Absolutely, agreed, but the point of checks is to handle unexpected > > situations. If someone does pass NULL, as of a500b975 the response will > be > > undefined behaviour, where previously it would have been cleanly handled > > with an explicit error code. I'd contend that this is a bad response. > > > You are contradicting yourself here: As the commit message of a500b975 > makes clear and as you explain in the first paragraph, a NULL value > would not have been handled cleanly before a500b975: Using NULL for %s > is undefined behaviour, too. Just wanted to mention it because you > repeat this point later in another mail: > > Jack Haughton: > > Isn't it better for that condition to be handled cleanly (as it was > > before a500b975) rather than causing undefined behaviour? > > - 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". -- Argon Design Ltd., Registration No. 06977690, a Broadcom Inc. company Registered in England with registered office at St John's Innovation Centre, Cowley Road, Cambridge, CB4 0WS ___ 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] avutil/opt: Restore NULL input handling to set_string_video_rate()
Commit a500b975 removed NULL input handling from this function, moving the check higher up the call tree in one branch. However, there is another call to set_string_video_rate() which may pass NULL, and future users of the function may not be clear that a NULL check is required. This patch restores the NULL check to avoid these problems. --- libavutil/opt.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index c8413fa5e1..50bf769cbd 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -333,7 +333,10 @@ static int set_string_image_size(void *obj, const AVOption *o, const char *val, static int set_string_video_rate(void *obj, const AVOption *o, const char *val, AVRational *dst) { -int ret = av_parse_video_rate(dst, val); +int ret; + +av_assert0(val); +ret = av_parse_video_rate(dst, val); if (ret < 0) av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as video rate\n", val); return ret; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4] avformat/mxfdec: Read video range from PictureDescriptor
tor 2020-08-13 klockan 11:04 +0100 skrev Harry Mallon: > Here is an updated patch (now hopefully going with correct email headers). It would be nice if in the future you either attach the patch or make the entire email the patch itself. I've had to trim these first couple of lines in each of the patches so far, after doing "git am" on the .mbox from saving your messages > From 5866d0dc5536a6ea3f6a899c3d09f19df083c16a Mon Sep 17 00:00:00 2001 > > From: Harry Mallon > Date: Wed, 12 Aug 2020 10:26:23 +0100 > Subject: [PATCH v4] avformat/mxfdec: Read video range from PictureDescriptor > > * Capture black_ref, white_ref and color_range and recognise > full and narrow range. > > Signed-off-by: Harry Mallon > --- > libavformat/mxfdec.c | 29 + > tests/ref/fate/mxf-probe-dnxhd | 2 +- > tests/ref/fate/mxf-probe-dv25 | 2 +- > 3 files changed, 31 insertions(+), 2 deletions(-) Looks good to me. Running FATE atm, will push in a day if there are no objections. /Tomas ___ 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] dnn_backend_openvino.c: parse options in openvino backend
Signed-off-by: Guo, Yejun --- libavfilter/dnn/dnn_backend_openvino.c | 40 +- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index d343bf2..030670b 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -26,8 +26,14 @@ #include "dnn_backend_openvino.h" #include "libavformat/avio.h" #include "libavutil/avassert.h" +#include "libavutil/avstring.h" #include +typedef struct OVOptions{ +uint32_t batch_size; +uint32_t req_num; +} OVOptions; + typedef struct OVModel{ ie_core_t *core; ie_network_t *network; @@ -36,6 +42,7 @@ typedef struct OVModel{ ie_blob_t *input_blob; ie_blob_t **output_blobs; uint32_t nb_output; +OVOptions options; } OVModel; static DNNDataType precision_to_datatype(precision_e precision) @@ -50,6 +57,32 @@ static DNNDataType precision_to_datatype(precision_e precision) } } +static int parse_options(OVOptions *to, const char *from) +{ +AVDictionary *dict = NULL; +AVDictionaryEntry *opt = NULL; +int err = av_dict_parse_string(&dict, from, "=", "&", 0); +if (err < 0) { +av_dict_free(&dict); +return err; +} + +opt = av_dict_get(dict, "nireq", opt, AV_DICT_MATCH_CASE); +if (opt != NULL) +{ +to->req_num = atoi(opt->value); +} + +opt = av_dict_get(dict, "batch", opt, AV_DICT_MATCH_CASE); +if (opt != NULL) +{ +to->batch_size = atoi(opt->value); +} + +av_dict_free(&dict); +return 0; +} + static DNNReturnType get_input_ov(void *model, DNNData *input, const char *input_name) { OVModel *ov_model = (OVModel *)model; @@ -171,6 +204,12 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options) if (!ov_model) goto err; +model->options = options; +if (model->options != NULL) +{ +parse_options(&ov_model->options, model->options); +} + status = ie_core_create("", &ov_model->core); if (status != OK) goto err; @@ -186,7 +225,6 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options) model->model = (void *)ov_model; model->set_input_output = &set_input_output_ov; model->get_input = &get_input_ov; -model->options = options; return model; -- 2.7.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".
[FFmpeg-devel] [PATCH 1/2] dnn: fix build issue for tensorflow backend
Signed-off-by: Guo, Yejun --- libavfilter/dnn/dnn_backend_tf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 86da991..9099d2b 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -490,7 +490,7 @@ static DNNReturnType load_native_model(TFModel *tf_model, const char *model_file DNNModel *native_model = NULL; ConvolutionalNetwork *conv_network; -native_model = ff_dnn_load_model_native(model_filename); +native_model = ff_dnn_load_model_native(model_filename, NULL); if (!native_model){ return DNN_ERROR; } -- 2.7.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".
[FFmpeg-devel] [PATCH] dnn_backend_native_layer_mathbinary: add pow support
Signed-off-by: Mingyu Yin --- .../dnn/dnn_backend_native_layer_mathbinary.c | 17 + .../dnn/dnn_backend_native_layer_mathbinary.h | 1 + tests/dnn/dnn-layer-mathbinary-test.c | 5 + tools/python/convert_from_tensorflow.py | 2 +- tools/python/convert_header.py | 2 +- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c index dd42c329a9..978c37bdf4 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c +++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c @@ -175,6 +175,23 @@ int dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_ope } } return 0; +case DMBO_POW: +if (params->input0_broadcast) { +for (int i = 0; i < dims_count; ++i) { +dst[i] = pow(params->v, src[i]); +} +} else if (params->input1_broadcast) { +for (int i = 0; i < dims_count; ++i) { +dst[i] = pow(src[i], params->v); +} +} else { +const DnnOperand *input1 = &operands[input_operand_indexes[1]]; +const float *src1 = input1->data; +for (int i = 0; i < dims_count; ++i) { +dst[i] = pow(src[i], src1[i]); +} +} +return 0; default: return -1; } diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h index 0acf3b0ea0..4a15d0ab12 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h +++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h @@ -36,6 +36,7 @@ typedef enum { DMBO_MUL = 2, DMBO_REALDIV = 3, DMBO_MINIMUM = 4, +DMBO_POW = 5, DMBO_COUNT } DNNMathBinaryOperation; diff --git a/tests/dnn/dnn-layer-mathbinary-test.c b/tests/dnn/dnn-layer-mathbinary-test.c index e7f8f8557c..1c6a715470 100644 --- a/tests/dnn/dnn-layer-mathbinary-test.c +++ b/tests/dnn/dnn-layer-mathbinary-test.c @@ -40,6 +40,8 @@ static float get_expected(float f1, float f2, DNNMathBinaryOperation op) return f1 / f2; case DMBO_MINIMUM: return (f1 < f2) ? f1 : f2; +case DMBO_POW: +return pow(f1, f2); default: av_assert0(!"not supported yet"); return 0.f; @@ -205,5 +207,8 @@ int main(int argc, char **argv) if (test(DMBO_MINIMUM)) return 1; +if (test(DMBO_POW)) +return 1; + return 0; } diff --git a/tools/python/convert_from_tensorflow.py b/tools/python/convert_from_tensorflow.py index 65fdbc5d43..5231bd1773 100644 --- a/tools/python/convert_from_tensorflow.py +++ b/tools/python/convert_from_tensorflow.py @@ -71,7 +71,7 @@ class TFConverter: self.conv2d_scope_names = set() self.conv2d_scopename_inputname_dict = {} self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3, 'Maximum':4, 'MathBinary':5, 'MathUnary':6} -self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 'Minimum':4} +self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 'Minimum':4, 'Pow':5} self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4, 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9, 'Asinh':10, 'Acosh':11, 'Atanh':12, 'Ceil':13, 'Floor':14, 'Round':15} diff --git a/tools/python/convert_header.py b/tools/python/convert_header.py index 747c8776eb..782a6341f9 100644 --- a/tools/python/convert_header.py +++ b/tools/python/convert_header.py @@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE' major = 1 # increase minor when we don't have to re-convert the model file -minor = 21 +minor = 22 -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 22/22] avfilter/formats: Avoid allocations when merging channel layouts
Andreas Rheinhardt (12020-08-13): > No, I just swap the pointers, not the structures themselves. It just > ensures a->refcount <= b->refcount in the following code. (The same > swapping btw already happens at the beginning of the function.) Oh, yes, my bad. I thought you wanted to reuse the formats array, but it is not possible for channel layouts. Then please go ahead. 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] lavfi: check the validity of formats lists.
Andreas Rheinhardt (12020-08-13): > Which part of the code fails if there are duplicates? At least the merge loops. They can be protected, but the result is still invalid and should be avoided, preferably with useful diagnostic. > ff_merge_channel_layouts() can be easily fixed by adding breaks to all > loops, so if it is only this, we could forgo checking as its cost is > quadratic in the number of elements. The merges are quadratic too, this is just changing the constant. We could avoid all quadratic operations by sorting the list. If we decide to do so, these check functions are good candidates to be renamed "prepare" or "optimize" and do it. 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 22/22] avfilter/formats: Avoid allocations when merging channel layouts
Nicolas George: > Andreas Rheinhardt (12020-08-12): >> When one merges two AVFilterChannelLayouts structs, there is no need to >> allocate a new one. Instead one can reuse one of the two given ones. >> If one does this, one also doesn't need to update the references of the >> AVFilterChannelLayouts that is reused. Therefore this commit reuses the >> structure with the higher refcount. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> This can of course be applied independently of 7-21. >> >> libavfilter/formats.c | 48 +++ >> 1 file changed, 21 insertions(+), 27 deletions(-) >> >> diff --git a/libavfilter/formats.c b/libavfilter/formats.c >> index 00d050e439..2d33dd7afe 100644 >> --- a/libavfilter/formats.c >> +++ b/libavfilter/formats.c >> @@ -48,13 +48,13 @@ do { >> \ >> av_freep(&a); \ >> } while (0) >> >> -#define MERGE_REF(ret, a, fmts, type, fail)\ >> +#define MERGE_REF(ret, a, fmts, type, fail_statement) \ >> do { \ >> type ***tmp; \ >> \ >> if (!(tmp = av_realloc_array(ret->refs, ret->refcount + a->refcount, \ >> sizeof(*tmp \ >> -goto fail; \ >> +{ fail_statement } \ >> ret->refs = tmp; \ >> MERGE_REF_NO_ALLOC(ret, a, fmts); \ >> } while (0) >> @@ -157,10 +157,10 @@ AVFilterFormats *ff_merge_samplerates(AVFilterFormats >> *a, >> if (a->nb_formats && b->nb_formats) { >> MERGE_FORMATS(ret, a, b, formats, nb_formats, AVFilterFormats, >> fail); >> } else if (a->nb_formats) { >> -MERGE_REF(a, b, formats, AVFilterFormats, fail); >> +MERGE_REF(a, b, formats, AVFilterFormats, return NULL;); >> ret = a; >> } else { >> -MERGE_REF(b, a, formats, AVFilterFormats, fail); >> +MERGE_REF(b, a, formats, AVFilterFormats, return NULL;); >> ret = b; >> } >> >> @@ -177,7 +177,7 @@ fail: >> AVFilterChannelLayouts *ff_merge_channel_layouts(AVFilterChannelLayouts *a, >> AVFilterChannelLayouts *b) >> { >> -AVFilterChannelLayouts *ret = NULL; >> +uint64_t *channel_layouts; >> unsigned a_all = a->all_layouts + a->all_counts; >> unsigned b_all = b->all_layouts + b->all_counts; >> int ret_max, ret_nb = 0, i, j, round; >> @@ -201,15 +201,13 @@ AVFilterChannelLayouts >> *ff_merge_channel_layouts(AVFilterChannelLayouts *a, >> return NULL; >> b->nb_channel_layouts = j; >> } >> -MERGE_REF(b, a, channel_layouts, AVFilterChannelLayouts, fail); >> +MERGE_REF(b, a, channel_layouts, AVFilterChannelLayouts, return >> NULL;); >> return b; >> } >> >> ret_max = a->nb_channel_layouts + b->nb_channel_layouts; >> -if (!(ret = av_mallocz(sizeof(*ret))) || >> -!(ret->channel_layouts = av_malloc_array(ret_max, >> - >> sizeof(*ret->channel_layouts >> -goto fail; > >> +if (!(channel_layouts = av_malloc_array(ret_max, >> sizeof(channel_layouts > > sizeof(*channel_layouts) True. Fixed locally. > >> +return NULL; >> >> /* a[known] intersect b[known] */ >> for (i = 0; i < a->nb_channel_layouts; i++) { >> @@ -217,7 +215,7 @@ AVFilterChannelLayouts >> *ff_merge_channel_layouts(AVFilterChannelLayouts *a, >> continue; >> for (j = 0; j < b->nb_channel_layouts; j++) { >> if (a->channel_layouts[i] == b->channel_layouts[j]) { >> -ret->channel_layouts[ret_nb++] = a->channel_layouts[i]; >> +channel_layouts[ret_nb++] = a->channel_layouts[i]; >> a->channel_layouts[i] = b->channel_layouts[j] = 0; >> } >> } >> @@ -232,7 +230,7 @@ AVFilterChannelLayouts >> *ff_merge_channel_layouts(AVFilterChannelLayouts *a, >> bfmt = FF_COUNT2LAYOUT(av_get_channel_layout_nb_channels(fmt)); >> for (j = 0; j < b->nb_channel_layouts; j++) >> if (b->channel_layouts[j] == bfmt) >> -ret->channel_layouts[ret_nb++] = a->channel_layouts[i]; >> +channel_layouts[ret_nb++] = a->channel_layouts[i]; >> } >> /* 1st round: swap to prepare 2nd round; 2nd round: put it back */ >> FFSWAP(AVFilterChannelLayouts *, a, b); >> @@ -243
Re: [FFmpeg-devel] [PATCH 22/22] avfilter/formats: Avoid allocations when merging channel layouts
Andreas Rheinhardt (12020-08-12): > When one merges two AVFilterChannelLayouts structs, there is no need to > allocate a new one. Instead one can reuse one of the two given ones. > If one does this, one also doesn't need to update the references of the > AVFilterChannelLayouts that is reused. Therefore this commit reuses the > structure with the higher refcount. > > Signed-off-by: Andreas Rheinhardt > --- > This can of course be applied independently of 7-21. > > libavfilter/formats.c | 48 +++ > 1 file changed, 21 insertions(+), 27 deletions(-) > > diff --git a/libavfilter/formats.c b/libavfilter/formats.c > index 00d050e439..2d33dd7afe 100644 > --- a/libavfilter/formats.c > +++ b/libavfilter/formats.c > @@ -48,13 +48,13 @@ do { > \ > av_freep(&a); \ > } while (0) > > -#define MERGE_REF(ret, a, fmts, type, fail)\ > +#define MERGE_REF(ret, a, fmts, type, fail_statement) \ > do { \ > type ***tmp; \ > \ > if (!(tmp = av_realloc_array(ret->refs, ret->refcount + a->refcount, \ > sizeof(*tmp \ > -goto fail; \ > +{ fail_statement } \ > ret->refs = tmp; \ > MERGE_REF_NO_ALLOC(ret, a, fmts); \ > } while (0) > @@ -157,10 +157,10 @@ AVFilterFormats *ff_merge_samplerates(AVFilterFormats > *a, > if (a->nb_formats && b->nb_formats) { > MERGE_FORMATS(ret, a, b, formats, nb_formats, AVFilterFormats, fail); > } else if (a->nb_formats) { > -MERGE_REF(a, b, formats, AVFilterFormats, fail); > +MERGE_REF(a, b, formats, AVFilterFormats, return NULL;); > ret = a; > } else { > -MERGE_REF(b, a, formats, AVFilterFormats, fail); > +MERGE_REF(b, a, formats, AVFilterFormats, return NULL;); > ret = b; > } > > @@ -177,7 +177,7 @@ fail: > AVFilterChannelLayouts *ff_merge_channel_layouts(AVFilterChannelLayouts *a, > AVFilterChannelLayouts *b) > { > -AVFilterChannelLayouts *ret = NULL; > +uint64_t *channel_layouts; > unsigned a_all = a->all_layouts + a->all_counts; > unsigned b_all = b->all_layouts + b->all_counts; > int ret_max, ret_nb = 0, i, j, round; > @@ -201,15 +201,13 @@ AVFilterChannelLayouts > *ff_merge_channel_layouts(AVFilterChannelLayouts *a, > return NULL; > b->nb_channel_layouts = j; > } > -MERGE_REF(b, a, channel_layouts, AVFilterChannelLayouts, fail); > +MERGE_REF(b, a, channel_layouts, AVFilterChannelLayouts, return > NULL;); > return b; > } > > ret_max = a->nb_channel_layouts + b->nb_channel_layouts; > -if (!(ret = av_mallocz(sizeof(*ret))) || > -!(ret->channel_layouts = av_malloc_array(ret_max, > - > sizeof(*ret->channel_layouts > -goto fail; > +if (!(channel_layouts = av_malloc_array(ret_max, > sizeof(channel_layouts sizeof(*channel_layouts) > +return NULL; > > /* a[known] intersect b[known] */ > for (i = 0; i < a->nb_channel_layouts; i++) { > @@ -217,7 +215,7 @@ AVFilterChannelLayouts > *ff_merge_channel_layouts(AVFilterChannelLayouts *a, > continue; > for (j = 0; j < b->nb_channel_layouts; j++) { > if (a->channel_layouts[i] == b->channel_layouts[j]) { > -ret->channel_layouts[ret_nb++] = a->channel_layouts[i]; > +channel_layouts[ret_nb++] = a->channel_layouts[i]; > a->channel_layouts[i] = b->channel_layouts[j] = 0; > } > } > @@ -232,7 +230,7 @@ AVFilterChannelLayouts > *ff_merge_channel_layouts(AVFilterChannelLayouts *a, > bfmt = FF_COUNT2LAYOUT(av_get_channel_layout_nb_channels(fmt)); > for (j = 0; j < b->nb_channel_layouts; j++) > if (b->channel_layouts[j] == bfmt) > -ret->channel_layouts[ret_nb++] = a->channel_layouts[i]; > +channel_layouts[ret_nb++] = a->channel_layouts[i]; > } > /* 1st round: swap to prepare 2nd round; 2nd round: put it back */ > FFSWAP(AVFilterChannelLayouts *, a, b); > @@ -243,27 +241,23 @@ AVFilterChannelLayouts > *ff_merge_channel_layouts(AVFilterChannelLayouts *a, > continue; > for (j = 0; j < b->nb
Re: [FFmpeg-devel] [PATCH] lavfi: check the validity of formats lists.
Nicolas George: > Part of the code expect valid lists, in particular no duplicates. Which part of the code fails if there are duplicates? ff_merge_channel_layouts() can be easily fixed by adding breaks to all loops, so if it is only this, we could forgo checking as its cost is quadratic in the number of elements. > These tests allow to catch bugs in filters (unlikely but possible) > and to give a clear message when the error comes from the user > ((a)formats) or the application (buffersink). > > Signed-off-by: Nicolas George > --- > libavfilter/avfiltergraph.c | 50 ++ > libavfilter/formats.c | 71 + > libavfilter/formats.h | 28 +++ > 3 files changed, 149 insertions(+) > > diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c > index c8a52b1f47..b9c7669417 100644 > --- a/libavfilter/avfiltergraph.c > +++ b/libavfilter/avfiltergraph.c > @@ -313,6 +313,53 @@ static void sanitize_channel_layouts(void *log, > AVFilterChannelLayouts *l) > } > } > > +static int filter_link_check_formats(void *log, AVFilterLink *link, > AVFilterFormatsConfig *cfg) > +{ > +int ret; > + > +switch (link->type) { > + > +case AVMEDIA_TYPE_VIDEO: > +if ((ret = ff_formats_check_pixel_formats(log, cfg->formats)) < > 0) > +return ret; > +break; > + > +case AVMEDIA_TYPE_AUDIO: > +if ((ret = ff_formats_check_sample_formats(log, cfg->formats)) < > 0 || > +(ret = ff_formats_check_sample_rates(log, cfg->samplerates)) > < 0 || > +(ret = ff_formats_check_channel_layouts(log, > cfg->channel_layouts)) < 0) > +return ret; > +break; > + > +default: > +av_assert0(!"reached"); > +} > +return 0; > +} > + > +/** > + * Check the validity of the formats / etc. lists set by query_formats(). > + * > + * In particular, check they do not contain any redundant element. > + */ > +static int filter_check_formats(AVFilterContext *ctx) > +{ > +unsigned i; > +int ret; > + > +for (i = 0; i < ctx->nb_inputs; i++) { > +ret = filter_link_check_formats(ctx, ctx->inputs[i], > &ctx->inputs[i]->outcfg); > +if (ret < 0) > +return ret; > +} > +for (i = 0; i < ctx->nb_outputs; i++) { > +ret = filter_link_check_formats(ctx, ctx->outputs[i], > &ctx->outputs[i]->incfg); > +if (ret < 0) > +return ret; > +} > +return 0; > +} > + > static int filter_query_formats(AVFilterContext *ctx) > { > int ret, i; > @@ -329,6 +376,9 @@ static int filter_query_formats(AVFilterContext *ctx) > ctx->name, av_err2str(ret)); > return ret; > } > +ret = filter_check_formats(ctx); > +if (ret < 0) > +return ret; > > for (i = 0; i < ctx->nb_inputs; i++) > sanitize_channel_layouts(ctx, > ctx->inputs[i]->outcfg.channel_layouts); > diff --git a/libavfilter/formats.c b/libavfilter/formats.c > index 8843200f47..fb32874fb6 100644 > --- a/libavfilter/formats.c > +++ b/libavfilter/formats.c > @@ -723,3 +723,74 @@ int ff_parse_channel_layout(int64_t *ret, int *nret, > const char *arg, > > return 0; > } > + > +static int check_list(void *log, const char *name, const AVFilterFormats > *fmts) > +{ > +unsigned i, j; > + > +if (!fmts) > +return 0; > +if (!fmts->nb_formats) { > +av_log(log, AV_LOG_ERROR, "Empty %s list\n", name); > +return AVERROR(EINVAL); > +} > +for (i = 0; i < fmts->nb_formats; i++) { > +for (j = i + 1; j < fmts->nb_formats; j++) { > +if (fmts->formats[i] == fmts->formats[j]) { > +av_log(log, AV_LOG_ERROR, "Duplicated %s\n", name); > +return AVERROR(EINVAL); > +} > +} > +} > +return 0; > +} > + > +int ff_formats_check_pixel_formats(void *log, const AVFilterFormats *fmts) > +{ > +return check_list(log, "pixel format", fmts); > +} > + > +int ff_formats_check_sample_formats(void *log, const AVFilterFormats *fmts) > +{ > +return check_list(log, "sample format", fmts); > +} > + > +int ff_formats_check_sample_rates(void *log, const AVFilterFormats *fmts) > +{ > +if (!fmts || !fmts->nb_formats) > +return 0; > +return check_list(log, "sample rate", fmts); > +} > + > +static int layouts_compatible(uint64_t a, uint64_t b) > +{ > +return a == b || > + (KNOWN(a) && !KNOWN(b) && av_get_channel_layout_nb_channels(a) == > FF_LAYOUT2COUNT(b)) || > + (KNOWN(b) && !KNOWN(a) && av_get_channel_layout_nb_channels(b) == > FF_LAYOUT2COUNT(a)); > +} > + > +int ff_formats_check_channel_layouts(void *log, const AVFilterChannelLayouts > *fmts) > +{ > +unsigned i, j; > + > +if (!fmts) > +return 0; > +if (fmts->all_layouts < fmts->all_counts || > +(!fmts->all_layouts && !fmts->nb_c
Re: [FFmpeg-devel] [PATCH] avfilter/formats: Fix heap-buffer overflow when merging channel layouts
Nicolas George: > Andreas Rheinhardt (12020-08-13): >> The channel layouts accepted by ff_merge_channel_layouts() are of two >> types: Ordinary channel layouts and generic channel layouts. These are >> layouts that match all layouts with a certain number of channels. >> Therefore parsing these channel layouts is not done in one go; instead >> first the intersection of the ordinary layouts of the first input >> list of channel layouts with the ordinary layouts of the second list is >> determined, then the intersection of the ordinary layouts of the first >> one and the generic layouts of the second one etc. In order to mark the >> ordinary channel layouts that have already been matched as used they are >> zeroed. The inner loop that does this is as follows: >> >> for (j = 0; j < b->nb_channel_layouts; j++) { >> if (a->channel_layouts[i] == b->channel_layouts[j]) { >> ret->channel_layouts[ret_nb++] = a->channel_layouts[i]; >> a->channel_layouts[i] = b->channel_layouts[j] = 0; >> } >> } >> >> (Here ret->channel_layouts is the array containing the intersection of >> the two input arrays.) >> >> Yet the problem with this code is that after a match has been found, the >> loop continues the search with the new value a->channel_layouts[i]. >> The intention of zeroing these elements was to make sure that elements >> already paired at this stage are ignored later. And while they are indeed >> ignored when pairing ordinary and generic channel layouts later, it has >> the exact opposite effect when pairing ordinary channel layouts. >> >> To see this consider the channel layouts A B C D E and E D C B A. In the >> first round, A and A will be paired and added to ret->channel_layouts. >> In the second round, the input arrays are 0 B C D E and E D C B 0. >> At first B and B will be matched and zeroed, but after doing so matching >> continues, but this time it will search for 0, which will match with the >> last entry of the second array. ret->channel_layouts now contains A B 0. >> In the third round, C 0 0 will be added to ret->channel_layouts etc. >> This gives a quadratic amount of elements, yet the amount of elements >> allocated for said array is only the sum of the sizes of a and b. >> >> This issue can e.g. be reproduced by >> ffmpeg -f lavfi -i anullsrc=cl=7.1 \ >> -af 'aformat=cl=mono|stereo|2.1|3.0|4.0,aformat=cl=4.0|3.0|2.1|stereo|mono' \ >> -f null - > > Oh, good catch. It is a bug indeed. > >> The fix is easy: break out of the inner loop after having found a match. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> 1. This patch is intended to be applied before >> https://ffmpeg.org/pipermail/ffmpeg-devel/2020-August/267790.html >> > >> 2. After this patch the code will stay within the buffer provided that >> no list contains one and the same generic channel layout multiple times >> (ordinary channel layouts may appear arbitrary often and there may even >> be ordinary channel layouts and generic channel layouts of the same >> channel count in the same list). But is this actually ensured? >> (Given that the concept of generic channel layouts is not part of the >> public API, but just valid in AVFilterChannelLayouts the question can be >> rephrased as: Is it possible for the (API) user to somehow create >> generic channel layouts?) > > I thought it was ensured by the rest of the code, where the lists of > supported formats are very limited. But I forgot what you found: a few > filters accept them from the application or the user. In particular, > bufferink can inject generic layouts. > > I will make a patch that checks the validity after calling > query_formats. > >> >> libavfilter/formats.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/libavfilter/formats.c b/libavfilter/formats.c >> index 00d050e439..f39396ed81 100644 >> --- a/libavfilter/formats.c >> +++ b/libavfilter/formats.c >> @@ -219,6 +219,7 @@ AVFilterChannelLayouts >> *ff_merge_channel_layouts(AVFilterChannelLayouts *a, >> if (a->channel_layouts[i] == b->channel_layouts[j]) { >> ret->channel_layouts[ret_nb++] = a->channel_layouts[i]; >> a->channel_layouts[i] = b->channel_layouts[j] = 0; >> +break; >> } >> } >> } > > I think you can add the break to the other two loops too. > Yes. And this even makes sure that we always stay within the buffer regardless of whether the lists contain duplicate generic elements. - 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] lavfi: check the validity of formats lists.
Part of the code expect valid lists, in particular no duplicates. These tests allow to catch bugs in filters (unlikely but possible) and to give a clear message when the error comes from the user ((a)formats) or the application (buffersink). Signed-off-by: Nicolas George --- libavfilter/avfiltergraph.c | 50 ++ libavfilter/formats.c | 71 + libavfilter/formats.h | 28 +++ 3 files changed, 149 insertions(+) diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index c8a52b1f47..b9c7669417 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -313,6 +313,53 @@ static void sanitize_channel_layouts(void *log, AVFilterChannelLayouts *l) } } +static int filter_link_check_formats(void *log, AVFilterLink *link, AVFilterFormatsConfig *cfg) +{ +int ret; + +switch (link->type) { + +case AVMEDIA_TYPE_VIDEO: +if ((ret = ff_formats_check_pixel_formats(log, cfg->formats)) < 0) +return ret; +break; + +case AVMEDIA_TYPE_AUDIO: +if ((ret = ff_formats_check_sample_formats(log, cfg->formats)) < 0 || +(ret = ff_formats_check_sample_rates(log, cfg->samplerates)) < 0 || +(ret = ff_formats_check_channel_layouts(log, cfg->channel_layouts)) < 0) +return ret; +break; + +default: +av_assert0(!"reached"); +} +return 0; +} + +/** + * Check the validity of the formats / etc. lists set by query_formats(). + * + * In particular, check they do not contain any redundant element. + */ +static int filter_check_formats(AVFilterContext *ctx) +{ +unsigned i; +int ret; + +for (i = 0; i < ctx->nb_inputs; i++) { +ret = filter_link_check_formats(ctx, ctx->inputs[i], &ctx->inputs[i]->outcfg); +if (ret < 0) +return ret; +} +for (i = 0; i < ctx->nb_outputs; i++) { +ret = filter_link_check_formats(ctx, ctx->outputs[i], &ctx->outputs[i]->incfg); +if (ret < 0) +return ret; +} +return 0; +} + static int filter_query_formats(AVFilterContext *ctx) { int ret, i; @@ -329,6 +376,9 @@ static int filter_query_formats(AVFilterContext *ctx) ctx->name, av_err2str(ret)); return ret; } +ret = filter_check_formats(ctx); +if (ret < 0) +return ret; for (i = 0; i < ctx->nb_inputs; i++) sanitize_channel_layouts(ctx, ctx->inputs[i]->outcfg.channel_layouts); diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 8843200f47..fb32874fb6 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -723,3 +723,74 @@ int ff_parse_channel_layout(int64_t *ret, int *nret, const char *arg, return 0; } + +static int check_list(void *log, const char *name, const AVFilterFormats *fmts) +{ +unsigned i, j; + +if (!fmts) +return 0; +if (!fmts->nb_formats) { +av_log(log, AV_LOG_ERROR, "Empty %s list\n", name); +return AVERROR(EINVAL); +} +for (i = 0; i < fmts->nb_formats; i++) { +for (j = i + 1; j < fmts->nb_formats; j++) { +if (fmts->formats[i] == fmts->formats[j]) { +av_log(log, AV_LOG_ERROR, "Duplicated %s\n", name); +return AVERROR(EINVAL); +} +} +} +return 0; +} + +int ff_formats_check_pixel_formats(void *log, const AVFilterFormats *fmts) +{ +return check_list(log, "pixel format", fmts); +} + +int ff_formats_check_sample_formats(void *log, const AVFilterFormats *fmts) +{ +return check_list(log, "sample format", fmts); +} + +int ff_formats_check_sample_rates(void *log, const AVFilterFormats *fmts) +{ +if (!fmts || !fmts->nb_formats) +return 0; +return check_list(log, "sample rate", fmts); +} + +static int layouts_compatible(uint64_t a, uint64_t b) +{ +return a == b || + (KNOWN(a) && !KNOWN(b) && av_get_channel_layout_nb_channels(a) == FF_LAYOUT2COUNT(b)) || + (KNOWN(b) && !KNOWN(a) && av_get_channel_layout_nb_channels(b) == FF_LAYOUT2COUNT(a)); +} + +int ff_formats_check_channel_layouts(void *log, const AVFilterChannelLayouts *fmts) +{ +unsigned i, j; + +if (!fmts) +return 0; +if (fmts->all_layouts < fmts->all_counts || +(!fmts->all_layouts && !fmts->nb_channel_layouts)) { +av_log(log, AV_LOG_ERROR, "Inconsistent generic list\n"); +return AVERROR(EINVAL); +} +if (!fmts->all_layouts && !fmts->nb_channel_layouts) { +av_log(log, AV_LOG_ERROR, "Empty channel layout list\n"); +return AVERROR(EINVAL); +} +for (i = 0; i < fmts->nb_channel_layouts; i++) { +for (j = i + 1; j < fmts->nb_channel_layouts; j++) { +if (layouts_compatible(fmts->channel_layouts[i], fmts->channel_layouts[j])) { +av_log(log, AV_LOG_ERROR, "Duplicated or redun
[FFmpeg-devel] [PATCH 2/2] lavfi/formats: simplify a macro parameters.
Signed-off-by: Nicolas George --- libavfilter/formats.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 32f41f2c13..8843200f47 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -549,15 +549,15 @@ void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref) FORMATS_CHANGEREF(oldref, newref); } -#define SET_COMMON_FORMATS(ctx, fmts, in_fmts, out_fmts, ref_fn, unref_fn, list) \ +#define SET_COMMON_FORMATS(ctx, fmts, ref_fn, unref_fn, list) \ int count = 0, i; \ \ if (!fmts) \ return AVERROR(ENOMEM); \ \ for (i = 0; i < ctx->nb_inputs; i++) { \ -if (ctx->inputs[i] && !ctx->inputs[i]->out_fmts) { \ -int ret = ref_fn(fmts, &ctx->inputs[i]->out_fmts); \ +if (ctx->inputs[i] && !ctx->inputs[i]->outcfg.fmts) { \ +int ret = ref_fn(fmts, &ctx->inputs[i]->outcfg.fmts); \ if (ret < 0) { \ unref_fn(&fmts);\ if (fmts) \ @@ -569,8 +569,8 @@ void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref) } \ } \ for (i = 0; i < ctx->nb_outputs; i++) { \ -if (ctx->outputs[i] && !ctx->outputs[i]->in_fmts) { \ -int ret = ref_fn(fmts, &ctx->outputs[i]->in_fmts); \ +if (ctx->outputs[i] && !ctx->outputs[i]->incfg.fmts) { \ +int ret = ref_fn(fmts, &ctx->outputs[i]->incfg.fmts); \ if (ret < 0) { \ unref_fn(&fmts);\ if (fmts) \ @@ -591,16 +591,16 @@ void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref) return 0; int ff_set_common_channel_layouts(AVFilterContext *ctx, - AVFilterChannelLayouts *layouts) + AVFilterChannelLayouts *channel_layouts) { -SET_COMMON_FORMATS(ctx, layouts, incfg.channel_layouts, outcfg.channel_layouts, +SET_COMMON_FORMATS(ctx, channel_layouts, ff_channel_layouts_ref, ff_channel_layouts_unref, channel_layouts); } int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates) { -SET_COMMON_FORMATS(ctx, samplerates, incfg.samplerates, outcfg.samplerates, +SET_COMMON_FORMATS(ctx, samplerates, ff_formats_ref, ff_formats_unref, formats); } @@ -611,7 +611,7 @@ int ff_set_common_samplerates(AVFilterContext *ctx, */ int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) { -SET_COMMON_FORMATS(ctx, formats, incfg.formats, outcfg.formats, +SET_COMMON_FORMATS(ctx, formats, ff_formats_ref, ff_formats_unref, formats); } -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] lavfi: regroup formats lists in a single structure.
It will allow to refernce it as a whole without clunky macros. Most of the changes have been automatically made with sed: sed -i ' s/-> *in_formats/->incfg.formats/g; s/-> *out_formats/->outcfg.formats/g; s/-> *in_channel_layouts/->incfg.channel_layouts/g; s/-> *out_channel_layouts/->outcfg.channel_layouts/g; s/-> *in_samplerates/->incfg.samplerates/g; s/-> *out_samplerates/->outcfg.samplerates/g; ' src/libavfilter/*(.) Signed-off-by: Nicolas George --- I would appreciate quick feed-back on this one, because I need to build on it (test the validity of the config), and it is the kind of patch that is nightmarish to rebase because it can create many conflicts. Andreas? libavfilter/aeval.c| 4 +- libavfilter/af_afir.c | 8 +- libavfilter/af_agate.c | 10 +- libavfilter/af_aiir.c | 2 +- libavfilter/af_amerge.c| 12 +- libavfilter/af_anequalizer.c | 14 +- libavfilter/af_aresample.c | 12 +- libavfilter/af_asetrate.c | 2 +- libavfilter/af_channelmap.c| 4 +- libavfilter/af_channelsplit.c | 4 +- libavfilter/af_hdcd.c | 4 +- libavfilter/af_headphone.c | 8 +- libavfilter/af_join.c | 4 +- libavfilter/af_ladspa.c| 6 +- libavfilter/af_loudnorm.c | 4 +- libavfilter/af_lv2.c | 6 +- libavfilter/af_pan.c | 4 +- libavfilter/af_resample.c | 12 +- libavfilter/af_sidechaincompress.c | 10 +- libavfilter/af_sofalizer.c | 4 +- libavfilter/af_surround.c | 4 +- libavfilter/avf_abitscope.c| 8 +- libavfilter/avf_ahistogram.c | 8 +- libavfilter/avf_aphasemeter.c | 14 +- libavfilter/avf_avectorscope.c | 8 +- libavfilter/avf_concat.c | 12 +- libavfilter/avf_showcqt.c | 8 +- libavfilter/avf_showfreqs.c| 8 +- libavfilter/avf_showspatial.c | 8 +- libavfilter/avf_showspectrum.c | 8 +- libavfilter/avf_showvolume.c | 8 +- libavfilter/avf_showwaves.c| 8 +- libavfilter/avfilter.c | 30 ++--- libavfilter/avfilter.h | 59 +--- libavfilter/avfiltergraph.c| 208 ++--- libavfilter/f_drawgraph.c | 2 +- libavfilter/f_ebur128.c| 14 +- libavfilter/f_graphmonitor.c | 2 +- libavfilter/formats.c | 6 +- libavfilter/src_movie.c| 8 +- libavfilter/tests/filtfmts.c | 6 +- libavfilter/vaapi_vpp.c| 4 +- libavfilter/vaf_spectrumsynth.c| 10 +- libavfilter/vf_alphamerge.c| 6 +- libavfilter/vf_ciescope.c | 4 +- libavfilter/vf_colorspace.c| 4 +- libavfilter/vf_coreimage.m | 6 +- libavfilter/vf_elbg.c | 4 +- libavfilter/vf_extractplanes.c | 12 +- libavfilter/vf_fieldmatch.c| 6 +- libavfilter/vf_fieldorder.c| 4 +- libavfilter/vf_histogram.c | 12 +- libavfilter/vf_hwdownload.c| 4 +- libavfilter/vf_hwmap.c | 4 +- libavfilter/vf_hwupload.c | 4 +- libavfilter/vf_hwupload_cuda.c | 4 +- libavfilter/vf_lut2.c | 4 +- libavfilter/vf_mergeplanes.c | 4 +- libavfilter/vf_overlay.c | 6 +- libavfilter/vf_overlay_qsv.c | 4 +- libavfilter/vf_palettegen.c| 4 +- libavfilter/vf_paletteuse.c| 6 +- libavfilter/vf_remap.c | 8 +- libavfilter/vf_scale.c | 4 +- libavfilter/vf_showpalette.c | 4 +- libavfilter/vf_vectorscope.c | 12 +- libavfilter/vf_vpp_qsv.c | 4 +- libavfilter/vf_waveform.c | 14 +- libavfilter/vf_yadif_cuda.c| 4 +- libavfilter/vf_zscale.c| 4 +- 70 files changed, 381 insertions(+), 360 deletions(-) diff --git a/libavfilter/aeval.c b/libavfilter/aeval.c index c7a8cd6550..4c62c98097 100644 --- a/libavfilter/aeval.c +++ b/libavfilter/aeval.c @@ -362,7 +362,7 @@ static int aeval_query_formats(AVFilterContext *ctx) // inlink supports any channel layout layouts = ff_all_channel_counts(); -if ((ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts)) < 0) +if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) return ret; if (eval->same_chlayout) { @@ -376,7 +376,7 @@ static int aeval_query_formats(AVFilterContext *ctx) eval->out_channel_layout ? eval->out_channel_layout : FF_COUNT2LAYOUT(eval->nb_channels))) < 0) return ret; -if ((ret = ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts)) < 0) +if ((ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts)) < 0) return ret; } diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.
Re: [FFmpeg-devel] [PATCH] avformat/mpegts: only reset timestamps to NOPTS for DVB teletext
On Thu, Aug 13, 2020 at 10:34 AM Marton Balint wrote: > > > > On Thu, 13 Aug 2020, Jan Ekström wrote: > > > While having the possibility of non-NOPTS values that can suddenly > > jump in time due to adjustments to match PCR is not nice for DVB > > subtitles, apparently the parser for this format bases its behavior on > > whether the packets' timestamps are NOPTS or not. > > Actually what matters is that the parser separates packets which have > different PTS values. Having a DVB subtitle packet with no PTS is not even > valid based on what I read from the specs: > > "Each PES header shall carry a PTS, associated with all the subtitle data > contained within that PES packet. " > > So I guess current code assumes that if a packet has no PTS then it is > also part of the previous packet, but this also seems like a workaround > for bad streams... > Yup, it's layers upon layers of fun :) Just like a box of chocolates or an onion. I posted this patch to get a discussion rolling, as I was highlighted on the parser being broken with NOPTS. > > Thus while we can adjust timestamps, we should exclude DVB subtitles > > from the timestamp unsetting logic. > > Ok, but to be frank the timestamp setting logic (even when it is > used with PCR) also breaks the parser, because it might assign different > PTS to PES packets which have the same PTS... > Yup. Cascades of things and all that jazz are fun. I just addressed the most obvious bit which I caused by my unsetting of timestamps (which in turn was to make sure that the time line doesn't suddenly jump X hours back or so). On trac reverting http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=42aa02418e43802b4ebcca373d2413ab63a0307e was mentioned, but that seems to have been a case fixing https://trac.ffmpeg.org/ticket/4200 . The ticket lacks exact details, but I expect there to be a bad mux with the subtitle timestamps not matching the general time line according to PCR. > > > > Fixes #8844 > > --- > > libavformat/mpegts.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c > > index f71f18a57d..50d4d5e9bc 100644 > > --- a/libavformat/mpegts.c > > +++ b/libavformat/mpegts.c > > @@ -1343,7 +1343,8 @@ skip: > > } > > } > > > > -if (!pcr_found) { > > +if (pes->st->codecpar->codec_id == > > AV_CODEC_ID_DVB_TELETEXT && > > +!pcr_found) { > > av_log(pes->stream, AV_LOG_VERBOSE, > >"Forcing DTS/PTS to be unset for a " > >"non-trustworthy PES packet for PID %d as " > > Patch LGTM, I am just saying that the problems lies more deep... > Thanks. Unless people have a better idea of how to go forward with this, I'll apply this patch. Jan ___ 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 v4] avformat/mxfdec: Read video range from PictureDescriptor
Here is an updated patch (now hopefully going with correct email headers). From 5866d0dc5536a6ea3f6a899c3d09f19df083c16a Mon Sep 17 00:00:00 2001 From: Harry Mallon Date: Wed, 12 Aug 2020 10:26:23 +0100 Subject: [PATCH v4] avformat/mxfdec: Read video range from PictureDescriptor * Capture black_ref, white_ref and color_range and recognise full and narrow range. Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 29 + tests/ref/fate/mxf-probe-dnxhd | 2 +- tests/ref/fate/mxf-probe-dv25 | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4b56984b77..0831ad5768 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -199,6 +199,9 @@ typedef struct MXFDescriptor { int bits_per_sample; int64_t duration; /* ContainerDuration optional property */ unsigned int component_depth; +unsigned int black_ref_level; +unsigned int white_ref_level; +unsigned int color_range; unsigned int horiz_subsampling; unsigned int vert_subsampling; UID *sub_descriptors_refs; @@ -1222,6 +1225,15 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int case 0x3302: descriptor->horiz_subsampling = avio_rb32(pb); break; +case 0x3304: +descriptor->black_ref_level = avio_rb32(pb); +break; +case 0x3305: +descriptor->white_ref_level = avio_rb32(pb); +break; +case 0x3306: +descriptor->color_range = avio_rb32(pb); +break; case 0x3308: descriptor->vert_subsampling = avio_rb32(pb); break; @@ -2492,6 +2504,23 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) } if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den) st->display_aspect_ratio = descriptor->aspect_ratio; +if (descriptor->component_depth && +descriptor->black_ref_level == 0 && +descriptor->white_ref_level == ((1color_range == ((1 codecpar->color_range = AVCOL_RANGE_JPEG; +} +else if (descriptor->component_depth >= 8 && + descriptor->black_ref_level == (1 <<(descriptor->component_depth - 4)) && + descriptor->white_ref_level == (235<<(descriptor->component_depth - 8)) && + descriptor->color_range == ((14<<(descriptor->component_depth - 4)) + 1)) { +st->codecpar->color_range = AVCOL_RANGE_MPEG; +} +else if (descriptor->black_ref_level || descriptor->white_ref_level || descriptor->color_range) { +avpriv_request_sample(mxf->fc, "Unrecognized color range (range %d, b %d, w %d, depth %d)", + descriptor->color_range, descriptor->black_ref_level, + descriptor->white_ref_level, descriptor->component_depth); +} st->codecpar->color_primaries = mxf_get_codec_ul(ff_mxf_color_primaries_uls, &descriptor->color_primaries_ul)->id; st->codecpar->color_trc = mxf_get_codec_ul(ff_mxf_color_trc_uls, &descriptor->color_trc_ul)->id; st->codecpar->color_space = mxf_get_codec_ul(ff_mxf_color_space_uls, &descriptor->color_space_ul)->id; diff --git a/tests/ref/fate/mxf-probe-dnxhd b/tests/ref/fate/mxf-probe-dnxhd index 012d3ea1d9..5a6221b1d5 100644 --- a/tests/ref/fate/mxf-probe-dnxhd +++ b/tests/ref/fate/mxf-probe-dnxhd @@ -124,7 +124,7 @@ sample_aspect_ratio=1:1 display_aspect_ratio=4:3 pix_fmt=yuv422p level=-99 -color_range=unknown +color_range=tv color_space=bt709 color_transfer=bt709 color_primaries=bt709 diff --git a/tests/ref/fate/mxf-probe-dv25 b/tests/ref/fate/mxf-probe-dv25 index 810f145f41..ffd26c4dfd 100644 --- a/tests/ref/fate/mxf-probe-dv25 +++ b/tests/ref/fate/mxf-probe-dv25 @@ -16,7 +16,7 @@ sample_aspect_ratio=16:15 display_aspect_ratio=4:3 pix_fmt=yuv420p level=-99 -color_range=unknown +color_range=tv color_space=unknown color_transfer=bt470m color_primaries=unknown -- 2.28.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] fix memory leak in qsvenc.c
make sense. regards Max On Thu, Aug 13, 2020 at 4:15 AM Alex Pokotilo wrote: > > ___ > 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] avformat/mxfdec: Read video range from PictureDescriptor
> On 12 Aug 2020, at 14:59, Tomas Härdin wrote: > > ons 2020-08-12 klockan 13:43 +0100 skrev Harry Mallon: >> @@ -2492,6 +2504,18 @@ static int mxf_parse_structural_metadata(MXFContext >> *mxf) >> } >> if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den) >> st->display_aspect_ratio = descriptor->aspect_ratio; >> +if (descriptor->component_depth && >> +descriptor->black_ref_level == 0 && >> +descriptor->white_ref_level == >> ((1> +descriptor->color_range == >> ((1 > +st->codecpar->color_range = AVCOL_RANGE_JPEG; >> +} >> +else if (descriptor->component_depth >= 8 && >> + descriptor->black_ref_level == (1 >> <<(descriptor->component_depth - 4)) && >> + descriptor->white_ref_level == >> (235<<(descriptor->component_depth - 8)) && >> + descriptor->color_range == >> ((14<<(descriptor->component_depth - 4)) + 1)) { >> +st->codecpar->color_range = AVCOL_RANGE_MPEG; >> +} > > Put a warning here in case levels are set but neither of these two ifs > are true, perhaps using avpriv_request_sample(). I can imagine there's > encoders that put off-by-one values in here. I'd like to see such files > first though before we widen these if clauses, so we can put the > samples in FATE. > > I'm testing the previous patch. Will push that one once FATE passes. > > /Tomas > Thanks Tomas, here is an updated V4 From 5866d0dc5536a6ea3f6a899c3d09f19df083c16a Mon Sep 17 00:00:00 2001 From: Harry Mallon Date: Wed, 12 Aug 2020 10:26:23 +0100 Subject: [PATCH v4] avformat/mxfdec: Read video range from PictureDescriptor * Capture black_ref, white_ref and color_range and recognise full and narrow range. Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 29 + tests/ref/fate/mxf-probe-dnxhd | 2 +- tests/ref/fate/mxf-probe-dv25 | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4b56984b77..0831ad5768 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -199,6 +199,9 @@ typedef struct MXFDescriptor { int bits_per_sample; int64_t duration; /* ContainerDuration optional property */ unsigned int component_depth; +unsigned int black_ref_level; +unsigned int white_ref_level; +unsigned int color_range; unsigned int horiz_subsampling; unsigned int vert_subsampling; UID *sub_descriptors_refs; @@ -1222,6 +1225,15 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int case 0x3302: descriptor->horiz_subsampling = avio_rb32(pb); break; +case 0x3304: +descriptor->black_ref_level = avio_rb32(pb); +break; +case 0x3305: +descriptor->white_ref_level = avio_rb32(pb); +break; +case 0x3306: +descriptor->color_range = avio_rb32(pb); +break; case 0x3308: descriptor->vert_subsampling = avio_rb32(pb); break; @@ -2492,6 +2504,23 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) } if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den) st->display_aspect_ratio = descriptor->aspect_ratio; +if (descriptor->component_depth && +descriptor->black_ref_level == 0 && +descriptor->white_ref_level == ((1 color_range == ((1 codecpar->color_range = AVCOL_RANGE_JPEG; +} +else if (descriptor->component_depth >= 8 && + descriptor->black_ref_level == (1 <<(descriptor->component_depth - 4)) && + descriptor->white_ref_level == (235<<(descriptor->component_depth - 8)) && + descriptor->color_range == ((14<<(descriptor->component_depth - 4)) + 1)) { +st->codecpar->color_range = AVCOL_RANGE_MPEG; +} +else if (descriptor->black_ref_level || descriptor->white_ref_level || descriptor->color_range) { +avpriv_request_sample(mxf->fc, "Unrecognized color range (range %d, b %d, w %d, depth %d)", + descriptor->color_range, descriptor->black_ref_level, + descriptor->white_ref_level, descriptor->component_depth); +} st->codecpar->color_primaries = mxf_get_codec_ul(ff_mxf_color_primaries_uls, &descriptor->color_primaries_ul)->id; st->codecpar->color_trc = mxf_get_codec_ul(ff_mxf_color_trc_uls, &descriptor->color_trc_ul)->id; st->codecpar->color_space = mxf_get_codec_ul(ff_mxf_color_space
Re: [FFmpeg-devel] [PATCH] avfilter/formats: Fix heap-buffer overflow when merging channel layouts
Andreas Rheinhardt (12020-08-13): > The channel layouts accepted by ff_merge_channel_layouts() are of two > types: Ordinary channel layouts and generic channel layouts. These are > layouts that match all layouts with a certain number of channels. > Therefore parsing these channel layouts is not done in one go; instead > first the intersection of the ordinary layouts of the first input > list of channel layouts with the ordinary layouts of the second list is > determined, then the intersection of the ordinary layouts of the first > one and the generic layouts of the second one etc. In order to mark the > ordinary channel layouts that have already been matched as used they are > zeroed. The inner loop that does this is as follows: > > for (j = 0; j < b->nb_channel_layouts; j++) { > if (a->channel_layouts[i] == b->channel_layouts[j]) { > ret->channel_layouts[ret_nb++] = a->channel_layouts[i]; > a->channel_layouts[i] = b->channel_layouts[j] = 0; > } > } > > (Here ret->channel_layouts is the array containing the intersection of > the two input arrays.) > > Yet the problem with this code is that after a match has been found, the > loop continues the search with the new value a->channel_layouts[i]. > The intention of zeroing these elements was to make sure that elements > already paired at this stage are ignored later. And while they are indeed > ignored when pairing ordinary and generic channel layouts later, it has > the exact opposite effect when pairing ordinary channel layouts. > > To see this consider the channel layouts A B C D E and E D C B A. In the > first round, A and A will be paired and added to ret->channel_layouts. > In the second round, the input arrays are 0 B C D E and E D C B 0. > At first B and B will be matched and zeroed, but after doing so matching > continues, but this time it will search for 0, which will match with the > last entry of the second array. ret->channel_layouts now contains A B 0. > In the third round, C 0 0 will be added to ret->channel_layouts etc. > This gives a quadratic amount of elements, yet the amount of elements > allocated for said array is only the sum of the sizes of a and b. > > This issue can e.g. be reproduced by > ffmpeg -f lavfi -i anullsrc=cl=7.1 \ > -af 'aformat=cl=mono|stereo|2.1|3.0|4.0,aformat=cl=4.0|3.0|2.1|stereo|mono' \ > -f null - Oh, good catch. It is a bug indeed. > The fix is easy: break out of the inner loop after having found a match. > > Signed-off-by: Andreas Rheinhardt > --- > 1. This patch is intended to be applied before > https://ffmpeg.org/pipermail/ffmpeg-devel/2020-August/267790.html > > 2. After this patch the code will stay within the buffer provided that > no list contains one and the same generic channel layout multiple times > (ordinary channel layouts may appear arbitrary often and there may even > be ordinary channel layouts and generic channel layouts of the same > channel count in the same list). But is this actually ensured? > (Given that the concept of generic channel layouts is not part of the > public API, but just valid in AVFilterChannelLayouts the question can be > rephrased as: Is it possible for the (API) user to somehow create > generic channel layouts?) I thought it was ensured by the rest of the code, where the lists of supported formats are very limited. But I forgot what you found: a few filters accept them from the application or the user. In particular, bufferink can inject generic layouts. I will make a patch that checks the validity after calling query_formats. > > libavfilter/formats.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/libavfilter/formats.c b/libavfilter/formats.c > index 00d050e439..f39396ed81 100644 > --- a/libavfilter/formats.c > +++ b/libavfilter/formats.c > @@ -219,6 +219,7 @@ AVFilterChannelLayouts > *ff_merge_channel_layouts(AVFilterChannelLayouts *a, > if (a->channel_layouts[i] == b->channel_layouts[j]) { > ret->channel_layouts[ret_nb++] = a->channel_layouts[i]; > a->channel_layouts[i] = b->channel_layouts[j] = 0; > +break; > } > } > } I think you can add the break to the other two loops too. 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] avformat/mpegts: only reset timestamps to NOPTS for DVB teletext
On Thu, 13 Aug 2020, Jan Ekström wrote: While having the possibility of non-NOPTS values that can suddenly jump in time due to adjustments to match PCR is not nice for DVB subtitles, apparently the parser for this format bases its behavior on whether the packets' timestamps are NOPTS or not. Actually what matters is that the parser separates packets which have different PTS values. Having a DVB subtitle packet with no PTS is not even valid based on what I read from the specs: "Each PES header shall carry a PTS, associated with all the subtitle data contained within that PES packet. " So I guess current code assumes that if a packet has no PTS then it is also part of the previous packet, but this also seems like a workaround for bad streams... Thus while we can adjust timestamps, we should exclude DVB subtitles from the timestamp unsetting logic. Ok, but to be frank the timestamp setting logic (even when it is used with PCR) also breaks the parser, because it might assign different PTS to PES packets which have the same PTS... Fixes #8844 --- libavformat/mpegts.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index f71f18a57d..50d4d5e9bc 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1343,7 +1343,8 @@ skip: } } -if (!pcr_found) { +if (pes->st->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT && +!pcr_found) { av_log(pes->stream, AV_LOG_VERBOSE, "Forcing DTS/PTS to be unset for a " "non-trustworthy PES packet for PID %d as " Patch LGTM, I am just saying that the problems lies more deep... 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] [FFmpeg-cvslog] lavf/url: rewrite ff_make_absolute_url() using ff_url_decompose().
On Wed, 12 Aug 2020, Alexander Strasser wrote: Hi all! On 2020-08-12 14:53 +, Nicolas George wrote: ffmpeg | branch: master | Nicolas George | Thu Jul 30 00:02:10 2020 +0200| [1201687da268c11459891a80ca1972aeaca8db88] | committer: Nicolas George lavf/url: rewrite ff_make_absolute_url() using ff_url_decompose(). Also add and update some tests. Change the semantic a little, because for filesytem paths symlinks complicate things. See the comments in the code for detail. Fix trac tickets #8813 and 8814. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1201687da268c11459891a80ca1972aeaca8db88 --- libavformat/tests/url.c | 60 ++- libavformat/url.c | 261 libavformat/url.h | 4 +- tests/ref/fate/url | 54 +- 4 files changed, 245 insertions(+), 134 deletions(-) [...] + +/* This is tricky. + For HTTP, http://server/site/page + ../media/file + should resolve into http://server/media/file + but for filesystem access, dir/playlist + ../media/file + should resolve into dir/../media/file + because dir could be a symlink, and .. points to + the actual parent of the target directory. + + We'll consider that URLs with an actual scheme and authority, + i.e. starting with scheme://, need parent dir simplification, + while bare paths or pseudo-URLs starting with proto: without + the double slash do not. + + For real URLs, the processing is similar to the algorithm described + here: + https://tools.ietf.org/html/rfc3986#section-5 + */ Stupid question: Why do we transform relative URLs at all? Isn't it normally supposed to work for HTTP on the server-side too? Many clients seem to do it. Just curious why... The RFC requires you to do it: https://tools.ietf.org/html/rfc3986#section-5.2.4 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".