[FFmpeg-devel] [PATCH 3/3] lavc/qsv: add memory type message

2019-09-19 Thread Zhong Li
Signed-off-by: Zhong Li 
---
 libavcodec/qsv.c  | 29 +
 libavcodec/qsv_internal.h |  3 +++
 libavcodec/qsvdec.c   |  2 ++
 3 files changed, 34 insertions(+)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 87ff694030..9c5a0647c9 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -137,6 +137,35 @@ int ff_qsv_level_to_mfx(enum AVCodecID codec_id, int level)
 }
 }
 
+static const struct {
+  int mfx_iopattern;
+  const char *desc;
+} qsv_iopatterns[] = {
+{MFX_IOPATTERN_IN_VIDEO_MEMORY, "input is video memory surface"
 },
+{MFX_IOPATTERN_IN_SYSTEM_MEMORY,"input is system memory surface"   
 },
+{MFX_IOPATTERN_IN_OPAQUE_MEMORY,"input is opaque memory surface"   
 },
+{MFX_IOPATTERN_OUT_VIDEO_MEMORY,"output is video memory surface"   
 },
+{MFX_IOPATTERN_OUT_SYSTEM_MEMORY,   "output is system memory surface"  
 },
+{MFX_IOPATTERN_OUT_OPAQUE_MEMORY,   "output is opaque memory surface"  
 },
+};
+
+int ff_qsv_print_iopattern(void *log_ctx, int mfx_iopattern,
+   const char *extra_string)
+{
+const char *desc = NULL;
+
+for (int i = 0; i < FF_ARRAY_ELEMS(qsv_iopatterns); i++) {
+if (qsv_iopatterns[i].mfx_iopattern == mfx_iopattern) {
+desc = qsv_iopatterns[i].desc;
+}
+}
+if (!desc)
+desc = "unknown iopattern";
+
+av_log(log_ctx, AV_LOG_VERBOSE, "%s: %s\n", extra_string, desc);
+return 0;
+}
+
 static const struct {
 mfxStatus   mfxerr;
 int averr;
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 62885134b1..8b44a9b6f4 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -101,6 +101,9 @@ typedef struct QSVFramesContext {
 int  nb_mids;
 } QSVFramesContext;
 
+int ff_qsv_print_iopattern(void *log_ctx, int mfx_iopattern,
+   const char *extra_string);
+
 /**
  * Convert a libmfx error code into an ffmpeg error code.
  */
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 2fce478d63..9299596e33 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -193,6 +193,8 @@ static int qsv_decode_preinit(AVCodecContext *avctx, 
QSVContext *q, enum AVPixel
 iopattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
 q->iopattern = iopattern;
 
+ff_qsv_print_iopattern(avctx, q->iopattern, "Decoder");
+
 ret = qsv_init_session(avctx, q, session, avctx->hw_frames_ctx, 
avctx->hw_device_ctx);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "Error initializing an MFX session\n");
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 2/3] lavc/qsv: Fix MSDK initialization failure in system memory mode

2019-09-19 Thread Zhong Li
MSDK does not create internal acceleration device on Linux,
So MFXVideoCORE_SetHandle() is necessary.
It has been added for ff_qsv_init_session_device().
But missed for ff_qsv_init_internal_session() due to commit
1f26a23 overwrited commit db89f45

Fix #7030

Signed-off-by: Zhong Li 
---
 libavcodec/qsv.c  | 62 ---
 libavcodec/qsv_internal.h | 28 +-
 libavcodec/qsvdec.c   | 29 +-
 libavcodec/qsvdec.h   |  2 +-
 libavcodec/qsvenc.c   | 17 +--
 libavcodec/qsvenc.h   |  2 +-
 6 files changed, 109 insertions(+), 31 deletions(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 65ad070e1f..87ff694030 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -348,7 +348,41 @@ load_plugin_fail:
 
 }
 
-int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
+//This code is only required for Linux since a display handle is required.
+//For Windows the session is complete and ready to use.
+
+#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
+static int ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs)
+{
+AVDictionary *child_device_opts = NULL;
+AVVAAPIDeviceContext *hwctx;
+int ret;
+
+av_dict_set(_device_opts, "kernel_driver", "i915", 0);
+av_dict_set(_device_opts, "driver","iHD",  0);
+
+ret = av_hwdevice_ctx_create(>va_device_ref, AV_HWDEVICE_TYPE_VAAPI, 
NULL, child_device_opts, 0);
+if (ret < 0) {
+   av_log(avctx, AV_LOG_ERROR, "Failed to create a VAAPI device.\n");
+return ret;
+} else {
+qs->va_device_ctx = (AVHWDeviceContext*)qs->va_device_ref->data;
+hwctx = qs->va_device_ctx->hwctx;
+
+   ret = MFXVideoCORE_SetHandle(qs->session,
+   (mfxHandleType)MFX_HANDLE_VA_DISPLAY, (mfxHDL)hwctx->display);
+   if (ret < 0) {
+   return ff_qsv_print_error(avctx, ret, "Error during set display 
handle\n");
+   }
+}
+
+av_dict_free(_device_opts);
+
+return 0;
+}
+#endif //AVCODEC_QSV_LINUX_SESSION_HANDLE
+
+int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs,
  const char *load_plugins)
 {
 mfxIMPL impl   = MFX_IMPL_AUTO_ANY;
@@ -357,18 +391,24 @@ int ff_qsv_init_internal_session(AVCodecContext *avctx, 
mfxSession *session,
 const char *desc;
 int ret;
 
-ret = MFXInit(impl, , session);
+ret = MFXInit(impl, , >session);
 if (ret < 0)
 return ff_qsv_print_error(avctx, ret,
   "Error initializing an internal MFX 
session");
 
-ret = qsv_load_plugins(*session, load_plugins, avctx);
+#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
+ret = ff_qsv_set_display_handle(avctx, qs);
+if (ret < 0)
+return ret;
+#endif
+
+ret = qsv_load_plugins(qs->session, load_plugins, avctx);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "Error loading plugins\n");
 return ret;
 }
 
-MFXQueryIMPL(*session, );
+MFXQueryIMPL(qs->session, );
 
 switch (MFX_IMPL_BASETYPE(impl)) {
 case MFX_IMPL_SOFTWARE:
@@ -758,3 +798,17 @@ int ff_qsv_init_session_frames(AVCodecContext *avctx, 
mfxSession *psession,
 *psession = session;
 return 0;
 }
+
+int ff_qsv_close_internal_session(QSVSession *qs)
+{
+if (qs->session) {
+MFXClose(qs->session);
+qs->session = NULL;
+}
+#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
+if (qs->va_device_ctx) {
+qs->va_device_ctx->free(qs->va_device_ctx);
+}
+#endif
+return 0;
+}
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index c50e9c792c..62885134b1 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -21,6 +21,22 @@
 #ifndef AVCODEC_QSV_INTERNAL_H
 #define AVCODEC_QSV_INTERNAL_H
 
+#if CONFIG_VAAPI
+#define AVCODEC_QSV_LINUX_SESSION_HANDLE
+#endif //CONFIG_VAAPI
+
+#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
+#include 
+#include 
+#if HAVE_UNISTD_H
+#include 
+#endif
+#include 
+#include 
+#include 
+#include "libavutil/hwcontext_vaapi.h"
+#endif
+
 #include 
 
 #include "libavutil/frame.h"
@@ -64,6 +80,14 @@ typedef struct QSVFrame {
 struct QSVFrame *next;
 } QSVFrame;
 
+typedef struct QSVSession {
+mfxSession session;
+#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
+AVBufferRef *va_device_ref;
+AVHWDeviceContext *va_device_ctx;
+#endif
+} QSVSession;
+
 typedef struct QSVFramesContext {
 AVBufferRef *hw_frames_ctx;
 void *logctx;
@@ -99,9 +123,11 @@ enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type);
 
 enum AVFieldOrder ff_qsv_map_picstruct(int mfx_pic_struct);
 
-int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
+int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs,
  const char *load_plugins);
 
+int ff_qsv_close_internal_session(QSVSession *qs);
+
 int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession,
  

[FFmpeg-devel] [PATCH 1/3] lavu/qsv: remove redundant version query

2019-09-19 Thread Zhong Li
Signed-off-by: Zhong Li 
---
 libavutil/hwcontext_qsv.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 0329a81ec3..b1b67400de 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1180,11 +1180,6 @@ static int 
qsv_device_derive_from_child(AVHWDeviceContext *ctx,
 goto fail;
 }
 
-ret = MFXQueryVersion(hwctx->session,);
-if (ret == MFX_ERR_NONE) {
-av_log(ctx, AV_LOG_VERBOSE, "MFX compile/runtime API: %d.%d/%d.%d\n",
-   MFX_VERSION_MAJOR, MFX_VERSION_MINOR, ver.Major, ver.Minor);
-}
 return 0;
 
 fail:
-- 
2.17.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 4/4] libavfilter/dnn: support multiple outputs for native mode

2019-09-19 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_native.c | 43 +++-
 libavfilter/dnn/dnn_backend_native.h |  2 ++
 2 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 1b0aea2..68fca50 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -38,6 +38,7 @@ static DNNReturnType set_input_output_native(void *model, 
DNNInputData *input, c
 if (network->layers_num <= 0 || network->operands_num <= 0)
 return DNN_ERROR;
 
+/* inputs */
 av_assert0(input->dt == DNN_FLOAT);
 for (int i = 0; i < network->operands_num; ++i) {
 oprd = >operands[i];
@@ -64,6 +65,28 @@ static DNNReturnType set_input_output_native(void *model, 
DNNInputData *input, c
 return DNN_ERROR;
 
 input->data = oprd->data;
+
+/* outputs */
+network->nb_output = 0;
+av_freep(>output_indexes);
+network->output_indexes = av_mallocz_array(nb_output, 
sizeof(*network->output_indexes));
+if (!network->output_indexes)
+return DNN_ERROR;
+
+for (uint32_t i = 0; i < nb_output; ++i) {
+const char *output_name = output_names[i];
+for (int j = 0; j < network->operands_num; ++j) {
+oprd = >operands[j];
+if (strcmp(oprd->name, output_name) == 0) {
+network->output_indexes[network->nb_output++] = j;
+break;
+}
+}
+}
+
+if (network->nb_output != nb_output)
+return DNN_ERROR;
+
 return DNN_SUCCESS;
 }
 
@@ -315,6 +338,7 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel 
*model, DNNData *output
 DepthToSpaceParams *depth_to_space_params;
 LayerPadParams *pad_params;
 DnnLayerMaximumParams *maximum_params;
+uint32_t nb = FFMIN(nb_output, network->nb_output);
 
 if (network->layers_num <= 0 || network->operands_num <= 0)
 return DNN_ERROR;
@@ -348,17 +372,13 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel 
*model, DNNData *output
 }
 }
 
-// native mode does not support multiple outputs yet
-if (nb_output > 1)
-return DNN_ERROR;
-
-/**
- * as the first step, suppose network->operands[network->operands_num - 1] 
is the output operand.
- */
-outputs[0].data = network->operands[network->operands_num - 1].data;
-outputs[0].height = network->operands[network->operands_num - 1].dims[1];
-outputs[0].width = network->operands[network->operands_num - 1].dims[2];
-outputs[0].channels = network->operands[network->operands_num - 1].dims[3];
+for (uint32_t i = 0; i < nb; ++i) {
+DnnOperand *oprd = >operands[network->output_indexes[i]];
+outputs[i].data = oprd->data;
+outputs[i].height = oprd->dims[1];
+outputs[i].width = oprd->dims[2];
+outputs[i].channels = oprd->dims[3];
+}
 
 return DNN_SUCCESS;
 }
@@ -401,6 +421,7 @@ void ff_dnn_free_model_native(DNNModel **model)
 av_freep(>operands[operand].data);
 av_freep(>operands);
 
+av_freep(>output_indexes);
 av_freep();
 av_freep(model);
 }
diff --git a/libavfilter/dnn/dnn_backend_native.h 
b/libavfilter/dnn/dnn_backend_native.h
index b238d18..3f2840c 100644
--- a/libavfilter/dnn/dnn_backend_native.h
+++ b/libavfilter/dnn/dnn_backend_native.h
@@ -96,6 +96,8 @@ typedef struct ConvolutionalNetwork{
 int32_t layers_num;
 DnnOperand *operands;
 int32_t operands_num;
+int32_t *output_indexes;
+uint32_t nb_output;
 } ConvolutionalNetwork;
 
 DNNModel *ff_dnn_load_model_native(const char *model_filename);
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 3/4] libavfilter/dnn/dnn_backend_native: find the input operand according to input name

2019-09-19 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_native.c | 39 +---
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 22a9a33..1b0aea2 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -33,30 +33,37 @@
 static DNNReturnType set_input_output_native(void *model, DNNInputData *input, 
const char *input_name, const char **output_names, uint32_t nb_output)
 {
 ConvolutionalNetwork *network = (ConvolutionalNetwork *)model;
+DnnOperand *oprd = NULL;
 
 if (network->layers_num <= 0 || network->operands_num <= 0)
 return DNN_ERROR;
 
 av_assert0(input->dt == DNN_FLOAT);
+for (int i = 0; i < network->operands_num; ++i) {
+oprd = >operands[i];
+if (strcmp(oprd->name, input_name) == 0) {
+if (oprd->type != DOT_INPUT)
+return DNN_ERROR;
+break;
+}
+oprd = NULL;
+}
 
-/**
- * as the first step, suppose network->operands[0] is the input operand.
- */
-network->operands[0].dims[0] = 1;
-network->operands[0].dims[1] = input->height;
-network->operands[0].dims[2] = input->width;
-network->operands[0].dims[3] = input->channels;
-network->operands[0].type = DOT_INPUT;
-network->operands[0].data_type = DNN_FLOAT;
-network->operands[0].isNHWC = 1;
-
-av_freep(>operands[0].data);
-network->operands[0].length = 
calculate_operand_data_length(>operands[0]);
-network->operands[0].data = av_malloc(network->operands[0].length);
-if (!network->operands[0].data)
+if (!oprd)
+return DNN_ERROR;
+
+oprd->dims[0] = 1;
+oprd->dims[1] = input->height;
+oprd->dims[2] = input->width;
+oprd->dims[3] = input->channels;
+
+av_freep(>data);
+oprd->length = calculate_operand_data_length(oprd);
+oprd->data = av_malloc(oprd->length);
+if (!oprd->data)
 return DNN_ERROR;
 
-input->data = network->operands[0].data;
+input->data = oprd->data;
 return DNN_SUCCESS;
 }
 
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 2/4] FATE/dnn: add unit test for layer maximum

2019-09-19 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 tests/dnn/Makefile |  1 +
 tests/dnn/dnn-layer-maximum-test.c | 71 ++
 tests/fate/dnn.mak |  5 +++
 3 files changed, 77 insertions(+)
 create mode 100644 tests/dnn/dnn-layer-maximum-test.c

diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile
index 3cb5f6d..e1bfe3f 100644
--- a/tests/dnn/Makefile
+++ b/tests/dnn/Makefile
@@ -1,6 +1,7 @@
 DNNTESTPROGS += dnn-layer-pad
 DNNTESTPROGS += dnn-layer-conv2d
 DNNTESTPROGS += dnn-layer-depth2space
+DNNTESTPROGS += dnn-layer-maximum
 
 DNNTESTOBJS  := $(DNNTESTOBJS:%=$(DNNTESTSDIR)%) 
$(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test.o)
 DNNTESTPROGS := $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test$(EXESUF))
diff --git a/tests/dnn/dnn-layer-maximum-test.c 
b/tests/dnn/dnn-layer-maximum-test.c
new file mode 100644
index 000..06daf64
--- /dev/null
+++ b/tests/dnn/dnn-layer-maximum-test.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2019 Guo Yejun
+ *
+ * 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 
+#include 
+#include "libavfilter/dnn/dnn_backend_native_layer_maximum.h"
+
+#define EPSON 0.1
+
+static int test(void)
+{
+DnnLayerMaximumParams params;
+DnnOperand operands[2];
+int32_t input_indexes[1];
+float input[1*1*2*3] = {
+-3, 2.5, 2, -2.1, 7.8, 100
+};
+float *output;
+
+params.val.y = 2.3;
+
+operands[0].data = input;
+operands[0].dims[0] = 1;
+operands[0].dims[1] = 1;
+operands[0].dims[2] = 2;
+operands[0].dims[3] = 3;
+operands[1].data = NULL;
+
+input_indexes[0] = 0;
+dnn_execute_layer_maximum(operands, input_indexes, 1, );
+
+output = operands[1].data;
+for (int i = 0; i < sizeof(input) / sizeof(float); i++) {
+float expected_output = input[i] > params.val.y ? input[i] : 
params.val.y;
+if (fabs(output[i] - expected_output) > EPSON) {
+printf("at index %d, output: %f, expected_output: %f\n", i, 
output[i], expected_output);
+av_freep();
+return 1;
+}
+}
+
+av_freep();
+return 0;
+
+}
+
+int main(int argc, char **argv)
+{
+if (test())
+return 1;
+
+return 0;
+}
diff --git a/tests/fate/dnn.mak b/tests/fate/dnn.mak
index 99578e0..ec60b07 100644
--- a/tests/fate/dnn.mak
+++ b/tests/fate/dnn.mak
@@ -13,6 +13,11 @@ fate-dnn-layer-depth2space: 
$(DNNTESTSDIR)/dnn-layer-depth2space-test$(EXESUF)
 fate-dnn-layer-depth2space: CMD = run 
$(DNNTESTSDIR)/dnn-layer-depth2space-test$(EXESUF)
 fate-dnn-layer-depth2space: CMP = null
 
+FATE_DNN += fate-dnn-layer-maximum
+fate-dnn-layer-maximum: $(DNNTESTSDIR)/dnn-layer-maximum-test$(EXESUF)
+fate-dnn-layer-maximum: CMD = run 
$(DNNTESTSDIR)/dnn-layer-maximum-test$(EXESUF)
+fate-dnn-layer-maximum: CMP = null
+
 FATE-yes += $(FATE_DNN)
 
 fate-dnn: $(FATE_DNN)
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 1/4] libavfilter/dnn: add layer maximum for native mode.

2019-09-19 Thread Guo, Yejun
The reason to add this layer is that it is used by srcnn in vf_sr.
This layer is currently ignored in native mode. After this patch,
we can add multiple outputs support for native mode.

Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/Makefile   |  1 +
 libavfilter/dnn/dnn_backend_native.c   | 36 ++-
 libavfilter/dnn/dnn_backend_native.h   |  6 +--
 libavfilter/dnn/dnn_backend_native_layer_maximum.c | 54 ++
 libavfilter/dnn/dnn_backend_native_layer_maximum.h | 42 +
 libavfilter/dnn/dnn_backend_tf.c   | 47 +++
 tools/python/convert_from_tensorflow.py| 17 ++-
 tools/python/convert_header.py |  2 +-
 8 files changed, 198 insertions(+), 7 deletions(-)
 create mode 100644 libavfilter/dnn/dnn_backend_native_layer_maximum.c
 create mode 100644 libavfilter/dnn/dnn_backend_native_layer_maximum.h

diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
index 63a35e7..721094d 100644
--- a/libavfilter/dnn/Makefile
+++ b/libavfilter/dnn/Makefile
@@ -3,6 +3,7 @@ OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_pad.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_conv2d.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_depth2space.o
+OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_maximum.o
 
 DNN-OBJS-$(CONFIG_LIBTENSORFLOW) += dnn/dnn_backend_tf.o
 
diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index be548c6..22a9a33 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -28,6 +28,7 @@
 #include "dnn_backend_native_layer_pad.h"
 #include "dnn_backend_native_layer_conv2d.h"
 #include "dnn_backend_native_layer_depth2space.h"
+#include "dnn_backend_native_layer_maximum.h"
 
 static DNNReturnType set_input_output_native(void *model, DNNInputData *input, 
const char *input_name, const char **output_names, uint32_t nb_output)
 {
@@ -78,6 +79,7 @@ DNNModel *ff_dnn_load_model_native(const char *model_filename)
 ConvolutionalParams *conv_params;
 DepthToSpaceParams *depth_to_space_params;
 LayerPadParams *pad_params;
+DnnLayerMaximumParams *maximum_params;
 
 model = av_malloc(sizeof(DNNModel));
 if (!model){
@@ -237,6 +239,21 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 network->layers[layer].type = MIRROR_PAD;
 network->layers[layer].params = pad_params;
 break;
+case MAXIMUM:
+maximum_params = av_malloc(sizeof(*maximum_params));
+if (!maximum_params){
+avio_closep(_file_context);
+ff_dnn_free_model_native();
+return NULL;
+}
+maximum_params->val.u32 = avio_rl32(model_file_context);
+dnn_size += 4;
+network->layers[layer].type = MAXIMUM;
+network->layers[layer].params = maximum_params;
+network->layers[layer].input_operand_indexes[0] = 
(int32_t)avio_rl32(model_file_context);
+network->layers[layer].output_operand_index = 
(int32_t)avio_rl32(model_file_context);
+dnn_size += 8;
+break;
 default:
 avio_closep(_file_context);
 ff_dnn_free_model_native();
@@ -290,6 +307,7 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel 
*model, DNNData *output
 ConvolutionalParams *conv_params;
 DepthToSpaceParams *depth_to_space_params;
 LayerPadParams *pad_params;
+DnnLayerMaximumParams *maximum_params;
 
 if (network->layers_num <= 0 || network->operands_num <= 0)
 return DNN_ERROR;
@@ -313,6 +331,11 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel 
*model, DNNData *output
 dnn_execute_layer_pad(network->operands, 
network->layers[layer].input_operand_indexes,
   network->layers[layer].output_operand_index, 
pad_params);
 break;
+case MAXIMUM:
+maximum_params = (DnnLayerMaximumParams 
*)network->layers[layer].params;
+dnn_execute_layer_maximum(network->operands, 
network->layers[layer].input_operand_indexes,
+  network->layers[layer].output_operand_index, 
maximum_params);
+break;
 case INPUT:
 return DNN_ERROR;
 }
@@ -333,10 +356,19 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel 
*model, DNNData *output
 return DNN_SUCCESS;
 }
 
-int32_t calculate_operand_data_length(DnnOperand* operand)
+int32_t calculate_operand_dims_count(const DnnOperand *oprd)
+{
+int32_t result = 1;
+for (int i = 0; i < 4; ++i)
+result *= oprd->dims[i];
+
+return 

[FFmpeg-devel] [PATCH v3 2/3] avfilter/vf_minterpolate: change the default threshold to get better scene change detect result

2019-09-19 Thread lance . lmwang
From: Limin Wang 

 ./ffmpeg -loglevel debug -i ../fate-suite/svq3/Vertical400kbit.sorenson3.mov 
-vf
 minterpolate=fps=60:mi_mode=blend -an -f null -
 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 1600
 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 4120
 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 5780
 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 6700
 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 8140
 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 9740
 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 14060
 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 15680
 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 18480
 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 20020
 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 21740

 The results are consistent with tests/ref/fate/filter-metadata-scenedetect

 For the master, it'll detect more than 20 scene change for the same source.

Signed-off-by: Limin Wang 
---
 doc/filters.texi  | 2 +-
 libavfilter/vf_minterpolate.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 06ce7ec069..fc299f1405 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12743,7 +12743,7 @@ Frame difference. Corresponding pixel values are 
compared and if it satisfies @v
 Default method is @samp{fdiff}.
 
 @item scd_threshold
-Scene change detection threshold. Default is @code{5.0}.
+Scene change detection threshold. Default is @code{10.}.
 @end table
 
 @section mix
diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
index fc8054b710..c9ce80420d 100644
--- a/libavfilter/vf_minterpolate.c
+++ b/libavfilter/vf_minterpolate.c
@@ -230,7 +230,7 @@ static const AVOption minterpolate_options[] = {
 { "scd", "scene change detection method", OFFSET(scd_method), 
AV_OPT_TYPE_INT, {.i64 = SCD_METHOD_FDIFF}, SCD_METHOD_NONE, SCD_METHOD_FDIFF, 
FLAGS, "scene" },
 CONST("none",   "disable detection",
SCD_METHOD_NONE,"scene"),
 CONST("fdiff",  "frame difference", 
SCD_METHOD_FDIFF,   "scene"),
-{ "scd_threshold", "scene change threshold", OFFSET(scd_threshold), 
AV_OPT_TYPE_DOUBLE, {.dbl = 5.0}, 0, 100.0, FLAGS },
+{ "scd_threshold", "scene change threshold", OFFSET(scd_threshold), 
AV_OPT_TYPE_DOUBLE, {.dbl = 10.}, 0, 100.0, FLAGS },
 { NULL }
 };
 
@@ -1097,6 +1097,7 @@ static void interpolate(AVFilterLink *inlink, AVFrame 
*avf_out)
 }
 
 if (mi_ctx->scene_changed) {
+av_log(ctx, AV_LOG_DEBUG, "scene changed, input pts %"PRId64"\n", 
mi_ctx->frames[1].avf->pts);
 /* duplicate frame */
 av_frame_copy(avf_out, alpha > ALPHA_MAX / 2 ? mi_ctx->frames[2].avf : 
mi_ctx->frames[1].avf);
 return;
-- 
2.21.0

___
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 1/3] avfilter/vf_minterpolate: correct the mafd calculation

2019-09-19 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavfilter/vf_minterpolate.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
index b0bb238ade..fc8054b710 100644
--- a/libavfilter/vf_minterpolate.c
+++ b/libavfilter/vf_minterpolate.c
@@ -185,6 +185,7 @@ typedef struct MIContext {
 int64_t out_pts;
 int b_width, b_height, b_count;
 int log2_mb_size;
+int bitdepth;
 
 int scd_method;
 int scene_changed;
@@ -343,6 +344,7 @@ static int config_input(AVFilterLink *inlink)
 
 mi_ctx->log2_chroma_h = desc->log2_chroma_h;
 mi_ctx->log2_chroma_w = desc->log2_chroma_w;
+mi_ctx->bitdepth = desc->comp[0].depth;
 
 mi_ctx->nb_planes = av_pix_fmt_count_planes(inlink->format);
 
@@ -383,7 +385,7 @@ static int config_input(AVFilterLink *inlink)
 }
 
 if (mi_ctx->scd_method == SCD_METHOD_FDIFF) {
-mi_ctx->sad = ff_scene_sad_get_fn(8);
+mi_ctx->sad = ff_scene_sad_get_fn(mi_ctx->bitdepth == 8 ? 8 : 16);
 if (!mi_ctx->sad)
 return AVERROR(EINVAL);
 }
@@ -836,7 +838,7 @@ static int detect_scene_change(MIContext *mi_ctx)
 uint64_t sad;
 mi_ctx->sad(p1, linesize1, p2, linesize2, me_ctx->width, 
me_ctx->height, );
 emms_c();
-mafd = (double) sad / (me_ctx->height * me_ctx->width * 3);
+mafd = (double) sad * 100.0 / (me_ctx->height * me_ctx->width) / (1 << 
mi_ctx->bitdepth);
 diff = fabs(mafd - mi_ctx->prev_mafd);
 ret  = av_clipf(FFMIN(mafd, diff), 0, 100.0);
 mi_ctx->prev_mafd = mafd;
-- 
2.21.0

___
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, v2 2/2] lavc/vaapi_decode: recreate hw_frames_ctx for vp9 without destroy va_context

2019-09-19 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Fu, Linjie
> Sent: Wednesday, September 11, 2019 00:02
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH, v2 2/2] lavc/vaapi_decode: recreate
> hw_frames_ctx for vp9 without destroy va_context
> 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of Mark Thompson
> > Sent: Tuesday, September 10, 2019 08:02
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH, v2 2/2] lavc/vaapi_decode: recreate
> > hw_frames_ctx for vp9 without destroy va_context
> >
> > On 09/09/2019 16:40, Fu, Linjie wrote:
> > >> -Original Message-
> > >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > Behalf
> > >> Of Fu, Linjie
> > >> Sent: Friday, August 30, 2019 16:05
> > >> To: FFmpeg development discussions and patches  > >> de...@ffmpeg.org>
> > >> Subject: Re: [FFmpeg-devel] [PATCH, v2 2/2] lavc/vaapi_decode:
> recreate
> > >> hw_frames_ctx for vp9 without destroy va_context
> > >>
> > >>> -Original Message-
> > >>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > >> Behalf
> > >>> Of Fu, Linjie
> > >>> Sent: Friday, August 9, 2019 19:47
> > >>> To: FFmpeg development discussions and patches  > >>> de...@ffmpeg.org>
> > >>> Subject: Re: [FFmpeg-devel] [PATCH, v2 2/2] lavc/vaapi_decode:
> > recreate
> > >>> hw_frames_ctx for vp9 without destroy va_context
> > >>>
> >  -Original Message-
> >  From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > >>> Behalf
> >  Of Hendrik Leppkes
> >  Sent: Friday, August 9, 2019 17:40
> >  To: FFmpeg development discussions and patches  >  de...@ffmpeg.org>
> >  Subject: Re: [FFmpeg-devel] [PATCH, v2 2/2] lavc/vaapi_decode:
> > >> recreate
> >  hw_frames_ctx for vp9 without destroy va_context
> > 
> >  On Tue, Aug 6, 2019 at 10:55 AM Fu, Linjie 
> wrote:
> > >
> > >> -Original Message-
> > >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org]
> > On
> >  Behalf
> > >> Of Hendrik Leppkes
> > >> Sent: Tuesday, August 6, 2019 16:27
> > >> To: FFmpeg development discussions and patches  > >> de...@ffmpeg.org>
> > >> Subject: Re: [FFmpeg-devel] [PATCH, v2 2/2] lavc/vaapi_decode:
> >  recreate
> > >> hw_frames_ctx for vp9 without destroy va_context
> > >>
> > >> On Thu, Jul 11, 2019 at 10:20 AM Linjie Fu 
> > wrote:
> > >>>
> > >>> VP9 allows resolution changes per frame. Currently in VAAPI,
> > >>> resolution
> > >>> changes leads to va context destroy and reinit. This will cause
> > >>> reference frame surface lost and produce garbage.
> > >>>
> > >>> Though refs surface id could be passed to media driver and found
> > in
> > >>> RTtbl, vp9RefList[] in hal layer has already been destroyed. Thus
> > the
> > >>> new created VaContext could only got an empty RefList.
> > >>>
> > >>> As libva allows re-create surface separately without changing the
> > >>> context, this issue could be handled by only recreating
> > >>> hw_frames_ctx.
> > >>>
> > >>> Set hwaccel_priv_data_keeping flag for vp9 to only recreating
> > >>> hw_frame_ctx when dynamic resolution changing happens.
> > >>>
> > >>> Could be verified by:
> > >>> ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -i
> > >>>   ./resolutions.ivf -pix_fmt p010le -f rawvideo -vframes 20 -y
> > >> vaapi.yuv
> > >>>
> > >>> Signed-off-by: Linjie Fu 
> > >>> ---
> > >>>  libavcodec/decode.c| 10 +-
> > >>>  libavcodec/internal.h  |  1 +
> > >>>  libavcodec/pthread_frame.c |  2 ++
> > >>>  libavcodec/vaapi_decode.c  | 40 ++
> --
> > -
> > >> --
> > >>> --
> >  -
> > >> --
> > >>>  libavcodec/vaapi_vp9.c |  4 
> > >>>  5 files changed, 34 insertions(+), 23 deletions(-)
> > >>>
> > >>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> > >>> index 0863b82..7b15fa5 100644
> > >>> --- a/libavcodec/decode.c
> > >>> +++ b/libavcodec/decode.c
> > >>> @@ -1254,7 +1254,6 @@ int
> > >> ff_decode_get_hw_frames_ctx(AVCodecContext *avctx,
> > >>>
> > >>>  frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx-
> >  data;
> > >>>
> > >>> -
> > >>>  if (frames_ctx->initial_pool_size) {
> > >>>  // We guarantee 4 base work surfaces. The function above
> >  guarantees
> > >> 1
> > >>>  // (the absolute minimum), so add the missing count.
> > >>
> > >> Unrelated whitespace change
> > >
> > > There is  a redundant whitespace here, so I removed it within this
> > patch.
> > >
> > >>> @@ -1333,7 +1332,7 @@ static int hwaccel_init(AVCodecContext
> >  *avctx,
> > >>>  return 

Re: [FFmpeg-devel] [PATCH v2 3/3] FATE: add fate test for minterpolate filter

2019-09-19 Thread Limin Wang
On Sun, Sep 15, 2019 at 07:05:35PM +0200, Michael Niedermayer wrote:
> On Sat, Sep 14, 2019 at 11:37:31AM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  tests/fate/filter-video.mak |  4 
> >  tests/ref/fate/filter-minterpolate-down |  6 ++
> >  tests/ref/fate/filter-minterpolate-up   | 15 +++
> >  3 files changed, 25 insertions(+)
> >  create mode 100644 tests/ref/fate/filter-minterpolate-down
> >  create mode 100644 tests/ref/fate/filter-minterpolate-up
> > 
> > diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
> > index 0c6ee72..ab7b624 100644
> > --- a/tests/fate/filter-video.mak
> > +++ b/tests/fate/filter-video.mak
> > @@ -122,6 +122,10 @@ FATE_FILTER-$(call ALLYES, FRAMERATE_FILTER 
> > TESTSRC2_FILTER FORMAT_FILTER) += fa
> >  fate-filter-framerate-12bit-up: CMD = framecrc -lavfi 
> > testsrc2=r=50:d=1,format=pix_fmts=yuv422p12le,framerate=fps=60 -t 1 
> > -pix_fmt yuv422p12le
> >  fate-filter-framerate-12bit-down: CMD = framecrc -lavfi 
> > testsrc2=r=60:d=1,format=pix_fmts=yuv422p12le,framerate=fps=50 -t 1 
> > -pix_fmt yuv422p12le
> >  
> > +FATE_FILTER-$(call ALLYES, MINTERPOLATE_FILTER TESTSRC2_FILTER) += 
> > fate-filter-minterpolate-up fate-filter-minterpolate-down
> 
> > +fate-filter-minterpolate-up: CMD = framecrc -lavfi 
> > testsrc2=r=2:d=10,framerate=fps=10 -t 1
> > +fate-filter-minterpolate-down: CMD = framecrc -lavfi 
> > testsrc2=r=2:d=10,framerate=fps=1 -t 1
> 
> tested on linux x86_32/64, mingw32/64 arm & mips qemu

Michael, thanks for the testing, I update the commit message to include
the testing result.


> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> When you are offended at any man's fault, turn to yourself and study your
> own failings. Then you will forget your anger. -- Epictetus



> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

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

[FFmpeg-devel] [PATCH v3 3/3] FATE: add fate test for minterpolate filter

2019-09-19 Thread lance . lmwang
From: Limin Wang 

have tested on linux x86_32/64, mingw32/64 arm & mips qemu

Tested-by: Michael Niedermayer 
Signed-off-by: Limin Wang 
---
 tests/fate/filter-video.mak |  4 
 tests/ref/fate/filter-minterpolate-down |  6 ++
 tests/ref/fate/filter-minterpolate-up   | 15 +++
 3 files changed, 25 insertions(+)
 create mode 100644 tests/ref/fate/filter-minterpolate-down
 create mode 100644 tests/ref/fate/filter-minterpolate-up

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 0c6ee72432..ab7b6245a1 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -122,6 +122,10 @@ FATE_FILTER-$(call ALLYES, FRAMERATE_FILTER 
TESTSRC2_FILTER FORMAT_FILTER) += fa
 fate-filter-framerate-12bit-up: CMD = framecrc -lavfi 
testsrc2=r=50:d=1,format=pix_fmts=yuv422p12le,framerate=fps=60 -t 1 -pix_fmt 
yuv422p12le
 fate-filter-framerate-12bit-down: CMD = framecrc -lavfi 
testsrc2=r=60:d=1,format=pix_fmts=yuv422p12le,framerate=fps=50 -t 1 -pix_fmt 
yuv422p12le
 
+FATE_FILTER-$(call ALLYES, MINTERPOLATE_FILTER TESTSRC2_FILTER) += 
fate-filter-minterpolate-up fate-filter-minterpolate-down
+fate-filter-minterpolate-up: CMD = framecrc -lavfi 
testsrc2=r=2:d=10,framerate=fps=10 -t 1
+fate-filter-minterpolate-down: CMD = framecrc -lavfi 
testsrc2=r=2:d=10,framerate=fps=1 -t 1
+
 FATE_FILTER_VSYNTH-$(CONFIG_BOXBLUR_FILTER) += fate-filter-boxblur
 fate-filter-boxblur: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf boxblur=2:1
 
diff --git a/tests/ref/fate/filter-minterpolate-down 
b/tests/ref/fate/filter-minterpolate-down
new file mode 100644
index 00..4eab7aab85
--- /dev/null
+++ b/tests/ref/fate/filter-minterpolate-down
@@ -0,0 +1,6 @@
+#tb 0: 1/1
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 320x240
+#sar 0: 1/1
+0,  0,  0,1,   115200, 0x3744b3ed
diff --git a/tests/ref/fate/filter-minterpolate-up 
b/tests/ref/fate/filter-minterpolate-up
new file mode 100644
index 00..a276bf660d
--- /dev/null
+++ b/tests/ref/fate/filter-minterpolate-up
@@ -0,0 +1,15 @@
+#tb 0: 1/10
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 320x240
+#sar 0: 1/1
+0,  0,  0,1,   115200, 0x3744b3ed
+0,  1,  1,1,   115200, 0xec1fdfa0
+0,  2,  2,1,   115200, 0xa17f0d74
+0,  3,  3,1,   115200, 0xd72532a9
+0,  4,  4,1,   115200, 0x032e60f8
+0,  5,  5,1,   115200, 0x6e318ba0
+0,  6,  6,1,   115200, 0x76018292
+0,  7,  7,1,   115200, 0x89e27599
+0,  8,  8,1,   115200, 0x68536eac
+0,  9,  9,1,   115200, 0xc3ac62a8
-- 
2.21.0

___
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] avutil/avstring: support input path is a null pointer or empty string

2019-09-19 Thread lance . lmwang
From: Limin Wang 

Linux and OSX systems support basename and dirname via , I plan to
make the wrapper interface conform to the standard interface first.
If it is feasible, I will continue to modify it to call the system interface
if there is already a system call interface.

You can get more descrioption about the system interface by below command:
 "man 3 basename"

Reviewed-by: Marton Balint 
Reviewed-by: Tomas Härdin 
Reviewed-by: Liu Steven 
Signed-off-by: Limin Wang 
---
 libavutil/avstring.c | 12 
 libavutil/avstring.h | 13 +
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index 4c068f5..76a13ba 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -257,8 +257,12 @@ char *av_strireplace(const char *str, const char *from, 
const char *to)
 
 const char *av_basename(const char *path)
 {
-char *p = strrchr(path, '/');
+char *p;
 
+if (!path || *path == '\0')
+return ".";
+
+p = strrchr(path, '/');
 #if HAVE_DOS_PATHS
 char *q = strrchr(path, '\\');
 char *d = strchr(path, ':');
@@ -274,11 +278,11 @@ const char *av_basename(const char *path)
 
 const char *av_dirname(char *path)
 {
-char *p = strrchr(path, '/');
+char *p = path ? strrchr(path, '/') : NULL;
 
 #if HAVE_DOS_PATHS
-char *q = strrchr(path, '\\');
-char *d = strchr(path, ':');
+char *q = path ? strrchr(path, '\\') : NULL;
+char *d = path ? strchr(path, ':')  : NULL;
 
 d = d ? d + 1 : d;
 
diff --git a/libavutil/avstring.h b/libavutil/avstring.h
index 37dd4e2..274335c 100644
--- a/libavutil/avstring.h
+++ b/libavutil/avstring.h
@@ -274,16 +274,21 @@ char *av_strireplace(const char *str, const char *from, 
const char *to);
 
 /**
  * Thread safe basename.
- * @param path the path, on DOS both \ and / are considered separators.
+ * @param path the string to parse, on DOS both \ and / are considered 
separators.
  * @return pointer to the basename substring.
+ * If path does not contain a slash, the function returns a copy of path.
+ * If path is a NULL pointer or points to an empty string, a pointer
+ * to a string "." is returned.
  */
 const char *av_basename(const char *path);
 
 /**
  * Thread safe dirname.
- * @param path the path, on DOS both \ and / are considered separators.
- * @return the path with the separator replaced by the string terminator or 
".".
- * @note the function may change the input string.
+ * @param path the string to parse, on DOS both \ and / are considered 
separators.
+ * @return A pointer to a string that's the parent directory of path.
+ * If path is a NULL pointer or points to an empty string, a pointer
+ * to a string "." is returned.
+ * @note the function may modify the contents of the path, so copies should be 
passed.
  */
 const char *av_dirname(char *path);
 
-- 
2.9.5

___
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] lavc/vaapi_decode: Add 4:4:4 8/10 bit decode support for VP9

2019-09-19 Thread Linjie Fu
Add decode support for VP9 4:4:4 8 bit and 10 bit.
Supported since ICL.

Signed-off-by: Linjie Fu 
---
 libavcodec/vaapi_decode.c | 2 ++
 libavcodec/vp9.c  | 6 ++
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 69512e1..1a48e3b 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -396,7 +396,9 @@ static const struct {
 MAP(VP9, VP9_0,   VP9Profile0 ),
 #endif
 #if VA_CHECK_VERSION(0, 39, 0)
+MAP(VP9, VP9_1,   VP9Profile1 ),
 MAP(VP9, VP9_2,   VP9Profile2 ),
+MAP(VP9, VP9_3,   VP9Profile3 ),
 #endif
 #undef MAP
 };
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index f16462b..d9003d8 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -211,6 +211,12 @@ static int update_size(AVCodecContext *avctx, int w, int h)
 *fmtp++ = AV_PIX_FMT_VAAPI;
 #endif
 break;
+case AV_PIX_FMT_YUV444P:
+case AV_PIX_FMT_YUV444P10:
+#if CONFIG_VP9_VAAPI_HWACCEL
+*fmtp++ = AV_PIX_FMT_VAAPI;
+#endif
+break;
 }
 
 *fmtp++ = s->pix_fmt;
-- 
2.7.4

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

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

Re: [FFmpeg-devel] [PATCH]lavfi/movie: Use filter threads as decoding threads

2019-09-19 Thread Carl Eugen Hoyos
Am So., 25. Aug. 2019 um 18:43 Uhr schrieb Carl Eugen Hoyos
:
>
> Am So., 25. Aug. 2019 um 18:38 Uhr schrieb James Almer :
> >
> > On 8/25/2019 1:27 PM, Carl Eugen Hoyos wrote:
> > > Hi!
> > >
> > > Attached patch should fix ticket #7542.
> > >
> > > Please comment, Carl Eugen
> > >
> > >
> > > 0001-lavfi-movie-Use-filter-thread-count-for-decoding-thr.patch
> > >
> > > From 21f3c281dbd9d97ac47ed611958a85881c4b7fba Mon Sep 17 00:00:00 2001
> > > From: Carl Eugen Hoyos 
> > > Date: Sun, 25 Aug 2019 18:12:30 +0200
> > > Subject: [PATCH] lavfi/movie: Use filter thread count for decoding 
> > > threads.
> > >
> > > Fixes ticket #7542.
> > > ---
> > >  libavfilter/src_movie.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
> > > index bcabfcc4c2..78c73e78a4 100644
> > > --- a/libavfilter/src_movie.c
> > > +++ b/libavfilter/src_movie.c
> > > @@ -153,7 +153,7 @@ static AVStream *find_stream(void *log, 
> > > AVFormatContext *avf, const char *spec)
> > >  return found;
> > >  }
> > >
> > > -static int open_stream(void *log, MovieStream *st)
> > > +static int open_stream(AVFilterContext *ctx, MovieStream *st)
> >
> > log is now undeclared. Or rather, it still is for some reason (i guess
> > the function parameter overloaded some global declaration), just not
> > pointing to what you wanted it to.
>
> New patch attached.

Ping.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 05/11] avformat/nutenc: Don't pass NULL to memcmp

2019-09-19 Thread Carl Eugen Hoyos
Am Fr., 20. Sept. 2019 um 00:30 Uhr schrieb Andreas Rheinhardt
:
>
> Fixes lots of FATE tests, e.g. lavf-nut, as well as the nut part of
> ticket #7980.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
> This patch is made to match the previous behaviour; whether the previous
> behaviour is correct at all if the header length is zero is unknown to
> me.
>
>  libavformat/nutenc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
> index e9a3bb49db..dc714eb809 100644
> --- a/libavformat/nutenc.c
> +++ b/libavformat/nutenc.c
> @@ -791,8 +791,9 @@ static int get_needed_flags(NUTContext *nut, 
> StreamContext *nus, FrameCode *fc,
>  flags |= FLAG_CHECKSUM;
>  if (pkt->size < nut->header_len[fc->header_idx] ||
>  (pkt->size > 4096 && fc->header_idx)||
> -memcmp(pkt->data, nut->header[fc->header_idx],
> -   nut->header_len[fc->header_idx]))
> +(nut->header_len[fc->header_idx] > 0 &&
> + memcmp(pkt->data, nut->header[fc->header_idx],
> +nut->header_len[fc->header_idx])))
>  flags |= FLAG_HEADER_IDX;

Is this different from the patch I sent?
(Why does it look different)
https://patchwork.ffmpeg.org/patch/13782/

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 00/11] Fix undefined behaviour

2019-09-19 Thread Carl Eugen Hoyos
Am Fr., 20. Sept. 2019 um 00:23 Uhr schrieb Andreas Rheinhardt
:
>
> 1. When one uses UBSan (Undefined behaviour sanitizer) compiled with the
> -fsanitize-trap=undefined option (that makes the resulting binary trap
> on undefined behaviour instead of simply emitting a warning), lots of
> FATE tests (about 960 on an x64) fail. Over 200 of these are false positives
> because of unaligned accesses inside #ifdef HAVE_FAST_UNALIGNED, but
> even accounting for that, the number is impressive.
>
> 2. ubitux (who runs a FATE box that uses UBSan [1]) has therefore
> proposed that the UBSan toolchain configure options be changed to trap
> by default so that undefined behaviour doesn't go unnoticed. What does
> the community think about this?

Your first paragraph seems to indicate that this is not a good idea,
but maybe I misunderstand: Is unaligned access undefined behaviour?
If yes, how do other projects deal with it?

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 09/11] avcodec/g723_1dec: Fix invalid shift

2019-09-19 Thread Andreas Rheinhardt
Fixes the FATE-tests g723_1-dec-1, g723_1-dec-2 and g723_1-dec-4.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/g723_1dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/g723_1dec.c b/libavcodec/g723_1dec.c
index d8bc3f97ac..d1faf92c39 100644
--- a/libavcodec/g723_1dec.c
+++ b/libavcodec/g723_1dec.c
@@ -1010,7 +1010,7 @@ static int g723_1_decode_frame(AVCodecContext *avctx, 
void *data,
 formant_postfilter(p, lpc, p->audio, out);
 } else { // if output is not postfiltered it should be scaled by 2
 for (i = 0; i < FRAME_LEN; i++)
-out[i] = av_clip_int16(p->audio[LPC_ORDER + i] << 1);
+out[i] = av_clip_int16(2 * p->audio[LPC_ORDER + i]);
 }
 }
 
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 04/11] avcodec/tdsc: Fix undefined shifts

2019-09-19 Thread Andreas Rheinhardt
Fixes the tdsc FATE-test.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/tdsc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c
index 4182404cf0..e9ea41ef55 100644
--- a/libavcodec/tdsc.c
+++ b/libavcodec/tdsc.c
@@ -187,7 +187,7 @@ static void tdsc_paint_cursor(AVCodecContext *avctx, 
uint8_t *dst, int stride)
 static int tdsc_load_cursor(AVCodecContext *avctx)
 {
 TDSCContext *ctx  = avctx->priv_data;
-int i, j, k, ret, bits, cursor_fmt;
+int i, j, k, ret, cursor_fmt;
 uint8_t *dst;
 
 ctx->cursor_hot_x = bytestream2_get_le16(>gbc);
@@ -231,7 +231,7 @@ static int tdsc_load_cursor(AVCodecContext *avctx)
 case CUR_FMT_MONO:
 for (j = 0; j < ctx->cursor_h; j++) {
 for (i = 0; i < ctx->cursor_w; i += 32) {
-bits = bytestream2_get_be32(>gbc);
+uint32_t bits = bytestream2_get_be32(>gbc);
 for (k = 0; k < 32; k++) {
 dst[0] = !!(bits & 0x8000);
 dst   += 4;
@@ -244,7 +244,7 @@ static int tdsc_load_cursor(AVCodecContext *avctx)
 dst = ctx->cursor;
 for (j = 0; j < ctx->cursor_h; j++) {
 for (i = 0; i < ctx->cursor_w; i += 32) {
-bits = bytestream2_get_be32(>gbc);
+uint32_t bits = bytestream2_get_be32(>gbc);
 for (k = 0; k < 32; k++) {
 int mask_bit = !!(bits & 0x8000);
 switch (dst[0] * 2 + mask_bit) {
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH]lavc/opus: Create extradata if it is missing

2019-09-19 Thread Carl Eugen Hoyos
Hi!

Attached patch fixes remuxing opus from sdp, reported by Juan Navarro.

Please comment, Carl Eugen
From 957e568e7dd1c2acc0ea29dad122919c8c9e05ce Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Fri, 20 Sep 2019 00:29:16 +0200
Subject: [PATCH] lavc/opus: Create extradata if it is missing.

Fixes streamcopying from sdp.
Reported-by: Juan Navarro, juan dot navarro at gmx dot es
---
 libavcodec/opus.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavcodec/opus.c b/libavcodec/opus.c
index f74278a7e3..2f1045facb 100644
--- a/libavcodec/opus.c
+++ b/libavcodec/opus.c
@@ -307,12 +307,16 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
"Multichannel configuration without extradata.\n");
 return AVERROR(EINVAL);
 }
-extradata  = opus_default_extradata;
-extradata_size = sizeof(opus_default_extradata);
-} else {
-extradata = avctx->extradata;
-extradata_size = avctx->extradata_size;
+avctx->extradata = av_malloc(sizeof(opus_default_extradata) + AV_INPUT_BUFFER_PADDING_SIZE);
+if (!avctx->extradata)
+return AVERROR(ENOMEM);
+memcpy(avctx->extradata, opus_default_extradata, sizeof(opus_default_extradata));
+memset(avctx->extradata + sizeof(opus_default_extradata), 0, AV_INPUT_BUFFER_PADDING_SIZE);
+avctx->extradata_size = sizeof(opus_default_extradata);
+avctx->extradata[9] = avctx->channels;
 }
+extradata = avctx->extradata;
+extradata_size = avctx->extradata_size;
 
 if (extradata_size < 19) {
 av_log(avctx, AV_LOG_ERROR, "Invalid extradata size: %d\n",
@@ -330,7 +334,7 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
 if (avctx->internal)
 avctx->internal->skip_samples = avctx->delay;
 
-channels = avctx->extradata ? extradata[9] : (avctx->channels == 1) ? 1 : 2;
+channels = extradata[9];
 if (!channels) {
 av_log(avctx, AV_LOG_ERROR, "Zero channel count specified in the extradata\n");
 return AVERROR_INVALIDDATA;
-- 
2.23.0

___
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 02/11] avcodec/mpeg12dec: Sanitize start codes earlier

2019-09-19 Thread Andreas Rheinhardt
The MPEG-1/2 decoder uses avpriv_find_start_code to search for start
codes and worked with the resulting start code before checking that it
is really a start code of a slice. In particular, if the picture is so
big that a slice_vertical_position_extension is present, it added the
slice_vertical_position_extension as if it had a slice. Then a left
shift is performed, without making sure that the value to be shifted is
nonnegative.
Afterwards the end result is checked, but even if a start code of a
non-slice has been found, it might pass these checks: If
slice_vertical_position_extension is present a start code <
SLICE_MIN_START_CODE can lead to a macroblock-row index that appears
valid. Furthermore, the left shift might make an invalid start code
appear valid by discarding the highest bit.
This has been fixed by checking directly after avpriv_find_start_code
has returned.

Fixes ticket #8162 (which is about the undefined left shifts).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg12dec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 83e537884b..1904b75213 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2011,13 +2011,15 @@ static int slice_decode_thread(AVCodecContext *c, void 
*arg)
 
 start_code = -1;
 buf= avpriv_find_start_code(buf, s->gb.buffer_end, 
_code);
+if (start_code < SLICE_MIN_START_CODE || start_code > 
SLICE_MAX_START_CODE)
+return AVERROR_INVALIDDATA;
 mb_y   = start_code - SLICE_MIN_START_CODE;
 if (s->codec_id != AV_CODEC_ID_MPEG1VIDEO && s->mb_height > 2800/16)
 mb_y += (*buf&0xE0)<<2;
 mb_y <<= field_pic;
 if (s->picture_structure == PICT_BOTTOM_FIELD)
 mb_y++;
-if (mb_y < 0 || mb_y >= s->end_mb_y)
+if (mb_y >= s->end_mb_y)
 return AVERROR_INVALIDDATA;
 }
 }
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 07/11] avcodec/pcm: Cosmetics

2019-09-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/pcm.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index d9176732d9..83850cc793 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -300,23 +300,23 @@ static av_cold int pcm_decode_close(AVCodecContext *avctx)
  * @param shift  Bitshift (bits)
  * @param offset Sample value offset
  */
-#define DECODE(size, endian, src, dst, n, shift, offset)\
-for (; n > 0; n--) {\
-uint ## size ## _t v = bytestream_get_ ## endian(); \
-AV_WN ## size ## A(dst, (uint ## size ## _t)(v - offset) << shift); \
-dst += size / 8;\
+#define DECODE(size, endian, src, dst, n, shift, offset)   
\
+for (; n > 0; n--) {   
\
+uint ## size ## _t v = bytestream_get_ ## endian();
\
+AV_WN ## size ## A(dst, (uint ## size ## _t)(v - offset) << shift);
\
+dst += size / 8;   
\
 }
 
-#define DECODE_PLANAR(size, endian, src, dst, n, shift, offset) \
-n /= avctx->channels;   \
-for (c = 0; c < avctx->channels; c++) { \
-int i;  \
-dst = frame->extended_data[c];\
-for (i = n; i > 0; i--) {   \
-uint ## size ## _t v = bytestream_get_ ## endian(); \
+#define DECODE_PLANAR(size, endian, src, dst, n, shift, offset)
\
+n /= avctx->channels;  
\
+for (c = 0; c < avctx->channels; c++) {
\
+int i; 
\
+dst = frame->extended_data[c]; 
\
+for (i = n; i > 0; i--) {  
\
+uint ## size ## _t v = bytestream_get_ ## endian();
\
 AV_WN ## size ## A(dst, (uint ## size ##_t)(v - offset) << shift); 
\
-dst += size / 8;\
-}   \
+dst += size / 8;   
\
+}  
\
 }
 
 static int pcm_decode_frame(AVCodecContext *avctx, void *data,
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 05/11] avformat/nutenc: Don't pass NULL to memcmp

2019-09-19 Thread Andreas Rheinhardt
Fixes lots of FATE tests, e.g. lavf-nut, as well as the nut part of
ticket #7980.

Signed-off-by: Andreas Rheinhardt 
---
This patch is made to match the previous behaviour; whether the previous
behaviour is correct at all if the header length is zero is unknown to
me.

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

diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index e9a3bb49db..dc714eb809 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -791,8 +791,9 @@ static int get_needed_flags(NUTContext *nut, StreamContext 
*nus, FrameCode *fc,
 flags |= FLAG_CHECKSUM;
 if (pkt->size < nut->header_len[fc->header_idx] ||
 (pkt->size > 4096 && fc->header_idx)||
-memcmp(pkt->data, nut->header[fc->header_idx],
-   nut->header_len[fc->header_idx]))
+(nut->header_len[fc->header_idx] > 0 &&
+ memcmp(pkt->data, nut->header[fc->header_idx],
+nut->header_len[fc->header_idx])))
 flags |= FLAG_HEADER_IDX;
 
 return flags | (fc->flags & FLAG_CODED);
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 11/11] avcodec/ac3enc: Fix invalid shift

2019-09-19 Thread Andreas Rheinhardt
Fixes the FATE-tests unknown_layout-ac3, ac3-fixed-encode, ac3-encode
and eac3-encode. It furthermore fixes the ac3-encoder bugs mentioned in
tickets #7994, #8144 and #8159.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ac3enc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index f1c95ce877..76872a8fe0 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1065,7 +1065,7 @@ static int bit_alloc(AC3EncodeContext *s, int snr_offset)
 {
 int blk, ch;
 
-snr_offset = (snr_offset - 240) << 2;
+snr_offset = (snr_offset - 240) * 4;
 
 reset_block_bap(s);
 for (blk = 0; blk < s->num_blocks; blk++) {
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 08/11] avformat/movenc: Fix undefined shift

2019-09-19 Thread Andreas Rheinhardt
Fixes the movenc FATE-test.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/movenc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index edddfeeb00..ce9fc8c5aa 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1,3 +1,4 @@
+
 /*
  * MOV, 3GP, MP4 muxer
  * Copyright (c) 2003 Thomas Raivio
@@ -4511,7 +4512,8 @@ static int mov_write_sidx_tag(AVIOContext *pb,
 {
 int64_t pos = avio_tell(pb), offset_pos, end_pos;
 int64_t presentation_time, duration, offset;
-int starts_with_SAP, i, entries;
+unsigned starts_with_SAP;
+int i, entries;
 
 if (track->entry) {
 entries = 1;
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 10/11] avcodec/truespeech: Fix invalid shifts

2019-09-19 Thread Andreas Rheinhardt
Fixes the truespeech FATE-test as well as the truespeech bugs reported
in ticket #8159.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/truespeech.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c
index d4ddfcbf9c..f08f5f2680 100644
--- a/libavcodec/truespeech.c
+++ b/libavcodec/truespeech.c
@@ -133,7 +133,7 @@ static void truespeech_correlate_filter(TSContext *dec)
 memcpy(tmp, dec->cvector, i * sizeof(*tmp));
 for(j = 0; j < i; j++)
 dec->cvector[j] = ((tmp[i - j - 1] * dec->vector[i]) +
-   (dec->cvector[j] << 15) + 0x4000) >> 15;
+   dec->cvector[j] * (1 << 15) + 0x4000) >> 15;
 }
 dec->cvector[i] = (8 - dec->vector[i]) >> 3;
 }
@@ -256,7 +256,7 @@ static void truespeech_synth(TSContext *dec, int16_t *out, 
int quart)
 int sum = 0;
 for(k = 0; k < 8; k++)
 sum += ptr0[k] * ptr1[k];
-sum = (sum + (out[i] << 12) + 0x800) >> 12;
+sum = (sum + out[i] * (1 << 12) + 0x800) >> 12;
 out[i] = av_clip(sum, -0x7FFE, 0x7FFE);
 for(k = 7; k > 0; k--)
 ptr0[k] = ptr0[k - 1];
@@ -274,7 +274,7 @@ static void truespeech_synth(TSContext *dec, int16_t *out, 
int quart)
 for(k = 7; k > 0; k--)
 ptr0[k] = ptr0[k - 1];
 ptr0[0] = out[i];
-out[i] = ((out[i] << 12) - sum) >> 12;
+out[i] = (out[i] * (1 << 12) - sum) >> 12;
 }
 
 for(i = 0; i < 8; i++)
@@ -282,7 +282,7 @@ static void truespeech_synth(TSContext *dec, int16_t *out, 
int quart)
 
 ptr0 = dec->tmp3;
 for(i = 0; i < 60; i++){
-int sum = out[i] << 12;
+int sum = out[i] * (1 << 12);
 for(k = 0; k < 8; k++)
 sum += ptr0[k] * t[k];
 for(k = 7; k > 0; k--)
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 06/11] avcodec/pcm: Fix undefined shifts

2019-09-19 Thread Andreas Rheinhardt
Fixes the acodec-pcm-u16[lb]e FATE-tests.

Signed-off-by: Andreas Rheinhardt 
---
Changing the macro for planar decoding is actually unnecessary, as none
of the currently used users of this macro need it. I have nevertheless
done so to minimise the changes between the macros.

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

diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index ffcbccc77d..d9176732d9 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -303,7 +303,7 @@ static av_cold int pcm_decode_close(AVCodecContext *avctx)
 #define DECODE(size, endian, src, dst, n, shift, offset)\
 for (; n > 0; n--) {\
 uint ## size ## _t v = bytestream_get_ ## endian(); \
-AV_WN ## size ## A(dst, (v - offset) << shift); \
+AV_WN ## size ## A(dst, (uint ## size ## _t)(v - offset) << shift); \
 dst += size / 8;\
 }
 
@@ -314,7 +314,7 @@ static av_cold int pcm_decode_close(AVCodecContext *avctx)
 dst = frame->extended_data[c];\
 for (i = n; i > 0; i--) {   \
 uint ## size ## _t v = bytestream_get_ ## endian(); \
-AV_WN ## size ## A(dst, (v - offset) << shift); \
+AV_WN ## size ## A(dst, (uint ## size ##_t)(v - offset) << shift); 
\
 dst += size / 8;\
 }   \
 }
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 01/11] avformat/sdsdec: Fix undefined shifts

2019-09-19 Thread Andreas Rheinhardt
An uint8_t gets promoted to an int before left shifting, so that it is
subject to the usual restrictions of signed types wrt shifts. Given that
the destination is an unsigned, simply convert to unsigned before
shifting.

Fixes tickets #8163, #8164 and #8165.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/sdsdec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/sdsdec.c b/libavformat/sdsdec.c
index 9c361cdff2..adc7d02a4d 100644
--- a/libavformat/sdsdec.c
+++ b/libavformat/sdsdec.c
@@ -43,7 +43,7 @@ static void byte2_read(const uint8_t *src, uint32_t *dst)
 int i;
 
 for (i = 0; i < 120; i += 2) {
-unsigned sample = (src[i + 0] << 25) + (src[i + 1] << 18);
+unsigned sample = ((unsigned)src[i + 0] << 25) + (src[i + 1] << 18);
 
 dst[i / 2] = sample;
 }
@@ -56,7 +56,7 @@ static void byte3_read(const uint8_t *src, uint32_t *dst)
 for (i = 0; i < 120; i += 3) {
 unsigned sample;
 
-sample = (src[i + 0] << 25) | (src[i + 1] << 18) | (src[i + 2] << 11);
+sample = ((unsigned)src[i + 0] << 25) | (src[i + 1] << 18) | (src[i + 
2] << 11);
 dst[i / 3] = sample;
 }
 }
@@ -68,7 +68,7 @@ static void byte4_read(const uint8_t *src, uint32_t *dst)
 for (i = 0; i < 120; i += 4) {
 unsigned sample;
 
-sample = (src[i + 0] << 25) | (src[i + 1] << 18) | (src[i + 2] << 11) 
| (src[i + 3] << 4);
+sample = ((unsigned)src[i + 0] << 25) | (src[i + 1] << 18) | (src[i + 
2] << 11) | (src[i + 3] << 4);
 dst[i / 4] = sample;
 }
 }
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 03/11] avcodec/wavpackenc: Fix undefined shifts

2019-09-19 Thread Andreas Rheinhardt
Fixes ticket #8161 and the acodec-wavpack FATE-test.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/wavpackenc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
index 95f4b6530c..0c85fbe374 100644
--- a/libavcodec/wavpackenc.c
+++ b/libavcodec/wavpackenc.c
@@ -529,9 +529,9 @@ static int8_t store_weight(int weight)
 
 static int restore_weight(int8_t weight)
 {
-int result;
+int result = 8 * weight;
 
-if ((result = (int) weight << 3) > 0)
+if (result > 0)
 result += (result + 64) >> 7;
 
 return result;
@@ -2557,7 +2557,7 @@ static int wavpack_encode_block(WavPackEncodeContext *s,
 ret = wv_mono(s, samples_l, !s->num_terms, 1);
 } else {
 for (i = 0; i < nb_samples; i++)
-crc += (crc << 3) + (samples_l[i] << 1) + samples_l[i] + 
samples_r[i];
+crc += (crc << 3) + ((uint32_t)samples_l[i] << 1) + samples_l[i] + 
samples_r[i];
 
 if (s->num_passes)
 ret = wv_stereo(s, samples_l, samples_r, !s->num_terms, 1);
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 00/11] Fix undefined behaviour

2019-09-19 Thread Andreas Rheinhardt
1. When one uses UBSan (Undefined behaviour sanitizer) compiled with the
-fsanitize-trap=undefined option (that makes the resulting binary trap
on undefined behaviour instead of simply emitting a warning), lots of
FATE tests (about 960 on an x64) fail. Over 200 of these are false positives
because of unaligned accesses inside #ifdef HAVE_FAST_UNALIGNED, but
even accounting for that, the number is impressive.

2. ubitux (who runs a FATE box that uses UBSan [1]) has therefore
proposed that the UBSan toolchain configure options be changed to trap
by default so that undefined behaviour doesn't go unnoticed. What does
the community think about this?

3. I have also fixed some of the occurences of undefined behaviour. With
the exception of the mpeg12dec patch all these patches are little
no-brainer.

- Andreas

[1]: 
http://fate.ffmpeg.org/report.cgi?slot=x86_64-archlinux-gcc-ubsan=20190919170122
  

Andreas Rheinhardt (11):
  avformat/sdsdec: Fix undefined shifts
  avcodec/mpeg12dec: Sanitize start codes earlier
  avcodec/wavpackenc: Fix undefined shifts
  avcodec/tdsc: Fix undefined shifts
  avformat/nutenc: Don't pass NULL to memcmp
  avcodec/pcm: Fix undefined shifts
  avcodec/pcm: Cosmetics
  avformat/movenc: Fix undefined shift
  avcodec/g723_1dec: Fix invalid shift
  avcodec/truespeech: Fix invalid shifts
  avcodec/ac3enc: Fix invalid shift

 libavcodec/ac3enc.c |  2 +-
 libavcodec/g723_1dec.c  |  2 +-
 libavcodec/mpeg12dec.c  |  4 +++-
 libavcodec/pcm.c| 30 +++---
 libavcodec/tdsc.c   |  6 +++---
 libavcodec/truespeech.c |  8 
 libavcodec/wavpackenc.c |  6 +++---
 libavformat/movenc.c|  4 +++-
 libavformat/nutenc.c|  5 +++--
 libavformat/sdsdec.c|  6 +++---
 10 files changed, 39 insertions(+), 34 deletions(-)

-- 
2.20.1

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

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

Re: [FFmpeg-devel] Adding ICC profile support to MOV decode/encode

2019-09-19 Thread James Almer
On 9/18/2019 7:27 AM, Hello Vectronic wrote:
> 
> 
>> On 18 Sep 2019, at 11:09, Hendrik Leppkes  wrote:
>>
>> On Wed, Sep 18, 2019 at 11:37 AM Hello Vectronic
>>  wrote:
>>>
>>> Hello,
>>>
>>> I need to implement support for reading and writing ICC profiles which can 
>>> be stored in MOV/MP4 sample descriptor colour information.
>>>
>>> The relevant extract from the ISO standard is:
>>>
>>> class ColourInformationBox extends Box('colr'){
>>>unsigned int(32) colour_type;
>>>if (colour_type == 'nclx')  /* on-screen colours */
>>>{
>>>unsigned int(16) colour_primaries;
>>>unsigned int(16) transfer_characteristics;
>>>unsigned int(16) matrix_coefficients;
>>>unsigned int(1)  full_range_flag;
>>>unsigned int(7)  reserved = 0;
>>>}
>>>else if (colour_type == 'rICC')
>>>{
>>>ICC_profile;// restricted ICC profile
>>>}
>>>else if (colour_type == 'prof')
>>>{
>>>ICC_profile;// unrestricted ICC profile
>>>}
>>> }
>>>
>>> At the moment the code only supports nclc/nclx colour type in:
>>>
>>> libavformat/mov.c  => mov_read_colr()
>>> libavformat/moveenc.c =>  mov_write_colr_tag()
>>>
>>> Support for ICC profile is implemented on a per frame basis in 
>>> AVFrameSideDataType.AV_FRAME_DATA_ICC_PROFILE. This is used by the PNG, 
>>> WEBP and MJPEG codec implementations. The ICC profile in this scenario is 
>>> treated as an opaque octet buffer. I don't believe this is relevant to my 
>>> use case as the colour information within the MOV/MP4 sample descriptor 
>>> relates to the entire stream and is not used on a per-frame basis.
>>>
>>> My thinking is to implement support for ICC profile in a similar way that 
>>> color_range, color_primaries etc. are currently handled:
>>>
>>> 1. Store the ICC profile as an opaque octet buffer stored in an 
>>> AVCodecParameters struct value:
>>>
>>> uint8_t *icc_profile_data;
>>> int icc_profile_size;
>>>
>>
>> Something like this has no place in AVCodecParameters, which is
>> intentionally kept simple and easy. It should be stream-global
>> side-data, similar to the frame side data, just on a stream level,
>> which is already a concept we have, so it should be easy to fit it in
>> there.
>>
>> - Hendrik
>>
> 
> 
> 
> Thanks for the advice. 
> 
> So it seems I would:
> 
> 1. add a new enum value AVPacketSideDataType.AV_PKT_DATA_ICC_PROFILE
> 
> 2. use av_stream_add_side_data() when reading from the MOV/MP4 in 
> libavformat/mov.c => mov_read_colr()
> 
> 3. use av_stream_get_side_data() when writing to the MOV/MP4 in 
> libavformat/moveenc.c => mov_write_colr_tag()
> 
> And I think that is it..?

You may also need to add the new packet side data type to the list in
libavcodec/decode.c:ff_decode_frame_props(), so the icc profiles are
attached to decoded frames. But otherwise, yes, that should be about it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 2/4] avcodec/flac_parser: Make expected_frame_num, expected_sample_num 64bit

2019-09-19 Thread Michael Niedermayer
Fixes: Integer overflow
Fixes: 
17199/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-5696145187143680

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/flac_parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c
index f085159d1d..60145040d5 100644
--- a/libavcodec/flac_parser.c
+++ b/libavcodec/flac_parser.c
@@ -321,7 +321,7 @@ static int check_header_mismatch(FLACParseContext  *fpc,
 (child_fi->frame_or_sample_num
  != header_fi->frame_or_sample_num + 1)) {
 FLACHeaderMarker *curr;
-int expected_frame_num, expected_sample_num;
+int64_t expected_frame_num, expected_sample_num;
 /* If there are frames in the middle we expect this deduction,
as they are probably valid and this one follows it */
 
-- 
2.23.0

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

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

[FFmpeg-devel] [PATCH 4/4] avcodec/jpeglsdec: Apply transform only to initialized lines

2019-09-19 Thread Michael Niedermayer
Fixes: Timeout (110sec -> 1sec)
Fixes: 
17123/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMV_fuzzer-5636452758585344

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/jpeglsdec.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c
index 79f7fc1322..0b1e139048 100644
--- a/libavcodec/jpeglsdec.c
+++ b/libavcodec/jpeglsdec.c
@@ -352,6 +352,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int 
near,
 uint8_t *zero, *last, *cur;
 JLSState *state;
 int off = 0, stride = 1, width, shift, ret = 0;
+int decoded_height = 0;
 
 zero = av_mallocz(s->picture_ptr->linesize[0]);
 if (!zero)
@@ -427,6 +428,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int 
near,
 skip_bits(>gb, 16); /* skip RSTn */
 }
 }
+decoded_height = i;
 } else if (ilv == 1) { /* line interleaving */
 int j;
 int Rc[3] = { 0, 0, 0 };
@@ -452,6 +454,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int 
near,
 last = cur;
 cur += s->picture_ptr->linesize[0];
 }
+decoded_height = i;
 } else if (ilv == 2) { /* sample interleaving */
 avpriv_report_missing_feature(s->avctx, "Sample interleaved images");
 ret = AVERROR_PATCHWELCOME;
@@ -517,7 +520,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int 
near,
 if (s->bits <= 8) {
 uint8_t *src = s->picture_ptr->data[0];
 
-for (i = 0; i < s->height; i++) {
+for (i = 0; i < decoded_height; i++) {
 for (x = off; x < w; x += stride)
 src[x] <<= shift;
 src += s->picture_ptr->linesize[0];
@@ -525,7 +528,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int 
near,
 } else {
 uint16_t *src = (uint16_t *)s->picture_ptr->data[0];
 
-for (i = 0; i < s->height; i++) {
+for (i = 0; i < decoded_height; i++) {
 for (x = 0; x < w; x++)
 src[x] <<= shift;
 src += s->picture_ptr->linesize[0] / 2;
-- 
2.23.0

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

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

[FFmpeg-devel] [PATCH 3/4] avcodec/jpeglsdec: Return error codes from ls_decode_line()

2019-09-19 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavcodec/jpeglsdec.c | 26 ++
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c
index 5308b744df..79f7fc1322 100644
--- a/libavcodec/jpeglsdec.c
+++ b/libavcodec/jpeglsdec.c
@@ -222,7 +222,7 @@ static inline int ls_get_code_runterm(GetBitContext *gb, 
JLSState *state,
 /**
  * Decode one line of image
  */
-static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s,
+static inline int ls_decode_line(JLSState *state, MJpegDecodeContext *s,
   void *last, void *dst, int last2, int w,
   int stride, int comp, int bits)
 {
@@ -234,7 +234,7 @@ static inline void ls_decode_line(JLSState *state, 
MJpegDecodeContext *s,
 int err, pred;
 
 if (get_bits_left(>gb) <= 0)
-return;
+return AVERROR_INVALIDDATA;
 
 /* compute gradients */
 Ra = x ? R(dst, x - stride) : R(last, x);
@@ -263,11 +263,11 @@ static inline void ls_decode_line(JLSState *state, 
MJpegDecodeContext *s,
 }
 /* if EOL reached, we stop decoding */
 if (r != 1 << ff_log2_run[state->run_index[comp]])
-return;
+return 0;
 if (state->run_index[comp] < 31)
 state->run_index[comp]++;
 if (x + stride > w)
-return;
+return 0;
 }
 /* decode aborted run */
 r = ff_log2_run[state->run_index[comp]];
@@ -284,7 +284,7 @@ static inline void ls_decode_line(JLSState *state, 
MJpegDecodeContext *s,
 if (x >= w) {
 av_log(NULL, AV_LOG_ERROR, "run overflow\n");
 av_assert0(x <= w);
-return;
+return AVERROR_INVALIDDATA;
 }
 
 /* decode run termination value */
@@ -341,6 +341,8 @@ static inline void ls_decode_line(JLSState *state, 
MJpegDecodeContext *s,
 W(dst, x, pred);
 x += stride;
 }
+
+return 0;
 }
 
 int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
@@ -407,13 +409,16 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int 
near,
 width  = s->width * stride;
 cur   += off;
 for (i = 0; i < s->height; i++) {
+int ret;
 if (s->bits <= 8) {
-ls_decode_line(state, s, last, cur, t, width, stride, off, 8);
+ret = ls_decode_line(state, s, last, cur, t, width, stride, 
off, 8);
 t = last[0];
 } else {
-ls_decode_line(state, s, last, cur, t, width, stride, off, 16);
+ret = ls_decode_line(state, s, last, cur, t, width, stride, 
off, 16);
 t = *((uint16_t *)last);
 }
+if (ret < 0)
+break;
 last = cur;
 cur += s->picture_ptr->linesize[0];
 
@@ -429,9 +434,12 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int 
near,
 memset(cur, 0, s->picture_ptr->linesize[0]);
 width = s->width * stride;
 for (i = 0; i < s->height; i++) {
+int ret;
 for (j = 0; j < stride; j++) {
-ls_decode_line(state, s, last + j, cur + j,
+ret = ls_decode_line(state, s, last + j, cur + j,
Rc[j], width, stride, j, 8);
+if (ret < 0)
+break;
 Rc[j] = last[j];
 
 if (s->restart_interval && !--s->restart_count) {
@@ -439,6 +447,8 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int 
near,
 skip_bits(>gb, 16); /* skip RSTn */
 }
 }
+if (ret < 0)
+break;
 last = cur;
 cur += s->picture_ptr->linesize[0];
 }
-- 
2.23.0

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

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

[FFmpeg-devel] [PATCH 1/4] avcodec/flac_parser: do not over-decrement nb_headers_buffered

2019-09-19 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
15400/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-5669509794365440

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/flac_parser.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c
index 2721286464..f085159d1d 100644
--- a/libavcodec/flac_parser.c
+++ b/libavcodec/flac_parser.c
@@ -570,7 +570,6 @@ static int flac_parse(AVCodecParserContext *s, 
AVCodecContext *avctx,
 for (curr = best_child->next; curr; curr = curr->next)
 curr->offset -= best_child->offset;
 
-fpc->nb_headers_buffered--;
 best_child->offset = 0;
 fpc->headers   = best_child;
 if (fpc->nb_headers_buffered >= FLAC_MIN_HEADERS) {
-- 
2.23.0

___
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] DVB EPG decoder

2019-09-19 Thread Marton Balint



On Thu, 12 Sep 2019, Anthony Delannoy wrote:


But I'd like to see data decoder in the future to use more easily
EPG/NIT/BAT etc tables.
Will it be possible? With modifications if it needs to be?


I don't see how, as it does not fit into the concept of the libav*
libraries. I feel this belongs to a separate library.


A new libavdata library for data handling ?


In case of a scrambled EIT (which I have never seen myself in the wild) you'd
print this at every packet. You should either remove the warning, or check if
this is the first time (e.g. by checking if the EPG stream was just created).



You should remove this, there are tons of captures where EIT PID is
intentionally filtered, we should not spam the user.


I made both of this log print on AV_LOG_TRACE level, I rather keep
them here if i need them.


Thanks, applied patches 1-3 with some slight changes. Sorry, but I removed 
the TRACE log for the no EIT packets received case, I just don't see it 
useful.


Regards,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/dvenc: support encoding dvcprohd

2019-09-19 Thread Michael Niedermayer
On Wed, Sep 11, 2019 at 12:29:57PM -0700, Baptiste Coudurier wrote:
> ---
>  libavcodec/dv.h|   1 +
>  libavcodec/dvenc.c | 576 -
>  2 files changed, 522 insertions(+), 55 deletions(-)

a fate test should be added for this if its not already planed or done


> 
> diff --git a/libavcodec/dv.h b/libavcodec/dv.h
> index 7ef5b7c552..0205d72347 100644
> --- a/libavcodec/dv.h
> +++ b/libavcodec/dv.h
> @@ -83,6 +83,7 @@ enum dv_pack_type {
>  
>  #define DV_PROFILE_IS_HD(p) ((p)->video_stype & 0x10)
>  #define DV_PROFILE_IS_1080i50(p) (((p)->video_stype == 0x14) && ((p)->dsf == 
> 1))
> +#define DV_PROFILE_IS_1080i60(p) (((p)->video_stype == 0x14) && ((p)->dsf == 
> 0))
>  #define DV_PROFILE_IS_720p50(p)  (((p)->video_stype == 0x18) && ((p)->dsf == 
> 1))
>  
>  /**
> diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
> index ce2fc75daa..b7a771fa18 100644
> --- a/libavcodec/dvenc.c
> +++ b/libavcodec/dvenc.c
> @@ -60,10 +60,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext 
> *avctx)
>  ff_dv_print_profiles(avctx, AV_LOG_ERROR);
>  return AVERROR(EINVAL);
>  }
> -if (avctx->height > 576) {
> -av_log(avctx, AV_LOG_ERROR, "DVCPRO HD encoding is not 
> supported.\n");
> -return AVERROR_PATCHWELCOME;
> -}
> +
>  ret = ff_dv_init_dynamic_tables(s, s->sys);
>  if (ret < 0) {
>  av_log(avctx, AV_LOG_ERROR, "Error initializing work tables.\n");
> @@ -90,6 +87,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext 
> *avctx)
>  }
>  
>  /* bit budget for AC only in 5 MBs */
> +static const int vs_total_ac_bits_hd = (68 * 6 + 52*2) * 5;
>  static const int vs_total_ac_bits = (100 * 4 + 68 * 2) * 5;
>  static const int mb_area_start[5] = { 1, 6, 21, 43, 64 };
>  
> @@ -158,6 +156,11 @@ typedef struct EncBlockInfo {
>  uint8_t  sign[64];
>  uint8_t  partial_bit_count;
>  uint32_t partial_bit_buffer; /* we can't use uint16_t here */
> +/* used by DV100 only: a copy of the weighted and classified but
> +   not-yet-quantized AC coefficients. This is necessary for
> +   re-quantizing at different steps. */
> +int16_t  save[64];
> +int  min_qlevel; /* DV100 only: minimum qlevel (for AC coefficients 
> >255) */
>  } EncBlockInfo;
>  
>  static av_always_inline PutBitContext *dv_encode_ac(EncBlockInfo *bi,
> @@ -243,13 +246,135 @@ static const int dv_weight_248[64] = {
>  170627, 170627, 153560, 153560, 165371, 165371, 144651, 144651,
>  };
>  
> -static av_always_inline int dv_init_enc_block(EncBlockInfo *bi, uint8_t 
> *data,
> -  ptrdiff_t linesize,
> -  DVVideoContext *s, int bias)

> +/* setting this to 1 results in a faster codec but
> + * somewhat lower image quality */
> +#define DV100_SACRIFICE_QUALITY_FOR_SPEED 1
> +#define DV100_ENABLE_FINER 1

These could be changed to runtime user options
[...]

> +/* how much to increase qlevel when we need to compress more coarsely */
> +/* this is a tradeoff between encoding speed and space efficiency */
> +/* the highest-quality, lowest-speed option it to use 1 for all qlevels. */
> +static const uint8_t dv100_qstep_delta[16] = {
> +#if DV100_SACRIFICE_QUALITY_FOR_SPEED
> +0, 2, 0, 5, 0, 0, 0, 0, 1, 6, 0, 0, 0, 0, 0, 0,
> +#else
> +1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> +#endif
> +};

This is unused


> +
> +static const int dv100_min_bias = 0;
> +static const int dv100_chroma_bias = 0;
> +static const int dv100_starting_qno = 1;

> +static const int dv100_min_qno = 1;

unused
[...]
>  
> +/* this function just copies the DCT coefficients and performs
> +   the initial (non-)quantization. */
> +static inline void dv_set_class_number_hd(DVVideoContext *s,
> +  int16_t *blk, EncBlockInfo *bi,
> +  const uint8_t *zigzag_scan,
> +  const int *weight, int bias)
> +{
> +int i, max = 0;
> +
> +/* the first quantization (none at all) */
> +bi->area_q[0] = 1;
> +

> +/* LOOP1: weigh AC components and store to save[] */
> +/* (i=0 is the DC component; we only include it to make the
> +   number of loop iterations even, for future possible SIMD 
> optimization) */
> +for (i = 0; i < 64; i += 2) {
> +int level0, level1;
> +
> +/* get the AC component (in zig-zag order) */
> +level0 = blk[zigzag_scan[i+0]];
> +level1 = blk[zigzag_scan[i+1]];
> +
> +/* extract sign and make it the lowest bit */
> +bi->sign[i+0] = (level0>>31)&1;
> +bi->sign[i+1] = (level1>>31)&1;
> +
> +/* take absolute value of the level */
> +level0 = FFABS(level0);
> +level1 = FFABS(level1);
> +
> +/* weigh it */
> +level0 = (level0*weight[i+0] + 4096 + (1<<17)) >> 18;
> +level1 = (level1*weight[i+1] + 4096 + 

Re: [FFmpeg-devel] [PATCH v3] avdevice/xcbgrab: check return values of xcb query functions

2019-09-19 Thread Moritz Barsnick
On Thu, Sep 19, 2019 at 17:42:30 +0200, Moritz Barsnick wrote:
> +av_log(c, AV_LOG_ERROR, "Failed get xcb geometry\n");

D'uh, missing a "to " in there. Will fix, or pusher please do so.
Moritz
___
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] avdevice/xcbgrab: check return values of xcb query functions

2019-09-19 Thread Moritz Barsnick
xcb_query_pointer_reply() and xcb_get_geometry_reply() can return NULL
if e.g. the X server closes or the connection is lost. This needs to
be checked in order to cleanly exit, because the returned pointers are
dereferenced later.

Furthermore, their return values need to be free()d, also in error
code paths.

Signed-off-by: Moritz Barsnick 
---
To reproduce:
Terminal 1:
$ Xvfb :1 -nolisten tcp -screen 0 800x600x24
Terminal 2:
$ ffmpeg -f x11grab -i :1 -f null -
or rather
$ gdb -ex r --args ffmpeg_g -f x11grab -i :1 -f null -
Then terminate Xvfb while ffmpeg is running.

 libavdevice/xcbgrab.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index b7e689343e..3fb3c56285 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -326,8 +326,10 @@ static void xcbgrab_draw_mouse(AVFormatContext *s, 
AVPacket *pkt,
 return;

 cursor = xcb_xfixes_get_cursor_image_cursor_image(ci);
-if (!cursor)
+if (!cursor) {
+free(ci);
 return;
+}

 cx = ci->x - ci->xhot;
 cy = ci->y - ci->yhot;
@@ -404,7 +406,16 @@ static int xcbgrab_read_packet(AVFormatContext *s, 
AVPacket *pkt)
 pc  = xcb_query_pointer(c->conn, c->screen->root);
 gc  = xcb_get_geometry(c->conn, c->screen->root);
 p   = xcb_query_pointer_reply(c->conn, pc, NULL);
+if (!p) {
+av_log(c, AV_LOG_ERROR, "Failed to query xcb pointer\n");
+return AVERROR(EIO);
+}
 geo = xcb_get_geometry_reply(c->conn, gc, NULL);
+if (!geo) {
+av_log(c, AV_LOG_ERROR, "Failed get xcb geometry\n");
+free(p);
+return AVERROR(EIO);
+}
 }

 if (c->follow_mouse && p->same_screen)
@@ -537,6 +548,10 @@ static int create_stream(AVFormatContext *s)

 gc  = xcb_get_geometry(c->conn, c->screen->root);
 geo = xcb_get_geometry_reply(c->conn, gc, NULL);
+if (!geo) {
+av_log(c, AV_LOG_ERROR, "Failed to get xcb geometry\n");
+return AVERROR(EIO);
+}

 if (c->x + c->width > geo->width ||
 c->y + c->height > geo->height) {
--
2.20.1

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

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

Re: [FFmpeg-devel] [PATCH v2 2/2] avcodec/v210dec: add the frame and slice threading support

2019-09-19 Thread Limin Wang

Another friendly ping.

On Fri, Sep 06, 2019 at 11:28:29PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> The multithread is avoid one core cpu is full with other filter like scale 
> etc.
> About the performance, the gain is very small, below is my testing for
> performance.
> In order to avoid the disk bottleneck, I'll use stream_loop mode for 10 frame
> only.
> 
> ./ffmpeg -y -i ~/Movies/4k_Rec709_ProResHQ.mov -c:v v210 -f rawvideo -frames 
> 10
> ~/Movies/1.v210
> 
> master:
> ./ffmpeg -threads 1 -s 4096x3072 -stream_loop 100 -i ~/Movies/1.v210 
> -benchmark
> -f null -
> frame= 1010 fps= 42 q=-0.0 Lsize=N/A time=00:00:40.40 bitrate=N/A speed=1.69x
> video:529kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing
> overhead: unknown
> bench: utime=10.082s stime=13.784s rtime=23.889s
> bench: maxrss=147836928kB
> 
> patch applied:
> ./ffmpeg -threads 4 -thread_type frame+slice  -s 4096x3072 -stream_loop 100 -i
> ~/Movies/1.v210 -benchmark -f null -
> 
> frame= 1010 fps= 55 q=-0.0 Lsize=N/A time=00:00:40.40 bitrate=N/A speed=2.22x
> video:529kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing
> overhead: unknown
> bench: utime=11.407s stime=17.258s rtime=18.279s
> bench: maxrss=442884096kB
> 
> Signed-off-by: Limin Wang 
> ---
>  libavcodec/v210dec.c | 135 
> +--
>  libavcodec/v210dec.h |   1 +
>  2 files changed, 88 insertions(+), 48 deletions(-)
> 
> diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
> index 6ce18aa..2cdb99e 100644
> --- a/libavcodec/v210dec.c
> +++ b/libavcodec/v210dec.c
> @@ -28,6 +28,7 @@
>  #include "libavutil/internal.h"
>  #include "libavutil/mem.h"
>  #include "libavutil/intreadwrite.h"
> +#include "thread.h"
>  
>  #define READ_PIXELS(a, b, c) \
>  do { \
> @@ -37,6 +38,13 @@
>  *c++ = (val >> 20) & 0x3FF;  \
>  } while (0)
>  
> +#define MAX_SLICES 32
> +typedef struct ThreadData {
> +AVFrame *frame;
> +uint8_t *buf;
> +int stride;
> +} ThreadData;
> +
>  static void v210_planar_unpack_c(const uint32_t *src, uint16_t *y, uint16_t 
> *u, uint16_t *v, int width)
>  {
>  uint32_t val;
> @@ -67,58 +75,32 @@ static av_cold int decode_init(AVCodecContext *avctx)
>  s->aligned_input = 0;
>  ff_v210dec_init(s);
>  
> +s->slice_count = av_clip(avctx->thread_count, 1, MAX_SLICES);
>  return 0;
>  }
>  
> -static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
> -AVPacket *avpkt)
> +static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, 
> int nb_jobs)
>  {
>  V210DecContext *s = avctx->priv_data;
> -
> -int h, w, ret, stride, aligned_input;
> -AVFrame *pic = data;
> -const uint8_t *psrc = avpkt->data;
> +int h, w;
> +ThreadData *td = arg;
> +AVFrame *frame = td->frame;
> +int stride = td->stride;
> +int slice_h = avctx->height / s->slice_count;
> +int slice_m = avctx->height % s->slice_count;
> +int slice_start = jobnr * slice_h;
> +int slice_end = slice_start + slice_h;
> +const uint8_t *psrc = td->buf + stride * slice_start;
>  uint16_t *y, *u, *v;
>  
> -if (s->custom_stride )
> -stride = s->custom_stride;
> -else {
> -int aligned_width = ((avctx->width + 47) / 48) * 48;
> -stride = aligned_width * 8 / 3;
> -}
> -
> -if (avpkt->size < stride * avctx->height) {
> -if avctx->width + 23) / 24) * 24 * 8) / 3 * avctx->height == 
> avpkt->size) {
> -stride = avpkt->size / avctx->height;
> -if (!s->stride_warning_shown)
> -av_log(avctx, AV_LOG_WARNING, "Broken v210 with too small 
> padding (64 byte) detected\n");
> -s->stride_warning_shown = 1;
> -} else {
> -av_log(avctx, AV_LOG_ERROR, "packet too small\n");
> -return AVERROR_INVALIDDATA;
> -}
> -}
> -if (avctx->codec_tag == MKTAG('C', '2', '1', '0')
> -&& AV_RN32(psrc) == AV_RN32("INFO")
> -&& avpkt->size - 64 >= stride * avctx->height)
> -psrc += 64;
> -
> -aligned_input = !((uintptr_t)psrc & 0x1f) && !(stride & 0x1f);
> -if (aligned_input != s->aligned_input) {
> -s->aligned_input = aligned_input;
> -ff_v210dec_init(s);
> -}
> -
> -if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
> -return ret;
> -
> -y = (uint16_t*)pic->data[0];
> -u = (uint16_t*)pic->data[1];
> -v = (uint16_t*)pic->data[2];
> -pic->pict_type = AV_PICTURE_TYPE_I;
> -pic->key_frame = 1;
> +/* add the remaining slice for the last job */
> +if (jobnr == s->slice_count - 1)
> +slice_end += slice_m;
>  
> -for (h = 0; h < avctx->height; h++) {
> +y = (uint16_t*)frame->data[0] + slice_start * frame->linesize[0] / 2;
> +u = (uint16_t*)frame->data[1] + slice_start * frame->linesize[1] / 2;
> +v = 

Re: [FFmpeg-devel] [PATCH v4] libavformat/rtsp: return error if rtsp_hd_out is null instead of crash

2019-09-19 Thread Ross Nicholson
Updated to v4 of patch after learning from Aman Gupta that 'rt' did not
need to be checked in the context of this function.

Should be good to go now.

On Thu, 19 Sep 2019 at 16:12, phunkyfish  wrote:

> ---
>  libavformat/rtsp.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index c153cac88b..859defa592 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -1318,6 +1318,9 @@ static int
> rtsp_send_cmd_with_content_async(AVFormatContext *s,
>  char buf[4096], *out_buf;
>  char base64buf[AV_BASE64_SIZE(sizeof(buf))];
>
> +if (!rt->rtsp_hd_out)
> +return ENOTCONN;
> +
>  /* Add in RTSP headers */
>  out_buf = buf;
>  rt->seq++;
> --
> 2.20.1 (Apple Git-117)
>
>
___
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 v4] libavformat/rtsp: return error if rtsp_hd_out is null instead of crash

2019-09-19 Thread phunkyfish
---
 libavformat/rtsp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index c153cac88b..859defa592 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1318,6 +1318,9 @@ static int 
rtsp_send_cmd_with_content_async(AVFormatContext *s,
 char buf[4096], *out_buf;
 char base64buf[AV_BASE64_SIZE(sizeof(buf))];
 
+if (!rt->rtsp_hd_out)
+return ENOTCONN;
+
 /* Add in RTSP headers */
 out_buf = buf;
 rt->seq++;
-- 
2.20.1 (Apple Git-117)

___
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 v1 1/3] avfilter/f_sidedata: try to fix warning: comparison of constant -1 with expression of type 'enum AVFrameSideDataType'

2019-09-19 Thread Limin Wang
On Thu, Sep 19, 2019 at 09:58:46AM +0200, Marton Balint wrote:
> 
> On Thu, 19 Sep 2019, Limin Wang wrote:
> 
> >On Wed, Sep 18, 2019 at 08:23:46PM +0200, Michael Niedermayer wrote:
> >>On Sun, Aug 25, 2019 at 12:17:58AM +0800, lance.lmw...@gmail.com wrote:
> >>> From: Limin Wang 
> >>> > Signed-off-by: Limin Wang 
> >>> ---
> >>>  libavfilter/f_sidedata.c | 10 +-
> >>>  libavutil/frame.h| 10 ++
> >>>  2 files changed, 15 insertions(+), 5 deletions(-)
> >>> > diff --git a/libavfilter/f_sidedata.c
> >>b/libavfilter/f_sidedata.c
> >>> index 381da5a..3082aa6 100644
> >>> --- a/libavfilter/f_sidedata.c
> >>> +++ b/libavfilter/f_sidedata.c
> >>> @@ -49,7 +49,7 @@ static const AVOption filt_name##_options[] = { \
> >>>  { "mode", "set a mode of operation", OFFSET(mode),   
> >>> AV_OPT_TYPE_INT,{.i64 = 0 }, 0, SIDEDATA_NB-1, FLAGS, "mode" }, \
> >>>  {   "select", "select frame",0,  
> >>> AV_OPT_TYPE_CONST,  {.i64 = SIDEDATA_SELECT }, 0, 0, FLAGS, "mode" }, \
> >>>  {   "delete", "delete side data",0,  
> >>> AV_OPT_TYPE_CONST,  {.i64 = SIDEDATA_DELETE }, 0, 0, FLAGS, "mode" }, \
> >>> -{ "type",   "set side data type",OFFSET(type),   
> >>> AV_OPT_TYPE_INT,{.i64 = -1 }, -1, INT_MAX, FLAGS, "type" }, \
> >>> +{ "type",   "set side data type",OFFSET(type),   
> >>> AV_OPT_TYPE_INT,{.i64 = AV_FRAME_DATA_NB }, 0, AV_FRAME_DATA_NB, 
> >>> FLAGS, "type" }, \
> >>>  {   "PANSCAN","", 0, 
> >>> AV_OPT_TYPE_CONST,  {.i64 = AV_FRAME_DATA_PANSCAN}, 
> >>> 0, 0, FLAGS, "type" }, \
> >>>  {   "A53_CC", "", 0, 
> >>> AV_OPT_TYPE_CONST,  {.i64 = AV_FRAME_DATA_A53_CC }, 
> >>> 0, 0, FLAGS, "type" }, \
> >>>  {   "STEREO3D",   "", 0, 
> >>> AV_OPT_TYPE_CONST,  {.i64 = AV_FRAME_DATA_STEREO3D   }, 
> >>> 0, 0, FLAGS, "type" }, \
> >>> @@ -79,7 +79,7 @@ static const AVOption filt_name##_options[] = { \
> >>>  { "mode", "set a mode of operation", OFFSET(mode),   
> >>> AV_OPT_TYPE_INT,{.i64 = 0 }, 0, SIDEDATA_NB-1, FLAGS, "mode" }, \
> >>>  {   "select", "select frame",0,  
> >>> AV_OPT_TYPE_CONST,  {.i64 = SIDEDATA_SELECT }, 0, 0, FLAGS, "mode" }, \
> >>>  {   "delete", "delete side data",0,  
> >>> AV_OPT_TYPE_CONST,  {.i64 = SIDEDATA_DELETE }, 0, 0, FLAGS, "mode" }, \
> >>> -{ "type",   "set side data type",OFFSET(type),   
> >>> AV_OPT_TYPE_INT,{.i64 = -1 }, -1, INT_MAX, FLAGS, "type" }, \
> >>> +{ "type",   "set side data type",OFFSET(type),   
> >>> AV_OPT_TYPE_INT,{.i64 = AV_FRAME_DATA_NB }, 0, AV_FRAME_DATA_NB, 
> >>> FLAGS, "type" }, \
> >>>  {   "PANSCAN","", 0, 
> >>> AV_OPT_TYPE_CONST,  {.i64 = AV_FRAME_DATA_PANSCAN}, 
> >>> 0, 0, FLAGS, "type" }, \
> >>>  {   "A53_CC", "", 0, 
> >>> AV_OPT_TYPE_CONST,  {.i64 = AV_FRAME_DATA_A53_CC }, 
> >>> 0, 0, FLAGS, "type" }, \
> >>>  {   "STEREO3D",   "", 0, 
> >>> AV_OPT_TYPE_CONST,  {.i64 = AV_FRAME_DATA_STEREO3D   }, 
> >>> 0, 0, FLAGS, "type" }, \
> >>> @@ -107,7 +107,7 @@ static av_cold int init(AVFilterContext *ctx)
> >>>  {
> >>>  SideDataContext *s = ctx->priv;
> >>> > -if (s->type == -1 && s->mode != SIDEDATA_DELETE) {
> >>> +if (s->type == AV_FRAME_DATA_NB && s->mode != SIDEDATA_DELETE) {
> >>>  av_log(ctx, AV_LOG_ERROR, "Side data type must be set\n");
> >>>  return AVERROR(EINVAL);
> >>>  }
> >>> @@ -122,7 +122,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> >>> *frame)
> >>>  SideDataContext *s = ctx->priv;
> >>>  AVFrameSideData *sd = NULL;
> >>> > -if (s->type != -1)
> >>> +if (s->type != AV_FRAME_DATA_NB)
> >>> sd = av_frame_get_side_data(frame, s->type);
> >>> >  switch (s->mode) {
> >>> @@ -132,7 +132,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> >>> *frame)
> >>>  }
> >>>  break;
> >>>  case SIDEDATA_DELETE:
> >>> -if (s->type == -1) {
> >>> +if (s->type == AV_FRAME_DATA_NB) {
> >>>  while (frame->nb_side_data)
> >>>  av_frame_remove_side_data(frame, 
> >>> frame->side_data[0]->type);
> >>>  } else if (sd) {
> >>> diff --git a/libavutil/frame.h b/libavutil/frame.h
> >>> index 5d3231e..4b83125 100644
> >>> --- a/libavutil/frame.h
> >>> +++ b/libavutil/frame.h
> >>> @@ -179,6 +179,16 @@ enum AVFrameSideDataType {
> >>>   * array element is implied by AVFrameSideData.size / 
> >>> AVRegionOfInterest.self_size.
> >>>   */
> >>>  AV_FRAME_DATA_REGIONS_OF_INTEREST,
> >>> +
> >>> +/**
> >>> + * The number of side data types.
> >>> + * This is not part of the public API/ABI in the sense that it may

Re: [FFmpeg-devel] [PATCH 4/4] FATE/dnn: add unit test for dnn depth_to_space layer

2019-09-19 Thread Pedro Arthur
LGTM

Pushed, thanks!

Em qui, 5 de set de 2019 às 03:05, Guo, Yejun  escreveu:
>
> 'make fate-dnn-layer-depth2space' to run the test
>
> Signed-off-by: Guo, Yejun 
> ---
>  tests/dnn/Makefile |   1 +
>  tests/dnn/dnn-layer-depth2space-test.c | 100 
> +
>  tests/fate/dnn.mak |   5 ++
>  3 files changed, 106 insertions(+)
>  create mode 100644 tests/dnn/dnn-layer-depth2space-test.c
>
> diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile
> index 3adefe8..3cb5f6d 100644
> --- a/tests/dnn/Makefile
> +++ b/tests/dnn/Makefile
> @@ -1,5 +1,6 @@
>  DNNTESTPROGS += dnn-layer-pad
>  DNNTESTPROGS += dnn-layer-conv2d
> +DNNTESTPROGS += dnn-layer-depth2space
>
>  DNNTESTOBJS  := $(DNNTESTOBJS:%=$(DNNTESTSDIR)%) 
> $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test.o)
>  DNNTESTPROGS := $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test$(EXESUF))
> diff --git a/tests/dnn/dnn-layer-depth2space-test.c 
> b/tests/dnn/dnn-layer-depth2space-test.c
> new file mode 100644
> index 000..87118de
> --- /dev/null
> +++ b/tests/dnn/dnn-layer-depth2space-test.c
> @@ -0,0 +1,100 @@
> +/*
> + * Copyright (c) 2019 Guo Yejun
> + *
> + * 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 
> +#include 
> +#include "libavfilter/dnn/dnn_backend_native.h"
> +#include "libavfilter/dnn/dnn_backend_native_layer_depth2space.h"
> +
> +#define EPSON 0.1
Just a note, I think you mean EPSILON right?  using EPSILON or EPS is
more conformant with the usual notation.

> +
> +static int test(void)
> +{
> +// the input data and expected data are generated with below python code.
> +/*
> +x = tf.placeholder(tf.float32, shape=[1, None, None, 4])
> +y = tf.depth_to_space(x, 2)
> +data = np.random.rand(1, 5, 3, 4);
> +
> +sess=tf.Session()
> +sess.run(tf.global_variables_initializer())
> +
> +output = sess.run(y, feed_dict={x: data})
> +
> +print("input:")
> +print(data.shape)
> +print(list(data.flatten()))
> +
> +print("output:")
> +print(output.shape)
> +print(list(output.flatten()))
> +*/
> +
> +DnnOperand operands[2];
> +int32_t input_indexes[1];
> +float input[1*5*3*4] = {
> +0.09771065121566602, 0.6336807372403175, 0.5142416549709786, 
> 0.8027206567330333, 0.2154276025069397, 0.12112878462616772, 
> 0.913936596765778,
> +0.38881443647542646, 0.5850447615898835, 0.9311499327398275, 
> 0.3613660929428246, 0.5420722002125493, 0.6002131190230359, 
> 0.44800665702299525,
> +0.7271322557896777, 0.3869293511885826, 0.5144404769364138, 
> 0.6910844856987723, 0.6142102742269762, 0.6249991371621018, 
> 0.45663376215836626,
> +0.19523477129943423, 0.2483895888532045, 0.64326768256278, 
> 0.5485877602998981, 0.45442067849873546, 0.529374943304256, 
> 0.30439850391811885,
> +0.11961343361340993, 0.2909643484561082, 0.9810970344127848, 
> 0.8886928489786549, 0.6112237084436409, 0.8852482695156674, 
> 0.9110868043114374,
> +0.21242780027585217, 0.7101536973207572, 0.9709717457443375, 
> 0.2702666770969332, 0.7718295953780221, 0.3957005164588574, 
> 0.24383544252475453,
> +0.040143453532367035, 0.26358051835323115, 0.013130251443791319, 
> 0.3016550481482074, 0.03582340459943956, 0.718025513612361, 
> 0.09844204177633753,
> +0.04433767496953056, 0.6221895044119757, 0.6190414032940228, 
> 0.8963550834625371, 0.5642449700064629, 0.2482982014723497, 
> 0.17824909294583013,
> +0.024401882408643272, 0.21742800875253465, 0.6794724473181843, 
> 0.4814830479242237
> +};
> +float expected_output[1*10*6*1] = {
> +0.097710654, 0.63368076, 0.2154276, 0.12112878, 0.58504474, 
> 0.93114996, 0.51424164, 0.80272067, 0.9139366, 0.38881445,
> +0.3613661, 0.5420722, 0.6002131, 0.44800666, 0.5144405, 0.6910845, 
> 0.45663378, 0.19523478, 0.72713226, 0.38692936,
> +0.61421025, 0.62499917, 0.24838959, 0.6432677, 0.54858774, 
> 0.4544207, 0.11961343, 0.29096434, 0.6112237, 0.88524824,
> +0.52937496, 0.3043985, 0.98109704, 0.88869286, 0.9110868, 0.2124278, 
> 0.7101537, 0.97097176, 0.3957005, 0.24383545,
> +0.013130251, 0.30165505, 0.27026668, 0.7718296, 0.040143453, 
> 

Re: [FFmpeg-devel] [PATCH 2/4] FATE/dnn: add unit test for dnn conv2d layer

2019-09-19 Thread Pedro Arthur
Em qui, 5 de set de 2019 às 03:05, Guo, Yejun  escreveu:
>
> 'make fate-dnn-layer-conv2d' to run the test
>
> Signed-off-by: Guo, Yejun 
> ---
>  tests/dnn/Makefile|   1 +
>  tests/dnn/dnn-layer-conv2d-test.c | 238 
> ++
>  tests/fate/dnn.mak|   5 +
>  3 files changed, 244 insertions(+)
>  create mode 100644 tests/dnn/dnn-layer-conv2d-test.c
>
> diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile
> index fabed75..3adefe8 100644
> --- a/tests/dnn/Makefile
> +++ b/tests/dnn/Makefile
> @@ -1,4 +1,5 @@
>  DNNTESTPROGS += dnn-layer-pad
> +DNNTESTPROGS += dnn-layer-conv2d
>
>  DNNTESTOBJS  := $(DNNTESTOBJS:%=$(DNNTESTSDIR)%) 
> $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test.o)
>  DNNTESTPROGS := $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test$(EXESUF))
> diff --git a/tests/dnn/dnn-layer-conv2d-test.c 
> b/tests/dnn/dnn-layer-conv2d-test.c
> new file mode 100644
> index 000..afc5391
> --- /dev/null
> +++ b/tests/dnn/dnn-layer-conv2d-test.c
> @@ -0,0 +1,238 @@
> +/*
> + * Copyright (c) 2019 Guo Yejun
> + *
> + * 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 
> +#include 
> +#include "libavfilter/dnn/dnn_backend_native_layer_conv2d.h"
> +
> +#define EPSON 0.1
> +
> +static int test_with_same_dilate(void)
> +{
> +// the input data and expected data are generated with below python code.
> +/*
> +x = tf.placeholder(tf.float32, shape=[1, None, None, 3])
> +y = tf.layers.conv2d(x, 2, 3, activation=tf.nn.tanh, padding='same', 
> dilation_rate=(2, 2), bias_initializer=tf.keras.initializers.he_normal())
> +data = np.random.rand(1, 5, 6, 3);
> +
> +sess=tf.Session()
> +sess.run(tf.global_variables_initializer())
> +
> +weights = dict([(var.name, sess.run(var)) for var in 
> tf.trainable_variables()])
> +kernel = weights['conv2d/kernel:0']
> +kernel = np.transpose(kernel, [3, 0, 1, 2])
> +print("kernel:")
> +print(kernel.shape)
> +print(list(kernel.flatten()))
> +
> +bias = weights['conv2d/bias:0']
> +print("bias:")
> +print(bias.shape)
> +print(list(bias.flatten()))
> +
> +output = sess.run(y, feed_dict={x: data})
> +
> +print("input:")
> +print(data.shape)
> +print(list(data.flatten()))
> +
> +print("output:")
> +print(output.shape)
> +print(list(output.flatten()))
> +*/
> +
> +ConvolutionalParams params;
> +DnnOperand operands[2];
> +int32_t input_indexes[1];
> +float input[1*5*6*3] = {
> +0.7012556460308194, 0.4233847954643357, 0.19515900664313612, 
> 0.16343083004926495, 0.5758261611052848, 0.9510767434014871, 
> 0.11014085055947687,
> +0.906327053637727, 0.8136794715542507, 0.45371764543639526, 
> 0.5768443343523952, 0.19543668786046986, 0.15648326047898609, 
> 0.2099500241141279,
> +0.17658777090552413, 0.059335724777169196, 0.1729991838469117, 
> 0.8150514704819208, 0.4435535466703049, 0.3752188477566878, 0.749936650421431,
> +0.6823494635284907, 0.10776389679424747, 0.34247481674596836, 
> 0.5147867256244629, 0.9063709728129032, 0.12423605800856818, 
> 0.6064872945412728,
> +0.5891681538551459, 0.9865836236466314, 0.9002163879294677, 
> 0.003968273184274618, 0.8628374809643967, 0.1327176268279583, 
> 0.8449799925703798,
> +0.1937671869354366, 0.41524410152707425, 0.02038786604756837, 
> 0.49792466069597496, 0.8881874553848784, 0.9683921035597336, 
> 0.4122972568010813,
> +0.843553550993252, 0.9588482762501964, 0.5190350762645546, 
> 0.4283584264145317, 0.09781496073714646, 0.9501058833776156, 
> 0.8665541760152776,
> +0.31669272550095806, 0.07133074675453632, 0.606438007334886, 
> 0.7007157020538224, 0.4827996264130444, 0.5167615606392761, 
> 0.6385043039312651,
> +0.23069664707810555, 0.058233497329354456, 0.06323892961591071, 
> 0.24816458893245974, 0.8646369065257812, 0.24742185893094837, 
> 0.09991225948167437,
> +0.625700606979606, 0.7678541502111257, 0.6215834594679912, 
> 0.5623003956582483, 0.07389123942681242, 0.7659100715711249, 
> 0.486061471642225,
> +0.9947455699829012, 0.9094911797643259, 0.7644355876253265, 
> 0.05384315321492239, 0.13565394382783613, 

Re: [FFmpeg-devel] [PATCH 1/4] libavfilter/dnn: separate conv2d layer from dnn_backend_native.c to a new file

2019-09-19 Thread Pedro Arthur
Em qui, 5 de set de 2019 às 03:05, Guo, Yejun  escreveu:
>
> the logic is that one layer in one separated source file to make
> the source files simple for maintaining.
>
> Signed-off-by: Guo, Yejun 
> ---
>  libavfilter/dnn/Makefile  |   1 +
>  libavfilter/dnn/dnn_backend_native.c  |  80 +
>  libavfilter/dnn/dnn_backend_native.h  |  13 ---
>  libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 101 
> ++
>  libavfilter/dnn/dnn_backend_native_layer_conv2d.h |  39 +
>  libavfilter/dnn/dnn_backend_tf.c  |   1 +
>  6 files changed, 143 insertions(+), 92 deletions(-)
>  create mode 100644 libavfilter/dnn/dnn_backend_native_layer_conv2d.c
>  create mode 100644 libavfilter/dnn/dnn_backend_native_layer_conv2d.h
>
> diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
> index 83938e5..40b848b 100644
> --- a/libavfilter/dnn/Makefile
> +++ b/libavfilter/dnn/Makefile
> @@ -1,6 +1,7 @@
>  OBJS-$(CONFIG_DNN)   += dnn/dnn_interface.o
>  OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native.o
>  OBJS-$(CONFIG_DNN)   += 
> dnn/dnn_backend_native_layer_pad.o
> +OBJS-$(CONFIG_DNN)   += 
> dnn/dnn_backend_native_layer_conv2d.o
>
>  DNN-OBJS-$(CONFIG_LIBTENSORFLOW) += dnn/dnn_backend_tf.o
>
> diff --git a/libavfilter/dnn/dnn_backend_native.c 
> b/libavfilter/dnn/dnn_backend_native.c
> index f56cd81..5dabd15 100644
> --- a/libavfilter/dnn/dnn_backend_native.c
> +++ b/libavfilter/dnn/dnn_backend_native.c
> @@ -26,6 +26,7 @@
>  #include "dnn_backend_native.h"
>  #include "libavutil/avassert.h"
>  #include "dnn_backend_native_layer_pad.h"
> +#include "dnn_backend_native_layer_conv2d.h"
>
>  static DNNReturnType set_input_output_native(void *model, DNNInputData 
> *input, const char *input_name, const char **output_names, uint32_t nb_output)
>  {
> @@ -281,85 +282,6 @@ DNNModel *ff_dnn_load_model_native(const char 
> *model_filename)
>  return model;
>  }
>
> -#define CLAMP_TO_EDGE(x, w) ((x) < 0 ? 0 : ((x) >= (w) ? (w - 1) : (x)))
> -
> -static int convolve(DnnOperand *operands, const int32_t 
> *input_operand_indexes, int32_t output_operand_index, const 
> ConvolutionalParams *conv_params)
> -{
> -float *output;
> -int32_t input_operand_index = input_operand_indexes[0];
> -int number = operands[input_operand_index].dims[0];
> -int height = operands[input_operand_index].dims[1];
> -int width = operands[input_operand_index].dims[2];
> -int channel = operands[input_operand_index].dims[3];
> -const float *input = operands[input_operand_index].data;
> -
> -int radius = conv_params->kernel_size >> 1;
> -int src_linesize = width * conv_params->input_num;
> -int filter_linesize = conv_params->kernel_size * conv_params->input_num;
> -int filter_size = conv_params->kernel_size * filter_linesize;
> -int pad_size = (conv_params->padding_method == VALID) ? 
> (conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
> -
> -DnnOperand *output_operand = [output_operand_index];
> -output_operand->dims[0] = number;
> -output_operand->dims[1] = height - pad_size * 2;
> -output_operand->dims[2] = width - pad_size * 2;
> -output_operand->dims[3] = conv_params->output_num;
> -output_operand->length = calculate_operand_data_length(output_operand);
> -output_operand->data = av_realloc(output_operand->data, 
> output_operand->length);
> -if (!output_operand->data)
> -return -1;
> -output = output_operand->data;
> -
> -av_assert0(channel == conv_params->input_num);
> -
> -for (int y = pad_size; y < height - pad_size; ++y) {
> -for (int x = pad_size; x < width - pad_size; ++x) {
> -for (int n_filter = 0; n_filter < conv_params->output_num; 
> ++n_filter) {
> -output[n_filter] = conv_params->biases[n_filter];
> -
> -for (int ch = 0; ch < conv_params->input_num; ++ch) {
> -for (int kernel_y = 0; kernel_y < 
> conv_params->kernel_size; ++kernel_y) {
> -for (int kernel_x = 0; kernel_x < 
> conv_params->kernel_size; ++kernel_x) {
> -float input_pel;
> -if (conv_params->padding_method == 
> SAME_CLAMP_TO_EDGE) {
> -int y_pos = CLAMP_TO_EDGE(y + (kernel_y - 
> radius) * conv_params->dilation, height);
> -int x_pos = CLAMP_TO_EDGE(x + (kernel_x - 
> radius) * conv_params->dilation, width);
> -input_pel = input[y_pos * src_linesize + 
> x_pos * conv_params->input_num + ch];
> -} else {
> -int y_pos = y + (kernel_y - radius) * 
> conv_params->dilation;
> -int x_pos = x + (kernel_x - radius) * 
> 

Re: [FFmpeg-devel] [PATCH 3/4] libavfilter/dnn: separate depth_to_space layer from dnn_backend_native.c to a new file

2019-09-19 Thread Pedro Arthur
LGTM

Pushed, thanks!

Em qui, 5 de set de 2019 às 03:05, Guo, Yejun  escreveu:
>
> the logic is that one layer in one separated source file to make
> the source files simple for maintaining.
>
> Signed-off-by: Guo, Yejun 
> ---
>  libavfilter/dnn/Makefile   |  1 +
>  libavfilter/dnn/dnn_backend_native.c   | 44 +-
>  libavfilter/dnn/dnn_backend_native.h   |  4 --
>  .../dnn/dnn_backend_native_layer_depth2space.c | 71 
> ++
>  .../dnn/dnn_backend_native_layer_depth2space.h | 39 
>  libavfilter/dnn/dnn_backend_tf.c   |  1 +
>  6 files changed, 113 insertions(+), 47 deletions(-)
>  create mode 100644 libavfilter/dnn/dnn_backend_native_layer_depth2space.c
>  create mode 100644 libavfilter/dnn/dnn_backend_native_layer_depth2space.h
>
> diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
> index 40b848b..63a35e7 100644
> --- a/libavfilter/dnn/Makefile
> +++ b/libavfilter/dnn/Makefile
> @@ -2,6 +2,7 @@ OBJS-$(CONFIG_DNN)   += 
> dnn/dnn_interface.o
>  OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native.o
>  OBJS-$(CONFIG_DNN)   += 
> dnn/dnn_backend_native_layer_pad.o
>  OBJS-$(CONFIG_DNN)   += 
> dnn/dnn_backend_native_layer_conv2d.o
> +OBJS-$(CONFIG_DNN)   += 
> dnn/dnn_backend_native_layer_depth2space.o
>
>  DNN-OBJS-$(CONFIG_LIBTENSORFLOW) += dnn/dnn_backend_tf.o
>
> diff --git a/libavfilter/dnn/dnn_backend_native.c 
> b/libavfilter/dnn/dnn_backend_native.c
> index 5dabd15..be548c6 100644
> --- a/libavfilter/dnn/dnn_backend_native.c
> +++ b/libavfilter/dnn/dnn_backend_native.c
> @@ -27,6 +27,7 @@
>  #include "libavutil/avassert.h"
>  #include "dnn_backend_native_layer_pad.h"
>  #include "dnn_backend_native_layer_conv2d.h"
> +#include "dnn_backend_native_layer_depth2space.h"
>
>  static DNNReturnType set_input_output_native(void *model, DNNInputData 
> *input, const char *input_name, const char **output_names, uint32_t nb_output)
>  {
> @@ -282,49 +283,6 @@ DNNModel *ff_dnn_load_model_native(const char 
> *model_filename)
>  return model;
>  }
>
> -static int depth_to_space(DnnOperand *operands, const int32_t 
> *input_operand_indexes, int32_t output_operand_index, int block_size)
> -{
> -float *output;
> -int32_t input_operand_index = input_operand_indexes[0];
> -int number = operands[input_operand_index].dims[0];
> -int height = operands[input_operand_index].dims[1];
> -int width = operands[input_operand_index].dims[2];
> -int channels = operands[input_operand_index].dims[3];
> -const float *input = operands[input_operand_index].data;
> -
> -int y, x, by, bx, ch;
> -int new_channels = channels / (block_size * block_size);
> -int output_linesize = width * channels;
> -int by_linesize = output_linesize / block_size;
> -int x_linesize = new_channels * block_size;
> -
> -DnnOperand *output_operand = [output_operand_index];
> -output_operand->dims[0] = number;
> -output_operand->dims[1] = height * block_size;
> -output_operand->dims[2] = width * block_size;
> -output_operand->dims[3] = new_channels;
> -output_operand->length = calculate_operand_data_length(output_operand);
> -output_operand->data = av_realloc(output_operand->data, 
> output_operand->length);
> -if (!output_operand->data)
> -return -1;
> -output = output_operand->data;
> -
> -for (y = 0; y < height; ++y){
> -for (x = 0; x < width; ++x){
> -for (by = 0; by < block_size; ++by){
> -for (bx = 0; bx < block_size; ++bx){
> -for (ch = 0; ch < new_channels; ++ch){
> -output[by * by_linesize + x * x_linesize + bx * 
> new_channels + ch] = input[ch];
> -}
> -input += new_channels;
> -}
> -}
> -}
> -output += output_linesize;
> -}
> -return 0;
> -}
> -
>  DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData 
> *outputs, uint32_t nb_output)
>  {
>  ConvolutionalNetwork *network = (ConvolutionalNetwork *)model->model;
> diff --git a/libavfilter/dnn/dnn_backend_native.h 
> b/libavfilter/dnn/dnn_backend_native.h
> index aa5..a74d138 100644
> --- a/libavfilter/dnn/dnn_backend_native.h
> +++ b/libavfilter/dnn/dnn_backend_native.h
> @@ -90,10 +90,6 @@ typedef struct InputParams{
>  int height, width, channels;
>  } InputParams;
>
> -typedef struct DepthToSpaceParams{
> -int block_size;
> -} DepthToSpaceParams;
> -
>  // Represents simple feed-forward convolutional network.
>  typedef struct ConvolutionalNetwork{
>  Layer *layers;
> diff --git a/libavfilter/dnn/dnn_backend_native_layer_depth2space.c 
> b/libavfilter/dnn/dnn_backend_native_layer_depth2space.c
> new file mode 100644
> index 000..a248764
> 

Re: [FFmpeg-devel] [PATCH] avformat/rtpenc_mpegts: copy metadata to mpegts sub-muxer

2019-09-19 Thread Moritz Barsnick
On Fri, Sep 07, 2018 at 21:32:02 +0200, Moritz Barsnick wrote:
> On Mon, Jul 02, 2018 at 13:38:04 +0200, Moritz Barsnick wrote:
> > Fixes #7293.
>
> Ping.

Another friendly ping.

For reference, since it's quite a while back:
https://patchwork.ffmpeg.org/patch/9566/
Still applies cleanly to HEAD of master.

Thanks,
Moritz
___
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/aiffdec: parse replaygain metadata

2019-09-19 Thread Moritz Barsnick
On Mon, Mar 18, 2019 at 11:01:21 +0100, Paul B Mahol wrote:
> On 3/18/19, Moritz Barsnick  wrote:
> >> Tested against sample provided here:
> >> https://ffmpeg.org/pipermail/ffmpeg-user/2019-March/043717.html
> >>
> >>  libavformat/aiffdec.c | 5 +
> >>  1 file changed, 5 insertions(+)
> >
> > Friendly ping.
>
> LGTM

Another ping for push of patch. (Still applies cleanly to HEAD of
master.)

Moritz

https://patchwork.ffmpeg.org/patch/12302/
in case it got out of view...
___
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] Adding ICC profile support to MOV decode/encode

2019-09-19 Thread vectronic


> On 18 Sep 2019, at 18:43, Derek Buitenhuis  wrote:
> 
> On 18/09/2019 17:29, Hello Vectronic wrote:
>> And here is an example file: http://vectronic.io/icc-profile/icc-profile.mov
>> 
>> And here is the relevant standard: 
>> https://standards.iso.org/ittf/PubliclyAvailableStandards/c068960_ISO_IEC_14496-12_2015.zip
>> 
> 
> Of note, the example file is not ISOBMFF, and thus not covered by the linked
> standard. It's covered by QTFF, which I mentioned in the other mail, has
> quite a quite iffy definition...
> 
> Is it possible to generate ISOBMFF with the VideoToolBox API too?
> 

Here is an updated example in both flavours:

http://vectronic.io/icc-profile/icc-profile.mov 


http://vectronic.io/icc-profile/icc-profile.mp4 




___
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 v2 3/3] avformat/hashenc: add streamhash muxer

2019-09-19 Thread Peter B.
btw: If you need anything to be tested, just let me know :)


Cheers!
Peter
___
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 v1 1/3] avfilter/f_sidedata: try to fix warning: comparison of constant -1 with expression of type 'enum AVFrameSideDataType'

2019-09-19 Thread Marton Balint


On Thu, 19 Sep 2019, Limin Wang wrote:


On Wed, Sep 18, 2019 at 08:23:46PM +0200, Michael Niedermayer wrote:

On Sun, Aug 25, 2019 at 12:17:58AM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 

> ---
>  libavfilter/f_sidedata.c | 10 +-
>  libavutil/frame.h| 10 ++
>  2 files changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/libavfilter/f_sidedata.c b/libavfilter/f_sidedata.c

> index 381da5a..3082aa6 100644
> --- a/libavfilter/f_sidedata.c
> +++ b/libavfilter/f_sidedata.c
> @@ -49,7 +49,7 @@ static const AVOption filt_name##_options[] = { \
>  { "mode", "set a mode of operation", OFFSET(mode),   AV_OPT_TYPE_INT,{.i64 = 0 
}, 0, SIDEDATA_NB-1, FLAGS, "mode" }, \
>  {   "select", "select frame",0,  AV_OPT_TYPE_CONST,  {.i64 = 
SIDEDATA_SELECT }, 0, 0, FLAGS, "mode" }, \
>  {   "delete", "delete side data",0,  AV_OPT_TYPE_CONST,  {.i64 = 
SIDEDATA_DELETE }, 0, 0, FLAGS, "mode" }, \
> -{ "type",   "set side data type",OFFSET(type),   AV_OPT_TYPE_INT,{.i64 = 
-1 }, -1, INT_MAX, FLAGS, "type" }, \
> +{ "type",   "set side data type",OFFSET(type),   AV_OPT_TYPE_INT,{.i64 = 
AV_FRAME_DATA_NB }, 0, AV_FRAME_DATA_NB, FLAGS, "type" }, \
>  {   "PANSCAN","", 0, AV_OPT_TYPE_CONST,  {.i64 = 
AV_FRAME_DATA_PANSCAN}, 0, 0, FLAGS, "type" }, \
>  {   "A53_CC", "", 0, AV_OPT_TYPE_CONST,  {.i64 = 
AV_FRAME_DATA_A53_CC }, 0, 0, FLAGS, "type" }, \
>  {   "STEREO3D",   "", 0, AV_OPT_TYPE_CONST,  {.i64 = 
AV_FRAME_DATA_STEREO3D   }, 0, 0, FLAGS, "type" }, \
> @@ -79,7 +79,7 @@ static const AVOption filt_name##_options[] = { \
>  { "mode", "set a mode of operation", OFFSET(mode),   AV_OPT_TYPE_INT,{.i64 = 0 
}, 0, SIDEDATA_NB-1, FLAGS, "mode" }, \
>  {   "select", "select frame",0,  AV_OPT_TYPE_CONST,  {.i64 = 
SIDEDATA_SELECT }, 0, 0, FLAGS, "mode" }, \
>  {   "delete", "delete side data",0,  AV_OPT_TYPE_CONST,  {.i64 = 
SIDEDATA_DELETE }, 0, 0, FLAGS, "mode" }, \
> -{ "type",   "set side data type",OFFSET(type),   AV_OPT_TYPE_INT,{.i64 = 
-1 }, -1, INT_MAX, FLAGS, "type" }, \
> +{ "type",   "set side data type",OFFSET(type),   AV_OPT_TYPE_INT,{.i64 = 
AV_FRAME_DATA_NB }, 0, AV_FRAME_DATA_NB, FLAGS, "type" }, \
>  {   "PANSCAN","", 0, AV_OPT_TYPE_CONST,  {.i64 = 
AV_FRAME_DATA_PANSCAN}, 0, 0, FLAGS, "type" }, \
>  {   "A53_CC", "", 0, AV_OPT_TYPE_CONST,  {.i64 = 
AV_FRAME_DATA_A53_CC }, 0, 0, FLAGS, "type" }, \
>  {   "STEREO3D",   "", 0, AV_OPT_TYPE_CONST,  {.i64 = 
AV_FRAME_DATA_STEREO3D   }, 0, 0, FLAGS, "type" }, \
> @@ -107,7 +107,7 @@ static av_cold int init(AVFilterContext *ctx)
>  {
>  SideDataContext *s = ctx->priv;
> 
> -if (s->type == -1 && s->mode != SIDEDATA_DELETE) {

> +if (s->type == AV_FRAME_DATA_NB && s->mode != SIDEDATA_DELETE) {
>  av_log(ctx, AV_LOG_ERROR, "Side data type must be set\n");
>  return AVERROR(EINVAL);
>  }
> @@ -122,7 +122,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
>  SideDataContext *s = ctx->priv;
>  AVFrameSideData *sd = NULL;
> 
> -if (s->type != -1)

> +if (s->type != AV_FRAME_DATA_NB)
> sd = av_frame_get_side_data(frame, s->type);
> 
>  switch (s->mode) {

> @@ -132,7 +132,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
>  }
>  break;
>  case SIDEDATA_DELETE:
> -if (s->type == -1) {
> +if (s->type == AV_FRAME_DATA_NB) {
>  while (frame->nb_side_data)
>  av_frame_remove_side_data(frame, frame->side_data[0]->type);
>  } else if (sd) {
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index 5d3231e..4b83125 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -179,6 +179,16 @@ enum AVFrameSideDataType {
>   * array element is implied by AVFrameSideData.size / 
AVRegionOfInterest.self_size.
>   */
>  AV_FRAME_DATA_REGIONS_OF_INTEREST,
> +
> +/**
> + * The number of side data types.
> + * This is not part of the public API/ABI in the sense that it may
> + * change when new side data types are added.
> + * This must stay the last enum value.
> + * If its value becomes huge, some code using it
> + * needs to be updated as it assumes it to be smaller than other limits.
> + */
> +AV_FRAME_DATA_NB
>  };

This looks not really correct
this defines a constant in libavutil that can change with libavutils
minor version and then use it outside in libavfilter
it could then mismatch what is linked at runtime ...


Thanks for the 

Re: [FFmpeg-devel] [PATCH 4/6] lavu/hwcontext_vaapi: add vaapi_format_map support for AYUV/Y210/Y410

2019-09-19 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Friday, September 13, 2019 07:48
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 4/6] lavu/hwcontext_vaapi: add
> vaapi_format_map support for AYUV/Y210/Y410
> 
> On 10/09/2019 17:07, Linjie Fu wrote:
> > There is no VA_RT_FORMAT_AYUV in defined in libva, and currently in
> > media-driver, VA_FOURCC_AYUV is used to represent
> VA_RT_FORMAT_AYUV.
> 
> That doesn't make sense - VA_RT_FORMAT_* is a bit mask, so using
> VA_FOURCC_AYUV looks like a random combination of other values.
> > Another patch could be sent to refine the code after this issue is
> > addressed:
> > https://github.com/intel/libva/issues/335
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavutil/hwcontext_vaapi.c | 9 +
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> > index cf11764..724bbeb 100644
> > --- a/libavutil/hwcontext_vaapi.c
> > +++ b/libavutil/hwcontext_vaapi.c
> > @@ -116,6 +116,15 @@ static const VAAPIFormatDescriptor
> vaapi_format_map[] = {
> >  #endif
> >  MAP(UYVY, YUV422,  UYVY422, 0),
> >  MAP(YUY2, YUV422,  YUYV422, 0),
> > +#ifdef VA_FOURCC_Y210
> > +MAP(Y210, YUV422_10,Y210, 0),
> > +#endif
> > +#define VA_RT_FORMAT_AYUV VA_FOURCC_AYUV
> > +MAP(AYUV,   AYUV, AYUV, 0),
> > +#undef VA_RT_FORMAT_AYUV
> > +#ifdef VA_FOURCC_Y410
> > +MAP(Y410, YUV444_10,Y410, 0),
> 
> That looks suspicious - you've defined Y410 as having an alpha channel, but
> that render target format doesn't have one.

Also mentioned this in https://github.com/intel/libva/issues/335.

> 
> > +#endif
> >  MAP(411P, YUV411,  YUV411P, 0),
> >  MAP(422V, YUV422,  YUV440P, 0),
> >  MAP(444P, YUV444,  YUV444P, 0),
> 
> To try to clarify the intent here, the formats you are intending to use for 
> this
> new decoder are:
> 
> 4:2:0:
> * 8-bit: NV12.
> * 10-bit: P010.
> * With alpha: not supported.
> 
> 4:2:2:
> * 8-bit: YUYV or similar?

Supported FourCC is YUY2, and supported decode format is YUYV422;

> * 10-bit: Y210.
> * With alpha: not supported.
> 
> 4:4:4:
> * 8-bit: the existing 444P, or not supported?
> * 10-bit: not supported.

The planar format  for decoder output is not supported in driver/hardware.

> * 8-bit + alpha: AYUV.
> * 10-bit + alpha: Y410?  (With the alpha channel truncated?)

The 10-bit+alpha format is Y410, and the alpha channel data is truncated to 2 
bits.

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

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

Re: [FFmpeg-devel] Is it ok to add G.722.1 decoder as external lib?

2019-09-19 Thread Tomas Härdin
tor 2019-09-19 klockan 13:58 +0900 skrev Hyun Yoo:
> On Thu, Sep 19, 2019 at 7:28 AM Carl Eugen Hoyos  wrote:
> > Am Di., 17. Sept. 2019 um 02:37 Uhr schrieb Hyun Yoo 
> > :
> > > I implemented a g.722.1 decoder by linking FreeSwitch's libg722_1
> > > as external lib like libilbc, libspeex(ex. configure --enable-libg722_1)
> > > (https://github.com/traviscross/freeswitch/tree/master/libs/libg722_1)
> > 
> > Please provide your patch by either sending it to this mailing list
> > or putting it somewhere so it is kept for interested people (after
> > the kind reactions you received).
> 
> Let me sum up.
> Non-free codecs are not allowed in ffmpeg codebase except
> linked as external lib like fdk-aac (added to EXTERNAL_LIBRARY_NONFREE_LIST)

Non-free originally came to be because of fdk-aac, which is open source
but doesn't meet the requirements of the (L)GPL. Some have taken this
to mean that we should include wrappers for proprietary codecs, which
has also been done (arguably by mistake) for things like NDI. This has
led to much friction..

I think we should try and talk to FreeSwitch and/or Polycom and see if
we can get them to relicense to something suitable. If Polycom are
worried about competitors, perhaps they would agree to dual license
under the AGPL?

/Tomas

___
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".