[FFmpeg-cvslog] avcodec/avpacket: Don't write into non-writable buffer
ffmpeg | branch: master | Andreas Rheinhardt | Wed Feb 12 13:27:17 2020 +0100| [8f51a89d66aacd9dc5896bac22e62cbd566e7a71] | committer: Andreas Rheinhardt avcodec/avpacket: Don't write into non-writable buffer The data of an AVPacket may be a part of the data of an AVBufferRef; Therefore av_grow_packet() doesn't reallocate if the available space in the actual buffer is sufficient for the enlargement. But given that it also zeroes the padding it also needs to make sure that the buffer is actually writable; this commit implements this. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8f51a89d66aacd9dc5896bac22e62cbd566e7a71 --- libavcodec/avpacket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 55b509108e..ee51c0799c 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -128,7 +128,8 @@ int av_grow_packet(AVPacket *pkt, int grow_by) return AVERROR(ENOMEM); } -if (new_size + data_offset > pkt->buf->size) { +if (new_size + data_offset > pkt->buf->size || +!av_buffer_is_writable(pkt->buf)) { int ret = av_buffer_realloc(&pkt->buf, new_size + data_offset); if (ret < 0) { pkt->data = old_data; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] tools: fix const specifier for AVInputFormat
ffmpeg | branch: master | Josh de Kock | Wed Apr 29 11:45:49 2020 +0100| [d817b57d36795b22dc493ef66e3ed14a583cae49] | committer: Josh de Kock tools: fix const specifier for AVInputFormat Signed-off-by: Josh de Kock > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d817b57d36795b22dc493ef66e3ed14a583cae49 --- tools/probetest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/probetest.c b/tools/probetest.c index cfa309cabd..6f0e002b74 100644 --- a/tools/probetest.c +++ b/tools/probetest.c @@ -66,7 +66,7 @@ static void probe(AVProbeData *pd, int type, int p, int size) static void print_times(void) { int i = 0; -AVInputFormat *fmt = NULL; +const AVInputFormat *fmt = NULL; void *fmt_opaque = NULL; while ((fmt = av_demuxer_iterate(&fmt_opaque))) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/af_crossfeed: make slope configurable
ffmpeg | branch: master | Paul B Mahol | Thu Apr 30 11:58:04 2020 +0200| [35d6001815e1282c5babf71c71f1fd04b59e5440] | committer: Paul B Mahol avfilter/af_crossfeed: make slope configurable > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=35d6001815e1282c5babf71c71f1fd04b59e5440 --- doc/filters.texi | 4 libavfilter/af_crossfeed.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index be224bd5b9..8ff32f49bf 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3267,6 +3267,10 @@ Set soundstage wideness. Default is 0.5. Allowed range is from 0 to 1. This sets cut off frequency of low shelf filter. Default is cut off near 1550 Hz. With range set to 1 cut off frequency is set to 2100 Hz. +@item slope +Set curve slope of low shelf filter. Default is 0.5. +Allowed range is from 0.01 to 1. + @item level_in Set input gain. Default is 0.9. diff --git a/libavfilter/af_crossfeed.c b/libavfilter/af_crossfeed.c index f1bbb357ba..cc2db70e62 100644 --- a/libavfilter/af_crossfeed.c +++ b/libavfilter/af_crossfeed.c @@ -28,6 +28,7 @@ typedef struct CrossfeedContext { double range; double strength; +double slope; double level_in; double level_out; @@ -62,7 +63,7 @@ static int config_input(AVFilterLink *inlink) double w0 = 2 * M_PI * (1. - s->range) * 2100 / inlink->sample_rate; double alpha; -alpha = sin(w0) / 2 * sqrt((A + 1 / A) * (1 / 0.5 - 1) + 2); +alpha = sin(w0) / 2 * sqrt((A + 1 / A) * (1 / s->slope - 1) + 2); s->a0 = (A + 1) + (A - 1) * cos(w0) + 2 * sqrt(A) * alpha; s->a1 =-2 * ((A - 1) + (A + 1) * cos(w0)); @@ -139,6 +140,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) static const AVOption crossfeed_options[] = { { "strength", "set crossfeed strength", OFFSET(strength), AV_OPT_TYPE_DOUBLE, {.dbl=.2}, 0, 1, FLAGS }, { "range", "set soundstage wideness", OFFSET(range), AV_OPT_TYPE_DOUBLE, {.dbl=.5}, 0, 1, FLAGS }, +{ "slope", "set curve slope", OFFSET(slope), AV_OPT_TYPE_DOUBLE, {.dbl=.5}, .01, 1, FLAGS }, { "level_in", "set level in",OFFSET(level_in), AV_OPT_TYPE_DOUBLE, {.dbl=.9}, 0, 1, FLAGS }, { "level_out", "set level out", OFFSET(level_out), AV_OPT_TYPE_DOUBLE, {.dbl=1.}, 0, 1, FLAGS }, { NULL } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/af_crossfeed: fix calculation of alpha parameter
ffmpeg | branch: master | Paul B Mahol | Thu Apr 30 11:44:48 2020 +0200| [0ec61fcff71d212b616660a6e93d856ef1849466] | committer: Paul B Mahol avfilter/af_crossfeed: fix calculation of alpha parameter Use A in calculation. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0ec61fcff71d212b616660a6e93d856ef1849466 --- libavfilter/af_crossfeed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/af_crossfeed.c b/libavfilter/af_crossfeed.c index c819ca59a7..f1bbb357ba 100644 --- a/libavfilter/af_crossfeed.c +++ b/libavfilter/af_crossfeed.c @@ -62,7 +62,7 @@ static int config_input(AVFilterLink *inlink) double w0 = 2 * M_PI * (1. - s->range) * 2100 / inlink->sample_rate; double alpha; -alpha = sin(w0) / 2 * sqrt(2 * (1 / 0.5 - 1) + 2); +alpha = sin(w0) / 2 * sqrt((A + 1 / A) * (1 / 0.5 - 1) + 2); s->a0 = (A + 1) + (A - 1) * cos(w0) + 2 * sqrt(A) * alpha; s->a1 =-2 * ((A - 1) + (A + 1) * cos(w0)); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter: add asubboost filter
ffmpeg | branch: master | Paul B Mahol | Wed Apr 22 15:29:16 2020 +0200| [c7d8082357965bfd02bc3a8ba6867b36119d2895] | committer: Paul B Mahol avfilter: add asubboost filter > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c7d8082357965bfd02bc3a8ba6867b36119d2895 --- Changelog | 1 + doc/filters.texi | 39 libavfilter/Makefile | 1 + libavfilter/af_asubboost.c | 232 + libavfilter/allfilters.c | 1 + libavfilter/version.h | 2 +- 6 files changed, 275 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 83b8a4a46e..9b3e34560f 100644 --- a/Changelog +++ b/Changelog @@ -63,6 +63,7 @@ version : - maskedthreshold filter - Support for muxing pcm and pgs in m2ts - Cunning Developments ADPCM decoder +- asubboost filter version 4.2: diff --git a/doc/filters.texi b/doc/filters.texi index f8dc02f00d..be224bd5b9 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -2454,6 +2454,45 @@ Number of points where the waveform crosses the zero level axis. Rate of Zero crossings and number of audio samples. @end table +@section asubboost +Boost subwoofer frequencies. + +The filter accepts the following options: + +@table @option +@item dry +Set dry gain, how much of original signal is kept. Allowed range is from 0 to 1. +Default value is 0.5. + +@item wet +Set wet gain, how much of filtered signal is kept. Allowed range is from 0 to 1. +Default value is 0.8. + +@item decay +Set delay line decay gain value. Allowed range is from 0 to 1. +Default value is 0.7. + +@item feedback +Set delay line feedback gain value. Allowed range is from 0 to 1. +Default value is 0.5. + +@item cutoff +Set cutoff frequency in herz. Allowed range is 50 to 900. +Default value is 100. + +@item slope +Set slope amount for cutoff frequency. Allowed range is 0.0001 to 1. +Default value is 0.5. + +@item delay +Set delay. Allowed range is from 1 to 100. +Default value is 20. +@end table + +@subsection Commands + +This filter supports the all above options as @ref{commands}. + @section atempo Adjust audio tempo. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index e1205eb063..f982afe15f 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -86,6 +86,7 @@ OBJS-$(CONFIG_ASPLIT_FILTER) += split.o OBJS-$(CONFIG_ASR_FILTER)+= af_asr.o OBJS-$(CONFIG_ASTATS_FILTER) += af_astats.o OBJS-$(CONFIG_ASTREAMSELECT_FILTER) += f_streamselect.o framesync.o +OBJS-$(CONFIG_ASUBBOOST_FILTER) += af_asubboost.o OBJS-$(CONFIG_ATEMPO_FILTER) += af_atempo.o OBJS-$(CONFIG_ATRIM_FILTER) += trim.o OBJS-$(CONFIG_AXCORRELATE_FILTER)+= af_axcorrelate.o diff --git a/libavfilter/af_asubboost.c b/libavfilter/af_asubboost.c new file mode 100644 index 00..f8369fd818 --- /dev/null +++ b/libavfilter/af_asubboost.c @@ -0,0 +1,232 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/channel_layout.h" +#include "libavutil/ffmath.h" +#include "libavutil/opt.h" +#include "avfilter.h" +#include "audio.h" +#include "formats.h" + +typedef struct ASubBoostContext { +const AVClass *class; + +double dry_gain; +double wet_gain; +double feedback; +double decay; +double delay; +double cutoff; +double slope; + +double a0, a1, a2; +double b0, b1, b2; + +int write_pos; +int buffer_samples; + +AVFrame *i, *o; +AVFrame *buffer; +} ASubBoostContext; + +static int query_formats(AVFilterContext *ctx) +{ +AVFilterFormats *formats = NULL; +AVFilterChannelLayouts *layouts = NULL; +static const enum AVSampleFormat sample_fmts[] = { +AV_SAMPLE_FMT_DBLP, +AV_SAMPLE_FMT_NONE +}; +int ret; + +formats = ff_make_format_list(sample_fmts); +if (!formats) +return AVERROR(ENOMEM); +ret = ff_set_common_formats(ctx, formats); +if (ret < 0) +return ret; + +layouts = ff_all_channel_counts(); +if (!layouts) +return AVERROR(ENOMEM); + +ret = ff_set_common_channel_layouts(ctx, layouts); +if (ret < 0) +return ret; + +formats = ff_all_sam
[FFmpeg-cvslog] avfilter/af_crossfeed: make options runtime configurable
ffmpeg | branch: master | Paul B Mahol | Thu Apr 30 12:04:27 2020 +0200| [0a181c2cb1fe4038f900d3e1e7c8106e0326f784] | committer: Paul B Mahol avfilter/af_crossfeed: make options runtime configurable > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0a181c2cb1fe4038f900d3e1e7c8106e0326f784 --- doc/filters.texi | 4 libavfilter/af_crossfeed.c | 15 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index 8ff32f49bf..d19fd346ae 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3278,6 +3278,10 @@ Set input gain. Default is 0.9. Set output gain. Default is 1. @end table +@subsection Commands + +This filter supports the all above options as @ref{commands}. + @section crystalizer Simple algorithm to expand audio dynamic range. diff --git a/libavfilter/af_crossfeed.c b/libavfilter/af_crossfeed.c index cc2db70e62..70dd26eb28 100644 --- a/libavfilter/af_crossfeed.c +++ b/libavfilter/af_crossfeed.c @@ -134,8 +134,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) return ff_filter_frame(outlink, out); } +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, + char *res, int res_len, int flags) +{ +int ret; + +ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags); +if (ret < 0) +return ret; + +return config_input(ctx->inputs[0]); +} + #define OFFSET(x) offsetof(CrossfeedContext, x) -#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM +#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM static const AVOption crossfeed_options[] = { { "strength", "set crossfeed strength", OFFSET(strength), AV_OPT_TYPE_DOUBLE, {.dbl=.2}, 0, 1, FLAGS }, @@ -175,4 +187,5 @@ AVFilter ff_af_crossfeed = { .inputs = inputs, .outputs= outputs, .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL, +.process_command = process_command, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfoundation: Fix building on iOS
ffmpeg | branch: master | Martin Storsjö | Thu Apr 30 13:34:13 2020 +0300| [c810a9502cebe32e1dd08ee3d0d17053dde44aa9] | committer: Thilo Borgmann avfoundation: Fix building on iOS Apparently the changes from 3c9185bf3a83395d12a987f626dbdb985eac4320 aren't enough; even with that in place, I got errors like this when trying to build for iOS: src/libavdevice/avfoundation.m:135:5: error: 'AVCaptureDeviceTransportControlsPlaybackMode' is unavailable: not available on iOS AVCaptureDeviceTransportControlsPlaybackMode observed_mode; ^ > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c810a9502cebe32e1dd08ee3d0d17053dde44aa9 --- libavdevice/avfoundation.m | 4 1 file changed, 4 insertions(+) diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m index 0b1888693f..59d5b0af4f 100644 --- a/libavdevice/avfoundation.m +++ b/libavdevice/avfoundation.m @@ -132,7 +132,9 @@ typedef struct CMSampleBufferRef current_audio_frame; AVCaptureDevice *observed_device; +#if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 AVCaptureDeviceTransportControlsPlaybackMode observed_mode; +#endif int observed_quit; } AVFContext; @@ -200,6 +202,7 @@ static void unlock_frames(AVFContext* ctx) change:(NSDictionary *)change context:(void *)context { if (context == _context) { +#if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 AVCaptureDeviceTransportControlsPlaybackMode mode = [change[NSKeyValueChangeNewKey] integerValue]; @@ -209,6 +212,7 @@ static void unlock_frames(AVFContext* ctx) } _context->observed_mode = mode; } +#endif } else { [super observeValueForKeyPath: keyPath ofObject: object ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/v4l2_context: Log warning when all capture buffers are in userspace
ffmpeg | branch: master | Andriy Gelman | Thu Apr 30 10:58:37 2020 -0400| [2a9d62356152d4ef079416101664f26d2562c681] | committer: Andriy Gelman avcodec/v4l2_context: Log warning when all capture buffers are in userspace v4l2_m2m uses device memory mapped buffers to store dequeued frames/packets (reference counted by AVBufferRef). When the reference count drops to zero, the buffer ownership is returned back to the device, so that they can re-filled with frames/packets. There are some cases when all the capture buffers are in userspace (i.e. due to internal buffering in ffmpeg). On the s5p-mfc this causes an infinite wait when polling to dequeue the buffers, which can be prevented by increasing the total number of buffers. This commit adds a warning when all the capture buffers are dequeued. Reviewed-by: Ming Qian Signed-off-by: Andriy Gelman > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2a9d62356152d4ef079416101664f26d2562c681 --- libavcodec/v4l2_context.c | 12 1 file changed, 12 insertions(+) diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index 6c2db5c849..f70e151ec8 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -291,6 +291,18 @@ static V4L2Buffer* v4l2_dequeue_v4l2buf(V4L2Context *ctx, int timeout) }; int i, ret; +if (!V4L2_TYPE_IS_OUTPUT(ctx->type) && ctx->buffers) { +for (i = 0; i < ctx->num_buffers; i++) { +if (ctx->buffers[i].status == V4L2BUF_IN_DRIVER) +break; +} +if (i == ctx->num_buffers) +av_log(logger(ctx), AV_LOG_WARNING, "All capture buffers returned to " +"userspace. Increase num_capture_buffers " +"to prevent device deadlock or dropped " +"packets/frames.\n"); +} + /* if we are draining and there are no more capture buffers queued in the driver we are done */ if (!V4L2_TYPE_IS_OUTPUT(ctx->type) && ctx_to_m2mctx(ctx)->draining) { for (i = 0; i < ctx->num_buffers; i++) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/cbs_h265: fix writing extension_data bits
ffmpeg | branch: master | James Almer | Mon Apr 20 15:25:58 2020 -0300| [38d1815cc65dd447de80760895ee008cfc9a0091] | committer: James Almer avcodec/cbs_h265: fix writing extension_data bits We only care about the right most bit. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=38d1815cc65dd447de80760895ee008cfc9a0091 --- libavcodec/cbs_h265_syntax_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index 5f5531944c..0696eeeb9e 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -80,7 +80,7 @@ static int FUNC(extension_data)(CodedBitstreamContext *ctx, RWContext *rw, } #else for (k = 0; k < current->bit_length; k++) -xu(1, extension_data, current->data[k / 8] >> (7 - k % 8), 0, 1, 0); +xu(1, extension_data, current->data[k / 8] >> (7 - k % 8) & 1, 0, 1, 0); #endif return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/utils: change the duration to int64_t for update_initial_durations
ffmpeg | branch: master | Limin Wang | Wed Apr 29 07:49:24 2020 +0800| [8afa03a5f682cec9925b302a092d66a0532ae328] | committer: Limin Wang avformat/utils: change the duration to int64_t for update_initial_durations Reviewed-by: Michael Niedermayer Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8afa03a5f682cec9925b302a092d66a0532ae328 --- libavformat/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 3b53f97bee..44109d866d 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1174,7 +1174,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, } static void update_initial_durations(AVFormatContext *s, AVStream *st, - int stream_index, int duration) + int stream_index, int64_t duration) { AVPacketList *pktl = s->internal->packet_buffer ? s->internal->packet_buffer : s->internal->parse_queue; int64_t cur_dts= RELATIVE_TS_BASE; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] oggdec: add support for proper demuxing of chained Opus files and streams
ffmpeg | branch: master | Lynne | Tue Apr 28 12:25:46 2020 +0100| [8296443a70f052a6f5c9a867d28b83a5eb7d304d] | committer: Lynne oggdec: add support for proper demuxing of chained Opus files and streams Part of this patch is based on Paul B Mahol's patch from last year. This also allows for single-stream parameter/codec changes. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8296443a70f052a6f5c9a867d28b83a5eb7d304d --- libavformat/oggdec.c | 45 + libavformat/oggdec.h | 1 + libavformat/oggparseopus.c | 1 + 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 92dcafe2ed..c591bafddd 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -178,6 +178,7 @@ static int ogg_reset(AVFormatContext *s) if (start_pos <= s->internal->data_offset) { os->lastpts = 0; } +os->start_trimming = 0; os->end_trimming = 0; av_freep(&os->new_metadata); os->new_metadata_size = 0; @@ -206,7 +207,8 @@ static const struct ogg_codec *ogg_find_codec(uint8_t *buf, int size) * situation where a new audio stream spawn (identified with a new serial) and * must replace the previous one (track switch). */ -static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic) +static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic, + int probing) { struct ogg *ogg = s->priv_data; struct ogg_stream *os; @@ -220,24 +222,25 @@ static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic) /* Check for codecs */ codec = ogg_find_codec(magic, 8); -if (!codec) { +if (!codec && !probing) { av_log(s, AV_LOG_ERROR, "Cannot identify new stream\n"); return AVERROR_INVALIDDATA; } -/* If the codec matches, then we assume its a replacement */ -for (i = 0; i < ogg->nstreams; i++) { -if (ogg->streams[i].codec == codec) -break; -} - -/* Otherwise, create a new stream */ -if (i >= ogg->nstreams) -return ogg_new_stream(s, serial); - -os = &ogg->streams[i]; -os->serial = serial; -os->codec = codec; +/* We only have a single stream anyway, so if there's a new stream with + * a different codec just replace it */ +os = &ogg->streams[0]; +os->serial = serial; +os->codec = codec; +os->serial = serial; +os->lastpts = 0; +os->lastdts = 0; +os->start_trimming = 0; +os->end_trimming = 0; + +/* Chained files have extradata as a new packet */ +if (codec == &ff_opus_codec) +os->header = -1; return i; } @@ -294,7 +297,7 @@ static int data_packets_seen(const struct ogg *ogg) return 0; } -static int ogg_read_page(AVFormatContext *s, int *sid) +static int ogg_read_page(AVFormatContext *s, int *sid, int probing) { AVIOContext *bc = s->pb; struct ogg *ogg = s->priv_data; @@ -417,7 +420,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid) /* CRC is correct so we can be 99% sure there's an actual change here */ if (idx < 0) { if (data_packets_seen(ogg)) -idx = ogg_replace_stream(s, serial, readout_buf); +idx = ogg_replace_stream(s, serial, readout_buf, probing); else idx = ogg_new_stream(s, serial); @@ -492,7 +495,7 @@ static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize, idx = ogg->curidx; while (idx < 0) { -ret = ogg_read_page(s, &idx); +ret = ogg_read_page(s, &idx, 0); if (ret < 0) return ret; } @@ -643,7 +646,7 @@ static int ogg_get_length(AVFormatContext *s) avio_seek(s->pb, end, SEEK_SET); ogg->page_pos = -1; -while (!ogg_read_page(s, &i)) { +while (!ogg_read_page(s, &i, 1)) { if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 && ogg->streams[i].codec) { s->streams[i]->duration = @@ -847,13 +850,15 @@ retry: pkt->duration = os->pduration; pkt->pos = fpos; -if (os->end_trimming) { +if (os->start_trimming || os->end_trimming) { uint8_t *side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10); if(!side_data) return AVERROR(ENOMEM); + AV_WL32(side_data + 0, os->start_trimming); AV_WL32(side_data + 4, os->end_trimming); +os->start_trimming = 0; os->end_trimming = 0; } diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h index 4a2b6ddee8..e2057c46f6 100644 --- a/libavformat/oggdec.h +++ b/libavformat/oggdec.h @@ -84,6 +84,7 @@ struct ogg_stream { int got_start; int got_data; ///< 1 if the stream got some
[FFmpeg-cvslog] oggdec: use ffio_ensure_seekback() to seek back on incorrect data
ffmpeg | branch: master | Lynne | Tue Apr 28 12:55:17 2020 +0100| [e983197cbc93420b67aa7e811be47d7278c2c8a2] | committer: Lynne oggdec: use ffio_ensure_seekback() to seek back on incorrect data This cleans up the code and simplifies it. It also speeds up parsing since the old pb position was incorrect. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e983197cbc93420b67aa7e811be47d7278c2c8a2 --- libavformat/oggdec.c | 68 +--- 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index e0188c7c59..92dcafe2ed 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -206,59 +206,40 @@ static const struct ogg_codec *ogg_find_codec(uint8_t *buf, int size) * situation where a new audio stream spawn (identified with a new serial) and * must replace the previous one (track switch). */ -static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, int size) +static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic) { struct ogg *ogg = s->priv_data; struct ogg_stream *os; const struct ogg_codec *codec; int i = 0; -if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { -uint8_t magic[8]; -avio_seek(s->pb, -size, SEEK_CUR); -if (avio_read(s->pb, magic, sizeof(magic)) != sizeof(magic)) -return AVERROR_INVALIDDATA; -avio_seek(s->pb, size - sizeof(magic), SEEK_CUR); -codec = ogg_find_codec(magic, sizeof(magic)); -if (!codec) { -av_log(s, AV_LOG_ERROR, "Cannot identify new stream\n"); -return AVERROR_INVALIDDATA; -} -for (i = 0; i < ogg->nstreams; i++) { -if (ogg->streams[i].codec == codec) -break; -} -if (i >= ogg->nstreams) -return ogg_new_stream(s, serial); -} else if (ogg->nstreams != 1) { +if (ogg->nstreams != 1) { avpriv_report_missing_feature(s, "Changing stream parameters in multistream ogg"); return AVERROR_PATCHWELCOME; } -os = &ogg->streams[i]; - -os->serial = serial; -return i; +/* Check for codecs */ +codec = ogg_find_codec(magic, 8); +if (!codec) { +av_log(s, AV_LOG_ERROR, "Cannot identify new stream\n"); +return AVERROR_INVALIDDATA; +} -#if 0 -buf = os->buf; -bufsize = os->bufsize; -codec = os->codec; +/* If the codec matches, then we assume its a replacement */ +for (i = 0; i < ogg->nstreams; i++) { +if (ogg->streams[i].codec == codec) +break; +} -if (!ogg->state || ogg->state->streams[i].private != os->private) -av_freep(&ogg->streams[i].private); +/* Otherwise, create a new stream */ +if (i >= ogg->nstreams) +return ogg_new_stream(s, serial); -/* Set Ogg stream settings similar to what is done in ogg_new_stream(). We - * also re-use the ogg_stream allocated buffer */ -memset(os, 0, sizeof(*os)); -os->serial = serial; -os->bufsize = bufsize; -os->buf = buf; -os->header = -1; -os->codec = codec; +os = &ogg->streams[i]; +os->serial = serial; +os->codec = codec; return i; -#endif } static int ogg_new_stream(AVFormatContext *s, uint32_t serial) @@ -325,6 +306,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid) uint32_t crc, crc_tmp; int size = 0, idx; int64_t version, page_pos; +int64_t start_pos; uint8_t sync[4]; uint8_t segments[255]; uint8_t *readout_buf; @@ -364,6 +346,10 @@ static int ogg_read_page(AVFormatContext *s, int *sid) /* 0x4fa9b05f = av_crc(AV_CRC_32_IEEE, 0x0, "OggS", 4) */ ffio_init_checksum(bc, ff_crc04C11DB7_update, 0x4fa9b05f); +/* To rewind if checksum is bad/check magic on switches - this is the max packet size */ +ffio_ensure_seekback(bc, MAX_PAGE_SIZE); +start_pos = avio_tell(bc); + version = avio_r8(bc); flags = avio_r8(bc); gp = avio_rl64(bc); @@ -414,7 +400,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid) av_log(s, AV_LOG_ERROR, "CRC mismatch!\n"); if (idx < 0) av_free(readout_buf); -avio_seek(bc, -size, SEEK_CUR); +avio_seek(bc, start_pos, SEEK_SET); return 0; } @@ -424,14 +410,14 @@ static int ogg_read_page(AVFormatContext *s, int *sid) av_log(s, AV_LOG_ERROR, "Invalid Ogg vers!\n"); if (idx < 0) av_free(readout_buf); -avio_seek(bc, -size, SEEK_CUR); +avio_seek(bc, start_pos, SEEK_SET); return 0; } /* CRC is correct so we can be 99% sure there's an actual change here */ if (idx < 0) { if (data_packets_seen(ogg)) -idx = ogg_replace_stream(s, serial, size); +idx = ogg_replace_stream(s, serial, readout_buf); else idx = ogg_new_stream(s, serial);
[FFmpeg-cvslog] oggdec: eliminate copies and extra buffers
ffmpeg | branch: master | Lynne | Tue Apr 28 12:41:34 2020 +0100| [f619e1ec66b89215582eff4404b681b760540b4f] | committer: Lynne oggdec: eliminate copies and extra buffers This also makes implementing CRC checking far simpler and more robust. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f619e1ec66b89215582eff4404b681b760540b4f --- libavformat/oggdec.c | 127 +++ 1 file changed, 58 insertions(+), 69 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 95190589ab..7db26840b2 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -205,7 +205,7 @@ static const struct ogg_codec *ogg_find_codec(uint8_t *buf, int size) * situation where a new audio stream spawn (identified with a new serial) and * must replace the previous one (track switch). */ -static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, int nsegs) +static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, int size) { struct ogg *ogg = s->priv_data; struct ogg_stream *os; @@ -214,11 +214,10 @@ static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, int nsegs) if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { uint8_t magic[8]; -int64_t pos = avio_tell(s->pb); -avio_skip(s->pb, nsegs); +avio_seek(s->pb, -size, SEEK_CUR); if (avio_read(s->pb, magic, sizeof(magic)) != sizeof(magic)) return AVERROR_INVALIDDATA; -avio_seek(s->pb, pos, SEEK_SET); +avio_seek(s->pb, size - sizeof(magic), SEEK_CUR); codec = ogg_find_codec(magic, sizeof(magic)); if (!codec) { av_log(s, AV_LOG_ERROR, "Cannot identify new stream\n"); @@ -303,27 +302,6 @@ static int ogg_new_stream(AVFormatContext *s, uint32_t serial) return idx; } -static int ogg_new_buf(struct ogg *ogg, int idx) -{ -struct ogg_stream *os = ogg->streams + idx; -uint8_t *nb = av_malloc(os->bufsize + AV_INPUT_BUFFER_PADDING_SIZE); -int size = os->bufpos - os->pstart; - -if (!nb) -return AVERROR(ENOMEM); - -if (os->buf) { -memcpy(nb, os->buf + os->pstart, size); -av_free(os->buf); -} - -os->buf= nb; -os->bufpos = size; -os->pstart = 0; - -return 0; -} - static int data_packets_seen(const struct ogg *ogg) { int i; @@ -343,8 +321,11 @@ static int ogg_read_page(AVFormatContext *s, int *sid) int flags, nsegs; uint64_t gp; uint32_t serial; -int size, idx; +int size = 0, idx; +int64_t page_pos; uint8_t sync[4]; +uint8_t segments[255]; +uint8_t *readout_buf; int sp = 0; ret = avio_read(bc, sync, 4); @@ -387,47 +368,73 @@ static int ogg_read_page(AVFormatContext *s, int *sid) gp = avio_rl64(bc); serial = avio_rl32(bc); avio_skip(bc, 8); /* seq, crc */ -nsegs = avio_r8(bc); + +nsegs= avio_r8(bc); +page_pos = avio_tell(bc) - 27; + +ret = avio_read(bc, segments, nsegs); +if (ret < nsegs) +return ret < 0 ? ret : AVERROR_EOF; if (avio_feof(bc)) return AVERROR_EOF; +for (i = 0; i < nsegs; i++) +size += segments[i]; + idx = ogg_find_stream(ogg, serial); +if (idx >= 0) { +os = ogg->streams + idx; + +/* Even if invalid guarantee there's enough memory to read the page */ +if (os->bufsize - os->bufpos < size) { +uint8_t *nb = av_realloc(os->buf, 2*os->bufsize + AV_INPUT_BUFFER_PADDING_SIZE); +if (!nb) +return AVERROR(ENOMEM); +os->buf = nb; +os->bufsize *= 2; +} + +readout_buf = os->buf + os->bufpos; +} else { +readout_buf = av_malloc(size); +} + +ret = avio_read(bc, readout_buf, size); +if (ret < size) { +if (idx < 0) +av_free(readout_buf); +return ret < 0 ? ret : AVERROR_EOF; +} + if (idx < 0) { if (data_packets_seen(ogg)) -idx = ogg_replace_stream(s, serial, nsegs); +idx = ogg_replace_stream(s, serial, size); else idx = ogg_new_stream(s, serial); if (idx < 0) { av_log(s, AV_LOG_ERROR, "failed to create or replace stream\n"); +av_free(readout_buf); return idx; } -} -os = ogg->streams + idx; -ogg->page_pos = -os->page_pos = avio_tell(bc) - 27; +os = ogg->streams + idx; -if (os->psize > 0) { -ret = ogg_new_buf(ogg, idx); -if (ret < 0) -return ret; +memcpy(os->buf + os->bufpos, readout_buf, size); +av_free(readout_buf); } -ret = avio_read(bc, os->segments, nsegs); -if (ret < nsegs) -return ret < 0 ? ret : AVERROR_EOF; - -os->nsegs = nsegs; -os->segp = 0; - -size = 0; -for (i = 0; i < nsegs; i++) -size += os->segments[i]; - -if (!(flags & OGG_FLAG_BOS)) -
[FFmpeg-cvslog] oggdec: verify page checksum
ffmpeg | branch: master | Lynne | Tue Apr 28 12:52:11 2020 +0100| [9ad47762c17d2c6d06595aa17b88112baa91b72c] | committer: Lynne oggdec: verify page checksum This makes decoding far more robust, since OggS, the ogg magic, can be commonly found randomly in streams, which previously made the demuxer think there's a new stream or a change in such. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9ad47762c17d2c6d06595aa17b88112baa91b72c --- libavformat/oggdec.c | 46 ++ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 7db26840b2..e0188c7c59 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -31,6 +31,7 @@ #include #include "libavutil/avassert.h" #include "libavutil/intreadwrite.h" +#include "avio_internal.h" #include "oggdec.h" #include "avformat.h" #include "internal.h" @@ -321,8 +322,9 @@ static int ogg_read_page(AVFormatContext *s, int *sid) int flags, nsegs; uint64_t gp; uint32_t serial; +uint32_t crc, crc_tmp; int size = 0, idx; -int64_t page_pos; +int64_t version, page_pos; uint8_t sync[4]; uint8_t segments[255]; uint8_t *readout_buf; @@ -359,15 +361,19 @@ static int ogg_read_page(AVFormatContext *s, int *sid) return AVERROR_INVALIDDATA; } -if (avio_r8(bc) != 0) { /* version */ -av_log (s, AV_LOG_ERROR, "ogg page, unsupported version\n"); -return AVERROR_INVALIDDATA; -} +/* 0x4fa9b05f = av_crc(AV_CRC_32_IEEE, 0x0, "OggS", 4) */ +ffio_init_checksum(bc, ff_crc04C11DB7_update, 0x4fa9b05f); -flags = avio_r8(bc); -gp = avio_rl64(bc); -serial = avio_rl32(bc); -avio_skip(bc, 8); /* seq, crc */ +version = avio_r8(bc); +flags = avio_r8(bc); +gp = avio_rl64(bc); +serial = avio_rl32(bc); +avio_skip(bc, 4); /* seq */ + +crc_tmp = ffio_get_checksum(bc); +crc = avio_rb32(bc); +crc_tmp = ff_crc04C11DB7_update(crc_tmp, (uint8_t[4]){0}, 4); +ffio_init_checksum(bc, ff_crc04C11DB7_update, crc_tmp); nsegs= avio_r8(bc); page_pos = avio_tell(bc) - 27; @@ -376,9 +382,6 @@ static int ogg_read_page(AVFormatContext *s, int *sid) if (ret < nsegs) return ret < 0 ? ret : AVERROR_EOF; -if (avio_feof(bc)) -return AVERROR_EOF; - for (i = 0; i < nsegs; i++) size += segments[i]; @@ -407,6 +410,25 @@ static int ogg_read_page(AVFormatContext *s, int *sid) return ret < 0 ? ret : AVERROR_EOF; } +if (crc ^ ffio_get_checksum(bc)) { +av_log(s, AV_LOG_ERROR, "CRC mismatch!\n"); +if (idx < 0) +av_free(readout_buf); +avio_seek(bc, -size, SEEK_CUR); +return 0; +} + +/* Since we're almost sure its a valid packet, checking the version after + * the checksum lets the demuxer be more tolerant */ +if (version) { +av_log(s, AV_LOG_ERROR, "Invalid Ogg vers!\n"); +if (idx < 0) +av_free(readout_buf); +avio_seek(bc, -size, SEEK_CUR); +return 0; +} + +/* CRC is correct so we can be 99% sure there's an actual change here */ if (idx < 0) { if (data_packets_seen(ogg)) idx = ogg_replace_stream(s, serial, size); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/vf_mix: Check sscanf() return value
ffmpeg | branch: master | Limin Wang | Sun Mar 29 09:08:13 2020 +0800| [ee5d6d2ef88a3a7fd480435cf931dd6165bbb688] | committer: Limin Wang avfilter/vf_mix: Check sscanf() return value Reviewed-by: Nicolas George Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ee5d6d2ef88a3a7fd480435cf931dd6165bbb688 --- libavfilter/vf_mix.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_mix.c b/libavfilter/vf_mix.c index f418c6fba8..bdb67d8e5a 100644 --- a/libavfilter/vf_mix.c +++ b/libavfilter/vf_mix.c @@ -108,7 +108,10 @@ static av_cold int init(AVFilterContext *ctx) break; p = NULL; -av_sscanf(arg, "%f", &s->weights[i]); +if (av_sscanf(arg, "%f", &s->weights[i]) != 1) { +av_log(ctx, AV_LOG_ERROR, "Invalid syntax for weights[%d].\n", i); +return AVERROR(EINVAL); +} s->wfactor += s->weights[i]; last = i; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/af_adelay: Check sscanf() return value
ffmpeg | branch: master | Limin Wang | Sun Mar 29 08:08:05 2020 +0800| [f441fadbcffa32b71470220b522d4971a774e760] | committer: Limin Wang avfilter/af_adelay: Check sscanf() return value Reviewed-by: Michael Niedermayer Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f441fadbcffa32b71470220b522d4971a774e760 --- libavfilter/af_adelay.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c index c9647771f2..6ac81c2a3e 100644 --- a/libavfilter/af_adelay.c +++ b/libavfilter/af_adelay.c @@ -155,7 +155,10 @@ static int config_input(AVFilterLink *inlink) ret = av_sscanf(arg, "%d%c", &d->delay, &type); if (ret != 2 || type != 'S') { div = type == 's' ? 1.0 : 1000.0; -av_sscanf(arg, "%f", &delay); +if (av_sscanf(arg, "%f", &delay) != 1) { +av_log(ctx, AV_LOG_ERROR, "Invalid syntax for delay.\n"); +return AVERROR(EINVAL); +} d->delay = delay * inlink->sample_rate / div; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fate/oggopus-demux: fix fate failure
ffmpeg | branch: master | Lynne | Fri May 1 01:36:43 2020 +0100| [4fd0559b77cfdd38d37a94a45cc830d90454194e] | committer: Lynne fate/oggopus-demux: fix fate failure Failure was due to the extra comment printed by libavcodec/utils.c since side data is used to signal the skipped samples. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4fd0559b77cfdd38d37a94a45cc830d90454194e --- tests/ref/fate/oggopus-demux | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ref/fate/oggopus-demux b/tests/ref/fate/oggopus-demux index 9192760700..580758c0dc 100644 --- a/tests/ref/fate/oggopus-demux +++ b/tests/ref/fate/oggopus-demux @@ -5,7 +5,7 @@ #sample_rate 0: 48000 #channel_layout 0: 3 #channel_layout_name 0: stereo -0, -356, -356, 960, 402, 0x89b1c40f +0, -356, -356, 960, 402, 0x89b1c40f, S=1, 10, 0x03f10065 0,604,604, 960, 216, 0x7bf97146 0, 1564, 1564, 960, 215, 0x6cb86d8b 0, 2524, 2524, 960, 218, 0x9cfd691c ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/mpegts: fix av_freep for dovi pointer
ffmpeg | branch: master | Limin Wang | Thu Apr 30 21:20:28 2020 +0800| [9dd2587f60015a211f3120233e44e829ffd66c6f] | committer: Jun Zhao avformat/mpegts: fix av_freep for dovi pointer Reviewed-by: Andreas Rheinhardt Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9dd2587f60015a211f3120233e44e829ffd66c6f --- libavformat/mpegts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index ff3898c3a5..0833d62ea5 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2180,7 +2180,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF, (uint8_t *)dovi, dovi_size); if (ret < 0) { -av_freep(dovi); +av_free(dovi); return ret; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/mov: fix av_freep for dovi pointer
ffmpeg | branch: master | Limin Wang | Thu Apr 30 21:19:11 2020 +0800| [1112823962ab2e881359e5d60d706ba322ea8551] | committer: Jun Zhao avformat/mov: fix av_freep for dovi pointer Reviewed-by: Andreas Rheinhardt Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1112823962ab2e881359e5d60d706ba322ea8551 --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 3d6fef685d..ad718cdaa2 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6827,7 +6827,7 @@ static int mov_read_dvcc_dvvc(MOVContext *c, AVIOContext *pb, MOVAtom atom) ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF, (uint8_t *)dovi, dovi_size); if (ret < 0) { -av_freep(dovi); +av_free(dovi); return ret; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskadec: Reject sipr flavor > 3
ffmpeg | branch: master | Andreas Rheinhardt | Mon Dec 2 10:41:12 2019 +0100| [8287c201536e52f2765cfa9a70551814a6f36ebb] | committer: Andreas Rheinhardt avformat/matroskadec: Reject sipr flavor > 3 Only flavors 0..3 seem to exist. E.g. rmdec.c treats any flavor > 3 as invalid data. Furthermore, we do not know how big the packets to create ought to be given that for sipr these values are not read from the bitstream, but from a table. Furthermore, flavor is only used for sipr, so only check it for sipr; rmdec.c does the same. (The old check for flavor being < 0 was always wrong given that flavor is an int that is read via avio_rb16(), so it has been removed completely.) Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8287c201536e52f2765cfa9a70551814a6f36ebb --- libavformat/matroskadec.c | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 8e1326abf6..8c65e98e77 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2606,28 +2606,30 @@ static int matroska_parse_tracks(AVFormatContext *s) track->audio.sub_packet_h= avio_rb16(&b); track->audio.frame_size = avio_rb16(&b); track->audio.sub_packet_size = avio_rb16(&b); -if (flavor< 0 || -track->audio.coded_framesize <= 0 || +if (track->audio.coded_framesize <= 0 || track->audio.sub_packet_h<= 0 || track->audio.frame_size <= 0 || track->audio.sub_packet_size <= 0 && codec_id != AV_CODEC_ID_SIPR) return AVERROR_INVALIDDATA; -track->audio.buf = av_malloc_array(track->audio.sub_packet_h, - track->audio.frame_size); -if (!track->audio.buf) -return AVERROR(ENOMEM); + if (codec_id == AV_CODEC_ID_RA_288) { st->codecpar->block_align = track->audio.coded_framesize; track->codec_priv.size = 0; } else { -if (codec_id == AV_CODEC_ID_SIPR && flavor < 4) { +if (codec_id == AV_CODEC_ID_SIPR) { static const int sipr_bit_rate[4] = { 6504, 8496, 5000, 16000 }; +if (flavor > 3) +return AVERROR_INVALIDDATA; track->audio.sub_packet_size = ff_sipr_subpk_size[flavor]; st->codecpar->bit_rate = sipr_bit_rate[flavor]; } st->codecpar->block_align = track->audio.sub_packet_size; extradata_offset = 78; } +track->audio.buf = av_malloc_array(track->audio.sub_packet_h, + track->audio.frame_size); +if (!track->audio.buf) +return AVERROR(ENOMEM); } else if (codec_id == AV_CODEC_ID_FLAC && track->codec_priv.size) { ret = matroska_parse_flac(s, track, &extradata_offset); if (ret < 0) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskadec: Simplify check for RealAudio
ffmpeg | branch: master | Andreas Rheinhardt | Mon Dec 2 11:04:55 2019 +0100| [c6f60b90f00da7d942a7dbeb513ed284953f6f20] | committer: Andreas Rheinhardt avformat/matroskadec: Simplify check for RealAudio They need a special parsing mode and in order to find out whether this mode is in use, several checks have to be performed. They can all be combined into one: If the buffer that is only used to assemble their packets has been allocated, use the RealAudio parsing mode. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c6f60b90f00da7d942a7dbeb513ed284953f6f20 --- libavformat/matroskadec.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 8c65e98e77..668323ba08 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3617,11 +3617,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf for (n = 0; n < laces; n++) { int64_t lace_duration = block_duration*(n+1) / laces - block_duration*n / laces; -if ((st->codecpar->codec_id == AV_CODEC_ID_RA_288 || - st->codecpar->codec_id == AV_CODEC_ID_COOK || - st->codecpar->codec_id == AV_CODEC_ID_SIPR || - st->codecpar->codec_id == AV_CODEC_ID_ATRAC3) && -st->codecpar->block_align && track->audio.sub_packet_size) { +if (track->audio.buf) { res = matroska_parse_rm_audio(matroska, track, st, data, lace_size[n], timecode, pos); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskadec: Fix demuxing RealAudio 28.8
ffmpeg | branch: master | Andreas Rheinhardt | Mon Apr 20 07:47:06 2020 +0200| [c91e3690d9c6667123b116c9fd3becf5f4f4530e] | committer: Andreas Rheinhardt avformat/matroskadec: Fix demuxing RealAudio 28.8 RealAudio 28.8 does not need or use sub_packet_size for its demuxing and this field is therefore commonly set to zero. But since 18ca491b the Real Audio specific demuxing is no longer applied if sub_packet_size is zero because the codepath for cook and ATRAC3 divide by it; this made these files undecodable. Furthermore, since 569d18aa (merged in 2c8d876d) sub_packet_size being zero is used as an indicator for invalid data, so that a file containing such a track was completely skipped. This commit fixes this by not checking sub_packet_size for RealAudio 28.8 at all. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c91e3690d9c6667123b116c9fd3becf5f4f4530e --- libavformat/matroskadec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 668323ba08..844f96cd52 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2608,8 +2608,7 @@ static int matroska_parse_tracks(AVFormatContext *s) track->audio.sub_packet_size = avio_rb16(&b); if (track->audio.coded_framesize <= 0 || track->audio.sub_packet_h<= 0 || -track->audio.frame_size <= 0 || -track->audio.sub_packet_size <= 0 && codec_id != AV_CODEC_ID_SIPR) +track->audio.frame_size <= 0) return AVERROR_INVALIDDATA; if (codec_id == AV_CODEC_ID_RA_288) { @@ -2622,7 +2621,8 @@ static int matroska_parse_tracks(AVFormatContext *s) return AVERROR_INVALIDDATA; track->audio.sub_packet_size = ff_sipr_subpk_size[flavor]; st->codecpar->bit_rate = sipr_bit_rate[flavor]; -} +} else if (track->audio.sub_packet_size <= 0) +return AVERROR_INVALIDDATA; st->codecpar->block_align = track->audio.sub_packet_size; extradata_offset = 78; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskadec: Fix buffer overflow when demuxing RealAudio 28.8
ffmpeg | branch: master | Andreas Rheinhardt | Wed Apr 22 00:15:54 2020 +0200| [4f5c6c1b0ec2407dfd42fcfa3441067de1962a54] | committer: Andreas Rheinhardt avformat/matroskadec: Fix buffer overflow when demuxing RealAudio 28.8 RealAudio 28.8 (like other RealAudio codecs) uses a special demuxing mode in which the data of the existing Matroska Blocks is not simply forwarded as-is. Instead data from several Blocks is recombined together to output several packets. The parameters governing this process are parsed from the CodecPrivate: Coded framesize (cfs), frame size (w) and sub_packet_h (h). During demuxing, h/2 pieces of data of size cfs each are read from every Matroska (Simple)Block and put at offset m * 2 * w + n * cfs of a buffer of size h * w, where m ranges from 0 to h/2 - 1 for each Block while n is initially zero and incremented after a Block has been parsed until it is h, at which poin the assembled packets are output and n reset. The highest offset is given by (h/2 - 1) * 2 * w + (h - 1) * cfs + cfs while the destination buffer's size is given by h * w. For even h, this leads to a buffer overflow (and potential segfault) if h * cfs > 2 * w; for odd h, the condition is h * cfs > 3 * w. This commit adds a check to rule this out. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4f5c6c1b0ec2407dfd42fcfa3441067de1962a54 --- libavformat/matroskadec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 844f96cd52..951695b5b5 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2612,6 +2612,9 @@ static int matroska_parse_tracks(AVFormatContext *s) return AVERROR_INVALIDDATA; if (codec_id == AV_CODEC_ID_RA_288) { +if ((int64_t)track->audio.sub_packet_h * track->audio.coded_framesize +> (2 + (track->audio.sub_packet_h & 1)) * track->audio.frame_size) +return AVERROR_INVALIDDATA; st->codecpar->block_align = track->audio.coded_framesize; track->codec_priv.size = 0; } else { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskadec: Don't output uninitialized data for RealAudio 28.8
ffmpeg | branch: master | Andreas Rheinhardt | Wed Apr 22 15:17:41 2020 +0200| [bdaa98dd4aac08b8f23f959cbb5a80db2dacd14a] | committer: Andreas Rheinhardt avformat/matroskadec: Don't output uninitialized data for RealAudio 28.8 The Matroska demuxer splits every sequence of h Matroska Blocks into h * w / cfs packets of size cfs; here h (sub_packet_h), w (frame_size) and cfs (coded_framesize) are parameters from the track's CodecPrivate. It does this by splitting the Block's data in h/2 pieces of size cfs each and putting them into a buffer at offset m * 2 * w + n * cfs where m (range 0..(h/2 - 1)) indicates the index of the current piece in the current Block and n (range 0..(h - 1)) is the index of the current Block in the current sequence of Blocks. The data in this buffer is then used for the output packets. The problem is that there is currently no check to actually guarantee that no uninitialized data will be output. One instance where this is trivially so is if h == 1; another is if cfs * h is so small that the input pieces do not cover everything that is output. In order to preclude this, rmdec.c checks for h * cfs == 2 * w and h >= 2. The former requirement certainly makes much sense, as it means that for every given m the input pieces (corresponding to the h different values of n) form a nonoverlapping partition of the two adjacent frames of size w corresponding to m. But precluding h == 1 is not enough, other odd values can cause problems, too. That is because the assumption behind the code is that h frames of size w contain data to be output, although the real number is h/2 * 2. E.g. for h = 3, cfs = 2 and w = 3 the current code would output four (== h * w / cfs) packets. although only data for three (== h/2 * h) packets has been read. (Notice that if h * cfs == 2 * w, h being even is equivalent to cfs dividing w; the latter condition also seems very reasonable: It means that the subframes are a partition of the frames.) Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bdaa98dd4aac08b8f23f959cbb5a80db2dacd14a --- libavformat/matroskadec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 951695b5b5..1dc0b77962 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2612,8 +2612,8 @@ static int matroska_parse_tracks(AVFormatContext *s) return AVERROR_INVALIDDATA; if (codec_id == AV_CODEC_ID_RA_288) { -if ((int64_t)track->audio.sub_packet_h * track->audio.coded_framesize -> (2 + (track->audio.sub_packet_h & 1)) * track->audio.frame_size) +if (track->audio.sub_packet_h & 1 || 2 * track->audio.frame_size +!= (int64_t)track->audio.sub_packet_h * track->audio.coded_framesize) return AVERROR_INVALIDDATA; st->codecpar->block_align = track->audio.coded_framesize; track->codec_priv.size = 0; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskadec: Simplify checks for cook and ATRAC3
ffmpeg | branch: master | Andreas Rheinhardt | Mon Apr 20 08:54:23 2020 +0200| [4b1c19a054432b4a5bc3e90b8c186dc25a416ebd] | committer: Andreas Rheinhardt avformat/matroskadec: Simplify checks for cook and ATRAC3 Some conditions which don't change and which can therefore be checked in read_header() were instead rechecked upon parsing each block. This has been changed. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4b1c19a054432b4a5bc3e90b8c186dc25a416ebd --- libavformat/matroskadec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 1dc0b77962..5643e15a20 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2624,7 +2624,8 @@ static int matroska_parse_tracks(AVFormatContext *s) return AVERROR_INVALIDDATA; track->audio.sub_packet_size = ff_sipr_subpk_size[flavor]; st->codecpar->bit_rate = sipr_bit_rate[flavor]; -} else if (track->audio.sub_packet_size <= 0) +} else if (track->audio.sub_packet_size <= 0 || + track->audio.frame_size % track->audio.sub_packet_size) return AVERROR_INVALIDDATA; st->codecpar->block_align = track->audio.sub_packet_size; extradata_offset = 78; @@ -3138,7 +3139,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska, } memcpy(track->audio.buf + y * w, data, w); } else { -if (size < sps * w / sps || h<=0 || w%sps) { +if (size < w) { av_log(matroska->ctx, AV_LOG_ERROR, "Corrupt generic RM-style audio packet size\n"); return AVERROR_INVALIDDATA; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskadec: Don't discard valid packets
ffmpeg | branch: master | Andreas Rheinhardt | Wed Mar 25 06:00:53 2020 +0100| [e471faf96230076f67e393df9d1a90a08c22a055] | committer: Andreas Rheinhardt avformat/matroskadec: Don't discard valid packets A Block (meaning both a Block in a BlockGroup as well as a SimpleBlock) must have at least three bytes after the field containing the encoded TrackNumber. So if there are <= 3 bytes, the Matroska demuxer would skip this block, believing it to be an empty, but valid Block. This might discard valid nonempty Blocks, namely if the track uses header stripping. And certain definitely spec-incompliant Blocks don't raise errors: Those with two or less bytes left after the encoded TrackNumber and those with three bytes left, but with flags indicating that the Block uses lacing as then there has to be further data describing the lacing. Furthermore, zero-sized packets were still possible because only the size of the last entry of a lace was checked. This commit fixes this. All spec-compliant Blocks that contain data (even if side data only) are now returned to the caller; spec-compliant Blocks that don't contain anything are not returned. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e471faf96230076f67e393df9d1a90a08c22a055 --- libavformat/matroskadec.c | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 5643e15a20..3b1b447d8a 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3020,7 +3020,9 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, return 0; } -av_assert0(size > 0); +if (size <= 0) +return AVERROR_INVALIDDATA; + *laces= *data + 1; data += 1; size -= 1; @@ -3046,7 +3048,7 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, break; } } -if (size <= total) { +if (size < total) { return AVERROR_INVALIDDATA; } @@ -3093,7 +3095,7 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, } data += offset; size -= offset; -if (size <= total) { +if (size < total) { return AVERROR_INVALIDDATA; } lace_size[*laces - 1] = size - total; @@ -3413,7 +3415,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, { MatroskaTrackEncoding *encodings = track->encodings.elem; uint8_t *pkt_data = data; -int res; +int res = 0; AVPacket pktl, *pkt = &pktl; if (encodings && !encodings->type && encodings->scope & 1) { @@ -3449,6 +3451,9 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, pkt_data = pr_data; } +if (!pkt_size && !additional_size) +goto no_output; + av_init_packet(pkt); if (pkt_data != data) pkt->buf = av_buffer_create(pkt_data, pkt_size + AV_INPUT_BUFFER_PADDING_SIZE, @@ -3519,6 +3524,7 @@ FF_ENABLE_DEPRECATION_WARNINGS return 0; +no_output: fail: if (pkt_data != data) av_freep(&pkt_data); @@ -3554,8 +3560,8 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf av_log(matroska->ctx, AV_LOG_INFO, "Invalid stream %"PRIu64"\n", num); return AVERROR_INVALIDDATA; -} else if (size <= 3) -return 0; +} else if (size < 3) +return AVERROR_INVALIDDATA; st = track->stream; if (st->discard >= AVDISCARD_ALL) return res; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskadec: Improve forward compability
ffmpeg | branch: master | Andreas Rheinhardt | Wed Mar 25 06:52:09 2020 +0100| [b577968cabae4a0927adcf5d7c24fca5a7a8385d] | committer: Andreas Rheinhardt avformat/matroskadec: Improve forward compability Matroska is built around the principle that a reader does not need to understand everything in a file in order to be able to make use of it; it just needs to ignore the data it doesn't know about. Our demuxer typically follows this principle, but there is one important instance where it does not: A Block belonging to a TrackEntry with no associated stream is treated as invalid data (i.e. the demuxer will try to resync to the next level 1 element because it takes this as a sign that it has lost sync). Given that we do not create streams if we don't know or don't support the type of the TrackEntry, this impairs this demuxer's forward compability. Furthermore, ignoring Blocks belonging to a TrackEntry without corresponding stream can (in future commits) also be used to ignore TrackEntries with obviously bogus entries without affecting the other TrackEntries (by not creating a stream for said TrackEntry). Finally, given that matroska_find_track_by_num() already emits its own error message in case there is no TrackEntry with a given TrackNumber, the error message (with level AV_LOG_INFO) for this can be removed. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b577968cabae4a0927adcf5d7c24fca5a7a8385d --- libavformat/matroskadec.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 3b1b447d8a..088eeabf2d 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3556,13 +3556,16 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf size -= n; track = matroska_find_track_by_num(matroska, num); -if (!track || !track->stream) { -av_log(matroska->ctx, AV_LOG_INFO, - "Invalid stream %"PRIu64"\n", num); +if (!track || size < 3) return AVERROR_INVALIDDATA; -} else if (size < 3) -return AVERROR_INVALIDDATA; -st = track->stream; + +if (!(st = track->stream)) { +av_log(matroska->ctx, AV_LOG_VERBOSE, + "No stream associated to TrackNumber %"PRIu64". " + "Ignoring Block with this TrackNumber.\n", num); +return 0; +} + if (st->discard >= AVDISCARD_ALL) return res; av_assert1(block_duration != AV_NOPTS_VALUE); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskadec: Cache whether a track needs to be decoded
ffmpeg | branch: master | Andreas Rheinhardt | Wed Dec 4 17:54:45 2019 +0100| [96012d17a9f5003f2695e137c4876485e2fdb03a] | committer: Andreas Rheinhardt avformat/matroskadec: Cache whether a track needs to be decoded There is no need to recheck this for every frame. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=96012d17a9f5003f2695e137c4876485e2fdb03a --- libavformat/matroskadec.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 088eeabf2d..9e3e98e9c0 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -249,6 +249,7 @@ typedef struct MatroskaTrack { AVStream *stream; int64_t end_timecode; int ms_compat; +int needs_decoding; uint64_t max_block_additional_id; uint32_t palette[AVPALETTE_COUNT]; @@ -2405,6 +2406,11 @@ static int matroska_parse_tracks(AVFormatContext *s) } } } +track->needs_decoding = encodings && !encodings[0].type && +encodings[0].scope & 1 && +(encodings[0].compression.algo != + MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP || + encodings[0].compression.settings.size); for (j = 0; ff_mkv_codec_tags[j].id != AV_CODEC_ID_NONE; j++) { if (!strncmp(ff_mkv_codec_tags[j].str, track->codec_id, @@ -3413,12 +3419,11 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, uint8_t *additional, uint64_t additional_id, int additional_size, int64_t discard_padding) { -MatroskaTrackEncoding *encodings = track->encodings.elem; uint8_t *pkt_data = data; int res = 0; AVPacket pktl, *pkt = &pktl; -if (encodings && !encodings->type && encodings->scope & 1) { +if (track->needs_decoding) { res = matroska_decode_buffer(&pkt_data, &pkt_size, track); if (res < 0) return res; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskadec: Support ContentCompression for all codecs
ffmpeg | branch: master | Andreas Rheinhardt | Fri Dec 6 09:53:34 2019 +0100| [979b5b89594c7628bd846c63198cb64ef9d81d16] | committer: Andreas Rheinhardt avformat/matroskadec: Support ContentCompression for all codecs The Matroska demuxer has three functions for creating packets out of the data read: One for certain RealAudio codecs (ATRAC3, cook, sipr, RealAudio 28.8), one for WebVTT (actually, the WebM flavour of it) and one for all the others. Only the last function supported Matroska's ContentCompression (e.g. it reversed zlib compression or added the removed headers to the packets). But in Matroska, all tracks are allowed to be compressed. This commit adds support for this. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=979b5b89594c7628bd846c63198cb64ef9d81d16 --- libavformat/matroskadec.c | 79 ++- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 9e3e98e9c0..c16e18cb22 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3192,10 +3192,11 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska, } /* reconstruct full wavpack blocks from mangled matroska ones */ -static int matroska_parse_wavpack(MatroskaTrack *track, uint8_t *src, - uint8_t **pdst, int *size) +static int matroska_parse_wavpack(MatroskaTrack *track, + uint8_t **data, int *size) { uint8_t *dst = NULL; +uint8_t *src = *data; int dstlen = 0; int srclen = *size; uint32_t samples; @@ -3265,7 +3266,7 @@ static int matroska_parse_wavpack(MatroskaTrack *track, uint8_t *src, memset(dst + dstlen, 0, AV_INPUT_BUFFER_PADDING_SIZE); -*pdst = dst; +*data = dst; *size = dstlen; return 0; @@ -3275,8 +3276,8 @@ fail: return ret; } -static int matroska_parse_prores(MatroskaTrack *track, uint8_t *src, - uint8_t **pdst, int *size) +static int matroska_parse_prores(MatroskaTrack *track, + uint8_t **data, int *size) { uint8_t *dst; int dstlen = *size + 8; @@ -3287,10 +3288,10 @@ static int matroska_parse_prores(MatroskaTrack *track, uint8_t *src, AV_WB32(dst, dstlen); AV_WB32(dst + 4, MKBETAG('i', 'c', 'p', 'f')); -memcpy(dst + 8, src, dstlen - 8); +memcpy(dst + 8, *data, dstlen - 8); memset(dst + dstlen, 0, AV_INPUT_BUFFER_PADDING_SIZE); -*pdst = dst; +*data = dst; *size = dstlen; return 0; @@ -3413,54 +3414,46 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, static int matroska_parse_frame(MatroskaDemuxContext *matroska, MatroskaTrack *track, AVStream *st, -AVBufferRef *buf, uint8_t *data, int pkt_size, +AVBufferRef *buf, uint8_t **data, int pkt_size, uint64_t timecode, uint64_t lace_duration, int64_t pos, int is_keyframe, uint8_t *additional, uint64_t additional_id, int additional_size, int64_t discard_padding) { -uint8_t *pkt_data = data; +uint8_t *pkt_data = *data; int res = 0; AVPacket pktl, *pkt = &pktl; -if (track->needs_decoding) { -res = matroska_decode_buffer(&pkt_data, &pkt_size, track); -if (res < 0) -return res; -} - if (st->codecpar->codec_id == AV_CODEC_ID_WAVPACK) { -uint8_t *wv_data; -res = matroska_parse_wavpack(track, pkt_data, &wv_data, &pkt_size); +res = matroska_parse_wavpack(track, &pkt_data, &pkt_size); if (res < 0) { av_log(matroska->ctx, AV_LOG_ERROR, "Error parsing a wavpack block.\n"); goto fail; } -if (pkt_data != data) -av_freep(&pkt_data); -pkt_data = wv_data; +if (!buf) +av_freep(data); +buf = NULL; } if (st->codecpar->codec_id == AV_CODEC_ID_PRORES && AV_RB32(pkt_data + 4) != MKBETAG('i', 'c', 'p', 'f')) { -uint8_t *pr_data; -res = matroska_parse_prores(track, pkt_data, &pr_data, &pkt_size); +res = matroska_parse_prores(track, &pkt_data, &pkt_size); if (res < 0) { av_log(matroska->ctx, AV_LOG_ERROR, "Error parsing a prores block.\n"); goto fail; } -if (pkt_data != data) -av_freep(&pkt_data); -pkt_data = pr_data; +if (!buf) +av_freep(data); +buf = NULL; } if (!pkt_size && !additional_size) goto no_output; av_init_packet(pkt); -if (pkt_data != data) +if (!buf) pkt->buf = av_buffer_create
[FFmpeg-cvslog] avformat/matroskadec: Cosmetics
ffmpeg | branch: master | Andreas Rheinhardt | Sat Dec 7 00:11:01 2019 +0100| [39fb1e968a5a8bd62bb454a5291d877a6ddd726c] | committer: Andreas Rheinhardt avformat/matroskadec: Cosmetics Reindentation as well as marking several variables used for demuxing RealAudio as const to clearly see that they don't change during demuxing. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=39fb1e968a5a8bd62bb454a5291d877a6ddd726c --- libavformat/matroskadec.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index c16e18cb22..917c106258 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3119,12 +3119,12 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska, uint8_t *data, int size, uint64_t timecode, int64_t pos) { -int a = st->codecpar->block_align; -int sps = track->audio.sub_packet_size; -int cfs = track->audio.coded_framesize; -int h = track->audio.sub_packet_h; +const int a = st->codecpar->block_align; +const int sps = track->audio.sub_packet_size; +const int cfs = track->audio.coded_framesize; +const int h = track->audio.sub_packet_h; +const int w = track->audio.frame_size; int y = track->audio.sub_packet_cnt; -int w = track->audio.frame_size; int x; if (!track->audio.pkt_cnt) { @@ -3282,14 +3282,14 @@ static int matroska_parse_prores(MatroskaTrack *track, uint8_t *dst; int dstlen = *size + 8; -dst = av_malloc(dstlen + AV_INPUT_BUFFER_PADDING_SIZE); -if (!dst) -return AVERROR(ENOMEM); +dst = av_malloc(dstlen + AV_INPUT_BUFFER_PADDING_SIZE); +if (!dst) +return AVERROR(ENOMEM); -AV_WB32(dst, dstlen); -AV_WB32(dst + 4, MKBETAG('i', 'c', 'p', 'f')); -memcpy(dst + 8, *data, dstlen - 8); -memset(dst + dstlen, 0, AV_INPUT_BUFFER_PADDING_SIZE); +AV_WB32(dst, dstlen); +AV_WB32(dst + 4, MKBETAG('i', 'c', 'p', 'f')); +memcpy(dst + 8, *data, dstlen - 8); +memset(dst + dstlen, 0, AV_INPUT_BUFFER_PADDING_SIZE); *data = dst; *size = dstlen; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".