[FFmpeg-devel] [PATCH] avfilter/avf_showcqt: add bar_t option
custom bargraph transparency Signed-off-by: Muhammad Faiz --- doc/filters.texi | 4 libavfilter/avf_showcqt.c | 14 +- libavfilter/avf_showcqt.h | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index c37fa29..fb04a56 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16835,6 +16835,10 @@ Acceptable range is @code{[1, 7]}. Specify the bargraph gamma. Default value is @code{1}. Acceptable range is @code{[1, 7]}. +@item bar_t +Specify the bargraph transparency level. Lower value makes the bargraph sharper. +Default value is @code{1}. Acceptable range is @code{[0, 1]}. + @item timeclamp, tc Specify the transform timeclamp. At low frequency, there is trade-off between accuracy in time domain and frequency domain. If timeclamp is lower, diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c index 49b950c..a25176d 100644 --- a/libavfilter/avf_showcqt.c +++ b/libavfilter/avf_showcqt.c @@ -75,6 +75,7 @@ static const AVOption showcqt_options[] = { { "gamma","set sonogram gamma", OFFSET(sono_g), AV_OPT_TYPE_FLOAT, { .dbl = 3.0 },1.0, 7.0, FLAGS }, { "bar_g","set bargraph gamma", OFFSET(bar_g), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 },1.0, 7.0, FLAGS }, { "gamma2", "set bargraph gamma", OFFSET(bar_g), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 },1.0, 7.0, FLAGS }, +{ "bar_t", "set bar transparency", OFFSET(bar_t), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 },0.0, 1.0, FLAGS }, { "timeclamp", "set timeclamp", OFFSET(timeclamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.17 }, 0.1, 1.0, FLAGS }, { "tc","set timeclamp", OFFSET(timeclamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.17 }, 0.1, 1.0, FLAGS }, { "basefreq", "set base frequency", OFFSET(basefreq), AV_OPT_TYPE_DOUBLE, { .dbl = BASEFREQ }, 10.0, 10.0, FLAGS }, @@ -752,10 +753,10 @@ static void yuv_from_cqt(ColorFloat *c, const FFTComplex *v, float gamma, int le } static void draw_bar_rgb(AVFrame *out, const float *h, const float *rcp_h, - const ColorFloat *c, int bar_h) + const ColorFloat *c, int bar_h, float bar_t) { int x, y, w = out->width; -float mul, ht, rcp_bar_h = 1.0f / bar_h; +float mul, ht, rcp_bar_h = 1.0f / bar_h, rcp_bar_t = 1.0f / bar_t; uint8_t *v = out->data[0], *lp; int ls = out->linesize[0]; @@ -769,6 +770,7 @@ static void draw_bar_rgb(AVFrame *out, const float *h, const float *rcp_h, *lp++ = 0; } else { mul = (h[x] - ht) * rcp_h[x]; +mul = (mul < bar_t) ? (mul * rcp_bar_t) : 1.0f; *lp++ = lrintf(mul * c[x].rgb.r); *lp++ = lrintf(mul * c[x].rgb.g); *lp++ = lrintf(mul * c[x].rgb.b); @@ -785,6 +787,7 @@ do { \ *lpv++ = 128; \ } else { \ mul = (h[x] - ht) * rcp_h[x]; \ +mul = (mul < bar_t) ? (mul * rcp_bar_t) : 1.0f; \ *lpy++ = lrintf(mul * c[x].yuv.y + 16.0f); \ *lpu++ = lrintf(mul * c[x].yuv.u + 128.0f); \ *lpv++ = lrintf(mul * c[x].yuv.v + 128.0f); \ @@ -797,15 +800,16 @@ do { \ *lpy++ = 16; \ } else { \ mul = (h[x] - ht) * rcp_h[x]; \ +mul = (mul < bar_t) ? (mul * rcp_bar_t) : 1.0f; \ *lpy++ = lrintf(mul * c[x].yuv.y + 16.0f); \ } \ } while (0) static void draw_bar_yuv(AVFrame *out, const float *h, const float *rcp_h, - const ColorFloat *c, int bar_h) + const ColorFloat *c, int bar_h, float bar_t) { int x, y, yh, w = out->width; -float mul, ht, rcp_bar_h = 1.0f / bar_h; +float mul, ht, rcp_bar_h = 1.0f / bar_h, rcp_bar_t = 1.0f / bar_t; uint8_t *vy = out->data[0], *vu = out->data[1], *vv = out->data[2]; uint8_t *lpy, *lpu, *lpv; int lsy = out->linesize[0], lsu = out->linesize[1], lsv = out->linesize[2]; @@ -1160,7 +1164,7 @@ static int plot_cqt(AVFilterContext *ctx, AVFrame **frameout) UPDATE_TIME(s->alloc_time); if (s->bar_h) { -s->draw_bar(out, s->h_buf, s->rcp_h_buf, s->c_buf, s->bar_h); +s->draw_bar(out, s->h_buf, s->rcp_h_buf, s->c_buf, s->bar_h, s->bar_t); UPDATE_TIME(s->bar_time); } diff --git a/libavfilter/avf_showcqt.h b/libavfilter/avf_showcqt.h index 165d36e..3fa36f8 100644 --- a/libavfilter/avf_showcqt.h +++ b/libavfilter/avf_showcqt.h @@ -78,7 +78,7 @@ typedef struct { int len, int fft_len); void(*permute_coeffs)(float *v, int len); void(*draw_bar)(AVFrame *out, const float *h, const float *rcp_h, -const ColorFloat *c, int bar_h); +const ColorFloat *c, int bar_h, float bar_t); void
[FFmpeg-devel] [PATCH] Fix build with LibreSSL
Signed-off-by: Michael Forney --- libavformat/tls_openssl.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c index c551ac7..9712856 100644 --- a/libavformat/tls_openssl.c +++ b/libavformat/tls_openssl.c @@ -43,7 +43,7 @@ typedef struct TLSContext { TLSShared tls_shared; SSL_CTX *ctx; SSL *ssl; -#if OPENSSL_VERSION_NUMBER >= 0x101fL +#if OPENSSL_VERSION_NUMBER >= 0x101fL && !defined(LIBRESSL_VERSION_NUMBER) BIO_METHOD* url_bio_method; #endif } TLSContext; @@ -68,7 +68,7 @@ static unsigned long openssl_thread_id(void) static int url_bio_create(BIO *b) { -#if OPENSSL_VERSION_NUMBER >= 0x101fL +#if OPENSSL_VERSION_NUMBER >= 0x101fL && !defined(LIBRESSL_VERSION_NUMBER) BIO_set_init(b, 1); BIO_set_data(b, NULL); BIO_set_flags(b, 0); @@ -85,7 +85,7 @@ static int url_bio_destroy(BIO *b) return 1; } -#if OPENSSL_VERSION_NUMBER >= 0x101fL +#if OPENSSL_VERSION_NUMBER >= 0x101fL && !defined(LIBRESSL_VERSION_NUMBER) #define GET_BIO_DATA(x) BIO_get_data(x); #else #define GET_BIO_DATA(x) (x)->ptr; @@ -133,7 +133,7 @@ static int url_bio_bputs(BIO *b, const char *str) return url_bio_bwrite(b, str, strlen(str)); } -#if OPENSSL_VERSION_NUMBER < 0x101fL +#if OPENSSL_VERSION_NUMBER < 0x101fL || defined(LIBRESSL_VERSION_NUMBER) static BIO_METHOD url_bio_method = { .type = BIO_TYPE_SOURCE_SINK, .name = "urlprotocol bio", @@ -212,7 +212,7 @@ static int tls_close(URLContext *h) SSL_CTX_free(c->ctx); if (c->tls_shared.tcp) ffurl_close(c->tls_shared.tcp); -#if OPENSSL_VERSION_NUMBER >= 0x101fL +#if OPENSSL_VERSION_NUMBER >= 0x101fL && !defined(LIBRESSL_VERSION_NUMBER) if (c->url_bio_method) BIO_meth_free(c->url_bio_method); #endif @@ -265,7 +265,7 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op ret = AVERROR(EIO); goto fail; } -#if OPENSSL_VERSION_NUMBER >= 0x101fL +#if OPENSSL_VERSION_NUMBER >= 0x101fL && !defined(LIBRESSL_VERSION_NUMBER) p->url_bio_method = BIO_meth_new(BIO_TYPE_SOURCE_SINK, "urlprotocol bio"); BIO_meth_set_write(p->url_bio_method, url_bio_bwrite); BIO_meth_set_read(p->url_bio_method, url_bio_bread); -- 2.10.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] lavfi/pan: allow negative gain parameters also for other inputs than the first named
Expands the parser to also accept the separator '-' in addition to '+', and take the negative sign into consideration. The optional sign for the first factor in the expression is already covered by parsing for an integer. Signed-off-by: Moritz Barsnick --- doc/filters.texi | 2 +- libavfilter/af_pan.c | 10 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index c37fa29..bff4640 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3025,7 +3025,7 @@ output channel layout or number of channels @item outdef output channel specification, of the form: -"@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]" +"@var{out_name}=[@var{gain}*]@var{in_name}[(+-)[@var{gain}*]@var{in_name}...]" @item out_name output channel to define, either a channel name (FL, FR, etc.) or a channel diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c index fbd79a5..94f1587 100644 --- a/libavfilter/af_pan.c +++ b/libavfilter/af_pan.c @@ -102,7 +102,7 @@ static av_cold int init(AVFilterContext *ctx) { PanContext *const pan = ctx->priv; char *arg, *arg0, *tokenizer, *args = av_strdup(pan->args); -int out_ch_id, in_ch_id, len, named, ret; +int out_ch_id, in_ch_id, len, named, ret, sign = 1; int nb_in_channels[2] = { 0, 0 }; // number of unnamed and named input channels double gain; @@ -178,14 +178,18 @@ static av_cold int init(AVFilterContext *ctx) ret = AVERROR(EINVAL); goto fail; } -pan->gain[out_ch_id][in_ch_id] = gain; +pan->gain[out_ch_id][in_ch_id] = sign * gain; skip_spaces(&arg); if (!*arg) break; -if (*arg != '+') { +if (*arg == '-') { +sign = -1; +} else if (*arg != '+') { av_log(ctx, AV_LOG_ERROR, "Syntax error near \"%.8s\"\n", arg); ret = AVERROR(EINVAL); goto fail; +} else { +sign = 1; } arg++; } -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavfi/pan: allow negative gain parameters also for other inputs than the first named
On Thu, Oct 13, 2016 at 11:31:22 +0200, Nicolas George wrote: > Nit: inconsistent placement of the else clause. Not blocking. Fixed, and ping. Thanks, Moritz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] ffmpeg: parameters for filter thread counts
Enables specifying how many threads are available to each filtergraph. --- doc/ffmpeg.texi | 10 ++ ffmpeg.h| 3 +++ ffmpeg_filter.c | 9 + ffmpeg_opt.c| 4 4 files changed, 26 insertions(+) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 47c8935..8be24b2 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -415,6 +415,11 @@ This option is similar to @option{-filter}, the only difference is that its argument is the name of the file from which a filtergraph description is to be read. +@item -filter_threads @var{nb_thraeds} (@emph{global}) +Defines how many threads are used to process a filter pipeline. +Some filters support parallel processing. The default is the number of available +CPUs. + @item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream}) Specify the preset for matching stream(s). @@ -1201,6 +1206,11 @@ To generate 5 seconds of pure red video using lavfi @code{color} source: ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv @end example +@item -filter_complex_threads @var{nb_threads} (@emph{global}) +Defines how many threads are used to process a @code{-filter_complex} pipeline. +Some filters support parallel processing. The default is the number of available +CPUs. + @item -lavfi @var{filtergraph} (@emph{global}) Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or outputs. Equivalent to @option{-filter_complex}. diff --git a/ffmpeg.h b/ffmpeg.h index e1d4593..9a4389f 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -569,6 +569,9 @@ extern AVIOContext *progress_avio; extern float max_error_rate; extern char *videotoolbox_pixfmt; +extern int filter_nbthreads; +extern int filter_complex_nbthreads; + extern const AVIOInterruptCB int_cb; extern const OptionDef options[]; diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c index 27aeca0..4554456 100644 --- a/ffmpeg_filter.c +++ b/ffmpeg_filter.c @@ -39,6 +39,9 @@ #include "libavutil/imgutils.h" #include "libavutil/samplefmt.h" +int filter_nbthreads = -1; +int filter_complex_nbthreads = -1; + static const enum AVPixelFormat *get_compliance_unofficial_pix_fmts(enum AVCodecID codec_id, const enum AVPixelFormat default_formats[]) { static const enum AVPixelFormat mjpeg_formats[] = @@ -309,6 +312,8 @@ int init_complex_filtergraph(FilterGraph *fg) if (!graph) return AVERROR(ENOMEM); +// As a temporary graph, don't bother making threads +graph->nb_threads = 1; ret = avfilter_graph_parse2(graph, fg->graph_desc, &inputs, &outputs); if (ret < 0) goto fail; @@ -992,6 +997,8 @@ int configure_filtergraph(FilterGraph *fg) char args[512]; AVDictionaryEntry *e = NULL; +fg->graph->nb_threads = filter_complex_nbthreads; + args[0] = 0; while ((e = av_dict_get(ost->sws_dict, "", e, AV_DICT_IGNORE_SUFFIX))) { @@ -1022,6 +1029,8 @@ int configure_filtergraph(FilterGraph *fg) e = av_dict_get(ost->encoder_opts, "threads", NULL, 0); if (e) av_opt_set(fg->graph, "threads", e->value, 0); +} else { +fg->graph->nb_threads = filter_nbthreads; } if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, &outputs)) < 0) diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 4d25fff..dc94380 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -3365,12 +3365,16 @@ const OptionDef options[] = { "set profile", "profile" }, { "filter", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filters) }, "set stream filtergraph", "filter_graph" }, +{ "filter_threads", HAS_ARG | OPT_INT, { &filter_nbthreads }, +"number of non-complex filter threads" }, { "filter_script", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filter_scripts) }, "read stream filtergraph description from a file", "filename" }, { "reinit_filter", HAS_ARG | OPT_INT | OPT_SPEC | OPT_INPUT,{ .off = OFFSET(reinit_filters) }, "reinit filtergraph on input parameter changes", "" }, { "filter_complex", HAS_ARG | OPT_EXPERT,{ .func_arg = opt_filter_complex }, "create a complex filtergraph", "graph_description" }, +{ "filter_complex_threads", HAS_ARG | OPT_INT, { &filter_complex_nbthreads }, +"number of threads for -filter_complex" }, { "lavfi", HAS_ARG | OPT_EXPERT,{ .func_arg = opt_filter_complex }, "create a complex filtergraph", "graph_description" }, { "filter_complex_script", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex_script }, -- 1.8.4.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Remove the ffserver program and the ffm muxer/demuxer
On Thu, 27 Oct 2016 15:42:22 -0300 James Almer wrote: > On 10/27/2016 3:36 PM, Reynaldo H. Verdejo Pinochet wrote: > > On 10/27/2016 11:25 AM, James Almer wrote: > >> This is not how things were agreed. > > I haven't agreed to this. > You could have shown your displeasure in the relevant discussion and > patch threads, and on IRC. Why didn't you? > > A quick search on the archive shows > https://ffmpeg.org/pipermail/ffmpeg-devel/2016-April/192808.html > https://ffmpeg.org/pipermail/ffmpeg-devel/2016-July/196500.html but then there was this in september, after the news entry was posted http://ffmpeg.org/pipermail/ffmpeg-devel/2016-September/199686.html i'd suggest talking to that person before applying said patch. we can talk before applying a patch still, right? :) -compn ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Remove the ffserver program and the ffm muxer/demuxer
On 10/28/2016 2:31 PM, compn wrote: > On Thu, 27 Oct 2016 15:42:22 -0300 James Almer wrote: >> On 10/27/2016 3:36 PM, Reynaldo H. Verdejo Pinochet wrote: >>> On 10/27/2016 11:25 AM, James Almer wrote: This is not how things were agreed. >>> I haven't agreed to this. >> You could have shown your displeasure in the relevant discussion and >> patch threads, and on IRC. Why didn't you? >> >> A quick search on the archive shows >> https://ffmpeg.org/pipermail/ffmpeg-devel/2016-April/192808.html >> https://ffmpeg.org/pipermail/ffmpeg-devel/2016-July/196500.html > > but then there was this in september, after the news entry was posted > > http://ffmpeg.org/pipermail/ffmpeg-devel/2016-September/199686.html This is like someone showing up the day a collapsing building is scheduled to be demolished suggesting to instead add some extra cement to keep it in place. That simply would fly. One at most can suggest what could be built in its place afterwards. > > i'd suggest talking to that person before applying said patch. As i said, nobody is against a working ffserver replacement made from scratch, out of tree or otherwise, but the decision was already made and announced in more than one channel. > we can talk before applying a patch still, right? :) Sure, we're doing it right now. But the time to have an effect on the decision is long past. It was at the latest back with the news entry patch. A thread where for that matter you didn't talk. > > -compn ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Remove the ffserver program and the ffm muxer/demuxer
Hi I'm already working on what I think it's a proper transition in line with the idea presented on my first reply to this thread. My impression from today's discussion on IRC is that James and Rostislav are willing to give this process some time but nothing past next release. Bests, -- Reynaldo H. Verdejo Pinochet Open Source Group - Samsung Research America ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] openssl: Allow TLS 1.2
The use of TLSv1_method() disallows newer protocol versions; instead use SSLv23_method() and then explicitly disable the older versions which should not be supported. Fixes ticket #5915. --- libavformat/tls_openssl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c index c551ac7..7c9dd61 100644 --- a/libavformat/tls_openssl.c +++ b/libavformat/tls_openssl.c @@ -233,12 +233,13 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op if ((ret = ff_tls_open_underlying(c, h, uri, options)) < 0) goto fail; -p->ctx = SSL_CTX_new(c->listen ? TLSv1_server_method() : TLSv1_client_method()); +p->ctx = SSL_CTX_new(c->listen ? SSLv23_server_method() : SSLv23_client_method()); if (!p->ctx) { av_log(h, AV_LOG_ERROR, "%s\n", ERR_error_string(ERR_get_error(), NULL)); ret = AVERROR(EIO); goto fail; } +SSL_CTX_set_options(p->ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); if (c->ca_file) { if (!SSL_CTX_load_verify_locations(p->ctx, c->ca_file, NULL)) av_log(h, AV_LOG_ERROR, "SSL_CTX_load_verify_locations %s\n", ERR_error_string(ERR_get_error(), NULL)); -- 2.9.3 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] configure: add '-uninstalled' to uninstalled .pc files
From: "Reynaldo H. Verdejo Pinochet" pkg-config(1) expects uninstalled pc files to follow the blah-uninstalled.pc naming convention and the behavior of the program is impacted by it. Without this fix overriding PKGP_CONFIG_LIBDIR is required to ensure uninstalled files are preferred (overkill), instead of just adding pc-uninstalled/ to the utility's search path by setting PKG_CONFIG_PATH accordingly. Signed-off-by: Reynaldo H. Verdejo Pinochet --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 7476ca8..a26b91c 100755 --- a/configure +++ b/configure @@ -6813,7 +6813,7 @@ EOF mkdir -p doc/examples/pc-uninstalled includedir=${source_path} [ "$includedir" = . ] && includedir="\${pcfiledir}/../../.." -cat < doc/examples/pc-uninstalled/$name.pc +cat < doc/examples/pc-uninstalled/${name}-uninstalled.pc prefix= exec_prefix= libdir=\${pcfiledir}/../../../$name -- 2.9.3 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] fix tls 1.2 when ffmpeg is compiled with openssl
Made by vpeter of the LibreELEC project. --- a/libavformat/tls_openssl.c 2016-10-28 18:52:40.526626700 +0200 +++ b/libavformat/tls_openssl.c 2016-10-28 19:21:41.520615426 +0200 @@ -233,7 +233,8 @@ static int tls_open(URLContext *h, const if ((ret = ff_tls_open_underlying(c, h, uri, options)) < 0) goto fail; -p->ctx = SSL_CTX_new(c->listen ? TLSv1_server_method() : TLSv1_client_method()); +//SSLv23_client_method allows to use TLS v1.2 protocol +p->ctx = SSL_CTX_new(c->listen ? TLSv1_server_method() : SSLv23_client_method()); if (!p->ctx) { av_log(h, AV_LOG_ERROR, "%s\n", ERR_error_string(ERR_get_error(), NULL)); ret = AVERROR(EIO); ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] doc/examples: add fuzz target for individual ffmpeg APIs for in-process fuzzing with libFuzzer, AFL, and similar fuzzing engines.
From: Thomas Garnier Signed-off-by: Michael Niedermayer --- doc/examples/decoder_targeted.c | 183 1 file changed, 183 insertions(+) create mode 100644 doc/examples/decoder_targeted.c diff --git a/doc/examples/decoder_targeted.c b/doc/examples/decoder_targeted.c new file mode 100644 index 000..72e2c51 --- /dev/null +++ b/doc/examples/decoder_targeted.c @@ -0,0 +1,183 @@ +/* Targeted fuzzer that targets specific codecs depending on two + compile-time flags. + INSTRUCTIONS: + + * Get the very fresh clang, e.g. see http://libfuzzer.info#versions + * Get and build libFuzzer: + svn co http://llvm.org/svn/llvm-project/llvm/trunk/lib/Fuzzer + ./Fuzzer/build.sh + * build ffmpeg for fuzzing: +FLAGS="-fsanitize=address -fsanitize-coverage=trace-pc-guard,trace-cmp -g" CC="clang $FLAGS" CXX="clang++ $FLAGS" ./configure --disable-yasm +make clean && make -j + * build the fuzz target. +Choose the value of FFMPEG_CODEC (e.g. AV_CODEC_ID_DVD_SUBTITLE) and +choose one of FUZZ_FFMPEG_VIDEO, FUZZ_FFMPEG_AUDIO, FUZZ_FFMPEG_SUBTITLE. +clang -fsanitize=address -fsanitize-coverage=trace-pc-guard,trace-cmp doc/examples/decoder_targeted.c -o decoder_targeted -I. -DFFMPEG_CODEC=AV_CODEC_ID_MPEG1VIDEO -DFUZZ_FFMPEG_VIDEO ../../libfuzzer/libFuzzer.a -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample -Wl,--as-needed -Wl,-z,noexecstack -Wl,--warn-common -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample -lavdevice -lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil -ldl -lxcb -lxcb-shm -lxcb -lxcb-xfixes -lxcb -lxcb-shape -lxcb -lX11 -lasound -lm -lbz2 -lz -pthread + * create a corpus directory and put some samples there (empty dir is ok too): +mkdir CORPUS && cp some-files CORPUS + + * Run fuzzing: +./decoder_targeted -max_len=10 CORPUS + + More info: + http://libfuzzer.info + http://tutorial.libfuzzer.info + https://github.com/google/oss-fuzz + http://lcamtuf.coredump.cx/afl/ + https://security.googleblog.com/2016/08/guided-in-process-fuzzing-of-chrome.html +*/ + +#include "libavutil/avassert.h" + +#include "libavcodec/avcodec.h" +#include "libavformat/avformat.h" + +static void error(const char *err) +{ +fprintf(stderr, "%s", err); +exit(1); +} + +static AVCodec *c = NULL; +static AVCodec *AVCodecInitialize(enum AVCodecID codec_id) +{ +AVCodec *res; +av_register_all(); +av_log_set_level(AV_LOG_PANIC); +res = avcodec_find_decoder(codec_id); +if (!res) +error("Failed to find decoder"); +return res; +} + +#if defined(FUZZ_FFMPEG_VIDEO) +#define decode_handler avcodec_decode_video2 +#elif defined(FUZZ_FFMPEG_AUDIO) +#define decode_handler avcodec_decode_audio4 +#elif defined(FUZZ_FFMPEG_SUBTITLE) +static int subtitle_handler(AVCodecContext *avctx, void *frame, +int *got_sub_ptr, AVPacket *avpkt) +{ +AVSubtitle sub; +int ret = avcodec_decode_subtitle2(avctx, &sub, got_sub_ptr, avpkt); +if (ret >= 0 && *got_sub_ptr) +avsubtitle_free(&sub); +return ret; +} + +#define decode_handler subtitle_handler +#else +#error "Specify encoder type" // To catch mistakes +#endif + +// Class to handle buffer allocation and resize for each frame +typedef struct FuzzDataBuffer { +size_t size_; +uint8_t *data_; +} FuzzDataBuffer; + +void FDBCreate(FuzzDataBuffer *FDB) { +FDB->size_ = 0x1000; +FDB->data_ = av_malloc(FDB->size_); +if (!FDB->data_) +error("Failed memory allocation"); +} + +void FDBDesroy(FuzzDataBuffer *FDB) { av_free(FDB->data_); } + +void FDBRealloc(FuzzDataBuffer *FDB, size_t size) { +size_t needed = size + FF_INPUT_BUFFER_PADDING_SIZE; +av_assert0(needed > size); +if (needed > FDB->size_) { +av_free(FDB->data_); +FDB->size_ = needed; +FDB->data_ = av_malloc(FDB->size_); +if (!FDB->data_) +error("Failed memory allocation"); +} +} + +void FDBPrepare(FuzzDataBuffer *FDB, AVPacket *dst, const uint8_t *data, +size_t size) +{ +FDBRealloc(FDB, size); +memcpy(FDB->data_, data, size); +size_t padd = FDB->size_ - size; +if (padd > FF_INPUT_BUFFER_PADDING_SIZE) +padd = FF_INPUT_BUFFER_PADDING_SIZE; +memset(FDB->data_ + size, 0, padd); +av_init_packet(dst); +dst->data = FDB->data_; +dst->size = size; +} + +// Ensure we don't loop forever +const uint32_t maxiteration = 8096; + +static const uint64_t FUZZ_TAG = 0x4741542D5A5A5546ULL; + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +const uint64_t fuzz_tag = FUZZ_TAG; +FuzzDataBuffer buffer; +const uint8_t *last = data; +const uint8_t *end = data + size; +uint32_t it = 0; + +if (!c) +c = AVCodecInitialize(FFMPEG_CODEC); // Done once. + +
Re: [FFmpeg-devel] [PATCH] fix tls 1.2 when ffmpeg is compiled with openssl
On Fri, Oct 28, 2016 at 8:42 PM, Martin Larsson wrote: > Made by vpeter of the LibreELEC project. > > --- a/libavformat/tls_openssl.c 2016-10-28 18:52:40.526626700 +0200 > +++ b/libavformat/tls_openssl.c 2016-10-28 19:21:41.520615426 +0200 > @@ -233,7 +233,8 @@ static int tls_open(URLContext *h, const > if ((ret = ff_tls_open_underlying(c, h, uri, options)) < 0) > goto fail; > > -p->ctx = SSL_CTX_new(c->listen ? TLSv1_server_method() : > TLSv1_client_method()); > +//SSLv23_client_method allows to use TLS v1.2 protocol > +p->ctx = SSL_CTX_new(c->listen ? TLSv1_server_method() : > SSLv23_client_method()); > if (!p->ctx) { > av_log(h, AV_LOG_ERROR, "%s\n", ERR_error_string(ERR_get_error(), > NULL)); > ret = AVERROR(EIO); To ensure the same security restrictions apply as before, it should perhaps set the options to disable SSLv2/3 then? SSL_CTX_set_options(p->ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3) Otherwise looks fine, the API seems to be rather weird there. - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] openssl: Allow TLS 1.2
On Fri, Oct 28, 2016 at 8:56 PM, Mark Thompson wrote: > The use of TLSv1_method() disallows newer protocol versions; instead > use SSLv23_method() and then explicitly disable the older versions > which should not be supported. > > Fixes ticket #5915. > --- > libavformat/tls_openssl.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c > index c551ac7..7c9dd61 100644 > --- a/libavformat/tls_openssl.c > +++ b/libavformat/tls_openssl.c > @@ -233,12 +233,13 @@ static int tls_open(URLContext *h, const char *uri, int > flags, AVDictionary **op > if ((ret = ff_tls_open_underlying(c, h, uri, options)) < 0) > goto fail; > > -p->ctx = SSL_CTX_new(c->listen ? TLSv1_server_method() : > TLSv1_client_method()); > +p->ctx = SSL_CTX_new(c->listen ? SSLv23_server_method() : > SSLv23_client_method()); > if (!p->ctx) { > av_log(h, AV_LOG_ERROR, "%s\n", ERR_error_string(ERR_get_error(), > NULL)); > ret = AVERROR(EIO); > goto fail; > } > +SSL_CTX_set_options(p->ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); > if (c->ca_file) { > if (!SSL_CTX_load_verify_locations(p->ctx, c->ca_file, NULL)) > av_log(h, AV_LOG_ERROR, "SSL_CTX_load_verify_locations %s\n", > ERR_error_string(ERR_get_error(), NULL)); > -- > 2.9.3 > I should have looked further when commenting on the other patch - I guess. :) Looks good to me, the OpenSSL API seems to be rather confusing in this regard. Maybe a comment might be useful to indicate why this is done. - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] fix tls 1.2 when ffmpeg is compiled with openssl
On Fri, Oct 28, 2016 at 11:13 PM, Hendrik Leppkes wrote: > On Fri, Oct 28, 2016 at 8:42 PM, Martin Larsson > wrote: >> Made by vpeter of the LibreELEC project. >> >> --- a/libavformat/tls_openssl.c 2016-10-28 18:52:40.526626700 +0200 >> +++ b/libavformat/tls_openssl.c 2016-10-28 19:21:41.520615426 +0200 >> @@ -233,7 +233,8 @@ static int tls_open(URLContext *h, const >> if ((ret = ff_tls_open_underlying(c, h, uri, options)) < 0) >> goto fail; >> >> -p->ctx = SSL_CTX_new(c->listen ? TLSv1_server_method() : >> TLSv1_client_method()); >> +//SSLv23_client_method allows to use TLS v1.2 protocol >> +p->ctx = SSL_CTX_new(c->listen ? TLSv1_server_method() : >> SSLv23_client_method()); >> if (!p->ctx) { >> av_log(h, AV_LOG_ERROR, "%s\n", ERR_error_string(ERR_get_error(), >> NULL)); >> ret = AVERROR(EIO); > > To ensure the same security restrictions apply as before, it should > perhaps set the options to disable SSLv2/3 then? > > SSL_CTX_set_options(p->ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3) > > Otherwise looks fine, the API seems to be rather weird there. > Nevermind, there is another patch on the ML doing just this. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] fate: add apng encoding/muxing test
On 28.10.2016 02:14, James Almer wrote: > On 10/27/2016 8:45 PM, Andreas Cadhalpun wrote: >> Also test the fallback to png creation for a single frame. >> >> Signed-off-by: Andreas Cadhalpun >> --- >> >> Obviously, the patch fixing this has to be applied first. >> >> --- >> tests/fate/avformat.mak | 1 + >> tests/lavf-regression.sh | 9 + >> tests/ref/lavf/apng | 6 ++ >> 3 files changed, 16 insertions(+) >> create mode 100644 tests/ref/lavf/apng >> >> diff --git a/tests/fate/avformat.mak b/tests/fate/avformat.mak >> index 3760e41..bbb1f98 100644 >> --- a/tests/fate/avformat.mak >> +++ b/tests/fate/avformat.mak >> @@ -1,5 +1,6 @@ >> FATE_LAVF-$(call ENCDEC, PCM_S16BE, AIFF) += aiff >> FATE_LAVF-$(call ENCDEC, PCM_ALAW, PCM_ALAW) += alaw >> +FATE_LAVF-$(call ENCDEC, APNG, APNG) += apng >> FATE_LAVF-$(call ENCDEC2, MSMPEG4V3, MP2, ASF)+= asf >> FATE_LAVF-$(call ENCDEC, PCM_S16BE_PLANAR, AST)+= ast >> FATE_LAVF-$(call ENCDEC, PCM_S16BE, AU) += au >> diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh >> index 8d96178..9050027 100755 >> --- a/tests/lavf-regression.sh >> +++ b/tests/lavf-regression.sh >> @@ -212,6 +212,15 @@ do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i >> $raw_src $ENC_OPTS -t 1 -q >> do_avconv_crc $file $DEC_OPTS -i $target_path/$file -pix_fmt rgb24 >> fi >> >> +if [ -n "$do_apng" ] ; then >> +file=${outfile}lavf.apng >> +do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS -t >> 1 -qscale 10 -pix_fmt rgb24 >> +do_avconv_crc $file $DEC_OPTS -i $target_path/$file -pix_fmt rgb24 >> +file=${outfile}lavf.png >> +do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS -t >> 1 -qscale 10 -pix_fmt rgb24 -frames:v 1 > > You're already using -frames:v 1, so -t 1 is superfluous. > > And you need to force apng as muxer, otherwise it will default to the image2 > muxer because the output file extension is png. Fixed that and also dropped the useless qscale argument. >> +do_avconv_crc $file $DEC_OPTS -i $target_path/$file -pix_fmt rgb24 >> +fi >> + >> if [ -n "$do_yuv4mpeg" ] ; then >> file=${outfile}lavf.y4m >> do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS -t >> 1 -qscale 10 >> diff --git a/tests/ref/lavf/apng b/tests/ref/lavf/apng >> new file mode 100644 >> index 000..4d35408 >> --- /dev/null >> +++ b/tests/ref/lavf/apng >> @@ -0,0 +1,6 @@ >> +a4c46fad7716ad094eb3c78b74ca0244 *./tests/data/lavf/lavf.apng >> +6209864 ./tests/data/lavf/lavf.apng >> +./tests/data/lavf/lavf.apng CRC=0x87b3c15f >> +c5900fdd1b2fc30b985793f5226fd0c4 *./tests/data/lavf/lavf.png >> +248854 ./tests/data/lavf/lavf.png >> +./tests/data/lavf/lavf.png CRC=0xd8c7b7a1 > > LGTM after the above changes. Pushed. Best regards, Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] configure: make sure LTO does not optimize out the test functions
On 26.10.2016 02:07, Michael Niedermayer wrote: > On Wed, Oct 26, 2016 at 01:35:34AM +0200, Andreas Cadhalpun wrote: >> On 26.10.2016 01:26, Michael Niedermayer wrote: >>> On Wed, Oct 26, 2016 at 01:16:13AM +0200, Andreas Cadhalpun wrote: configure |7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) 742684cf379693d08075d43fdfb75ed5e2e936c6 0001-configure-make-sure-LTO-does-not-optimize-out-the-te.patch From bb289a0b2b0948afa99227bcff188301c1143624 Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun Date: Tue, 25 Oct 2016 19:09:46 +0200 Subject: [PATCH] configure: make sure LTO does not optimize out the test functions Fixes trac ticket #5909 Bud-Id: https://bugs.gentoo.org/show_bug.cgi?id=598054 Signed-off-by: Andreas Cadhalpun --- configure | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 481f692..54faef1 100755 --- a/configure +++ b/configure @@ -1150,7 +1150,12 @@ check_func_headers(){ for func in $funcs; do echo "long check_$func(void) { return (long) $func; }" done -echo "int main(void) { return 0; }" +echo "int main(void) { int ret = 0;" +# LTO could optimize out the test functions without this +for func in $funcs; do +echo " ret |= ((intptr_t)check_$func) & 0x;" +done +echo "return ret; }" >>> >>> breaks configure >>> >>> i get this: >>> >>> ERROR: LoadLibrary/dlopen not found for avisynth >> >> I forgot to include stdint.h. Fixed patch attached. > > seems working here now > > Acked-by: Michael Pushed. Best regards, Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] crystalhd: Reorder mspeg4 decoder after software decoders
On 28.10.2016 03:40, Philip Langdale wrote: > This avoids it getting picked by default, which is generally > undesirable and can break test runs. > > Signed-off-by: Philip Langdale > --- > libavcodec/allcodecs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > index b592aa3..594d104 100644 > --- a/libavcodec/allcodecs.c > +++ b/libavcodec/allcodecs.c > @@ -261,10 +261,10 @@ void avcodec_register_all(void) > REGISTER_DECODER(MPEG2_CRYSTALHD, mpeg2_crystalhd); > REGISTER_DECODER(MPEG2_QSV, mpeg2_qsv); > REGISTER_DECODER(MSA1, msa1); > -REGISTER_DECODER(MSMPEG4_CRYSTALHD, msmpeg4_crystalhd); > REGISTER_DECODER(MSMPEG4V1, msmpeg4v1); > REGISTER_ENCDEC (MSMPEG4V2, msmpeg4v2); > REGISTER_ENCDEC (MSMPEG4V3, msmpeg4v3); > +REGISTER_DECODER(MSMPEG4_CRYSTALHD, msmpeg4_crystalhd); > REGISTER_DECODER(MSRLE, msrle); > REGISTER_DECODER(MSS1, mss1); > REGISTER_DECODER(MSS2, mss2); > LGTM. Best regards, Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] ffmpeg: parameters for filter thread counts
DHE 于2016年10月28日 周五下午10:30写道: > Enables specifying how many threads are available to each filtergraph. > --- > doc/ffmpeg.texi | 10 ++ > ffmpeg.h| 3 +++ > ffmpeg_filter.c | 9 + > ffmpeg_opt.c| 4 > 4 files changed, 26 insertions(+) > > diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi > index 47c8935..8be24b2 100644 > --- a/doc/ffmpeg.texi > +++ b/doc/ffmpeg.texi > @@ -415,6 +415,11 @@ This option is similar to @option{-filter}, the only > difference is that its > argument is the name of the file from which a filtergraph description is > to be > read. > > +@item -filter_threads @var{nb_thraeds} (@emph{global}) > +Defines how many threads are used to process a filter pipeline. > +Some filters support parallel processing. The default is the number of > available > +CPUs. > + > @item -pre[:@var{stream_specifier}] @var{preset_name} > (@emph{output,per-stream}) > Specify the preset for matching stream(s). > > @@ -1201,6 +1206,11 @@ To generate 5 seconds of pure red video using lavfi > @code{color} source: > ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv > @end example > > +@item -filter_complex_threads @var{nb_threads} (@emph{global}) > +Defines how many threads are used to process a @code{-filter_complex} > pipeline. > +Some filters support parallel processing. The default is the number of > available > +CPUs. > + > @item -lavfi @var{filtergraph} (@emph{global}) > Define a complex filtergraph, i.e. one with arbitrary number of inputs > and/or > outputs. Equivalent to @option{-filter_complex}. > diff --git a/ffmpeg.h b/ffmpeg.h > index e1d4593..9a4389f 100644 > --- a/ffmpeg.h > +++ b/ffmpeg.h > @@ -569,6 +569,9 @@ extern AVIOContext *progress_avio; > extern float max_error_rate; > extern char *videotoolbox_pixfmt; > > +extern int filter_nbthreads; > +extern int filter_complex_nbthreads; > + > extern const AVIOInterruptCB int_cb; > > extern const OptionDef options[]; > diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c > index 27aeca0..4554456 100644 > --- a/ffmpeg_filter.c > +++ b/ffmpeg_filter.c > @@ -39,6 +39,9 @@ > #include "libavutil/imgutils.h" > #include "libavutil/samplefmt.h" > > +int filter_nbthreads = -1; > +int filter_complex_nbthreads = -1; > + > static const enum AVPixelFormat *get_compliance_unofficial_pix_fmts(enum > AVCodecID codec_id, const enum AVPixelFormat default_formats[]) > { > static const enum AVPixelFormat mjpeg_formats[] = > @@ -309,6 +312,8 @@ int init_complex_filtergraph(FilterGraph *fg) > if (!graph) > return AVERROR(ENOMEM); > > +// As a temporary graph, don't bother making threads > +graph->nb_threads = 1; > ret = avfilter_graph_parse2(graph, fg->graph_desc, &inputs, &outputs); > if (ret < 0) > goto fail; > @@ -992,6 +997,8 @@ int configure_filtergraph(FilterGraph *fg) > char args[512]; > AVDictionaryEntry *e = NULL; > > +fg->graph->nb_threads = filter_complex_nbthreads; > + > args[0] = 0; > while ((e = av_dict_get(ost->sws_dict, "", e, > AV_DICT_IGNORE_SUFFIX))) { > @@ -1022,6 +1029,8 @@ int configure_filtergraph(FilterGraph *fg) > e = av_dict_get(ost->encoder_opts, "threads", NULL, 0); > if (e) > av_opt_set(fg->graph, "threads", e->value, 0); > +} else { > +fg->graph->nb_threads = filter_nbthreads; > } > > if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, > &outputs)) < 0) > diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c > index 4d25fff..dc94380 100644 > --- a/ffmpeg_opt.c > +++ b/ffmpeg_opt.c > @@ -3365,12 +3365,16 @@ const OptionDef options[] = { > "set profile", "profile" }, > { "filter", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { > .off = OFFSET(filters) }, > "set stream filtergraph", "filter_graph" }, > +{ "filter_threads", HAS_ARG | OPT_INT, { > &filter_nbthreads }, > +"number of non-complex filter threads" }, > { "filter_script", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { > .off = OFFSET(filter_scripts) }, > "read stream filtergraph description from a file", "filename" }, > { "reinit_filter", HAS_ARG | OPT_INT | OPT_SPEC | OPT_INPUT,{ > .off = OFFSET(reinit_filters) }, > "reinit filtergraph on input parameter changes", "" }, > { "filter_complex", HAS_ARG | OPT_EXPERT,{ > .func_arg = opt_filter_complex }, > "create a complex filtergraph", "graph_description" }, > +{ "filter_complex_threads", HAS_ARG | OPT_INT, { > &filter_complex_nbthreads }, > +"number of threads for -filter_complex" }, > { "lavfi", HAS_ARG | OPT_EXPERT,{ > .func_arg = opt_filter_complex }, > "create a complex filtergraph", "graph_description" }, > { "filter_complex_script", HAS_ARG | OPT_EXPERT, { > .func_arg = opt_filter_co
Re: [FFmpeg-devel] [PATCH] ffmpeg: parameters for filter thread counts
On 10/28/2016 10:30 AM, DHE wrote: > Enables specifying how many threads are available to each filtergraph. > --- > doc/ffmpeg.texi | 10 ++ > ffmpeg.h| 3 +++ > ffmpeg_filter.c | 9 + > ffmpeg_opt.c| 4 > 4 files changed, 26 insertions(+) > > diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi > index 47c8935..8be24b2 100644 > --- a/doc/ffmpeg.texi > +++ b/doc/ffmpeg.texi > @@ -415,6 +415,11 @@ This option is similar to @option{-filter}, the only > difference is that its > argument is the name of the file from which a filtergraph description is to > be > read. > > +@item -filter_threads @var{nb_thraeds} (@emph{global}) > +Defines how many threads are used to process a filter pipeline. > +Some filters support parallel processing. The default is the number of > available > +CPUs. > + > @item -pre[:@var{stream_specifier}] @var{preset_name} > (@emph{output,per-stream}) > Specify the preset for matching stream(s). > > @@ -1201,6 +1206,11 @@ To generate 5 seconds of pure red video using lavfi > @code{color} source: > ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv > @end example > > +@item -filter_complex_threads @var{nb_threads} (@emph{global}) > +Defines how many threads are used to process a @code{-filter_complex} > pipeline. > +Some filters support parallel processing. The default is the number of > available > +CPUs. > + > @item -lavfi @var{filtergraph} (@emph{global}) > Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or > outputs. Equivalent to @option{-filter_complex}. > diff --git a/ffmpeg.h b/ffmpeg.h > index e1d4593..9a4389f 100644 > --- a/ffmpeg.h > +++ b/ffmpeg.h > @@ -569,6 +569,9 @@ extern AVIOContext *progress_avio; > extern float max_error_rate; > extern char *videotoolbox_pixfmt; > > +extern int filter_nbthreads; > +extern int filter_complex_nbthreads; > + > extern const AVIOInterruptCB int_cb; > > extern const OptionDef options[]; > diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c > index 27aeca0..4554456 100644 > --- a/ffmpeg_filter.c > +++ b/ffmpeg_filter.c > @@ -39,6 +39,9 @@ > #include "libavutil/imgutils.h" > #include "libavutil/samplefmt.h" > > +int filter_nbthreads = -1; > +int filter_complex_nbthreads = -1; > + > static const enum AVPixelFormat *get_compliance_unofficial_pix_fmts(enum > AVCodecID codec_id, const enum AVPixelFormat default_formats[]) > { > static const enum AVPixelFormat mjpeg_formats[] = > @@ -309,6 +312,8 @@ int init_complex_filtergraph(FilterGraph *fg) > if (!graph) > return AVERROR(ENOMEM); > > +// As a temporary graph, don't bother making threads > +graph->nb_threads = 1; I just noticed, this hunk arguably doens't belong in this patch as it isn't directly related to the command-line parameters I added. I meant to split this into a different patch depending on how well this one was received. > ret = avfilter_graph_parse2(graph, fg->graph_desc, &inputs, &outputs); > if (ret < 0) > goto fail; > @@ -992,6 +997,8 @@ int configure_filtergraph(FilterGraph *fg) > char args[512]; > AVDictionaryEntry *e = NULL; > > +fg->graph->nb_threads = filter_complex_nbthreads; > + > args[0] = 0; > while ((e = av_dict_get(ost->sws_dict, "", e, > AV_DICT_IGNORE_SUFFIX))) { > @@ -1022,6 +1029,8 @@ int configure_filtergraph(FilterGraph *fg) > e = av_dict_get(ost->encoder_opts, "threads", NULL, 0); > if (e) > av_opt_set(fg->graph, "threads", e->value, 0); > +} else { > +fg->graph->nb_threads = filter_nbthreads; > } > > if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, > &outputs)) < 0) > diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c > index 4d25fff..dc94380 100644 > --- a/ffmpeg_opt.c > +++ b/ffmpeg_opt.c > @@ -3365,12 +3365,16 @@ const OptionDef options[] = { > "set profile", "profile" }, > { "filter", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off > = OFFSET(filters) }, > "set stream filtergraph", "filter_graph" }, > +{ "filter_threads", HAS_ARG | OPT_INT, { > &filter_nbthreads }, > +"number of non-complex filter threads" }, > { "filter_script", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off > = OFFSET(filter_scripts) }, > "read stream filtergraph description from a file", "filename" }, > { "reinit_filter", HAS_ARG | OPT_INT | OPT_SPEC | OPT_INPUT,{ .off > = OFFSET(reinit_filters) }, > "reinit filtergraph on input parameter changes", "" }, > { "filter_complex", HAS_ARG | OPT_EXPERT,{ > .func_arg = opt_filter_complex }, > "create a complex filtergraph", "graph_description" }, > +{ "filter_complex_threads", HAS_ARG | OPT_INT, { > &filter_complex_nbthreads }, > +"number of threads for -filter_complex" }, > { "lavf
Re: [FFmpeg-devel] [PATCH] crystalhd: Reorder mspeg4 decoder after software decoders
On Sat, 29 Oct 2016 00:59:23 +0200 Andreas Cadhalpun wrote: > On 28.10.2016 03:40, Philip Langdale wrote: > > This avoids it getting picked by default, which is generally > > undesirable and can break test runs. > > > > Signed-off-by: Philip Langdale > > --- > > libavcodec/allcodecs.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > > index b592aa3..594d104 100644 > > --- a/libavcodec/allcodecs.c > > +++ b/libavcodec/allcodecs.c > > @@ -261,10 +261,10 @@ void avcodec_register_all(void) > > REGISTER_DECODER(MPEG2_CRYSTALHD, mpeg2_crystalhd); > > REGISTER_DECODER(MPEG2_QSV, mpeg2_qsv); > > REGISTER_DECODER(MSA1, msa1); > > -REGISTER_DECODER(MSMPEG4_CRYSTALHD, msmpeg4_crystalhd); > > REGISTER_DECODER(MSMPEG4V1, msmpeg4v1); > > REGISTER_ENCDEC (MSMPEG4V2, msmpeg4v2); > > REGISTER_ENCDEC (MSMPEG4V3, msmpeg4v3); > > +REGISTER_DECODER(MSMPEG4_CRYSTALHD, msmpeg4_crystalhd); > > REGISTER_DECODER(MSRLE, msrle); > > REGISTER_DECODER(MSS1, mss1); > > REGISTER_DECODER(MSS2, mss2); > > > > LGTM. > > Best regards, > Andreas Pushed. Thanks. --phil ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel