Re: [FFmpeg-devel] [PATCH 2/5] avformat/mxfdec: reindent code
tor 2020-04-30 klockan 20:59 +0800 skrev lance.lmw...@gmail.com: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavformat/mxfdec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c > index fdd0dd2a88..02a2a6d97a 100644 > --- a/libavformat/mxfdec.c > +++ b/libavformat/mxfdec.c > @@ -363,7 +363,7 @@ static void mxf_free_metadataset(MXFMetadataSet > **ctx, int freectx) > break; > } > if (freectx) > -av_freep(ctx); > +av_freep(ctx); > } Might as well att some {} braces too /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".
Re: [FFmpeg-devel] [PATCH v4 7/8] avformat: implement retiming directly in mxfenc and gxfenc
tis 2020-04-28 klockan 19:37 +0200 skrev Marton Balint: > Generic retime functionality is replaced by a few lines of code directly in > the > muxers which used it, which seems a lot easier to understand and this way the > retiming is not dependant of the input durations. > > Signed-off-by: Marton Balint > --- > libavformat/Makefile | 4 ++-- > libavformat/gxfenc.c | 21 ++--- > libavformat/mxfenc.c | 14 +- > 3 files changed, 25 insertions(+), 14 deletions(-) > > diff --git a/libavformat/Makefile b/libavformat/Makefile > index 56ca55fbd5..0a2edffc86 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -205,7 +205,7 @@ OBJS-$(CONFIG_GIF_DEMUXER) += gifdec.o > OBJS-$(CONFIG_GSM_DEMUXER) += gsmdec.o > OBJS-$(CONFIG_GSM_MUXER) += rawenc.o > OBJS-$(CONFIG_GXF_DEMUXER) += gxf.o > -OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o retimeinterleave.o > +OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o > OBJS-$(CONFIG_G722_DEMUXER) += g722.o rawdec.o > OBJS-$(CONFIG_G722_MUXER)+= rawenc.o > OBJS-$(CONFIG_G723_1_DEMUXER)+= g723_1.o > @@ -347,7 +347,7 @@ OBJS-$(CONFIG_MUSX_DEMUXER) += musx.o > OBJS-$(CONFIG_MV_DEMUXER)+= mvdec.o > OBJS-$(CONFIG_MVI_DEMUXER) += mvi.o > OBJS-$(CONFIG_MXF_DEMUXER) += mxfdec.o mxf.o > -OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o > retimeinterleave.o avc.o > +OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o avc.o > OBJS-$(CONFIG_MXG_DEMUXER) += mxg.o > OBJS-$(CONFIG_NC_DEMUXER)+= ncdec.o > OBJS-$(CONFIG_NISTSPHERE_DEMUXER)+= nistspheredec.o pcm.o > diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c > index 60468c36ce..6d4df894f6 100644 > --- a/libavformat/gxfenc.c > +++ b/libavformat/gxfenc.c > @@ -27,7 +27,6 @@ > #include "avformat.h" > #include "internal.h" > #include "gxf.h" > -#include "retimeinterleave.h" > > #define GXF_SAMPLES_PER_FRAME 32768 > #define GXF_AUDIO_PACKET_SIZE 65536 > @@ -45,7 +44,7 @@ typedef struct GXFTimecode{ > } GXFTimecode; > > typedef struct GXFStreamContext { > -RetimeInterleaveContext aic; > +int64_t pkt_cnt; > uint32_t track_type; > uint32_t sample_size; > uint32_t sample_rate; > @@ -815,7 +814,6 @@ static int gxf_write_header(AVFormatContext *s) > return -1; > } > } > -ff_retime_interleave_init(&sc->aic, st->time_base); > /* FIXME first 10 audio tracks are 0 to 9 next 22 are A to V */ > sc->media_info = media_info<<8 | ('0'+tracks[media_info]++); > sc->order = s->nb_streams - st->index; > @@ -1012,10 +1010,19 @@ static int gxf_compare_field_nb(AVFormatContext *s, > const AVPacket *next, > > static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket > *pkt, int flush) > { > -if (pkt && s->streams[pkt->stream_index]->codecpar->codec_type == > AVMEDIA_TYPE_VIDEO) > -pkt->duration = 2; // enforce 2 fields > -return ff_retime_interleave(s, out, pkt, flush, > -ff_interleave_packet_per_dts, > gxf_compare_field_nb); > +int ret; > +if (pkt) { > +AVStream *st = s->streams[pkt->stream_index]; > +GXFStreamContext *sc = st->priv_data; > +if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) > +pkt->pts = pkt->dts = sc->pkt_cnt * 2; // enforce 2 fields > +else > +pkt->pts = pkt->dts = sc->pkt_cnt * GXF_SAMPLES_PER_FRAME; > +sc->pkt_cnt++; > +if ((ret = ff_interleave_add_packet(s, pkt, gxf_compare_field_nb)) < > 0) > +return ret; > +} > +return ff_interleave_packet_per_dts(s, out, NULL, flush); > } Doesn't apply on master /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".
Re: [FFmpeg-devel] [PATCH v4 7/8] avformat: implement retiming directly in mxfenc and gxfenc
tis 2020-04-28 klockan 19:37 +0200 skrev Marton Balint: > Generic retime functionality is replaced by a few lines of code > directly in the > muxers which used it, which seems a lot easier to understand and this > way the > retiming is not dependant of the input durations. > > Signed-off-by: Marton Balint > --- > libavformat/Makefile | 4 ++-- > libavformat/gxfenc.c | 21 ++--- > libavformat/mxfenc.c | 14 +- > 3 files changed, 25 insertions(+), 14 deletions(-) Wups, I missed that this is part of a larger patchset. Looks trivial enough /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".
Re: [FFmpeg-devel] subtitles filter and -ss
Manolis Stamatogiannakis (12020-05-03): > I've noticed what appears to be a bug/missing feature in the subtitles > filter: when "-ss" is used for the input, it is not applied to the > subtitles stream. E.g., for the following command line, the video playback > will start on 20:10, but the subtitles will start from 00:00. You can use -copyts to keep the timestamps of the video matching with the subtitles. 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/5] avformat/mxfdec: reindent code
On Mon, May 4, 2020 at 4:13 PM Tomas Härdin wrote: > tor 2020-04-30 klockan 20:59 +0800 skrev lance.lmw...@gmail.com: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavformat/mxfdec.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c > > index fdd0dd2a88..02a2a6d97a 100644 > > --- a/libavformat/mxfdec.c > > +++ b/libavformat/mxfdec.c > > @@ -363,7 +363,7 @@ static void mxf_free_metadataset(MXFMetadataSet > > **ctx, int freectx) > > break; > > } > > if (freectx) > > -av_freep(ctx); > > +av_freep(ctx); > > } > > Might as well att some {} braces too > > Sorry, I haven't understand your comments, are you want to change like below? if (freectx) { av_freep(cox); } /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 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 3/5] avformat/mov: fix av_freep for dovi pointer
Quoting Andreas Rheinhardt (2020-04-30 15:10:59) > lance.lmw...@gmail.com: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavformat/mov.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > index 3d6fef685d..03c8801402 100644 > > --- a/libavformat/mov.c > > +++ b/libavformat/mov.c > > @@ -6827,7 +6827,7 @@ static int mov_read_dvcc_dvvc(MOVContext *c, > > AVIOContext *pb, MOVAtom atom) > > ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF, > >(uint8_t *)dovi, dovi_size); > > if (ret < 0) { > > -av_freep(dovi); > > +av_freep(&dovi); > > return ret; > > } > > > > > Nice catch. LGTM; but you could also just use av_free() given that the > lifetime of the dovi pointer ends automatically when you exit the function. FWIW I prefer to just use av_freep() always even when it is not strictly necessary, simply because it's never worse than av_free (overhead is negligible) so you don't waste any brainpower wondering which one to use. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/5] avformat/mxfdec: reindent code
mån 2020-05-04 klockan 18:58 +0800 skrev Lance Wang: > On Mon, May 4, 2020 at 4:13 PM Tomas Härdin > wrote: > > > tor 2020-04-30 klockan 20:59 +0800 skrev lance.lmw...@gmail.com: > > > From: Limin Wang > > > > > > Signed-off-by: Limin Wang > > > --- > > > libavformat/mxfdec.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c > > > index fdd0dd2a88..02a2a6d97a 100644 > > > --- a/libavformat/mxfdec.c > > > +++ b/libavformat/mxfdec.c > > > @@ -363,7 +363,7 @@ static void > > > mxf_free_metadataset(MXFMetadataSet > > > **ctx, int freectx) > > > break; > > > } > > > if (freectx) > > > -av_freep(ctx); > > > +av_freep(ctx); > > > } > > > > Might as well att some {} braces too > > > > > Sorry, I haven't understand your comments, are you want to change > like > below? > if (freectx) { > av_freep(cox); > } > yes ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/4] lavc/pgs_frame_merge_bsf: add bsf to merge PGS segments
On Mon, 2020-05-04 at 08:29 +0200, Andreas Rheinhardt wrote: > John Stebbins: > > On Sat, 2020-05-02 at 22:30 +0200, Andreas Rheinhardt wrote: > > > John Stebbins: > > > > Required to remux m2ts to mkv > > > > --- > > > > Changelog| 1 + > > > > doc/bitstream_filters.texi | 8 ++ > > > > libavcodec/Makefile | 1 + > > > > libavcodec/bitstream_filters.c | 1 + > > > > libavcodec/pgs_frame_merge_bsf.c | 168 > > > > +++ > > > > 5 files changed, 179 insertions(+) > > > > create mode 100644 libavcodec/pgs_frame_merge_bsf.c > > > > > > > > diff --git a/Changelog b/Changelog > > > > index d9fcd8bb0a..fec4867488 100644 > > > > --- a/Changelog > > > > +++ b/Changelog > > > > @@ -59,6 +59,7 @@ version : > > > > - mv30 decoder > > > > - Expanded styling support for 3GPP Timed Text Subtitles > > > > (movtext) > > > > - WebP parser > > > > +- PGS subtitle frame merge bitstream filter > > > > > > > > > > > > version 4.2: > > > > diff --git a/doc/bitstream_filters.texi > > > > b/doc/bitstream_filters.texi > > > > index 8fe5b3ad75..21ed09986c 100644 > > > > --- a/doc/bitstream_filters.texi > > > > +++ b/doc/bitstream_filters.texi > > > > @@ -548,6 +548,14 @@ ffmpeg -i INPUT -c copy -bsf noise[=1] > > > > output.mkv > > > > @section null > > > > This bitstream filter passes the packets through unchanged. > > > > > > > > +@section pgs_frame_merge > > > > + > > > > +Merge a sequence of PGS Subtitle segments ending with an "end > > > > of > > > > display set" > > > > +segment into a single packet. > > > > + > > > > +This is required by some containers that support PGS subtitles > > > > +(muxer @code{matroska}). > > > > + > > > > @section prores_metadata > > > > > > > > Modify color property metadata embedded in prores stream. > > > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > > > > index 88944d9a3a..b630de21bc 100644 > > > > --- a/libavcodec/Makefile > > > > +++ b/libavcodec/Makefile > > > > @@ -1115,6 +1115,7 @@ OBJS- > > > > $(CONFIG_MP3_HEADER_DECOMPRESS_BSF) += > > > > mp3_header_decompress_bsf.o \ > > > > OBJS-$(CONFIG_MPEG2_METADATA_BSF) += > > > > mpeg2_metadata_bsf.o > > > > OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o > > > > OBJS-$(CONFIG_NULL_BSF) += null_bsf.o > > > > +OBJS-$(CONFIG_PGS_FRAME_MERGE_BSF)+= > > > > pgs_frame_merge_bsf.o > > > > OBJS-$(CONFIG_PRORES_METADATA_BSF)+= > > > > prores_metadata_bsf.o > > > > OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += > > > > remove_extradata_bsf.o > > > > OBJS-$(CONFIG_TEXT2MOVSUB_BSF)+= movsub_bsf.o > > > > diff --git a/libavcodec/bitstream_filters.c > > > > b/libavcodec/bitstream_filters.c > > > > index 6b5ffe4d70..92619225f0 100644 > > > > --- a/libavcodec/bitstream_filters.c > > > > +++ b/libavcodec/bitstream_filters.c > > > > @@ -49,6 +49,7 @@ extern const AVBitStreamFilter > > > > ff_mpeg4_unpack_bframes_bsf; > > > > extern const AVBitStreamFilter ff_mov2textsub_bsf; > > > > extern const AVBitStreamFilter ff_noise_bsf; > > > > extern const AVBitStreamFilter ff_null_bsf; > > > > +extern const AVBitStreamFilter ff_pgs_frame_merge_bsf; > > > > extern const AVBitStreamFilter ff_prores_metadata_bsf; > > > > extern const AVBitStreamFilter ff_remove_extradata_bsf; > > > > extern const AVBitStreamFilter ff_text2movsub_bsf; > > > > diff --git a/libavcodec/pgs_frame_merge_bsf.c > > > > b/libavcodec/pgs_frame_merge_bsf.c > > > > new file mode 100644 > > > > index 00..cae5c75655 > > > > --- /dev/null > > > > +++ b/libavcodec/pgs_frame_merge_bsf.c > > > > @@ -0,0 +1,168 @@ > > > > +/* > > > > + * Copyright (c) 2020 John Stebbins > > > > + * > > > > + * This file is part of FFmpeg. > > > > + * > > > > + * FFmpeg is free software; you can redistribute it and/or > > > > + * modify it under the terms of the GNU Lesser General Public > > > > + * License as published by the Free Software Foundation; > > > > either > > > > + * version 2.1 of the License, or (at your option) any later > > > > version. > > > > + * > > > > + * FFmpeg is distributed in the hope that it will be useful, > > > > + * but WITHOUT ANY WARRANTY; without even the implied warranty > > > > of > > > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See > > > > the > > > > GNU > > > > + * Lesser General Public License for more details. > > > > + * > > > > + * You should have received a copy of the GNU Lesser General > > > > Public > > > > + * License along with FFmpeg; if not, write to the Free > > > > Software > > > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, > > > > MA > > > > 02110-1301 USA > > > > + */ > > > > + > > > > +/** > > > > + * @file > > > > + * This bitstream filter merges PGS subtitle packets > > > > containing > > > > incomplete > > > > + * set of segments into a single packet > > > > + * > > > > + * Packets already containing a complete set of segments will > > > > be >
Re: [FFmpeg-devel] [PATCH v11] avformat: add demuxer for Pro Pinball Series' Soundbanks
On Sun, 3 May 2020 19:10:51 +0200 "Michael Niedermayer" wrote: > > > just tried, and as expected this doesnt work > > > > > > ./ffmpeg -i pinball/ie74.5C -map 0 test.nut > > > ... > > > Press [q] to stop, [?] for help > > > Too many packets buffered for output stream 0:1. > > > [libvorbis @ 0x557f49f3da40] 16 frames left in the queue on > > > closing [libvorbis @ 0x557f49f3f340] 14 frames left in the queue > > > on closing Conversion failed! > > > > > > > Interesting... that worked for me :/ > > > > ./ffmpeg -y -i pp/ie74.5C -map 0 test.nut > > ... > > [nut @ 0x55615988d700] Multiple keyframes with same PTS > > Last message repeated 5 times > > size= 632kB time=00:00:06.37 bitrate= 812.2kbits/s speed=59.8x > > video:0kB audio:630kB subtitle:0kB other streams:0kB global > > headers:0kB muxing overhead: 0.366753% > > Interresting, but the problem with 100% uninterleaved streams remains > applications will have issues with this, and the more the longer > these are > Yeah, I was able to reproduce this with a longer file. Have fixed it by reading packets from the streams in a round-robin manner. A bit nasty, but I don't see any nicer way of doing it. Zane ___ 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] avformat/mxfdec: reindent code
From: Limin Wang Signed-off-by: Limin Wang --- libavformat/mxfdec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index fdd0dd2..a60bdfe 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -362,8 +362,9 @@ static void mxf_free_metadataset(MXFMetadataSet **ctx, int freectx) default: break; } -if (freectx) -av_freep(ctx); +if (freectx) { +av_freep(ctx); +} } static int64_t klv_decode_ber_length(AVIOContext *pb) -- 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 v12] avformat: add demuxer for Pro Pinball Series' Soundbanks
Adds support for the soundbank files used by the Pro Pinball series of games. v12: [9] - Read packets in a round-robin fashion to avoid "Too many packets buffered" errors. v11: [8] - Change probe function to be all-or-nothing v10: [7] - Change while() to for(). v9: [6] - Rebase after codec_id.h changes - style fixes - Fix an uninitialised variable read v8: [5] - change "goto done" to a return + "goto fail" - Handle truncated files - Fix potential byte counter desync v7: [4] - Fix empty lines - Use av_malloc_array() instead of av_reallocp_array() - Replace multiple av_freep()'s with a goto - Minor comment cleanups - Ask for a sample if unexpected header values are found v6: [3] - fix tools/probetest failure v5: - add probe function - add flag #define's v4: [2] - fix adpcm index table type v3: [1] - fix potential memory leak if read_header() fails - fix a buffer overread - attempt seek before updating state - remove unneeded check - naming fixes v2: - Add sanity checks in header fields - Formatting and comment fixes - Change the struct names to match the files [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/258672.html [2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/258918.html [3]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259278.html [4]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/259864.html [5]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/259863.html [6]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/260706.html [7]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/260854.html [8]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/261497.html [9]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-May/262030.html Signed-off-by: Zane van Iperen --- Changelog| 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/pp_bnk.c | 292 +++ libavformat/version.h| 4 +- 5 files changed, 297 insertions(+), 2 deletions(-) create mode 100644 libavformat/pp_bnk.c diff --git a/Changelog b/Changelog index 9b3e34560f..aed70d8da5 100644 --- a/Changelog +++ b/Changelog @@ -64,6 +64,7 @@ version : - Support for muxing pcm and pgs in m2ts - Cunning Developments ADPCM decoder - asubboost filter +- Pro Pinball Series Soundbank demuxer version 4.2: diff --git a/libavformat/Makefile b/libavformat/Makefile index d4bed3c113..b744eb69b2 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -428,6 +428,7 @@ OBJS-$(CONFIG_PCM_VIDC_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_VIDC_MUXER)+= pcmenc.o rawenc.o OBJS-$(CONFIG_PJS_DEMUXER) += pjsdec.o subtitles.o OBJS-$(CONFIG_PMP_DEMUXER) += pmpdec.o +OBJS-$(CONFIG_PP_BNK_DEMUXER)+= pp_bnk.o OBJS-$(CONFIG_PVA_DEMUXER) += pva.o OBJS-$(CONFIG_PVF_DEMUXER) += pvfdec.o pcm.o OBJS-$(CONFIG_QCP_DEMUXER) += qcp.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 39d2c352f5..3919c9e4c1 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -341,6 +341,7 @@ extern AVInputFormat ff_pcm_u8_demuxer; extern AVOutputFormat ff_pcm_u8_muxer; extern AVInputFormat ff_pjs_demuxer; extern AVInputFormat ff_pmp_demuxer; +extern AVInputFormat ff_pp_bnk_demuxer; extern AVOutputFormat ff_psp_muxer; extern AVInputFormat ff_pva_demuxer; extern AVInputFormat ff_pvf_demuxer; diff --git a/libavformat/pp_bnk.c b/libavformat/pp_bnk.c new file mode 100644 index 00..69f0b90bb3 --- /dev/null +++ b/libavformat/pp_bnk.c @@ -0,0 +1,292 @@ +/* + * Pro Pinball Series Soundbank (44c, 22c, 11c, 5c) demuxer. + * + * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include "avformat.h" +#include "internal.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/avassert.h" +#include "libavutil/internal.h" + +#define PP_BNK_MAX_READ_SIZE4096 +#define PP_BNK_FILE_HEADER_SIZE 20 +#define PP_BNK_TRACK_SIZE 20 + +typedef struct PPBnkHeader { +uint32_tbank_id;/*< Bank ID, useless for our purposes. */ +uint32_tsa
Re: [FFmpeg-devel] [PATCH 1/5] avcodec/v4l2_m2m_enc: reindent code
On Thu, Apr 30, 2020 at 11:47:11AM -0400, Andriy Gelman wrote: > On Thu, 30. Apr 20:59, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavcodec/v4l2_m2m_enc.c | 20 ++-- > > 1 file changed, 10 insertions(+), 10 deletions(-) > > > > diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c > > index 8454e2326c..98b93c61af 100644 > > --- a/libavcodec/v4l2_m2m_enc.c > > +++ b/libavcodec/v4l2_m2m_enc.c > > @@ -204,11 +204,11 @@ static int v4l2_prepare_encoder(V4L2m2mContext *s) > > switch (avctx->codec_id) { > > case AV_CODEC_ID_H264: > > if (avctx->profile != FF_PROFILE_UNKNOWN) { > > -val = v4l2_h264_profile_from_ff(avctx->profile); > > -if (val < 0) > > -av_log(avctx, AV_LOG_WARNING, "h264 profile not found\n"); > > -else > > -v4l2_set_ext_ctrl(s, MPEG_CID(H264_PROFILE), val, "h264 > > profile", 1); > > +val = v4l2_h264_profile_from_ff(avctx->profile); > > +if (val < 0) > > +av_log(avctx, AV_LOG_WARNING, "h264 profile not found\n"); > > +else > > +v4l2_set_ext_ctrl(s, MPEG_CID(H264_PROFILE), val, "h264 > > profile", 1); > > } > > qmin_cid = MPEG_CID(H264_MIN_QP); > > qmax_cid = MPEG_CID(H264_MAX_QP); > > @@ -217,11 +217,11 @@ static int v4l2_prepare_encoder(V4L2m2mContext *s) > > break; > > case AV_CODEC_ID_MPEG4: > > if (avctx->profile != FF_PROFILE_UNKNOWN) { > > -val = v4l2_mpeg4_profile_from_ff(avctx->profile); > > -if (val < 0) > > -av_log(avctx, AV_LOG_WARNING, "mpeg4 profile not found\n"); > > -else > > -v4l2_set_ext_ctrl(s, MPEG_CID(MPEG4_PROFILE), val, "mpeg4 > > profile", 1); > > +val = v4l2_mpeg4_profile_from_ff(avctx->profile); > > +if (val < 0) > > +av_log(avctx, AV_LOG_WARNING, "mpeg4 profile not found\n"); > > +else > > +v4l2_set_ext_ctrl(s, MPEG_CID(MPEG4_PROFILE), val, "mpeg4 > > profile", 1); > > } > > qmin_cid = MPEG_CID(MPEG4_MIN_QP); > > qmax_cid = MPEG_CID(MPEG4_MAX_QP); > > lgtm will apply the rest of patchset #1,#2,#5 tomorrow if no more comments. > > Thanks, > -- > Andriy -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v1] avfilter/src_movie: Fix the loop function of dynamic logo
On Sun, May 03, 2020 at 07:10:07PM +0200, Marton Balint wrote: > > > On Sun, 3 May 2020, lance.lmw...@gmail.com wrote: > > > On Tue, Mar 17, 2020 at 06:55:00PM +0800, lance.lmw...@gmail.com wrote: > > > From: Limin Wang > > > > > > The following command will attempt to create the input and overlay test > > > sequence for you. > > > ./ffmpeg -f lavfi -i color=white:duration=100:r=25:size=1280x720 > > > input.mkv > > > ./ffmpeg -f lavfi -i "testsrc=duration=5:size=320x240:rate=25" overlay.mkv > > > > > > Please try with below command and compare the final output. > > > ./ffmpeg -y -filter_complex > > > "movie=./input.mkv,setpts=PTS-STARTPTS[main];movie=./overlay.mkv:loop=5,setpts=PTS-STARTPTS[overlay];[main][overlay]overlay=10:10: > > > enable='between(t,0,25)" test.mkv > > > > > > Without the patch applied, the overlay will repeat the last frame in > > > overlay.mkv after the first loop. > > Why? I haven't clear about the question yet, if you try to insert a dynamic logo repeatly, without the patch, the dynamic logo will not overlay repeatly. > > Thanks, > Marton > > > > > > > Signed-off-by: Limin Wang > > > --- > > > libavfilter/src_movie.c | 6 ++ > > > 1 file changed, 6 insertions(+) > > > > > > diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c > > > index 79423a8..2327046 100644 > > > --- a/libavfilter/src_movie.c > > > +++ b/libavfilter/src_movie.c > > > @@ -68,6 +68,8 @@ typedef struct MovieContext { > > > int loop_count; > > > int64_t discontinuity_threshold; > > > int64_t ts_offset; > > > +int64_t last_pts; > > > +int64_t last_loop_pts; > > > > > > AVFormatContext *format_ctx; > > > int eof; > > > @@ -455,6 +457,7 @@ static int rewind_file(AVFilterContext *ctx) > > > movie->st[i].done = 0; > > > } > > > movie->eof = 0; > > > +movie->last_loop_pts = movie->last_pts; > > > return 0; > > > } > > > > > > @@ -565,6 +568,8 @@ static int movie_push_frame(AVFilterContext *ctx, > > > unsigned out_id) > > > if (frame->pts != AV_NOPTS_VALUE) { > > > if (movie->ts_offset) > > > frame->pts += av_rescale_q_rnd(movie->ts_offset, > > > AV_TIME_BASE_Q, outlink->time_base, AV_ROUND_UP); > > > +if (movie->last_loop_pts) > > > +frame->pts += movie->last_loop_pts; > > > if (st->discontinuity_threshold) { > > > if (st->last_pts != AV_NOPTS_VALUE) { > > > int64_t diff = frame->pts - st->last_pts; > > > @@ -575,6 +580,7 @@ static int movie_push_frame(AVFilterContext *ctx, > > > unsigned out_id) > > > } > > > } > > > } > > > +movie->last_pts = > > > st->last_pts = frame->pts; > > > } > > > ff_dlog(ctx, "movie_push_frame(): file:'%s' %s\n", movie->file_name, > > > -- > > > 2.9.5 > > > > > > > ping > > > > -- > > 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 mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/prores_metadata_bsf: Use AVCOL_TRC_NB - 1 for the valid max range
On Mon, May 04, 2020 at 05:50:32AM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Report by Marton after commit. > > Reviewed-by: Marton Balint > Signed-off-by: Limin Wang > --- > libavcodec/prores_metadata_bsf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/prores_metadata_bsf.c > b/libavcodec/prores_metadata_bsf.c > index 8bfcb50..7cc2320 100644 > --- a/libavcodec/prores_metadata_bsf.c > +++ b/libavcodec/prores_metadata_bsf.c > @@ -140,7 +140,7 @@ static const AVOption options[] = { > {"smpte431",NULL, 0, AV_OPT_TYPE_CONST, > {.i64=AVCOL_PRI_SMPTE431}, INT_MIN, INT_MAX, FLAGS, "color_primaries"}, > {"smpte432",NULL, 0, AV_OPT_TYPE_CONST, > {.i64=AVCOL_PRI_SMPTE432}, INT_MIN, INT_MAX, FLAGS, "color_primaries"}, > > -{"color_trc", "select color transfer", OFFSET(transfer_characteristics), > AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_TRC_NB, FLAGS, "color_trc"}, > +{"color_trc", "select color transfer", OFFSET(transfer_characteristics), > AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_TRC_NB - 1, FLAGS, "color_trc"}, > {"auto", "keep the same color transfer", 0, AV_OPT_TYPE_CONST, > {.i64=-1}, INT_MIN, INT_MAX, FLAGS, > "color_trc"}, > {"unknown",NULL, 0, AV_OPT_TYPE_CONST, > {.i64=0},INT_MIN, INT_MAX, FLAGS, > "color_trc"}, > {"bt709", NULL, 0, AV_OPT_TYPE_CONST, > {.i64=AVCOL_TRC_BT709}, INT_MIN, INT_MAX, FLAGS, > "color_trc"}, > -- > 1.8.3.1 > will apply tomorrow. -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v12] avformat: add demuxer for Pro Pinball Series' Soundbanks
On Mon, 04 May 2020 13:02:14 + "Zane van Iperen" wrote: > Adds support for the soundbank files used by the Pro Pinball series > of games. Please disregard, I sent the wrong commit. Zane ___ 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] avdevice/v4l2enc: Allow writing non-rawvideos to v4l2
On Sun, Apr 26, 2020 at 11:26 PM David Manouchehri wrote: > > Resubmit of a previous patch, not sure why the diff didn't come through. > ___ > > @@ -56,7 +55,13 @@ static av_cold int write_header(AVFormatContext *s1) > > par = s1->streams[0]->codecpar; > > -v4l2_pixfmt = ff_fmt_ff2v4l(par->format, AV_CODEC_ID_RAWVIDEO); > +if(s1->streams[0]->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) { > +v4l2_pixfmt = ff_fmt_ff2v4l(par->format, AV_CODEC_ID_RAWVIDEO); > +} > +else { > +v4l2_pixfmt = ff_fmt_ff2v4l(AV_PIX_FMT_NONE, > s1->streams[0]->codecpar->codec_id); > +} > + Hi, A small nit. Wouldn't the variable `par` be usable there that was just created right on top of this if/else structure ? A la `par->codec_id` instead of poking at s1->streams[0] again? Otherwise looks good to me, linked this today on IRC as someone needed to test a v4l2 device they were developing with MJPEG. Didn't work, but that could be due to our MJPEG encoder adding all the metadata headers etc into the bit stream. Best regards, 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 v13] avformat: add demuxer for Pro Pinball Series' Soundbanks
Adds support for the soundbank files used by the Pro Pinball series of games. v13: - Increment current_track after reading a packet. v12: [9] - Read packets in a round-robin fashion to avoid "Too many packets buffered" errors. v11: [8] - Change probe function to be all-or-nothing v10: [7] - Change while() to for(). v9: [6] - Rebase after codec_id.h changes - style fixes - Fix an uninitialised variable read v8: [5] - change "goto done" to a return + "goto fail" - Handle truncated files - Fix potential byte counter desync v7: [4] - Fix empty lines - Use av_malloc_array() instead of av_reallocp_array() - Replace multiple av_freep()'s with a goto - Minor comment cleanups - Ask for a sample if unexpected header values are found v6: [3] - fix tools/probetest failure v5: - add probe function - add flag #define's v4: [2] - fix adpcm index table type v3: [1] - fix potential memory leak if read_header() fails - fix a buffer overread - attempt seek before updating state - remove unneeded check - naming fixes v2: - Add sanity checks in header fields - Formatting and comment fixes - Change the struct names to match the files [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/258672.html [2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/258918.html [3]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259278.html [4]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/259864.html [5]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/259863.html [6]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/260706.html [7]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/260854.html [8]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/261497.html [9]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-May/262030.html Signed-off-by: Zane van Iperen --- Changelog| 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/pp_bnk.c | 292 +++ libavformat/version.h| 4 +- 5 files changed, 297 insertions(+), 2 deletions(-) create mode 100644 libavformat/pp_bnk.c diff --git a/Changelog b/Changelog index 9b3e34560f..aed70d8da5 100644 --- a/Changelog +++ b/Changelog @@ -64,6 +64,7 @@ version : - Support for muxing pcm and pgs in m2ts - Cunning Developments ADPCM decoder - asubboost filter +- Pro Pinball Series Soundbank demuxer version 4.2: diff --git a/libavformat/Makefile b/libavformat/Makefile index d4bed3c113..b744eb69b2 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -428,6 +428,7 @@ OBJS-$(CONFIG_PCM_VIDC_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_VIDC_MUXER)+= pcmenc.o rawenc.o OBJS-$(CONFIG_PJS_DEMUXER) += pjsdec.o subtitles.o OBJS-$(CONFIG_PMP_DEMUXER) += pmpdec.o +OBJS-$(CONFIG_PP_BNK_DEMUXER)+= pp_bnk.o OBJS-$(CONFIG_PVA_DEMUXER) += pva.o OBJS-$(CONFIG_PVF_DEMUXER) += pvfdec.o pcm.o OBJS-$(CONFIG_QCP_DEMUXER) += qcp.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 39d2c352f5..3919c9e4c1 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -341,6 +341,7 @@ extern AVInputFormat ff_pcm_u8_demuxer; extern AVOutputFormat ff_pcm_u8_muxer; extern AVInputFormat ff_pjs_demuxer; extern AVInputFormat ff_pmp_demuxer; +extern AVInputFormat ff_pp_bnk_demuxer; extern AVOutputFormat ff_psp_muxer; extern AVInputFormat ff_pva_demuxer; extern AVInputFormat ff_pvf_demuxer; diff --git a/libavformat/pp_bnk.c b/libavformat/pp_bnk.c new file mode 100644 index 00..8364de1fd9 --- /dev/null +++ b/libavformat/pp_bnk.c @@ -0,0 +1,292 @@ +/* + * Pro Pinball Series Soundbank (44c, 22c, 11c, 5c) demuxer. + * + * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include "avformat.h" +#include "internal.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/avassert.h" +#include "libavutil/internal.h" + +#define PP_BNK_MAX_READ_SIZE4096 +#define PP_BNK_FILE_HEADER_SIZE 20 +#define PP_BNK_TRACK_SIZE 20 + +typedef struct PPBnkHeader { +uint32_tbank_id;/*< Ban
Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode: add FF_CODEC_CAP_INIT_CLEANUP caps for encoders
> From: ffmpeg-devel On Behalf Of > Timo Rothenpieler > Sent: Monday, May 4, 2020 13:20 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode: add > FF_CODEC_CAP_INIT_CLEANUP caps for encoders > > On 31.03.2020 17:34, Linjie Fu wrote: > > ff_vaapi_encode_close() is not enough to free the resources like cbs > > if initialization failure happens after codec->configure (except for > > vp8/vp9). > > > > We need to call avctx->codec->close() to deallocate, otherwise memory > > leak happens. > > > > Add FF_CODEC_CAP_INIT_CLEANUP for vaapi encoders and deallocate the > > resources at free_and_end inside avcodec_open2(). > > > > Signed-off-by: Linjie Fu > > Not my area of code, but the patch looks straight forward enough to my eyes. Thanks for review, and hope this could be merged soon. - Linjie ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avformat movenc add flag to disable silent limit on timescale
Indent Signed-off-by: vectronic --- libavformat/movenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 143b00063d..ec7e95e838 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -6462,8 +6462,8 @@ static int mov_init(AVFormatContext *s) } else { track->timescale = st->time_base.den; if (!(mov->flags & FF_MOV_FLAG_ALLOW_SMALL_TSCALE)) { -while(track->timescale < 1) -track->timescale *= 2; +while(track->timescale < 1) +track->timescale *= 2; av_log(s, AV_LOG_DEBUG, "track timescale was less than 1, it has been forced to %d\n", track->timescale); } } -- 2.24.2 (Apple Git-127) ___ 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] avformat movenc add flag to disable silent limit on timescale
Add a flag to allow user to disable the forcing of a track timescale to be greater than 1. Log a debug message if the timescale is forced to be greater than 1. Signed-off-by: vectronic --- libavformat/movenc.c | 4 libavformat/movenc.h | 1 + 2 files changed, 5 insertions(+) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 32e8109268..143b00063d 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -107,6 +107,7 @@ static const AVOption options[] = { { "wallclock", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = MOV_PRFT_SRC_WALLCLOCK}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM, "prft"}, { "pts", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = MOV_PRFT_SRC_PTS}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM, "prft"}, { "empty_hdlr_name", "write zero-length name string in hdlr atoms within mdia and minf atoms", offsetof(MOVMuxContext, empty_hdlr_name), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM}, +{ "allow_small_timescale", "Do not force track timescale to be >= 1", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_ALLOW_SMALL_TSCALE}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { NULL }, }; @@ -6460,8 +6461,11 @@ static int mov_init(AVFormatContext *s) av_log(s, AV_LOG_WARNING, "Warning: some tools, like mp4split, assume a timescale of 1000 for ISMV.\n"); } else { track->timescale = st->time_base.den; +if (!(mov->flags & FF_MOV_FLAG_ALLOW_SMALL_TSCALE)) { while(track->timescale < 1) track->timescale *= 2; +av_log(s, AV_LOG_DEBUG, "track timescale was less than 1, it has been forced to %d\n", track->timescale); +} } if (st->codecpar->width > 65535 || st->codecpar->height > 65535) { av_log(s, AV_LOG_ERROR, "Resolution %dx%d too large for mov/mp4\n", st->codecpar->width, st->codecpar->height); diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 997b2d61c0..f91cd3420f 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -261,6 +261,7 @@ typedef struct MOVMuxContext { #define FF_MOV_FLAG_SKIP_SIDX (1 << 21) #define FF_MOV_FLAG_CMAF (1 << 22) #define FF_MOV_FLAG_PREFER_ICC(1 << 23) +#define FF_MOV_FLAG_ALLOW_SMALL_TSCALE(1 << 24) int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt); -- 2.24.2 (Apple Git-127) ___ 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 0/2] avformat movenc add flag to allow disabling limit on timescale
I needed to encode to mov/mp4 with a timebase of 1/600 and the output was not as expected. I discovered the reason is a silent limiting of a track timebase added here: https://github.com/FFmpeg/FFmpeg/commit/b02493e47668e66757b72a7163476e590edfea3a The patch attached provides a new flag to disable the timebase limit, and in the case that the limit is applied, a debug message is logged to prevent future user confusion. vectronic (2): avformat movenc add flag to disable silent limit on timescale avformat movenc add flag to disable silent limit on timescale libavformat/movenc.c | 8 ++-- libavformat/movenc.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) -- 2.24.2 (Apple Git-127) ___ 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 0/2] avformat movenc add flag to allow disabling limit on timescale
On 04-05-2020 09:54 pm, vectronic wrote: I needed to encode to mov/mp4 with a timebase of 1/600 and the output was not as expected. What was the unexpected output? You can use video_track_timescale to set any custom scale. Gyan ___ 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] Use gcc/clang builtins for av_sat_(add|sub)_64_c if available.
Bump. I have 5 integer overflow fuzzing issues awaiting our resolution of this discussion. Thanks. - dale On Fri, May 1, 2020 at 2:53 PM Dale Curtis wrote: > On Fri, May 1, 2020 at 2:00 PM Carl Eugen Hoyos > wrote: > >> Am Fr., 1. Mai 2020 um 22:16 Uhr schrieb Dale Curtis < >> dalecur...@chromium.org>: >> > >> > On Fri, May 1, 2020 at 1:12 PM Carl Eugen Hoyos >> wrote: >> > >> > > Am Fr., 1. Mai 2020 um 22:06 Uhr schrieb James Almer < >> jamr...@gmail.com>: >> > > > Just make the check >> > > > >> > > > (AV_GCC_VERSION_AT_LEAST(5,1) || defined(__clang__)) && >> > > > !defined(__INTEL_COMPILER) >> > > >> > > And switch the conditions. >> > >> > Thanks. Done. >> >> Is there a reason why this doesn't use >> __has_builtin(__builtin_add_overflow) >> for clang? >> > > Yes, prior to clang 10 it didn't work properly: > https://clang.llvm.org/docs/LanguageExtensions.html#has-builtin > > - dale > > > ___ 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] [libavutil] Add saturated add/sub operations for int64_t.
Bump. I have 5 integer overflow fuzzing issues awaiting our resolution of this discussion. Thanks. - dale On Fri, May 1, 2020 at 1:13 PM Dale Curtis wrote: > On Fri, May 1, 2020 at 12:53 PM Michael Niedermayer > wrote: > >> On Thu, Apr 30, 2020 at 05:39:43PM -0700, Dale Curtis wrote: >> > On Thu, Apr 30, 2020 at 5:21 PM James Almer wrote: >> > >> > > On 4/30/2020 7:19 PM, Dale Curtis wrote: >> > > > Many places are using their own custom code for handling overflow >> > > > around timestamps or other int64_t values. There are enough of these >> > > > now that having some common saturated math functions seems sound. >> > > > >> > > > This adds implementations that just use the builtin functions for >> > > > recent gcc, clang when available or implements its own version for >> > > > older compilers. >> > > >> > > These look like 64 bit versions of av_sat_add32 and av_sat_sub32, from >> > > common.h, so you should probably add them there and rename them >> > > accordingly. >> > > >> > > >> > Ah! I was looking for those, but missed them. Thanks. Done. >> >> one disadvantage the av_sat* functions have is the lack of inexact >> detection >> >> In addition to av_sat* >> In situations where its better to fail than to clip, something that >> emulates what (+-Inf/)NaN is for float may make sense. >> That would allow to simply check after a computation if any inexactness >> occured >> >> Such a thing could be usefull in situations where a exact value or an >> error is wanted. >> >> > The __builtin functions provide exactly this API, we're just hiding it. I > could add something like: > int did_overflow = av_checked_sat_(add|sub)64(int64_t a, int64_t b, > int64_t* result) > > |result| would still satuate and thus av_sat_(add|sub)64 could use it > without checking the return value, but those which want to check and abort > could do so. This is similar to the API shape we expose in Chromium modulo > the fact we enforce an assert. > > - dale > > ___ 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] Use gcc/clang builtins for av_sat_(add|sub)_64_c if available.
On 5/4/2020 3:09 PM, Dale Curtis wrote: > Bump. I have 5 integer overflow fuzzing issues awaiting our resolution of > this discussion. Thanks. > > - dale What's the first version of clang with support for __builtin_*_overflow? Because with your patch as is (Checking only __clang__), it's very likely old clang builds could be broken. We have things like Clang 3 on FATE right now. Also, does clang-cl define __clang__ and these builtins? Because maybe we could remove that check and just keep the GCC + Intel one. The former should in theory cover Clang builds that are reportedly compatible with GCC >= 5.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 01/10] libavformat/nutenc: Remove redundant function parameter
calculate_checksum in put_packet() is always 1. Signed-off-by: Andreas Rheinhardt --- libavformat/nutenc.c | 25 +++-- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 1d48625815..44ee5d810a 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -299,13 +299,12 @@ static void put_s(AVIOContext *bc, int64_t val) ff_put_v(bc, 2 * FFABS(val) - (val > 0)); } -//FIXME remove calculate_checksum static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, - int calculate_checksum, uint64_t startcode) + uint64_t startcode) { uint8_t *dyn_buf = NULL; int dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf); -int forw_ptr = dyn_size + 4 * calculate_checksum; +int forw_ptr = dyn_size + 4; if (forw_ptr > 4096) ffio_init_checksum(bc, ff_crc04C11DB7_update, 0); @@ -314,11 +313,9 @@ static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, if (forw_ptr > 4096) avio_wl32(bc, ffio_get_checksum(bc)); -if (calculate_checksum) -ffio_init_checksum(bc, ff_crc04C11DB7_update, 0); +ffio_init_checksum(bc, ff_crc04C11DB7_update, 0); avio_write(bc, dyn_buf, dyn_size); -if (calculate_checksum) -avio_wl32(bc, ffio_get_checksum(bc)); +avio_wl32(bc, ffio_get_checksum(bc)); av_free(dyn_buf); } @@ -630,7 +627,7 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc) if (ret < 0) return ret; write_mainheader(nut, dyn_bc); -put_packet(nut, bc, dyn_bc, 1, MAIN_STARTCODE); +put_packet(nut, bc, dyn_bc, MAIN_STARTCODE); for (i = 0; i < nut->avf->nb_streams; i++) { ret = avio_open_dyn_buf(&dyn_bc); @@ -641,14 +638,14 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc) ffio_free_dyn_buf(&dyn_bc); return ret; } -put_packet(nut, bc, dyn_bc, 1, STREAM_STARTCODE); +put_packet(nut, bc, dyn_bc, STREAM_STARTCODE); } ret = avio_open_dyn_buf(&dyn_bc); if (ret < 0) return ret; write_globalinfo(nut, dyn_bc); -put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE); +put_packet(nut, bc, dyn_bc, INFO_STARTCODE); for (i = 0; i < nut->avf->nb_streams; i++) { ret = avio_open_dyn_buf(&dyn_bc); @@ -656,7 +653,7 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc) return ret; ret = write_streaminfo(nut, dyn_bc, i); if (ret > 0) -put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE); +put_packet(nut, bc, dyn_bc, INFO_STARTCODE); else { ffio_free_dyn_buf(&dyn_bc); if (ret < 0) @@ -673,7 +670,7 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc) ffio_free_dyn_buf(&dyn_bc); return ret; } -put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE); +put_packet(nut, bc, dyn_bc, INFO_STARTCODE); } nut->last_syncpoint_pos = INT_MIN; @@ -1022,7 +1019,7 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt) put_tt(nut, nus->time_base, dyn_bc, av_rescale_q(av_gettime(), AV_TIME_BASE_Q, *nus->time_base)); } -put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE); +put_packet(nut, bc, dyn_bc, SYNCPOINT_STARTCODE); if (nut->write_index) { if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0 /*unused*/, pkt->dts)) < 0) @@ -1175,7 +1172,7 @@ static int nut_write_trailer(AVFormatContext *s) if (ret >= 0) { av_assert1(nut->write_index); // sp_count should be 0 if no index is going to be written write_index(nut, dyn_bc); -put_packet(nut, bc, dyn_bc, 1, INDEX_STARTCODE); +put_packet(nut, bc, dyn_bc, INDEX_STARTCODE); } return 0; -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 02/10] avformat/nutenc: Reuse dynamic buffers when possible
NUT uses variable-length integers in order to for length fields. Therefore the NUT muxer often writes data into a dynamic buffer in order to get the length of it, then writes the length field using the fewest amount of bytes needed. To do this, a new dynamic buffer was opened, used and freed for each element which involves lots of allocations. This commit changes this: The dynamic buffers are now resetted and reused. Signed-off-by: Andreas Rheinhardt --- libavformat/nutenc.c | 24 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 44ee5d810a..6125429cc3 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -303,7 +303,7 @@ static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, uint64_t startcode) { uint8_t *dyn_buf = NULL; -int dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf); +int dyn_size = avio_get_dyn_buf(dyn_bc, &dyn_buf); int forw_ptr = dyn_size + 4; if (forw_ptr > 4096) @@ -317,7 +317,7 @@ static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, avio_write(bc, dyn_buf, dyn_size); avio_wl32(bc, ffio_get_checksum(bc)); -av_free(dyn_buf); +ffio_reset_dyn_buf(dyn_bc); } static void write_mainheader(NUTContext *nut, AVIOContext *bc) @@ -630,9 +630,6 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc) put_packet(nut, bc, dyn_bc, MAIN_STARTCODE); for (i = 0; i < nut->avf->nb_streams; i++) { -ret = avio_open_dyn_buf(&dyn_bc); -if (ret < 0) -return ret; ret = write_streamheader(avctx, dyn_bc, nut->avf->streams[i], i); if (ret < 0) { ffio_free_dyn_buf(&dyn_bc); @@ -641,30 +638,20 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc) put_packet(nut, bc, dyn_bc, STREAM_STARTCODE); } -ret = avio_open_dyn_buf(&dyn_bc); -if (ret < 0) -return ret; write_globalinfo(nut, dyn_bc); put_packet(nut, bc, dyn_bc, INFO_STARTCODE); for (i = 0; i < nut->avf->nb_streams; i++) { -ret = avio_open_dyn_buf(&dyn_bc); -if (ret < 0) -return ret; ret = write_streaminfo(nut, dyn_bc, i); if (ret > 0) put_packet(nut, bc, dyn_bc, INFO_STARTCODE); -else { +else if (ret < 0) { ffio_free_dyn_buf(&dyn_bc); -if (ret < 0) return ret; } } for (i = 0; i < nut->avf->nb_chapters; i++) { -ret = avio_open_dyn_buf(&dyn_bc); -if (ret < 0) -return ret; ret = write_chapter(nut, dyn_bc, i); if (ret < 0) { ffio_free_dyn_buf(&dyn_bc); @@ -675,6 +662,9 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc) nut->last_syncpoint_pos = INT_MIN; nut->header_count++; + +ffio_free_dyn_buf(&dyn_bc); + return 0; } @@ -1020,6 +1010,7 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt) av_rescale_q(av_gettime(), AV_TIME_BASE_Q, *nus->time_base)); } put_packet(nut, bc, dyn_bc, SYNCPOINT_STARTCODE); +ffio_free_dyn_buf(&dyn_bc); if (nut->write_index) { if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0 /*unused*/, pkt->dts)) < 0) @@ -1173,6 +1164,7 @@ static int nut_write_trailer(AVFormatContext *s) av_assert1(nut->write_index); // sp_count should be 0 if no index is going to be written write_index(nut, dyn_bc); put_packet(nut, bc, dyn_bc, INDEX_STARTCODE); +ffio_free_dyn_buf(&dyn_bc); } return 0; -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 04/10] avformat/aviobuf, nutenc: Move ff_puv_v, ff_get_v_length to nutenc.c
and make it static again. These functions have been moved from nutenc to aviobuf and internal.h in f8280ff4c00eeaa245085fa9691035203abd168c in order to use them in a forthcoming patch in utils.c. Said patch never happened, so this commit moves them back and makes them static, effectively reverting said commit as well as f8280ff4c00eeaa245085fa9691035203abd168c (which added the ff-prefix to these functions). Signed-off-by: Andreas Rheinhardt --- libavformat/aviobuf.c | 20 - libavformat/internal.h | 10 --- libavformat/nutenc.c | 172 - 3 files changed, 99 insertions(+), 103 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 85c01c938a..eb0387bdf7 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -432,26 +432,6 @@ PUT_STR16(be, 1) #undef PUT_STR16 -int ff_get_v_length(uint64_t val) -{ -int i = 1; - -while (val >>= 7) -i++; - -return i; -} - -void ff_put_v(AVIOContext *bc, uint64_t val) -{ -int i = ff_get_v_length(val); - -while (--i > 0) -avio_w8(bc, 128 | (uint8_t)(val >> (7*i))); - -avio_w8(bc, val & 127); -} - void avio_wl64(AVIOContext *s, uint64_t val) { avio_wl32(s, (uint32_t)(val & 0x)); diff --git a/libavformat/internal.h b/libavformat/internal.h index 6786b732ac..45a4149c5a 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -289,16 +289,6 @@ void ff_sdp_write_media(char *buff, int size, AVStream *st, int idx, int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt, AVFormatContext *src, int interleave); -/** - * Get the length in bytes which is needed to store val as v. - */ -int ff_get_v_length(uint64_t val); - -/** - * Put val using a variable number of bytes. - */ -void ff_put_v(AVIOContext *bc, uint64_t val); - /** * Read a whole line of text from AVIOContext. Stop reading after reaching * either a \\n, a \\0 or EOF. The returned string is always \\0-terminated, diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index c1606651fe..ca433038d4 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -277,11 +277,37 @@ static void build_frame_code(AVFormatContext *s) nut->frame_code['N'].flags = FLAG_INVALID; } +/** + * Get the length in bytes which is needed to store val as v. + */ +static int get_v_length(uint64_t val) +{ +int i = 1; + +while (val >>= 7) +i++; + +return i; +} + +/** + * Put val using a variable number of bytes. + */ +static void put_v(AVIOContext *bc, uint64_t val) +{ +int i = get_v_length(val); + +while (--i > 0) +avio_w8(bc, 128 | (uint8_t)(val >> (7*i))); + +avio_w8(bc, val & 127); +} + static void put_tt(NUTContext *nut, AVRational *time_base, AVIOContext *bc, uint64_t val) { val *= nut->time_base_count; val += time_base - nut->time_base; -ff_put_v(bc, val); +put_v(bc, val); } /** * Store a string as vb. @@ -290,13 +316,13 @@ static void put_str(AVIOContext *bc, const char *string) { size_t len = strlen(string); -ff_put_v(bc, len); +put_v(bc, len); avio_write(bc, string, len); } static void put_s(AVIOContext *bc, int64_t val) { -ff_put_v(bc, 2 * FFABS(val) - (val > 0)); +put_v(bc, 2 * FFABS(val) - (val > 0)); } static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, @@ -309,7 +335,7 @@ static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, if (forw_ptr > 4096) ffio_init_checksum(bc, ff_crc04C11DB7_update, 0); avio_wb64(bc, startcode); -ff_put_v(bc, forw_ptr); +put_v(bc, forw_ptr); if (forw_ptr > 4096) avio_wl32(bc, ffio_get_checksum(bc)); @@ -326,16 +352,16 @@ static void write_mainheader(NUTContext *nut, AVIOContext *bc) tmp_head_idx; int64_t tmp_match; -ff_put_v(bc, nut->version); +put_v(bc, nut->version); if (nut->version > 3) -ff_put_v(bc, nut->minor_version = 1); -ff_put_v(bc, nut->avf->nb_streams); -ff_put_v(bc, nut->max_distance); -ff_put_v(bc, nut->time_base_count); +put_v(bc, nut->minor_version = 1); +put_v(bc, nut->avf->nb_streams); +put_v(bc, nut->max_distance); +put_v(bc, nut->time_base_count); for (i = 0; i < nut->time_base_count; i++) { -ff_put_v(bc, nut->time_base[i].num); -ff_put_v(bc, nut->time_base[i].den); +put_v(bc, nut->time_base[i].num); +put_v(bc, nut->time_base[i].den); } tmp_pts = 0; @@ -379,25 +405,25 @@ static void write_mainheader(NUTContext *nut, AVIOContext *bc) if (j != tmp_mul - tmp_size) tmp_fields = 6; -ff_put_v(bc, tmp_flags); -ff_put_v(bc, tmp_fields); +put_v(bc, tmp_flags); +put_v(bc, tmp_fields); if (tmp_fields > 0) put_s(bc, tmp_pts); -if (tmp_fields > 1) ff_put_v(bc, tmp_mul); -if (tmp_fields > 2) ff_p
[FFmpeg-devel] [PATCH 10/10] avformat/nutenc: Don't allocate array with zero entries
Allocating an array with zero entries is both unnecessary as well as potentially troublesome because the behaviour in this case is not really well defined. Signed-off-by: Andreas Rheinhardt --- libavformat/nutenc.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 6df7dfe210..5071278835 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -711,11 +711,15 @@ static int nut_write_header(AVFormatContext *s) } nut->stream = av_calloc(s->nb_streams, sizeof(*nut->stream )); -nut->chapter = av_calloc(s->nb_chapters, sizeof(*nut->chapter)); nut->time_base= av_calloc(s->nb_streams + s->nb_chapters, sizeof(*nut->time_base)); -if (!nut->stream || !nut->chapter || !nut->time_base) +if (!nut->stream || !nut->time_base) return AVERROR(ENOMEM); +if (s->nb_chapters) { +nut->chapter = av_calloc(s->nb_chapters, sizeof(*nut->chapter)); +if (!nut->chapter) +return AVERROR(ENOMEM); +} for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 03/10] avformat/nutenc: Add goto fail in nut_write_headers()
It allows to combine several ffio_free_dyn_buf(). Signed-off-by: Andreas Rheinhardt --- libavformat/nutenc.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 6125429cc3..c1606651fe 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -632,8 +632,7 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc) for (i = 0; i < nut->avf->nb_streams; i++) { ret = write_streamheader(avctx, dyn_bc, nut->avf->streams[i], i); if (ret < 0) { -ffio_free_dyn_buf(&dyn_bc); -return ret; +goto fail; } put_packet(nut, bc, dyn_bc, STREAM_STARTCODE); } @@ -646,16 +645,14 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc) if (ret > 0) put_packet(nut, bc, dyn_bc, INFO_STARTCODE); else if (ret < 0) { -ffio_free_dyn_buf(&dyn_bc); -return ret; +goto fail; } } for (i = 0; i < nut->avf->nb_chapters; i++) { ret = write_chapter(nut, dyn_bc, i); if (ret < 0) { -ffio_free_dyn_buf(&dyn_bc); -return ret; +goto fail; } put_packet(nut, bc, dyn_bc, INFO_STARTCODE); } @@ -663,9 +660,11 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc) nut->last_syncpoint_pos = INT_MIN; nut->header_count++; +ret = 0; +fail: ffio_free_dyn_buf(&dyn_bc); -return 0; +return ret; } static int nut_write_header(AVFormatContext *s) -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 05/10] avformat/nutenc: Create put_* functions by macro
It allows to add analogous functions using e.g. the bytestream API instead of using an AVIOContext. Signed-off-by: Andreas Rheinhardt --- libavformat/nutenc.c | 49 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index ca433038d4..a75d9282fe 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -290,25 +290,35 @@ static int get_v_length(uint64_t val) return i; } -/** - * Put val using a variable number of bytes. - */ -static void put_v(AVIOContext *bc, uint64_t val) -{ -int i = get_v_length(val); - -while (--i > 0) -avio_w8(bc, 128 | (uint8_t)(val >> (7*i))); - -avio_w8(bc, val & 127); +#define PUT_FUNCTIONS(type, write, suffix) \ +/**\ + * Put val using a variable number of bytes. \ + */\ +static void put_v##suffix(type dst, uint64_t val) \ +{ \ +int i = get_v_length(val); \ + \ +while (--i > 0)\ +write(dst, 128 | (uint8_t)(val >> (7*i))); \ + \ +write(dst, val & 127); \ +} \ + \ +static void put_tt##suffix(NUTContext *nut, AVRational *time_base, \ + type dst, uint64_t val) \ +{ \ +val *= nut->time_base_count; \ +val += time_base - nut->time_base; \ +put_v##suffix(dst, val); \ +} \ + \ +static void put_s##suffix(type dst, int64_t val) \ +{ \ +put_v##suffix(dst, 2 * FFABS(val) - (val > 0));\ } -static void put_tt(NUTContext *nut, AVRational *time_base, AVIOContext *bc, uint64_t val) -{ -val *= nut->time_base_count; -val += time_base - nut->time_base; -put_v(bc, val); -} +PUT_FUNCTIONS(AVIOContext *, avio_w8,) + /** * Store a string as vb. */ @@ -320,11 +330,6 @@ static void put_str(AVIOContext *bc, const char *string) avio_write(bc, string, len); } -static void put_s(AVIOContext *bc, int64_t val) -{ -put_v(bc, 2 * FFABS(val) - (val > 0)); -} - static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, uint64_t startcode) { -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 09/10] avformat/nutenc: Write size into right dynamic buffer
Signed-off-by: Andreas Rheinhardt --- libavformat/nutenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 5735055d19..6df7dfe210 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -902,7 +902,7 @@ static int write_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int put_str(dyn_bc, "ChannelLayout"); put_s(dyn_bc, -2); put_str(dyn_bc, "u64"); -put_v(bc, 8); +put_v(dyn_bc, 8); avio_write(dyn_bc, data, 8); data+=8; sm_data_count++; } -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 08/10] avformat/nutenc: Cosmetics
Mainly reindentation. Signed-off-by: Andreas Rheinhardt --- libavformat/nutenc.c | 42 ++ 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index ab44214efd..5735055d19 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -332,7 +332,7 @@ static void put_str(AVIOContext *bc, const char *string) } static int put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, - const uint8_t *prelude, int prelude_size, uint64_t startcode) + const uint8_t *prelude, int prelude_size, uint64_t startcode) { uint8_t *dyn_buf = NULL; int dyn_size = dyn_bc ? avio_get_dyn_buf(dyn_bc, &dyn_buf) : 0; @@ -583,7 +583,8 @@ static void write_chapter(NUTContext *nut, AVIOContext *bc, int id, *prelude_size = ptr - prelude; } -static int write_index(NUTContext *nut, AVIOContext *bc) { +static int write_index(NUTContext *nut, AVIOContext *bc) +{ int i; Syncpoint dummy= { .pos= 0 }; Syncpoint *next_node[2] = { NULL }; @@ -654,9 +655,8 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc) for (i = 0; i < nut->avf->nb_streams; i++) { ret = write_streamheader(avctx, dyn_bc, nut->avf->streams[i], i); -if (ret < 0) { +if (ret < 0) goto fail; -} ret = put_packet(nut, bc, dyn_bc, NULL, 0, STREAM_STARTCODE); if (ret < 0) goto fail; @@ -668,8 +668,7 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc) goto fail; for (i = 0; i < nut->avf->nb_streams; i++) { -ret = write_streaminfo(nut, dyn_bc, i, prelude, &prelude_size); -if (!ret) +if (!write_streaminfo(nut, dyn_bc, i, prelude, &prelude_size)) continue; ret = put_packet(nut, bc, dyn_bc, prelude, prelude_size, INFO_STARTCODE); if (ret < 0) @@ -1035,21 +1034,24 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt) put_packet(nut, bc, NULL, syncpoint, ptr - syncpoint, SYNCPOINT_STARTCODE); if (nut->write_index) { -if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0 /*unused*/, pkt->dts)) < 0) -goto fail; - -if ((1ll<<60) % nut->sp_count == 0) -for (i=0; inb_streams; i++) { -int j; -StreamContext *nus = &nut->stream[i]; -av_reallocp_array(&nus->keyframe_pts, 2*nut->sp_count, sizeof(*nus->keyframe_pts)); -if (!nus->keyframe_pts) { -ret = AVERROR(ENOMEM); -goto fail; +if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, + 0 /*unused*/, pkt->dts)) < 0) +goto fail; + +if ((1ll << 60) % nut->sp_count == 0) +for (i = 0; i < s->nb_streams; i++) { +int j; +StreamContext *nus = &nut->stream[i]; +av_reallocp_array(&nus->keyframe_pts, 2*nut->sp_count, + sizeof(*nus->keyframe_pts)); +if (!nus->keyframe_pts) { +ret = AVERROR(ENOMEM); +goto fail; +} +for (j = nut->sp_count == 1 ? 0 : nut->sp_count; + j < 2 * nut->sp_count; j++) +nus->keyframe_pts[j] = AV_NOPTS_VALUE; } -for (j=nut->sp_count == 1 ? 0 : nut->sp_count; j<2*nut->sp_count; j++) -nus->keyframe_pts[j] = AV_NOPTS_VALUE; -} } } av_assert0(nus->last_pts != AV_NOPTS_VALUE); -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 06/10] avformat/nutenc: Avoid intermediate dynamic buffers
NUT uses variable length fields and in order to write the length fields of its various elements on the lowest amount of bytes possible, the NUT muxer uses dynamic buffers to assemble the elements in memory before writing them. Several of these elements had a small prelude containing the amount of subentries of this element and because this amount is also variable-length coded, the muxer used a dynamic buffer for the entries, then wrote the prelude in the dynamic buffer (destined for the whole element) and then copied the content of the dynamic buffer for the entries to the other dynamic buffer. This commit changes this: Given that this prelude is always very small (<= 50 bytes), it is now written into a separate buffer on the stack; put_packet(), the function that actually outputs the data, now receives both this prelude as well as the dynamic buffer containing the other contents and treats it as if it were one buffer. Furthermore, up until now writing a syncpoint also used a dynamic buffer, although its size is always very small (<= 30 bytes). In this case, the dynamic buffer could be completely eliminated: The whole element is treated as a prelude. Signed-off-by: Andreas Rheinhardt --- libavformat/nutenc.c | 149 ++- 1 file changed, 63 insertions(+), 86 deletions(-) diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index a75d9282fe..404a265597 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -318,6 +318,7 @@ static void put_s##suffix(type dst, int64_t val) \ } PUT_FUNCTIONS(AVIOContext *, avio_w8,) +PUT_FUNCTIONS(uint8_t **, bytestream_put_byte, _buf) /** * Store a string as vb. @@ -331,11 +332,11 @@ static void put_str(AVIOContext *bc, const char *string) } static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, - uint64_t startcode) + const uint8_t *prelude, int prelude_size, uint64_t startcode) { uint8_t *dyn_buf = NULL; -int dyn_size = avio_get_dyn_buf(dyn_bc, &dyn_buf); -int forw_ptr = dyn_size + 4; +int dyn_size = dyn_bc ? avio_get_dyn_buf(dyn_bc, &dyn_buf) : 0; +unsigned forw_ptr = prelude_size + dyn_size + 4; if (forw_ptr > 4096) ffio_init_checksum(bc, ff_crc04C11DB7_update, 0); @@ -345,10 +346,14 @@ static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, avio_wl32(bc, ffio_get_checksum(bc)); ffio_init_checksum(bc, ff_crc04C11DB7_update, 0); -avio_write(bc, dyn_buf, dyn_size); +if (prelude_size) +avio_write(bc, prelude, prelude_size); +if (dyn_bc) { +avio_write(bc, dyn_buf, dyn_size); +ffio_reset_dyn_buf(dyn_bc); +} avio_wl32(bc, ffio_get_checksum(bc)); -ffio_reset_dyn_buf(dyn_bc); } static void write_mainheader(NUTContext *nut, AVIOContext *bc) @@ -496,50 +501,41 @@ static int add_info(AVIOContext *bc, const char *type, const char *value) return 1; } -static int write_globalinfo(NUTContext *nut, AVIOContext *bc) +static void write_globalinfo(NUTContext *nut, AVIOContext *bc, + uint8_t prelude[50], int *prelude_size) { AVFormatContext *s = nut->avf; AVDictionaryEntry *t = NULL; -AVIOContext *dyn_bc; -uint8_t *dyn_buf = NULL; -int count= 0, dyn_size; -int ret = avio_open_dyn_buf(&dyn_bc); -if (ret < 0) -return ret; +uint8_t *ptr = prelude; +int count= 0; ff_standardize_creation_time(s); while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) -count += add_info(dyn_bc, t->key, t->value); +count += add_info(bc, t->key, t->value); -put_v(bc, 0); //stream_if_plus1 -put_v(bc, 0); //chapter_id -put_v(bc, 0); //timestamp_start -put_v(bc, 0); //length +put_v_buf(&ptr, 0); //stream_if_plus1 +put_v_buf(&ptr, 0); //chapter_id +put_v_buf(&ptr, 0); //timestamp_start +put_v_buf(&ptr, 0); //length -put_v(bc, count); - -dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf); -avio_write(bc, dyn_buf, dyn_size); -av_free(dyn_buf); -return 0; +put_v_buf(&ptr, count); +*prelude_size = ptr - prelude; } -static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id) { +static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id, +uint8_t prelude[50], int *prelude_size) +{ AVFormatContext *s= nut->avf; AVStream* st = s->streams[stream_id]; AVDictionaryEntry *t = NULL; -AVIOContext *dyn_bc; -uint8_t *dyn_buf=NULL; -int count=0, dyn_size, i; -int ret = avio_open_dyn_buf(&dyn_bc); -if (ret < 0) -return ret; +uint8_t *ptr = prelude; +int count = 0, i; while ((t = av_dict_get(st->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) -count += add_info(dyn_bc, t->key, t->value); +count += add_in
[FFmpeg-devel] [PATCH 07/10] avformat/nutenc: Check allocations implicit in dynamic buffers
For nut_write_trailer() this includes actually returning such errors. Signed-off-by: Andreas Rheinhardt --- libavformat/nutenc.c | 33 - 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 404a265597..ab44214efd 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -331,13 +331,16 @@ static void put_str(AVIOContext *bc, const char *string) avio_write(bc, string, len); } -static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, +static int put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, const uint8_t *prelude, int prelude_size, uint64_t startcode) { uint8_t *dyn_buf = NULL; int dyn_size = dyn_bc ? avio_get_dyn_buf(dyn_bc, &dyn_buf) : 0; unsigned forw_ptr = prelude_size + dyn_size + 4; +if (dyn_bc && dyn_bc->error < 0) +return dyn_bc->error; + if (forw_ptr > 4096) ffio_init_checksum(bc, ff_crc04C11DB7_update, 0); avio_wb64(bc, startcode); @@ -354,6 +357,7 @@ static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, } avio_wl32(bc, ffio_get_checksum(bc)); +return 0; } static void write_mainheader(NUTContext *nut, AVIOContext *bc) @@ -644,28 +648,39 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc) if (ret < 0) return ret; write_mainheader(nut, dyn_bc); -put_packet(nut, bc, dyn_bc, NULL, 0, MAIN_STARTCODE); +ret = put_packet(nut, bc, dyn_bc, NULL, 0, MAIN_STARTCODE); +if (ret < 0) +goto fail; for (i = 0; i < nut->avf->nb_streams; i++) { ret = write_streamheader(avctx, dyn_bc, nut->avf->streams[i], i); if (ret < 0) { goto fail; } -put_packet(nut, bc, dyn_bc, NULL, 0, STREAM_STARTCODE); +ret = put_packet(nut, bc, dyn_bc, NULL, 0, STREAM_STARTCODE); +if (ret < 0) +goto fail; } write_globalinfo(nut, dyn_bc, prelude, &prelude_size); -put_packet(nut, bc, dyn_bc, prelude, prelude_size, INFO_STARTCODE); +ret = put_packet(nut, bc, dyn_bc, prelude, prelude_size, INFO_STARTCODE); +if (ret < 0) +goto fail; for (i = 0; i < nut->avf->nb_streams; i++) { ret = write_streaminfo(nut, dyn_bc, i, prelude, &prelude_size); -if (ret > 0) -put_packet(nut, bc, dyn_bc, prelude, prelude_size, INFO_STARTCODE); +if (!ret) +continue; +ret = put_packet(nut, bc, dyn_bc, prelude, prelude_size, INFO_STARTCODE); +if (ret < 0) +goto fail; } for (i = 0; i < nut->avf->nb_chapters; i++) { write_chapter(nut, dyn_bc, i, prelude, &prelude_size); -put_packet(nut, bc, dyn_bc, prelude, prelude_size, INFO_STARTCODE); +ret = put_packet(nut, bc, dyn_bc, prelude, prelude_size, INFO_STARTCODE); +if (ret < 0) +goto fail; } nut->last_syncpoint_pos = INT_MIN; @@ -1170,11 +1185,11 @@ static int nut_write_trailer(AVFormatContext *s) if (ret >= 0) { av_assert1(nut->write_index); // sp_count should be 0 if no index is going to be written write_index(nut, dyn_bc); -put_packet(nut, bc, dyn_bc, NULL, 0, INDEX_STARTCODE); +ret = put_packet(nut, bc, dyn_bc, NULL, 0, INDEX_STARTCODE); ffio_free_dyn_buf(&dyn_bc); } -return 0; +return ret; } static void nut_write_deinit(AVFormatContext *s) -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [GSOC] FLIF16 Decoder (and Encoder)
On 5/4/2020 3:26 PM, Anamitra Ghorui wrote: > Hello, > > I have a question regerding the internal decoding/encoding API. There seems > to be two functions that may be alternatively called, on the basis of whether > they are defined or not, both defined in the AVCodec struct: > 1. decode() > 2. receive_frame() > > From the comments above the definition of receive_frame(): > "Decode API with decoupled packet/frame dataflow. This function is called to > get > one output frame. It should call ff_decode_get_packet() to obtain input data." > > From what I can see, if receive_frame() is not defined, a separate function is > called, decode_simple_receive_frame(), which in turn calls > decode_receive_frame_internal(). > * receive_frame() therefore allows more "fine grained" control on how the > frame generation and return values are handled, from what I can see. > * But for most purposes defining decode() is enough. > * receive_frame() takes priority over decode(). > > Is this correct? Yes. For a simple decoder, using AVCodec.decode() is enough. It is also currently required if you want to implement frame threading. Calls to AVCodec.decode() will always include a new packet to process, even if you don't currently need one because you for example have more frames to output with the data you already processed, whereas calls to AVCodec.receive_frame() let you requests packets when you need them using ff_decode_get_packet(). ___ 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] Use gcc/clang builtins for av_sat_(add|sub)_64_c if available.
On Mon, May 4, 2020 at 11:19 AM James Almer wrote: > On 5/4/2020 3:09 PM, Dale Curtis wrote: > > Bump. I have 5 integer overflow fuzzing issues awaiting our resolution of > > this discussion. Thanks. > > > > - dale > > What's the first version of clang with support for __builtin_*_overflow? > Because with your patch as is (Checking only __clang__), it's very > likely old clang builds could be broken. We have things like Clang 3 on > FATE right now. > Clang 10.0 apparently: https://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros - I'm fine with limiting support to where it works though. Attached patch does that. > > Also, does clang-cl define __clang__ and these builtins? Because maybe > we could remove that check and just keep the GCC + Intel one. The former > should in theory cover Clang builds that are reportedly compatible with > GCC >= 5.1 > Yes, clang-cl defines __clang__ and these builtins. - dale sat_math_builtin_v5.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 2/2] Use gcc/clang builtins for av_sat_(add|sub)_64_c if available.
On 5/4/2020 3:40 PM, Dale Curtis wrote: > On Mon, May 4, 2020 at 11:19 AM James Almer wrote: > >> On 5/4/2020 3:09 PM, Dale Curtis wrote: >>> Bump. I have 5 integer overflow fuzzing issues awaiting our resolution of >>> this discussion. Thanks. >>> >>> - dale >> >> What's the first version of clang with support for __builtin_*_overflow? >> Because with your patch as is (Checking only __clang__), it's very >> likely old clang builds could be broken. We have things like Clang 3 on >> FATE right now. >> > > Clang 10.0 apparently: > https://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros - > I'm fine with limiting support to where it works though. Attached patch > does that. > > >> >> Also, does clang-cl define __clang__ and these builtins? Because maybe >> we could remove that check and just keep the GCC + Intel one. The former >> should in theory cover Clang builds that are reportedly compatible with >> GCC >= 5.1 >> > > Yes, clang-cl defines __clang__ and these builtins. > > - dale Ok, if __has_builtin() works for these then this patch LGTM, but I'd prefer to first hear Michael's opinion about your reply to his question. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v1] avfilter/src_movie: Fix the loop function of dynamic logo
On Mon, 4 May 2020, lance.lmw...@gmail.com wrote: On Sun, May 03, 2020 at 07:10:07PM +0200, Marton Balint wrote: On Sun, 3 May 2020, lance.lmw...@gmail.com wrote: > On Tue, Mar 17, 2020 at 06:55:00PM +0800, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > The following command will attempt to create the input and overlay test sequence for you. > > ./ffmpeg -f lavfi -i color=white:duration=100:r=25:size=1280x720 input.mkv > > ./ffmpeg -f lavfi -i "testsrc=duration=5:size=320x240:rate=25" overlay.mkv > > > > Please try with below command and compare the final output. > > ./ffmpeg -y -filter_complex "movie=./input.mkv,setpts=PTS-STARTPTS[main];movie=./overlay.mkv:loop=5,setpts=PTS-STARTPTS[overlay];[main][overlay]overlay=10:10: > > enable='between(t,0,25)" test.mkv > > > > Without the patch applied, the overlay will repeat the last frame in overlay.mkv after the first loop. Why? I haven't clear about the question yet, if you try to insert a dynamic logo repeatly, without the patch, the dynamic logo will not overlay repeatly. But why is that? You explained what this patch fixes. But you have not explained why the error is happening and what goes wrong in the current code. I am asking, because there is some timestamp discontinuity handling in src_movie, shouldn't that handle the timestamp discontinuity caused by looping? Thanks, Marton > > Thanks, Marton > > > > Signed-off-by: Limin Wang > > --- > > libavfilter/src_movie.c | 6 ++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c > > index 79423a8..2327046 100644 > > --- a/libavfilter/src_movie.c > > +++ b/libavfilter/src_movie.c > > @@ -68,6 +68,8 @@ typedef struct MovieContext { > > int loop_count; > > int64_t discontinuity_threshold; > > int64_t ts_offset; > > +int64_t last_pts; > > +int64_t last_loop_pts; > > > > AVFormatContext *format_ctx; > > int eof; > > @@ -455,6 +457,7 @@ static int rewind_file(AVFilterContext *ctx) > > movie->st[i].done = 0; > > } > > movie->eof = 0; > > +movie->last_loop_pts = movie->last_pts; > > return 0; > > } > > > > @@ -565,6 +568,8 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) > > if (frame->pts != AV_NOPTS_VALUE) { > > if (movie->ts_offset) > > frame->pts += av_rescale_q_rnd(movie->ts_offset, AV_TIME_BASE_Q, outlink->time_base, AV_ROUND_UP); > > +if (movie->last_loop_pts) > > +frame->pts += movie->last_loop_pts; > > if (st->discontinuity_threshold) { > > if (st->last_pts != AV_NOPTS_VALUE) { > > int64_t diff = frame->pts - st->last_pts; > > @@ -575,6 +580,7 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) > > } > > } > > } > > +movie->last_pts = > > st->last_pts = frame->pts; > > } > > ff_dlog(ctx, "movie_push_frame(): file:'%s' %s\n", movie->file_name, > > -- > > 2.9.5 > > > > ping > > -- > 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 mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/prores_metadata_bsf: Use AVCOL_TRC_NB - 1 for the valid max range
On Mon, 4 May 2020, lance.lmw...@gmail.com wrote: On Mon, May 04, 2020 at 05:50:32AM +0800, lance.lmw...@gmail.com wrote: From: Limin Wang Report by Marton after commit. Reviewed-by: Marton Balint Signed-off-by: Limin Wang --- libavcodec/prores_metadata_bsf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/prores_metadata_bsf.c b/libavcodec/prores_metadata_bsf.c index 8bfcb50..7cc2320 100644 --- a/libavcodec/prores_metadata_bsf.c +++ b/libavcodec/prores_metadata_bsf.c @@ -140,7 +140,7 @@ static const AVOption options[] = { {"smpte431",NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE431}, INT_MIN, INT_MAX, FLAGS, "color_primaries"}, {"smpte432",NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE432}, INT_MIN, INT_MAX, FLAGS, "color_primaries"}, -{"color_trc", "select color transfer", OFFSET(transfer_characteristics), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_TRC_NB, FLAGS, "color_trc"}, +{"color_trc", "select color transfer", OFFSET(transfer_characteristics), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_TRC_NB - 1, FLAGS, "color_trc"}, {"auto", "keep the same color transfer", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, FLAGS, "color_trc"}, {"unknown",NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, INT_MIN, INT_MAX, FLAGS, "color_trc"}, {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT709}, INT_MIN, INT_MAX, FLAGS, "color_trc"}, -- 1.8.3.1 will apply tomorrow. LGTM, thanks. Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 0/3] Patch set to delay output live stream
On Sat, 2 May 2020, Tao Zhang wrote: Marton Balint 于2020年5月2日周六 下午7:05写道: [...] I see. But you could add an option to the fifo muxer to only write header when the first packet arrives. This way you will be able to use a bitstream filter to buffer packets and the fifo muxer will only write header when the first packet passes through the bitstream filter. Does this seem OK? It seems OK. If nobody object it, I'm glad to add write_header_on_first_packet option on fifo muxer and create a new bitstream filter which buffers fixed duration packets. Great. I suggest a shorter name for the option of the fifo muxer, delay_write_header I think is enough, you can explain the details in the docs. Also it should be pretty straightforward to add this feature to fifo.c, from a quick look at the code one approach is to add a NOOP message type, and if the option is set, then use that message type for the first message, if it is not set, use the WRITE_HEADER message type, as it is used now. Also we should find a good name for the bitstream filter, maybe "buffer", or "fifo", or if you want to better refer to the use case, then "timeshift" can also work. Another thing you should think about is what should happen at the end of the stream, when flushing the bitstream filter: - drop pending packets - flush pending packets as fast as possible - flush pendning packets realtime Maybe it should be selectable between the 3 options? I can imagine use cases for all three possibilities. Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 14/14] [inline assembly] add mmx clobbers to cavsdsp
Hi Michael, I would like an update on the review process. The patches add missing clobbers (mmx, xmm and memory) to some assembly chunks. Note that looking at the commit history, some other chunks have already been patched in such a way by the past. Moreover, as far as I know, the patches from 1 to 14 passed the fate tests, both on my computer and on patchwork. Let me know if you have any remark on them. By the way, I have a deadline that comes and I would really appreciate to see the patches applied by wednesday night. Do you think it would be possible? Regards, Frédéric De: "frederic recoules" À: "ffmpeg-devel" Cc: "frederic recoules" Envoyé: Dimanche 26 Avril 2020 21:44:24 Objet: [FFmpeg-devel] [PATCH 14/14] [inline assembly] add mmx clobbers to cavsdsp From: Frédéric Recoules --- libavcodec/x86/cavsdsp.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/cavsdsp.c b/libavcodec/x86/cavsdsp.c index becb3a4808..b1b2c7b069 100644 --- a/libavcodec/x86/cavsdsp.c +++ b/libavcodec/x86/cavsdsp.c @@ -166,7 +166,8 @@ static void cavs_idct8_add_sse2(uint8_t *dst, int16_t *block, ptrdiff_t stride) : "+a"(src), "+c"(dst)\ : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride)\ NAMED_CONSTRAINTS_ADD(ADD,MUL1,MUL2)\ - : "memory"\ + : "memory" MMX_CLOBBERS(, "mm0", "mm1", "mm2", "mm3",\ + "mm4", "mm5", "mm6", "mm7") \ );\ if(h==16){\ __asm__ volatile(\ @@ -182,7 +183,8 @@ static void cavs_idct8_add_sse2(uint8_t *dst, int16_t *block, ptrdiff_t stride) : "+a"(src), "+c"(dst)\ : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride)\ NAMED_CONSTRAINTS_ADD(ADD,MUL1,MUL2)\ - : "memory"\ + : "memory" MMX_CLOBBERS(, "mm0", "mm1", "mm2", "mm3",\ + "mm4", "mm5", "mm6", "mm7") \ );\ }\ src += 4-(h+5)*srcStride;\ @@ -235,7 +237,8 @@ static void OPNAME ## cavs_qpel8_h_ ## MMX(uint8_t *dst, const uint8_t *src, ptr : "+a"(src), "+c"(dst), "+m"(h)\ : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride)\ NAMED_CONSTRAINTS_ADD(ff_pw_4,ff_pw_5)\ - : "memory"\ + : "memory" MMX_CLOBBERS(, "mm0", "mm1", "mm2", "mm3",\ + "mm4", "mm5", "mm6", "mm7")\ );\ }\ \ -- 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".
[FFmpeg-devel] [PATCH] avcodec/dsddec: Check channels
Fixes: division by zero Fixes: 21677/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DSD_MSBF_fuzzer-5712547983654912 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/dsddec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/dsddec.c b/libavcodec/dsddec.c index 7c3ae15768..39837a5ad9 100644 --- a/libavcodec/dsddec.c +++ b/libavcodec/dsddec.c @@ -44,6 +44,9 @@ static av_cold int decode_init(AVCodecContext *avctx) int i; uint8_t silence; +if (!avctx->channels) +return AVERROR_INVALIDDATA; + ff_init_dsd_data(); s = av_malloc_array(sizeof(DSDContext), avctx->channels); -- 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] [libavutil] Add saturated add/sub operations for int64_t.
On Fri, May 01, 2020 at 01:13:58PM -0700, Dale Curtis wrote: > On Fri, May 1, 2020 at 12:53 PM Michael Niedermayer > wrote: > > > On Thu, Apr 30, 2020 at 05:39:43PM -0700, Dale Curtis wrote: > > > On Thu, Apr 30, 2020 at 5:21 PM James Almer wrote: > > > > > > > On 4/30/2020 7:19 PM, Dale Curtis wrote: > > > > > Many places are using their own custom code for handling overflow > > > > > around timestamps or other int64_t values. There are enough of these > > > > > now that having some common saturated math functions seems sound. > > > > > > > > > > This adds implementations that just use the builtin functions for > > > > > recent gcc, clang when available or implements its own version for > > > > > older compilers. > > > > > > > > These look like 64 bit versions of av_sat_add32 and av_sat_sub32, from > > > > common.h, so you should probably add them there and rename them > > > > accordingly. > > > > > > > > > > > Ah! I was looking for those, but missed them. Thanks. Done. > > > > one disadvantage the av_sat* functions have is the lack of inexact > > detection > > > > In addition to av_sat* > > In situations where its better to fail than to clip, something that > > emulates what (+-Inf/)NaN is for float may make sense. > > That would allow to simply check after a computation if any inexactness > > occured > > > > Such a thing could be usefull in situations where a exact value or an > > error is wanted. > > > > > The __builtin functions provide exactly this API, we're just hiding it. I > could add something like: > int did_overflow = av_checked_sat_(add|sub)64(int64_t a, int64_t b, > int64_t* result) this could be done, but iam unsure this API is optimal Maybe its best to show an example, why iam unsure about the API lets consider a simple random expression a*x + b*y overflow = av_checked_sat_mul64(a, x, &T0); overflow |= av_checked_sat_mul64(b, y, &T1); overflow |= av_checked_sat_add64(T0, T1, &result); if (overflow) ... vs. int64_t result = av_add_eint64( av_mul_eint64(a, x), av_mul_eint64(b, y) ); if (!av_is_finite_eint64(result)) To me the 2nd variant looks easier to read, (eint here is supposed to mean extended integer, that is extended by +/- infinity and NaN with IEEE like semantics) also the NaN element should have the same value as AV_NOPTS_VALUE, that would likely be most usefull. This could also allow the removial of alot of AV_NOPTS_VALUE special casing ... But this is independant of the pure integer saturation API and should probably not hold it up when that itself is needed. thx > > |result| would still satuate and thus av_sat_(add|sub)64 could use it > without checking the return value, but those which want to check and abort > could do so. This is similar to the API shape we expose in Chromium modulo > the fact we enforce an assert. > > - dale > ___ > 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". -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When the tyrant has disposed of foreign enemies by conquest or treaty, and there is nothing more to fear from them, then he is always stirring up some war or other, in order that the people may require a leader. -- Plato 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] Don't adjust start time for MP3 files; packets are not adjusted.
Any comments on this? Thanks. - dale On Thu, Apr 30, 2020 at 12:42 PM Dale Curtis wrote: > Ping for this patch. Thanks > > - dale > > On Thu, Apr 23, 2020 at 4:33 PM Dale Curtis > wrote: > >> This is a patch Chromium has carried for a while, we forgot to send it >> upstream. 7546ac2fee4 made it so that the start_time for mp3 files is >> adjusted for skip_samples. However, this appears incorrect because >> subsequent packet timestamps are not adjusted and skip_samples are >> applied by deleting data from a packet without changing the timestamp. >> >> E.g., we are told the start_time is ~25ms and we get a packet with a >> timestamp of 0 that has had the skip_samples discarded from it. As such >> rendering engines may incorrectly discard everything prior to the >> 25ms thinking that is where playback should officially start. Since the >> samples were deleted without adjusting timestamps though, the true >> start_time is still 0. >> >> Other formats like MP4 with edit lists will adjust both the start >> time and the timestamps of subsequent packets to avoid this issue. >> >> Signed-off-by: Dale Curtis >> > ___ 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] [libavutil] Add saturated add/sub operations for int64_t.
On Mon, May 4, 2020 at 1:48 PM Michael Niedermayer wrote: > this could be done, but iam unsure this API is optimal > > Maybe its best to show an example, why iam unsure about the API > Thanks, but maybe a more concrete case to look at would be the patch I sent for fixing skip samples: "Avoid integer overflow on start_time with skip_samples." Here's the current proposed fix: @@ -1155,8 +1155,11 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, if (st->start_time == AV_NOPTS_VALUE && pktl_it->pkt.pts != AV_NOPTS_VALUE) { st->start_time = pktl_it->pkt.pts; -if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate) -st->start_time += av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base); +if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate) { +int64_t skip_time = av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base); +if (st->start_time > 0 ? skip_time <= INT64_MAX - st->start_time : skip_time >= INT64_MIN - st->start_time) +st->start_time += skip_time; +} } } With the APIs we're discussing the new fix would be either: if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate) -st->start_time += av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base); +st->start_time = av_sat_add64(st->start_time, av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base)) or with checked overflow: -if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate) -st->start_time += av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base); +if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate) { +int64_t tmp; +if (!av_checked_sat_add64(st->start_time, av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base), &tmp)) +st->start_time = tmp; +} > lets consider a simple random expression > a*x + b*y > > overflow = av_checked_sat_mul64(a, x, &T0); > overflow |= av_checked_sat_mul64(b, y, &T1); > overflow |= av_checked_sat_add64(T0, T1, &result); > if (overflow) > ... > > vs. > > int64_t result = av_add_eint64( av_mul_eint64(a, x), > av_mul_eint64(b, y) ); > if (!av_is_finite_eint64(result)) > > > To me the 2nd variant looks easier to read, (eint here is supposed to mean > extended integer, that is extended by +/- infinity and NaN with IEEE like > semantics) > also the NaN element should have the same value as AV_NOPTS_VALUE, that > would > likely be most usefull. > This could also allow the removial of alot of AV_NOPTS_VALUE special > casing ... > Are you just proposing sentinel values for those extensions? E.g., +inf = INT64_MAX, -inf=-INT64_MAX, nan=INT64_MIN? It seems like you could just layer that on top of the saturated versions I'm proposing here. I don't think I'd recommend that solution though, instead it seems more legible and familiar to just use a float/double type in those cases where it'd be relevant. Once you start introducing sentinel checks everywhere, I doubt you'd keep much if any performance over a known type like float/double. > > But this is independant of the pure integer saturation API and should > probably > not hold it up when that itself is needed. > > thx > ___ 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 1/8] avformat/mux: move interleaved packet functions upwards
On Tue, 28 Apr 2020, Marton Balint wrote: Will be needed later to avoid a forward declaration. Will apply the series soon, this has been delayed for a very long time now... Regards, Marton Signed-off-by: Marton Balint --- libavformat/mux.c | 208 +++--- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/libavformat/mux.c b/libavformat/mux.c index 3d1f71ab1a..df0d9e993a 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -809,110 +809,6 @@ static int prepare_input_packet(AVFormatContext *s, AVPacket *pkt) return 0; } -static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) { -AVStream *st = s->streams[pkt->stream_index]; -int ret; - -if (!(s->flags & AVFMT_FLAG_AUTO_BSF)) -return 1; - -if (s->oformat->check_bitstream) { -if (!st->internal->bitstream_checked) { -if ((ret = s->oformat->check_bitstream(s, pkt)) < 0) -return ret; -else if (ret == 1) -st->internal->bitstream_checked = 1; -} -} - -if (st->internal->bsfc) { -AVBSFContext *ctx = st->internal->bsfc; -// TODO: when any bitstream filter requires flushing at EOF, we'll need to -// flush each stream's BSF chain on write_trailer. -if ((ret = av_bsf_send_packet(ctx, pkt)) < 0) { -av_log(ctx, AV_LOG_ERROR, -"Failed to send packet to filter %s for stream %d\n", -ctx->filter->name, pkt->stream_index); -return ret; -} -// TODO: when any automatically-added bitstream filter is generating multiple -// output packets for a single input one, we'll need to call this in a loop -// and write each output packet. -if ((ret = av_bsf_receive_packet(ctx, pkt)) < 0) { -if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) -return 0; -av_log(ctx, AV_LOG_ERROR, -"Failed to receive packet from filter %s for stream %d\n", -ctx->filter->name, pkt->stream_index); -if (s->error_recognition & AV_EF_EXPLODE) -return ret; -return 0; -} -} -return 1; -} - -int av_write_frame(AVFormatContext *s, AVPacket *in) -{ -AVPacket local_pkt, *pkt = &local_pkt; -int ret; - -if (!in) { -if (s->oformat->flags & AVFMT_ALLOW_FLUSH) { -ret = s->oformat->write_packet(s, NULL); -flush_if_needed(s); -if (ret >= 0 && s->pb && s->pb->error < 0) -ret = s->pb->error; -return ret; -} -return 1; -} - -if (in->flags & AV_PKT_FLAG_UNCODED_FRAME) { -pkt = in; -} else { -/* We don't own in, so we have to make sure not to modify it. - * The following avoids copying in's data unnecessarily. - * Copying side data is unavoidable as a bitstream filter - * may change it, e.g. free it on errors. */ -pkt->buf = NULL; -pkt->data = in->data; -pkt->size = in->size; -ret = av_packet_copy_props(pkt, in); -if (ret < 0) -return ret; -if (in->buf) { -pkt->buf = av_buffer_ref(in->buf); -if (!pkt->buf) { -ret = AVERROR(ENOMEM); -goto fail; -} -} -} - -ret = prepare_input_packet(s, pkt); -if (ret < 0) -goto fail; - -ret = do_packet_auto_bsf(s, pkt); -if (ret <= 0) -goto fail; - -#if FF_API_COMPUTE_PKT_FIELDS2 && FF_API_LAVF_AVCTX -ret = compute_muxer_pkt_fields(s, s->streams[pkt->stream_index], pkt); - -if (ret < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) -goto fail; -#endif - -ret = write_packet(s, pkt); - -fail: -// Uncoded frames using the noninterleaved codepath are also freed here -av_packet_unref(pkt); -return ret; -} - #define CHUNK_START 0x1000 int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, @@ -1181,6 +1077,110 @@ static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, in return ff_interleave_packet_per_dts(s, out, in, flush); } +static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) { +AVStream *st = s->streams[pkt->stream_index]; +int ret; + +if (!(s->flags & AVFMT_FLAG_AUTO_BSF)) +return 1; + +if (s->oformat->check_bitstream) { +if (!st->internal->bitstream_checked) { +if ((ret = s->oformat->check_bitstream(s, pkt)) < 0) +return ret; +else if (ret == 1) +st->internal->bitstream_checked = 1; +} +} + +if (st->internal->bsfc) { +AVBSFContext *ctx = st->internal->bsfc; +// TODO: when any bitstream filter requires flushing at EOF, we'll need to +// flush each stream's BSF chain on write_trailer. +if ((ret = av_bs
Re: [FFmpeg-devel] [PATCH v4 1/8] avformat/mux: move interleaved packet functions upwards
Marton Balint: > > > On Tue, 28 Apr 2020, Marton Balint wrote: > >> Will be needed later to avoid a forward declaration. > > Will apply the series soon, this has been delayed for a very long time > now... > Sorry for this, will try to look over it this night. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 0/2] avformat movenc add flag to allow disabling limit on timescale
> On 4 May 2020, at 17:56, Gyan Doshi wrote: > > > > On 04-05-2020 09:54 pm, vectronic wrote: >> I needed to encode to mov/mp4 with a timebase of 1/600 and the output was >> not as expected. > > What was the unexpected output? > > You can use video_track_timescale to set any custom scale. > > Gyan The unexpected output is that if you request a timebase of 600 as an argument for ffmpeg on the command line, the output timebase is forced to be greater than 1. As far as I can see there is no documentation or message logged that the following logic is applied which means the output differs to what a user has requested and expects: while(track->timescale < 1) track->timescale *= 2; I believe video_track_timescale applies to all tracks - so you unable to specify timescales per track? Nick ___ 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] [GSOC] FLIF16 Decoder (and Encoder)
Hello, I have a question regerding the internal decoding/encoding API. There seems to be two functions that may be alternatively called, on the basis of whether they are defined or not, both defined in the AVCodec struct: 1. decode() 2. receive_frame() From the comments above the definition of receive_frame(): "Decode API with decoupled packet/frame dataflow. This function is called to get one output frame. It should call ff_decode_get_packet() to obtain input data." From what I can see, if receive_frame() is not defined, a separate function is called, decode_simple_receive_frame(), which in turn calls decode_receive_frame_internal(). * receive_frame() therefore allows more "fine grained" control on how the frame generation and return values are handled, from what I can see. * But for most purposes defining decode() is enough. * receive_frame() takes priority over decode(). Is this correct? --- I have gone through theory regarding arithmetic coding and have been able to build my own arithmetic encoder. Range coding seems to differ from an arithmetic coder in only two cases, which is the renormalisation and ending the encoding/decoding process. Here's what I have managed to gather: * The general process of renormalisation in an arithcoder is [2]: (Here, `n` is initially 0) While range is too small: (range < Quarter of original) |If range is in first half of original range ("Upper" condition) |Output a 0, and `n` number of 1's |Else If range is in second half of original range: ("Lower" condidtion) |Output a 1, and `n` number of 0's |Else If range straddles the middle: ("Straddle" condition) |Increment `n` by 1 | |Blow up the range by multiplying `range` and `low` by 2 |(or shifting left by 1) The range-low notation (instead of the supposedly conventional high-low notation) is used in most of the rangecoder algorithms/implementations I have seen. * Whereas, in the range coder implementation of [1], the following happens: (here, `buffer` is 1 byte in size, and `low`, `range` are 4 bytes in size) (All arithmetic is in unsigned integers) Upper bound of the range is 1 << 31, and lower bound is (upper bound >> 8) (0x8000 and 0x0080 respectively) While range is too small: (range < lower bound) | If `low` is less than 0x7F80 (0xFF << 23) | Output `buffer`, and `n` number of 0xFF's | Put MSByte of `low` into `buffer` | Else if MSBit of `low` is 1 (The "Carry" bit) | Output (`buffer` + 1) and `n` number of 0x0's | Put MSByte of `low` into `buffer` | Else | Increment `n` by 1 | | Left Shift range by 8 | Left Shift low by 8 | Clear the carry bit of `low` So we can make out the limits to be as: "Lower" half: low < 0x7F80 "Upper" half: low >= 0x8000 (Counting in the previous condition) "Straddle" condition: `low` is greater than or eq. to 0x7F80, and the number's carry bit is 0, i.e., 0x7F80 <= `low` < 0x8000. There isn't a definitive "point" for the straddling but a range, from what I can see. Note that 0x7F80 + 0x0080 = 0x8000. The renormalisation used in the RAC FLIF uses [3] is much more simpler than the one described above. So more or less easily implementable. However, the upper and lower limits used in ffmpeg's rangecoder implementation cannot be changed and would need some rewriting. Consequently, we will have to rewrite/change the code in any codec that uses the functions. I will also add in an explanation regarding the range coder in the FLIF specification, which is not present, using whatever I have understood. The rangecoder implementation used in ffmpeg uses a very small range (0xFF00). I do not know the exact rationale behind it since I think it will require more frequent renormalisation, but it may have someting to do with the codecs it was implemented for, or the probability model. For now, I will implement the RAC in a secondary file without altering rangecoder.c/rangecoder.h. However, in the FLIF sourcecode, src/maniac/chance.cpp [4] uses an almost exact copy of the function in rangecoder.c for building the probability model (libavcodec/rangcoder.c, ff_build_rac_states). Therefore we can reuse that. It might also be possible that the original author copy pasted it there with some modifications. Dealing with the second header shouldn't be much of a problem now. An interesting thing is that the uniform symbol coder (see src/maniac/symbol.hpp) [5] is implemented recursively, which might mean that the recursion was written in mind that a stack overflow will not occur. --- As for the pixel transformations, it will mostly consist of translating the existing reference implementation into the ffmpeg API/C. About the same goes for the MANIAC encoding. --- In conclusion, I believe writing the decoder will involve a lot of "copying and pasting" (or closely following) the FLIF reference implementation, which I really don't want to do.
Re: [FFmpeg-devel] [PATCH] [libavutil] Add saturated add/sub operations for int64_t.
On Mon, May 04, 2020 at 02:19:47PM -0700, Dale Curtis wrote: > On Mon, May 4, 2020 at 1:48 PM Michael Niedermayer [...] > > > > lets consider a simple random expression > > a*x + b*y > > > > overflow = av_checked_sat_mul64(a, x, &T0); > > overflow |= av_checked_sat_mul64(b, y, &T1); > > overflow |= av_checked_sat_add64(T0, T1, &result); > > if (overflow) > > ... > > > > vs. > > > > int64_t result = av_add_eint64( av_mul_eint64(a, x), > > av_mul_eint64(b, y) ); > > if (!av_is_finite_eint64(result)) > > > > > > To me the 2nd variant looks easier to read, (eint here is supposed to mean > > extended integer, that is extended by +/- infinity and NaN with IEEE like > > semantics) > > > > also the NaN element should have the same value as AV_NOPTS_VALUE, that > > would > > likely be most usefull. > > This could also allow the removial of alot of AV_NOPTS_VALUE special > > casing ... > > > > Are you just proposing sentinel values for those extensions? E.g., +inf = > INT64_MAX, -inf=-INT64_MAX, nan=INT64_MIN? yes > It seems like you could just > layer that on top of the saturated versions I'm proposing here. I don't > think I'd recommend that solution though, instead it seems more legible and > familiar to just use a float/double type in those cases where it'd be > relevant. Once you start introducing sentinel checks everywhere, I doubt > you'd keep much if any performance over a known type like float/double. float/double is avoided (for timestamp computations) because it is "inexactly specified", 2 platforms, 2 different compilers and the results can be different. With reproducing things and regression testing thats just a rather annoying thing. Performance does matter for some code but for computations done per video frame of a 60fps video 2 cpu cycles more would not matter for many small packets it could matter, but somehow all of this kind of feels like its too much and avoidable when its on a codepath that is actually speed relevant ... but how much worse is it performance wise ? your code does 3 checks for normal numbers if (b >= 0 && a >= INT64_MAX - b) return INT64_MAX; if (b <= 0 && a <= INT64_MIN - b) return INT64_MIN; return a + b; but this needs additional operations for tracking overflows if checking is wanted for handling the eint stuff, you would likely check if the inputs are finite, thats a simple value + constant > constant2 check per input though in case of previous operations the compiler could already know if the value is finite depending on the branch it comes from. When they are finite (common case) the following code is basically the same but it does not need explicit overflow tracking, the uncommon non finite code path would need some more checks. one can of course also implement this eint stuff differently to reduce the checks. a int64_t and a seperate "finite" flag would be an option The main advantage of keeping track of finiteness in the "value" itself instead of a obverflow return code is that it naturally propagates the information instead of explicitly keeping track of it. for a single isolated operation there is no advantage That all said, this leaves many question open. which may be interresting to awnser. A. how much time in % do we actually spend in timestamp computations which would need checks, saturation or other ? B. how much actual performance difference is there for the different possible options C. in the cases which affect performance most, can we avoid the computations alltogether ? very very small constant sized audio packets come to mind, the obvious idea would be to group them in bigger chunks. That would likely gain more than any difference between anything done by these checks not saying you should awnser any of these questions, these are more meant in a general sense related to the subject Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The educated differ from the uneducated as much as the living from the dead. -- Aristotle signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] [libavutil] Add saturated add/sub operations for int64_t.
On Mon, May 4, 2020 at 3:39 PM Michael Niedermayer wrote: > On Mon, May 04, 2020 at 02:19:47PM -0700, Dale Curtis wrote: > > On Mon, May 4, 2020 at 1:48 PM Michael Niedermayer > > [...] > You snipped out the example I provided, but did you have an opinion on which approach looked best there? I think the concept of an "eint" type is interesting, but is a project wide change that's a bit beyond what I can commit to. > Are you just proposing sentinel values for those extensions? E.g., +inf = > > INT64_MAX, -inf=-INT64_MAX, nan=INT64_MIN? > > yes > Okay. Having an "eint" type for timestamps seems reasonable. Some sort of "AVTimestamp" type perhaps with a new class of arithmetic to handle operations to it. This would be similar to how we handle time in Chromium: https://source.chromium.org/chromium/chromium/src/+/master:base/time/time.h;l=119 > That all said, this leaves many question open. which may be interresting > to awnser. > A. how much time in % do we actually spend in timestamp computations which >would need checks, saturation or other ? > B. how much actual performance difference is there for the different >possible options > C. in the cases which affect performance most, can we avoid the > computations >alltogether ? >very very small constant sized audio packets come to mind, the obvious > idea would be >to group them in bigger chunks. That would likely gain more than any >difference between anything done by these checks > > not saying you should awnser any of these questions, these are more meant > in > a general sense related to the subject > Sorry I didn't mean to derail into a performance discussion. I agree, generally I don't think performance will change much. Timestamp calculations are probably not on any critical paths. ___ 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] lavf/dashdec: support larger manifests
> 2020年5月2日 下午2:33,rcombs 写道: > > --- > libavformat/dashdec.c | 29 +++-- > 1 file changed, 15 insertions(+), 14 deletions(-) > > diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c > index 5ba7feb245..bde4b0846d 100644 > --- a/libavformat/dashdec.c > +++ b/libavformat/dashdec.c > @@ -29,6 +29,8 @@ > #include "dash.h" > > #define INITIAL_BUFFER_SIZE 32768 > +#define MAX_MANIFEST_SIZE 50 * 1024 > +#define DEFAULT_MANIFEST_SIZE 8 * 1024 > > struct fragment { > int64_t url_offset; > @@ -1220,7 +1222,7 @@ static int parse_manifest(AVFormatContext *s, const > char *url, AVIOContext *in) > int close_in = 0; > uint8_t *new_url = NULL; > int64_t filesize = 0; > -char *buffer = NULL; > +AVBPrint buf; > AVDictionary *opts = NULL; > xmlDoc *doc = NULL; > xmlNodePtr root_element = NULL; > @@ -1254,24 +1256,23 @@ static int parse_manifest(AVFormatContext *s, const > char *url, AVIOContext *in) > } > > filesize = avio_size(in); > -if (filesize <= 0) { > -filesize = 8 * 1024; > +if (filesize > MAX_MANIFEST_SIZE) { > +av_log(s, AV_LOG_ERROR, "Manifest too large: %"PRId64"\n", filesize); > +return AVERROR_INVALIDDATA; > } > > -buffer = av_mallocz(filesize); > -if (!buffer) { > -av_free(c->base_url); > -return AVERROR(ENOMEM); > -} > +av_bprint_init(&buf, (filesize > 0) ? filesize + 1 : > DEFAULT_MANIFEST_SIZE, AV_BPRINT_SIZE_UNLIMITED); > > -filesize = avio_read(in, buffer, filesize); > -if (filesize <= 0) { > -av_log(s, AV_LOG_ERROR, "Unable to read to offset '%s'\n", url); > -ret = AVERROR_INVALIDDATA; > +if ((ret = avio_read_to_bprint(in, &buf, MAX_MANIFEST_SIZE)) < 0 || > +!avio_feof(in) || > +(filesize = buf.len) == 0) { > +av_log(s, AV_LOG_ERROR, "Unable to read to manifest '%s'\n", url); > +if (ret == 0) > +ret = AVERROR_INVALIDDATA; > } else { > LIBXML_TEST_VERSION > > -doc = xmlReadMemory(buffer, filesize, c->base_url, NULL, 0); > +doc = xmlReadMemory(buf.str, filesize, c->base_url, NULL, 0); > root_element = xmlDocGetRootElement(doc); > node = root_element; > > @@ -1394,7 +1395,7 @@ cleanup: > } > > av_free(new_url); > -av_free(buffer); > +av_bprint_finalize(&buf, NULL); > if (close_in) { > avio_close(in); > } > -- > 2.24.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". LGTM Thanks Steven Liu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v1] avfilter/src_movie: Fix the loop function of dynamic logo
On Mon, May 04, 2020 at 09:34:02PM +0200, Marton Balint wrote: > > > On Mon, 4 May 2020, lance.lmw...@gmail.com wrote: > > > On Sun, May 03, 2020 at 07:10:07PM +0200, Marton Balint wrote: > > > > > > > > > On Sun, 3 May 2020, lance.lmw...@gmail.com wrote: > > > > > > > On Tue, Mar 17, 2020 at 06:55:00PM +0800, lance.lmw...@gmail.com wrote: > > > > > From: Limin Wang > > > > > > > The following command will attempt to create the input and > > > overlay test sequence for you. > > > > > ./ffmpeg -f lavfi -i color=white:duration=100:r=25:size=1280x720 > > > > > input.mkv > > > > > ./ffmpeg -f lavfi -i "testsrc=duration=5:size=320x240:rate=25" > > > > > overlay.mkv > > > > > > > Please try with below command and compare the final output. > > > > > ./ffmpeg -y -filter_complex > > > > > "movie=./input.mkv,setpts=PTS-STARTPTS[main];movie=./overlay.mkv:loop=5,setpts=PTS-STARTPTS[overlay];[main][overlay]overlay=10:10: > > > > > enable='between(t,0,25)" test.mkv > > > > > > > Without the patch applied, the overlay will repeat the last > > > frame in overlay.mkv after the first loop. > > > > > > Why? > > > > I haven't clear about the question yet, if you try to insert a dynamic logo > > repeatly, without the patch, the dynamic logo will not overlay repeatly. > > But why is that? You explained what this patch fixes. But you have not > explained why the error is happening and what goes wrong in the current > code. I am asking, because there is some timestamp discontinuity handling in > src_movie, shouldn't that handle the timestamp discontinuity caused by > looping? When the dynamic logo is end for reading, the pts will not accumulate with the first loop, so it'll failed to overlay. > > Thanks, > Marton > > > > > > > > > > Thanks, > > > Marton > > > > > > > > > > Signed-off-by: Limin Wang > > > > > --- > > > > > libavfilter/src_movie.c | 6 ++ > > > > > 1 file changed, 6 insertions(+) > > > > > > > diff --git a/libavfilter/src_movie.c > > > b/libavfilter/src_movie.c > > > > > index 79423a8..2327046 100644 > > > > > --- a/libavfilter/src_movie.c > > > > > +++ b/libavfilter/src_movie.c > > > > > @@ -68,6 +68,8 @@ typedef struct MovieContext { > > > > > int loop_count; > > > > > int64_t discontinuity_threshold; > > > > > int64_t ts_offset; > > > > > +int64_t last_pts; > > > > > +int64_t last_loop_pts; > > > > > > > AVFormatContext *format_ctx; > > > > > int eof; > > > > > @@ -455,6 +457,7 @@ static int rewind_file(AVFilterContext *ctx) > > > > > movie->st[i].done = 0; > > > > > } > > > > > movie->eof = 0; > > > > > +movie->last_loop_pts = movie->last_pts; > > > > > return 0; > > > > > } > > > > > > > @@ -565,6 +568,8 @@ static int > > > movie_push_frame(AVFilterContext *ctx, unsigned out_id) > > > > > if (frame->pts != AV_NOPTS_VALUE) { > > > > > if (movie->ts_offset) > > > > > frame->pts += av_rescale_q_rnd(movie->ts_offset, > > > > > AV_TIME_BASE_Q, outlink->time_base, AV_ROUND_UP); > > > > > +if (movie->last_loop_pts) > > > > > +frame->pts += movie->last_loop_pts; > > > > > if (st->discontinuity_threshold) { > > > > > if (st->last_pts != AV_NOPTS_VALUE) { > > > > > int64_t diff = frame->pts - st->last_pts; > > > > > @@ -575,6 +580,7 @@ static int movie_push_frame(AVFilterContext *ctx, > > > > > unsigned out_id) > > > > > } > > > > > } > > > > > } > > > > > +movie->last_pts = > > > > > st->last_pts = frame->pts; > > > > > } > > > > > ff_dlog(ctx, "movie_push_frame(): file:'%s' %s\n", > > > > > movie->file_name, > > > > > -- > > 2.9.5 > > > > > > > ping > > > > > -- > 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 mailing list > > > ffmpeg-devel@ffmpeg.org > > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > > > To unsubscribe, visit link above, or email > > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > > > > -- > > Thanks, > > Limin Wang > > ___ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang ___
Re: [FFmpeg-devel] [PATCH 0/3] Patch set to delay output live stream
Marton Balint 于2020年5月5日周二 上午3:48写道: > > > > On Sat, 2 May 2020, Tao Zhang wrote: > > > Marton Balint 于2020年5月2日周六 下午7:05写道: > > [...] > > >> I see. But you could add an option to the fifo muxer to only write header > >> when the first packet arrives. This way you will be able to use a > >> bitstream filter to buffer packets and the fifo muxer will only write > >> header when the first packet passes through the bitstream filter. Does > >> this seem OK? > > It seems OK. If nobody object it, I'm glad to add > > write_header_on_first_packet option on fifo muxer and create a new > > bitstream filter which buffers fixed duration packets. > > Great. I suggest a shorter name for the option of the fifo muxer, > delay_write_header I think is enough, you can explain the details in the > docs. Great suggestion. I'll follow it. > > Also it should be pretty straightforward to add this feature to fifo.c, > from a quick look at the code one approach is to add a NOOP message type, > and if the option is set, then use that message type for the first > message, if it is not set, use the WRITE_HEADER message type, as it is > used now. > > Also we should find a good name for the bitstream filter, maybe "buffer", > or "fifo", or if you want to better refer to the use case, then > "timeshift" can also work. Maybe "caching" or "cache"? > > Another thing you should think about is what should happen at the end of > the stream, when flushing the bitstream filter: > - drop pending packets > - flush pending packets as fast as possible > - flush pendning packets realtime > Maybe it should be selectable between the 3 options? I can imagine use > cases for all three possibilities. Although I have not imagined the first and second use cases, I'm glad to implement all three. > > Thanks, > Marton > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ 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 0/2] avformat movenc add flag to allow disabling limit on timescale
On 05-05-2020 03:16 am, vectronic wrote: On 4 May 2020, at 17:56, Gyan Doshi wrote: On 04-05-2020 09:54 pm, vectronic wrote: I needed to encode to mov/mp4 with a timebase of 1/600 and the output was not as expected. What was the unexpected output? You can use video_track_timescale to set any custom scale. Gyan The unexpected output is that if you request a timebase of 600 as an argument for ffmpeg on the command line, the output timebase is forced to be greater than 1. As far as I can see there is no documentation or message logged that the following logic is applied which means the output differs to what a user has requested and expects: while(track->timescale < 1) track->timescale *= 2; I believe video_track_timescale applies to all tracks - so you unable to specify timescales per track? I believe your flag also disables the scale clamping for all video tracks. In that case, better to extend the min value of video_track_timescale to -1 to implement this instead of a new flag. Gyan ___ 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/v4l2_m2m_dec: Use av_packet_move_ref()
From: Andriy Gelman Signed-off-by: Andriy Gelman --- libavcodec/v4l2_m2m_dec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c index 3e17e0fcac..f1ad1aa2a2 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -142,8 +142,7 @@ static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame) int ret; if (s->buf_pkt.size) { -avpkt = s->buf_pkt; -memset(&s->buf_pkt, 0, sizeof(AVPacket)); +av_packet_move_ref(&avpkt, &s->buf_pkt); } else { ret = ff_decode_get_packet(avctx, &avpkt); if (ret < 0 && ret != AVERROR_EOF) -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 5/8] avcodec/pcm_rechunk_bsf: add bitstream filter to rechunk pcm audio
Marton Balint: > Signed-off-by: Marton Balint > --- > Changelog | 1 + > doc/bitstream_filters.texi | 30 ++ > libavcodec/Makefile| 1 + > libavcodec/bitstream_filters.c | 1 + > libavcodec/pcm_rechunk_bsf.c | 220 > + > libavcodec/version.h | 2 +- > 6 files changed, 254 insertions(+), 1 deletion(-) > create mode 100644 libavcodec/pcm_rechunk_bsf.c > > diff --git a/Changelog b/Changelog > index 83b8a4a46e..883e0bff99 100644 > --- a/Changelog > +++ b/Changelog > @@ -63,6 +63,7 @@ version : > - maskedthreshold filter > - Support for muxing pcm and pgs in m2ts > - Cunning Developments ADPCM decoder > +- pcm_rechunk bitstream filter > > > version 4.2: > diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi > index 8fe5b3ad75..287d320cc0 100644 > --- a/doc/bitstream_filters.texi > +++ b/doc/bitstream_filters.texi > @@ -548,6 +548,36 @@ ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv > @section null > This bitstream filter passes the packets through unchanged. > > +@section pcm_rechunk > + > +Repacketize PCM audio to a fixed number of samples per packet or a fixed > packet > +rate per second. This is similar to the @ref{asetnsamples,,asetnsamples audio > +filter,ffmpeg-filters} but works on audio packets instead of audio frames. > + > +@table @option > +@item nb_out_samples, n > +Set the number of samples per each output audio packet. The number is > intended > +as the number of samples @emph{per each channel}. Default value is 1024. > + > +@item pad, p > +If set to 1, the filter will pad the last audio packet with silence, so that > it > +will contain the same number of samples (or roughly the same number of > samples, > +see @option{frame_rate}) as the previous ones. Default value is 1. > + > +@item frame_rate, r > +This option makes the filter output a fixed numer of packets per second > instead numer > +of a fixed number of samples per packet. If the audio sample rate is not > +divisible by the frame rate then the number of samples will not be constant > but > +will vary slightly so that each packet will start as close to the frame > +boundary as possible. Using this option has precedence over > @option{nb_out_samples}. > +@end table > + > +You can generate the well known 1602-1601-1602-1601-1602 pattern of 48kHz > audio > +for NTSC frame rate using the @option{frame_rate} option. > +@example > +ffmpeg -f lavfi -i sine=r=48000:d=1 -c pcm_s16le -bsf > pcm_rechunk=r=3/1001 -f framecrc - > +@end example > + > @section prores_metadata > > Modify color property metadata embedded in prores stream. > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 28076c2c83..f5dcbb44ee 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1116,6 +1116,7 @@ OBJS-$(CONFIG_MP3_HEADER_DECOMPRESS_BSF) += > mp3_header_decompress_bsf.o \ > OBJS-$(CONFIG_MPEG2_METADATA_BSF) += mpeg2_metadata_bsf.o > OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o > OBJS-$(CONFIG_NULL_BSF) += null_bsf.o > +OBJS-$(CONFIG_PCM_RECHUNK_BSF)+= pcm_rechunk_bsf.o > OBJS-$(CONFIG_PRORES_METADATA_BSF)+= prores_metadata_bsf.o > OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += remove_extradata_bsf.o > OBJS-$(CONFIG_TEXT2MOVSUB_BSF)+= movsub_bsf.o > diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c > index 6b5ffe4d70..9e701191f8 100644 > --- a/libavcodec/bitstream_filters.c > +++ b/libavcodec/bitstream_filters.c > @@ -49,6 +49,7 @@ extern const AVBitStreamFilter ff_mpeg4_unpack_bframes_bsf; > extern const AVBitStreamFilter ff_mov2textsub_bsf; > extern const AVBitStreamFilter ff_noise_bsf; > extern const AVBitStreamFilter ff_null_bsf; > +extern const AVBitStreamFilter ff_pcm_rechunk_bsf; > extern const AVBitStreamFilter ff_prores_metadata_bsf; > extern const AVBitStreamFilter ff_remove_extradata_bsf; > extern const AVBitStreamFilter ff_text2movsub_bsf; > diff --git a/libavcodec/pcm_rechunk_bsf.c b/libavcodec/pcm_rechunk_bsf.c > new file mode 100644 > index 00..b528ed0c71 > --- /dev/null > +++ b/libavcodec/pcm_rechunk_bsf.c > @@ -0,0 +1,220 @@ > +/* > + * Copyright (c) 2020 Marton Balint > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write
Re: [FFmpeg-devel] [EXT] [PATCH v5] avcodec/v4l2_m2m_enc: Support changing qmin/qmax
On Thu, 30. Apr 12:00, Andriy Gelman wrote: > On Wed, 29. Apr 02:45, Ming Qian wrote: > > > -Original Message- > > > From: ffmpeg-devel On Behalf Of Andriy > > > Gelman > > > Sent: Wednesday, April 29, 2020 1:07 AM > > > To: ffmpeg-devel@ffmpeg.org > > > Cc: Andriy Gelman > > > Subject: [EXT] [FFmpeg-devel] [PATCH v5] avcodec/v4l2_m2m_enc: Support > > > changing qmin/qmax > > > > > > Caution: EXT Email > > > > > > From: Andriy Gelman > > > > > > Hard coded parameters for qmin and qmax are currently used to initialize > > > v4l2_m2m device. This commit uses values from avctx->{qmin,qmax} if they > > > are set. > > > > > > Signed-off-by: Andriy Gelman > > > --- > > > > > > Changes in v5: > > > - Check that qmin does not exceed qmax (thanks for feedback from Ming > > > Qian) > > > > > > libavcodec/v4l2_m2m_enc.c | 23 +++ > > > 1 file changed, 19 insertions(+), 4 deletions(-) > > > > > > diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c index > > > 8454e2326c..b22cfc61fb 100644 > > > --- a/libavcodec/v4l2_m2m_enc.c > > > +++ b/libavcodec/v4l2_m2m_enc.c > > > @@ -31,6 +31,7 @@ > > > #include "v4l2_context.h" > > > #include "v4l2_m2m.h" > > > #include "v4l2_fmt.h" > > > +#include "internal.h" > > > > > > #define MPEG_CID(x) V4L2_CID_MPEG_VIDEO_##x #define MPEG_VIDEO(x) > > > V4L2_MPEG_VIDEO_##x @@ -252,11 +253,18 @@ static int > > > v4l2_prepare_encoder(V4L2m2mContext *s) > > > return 0; > > > } > > > > > > -if (qmin != avctx->qmin || qmax != avctx->qmax) > > > -av_log(avctx, AV_LOG_WARNING, "Encoder adjusted: qmin (%d), > > > qmax (%d)\n", qmin, qmax); > > > +if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > > > > avctx->qmax) > > > { > > > +av_log(avctx, AV_LOG_WARNING, "Invalid qmin:%d qmax:%d. qmin > > > should not " > > > + "exceed qmax\n", avctx->qmin, > > > avctx->qmax); > > > +} else { > > > +qmin = avctx->qmin >= 0 ? avctx->qmin : qmin; > > > +qmax = avctx->qmax >= 0 ? avctx->qmax : qmax; > > > +} > > > > > > -v4l2_set_ext_ctrl(s, qmin_cid, qmin, "minimum video quantizer > > > scale", 0); > > > -v4l2_set_ext_ctrl(s, qmax_cid, qmax, "maximum video quantizer scale", > > > 0); > > > +v4l2_set_ext_ctrl(s, qmin_cid, qmin, "minimum video quantizer scale", > > > + avctx->qmin >= 0); > > > +v4l2_set_ext_ctrl(s, qmax_cid, qmax, "maximum video quantizer scale", > > > + avctx->qmax >= 0); > > > > > > return 0; > > > } > > > @@ -369,6 +377,12 @@ static const AVOption options[] = { > > > { NULL }, > > > }; > > > > > > +static const AVCodecDefault v4l2_m2m_defaults[] = { > > > +{ "qmin", "-1" }, > > > +{ "qmax", "-1" }, > > > +{ NULL }, > > > +}; > > > + > > > #define M2MENC_CLASS(NAME) \ > > > static const AVClass v4l2_m2m_ ## NAME ## _enc_class = { \ > > > .class_name = #NAME "_v4l2m2m_encoder", \ @@ -390,6 +404,7 > > > @@ static const AVOption options[] = { > > > .send_frame = v4l2_send_frame, \ > > > .receive_packet = v4l2_receive_packet, \ > > > .close = v4l2_encode_close, \ > > > +.defaults = v4l2_m2m_defaults, \ > > > .capabilities = AV_CODEC_CAP_HARDWARE | > > > AV_CODEC_CAP_DELAY, \ > > > .wrapper_name = "v4l2m2m", \ > > > }; > > > -- > > > 2.25.1 > > > > > > > > Lgtm > > > > Thanks, I also locally put internal.h header in the correct alphabetical > order. > > Will apply Sunday if no one objects. Applied. Thanks, -- 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 v4 8/8] avformat: remove retimeinterleave
Marton Balint: > It is not used by anything anymore. > > Signed-off-by: Marton Balint > --- > libavformat/retimeinterleave.c | 51 > -- > libavformat/retimeinterleave.h | 51 > -- > 2 files changed, 102 deletions(-) > delete mode 100644 libavformat/retimeinterleave.c > delete mode 100644 libavformat/retimeinterleave.h > > diff --git a/libavformat/retimeinterleave.c b/libavformat/retimeinterleave.c > deleted file mode 100644 > index 9f874e3626..00 > --- a/libavformat/retimeinterleave.c > +++ /dev/null > @@ -1,51 +0,0 @@ > -/* > - * Retime Interleaving functions > - * > - * Copyright (c) 2009 Baptiste Coudurier dot com> > - * > - * This file is part of FFmpeg. > - * > - * FFmpeg is free software; you can redistribute it and/or > - * modify it under the terms of the GNU Lesser General Public > - * License as published by the Free Software Foundation; either > - * version 2.1 of the License, or (at your option) any later version. > - * > - * FFmpeg is distributed in the hope that it will be useful, > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > - * Lesser General Public License for more details. > - * > - * You should have received a copy of the GNU Lesser General Public > - * License along with FFmpeg; if not, write to the Free Software > - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > - */ > - > -#include "libavutil/mathematics.h" > -#include "avformat.h" > -#include "retimeinterleave.h" > -#include "internal.h" > - > -void ff_retime_interleave_init(RetimeInterleaveContext *aic, AVRational > time_base) > -{ > -aic->time_base = time_base; > -} > - > -int ff_retime_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, > int flush, > -int (*get_packet)(AVFormatContext *, AVPacket *, > AVPacket *, int), > -int (*compare_ts)(AVFormatContext *, const AVPacket > *, const AVPacket *)) > -{ > -int ret; > - > -if (pkt) { > -AVStream *st = s->streams[pkt->stream_index]; > -RetimeInterleaveContext *aic = st->priv_data; > -pkt->duration = av_rescale_q(pkt->duration, st->time_base, > aic->time_base); > -// rewrite pts and dts to be decoded time line position > -pkt->pts = pkt->dts = aic->dts; > -aic->dts += pkt->duration; > -if ((ret = ff_interleave_add_packet(s, pkt, compare_ts)) < 0) > -return ret; > -} > - > -return get_packet(s, out, NULL, flush); > -} > diff --git a/libavformat/retimeinterleave.h b/libavformat/retimeinterleave.h > deleted file mode 100644 > index de0a7442b0..00 > --- a/libavformat/retimeinterleave.h > +++ /dev/null > @@ -1,51 +0,0 @@ > -/* > - * audio interleaving prototypes and declarations > - * > - * Copyright (c) 2009 Baptiste Coudurier dot com> > - * > - * This file is part of FFmpeg. > - * > - * FFmpeg is free software; you can redistribute it and/or > - * modify it under the terms of the GNU Lesser General Public > - * License as published by the Free Software Foundation; either > - * version 2.1 of the License, or (at your option) any later version. > - * > - * FFmpeg is distributed in the hope that it will be useful, > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > - * Lesser General Public License for more details. > - * > - * You should have received a copy of the GNU Lesser General Public > - * License along with FFmpeg; if not, write to the Free Software > - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > - */ > - > -#ifndef AVFORMAT_RETIMEINTERLEAVE_H > -#define AVFORMAT_RETIMEINTERLEAVE_H > - > -#include "avformat.h" > - > -typedef struct RetimeInterleaveContext { > -uint64_t dts; ///< current dts > -AVRational time_base; ///< time base of output packets > -} RetimeInterleaveContext; > - > -/** > - * Init the retime interleave context > - */ > -void ff_retime_interleave_init(RetimeInterleaveContext *aic, AVRational > time_base); > - > -/** > - * Retime packets per RetimeInterleaveContext->time_base and interleave them > - * correctly. > - * The first element of AVStream->priv_data must be RetimeInterleaveContext > - * when using this function. > - * > - * @param get_packet function will output a packet when streams are > correctly interleaved. > - * @param compare_ts function will compare AVPackets and decide interleaving > order. > - */ > -int ff_retime_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, > int flush, > -int (*get_packet)(AVFormatContext *, AVPacket *, > AVPacket *, int), > -int (*compare_ts)(AVFormatContext *, const AVPacket > *, const AVPacket *)); > - > -#endif /*
Re: [FFmpeg-devel] [PATCH v4 4/8] avformat/mux: add proper support for full N:M bitstream filtering
Marton Balint: > Previously only 1:1 bitstream filters were supported, the end of the stream > was > not signalled to the bitstream filters and time base changes were ignored. > > This change also allows muxers to set up bitstream filters regardless of the > autobsf flag during write_header instead of during check_bitstream and those > bitstream filters will always be executed. Ignoring the autobsf flag is not ok IMO. The muxer should not add a bsf when the user explicitly didn't want this. - Andreas > > Signed-off-by: Marton Balint > --- > libavformat/mux.c | 87 > +++ > 1 file changed, 56 insertions(+), 31 deletions(-) > > diff --git a/libavformat/mux.c b/libavformat/mux.c > index 33aed9da90..d3a98499ce 100644 > --- a/libavformat/mux.c > +++ b/libavformat/mux.c > @@ -1077,8 +1077,8 @@ static int interleave_packet(AVFormatContext *s, > AVPacket *out, AVPacket *in, in > return ff_interleave_packet_per_dts(s, out, in, flush); > } > > -static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) { > -AVStream *st = s->streams[pkt->stream_index]; > +static int check_bitstream(AVFormatContext *s, AVStream *st, AVPacket *pkt) > +{ > int ret; > > if (!(s->flags & AVFMT_FLAG_AUTO_BSF)) > @@ -1093,30 +1093,6 @@ static int do_packet_auto_bsf(AVFormatContext *s, > AVPacket *pkt) { > } > } > > -if (st->internal->bsfc) { > -AVBSFContext *ctx = st->internal->bsfc; > -// TODO: when any bitstream filter requires flushing at EOF, we'll > need to > -// flush each stream's BSF chain on write_trailer. > -if ((ret = av_bsf_send_packet(ctx, pkt)) < 0) { > -av_log(ctx, AV_LOG_ERROR, > -"Failed to send packet to filter %s for stream %d\n", > -ctx->filter->name, pkt->stream_index); > -return ret; > -} > -// TODO: when any automatically-added bitstream filter is generating > multiple > -// output packets for a single input one, we'll need to call this in > a loop > -// and write each output packet. > -if ((ret = av_bsf_receive_packet(ctx, pkt)) < 0) { > -if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) > -return 0; > -av_log(ctx, AV_LOG_ERROR, > -"Failed to receive packet from filter %s for stream > %d\n", > -ctx->filter->name, pkt->stream_index); > -if (s->error_recognition & AV_EF_EXPLODE) > -return ret; > -return 0; > -} > -} > return 1; > } > > @@ -1161,17 +1137,53 @@ static int write_packet_common(AVFormatContext *s, > AVStream *st, AVPacket *pkt, > } > } > > +static int write_packets_from_bsfs(AVFormatContext *s, AVStream *st, > AVPacket *pkt, int interleaved) > +{ > +AVBSFContext *bsfc = st->internal->bsfc; > +int ret; > + > +if ((ret = av_bsf_send_packet(bsfc, pkt)) < 0) { > +av_log(s, AV_LOG_ERROR, > +"Failed to send packet to filter %s for stream %d\n", > +bsfc->filter->name, st->index); > +return ret; > +} > + > +do { > +ret = av_bsf_receive_packet(bsfc, pkt); > +if (ret < 0) { > +if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) > +return 0; > +av_log(s, AV_LOG_ERROR, "Error applying bitstream filters to an > output " > + "packet for stream #%d: %s\n", st->index, > av_err2str(ret)); > +if (!(s->error_recognition & AV_EF_EXPLODE) && ret != > AVERROR(ENOMEM)) > +continue; > +return ret; > +} > +av_packet_rescale_ts(pkt, bsfc->time_base_out, st->time_base); > +ret = write_packet_common(s, st, pkt, interleaved); > +if (ret >= 0 && !interleaved) // a successful write_packet_common > already unrefed pkt for interleaved > +av_packet_unref(pkt); > +} while (ret >= 0); > + > +return ret; > +} > + > static int write_packets_common(AVFormatContext *s, AVStream *st, AVPacket > *pkt, int interleaved) > { > int ret = prepare_input_packet(s, pkt); > if (ret < 0) > return ret; > > -ret = do_packet_auto_bsf(s, pkt); > -if (ret <= 0) > +ret = check_bitstream(s, st, pkt); > +if (ret < 0) > return ret; > > -return write_packet_common(s, st, pkt, interleaved); > +if (st->internal->bsfc) { > +return write_packets_from_bsfs(s, st, pkt, interleaved); > +} else { > +return write_packet_common(s, st, pkt, interleaved); > +} > } > > int av_write_frame(AVFormatContext *s, AVPacket *in) > @@ -1238,9 +1250,22 @@ int av_interleaved_write_frame(AVFormatContext *s, > AVPacket *pkt) > > int av_write_trailer(AVFormatContext *s) > { > -int ret, i; > +int i, ret1, ret = 0; > +AVPacket pkt = {0}; > +av_init_packet(&pk