[FFmpeg-cvslog] avfilter/vf_xmedian: add timeline support

2020-12-30 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Dec 30 15:33:50 
2020 +0100| [9ac31b419cb35e755a59675479ba6207cf666c89] | committer: Paul B Mahol

avfilter/vf_xmedian: add timeline support

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9ac31b419cb35e755a59675479ba6207cf666c89
---

 libavfilter/vf_xmedian.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_xmedian.c b/libavfilter/vf_xmedian.c
index 0c4d4ab047..7794f8cb43 100644
--- a/libavfilter/vf_xmedian.c
+++ b/libavfilter/vf_xmedian.c
@@ -244,14 +244,20 @@ static int process_frame(FFFrameSync *fs)
 return ret;
 }
 
-out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
+if (ctx->is_disabled) {
+out = av_frame_clone(in[0]);
+} else {
+out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
+}
 if (!out)
 return AVERROR(ENOMEM);
 out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
 
-td.in = in;
-td.out = out;
-ctx->internal->execute(ctx, s->median_frames, &td, NULL, 
FFMIN(s->height[1], ff_filter_get_nb_threads(ctx)));
+if (!ctx->is_disabled) {
+td.in = in;
+td.out = out;
+ctx->internal->execute(ctx, s->median_frames, &td, NULL, 
FFMIN(s->height[1], ff_filter_get_nb_threads(ctx)));
+}
 
 return ff_filter_frame(outlink, out);
 }
@@ -395,7 +401,8 @@ AVFilter ff_vf_xmedian = {
 .init  = init,
 .uninit= uninit,
 .activate  = activate,
-.flags = AVFILTER_FLAG_DYNAMIC_INPUTS | 
AVFILTER_FLAG_SLICE_THREADS,
+.flags = AVFILTER_FLAG_DYNAMIC_INPUTS | 
AVFILTER_FLAG_SLICE_THREADS |
+ AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
 .process_command = process_command,
 };
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] avfilter/vf_xmedian: allow to control eof handling

2020-12-30 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Dec 30 15:51:24 
2020 +0100| [aea3cf4f18d005c01d57d52019f15cf5e84e14ec] | committer: Paul B Mahol

avfilter/vf_xmedian: allow to control eof handling

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aea3cf4f18d005c01d57d52019f15cf5e84e14ec
---

 libavfilter/vf_xmedian.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_xmedian.c b/libavfilter/vf_xmedian.c
index 7794f8cb43..8b6dd69709 100644
--- a/libavfilter/vf_xmedian.c
+++ b/libavfilter/vf_xmedian.c
@@ -322,7 +322,7 @@ static int config_output(AVFilterLink *outlink)
 in[i].time_base = inlink->time_base;
 in[i].sync   = 1;
 in[i].before = EXT_STOP;
-in[i].after  = EXT_STOP;
+in[i].after  = EXT_INFINITY;
 }
 
 ret = ff_framesync_configure(&s->fs);
@@ -389,7 +389,7 @@ static const AVFilterPad outputs[] = {
 };
 
 #if CONFIG_XMEDIAN_FILTER
-AVFILTER_DEFINE_CLASS(xmedian);
+FRAMESYNC_DEFINE_CLASS(xmedian, XMedianContext, fs);
 
 AVFilter ff_vf_xmedian = {
 .name  = "xmedian",
@@ -398,6 +398,7 @@ AVFilter ff_vf_xmedian = {
 .priv_class= &xmedian_class,
 .query_formats = query_formats,
 .outputs   = outputs,
+.preinit   = xmedian_framesync_preinit,
 .init  = init,
 .uninit= uninit,
 .activate  = activate,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] avfilter/vf_w3fdif: add support for commands

2020-12-30 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Dec 30 16:31:19 
2020 +0100| [2f20e35892c866d4e141e73a3e2df16457f9a21a] | committer: Paul B Mahol

avfilter/vf_w3fdif: add support for commands

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f20e35892c866d4e141e73a3e2df16457f9a21a
---

 doc/filters.texi| 3 +++
 libavfilter/vf_w3fdif.c | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 959f5cd22b..435575a5fb 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -20922,6 +20922,9 @@ Only deinterlace frames marked as interlaced.
 Default value is @samp{all}.
 @end table
 
+@subsection Commands
+This filter supports same @ref{commands} as options.
+
 @section waveform
 Video waveform monitor.
 
diff --git a/libavfilter/vf_w3fdif.c b/libavfilter/vf_w3fdif.c
index 5d64dbd953..c7c6984241 100644
--- a/libavfilter/vf_w3fdif.c
+++ b/libavfilter/vf_w3fdif.c
@@ -49,7 +49,7 @@ typedef struct W3FDIFContext {
 } W3FDIFContext;
 
 #define OFFSET(x) offsetof(W3FDIFContext, x)
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+#define FLAGS 
AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, 
{.i64=val}, 0, 0, FLAGS, unit }
 
 static const AVOption w3fdif_options[] = {
@@ -602,4 +602,5 @@ AVFilter ff_vf_w3fdif = {
 .inputs= w3fdif_inputs,
 .outputs   = w3fdif_outputs,
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | 
AVFILTER_FLAG_SLICE_THREADS,
+.process_command = ff_filter_process_command,
 };

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] hwcontext_drm: make dependency on Linux kernel headers optional

2020-12-30 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Dec 30 22:19:16 2020 
+0100| [53c56585a6bebfd1dd73f73ace5d719120822b0a] | committer: Lynne

hwcontext_drm: make dependency on Linux kernel headers optional

This was introduced in version 4.6. And may not exist all without an
optional package. So to prevent a hard dependency on needing the Linux
kernel headers to compile, make this optional.

Also ignore the status of the ioctl, since it may fail on older kernels
which don't support it. It's okay to ignore as its not fatal and any
serious errors will be caught later by the mmap call.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=53c56585a6bebfd1dd73f73ace5d719120822b0a
---

 configure |  4 
 libavutil/hwcontext_drm.c | 50 +++
 2 files changed, 33 insertions(+), 21 deletions(-)

diff --git a/configure b/configure
index 90914752f1..df42f37d08 100755
--- a/configure
+++ b/configure
@@ -2125,6 +2125,7 @@ HEADERS_LIST="
 ES2_gl_h
 gsm_h
 io_h
+linux_dma_buf_h
 linux_perf_event_h
 machine_ioctl_bt848_h
 machine_ioctl_meteor_h
@@ -6151,6 +6152,9 @@ check_headers dxgidebug.h
 check_headers dxva.h
 check_headers dxva2api.h -D_WIN32_WINNT=0x0600
 check_headers io.h
+enabled libdrm &&
+check_headers linux/dma-buf.h
+
 check_headers linux/perf_event.h
 check_headers libcrystalhd/libcrystalhd_if.h
 check_headers malloc.h
diff --git a/libavutil/hwcontext_drm.c b/libavutil/hwcontext_drm.c
index ceacf683a0..7a9fdbd263 100644
--- a/libavutil/hwcontext_drm.c
+++ b/libavutil/hwcontext_drm.c
@@ -16,11 +16,19 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
+
 #include 
 #include 
 #include 
+
+/* This was introduced in version 4.6. And may not exist all without an
+ * optional package. So to prevent a hard dependency on needing the Linux
+ * kernel headers to compile, make this optional. */
+#if HAVE_LINUX_DMA_BUF_H
 #include 
 #include 
+#endif
 
 #include 
 #include 
@@ -97,14 +105,12 @@ static void drm_unmap_frame(AVHWFramesContext *hwfc,
 HWMapDescriptor *hwmap)
 {
 DRMMapping *map = hwmap->priv;
-struct dma_buf_sync sync = { .flags = DMA_BUF_SYNC_END | map->sync_flags };
-int i, ret;
-
-for (i = 0; i < map->nb_regions; i++) {
-ret = ioctl(map->object[i], DMA_BUF_IOCTL_SYNC, &sync);
-if (ret)
-av_log(hwfc, AV_LOG_ERROR, "Failed to issue ioctl sync to DRM 
object "
-   "%d: %d.\n", map->object[i], errno);
+
+for (int i = 0; i < map->nb_regions; i++) {
+#if HAVE_LINUX_DMA_BUF_H
+struct dma_buf_sync sync = { .flags = DMA_BUF_SYNC_END | 
map->sync_flags };
+ioctl(map->object[i], DMA_BUF_IOCTL_SYNC, &sync);
+#endif
 munmap(map->address[i], map->length[i]);
 }
 
@@ -115,7 +121,9 @@ static int drm_map_frame(AVHWFramesContext *hwfc,
  AVFrame *dst, const AVFrame *src, int flags)
 {
 const AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor*)src->data[0];
+#if HAVE_LINUX_DMA_BUF_H
 struct dma_buf_sync sync_start = { 0 };
+#endif
 DRMMapping *map;
 int err, i, p, plane;
 int mmap_prot;
@@ -126,16 +134,18 @@ static int drm_map_frame(AVHWFramesContext *hwfc,
 return AVERROR(ENOMEM);
 
 mmap_prot = 0;
-if (flags & AV_HWFRAME_MAP_READ) {
+if (flags & AV_HWFRAME_MAP_READ)
 mmap_prot |= PROT_READ;
-map->sync_flags |= DMA_BUF_SYNC_READ;
-}
-if (flags & AV_HWFRAME_MAP_WRITE) {
+if (flags & AV_HWFRAME_MAP_WRITE)
 mmap_prot |= PROT_WRITE;
-map->sync_flags |= DMA_BUF_SYNC_WRITE;
-}
 
+#if HAVE_LINUX_DMA_BUF_H
+if (flags & AV_HWFRAME_MAP_READ)
+map->sync_flags |= DMA_BUF_SYNC_READ;
+if (flags & AV_HWFRAME_MAP_WRITE)
+map->sync_flags |= DMA_BUF_SYNC_WRITE;
 sync_start.flags = DMA_BUF_SYNC_START | map->sync_flags;
+#endif
 
 av_assert0(desc->nb_objects <= AV_DRM_MAX_PLANES);
 for (i = 0; i < desc->nb_objects; i++) {
@@ -152,13 +162,11 @@ static int drm_map_frame(AVHWFramesContext *hwfc,
 map->length[i]  = desc->objects[i].size;
 map->object[i] = desc->objects[i].fd;
 
-err = ioctl(desc->objects[i].fd, DMA_BUF_IOCTL_SYNC, &sync_start);
-if (err) {
-err = AVERROR(errno);
-av_log(hwfc, AV_LOG_ERROR, "Failed to issue ioctl sync to DRM 
object "
-   "%d: %d.\n", desc->objects[i].fd, errno);
-goto fail;
-}
+#if HAVE_LINUX_DMA_BUF_H
+/* We're not checking for errors here because the kernel may not
+ * support the ioctl, in which case its okay to carry on */
+ioctl(desc->objects[i].fd, DMA_BUF_IOCTL_SYNC, &sync_start);
+#endif
 }
 map->nb_regions = i;
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsub

[FFmpeg-cvslog] avformat/url: Change () position in ff_make_absolute_url()

2020-12-30 Thread Michael Niedermayer
ffmpeg | branch: release/4.3 | Michael Niedermayer  | 
Wed Dec 16 19:15:12 2020 +0100| [8f3741a5e39f492a499121f14251e94edf398717] | 
committer: Marton Balint

avformat/url: Change () position in ff_make_absolute_url()

No testcase
Reviewed-by: Nicolas George 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit ef59a40c2a0df694cf6f23870f94b6e32deabfe1)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8f3741a5e39f492a499121f14251e94edf398717
---

 libavformat/url.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/url.c b/libavformat/url.c
index 6db4b4e1ae..77d610d95f 100644
--- a/libavformat/url.c
+++ b/libavformat/url.c
@@ -211,8 +211,8 @@ int ff_make_absolute_url(char *buf, int size, const char 
*base,
 
 if (!base)
 base = "";
-if ((ret = ff_url_decompose(&ub, base, NULL) < 0) ||
-(ret = ff_url_decompose(&uc, rel,  NULL) < 0))
+if ((ret = ff_url_decompose(&ub, base, NULL)) < 0 ||
+(ret = ff_url_decompose(&uc, rel,  NULL)) < 0)
 goto error;
 
 keep = ub.url;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] avfilter/vf_framerate: fix infinite loop with 1-frame input

2020-12-30 Thread Marton Balint
ffmpeg | branch: release/4.3 | Marton Balint  | Sun Dec 20 
19:32:56 2020 +0100| [ed735e657704371753aa2e087ac7cfd77db48f78] | committer: 
Marton Balint

avfilter/vf_framerate: fix infinite loop with 1-frame input

Fixes infinite loop in:
ffmpeg -f lavfi -i testsrc=d=0.04 -vf framerate=50 -f null none

Signed-off-by: Marton Balint 
(cherry picked from commit 6d3b70c27ef1639784fdb3382e5a06b1afa3fe3e)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ed735e657704371753aa2e087ac7cfd77db48f78
---

 libavfilter/vf_framerate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index 6c8d01c94b..f5085705a4 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -170,7 +170,9 @@ static int process_work_frame(AVFilterContext *ctx)
 return 0;
 
 if (!s->f0) {
-s->work = av_frame_clone(s->f1);
+av_assert1(s->flush);
+s->work = s->f1;
+s->f1 = NULL;
 } else {
 if (work_pts >= s->pts1 + s->delta && s->flush)
 return 0;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] dnn: fix redefining typedefs and also refine naming with correct prefix

2020-12-30 Thread Guo , Yejun
ffmpeg | branch: master | Guo, Yejun  | Wed Dec 30 
09:37:14 2020 +0800| [8e78d5d394a3cdeb1da195aa901ff2f7b5b1b3ea] | committer: 
Guo, Yejun

dnn: fix redefining typedefs and also refine naming with correct prefix

The prefix for symbols not exported from the library and not
local to one translation unit is ff_ (or FF for types).

Signed-off-by: Guo, Yejun 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8e78d5d394a3cdeb1da195aa901ff2f7b5b1b3ea
---

 libavfilter/dnn/dnn_backend_openvino.c | 32 -
 libavfilter/dnn/queue.c| 66 +-
 libavfilter/dnn/queue.h| 20 +--
 libavfilter/dnn/safe_queue.c   | 34 +-
 libavfilter/dnn/safe_queue.h   | 14 
 5 files changed, 83 insertions(+), 83 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index a35d72a38c..331f13b263 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -53,8 +53,8 @@ typedef struct OVModel{
 ie_infer_request_t *infer_request;
 
 /* for async execution */
-safe_queue *request_queue;  // holds RequestItem
-queue *task_queue;  // holds TaskItem
+FFSafeQueue *request_queue;   // holds RequestItem
+FFQueue *task_queue;  // holds TaskItem
 } OVModel;
 
 typedef struct TaskItem {
@@ -208,7 +208,7 @@ static void infer_completion_callback(void *args)
 
 if (task->async) {
 request->task = NULL;
-safe_queue_push_back(task->ov_model->request_queue, request);
+ff_safe_queue_push_back(task->ov_model->request_queue, request);
 }
 
 task->done = 1;
@@ -417,7 +417,7 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, 
const char *options,
 ctx->options.nireq = av_cpu_count() / 2 + 1;
 }
 
-ov_model->request_queue = safe_queue_create();
+ov_model->request_queue = ff_safe_queue_create();
 if (!ov_model->request_queue) {
 goto err;
 }
@@ -436,10 +436,10 @@ DNNModel *ff_dnn_load_model_ov(const char 
*model_filename, const char *options,
 item->infer_request = request;
 item->callback.completeCallBackFunc = infer_completion_callback;
 item->callback.args = item;
-safe_queue_push_back(ov_model->request_queue, item);
+ff_safe_queue_push_back(ov_model->request_queue, item);
 }
 
-ov_model->task_queue = queue_create();
+ov_model->task_queue = ff_queue_create();
 if (!ov_model->task_queue) {
 goto err;
 }
@@ -527,9 +527,9 @@ DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel 
*model, const char *i
 task->output_name = output_names[0];
 task->out_frame = out_frame;
 task->ov_model = ov_model;
-queue_push_back(ov_model->task_queue, task);
+ff_queue_push_back(ov_model->task_queue, task);
 
-request = safe_queue_pop_front(ov_model->request_queue);
+request = ff_safe_queue_pop_front(ov_model->request_queue);
 if (!request) {
 av_log(ctx, AV_LOG_ERROR, "unable to get infer request.\n");
 return DNN_ERROR;
@@ -541,7 +541,7 @@ DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel 
*model, const char *i
 DNNAsyncStatusType ff_dnn_get_async_result_ov(const DNNModel *model, AVFrame 
**in, AVFrame **out)
 {
 OVModel *ov_model = (OVModel *)model->model;
-TaskItem *task = queue_peek_front(ov_model->task_queue);
+TaskItem *task = ff_queue_peek_front(ov_model->task_queue);
 
 if (!task) {
 return DAST_EMPTY_QUEUE;
@@ -553,7 +553,7 @@ DNNAsyncStatusType ff_dnn_get_async_result_ov(const 
DNNModel *model, AVFrame **i
 
 *in = task->in_frame;
 *out = task->out_frame;
-queue_pop_front(ov_model->task_queue);
+ff_queue_pop_front(ov_model->task_queue);
 av_freep(&task);
 
 return DAST_SUCCESS;
@@ -563,20 +563,20 @@ void ff_dnn_free_model_ov(DNNModel **model)
 {
 if (*model){
 OVModel *ov_model = (OVModel *)(*model)->model;
-while (safe_queue_size(ov_model->request_queue) != 0) {
-RequestItem *item = safe_queue_pop_front(ov_model->request_queue);
+while (ff_safe_queue_size(ov_model->request_queue) != 0) {
+RequestItem *item = 
ff_safe_queue_pop_front(ov_model->request_queue);
 if (item && item->infer_request) {
 ie_infer_request_free(&item->infer_request);
 }
 av_freep(&item);
 }
-safe_queue_destroy(ov_model->request_queue);
+ff_safe_queue_destroy(ov_model->request_queue);
 
-while (queue_size(ov_model->task_queue) != 0) {
-TaskItem *item = queue_pop_front(ov_model->task_queue);
+while (ff_queue_size(ov_model->task_queue) != 0) {
+TaskItem *item = ff_queue_pop_front(ov_model->task_queue);
 av_freep(&item);
 }
-queue_destroy(ov_model->task_queue);
+ff_queue_destroy(ov_mod

[FFmpeg-cvslog] dnn: fix issue when pthread is not supported

2020-12-30 Thread Guo , Yejun
ffmpeg | branch: master | Guo, Yejun  | Wed Dec 30 
10:47:29 2020 +0800| [97f520b700b9c250883bf6e3a06fbb6ebffc3c91] | committer: 
Guo, Yejun

dnn: fix issue when pthread is not supported

Signed-off-by: Guo, Yejun 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=97f520b700b9c250883bf6e3a06fbb6ebffc3c91
---

 libavfilter/dnn/safe_queue.c| 50 -
 libavfilter/vf_dnn_processing.c |  7 ++
 2 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/libavfilter/dnn/safe_queue.c b/libavfilter/dnn/safe_queue.c
index 52a60982b5..559b939ec9 100644
--- a/libavfilter/dnn/safe_queue.c
+++ b/libavfilter/dnn/safe_queue.c
@@ -25,10 +25,28 @@
 #include "libavutil/avassert.h"
 #include "libavutil/thread.h"
 
+#if HAVE_PTHREAD_CANCEL
+#define DNNCond pthread_cond_t
+#define dnn_cond_init pthread_cond_init
+#define dnn_cond_destroy pthread_cond_destroy
+#define dnn_cond_signal pthread_cond_signal
+#define dnn_cond_wait pthread_cond_wait
+#else
+#define DNNCond char
+static inline int dnn_cond_init(DNNCond *cond, const void *attr) { return 0; }
+static inline int dnn_cond_destroy(DNNCond *cond) { return 0; }
+static inline int dnn_cond_signal(DNNCond *cond) { return 0; }
+static inline int dnn_cond_wait(DNNCond *cond, AVMutex *mutex)
+{
+av_assert0(!"should not reach here");
+return 0;
+}
+#endif
+
 struct FFSafeQueue {
 FFQueue *q;
-pthread_mutex_t mutex;
-pthread_cond_t cond;
+AVMutex mutex;
+DNNCond cond;
 };
 
 FFSafeQueue *ff_safe_queue_create(void)
@@ -41,8 +59,8 @@ FFSafeQueue *ff_safe_queue_create(void)
 if (!sq->q)
 return NULL;
 
-pthread_mutex_init(&sq->mutex, NULL);
-pthread_cond_init(&sq->cond, NULL);
+ff_mutex_init(&sq->mutex, NULL);
+dnn_cond_init(&sq->cond, NULL);
 return sq;
 }
 
@@ -52,8 +70,8 @@ void ff_safe_queue_destroy(FFSafeQueue *sq)
 return;
 
 ff_queue_destroy(sq->q);
-pthread_mutex_destroy(&sq->mutex);
-pthread_cond_destroy(&sq->cond);
+ff_mutex_destroy(&sq->mutex);
+dnn_cond_destroy(&sq->cond);
 av_freep(&sq);
 }
 
@@ -64,29 +82,29 @@ size_t ff_safe_queue_size(FFSafeQueue *sq)
 
 void ff_safe_queue_push_front(FFSafeQueue *sq, void *v)
 {
-pthread_mutex_lock(&sq->mutex);
+ff_mutex_lock(&sq->mutex);
 ff_queue_push_front(sq->q, v);
-pthread_cond_signal(&sq->cond);
-pthread_mutex_unlock(&sq->mutex);
+dnn_cond_signal(&sq->cond);
+ff_mutex_unlock(&sq->mutex);
 }
 
 void ff_safe_queue_push_back(FFSafeQueue *sq, void *v)
 {
-pthread_mutex_lock(&sq->mutex);
+ff_mutex_lock(&sq->mutex);
 ff_queue_push_back(sq->q, v);
-pthread_cond_signal(&sq->cond);
-pthread_mutex_unlock(&sq->mutex);
+dnn_cond_signal(&sq->cond);
+ff_mutex_unlock(&sq->mutex);
 }
 
 void *ff_safe_queue_pop_front(FFSafeQueue *sq)
 {
 void *value;
-pthread_mutex_lock(&sq->mutex);
+ff_mutex_lock(&sq->mutex);
 while (ff_queue_size(sq->q) == 0) {
-pthread_cond_wait(&sq->cond, &sq->mutex);
+dnn_cond_wait(&sq->cond, &sq->mutex);
 }
 value = ff_queue_pop_front(sq->q);
-pthread_cond_signal(&sq->cond);
-pthread_mutex_unlock(&sq->mutex);
+dnn_cond_signal(&sq->cond);
+ff_mutex_unlock(&sq->mutex);
 return value;
 }
diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter/vf_dnn_processing.c
index da4508b50e..fff5696a31 100644
--- a/libavfilter/vf_dnn_processing.c
+++ b/libavfilter/vf_dnn_processing.c
@@ -110,6 +110,13 @@ static av_cold int init(AVFilterContext *context)
 av_log(ctx, AV_LOG_WARNING, "this backend does not support async 
execution, roll back to sync.\n");
 }
 
+#if !HAVE_PTHREAD_CANCEL
+if (ctx->async) {
+ctx->async = 0;
+av_log(ctx, AV_LOG_WARNING, "pthread is not supported, roll back to 
sync.\n");
+}
+#endif
+
 return 0;
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] dnn/queue: add error check and cleanup

2020-12-30 Thread Guo , Yejun
ffmpeg | branch: master | Guo, Yejun  | Wed Dec 30 
13:11:27 2020 +0800| [6b0cfa8399d34e34ba68d98a837dec82c88d49c6] | committer: 
Guo, Yejun

dnn/queue: add error check and cleanup

Signed-off-by: Guo, Yejun 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6b0cfa8399d34e34ba68d98a837dec82c88d49c6
---

 libavfilter/dnn/dnn_backend_openvino.c | 16 +---
 libavfilter/dnn/queue.c| 28 ++--
 libavfilter/dnn/queue.h|  4 ++--
 libavfilter/dnn/safe_queue.c   | 16 +++-
 libavfilter/dnn/safe_queue.h   |  4 ++--
 5 files changed, 50 insertions(+), 18 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 331f13b263..d27e451eea 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -208,7 +208,10 @@ static void infer_completion_callback(void *args)
 
 if (task->async) {
 request->task = NULL;
-ff_safe_queue_push_back(task->ov_model->request_queue, request);
+if (ff_safe_queue_push_back(task->ov_model->request_queue, request) < 
0) {
+av_log(ctx, AV_LOG_ERROR, "Failed to push back request_queue.\n");
+return;
+}
 }
 
 task->done = 1;
@@ -436,7 +439,10 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, 
const char *options,
 item->infer_request = request;
 item->callback.completeCallBackFunc = infer_completion_callback;
 item->callback.args = item;
-ff_safe_queue_push_back(ov_model->request_queue, item);
+if (ff_safe_queue_push_back(ov_model->request_queue, item) < 0) {
+av_freep(&item);
+goto err;
+}
 }
 
 ov_model->task_queue = ff_queue_create();
@@ -527,7 +533,11 @@ DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel 
*model, const char *i
 task->output_name = output_names[0];
 task->out_frame = out_frame;
 task->ov_model = ov_model;
-ff_queue_push_back(ov_model->task_queue, task);
+if (ff_queue_push_back(ov_model->task_queue, task) < 0) {
+av_freep(&task);
+av_log(ctx, AV_LOG_ERROR, "unable to push back task_queue.\n");
+return DNN_ERROR;
+}
 
 request = ff_safe_queue_pop_front(ov_model->request_queue);
 if (!request) {
diff --git a/libavfilter/dnn/queue.c b/libavfilter/dnn/queue.c
index aa912b6f3a..e64f567906 100644
--- a/libavfilter/dnn/queue.c
+++ b/libavfilter/dnn/queue.c
@@ -40,8 +40,8 @@ struct FFQueue {
 static inline FFQueueEntry *create_entry(void *val)
 {
 FFQueueEntry *entry = av_malloc(sizeof(*entry));
-av_assert0(entry != NULL);
-entry->value = val;
+if (entry)
+entry->value = val;
 return entry;
 }
 
@@ -53,6 +53,14 @@ FFQueue* ff_queue_create(void)
 
 q->head = create_entry(q);
 q->tail = create_entry(q);
+
+if (!q->head || !q->tail) {
+av_freep(&q->head);
+av_freep(&q->tail);
+av_freep(&q);
+return NULL;
+}
+
 q->head->next = q->tail;
 q->tail->prev = q->head;
 q->head->prev = NULL;
@@ -99,14 +107,16 @@ void *ff_queue_peek_back(FFQueue *q)
 return q->tail->prev->value;
 }
 
-void ff_queue_push_front(FFQueue *q, void *v)
+int ff_queue_push_front(FFQueue *q, void *v)
 {
 FFQueueEntry *new_entry;
 FFQueueEntry *original_next;
 if (!q)
-return;
+return 0;
 
 new_entry = create_entry(v);
+if (!new_entry)
+return -1;
 original_next = q->head->next;
 
 q->head->next = new_entry;
@@ -114,16 +124,20 @@ void ff_queue_push_front(FFQueue *q, void *v)
 new_entry->prev = q->head;
 new_entry->next = original_next;
 q->length++;
+
+return q->length;
 }
 
-void ff_queue_push_back(FFQueue *q, void *v)
+int ff_queue_push_back(FFQueue *q, void *v)
 {
 FFQueueEntry *new_entry;
 FFQueueEntry *original_prev;
 if (!q)
-return;
+return 0;
 
 new_entry = create_entry(v);
+if (!new_entry)
+return -1;
 original_prev = q->tail->prev;
 
 q->tail->prev = new_entry;
@@ -131,6 +145,8 @@ void ff_queue_push_back(FFQueue *q, void *v)
 new_entry->next = q->tail;
 new_entry->prev = original_prev;
 q->length++;
+
+return q->length;
 }
 
 void *ff_queue_pop_front(FFQueue *q)
diff --git a/libavfilter/dnn/queue.h b/libavfilter/dnn/queue.h
index 5703cef58c..df913d91ac 100644
--- a/libavfilter/dnn/queue.h
+++ b/libavfilter/dnn/queue.h
@@ -32,8 +32,8 @@ size_t ff_queue_size(FFQueue *q);
 void *ff_queue_peek_front(FFQueue *q);
 void *ff_queue_peek_back(FFQueue *q);
 
-void ff_queue_push_front(FFQueue *q, void *v);
-void ff_queue_push_back(FFQueue *q, void *v);
+int ff_queue_push_front(FFQueue *q, void *v);
+int ff_queue_push_back(FFQueue *q, void *v);
 
 void *ff_queue_pop_front(FFQueue *q);
 void *ff_queue_pop_back(FFQueue *q);
diff --git a/libavfilter/dnn/safe_queue.c b/libavfilter/dnn/safe_queu

[FFmpeg-cvslog] dnn_interface.h: fix redefining typedefs

2020-12-30 Thread Guo , Yejun
ffmpeg | branch: master | Guo, Yejun  | Thu Dec 31 
09:19:39 2020 +0800| [477dd2df60e6419ad8776a9865c421e8d42f68fe] | committer: 
Guo, Yejun

dnn_interface.h: fix redefining typedefs

Signed-off-by: Guo, Yejun 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=477dd2df60e6419ad8776a9865c421e8d42f68fe
---

 libavfilter/dnn_interface.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/dnn_interface.h b/libavfilter/dnn_interface.h
index 1e2842425a..9533c88829 100644
--- a/libavfilter/dnn_interface.h
+++ b/libavfilter/dnn_interface.h
@@ -28,7 +28,7 @@
 
 #include 
 #include "libavutil/frame.h"
-typedef struct AVFilterContext AVFilterContext;
+#include "avfilter.h"
 
 typedef enum {DNN_SUCCESS, DNN_ERROR} DNNReturnType;
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".