[FFmpeg-devel] [PATCH] avformat/libsrt: remove url_get_file_handle implementation
SRTSOCKET is an abstraction designed by libsrt, it's not guaranteed to be a real file descriptor. Even if it is, it should not be operated directly outside of libsrt. --- libavformat/libsrt.c | 7 --- 1 file changed, 7 deletions(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index e5701625b8..9aeaa8eb40 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -706,12 +706,6 @@ static int libsrt_close(URLContext *h) return 0; } -static int libsrt_get_file_handle(URLContext *h) -{ -SRTContext *s = h->priv_data; -return s->fd; -} - static const AVClass libsrt_class = { .class_name = "libsrt", .item_name = av_default_item_name, @@ -725,7 +719,6 @@ const URLProtocol ff_libsrt_protocol = { .url_read= libsrt_read, .url_write = libsrt_write, .url_close = libsrt_close, -.url_get_file_handle = libsrt_get_file_handle, .priv_data_size = sizeof(SRTContext), .flags = URL_PROTOCOL_FLAG_NETWORK, .priv_data_class = &libsrt_class, -- 2.31.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avutils/hwcontext: When deriving a hwdevice, search for existing device in both directions
On Sat, 2021-08-07 at 01:46 +, Soft Works wrote: > The test /libavutil/tests/hwdevice checks that when deriving a device > from a source device and then deriving back to the type of the source > device, the result is matching the original source device, i.e. the > derivation mechanism doesn't create a new device in this case. > > Previously, this test was usually passed, but only due to two different > kind of flaws: > > 1. The test covers only a single level of derivation (and back) > > It derives device Y from device X and then Y back to the type of X and > checks whether the result matches X. > > What it doesn't check for, are longer chains of derivation like: > > CUDA1 > OpenCL2 > CUDA3 and then back to OpenCL4 > > In that case, the second derivation returns the first device (CUDA3 == > CUDA1), but when deriving OpenCL4, hwcontext.c was creating a new > OpenCL4 context instead of returning OpenCL2, because there was no link > from CUDA1 to OpenCL2 (only backwards from OpenCL2 to CUDA1) > > If the test would check for two levels of derivation, it would have > failed. > > This patch fixes those (yet untested) cases by introducing forward > references (derived_device) in addition to the existing back references > (source_device). > > 2. hwcontext_qsv didn't properly set the source_device > > In case of QSV, hwcontext_qsv creates a source context internally > (vaapi, dxva2 or d3d11va) without calling av_hwdevice_ctx_create_derived > and without setting source_device. > > This way, the hwcontext test ran successful, but what practically > happened, was that - for example - deriving vaapi from qsv didn't return > the original underlying vaapi device and a new one was created instead: > Exactly what the test is intended to detect and prevent. It just > couldn't do so, because the original device was hidden (= not set as the > source_device of the QSV device). > > This patch properly makes these setting and fixes all derivation > scenarios. > > (at a later stage, /libavutil/tests/hwdevice should be extended to check > longer derivation chains as well) > > Signed-off-by: softworkz > --- > libavutil/hwcontext.c | 16 > libavutil/hwcontext_internal.h | 6 ++ > libavutil/hwcontext_qsv.c | 7 ++- > 3 files changed, 28 insertions(+), 1 deletion(-) > > diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c > index d13d0f7c9b..3714ce7553 100644 > --- a/libavutil/hwcontext.c > +++ b/libavutil/hwcontext.c > @@ -132,6 +132,7 @@ static void hwdevice_ctx_free(void *opaque, uint8_t *data) > ctx->free(ctx); > > av_buffer_unref(&ctx->internal->source_device); > +av_buffer_unref(&ctx->internal->derived_device); > > av_freep(&ctx->hwctx); > av_freep(&ctx->internal->priv); > @@ -666,6 +667,20 @@ int av_hwdevice_ctx_create_derived_opts(AVBufferRef > **dst_ref_ptr, > tmp_ref = tmp_ctx->internal->source_device; > } > > +tmp_ref = src_ref; > +while (tmp_ref) { > +tmp_ctx = (AVHWDeviceContext*)tmp_ref->data; > +if (tmp_ctx->type == type) { > +dst_ref = av_buffer_ref(tmp_ref); > +if (!dst_ref) { > +ret = AVERROR(ENOMEM); > +goto fail; > +} > +goto done; > +} > +tmp_ref = tmp_ctx->internal->derived_device; > +} > + > dst_ref = av_hwdevice_ctx_alloc(type); > if (!dst_ref) { > ret = AVERROR(ENOMEM); > @@ -683,6 +698,7 @@ int av_hwdevice_ctx_create_derived_opts(AVBufferRef > **dst_ref_ptr, > flags); > if (ret == 0) { > dst_ctx->internal->source_device = av_buffer_ref(src_ref); > +tmp_ctx->internal->derived_device = av_buffer_ref(dst_ref); > if (!dst_ctx->internal->source_device) { Need to check tmp_ctx->internal->derived_device too. > ret = AVERROR(ENOMEM); > goto fail; > diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h > index e6266494ac..cfe525d20c 100644 > --- a/libavutil/hwcontext_internal.h > +++ b/libavutil/hwcontext_internal.h > @@ -109,6 +109,12 @@ struct AVHWDeviceInternal { > * context it was derived from. > */ > AVBufferRef *source_device; > + > +/** > + * A reference to a device context which > + * was derived from this device. > + */ > +AVBufferRef *derived_device; > }; > > struct AVHWFramesInternal { > diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c > index 08a6e0ee1c..27d96d116f 100644 > --- a/libavutil/hwcontext_qsv.c > +++ b/libavutil/hwcontext_qsv.c > @@ -1268,8 +1268,13 @@ static int qsv_device_create(AVHWDeviceContext *ctx, > const char *device, > child_device = (AVHWDeviceContext*)priv->child_device_ctx->data; > > impl = choose_implementation(device); > +ret = qsv_device_derive_from_child(ctx, impl
Re: [FFmpeg-devel] [PATCH v4 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time
Soft Works (12021-08-09): > Signed-off-by: softworkz > --- > v2: split commits differently, fix AVBPrint finalization > doc/APIchanges | 3 +++ > libavutil/log.c | 33 ++--- > libavutil/log.h | 10 ++ > libavutil/version.h | 2 +- > 4 files changed, 44 insertions(+), 4 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index 6eefc7fc33..be707314f3 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -14,6 +14,9 @@ libavutil: 2021-04-27 > > API changes, most recent first: > > +2021-08-09 - xx - lavu 57.4.100 - log.h > + Add new defines: AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME > + > 2021-08-02 - xx - lavc 59.4.100 - packet.h >Add AVPacket.opaque, AVPacket.opaque_ref, AVPacket.time_base. > > diff --git a/libavutil/log.c b/libavutil/log.c > index 66defa9c42..f29533a91f 100644 > --- a/libavutil/log.c > +++ b/libavutil/log.c > @@ -40,6 +40,8 @@ > #include "internal.h" > #include "log.h" > #include "thread.h" > +#include "time.h" > +#include "time_internal.h" > > static AVMutex mutex = AV_MUTEX_INITIALIZER; > > @@ -289,14 +291,32 @@ static const char *get_level_str(int level) > } > } > > +static void format_date_now(AVBPrint* timeBuf, int include_date) Pointer mark belongs with the variable, not with the type. Even if the surrounding code is wrong too. > +{ > +struct tm *ptm, tmbuf; > +int64_t time_us = av_gettime(); > +int64_t time_ms = time_us / 1000; You can merge these two lines, since time_us is used only there. > +const time_t time_s = time_ms / 1000; > +int millisec = time_ms - (time_s * 1000); Using % would probably be more easily optimized by compilers. > +ptm = localtime_r(&time_s, &tmbuf); > +if (ptm) { > +if (include_date) > +av_bprint_strftime(timeBuf, "%Y-%m-%d ", ptm); > + > +av_bprint_strftime(timeBuf, "%H:%M:%S", ptm); Are we ok printing a local time without a time zone? > +av_bprintf(timeBuf, ".%03d ", millisec); > +} > +} > + > static void format_line(void *avcl, int level, const char *fmt, va_list vl, > -AVBPrint part[4], int *print_prefix, int type[2]) > +AVBPrint part[5], int *print_prefix, int type[2]) > { > AVClass* avc = avcl ? *(AVClass **) avcl : NULL; > av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC); > av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC); > av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC); > av_bprint_init(part+3, 0, 65536); > +av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC); > > if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16; > if (*print_prefix && avc) { > @@ -314,6 +334,10 @@ static void format_line(void *avcl, int level, const > char *fmt, va_list vl, > if(type) type[1] = get_category(avcl); > } > > +if (*print_prefix > +&& ((flags & AV_LOG_PRINT_TIME) || (flags & AV_LOG_PRINT_DATETIME))) flags & (AV_LOG_PRINT_TIME | AV_LOG_PRINT_DATETIME) > +format_date_now(&part[4], flags & AV_LOG_PRINT_DATETIME); > + > if (*print_prefix && (level > AV_LOG_QUIET) && (flags & > AV_LOG_PRINT_LEVEL)) > av_bprintf(part+2, "[%s] ", get_level_str(level)); > > @@ -334,7 +358,7 @@ void av_log_format_line(void *ptr, int level, const char > *fmt, va_list vl, > int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, > char *line, int line_size, int *print_prefix) > { > -AVBPrint part[4]; > +AVBPrint part[5]; > int ret; > > format_line(ptr, level, fmt, vl, part, print_prefix, NULL); > @@ -348,7 +372,7 @@ void av_log_default_callback(void* ptr, int level, const > char* fmt, va_list vl) > static int print_prefix = 1; > static int count; > static char prev[LINE_SZ]; > -AVBPrint part[4]; > +AVBPrint part[5]; > char line[LINE_SZ]; > static int is_atty; > int type[2]; > @@ -383,6 +407,9 @@ void av_log_default_callback(void* ptr, int level, const > char* fmt, va_list vl) > count = 0; > } > strcpy(prev, line); > + > +sanitize(part[4].str); Not really necessary. > +colored_fputs(7, 0, part[4].str); > sanitize(part[0].str); > colored_fputs(type[0], 0, part[0].str); > sanitize(part[1].str); > diff --git a/libavutil/log.h b/libavutil/log.h > index 8727c38afc..27eb071884 100644 > --- a/libavutil/log.h > +++ b/libavutil/log.h > @@ -377,6 +377,16 @@ int av_log_format_line2(void *ptr, int level, const char > *fmt, va_list vl, > */ > #define AV_LOG_PRINT_LEVEL 2 > > +/** > + * Include system time in log output. "local time" > + */ > +#define AV_LOG_PRINT_TIME 4 > + > +/** > + * Include system date and time in log output. Ditto. > + */ > +#define AV_LOG_PRINT_DATETIME 8 > + > void av_log_set_flags(int arg); > int av_log_get_flags(void); > > diff --git a/libavutil/version.h b/libavu
Re: [FFmpeg-devel] [PATCH v2] avfilter: add QSV variants of the stack filters
On Sat, 2021-08-07 at 03:24 +, Soft Works wrote: > > -Original Message- > > From: ffmpeg-devel On Behalf Of > > Xiang, Haihao > > Sent: Friday, 6 August 2021 07:15 > > To: ffmpeg-devel@ffmpeg.org > > Subject: Re: [FFmpeg-devel] [PATCH v2] avfilter: add QSV variants of the > > stack filters > > > > On Thu, 2021-08-05 at 15:53 +, Soft Works wrote: > > > > -Original Message- > > > > From: ffmpeg-devel On Behalf Of > > > > Xiang, Haihao > > > > Sent: Thursday, 5 August 2021 04:33 > > > > To: ffmpeg-devel@ffmpeg.org > > > > Subject: Re: [FFmpeg-devel] [PATCH v2] avfilter: add QSV variants of > > > > the stack filters > > > > > > > > On Wed, 2021-08-04 at 09:17 +, Soft Works wrote: > > > > > > -Original Message- > > > > > > From: ffmpeg-devel On > > > > Behalf > > > > > > Of Haihao Xiang > > > > > > Sent: Wednesday, 4 August 2021 10:33 > > > > > > To: ffmpeg-devel@ffmpeg.org > > > > > > Cc: Haihao Xiang > > > > > > Subject: [FFmpeg-devel] [PATCH v2] avfilter: add QSV variants of > > > > > > the stack filters > > > > > > > > > > > > Include hstack_qsv, vstack_qsv and xstack_qsv, some code is copy > > > > > > and pasted from other filters > > > > > > > > > > > > Example: > > > > > > $> ffmpeg -hwaccel qsv -c:v hevc_qsv -i input.h265 > > > > > > -filter_complex "[0:v][0:v]hstack_qsv" -f null - > > > > > > --- > > > > > > > > > > [...] > > > > > > > > > > > + > > > > > > +/* > > > > > > + * Callback for qsvvpp > > > > > > + * @Note: qsvvpp composition does not generate PTS for result > > > > frame. > > > > > > + *so we assign the PTS from framesync to the output frame. > > > > > > + */ > > > > > > + > > > > > > +static int filter_callback(AVFilterLink *outlink, AVFrame *frame) { > > > > > > +QSVStackContext *sctx = outlink->src->priv; > > > > > > + > > > > > > +frame->pts = av_rescale_q(sctx->fs.pts, > > > > > > + sctx->fs.time_base, outlink- > > > > > > >time_base); > > > > > > +return ff_filter_frame(outlink, frame); } > > > > > > > > > > If the surface.Data.TimeStamp gets overwritten by libMFX, why not > > > > > copy the PTS from the input frame in ff_qsvvpp_filter_frame ? > > > > > > > > > > That would apply the timestamp from the last input, though. > > > > > Preferably would it be taken from the first input instead. For > > > > > 2-n, you could perhaps clone the frames and assign the pts from > > > > > the first input's frame? > > > > > > > > Thanks for the comment and suggestion. This callback function was > > > > copy- > > > > and- pasted from overlay_qsv filter because MSDK composition is also > > > > used by this filter, I'd like to use the same way to generate pts > > > > for these filters, but I'll try your suggestion for these filters in > > > > the future. > > > > > > Yea I see - the overlay_qsv filter does it the same way. This has > > > probably been ok earlier because the callback happened synchronously. > > > This is no longer the case since the async_depth patch which > > > introduced the fifo processing. Now it can happen that the calback is > > > performed for an earlier frame than the one that is currently gated by > > > framesync. > > > > async_depth is not enabled for overlay_qsv and stack qsv filters, s- > > > async_depth is 0, so the callback is still performed synchronously for > > > these > > > > filters. > > Yes I know. But with the newly added looping and read/write from the > fifos, I'm not sure whether it's always guaranteed that the callback will be > called for the submitted frame or whether it could happen that there's > another out_frame left in the fifo. I think it is guaranteed because there is at most 1 qsv fifo item in the fifo for these filters. > > Another detail that doesn't look solid to me is the acquisition of the > out_frame > in cases when composition is used, i.e. ff_qsvvpp_filter_frame is called > multiple times for the same output frame: > > - When VPP returns MFX_ERR_MORE_DATA (awaiting another input for > overlay), we return without caring about the out_frame (no storing, no > increasing of the queued property) > - Instead, each time, the out_frame is queried again via query_frame > The code doesn't really make sure that it operates on the same frame > for output, this seems more like a coincidence at the current state > (probably only the check for surface->Data->Locked in clear_unused_frames > is preventing the output frame from being cleared meanwhile) > > I think there's some room for improvement at least.. Agree. According to the pseudo code in https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#example-4-video-processing-pseudo-code , we should reuse out_frame for MFX_ERR_MORE_DATA. I think it is better to improve ff_qsvvpp_filter_frame() in another patch and this patch focuses on the new filters. Thanks Haihao ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org
Re: [FFmpeg-devel] [PATCH 07/10] sws: add a new scaling API
Quoting James Almer (2021-08-09 05:45:09) > On 8/8/2021 2:29 PM, Anton Khirnov wrote: > > +int sws_frame_start(struct SwsContext *c, AVFrame *dst, const AVFrame *src) > > +{ > > +int ret, allocated = 0; > > + > > +ret = av_frame_ref(c->frame_src, src); > > +if (ret < 0) > > +return ret; > > + > > +if (!dst->buf[0]) { > > The frame could have non refcounted buffers, and av_frame_get_buffer() > below would overwrite the data pointers. > IMO, just state in the doxy that if already allocated, the data buffers > must be reference counted. Ok, will do. I don't think there's any reason to support non-refcounted frames anymore. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avfilter: add (a)segment filters
Paul B Mahol (12021-08-02): > Signed-off-by: Paul B Mahol > --- > doc/filters.texi | 31 > libavfilter/Makefile | 2 + > libavfilter/allfilters.c | 2 + > libavfilter/f_segment.c | 328 +++ > 4 files changed, 363 insertions(+) > create mode 100644 libavfilter/f_segment.c > > diff --git a/doc/filters.texi b/doc/filters.texi > index 66c0f87e47..fa72eeed8b 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -25659,6 +25659,37 @@ A processing speed faster than what is possible > without these filters cannot > be achieved. > @end table > > +@section segment, asegment > + > +Split single input stream into multiple streams. Please add: "This filter does the opposite of concat." The idea is to make sure the documentation contains as many key words as possible so that users will find what they are looking for even if they do not think with the same words as us. > + > +@code{segment} works on video frames, @code{asegment} on audio samples. > + > +This filter accepts the following options: > + > +@table @option > +@item durations > +Durations of input at which to split input. Each duration point is split by > '|'. "Durations of the segments output segments, separated by '|'. The first segment will run from the beginning of the input stream. The last segment will run until the end of the input stream." But the code is inconsistent with this: it uses timestamps, not durations. That need to be fixed: see below. > + > +@item frames, samples > +Exact frame/sample at which to do separations of input video/audio stream. > Each point > +is split by '|'. "Exact frame/sample count to split the segments." > +@end table > + > +@subsection Examples > + > +@itemize > + > +@item > +Split input audio stream into three output audio streams, starting at start > of input audio stream > +and storing that in 1st output audio stream, then following at 60th second > and storing than in 2nd > +output audio stream, and last after 120th second of input audio stream store > in 3rd output audio stream: > +@example > +asegment=durations="60 | 120" > +@end example > + > +@end itemize > + > @anchor{select} > @section select, aselect > > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index 49c0c8342b..102ce7beff 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -78,6 +78,7 @@ OBJS-$(CONFIG_AREALTIME_FILTER) += f_realtime.o > OBJS-$(CONFIG_ARESAMPLE_FILTER) += af_aresample.o > OBJS-$(CONFIG_AREVERSE_FILTER) += f_reverse.o > OBJS-$(CONFIG_ARNNDN_FILTER) += af_arnndn.o > +OBJS-$(CONFIG_ASEGMENT_FILTER) += f_segment.o > OBJS-$(CONFIG_ASELECT_FILTER)+= f_select.o > OBJS-$(CONFIG_ASENDCMD_FILTER) += f_sendcmd.o > OBJS-$(CONFIG_ASETNSAMPLES_FILTER) += af_asetnsamples.o > @@ -404,6 +405,7 @@ OBJS-$(CONFIG_SCALE_VULKAN_FILTER) += > vf_scale_vulkan.o vulkan.o > OBJS-$(CONFIG_SCALE2REF_FILTER) += vf_scale.o scale_eval.o > OBJS-$(CONFIG_SCDET_FILTER) += vf_scdet.o > OBJS-$(CONFIG_SCROLL_FILTER) += vf_scroll.o > +OBJS-$(CONFIG_SEGMENT_FILTER)+= f_segment.o > OBJS-$(CONFIG_SELECT_FILTER) += f_select.o > OBJS-$(CONFIG_SELECTIVECOLOR_FILTER) += vf_selectivecolor.o > OBJS-$(CONFIG_SENDCMD_FILTER)+= f_sendcmd.o > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c > index ae74f9c891..73040d2824 100644 > --- a/libavfilter/allfilters.c > +++ b/libavfilter/allfilters.c > @@ -71,6 +71,7 @@ extern const AVFilter ff_af_arealtime; > extern const AVFilter ff_af_aresample; > extern const AVFilter ff_af_areverse; > extern const AVFilter ff_af_arnndn; > +extern const AVFilter ff_af_asegment; > extern const AVFilter ff_af_aselect; > extern const AVFilter ff_af_asendcmd; > extern const AVFilter ff_af_asetnsamples; > @@ -385,6 +386,7 @@ extern const AVFilter ff_vf_scale_vulkan; > extern const AVFilter ff_vf_scale2ref; > extern const AVFilter ff_vf_scdet; > extern const AVFilter ff_vf_scroll; > +extern const AVFilter ff_vf_segment; > extern const AVFilter ff_vf_select; > extern const AVFilter ff_vf_selectivecolor; > extern const AVFilter ff_vf_sendcmd; > diff --git a/libavfilter/f_segment.c b/libavfilter/f_segment.c > new file mode 100644 > index 00..aecadc8224 > --- /dev/null > +++ b/libavfilter/f_segment.c > @@ -0,0 +1,328 @@ > +/* > + * 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 > + * MERCHANTABIL
Re: [FFmpeg-devel] [PATCH v3 9/9] [GSoC] lavfi/dnn: DNNAsyncExecModule Execution Failure Handling
> -Original Message- > From: ffmpeg-devel On Behalf Of > Shubhanshu Saxena > Sent: 2021年8月8日 18:56 > To: ffmpeg-devel@ffmpeg.org > Cc: Shubhanshu Saxena > Subject: [FFmpeg-devel] [PATCH v3 9/9] [GSoC] lavfi/dnn: > DNNAsyncExecModule Execution Failure Handling > > This commit adds the case handling if the asynchronous execution of a request > fails by checking the exit status of the thread when joining before starting > another execution. On failure, it does the cleanup as well. > > Signed-off-by: Shubhanshu Saxena > --- > libavfilter/dnn/dnn_backend_common.c | 23 +++ > libavfilter/dnn/dnn_backend_tf.c | 10 +- > 2 files changed, 28 insertions(+), 5 deletions(-) > > diff --git a/libavfilter/dnn/dnn_backend_common.c > b/libavfilter/dnn/dnn_backend_common.c > index 470fffa2ae..426683b73d 100644 > --- a/libavfilter/dnn/dnn_backend_common.c > +++ b/libavfilter/dnn/dnn_backend_common.c > @@ -23,6 +23,9 @@ > > #include "dnn_backend_common.h" > > +#define DNN_ASYNC_SUCCESS (void *)0 > +#define DNN_ASYNC_FAIL (void *)-1 > + > int ff_check_exec_params(void *ctx, DNNBackendType backend, > DNNFunctionType func_type, DNNExecBaseParams *exec_params) { > if (!exec_params) { > @@ -79,18 +82,25 @@ static void *async_thread_routine(void *args) > DNNAsyncExecModule *async_module = args; > void *request = async_module->args; > > -async_module->start_inference(request); > +if (async_module->start_inference(request) != DNN_SUCCESS) { > +return DNN_ASYNC_FAIL; > +} > async_module->callback(request); > -return NULL; > +return DNN_ASYNC_SUCCESS; > } > > DNNReturnType ff_dnn_async_module_cleanup(DNNAsyncExecModule > *async_module) { > +void *status = 0; > if (!async_module) { > return DNN_ERROR; > } > #if HAVE_PTHREAD_CANCEL > -pthread_join(async_module->thread_id, NULL); > +pthread_join(async_module->thread_id, &status); > +if (status == DNN_ASYNC_FAIL) { > +av_log(NULL, AV_LOG_ERROR, "Last Inference Failed.\n"); > +return DNN_ERROR; > +} > #endif > async_module->start_inference = NULL; > async_module->callback = NULL; > @@ -101,6 +111,7 @@ DNNReturnType > ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module) > DNNReturnType ff_dnn_start_inference_async(void *ctx, > DNNAsyncExecModule *async_module) { > int ret; > +void *status = 0; > > if (!async_module) { > av_log(ctx, AV_LOG_ERROR, "async_module is null when starting async > inference.\n"); @@ -108,7 +119,11 @@ DNNReturnType > ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_ > } > > #if HAVE_PTHREAD_CANCEL > -pthread_join(async_module->thread_id, NULL); > +pthread_join(async_module->thread_id, &status); > +if (status == DNN_ASYNC_FAIL) { > +av_log(ctx, AV_LOG_ERROR, "Unable to start inference as previous > inference failed.\n"); > +return DNN_ERROR; > +} > ret = pthread_create(&async_module->thread_id, NULL, > async_thread_routine, async_module); > if (ret != 0) { > av_log(ctx, AV_LOG_ERROR, "Unable to start async inference.\n"); > diff --git > a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c > index fb3f6f5ea6..ffec1b1328 100644 > --- a/libavfilter/dnn/dnn_backend_tf.c > +++ b/libavfilter/dnn/dnn_backend_tf.c > @@ -91,6 +91,7 @@ AVFILTER_DEFINE_CLASS(dnn_tensorflow); > > static DNNReturnType execute_model_tf(TFRequestItem *request, Queue > *inference_queue); static void infer_completion_callback(void *args); > +static inline void destroy_request_item(TFRequestItem **arg); > > static void free_buffer(void *data, size_t length) { @@ -172,6 +173,10 @@ > static DNNReturnType tf_start_inference(void *args) >request->status); > if (TF_GetCode(request->status) != TF_OK) { > av_log(&tf_model->ctx, AV_LOG_ERROR, "%s", TF_Message(request- > >status)); > +tf_free_request(infer_request); > +if (ff_safe_queue_push_back(tf_model->request_queue, request) < 0) { > +destroy_request_item(&request); > +} > return DNN_ERROR; > } > return DNN_SUCCESS; > @@ -1095,7 +1100,10 @@ static DNNReturnType > execute_model_tf(TFRequestItem *request, Queue *inference_q > } > > if (task->async) { > -return ff_dnn_start_inference_async(ctx, &request->exec_module); > +if (ff_dnn_start_inference_async(ctx, &request->exec_module) != > DNN_SUCCESS) { > +goto err; > +} > +return DNN_SUCCESS; > } else { > if (tf_start_inference(request) != DNN_SUCCESS) { > goto err; > -- > 2.25.1 LGTM, those patches function well and tensorflow backend performs much better. > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit l
[FFmpeg-devel] [PATCH 2/2] FATE: add tests for v360/ssim360 filters
--- libavfilter/Makefile | 3 +- tests/Makefile | 4 +- tests/fate-run.sh | 6 + tests/fate/filter-video.mak| 14 ++ tests/ref/fate/filter-spherical-barrel | 192 + tests/ref/fate/filter-spherical-c3x2 | 192 + tools/Makefile | 1 + tools/spherical_compare.c | 148 +++ 8 files changed, 558 insertions(+), 2 deletions(-) create mode 100644 tests/ref/fate/filter-spherical-barrel create mode 100644 tests/ref/fate/filter-spherical-c3x2 create mode 100644 tools/spherical_compare.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index b0348ccfa3..27dd0c4b47 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -559,7 +559,8 @@ SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h OBJS-$(CONFIG_LIBGLSLANG)+= glslang.o -TOOLS = graph2dot +TOOLS = graph2dot \ +spherical_compare TESTPROGS = drawutils filtfmts formats integral TOOLS-$(CONFIG_LIBZMQ) += zmqsend diff --git a/tests/Makefile b/tests/Makefile index e42e66d81b..aba31b59d0 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -208,7 +208,8 @@ FATE_EXTERN-$(CONFIG_FFMPEG) += $(FATE_SAMPLES_AVCONV) $(FATE_SAMPLES_FFMPEG) FATE_EXTERN-$(CONFIG_FFPROBE) += $(FATE_SAMPLES_FFPROBE) FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_SAMPLES_FFMPEG_FFPROBE-yes) FATE_EXTERN-$(call ALLYES, FFMPEG FFPROBE) += $(FATE_SAMPLES_FFMPEG_FFPROBE) -FATE_EXTERN += $(FATE_EXTERN-yes) $(FATE_SAMPLES_FASTSTART) +FATE_EXTERN += $(FATE_EXTERN-yes) $(FATE_SAMPLES_FASTSTART) \ + $(FATE_SAMPLES_SPHERICAL_COMPARE) FATE += $(FATE-yes) @@ -222,6 +223,7 @@ $(FATE_FFPROBE) $(FATE_FFMPEG_FFPROBE) $(FATE_SAMPLES_FFPROBE) $(FATE_SAMPLES_FF $(FATE_SAMPLES_FASTSTART): tools/qt-faststart$(EXESUF) $(FATE_SAMPLES_DUMP_DATA): tools/venc_data_dump$(EXESUF) $(FATE_SAMPLES_SCALE_SLICE): tools/scale_slice_test$(EXESUF) +$(FATE_SAMPLES_SPHERICAL_COMPARE): tools/spherical_compare$(EXESUF) ifdef SAMPLES FATE += $(FATE_EXTERN) diff --git a/tests/fate-run.sh b/tests/fate-run.sh index cd16f5fcff..afdbb4d2ec 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -507,6 +507,12 @@ venc_data(){ run tools/venc_data_dump${EXECSUF} ${file} ${stream} ${frames} ${threads} ${thread_type} } +spherical_compare(){ +file=$1 +filterchain=$2 +run tools/spherical_compare${EXECSUF} ${file} ${filterchain} +} + null(){ : } diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 16f24a8422..a28c3f7aec 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -845,6 +845,20 @@ FATE_FILTER_SAMPLES-$(call ALLYES, MOV_DEMUXER H264_DECODER AAC_FIXED_DECODER PC fate-filter-meta-4560-rotate0: tests/data/file4560-override2rotate0.mov fate-filter-meta-4560-rotate0: CMD = framecrc -auto_conversion_filters -flags +bitexact -c:a aac_fixed -i $(TARGET_PATH)/tests/data/file4560-override2rotate0.mov +SPHERICAL_DEPS = MATROSKA_DEMUXER VP8_DECODER V360_FILTER SSIM360_FILTER +SPHERICAL_SAMPLE = $(TARGET_SAMPLES)/spherical/Worlds_First_Live_360_Rocket_Launch-_Orbital_ATK_CRS-7_cut.mkv + +FATE_FILTER_SPHERICAL += fate-filter-spherical-c3x2 +fate-filter-spherical-c3x2: CMD = spherical_compare $(SPHERICAL_SAMPLE) \ + "split[in][ref];[in]v360=input=e:output=c3x2[main];[main][ref]ssim360=main_projection=c3x2:ref_projection=e" + +FATE_FILTER_SPHERICAL += fate-filter-spherical-barrel +fate-filter-spherical-barrel: CMD = spherical_compare $(SPHERICAL_SAMPLE) \ + "split[in][ref];[in]v360=input=e:output=barrel[main];[main][ref]ssim360=main_projection=barrel:ref_projection=e" + +FATE_SAMPLES_SPHERICAL_COMPARE-$(call ALLYES, $(SPHERICAL_DEPS)) += $(FATE_FILTER_SPHERICAL) +FATE_SAMPLES_SPHERICAL_COMPARE += $(FATE_SAMPLES_SPHERICAL_COMPARE-yes) + REFCMP_DEPS = FFMPEG LAVFI_INDEV TESTSRC2_FILTER AVGBLUR_FILTER METADATA_FILTER FATE_FILTER-$(call ALLYES, $(REFCMP_DEPS) PSNR_FILTER) += fate-filter-refcmp-psnr-rgb diff --git a/tests/ref/fate/filter-spherical-barrel b/tests/ref/fate/filter-spherical-barrel new file mode 100644 index 00..a2ff075a26 --- /dev/null +++ b/tests/ref/fate/filter-spherical-barrel @@ -0,0 +1,192 @@ +frame 0 +lavfi.ssim360.Y=0.97 +lavfi.ssim360.U=1.00 +lavfi.ssim360.V=1.00 +lavfi.ssim360.All=1.00 +lavfi.ssim360.dB=25.19 +frame 1 +lavfi.ssim360.Y=0.97 +lavfi.ssim360.U=1.00 +lavfi.ssim360.V=1.00 +lavfi.ssim360.All=1.00 +lavfi.ssim360.dB=25.04 +frame 2 +lavfi.ssim360.Y=0.97 +lavfi.ssim360.U=1.00 +lavfi.ssim360.V=1.00 +lavfi.ssim360.All=1.00 +lavfi.ssim360.dB=24.95 +frame 3 +lavfi.ssim360.Y=0.97 +lavfi.ssim360.U=1.00 +lavfi.ssim360.V=1.00 +lavfi.ssim360.All=1.00 +lavfi.ssim360.dB=24.88 +frame 4 +lavfi.ssim360.Y=0.97 +lavfi.ssim360.U=1.00 +lavfi.ssim360.V=1.00 +la
[FFmpeg-devel] [PATCH 1/2] lavfi: Add vf_ssim360 filter
From: Shannon Chen Customized SSIM for various projections (and stereo formats) of 360 images and videos. Further contributions by: Ashok Mathew Kuruvilla Matthieu Patou Yu-Hui Wu Anton Khirnov Suggested-By: ffm...@fb.com Signed-off-by: Anton Khirnov --- Changelog|1 + libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/version.h|4 +- libavfilter/vf_ssim360.c | 1762 ++ 5 files changed, 1767 insertions(+), 2 deletions(-) create mode 100644 libavfilter/vf_ssim360.c diff --git a/Changelog b/Changelog index 1037688682..56791ba26d 100644 --- a/Changelog +++ b/Changelog @@ -9,6 +9,7 @@ version : - Argonaut Games CVG muxer - Concatf protocol - afwtdn audio filter +- ssim360 video filter version 4.4: diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 49c0c8342b..b0348ccfa3 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -433,6 +433,7 @@ OBJS-$(CONFIG_SPLIT_FILTER) += split.o OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o qp_table.o OBJS-$(CONFIG_SR_FILTER) += vf_sr.o OBJS-$(CONFIG_SSIM_FILTER) += vf_ssim.o framesync.o +OBJS-$(CONFIG_SSIM360_FILTER)+= vf_ssim360.o framesync.o OBJS-$(CONFIG_STEREO3D_FILTER) += vf_stereo3d.o OBJS-$(CONFIG_STREAMSELECT_FILTER) += f_streamselect.o framesync.o OBJS-$(CONFIG_SUBTITLES_FILTER) += vf_subtitles.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index ae74f9c891..76863c9ea1 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -413,6 +413,7 @@ extern const AVFilter ff_vf_split; extern const AVFilter ff_vf_spp; extern const AVFilter ff_vf_sr; extern const AVFilter ff_vf_ssim; +extern const AVFilter ff_vf_ssim360; extern const AVFilter ff_vf_stereo3d; extern const AVFilter ff_vf_streamselect; extern const AVFilter ff_vf_subtitles; diff --git a/libavfilter/version.h b/libavfilter/version.h index 75cd10dccd..67f2a5883c 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -30,8 +30,8 @@ #include "libavutil/version.h" #define LIBAVFILTER_VERSION_MAJOR 8 -#define LIBAVFILTER_VERSION_MINOR 1 -#define LIBAVFILTER_VERSION_MICRO 103 +#define LIBAVFILTER_VERSION_MINOR 2 +#define LIBAVFILTER_VERSION_MICRO 100 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vf_ssim360.c b/libavfilter/vf_ssim360.c new file mode 100644 index 00..1e6216c630 --- /dev/null +++ b/libavfilter/vf_ssim360.c @@ -0,0 +1,1762 @@ +/** + * Copyright (c) 2015-2021, Facebook, Inc. + * All rights reserved. + * + * 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 + */ + +/* Computes the Structural Similarity Metric between two 360 video streams. + * original SSIM algorithm: + * Z. Wang, A. C. Bovik, H. R. Sheikh and E. P. Simoncelli, + * "Image quality assessment: From error visibility to structural similarity," + * IEEE Transactions on Image Processing, vol. 13, no. 4, pp. 600-612, Apr. 2004. + * + * To improve speed, this implementation uses the standard approximation of + * overlapped 8x8 block sums, rather than the original gaussian weights. + * + * To address warping from 360 projections for videos with same + * projection and resolution, the 8x8 blocks sampled are weighted by + * their location in the image. + * + * To apply SSIM across projections and video sizes, we render the video on to + * a flat "tape" from which the 8x8 are selected and compared. + */ + +/* + * @file + * Caculate the SSIM between two input 360 videos. + */ + +#include "libavutil/avstring.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "avfilter.h" +#include "drawutils.h" +#include "formats.h" +#include "internal.h" +#include "video.h" +#include "framesync.h" +#include + +#define RIGHT 0 +#define LEFT1 +#define TOP 2 +#define BOTTOM 3 +#define FRONT 4 +#define BACK5 + +#define DEFAULT_HEATMAP_W 32 +#define DEFAULT_HEATMAP_H 16 + +#define M_PI_F ((float)M_PI) +#define M_PI_2_F ((float)M_PI_2) +#define M_PI_4_F ((float)M_PI_4) +#define M_SQRT2_F ((float)M_SQRT2) + +#define DEFAULT_EXPANSION_COEF 1.01f + +sta
[FFmpeg-devel] [PATCH] mxf : allow using codecs RAWVIDEO and V210 (with more rgb format and correct stored width/height)
* Let older tags on the same place as originally * Add new fate tests for rawvideo and v210 and update checksum for mxf tests * Add more rgb format (to allow r210 raw format) * Correct stored width and height when rawvideo or v210 encoder are used --- libavformat/mxf.c | 19 +++ libavformat/mxf.h | 1 + libavformat/mxfenc.c| 188 +++- tests/fate/lavf-container.mak | 7 + tests/ref/fate/copy-trac4914| 2 +- tests/ref/fate/mxf-d10-user-comments| 2 +- tests/ref/fate/mxf-opatom-user-comments | 2 +- tests/ref/fate/mxf-reel_name| 2 +- tests/ref/fate/mxf-user-comments| 2 +- tests/ref/fate/time_base| 2 +- tests/ref/lavf/mxf | 6 +- tests/ref/lavf/mxf_d10 | 2 +- tests/ref/lavf/mxf_dv25 | 2 +- tests/ref/lavf/mxf_dvcpro50 | 2 +- tests/ref/lavf/mxf_opatom | 2 +- tests/ref/lavf/mxf_opatom_audio | 2 +- tests/ref/lavf/mxf_rawvideo_uyvy422 | 3 + tests/ref/lavf/mxf_rawvideo_yuv420p | 3 + tests/ref/lavf/mxf_rawvideo_yuv422p | 3 + tests/ref/lavf/mxf_rawvideo_yuyv422 | 3 + tests/ref/lavf/mxf_v210 | 3 + 21 files changed, 204 insertions(+), 54 deletions(-) create mode 100644 tests/ref/lavf/mxf_rawvideo_uyvy422 create mode 100644 tests/ref/lavf/mxf_rawvideo_yuv420p create mode 100644 tests/ref/lavf/mxf_rawvideo_yuv422p create mode 100644 tests/ref/lavf/mxf_rawvideo_yuyv422 create mode 100644 tests/ref/lavf/mxf_v210 diff --git a/libavformat/mxf.c b/libavformat/mxf.c index 36d662b58c..748214a64f 100644 --- a/libavformat/mxf.c +++ b/libavformat/mxf.c @@ -81,6 +81,8 @@ const MXFCodecUL ff_mxf_codec_uls[] = { const MXFCodecUL ff_mxf_pixel_format_uls[] = { { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x01,0x01 }, 16, AV_PIX_FMT_UYVY422 }, { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x01,0x02 }, 16, AV_PIX_FMT_YUYV422 }, +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x01,0x03 }, 16, AV_PIX_FMT_YUV422P }, +{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x03,0x01,0x02 }, 16, AV_PIX_FMT_YUV420P }, { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,AV_PIX_FMT_NONE }, }; @@ -165,6 +167,8 @@ static const struct { {AV_PIX_FMT_RGBA,{'R', 8, 'G', 8, 'B', 8, 'A', 8 }}, {AV_PIX_FMT_PAL8,{'P', 8 }}, {AV_PIX_FMT_GRAY8, {'A', 8 }}, +{AV_PIX_FMT_GBRP10BE,{'F', 2, 'R', 10, 'G', 10, 'B', 10 }}, +{AV_PIX_FMT_GBRP10LE,{'F', 2, 'r', 10, 'g', 10, 'b', 10 }}, }; static const int num_pixel_layouts = FF_ARRAY_ELEMS(ff_mxf_pixel_layouts); @@ -183,6 +187,21 @@ int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat * return -1; } +int ff_mxf_find_pixel_layout(const char** pixel_layout, const enum AVPixelFormat pix_fmt) +{ +int x; +*pixel_layout = NULL; + +for(x = 0; x < num_pixel_layouts; x++) { +if(ff_mxf_pixel_layouts[x].pix_fmt == pix_fmt) { +*pixel_layout = ff_mxf_pixel_layouts[x].data; +return 0; +} +} + +return -1; +} + /** * See SMPTE 326M-2000 Section 7.2 Content package rate * MXFContentPackageRate->rate is bits b5..b0. diff --git a/libavformat/mxf.h b/libavformat/mxf.h index fe9c52732c..fa4a4eb0d2 100644 --- a/libavformat/mxf.h +++ b/libavformat/mxf.h @@ -114,6 +114,7 @@ extern const MXFCodecUL ff_mxf_color_trc_uls[]; extern const MXFCodecUL ff_mxf_color_space_uls[]; int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat *pix_fmt); +int ff_mxf_find_pixel_layout(const char** pixel_layout, const enum AVPixelFormat pix_fmt); int ff_mxf_get_content_package_rate(AVRational time_base); diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 5ec619675b..8b7f463ef8 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -127,6 +127,8 @@ enum ULIndex { INDEX_H264, INDEX_S436M, INDEX_PRORES, +INDEX_RAWVIDEO, +INDEX_V210 }; static const struct { @@ -141,6 +143,8 @@ static const struct { { AV_CODEC_ID_JPEG2000, INDEX_JPEG2000 }, { AV_CODEC_ID_H264, INDEX_H264 }, { AV_CODEC_ID_PRORES, INDEX_PRORES }, +{ AV_CODEC_ID_RAWVIDEO, INDEX_RAWVIDEO }, +{ AV_CODEC_ID_V210, INDEX_V210 }, { AV_CODEC_ID_NONE } }; @@ -148,6 +152,7 @@ static void mxf_write_wav_desc(AVFormatContext *s, AVStream *st); static void mxf_write_aes3_desc(AVFormatContext *s, AVStream *st); static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st); static void mxf_write_h264_desc(AVFormatConte
Re: [FFmpeg-devel] [PATCH 1/2] lavfi: Add vf_ssim360 filter
Anton Khirnov (12021-08-09): > +heatmap_file = av_fopen_utf8(s->heatmap_path, "r"); > +if (!heatmap_file) { > +av_log(ctx, AV_LOG_ERROR, "cannot open heatmap file %s\n", > s->heatmap_path); > +return AVERROR(EINVAL); > +} > +ret = load_heatmaps(&s->heatmaps, heatmap_file, > +s->default_heatmap_w, s->default_heatmap_h); > +if (ret < 0) > +return ret; I cannot comment much, but I notice you might be leaking heatmap_file. Why do you do this with a test in each activate() rather than in init() or one of the config_props()? Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 9/9] [GSoC] lavfi/dnn: DNNAsyncExecModule Execution Failure Handling
> -Original Message- > From: ffmpeg-devel On Behalf Of Fu, > Ting > Sent: 2021年8月9日 18:13 > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH v3 9/9] [GSoC] lavfi/dnn: > DNNAsyncExecModule Execution Failure Handling > > > > > -Original Message- > > From: ffmpeg-devel On Behalf Of > > Shubhanshu Saxena > > Sent: 2021年8月8日 18:56 > > To: ffmpeg-devel@ffmpeg.org > > Cc: Shubhanshu Saxena > > Subject: [FFmpeg-devel] [PATCH v3 9/9] [GSoC] lavfi/dnn: > > DNNAsyncExecModule Execution Failure Handling > > > > This commit adds the case handling if the asynchronous execution of a > > request fails by checking the exit status of the thread when joining > > before starting another execution. On failure, it does the cleanup as well. > > > > Signed-off-by: Shubhanshu Saxena > > --- > > libavfilter/dnn/dnn_backend_common.c | 23 +++ > > libavfilter/dnn/dnn_backend_tf.c | 10 +- > > 2 files changed, 28 insertions(+), 5 deletions(-) > > > > diff --git a/libavfilter/dnn/dnn_backend_common.c > > b/libavfilter/dnn/dnn_backend_common.c > > index 470fffa2ae..426683b73d 100644 > > --- a/libavfilter/dnn/dnn_backend_common.c > > +++ b/libavfilter/dnn/dnn_backend_common.c > > @@ -23,6 +23,9 @@ > > > > #include "dnn_backend_common.h" > > > > +#define DNN_ASYNC_SUCCESS (void *)0 > > +#define DNN_ASYNC_FAIL (void *)-1 > > + > > int ff_check_exec_params(void *ctx, DNNBackendType backend, > > DNNFunctionType func_type, DNNExecBaseParams *exec_params) { > > if (!exec_params) { > > @@ -79,18 +82,25 @@ static void *async_thread_routine(void *args) > > DNNAsyncExecModule *async_module = args; > > void *request = async_module->args; > > > > -async_module->start_inference(request); > > +if (async_module->start_inference(request) != DNN_SUCCESS) { > > +return DNN_ASYNC_FAIL; > > +} > > async_module->callback(request); > > -return NULL; > > +return DNN_ASYNC_SUCCESS; > > } > > > > DNNReturnType ff_dnn_async_module_cleanup(DNNAsyncExecModule > > *async_module) { > > +void *status = 0; > > if (!async_module) { > > return DNN_ERROR; > > } > > #if HAVE_PTHREAD_CANCEL > > -pthread_join(async_module->thread_id, NULL); > > +pthread_join(async_module->thread_id, &status); > > +if (status == DNN_ASYNC_FAIL) { > > +av_log(NULL, AV_LOG_ERROR, "Last Inference Failed.\n"); > > +return DNN_ERROR; > > +} > > #endif > > async_module->start_inference = NULL; > > async_module->callback = NULL; > > @@ -101,6 +111,7 @@ DNNReturnType > > ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module) > > DNNReturnType ff_dnn_start_inference_async(void *ctx, > > DNNAsyncExecModule *async_module) { > > int ret; > > +void *status = 0; > > > > if (!async_module) { > > av_log(ctx, AV_LOG_ERROR, "async_module is null when starting > > async inference.\n"); @@ -108,7 +119,11 @@ DNNReturnType > > ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_ > > } > > > > #if HAVE_PTHREAD_CANCEL > > -pthread_join(async_module->thread_id, NULL); > > +pthread_join(async_module->thread_id, &status); > > +if (status == DNN_ASYNC_FAIL) { > > +av_log(ctx, AV_LOG_ERROR, "Unable to start inference as > > + previous > > inference failed.\n"); > > +return DNN_ERROR; > > +} > > ret = pthread_create(&async_module->thread_id, NULL, > > async_thread_routine, async_module); > > if (ret != 0) { > > av_log(ctx, AV_LOG_ERROR, "Unable to start async > > inference.\n"); diff --git a/libavfilter/dnn/dnn_backend_tf.c > > b/libavfilter/dnn/dnn_backend_tf.c > > index fb3f6f5ea6..ffec1b1328 100644 > > --- a/libavfilter/dnn/dnn_backend_tf.c > > +++ b/libavfilter/dnn/dnn_backend_tf.c > > @@ -91,6 +91,7 @@ AVFILTER_DEFINE_CLASS(dnn_tensorflow); > > > > static DNNReturnType execute_model_tf(TFRequestItem *request, > Queue > > *inference_queue); static void infer_completion_callback(void *args); > > +static inline void destroy_request_item(TFRequestItem **arg); > > > > static void free_buffer(void *data, size_t length) { @@ -172,6 > > +173,10 @@ static DNNReturnType tf_start_inference(void *args) > >request->status); > > if (TF_GetCode(request->status) != TF_OK) { > > av_log(&tf_model->ctx, AV_LOG_ERROR, "%s", > > TF_Message(request- > > >status)); > > +tf_free_request(infer_request); > > +if (ff_safe_queue_push_back(tf_model->request_queue, request) < > 0) { > > +destroy_request_item(&request); > > +} > > return DNN_ERROR; > > } > > return DNN_SUCCESS; > > @@ -1095,7 +1100,10 @@ static DNNReturnType > > execute_model_tf(TFRequestItem *request, Queue *inference_q > > } > > > > if (task->async) { > > -return ff_dnn_start_inference_async(ctx, &request->exec_module); > > +if (ff_d
Re: [FFmpeg-devel] [PATCH v3 1/2] avformat/ttml: split TTML paragraph based or not check into header
On Mon, Aug 2, 2021 at 3:54 PM Andreas Rheinhardt wrote: > > Jan Ekström: > > From: Jan Ekström > > > > This way it can be re-utilized in movenc. > > > > Signed-off-by: Jan Ekström > > --- > > libavformat/ttmlenc.c | 9 ++--- > > libavformat/ttmlenc.h | 39 +++ > > 2 files changed, 41 insertions(+), 7 deletions(-) > > create mode 100644 libavformat/ttmlenc.h > > > > diff --git a/libavformat/ttmlenc.c b/libavformat/ttmlenc.c > > index 7577cb543b..5c4cd8b5e9 100644 > > --- a/libavformat/ttmlenc.c > > +++ b/libavformat/ttmlenc.c > > @@ -29,6 +29,7 @@ > > > > #include "avformat.h" > > #include "internal.h" > > +#include "ttmlenc.h" > > #include "libavcodec/ttmlenc.h" > > #include "libavutil/internal.h" > > > > @@ -137,13 +138,7 @@ static int ttml_write_header(AVFormatContext *ctx) > >0); > > const char *printed_lang = (lang && lang->value) ? lang->value : > > ""; > > > > -// Not perfect, but decide whether the packet is a document or not > > -// by the existence of the lavc ttmlenc extradata. > > -ttml_ctx->input_type = (st->codecpar->extradata && > > -st->codecpar->extradata_size >= > > TTMLENC_EXTRADATA_SIGNATURE_SIZE && > > -!memcmp(st->codecpar->extradata, > > -TTMLENC_EXTRADATA_SIGNATURE, > > -TTMLENC_EXTRADATA_SIGNATURE_SIZE)) > > ? > > +ttml_ctx->input_type = > > ff_is_ttml_stream_paragraph_based(st->codecpar) ? > > PACKET_TYPE_PARAGRAPH : > > PACKET_TYPE_DOCUMENT; > > > > diff --git a/libavformat/ttmlenc.h b/libavformat/ttmlenc.h > > new file mode 100644 > > index 00..2da233b8f1 > > --- /dev/null > > +++ b/libavformat/ttmlenc.h > > @@ -0,0 +1,39 @@ > > +/* > > + * Generic TTML helpers > > + * Copyright (c) 2021 24i > > + * > > + * This file is part of FFmpeg. > > + * > > + * FFmpeg is free software; you can redistribute it and/or > > + * modify it under the terms of the GNU Lesser General Public > > + * License as published by the Free Software Foundation; either > > + * version 2.1 of the License, or (at your option) any later version. > > + * > > + * FFmpeg is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > + * Lesser General Public License for more details. > > + * > > + * You should have received a copy of the GNU Lesser General Public > > + * License along with FFmpeg; if not, write to the Free Software > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > > 02110-1301 USA > > + */ > > + > > +#ifndef AVFORMAT_TTMLENC_H > > +#define AVFORMAT_TTMLENC_H > > + > > +#include "avformat.h" > > You actually only need libavcodec/codec_par.h > Switched to that specific header. > > +#include "libavcodec/ttmlenc.h" > > + > > +static inline unsigned int > > ff_is_ttml_stream_paragraph_based(AVCodecParameters *codecpar) > > Missing const. > Added const. Jan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 2/2] avformat/movenc: add support for TTML muxing
On Thu, Aug 5, 2021 at 10:33 PM Andreas Rheinhardt wrote: > > Jan Ekström: > > From: Jan Ekström > > > > Includes basic support for both the ISMV ('dfxp') and MP4 ('stpp') > > methods. This initial version also foregoes fragmentation support > > in case the built-in sample squashing is to be utilized, as this > > eases the initial review. > > > > Additionally, add basic tests for both muxing modes in MP4. > > > > Signed-off-by: Jan Ekström > > --- > > libavformat/Makefile | 2 +- > > libavformat/isom.h | 3 + > > libavformat/movenc.c | 179 ++- > > libavformat/movenc.h | 5 + > > libavformat/movenc_ttml.c| 178 ++ > > libavformat/movenc_ttml.h| 31 ++ > > tests/fate/subtitles.mak | 4 + > > tests/ref/fate/sub-ttml-mp4-dfxp | 44 > > tests/ref/fate/sub-ttml-mp4-stpp | 44 > > 9 files changed, 487 insertions(+), 3 deletions(-) > > create mode 100644 libavformat/movenc_ttml.c > > create mode 100644 libavformat/movenc_ttml.h > > create mode 100644 tests/ref/fate/sub-ttml-mp4-dfxp > > create mode 100644 tests/ref/fate/sub-ttml-mp4-stpp > > > > diff --git a/libavformat/Makefile b/libavformat/Makefile > > index 813ddd3c20..7e0f587b41 100644 > > --- a/libavformat/Makefile > > +++ b/libavformat/Makefile > > @@ -337,7 +337,7 @@ OBJS-$(CONFIG_MOV_DEMUXER) += mov.o > > mov_chan.o mov_esds.o \ > > qtpalette.o replaygain.o > > OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o > > vpcc.o \ > > movenchint.o mov_chan.o rtp.o \ > > -movenccenc.o rawutils.o > > +movenccenc.o movenc_ttml.o > > rawutils.o > > OBJS-$(CONFIG_MP2_MUXER) += rawenc.o > > OBJS-$(CONFIG_MP3_DEMUXER) += mp3dec.o replaygain.o > > OBJS-$(CONFIG_MP3_MUXER) += mp3enc.o rawenc.o id3v2enc.o > > diff --git a/libavformat/isom.h b/libavformat/isom.h > > index ac1b3f3d56..34a58c79b7 100644 > > --- a/libavformat/isom.h > > +++ b/libavformat/isom.h > > @@ -387,4 +387,7 @@ static inline enum AVCodecID > > ff_mov_get_lpcm_codec_id(int bps, int flags) > > return ff_get_pcm_codec_id(bps, flags & 1, flags & 2, flags & 4 ? -1 : > > 0); > > } > > > > +#define MOV_ISMV_TTML_TAG MKTAG('d', 'f', 'x', 'p') > > +#define MOV_MP4_TTML_TAG MKTAG('s', 't', 'p', 'p') > > + > > #endif /* AVFORMAT_ISOM_H */ > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > > index c85efe8748..f3e295ad80 100644 > > --- a/libavformat/movenc.c > > +++ b/libavformat/movenc.c > > @@ -56,6 +56,8 @@ > > #include "hevc.h" > > #include "rtpenc.h" > > #include "mov_chan.h" > > +#include "movenc_ttml.h" > > +#include "ttmlenc.h" > > #include "vpcc.h" > > > > static const AVOption options[] = { > > @@ -119,6 +121,7 @@ static const AVClass mov_isobmff_muxer_class = { > > }; > > > > static int get_moov_size(AVFormatContext *s); > > +static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt); > > > > static int utf8len(const uint8_t *b) > > { > > @@ -1787,7 +1790,29 @@ static int mov_write_subtitle_tag(AVIOContext *pb, > > MOVTrack *track) > > > > if (track->par->codec_id == AV_CODEC_ID_DVD_SUBTITLE) > > mov_write_esds_tag(pb, track); > > -else if (track->par->extradata_size) > > +else if (track->par->codec_id == AV_CODEC_ID_TTML) { > > +switch (track->par->codec_tag) { > > +case MOV_ISMV_TTML_TAG: > > +// ISMV dfxp requires no extradata. > > +break; > > +case MOV_MP4_TTML_TAG: > > +// As specified in 14496-30, XMLSubtitleSampleEntry > > +// Namespace > > +avio_put_str(pb, "http://www.w3.org/ns/ttml";); > > +// Empty schema_location > > +avio_w8(pb, 0); > > +// Empty auxiliary_mime_types > > +avio_w8(pb, 0); > > +break; > > +default: > > +av_log(NULL, AV_LOG_ERROR, > > + "Unknown codec tag '%s' utilized for TTML stream with " > > + "index %d (track id %d)!\n", > > + av_fourcc2str(track->par->codec_tag), track->st->index, > > + track->track_id); > > +return AVERROR(EINVAL); > > +} > > +} else if (track->par->extradata_size) > > avio_write(pb, track->par->extradata, track->par->extradata_size); > > > > if (track->mode == MODE_MP4 && > > @@ -2661,6 +2686,14 @@ static int mov_write_nmhd_tag(AVIOContext *pb) > > return 12; > > } > > > > +static int mov_write_sthd_tag(AVIOContext *pb) > > +{ > > +avio_wb32(pb, 12); > > +ffio_wfourcc(pb, "sthd"); > > +avio_wb32(pb, 0); > > +return 12; > > +} > > + > > static int mov_write_tcmi_tag(AVI
Re: [FFmpeg-devel] [PATCH] Nvenc: Adding support for chroma qp offset for h264_nvenc and hevc_nvenc
On 09.08.2021 11:04, Ricardo Monteiro wrote: If that limits its usage to constant QP only RC then I would keep it as is. Alright, applied with some minor amendments. Thanks, Timo smime.p7s Description: S/MIME Cryptographic Signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] FATE: add tests for v360/ssim360 filters
On 8/9/2021 11:29 AM, Anton Khirnov wrote: > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index b0348ccfa3..27dd0c4b47 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -559,7 +559,8 @@ SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h > > OBJS-$(CONFIG_LIBGLSLANG)+= glslang.o > > -TOOLS = graph2dot > +TOOLS = graph2dot \ > +spherical_compare Is there a reason it needs a new tool rather than ffmpeg.c? > +frame 0 > +lavfi.ssim360.Y=0.97 > +lavfi.ssim360.U=1.00 > +lavfi.ssim360.V=1.00 > +lavfi.ssim360.All=1.00 > +lavfi.ssim360.dB=25.19 Is it wise to do a non-fuzzy compare of floats? - Derek ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/movenc: Don't auto flush fragment if no frame available
Even if FF_MOV_FLAG_FRAG_EVERY_FRAME is set, don't flush if no frame available. This fixes an issue that we overwrite the track duration, causing it to be out-of-sync with the last written packet in previous fragment. Signed-off-by: Hu Weiwen --- Hi Martin, I can confirm your patch "movenc: Don't try to fix the fragment end duration if none will be written"[1] does fix my issue reported in [2]. But I think my current patch would be a better fix. It is more self-explanatory, and more consistent in the case of FF_MOV_FLAG_FRAG_KEYFRAME. Also, I think my original patch [2] still has its value. "frag_start" seems to be redundant, and it is only updated relative to its previous value. This is bad because any potential error updating it will have infinite impact on future packets. [1]: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210805123421.10527-1-mar...@martin.st/ [2]: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210718102232.1382376-1-seh...@mail.scut.edu.cn/ libavformat/movenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 57062f45c57..72fe8df12c2 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -5929,7 +5929,7 @@ static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt) (mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME && par->codec_type == AVMEDIA_TYPE_VIDEO && trk->entry && pkt->flags & AV_PKT_FLAG_KEY) || -(mov->flags & FF_MOV_FLAG_FRAG_EVERY_FRAME)) { +(mov->flags & FF_MOV_FLAG_FRAG_EVERY_FRAME && trk->entry)) { if (frag_duration >= mov->min_fragment_duration) { // Set the duration of this track to line up with the next // sample in this track. This avoids relying on AVPacket -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 1/2] lavfi/vf_scale: dump the exact swscale_options to passed to libswscale
From: Linjie Fu Printed verbose log doesn't match the sws_flags specified in the cmdline for simple filter graph. ffmpeg .. -sws_flags bicubic .. [auto_scaler_0] w:iw h:ih flags:'' interl:0 [auto_scaler_0] w:310 h:449 fmt:yuva420p sar:0/1 -> w:310 h:449 fmt:yuv420p sar:0/1 flags:0x0 Filter complex doesn't have this issue as mentioned in 12e7e1d03, the auto-inserted scaler accepts sws_flags in filtergraph complex which overrides the 'flags' option for vf_scale and dump it as a verbose log: ffmpeg .. -filter_complex "sws_flags=bicubic;format=nv12" .. [auto_scaler_0] w:iw h:ih flags:'bicubic' interl:0 [auto_scaler_0] w:310 h:449 fmt:yuva420p sar:0/1 -> w:310 h:449 fmt:nv12 sar:0/1 flags:0x2 To catch the difference, dump the exact sws_flags which is passed to libswscale. [auto_scaler_0] swscale_options:'sws_flags=bicubic' Signed-off-by: Linjie Fu --- libavfilter/vf_scale.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index aa855b894a..dc8051a236 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -552,10 +552,16 @@ static int config_props(AVFilterLink *outlink) scale->out_range == AVCOL_RANGE_JPEG, 0); if (scale->opts) { +char args[512] = { 0 }; AVDictionaryEntry *e = NULL; while ((e = av_dict_get(scale->opts, "", e, AV_DICT_IGNORE_SUFFIX))) { if ((ret = av_opt_set(*s, e->key, e->value, 0)) < 0) return ret; +av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value); +} +if (args[0] != '\0') { +args[strlen(args)-1] = 0; +av_log(ctx, AV_LOG_VERBOSE, "swscale_options:'%s'\n", args); } } /* Override YUV420P default settings to have the correct (MPEG-2) chroma positions -- 2.31.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 2/2] libavfilter/graphparser: Add scale_sws_opts parse support in avfilter_graph_parse2
From: Linjie Fu To pass the swscale options for the inserted scalers. ffmpeg -i input.mp4 -filter_complex \ "scale_sws_opts=alphablend=checkerboard;format=nv12" \ -t 0.5 output.mp4 Update docs. Signed-off-by: Linjie Fu --- doc/filters.texi | 7 --- libavfilter/graphparser.c | 22 ++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index bdeb3fedfd..67108f91ff 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -204,9 +204,9 @@ pads must be connected. A filtergraph is considered valid if all the filter input and output pads of all the filterchains are connected. Libavfilter will automatically insert @ref{scale} filters where format -conversion is required. It is possible to specify swscale flags -for those automatically inserted scalers by prepending -@code{sws_flags=@var{flags};} +conversion is required. It is possible to specify swscale flags or +scale_sws_opts for those automatically inserted scalers by prepending +@code{sws_flags=@var{flags};} or @code{scale_sws_opts=@var{scale_sws_opts};} to the filtergraph description. Here is a BNF description of the filtergraph syntax: @@ -219,6 +219,7 @@ Here is a BNF description of the filtergraph syntax: @var{FILTER} ::= [@var{LINKLABELS}] @var{FILTER_NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}] @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}] @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}] +@var{FILTERGRAPH} ::= [scale_sws_opts=@var{opts};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}] @end example @anchor{filtergraph escaping} diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c index 1385c3ae71..96ae8940af 100644 --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@ -415,6 +415,25 @@ static int parse_sws_flags(const char **buf, AVFilterGraph *graph) return 0; } +static int parse_scale_sws_opts(const char **buf, AVFilterGraph *graph) +{ +char *p = strchr(*buf, ';'); + +if (!av_strstart(*buf, "scale_sws_opts=", buf)) +return 0; + +if (!p) { +av_log(graph, AV_LOG_ERROR, "scale_sws_opts not terminated with ';'.\n"); +return AVERROR(EINVAL); +} + +av_freep(&graph->scale_sws_opts); +graph->scale_sws_opts = av_strndup(*buf, p - *buf); + +*buf = p + 1; +return 0; +} + int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs) @@ -429,6 +448,9 @@ int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, if ((ret = parse_sws_flags(&filters, graph)) < 0) goto fail; +if ((ret = parse_scale_sws_opts(&filters, graph)) < 0) +goto fail; + do { AVFilterContext *filter; filters += strspn(filters, WHITESPACES); -- 2.31.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/movenc: Don't auto flush fragment if no frame available
Hi, On Mon, 9 Aug 2021, Hu Weiwen wrote: Even if FF_MOV_FLAG_FRAG_EVERY_FRAME is set, don't flush if no frame available. This fixes an issue that we overwrite the track duration, causing it to be out-of-sync with the last written packet in previous fragment. Signed-off-by: Hu Weiwen --- Hi Martin, I can confirm your patch "movenc: Don't try to fix the fragment end duration if none will be written"[1] does fix my issue reported in [2]. But I think my current patch would be a better fix. It is more self-explanatory, and more consistent in the case of FF_MOV_FLAG_FRAG_KEYFRAME. This patch is indeed more straightforward, but it misses a couple cases. If the current muxed packet is a keyframe, but we have no queued packets in this track, we'd end up with the same bug again. And the other way around, if we'd have a packet queued in another track, we won't flush that fragment right here, which is a notable behaviour change from how FF_MOV_FLAG_FRAG_EVERY_FRAME behaves right now. Also, I think my original patch [2] still has its value. "frag_start" seems to be redundant, and it is only updated relative to its previous value. This is bad because any potential error updating it will have infinite impact on future packets. I disagree here. If we have a bug where we update things making them inconsistent, we should fix that bug. These other patches that are discussed is one case of that. This code is quite complex and it's almost a decade since I wrote most of it, so I don't recall offhand exactly how it behaves in all cases - but it's designed to try to make the output consistent and correct for a number of weird cases. If the variable really is strictly redundant, you can send a patch which can be proven to not alter behaviour anywhere under any circumstances. But if it's made with the intent to be more robust, then it's also a possible behaviour change, and in that case I prefer not changing behaviour blindly. But separately, as I said, I'm totally open to a patch to add an option to make it stop adjusting the start of the next fragment (making tfdt the authoritative source, possibly differing from the sum of earlier durations). // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 10/10] lavfi/vf_scale: pass the thread count to the scaler
On Sun, Aug 08, 2021 at 07:29:41PM +0200, Anton Khirnov wrote: > --- > libavfilter/vf_scale.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c > index b62fb37d4b..14e202bf77 100644 > --- a/libavfilter/vf_scale.c > +++ b/libavfilter/vf_scale.c > @@ -542,6 +542,7 @@ static int config_props(AVFilterLink *outlink) > av_opt_set_int(*s, "sws_flags", scale->flags, 0); > av_opt_set_int(*s, "param0", scale->param[0], 0); > av_opt_set_int(*s, "param1", scale->param[1], 0); > +av_opt_set_int(*s, "threads", ff_filter_get_nb_threads(ctx), 0); > if (scale->in_range != AVCOL_RANGE_UNSPECIFIED) > av_opt_set_int(*s, "src_range", > scale->in_range == AVCOL_RANGE_JPEG, 0); > -- > 2.30.2 breaks: ./ffmpeg -i ~/tickets/1012/IV50_random_points.avi -threads 5 -y file1012.avi it contains horizontal bright green lines [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Old school: Use the lowest level language in which you can solve the problem conveniently. New school: Use the highest level language in which the latest supercomputer can solve the problem without the user falling asleep waiting. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avfilter: add (a)segment filters
Signed-off-by: Paul B Mahol --- doc/filters.texi | 34 libavfilter/Makefile | 2 + libavfilter/allfilters.c | 2 + libavfilter/f_segment.c | 335 +++ 4 files changed, 373 insertions(+) create mode 100644 libavfilter/f_segment.c diff --git a/doc/filters.texi b/doc/filters.texi index bdeb3fedfd..b65afbda65 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -25665,6 +25665,40 @@ A processing speed faster than what is possible without these filters cannot be achieved. @end table +@section segment, asegment + +Split single input stream into multiple streams. + +This filter does opposite of concat filters. + +@code{segment} works on video frames, @code{asegment} on audio samples. + +This filter accepts the following options: + +@table @option +@item timestamps +Timestamps of output segments separated by '|'. The first segment will run +from the beginning of the input stream. The last segment will run until +the end of the input stream + +@item frames, samples +Exact frame/sample count to split the segments. +@end table + +@subsection Examples + +@itemize + +@item +Split input audio stream into three output audio streams, starting at start of input audio stream +and storing that in 1st output audio stream, then following at 60th second and storing than in 2nd +output audio stream, and last after 120th second of input audio stream store in 3rd output audio stream: +@example +asegment=timestamps="60 | 120" +@end example + +@end itemize + @anchor{select} @section select, aselect diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 49c0c8342b..102ce7beff 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -78,6 +78,7 @@ OBJS-$(CONFIG_AREALTIME_FILTER) += f_realtime.o OBJS-$(CONFIG_ARESAMPLE_FILTER) += af_aresample.o OBJS-$(CONFIG_AREVERSE_FILTER) += f_reverse.o OBJS-$(CONFIG_ARNNDN_FILTER) += af_arnndn.o +OBJS-$(CONFIG_ASEGMENT_FILTER) += f_segment.o OBJS-$(CONFIG_ASELECT_FILTER)+= f_select.o OBJS-$(CONFIG_ASENDCMD_FILTER) += f_sendcmd.o OBJS-$(CONFIG_ASETNSAMPLES_FILTER) += af_asetnsamples.o @@ -404,6 +405,7 @@ OBJS-$(CONFIG_SCALE_VULKAN_FILTER) += vf_scale_vulkan.o vulkan.o OBJS-$(CONFIG_SCALE2REF_FILTER) += vf_scale.o scale_eval.o OBJS-$(CONFIG_SCDET_FILTER) += vf_scdet.o OBJS-$(CONFIG_SCROLL_FILTER) += vf_scroll.o +OBJS-$(CONFIG_SEGMENT_FILTER)+= f_segment.o OBJS-$(CONFIG_SELECT_FILTER) += f_select.o OBJS-$(CONFIG_SELECTIVECOLOR_FILTER) += vf_selectivecolor.o OBJS-$(CONFIG_SENDCMD_FILTER)+= f_sendcmd.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index ae74f9c891..73040d2824 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -71,6 +71,7 @@ extern const AVFilter ff_af_arealtime; extern const AVFilter ff_af_aresample; extern const AVFilter ff_af_areverse; extern const AVFilter ff_af_arnndn; +extern const AVFilter ff_af_asegment; extern const AVFilter ff_af_aselect; extern const AVFilter ff_af_asendcmd; extern const AVFilter ff_af_asetnsamples; @@ -385,6 +386,7 @@ extern const AVFilter ff_vf_scale_vulkan; extern const AVFilter ff_vf_scale2ref; extern const AVFilter ff_vf_scdet; extern const AVFilter ff_vf_scroll; +extern const AVFilter ff_vf_segment; extern const AVFilter ff_vf_select; extern const AVFilter ff_vf_selectivecolor; extern const AVFilter ff_vf_sendcmd; diff --git a/libavfilter/f_segment.c b/libavfilter/f_segment.c new file mode 100644 index 00..7e0521b3c1 --- /dev/null +++ b/libavfilter/f_segment.c @@ -0,0 +1,335 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "libavutil/avstring.h" +#include "libavutil/channel_layout.h" +#include "libavutil/common.h" +#include "libavutil/log.h" +#include "libavutil/mathematics.h" +#include "libavutil/opt.h" +#include "libavutil/parseutils.h" +#include "libavutil/samplefmt.h" + +#include "audio.h" +#include "avfilter.h" +#include "filters.h" +#include "internal.h" + +typedef struct SegmentContext { +const AVClass *class; + +ch
[FFmpeg-devel] [PATCH v3 1/4] avdevice/decklink: add link configuration
From: Limin Wang Signed-off-by: Limin Wang --- doc/outdevs.texi| 6 ++ libavdevice/decklink_common.cpp | 9 + libavdevice/decklink_common.h | 8 libavdevice/decklink_common_c.h | 1 + libavdevice/decklink_enc.cpp| 2 ++ libavdevice/decklink_enc_c.c| 5 + 6 files changed, 31 insertions(+) diff --git a/doc/outdevs.texi b/doc/outdevs.texi index aaf2479..f046b23 100644 --- a/doc/outdevs.texi +++ b/doc/outdevs.texi @@ -205,6 +205,12 @@ Defaults to @samp{unset}. Sets the genlock timing pixel offset on the used output. Defaults to @samp{unset}. +@item link +Sets the SDI video link configuration on the used output. Must be +@samp{unset}, @samp{single} link SDI, @samp{dual} link SDI or @samp{quad} link +SDI. +Defaults to @samp{unset}. + @end table @subsection Examples diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp index 24aa9b1..4e0df04 100644 --- a/libavdevice/decklink_common.cpp +++ b/libavdevice/decklink_common.cpp @@ -214,6 +214,15 @@ int ff_decklink_set_configs(AVFormatContext *avctx, if (res != S_OK) av_log(avctx, AV_LOG_WARNING, "Setting timing offset failed.\n"); } + +if (direction == DIRECTION_OUT && ctx->link > 0) { +res = ctx->cfg->SetInt(bmdDeckLinkConfigSDIOutputLinkConfiguration, ctx->link); +if (res != S_OK) +av_log(avctx, AV_LOG_WARNING, "Setting link configuration failed.\n"); +else +av_log(avctx, AV_LOG_VERBOSE, "Successfully set link configuration: 0x%x.\n", ctx->link); +} + return 0; } diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h index 6e03295..ad8b33c 100644 --- a/libavdevice/decklink_common.h +++ b/libavdevice/decklink_common.h @@ -131,6 +131,7 @@ struct decklink_ctx { int64_t teletext_lines; double preroll; int duplex_mode; +BMDLinkConfiguration link; DecklinkPtsSource audio_pts_source; DecklinkPtsSource video_pts_source; int draw_bars; @@ -200,6 +201,13 @@ static const BMDTimecodeFormat decklink_timecode_format_map[] = { #endif }; +static const BMDLinkConfiguration decklink_link_conf_map[] = { +(BMDLinkConfiguration)0, +bmdLinkConfigurationSingleLink, +bmdLinkConfigurationDualLink, +bmdLinkConfigurationQuadLink +}; + int ff_decklink_set_configs(AVFormatContext *avctx, decklink_direction_t direction); int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int tb_num, int tb_den, enum AVFieldOrder field_order, decklink_direction_t direction = DIRECTION_OUT); int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction); diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h index 68978fa..f37e0c0 100644 --- a/libavdevice/decklink_common_c.h +++ b/libavdevice/decklink_common_c.h @@ -48,6 +48,7 @@ struct decklink_cctx { int audio_channels; int audio_depth; int duplex_mode; +int link; DecklinkPtsSource audio_pts_source; DecklinkPtsSource video_pts_source; int audio_input; diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp index 4c1eb05..6dec5f3 100644 --- a/libavdevice/decklink_enc.cpp +++ b/libavdevice/decklink_enc.cpp @@ -559,6 +559,8 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx) ctx->list_formats = cctx->list_formats; ctx->preroll = cctx->preroll; ctx->duplex_mode = cctx->duplex_mode; +if (cctx->link > 0 && (unsigned int)cctx->link < FF_ARRAY_ELEMS(decklink_link_conf_map)) +ctx->link = decklink_link_conf_map[cctx->link]; cctx->ctx = ctx; #if CONFIG_LIBKLVANC if (klvanc_context_create(&ctx->vanc_ctx) < 0) { diff --git a/libavdevice/decklink_enc_c.c b/libavdevice/decklink_enc_c.c index 828cf5d..4d191d8 100644 --- a/libavdevice/decklink_enc_c.c +++ b/libavdevice/decklink_enc_c.c @@ -35,6 +35,11 @@ static const AVOption options[] = { { "unset" , NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 0 }, 0, 0, ENC, "duplex_mode"}, { "half", NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 1 }, 0, 0, ENC, "duplex_mode"}, { "full", NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 2 }, 0, 0, ENC, "duplex_mode"}, +{ "link" , "single/dual/quad SDI link configuration", OFFSET(link), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, ENC, "link"}, +{ "unset" , NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 0 }, 0, 0, ENC, "link"}, +{ "single" , NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 1 }, 0, 0, ENC, "link"}, +{ "dual", NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 2 }, 0, 0, ENC, "link"}, +{ "quad", NULL , 0 , AV_OPT_TYPE_CONST
[FFmpeg-devel] [PATCH v3 2/4] avdevice/decklink: add sqd configure
From: Limin Wang Signed-off-by: Limin Wang --- configure | 2 +- doc/outdevs.texi| 5 + libavdevice/decklink_common.cpp | 7 +++ libavdevice/decklink_common_c.h | 1 + libavdevice/decklink_enc_c.c| 4 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/configure b/configure index f9fdf58..11f774c 100755 --- a/configure +++ b/configure @@ -6387,7 +6387,7 @@ enabled avisynth && require_headers "avisynth/avisynth_c.h" enabled cuda_nvcc && { check_nvcc cuda_nvcc || die "ERROR: failed checking for nvcc."; } enabled chromaprint && require chromaprint chromaprint.h chromaprint_get_version -lchromaprint enabled decklink && { require_headers DeckLinkAPI.h && - { test_cpp_condition DeckLinkAPIVersion.h "BLACKMAGIC_DECKLINK_API_VERSION >= 0x0a0a" || die "ERROR: Decklink API version must be >= 10.10"; } } + { test_cpp_condition DeckLinkAPIVersion.h "BLACKMAGIC_DECKLINK_API_VERSION >= 0x0a0b0400" || die "ERROR: Decklink API version must be >= 10.11.4"; } } enabled frei0r&& require_headers "frei0r.h dlfcn.h" enabled gmp && require gmp gmp.h mpz_export -lgmp enabled gnutls&& require_pkg_config gnutls gnutls gnutls/gnutls.h gnutls_global_init diff --git a/doc/outdevs.texi b/doc/outdevs.texi index f046b23..e3e88b2 100644 --- a/doc/outdevs.texi +++ b/doc/outdevs.texi @@ -211,6 +211,11 @@ Sets the SDI video link configuration on the used output. Must be SDI. Defaults to @samp{unset}. +@item sqd +Enable Square Division Quad Split mode for Quad-link SDI output. +Must be @samp{unset}, @samp{true} or @samp{false}. +Defaults to @option{unset}. + @end table @subsection Examples diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp index 4e0df04..a892a6c 100644 --- a/libavdevice/decklink_common.cpp +++ b/libavdevice/decklink_common.cpp @@ -221,6 +221,13 @@ int ff_decklink_set_configs(AVFormatContext *avctx, av_log(avctx, AV_LOG_WARNING, "Setting link configuration failed.\n"); else av_log(avctx, AV_LOG_VERBOSE, "Successfully set link configuration: 0x%x.\n", ctx->link); +if (ctx->link == bmdLinkConfigurationQuadLink && cctx->sqd >= 0) { +res = ctx->cfg->SetFlag(bmdDeckLinkConfigQuadLinkSDIVideoOutputSquareDivisionSplit, cctx->sqd); +if (res != S_OK) +av_log(avctx, AV_LOG_WARNING, "Setting SquareDivisionSplit failed.\n"); +else +av_log(avctx, AV_LOG_VERBOSE, "Successfully set SquareDivisionSplit.\n"); +} } return 0; diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h index f37e0c0..fdaa1f9 100644 --- a/libavdevice/decklink_common_c.h +++ b/libavdevice/decklink_common_c.h @@ -49,6 +49,7 @@ struct decklink_cctx { int audio_depth; int duplex_mode; int link; +int sqd; DecklinkPtsSource audio_pts_source; DecklinkPtsSource video_pts_source; int audio_input; diff --git a/libavdevice/decklink_enc_c.c b/libavdevice/decklink_enc_c.c index 4d191d8..4bcdbfe 100644 --- a/libavdevice/decklink_enc_c.c +++ b/libavdevice/decklink_enc_c.c @@ -40,6 +40,10 @@ static const AVOption options[] = { { "single" , NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 1 }, 0, 0, ENC, "link"}, { "dual", NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 2 }, 0, 0, ENC, "link"}, { "quad", NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 3 }, 0, 0, ENC, "link"}, +{ "sqd" , "set Square Division" , OFFSET(sqd) , AV_OPT_TYPE_INT,{ .i64 = -1 }, -1,1, ENC, "sqd"}, +{ "unset" , NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = -1 }, 0, 0, ENC, "sqd"}, +{ "false" , NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 0 }, 0, 0, ENC, "sqd"}, +{ "true", NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 1 }, 0, 0, ENC, "sqd"}, { "timing_offset", "genlock timing pixel offset", OFFSET(timing_offset), AV_OPT_TYPE_INT, { .i64 = INT_MIN }, INT_MIN, INT_MAX, ENC, "timing_offset"}, { "unset" , NULL , 0, AV_OPT_TYPE_CONST, { .i64 = INT_MIN }, 0, 0, ENC, "timing_offset"}, { NULL }, -- 1.8.3.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 3/4] avdevice/decklink: add level_a configure
From: Limin Wang Signed-off-by: Limin Wang --- doc/outdevs.texi| 5 + libavdevice/decklink_common.cpp | 17 + libavdevice/decklink_common_c.h | 1 + libavdevice/decklink_enc_c.c| 4 4 files changed, 27 insertions(+) diff --git a/doc/outdevs.texi b/doc/outdevs.texi index e3e88b2..cc0c94a 100644 --- a/doc/outdevs.texi +++ b/doc/outdevs.texi @@ -216,6 +216,11 @@ Enable Square Division Quad Split mode for Quad-link SDI output. Must be @samp{unset}, @samp{true} or @samp{false}. Defaults to @option{unset}. +@item level_a +Enable SMPTE Level A mode on the used output. +Must be @samp{unset}, @samp{true} or @samp{false}. +Defaults to @option{unset}. + @end table @subsection Examples diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp index a892a6c..0569462 100644 --- a/libavdevice/decklink_common.cpp +++ b/libavdevice/decklink_common.cpp @@ -230,6 +230,23 @@ int ff_decklink_set_configs(AVFormatContext *avctx, } } +if (direction == DIRECTION_OUT && cctx->level_a >= 0) { +DECKLINK_BOOL level_a_supported = false; + +if (ctx->attr->GetFlag(BMDDeckLinkSupportsSMPTELevelAOutput, &level_a_supported) != S_OK) +level_a_supported = false; + +if (level_a_supported) { +res = ctx->cfg->SetFlag(bmdDeckLinkConfigSMPTELevelAOutput, cctx->level_a); +if (res != S_OK) +av_log(avctx, AV_LOG_WARNING, "Setting SMPTE levelA failed.\n"); +else +av_log(avctx, AV_LOG_VERBOSE, "Successfully set SMPTE levelA.\n"); +} else { +av_log(avctx, AV_LOG_WARNING, "Unable to set SMPTE levelA mode, because it is not supported.\n"); +} +} + return 0; } diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h index fdaa1f9..c257721 100644 --- a/libavdevice/decklink_common_c.h +++ b/libavdevice/decklink_common_c.h @@ -50,6 +50,7 @@ struct decklink_cctx { int duplex_mode; int link; int sqd; +int level_a; DecklinkPtsSource audio_pts_source; DecklinkPtsSource video_pts_source; int audio_input; diff --git a/libavdevice/decklink_enc_c.c b/libavdevice/decklink_enc_c.c index 4bcdbfe..559f078 100644 --- a/libavdevice/decklink_enc_c.c +++ b/libavdevice/decklink_enc_c.c @@ -44,6 +44,10 @@ static const AVOption options[] = { { "unset" , NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = -1 }, 0, 0, ENC, "sqd"}, { "false" , NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 0 }, 0, 0, ENC, "sqd"}, { "true", NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 1 }, 0, 0, ENC, "sqd"}, +{ "level_a" , "set SMPTE LevelA", OFFSET(level_a) , AV_OPT_TYPE_INT,{ .i64 = -1 }, -1,1, ENC, "level_a"}, +{ "unset" , NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = -1 }, 0, 0, ENC, "level_a"}, +{ "false" , NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 0 }, 0, 0, ENC, "level_a"}, +{ "true", NULL , 0 , AV_OPT_TYPE_CONST , { .i64 = 1 }, 0, 0, ENC, "level_a"}, { "timing_offset", "genlock timing pixel offset", OFFSET(timing_offset), AV_OPT_TYPE_INT, { .i64 = INT_MIN }, INT_MIN, INT_MAX, ENC, "timing_offset"}, { "unset" , NULL , 0, AV_OPT_TYPE_CONST, { .i64 = INT_MIN }, 0, 0, ENC, "timing_offset"}, { NULL }, -- 1.8.3.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 4/4] avdevice/decklink: support for more duplex mode for Decklink 8K Pro
From: Limin Wang Signed-off-by: Limin Wang --- doc/indevs.texi | 16 +++- doc/outdevs.texi| 16 +++- libavdevice/decklink_common.cpp | 4 ++-- libavdevice/decklink_common.h | 11 +++ libavdevice/decklink_dec_c.c| 10 ++ libavdevice/decklink_enc_c.c| 10 ++ 6 files changed, 63 insertions(+), 4 deletions(-) diff --git a/doc/indevs.texi b/doc/indevs.texi index b377924..c2ec0f4 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -344,9 +344,23 @@ Defines number of audio channels to capture. Must be @samp{2}, @samp{8} or @samp Defaults to @samp{2}. @item duplex_mode -Sets the decklink device duplex mode. Must be @samp{unset}, @samp{half} or @samp{full}. +Sets the decklink device duplex/profile mode. Must be @samp{unset}, @samp{half}, @samp{full}, +@samp{one_sub_device_full}, @samp{one_sub_device_half}, @samp{two_sub_device_full}, +@samp{four_sub_device_half} Defaults to @samp{unset}. +Note: DeckLink SDK 11.0 have replaced the duplex property by a profile property. +For the DeckLink Duo 2 and DeckLink Quad 2, a profile is shared between any 2 +sub-devices that utilize the same connectors. For the DeckLink 8K Pro, a profile +is shared between all 4 sub-devices. So DeckLink 8K Pro support four profiles. + +Valid profile mode for DeckLink 8K Pro(Updated DeckLink SDK to >= 11.0): +@samp{one_sub_device_full}, @samp{one_sub_device_half}, @samp{two_sub_device_full}, +@samp{four_sub_device_half} + +Valid profile mode for DeckLink Quad 2 and DeckLink Duo 2: +@samp{half}, @samp{full} + @item timecode_format Timecode type to include in the frame and video stream metadata. Must be @samp{none}, @samp{rp188vitc}, @samp{rp188vitc2}, @samp{rp188ltc}, diff --git a/doc/outdevs.texi b/doc/outdevs.texi index cc0c94a..47dd913 100644 --- a/doc/outdevs.texi +++ b/doc/outdevs.texi @@ -198,9 +198,23 @@ Amount of time to preroll video in seconds. Defaults to @option{0.5}. @item duplex_mode -Sets the decklink device duplex mode. Must be @samp{unset}, @samp{half} or @samp{full}. +Sets the decklink device duplex/profile mode. Must be @samp{unset}, @samp{half}, @samp{full}, +@samp{one_sub_device_full}, @samp{one_sub_device_half}, @samp{two_sub_device_full}, +@samp{four_sub_device_half} Defaults to @samp{unset}. +Note: DeckLink SDK 11.0 have replaced the duplex property by a profile property. +For the DeckLink Duo 2 and DeckLink Quad 2, a profile is shared between any 2 +sub-devices that utilize the same connectors. For the DeckLink 8K Pro, a profile +is shared between all 4 sub-devices. So DeckLink 8K Pro support four profiles. + +Valid profile mode for DeckLink 8K Pro(Updated DeckLink SDK to >= 11.0): +@samp{one_sub_device_full}, @samp{one_sub_device_half}, @samp{two_sub_device_full}, +@samp{four_sub_device_half} + +Valid profile mode for DeckLink Quad 2 and DeckLink Duo 2: +@samp{half}, @samp{full} + @item timing_offset Sets the genlock timing pixel offset on the used output. Defaults to @samp{unset}. diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp index 0569462..8e77f4d 100644 --- a/libavdevice/decklink_common.cpp +++ b/libavdevice/decklink_common.cpp @@ -182,7 +182,7 @@ int ff_decklink_set_configs(AVFormatContext *avctx, if (duplex_supported) { #if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b00 IDeckLinkProfile *profile = NULL; -BMDProfileID bmd_profile_id = ctx->duplex_mode == 2 ? bmdProfileOneSubDeviceFullDuplex : bmdProfileTwoSubDevicesHalfDuplex; +BMDProfileID bmd_profile_id = decklink_profile_id_map[ctx->duplex_mode]; res = manager->GetProfile(bmd_profile_id, &profile); if (res == S_OK) { res = profile->SetActive(); @@ -195,7 +195,7 @@ int ff_decklink_set_configs(AVFormatContext *avctx, if (res != S_OK) av_log(avctx, AV_LOG_WARNING, "Setting duplex mode failed.\n"); else -av_log(avctx, AV_LOG_VERBOSE, "Successfully set duplex mode to %s duplex.\n", ctx->duplex_mode == 2 ? "full" : "half"); +av_log(avctx, AV_LOG_VERBOSE, "Successfully set duplex mode to %s duplex.\n", ctx->duplex_mode == 2 || ctx->duplex_mode == 4 ? "full" : "half"); } else { av_log(avctx, AV_LOG_WARNING, "Unable to set duplex mode, because it is not supported.\n"); } diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h index ad8b33c..5b11dcd 100644 --- a/libavdevice/decklink_common.h +++ b/libavdevice/decklink_common.h @@ -208,6 +208,17 @@ static const BMDLinkConfiguration decklink_link_conf_map[] = { bmdLinkConfigurationQuadLink }; +#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b00 +static const BMDProfileID decklink_profile_id_map[] = { +(BMDProfileID)0, +bmdProfileTwoSubDevicesHalfDuplex, +bmdProfileOneSubDeviceFullDuplex, +bmdProfileOneSubDeviceHalfDuplex, +
Re: [FFmpeg-devel] [PATCH] lavfi/qsvvpp: do not mix up FFmpeg and SDK error code
On Thu, 2021-08-05 at 16:05 +, Soft Works wrote: > > -Original Message- > > From: ffmpeg-devel On Behalf Of > > Xiang, Haihao > > Sent: Thursday, 5 August 2021 07:24 > > To: ffmpeg-devel@ffmpeg.org > > Subject: Re: [FFmpeg-devel] [PATCH] lavfi/qsvvpp: do not mix up FFmpeg > > and SDK error code > > > > On Wed, 2021-08-04 at 06:34 +, Soft Works wrote: > > > > -Original Message- > > > > From: ffmpeg-devel On Behalf Of > > > > Haihao Xiang > > > > Sent: Friday, 30 July 2021 04:39 > > > > To: ffmpeg-devel@ffmpeg.org > > > > Cc: Haihao Xiang > > > > Subject: [FFmpeg-devel] [PATCH] lavfi/qsvvpp: do not mix up FFmpeg > > > > and SDK error code > > > > > > > > The function ff_qsvvpp_filter_frame should return a FFmpeg error > > > > code if there is an error. However it might return a SDK error code > > > > without this patch. > > > > --- > > > > libavfilter/qsvvpp.c | 15 +-- > > > > 1 file changed, 9 insertions(+), 6 deletions(-) > > > > > > > > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index > > > > 4768f6208b..c7ef8a915f 100644 > > > > --- a/libavfilter/qsvvpp.c > > > > +++ b/libavfilter/qsvvpp.c > > > > @@ -807,8 +807,7 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, > > > > AVFilterLink *inlink, AVFrame *picr > > > >if (MFXVideoCORE_SyncOperation(s->session, sync, 1000) < 0) > > > >av_log(ctx, AV_LOG_WARNING, "Sync failed.\n"); > > > > > > Why no looping and no checking for MFX_WRN_IN_EXECUTION like > > > > below? > > > > Thanks for catching this, I think it should check for > > MFX_WRN_IN_EXECUTION, but it should be fixed in another patch. > > OK. > > > > > > > > > filter_ret = s->filter_frame(outlink, tmp->frame); > > > > if (filter_ret < 0) { > > > > av_frame_free(&tmp->frame); > > > > -ret = filter_ret; > > > > -break; > > > > +return filter_ret; > > > > > > The title is about not to mix error codes, but this is a behavioral > > > change. > > > After the patch, the input frame would no longer be processed in case > > > of a sync error. > > > > The condition is 's->eof && qsv_fifo_size(s->async_fifo)'. When s->eof is > > true, the input frame is actually NULL. So without this patch, this function > > returns 0 for this case, the error code is ignored. > > My bad, I missed the eof condition. > > > All details clarified. Patch LGTM. Could someone merge this patch if no more comments, please? Thanks Haihao ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavfi/qsvvpp: do not mix up FFmpeg and SDK error code
On 8/9/2021 10:55 PM, Xiang, Haihao wrote: On Thu, 2021-08-05 at 16:05 +, Soft Works wrote: -Original Message- From: ffmpeg-devel On Behalf Of Xiang, Haihao Sent: Thursday, 5 August 2021 07:24 To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH] lavfi/qsvvpp: do not mix up FFmpeg and SDK error code On Wed, 2021-08-04 at 06:34 +, Soft Works wrote: -Original Message- From: ffmpeg-devel On Behalf Of Haihao Xiang Sent: Friday, 30 July 2021 04:39 To: ffmpeg-devel@ffmpeg.org Cc: Haihao Xiang Subject: [FFmpeg-devel] [PATCH] lavfi/qsvvpp: do not mix up FFmpeg and SDK error code The function ff_qsvvpp_filter_frame should return a FFmpeg error code if there is an error. However it might return a SDK error code without this patch. --- libavfilter/qsvvpp.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index 4768f6208b..c7ef8a915f 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -807,8 +807,7 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr if (MFXVideoCORE_SyncOperation(s->session, sync, 1000) < 0) av_log(ctx, AV_LOG_WARNING, "Sync failed.\n"); Why no looping and no checking for MFX_WRN_IN_EXECUTION like below? Thanks for catching this, I think it should check for MFX_WRN_IN_EXECUTION, but it should be fixed in another patch. OK. filter_ret = s->filter_frame(outlink, tmp->frame); if (filter_ret < 0) { av_frame_free(&tmp->frame); -ret = filter_ret; -break; +return filter_ret; The title is about not to mix error codes, but this is a behavioral change. After the patch, the input frame would no longer be processed in case of a sync error. The condition is 's->eof && qsv_fifo_size(s->async_fifo)'. When s->eof is true, the input frame is actually NULL. So without this patch, this function returns 0 for this case, the error code is ignored. My bad, I missed the eof condition. All details clarified. Patch LGTM. Could someone merge this patch if no more comments, please? Thanks Haihao Pushed. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libavcodec/nvdec: Do not exceed 32 surfaces when initializing hw_frames_ctx
From: ameerj <52414509+ame...@users.noreply.github.com> nvdec is likely to fail when the initial pool size exceeds 32. This change ensures we don't exceed the limit when initializing a new hw_frames_ctx Signed-off-by: ameerj <52414509+ame...@users.noreply.github.com> --- libavcodec/nvdec.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c index 251be039a8..bef33dbae9 100644 --- a/libavcodec/nvdec.c +++ b/libavcodec/nvdec.c @@ -303,8 +303,10 @@ static int nvdec_init_hwframes(AVCodecContext *avctx, AVBufferRef **out_frames_r frames_ctx = (AVHWFramesContext*)(*out_frames_ref)->data; if (dummy) { -// Copied from ff_decode_get_hw_frames_ctx for compatibility -frames_ctx->initial_pool_size += 3; +// The function above guarantees 1 work surface, We must guarantee 4 work surfaces. +// (the absolute minimum), so add the missing count without exceeding the maximum +// recommended for nvdec. +frames_ctx->initial_pool_size = min(frames_ctx->initial_pool_size + 3, 32); frames_ctx->free = nvdec_free_dummy; frames_ctx->pool = av_buffer_pool_init(0, nvdec_alloc_dummy); -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavfi/qsvvpp: do not mix up FFmpeg and SDK error code
On Mon, 2021-08-09 at 22:58 -0300, James Almer wrote: > On 8/9/2021 10:55 PM, Xiang, Haihao wrote: > > On Thu, 2021-08-05 at 16:05 +, Soft Works wrote: > > > > -Original Message- > > > > From: ffmpeg-devel On Behalf Of > > > > Xiang, Haihao > > > > Sent: Thursday, 5 August 2021 07:24 > > > > To: ffmpeg-devel@ffmpeg.org > > > > Subject: Re: [FFmpeg-devel] [PATCH] lavfi/qsvvpp: do not mix up FFmpeg > > > > and SDK error code > > > > > > > > On Wed, 2021-08-04 at 06:34 +, Soft Works wrote: > > > > > > -Original Message- > > > > > > From: ffmpeg-devel On Behalf Of > > > > > > Haihao Xiang > > > > > > Sent: Friday, 30 July 2021 04:39 > > > > > > To: ffmpeg-devel@ffmpeg.org > > > > > > Cc: Haihao Xiang > > > > > > Subject: [FFmpeg-devel] [PATCH] lavfi/qsvvpp: do not mix up FFmpeg > > > > > > and SDK error code > > > > > > > > > > > > The function ff_qsvvpp_filter_frame should return a FFmpeg error > > > > > > code if there is an error. However it might return a SDK error code > > > > > > without this patch. > > > > > > --- > > > > > > libavfilter/qsvvpp.c | 15 +-- > > > > > > 1 file changed, 9 insertions(+), 6 deletions(-) > > > > > > > > > > > > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index > > > > > > 4768f6208b..c7ef8a915f 100644 > > > > > > --- a/libavfilter/qsvvpp.c > > > > > > +++ b/libavfilter/qsvvpp.c > > > > > > @@ -807,8 +807,7 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, > > > > > > AVFilterLink *inlink, AVFrame *picr > > > > > > if (MFXVideoCORE_SyncOperation(s->session, sync, 1000) < 0) > > > > > > av_log(ctx, AV_LOG_WARNING, "Sync failed.\n"); > > > > > > > > > > Why no looping and no checking for MFX_WRN_IN_EXECUTION like > > > > > > > > below? > > > > > > > > Thanks for catching this, I think it should check for > > > > MFX_WRN_IN_EXECUTION, but it should be fixed in another patch. > > > > > > OK. > > > > > > > > > > > > > > > filter_ret = s->filter_frame(outlink, tmp->frame); > > > > > > if (filter_ret < 0) { > > > > > > av_frame_free(&tmp->frame); > > > > > > -ret = filter_ret; > > > > > > -break; > > > > > > +return filter_ret; > > > > > > > > > > The title is about not to mix error codes, but this is a behavioral > > > > > change. > > > > > After the patch, the input frame would no longer be processed in case > > > > > of a sync error. > > > > > > > > The condition is 's->eof && qsv_fifo_size(s->async_fifo)'. When s->eof > > > > is > > > > true, the input frame is actually NULL. So without this patch, this > > > > function > > > > returns 0 for this case, the error code is ignored. > > > > > > My bad, I missed the eof condition. > > > > > > > > > All details clarified. Patch LGTM. > > > > Could someone merge this patch if no more comments, please? > > > > Thanks > > Haihao > > Pushed. Thanks James. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavcodec/qsvence: Use QSV encoder defaults as ffmpeg defaults
> -Original Message- > From: ffmpeg-devel On Behalf Of > Xiang, Haihao > Sent: Monday, 9 August 2021 05:00 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/qsvence: Use QSV encoder > defaults as ffmpeg defaults > > On Sat, 2021-08-07 at 03:50 +, Soft Works wrote: > > Signed-off-by: softworkz > > --- > > libavcodec/qsvenc.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index > > fc8a14143e..7f729ce2ba 100644 > > --- a/libavcodec/qsvenc.h > > +++ b/libavcodec/qsvenc.h > > @@ -76,8 +76,8 @@ > > > > #define QSV_COMMON_OPTS \ > > { "async_depth", "Maximum processing parallelism", > > OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = > ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VE > > }, \ > > -{ "avbr_accuracy","Accuracy of the AVBR > > ratecontrol",OFFSET(qsv.avbr_accuracy),AV_OPT_TYPE_INT, { .i64 = 0 > > }, > > 0, INT_MAX, VE }, \ > > -{ "avbr_convergence", "Convergence of the AVBR ratecontrol", > > OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, > INT_MAX, VE > > }, \ > > +{ "avbr_accuracy","Accuracy of the AVBR ratecontrol (unit of tenth of > > percent)",OFFSET(qsv.avbr_accuracy),AV_OPT_TYPE_INT, { .i64 = 1 }, > > 0, > > INT_MAX, VE }, \ > > +{ "avbr_convergence", "Convergence of the AVBR ratecontrol (unit of > > +100 > > frames)", OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 1 }, > 0, > > INT_MAX, VE }, \ > > { "preset", NULL, OFFSET(qsv.preset), AV_OPT_TYPE_INT, { .i64 = > > MFX_TARGETUSAGE_BALANCED }, MFX_TARGETUSAGE_BEST_QUALITY, > > MFX_TARGETUSAGE_BEST_SPEED, VE, "preset" }, \ > > { "veryfast",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = > > MFX_TARGETUSAGE_BEST_SPEED }, INT_MIN, INT_MAX, VE, "preset" > > },\ > > { "faster", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = > > MFX_TARGETUSAGE_6 },INT_MIN, INT_MAX, VE, "preset" }, > > The range is [1, 65535] for both Accuracy and Convergence in the SDK, could > you change the range in options ? Sure, will do. I wonder what the logical maxima are, e.g. for accuracy, can there be an accuracy > 100% ? softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".