Re: [FFmpeg-devel] [PATCH, v2 1/2] lavc/qsvdec: add decode support for HEVC 4:2:2 8-bit and 10-bit
> From: ffmpeg-devel On Behalf Of > Max Dmitrichenko > Sent: Friday, May 15, 2020 16:19 > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Cc: Zhong Li > Subject: Re: [FFmpeg-devel] [PATCH, v2 1/2] lavc/qsvdec: add decode > support for HEVC 4:2:2 8-bit and 10-bit > > On Fri, May 15, 2020 at 9:06 AM Fu, Linjie wrote: > > > > From: ffmpeg-devel On Behalf Of > > > Artem Galin > > > Sent: Tuesday, April 28, 2020 00:26 > > > To: FFmpeg development discussions and patches > > de...@ffmpeg.org> > > > Cc: Zhong Li > > > Subject: Re: [FFmpeg-devel] [PATCH, v2 1/2] lavc/qsvdec: add decode > > > support for HEVC 4:2:2 8-bit and 10-bit > > > > > > On Wed, 15 Apr 2020 at 05:02, Fu, Linjie wrote: > > > > > > > > From: Zhong Li > > > > > Sent: Wednesday, April 15, 2020 09:58 > > > > > To: FFmpeg development discussions and patches > > > > de...@ffmpeg.org> > > > > > Cc: Fu, Linjie > > > > > Subject: Re: [FFmpeg-devel] [PATCH, v2 1/2] lavc/qsvdec: add decode > > > > > support for HEVC 4:2:2 8-bit and 10-bit > > > > > > > > > > Linjie Fu 于2020年2月26日周三 下午4:43 > 写道: > > > > > > > > > > > > Enables HEVC Range Extension decoding support (Linux) for 4:2:2 > > 8/10 > > > > bit > > > > > > on ICL+ (gen11 +) platform. > > > > > > > > > > > > Signed-off-by: Linjie Fu > > > > > > --- > > > > > > [v2]: restrict to support on Linux. > > > > > > > > > > > > libavcodec/qsv.c | 16 > > > > > > libavutil/hwcontext_qsv.c | 24 > > > > > > 2 files changed, 40 insertions(+) > > > > > > > > > > > > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c > > > > > > index db98c75..171a8d6 100644 > > > > > > --- a/libavcodec/qsv.c > > > > > > +++ b/libavcodec/qsv.c > > > > > > @@ -195,6 +195,12 @@ enum AVPixelFormat > > > ff_qsv_map_fourcc(uint32_t > > > > > fourcc) > > > > > > case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12; > > > > > > case MFX_FOURCC_P010: return AV_PIX_FMT_P010; > > > > > > case MFX_FOURCC_P8: return AV_PIX_FMT_PAL8; > > > > > > +#if CONFIG_VAAPI > > > > > > > LGTM. CONFIG_VAAPI is not needed here because crash does not > related to > > > these changes. > > > Full support MFX_FOURCC_YUY2 is WIP for Windows. > > > > > > > > > +case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422; > > > > > > > > > > There is no VAAPI structures here, so should not use CONFIG_VAAPI > to > > > > > disable them. > > > > > > > > > > > > > This is pointed out in [1] that D3D code doesn't support YUYV format, > > and > > > > indeed > > > > It leads to unexpected crash in windows.(instead of working or > > reporting > > > > unsupported > > > > On ICL- platform) > > > > > > > > Hence this patch restricted to add support on linux only. > > > > > > > > And I admit the best solution should be get this fully supported on > > both > > > > linux and windows. > > > > (I believe Max and Artem is helping on windows side) > > > > > > > > Thanks for the review, > > > > Linjie > > > > > > > > [1] > > > > https://patchwork.ffmpeg.org/project/ffmpeg/patch/1582596080- > 1035-1- > > > git-send-email-linjie...@intel.com/ > > > > Synced with Zhong, will keep the restriction for now and apply this set > > soon. (if no objections) > > > > > it make sense, as patch is clearly Linux focused > Thanks, applied. - Linjie ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/url: check the result of the strrchr
> 2020年5月17日 上午10:35,Steven Liu 写道: > > > >> 2020年5月15日 下午6:26,Steven Liu 写道: >> >> >> >>> 2020年5月15日 下午6:01,Steven Liu 写道: >>> >>> because it need be check for success, is should not >>> change the old way if it failure. >> Change the comments: >> because it need be checked for success status, it should not >> change the old way if it failure. >>> >>> Signed-off-by: Steven Liu >>> --- >>> libavformat/url.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/libavformat/url.c b/libavformat/url.c >>> index 7cd9e0c705..6956f6dc10 100644 >>> --- a/libavformat/url.c >>> +++ b/libavformat/url.c >>> @@ -182,7 +182,7 @@ void ff_make_absolute_url(char *buf, int size, const >>> char *base, >>> >>> /* Remove the file name from the base url */ >>> sep = strrchr(buf, '/'); >>> -if (sep <= root) >>> +if (sep && sep <= root) >>> sep = root; >>> >>> if (sep) >>> -- >>> 2.25.0 >>> > will apply after 24 hours if no objections. > Ping > Thanks Steven Liu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 6/6] avcodec: move mpeg4 profiles to profiles.h
> From: ffmpeg-devel On Behalf Of > Marton Balint > Sent: Tuesday, May 12, 2020 03:35 > To: ffmpeg-devel@ffmpeg.org > Cc: Marton Balint > Subject: [FFmpeg-devel] [PATCH 6/6] avcodec: move mpeg4 profiles to > profiles.h > > Signed-off-by: Marton Balint > --- > doc/codecs.texi| 17 ++--- > libavcodec/mpeg4videoenc.c | 2 ++ > libavcodec/options_table.h | 4 > libavcodec/profiles.h | 6 ++ > libavcodec/v4l2_m2m_enc.c | 34 ++ > 5 files changed, 32 insertions(+), 31 deletions(-) > > diff --git a/doc/codecs.texi b/doc/codecs.texi > index c08229ba7e..ece8d50edd 100644 > --- a/doc/codecs.texi > +++ b/doc/codecs.texi > @@ -837,21 +837,8 @@ Set number of macroblock rows at the bottom which > are skipped. > > @item profile @var{integer} (@emph{encoding,audio,video}) > > -Possible values: > -@table @samp > -@item unknown > - > -@item mpeg4_sp > - > -@item mpeg4_core > - > -@item mpeg4_main > - > -@item mpeg4_asp > - > -@end table > - > -Encoder specific profiles are documented in the relevant encoder > documentation. > +Set encoder codec profile. Default value is @samp{unknown}. Encoder > specific > +profiles are documented in the relevant encoder documentation. > > @item level @var{integer} (@emph{encoding,audio,video}) > > diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c > index 2cd5a8c015..2e0b119d7f 100644 > --- a/libavcodec/mpeg4videoenc.c > +++ b/libavcodec/mpeg4videoenc.c > @@ -27,6 +27,7 @@ > #include "mpegvideo.h" > #include "h263.h" > #include "mpeg4video.h" > +#include "profiles.h" > > /* The uni_DCtab_* tables below contain unified bits+length tables to > encode DC > * differences in MPEG-4. Unified in the sense that the specification > specifies > @@ -1376,6 +1377,7 @@ static const AVOption options[] = { > { "data_partitioning", "Use data partitioning.", > OFFSET(data_partitioning), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, > { "alternate_scan","Enable alternate scantable.", > OFFSET(alternate_scan),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, > FF_MPV_COMMON_OPTS > +FF_MPEG4_PROFILE_OPTS > { NULL }, > }; > > diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h > index 4c7dca696b..6db8facff6 100644 > --- a/libavcodec/options_table.h > +++ b/libavcodec/options_table.h > @@ -262,10 +262,6 @@ static const AVOption avcodec_options[] = { > {"skip_bottom", "number of macroblock rows at the bottom which are > skipped", OFFSET(skip_bottom), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, > INT_MIN, INT_MAX, V|D}, > {"profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, {.i64 = > FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, V|A|E|CC, "avctx.profile"}, > {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = > FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "avctx.profile"}, > -{"mpeg4_sp", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = > FF_PROFILE_MPEG4_SIMPLE }, INT_MIN, INT_MAX, V|E, "avctx.profile"}, > -{"mpeg4_core", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = > FF_PROFILE_MPEG4_CORE }, INT_MIN, INT_MAX, V|E, "avctx.profile"}, > -{"mpeg4_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = > FF_PROFILE_MPEG4_MAIN }, INT_MIN, INT_MAX, V|E, "avctx.profile"}, > -{"mpeg4_asp", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = > FF_PROFILE_MPEG4_ADVANCED_SIMPLE }, INT_MIN, INT_MAX, V|E, > "avctx.profile"}, > {"main10", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = > FF_PROFILE_HEVC_MAIN_10 }, INT_MIN, INT_MAX, V|E, "avctx.profile"}, > {"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = > FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"}, > {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, > INT_MIN, INT_MAX, V|A|E, "level"}, > diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h > index d950971875..e414ea77a7 100644 > --- a/libavcodec/profiles.h > +++ b/libavcodec/profiles.h > @@ -37,6 +37,12 @@ > FF_AVCTX_PROFILE_OPTION("mpeg2_aac_low", NULL, AUDIO, > FF_PROFILE_MPEG2_AAC_LOW)\ > FF_AVCTX_PROFILE_OPTION("mpeg2_aac_he", NULL, AUDIO, > FF_PROFILE_MPEG2_AAC_HE)\ > > +#define FF_MPEG4_PROFILE_OPTS \ > +FF_AVCTX_PROFILE_OPTION("mpeg4_sp", NULL, VIDEO, > FF_PROFILE_MPEG4_SIMPLE)\ > +FF_AVCTX_PROFILE_OPTION("mpeg4_core",NULL, VIDEO, > FF_PROFILE_MPEG4_CORE)\ > +FF_AVCTX_PROFILE_OPTION("mpeg4_main",NULL, VIDEO, > FF_PROFILE_MPEG4_MAIN)\ > +FF_AVCTX_PROFILE_OPTION("mpeg4_asp", NULL, VIDEO, > FF_PROFILE_MPEG4_ADVANCED_SIMPLE)\ > + Since it's now searchable according to the AVClass, we may not need the prefix anymore. (for now it's necessary for the ABI) Hence would it be better to add some deprecated flags for them and remove the prefix in future when avcodec version increase? (something like FF_API_NEXT) - Linjie ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject
Re: [FFmpeg-devel] [PATCH 1/6] avutil/opt: add AV_OPT_FLAG_CHILD_CONSTS
> From: ffmpeg-devel On Behalf Of > Marton Balint > Sent: Tuesday, May 12, 2020 03:35 > To: ffmpeg-devel@ffmpeg.org > Cc: Marton Balint > Subject: [FFmpeg-devel] [PATCH 1/6] avutil/opt: add > AV_OPT_FLAG_CHILD_CONSTS > > This will be used for AVCodecContext->profile. By specifying constants in the > encoders we won't have to use the common AVCodecContext options table > and > different encoders can use the same profile name even with different values. > > Signed-off-by: Marton Balint > --- > doc/APIchanges | 3 +++ > libavutil/opt.c | 3 ++- > libavutil/opt.h | 1 + > libavutil/version.h | 2 +- > 4 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index 75cfdb08b0..235888c174 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -15,6 +15,9 @@ libavutil: 2017-10-21 > > API changes, most recent first: > > +2020-05-xx - xx - lavu 56.44.101 - opt.h > + Add AV_OPT_FLAG_CHILD_CONSTS. > + > 2020-05-10 - xx - lavu 56.44.100 - hwcontext_vulkan.h >Add enabled_inst_extensions, num_enabled_inst_extensions, > enabled_dev_extensions >and num_enabled_dev_extensions fields to AVVulkanDeviceContext > diff --git a/libavutil/opt.c b/libavutil/opt.c > index b792dec01c..423313bce2 100644 > --- a/libavutil/opt.c > +++ b/libavutil/opt.c > @@ -256,11 +256,12 @@ static int set_string_number(void *obj, void > *target_obj, const AVOption *o, con > } > > { > -const AVOption *o_named = av_opt_find(target_obj, i ? buf : val, > o- > >unit, 0, 0); > int res; > int ci = 0; > double const_values[64]; > const char * const_names[64]; > +int search_flags = (o->flags & AV_OPT_FLAG_CHILD_CONSTS) ? > AV_OPT_SEARCH_CHILDREN : 0; > +const AVOption *o_named = av_opt_find(target_obj, i ? buf : val, > o- > >unit, 0, search_flags); > if (o_named && o_named->type == AV_OPT_TYPE_CONST) > d = DEFAULT_NUMVAL(o_named); > else { > diff --git a/libavutil/opt.h b/libavutil/opt.h > index 1969c984dd..e46119572a 100644 > --- a/libavutil/opt.h > +++ b/libavutil/opt.h > @@ -291,6 +291,7 @@ typedef struct AVOption { > #define AV_OPT_FLAG_RUNTIME_PARAM (1<<15) ///< a generic > parameter which can be set by the user at runtime > #define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic > parameter which can be set by the user for filtering > #define AV_OPT_FLAG_DEPRECATED (1<<17) ///< set if option is > deprecated, users should refer to AVOption.help text for more information > +#define AV_OPT_FLAG_CHILD_CONSTS(1<<18) ///< set if option > constants can also reside in child objects > //FIXME think about enc-audio, ... style flags > > /** > diff --git a/libavutil/version.h b/libavutil/version.h > index 48d8a38c42..c4946c1c7e 100644 > --- a/libavutil/version.h > +++ b/libavutil/version.h > @@ -80,7 +80,7 @@ > > #define LIBAVUTIL_VERSION_MAJOR 56 > #define LIBAVUTIL_VERSION_MINOR 44 > -#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.4 I'm with this idea to specify avctx->profile with candidate options in child encoder. Also verified that this would benefit encoders who share the standard profile options and use avtcx->profile directly. For others we may need to implement some corresponding changes to transfer from private->profile to avctx->profile. (But we may keep it for now, and change step by step) - Linjie ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/5] avformat/webmdashenc: Don't segfault on invalid arguments
The current parsing process for adaptation_sets does not guarantee every adaptation set to contain at least one stream, because the loop exits immediately as soon as the end of the string has been reached, without checking whether the currently active adaptation set group is lacking a stream. This would lead to segfaults lateron as the rest of the code presumed that every adaptation set contains a stream. This commit fixes this by erroring out when the last adaptation set group is incomplete. Signed-off-by: Andreas Rheinhardt --- libavformat/webmdashenc.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c index fd07b3e34a..3101e0a039 100644 --- a/libavformat/webmdashenc.c +++ b/libavformat/webmdashenc.c @@ -437,8 +437,13 @@ static int parse_adaptation_sets(AVFormatContext *s) } // syntax id=0,streams=0,1,2 id=1,streams=3,4 and so on state = new_set; -while (p < w->adaptation_sets + strlen(w->adaptation_sets)) { -if (state == new_set && *p == ' ') { +while (1) { +if (*p == '\0') { +if (state == new_set) +break; +else +return AVERROR(EINVAL); +} else if (state == new_set && *p == ' ') { p++; continue; } else if (state == new_set && !strncmp(p, "id=", 3)) { -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/5] avformat/webmdashenc: Simplify parsing strings
Don't use the functions for searching substrings when all one is looking for is a char anyway. Given that there is already a standard library function for "find last occurence of a char in a string" also allows one to remove a custom loop. Signed-off-by: Andreas Rheinhardt --- libavformat/webmdashenc.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c index 3101e0a039..eb286cab99 100644 --- a/libavformat/webmdashenc.c +++ b/libavformat/webmdashenc.c @@ -274,7 +274,6 @@ static int parse_filename(char *filename, char **representation_id, char **initialization_pattern, char **media_pattern) { char *underscore_pos = NULL; char *period_pos = NULL; -char *temp_pos = NULL; char *filename_str = av_strdup(filename); int ret = 0; @@ -282,16 +281,12 @@ static int parse_filename(char *filename, char **representation_id, ret = AVERROR(ENOMEM); goto end; } -temp_pos = av_stristr(filename_str, "_"); -while (temp_pos) { -underscore_pos = temp_pos + 1; -temp_pos = av_stristr(temp_pos + 1, "_"); -} +underscore_pos = strrchr(filename_str, '_'); if (!underscore_pos) { ret = AVERROR_INVALIDDATA; goto end; } -period_pos = av_stristr(underscore_pos, "."); +period_pos = strchr(++underscore_pos, '.'); if (!period_pos) { ret = AVERROR_INVALIDDATA; goto end; -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/5] avformat/webmdashenc: Remove possibility of infinite loop
The WebM DASH manifest muxer uses a loop to parse the adaptation_sets string (which is given by the user and governs which AVStreams are mapped to what adaptation set) and the very beginning of this loop is "if (*p == ' ') continue;". This of course leads to an infinite loop if the condition is true. It is true if e.g. the string begins with ' ' or if there are more than one ' ' between different adaptation set groups. To fix this, the parsing process has been modified to consume the space if it is at a place where it can legitimately occur, i.e. when a new adaptation set group is expected. The latter restriction implies that an error is returned if a space exists where none is allowed to exist. Signed-off-by: Andreas Rheinhardt --- libavformat/webmdashenc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c index 250c8ca3ad..fd07b3e34a 100644 --- a/libavformat/webmdashenc.c +++ b/libavformat/webmdashenc.c @@ -438,9 +438,10 @@ static int parse_adaptation_sets(AVFormatContext *s) // syntax id=0,streams=0,1,2 id=1,streams=3,4 and so on state = new_set; while (p < w->adaptation_sets + strlen(w->adaptation_sets)) { -if (*p == ' ') +if (state == new_set && *p == ' ') { +p++; continue; -else if (state == new_set && !strncmp(p, "id=", 3)) { +} else if (state == new_set && !strncmp(p, "id=", 3)) { void *mem = av_realloc(w->as, sizeof(*w->as) * (w->nb_as + 1)); const char *comma; if (mem == NULL) -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/5] avformat/webmdashenc: Avoid allocation for parsing a number
In order to parse a number from a string, the WebM DASH manifest muxer would duplicate (via heap-allocation) the part of the string that contains the number, then read the number via atoi() and then free the duplicate again. This has been replaced by simply using strtoll() (which in contrast to atoi() has defined behaviour when the number is not representable). Signed-off-by: Andreas Rheinhardt --- libavformat/webmdashenc.c | 14 +- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c index 465485c90c..05015a08c1 100644 --- a/libavformat/webmdashenc.c +++ b/libavformat/webmdashenc.c @@ -425,18 +425,6 @@ static int write_adaptation_set(AVFormatContext *s, int as_index) return 0; } -static int to_integer(char *p, int len) -{ -int ret; -char *q = av_malloc(len); -if (!q) -return AVERROR(ENOMEM); -av_strlcpy(q, p, len); -ret = atoi(q); -av_free(q); -return ret; -} - static int parse_adaptation_sets(AVFormatContext *s) { WebMDashMuxContext *w = s->priv_data; @@ -483,7 +471,7 @@ static int parse_adaptation_sets(AVFormatContext *s) return ret; q = p; while (*q != '\0' && *q != ',' && *q != ' ') q++; -as->streams[as->nb_streams - 1] = to_integer(p, q - p + 1); +as->streams[as->nb_streams - 1] = strtoll(p, NULL, 10); if (as->streams[as->nb_streams - 1] < 0 || as->streams[as->nb_streams - 1] >= s->nb_streams) { av_log(s, AV_LOG_ERROR, "Invalid value for 'streams' in adapation_sets.\n"); -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/5] avformat/webmdashenc: Be more strict when parsing stream indices
The syntax of the adaptation_sets string by which the user determines the mapping of AVStreams to adaptation sets is "id=x,streams=a,b,c id=y,streams=d,e" (means: the streams with the indices a, b and c belong to the adaptation set with id x). Yet there was no check for whether these indices were actual numbers and if there is a number whether it really extends to the next ',', ' ' or to the end of the string or not. This commit adds a check for this. Signed-off-by: Andreas Rheinhardt --- libavformat/webmdashenc.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c index 05015a08c1..250c8ca3ad 100644 --- a/libavformat/webmdashenc.c +++ b/libavformat/webmdashenc.c @@ -465,18 +465,18 @@ static int parse_adaptation_sets(AVFormatContext *s) state = parsing_streams; } else if (state == parsing_streams) { struct AdaptationSet *as = >as[w->nb_as - 1]; +int64_t num; int ret = av_reallocp_array(>streams, ++as->nb_streams, sizeof(*as->streams)); if (ret < 0) return ret; -q = p; -while (*q != '\0' && *q != ',' && *q != ' ') q++; -as->streams[as->nb_streams - 1] = strtoll(p, NULL, 10); -if (as->streams[as->nb_streams - 1] < 0 || -as->streams[as->nb_streams - 1] >= s->nb_streams) { +num = strtoll(p, , 10); +if (!av_isdigit(*p) || (*q != ' ' && *q != '\0' && *q != ',') || +num < 0 || num >= s->nb_streams) { av_log(s, AV_LOG_ERROR, "Invalid value for 'streams' in adapation_sets.\n"); return AVERROR(EINVAL); } +as->streams[as->nb_streams - 1] = num; if (*q == '\0') break; if (*q == ' ') state = new_set; p = ++q; -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Don't segfault on uncommon names
Andreas Rheinhardt: > Andreas Rheinhardt: >> The parsing process of the AVOpt-enabled string controlling the mapping >> of input streams to variant streams is roughly as follows: Space and tab >> separate variant stream group maps while the entries in each variant >> stream group map are separated by ','. >> >> The parsing process of each variant stream group proceeded as follows: >> At first the number of occurences of "a:", "v:" and "s:" in each variant >> stream group is calculated so that one can can allocate an array of >> streams with this number of entries. Then the string is split along ',' >> and each substring is parsed. If such a substring starts with "a:", "s:" >> or "v:" it is treated as stream specifier and (if there is a correct >> number after ':') a stream of the variant stream is mapped to one of the >> actual input streams. >> >> Nothing actually guarantees that the number of streams allocated initially >> equals the number of streams that are mapped to an actual input stream. >> These numbers can differ if e.g. the name, the sgroup, agroup or ccgroup >> of the variant stream contain "a:", "s:" or "v:". >> >> The problem hereby is that the rest of the code presumes these numbers >> to be equal and segfaults if it isn't (because the corresponding input >> stream is NULL). >> >> This commit fixes this by modifying the initial counting process to only >> count occurences of "a:", "s:" or "v:" that are at the beginning or that >> immediately follow a ','. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> Alternatively, one could error out if these two counts differed (in >> which case one can conclude that one of the other values must have >> contained "a:", "s:" or "v:"). I have not done so, because using these >> doesn't seem to be forbidden at all and there might even be usecases >> (think of "name:The_Lord_of_the_Rings:_The_Two_Towers" or "Avengers:"). >> >> Furthermore modifying the check has the advantage of not allocating to >> much and it also allows to introduce keys that end with 'a', 's' or 'v'. >> >> libavformat/hlsenc.c | 5 - >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c >> index 5695c6cc95..a381ca3e9e 100644 >> --- a/libavformat/hlsenc.c >> +++ b/libavformat/hlsenc.c >> @@ -1951,10 +1951,13 @@ static int >> parse_variant_stream_mapstring(AVFormatContext *s) >> return AVERROR(EINVAL); >> >> q = varstr; >> -while (q < varstr + strlen(varstr)) { >> +while (1) { >> if (!av_strncasecmp(q, "a:", 2) || !av_strncasecmp(q, "v:", 2) >> || >> !av_strncasecmp(q, "s:", 2)) >> vs->nb_streams++; >> +q = strchr(q, ','); >> +if (!q) >> +break; >> q++; >> } >> vs->streams = av_mallocz(sizeof(AVStream *) * vs->nb_streams); >> > Will apply this tomorrow if there are no objections. > > - Andreas > Applied. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 07/13] avformat/matroskaenc: Don't segfault when seekability changes
Andreas Rheinhardt: > If the Matroska muxer's AVIOContext was unseekable when writing the > header, but is seekable when writing the trailer, the code for writing > the trailer presumes that a dynamic buffer exists and tries to update > its content in order to overwrite data that has already been > preliminarily written when writing the header, yet said buffer doesn't > exist as it has been written finally and not preliminarily when writing > the header (because of the unseekability it was presumed that one won't > be able to update the data anyway). > > This commit adds a check for this and also for a similar situation > involving updating extradata with new data from packet side-data. > > Signed-off-by: Andreas Rheinhardt > --- > It seems that the whole code was based around the presumption that the > seekability does not change mid-stream. E.g. before add68dcca there were > the way level 1 elements were written depended upon the seekability and > the output would be corrupt if it changed between opening and closing. > > Given the lack of tickets about this it seems that this assumption holds > true. Therefore this patch uses the existence of the Tracks buffer as > proxy for seekability. > > libavformat/matroskaenc.c | 9 + > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c > index 99b549ecc4..1a142403fa 100644 > --- a/libavformat/matroskaenc.c > +++ b/libavformat/matroskaenc.c > @@ -2186,7 +2186,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, > const AVPacket *pkt) > > switch (par->codec_id) { > case AV_CODEC_ID_AAC: > -if (side_data_size && (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && > !mkv->is_live) { > +if (side_data_size && mkv->track.bc) { > int filler, output_sample_rate = 0; > ret = get_aac_sample_rates(s, side_data, side_data_size, > >sample_rate, > _sample_rate); > @@ -2213,7 +2213,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, > const AVPacket *pkt) > } > break; > case AV_CODEC_ID_FLAC: > -if (side_data_size && (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && > !mkv->is_live) { > +if (side_data_size && mkv->track.bc) { > uint8_t *old_extradata = par->extradata; > if (side_data_size != par->extradata_size) { > av_log(s, AV_LOG_ERROR, "Invalid FLAC STREAMINFO metadata > for output stream %d\n", > @@ -2229,8 +2229,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, > const AVPacket *pkt) > // FIXME: Remove the following once libaom starts propagating extradata > during init() > //See https://bugs.chromium.org/p/aomedia/issues/detail?id=2012 > case AV_CODEC_ID_AV1: > -if (side_data_size && (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && > !mkv->is_live && > -!par->extradata_size) { > +if (side_data_size && mkv->track.bc && !par->extradata_size) { > AVIOContext *dyn_cp; > uint8_t *codecpriv; > int codecpriv_size; > @@ -2541,6 +2540,7 @@ static int mkv_write_trailer(AVFormatContext *s) > if (ret < 0) > return ret; > > +if (mkv->info.bc) { > // update the duration > av_log(s, AV_LOG_DEBUG, "end duration = %" PRIu64 "\n", > mkv->duration); > avio_seek(mkv->info.bc, mkv->duration_offset, SEEK_SET); > @@ -2549,6 +2549,7 @@ static int mkv_write_trailer(AVFormatContext *s) > MATROSKA_ID_INFO, 0, 0, 0); > if (ret < 0) > return ret; > +} > > if (mkv->track.bc) { > // write Tracks master > Will apply this patchset tomorrow unless there are objections. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/6] avcodec/xiph: Return better error codes
Signed-off-by: Andreas Rheinhardt --- There is another "return -1" left which might either be invalid data or an unsupported future extension of the format (e.g. one that does not have three arrays). I left this as is. libavcodec/xiph.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/xiph.c b/libavcodec/xiph.c index d072224b4a..3073315e63 100644 --- a/libavcodec/xiph.c +++ b/libavcodec/xiph.c @@ -35,7 +35,7 @@ int avpriv_split_xiph_headers(const uint8_t *extradata, int extradata_size, header_start[i] = extradata; extradata += header_len[i]; if (overall_len > extradata_size - header_len[i]) -return -1; +return AVERROR_INVALIDDATA; overall_len += header_len[i]; } } else if (extradata_size >= 3 && extradata_size < INT_MAX - 0x1ff && extradata[0] == 2) { @@ -50,7 +50,7 @@ int avpriv_split_xiph_headers(const uint8_t *extradata, int extradata_size, header_len[i] += *extradata; overall_len += *extradata; if (overall_len > extradata_size) -return -1; +return AVERROR_INVALIDDATA; } header_len[2] = extradata_size - overall_len; header_start[0] = extradata; -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/6] avformat/matroskaenc: Forward errors from avpriv_split_xiph_headers()
Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 99b549ecc4..1b6e80da36 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -603,17 +603,18 @@ static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, const uint8_t *header_start[3]; int header_len[3]; int first_header_size; -int j; +int err, j; if (par->codec_id == AV_CODEC_ID_VORBIS) first_header_size = 30; else first_header_size = 42; -if (avpriv_split_xiph_headers(par->extradata, par->extradata_size, - first_header_size, header_start, header_len) < 0) { +err = avpriv_split_xiph_headers(par->extradata, par->extradata_size, +first_header_size, header_start, header_len); +if (err < 0) { av_log(s, AV_LOG_ERROR, "Extradata corrupt.\n"); -return -1; +return err; } avio_w8(pb, 2);// number packets - 1 -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 6/6] avformat/webm_chunk: Open AVIOContext before initializing sub-muxer
The description of AVOutputFormat.init contains the statement that "this method must not write output". Due to this, the webm_chunk muxer defers opening the AVIOContext for the child muxer until avformat_write_header(), i.e. there is no AVIOContext when the sub-muxer's avformat_init_output() is called. But this violates the documentation of said function which requires the AVFormatContext to have an already opened AVIOContext. This commit fixes this. Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 26 +++--- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 1749509975..f1bee5fa9f 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -44,6 +44,7 @@ typedef struct WebMChunkContext { uint64_t duration_written; int64_t prev_pts; AVFormatContext *avf; +int header_written; } WebMChunkContext; static int webm_chunk_init(AVFormatContext *s) @@ -101,6 +102,15 @@ static int webm_chunk_init(AVFormatContext *s) avpriv_set_pts_info(st, ost->pts_wrap_bits, ost->time_base.num, ost->time_base.den); +if (wc->http_method) +if ((ret = av_dict_set(, "method", wc->http_method, 0)) < 0) +return ret; +ret = s->io_open(s, >pb, oc->url, AVIO_FLAG_WRITE, ); +av_dict_free(); +if (ret < 0) +return ret; +oc->pb->seekable = 0; + if ((ret = av_dict_set_int(, "dash", 1, 0)) < 0 || (ret = av_dict_set_int(, "cluster_time_limit", wc->chunk_duration, 0)) < 0 || @@ -147,19 +157,10 @@ static int webm_chunk_write_header(AVFormatContext *s) WebMChunkContext *wc = s->priv_data; AVFormatContext *oc = wc->avf; int ret; -AVDictionary *options = NULL; -if (wc->http_method) -if ((ret = av_dict_set(, "method", wc->http_method, 0)) < 0) -return ret; -ret = s->io_open(s, >pb, oc->url, AVIO_FLAG_WRITE, ); -av_dict_free(); -if (ret < 0) -return ret; - -oc->pb->seekable = 0; ret = avformat_write_header(oc, NULL); ff_format_io_close(s, >pb); +wc->header_written = 1; if (ret < 0) return ret; return 0; @@ -270,7 +271,10 @@ static void webm_chunk_deinit(AVFormatContext *s) if (!wc->avf) return; -ffio_free_dyn_buf(>avf->pb); +if (wc->header_written) +ffio_free_dyn_buf(>avf->pb); +else +ff_format_io_close(s, >avf->pb); avformat_free_context(wc->avf); wc->avf = NULL; } -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/6] avformat/segment: Propagate disposition
Signed-off-by: Andreas Rheinhardt --- libavformat/segment.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/segment.c b/libavformat/segment.c index 7e8bd65976..2ff2b5372e 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -179,6 +179,7 @@ static int segment_mux_init(AVFormatContext *s) st->sample_aspect_ratio = ist->sample_aspect_ratio; st->time_base = ist->time_base; st->avg_frame_rate = ist->avg_frame_rate; +st->disposition = ist->disposition; #if FF_API_LAVF_AVCTX FF_DISABLE_DEPRECATION_WARNINGS if (ipar->codec_tag == MKTAG('t','m','c','d')) -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/6] avformat/matroskadec: Use proper context for logging
Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 26 ++ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index b277c05f9d..81e7b16821 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1771,7 +1771,7 @@ static void matroska_convert_tags(AVFormatContext *s) } } if (!found) { -av_log(NULL, AV_LOG_WARNING, +av_log(s, AV_LOG_WARNING, "The tags at index %d refer to a " "non-existent attachment %"PRId64".\n", i, tags[i].target.attachuid); @@ -1788,7 +1788,7 @@ static void matroska_convert_tags(AVFormatContext *s) } } if (!found) { -av_log(NULL, AV_LOG_WARNING, +av_log(s, AV_LOG_WARNING, "The tags at index %d refer to a non-existent chapter " "%"PRId64".\n", i, tags[i].target.chapteruid); @@ -1805,7 +1805,7 @@ static void matroska_convert_tags(AVFormatContext *s) } } if (!found) { -av_log(NULL, AV_LOG_WARNING, +av_log(s, AV_LOG_WARNING, "The tags at index %d refer to a non-existent track " "%"PRId64".\n", i, tags[i].target.trackuid); @@ -2157,7 +2157,9 @@ static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) { return 0; } -static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track) { +static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track, + void *logctx) +{ AVSphericalMapping *spherical; enum AVSphericalProjection projection; size_t spherical_size; @@ -2170,7 +2172,7 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track) track->video.projection.private.size); if (bytestream2_get_byte() != 0) { -av_log(NULL, AV_LOG_WARNING, "Unknown spherical metadata\n"); +av_log(logctx, AV_LOG_WARNING, "Unknown spherical metadata\n"); return 0; } @@ -2185,14 +2187,14 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track) r = bytestream2_get_be32(); if (b >= UINT_MAX - t || r >= UINT_MAX - l) { -av_log(NULL, AV_LOG_ERROR, +av_log(logctx, AV_LOG_ERROR, "Invalid bounding rectangle coordinates " "%"PRIu32",%"PRIu32",%"PRIu32",%"PRIu32"\n", l, t, r, b); return AVERROR_INVALIDDATA; } } else if (track->video.projection.private.size != 0) { -av_log(NULL, AV_LOG_ERROR, "Unknown spherical metadata\n"); +av_log(logctx, AV_LOG_ERROR, "Unknown spherical metadata\n"); return AVERROR_INVALIDDATA; } @@ -2203,19 +2205,19 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track) break; case MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP: if (track->video.projection.private.size < 4) { -av_log(NULL, AV_LOG_ERROR, "Missing projection private properties\n"); +av_log(logctx, AV_LOG_ERROR, "Missing projection private properties\n"); return AVERROR_INVALIDDATA; } else if (track->video.projection.private.size == 12) { uint32_t layout = bytestream2_get_be32(); if (layout) { -av_log(NULL, AV_LOG_WARNING, +av_log(logctx, AV_LOG_WARNING, "Unknown spherical cubemap layout %"PRIu32"\n", layout); return 0; } projection = AV_SPHERICAL_CUBEMAP; padding = bytestream2_get_be32(); } else { -av_log(NULL, AV_LOG_ERROR, "Unknown spherical metadata\n"); +av_log(logctx, AV_LOG_ERROR, "Unknown spherical metadata\n"); return AVERROR_INVALIDDATA; } break; @@ -2223,7 +2225,7 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track) /* No Spherical metadata */ return 0; default: -av_log(NULL, AV_LOG_WARNING, +av_log(logctx, AV_LOG_WARNING, "Unknown spherical metadata type %"PRIu64"\n", track->video.projection.type); return 0; @@ -2779,7 +2781,7 @@ static int matroska_parse_tracks(AVFormatContext *s) ret = mkv_parse_video_color(st, track); if (ret < 0) return ret; -ret = mkv_parse_video_projection(st, track); +ret = mkv_parse_video_projection(st, track, matroska->ctx); if (ret < 0)
[FFmpeg-devel] [PATCH 1/6] avformat/segment: Access AVStream more directly
by storing s->streams[i] in a pointer instead of constantly using s->streams[i]->... Signed-off-by: Andreas Rheinhardt --- libavformat/segment.c | 17 - 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libavformat/segment.c b/libavformat/segment.c index 32c09827eb..7e8bd65976 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -162,12 +162,11 @@ static int segment_mux_init(AVFormatContext *s) oc->flags = s->flags; for (i = 0; i < s->nb_streams; i++) { -AVStream *st; -AVCodecParameters *ipar, *opar; +AVStream *st, *ist = s->streams[i]; +AVCodecParameters *ipar = ist->codecpar, *opar; if (!(st = avformat_new_stream(oc, NULL))) return AVERROR(ENOMEM); -ipar = s->streams[i]->codecpar; opar = st->codecpar; avcodec_parameters_copy(opar, ipar); if (!oc->oformat->codec_tag || @@ -177,16 +176,16 @@ static int segment_mux_init(AVFormatContext *s) } else { opar->codec_tag = 0; } -st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio; -st->time_base = s->streams[i]->time_base; -st->avg_frame_rate = s->streams[i]->avg_frame_rate; +st->sample_aspect_ratio = ist->sample_aspect_ratio; +st->time_base = ist->time_base; +st->avg_frame_rate = ist->avg_frame_rate; #if FF_API_LAVF_AVCTX FF_DISABLE_DEPRECATION_WARNINGS -if (s->streams[i]->codecpar->codec_tag == MKTAG('t','m','c','d')) -st->codec->time_base = s->streams[i]->codec->time_base; +if (ipar->codec_tag == MKTAG('t','m','c','d')) +st->codec->time_base = ist->codec->time_base; FF_ENABLE_DEPRECATION_WARNINGS #endif -av_dict_copy(>metadata, s->streams[i]->metadata, 0); +av_dict_copy(>metadata, ist->metadata, 0); } return 0; -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/mpegts: Shuffle avio_seek
On Sun, May 17, 2020 at 02:11:19PM +0200, Marton Balint wrote: > > > On Thu, 7 May 2020, Michael Niedermayer wrote: > > >On Thu, May 07, 2020 at 02:09:43PM +0200, Anton Khirnov wrote: > >>Quoting Michael Niedermayer (2020-05-07 12:38:26) > >>>This avoids accessing an old, no longer valid buffer. > >>>Fixes: out of array access > >>>Fixes: crash_audio-2020 > >>> > >>>Found-by: le wu > >>>Signed-off-by: Michael Niedermayer > >>>--- > >>> libavformat/mpegts.c | 7 --- > >>> 1 file changed, 4 insertions(+), 3 deletions(-) > >>> > >>>diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c > >>>index 0833d62ea5..a065c61c40 100644 > >>>--- a/libavformat/mpegts.c > >>>+++ b/libavformat/mpegts.c > >>>@@ -2881,15 +2881,16 @@ static int mpegts_resync(AVFormatContext *s, int > >>>seekback, const uint8_t *curren > >>> AVIOContext *pb = s->pb; > >>> int c, i; > >>> uint64_t pos = avio_tell(pb); > >>>- > >>>-avio_seek(pb, -FFMIN(seekback, pos), SEEK_CUR); > >>>+int64_t back = FFMIN(seekback, pos); > >>> > >>> //Special case for files like 01c56b0dc1.ts > >>> if (current_packet[0] == 0x80 && current_packet[12] == 0x47) { > >>>-avio_seek(pb, 12, SEEK_CUR); > >>>+avio_seek(pb, 12 - back, SEEK_CUR); > >>> return 0; > >>> } > >>> > >>>+avio_seek(pb, -back, SEEK_CUR); > >>>+ > >> > >>This seems pretty non-obvious - why would ordering seeks in a specific > >>way result in invalid memorry access? > > > >because current_packet in one case points to the avio internal buffer > >and doing any "state changing" avio could change that buffer. > >so all accesses to the buffer must happen before any avio seeks > > Yuck. Patch LGTM though. will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are too smart to engage in politics are punished by being governed by those who are dumber. -- Plato signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/frame_thread_encoder: remove usage of avcodec_encode_video2()
On 5/17/2020 12:37 PM, Carl Eugen Hoyos wrote: > > >> Am 17.05.2020 um 16:07 schrieb James Almer : >> >> Call the encoder's internal AVCodec.encode2() function instead. > > Is there a performance impact? > > Carl Eugen None that i have noticed. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/frame_thread_encoder: remove usage of avcodec_encode_video2()
> Am 17.05.2020 um 16:07 schrieb James Almer : > > Call the encoder's internal AVCodec.encode2() function instead. Is there a performance impact? Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/frame_thread_encoder: remove usage of avcodec_encode_video2()
Call the encoder's internal AVCodec.encode2() function instead. Signed-off-by: James Almer --- libavcodec/encode.c | 20 libavcodec/frame_thread_encoder.c | 14 -- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 9ed2cf0f59..1358f33ea5 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -277,14 +277,12 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, return AVERROR(ENOSYS); } -if(CONFIG_FRAME_THREAD_ENCODER && - avctx->internal->frame_thread_encoder && (avctx->active_thread_type_THREAD_FRAME)) -return ff_thread_video_encode_frame(avctx, avpkt, frame, got_packet_ptr); - if ((avctx->flags_CODEC_FLAG_PASS1) && avctx->stats_out) avctx->stats_out[0] = '\0'; -if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) { +if (!frame && +!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY || + (avctx->internal->frame_thread_encoder && avctx->active_thread_type & FF_THREAD_FRAME))) { av_packet_unref(avpkt); return 0; } @@ -299,7 +297,15 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, av_assert0(avctx->codec->encode2); -ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr); + +if (CONFIG_FRAME_THREAD_ENCODER && +avctx->internal->frame_thread_encoder && avctx->active_thread_type & FF_THREAD_FRAME) +ret = ff_thread_video_encode_frame(avctx, avpkt, frame, got_packet_ptr); +else { +ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr); +if (!ret && *got_packet_ptr && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) +avpkt->pts = avpkt->dts = frame->pts; +} av_assert0(ret <= 0); emms_c(); @@ -326,8 +332,6 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, if (!ret) { if (!*got_packet_ptr) avpkt->size = 0; -else if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) -avpkt->pts = avpkt->dts = frame->pts; if (needs_realloc && avpkt->data) { ret = av_buffer_realloc(>buf, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE); diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c index 949bc69f81..cea0ea2af3 100644 --- a/libavcodec/frame_thread_encoder.c +++ b/libavcodec/frame_thread_encoder.c @@ -66,7 +66,7 @@ static void * attribute_align_arg worker(void *v){ AVPacket *pkt = NULL; while (!atomic_load(>exit)) { -int got_packet, ret; +int got_packet = 0, ret; AVFrame *frame; Task task; @@ -86,19 +86,21 @@ static void * attribute_align_arg worker(void *v){ pthread_mutex_unlock(>task_fifo_mutex); frame = task.indata; -ret = avcodec_encode_video2(avctx, pkt, frame, _packet); -pthread_mutex_lock(>buffer_mutex); -av_frame_unref(frame); -pthread_mutex_unlock(>buffer_mutex); -av_frame_free(); +ret = avctx->codec->encode2(avctx, pkt, frame, _packet); if(got_packet) { int ret2 = av_packet_make_refcounted(pkt); if (ret >= 0 && ret2 < 0) ret = ret2; +if (!ret) +pkt->pts = pkt->dts = frame->pts; } else { pkt->data = NULL; pkt->size = 0; } +pthread_mutex_lock(>buffer_mutex); +av_frame_unref(frame); +pthread_mutex_unlock(>buffer_mutex); +av_frame_free(); pthread_mutex_lock(>finished_task_mutex); c->finished_tasks[task.index].outdata = pkt; pkt = NULL; c->finished_tasks[task.index].return_code = ret; -- 2.26.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/mpegts: Check the next sync byte to avoid incorrectt detected raw packet size
On Sun, 17 May 2020, lance.lmw...@gmail.com wrote: On Sat, May 16, 2020 at 07:36:45PM +0200, Marton Balint wrote: On Sat, 16 May 2020, lance.lmw...@gmail.com wrote: > On Sat, May 16, 2020 at 11:44:01AM +0200, Marton Balint wrote: > > > > > > On Sat, 16 May 2020, lance.lmw...@gmail.com wrote: > > > > I suggest you capture the input, so this issue can be properly reproduced > > and share it. It may even make sense to create a fate test from it. > > Have tried, the issue can't be reproduced by capture offset file. I guess it's > caused by live stream seek isn't same as off line file. If that is the case then you can override the seekability of files by using -seekable 0 option. Alternatively you might find some other means to replay the recorded ts, anyhow this should be reproduced, because I have a feeling we don't have the whole picture of what is going on. I have spend more time to investigate it, I have try to capture a pcap file to reproduce the issue, with tcprelay, it can be reproduced every time, however if export to ts, I failed to reproduce it. Great. Can you share the pcap file? You can may send it to me privately if you don't want it to be made public. [...] Thanks for the advices, I spend more time to investigate and try to fix it in the resync logic, with more debug info, I notice the old reanalyze() has one drawback, the pos isn't one of 188/192/204, so it'll cause the stat will reset all stats ahead of one of stats[i] which cause normal 188 failed to detected anymore. I think it's better to return if pos isn't one of 188/192/204, it'll fix my issue by testing, please help to review whether it's reasonable or not. I am not sure yet. the log which explain why it failed to detect back to 188: [mpegts @ 0x3ef0180] reanalyze: stat: 1, stat[0]: 1, stat[1]: 0, stat[2]: 0, raw_packet_size: 192, pos: 188 [mpegts @ 0x3ef0180] reanalyze: stat: 2, stat[0]: 2, stat[1]: 0, stat[2]: 0, raw_packet_size: 192, pos: 188 [mpegts @ 0x3ef0180] reanalyze: stat: 3, stat[0]: 3, stat[1]: 0, stat[2]: 0, raw_packet_size: 192, pos: 188 [mpegts @ 0x3ef0180] reanalyze: stat: 4, stat[0]: 4, stat[1]: 0, stat[2]: 0, raw_packet_size: 192, pos: 188 [mpegts @ 0x3ef0180] reanalyze: stat: 5, stat[0]: 4, stat[1]: 0, stat[2]: 0, raw_packet_size: 192, pos: 564 [mpegts @ 0x3ef0180] reanalyze: stat: 6, stat[0]: 5, stat[1]: 0, stat[2]: 0, raw_packet_size: 192, pos: 188 [mpegts @ 0x3ef0180] reanalyze: stat: 7, stat[0]: 6, stat[1]: 0, stat[2]: 0, raw_packet_size: 192, pos: 188 [mpegts @ 0x3ef0180] reanalyze: stat: 8, stat[0]: 6, stat[1]: 0, stat[2]: 0, raw_packet_size: 192, pos: 376 [mpegts @ 0x3ef0180] reanalyze: stat: 9, stat[0]: 7, stat[1]: 0, stat[2]: 0, raw_packet_size: 192, pos: 188 [mpegts @ 0x3ef0180] reanalyze: stat: 10, stat[0]: 7, stat[1]: 0, stat[2]: 0, raw_packet_size: 192, pos: 474 [mpegts @ 0x3ef0180] reanalyze: stat: 0, stat[0]: 0, stat[1]: 0, stat[2]: 0, raw_packet_size: 192, pos: 752 pos as a multiple of 188 and not 188 is very suspicious, and it might be because pos47_full is only updated if the packet has a payload. Can you try the attached patch and see if it makes a difference? Thanks, Martondiff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 0833d62ea5..921a7ae2db 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2774,11 +2774,6 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet, int64_t pos) if (p >= p_end || !has_payload) return 0; -if (pos >= 0) { -av_assert0(pos >= TS_PACKET_SIZE); -ts->pos47_full = pos - TS_PACKET_SIZE; -} - if (tss->type == MPEGTS_SECTION) { if (is_start) { /* pointer field present */ @@ -2926,6 +2921,8 @@ static int read_packet(AVFormatContext *s, uint8_t *buf, int raw_packet_size, else continue; } else { +MpegTSContext *ts = s->priv_data; +ts->pos47_full = avio_tell(pb) - TS_PACKET_SIZE; break; } } ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/dump: Use int64_t for intermediate time values
On 17/05/2020 12:16, Paul B Mahol wrote: > LGTM Pushed, thanks. - Derek ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/mpegts: Shuffle avio_seek
On Thu, 7 May 2020, Michael Niedermayer wrote: On Thu, May 07, 2020 at 02:09:43PM +0200, Anton Khirnov wrote: Quoting Michael Niedermayer (2020-05-07 12:38:26) This avoids accessing an old, no longer valid buffer. Fixes: out of array access Fixes: crash_audio-2020 Found-by: le wu Signed-off-by: Michael Niedermayer --- libavformat/mpegts.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 0833d62ea5..a065c61c40 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2881,15 +2881,16 @@ static int mpegts_resync(AVFormatContext *s, int seekback, const uint8_t *curren AVIOContext *pb = s->pb; int c, i; uint64_t pos = avio_tell(pb); - -avio_seek(pb, -FFMIN(seekback, pos), SEEK_CUR); +int64_t back = FFMIN(seekback, pos); //Special case for files like 01c56b0dc1.ts if (current_packet[0] == 0x80 && current_packet[12] == 0x47) { -avio_seek(pb, 12, SEEK_CUR); +avio_seek(pb, 12 - back, SEEK_CUR); return 0; } +avio_seek(pb, -back, SEEK_CUR); + This seems pretty non-obvious - why would ordering seeks in a specific way result in invalid memorry access? because current_packet in one case points to the avio internal buffer and doing any "state changing" avio could change that buffer. so all accesses to the buffer must happen before any avio seeks Yuck. Patch LGTM though. Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/dump: Use int64_t for intermediate time values
LGTM On 5/16/20, Derek Buitenhuis wrote: > Prevents wrap-around to negative values while calculating the duration > string. > > Before: > > Duration: -411422:-59:-42.17, start: 0.00, bitrate: 0 kb/s > > After: > > Duration: 781623:28:34.17, start: 0.00, bitrate: 0 kb/s > > Signed-off-by: Derek Buitenhuis > --- > Minimal example file: http://chromashift.org/s/long3.mp4` > --- > libavformat/dump.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/libavformat/dump.c b/libavformat/dump.c > index 5e9a03185f..06bafc272d 100644 > --- a/libavformat/dump.c > +++ b/libavformat/dump.c > @@ -615,7 +615,7 @@ void av_dump_format(AVFormatContext *ic, int index, > if (!is_output) { > av_log(NULL, AV_LOG_INFO, " Duration: "); > if (ic->duration != AV_NOPTS_VALUE) { > -int hours, mins, secs, us; > +int64_t hours, mins, secs, us; > int64_t duration = ic->duration + (ic->duration <= INT64_MAX - > 5000 ? 5000 : 0); > secs = duration / AV_TIME_BASE; > us= duration % AV_TIME_BASE; > @@ -623,7 +623,7 @@ void av_dump_format(AVFormatContext *ic, int index, > secs %= 60; > hours = mins / 60; > mins %= 60; > -av_log(NULL, AV_LOG_INFO, "%02d:%02d:%02d.%02d", hours, mins, > secs, > +av_log(NULL, AV_LOG_INFO, > "%02"PRId64":%02"PRId64":%02"PRId64".%02"PRId64"", hours, mins, secs, > (100 * us) / AV_TIME_BASE); > } else { > av_log(NULL, AV_LOG_INFO, "N/A"); > -- > 2.26.2 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] avformat/mpegts: Fix misdetection of the raw packet size
From: Limin Wang Signed-off-by: Limin Wang --- libavformat/mpegts.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 0833d62..4bca339 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2852,6 +2852,8 @@ static void reanalyze(MpegTSContext *ts) { ts->size_stat[1] ++; } else if (pos == TS_FEC_PACKET_SIZE) { ts->size_stat[2] ++; +} else { +return; } ts->size_stat_count ++; -- 1.8.3.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/mpegts: Check the next sync byte to avoid incorrectt detected raw packet size
On Sat, May 16, 2020 at 07:36:45PM +0200, Marton Balint wrote: > > > On Sat, 16 May 2020, lance.lmw...@gmail.com wrote: > > > On Sat, May 16, 2020 at 11:44:01AM +0200, Marton Balint wrote: > > > > > > > > > On Sat, 16 May 2020, lance.lmw...@gmail.com wrote: > > > > > > > On Fri, May 15, 2020 at 06:52:55PM +0200, Marton Balint wrote: > > > > > > > > > On Fri, 15 May 2020, lance.lmw...@gmail.com wrote: > > > > > > > > On Fri, May 15, 2020 at 08:02:44PM +0800, myp...@gmail.com > > > wrote: > > > > > > > On Fri, May 15, 2020 at 6:23 PM wrote: > > > > > > > > > > > > > > > > From: Limin Wang > > > > > > > > > > > > > > > > reanalyze() may misdetect the new packet size as 204, but it's > > > > > > > > 188 still actualy, > > > > > > > > it'll cause many cc errors report and cannot be recovered. So > > > > > > > > it's better to check > > > > > > > > the next sync byte before skip the extra unused bytes. > > > > > > > > > > > > > > > > Also, it is best to change SIZE_STAT_THRESHOLD from 10 to 100? > > > > > > > > If the input stream has > > > > > > > > a master/slave switch serveral times, the raw size can be > > > > > > > > easily detected by mistake. > > > > > > > > > > > > > > > > Signed-off-by: Limin Wang > > > > > > > > --- > > > > > > > > libavformat/mpegts.c | 13 +++-- > > > > > > > > 1 file changed, 7 insertions(+), 6 deletions(-) > > > > > > > > > > > > > > > > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c > > > > > > > > index 0833d62..049555c 100644 > > > > > > > > --- a/libavformat/mpegts.c > > > > > > > > +++ b/libavformat/mpegts.c > > > > > > > > @@ -2932,11 +2932,12 @@ static int read_packet(AVFormatContext > > > > > > > > *s, uint8_t *buf, int raw_packet_size, > > > > > > > > return 0; > > > > > > > > } > > > > > > > > > > > > > > > > -static void finished_reading_packet(AVFormatContext *s, int > > > > > > > > raw_packet_size) > > > > > > > > +static void finished_reading_packet(AVFormatContext *s, const > > > > > > > > uint8_t *data, int raw_packet_size) > > > > > > > > { > > > > > > > > AVIOContext *pb = s->pb; > > > > > > > > int skip = raw_packet_size - TS_PACKET_SIZE; > > > > > > > > -if (skip > 0) > > > > > > > > +/* Check the next sync byte to avoid incorrectt detected > > > > > > > > raw packet size */ > > > > > > > > +if (skip > 0 && data[TS_PACKET_SIZE] != 0x47) > > > > > > > > avio_skip(pb, skip); > > > > > > > > } > > > > > > > > > > > > > > > > @@ -2985,7 +2986,7 @@ static int handle_packets(MpegTSContext > > > > > > > > *ts, int64_t nb_packets) > > > > > > > > if (ret != 0) > > > > > > > > break; > > > > > > > > ret = handle_packet(ts, data, avio_tell(s->pb)); > > > > > > > > -finished_reading_packet(s, ts->raw_packet_size); > > > > > > > > +finished_reading_packet(s, data, ts->raw_packet_size); > > > > > > > > if (ret != 0) > > > > > > > > break; > > > > > > > > } > > > > > > > > @@ -3137,7 +3138,7 @@ static int > > > > > > > > mpegts_read_header(AVFormatContext *s) > > > > > > > > pid = AV_RB16(data + 1) & 0x1fff; > > > > > > > > if ((pcr_pid == -1 || pcr_pid == pid) && > > > > > > > > parse_pcr(_h, _l, data) == 0) { > > > > > > > > -finished_reading_packet(s, > > > > > > > > ts->raw_packet_size); > > > > > > > > +finished_reading_packet(s, data, > > > > > > > > ts->raw_packet_size); > > > > > > > > pcr_pid = pid; > > > > > > > > packet_count[nb_pcrs] = nb_packets; > > > > > > > > pcrs[nb_pcrs] = pcr_h * 300 + pcr_l; > > > > > > > > @@ -3154,7 +3155,7 @@ static int > > > > > > > > mpegts_read_header(AVFormatContext *s) > > > > > > > > } > > > > > > > > } > > > > > > > > } else { > > > > > > > > -finished_reading_packet(s, > > > > > > > > ts->raw_packet_size); > > > > > > > > +finished_reading_packet(s, data, > > > > > > > > ts->raw_packet_size); > > > > > > > > } > > > > > > > > nb_packets++; > > > > > > > > } > > > > > > > > @@ -3194,7 +3195,7 @@ static int > > > > > > > > mpegts_raw_read_packet(AVFormatContext *s, AVPacket *pkt) > > > > > > > > } > > > > > > > > if (data != pkt->data) > > > > > > > > memcpy(pkt->data, data, ts->raw_packet_size); > > > > > > > > -finished_reading_packet(s, ts->raw_packet_size); > > > > > > > > +finished_reading_packet(s, data, ts->raw_packet_size); > > > > > > > > if (ts->mpeg2ts_compute_pcr) { > > > > > > > > /* compute exact PCR for each packet */ > > > > > > > > if (parse_pcr(_h, _l, pkt->data) == 0) { > > > > > > > > -- > > > > > > > > 1.8.3.1 > > > > > > > > > > > > > > > Do you have a case to reproduce the cc errors report? > > > > > > > Yes, it's real case which can be reproduced in lab. > > > >
[FFmpeg-devel] [PATCH 1/3] lavc/aac_ac3_parser: improve the raw AAC file bit rate calculation
From: Jun Zhao Now we just use one ADTS raw frame to calculate the bit rate, it's lead to a larger error when get the duration from bit rate, the improvement cumulate Nth ADTS frames to get the average bit rate. e,g used the command get the duration like: ffprobe -show_entries format=duration -i fate-suite/aac/foo.aac before this improvement dump the duration=2.173935 after this improvement dump the duration=1.979267 in fact, the real duration can be get by command like: ffmpeg -i fate-suite/aac/foo.aac -f null /dev/null with time=00:00:01.97 Also update the fate-adtstoasc_ticket3715. Signed-off-by: Jun Zhao --- libavcodec/aac_ac3_parser.c | 9 +++-- libavcodec/aac_ac3_parser.h | 2 ++ tests/ref/fate/adtstoasc_ticket3715 | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c index 54e4598..0746798 100644 --- a/libavcodec/aac_ac3_parser.c +++ b/libavcodec/aac_ac3_parser.c @@ -97,8 +97,13 @@ get_next: avctx->audio_service_type = s->service_type; } -if (avctx->codec_id != AV_CODEC_ID_EAC3) -avctx->bit_rate = s->bit_rate; +/* Calculate the average bit rate */ +s->frame_number++; +if (avctx->codec_id != AV_CODEC_ID_EAC3) { +avctx->bit_rate = +(s->last_bit_rate * (s->frame_number -1) + s->bit_rate)/s->frame_number; +s->last_bit_rate = avctx->bit_rate; +} } return i; diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h index c2506a5..b04041f 100644 --- a/libavcodec/aac_ac3_parser.h +++ b/libavcodec/aac_ac3_parser.h @@ -55,6 +55,8 @@ typedef struct AACAC3ParseContext { uint64_t state; int need_next_header; +int frame_number; +int last_bit_rate; enum AVCodecID codec_id; } AACAC3ParseContext; diff --git a/tests/ref/fate/adtstoasc_ticket3715 b/tests/ref/fate/adtstoasc_ticket3715 index 49fa3eb..3b473ee 100644 --- a/tests/ref/fate/adtstoasc_ticket3715 +++ b/tests/ref/fate/adtstoasc_ticket3715 @@ -1,4 +1,4 @@ -4110be924e21846d0e174fac679b062e *tests/data/fate/adtstoasc_ticket3715.mov +3e63cbb6bb6ec756d79fab2632fef305 *tests/data/fate/adtstoasc_ticket3715.mov 33324 tests/data/fate/adtstoasc_ticket3715.mov #extradata 0:2, 0x00340022 #tb 0: 1/44100 -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3] lavf/utils: Reindent after previous commit
From: Jun Zhao Reindent after previous commit. Signed-off-by: Jun Zhao --- libavformat/utils.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index d7fdd72..1798f70 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2988,9 +2988,9 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset) av_log(ic, AV_LOG_TRACE, "stream %d: start_time: N/A duration: %0.3f\n", i, (double) st->duration * av_q2d(st->time_base)); else -av_log(ic, AV_LOG_TRACE, "stream %d: start_time: %0.3f duration: %0.3f\n", i, - (double) st->start_time * av_q2d(st->time_base), - (double) st->duration * av_q2d(st->time_base)); +av_log(ic, AV_LOG_TRACE, "stream %d: start_time: %0.3f duration: %0.3f\n", i, + (double) st->start_time * av_q2d(st->time_base), + (double) st->duration * av_q2d(st->time_base)); } } @@ -3001,12 +3001,12 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset) duration_estimate_name(ic->duration_estimation_method), (int64_t)ic->bit_rate / 1000); else -av_log(ic, AV_LOG_TRACE, -"format: start_time: %0.3f duration: %0.3f (estimate from %s) bitrate=%"PRId64" kb/s\n", -(double) ic->start_time / AV_TIME_BASE, -(double) ic->duration / AV_TIME_BASE, -duration_estimate_name(ic->duration_estimation_method), -(int64_t)ic->bit_rate / 1000); +av_log(ic, AV_LOG_TRACE, + "format: start_time: %0.3f duration: %0.3f (estimate from %s) bitrate=%"PRId64" kb/s\n", + (double) ic->start_time / AV_TIME_BASE, + (double) ic->duration / AV_TIME_BASE, + duration_estimate_name(ic->duration_estimation_method), + (int64_t)ic->bit_rate / 1000); } } -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] lavf/utils: fix start_time dump when the value is AV_NOPTS_VALUE
From: Jun Zhao The command: ffprobe -show_format -i ../fate-suite/aac/foo.aac -loglevel 99 will dump the trace message as follow when start_time is AV_NOPTS_VALUE [aac @ 0x55bf8e1f3dc0] stream 0: start_time: -326791809695.818 duration: 2.174 [aac @ 0x55bf8e1f3dc0] format: start_time: -9223372036854.775 duration: 2.174 bitrate=120 kb/s after this fix, will dump the start_time with "N/A". Signed-off-by: Jun Zhao --- libavformat/utils.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index e6158d8..d7fdd72 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2983,11 +2983,24 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset) AVStream av_unused *st; for (i = 0; i < ic->nb_streams; i++) { st = ic->streams[i]; -if (st->time_base.den) +if (st->time_base.den) { +if (st->start_time == AV_NOPTS_VALUE) +av_log(ic, AV_LOG_TRACE, "stream %d: start_time: N/A duration: %0.3f\n", i, + (double) st->duration * av_q2d(st->time_base)); +else av_log(ic, AV_LOG_TRACE, "stream %d: start_time: %0.3f duration: %0.3f\n", i, (double) st->start_time * av_q2d(st->time_base), (double) st->duration * av_q2d(st->time_base)); +} } + +if (ic->start_time == AV_NOPTS_VALUE) +av_log(ic, AV_LOG_TRACE, + "format: start_time: N/A duration: %0.3f (estimate from %s) bitrate=%"PRId64" kb/s\n", + (double) ic->duration / AV_TIME_BASE, + duration_estimate_name(ic->duration_estimation_method), + (int64_t)ic->bit_rate / 1000); +else av_log(ic, AV_LOG_TRACE, "format: start_time: %0.3f duration: %0.3f (estimate from %s) bitrate=%"PRId64" kb/s\n", (double) ic->start_time / AV_TIME_BASE, -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".