Re: [FFmpeg-devel] [PATCH] avcodec/ass: Fix a memory leak defect.
Here is the patch. On Tue, Feb 13, 2018 at 3:30 PM, Gang Fan(范刚)wrote: > Thanks for the advice, let me have another try. > > On Tue, Feb 13, 2018 at 4:59 AM, wm4 wrote: > >> On Mon, 12 Feb 2018 20:56:25 +0800 >> Gang Fan(范刚) wrote: >> >> > Thanks to Hendrik >> > Here is the new patch: >> > >> > From 642a413080f20f9515321e42056248e86e003997 Mon Sep 17 00:00:00 2001 >> > From: Fan Gang >> > Date: Mon, 12 Feb 2018 20:55:06 +0800 >> > Subject: [PATCH] avcodec/ass: Fix a memory leak defect when realloc >> fails. >> > >> > --- >> > libavcodec/ass_split.c | 6 ++ >> > 1 file changed, 2 insertions(+), 4 deletions(-) >> > >> > diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c >> > index 872528b..eebe239 100644 >> > --- a/libavcodec/ass_split.c >> > +++ b/libavcodec/ass_split.c >> > @@ -249,7 +249,7 @@ static const char *ass_split_section(ASSSplitCon >> text >> > *ctx, const char *buf) >> > const ASSSection *section = _sections[ctx->current_section]; >> > int *number = >field_number[ctx->current_section]; >> > int *order = ctx->field_order[ctx->current_section]; >> > -int *tmp, i, len; >> > +int i, len; >> > >> > while (buf && *buf) { >> > if (buf[0] == '[') { >> > @@ -280,9 +280,7 @@ static const char *ass_split_section(ASSSplitCon >> text >> > *ctx, const char *buf) >> > while (!is_eol(*buf)) { >> > buf = skip_space(buf); >> > len = strcspn(buf, ", \r\n"); >> > -if (!(tmp = av_realloc_array(order, (*number + 1), >> > sizeof(*order >> > -return NULL; >> > -order = tmp; >> > +av_reallocp_array(, (*number + 1), >> > sizeof(*order)); >> > order[*number] = -1; >> > for (i=0; section->fields[i].name; i++) >> > if (!strncmp(buf, section->fields[i].name, >> len)) { >> >> The patch formatting is broken (line breaks). It will be cumbersome to >> apply it, which most likely will mean nobody is going to try. >> >> Never copy a patch into the text field of your email client. >> Instead you should do one of these things: >> >> - just attach the patch as text attachment >> - use git send-email >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > > > > -- > > > *With kind regards* > -- *With kind regards* From 5c66208ebdf94a854fdae823e58b164f2f8056b1 Mon Sep 17 00:00:00 2001 From: Fan Gang Date: Tue, 13 Feb 2018 15:38:59 +0800 Subject: [PATCH] avcodec/ass: Fix a memory leak defect when realloc fails. --- libavcodec/ass_split.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c index 872528b..67da7c6 100644 --- a/libavcodec/ass_split.c +++ b/libavcodec/ass_split.c @@ -249,7 +249,7 @@ static const char *ass_split_section(ASSSplitContext *ctx, const char *buf) const ASSSection *section = _sections[ctx->current_section]; int *number = >field_number[ctx->current_section]; int *order = ctx->field_order[ctx->current_section]; -int *tmp, i, len; +int i, len; while (buf && *buf) { if (buf[0] == '[') { @@ -280,9 +280,9 @@ static const char *ass_split_section(ASSSplitContext *ctx, const char *buf) while (!is_eol(*buf)) { buf = skip_space(buf); len = strcspn(buf, ", \r\n"); -if (!(tmp = av_realloc_array(order, (*number + 1), sizeof(*order +if (av_reallocp_array(, (*number + 1), sizeof(*order)) != 0) return NULL; -order = tmp; + order[*number] = -1; for (i=0; section->fields[i].name; i++) if (!strncmp(buf, section->fields[i].name, len)) { -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/ass: Fix a memory leak defect.
Thanks for the advice, let me have another try. On Tue, Feb 13, 2018 at 4:59 AM, wm4wrote: > On Mon, 12 Feb 2018 20:56:25 +0800 > Gang Fan(范刚) wrote: > > > Thanks to Hendrik > > Here is the new patch: > > > > From 642a413080f20f9515321e42056248e86e003997 Mon Sep 17 00:00:00 2001 > > From: Fan Gang > > Date: Mon, 12 Feb 2018 20:55:06 +0800 > > Subject: [PATCH] avcodec/ass: Fix a memory leak defect when realloc > fails. > > > > --- > > libavcodec/ass_split.c | 6 ++ > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c > > index 872528b..eebe239 100644 > > --- a/libavcodec/ass_split.c > > +++ b/libavcodec/ass_split.c > > @@ -249,7 +249,7 @@ static const char *ass_split_section(ASSSplitContext > > *ctx, const char *buf) > > const ASSSection *section = _sections[ctx->current_section]; > > int *number = >field_number[ctx->current_section]; > > int *order = ctx->field_order[ctx->current_section]; > > -int *tmp, i, len; > > +int i, len; > > > > while (buf && *buf) { > > if (buf[0] == '[') { > > @@ -280,9 +280,7 @@ static const char *ass_split_section(ASSSplitContext > > *ctx, const char *buf) > > while (!is_eol(*buf)) { > > buf = skip_space(buf); > > len = strcspn(buf, ", \r\n"); > > -if (!(tmp = av_realloc_array(order, (*number + 1), > > sizeof(*order > > -return NULL; > > -order = tmp; > > +av_reallocp_array(, (*number + 1), > > sizeof(*order)); > > order[*number] = -1; > > for (i=0; section->fields[i].name; i++) > > if (!strncmp(buf, section->fields[i].name, > len)) { > > The patch formatting is broken (line breaks). It will be cumbersome to > apply it, which most likely will mean nobody is going to try. > > Never copy a patch into the text field of your email client. > Instead you should do one of these things: > > - just attach the patch as text attachment > - use git send-email > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > -- *With kind regards* ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: remove Libav ABI compatibility hacks
On Tue, 13 Feb 2018 02:04:18 -0300 James Almerwrote: > On 2/13/2018 1:50 AM, wm4 wrote: > > On Tue, 13 Feb 2018 01:44:22 -0300 > > James Almer wrote: > > > >> On 2/13/2018 1:33 AM, wm4 wrote: > >>> --- > >>> If anyone knows of similar still remaining cases in the codebase, please > >>> tell me, and I'll send patches. > >>> --- > >>> libavcodec/avcodec.h | 49 > >>> - > >>> libavcodec/utils.c | 5 - > >>> libavcodec/version.h | 2 +- > >>> 3 files changed, 17 insertions(+), 39 deletions(-) > >>> > >>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > >>> index bc0eacd66b..b3dad5d614 100644 > >>> --- a/libavcodec/avcodec.h > >>> +++ b/libavcodec/avcodec.h > >>> @@ -409,8 +409,7 @@ enum AVCodecID { > >>> AV_CODEC_ID_DXV, > >>> AV_CODEC_ID_SCREENPRESSO, > >>> AV_CODEC_ID_RSCC, > >>> - > >>> -AV_CODEC_ID_Y41P = 0x8000, > >>> +AV_CODEC_ID_Y41P, > >>> AV_CODEC_ID_AVRP, > >>> AV_CODEC_ID_012V, > >>> AV_CODEC_ID_AVUI, > >>> @@ -480,14 +479,11 @@ enum AVCodecID { > >>> AV_CODEC_ID_PCM_S24LE_PLANAR, > >>> AV_CODEC_ID_PCM_S32LE_PLANAR, > >>> AV_CODEC_ID_PCM_S16BE_PLANAR, > >>> - > >>> -AV_CODEC_ID_PCM_S64LE = 0x10800, > >>> +AV_CODEC_ID_PCM_S64LE, > >>> AV_CODEC_ID_PCM_S64BE, > >>> AV_CODEC_ID_PCM_F16LE, > >>> AV_CODEC_ID_PCM_F24LE, > >>> - > >>> -/* various ADPCM codecs */ > >>> -AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, > >>> +AV_CODEC_ID_ADPCM_IMA_QT, > >> > >> This is not an ABI compat offset. It's to separate PCM from ADPCM > >> codecs. It's also in libav's avcodec.h > > > > I could reword the commit message. Unless you argue we should keep the > > codec "categorization"; in that case entire patch dropped. > > I'd rather keep them, yes. At any point we could add any of the missing > PCM codecs, or new ADPCM codecs, just to give an example, and these > offsets will prevent having to dump them at the bottom of the list. I also removed the comments and empty lines that indicate the sectioning, so new codecs would always be appended at the end of the list of each codec type. > This patch LGTM if removing the ABI compat offsets only, so up to you. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: remove Libav ABI compatibility hacks
On 2/13/2018 1:50 AM, wm4 wrote: > On Tue, 13 Feb 2018 01:44:22 -0300 > James Almerwrote: > >> On 2/13/2018 1:33 AM, wm4 wrote: >>> --- >>> If anyone knows of similar still remaining cases in the codebase, please >>> tell me, and I'll send patches. >>> --- >>> libavcodec/avcodec.h | 49 - >>> libavcodec/utils.c | 5 - >>> libavcodec/version.h | 2 +- >>> 3 files changed, 17 insertions(+), 39 deletions(-) >>> >>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h >>> index bc0eacd66b..b3dad5d614 100644 >>> --- a/libavcodec/avcodec.h >>> +++ b/libavcodec/avcodec.h >>> @@ -409,8 +409,7 @@ enum AVCodecID { >>> AV_CODEC_ID_DXV, >>> AV_CODEC_ID_SCREENPRESSO, >>> AV_CODEC_ID_RSCC, >>> - >>> -AV_CODEC_ID_Y41P = 0x8000, >>> +AV_CODEC_ID_Y41P, >>> AV_CODEC_ID_AVRP, >>> AV_CODEC_ID_012V, >>> AV_CODEC_ID_AVUI, >>> @@ -480,14 +479,11 @@ enum AVCodecID { >>> AV_CODEC_ID_PCM_S24LE_PLANAR, >>> AV_CODEC_ID_PCM_S32LE_PLANAR, >>> AV_CODEC_ID_PCM_S16BE_PLANAR, >>> - >>> -AV_CODEC_ID_PCM_S64LE = 0x10800, >>> +AV_CODEC_ID_PCM_S64LE, >>> AV_CODEC_ID_PCM_S64BE, >>> AV_CODEC_ID_PCM_F16LE, >>> AV_CODEC_ID_PCM_F24LE, >>> - >>> -/* various ADPCM codecs */ >>> -AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, >>> +AV_CODEC_ID_ADPCM_IMA_QT, >> >> This is not an ABI compat offset. It's to separate PCM from ADPCM >> codecs. It's also in libav's avcodec.h > > I could reword the commit message. Unless you argue we should keep the > codec "categorization"; in that case entire patch dropped. I'd rather keep them, yes. At any point we could add any of the missing PCM codecs, or new ADPCM codecs, just to give an example, and these offsets will prevent having to dump them at the bottom of the list. This patch LGTM if removing the ABI compat offsets only, so up to you. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: remove Libav ABI compatibility hacks
On Tue, 13 Feb 2018 01:44:22 -0300 James Almerwrote: > On 2/13/2018 1:33 AM, wm4 wrote: > > --- > > If anyone knows of similar still remaining cases in the codebase, please > > tell me, and I'll send patches. > > --- > > libavcodec/avcodec.h | 49 - > > libavcodec/utils.c | 5 - > > libavcodec/version.h | 2 +- > > 3 files changed, 17 insertions(+), 39 deletions(-) > > > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > > index bc0eacd66b..b3dad5d614 100644 > > --- a/libavcodec/avcodec.h > > +++ b/libavcodec/avcodec.h > > @@ -409,8 +409,7 @@ enum AVCodecID { > > AV_CODEC_ID_DXV, > > AV_CODEC_ID_SCREENPRESSO, > > AV_CODEC_ID_RSCC, > > - > > -AV_CODEC_ID_Y41P = 0x8000, > > +AV_CODEC_ID_Y41P, > > AV_CODEC_ID_AVRP, > > AV_CODEC_ID_012V, > > AV_CODEC_ID_AVUI, > > @@ -480,14 +479,11 @@ enum AVCodecID { > > AV_CODEC_ID_PCM_S24LE_PLANAR, > > AV_CODEC_ID_PCM_S32LE_PLANAR, > > AV_CODEC_ID_PCM_S16BE_PLANAR, > > - > > -AV_CODEC_ID_PCM_S64LE = 0x10800, > > +AV_CODEC_ID_PCM_S64LE, > > AV_CODEC_ID_PCM_S64BE, > > AV_CODEC_ID_PCM_F16LE, > > AV_CODEC_ID_PCM_F24LE, > > - > > -/* various ADPCM codecs */ > > -AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, > > +AV_CODEC_ID_ADPCM_IMA_QT, > > This is not an ABI compat offset. It's to separate PCM from ADPCM > codecs. It's also in libav's avcodec.h I could reword the commit message. Unless you argue we should keep the codec "categorization"; in that case entire patch dropped. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: remove Libav ABI compatibility hacks
On 2/13/2018 1:33 AM, wm4 wrote: > --- > If anyone knows of similar still remaining cases in the codebase, please > tell me, and I'll send patches. > --- > libavcodec/avcodec.h | 49 - > libavcodec/utils.c | 5 - > libavcodec/version.h | 2 +- > 3 files changed, 17 insertions(+), 39 deletions(-) > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > index bc0eacd66b..b3dad5d614 100644 > --- a/libavcodec/avcodec.h > +++ b/libavcodec/avcodec.h > @@ -409,8 +409,7 @@ enum AVCodecID { > AV_CODEC_ID_DXV, > AV_CODEC_ID_SCREENPRESSO, > AV_CODEC_ID_RSCC, > - > -AV_CODEC_ID_Y41P = 0x8000, > +AV_CODEC_ID_Y41P, > AV_CODEC_ID_AVRP, > AV_CODEC_ID_012V, > AV_CODEC_ID_AVUI, > @@ -480,14 +479,11 @@ enum AVCodecID { > AV_CODEC_ID_PCM_S24LE_PLANAR, > AV_CODEC_ID_PCM_S32LE_PLANAR, > AV_CODEC_ID_PCM_S16BE_PLANAR, > - > -AV_CODEC_ID_PCM_S64LE = 0x10800, > +AV_CODEC_ID_PCM_S64LE, > AV_CODEC_ID_PCM_S64BE, > AV_CODEC_ID_PCM_F16LE, > AV_CODEC_ID_PCM_F24LE, > - > -/* various ADPCM codecs */ > -AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, > +AV_CODEC_ID_ADPCM_IMA_QT, This is not an ABI compat offset. It's to separate PCM from ADPCM codecs. It's also in libav's avcodec.h > AV_CODEC_ID_ADPCM_IMA_WAV, > AV_CODEC_ID_ADPCM_IMA_DK3, > AV_CODEC_ID_ADPCM_IMA_DK4, > @@ -518,8 +514,7 @@ enum AVCodecID { > AV_CODEC_ID_ADPCM_G722, > AV_CODEC_ID_ADPCM_IMA_APC, > AV_CODEC_ID_ADPCM_VIMA, > - > -AV_CODEC_ID_ADPCM_AFC = 0x11800, > +AV_CODEC_ID_ADPCM_AFC, > AV_CODEC_ID_ADPCM_IMA_OKI, > AV_CODEC_ID_ADPCM_DTK, > AV_CODEC_ID_ADPCM_IMA_RAD, > @@ -529,26 +524,17 @@ enum AVCodecID { > AV_CODEC_ID_ADPCM_AICA, > AV_CODEC_ID_ADPCM_IMA_DAT4, > AV_CODEC_ID_ADPCM_MTAF, > - > -/* AMR */ > -AV_CODEC_ID_AMR_NB = 0x12000, > +AV_CODEC_ID_AMR_NB, Same. > AV_CODEC_ID_AMR_WB, > - > -/* RealAudio codecs*/ > -AV_CODEC_ID_RA_144 = 0x13000, > +AV_CODEC_ID_RA_144, Same > AV_CODEC_ID_RA_288, > - > -/* various DPCM codecs */ > -AV_CODEC_ID_ROQ_DPCM = 0x14000, > +AV_CODEC_ID_ROQ_DPCM, Same > AV_CODEC_ID_INTERPLAY_DPCM, > AV_CODEC_ID_XAN_DPCM, > AV_CODEC_ID_SOL_DPCM, > - > -AV_CODEC_ID_SDX2_DPCM = 0x14800, > +AV_CODEC_ID_SDX2_DPCM, > AV_CODEC_ID_GREMLIN_DPCM, > - > -/* audio codecs */ > -AV_CODEC_ID_MP2 = 0x15000, > +AV_CODEC_ID_MP2, Same > AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or > 3 > AV_CODEC_ID_AAC, > AV_CODEC_ID_AC3, > @@ -615,8 +601,7 @@ enum AVCodecID { > AV_CODEC_ID_PAF_AUDIO, > AV_CODEC_ID_ON2AVC, > AV_CODEC_ID_DSS_SP, > - > -AV_CODEC_ID_FFWAVESYNTH = 0x15800, > +AV_CODEC_ID_FFWAVESYNTH, > AV_CODEC_ID_SONIC, > AV_CODEC_ID_SONIC_LS, > AV_CODEC_ID_EVRC, > @@ -647,8 +632,7 @@ enum AVCodecID { > AV_CODEC_ID_HDMV_PGS_SUBTITLE, > AV_CODEC_ID_DVB_TELETEXT, > AV_CODEC_ID_SRT, > - > -AV_CODEC_ID_MICRODVD = 0x17800, > +AV_CODEC_ID_MICRODVD, > AV_CODEC_ID_EIA_608, > AV_CODEC_ID_JACOSUB, > AV_CODEC_ID_SAMI, > @@ -667,9 +651,8 @@ enum AVCodecID { > /* other specific kind of codecs (generally used for attachments) */ > AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing > at the start of various fake codecs. > AV_CODEC_ID_TTF = 0x18000, > - > AV_CODEC_ID_SCTE_35, ///< Contain timestamp estimated through PCR of > program stream. > -AV_CODEC_ID_BINTEXT= 0x18800, > +AV_CODEC_ID_BINTEXT, > AV_CODEC_ID_XBIN, > AV_CODEC_ID_IDF, > AV_CODEC_ID_OTF, > @@ -681,12 +664,12 @@ enum AVCodecID { > > AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like > AV_CODEC_ID_NONE) but lavf should attempt to identify it > > -AV_CODEC_ID_MPEG2TS = 0x2, /**< _FAKE_ codec to indicate a raw > MPEG-2 TS > +AV_CODEC_ID_MPEG2TS, /**< _FAKE_ codec to indicate a raw MPEG-2 TS > * stream (only used by libavformat) */ > -AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a > MPEG-4 Systems > +AV_CODEC_ID_MPEG4SYSTEMS, /**< _FAKE_ codec to indicate a MPEG-4 Systems > * stream (only used by libavformat) */ > -AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams > containing only metadata information. > -AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames > wrapped in AVPacket > +AV_CODEC_ID_FFMETADATA, ///< Dummy codec for streams containing only > metadata information. > +AV_CODEC_ID_WRAPPED_AVFRAME, ///< Passthrough codec, AVFrames wrapped in > AVPacket Same for these four. > }; > > /** > diff --git a/libavcodec/utils.c b/libavcodec/utils.c > index 8c7d056da6..7dcfa0be71 100644 > --- a/libavcodec/utils.c > +++ b/libavcodec/utils.c > @@ -1386,11
[FFmpeg-devel] [PATCH] avcodec: remove Libav ABI compatibility hacks
--- If anyone knows of similar still remaining cases in the codebase, please tell me, and I'll send patches. --- libavcodec/avcodec.h | 49 - libavcodec/utils.c | 5 - libavcodec/version.h | 2 +- 3 files changed, 17 insertions(+), 39 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index bc0eacd66b..b3dad5d614 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -409,8 +409,7 @@ enum AVCodecID { AV_CODEC_ID_DXV, AV_CODEC_ID_SCREENPRESSO, AV_CODEC_ID_RSCC, - -AV_CODEC_ID_Y41P = 0x8000, +AV_CODEC_ID_Y41P, AV_CODEC_ID_AVRP, AV_CODEC_ID_012V, AV_CODEC_ID_AVUI, @@ -480,14 +479,11 @@ enum AVCodecID { AV_CODEC_ID_PCM_S24LE_PLANAR, AV_CODEC_ID_PCM_S32LE_PLANAR, AV_CODEC_ID_PCM_S16BE_PLANAR, - -AV_CODEC_ID_PCM_S64LE = 0x10800, +AV_CODEC_ID_PCM_S64LE, AV_CODEC_ID_PCM_S64BE, AV_CODEC_ID_PCM_F16LE, AV_CODEC_ID_PCM_F24LE, - -/* various ADPCM codecs */ -AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, +AV_CODEC_ID_ADPCM_IMA_QT, AV_CODEC_ID_ADPCM_IMA_WAV, AV_CODEC_ID_ADPCM_IMA_DK3, AV_CODEC_ID_ADPCM_IMA_DK4, @@ -518,8 +514,7 @@ enum AVCodecID { AV_CODEC_ID_ADPCM_G722, AV_CODEC_ID_ADPCM_IMA_APC, AV_CODEC_ID_ADPCM_VIMA, - -AV_CODEC_ID_ADPCM_AFC = 0x11800, +AV_CODEC_ID_ADPCM_AFC, AV_CODEC_ID_ADPCM_IMA_OKI, AV_CODEC_ID_ADPCM_DTK, AV_CODEC_ID_ADPCM_IMA_RAD, @@ -529,26 +524,17 @@ enum AVCodecID { AV_CODEC_ID_ADPCM_AICA, AV_CODEC_ID_ADPCM_IMA_DAT4, AV_CODEC_ID_ADPCM_MTAF, - -/* AMR */ -AV_CODEC_ID_AMR_NB = 0x12000, +AV_CODEC_ID_AMR_NB, AV_CODEC_ID_AMR_WB, - -/* RealAudio codecs*/ -AV_CODEC_ID_RA_144 = 0x13000, +AV_CODEC_ID_RA_144, AV_CODEC_ID_RA_288, - -/* various DPCM codecs */ -AV_CODEC_ID_ROQ_DPCM = 0x14000, +AV_CODEC_ID_ROQ_DPCM, AV_CODEC_ID_INTERPLAY_DPCM, AV_CODEC_ID_XAN_DPCM, AV_CODEC_ID_SOL_DPCM, - -AV_CODEC_ID_SDX2_DPCM = 0x14800, +AV_CODEC_ID_SDX2_DPCM, AV_CODEC_ID_GREMLIN_DPCM, - -/* audio codecs */ -AV_CODEC_ID_MP2 = 0x15000, +AV_CODEC_ID_MP2, AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 AV_CODEC_ID_AAC, AV_CODEC_ID_AC3, @@ -615,8 +601,7 @@ enum AVCodecID { AV_CODEC_ID_PAF_AUDIO, AV_CODEC_ID_ON2AVC, AV_CODEC_ID_DSS_SP, - -AV_CODEC_ID_FFWAVESYNTH = 0x15800, +AV_CODEC_ID_FFWAVESYNTH, AV_CODEC_ID_SONIC, AV_CODEC_ID_SONIC_LS, AV_CODEC_ID_EVRC, @@ -647,8 +632,7 @@ enum AVCodecID { AV_CODEC_ID_HDMV_PGS_SUBTITLE, AV_CODEC_ID_DVB_TELETEXT, AV_CODEC_ID_SRT, - -AV_CODEC_ID_MICRODVD = 0x17800, +AV_CODEC_ID_MICRODVD, AV_CODEC_ID_EIA_608, AV_CODEC_ID_JACOSUB, AV_CODEC_ID_SAMI, @@ -667,9 +651,8 @@ enum AVCodecID { /* other specific kind of codecs (generally used for attachments) */ AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. AV_CODEC_ID_TTF = 0x18000, - AV_CODEC_ID_SCTE_35, ///< Contain timestamp estimated through PCR of program stream. -AV_CODEC_ID_BINTEXT= 0x18800, +AV_CODEC_ID_BINTEXT, AV_CODEC_ID_XBIN, AV_CODEC_ID_IDF, AV_CODEC_ID_OTF, @@ -681,12 +664,12 @@ enum AVCodecID { AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it -AV_CODEC_ID_MPEG2TS = 0x2, /**< _FAKE_ codec to indicate a raw MPEG-2 TS +AV_CODEC_ID_MPEG2TS, /**< _FAKE_ codec to indicate a raw MPEG-2 TS * stream (only used by libavformat) */ -AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems +AV_CODEC_ID_MPEG4SYSTEMS, /**< _FAKE_ codec to indicate a MPEG-4 Systems * stream (only used by libavformat) */ -AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information. -AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket +AV_CODEC_ID_FFMETADATA, ///< Dummy codec for streams containing only metadata information. +AV_CODEC_ID_WRAPPED_AVFRAME, ///< Passthrough codec, AVFrames wrapped in AVPacket }; /** diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 8c7d056da6..7dcfa0be71 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1386,11 +1386,6 @@ const char *avcodec_profile_name(enum AVCodecID codec_id, int profile) unsigned avcodec_version(void) { -//av_assert0(AV_CODEC_ID_V410==164); -av_assert0(AV_CODEC_ID_PCM_S8_PLANAR==65563); -av_assert0(AV_CODEC_ID_ADPCM_G722==69660); -// av_assert0(AV_CODEC_ID_BMV_AUDIO==86071); -av_assert0(AV_CODEC_ID_SRT==94216); av_assert0(LIBAVCODEC_VERSION_MICRO >= 100); return LIBAVCODEC_VERSION_INT; diff --git a/libavcodec/version.h
Re: [FFmpeg-devel] [PATCH] avutil/opt: remove ABI hacks
On Tue, 13 Feb 2018 00:27:03 -0300 James Almerwrote: > On 2/13/2018 12:12 AM, wm4 wrote: > > These were needed for ABI compatibility with Libav. We don't need them > > anymore. > > --- > > I'm assuming we're still sort of in the ABI unstable phase. > > Sure, why not? We haven't tagged the first release of the current major > library versions yet, and it looks nicer this way. Pushed. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avutil/opt: remove ABI hacks
On 2/13/2018 12:12 AM, wm4 wrote: > These were needed for ABI compatibility with Libav. We don't need them > anymore. > --- > I'm assuming we're still sort of in the ABI unstable phase. Sure, why not? We haven't tagged the first release of the current major library versions yet, and it looks nicer this way. > --- > libavutil/opt.h | 18 +- > libavutil/version.h | 2 +- > 2 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/libavutil/opt.h b/libavutil/opt.h > index 555929dd6b..391720f2e2 100644 > --- a/libavutil/opt.h > +++ b/libavutil/opt.h > @@ -229,15 +229,15 @@ enum AVOptionType{ > AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately > followed by an int for the length > AV_OPT_TYPE_DICT, > AV_OPT_TYPE_UINT64, > -AV_OPT_TYPE_CONST = 128, > -AV_OPT_TYPE_IMAGE_SIZE = MKBETAG('S','I','Z','E'), ///< offset must > point to two consecutive integers > -AV_OPT_TYPE_PIXEL_FMT = MKBETAG('P','F','M','T'), > -AV_OPT_TYPE_SAMPLE_FMT = MKBETAG('S','F','M','T'), > -AV_OPT_TYPE_VIDEO_RATE = MKBETAG('V','R','A','T'), ///< offset must > point to AVRational > -AV_OPT_TYPE_DURATION = MKBETAG('D','U','R',' '), > -AV_OPT_TYPE_COLOR = MKBETAG('C','O','L','R'), > -AV_OPT_TYPE_CHANNEL_LAYOUT = MKBETAG('C','H','L','A'), > -AV_OPT_TYPE_BOOL = MKBETAG('B','O','O','L'), > +AV_OPT_TYPE_CONST, > +AV_OPT_TYPE_IMAGE_SIZE, ///< offset must point to two consecutive > integers > +AV_OPT_TYPE_PIXEL_FMT, > +AV_OPT_TYPE_SAMPLE_FMT, > +AV_OPT_TYPE_VIDEO_RATE, ///< offset must point to AVRational > +AV_OPT_TYPE_DURATION, > +AV_OPT_TYPE_COLOR, > +AV_OPT_TYPE_CHANNEL_LAYOUT, > +AV_OPT_TYPE_BOOL, > }; > > /** > diff --git a/libavutil/version.h b/libavutil/version.h > index d81ec6fa7b..a2a820aebf 100644 > --- a/libavutil/version.h > +++ b/libavutil/version.h > @@ -80,7 +80,7 @@ > > #define LIBAVUTIL_VERSION_MAJOR 56 > #define LIBAVUTIL_VERSION_MINOR 7 > -#define LIBAVUTIL_VERSION_MICRO 100 > +#define LIBAVUTIL_VERSION_MICRO 101 > > #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ > LIBAVUTIL_VERSION_MINOR, \ > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avutil/opt: remove ABI hacks
These were needed for ABI compatibility with Libav. We don't need them anymore. --- I'm assuming we're still sort of in the ABI unstable phase. --- libavutil/opt.h | 18 +- libavutil/version.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libavutil/opt.h b/libavutil/opt.h index 555929dd6b..391720f2e2 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -229,15 +229,15 @@ enum AVOptionType{ AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length AV_OPT_TYPE_DICT, AV_OPT_TYPE_UINT64, -AV_OPT_TYPE_CONST = 128, -AV_OPT_TYPE_IMAGE_SIZE = MKBETAG('S','I','Z','E'), ///< offset must point to two consecutive integers -AV_OPT_TYPE_PIXEL_FMT = MKBETAG('P','F','M','T'), -AV_OPT_TYPE_SAMPLE_FMT = MKBETAG('S','F','M','T'), -AV_OPT_TYPE_VIDEO_RATE = MKBETAG('V','R','A','T'), ///< offset must point to AVRational -AV_OPT_TYPE_DURATION = MKBETAG('D','U','R',' '), -AV_OPT_TYPE_COLOR = MKBETAG('C','O','L','R'), -AV_OPT_TYPE_CHANNEL_LAYOUT = MKBETAG('C','H','L','A'), -AV_OPT_TYPE_BOOL = MKBETAG('B','O','O','L'), +AV_OPT_TYPE_CONST, +AV_OPT_TYPE_IMAGE_SIZE, ///< offset must point to two consecutive integers +AV_OPT_TYPE_PIXEL_FMT, +AV_OPT_TYPE_SAMPLE_FMT, +AV_OPT_TYPE_VIDEO_RATE, ///< offset must point to AVRational +AV_OPT_TYPE_DURATION, +AV_OPT_TYPE_COLOR, +AV_OPT_TYPE_CHANNEL_LAYOUT, +AV_OPT_TYPE_BOOL, }; /** diff --git a/libavutil/version.h b/libavutil/version.h index d81ec6fa7b..a2a820aebf 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -80,7 +80,7 @@ #define LIBAVUTIL_VERSION_MAJOR 56 #define LIBAVUTIL_VERSION_MINOR 7 -#define LIBAVUTIL_VERSION_MICRO 100 +#define LIBAVUTIL_VERSION_MICRO 101 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ -- 2.16.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/mpeg12enc: add support for specifying video_format in the sequence_display_extension
On Sat, 10 Feb 2018, Michael Niedermayer wrote: On Sat, Feb 10, 2018 at 07:45:36PM +0100, Marton Balint wrote: In a recent commit the default was changed from 0 (component) to 5 (unspecified), however some standards require using 0. With this option, the user will be able to do so. Signed-off-by: Marton Balint--- doc/encoders.texi | 5 + libavcodec/mpeg12enc.c | 12 ++-- libavcodec/mpegvideo.h | 7 +++ libavcodec/version.h | 2 +- just realized this mismatches the prefix of the commit message Thanks, applied with the proper prefix. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avdevice/decklink_dec: Extract NTSC VANC
On Sun, 11 Feb 2018, Ray Tiley wrote: This changes how NTSC VANC is extracted from the buffer. In NTSC the vanc data interleved between the uyvy and not just the luma as in high definition resolutions. In my testing this allows a decklink card encoding valid NTSC closed captions to pass the caption data to the x264 encoder. Updated with rewviews from Devon Heitmueller and Marton Balint. Signed-off-by: Ray Tiley--- libavdevice/decklink_dec.cpp | 23 --- 1 file changed, 20 insertions(+), 3 deletions(-) Thanks, applied. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/dpx: Support for RGB and RGBA 12-bit packed decoding
2018-02-12 23:38 GMT+01:00 Jerome Martinez: > On 12/02/2018 22:37, Carl Eugen Hoyos wrote: >> The only solution I can think of is to change the semantics of the fourth >> dpx layer by default and to add an option (to the decoder) that allows >> using the current semantics that defaults to "auto" reading the encoder >> value. > > IMO having the default everywhere as currently set is not "buggy", but a > global (not limited to DPX) option could be interesting I don't think this is a "global" issue, afaict, this is 100% dpx-specific. I also don't think a global flag (or similar) that indicates that alpha is actually infrared would me sense: GraphicsMagick (that does not show the issue that FFmpeg has) does not have such a flag and also supports a number of image formats that support alpha. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/dpx: Support for RGB and RGBA 12-bit packed decoding
On 12/02/2018 22:37, Carl Eugen Hoyos wrote: 2018-02-12 20:47 GMT+01:00 Jerome Martinez: https://mediaarea.net/temp/uncropped_DPX_4K_16bit_Overscan15pros.dpx is indicated by the person who provided it as with DPX alpha channel used for actually storing infrared Thank you! This sample appears to confirm that GraphicsMagick is right and FFmpeg is buggy. To avoid creating more incorrect (ffv1) encodes, I (strongly) suggest to first fix this issue and commit your patch to support more bit-depths but if you disagree, please feel free to commit! Sorry but I don't get it: the patch in this thread is totally separated from the alpha channel meaning issue. What should I "commit" about which "issue"? The only issues I have for the moment are that 12-bit padded DPX is supported by FFmpeg but not 12-bit packed DPX (the patch solves it), and that FFV1 support is with e.g. 12-bit YUVA but not 12-bit RGBA (I'll send a patch tomorrow for that, separated issue). I am not against continuing the discussion about the alpha channel meaning issue in a global manner, but I wish it is not blocking for this patch inclusion (I already sent the modified patch in order to fix the issues you indicated), as this patch does not create something new compared to what already exists (RGBA 8-bit, 16-bit, 10-bit padded, 12-bit padded, are already parsed by FFmpeg DPX parser) and the patch may be useful for people using "correctly" the alpha channel as they do for the other flavors of DPX, as well for people using RGB 12-bit packed. Let me know if I should split the patch in 2 (RGB part, RGBA part), so at least the RGB one could be included, as it is not related with any "alpha channel" stuff. There is also this sample though: http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2392/ The only solution I can think of is to change the semantics of the fourth dpx layer by default and to add an option (to the decoder) that allows using the current semantics that defaults to "auto" reading the encoder value. IMO having the default everywhere as currently set is not "buggy", but a global (not limited to DPX) option could be interesting for setting the semantics of the channel flagged as "alpha", because people may already use DPX or FFV1 (FFV1 supports RGBA 8-bit or YUVA 16-bit for a long time, nothing new) or any other format with alpha channel not having the "right" semantics (and whatever is the format, it is impossible to know how it is used) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]lavf/matroskaenc: Do not allow -reserve_index_space 1
2018-02-11 20:57 GMT+01:00 Nicolas George: > Carl Eugen Hoyos (2018-02-11): >> 2018-02-11 20:23 GMT+01:00 Nicolas George : >> > Carl Eugen Hoyos (2018-02-11): >> >> Attached patch fixes an assertion failure with the following command line: >> >> $ ffmpeg -f lavfi -i testsrc -reserve_index_space 1 out.mkv >> >> > Reading the code, it is pretty obvious that 0 is a valid value and >> > forbidding it would be bad. >> >> It is still the used default value... >> >> Uglier alternative attached. >> >> Carl Eugen > >> From 6a08d7cb89294b81e87dac93bbf58627e5d37cec Mon Sep 17 00:00:00 2001 >> From: Carl Eugen Hoyos >> Date: Sun, 11 Feb 2018 20:41:32 +0100 >> Subject: [PATCH] lavf/matroskaenc: Force the minimum value for >> -reserve_index_space to 2. >> >> Fixes an assertion failure: >> Assertion size >= 2 failed at libavformat/matroskaenc.c:298 >> --- >> libavformat/matroskaenc.c |2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c >> index f22c2ab..5950b4d 100644 >> --- a/libavformat/matroskaenc.c >> +++ b/libavformat/matroskaenc.c >> @@ -2001,6 +2001,8 @@ static int mkv_write_header(AVFormatContext *s) >> } >> if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && mkv->reserve_cues_space) { >> mkv->cues_pos = avio_tell(pb); > >> +if (mkv->reserve_cues_space == 1) >> +mkv->reserve_cues_space++; >> put_ebml_void(pb, mkv->reserve_cues_space); > > I would have written it: > > put_ebml_void(pb, FFMAX(2, mkv->reserve_cues_space)); > > That is more or less equivalent to this patch. Applied my variant as I consider it (very slightly) more readable. Thank you, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] libavformat/aac: Parse ID3 tags between ADTS frames.
There was only one version of this one. Thanks for applying. On Mon, Feb 12, 2018 at 1:17 PM, wm4wrote: > On Thu, 1 Feb 2018 18:37:45 -0800 > rshaf...@tunein.com wrote: > >> From: Richard Shaffer >> >> While rare, ID3 tags may be inserted between ADTS frames. This change enables >> parsing them and setting the appropriate metadata updated event flag. >> --- >> I have encountered a streaming provider that I must support which does this. >> There are indications that it isn't totally off the wall, and that it does >> happen in the wild: >> * https://www.w3.org/TR/mse-byte-stream-format-mpeg-audio/ >> (See specifically sections 3 and 4.) >> * https://github.com/video-dev/hls.js/issues/508 >> >> That being said, the providers that do this are in the minority. It seems >> most >> streaming providers will do one of the following: >> 1. If using .aac segments inside of HLS, use the #EXTINF for text metadata >> and >> use an ID3 tag at the head of the segment for things like timing >> metadata. >> 2. If streaming raw AAC over HTTP, use Icy metadata. >> >> Aside from comments on the code, I'd be interested in any opinion about >> whether >> this is something that should or should not be supported in libavformat. >> >> Thanks, >> >> -Richard >> >> libavformat/aacdec.c | 45 +++-- >> 1 file changed, 43 insertions(+), 2 deletions(-) >> >> diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c >> index 36d558ff54..5ec706bdc7 100644 >> --- a/libavformat/aacdec.c >> +++ b/libavformat/aacdec.c >> @@ -22,8 +22,10 @@ >> >> #include "libavutil/intreadwrite.h" >> #include "avformat.h" >> +#include "avio_internal.h" >> #include "internal.h" >> #include "id3v1.h" >> +#include "id3v2.h" >> #include "apetag.h" >> >> #define ADTS_HEADER_SIZE 7 >> @@ -116,13 +118,52 @@ static int adts_aac_read_header(AVFormatContext *s) >> return 0; >> } >> >> +static int handle_id3(AVFormatContext *s, AVPacket *pkt) >> +{ >> +AVDictionary *metadata = NULL; >> +AVIOContext ioctx; >> +ID3v2ExtraMeta *id3v2_extra_meta = NULL; >> +int ret; >> + >> +ret = av_append_packet(s->pb, pkt, ff_id3v2_tag_len(pkt->data) - >> pkt->size); >> +if (ret < 0) { >> +av_packet_unref(pkt); >> +return ret; >> +} >> + >> +ffio_init_context(, pkt->data, pkt->size, 0, NULL, NULL, NULL, >> NULL); >> +ff_id3v2_read_dict(, , ID3v2_DEFAULT_MAGIC, >> _extra_meta); >> +if ((ret = ff_id3v2_parse_priv_dict(, _extra_meta)) < 0) >> +goto error; >> + >> +if (metadata) { >> +if ((ret = av_dict_copy(>metadata, metadata, 0)) < 0) >> +goto error; >> +s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; >> +} >> + >> +error: >> +av_packet_unref(pkt); >> +ff_id3v2_free_extra_meta(_extra_meta); >> +av_dict_free(); >> + >> +return ret; >> +} >> + >> static int adts_aac_read_packet(AVFormatContext *s, AVPacket *pkt) >> { >> int ret, fsize; >> >> -ret = av_get_packet(s->pb, pkt, ADTS_HEADER_SIZE); >> +ret = av_get_packet(s->pb, pkt, FFMAX(ID3v2_HEADER_SIZE, >> ADTS_HEADER_SIZE)); >> + >> +if (ret >= ID3v2_HEADER_SIZE && ff_id3v2_match(pkt->data, >> ID3v2_DEFAULT_MAGIC)) { >> +if ((ret = handle_id3(s, pkt)) >= 0) >> +ret = av_get_packet(s->pb, pkt, ADTS_HEADER_SIZE); >> +} >> + >> if (ret < 0) >> return ret; >> + >> if (ret < ADTS_HEADER_SIZE) { >> av_packet_unref(pkt); >> return AVERROR(EIO); >> @@ -139,7 +180,7 @@ static int adts_aac_read_packet(AVFormatContext *s, >> AVPacket *pkt) >> return AVERROR_INVALIDDATA; >> } >> >> -ret = av_append_packet(s->pb, pkt, fsize - ADTS_HEADER_SIZE); >> +ret = av_append_packet(s->pb, pkt, fsize - pkt->size); >> if (ret < 0) >> av_packet_unref(pkt); >> > > Applied. (I hope this is the most recent version...) > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 6/8] avfilter/silencedetect: fix for ticket 6968 Fix missing log of silence_end at end of stream
2018-02-12 16:33 GMT+01:00 Gaullier Nicolas: > Here, the "fix for ticket 6968" should be the header, so I think the format > is correct ? I simply missed it, but a better alternative is: lavfi/silencedetect: Fix missing log at eos. Fixes ticket #6968. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/dpx: Support for RGB and RGBA 12-bit packed decoding
2018-02-12 20:47 GMT+01:00 Jerome Martinez: > https://mediaarea.net/temp/uncropped_DPX_4K_16bit_Overscan15pros.dpx > is indicated by the person who provided it as with DPX alpha channel used > for actually storing infrared Thank you! This sample appears to confirm that GraphicsMagick is right and FFmpeg is buggy. To avoid creating more incorrect (ffv1) encodes, I (strongly) suggest to first fix this issue and commit your patch to support more bit-depths but if you disagree, please feel free to commit! There is also this sample though: http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2392/ The only solution I can think of is to change the semantics of the fourth dpx layer by default and to add an option (to the decoder) that allows using the current semantics that defaults to "auto" reading the encoder value. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]lavf/rtpdec: Constify several pointers
2018-02-12 0:02 GMT+01:00 Muhammad Faiz: > On Mon, Feb 12, 2018 at 2:05 AM, Carl Eugen Hoyos wrote: >> 2018-02-11 0:32 GMT+01:00 Muhammad Faiz : >>> Probably, the variables should also be constified. >> >> Not sure which variables you mean. > > ff_*_dynamic_handler. Patch sent. Thank you, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] libavformat/aac: Parse ID3 tags between ADTS frames.
On Thu, 1 Feb 2018 18:37:45 -0800 rshaf...@tunein.com wrote: > From: Richard Shaffer> > While rare, ID3 tags may be inserted between ADTS frames. This change enables > parsing them and setting the appropriate metadata updated event flag. > --- > I have encountered a streaming provider that I must support which does this. > There are indications that it isn't totally off the wall, and that it does > happen in the wild: > * https://www.w3.org/TR/mse-byte-stream-format-mpeg-audio/ > (See specifically sections 3 and 4.) > * https://github.com/video-dev/hls.js/issues/508 > > That being said, the providers that do this are in the minority. It seems most > streaming providers will do one of the following: > 1. If using .aac segments inside of HLS, use the #EXTINF for text metadata > and > use an ID3 tag at the head of the segment for things like timing metadata. > 2. If streaming raw AAC over HTTP, use Icy metadata. > > Aside from comments on the code, I'd be interested in any opinion about > whether > this is something that should or should not be supported in libavformat. > > Thanks, > > -Richard > > libavformat/aacdec.c | 45 +++-- > 1 file changed, 43 insertions(+), 2 deletions(-) > > diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c > index 36d558ff54..5ec706bdc7 100644 > --- a/libavformat/aacdec.c > +++ b/libavformat/aacdec.c > @@ -22,8 +22,10 @@ > > #include "libavutil/intreadwrite.h" > #include "avformat.h" > +#include "avio_internal.h" > #include "internal.h" > #include "id3v1.h" > +#include "id3v2.h" > #include "apetag.h" > > #define ADTS_HEADER_SIZE 7 > @@ -116,13 +118,52 @@ static int adts_aac_read_header(AVFormatContext *s) > return 0; > } > > +static int handle_id3(AVFormatContext *s, AVPacket *pkt) > +{ > +AVDictionary *metadata = NULL; > +AVIOContext ioctx; > +ID3v2ExtraMeta *id3v2_extra_meta = NULL; > +int ret; > + > +ret = av_append_packet(s->pb, pkt, ff_id3v2_tag_len(pkt->data) - > pkt->size); > +if (ret < 0) { > +av_packet_unref(pkt); > +return ret; > +} > + > +ffio_init_context(, pkt->data, pkt->size, 0, NULL, NULL, NULL, > NULL); > +ff_id3v2_read_dict(, , ID3v2_DEFAULT_MAGIC, > _extra_meta); > +if ((ret = ff_id3v2_parse_priv_dict(, _extra_meta)) < 0) > +goto error; > + > +if (metadata) { > +if ((ret = av_dict_copy(>metadata, metadata, 0)) < 0) > +goto error; > +s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; > +} > + > +error: > +av_packet_unref(pkt); > +ff_id3v2_free_extra_meta(_extra_meta); > +av_dict_free(); > + > +return ret; > +} > + > static int adts_aac_read_packet(AVFormatContext *s, AVPacket *pkt) > { > int ret, fsize; > > -ret = av_get_packet(s->pb, pkt, ADTS_HEADER_SIZE); > +ret = av_get_packet(s->pb, pkt, FFMAX(ID3v2_HEADER_SIZE, > ADTS_HEADER_SIZE)); > + > +if (ret >= ID3v2_HEADER_SIZE && ff_id3v2_match(pkt->data, > ID3v2_DEFAULT_MAGIC)) { > +if ((ret = handle_id3(s, pkt)) >= 0) > +ret = av_get_packet(s->pb, pkt, ADTS_HEADER_SIZE); > +} > + > if (ret < 0) > return ret; > + > if (ret < ADTS_HEADER_SIZE) { > av_packet_unref(pkt); > return AVERROR(EIO); > @@ -139,7 +180,7 @@ static int adts_aac_read_packet(AVFormatContext *s, > AVPacket *pkt) > return AVERROR_INVALIDDATA; > } > > -ret = av_append_packet(s->pb, pkt, fsize - ADTS_HEADER_SIZE); > +ret = av_append_packet(s->pb, pkt, fsize - pkt->size); > if (ret < 0) > av_packet_unref(pkt); > Applied. (I hope this is the most recent version...) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH]lavf/rtpdec*: Constify all RTPDynamicProtocolHandler
Hi! Attached patch marks the RTPDynamicProtocolHandler as const. Please comment, Carl Eugen From e219322aa7396db6ecb6ab02fd5b42b42271f27f Mon Sep 17 00:00:00 2001 From: Carl Eugen HoyosDate: Mon, 12 Feb 2018 22:21:06 +0100 Subject: [PATCH] lavf/rtpdec*: Constify all RTPDynamicProtocolHandler. --- libavformat/rtpdec_ac3.c |2 +- libavformat/rtpdec_amr.c |4 +- libavformat/rtpdec_asf.c |2 +- libavformat/rtpdec_dv.c |2 +- libavformat/rtpdec_formats.h | 84 ++--- libavformat/rtpdec_g726.c |4 +- libavformat/rtpdec_h261.c |2 +- libavformat/rtpdec_h263.c |4 +- libavformat/rtpdec_h263_rfc2190.c |2 +- libavformat/rtpdec_h264.c |2 +- libavformat/rtpdec_hevc.c |2 +- libavformat/rtpdec_ilbc.c |2 +- libavformat/rtpdec_jpeg.c |2 +- libavformat/rtpdec_latm.c |2 +- libavformat/rtpdec_mpa_robust.c |2 +- libavformat/rtpdec_mpeg12.c |4 +- libavformat/rtpdec_mpeg4.c|4 +- libavformat/rtpdec_mpegts.c |2 +- libavformat/rtpdec_qcelp.c|2 +- libavformat/rtpdec_qdm2.c |2 +- libavformat/rtpdec_rfc4175.c |2 +- libavformat/rtpdec_svq3.c |2 +- libavformat/rtpdec_vc2hq.c|2 +- libavformat/rtpdec_vp8.c |2 +- libavformat/rtpdec_vp9.c |2 +- libavformat/rtpdec_xiph.c |4 +- 26 files changed, 73 insertions(+), 73 deletions(-) diff --git a/libavformat/rtpdec_ac3.c b/libavformat/rtpdec_ac3.c index 48b2d9c..56a379f 100644 --- a/libavformat/rtpdec_ac3.c +++ b/libavformat/rtpdec_ac3.c @@ -122,7 +122,7 @@ static int ac3_handle_packet(AVFormatContext *ctx, PayloadContext *data, return 0; } -RTPDynamicProtocolHandler ff_ac3_dynamic_handler = { +const RTPDynamicProtocolHandler ff_ac3_dynamic_handler = { .enc_name = "ac3", .codec_type = AVMEDIA_TYPE_AUDIO, .codec_id = AV_CODEC_ID_AC3, diff --git a/libavformat/rtpdec_amr.c b/libavformat/rtpdec_amr.c index 8687e65..35d3222 100644 --- a/libavformat/rtpdec_amr.c +++ b/libavformat/rtpdec_amr.c @@ -182,7 +182,7 @@ static int amr_parse_sdp_line(AVFormatContext *s, int st_index, return 0; } -RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler = { +const RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler = { .enc_name = "AMR", .codec_type = AVMEDIA_TYPE_AUDIO, .codec_id = AV_CODEC_ID_AMR_NB, @@ -192,7 +192,7 @@ RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler = { .parse_packet = amr_handle_packet, }; -RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler = { +const RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler = { .enc_name = "AMR-WB", .codec_type = AVMEDIA_TYPE_AUDIO, .codec_id = AV_CODEC_ID_AMR_WB, diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index 09f214a..54ffef6 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -300,7 +300,7 @@ static void asfrtp_close_context(PayloadContext *asf) } #define RTP_ASF_HANDLER(n, s, t) \ -RTPDynamicProtocolHandler ff_ms_rtp_ ## n ## _handler = { \ +const RTPDynamicProtocolHandler ff_ms_rtp_ ## n ## _handler = { \ .enc_name = s, \ .codec_type = t, \ .codec_id = AV_CODEC_ID_NONE, \ diff --git a/libavformat/rtpdec_dv.c b/libavformat/rtpdec_dv.c index de99d27..53a5855 100644 --- a/libavformat/rtpdec_dv.c +++ b/libavformat/rtpdec_dv.c @@ -131,7 +131,7 @@ static int dv_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_dv_ctx, return 0; } -RTPDynamicProtocolHandler ff_dv_dynamic_handler = { +const RTPDynamicProtocolHandler ff_dv_dynamic_handler = { .enc_name = "DV", .codec_type = AVMEDIA_TYPE_VIDEO, .codec_id = AV_CODEC_ID_DVVIDEO, diff --git a/libavformat/rtpdec_formats.h b/libavformat/rtpdec_formats.h index a436c9d..38c3f6f 100644 --- a/libavformat/rtpdec_formats.h +++ b/libavformat/rtpdec_formats.h @@ -47,47 +47,47 @@ int ff_h264_handle_frag_packet(AVPacket *pkt, const uint8_t *buf, int len, int nal_header_len); void ff_h264_parse_framesize(AVCodecParameters *par, const char *p); -extern RTPDynamicProtocolHandler ff_ac3_dynamic_handler; -extern RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler; -extern RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler; -extern RTPDynamicProtocolHandler ff_dv_dynamic_handler; -extern RTPDynamicProtocolHandler ff_g726_16_dynamic_handler; -extern RTPDynamicProtocolHandler ff_g726_24_dynamic_handler; -extern RTPDynamicProtocolHandler ff_g726_32_dynamic_handler; -extern RTPDynamicProtocolHandler ff_g726_40_dynamic_handler; -extern RTPDynamicProtocolHandler ff_g726le_16_dynamic_handler; -extern RTPDynamicProtocolHandler ff_g726le_24_dynamic_handler; -extern
Re: [FFmpeg-devel] [PATCH] fate: add aac id3v2 demux test
On Sat, 3 Feb 2018 23:24:45 -0800 rshaf...@tunein.com wrote: > From: Richard Shaffer> > A basic test for demuxing raw AAC (ADTS) with ID3v2 tags. > --- > This is related to the patch 'libavformat/aac: Parse ID3 tags between ADTS > frames', and will fail without it. The test file contains an ID3 tag at the > beginning as well as a second tag between frames. While the test doesn't check > that the tags' data have been parsed correctly, without the aforementioned > patch, the demuxing will fail on the second tag and return an invalid data > error. > > The sample will be attached in a separate email. > > Thanks, > > -Richard > > tests/fate/demux.mak| 3 +- > tests/ref/fate/adts-id3v2-demux | 240 > > 2 files changed, 242 insertions(+), 1 deletion(-) > create mode 100644 tests/ref/fate/adts-id3v2-demux > > diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak > index 9427ac30c8..306904b9de 100644 > --- a/tests/fate/demux.mak > +++ b/tests/fate/demux.mak > @@ -1,9 +1,10 @@ > FATE_SAMPLES_DEMUX-$(call DEMDEC, AVI, FRAPS) += fate-avio-direct > fate-avio-direct: CMD = framecrc -avioflags direct -i > $(TARGET_SAMPLES)/fraps/fraps-v5-bouncing-balls-partial.avi -avioflags direct > > -FATE_SAMPLES_DEMUX-$(call DEMDEC, AAC, AAC) += fate-adts-demux > fate-adts-id3v1-demux > +FATE_SAMPLES_DEMUX-$(call DEMDEC, AAC, AAC) += fate-adts-demux > fate-adts-id3v1-demux fate-adts-id3v2-demux > fate-adts-demux: CMD = crc -i $(TARGET_SAMPLES)/aac/ct_faac-adts.aac -c:a > copy > fate-adts-id3v1-demux: CMD = framecrc -f aac -i > $(TARGET_SAMPLES)/aac/id3v1.aac -c:a copy > +fate-adts-id3v2-demux: CMD = framecrc -f aac -i > $(TARGET_SAMPLES)/aac/id3v2.aac -c:a copy > > FATE_SAMPLES_DEMUX-$(CONFIG_AEA_DEMUXER) += fate-aea-demux > fate-aea-demux: CMD = crc -i $(TARGET_SAMPLES)/aea/chirp.aea -c:a copy > diff --git a/tests/ref/fate/adts-id3v2-demux b/tests/ref/fate/adts-id3v2-demux > new file mode 100644 > index 00..db00e3b81e > --- /dev/null > +++ b/tests/ref/fate/adts-id3v2-demux > @@ -0,0 +1,240 @@ > +#tb 0: 1/28224000 > +#media_type 0: audio > +#codec_id 0: aac > +#sample_rate 0: 48000 > +#channel_layout 0: 4 > +#channel_layout_name 0: mono > +0, 0, 0, 602112, 126, 0x639a3a5b > +0, 602112, 602112, 602112, 135, 0x5b1f3ced > +0,1204224,1204224, 602112, 123, 0xfcb73863 > +0,1806336,1806336, 602112, 126, 0x639a3a5b > +0,2408448,2408448, 602112, 135, 0x5b1f3ced > +0,3010560,3010560, 602112, 123, 0xfcb73863 > +0,3612672,3612672, 602112, 144, 0xa0434540 > +0,4214784,4214784, 602112, 119, 0x45053cc1 > +0,4816896,4816896, 602112, 111, 0x23043aaf > +0,5419008,5419008, 602112, 126, 0x693a3a67 > +0,6021120,6021120, 602112, 149, 0x31304a34 > +0,6623232,6623232, 602112, 111, 0x21603aab > +0,7225344,7225344, 602112, 132, 0xe42d43b3 > +0,7827456,7827456, 602112, 135, 0x5b1f3ced > +0,8429568,8429568, 602112, 123, 0xfe8b3867 > +0,9031680,9031680, 602112, 144, 0xa26b4544 > +0,9633792,9633792, 602112, 129, 0xf7de3bc7 > +0, 10235904, 10235904, 602112, 111, 0x1fbc3aa7 > +0, 10838016, 10838016, 602112, 126, 0x657a3a5f > +0, 11440128, 11440128, 602112, 140, 0xdb6542ec > +0, 12042240, 12042240, 602112, 123, 0xfcb73863 > +0, 12644352, 12644352, 602112, 138, 0xad7e44b6 > +0, 13246464, 13246464, 602112, 119, 0x46c93cc5 > +0, 13848576, 13848576, 602112, 123, 0xfe8b3867 > +0, 14450688, 14450688, 602112, 144, 0xa26b4544 > +0, 15052800, 15052800, 602112, 129, 0xf7de3bc7 > +0, 15654912, 15654912, 602112, 111, 0x1fbc3aa7 > +0, 16257024, 16257024, 602112, 126, 0x657a3a5f > +0, 16859136, 16859136, 602112, 140, 0xdb6542ec > +0, 17461248, 17461248, 602112, 123, 0xfcb73863 > +0, 18063360, 18063360, 602112, 138, 0xad7e44b6 > +0, 18665472, 18665472, 602112, 119, 0x46c93cc5 > +0, 19267584, 19267584, 602112, 123, 0xfe8b3867 > +0, 19869696, 19869696, 602112, 144, 0xa26b4544 > +0, 20471808, 20471808, 602112, 129, 0xf7de3bc7 > +0, 21073920, 21073920, 602112, 111, 0x1fbc3aa7 > +0, 21676032, 21676032, 602112, 126, 0x657a3a5f > +0, 22278144, 22278144, 602112, 140, 0xdb6542ec > +0, 22880256, 22880256, 602112, 123, 0xfcb73863 > +0, 23482368, 23482368, 602112, 138, 0xad7e44b6 > +0, 24084480, 24084480, 602112, 119, 0x488d3cc9 > +0, 24686592, 24686592, 602112, 123, 0xfe8b3867 > +0, 25288704, 25288704, 602112, 144, 0xa26b4544 > +0, 25890816, 25890816, 602112, 129, 0xf7de3bc7 > +0, 26492928, 26492928, 602112, 111,
Re: [FFmpeg-devel] [PATCH 5/6] lavf/mov: fix disposable flags in mov_fix_index
This will increase memory requirement, since we are storing one CTTS for each sample. Please see my comments on your previous patch. On Sun, Nov 19, 2017 at 1:00 PM, John Stebbinswrote: > Merges ctts_data into mov_index_entries. This allows a considerable > amount of code simplification. > --- > libavformat/isom.h | 1 + > libavformat/mov.c | 254 +++--- > --- > 2 files changed, 93 insertions(+), 162 deletions(-) > > diff --git a/libavformat/isom.h b/libavformat/isom.h > index 646b31ccc7..8fee8f4f53 100644 > --- a/libavformat/isom.h > +++ b/libavformat/isom.h > @@ -138,6 +138,7 @@ typedef struct MOVIndexRange { > } MOVIndexRange; > > typedef struct MOVIndexEntry { > +int ctts; > #define MOVINDEX_DISPOSABLE 0x01 > int8_t flags; > } MOVIndexEntry; > diff --git a/libavformat/mov.c b/libavformat/mov.c > index b064708ced..d1284a2d43 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -74,8 +74,7 @@ typedef struct MOVParseTableEntry { > > static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom); > static int mov_read_mfra(MOVContext *c, AVIOContext *f); > -static int64_t add_ctts_entry(MOVStts** ctts_data, unsigned int* > ctts_count, unsigned int* allocated_size, > - int count, int duration); > +static int64_t add_ctts_entry(MOVStreamContext *sc, int ctts, uint8_t > flags); > > static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext > *pb, > unsigned len, const char > *key) > @@ -2930,7 +2929,7 @@ static int mov_read_ctts(MOVContext *c, AVIOContext > *pb, MOVAtom atom) > { > AVStream *st; > MOVStreamContext *sc; > -unsigned int i, j, entries, ctts_count = 0; > +unsigned int i, j, entries; > > if (c->fc->nb_streams < 1) > return 0; > @@ -2945,11 +2944,12 @@ static int mov_read_ctts(MOVContext *c, > AVIOContext *pb, MOVAtom atom) > > if (!entries) > return 0; > -if (entries >= UINT_MAX / sizeof(*sc->ctts_data)) > +if (entries >= UINT_MAX / sizeof(*sc->mov_index_entries)) > return AVERROR_INVALIDDATA; > -av_freep(>ctts_data); > -sc->ctts_data = av_fast_realloc(NULL, >ctts_allocated_size, > entries * sizeof(*sc->ctts_data)); > -if (!sc->ctts_data) > +av_freep(>mov_index_entries); > +sc->mov_index_entries = av_fast_realloc(NULL, > >mov_index_allocated_size, > +entries * > sizeof(*sc->mov_index_entries)); > +if (!sc->mov_index_entries) > return AVERROR(ENOMEM); > > for (i = 0; i < entries && !pb->eof_reached; i++) { > @@ -2965,15 +2965,15 @@ static int mov_read_ctts(MOVContext *c, > AVIOContext *pb, MOVAtom atom) > > /* Expand entries such that we have a 1-1 mapping with samples. */ > for (j = 0; j < count; j++) > -add_ctts_entry(>ctts_data, _count, > >ctts_allocated_size, 1, duration); > +add_ctts_entry(sc, duration, 0); > > av_log(c->fc, AV_LOG_TRACE, "count=%d, duration=%d\n", > count, duration); > > if (FFNABS(duration) < -(1<<28) && i+2 av_log(c->fc, AV_LOG_WARNING, "CTTS invalid\n"); > -av_freep(>ctts_data); > -sc->ctts_count = 0; > +av_freep(>mov_index_entries); > +sc->nb_mov_index_entries = 0; > return 0; > } > > @@ -2981,8 +2981,6 @@ static int mov_read_ctts(MOVContext *c, AVIOContext > *pb, MOVAtom atom) > mov_update_dts_shift(sc, duration); > } > > -sc->ctts_count = ctts_count; > - > if (pb->eof_reached) > return AVERROR_EOF; > > @@ -3063,9 +3061,9 @@ static int get_edit_list_entry(MOVContext *mov, > * Find the closest previous frame to the timestamp_pts, in e_old index > * entries. Searching for just any frame / just key frames can be > controlled by > * last argument 'flag'. > - * Note that if ctts_data is not NULL, we will always search for a key > frame > - * irrespective of the value of 'flag'. If we don't find any keyframe, we > will > - * return the first frame of the video. > + * Note that if mov_index_entries is not NULL, we will always search for a > + * key frame irrespective of the value of 'flag'. If we don't find any > + * keyframe, we will return the first frame of the video. > * > * Here the timestamp_pts is considered to be a presentation timestamp and > * the timestamp of index entries are considered to be decoding > timestamps. > @@ -3073,27 +3071,23 @@ static int get_edit_list_entry(MOVContext *mov, > * Returns 0 if successful in finding a frame, else returns -1. > * Places the found index corresponding output arg. > * > - * If ctts_old is not NULL, then refines the searched entry by searching > - * backwards from the found timestamp, to find the frame with correct PTS. > - * > - * Places the found ctts_index
Re: [FFmpeg-devel] [PATCH] avcodec/ass: Fix a memory leak defect.
On Mon, 12 Feb 2018 20:56:25 +0800 Gang Fan(范刚)wrote: > Thanks to Hendrik > Here is the new patch: > > From 642a413080f20f9515321e42056248e86e003997 Mon Sep 17 00:00:00 2001 > From: Fan Gang > Date: Mon, 12 Feb 2018 20:55:06 +0800 > Subject: [PATCH] avcodec/ass: Fix a memory leak defect when realloc fails. > > --- > libavcodec/ass_split.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c > index 872528b..eebe239 100644 > --- a/libavcodec/ass_split.c > +++ b/libavcodec/ass_split.c > @@ -249,7 +249,7 @@ static const char *ass_split_section(ASSSplitContext > *ctx, const char *buf) > const ASSSection *section = _sections[ctx->current_section]; > int *number = >field_number[ctx->current_section]; > int *order = ctx->field_order[ctx->current_section]; > -int *tmp, i, len; > +int i, len; > > while (buf && *buf) { > if (buf[0] == '[') { > @@ -280,9 +280,7 @@ static const char *ass_split_section(ASSSplitContext > *ctx, const char *buf) > while (!is_eol(*buf)) { > buf = skip_space(buf); > len = strcspn(buf, ", \r\n"); > -if (!(tmp = av_realloc_array(order, (*number + 1), > sizeof(*order > -return NULL; > -order = tmp; > +av_reallocp_array(, (*number + 1), > sizeof(*order)); > order[*number] = -1; > for (i=0; section->fields[i].name; i++) > if (!strncmp(buf, section->fields[i].name, len)) { The patch formatting is broken (line breaks). It will be cumbersome to apply it, which most likely will mean nobody is going to try. Never copy a patch into the text field of your email client. Instead you should do one of these things: - just attach the patch as text attachment - use git send-email ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: remove av_codec_init_static()
On Mon, 12 Feb 2018 12:42:10 +0700 Muhammad Faizwrote: > Modify the behavior of init_static_data(). > > Signed-off-by: Muhammad Faiz > --- Seems OK, but I'm also not sure about the benefit. The fundamental problem that these codecs need to mutate AVCodec before the users sees it won't go away. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 4/6] lavf/mov: set AV_PKT_FLAG_DISPOSABLE from sdtp box
On Sun, Nov 19, 2017 at 12:46 PM, John Stebbinswrote: > --- > libavformat/isom.h | 10 ++ > libavformat/mov.c | 92 ++ > --- > libavformat/utils.c | 3 +- > 3 files changed, 99 insertions(+), 6 deletions(-) > > diff --git a/libavformat/isom.h b/libavformat/isom.h > index 65676fb0f5..646b31ccc7 100644 > --- a/libavformat/isom.h > +++ b/libavformat/isom.h > @@ -137,11 +137,19 @@ typedef struct MOVIndexRange { > int64_t end; > } MOVIndexRange; > > +typedef struct MOVIndexEntry { > +#define MOVINDEX_DISPOSABLE 0x01 > +int8_t flags; > +} MOVIndexEntry; > + > typedef struct MOVStreamContext { > AVIOContext *pb; > int pb_is_copied; > int ffindex; ///< AVStream index > int next_chunk; > +MOVIndexEntry * mov_index_entries; > +int nb_mov_index_entries; > +unsigned int mov_index_allocated_size; > unsigned int chunk_count; > int64_t *chunk_offsets; > unsigned int stts_count; > @@ -166,6 +174,8 @@ typedef struct MOVStreamContext { > int keyframe_absent; > unsigned int keyframe_count; > int *keyframes; > +unsigned int frame_deps_count; > +int *frame_deps; > should this be uint8_t ? Also this will increase the memory requirement quite a bit, since we are storing for 2 int's for every sample . If we are doing this only to find the disposable samples then, can we just store the sample indices of the samples which are disposable while parsing sdtp instead of having one entry for each sample. > int time_scale; > int64_t time_offset; ///< time offset of the edit list entries > int current_sample; > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 5c9f926bce..b064708ced 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -2680,6 +2680,43 @@ static int mov_read_stps(MOVContext *c, AVIOContext > *pb, MOVAtom atom) > return 0; > } > > +static int mov_read_sdtp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > +{ > +AVStream *st; > +MOVStreamContext *sc; > +unsigned int i, entries; > + > +if (c->fc->nb_streams < 1) > +return 0; > +st = c->fc->streams[c->fc->nb_streams-1]; > +sc = st->priv_data; > + > +if (atom.size < 8) > +return 0; > + > +avio_r8(pb); /* version */ > +avio_rb24(pb); /* flags */ > + > +entries = atom.size - 4; > +sc->frame_deps_count = 0; > +sc->frame_deps = av_malloc_array(entries, sizeof(*sc->frame_deps)); > + > +if (!sc->frame_deps) > +return AVERROR(ENOMEM); > + > +for (i = 0; i < entries && !pb->eof_reached; i++) { > +sc->frame_deps[i] = avio_r8(pb); > +} > + > +sc->frame_deps_count = i; > + > +if (pb->eof_reached) > +return AVERROR_EOF; > + > + > +return 0; > +} > + > static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom) > { > AVStream *st; > @@ -3635,15 +3672,40 @@ static void mov_build_index(MOVContext *mov, > AVStream *st) > > if (!sc->sample_count || st->nb_index_entries) > return; > -if (sc->sample_count >= UINT_MAX / sizeof(*st->index_entries) - > st->nb_index_entries) > +if (sc->sample_count >= UINT_MAX / sizeof(*st->index_entries)) > return; > -if (av_reallocp_array(>index_entries, > - st->nb_index_entries + sc->sample_count, > +if (av_reallocp_array(>index_entries, sc->sample_count, >sizeof(*st->index_entries)) < 0) { > st->nb_index_entries = 0; > return; > } > -st->index_entries_allocated_size = (st->nb_index_entries + > sc->sample_count) * sizeof(*st->index_entries); > +st->index_entries_allocated_size = sc->sample_count * > + sizeof(*st->index_entries); > + > +// realloc mov_index_entries if needed for frame dependencies > +// or if it already exists for ctts > +if (sc->frame_deps || sc->mov_index_entries) { > +// make mov_index_entries the same number of entries as > +// index_entries > +if (av_reallocp_array(>mov_index_entries, > + sc->sample_count, > + sizeof(*sc->mov_index_entries)) < 0) { > +sc->nb_mov_index_entries = 0; > +return; > +} > +sc->mov_index_allocated_size = sc->sample_count * > + sizeof(*sc->mov_index_ > entries); > + > +if (sc->sample_count > sc->nb_mov_index_entries) > +// In case there were samples without ctts entries, > ensure they > +// get zero valued entries. This ensures clips which mix > boxes > +// with and without ctts entries don't pickup > uninitialized > +// data. > +
Re: [FFmpeg-devel] [PATCH] avcodec/dpx: Support for RGB and RGBA 12-bit packed decoding
On 09/02/2018 11:39, Carl Eugen Hoyos wrote: I think the question is out of topic for this patch proposal, as this question is global for all flavors of DPX (also the ones already supported by FFmpeg, i.e. FFmpeg already supports RGBA 12-bit filled with Method A, here I just add the support for packed content, without adding anything else about alpha support in FFmpeg, this patch changes nothing about alpha support in FFmpeg and/or DPX) and the need for validating such patch is about sample files for RGBA 12-bit packed (RGBA 12-bit filled with method A being already available) and not for the content itself. Sorry, I thought you had access to such a sample and we would just have to test it, no? https://mediaarea.net/temp/uncropped_DPX_4K_16bit_Overscan15pros.dpx is indicated by the person who provided it as with DPX alpha channel used for actually storing infrared ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: remove av_codec_init_static()
On 2/12/2018 2:42 AM, Muhammad Faiz wrote: > Modify the behavior of init_static_data(). > > Signed-off-by: Muhammad Faiz> --- > libavcodec/allcodecs.c | 16 > libavcodec/avcodec.h | 4 +++- > libavcodec/libvpxdec.c | 15 ++- > libavcodec/libvpxenc.c | 15 ++- > libavcodec/libx264.c | 11 ++- > libavcodec/libx265.c | 11 ++- > 6 files changed, 55 insertions(+), 17 deletions(-) > > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > index 774b78ef09..02910b5594 100644 > --- a/libavcodec/allcodecs.c > +++ b/libavcodec/allcodecs.c > @@ -757,24 +757,16 @@ extern AVCodec ff_vp9_vaapi_encoder; > > #include "libavcodec/codec_list.c" > > -static AVOnce av_codec_static_init = AV_ONCE_INIT; > -static void av_codec_init_static(void) > -{ > -for (int i = 0; codec_list[i]; i++) { > -if (codec_list[i]->init_static_data) > -codec_list[i]->init_static_data((AVCodec*)codec_list[i]); > -} > -} > - > const AVCodec *av_codec_iterate(void **opaque) > { > uintptr_t i = (uintptr_t)*opaque; > const AVCodec *c = codec_list[i]; > > -ff_thread_once(_codec_static_init, av_codec_init_static); > - > -if (c) > +if (c) { > +if (c->init_static_data) > +c->init_static_data(); > *opaque = (void*)(i + 1); > +} > > return c; > } > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > index ad0b48a839..d89bf300fc 100644 > --- a/libavcodec/avcodec.h > +++ b/libavcodec/avcodec.h > @@ -3443,8 +3443,10 @@ typedef struct AVCodec { > * > * This is not intended for time consuming operations as it is > * run for every codec regardless of that codec being used. > + * This may be called multiple times from different threads, the callee > + * has responsibility for thread synchronization. > */ > -void (*init_static_data)(struct AVCodec *codec); > +void (*init_static_data)(void); What's the benefit of removing the parameter? > > int (*init)(AVCodecContext *); > int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size, > diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c > index 04f27d3396..f2003b836b 100644 > --- a/libavcodec/libvpxdec.c > +++ b/libavcodec/libvpxdec.c > @@ -30,6 +30,7 @@ > #include "libavutil/common.h" > #include "libavutil/imgutils.h" > #include "libavutil/intreadwrite.h" > +#include "libavutil/thread.h" > #include "avcodec.h" > #include "internal.h" > #include "libvpx.h" > @@ -299,6 +300,18 @@ static av_cold int vp9_init(AVCodecContext *avctx) > return vpx_init(avctx, _codec_vp9_dx_algo, 0); > } > > +static av_cold void vp9_init_static_once(void) > +{ > +extern AVCodec ff_libvpx_vp9_decoder; > +ff_vp9_init_static(_libvpx_vp9_decoder); > +} > + > +static av_cold void vp9_init_static(void) > +{ > +static AVOnce once = AV_ONCE_INIT; > +ff_thread_once(, vp9_init_static_once); > +} > + > AVCodec ff_libvpx_vp9_decoder = { > .name = "libvpx-vp9", > .long_name = NULL_IF_CONFIG_SMALL("libvpx VP9"), > @@ -309,7 +322,7 @@ AVCodec ff_libvpx_vp9_decoder = { > .close = vpx_free, > .decode = vpx_decode, > .capabilities = AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_DR1, > -.init_static_data = ff_vp9_init_static, > +.init_static_data = vp9_init_static, I think you can remove the init_static_data call to ff_vp9_init_static from the decoder altogether. It just sets AVCodec.pix_fmts, which afaics is only needed for the encoder. Doing it would also let us get rid of libvpx.c, as everything there can then be moved into libvpxenc.c > .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles), > .wrapper_name = "libvpx", > }; > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > index d0bd1e997a..086dd5defa 100644 > --- a/libavcodec/libvpxenc.c > +++ b/libavcodec/libvpxenc.c > @@ -39,6 +39,7 @@ > #include "libavutil/intreadwrite.h" > #include "libavutil/mathematics.h" > #include "libavutil/opt.h" > +#include "libavutil/thread.h" > > /** > * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h. > @@ -1209,6 +1210,18 @@ static av_cold int vp9_init(AVCodecContext *avctx) > return vpx_init(avctx, vpx_codec_vp9_cx()); > } > > +static av_cold void vp9_init_static_once(void) > +{ > +extern AVCodec ff_libvpx_vp9_encoder; > +ff_vp9_init_static(_libvpx_vp9_encoder); > +} > + > +static av_cold void vp9_init_static(void) > +{ > +static AVOnce once = AV_ONCE_INIT; > +ff_thread_once(, vp9_init_static_once); > +} > + > static const AVClass class_vp9 = { > .class_name = "libvpx-vp9 encoder", > .item_name = av_default_item_name, > @@ -1229,7 +1242,7 @@ AVCodec ff_libvpx_vp9_encoder = { > .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles), > .priv_class = _vp9, > .defaults = defaults, > -.init_static_data =
Re: [FFmpeg-devel] [PATCH 3/4] avformat/mpegenc - accept PCM_DVD streams
On 2/3/2018 4:02 AM, Michael Niedermayer wrote: --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c + +if (st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD) { +/* Skip first 3 bytes of packet data, which comprise PCM header + and will be written fresh by this muxer. */ +buf += 3; +size -= 3; Can this be reached with size < 3 ? if so it would probably do something bad Possible if input file is badly muxed, but revised patch attached. FATE patch follows in next email. Regards, Gyan From 75d6236f1964d014f615acf4dc48dec43cadf6a1 Mon Sep 17 00:00:00 2001 From: Gyan DoshiDate: Wed, 7 Feb 2018 18:05:08 +0530 Subject: [PATCH v3] avformat/mpegenc - accept PCM_DVD streams PCM_S16BE stream packets in MPEG-PS have a 3-byte header and are recognized as PCM_DVD by the demuxer which prevents their correct remuxing in MPEG-1/2 PS. --- libavformat/mpegenc.c | 23 +-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index 695de3f081..895873accd 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -353,7 +353,8 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) if (!s->is_mpeg2 && (st->codecpar->codec_id == AV_CODEC_ID_AC3 || st->codecpar->codec_id == AV_CODEC_ID_DTS || - st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE)) + st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE || + st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD)) av_log(ctx, AV_LOG_WARNING, "%s in MPEG-1 system streams is not widely supported, " "consider using the vob or the dvd muxer " @@ -363,7 +364,12 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) stream->id = ac3_id++; } else if (st->codecpar->codec_id == AV_CODEC_ID_DTS) { stream->id = dts_id++; -} else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE) { +} else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE || + st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD) { +if (st->codecpar->bits_per_coded_sample != 16) { +av_log(ctx, AV_LOG_ERROR, "Only 16 bit LPCM streams can be muxed.\n"); +goto fail; +} stream->id = lpcm_id++; for (j = 0; j < 4; j++) { if (lpcm_freq_tab[j] == st->codecpar->sample_rate) @@ -1150,6 +1156,19 @@ static int mpeg_mux_write_packet(AVFormatContext *ctx, AVPacket *pkt) return AVERROR(ENOMEM); pkt_desc->pts= pts; pkt_desc->dts= dts; + +if (st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD) { +if (size < 3) { +av_log(ctx, AV_LOG_ERROR, "Invalid packet size %d\n", size); +return -1; +} + +/* Skip first 3 bytes of packet data, which comprise PCM header + and will be written fresh by this muxer. */ +buf += 3; +size -= 3; +} + pkt_desc->unwritten_size = pkt_desc->size = size; if (!stream->predecode_packet) -- 2.11.1.windows.1___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 3/4] avformat/mpegenc - accept PCM_DVD streams
On 2/3/2018 3:59 AM, Michael Niedermayer wrote: Subject: [PATCH v2] avformat/mpegenc - accept PCM_DVD streams PCM_S16BE stream packets in MPEG-PS have a 3-byte header and recognized as PCM_DVD by the demuxer which prevents their proper remuxing in MPEG-1/2 PS. its probably a good idea to add a fate test for this too. (could be in a seperate patch) FATE patch and sample file attached. Sample file should go into (new) mpegps directory in suite. Regards, Gyan From cbeb8915b4149abfc33936a94c3280cf6872d9e6 Mon Sep 17 00:00:00 2001 From: Gyan DoshiDate: Mon, 12 Feb 2018 23:59:09 +0530 Subject: [PATCH] fate/mpegps: add fate test for remux of 16-bit PCM_DVD stream in MPEG-PS --- tests/Makefile| 1 + tests/fate/mpegps.mak | 9 + 2 files changed, 10 insertions(+) create mode 100644 tests/fate/mpegps.mak diff --git a/tests/Makefile b/tests/Makefile index 327e3f4420..f1ac610454 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -149,6 +149,7 @@ include $(SRC_PATH)/tests/fate/mov.mak include $(SRC_PATH)/tests/fate/mp3.mak include $(SRC_PATH)/tests/fate/mpc.mak include $(SRC_PATH)/tests/fate/mpeg4.mak +include $(SRC_PATH)/tests/fate/mpegps.mak include $(SRC_PATH)/tests/fate/mpegts.mak include $(SRC_PATH)/tests/fate/mxf.mak include $(SRC_PATH)/tests/fate/opus.mak diff --git a/tests/fate/mpegps.mak b/tests/fate/mpegps.mak new file mode 100644 index 00..56a88640bc --- /dev/null +++ b/tests/fate/mpegps.mak @@ -0,0 +1,9 @@ +# This tests that the mpegps muxer supports a 16-bit pcm_dvd stream in remuxing (-c:a copy) +FATE_MPEGPS-$(call DEMMUX, MPEGPS, MPEG1SYSTEM) += fate-mpegps-pcm_dvd-remux +fate-mpegps-pcm_dvd-remux: CMD = md5 -i $(TARGET_SAMPLES)/mpegps/pcm_aud.mpg -vn -c copy -fflags +bitexact -f mpeg +fate-mpegps-pcm_dvd-remux: CMP = oneline +fate-mpegps-pcm_dvd-remux: REF = 28e5de42b1b00d7fa6f98df6a82d122c + + +FATE_SAMPLES_FFMPEG += $(FATE_MPEGPS-yes) +fate-mpegps: $(FATE_MPEGPS-yes) -- 2.11.1.windows.1 pcm_aud.mpg Description: MPEG movie ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter/af_loudnorm: correctly initialize PTS
On 2/4/18, Muhammad Faizwrote: > On Sun, Feb 4, 2018 at 3:32 PM, Paul B Mahol wrote: >> On 2/4/18, Muhammad Faiz wrote: >>> On Sat, Feb 3, 2018 at 9:22 PM, Niklas Haas wrote: From: Niklas Haas Right now, the PTS always starts out as 0, which causes problems on a seek or when inserting this filter mid-stream. Initialize it instead to AV_NOPTS_VALUE and copy the PTS from the first frame instead if this is the case. --- libavfilter/af_loudnorm.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavfilter/af_loudnorm.c b/libavfilter/af_loudnorm.c index a7f11cbe6e..314b25fa39 100644 --- a/libavfilter/af_loudnorm.c +++ b/libavfilter/af_loudnorm.c @@ -431,6 +431,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) av_frame_copy_props(out, in); } +if (s->pts == AV_NOPTS_VALUE) +s->pts = in->pts; + out->pts = s->pts; src = (const double *)in->data[0]; dst = (double *)out->data[0]; @@ -763,7 +766,7 @@ static int config_input(AVFilterLink *inlink) inlink->partial_buf_size = frame_size(inlink->sample_rate, 3000); } -s->pts = +s->pts = AV_NOPTS_VALUE; s->buf_index = s->prev_buf_index = s->limiter_buf_index = 0; -- 2.16.1 >>> >>> Output pts ideally should be based on input pts in all cases >>> (not only in the first pts case), because input pts may be non-monotonic. >> >> That have nothing to do with this patch. > > Of course, if ideal fix isn't trivial, this fix is enough. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > So, if there are no more comments, I gonna apply this soon. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] GSoC 2018
Hi, > yet again, the registration for Google Summer of Code 2018 has opened. FFmpeg has just been accepted for Google Summer of Code 2018 - thanks for everyone's contribution so far! If you're a mentor this year, you should have got another mail already - if not, please ping me on that. The student application period will begin 12th of March. Thanks, Thilo ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] avformat/mov: Increase support for common encryption.
On Tue, Jan 30, 2018 at 11:27 AM, Jacob Trimblewrote: > On Wed, Jan 24, 2018 at 5:46 PM, Michael Niedermayer > wrote: >> On Wed, Jan 24, 2018 at 11:43:26AM -0800, Jacob Trimble wrote: >>> On Mon, Jan 22, 2018 at 7:38 PM, Michael Niedermayer >>> wrote >>> > [...] >>> >> This removes support for saio/saiz atoms, but it was incorrect before. >>> >> A follow-up change will add correct support for those. >>> > >>> > This removal should be done by a seperate patch if it is done. >>> > diff has matched up the removed function with a added one making this >>> > hard to read as is >>> > >>> >>> The problem is that the old code used the saiz atoms to parse the senc >>> atom. I split the patch up for readability, but the two patches need >>> to be applied at the same time (or squashed) since the first breaks >>> encrypted content. But I can squash them again if it is preferable to >>> not have a commit that intentionally breaks things. >> >> I didnt investigate this deeply so there is likely a better option that >> i miss but you could just remove the functions which become unused in a >> subsequent patch to prevent diff from messing the line matching up totally >> > > Done. > >> >>> >>> > >>> >> >>> >> Signed-off-by: Jacob Trimble >>> >> --- >>> >> libavformat/isom.h | 20 +- >>> >> libavformat/mov.c | 432 >>> >> ++--- >>> >> tests/fate/mov.mak | 8 + >>> >> tests/ref/fate/mov-frag-encrypted | 57 + >>> >> tests/ref/fate/mov-tenc-only-encrypted | 57 + >>> >> 5 files changed, 422 insertions(+), 152 deletions(-) >>> >> create mode 100644 tests/ref/fate/mov-frag-encrypted >>> >> create mode 100644 tests/ref/fate/mov-tenc-only-encrypted >>> > >>> > This depends on other patches you posted, this should be mentioned or >>> > all patches should be in the same patchset in order >>> > >>> >>> This depends on >>> http://ffmpeg.org/pipermail/ffmpeg-devel/2018-January/223754.html and >>> the recently pushed change to libavutil/aes_ctr. Should I add >>> something to the commit message or is that enough? >> >> If you post a new version, then there should be a mail or comment explaining >> any dependancies on yet to be applied patches. >> It should not be in the commit messages or commited changes ideally >> This way people trying to test code dont need to guess what they need >> to apply first before a patchset >> >> >> [...] >>> >> +static int get_current_encryption_info(MOVContext *c, >>> >> MOVEncryptionIndex **encryption_index, MOVStreamContext **sc) >>> >> { >>> >> +MOVFragmentStreamInfo *frag_stream_info; >>> >> AVStream *st; >>> >> -MOVStreamContext *sc; >>> >> -size_t auxiliary_info_size; >>> >> +int i; >>> >> >>> >> -if (c->decryption_key_len == 0 || c->fc->nb_streams < 1) >>> >> -return 0; >>> >> +frag_stream_info = get_current_frag_stream_info(>frag_index); >>> >> +if (frag_stream_info) { >>> >> +for (i = 0; i < c->fc->nb_streams; i++) { >>> >> +if (c->fc->streams[i]->id == frag_stream_info->id) { >>> >> + st = c->fc->streams[i]; >>> >> + break; >>> >> +} >>> >> +} >>> > >>> > the indention is inconsistent here >>> > >>> >>> No it's not, it looks like it because the diff looks odd. If you >>> apply the patch, the indentation in this method is consistent. >> >> Indention depth is 4 in mov*.c >> the hunk seems to add lines with a depth of 2 >> I would be surprised if this is not in the file after applying the patch >> >> personally i dont care about the depth that much but i know many other people >> care so this needs to be fixed before this can be applied > > Didn't see that. Fixed and did a grep for incorrect indentations. > >> >> [...] >> >> -- >> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB >> >> Let us carefully observe those good qualities wherein our enemies excel us >> and endeavor to excel them, by avoiding what is faulty, and imitating what >> is excellent in them. -- Plutarch >> >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> Ping. This depends on http://ffmpeg.org/pipermail/ffmpeg-devel/2018-January/223754.html. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] h264_mp4toannexb_bsf: Fix start code size of parameter sets.
Any parameter set shall have start code of at least 4 byte size. --- libavcodec/h264_mp4toannexb_bsf.c| 22 +++--- tests/ref/fate/h264-bsf-mp4toannexb | 2 +- tests/ref/fate/h264_mp4toannexb_ticket2991 | 22 +++--- tests/ref/fate/h264_mp4toannexb_ticket5927 | 10 +- tests/ref/fate/h264_mp4toannexb_ticket5927_2 | 10 +- tests/ref/fate/segment-mp4-to-ts | 4 ++-- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index 163d0f5..292d106 100644 --- a/libavcodec/h264_mp4toannexb_bsf.c +++ b/libavcodec/h264_mp4toannexb_bsf.c @@ -39,21 +39,21 @@ typedef struct H264BSFContext { static int alloc_and_copy(AVPacket *out, const uint8_t *sps_pps, uint32_t sps_pps_size, - const uint8_t *in, uint32_t in_size) + const uint8_t *in, uint32_t in_size, int ps) { uint32_t offset = out->size; -uint8_t nal_header_size = offset ? 3 : 4; +uint8_t start_code_size = offset == 0 || ps ? 4 : 3; int err; -err = av_grow_packet(out, sps_pps_size + in_size + nal_header_size); +err = av_grow_packet(out, sps_pps_size + in_size + start_code_size); if (err < 0) return err; if (sps_pps) memcpy(out->data + offset, sps_pps, sps_pps_size); -memcpy(out->data + sps_pps_size + nal_header_size + offset, in, in_size); -if (!offset) { -AV_WB32(out->data + sps_pps_size, 1); +memcpy(out->data + sps_pps_size + start_code_size + offset, in, in_size); +if (start_code_size == 4) { +AV_WB32(out->data + offset + sps_pps_size, 1); } else { (out->data + offset + sps_pps_size)[0] = (out->data + offset + sps_pps_size)[1] = 0; @@ -221,7 +221,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) if ((ret = alloc_and_copy(out, ctx->par_out->extradata + s->sps_offset, s->pps_offset != -1 ? s->pps_offset : ctx->par_out->extradata_size - s->sps_offset, - buf, nal_size)) < 0) + buf, nal_size, 1)) < 0) goto fail; s->idr_sps_seen = 1; goto next_nal; @@ -239,21 +239,21 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) if (s->new_idr && unit_type == 5 && !s->idr_sps_seen && !s->idr_pps_seen) { if ((ret=alloc_and_copy(out, ctx->par_out->extradata, ctx->par_out->extradata_size, - buf, nal_size)) < 0) + buf, nal_size, 1)) < 0) goto fail; s->new_idr = 0; /* if only SPS has been seen, also insert PPS */ } else if (s->new_idr && unit_type == 5 && s->idr_sps_seen && !s->idr_pps_seen) { if (s->pps_offset == -1) { av_log(ctx, AV_LOG_WARNING, "PPS not present in the stream, nor in AVCC, stream may be unreadable\n"); -if ((ret = alloc_and_copy(out, NULL, 0, buf, nal_size)) < 0) +if ((ret = alloc_and_copy(out, NULL, 0, buf, nal_size, 0)) < 0) goto fail; } else if ((ret = alloc_and_copy(out, ctx->par_out->extradata + s->pps_offset, ctx->par_out->extradata_size - s->pps_offset, -buf, nal_size)) < 0) +buf, nal_size, 1)) < 0) goto fail; } else { -if ((ret=alloc_and_copy(out, NULL, 0, buf, nal_size)) < 0) +if ((ret=alloc_and_copy(out, NULL, 0, buf, nal_size, unit_type == 7 || unit_type == 8)) < 0) goto fail; if (!s->new_idr && unit_type == 1) { s->new_idr = 1; diff --git a/tests/ref/fate/h264-bsf-mp4toannexb b/tests/ref/fate/h264-bsf-mp4toannexb index 2049f39..7cd086a 100644 --- a/tests/ref/fate/h264-bsf-mp4toannexb +++ b/tests/ref/fate/h264-bsf-mp4toannexb @@ -1 +1 @@ -5f04c27cc6ee8625fe2405fb0f7da9a3 +f340e7ca9a46d437af4e96f6c8de221c diff --git a/tests/ref/fate/h264_mp4toannexb_ticket2991 b/tests/ref/fate/h264_mp4toannexb_ticket2991 index 76bdf3c..3245ef4 100644 --- a/tests/ref/fate/h264_mp4toannexb_ticket2991 +++ b/tests/ref/fate/h264_mp4toannexb_ticket2991 @@ -1,12 +1,12 @@ -05d66e60ab22ee004720e0051af0fe74 *tests/data/fate/h264_mp4toannexb_ticket2991.h264 -1985815 tests/data/fate/h264_mp4toannexb_ticket2991.h264 -#extradata 0: 47, 0x3a590d55 +dba672c154b41414cf26aae967c27eef *tests/data/fate/h264_mp4toannexb_ticket2991.h264 +1985823 tests/data/fate/h264_mp4toannexb_ticket2991.h264 +#extradata 0: 48, 0x47ae0d55 #tb 0: 1/120
Re: [FFmpeg-devel] [PATCH] avformat/opensrt: add Haivision Open SRT protocol
If you or any other developer is against someone receiving git write access you only need to object to the patch adding him to the MAINTAINERS file. Thats one of the reasons why there is a MAINTAINERs file. It would be ideal IMO if for each part of teh codebase at least one person with write access cares/"Maintains" it. Is there someone who already has write access who wants to take care of opensrt.c ? (it seemed there is little interrest from teh lack of replies in the thread so far) Also i belive there already is a developer from nablet who is in the MAINTAINERs file and has write access. thanks thanks for your comments. I am going to send new patch later this week, as there are comments from the Nicolas George to be addressed anyway. it was your suggestion to edit MAINTAINERs file, so I followed it, but now I am disappointed. so what should I do now? I see the following options: 1) do not edit MAINTAINERs file (leave it as it was before) 2) add opensrt.c entry for existing maintainer from Nablet (Ivan Uskov) 3) change opensrt.c entry to another maintainer from Nablet (Sven Dueking ) which one do you prefer/suggest? if I change maintainer entry, does it imply what patch should be sent from maintainer's email and commit author should also match maintainer's email? P.S. added file (opensrt.c) doesn't have a Nablet or Haivision copyright - it has regular ffmpeg copyright used across the ffmpeg codebase, so it's not different in that aspect from other files, like tcp.c or udp.c. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] reitnerlace - tinterlace-like filter under LGPL
Hello, there have been some discussions about tinterlace filter licensing. In the end, I was unable to contact all the authorship holders. The main author, one from MPlayer project, is Michael Zucchi. It is quite probably that the copyright is holden by the company that he worked for, Ximian, which no longer exists. It is less probably that I'll came up with the approval off all the parts involved in this deal. However, some of the later developers of tinterlace agreed to release the parts they wrote under LGPL. I mention here Thomas Mundt and Stefano Sabatini. This being said, I come up with a new filter - reinterlace - which implements all the tinterlace functionalities and adds a few more. The new filter is added to ffmpeg without --enable-gpl and/or --enable-nonfree. However, it these configure options are specified, the reinterlace will use ASM opts, imported from tinterlace. I've used support for 16bit depth video from the code written by Thomas Mundt. I added 2 new modes MERGE_BFF and MERGE_TFF. I've changed MODE_PAD, so it does not drop last frame from the input - tinterlace did so. In terms of performance, reinterlace gives basically the same fps as tinterlace does. Here is the patch thats adds the filter. If everything goes well with this patch, I'll add a new patch that changes current tinterlace with reinterlace. Thanks, -Vasile Toncu From 45010f4b4671edfe1318b84285d09dd28a882d63 Mon Sep 17 00:00:00 2001 From: Vasile ToncuDate: Mon, 12 Feb 2018 14:16:27 +0200 Subject: [PATCH] Added reitnerlace filter. --- libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/reinterlace.h | 141 +++ libavfilter/vf_reinterlace.c | 773 ++ libavfilter/x86/Makefile | 1 + libavfilter/x86/vf_reinterlace_init.c | 101 + 6 files changed, 1018 insertions(+) create mode 100644 libavfilter/reinterlace.h create mode 100644 libavfilter/vf_reinterlace.c create mode 100644 libavfilter/x86/vf_reinterlace_init.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 6a60836..c3095ba 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -286,6 +286,7 @@ OBJS-$(CONFIG_RANDOM_FILTER) += vf_random.o OBJS-$(CONFIG_READEIA608_FILTER) += vf_readeia608.o OBJS-$(CONFIG_READVITC_FILTER) += vf_readvitc.o OBJS-$(CONFIG_REALTIME_FILTER) += f_realtime.o +OBJS-$(CONFIG_REINTERLACE_FILTER) += vf_reinterlace.o OBJS-$(CONFIG_REMAP_FILTER) += vf_remap.o framesync.o OBJS-$(CONFIG_REMOVEGRAIN_FILTER) += vf_removegrain.o OBJS-$(CONFIG_REMOVELOGO_FILTER) += bbox.o lswsutils.o lavfutils.o vf_removelogo.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 9adb109..60fb9b5 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -295,6 +295,7 @@ static void register_all(void) REGISTER_FILTER(READEIA608, readeia608, vf); REGISTER_FILTER(READVITC, readvitc, vf); REGISTER_FILTER(REALTIME, realtime, vf); + REGISTER_FILTER(REINTERLACE, reinterlace, vf); REGISTER_FILTER(REMAP, remap, vf); REGISTER_FILTER(REMOVEGRAIN, removegrain, vf); REGISTER_FILTER(REMOVELOGO, removelogo, vf); diff --git a/libavfilter/reinterlace.h b/libavfilter/reinterlace.h new file mode 100644 index 000..bb66f63 --- /dev/null +++ b/libavfilter/reinterlace.h @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2017 Vasile Toncu + Copyright (c) 2017 Thomas Mundt + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "video.h" +#include "libavutil/avassert.h" +#include "libavutil/imgutils.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" + +#include "libavutil/bswap.h" + +enum FilterMode { + MODE_MERGE, + MODE_DROP_EVEN, + MODE_DROP_ODD, + MODE_PAD, + MODE_INTERLEAVE_TOP, + MODE_INTERLEAVE_BOTTOM, + MODE_INTERLACE_X2, + MODE_MERGE_X2, + MODE_MERGE_TFF, +
Re: [FFmpeg-devel] [PATCH v2 6/8] avfilter/silencedetect: fix for ticket 6968 Fix missing log of silence_end at end of stream
Here, the "fix for ticket 6968" should be the header, so I think the format is correct ? Everything behind ("Fix missing...") should be the body of the commit message. NB: thanks to you to have reported it previously, I was not aware of this ticket when I started work on this issue! Nicolas Gaullier -Message d'origine- De : ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] De la part de Carl Eugen Hoyos Envoyé : lundi 12 février 2018 14:52 À : FFmpeg development discussions and patchesObjet : Re: [FFmpeg-devel] [PATCH v2 6/8] avfilter/silencedetect: fix for ticket 6968 Fix missing log of silence_end at end of stream 2018-02-12 10:48 GMT+01:00 Nicolas Gaullier : > From: nicolas gaullier Please mention ticket #6968 in the commit message if it is related. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 1/8] avfilter/silencedetect: add mono mode in mono mode, silence is detected in any single channel (instead of all them simultaneously)
>I believe there is an issue with your commit message: >It should be something like: >lavfi/silencedetect: Add mono mode > >In mono mode, silence is detected... >(Note the two linebreaks, other differences are irrelevant.) > >Carl Eugen Sorry, all my patches are missing an empty newline to separate the header and the body of the commit messages, I just realize my mistake, thank you. I will fix that in the next post at the end of the current review. Nicolas Gaullier ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/ass: Fix a memory leak defect.
On Mon, Feb 12, 2018 at 1:56 PM, Gang Fan(范刚)wrote: > Thanks to Hendrik > Here is the new patch: > > From 642a413080f20f9515321e42056248e86e003997 Mon Sep 17 00:00:00 2001 > From: Fan Gang > Date: Mon, 12 Feb 2018 20:55:06 +0800 > Subject: [PATCH] avcodec/ass: Fix a memory leak defect when realloc fails. > > --- > libavcodec/ass_split.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c > index 872528b..eebe239 100644 > --- a/libavcodec/ass_split.c > +++ b/libavcodec/ass_split.c > @@ -249,7 +249,7 @@ static const char *ass_split_section(ASSSplitContext > *ctx, const char *buf) > const ASSSection *section = _sections[ctx->current_section]; > int *number = >field_number[ctx->current_section]; > int *order = ctx->field_order[ctx->current_section]; > -int *tmp, i, len; > +int i, len; > > while (buf && *buf) { > if (buf[0] == '[') { > @@ -280,9 +280,7 @@ static const char *ass_split_section(ASSSplitContext > *ctx, const char *buf) > while (!is_eol(*buf)) { > buf = skip_space(buf); > len = strcspn(buf, ", \r\n"); > -if (!(tmp = av_realloc_array(order, (*number + 1), > sizeof(*order > -return NULL; > -order = tmp; > +av_reallocp_array(, (*number + 1), > sizeof(*order)); > order[*number] = -1; > for (i=0; section->fields[i].name; i++) > if (!strncmp(buf, section->fields[i].name, len)) { > -- > 1.9.1 > > Allocation can still fail, so you shouldn't remove the check - just need to change it, since it returns 0 for success, negative for failure. - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mpeg4videodec: Ignore multiple VOL headers
2018-02-11 23:59 GMT+01:00 Michael Niedermayer: > On Sun, Feb 11, 2018 at 08:01:36PM +0100, Carl Eugen Hoyos wrote: >> 2018-02-09 22:24 GMT+01:00 Michael Niedermayer : >> > Fixes: Ticket7005 >> > >> > Signed-off-by: Michael Niedermayer >> > --- >> > libavcodec/mpeg4videodec.c | 4 ++-- >> > 1 file changed, 2 insertions(+), 2 deletions(-) >> > >> > diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c >> > index 756753e2fc..19210d97fe 100644 >> > --- a/libavcodec/mpeg4videodec.c >> > +++ b/libavcodec/mpeg4videodec.c >> > @@ -2707,8 +2707,8 @@ int ff_mpeg4_decode_picture_header(Mpeg4DecContext >> > *ctx, GetBitContext *gb) >> > >> > if (startcode >= 0x120 && startcode <= 0x12F) { >> > if (vol) { >> > -av_log(s->avctx, AV_LOG_ERROR, "Multiple VOL headers"); >> > -return AVERROR_INVALIDDATA; >> > +av_log(s->avctx, AV_LOG_WARNING, "Ignoring multiple VOL >> > headers\n"); >> > +continue; >> > } >> >> Is it expected that the warning is printed as following on decoding >> now (context switches between NULL and mpeg4)? > > It doesnt really switch, i guess the NULL is from the AVParser which does not > have a codec setup and the context_to_name() uses the codec. Thank you, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 6/8] avfilter/silencedetect: fix for ticket 6968 Fix missing log of silence_end at end of stream
2018-02-12 10:48 GMT+01:00 Nicolas Gaullier: > From: nicolas gaullier Please mention ticket #6968 in the commit message if it is related. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 1/8] avfilter/silencedetect: add mono mode in mono mode, silence is detected in any single channel (instead of all them simultaneously)
2018-02-12 10:48 GMT+01:00 Nicolas Gaullier: > From: nicolas gaullier I believe there is an issue with your commit message: It should be something like: lavfi/silencedetect: Add mono mode In mono mode, silence is detected... (Note the two linebreaks, other differences are irrelevant.) Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/ass: Fix a memory leak defect.
Thanks to Hendrik Here is the new patch: From 642a413080f20f9515321e42056248e86e003997 Mon Sep 17 00:00:00 2001 From: Fan GangDate: Mon, 12 Feb 2018 20:55:06 +0800 Subject: [PATCH] avcodec/ass: Fix a memory leak defect when realloc fails. --- libavcodec/ass_split.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c index 872528b..eebe239 100644 --- a/libavcodec/ass_split.c +++ b/libavcodec/ass_split.c @@ -249,7 +249,7 @@ static const char *ass_split_section(ASSSplitContext *ctx, const char *buf) const ASSSection *section = _sections[ctx->current_section]; int *number = >field_number[ctx->current_section]; int *order = ctx->field_order[ctx->current_section]; -int *tmp, i, len; +int i, len; while (buf && *buf) { if (buf[0] == '[') { @@ -280,9 +280,7 @@ static const char *ass_split_section(ASSSplitContext *ctx, const char *buf) while (!is_eol(*buf)) { buf = skip_space(buf); len = strcspn(buf, ", \r\n"); -if (!(tmp = av_realloc_array(order, (*number + 1), sizeof(*order -return NULL; -order = tmp; +av_reallocp_array(, (*number + 1), sizeof(*order)); order[*number] = -1; for (i=0; section->fields[i].name; i++) if (!strncmp(buf, section->fields[i].name, len)) { -- 1.9.1 On Mon, Feb 12, 2018 at 8:32 PM, Gang Fan(范刚) wrote: > OK, should I email the new patch to the same thread or a new thread? > > Thanks > Gang > > On Mon, Feb 12, 2018 at 7:49 PM, Hendrik Leppkes > wrote: > >> On Mon, Feb 12, 2018 at 11:55 AM, Gang Fan(范刚) >> wrote: >> > There is a potential memory leak bug in file ass_split.c, here is the >> > description. >> > >> > A piece of memory is allocated on line 283. When executing the loop >> twice >> > and if the av_realloc_array returns null the function returns without >> > freeing the memory pointed by order. >> > >> > Suggested fix: >> > free(order) before return NULL; on line 284 >> > >> > Reference Ticket: https://trac.ffmpeg.org/ticket/7019#comment:1 >> > >> > Thanks >> > Gang >> > Sbrella >> > >> > >> > From 6850fc3a6562b4f5fb92e72eed125e057ad975ae Mon Sep 17 00:00:00 2001 >> > From: Fan Gang >> > Date: Mon, 12 Feb 2018 18:46:20 +0800 >> > Subject: [PATCH] avcodec/ass: Fix a memory leak defect when realloc >> fails. >> > >> > --- >> > libavcodec/ass_split.c | 4 +++- >> > 1 file changed, 3 insertions(+), 1 deletion(-) >> > >> > diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c >> > index 872528b..c7eb07d 100644 >> > --- a/libavcodec/ass_split.c >> > +++ b/libavcodec/ass_split.c >> > @@ -280,8 +280,10 @@ static const char *ass_split_section(ASSSplitCon >> text >> > *ctx, const char *buf) >> > while (!is_eol(*buf)) { >> > buf = skip_space(buf); >> > len = strcspn(buf, ", \r\n"); >> > -if (!(tmp = av_realloc_array(order, (*number + 1), >> > sizeof(*order >> > +if (!(tmp = av_realloc_array(order, (*number + 1), >> > sizeof(*order{ >> > +free(order); >> > return NULL; >> > +} >> > order = tmp; >> > order[*number] = -1; >> > for (i=0; section->fields[i].name; i++) >> > -- >> >> You would need to use av_free instead of free. However, a better >> option would be just using av_reallocp_array, which automatically >> frees the original pointer on failure. >> >> - Hendrik >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > > > > -- > > > *With kind regards* > -- *With kind regards* ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/ass: Fix a memory leak defect.
OK, should I email the new patch to the same thread or a new thread? Thanks Gang On Mon, Feb 12, 2018 at 7:49 PM, Hendrik Leppkeswrote: > On Mon, Feb 12, 2018 at 11:55 AM, Gang Fan(范刚) > wrote: > > There is a potential memory leak bug in file ass_split.c, here is the > > description. > > > > A piece of memory is allocated on line 283. When executing the loop twice > > and if the av_realloc_array returns null the function returns without > > freeing the memory pointed by order. > > > > Suggested fix: > > free(order) before return NULL; on line 284 > > > > Reference Ticket: https://trac.ffmpeg.org/ticket/7019#comment:1 > > > > Thanks > > Gang > > Sbrella > > > > > > From 6850fc3a6562b4f5fb92e72eed125e057ad975ae Mon Sep 17 00:00:00 2001 > > From: Fan Gang > > Date: Mon, 12 Feb 2018 18:46:20 +0800 > > Subject: [PATCH] avcodec/ass: Fix a memory leak defect when realloc > fails. > > > > --- > > libavcodec/ass_split.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c > > index 872528b..c7eb07d 100644 > > --- a/libavcodec/ass_split.c > > +++ b/libavcodec/ass_split.c > > @@ -280,8 +280,10 @@ static const char *ass_split_section( > ASSSplitContext > > *ctx, const char *buf) > > while (!is_eol(*buf)) { > > buf = skip_space(buf); > > len = strcspn(buf, ", \r\n"); > > -if (!(tmp = av_realloc_array(order, (*number + 1), > > sizeof(*order > > +if (!(tmp = av_realloc_array(order, (*number + 1), > > sizeof(*order{ > > +free(order); > > return NULL; > > +} > > order = tmp; > > order[*number] = -1; > > for (i=0; section->fields[i].name; i++) > > -- > > You would need to use av_free instead of free. However, a better > option would be just using av_reallocp_array, which automatically > frees the original pointer on failure. > > - Hendrik > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > -- *With kind regards* ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/ass: Fix a memory leak defect.
On Mon, Feb 12, 2018 at 11:55 AM, Gang Fan(范刚)wrote: > There is a potential memory leak bug in file ass_split.c, here is the > description. > > A piece of memory is allocated on line 283. When executing the loop twice > and if the av_realloc_array returns null the function returns without > freeing the memory pointed by order. > > Suggested fix: > free(order) before return NULL; on line 284 > > Reference Ticket: https://trac.ffmpeg.org/ticket/7019#comment:1 > > Thanks > Gang > Sbrella > > > From 6850fc3a6562b4f5fb92e72eed125e057ad975ae Mon Sep 17 00:00:00 2001 > From: Fan Gang > Date: Mon, 12 Feb 2018 18:46:20 +0800 > Subject: [PATCH] avcodec/ass: Fix a memory leak defect when realloc fails. > > --- > libavcodec/ass_split.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c > index 872528b..c7eb07d 100644 > --- a/libavcodec/ass_split.c > +++ b/libavcodec/ass_split.c > @@ -280,8 +280,10 @@ static const char *ass_split_section(ASSSplitContext > *ctx, const char *buf) > while (!is_eol(*buf)) { > buf = skip_space(buf); > len = strcspn(buf, ", \r\n"); > -if (!(tmp = av_realloc_array(order, (*number + 1), > sizeof(*order > +if (!(tmp = av_realloc_array(order, (*number + 1), > sizeof(*order{ > +free(order); > return NULL; > +} > order = tmp; > order[*number] = -1; > for (i=0; section->fields[i].name; i++) > -- You would need to use av_free instead of free. However, a better option would be just using av_reallocp_array, which automatically frees the original pointer on failure. - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avcodec/ass: Fix a memory leak defect.
There is a potential memory leak bug in file ass_split.c, here is the description. A piece of memory is allocated on line 283. When executing the loop twice and if the av_realloc_array returns null the function returns without freeing the memory pointed by order. Suggested fix: free(order) before return NULL; on line 284 Reference Ticket: https://trac.ffmpeg.org/ticket/7019#comment:1 Thanks Gang Sbrella From 6850fc3a6562b4f5fb92e72eed125e057ad975ae Mon Sep 17 00:00:00 2001 From: Fan GangDate: Mon, 12 Feb 2018 18:46:20 +0800 Subject: [PATCH] avcodec/ass: Fix a memory leak defect when realloc fails. --- libavcodec/ass_split.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c index 872528b..c7eb07d 100644 --- a/libavcodec/ass_split.c +++ b/libavcodec/ass_split.c @@ -280,8 +280,10 @@ static const char *ass_split_section(ASSSplitContext *ctx, const char *buf) while (!is_eol(*buf)) { buf = skip_space(buf); len = strcspn(buf, ", \r\n"); -if (!(tmp = av_realloc_array(order, (*number + 1), sizeof(*order +if (!(tmp = av_realloc_array(order, (*number + 1), sizeof(*order{ +free(order); return NULL; +} order = tmp; order[*number] = -1; for (i=0; section->fields[i].name; i++) -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] h264_idct: enable unmacro on newer NASM versions
On 12 February 2018 at 09:24, James Darnleywrote: > On 2018-02-10 14:17, Rostislav Pehlivanov wrote: > > Signed-off-by: Rostislav Pehlivanov > > --- > > libavcodec/x86/h264_idct.asm | 6 +- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/libavcodec/x86/h264_idct.asm b/libavcodec/x86/h264_idct.asm > > index 8804638091..c54f9f1a68 100644 > > --- a/libavcodec/x86/h264_idct.asm > > +++ b/libavcodec/x86/h264_idct.asm > > @@ -1144,7 +1144,11 @@ IDCT_DC_DEQUANT 0 > > INIT_MMX sse2 > > IDCT_DC_DEQUANT 7 > > > > -; %unmacro STORE_DIFFx2 8 ; remove macro from x86util.asm but yasm > doesn't have this yet > > +%ifdef __NASM_VER__ > > +%if __NASM_MAJOR__ >= 2 && __NASM_MINOR__ >= 4 > > +%unmacro STORE_DIFFx2 8 ; remove macro from x86util.asm but yasm > doesn't have this yet > > +%endif > > +%endif > > %macro STORE_DIFFx2 8 ; add1, add2, reg1, reg2, zero, shift, source, > stride > > movd %3, [%7] > > movd %4, [%7+%8] > > > > Looks good to me. Thanks for picking up my slack on this one. > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > Thanks, pushed ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 6/8] avfilter/silencedetect: fix for ticket 6968 Fix missing log of silence_end at end of stream
From: nicolas gaullier--- libavfilter/af_silencedetect.c | 33 +++-- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c index 8973049fe5..723136c2a8 100644 --- a/libavfilter/af_silencedetect.c +++ b/libavfilter/af_silencedetect.c @@ -41,7 +41,9 @@ typedef struct SilenceDetectContext { int independant_channels; ///< number of entries in following arrays (always 1 in mono mode) int64_t *nb_null_samples; ///< (array) current number of continuous zero samples int64_t *start; ///< (array) if silence is detected, this value contains the time of the first zero sample (default/unset = INT64_MIN) +int64_t frame_end; ///< pts of the end of the current frame (used to compute duration of silence at EOS) int last_sample_rate; ///< last sample rate to check for sample rate changes +AVRational time_base; ///< time_base void (*silencedetect)(struct SilenceDetectContext *s, AVFrame *insamples, int nb_samples, int64_t nb_samples_notify, @@ -92,13 +94,16 @@ static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, } } else { if (s->start[channel] > INT64_MIN) { -int64_t end_pts = insamples->pts + av_rescale_q(current_sample / s->channels, -(AVRational){ 1, s->last_sample_rate }, time_base); +int64_t end_pts = insamples ? insamples->pts + av_rescale_q(current_sample / s->channels, +(AVRational){ 1, s->last_sample_rate }, time_base) +: s->frame_end; int64_t duration_ts = end_pts - s->start[channel]; -set_meta(insamples, s->mono ? channel + 1 : 0, "silence_end", -av_ts2timestr(end_pts, _base)); -set_meta(insamples, s->mono ? channel + 1 : 0, "silence_duration", -av_ts2timestr(duration_ts, _base)); +if (insamples) { +set_meta(insamples, s->mono ? channel + 1 : 0, "silence_end", +av_ts2timestr(end_pts, _base)); +set_meta(insamples, s->mono ? channel + 1 : 0, "silence_duration", +av_ts2timestr(duration_ts, _base)); +} if (s->mono) av_log(s, AV_LOG_INFO, "channel: %d | ", channel); av_log(s, AV_LOG_INFO, "silence_end: %s | silence_duration: %s\n", @@ -177,6 +182,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) s->nb_null_samples[c] = srate * s->nb_null_samples[c] / s->last_sample_rate; } s->last_sample_rate = srate; +s->time_base = inlink->time_base; +s->frame_end = insamples->pts + av_rescale_q(insamples->nb_samples, +(AVRational){ 1, s->last_sample_rate }, inlink->time_base); // TODO: document metadata s->silencedetect(s, insamples, nb_samples, nb_samples_notify, @@ -218,6 +226,18 @@ static int query_formats(AVFilterContext *ctx) return ff_set_common_samplerates(ctx, formats); } +static av_cold void uninit(AVFilterContext *ctx) +{ +SilenceDetectContext *s = ctx->priv; +int c; + +for (c = 0; c < s->independant_channels; c++) +if (s->start[c] > INT64_MIN) +update(s, NULL, 0, c, 0, s->time_base); +av_freep(>nb_null_samples); +av_freep(>start); +} + static const AVFilterPad silencedetect_inputs[] = { { .name = "default", @@ -241,6 +261,7 @@ AVFilter ff_af_silencedetect = { .description = NULL_IF_CONFIG_SMALL("Detect silence."), .priv_size = sizeof(SilenceDetectContext), .query_formats = query_formats, +.uninit= uninit, .inputs= silencedetect_inputs, .outputs = silencedetect_outputs, .priv_class= _class, -- 2.14.1.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 7/8] fate: run command and get logs rungetavlogs() allows to get avlog messages
From: nicolas gaullier--- tests/fate-run.sh | 14 ++ 1 file changed, 14 insertions(+) diff --git a/tests/fate-run.sh b/tests/fate-run.sh index 05f4ca5e20..0f28af5858 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -84,6 +84,20 @@ runecho(){ $target_exec $target_path/"$@" >&3 } +# $1=regex $2..$n=command +# catch av_log messages +rungetavlogs(){ +test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"${@:2}" >&3 +$target_exec $target_path/"${@:2}" 3>&2 2>&1 1>&3|awk -F' ' "{ +if (/${@:1:1}/) { +for(i=4; i<=NF; ++i) +printf \$i FS +print \"\" +} else { +print > \"/dev/stderr\"} +}" +} + probefmt(){ run ffprobe${PROGSUF} -show_entries format=format_name -print_format default=nw=1:nk=1 -v 0 "$@" } -- 2.14.1.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 4/8] avfilter/silencedetect: fix silence_start accuracy
From: nicolas gaullier--- libavfilter/af_silencedetect.c | 7 +-- tests/ref/fate/filter-metadata-silencedetect | 26 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c index b4184c2486..749c3fbcb7 100644 --- a/libavfilter/af_silencedetect.c +++ b/libavfilter/af_silencedetect.c @@ -37,6 +37,7 @@ typedef struct SilenceDetectContext { double noise; ///< noise amplitude ratio double duration;///< minimum duration of silence until notification int mono; ///< mono mode : check each channel separately (default = check when ALL channels are silent) +int channels; ///< number of channels int independant_channels; ///< number of entries in following arrays (always 1 in mono mode) int64_t *nb_null_samples; ///< (array) current number of continuous zero samples int64_t *start; ///< (array) if silence is detected, this value contains the time of the first zero sample (default/unset = INT64_MIN) @@ -79,7 +80,8 @@ static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, if (s->start[channel] == INT64_MIN) { s->nb_null_samples[channel]++; if (s->nb_null_samples[channel] >= nb_samples_notify) { -s->start[channel] = insamples->pts - (int64_t)(s->duration / av_q2d(time_base) + .5); +s->start[channel] = insamples->pts + av_rescale_q(current_sample / s->channels + 1 - nb_samples_notify * s->independant_channels / s->channels, +(AVRational){ 1, s->last_sample_rate }, time_base); set_meta(insamples, s->mono ? channel + 1 : 0, "silence_start", av_ts2timestr(s->start[channel], _base)); if (s->mono) @@ -132,7 +134,8 @@ static int config_input(AVFilterLink *inlink) SilenceDetectContext *s = ctx->priv; int c; -s->independant_channels = s->mono ? inlink->channels : 1; +s->channels = inlink->channels; +s->independant_channels = s->mono ? s->channels : 1; s->nb_null_samples = av_mallocz_array(sizeof(*s->nb_null_samples), s->independant_channels); if (!s->nb_null_samples) return AVERROR(ENOMEM); diff --git a/tests/ref/fate/filter-metadata-silencedetect b/tests/ref/fate/filter-metadata-silencedetect index d1d6f67dc0..917b836250 100644 --- a/tests/ref/fate/filter-metadata-silencedetect +++ b/tests/ref/fate/filter-metadata-silencedetect @@ -12,12 +12,12 @@ pkt_pts=3200 pkt_pts=3520 pkt_pts=3840 pkt_pts=4160 -pkt_pts=4480|tag:lavfi.silence_start=-0.02 +pkt_pts=4480|tag:lavfi.silence_start=0 pkt_pts=4800 pkt_pts=5120 pkt_pts=5440 pkt_pts=5760 -pkt_pts=6080|tag:lavfi.silence_end=0.38|tag:lavfi.silence_duration=0.4 +pkt_pts=6080|tag:lavfi.silence_end=0.38|tag:lavfi.silence_duration=0.38 pkt_pts=6400 pkt_pts=6720 pkt_pts=7040 @@ -72,7 +72,7 @@ pkt_pts=22400 pkt_pts=22720 pkt_pts=23040 pkt_pts=23360 -pkt_pts=23680|tag:lavfi.silence_start=1.18 +pkt_pts=23680|tag:lavfi.silence_start=1.18756 pkt_pts=24000 pkt_pts=24320 pkt_pts=24640 @@ -97,7 +97,7 @@ pkt_pts=30400 pkt_pts=30720 pkt_pts=31040 pkt_pts=31360 -pkt_pts=31680|tag:lavfi.silence_end=1.98|tag:lavfi.silence_duration=0.8 +pkt_pts=31680|tag:lavfi.silence_end=1.98|tag:lavfi.silence_duration=0.792438 pkt_pts=32000 pkt_pts=32320 pkt_pts=32640 @@ -160,7 +160,7 @@ pkt_pts=50560 pkt_pts=50880 pkt_pts=51200 pkt_pts=51520 -pkt_pts=51840|tag:lavfi.silence_start=2.94 +pkt_pts=51840|tag:lavfi.silence_start=2.945 pkt_pts=52160 pkt_pts=52480 pkt_pts=52800 @@ -196,7 +196,7 @@ pkt_pts=62080 pkt_pts=62400 pkt_pts=62720 pkt_pts=63040 -pkt_pts=63360|tag:lavfi.silence_end=3.96|tag:lavfi.silence_duration=1.02 +pkt_pts=63360|tag:lavfi.silence_end=3.96|tag:lavfi.silence_duration=1.015 pkt_pts=63680 pkt_pts=64000 pkt_pts=64320 @@ -250,7 +250,7 @@ pkt_pts=79360 pkt_pts=79680 pkt_pts=8 pkt_pts=80320 -pkt_pts=80640|tag:lavfi.silence_start=4.74 +pkt_pts=80640|tag:lavfi.silence_start=4.75662 pkt_pts=80960 pkt_pts=81280 pkt_pts=81600 @@ -270,7 +270,7 @@ pkt_pts=85760 pkt_pts=86080 pkt_pts=86400 pkt_pts=86720 -pkt_pts=87040|tag:lavfi.silence_end=5.44|tag:lavfi.silence_duration=0.7 +pkt_pts=87040|tag:lavfi.silence_end=5.44|tag:lavfi.silence_duration=0.683375 pkt_pts=87360 pkt_pts=87680 pkt_pts=88000 @@ -326,7 +326,7 @@ pkt_pts=103680 pkt_pts=104000 pkt_pts=104320 pkt_pts=104640 -pkt_pts=104960|tag:lavfi.silence_start=6.26 +pkt_pts=104960|tag:lavfi.silence_start=6.27319 pkt_pts=105280 pkt_pts=105600 pkt_pts=105920 @@ -362,7 +362,7 @@ pkt_pts=115200 pkt_pts=115520 pkt_pts=115840 pkt_pts=116160 -pkt_pts=116480|tag:lavfi.silence_end=7.28|tag:lavfi.silence_duration=1.02 +pkt_pts=116480|tag:lavfi.silence_end=7.28|tag:lavfi.silence_duration=1.00681 pkt_pts=116800 pkt_pts=117120
[FFmpeg-devel] [PATCH v2 8/8] avfilter/silencedetect: new test for mono mode and logs (including log silence_end at end of stream)
From: nicolas gaullier--- tests/fate/filter-video.mak | 3 +++ tests/ref/fate/filter-metadata-silencedetect2 | 4 2 files changed, 7 insertions(+) create mode 100644 tests/ref/fate/filter-metadata-silencedetect2 diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 0575fc6767..c69db2a680 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -722,6 +722,9 @@ FATE_METADATA_FILTER-$(call ALLYES, $(SILENCEDETECT_DEPS)) += fate-filter-metada fate-filter-metadata-silencedetect: SRC = $(TARGET_SAMPLES)/amrwb/seed-12k65.awb fate-filter-metadata-silencedetect: CMD = run $(FILTER_METADATA_COMMAND) "amovie='$(SRC)',silencedetect=n=-42dB:d=.3" +FATE_METADATA_FILTER-$(call ALLYES, $(SILENCEDETECT_DEPS)) += fate-filter-metadata-silencedetect2 +fate-filter-metadata-silencedetect2: SRC = $(TARGET_SAMPLES)/ac3/millers_crossing_4.0.ac3 +fate-filter-metadata-silencedetect2: CMD = rungetavlogs "\[silencedetect.*\].*silence_(start|end)" $(FILTER_METADATA_COMMAND) "amovie='$(SRC)',silencedetect=n=0.02:d=.15:mono=1" EBUR128_METADATA_DEPS = FFPROBE AVDEVICE LAVFI_INDEV AMOVIE_FILTER FLAC_DEMUXER FLAC_DECODER EBUR128_FILTER FATE_METADATA_FILTER-$(call ALLYES, $(EBUR128_METADATA_DEPS)) += fate-filter-metadata-ebur128 diff --git a/tests/ref/fate/filter-metadata-silencedetect2 b/tests/ref/fate/filter-metadata-silencedetect2 new file mode 100644 index 00..674bb34199 --- /dev/null +++ b/tests/ref/fate/filter-metadata-silencedetect2 @@ -0,0 +1,4 @@ +channel: 3 | silence_start: 0 +channel: 2 | silence_start: 1.52054 +channel: 2 | silence_end: 1.90594 | silence_duration: 0.385396 +channel: 3 | silence_end: 1.984 | silence_duration: 1.984 -- 2.14.1.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 2/8] avfilter/silencedetect: fix when silence_start=0 0 is a valid value for silence_start
From: nicolas gaullier--- libavfilter/af_silencedetect.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c index c53b9d9218..b4184c2486 100644 --- a/libavfilter/af_silencedetect.c +++ b/libavfilter/af_silencedetect.c @@ -39,7 +39,7 @@ typedef struct SilenceDetectContext { int mono; ///< mono mode : check each channel separately (default = check when ALL channels are silent) int independant_channels; ///< number of entries in following arrays (always 1 in mono mode) int64_t *nb_null_samples; ///< (array) current number of continuous zero samples -int64_t *start; ///< (array) if silence is detected, this value contains the time of the first zero sample +int64_t *start; ///< (array) if silence is detected, this value contains the time of the first zero sample (default/unset = INT64_MIN) int last_sample_rate; ///< last sample rate to check for sample rate changes void (*silencedetect)(struct SilenceDetectContext *s, AVFrame *insamples, @@ -76,7 +76,7 @@ static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, { int channel = current_sample % s->independant_channels; if (is_silence) { -if (!s->start[channel]) { +if (s->start[channel] == INT64_MIN) { s->nb_null_samples[channel]++; if (s->nb_null_samples[channel] >= nb_samples_notify) { s->start[channel] = insamples->pts - (int64_t)(s->duration / av_q2d(time_base) + .5); @@ -89,7 +89,7 @@ static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, } } } else { -if (s->start[channel]) { +if (s->start[channel] > INT64_MIN) { int64_t end_pts = insamples->pts; int64_t duration_ts = end_pts - s->start[channel]; set_meta(insamples, s->mono ? channel + 1 : 0, "silence_end", @@ -102,7 +102,8 @@ static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, av_ts2timestr(end_pts, _base), av_ts2timestr(duration_ts, _base)); } -s->nb_null_samples[channel] = s->start[channel] = 0; +s->nb_null_samples[channel] = 0; +s->start[channel] = INT64_MIN; } } @@ -129,14 +130,17 @@ static int config_input(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; SilenceDetectContext *s = ctx->priv; +int c; s->independant_channels = s->mono ? inlink->channels : 1; s->nb_null_samples = av_mallocz_array(sizeof(*s->nb_null_samples), s->independant_channels); if (!s->nb_null_samples) return AVERROR(ENOMEM); -s->start = av_mallocz_array(sizeof(*s->start), s->independant_channels); +s->start = av_malloc_array(sizeof(*s->start), s->independant_channels); if (!s->start) return AVERROR(ENOMEM); +for (c = 0; c < s->independant_channels; c++) +s->start[c] = INT64_MIN; switch (inlink->format) { case AV_SAMPLE_FMT_DBL: s->silencedetect = silencedetect_dbl; break; -- 2.14.1.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 5/8] avfilter/silencedetect: fix silence_end accuracy
From: nicolas gaullier--- libavfilter/af_silencedetect.c | 3 ++- tests/ref/fate/filter-metadata-silencedetect | 12 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c index 749c3fbcb7..8973049fe5 100644 --- a/libavfilter/af_silencedetect.c +++ b/libavfilter/af_silencedetect.c @@ -92,7 +92,8 @@ static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, } } else { if (s->start[channel] > INT64_MIN) { -int64_t end_pts = insamples->pts; +int64_t end_pts = insamples->pts + av_rescale_q(current_sample / s->channels, +(AVRational){ 1, s->last_sample_rate }, time_base); int64_t duration_ts = end_pts - s->start[channel]; set_meta(insamples, s->mono ? channel + 1 : 0, "silence_end", av_ts2timestr(end_pts, _base)); diff --git a/tests/ref/fate/filter-metadata-silencedetect b/tests/ref/fate/filter-metadata-silencedetect index 917b836250..e4be2ffac7 100644 --- a/tests/ref/fate/filter-metadata-silencedetect +++ b/tests/ref/fate/filter-metadata-silencedetect @@ -17,7 +17,7 @@ pkt_pts=4800 pkt_pts=5120 pkt_pts=5440 pkt_pts=5760 -pkt_pts=6080|tag:lavfi.silence_end=0.38|tag:lavfi.silence_duration=0.38 +pkt_pts=6080|tag:lavfi.silence_end=0.384813|tag:lavfi.silence_duration=0.384813 pkt_pts=6400 pkt_pts=6720 pkt_pts=7040 @@ -97,7 +97,7 @@ pkt_pts=30400 pkt_pts=30720 pkt_pts=31040 pkt_pts=31360 -pkt_pts=31680|tag:lavfi.silence_end=1.98|tag:lavfi.silence_duration=0.792438 +pkt_pts=31680|tag:lavfi.silence_end=1.99538|tag:lavfi.silence_duration=0.807813 pkt_pts=32000 pkt_pts=32320 pkt_pts=32640 @@ -196,7 +196,7 @@ pkt_pts=62080 pkt_pts=62400 pkt_pts=62720 pkt_pts=63040 -pkt_pts=63360|tag:lavfi.silence_end=3.96|tag:lavfi.silence_duration=1.015 +pkt_pts=63360|tag:lavfi.silence_end=3.97138|tag:lavfi.silence_duration=1.02638 pkt_pts=63680 pkt_pts=64000 pkt_pts=64320 @@ -270,7 +270,7 @@ pkt_pts=85760 pkt_pts=86080 pkt_pts=86400 pkt_pts=86720 -pkt_pts=87040|tag:lavfi.silence_end=5.44|tag:lavfi.silence_duration=0.683375 +pkt_pts=87040|tag:lavfi.silence_end=5.45|tag:lavfi.silence_duration=0.693375 pkt_pts=87360 pkt_pts=87680 pkt_pts=88000 @@ -362,7 +362,7 @@ pkt_pts=115200 pkt_pts=115520 pkt_pts=115840 pkt_pts=116160 -pkt_pts=116480|tag:lavfi.silence_end=7.28|tag:lavfi.silence_duration=1.00681 +pkt_pts=116480|tag:lavfi.silence_end=7.28569|tag:lavfi.silence_duration=1.0125 pkt_pts=116800 pkt_pts=117120 pkt_pts=117440 @@ -452,7 +452,7 @@ pkt_pts=144000 pkt_pts=144320 pkt_pts=144640 pkt_pts=144960 -pkt_pts=145280|tag:lavfi.silence_end=9.08|tag:lavfi.silence_duration=0.828937 +pkt_pts=145280|tag:lavfi.silence_end=9.08156|tag:lavfi.silence_duration=0.8305 pkt_pts=145600 pkt_pts=145920 pkt_pts=146240 -- 2.14.1.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 3/8] avfilter/silencedetect: update test Set relevant filter parameters such that the result can easily be checked with a waveform editor. In particular, it makes it clear the
From: nicolas gaullier--- tests/fate/filter-video.mak | 3 +- tests/ref/fate/filter-metadata-silencedetect | 54 ++-- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 221ae81fdc..0575fc6767 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -720,7 +720,8 @@ fate-filter-metadata-cropdetect: CMD = run $(FILTER_METADATA_COMMAND) "sws_flags SILENCEDETECT_DEPS = FFPROBE AVDEVICE LAVFI_INDEV AMOVIE_FILTER AMR_DEMUXER AMRWB_DECODER SILENCEDETECT_FILTER FATE_METADATA_FILTER-$(call ALLYES, $(SILENCEDETECT_DEPS)) += fate-filter-metadata-silencedetect fate-filter-metadata-silencedetect: SRC = $(TARGET_SAMPLES)/amrwb/seed-12k65.awb -fate-filter-metadata-silencedetect: CMD = run $(FILTER_METADATA_COMMAND) "amovie='$(SRC)',silencedetect=d=-20dB" +fate-filter-metadata-silencedetect: CMD = run $(FILTER_METADATA_COMMAND) "amovie='$(SRC)',silencedetect=n=-42dB:d=.3" + EBUR128_METADATA_DEPS = FFPROBE AVDEVICE LAVFI_INDEV AMOVIE_FILTER FLAC_DEMUXER FLAC_DECODER EBUR128_FILTER FATE_METADATA_FILTER-$(call ALLYES, $(EBUR128_METADATA_DEPS)) += fate-filter-metadata-ebur128 diff --git a/tests/ref/fate/filter-metadata-silencedetect b/tests/ref/fate/filter-metadata-silencedetect index 4161287e6c..d1d6f67dc0 100644 --- a/tests/ref/fate/filter-metadata-silencedetect +++ b/tests/ref/fate/filter-metadata-silencedetect @@ -4,20 +4,20 @@ pkt_pts=640 pkt_pts=960 pkt_pts=1280 pkt_pts=1600 -pkt_pts=1920|tag:lavfi.silence_start=0.02 +pkt_pts=1920 pkt_pts=2240 -pkt_pts=2560|tag:lavfi.silence_end=0.16|tag:lavfi.silence_duration=0.14 +pkt_pts=2560 pkt_pts=2880 pkt_pts=3200 pkt_pts=3520 pkt_pts=3840 pkt_pts=4160 -pkt_pts=4480 +pkt_pts=4480|tag:lavfi.silence_start=-0.02 pkt_pts=4800 pkt_pts=5120 pkt_pts=5440 -pkt_pts=5760|tag:lavfi.silence_start=0.26|tag:lavfi.silence_end=0.36|tag:lavfi.silence_duration=0.1 -pkt_pts=6080 +pkt_pts=5760 +pkt_pts=6080|tag:lavfi.silence_end=0.38|tag:lavfi.silence_duration=0.4 pkt_pts=6400 pkt_pts=6720 pkt_pts=7040 @@ -67,12 +67,12 @@ pkt_pts=20800 pkt_pts=21120 pkt_pts=21440 pkt_pts=21760 -pkt_pts=22080|tag:lavfi.silence_start=1.28 +pkt_pts=22080 pkt_pts=22400 pkt_pts=22720 pkt_pts=23040 pkt_pts=23360 -pkt_pts=23680 +pkt_pts=23680|tag:lavfi.silence_start=1.18 pkt_pts=24000 pkt_pts=24320 pkt_pts=24640 @@ -97,7 +97,7 @@ pkt_pts=30400 pkt_pts=30720 pkt_pts=31040 pkt_pts=31360 -pkt_pts=31680|tag:lavfi.silence_end=1.98|tag:lavfi.silence_duration=0.7 +pkt_pts=31680|tag:lavfi.silence_end=1.98|tag:lavfi.silence_duration=0.8 pkt_pts=32000 pkt_pts=32320 pkt_pts=32640 @@ -160,10 +160,10 @@ pkt_pts=50560 pkt_pts=50880 pkt_pts=51200 pkt_pts=51520 -pkt_pts=51840 +pkt_pts=51840|tag:lavfi.silence_start=2.94 pkt_pts=52160 pkt_pts=52480 -pkt_pts=52800|tag:lavfi.silence_start=3.2 +pkt_pts=52800 pkt_pts=53120 pkt_pts=53440 pkt_pts=53760 @@ -193,10 +193,10 @@ pkt_pts=61120 pkt_pts=61440 pkt_pts=61760 pkt_pts=62080 -pkt_pts=62400|tag:lavfi.silence_end=3.9|tag:lavfi.silence_duration=0.7 +pkt_pts=62400 pkt_pts=62720 pkt_pts=63040 -pkt_pts=63360 +pkt_pts=63360|tag:lavfi.silence_end=3.96|tag:lavfi.silence_duration=1.02 pkt_pts=63680 pkt_pts=64000 pkt_pts=64320 @@ -248,9 +248,9 @@ pkt_pts=78720 pkt_pts=79040 pkt_pts=79360 pkt_pts=79680 -pkt_pts=8|tag:lavfi.silence_start=4.9 +pkt_pts=8 pkt_pts=80320 -pkt_pts=80640 +pkt_pts=80640|tag:lavfi.silence_start=4.74 pkt_pts=80960 pkt_pts=81280 pkt_pts=81600 @@ -270,7 +270,7 @@ pkt_pts=85760 pkt_pts=86080 pkt_pts=86400 pkt_pts=86720 -pkt_pts=87040|tag:lavfi.silence_end=5.44|tag:lavfi.silence_duration=0.54 +pkt_pts=87040|tag:lavfi.silence_end=5.44|tag:lavfi.silence_duration=0.7 pkt_pts=87360 pkt_pts=87680 pkt_pts=88000 @@ -325,8 +325,8 @@ pkt_pts=103360 pkt_pts=103680 pkt_pts=104000 pkt_pts=104320 -pkt_pts=104640|tag:lavfi.silence_start=6.44 -pkt_pts=104960 +pkt_pts=104640 +pkt_pts=104960|tag:lavfi.silence_start=6.26 pkt_pts=105280 pkt_pts=105600 pkt_pts=105920 @@ -361,8 +361,8 @@ pkt_pts=114880 pkt_pts=115200 pkt_pts=115520 pkt_pts=115840 -pkt_pts=116160|tag:lavfi.silence_end=7.26|tag:lavfi.silence_duration=0.82 -pkt_pts=116480 +pkt_pts=116160 +pkt_pts=116480|tag:lavfi.silence_end=7.28|tag:lavfi.silence_duration=1.02 pkt_pts=116800 pkt_pts=117120 pkt_pts=117440 @@ -425,19 +425,19 @@ pkt_pts=135360 pkt_pts=135680 pkt_pts=136000 pkt_pts=136320 -pkt_pts=136640 +pkt_pts=136640|tag:lavfi.silence_start=8.24 pkt_pts=136960 pkt_pts=137280 -pkt_pts=137600|tag:lavfi.silence_start=8.5 +pkt_pts=137600 pkt_pts=137920 pkt_pts=138240 pkt_pts=138560 -pkt_pts=138880|tag:lavfi.silence_end=8.68|tag:lavfi.silence_duration=0.18 +pkt_pts=138880 pkt_pts=139200 pkt_pts=139520 pkt_pts=139840 pkt_pts=140160 -pkt_pts=140480|tag:lavfi.silence_start=8.68 +pkt_pts=140480 pkt_pts=140800 pkt_pts=141120 pkt_pts=141440 @@ -447,12 +447,12 @@
[FFmpeg-devel] [PATCH v2 1/8] avfilter/silencedetect: add mono mode in mono mode, silence is detected in any single channel (instead of all them simultaneously)
From: nicolas gaullier--- libavfilter/af_silencedetect.c | 78 +++--- 1 file changed, 51 insertions(+), 27 deletions(-) diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c index b048d63738..c53b9d9218 100644 --- a/libavfilter/af_silencedetect.c +++ b/libavfilter/af_silencedetect.c @@ -36,8 +36,10 @@ typedef struct SilenceDetectContext { const AVClass *class; double noise; ///< noise amplitude ratio double duration;///< minimum duration of silence until notification -int64_t nb_null_samples;///< current number of continuous zero samples -int64_t start; ///< if silence is detected, this value contains the time of the first zero sample +int mono; ///< mono mode : check each channel separately (default = check when ALL channels are silent) +int independant_channels; ///< number of entries in following arrays (always 1 in mono mode) +int64_t *nb_null_samples; ///< (array) current number of continuous zero samples +int64_t *start; ///< (array) if silence is detected, this value contains the time of the first zero sample int last_sample_rate; ///< last sample rate to check for sample rate changes void (*silencedetect)(struct SilenceDetectContext *s, AVFrame *insamples, @@ -52,44 +54,55 @@ static const AVOption silencedetect_options[] = { { "noise", "set noise tolerance", OFFSET(noise), AV_OPT_TYPE_DOUBLE, {.dbl=0.001}, 0, DBL_MAX, FLAGS }, { "d", "set minimum duration in seconds", OFFSET(duration), AV_OPT_TYPE_DOUBLE, {.dbl=2.}, 0, 24*60*60, FLAGS }, { "duration", "set minimum duration in seconds", OFFSET(duration), AV_OPT_TYPE_DOUBLE, {.dbl=2.}, 0, 24*60*60, FLAGS }, +{ "mono", "check each channel separately",OFFSET(mono), AV_OPT_TYPE_BOOL, {.i64=0.}, 0, 1, FLAGS }, { NULL } }; AVFILTER_DEFINE_CLASS(silencedetect); -static char *get_metadata_val(AVFrame *insamples, const char *key) +static void set_meta(AVFrame *insamples, int channel, const char *key, char *value) { -AVDictionaryEntry *e = av_dict_get(insamples->metadata, key, NULL, 0); -return e && e->value ? e->value : NULL; -} +char key2[128]; +if (channel) +snprintf(key2, sizeof(key2), "lavfi.%s.%d", key, channel); +else +snprintf(key2, sizeof(key2), "lavfi.%s", key); +av_dict_set(>metadata, key2, value, 0); +} static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, -int is_silence, int64_t nb_samples_notify, +int is_silence, int current_sample, int64_t nb_samples_notify, AVRational time_base) { +int channel = current_sample % s->independant_channels; if (is_silence) { -if (!s->start) { -s->nb_null_samples++; -if (s->nb_null_samples >= nb_samples_notify) { -s->start = insamples->pts - (int64_t)(s->duration / av_q2d(time_base) + .5); -av_dict_set(>metadata, "lavfi.silence_start", -av_ts2timestr(s->start, _base), 0); +if (!s->start[channel]) { +s->nb_null_samples[channel]++; +if (s->nb_null_samples[channel] >= nb_samples_notify) { +s->start[channel] = insamples->pts - (int64_t)(s->duration / av_q2d(time_base) + .5); +set_meta(insamples, s->mono ? channel + 1 : 0, "silence_start", +av_ts2timestr(s->start[channel], _base)); +if (s->mono) +av_log(s, AV_LOG_INFO, "channel: %d | ", channel); av_log(s, AV_LOG_INFO, "silence_start: %s\n", - get_metadata_val(insamples, "lavfi.silence_start")); +av_ts2timestr(s->start[channel], _base)); } } } else { -if (s->start) { -av_dict_set(>metadata, "lavfi.silence_end", -av_ts2timestr(insamples->pts, _base), 0); -av_dict_set(>metadata, "lavfi.silence_duration", -av_ts2timestr(insamples->pts - s->start, _base), 0); -av_log(s, AV_LOG_INFO, - "silence_end: %s | silence_duration: %s\n", - get_metadata_val(insamples, "lavfi.silence_end"), - get_metadata_val(insamples, "lavfi.silence_duration")); +if (s->start[channel]) { +int64_t end_pts = insamples->pts; +int64_t duration_ts = end_pts - s->start[channel]; +set_meta(insamples, s->mono ? channel + 1 : 0, "silence_end", +av_ts2timestr(end_pts, _base)); +set_meta(insamples, s->mono ? channel + 1 : 0,
Re: [FFmpeg-devel] [PATCH] h264_idct: enable unmacro on newer NASM versions
On 2018-02-10 14:17, Rostislav Pehlivanov wrote: > Signed-off-by: Rostislav Pehlivanov> --- > libavcodec/x86/h264_idct.asm | 6 +- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/x86/h264_idct.asm b/libavcodec/x86/h264_idct.asm > index 8804638091..c54f9f1a68 100644 > --- a/libavcodec/x86/h264_idct.asm > +++ b/libavcodec/x86/h264_idct.asm > @@ -1144,7 +1144,11 @@ IDCT_DC_DEQUANT 0 > INIT_MMX sse2 > IDCT_DC_DEQUANT 7 > > -; %unmacro STORE_DIFFx2 8 ; remove macro from x86util.asm but yasm doesn't > have this yet > +%ifdef __NASM_VER__ > +%if __NASM_MAJOR__ >= 2 && __NASM_MINOR__ >= 4 > +%unmacro STORE_DIFFx2 8 ; remove macro from x86util.asm but yasm doesn't > have this yet > +%endif > +%endif > %macro STORE_DIFFx2 8 ; add1, add2, reg1, reg2, zero, shift, source, stride > movd %3, [%7] > movd %4, [%7+%8] > Looks good to me. Thanks for picking up my slack on this one. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 3/3] Adds a new hls_flag avg_bw
If this flag is set, AVERAGE-BANDWIDTH value will be added to a master playlist entry. This flag implies peak_segment_bw. --- doc/muxers.texi | 4 libavformat/dashenc.c | 2 +- libavformat/hlsenc.c | 20 libavformat/hlsplaylist.c | 6 -- libavformat/hlsplaylist.h | 4 ++-- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index e2c9cbfa2f..428d4009b3 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -745,6 +745,10 @@ Possible values: If this flag is set, BANDWIDTH value in a master playlist entry will be set to the peak segment bandwidth. +@item avg_bw +If this flag is set, AVERAGE-BANDWIDTH value will be added to a master +playlist entry. This flag implies peak_segment_bw. + @item single_file If this flag is set, the muxer will store all segments in a single MPEG-TS file, and will use byte ranges in the playlist. HLS playlists generated with diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 0f6f4f22fa..a918f7e649 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -827,7 +827,7 @@ static int write_manifest(AVFormatContext *s, int final) stream_bitrate += max_audio_bitrate; } get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, i); - ff_hls_write_stream_info(st, out, stream_bitrate, playlist_file, agroup, NULL, NULL); + ff_hls_write_stream_info(st, out, stream_bitrate, 0, playlist_file, agroup, NULL, NULL); } avio_close(out); if (use_rename) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index f40cd0b98f..aa704c94f8 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -99,6 +99,7 @@ typedef enum HLSFlags { HLS_PERIODIC_REKEY = (1 << 12), HLS_INDEPENDENT_SEGMENTS = (1 << 13), HLS_PEAK_SEGMENT_BW = (1 << 14), + HLS_AVG_BW = (1 << 15), } HLSFlags; typedef enum { @@ -113,6 +114,8 @@ typedef struct VariantStream { AVOutputFormat *vtt_oformat; AVIOContext *out; int packets_written; + int64_t bytes_written; + double total_duration; int init_range_length; AVFormatContext *avf; @@ -1177,7 +1180,7 @@ static int create_master_playlist(AVFormatContext *s, AVStream *vid_st, *aud_st; AVDictionary *options = NULL; unsigned int i, j; - int m3u8_name_size, ret, bandwidth; + int m3u8_name_size, ret, bandwidth, avgbw; char *m3u8_rel_name, *ccgroup; ClosedCaptionsStream *ccs; @@ -1294,7 +1297,9 @@ static int create_master_playlist(AVFormatContext *s, } bandwidth = 0; - if (last && hls->flags & HLS_PEAK_SEGMENT_BW) { + avgbw = 0; + if (last && (hls->flags & HLS_PEAK_SEGMENT_BW || + hls->flags & HLS_AVG_BW)) { HLSSegment *hs = vs->segments; while (hs) { int64_t segment_bandwidth = hs->size * 8 / hs->duration; @@ -1302,6 +1307,8 @@ static int create_master_playlist(AVFormatContext *s, bandwidth = segment_bandwidth; hs = hs->next; } + if (hls->flags & HLS_AVG_BW) + avgbw = vs->bytes_written / vs->total_duration; } else { if (vid_st) bandwidth += vid_st->codecpar->bit_rate; @@ -1325,8 +1332,8 @@ static int create_master_playlist(AVFormatContext *s, vs->ccgroup); } - ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, m3u8_rel_name, - aud_st ? vs->agroup : NULL, vs->codec_attr, ccgroup); + ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, avgbw, + m3u8_rel_name, aud_st ? vs->agroup : NULL, vs->codec_attr, ccgroup); av_freep(_rel_name); } @@ -2191,6 +2198,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) new_start_pos = avio_tell(vs->avf->pb); vs->size = new_start_pos - vs->start_pos; + vs->bytes_written += vs->size; + vs->total_duration += vs->duration; if (!byterange_mode) { if (hls->segment_type == SEGMENT_TYPE_FMP4) { @@ -2326,6 +2335,8 @@ failed: av_write_trailer(oc); if (oc->pb) { vs->size = avio_tell(vs->avf->pb) - vs->start_pos; + vs->bytes_written += vs->size; + vs->total_duration += vs->duration; if (hls->segment_type != SEGMENT_TYPE_FMP4) ff_format_io_close(s, >pb); @@ -2765,6 +2776,7 @@ static const AVOption options[] = { {"fmp4", "make segment file to fragment mp4 files in m3u8", 0, AV_OPT_TYPE_CONST, {.i64 = SEGMENT_TYPE_FMP4 }, 0, UINT_MAX, E, "segment_type"}, {"hls_fmp4_init_filename", "set fragment mp4 file init filename", OFFSET(fmp4_init_filename), AV_OPT_TYPE_STRING, {.str = "init.mp4"}, 0, 0, E}, {"hls_flags", "set flags affecting HLS playlist and media file
[FFmpeg-devel] [PATCH 1/3] Fix computation of vs->start_pos
Reset vs->start_pos when beginning a new file. --- libavformat/hlsenc.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index cc13c94e97..9970c4c575 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2227,7 +2227,10 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) ff_format_io_close(s, >out); } ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, vs->size); - vs->start_pos = new_start_pos; + if (hls->flags & HLS_SINGLE_FILE) + vs->start_pos = new_start_pos; + else + vs->start_pos = 0; if (ret < 0) { av_free(old_filename); return ret; -- 2.14.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/3] Add a new hls_flag peak_segment_bw
If this flag is set, BANDWIDTH value in a master playlist entry will be set to the peak segment bandwidth. --- doc/muxers.texi | 4 libavformat/hlsenc.c | 29 + 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index d9a5cc03dc..e2c9cbfa2f 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -741,6 +741,10 @@ subdirectories. Possible values: @table @samp +@item peak_segment_bw +If this flag is set, BANDWIDTH value in a master playlist entry will be +set to the peak segment bandwidth. + @item single_file If this flag is set, the muxer will store all segments in a single MPEG-TS file, and will use byte ranges in the playlist. HLS playlists generated with diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 9970c4c575..f40cd0b98f 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -98,6 +98,7 @@ typedef enum HLSFlags { HLS_TEMP_FILE = (1 << 11), HLS_PERIODIC_REKEY = (1 << 12), HLS_INDEPENDENT_SEGMENTS = (1 << 13), + HLS_PEAK_SEGMENT_BW = (1 << 14), } HLSFlags; typedef enum { @@ -1168,7 +1169,8 @@ static int get_relative_url(const char *master_url, const char *media_url, } static int create_master_playlist(AVFormatContext *s, - VariantStream * const input_vs) + VariantStream * const input_vs, + int last) { HLSContext *hls = s->priv_data; VariantStream *vs, *temp_vs; @@ -1185,7 +1187,7 @@ static int create_master_playlist(AVFormatContext *s, for (i = 0; i < hls->nb_varstreams; i++) if (!hls->var_streams[i].m3u8_created) return 0; - } else { + } else if (!last) { /* Keep publishing the master playlist at the configured rate */ if (>var_streams[0] != input_vs || !hls->master_publish_rate || input_vs->number % hls->master_publish_rate) @@ -1292,11 +1294,21 @@ static int create_master_playlist(AVFormatContext *s, } bandwidth = 0; - if (vid_st) - bandwidth += vid_st->codecpar->bit_rate; - if (aud_st) - bandwidth += aud_st->codecpar->bit_rate; - bandwidth += bandwidth / 10; + if (last && hls->flags & HLS_PEAK_SEGMENT_BW) { + HLSSegment *hs = vs->segments; + while (hs) { + int64_t segment_bandwidth = hs->size * 8 / hs->duration; + if (bandwidth < segment_bandwidth) + bandwidth = segment_bandwidth; + hs = hs->next; + } + } else { + if (vid_st) + bandwidth += vid_st->codecpar->bit_rate; + if (aud_st) + bandwidth += aud_st->codecpar->bit_rate; + bandwidth += bandwidth / 10; + } ccgroup = NULL; if (vid_st && vs->ccgroup) { @@ -1437,7 +1449,7 @@ fail: ff_rename(temp_filename, vs->m3u8_name, s); if (ret >= 0 && hls->master_pl_name) - if (create_master_playlist(s, vs) < 0) + if (create_master_playlist(s, vs, last) < 0) av_log(s, AV_LOG_WARNING, "Master playlist creation failed\n"); return ret; @@ -2753,6 +2765,7 @@ static const AVOption options[] = { {"fmp4", "make segment file to fragment mp4 files in m3u8", 0, AV_OPT_TYPE_CONST, {.i64 = SEGMENT_TYPE_FMP4 }, 0, UINT_MAX, E, "segment_type"}, {"hls_fmp4_init_filename", "set fragment mp4 file init filename", OFFSET(fmp4_init_filename), AV_OPT_TYPE_STRING, {.str = "init.mp4"}, 0, 0, E}, {"hls_flags", "set flags affecting HLS playlist and media file generation", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0 }, 0, UINT_MAX, E, "flags"}, + {"peak_segment_bw", "sets bandwidth in master play list to peak segment bandwidth", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_PEAK_SEGMENT_BW }, 0, UINT_MAX, E, "flags"}, {"single_file", "generate a single media file indexed with byte ranges", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SINGLE_FILE }, 0, UINT_MAX, E, "flags"}, {"temp_file", "write segment to temporary file and rename when complete", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_TEMP_FILE }, 0, UINT_MAX, E, "flags"}, {"delete_segments", "delete segment files that are no longer part of the playlist", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_DELETE_SEGMENTS }, 0, UINT_MAX, E, "flags"}, -- 2.14.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel