Re: [FFmpeg-devel] [PATCH] fftools: Accept more negative prefixes

2020-08-20 Thread Moritz Barsnick
On Thu, Aug 20, 2020 at 22:49:16 +0100, Mark Thompson wrote:

> With this patch, -disable_auto_conversion_filters does what you want.
[...]
> +if (!po->name) {
> +/* Try to match a boolean option with a negative prefix. */
> +for (int i = 0; i < FF_ARRAY_ELEMS(negative_prefixes); i++) {
> +size_t len = strlen(negative_prefixes[i]);
> +if (!strncmp(opt, negative_prefixes[i], len)) {
> +po = find_option(options, opt + len);
> +if (po->name && (po->flags & OPT_BOOL)) {
> +arg = "0";
> +break;
> +}
> +}
> +}

Without checking in more detail: Wouldn't this break the
"-noise_reduction", "-non_deterministic" and "-non_linear_quant"
options?

Cheers,
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 v2 1/2] qsv: needn't load user plugin since libmfx 1.28

2020-08-20 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Haihao Xiang
> Sent: Friday, August 21, 2020 7:23 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Haihao Xiang 
> Subject: [FFmpeg-devel] [PATCH v2 1/2] qsv: needn't load user plugin since
> libmfx 1.28
> 
> MFXVideoUSER_Load call is redundant since libmfx 1.28
> ---
> Fixed merge conflict when applying this patch by 'git am'
> 
>  libavcodec/qsv.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index
> 17720070f1..56a30ad642 100644
> --- a/libavcodec/qsv.c
> +++ b/libavcodec/qsv.c
> @@ -19,7 +19,6 @@
>   */
> 
>  #include 
> -#include 
>  #include 
> 
>  #include 
> @@ -36,6 +35,10 @@
>  #include "avcodec.h"
>  #include "qsv_internal.h"
> 
> +#if !QSV_VERSION_ATLEAST(1, 28)
> +#include 
> +#endif
> +
>  #if QSV_VERSION_ATLEAST(1, 12)
>  #include "mfx/mfxvp8.h"
>  #endif
> @@ -295,6 +298,9 @@ enum AVPictureType ff_qsv_map_pictype(int
> mfx_pic_type)  static int qsv_load_plugins(mfxSession session, const char
> *load_plugins,
>  void *logctx)  {
> +#if QSV_VERSION_ATLEAST(1, 28)
> +return 0;
> +#else
>  if (!load_plugins || !*load_plugins)
>  return 0;
> 
> @@ -340,6 +346,7 @@ load_plugin_fail:
>  }
> 
>  return 0;
> +#endif
> 
>  }


Hi,

Are you sure this check is right? You are checking the libmfx version
against which ffmpeg is compiled.

What happens, when a graphics driver supports only API level 1.21?

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

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

[FFmpeg-devel] [PATCH V2] dnn: move output name from DNNModel.set_input_output to DNNModule.execute_model

2020-08-20 Thread Guo, Yejun
currently, output is set both at DNNModel.set_input_output and
DNNModule.execute_model, it makes sense that the output name is
provided at model inference time so all the output info is set
at a single place.

and so DNNModel.set_input_output is renamed to DNNModel.set_input

Signed-off-by: Guo, Yejun 
---
v2: rebase with master

 libavfilter/dnn/dnn_backend_native.c   | 44 +++--
 libavfilter/dnn/dnn_backend_native.h   |  4 +-
 libavfilter/dnn/dnn_backend_openvino.c | 50 +--
 libavfilter/dnn/dnn_backend_openvino.h |  2 +-
 libavfilter/dnn/dnn_backend_tf.c   | 87 ++
 libavfilter/dnn/dnn_backend_tf.h   |  2 +-
 libavfilter/dnn_interface.h|  4 +-
 libavfilter/vf_derain.c|  6 +--
 libavfilter/vf_dnn_processing.c|  9 ++--
 libavfilter/vf_sr.c| 11 +++--
 10 files changed, 82 insertions(+), 137 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 0be9c0b..65a5670 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -50,7 +50,7 @@ static DNNReturnType get_input_native(void *model, DNNData 
*input, const char *i
 return DNN_ERROR;
 }
 
-static DNNReturnType set_input_output_native(void *model, DNNData *input, 
const char *input_name, const char **output_names, uint32_t nb_output)
+static DNNReturnType set_input_native(void *model, DNNData *input, const char 
*input_name)
 {
 NativeModel *native_model = (NativeModel *)model;
 DnnOperand *oprd = NULL;
@@ -87,27 +87,6 @@ static DNNReturnType set_input_output_native(void *model, 
DNNData *input, const
 
 input->data = oprd->data;
 
-/* outputs */
-native_model->nb_output = 0;
-av_freep(_model->output_indexes);
-native_model->output_indexes = av_mallocz_array(nb_output, 
sizeof(*native_model->output_indexes));
-if (!native_model->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 < native_model->operands_num; ++j) {
-oprd = _model->operands[j];
-if (strcmp(oprd->name, output_name) == 0) {
-native_model->output_indexes[native_model->nb_output++] = j;
-break;
-}
-}
-}
-
-if (native_model->nb_output != nb_output)
-return DNN_ERROR;
-
 return DNN_SUCCESS;
 }
 
@@ -243,7 +222,7 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename, const char *optio
 return NULL;
 }
 
-model->set_input_output = _input_output_native;
+model->set_input = _input_native;
 model->get_input = _input_native;
 model->options = options;
 
@@ -255,11 +234,10 @@ fail:
 return NULL;
 }
 
-DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData 
*outputs, uint32_t nb_output)
+DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData 
*outputs, const char **output_names, uint32_t nb_output)
 {
 NativeModel *native_model = (NativeModel *)model->model;
 int32_t layer;
-uint32_t nb = FFMIN(nb_output, native_model->nb_output);
 
 if (native_model->layers_num <= 0 || native_model->operands_num <= 0)
 return DNN_ERROR;
@@ -274,8 +252,19 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel 
*model, DNNData *output
 native_model->layers[layer].params);
 }
 
-for (uint32_t i = 0; i < nb; ++i) {
-DnnOperand *oprd = 
_model->operands[native_model->output_indexes[i]];
+for (uint32_t i = 0; i < nb_output; ++i) {
+DnnOperand *oprd = NULL;
+const char *output_name = output_names[i];
+for (int j = 0; j < native_model->operands_num; ++j) {
+if (strcmp(native_model->operands[j].name, output_name) == 0) {
+oprd = _model->operands[j];
+break;
+}
+}
+
+if (oprd == NULL)
+return DNN_ERROR;
+
 outputs[i].data = oprd->data;
 outputs[i].height = oprd->dims[1];
 outputs[i].width = oprd->dims[2];
@@ -335,7 +324,6 @@ void ff_dnn_free_model_native(DNNModel **model)
 av_freep(_model->operands);
 }
 
-av_freep(_model->output_indexes);
 av_freep(_model);
 }
 av_freep(model);
diff --git a/libavfilter/dnn/dnn_backend_native.h 
b/libavfilter/dnn/dnn_backend_native.h
index 228d5b7..554098f 100644
--- a/libavfilter/dnn/dnn_backend_native.h
+++ b/libavfilter/dnn/dnn_backend_native.h
@@ -112,13 +112,11 @@ typedef struct NativeModel{
 int32_t layers_num;
 DnnOperand *operands;
 int32_t operands_num;
-int32_t *output_indexes;
-uint32_t nb_output;
 } NativeModel;
 
 DNNModel *ff_dnn_load_model_native(const char *model_filename, const char 
*options);
 
-DNNReturnType 

[FFmpeg-devel] [PATCH 1/2] avcodec: add av1 hardware acceleration decoder

2020-08-20 Thread Fei Wang
This av1 decoder is now only used for av1 hardware acceleration
decoder. Consider it can be extend to a local decoder like hevc
or vp9 in the future, so define its name as "av1" and put it into
external libraries codec list.

Signed-off-by: Fei Wang 
---
 Changelog  |   1 +
 configure  |   1 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/av1dec.c| 746 +
 libavcodec/av1dec.h|  89 +
 libavcodec/version.h   |   2 +-
 7 files changed, 840 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/av1dec.c
 create mode 100644 libavcodec/av1dec.h

diff --git a/Changelog b/Changelog
index 1efc768387..3ff88cc12f 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@ version :
 - ADPCM Argonaut Games encoder
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
+- AV1 decoder (Hardware acceleration used only)
 
 
 version 4.3:
diff --git a/configure b/configure
index 6faff9bc7b..ef71e47c4e 100755
--- a/configure
+++ b/configure
@@ -2685,6 +2685,7 @@ atrac3al_decoder_select="mdct"
 atrac3p_decoder_select="mdct sinewin"
 atrac3pal_decoder_select="mdct sinewin"
 atrac9_decoder_select="mdct"
+av1_decoder_select="cbs_av1"
 avrn_decoder_select="exif jpegtables"
 bink_decoder_select="blockdsp hpeldsp"
 binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3431ba2dca..2371039bd2 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -764,6 +764,7 @@ OBJS-$(CONFIG_ZLIB_DECODER)+= lcldec.o
 OBJS-$(CONFIG_ZLIB_ENCODER)+= lclenc.o
 OBJS-$(CONFIG_ZMBV_DECODER)+= zmbv.o
 OBJS-$(CONFIG_ZMBV_ENCODER)+= zmbvenc.o
+OBJS-$(CONFIG_AV1_DECODER) += av1dec.o
 
 # (AD)PCM decoders/encoders
 OBJS-$(CONFIG_PCM_ALAW_DECODER)   += pcm.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 4bd830e5d0..00799d3431 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -761,6 +761,7 @@ extern AVCodec ff_idf_decoder;
  * above is available */
 extern AVCodec ff_aac_mf_encoder;
 extern AVCodec ff_ac3_mf_encoder;
+extern AVCodec ff_av1_decoder;
 extern AVCodec ff_h263_v4l2m2m_encoder;
 extern AVCodec ff_libaom_av1_decoder;
 extern AVCodec ff_libopenh264_encoder;
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
new file mode 100644
index 00..ab88ed987a
--- /dev/null
+++ b/libavcodec/av1dec.c
@@ -0,0 +1,746 @@
+/*
+ * AV1video decoder
+ *
+ * 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 "avcodec.h"
+#include "get_bits.h"
+#include "hwconfig.h"
+#include "internal.h"
+#include "profiles.h"
+#include "thread.h"
+#include "videodsp.h"
+#include "libavutil/avassert.h"
+#include "libavutil/pixdesc.h"
+
+#include "av1dec.h"
+#include "libavformat/av1.h"
+
+static void setup_past_independence(AV1Frame *f)
+{
+f->loop_filter_delta_enabled = 1;
+
+f->loop_filter_ref_deltas[AV1_REF_FRAME_INTRA] = 1;
+f->loop_filter_ref_deltas[AV1_REF_FRAME_LAST] = 0;
+f->loop_filter_ref_deltas[AV1_REF_FRAME_LAST2] = 0;
+f->loop_filter_ref_deltas[AV1_REF_FRAME_LAST3] = 0;
+f->loop_filter_ref_deltas[AV1_REF_FRAME_GOLDEN] = -1;
+f->loop_filter_ref_deltas[AV1_REF_FRAME_BWDREF] = 0;
+f->loop_filter_ref_deltas[AV1_REF_FRAME_ALTREF2] = -1;
+f->loop_filter_ref_deltas[AV1_REF_FRAME_ALTREF] = -1;
+
+f->loop_filter_mode_deltas[0] = 0;
+f->loop_filter_mode_deltas[1] = 0;
+}
+
+static void load_previous_and_update(AV1DecContext *s)
+{
+int i;
+
+memcpy(s->cur_frame.loop_filter_ref_deltas,
+   
s->ref[s->raw_frame_header.primary_ref_frame].loop_filter_ref_deltas,
+   AV1_TOTAL_REFS_PER_FRAME * sizeof(int8_t));
+memcpy(s->cur_frame.loop_filter_mode_deltas,
+   
s->ref[s->raw_frame_header.primary_ref_frame].loop_filter_mode_deltas,
+   2 * sizeof(int8_t));
+
+if (s->raw_frame_header.loop_filter_delta_update) {
+for (i = 0; i < AV1_TOTAL_REFS_PER_FRAME; i++) {
+if (s->raw_frame_header.update_ref_delta[i])
+s->cur_frame.loop_filter_ref_deltas[i] =
+s->raw_frame_header.loop_filter_ref_deltas[i];
+}
+
+

[FFmpeg-devel] [PATCH 2/2] avcodec: add av1 VAAPI decoder

2020-08-20 Thread Fei Wang
Example cmdline:
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -v verbose \
-c:v av1 -i input.ivf -pix_fmt yuv420p -vsync passthrough -f md5 \
-y out.md5

Signed-off-by: Fei Wang 
---
 Changelog |   1 +
 configure |   3 +
 libavcodec/Makefile   |   1 +
 libavcodec/av1dec.c   |  23 ++-
 libavcodec/hwaccels.h |   1 +
 libavcodec/vaapi_av1.c| 287 ++
 libavcodec/vaapi_decode.c |   8 ++
 libavcodec/version.h  |   2 +-
 8 files changed, 324 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/vaapi_av1.c

diff --git a/Changelog b/Changelog
index 3ff88cc12f..799ebcdccd 100644
--- a/Changelog
+++ b/Changelog
@@ -15,6 +15,7 @@ version :
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
 - AV1 decoder (Hardware acceleration used only)
+- AV1 VAAPI decoder
 
 
 version 4.3:
diff --git a/configure b/configure
index ef71e47c4e..2bdfff204a 100755
--- a/configure
+++ b/configure
@@ -2916,6 +2916,8 @@ videotoolbox_hwaccel_deps="videotoolbox pthreads"
 videotoolbox_hwaccel_extralibs="-framework QuartzCore"
 xvmc_deps="X11_extensions_XvMClib_h"
 
+av1_vaapi_hwaccel_deps="vaapi_1_8"
+av1_vaapi_hwaccel_select="av1_decoder"
 h263_vaapi_hwaccel_deps="vaapi"
 h263_vaapi_hwaccel_select="h263_decoder"
 h263_videotoolbox_hwaccel_deps="videotoolbox"
@@ -6679,6 +6681,7 @@ if enabled vaapi; then
 fi
 
 check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0, 0)"
+check_cpp_condition vaapi_1_8 "va/va.h" "VA_CHECK_VERSION(1, 8, 0)"
 
 check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
 check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 2371039bd2..fe4cd06942 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -949,6 +949,7 @@ OBJS-$(CONFIG_VP9_NVDEC_HWACCEL)  += nvdec_vp9.o
 OBJS-$(CONFIG_VP9_VAAPI_HWACCEL)  += vaapi_vp9.o
 OBJS-$(CONFIG_VP9_VDPAU_HWACCEL)  += vdpau_vp9.o
 OBJS-$(CONFIG_VP8_QSV_HWACCEL)+= qsvdec_other.o
+OBJS-$(CONFIG_AV1_VAAPI_HWACCEL)  += vaapi_av1.o
 
 # libavformat dependencies
 OBJS-$(CONFIG_ISO_MEDIA)   += mpeg4audio.o mpegaudiodata.o
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index ab88ed987a..d212c19f2b 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -286,7 +286,7 @@ static int get_pixel_format(AVCodecContext *avctx)
 uint8_t bit_depth;
 int ret = 0;
 enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
-#define HWACCEL_MAX (0)
+#define HWACCEL_MAX (CONFIG_AV1_VAAPI_HWACCEL)
 enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts;
 
 if (seq->seq_profile == 2 && seq->color_config.high_bitdepth)
@@ -347,6 +347,24 @@ static int get_pixel_format(AVCodecContext *avctx)
 return -1;
 s->pix_fmt = pix_fmt;
 
+switch (s->pix_fmt) {
+case AV_PIX_FMT_YUV420P:
+#if CONFIG_AV1_VAAPI_HWACCEL
+*fmtp++ = AV_PIX_FMT_VAAPI;
+#endif
+break;
+case AV_PIX_FMT_YUV420P10:
+#if CONFIG_AV1_VAAPI_HWACCEL
+*fmtp++ = AV_PIX_FMT_VAAPI;
+#endif
+break;
+case AV_PIX_FMT_YUV420P12:
+#if CONFIG_AV1_VAAPI_HWACCEL
+*fmtp++ = AV_PIX_FMT_VAAPI;
+#endif
+break;
+}
+
 *fmtp++ = s->pix_fmt;
 *fmtp = AV_PIX_FMT_NONE;
 ret = ff_thread_get_format(avctx, pix_fmts);
@@ -741,6 +759,9 @@ AVCodec ff_av1_decoder = {
 .flush = av1_decode_flush,
 .profiles  = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
 .hw_configs= (const AVCodecHWConfigInternal * []) {
+#if CONFIG_AV1_VAAPI_HWACCEL
+HWACCEL_VAAPI(av1),
+#endif
 NULL
 },
 };
diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
index 6109c89bd6..18e9079c55 100644
--- a/libavcodec/hwaccels.h
+++ b/libavcodec/hwaccels.h
@@ -21,6 +21,7 @@
 
 #include "avcodec.h"
 
+extern const AVHWAccel ff_av1_vaapi_hwaccel;
 extern const AVHWAccel ff_h263_vaapi_hwaccel;
 extern const AVHWAccel ff_h263_videotoolbox_hwaccel;
 extern const AVHWAccel ff_h264_d3d11va_hwaccel;
diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c
new file mode 100644
index 00..8a046031dc
--- /dev/null
+++ b/libavcodec/vaapi_av1.c
@@ -0,0 +1,287 @@
+/*
+ * AV1 HW decode acceleration through VA API
+ *
+ * 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
+ 

Re: [FFmpeg-devel] [PATCH v2] libavfilter/vf_libvmaf: document log_fmt = csv

2020-08-20 Thread Gyan Doshi



On 20-08-2020 10:09 pm, Harry Mallon wrote:

Signed-off-by: Harry Mallon 
---
  doc/filters.texi | 2 +-
  libavfilter/vf_libvmaf.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)


Pushed as 412d63fe72d4398d0ffd271a9bd30c6ac9fc0deb

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

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

[FFmpeg-devel] [PATCH v2 1/2] qsv: needn't load user plugin since libmfx 1.28

2020-08-20 Thread Haihao Xiang
MFXVideoUSER_Load call is redundant since libmfx 1.28
---
Fixed merge conflict when applying this patch by 'git am'

 libavcodec/qsv.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 17720070f1..56a30ad642 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -19,7 +19,6 @@
  */
 
 #include 
-#include 
 #include 
 
 #include 
@@ -36,6 +35,10 @@
 #include "avcodec.h"
 #include "qsv_internal.h"
 
+#if !QSV_VERSION_ATLEAST(1, 28)
+#include 
+#endif
+
 #if QSV_VERSION_ATLEAST(1, 12)
 #include "mfx/mfxvp8.h"
 #endif
@@ -295,6 +298,9 @@ enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
 static int qsv_load_plugins(mfxSession session, const char *load_plugins,
 void *logctx)
 {
+#if QSV_VERSION_ATLEAST(1, 28)
+return 0;
+#else
 if (!load_plugins || !*load_plugins)
 return 0;
 
@@ -340,6 +346,7 @@ load_plugin_fail:
 }
 
 return 0;
+#endif
 
 }
 
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH V3 2/2] dnn/native: add log error message

2020-08-20 Thread Ting Fu
Signed-off-by: Ting Fu 
---
V3:
1. modify log_ctx of NativeModel to non-pointer
2. modify log_ctx of NativeModel to ctx
3. delete empty line

 libavfilter/dnn/dnn_backend_native.c  | 67 ++-
 libavfilter/dnn/dnn_backend_native.h  |  5 ++
 .../dnn/dnn_backend_native_layer_avgpool.c| 10 ++-
 .../dnn/dnn_backend_native_layer_avgpool.h|  2 +-
 .../dnn/dnn_backend_native_layer_conv2d.c | 10 ++-
 .../dnn/dnn_backend_native_layer_conv2d.h |  2 +-
 .../dnn_backend_native_layer_depth2space.c| 10 ++-
 .../dnn_backend_native_layer_depth2space.h|  2 +-
 .../dnn/dnn_backend_native_layer_mathbinary.c | 11 ++-
 .../dnn/dnn_backend_native_layer_mathbinary.h |  2 +-
 .../dnn/dnn_backend_native_layer_mathunary.c  | 11 ++-
 .../dnn/dnn_backend_native_layer_mathunary.h  |  2 +-
 .../dnn/dnn_backend_native_layer_maximum.c| 10 ++-
 .../dnn/dnn_backend_native_layer_maximum.h|  2 +-
 .../dnn/dnn_backend_native_layer_pad.c| 10 ++-
 .../dnn/dnn_backend_native_layer_pad.h|  2 +-
 libavfilter/dnn/dnn_backend_native_layers.h   |  2 +-
 tests/dnn/dnn-layer-avgpool-test.c|  4 +-
 tests/dnn/dnn-layer-conv2d-test.c |  4 +-
 tests/dnn/dnn-layer-depth2space-test.c|  2 +-
 tests/dnn/dnn-layer-mathbinary-test.c |  6 +-
 tests/dnn/dnn-layer-mathunary-test.c  |  2 +-
 tests/dnn/dnn-layer-maximum-test.c|  2 +-
 tests/dnn/dnn-layer-pad-test.c|  6 +-
 24 files changed, 130 insertions(+), 56 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 0be9c0b53c..b7de27c709 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -28,15 +28,26 @@
 #include "dnn_backend_native_layer_conv2d.h"
 #include "dnn_backend_native_layers.h"
 
+static const AVClass dnn_native_class = {
+.class_name = "dnn_native",
+.item_name  = av_default_item_name,
+.option = NULL,
+.version= LIBAVUTIL_VERSION_INT,
+.category   = AV_CLASS_CATEGORY_FILTER,
+};
+
 static DNNReturnType get_input_native(void *model, DNNData *input, const char 
*input_name)
 {
 NativeModel *native_model = (NativeModel *)model;
+NetworkContext *ctx = _model->ctx;
 
 for (int i = 0; i < native_model->operands_num; ++i) {
 DnnOperand *oprd = _model->operands[i];
 if (strcmp(oprd->name, input_name) == 0) {
-if (oprd->type != DOT_INPUT)
+if (oprd->type != DOT_INPUT) {
+av_log(ctx, AV_LOG_ERROR, "Found \"%s\" in model, but it is 
not input node\n", input_name);
 return DNN_ERROR;
+}
 input->dt = oprd->data_type;
 av_assert0(oprd->dims[0] == 1);
 input->height = oprd->dims[1];
@@ -47,30 +58,37 @@ static DNNReturnType get_input_native(void *model, DNNData 
*input, const char *i
 }
 
 // do not find the input operand
+av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model\n", input_name);
 return DNN_ERROR;
 }
 
 static DNNReturnType set_input_output_native(void *model, DNNData *input, 
const char *input_name, const char **output_names, uint32_t nb_output)
 {
 NativeModel *native_model = (NativeModel *)model;
+NetworkContext *ctx = _model->ctx;
 DnnOperand *oprd = NULL;
 
-if (native_model->layers_num <= 0 || native_model->operands_num <= 0)
+if (native_model->layers_num <= 0 || native_model->operands_num <= 0) {
+av_log(ctx, AV_LOG_ERROR, "No operands or layers in model\n");
 return DNN_ERROR;
+}
 
 /* inputs */
 for (int i = 0; i < native_model->operands_num; ++i) {
 oprd = _model->operands[i];
 if (strcmp(oprd->name, input_name) == 0) {
-if (oprd->type != DOT_INPUT)
+if (oprd->type != DOT_INPUT) {
+av_log(ctx, AV_LOG_ERROR, "Found \"%s\" in model, but it is 
not input node\n", input_name);
 return DNN_ERROR;
+}
 break;
 }
 oprd = NULL;
 }
-
-if (!oprd)
+if (!oprd) {
+av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model\n", 
input_name);
 return DNN_ERROR;
+}
 
 oprd->dims[0] = 1;
 oprd->dims[1] = input->height;
@@ -79,11 +97,15 @@ static DNNReturnType set_input_output_native(void *model, 
DNNData *input, const
 
 av_freep(>data);
 oprd->length = calculate_operand_data_length(oprd);
-if (oprd->length <= 0)
+if (oprd->length <= 0) {
+av_log(ctx, AV_LOG_ERROR, "The input data length overflow\n");
 return DNN_ERROR;
+}
 oprd->data = av_malloc(oprd->length);
-if (!oprd->data)
+if (!oprd->data) {
+av_log(ctx, AV_LOG_ERROR, "Failed to malloc memory for input data\n");
 return DNN_ERROR;
+}
 
 input->data = oprd->data;
 
@@ -91,8 +113,10 @@ static DNNReturnType set_input_output_native(void *model, 
DNNData 

[FFmpeg-devel] [PATCH V3 1/2] dnn/native: unify error return to DNN_ERROR

2020-08-20 Thread Ting Fu
Unify all error return as DNN_ERROR, in order to cease model executing
when return error in ff_dnn_execute_model_native layer_func.pf_exec

Signed-off-by: Ting Fu 
---
 libavfilter/dnn/dnn_backend_native_layer_avgpool.c | 2 +-
 libavfilter/dnn/dnn_backend_native_layer_conv2d.c  | 4 ++--
 libavfilter/dnn/dnn_backend_native_layer_depth2space.c | 4 ++--
 libavfilter/dnn/dnn_backend_native_layer_mathbinary.c  | 2 +-
 libavfilter/dnn/dnn_backend_native_layer_mathunary.c   | 2 +-
 libavfilter/dnn/dnn_backend_native_layer_pad.c | 4 ++--
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c 
b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
index d745c35b4a..e21a635c82 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
@@ -109,7 +109,7 @@ int dnn_execute_layer_avg_pool(DnnOperand *operands, const 
int32_t *input_operan
 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;
+return DNN_ERROR;
 output = output_operand->data;
 
 for (int y = 0; y < height_end; y += kernel_strides) {
diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c 
b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index a2202e4073..25356901c2 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -114,10 +114,10 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 output_operand->data_type = operands[input_operand_index].data_type;
 output_operand->length = calculate_operand_data_length(output_operand);
 if (output_operand->length <= 0)
-return -1;
+return DNN_ERROR;
 output_operand->data = av_realloc(output_operand->data, 
output_operand->length);
 if (!output_operand->data)
-return -1;
+return DNN_ERROR;
 output = output_operand->data;
 
 av_assert0(channel == conv_params->input_num);
diff --git a/libavfilter/dnn/dnn_backend_native_layer_depth2space.c 
b/libavfilter/dnn/dnn_backend_native_layer_depth2space.c
index 2c8bddf23d..5a61025f7a 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_depth2space.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_depth2space.c
@@ -76,10 +76,10 @@ int dnn_execute_layer_depth2space(DnnOperand *operands, 
const int32_t *input_ope
 output_operand->data_type = operands[input_operand_index].data_type;
 output_operand->length = calculate_operand_data_length(output_operand);
 if (output_operand->length <= 0)
-return -1;
+return DNN_ERROR;
 output_operand->data = av_realloc(output_operand->data, 
output_operand->length);
 if (!output_operand->data)
-return -1;
+return DNN_ERROR;
 output = output_operand->data;
 
 for (y = 0; y < height; ++y){
diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c 
b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
index dd42c329a9..bffa41cdda 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
@@ -176,6 +176,6 @@ int dnn_execute_layer_math_binary(DnnOperand *operands, 
const int32_t *input_ope
 }
 return 0;
 default:
-return -1;
+return DNN_ERROR;
 }
 }
diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c 
b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c
index 58ee0e9d3d..57bbd9d3e8 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c
@@ -143,6 +143,6 @@ int dnn_execute_layer_math_unary(DnnOperand *operands, 
const int32_t *input_oper
 dst[i] = round(src[i]);
 return 0;
 default:
-return -1;
+return DNN_ERROR;
 }
 }
diff --git a/libavfilter/dnn/dnn_backend_native_layer_pad.c 
b/libavfilter/dnn/dnn_backend_native_layer_pad.c
index feaab001e8..5452d22878 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_pad.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_pad.c
@@ -112,10 +112,10 @@ int dnn_execute_layer_pad(DnnOperand *operands, const 
int32_t *input_operand_ind
 output_operand->data_type = operands[input_operand_index].data_type;
 output_operand->length = calculate_operand_data_length(output_operand);
 if (output_operand->length <= 0)
-return -1;
+return DNN_ERROR;
 output_operand->data = av_realloc(output_operand->data, 
output_operand->length);
 if (!output_operand->data)
-return -1;
+return DNN_ERROR;
 output = output_operand->data;
 
 // copy the original data
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

Re: [FFmpeg-devel] [PATCH V4] dnn_backend_openvino.c: parse options in openvino backend

2020-08-20 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Alexander Strasser
> Sent: 2020年8月21日 0:58
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V4] dnn_backend_openvino.c: parse options
> in openvino backend
> 
> On 2020-08-20 01:10 +, Guo, Yejun wrote:
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Alexander Strasser
> > > Sent: 2020年8月20日 4:06
> > > To: FFmpeg development discussions and patches
> > > 
> > > Subject: Re: [FFmpeg-devel] [PATCH V4] dnn_backend_openvino.c: parse
> > > options in openvino backend
> > >
> > > On 2020-08-18 23:08 +0800, Guo, Yejun wrote:
> > > > Signed-off-by: Guo, Yejun 
> > > > ---
> > > > v3: use AVOption
> > > > v4: don't add new file dnn_common.h/c
> > > >
> > > >  libavfilter/dnn/dnn_backend_openvino.c | 50
> > > > +-
> > > >  1 file changed, 49 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/libavfilter/dnn/dnn_backend_openvino.c
> > > > b/libavfilter/dnn/dnn_backend_openvino.c
> > > > index d343bf2..277c313 100644
> > > > --- a/libavfilter/dnn/dnn_backend_openvino.c
> > > > +++ b/libavfilter/dnn/dnn_backend_openvino.c
> > > > @@ -26,9 +26,37 @@
> > > >  #include "dnn_backend_openvino.h"
> > > >  #include "libavformat/avio.h"
> > > >  #include "libavutil/avassert.h"
> > > > +#include "libavutil/opt.h"
> > > >  #include 
> > > >
> > > > +typedef struct OVOptions{
> > > > +uint32_t batch_size;
> > > > +uint32_t req_num;
> > > > +} OVOptions;
> > > > +
> > > > +typedef struct OvContext {
> > > > +const AVClass *class;
> > > > +OVOptions options;
> > > > +} OvContext;
> > > > +
> > > > +#define OFFSET(x) offsetof(OvContext, x) #define FLAGS
> > > > +AV_OPT_FLAG_FILTERING_PARAM static const AVOption
> > > > +dnn_ov_options[] = {
> > > > +{ "batch",   "batch size",OFFSET(options.batch_size),
> > > AV_OPT_TYPE_INT,  { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS },
> > > > +{ "nireq",   "number of request", OFFSET(options.req_num),
> > > AV_OPT_TYPE_INT,  { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS },
> > > > +{ NULL },
> > > > +};
> > >
> > > If I'm not mistaken, you must use type int when using AV_OPT_TYPE_INT .
> > >
> > > AFAIK we have these integer types
> > >
> > > * AV_OPT_TYPE_INT -> int
> > > * AV_OPT_TYPE_INT64 -> int64_t
> > > * AV_OPT_TYPE_UINT64 -> uint64_t
> > >
> > > and you can assume int to be at least 32 bits wide.
> > >
> >
> > thanks, I'll change from uint32_t to int.
> 
> Sounds about right.
> 
> Though as I'm looking at the code again, you should correct the allowed range 
> as
> well. I assume full signed int range was never intended, since the original 
> type
> was uint32_t .

thanks, the range will be [0, int_max]

> 
> 
> > > > @@ -186,7 +235,6 @@ DNNModel *ff_dnn_load_model_ov(const char
> > > *model_filename, const char *options)
> > > >  model->model = (void *)ov_model;
> > > >  model->set_input_output = _input_output_ov;
> > > >  model->get_input = _input_ov;
> > > > -model->options = options;
> > > >
> > > >  return model;
> > > >
> > > > --
> > >
> > > Sorry, if I missed it, are the values set from the options used anywhere?
> >
> > You are right, the options are not used.
> >
> > My teammates and I are working on the dnn backend performance
> > improvement, we have done locally many quick dirty code to verify our
> > ideas and found it requires some changes in the DNN module including these
> options.
> > (In our quick code, we are using fixed magic number for these options)
> 
> I feel you. It can be a long path, including back tracking at some points, to
> properly include some quick hacks.
> 
> 
> > So, as a collaboration, my idea is to separate the changes one patch
> > by one patch, and we can keep rebase locally, the final purpose is to 
> > upstream
> all our local code with refinement.
> 
> Sounds like a good idea.
> 
> Would be good if you could do it in a way that the individual commits are 
> mostly
> understandable on their own. Like here: parsing the options but not using them
> somewhere looks strange.

yes, good point. I'll just pending it and will send with other patch which uses 
the options.

> 
> If it's not feasibly possible, it would at least be required to mention the 
> planned
> follow-ups in the commit message. So we can make sense of it when looking at
> the commit message years from now.
> 
> 
>   Alexander
> ___
> 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".

Re: [FFmpeg-devel] [PATCH] fix memory leak in qsvenc.c

2020-08-20 Thread Xiang, Haihao

Thanks for fixing the memory leak in qsv, it looks good to me. 

Regards
Haihao


> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
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 3/5] lavc/libkvazaar: export encoded frame stats

2020-08-20 Thread James Almer
On 8/15/2020 5:48 AM, myp...@gmail.com wrote:
> On Sun, Aug 9, 2020 at 6:07 AM Mark Thompson  wrote:
>>
>> On 26/07/2020 13:26, Jun Zhao wrote:
>>> From: Jun Zhao 
>>>
>>> Export choosen pict_type and qp.
>>>
>>> Signed-off-by: Jun Zhao 
>>> ---
>>>   libavcodec/libkvazaar.c | 30 ++
>>>   1 file changed, 30 insertions(+)
>>>
>>> diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
>>> index 71c9c8f..9032547 100644
>>> --- a/libavcodec/libkvazaar.c
>>> +++ b/libavcodec/libkvazaar.c
>>> @@ -37,6 +37,7 @@
>>>
>>>   #include "avcodec.h"
>>>   #include "internal.h"
>>> +#include "packet_internal.h"
>>>
>>>   typedef struct LibkvazaarContext {
>>>   const AVClass *class;
>>> @@ -170,6 +171,7 @@ static int libkvazaar_encode(AVCodecContext *avctx,
>>>   kvz_data_chunk *data_out = NULL;
>>>   uint32_t len_out = 0;
>>>   int retval = 0;
>>> +int pict_type;
>>>
>>>   *got_packet_ptr = 0;
>>>
>>> @@ -257,6 +259,34 @@ static int libkvazaar_encode(AVCodecContext *avctx,
>>>   avpkt->flags |= AV_PKT_FLAG_KEY;
>>>   }
>>>
>>> +switch (frame_info.slice_type) {
>>> +case KVZ_SLICE_I:
>>> +pict_type = AV_PICTURE_TYPE_I;
>>> +break;
>>> +case KVZ_SLICE_P:
>>> +pict_type = AV_PICTURE_TYPE_P;
>>> +break;
>>> +case KVZ_SLICE_B:
>>> +pict_type = AV_PICTURE_TYPE_B;
>>> +break;
>>> +default:
>>> +av_log(avctx, AV_LOG_ERROR, "Unknown picture type 
>>> encountered.\n");
>>> +return AVERROR_EXTERNAL;
>>> +}
>>> +#if FF_API_CODED_FRAME
>>> +FF_DISABLE_DEPRECATION_WARNINGS
>>> +avctx->coded_frame->pict_type = pict_type;
>>> +FF_ENABLE_DEPRECATION_WARNINGS
>>> +#endif
>>
>> Is there some value to setting the deprecated fields?  They will disappear 
>> on the next version bump, which probably isn't very far away.
>>
> I think we can keep this part, if we want to remove the
> avctx->coded_frame->pict_type from next version bump, we can drop this
> part from all codec one-time

No, the usage of deprecated features should not be expanded. It's kept
in old encoders for compatibility reasons, but new ones should not use
it at all. So please remove it.

>>> +
>>> +ff_side_data_set_encoder_stats(avpkt, frame_info.qp * 
>>> FF_QP2LAMBDA, NULL, 0, pict_type);
>>
>> I'm not familiar with kvazaar - is the QP value here actually reflective of 
>> the global quality in a useful way?  The documentation is not very good...
>>
> Yes, it's a global quality based on Frame in kvazaar
> 
>> (Your following patch for OpenH264 uses a field "AverageFrameQP", which has 
>> an much more usefully-suggestive name.)
>>
>> Zero is a valid QP value, but you shouldn't be passing it here.  Possibly it 
>> needs some more scaling to get the range to [1, FF_LAMDBA_MAX].
>>
> I know vpx encoder wrapper used the zero QP value in side data, maybe
> we can keep the same action
>>> +
>>> +#if FF_API_CODED_FRAME
>>> +FF_DISABLE_DEPRECATION_WARNINGS
>>> +avctx->coded_frame->quality = frame_info.qp * FF_QP2LAMBDA;
>>> +FF_ENABLE_DEPRECATION_WARNINGS
>>> +#endif
>>> +
>>>   *got_packet_ptr = 1;
>>>   }
>>>
>>>
>> - Mark
> ___
> 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".

Re: [FFmpeg-devel] Curly braces around single statements (was avformat/avidec: Fix memleak when error) happens after creating DV stream

2020-08-20 Thread Mark Thompson

On 20/08/2020 22:20, Alexander Strasser wrote:

Please pardon me for bringing this up in the context of this patch.
No objections or particular opinion regarding this instance of the
problem.

Though thinking more globally, I believe it would have a beneficial
impact to add the curly braces everywhere; even where they would not
be required because of the one-statement exception.

It might be a bit longer regarding vertical space consumption, but
I'm sure the advantages would outweigh this disadvantage over time.
Also because we don't put the opening brace on a line of its own,
it would not consume so much more vertical space.

Advantages I see are:

1. enables easier experimentation and debugging


In my opinion this is not a significant benefit, the overhead of any edits 
while doing this is trivial.  (Others may disagree, but it seems worth noting 
which parts I agree with.)


2. future changes are easier to write and create smaller diffs


I agree that this is a point in favour.


3. completely eliminates dangling-else problems


I think this is irrelevant, because compilers have already solved it:

$ cat test-dangling-else.c

int f(int a, int b)
{
if (a)
if (b)
return 1;
  else
  return 2;

return 0;
}
$ gcc -c -Wall test-dangling-else.c
test-dangling-else.c: In function ‘f’:
test-dangling-else.c:4:8: warning: suggest explicit braces to avoid ambiguous 
‘else’ [-Wdangling-else]
4 | if (a)
  |^




Just wanted to hear how other developers currently feel about this.


The freeform nature of C is often helpful to make code look nicer and such a 
requirement would make some useful patterns worse, so I oppose such a change.

To offer an example, consider the commonish code pattern:

if  (a) p = x;
else if (b) q = y;
else if (c) r = z;

with some alignment of related subexpressions.  Making uniform use of braces 
and newlines mandatory makes this actively worse however you do it.

(Some randomly-chosen similar examples: 
,
 
.)

- Mark
___
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 3/5] lavc/libkvazaar: export encoded frame stats

2020-08-20 Thread Mark Thompson

On 15/08/2020 09:48, myp...@gmail.com wrote:

On Sun, Aug 9, 2020 at 6:07 AM Mark Thompson  wrote:


On 26/07/2020 13:26, Jun Zhao wrote:

From: Jun Zhao 

Export choosen pict_type and qp.

Signed-off-by: Jun Zhao 
---
   libavcodec/libkvazaar.c | 30 ++
   1 file changed, 30 insertions(+)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 71c9c8f..9032547 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -37,6 +37,7 @@

   #include "avcodec.h"
   #include "internal.h"
+#include "packet_internal.h"

   typedef struct LibkvazaarContext {
   const AVClass *class;
@@ -170,6 +171,7 @@ static int libkvazaar_encode(AVCodecContext *avctx,
   kvz_data_chunk *data_out = NULL;
   uint32_t len_out = 0;
   int retval = 0;
+int pict_type;

   *got_packet_ptr = 0;

@@ -257,6 +259,34 @@ static int libkvazaar_encode(AVCodecContext *avctx,
   avpkt->flags |= AV_PKT_FLAG_KEY;
   }

+switch (frame_info.slice_type) {
+case KVZ_SLICE_I:
+pict_type = AV_PICTURE_TYPE_I;
+break;
+case KVZ_SLICE_P:
+pict_type = AV_PICTURE_TYPE_P;
+break;
+case KVZ_SLICE_B:
+pict_type = AV_PICTURE_TYPE_B;
+break;
+default:
+av_log(avctx, AV_LOG_ERROR, "Unknown picture type encountered.\n");
+return AVERROR_EXTERNAL;
+}
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
+avctx->coded_frame->pict_type = pict_type;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif


Is there some value to setting the deprecated fields?  They will disappear on 
the next version bump, which probably isn't very far away.


I think we can keep this part, if we want to remove the
avctx->coded_frame->pict_type from next version bump, we can drop this
part from all codec one-time

+
+ff_side_data_set_encoder_stats(avpkt, frame_info.qp * FF_QP2LAMBDA, 
NULL, 0, pict_type);


I'm not familiar with kvazaar - is the QP value here actually reflective of the 
global quality in a useful way?  The documentation is not very good...


Yes, it's a global quality based on Frame in kvazaar


(Your following patch for OpenH264 uses a field "AverageFrameQP", which has an 
much more usefully-suggestive name.)

Zero is a valid QP value, but you shouldn't be passing it here.  Possibly it 
needs some more scaling to get the range to [1, FF_LAMDBA_MAX].


I know vpx encoder wrapper used the zero QP value in side data, maybe
we can keep the same action


So the libvpx wrapper is also broken?  This all seems very inconsistent - the 
documentation requires that the number be in [1, FF_LAMBDA_MAX], but codecs are 
using random numbers which include zero.

libx264 is applying some sort of offset so that the returned qpplus1 field is 
actually qpplussomewherebetween1and30 (with 10-bit input qp == -12 gives 
qpplus1 == 1 and qp == 51 gives qpplus1 == 81), but we still subtract 1 so the 
result includes zero.

libx265 doesn't seem to support negative QPs so it's always in the 8-bit range, 
but that still includes zero.

nvenc has frameAvgQP - 1, which seems bizarre.  I guess it would work if it 
doesn't support QP < 2, but given that it allows 12-bit inputs (range -24 to 
51) that seems unlikely.

Scaling to match what the documentation actually says seems like the sanest way to fix 
this - we can't change the range because zero is the "unused" value.

- Mark
___
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] fftools: Accept more negative prefixes

2020-08-20 Thread Mark Thompson

In addition to "no", also allow "no_", "disable" and "disable_".
---
On 20/08/2020 18:49, Nicolas George wrote:

Alexander Strasser (12020-08-17):

Here are some suggestions in no particular order:

* auto_conversion_filters (from Marton)


I can be ok with this one. I really dislike boolean options that default
to yes and have to be disabled with no, because it requires remembering
what the default is, but if that is what everybody else prefers.


But we can fix that to be nicer!

With this patch, -disable_auto_conversion_filters does what you want.

(The duplication below is because one part is used for ffmpeg and the other for 
ffplay/ffprobe.)

- Mark


 fftools/cmdutils.c | 42 +-
 1 file changed, 33 insertions(+), 9 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 88fdbeaf1e..1a1740b46e 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -345,6 +345,13 @@ static int write_option(void *optctx, const OptionDef *po, 
const char *opt,
 return 0;
 }

+static const char *negative_prefixes[] = {
+"no_",
+"no",
+"disable_",
+"disable",
+};
+
 int parse_option(void *optctx, const char *opt, const char *arg,
  const OptionDef *options)
 {
@@ -352,11 +359,18 @@ int parse_option(void *optctx, const char *opt, const 
char *arg,
 int ret;

 po = find_option(options, opt);
-if (!po->name && opt[0] == 'n' && opt[1] == 'o') {
-/* handle 'no' bool option */
-po = find_option(options, opt + 2);
-if ((po->name && (po->flags & OPT_BOOL)))
-arg = "0";
+if (!po->name) {
+/* Try to match a boolean option with a negative prefix. */
+for (int i = 0; i < FF_ARRAY_ELEMS(negative_prefixes); i++) {
+size_t len = strlen(negative_prefixes[i]);
+if (!strncmp(opt, negative_prefixes[i], len)) {
+po = find_option(options, opt + len);
+if (po->name && (po->flags & OPT_BOOL)) {
+arg = "0";
+break;
+}
+}
+}
 } else if (po->flags & OPT_BOOL)
 arg = "1";

@@ -764,6 +778,7 @@ int split_commandline(OptionParseContext *octx, int argc, 
char *argv[],
 while (optindex < argc) {
 const char *opt = argv[optindex++], *arg;
 const OptionDef *po;
+int negative_match;
 int ret;

 av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", opt);
@@ -831,10 +846,19 @@ do {  
 \
 }
 }

-/* boolean -nofoo options */
-if (opt[0] == 'n' && opt[1] == 'o' &&
-(po = find_option(options, opt + 2)) &&
-po->name && po->flags & OPT_BOOL) {
+/* Boolean options with a negative prefix. */
+negative_match = 0;
+for (int i = 0; i < FF_ARRAY_ELEMS(negative_prefixes); i++) {
+size_t len = strlen(negative_prefixes[i]);
+if (!strncmp(opt, negative_prefixes[i], len)) {
+po = find_option(options, opt + len);
+if (po->name && (po->flags & OPT_BOOL)) {
+negative_match = 1;
+break;
+}
+}
+}
+if (negative_match) {
 add_opt(octx, po, opt, "0");
 av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "
"argument 0.\n", po->name, po->help);
--
2.28.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 1/2] ffmpeg: add disable_all_auto_conversion_filters option.

2020-08-20 Thread Alexander Strasser
On 2020-08-20 19:49 +0200, Nicolas George wrote:
> Alexander Strasser (12020-08-17):
> > I think the pendulum can swing in both direction here. So the overall
> > effect is not clear to me. E.g. one developer may think
> >
> > "hey what's this -> i need to fix it"
> >
> > another might think
> >
> > "hey what's this -> better just copy and not look into it"
> >
> > and a third might think
> >
> > "hey what's this -> just another idiosyncrasy :("
>
> Fortunately, patches are not accepted without review: they will do that,
> the reviewer will ask them to fix the test and re-submit.

True, that might work for the second developer, the third might get
silently fed up.


> > Here are some suggestions in no particular order:
> >
> > * auto_conversion_filters (from Marton)
>
> I can be ok with this one. I really dislike boolean options that default
> to yes and have to be disabled with no, because it requires remembering
> what the default is, but if that is what everybody else prefers.
>
> > * lavfi_auto_conversion
> > * lavfi_autoconv
> > * lavfi_sample_format_conversion
> > * lavfi_fmt_conversion (in reference to pix_fmt and sample_fmt)
> > * lavfi_fmt_conv
>
> The last three lack the "auto" bit. Explicit conversions are still
> supported.

I wonder if the auto (automatic) part is really needed for the name.

AFAIU explicit conversions are just explicit use of filters which change
the sample formats. I guess it would really far fetched to assume that
those could be disabled, since it would be like disabling all filters
or like allowing no conversions in the filter graph at all.

I agree it's possible to misunderstand, though I would have said not
very likely. After you said it out loud, it feels a little bit more
likely to me now ;-)


  Alexander
___
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] Curly braces around single statements (was avformat/avidec: Fix memleak when error) happens after creating DV stream

2020-08-20 Thread Alexander Strasser
On 2020-08-20 22:32 +0200, Michael Niedermayer wrote:
> On Thu, Aug 20, 2020 at 12:46:12PM +0200, Andreas Rheinhardt wrote:
> > Michael Niedermayer:
> > > On Wed, Aug 19, 2020 at 12:00:37AM +0200, Andreas Rheinhardt wrote:
> > >> Signed-off-by: Andreas Rheinhardt 
> > >> ---
> > >> The memleak can be reproduced with e.g. the first 163 bytes of
> > >> https://samples.ffmpeg.org/archive/all/avi+dvvideo+pcm_s16le++ffmpeg-avidec554-crash.avi
> > >>
> > >>  libavformat/avidec.c | 31 +--
> > >>  1 file changed, 17 insertions(+), 14 deletions(-)
> > >>
> > >> diff --git a/libavformat/avidec.c b/libavformat/avidec.c
> > >> index 5fc3e01aa9..08b864f19a 100644
> > >> --- a/libavformat/avidec.c
> > >> +++ b/libavformat/avidec.c
> > >> @@ -113,6 +113,7 @@ static const AVMetadataConv avi_metadata_conv[] = {
> > >>  { 0 },
> > >>  };
> > >>
> > >> +static int avi_read_close(AVFormatContext *s);
> > >>  static int avi_load_index(AVFormatContext *s);
> > >>  static int guess_ni_flag(AVFormatContext *s);
> > >>
> > >> @@ -464,6 +465,7 @@ static int calculate_bitrate(AVFormatContext *s)
> > >>  return 1;
> > >>  }
> > >>
> > >> +#define RETURN_ERROR(code) do { ret = (code); goto fail; } while (0)
> > >>  static int avi_read_header(AVFormatContext *s)
> > >>  {
> > >>  AVIContext *avi = s->priv_data;
> > >> @@ -499,7 +501,7 @@ static int avi_read_header(AVFormatContext *s)
> > >>  frame_period = 0;
> > >>  for (;;) {
> > >>  if (avio_feof(pb))
> > >> -goto fail;
> > >> +RETURN_ERROR(AVERROR_INVALIDDATA);
> > >
> > > this macro is messy
> > > it replaces writing
> > > {ret = AVERROR_INVALIDDATA; goto fail;}
> > > by
> > > RETURN_ERROR(AVERROR_INVALIDDATA);
> > >
> > > this is almost the same length but the first is directly understood C code
> > > the 2nd is harder to understand for someone reading the code so i
> > > suggest to avoid the 2nd and use something else, not saying that needs to
> > > be the first
> > >
> > The only reason this macro exists is because it allows me to add code
> > that can easily be removed lateron when cleaning up after read_header
> > failure will be automatic, whereas an
> >
> > if (foo) {
> > ret = bar;
> > goto fail;
> > }
> >
> > leads to a bigger diff now and later. If you want to, I could of course use
>
> I have no oppinion about the intermediate state but i think we should have
> optimally readable/clean code in the end after all planned changes

Please pardon me for bringing this up in the context of this patch.
No objections or particular opinion regarding this instance of the
problem.

Though thinking more globally, I believe it would have a beneficial
impact to add the curly braces everywhere; even where they would not
be required because of the one-statement exception.

It might be a bit longer regarding vertical space consumption, but
I'm sure the advantages would outweigh this disadvantage over time.
Also because we don't put the opening brace on a line of its own,
it would not consume so much more vertical space.

Advantages I see are:

1. enables easier experimentation and debugging
2. future changes are easier to write and create smaller diffs
3. completely eliminates dangling-else problems


Just wanted to hear how other developers currently feel about this.


  Alexander
___
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 1/3] avcodec/aacdec_template: keep tabs on layout in sniff_channel_order

2020-08-20 Thread Jan Ekström
On Tue, Aug 18, 2020 at 10:25 PM Jan Ekström  wrote:
>
> This way the layout set at various points can be checked instead
> of only having the layout at the end.
> ---
>  libavcodec/aacdec_template.c | 53 ++--
>  1 file changed, 32 insertions(+), 21 deletions(-)
>
> diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
> index 8c5048cc13..9eef1c0158 100644
> --- a/libavcodec/aacdec_template.c
> +++ b/libavcodec/aacdec_template.c
> @@ -198,7 +198,7 @@ struct elem_to_channel {
>
>  static int assign_pair(struct elem_to_channel e2c_vec[MAX_ELEM_ID],
> uint8_t (*layout_map)[3], int offset, uint64_t left,
> -   uint64_t right, int pos)
> +   uint64_t right, int pos, uint64_t *layout)
>  {
>  if (layout_map[offset][0] == TYPE_CPE) {
>  e2c_vec[offset] = (struct elem_to_channel) {
> @@ -207,6 +207,9 @@ static int assign_pair(struct elem_to_channel 
> e2c_vec[MAX_ELEM_ID],
>  .elem_id  = layout_map[offset][1],
>  .aac_position = pos
>  };
> +if (e2c_vec[offset].av_position != UINT64_MAX)
> +*layout |= e2c_vec[offset].av_position;
> +
>  return 1;
>  } else {
>  e2c_vec[offset] = (struct elem_to_channel) {
> @@ -221,6 +224,9 @@ static int assign_pair(struct elem_to_channel 
> e2c_vec[MAX_ELEM_ID],
>  .elem_id  = layout_map[offset + 1][1],
>  .aac_position = pos
>  };
> +if ((left|right) != UINT64_MAX)
> +*layout |= (left|right);

After taking a look at this for a second time, maybe the left and
right should be handled separately here? Although the function only
seems to be utilized with UINT64_MAX when both of the values are such,
handling them together doesn't currently break anything.

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

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

Re: [FFmpeg-devel] [PATCH] avformat/flvdec: RtmpSampleAccess no longer breaks stream detection

2020-08-20 Thread Michael Niedermayer
On Thu, Aug 20, 2020 at 05:14:12PM +0200, Peter van der Spek wrote:
> I suppose that’s okay. It’s in the input stream as well after all.

well, then the patch is probably ok, but ill wait a few days before applyng
so we dont miss something.
dont hesitate to remind me to apply this in a few days

thx

> On 20 Aug 2020, 13:19 +0200, Michael Niedermayer , 
> wrote:
> > On Wed, Aug 19, 2020 at 09:06:54AM +0200, Peter van der Spek wrote:
[...]
> > when transcoding this will copy this "|RtmpSampleAccess" thing in the output
> > is that intended ?
> >
> > thx
> >
> > [...]
> > --
> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > It is what and why we do it that matters, not just one of them.
> >
> > ___
> > 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".

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"I am not trying to be anyone's saviour, I'm trying to think about the
 future and not be sad" - Elon Musk



signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avformat/avidec: Fix memleak when error happens after creating DV stream

2020-08-20 Thread Michael Niedermayer
On Thu, Aug 20, 2020 at 12:46:12PM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > On Wed, Aug 19, 2020 at 12:00:37AM +0200, Andreas Rheinhardt wrote:
> >> Signed-off-by: Andreas Rheinhardt 
> >> ---
> >> The memleak can be reproduced with e.g. the first 163 bytes of
> >> https://samples.ffmpeg.org/archive/all/avi+dvvideo+pcm_s16le++ffmpeg-avidec554-crash.avi
> >>
> >>  libavformat/avidec.c | 31 +--
> >>  1 file changed, 17 insertions(+), 14 deletions(-)
> >>
> >> diff --git a/libavformat/avidec.c b/libavformat/avidec.c
> >> index 5fc3e01aa9..08b864f19a 100644
> >> --- a/libavformat/avidec.c
> >> +++ b/libavformat/avidec.c
> >> @@ -113,6 +113,7 @@ static const AVMetadataConv avi_metadata_conv[] = {
> >>  { 0 },
> >>  };
> >>  
> >> +static int avi_read_close(AVFormatContext *s);
> >>  static int avi_load_index(AVFormatContext *s);
> >>  static int guess_ni_flag(AVFormatContext *s);
> >>  
> >> @@ -464,6 +465,7 @@ static int calculate_bitrate(AVFormatContext *s)
> >>  return 1;
> >>  }
> >>  
> >> +#define RETURN_ERROR(code) do { ret = (code); goto fail; } while (0)
> >>  static int avi_read_header(AVFormatContext *s)
> >>  {
> >>  AVIContext *avi = s->priv_data;
> >> @@ -499,7 +501,7 @@ static int avi_read_header(AVFormatContext *s)
> >>  frame_period = 0;
> >>  for (;;) {
> >>  if (avio_feof(pb))
> >> -goto fail;
> >> +RETURN_ERROR(AVERROR_INVALIDDATA);
> > 
> > this macro is messy
> > it replaces writing 
> > {ret = AVERROR_INVALIDDATA; goto fail;}
> > by
> > RETURN_ERROR(AVERROR_INVALIDDATA);
> > 
> > this is almost the same length but the first is directly understood C code
> > the 2nd is harder to understand for someone reading the code so i  
> > suggest to avoid the 2nd and use something else, not saying that needs to
> > be the first
> > 
> The only reason this macro exists is because it allows me to add code
> that can easily be removed lateron when cleaning up after read_header
> failure will be automatic, whereas an
> 
> if (foo) {
> ret = bar;
> goto fail;
> }
> 
> leads to a bigger diff now and later. If you want to, I could of course use

I have no oppinion about the intermediate state but i think we should have
optimally readable/clean code in the end after all planned changes

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"Nothing to hide" only works if the folks in power share the values of
you and everyone you know entirely and always will -- Tom Scott



signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavformat/http, tls: honor http_proxy command line variable for HTTPS

2020-08-20 Thread Martin Storsjö

Hej,

On Thu, 20 Aug 2020, Moritz Barsnick wrote:


Hej Martin,

On Thu, Aug 20, 2020 at 22:05:39 +0300, Martin Storsjö wrote:


Even if you do e.g. a plain tls socket (or rtmps, or whatever), you may
want to do the tls connection through a proxy server (be that a socks
proxy or http proxy).


Actually, I forget that an HTTP proxy with CONNECT support cn transport
any plain socket. I will amend documentation to doc/*.texi.


For the case of rtmps, if you pass the http_proxy option, it should be
passed to the rtmps protocol, which doesn't have such an option, from
where it's passed along in the options dictionary down until the tls
protocol consumes it.


So you're saying it already works for rtmps, nothing needs to be
changed there? Fine.


I didn't test it, but from browsing the code, it looks like it would work.

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

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

Re: [FFmpeg-devel] [PATCH] libavformat/http, tls: honor http_proxy command line variable for HTTPS

2020-08-20 Thread Moritz Barsnick
Hej Martin,

On Thu, Aug 20, 2020 at 22:05:39 +0300, Martin Storsjö wrote:

> Even if you do e.g. a plain tls socket (or rtmps, or whatever), you may
> want to do the tls connection through a proxy server (be that a socks
> proxy or http proxy).

Actually, I forget that an HTTP proxy with CONNECT support cn transport
any plain socket. I will amend documentation to doc/*.texi.

> For the case of rtmps, if you pass the http_proxy option, it should be
> passed to the rtmps protocol, which doesn't have such an option, from
> where it's passed along in the options dictionary down until the tls
> protocol consumes it.

So you're saying it already works for rtmps, nothing needs to be
changed there? Fine.

Thanks for the review, will follow up with v2,
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] libavformat/ffmetadecc.c: Fix Use-of-uninitialized-value

2020-08-20 Thread Thierry Foucu
Check the return value of sscanf as it can return -1(EOF), for example
when the first char in the line is 0x00
---
 libavformat/ffmetadec.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/ffmetadec.c b/libavformat/ffmetadec.c
index 45c92f1ff6..0ea89fe3f3 100644
--- a/libavformat/ffmetadec.c
+++ b/libavformat/ffmetadec.c
@@ -101,19 +101,22 @@ static AVChapter *read_chapter(AVFormatContext *s)
 uint8_t line[256];
 int64_t start, end;
 AVRational tb = {1, 1e9};
+int ret;
 
 get_line(s->pb, line, sizeof(line));
 
 if (sscanf(line, "TIMEBASE=%d/%d", , ))
 get_line(s->pb, line, sizeof(line));
-if (!sscanf(line, "START=%"SCNd64, )) {
+ret = sscanf(line, "START=%"SCNd64, );
+if (ret <= 0) {
 av_log(s, AV_LOG_ERROR, "Expected chapter start timestamp, found 
%s.\n", line);
 start = (s->nb_chapters && s->chapters[s->nb_chapters - 1]->end != 
AV_NOPTS_VALUE) ?
  s->chapters[s->nb_chapters - 1]->end : 0;
 } else
 get_line(s->pb, line, sizeof(line));
 
-if (!sscanf(line, "END=%"SCNd64, )) {
+ret = sscanf(line, "END=%"SCNd64, );
+if (ret <= 0) {
 av_log(s, AV_LOG_ERROR, "Expected chapter end timestamp, found %s.\n", 
line);
 end = AV_NOPTS_VALUE;
 }
-- 
2.28.0.297.g1956fa8f8d-goog

___
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] libavformat/http, tls: honor http_proxy command line variable for HTTPS

2020-08-20 Thread Martin Storsjö

On Thu, 20 Aug 2020, Moritz Barsnick wrote:


Add the "http_proxy" option and its handling to the "tls" protocol,
pass the option from the "https" protocol.

The "https" protocol already defines the "http_proxy" command line
option, like the "http" protocol does. The "http" protocol properly
honors that command line option in addition to the environment
variable. The "https" protocol doesn't, because the proxy is
evaluated in the underlying "tls" protocol, which doesn't have this
option, and thus only handles the environment variable, which it
has access to.

Documentation for the "tls" protocol is not changed, as the new
option is basically only useful together with the "https" protocol.


The patch looks fine in general, I think, but I don't agree with the last 
statement here.


Even if you do e.g. a plain tls socket (or rtmps, or whatever), you may 
want to do the tls connection through a proxy server (be that a socks 
proxy or http proxy).


For the case of rtmps, if you pass the http_proxy option, it should be 
passed to the rtmps protocol, which doesn't have such an option, from 
where it's passed along in the options dictionary down until the tls 
protocol consumes it. This just doesn't work for https, as the shared 
http/https options dictionary consumes the option from the dictionary, so 
you have to readd it like you do in your patch.


// Martin

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

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

Re: [FFmpeg-devel] [RFC PATCH 4/4] libavcodec/j2kenc: Support for multiple layers

2020-08-20 Thread Gautam Ramakrishnan
On Thu, Aug 20, 2020 at 12:55 AM Paul B Mahol  wrote:
>
> On 8/19/20, Gautam Ramakrishnan  wrote:
> > On Wed, Aug 19, 2020 at 5:51 PM  wrote:
> >>
> >> From: Gautam Ramakrishnan 
> >>
> >> This patch allows setting a compression ratio and to
> >> set multiple layers. The user has to input a compression
> >> ratio for each layer.
> >> The per layer compression ration can be set as follows:
> >> -layer_rates "r1,r2,...rn"
> >> for to create 'n' layers.
> >> ---
> >>  libavcodec/j2kenc.c   | 443 ++
> >>  libavcodec/jpeg2000.c |  13 +-
> >>  libavcodec/jpeg2000.h |  10 +
> >>  3 files changed, 384 insertions(+), 82 deletions(-)
> >>
> >> diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
> >> index 8699296434..b09db36c14 100644
> >> --- a/libavcodec/j2kenc.c
> >> +++ b/libavcodec/j2kenc.c
> >> @@ -32,6 +32,7 @@
> >>   * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
> >>   * Copyright (c) 2005, Herve Drolon, FreeImage Team
> >>   * Copyright (c) 2007, Callum Lerwick 
> >> + * Copyright (c) 2020, Gautam Ramakrishnan 
> >>   * All rights reserved.
> >>   *
> >>   * Redistribution and use in source and binary forms, with or without
> >> @@ -100,6 +101,7 @@ static const int dwt_norms[2][4][10] = { //
> >> [dwt_type][band][rlevel] (multiplied
> >>
> >>  typedef struct {
> >> Jpeg2000Component *comp;
> >> +   double *layer_rates;
> >>  } Jpeg2000Tile;
> >>
> >>  typedef struct {
> >> @@ -126,12 +128,15 @@ typedef struct {
> >>  Jpeg2000QuantStyle  qntsty;
> >>
> >>  Jpeg2000Tile *tile;
> >> +int layer_rates[100];
> >>
> >>  int format;
> >>  int pred;
> >>  int sop;
> >>  int eph;
> >>  int prog;
> >> +int nlayers;
> >> +char *lr_str;
> >>  } Jpeg2000EncoderContext;
> >>
> >>
> >> @@ -332,7 +337,7 @@ static int put_cod(Jpeg2000EncoderContext *s)
> >>  bytestream_put_byte(>buf, scod);  // Scod
> >>  // SGcod
> >>  bytestream_put_byte(>buf, s->prog); // progression level
> >> -bytestream_put_be16(>buf, 1); // num of layers
> >> +bytestream_put_be16(>buf, s->nlayers); // num of layers
> >>  if(s->avctx->pix_fmt == AV_PIX_FMT_YUV444P){
> >>  bytestream_put_byte(>buf, 0); // unspecified
> >>  }else{
> >> @@ -411,6 +416,31 @@ static uint8_t *put_sot(Jpeg2000EncoderContext *s,
> >> int tileno)
> >>  return psotptr;
> >>  }
> >>
> >> +static void compute_rates(Jpeg2000EncoderContext* s)
> >> +{
> >> +int i, j;
> >> +int layno, compno;
> >> +for (i = 0; i < s->numYtiles; i++) {
> >> +for (j = 0; j < s->numXtiles; j++) {
> >> +Jpeg2000Tile *tile = >tile[s->numXtiles * i + j];
> >> +for (compno = 0; compno < s->ncomponents; compno++) {
> >> +int tilew = tile->comp[compno].coord[0][1] -
> >> tile->comp[compno].coord[0][0];
> >> +int tileh = tile->comp[compno].coord[1][1] -
> >> tile->comp[compno].coord[1][0];
> >> +int scale = (compno?1 << s->chroma_shift[0]:1) *
> >> (compno?1 << s->chroma_shift[1]:1);
> >> +for (layno = 0; layno < s->nlayers; layno++) {
> >> +if (s->layer_rates[layno] > 0.0f) {
> >> +tile->layer_rates[layno] += (double)(tilew *
> >> tileh) * s->ncomponents * s->cbps[compno] /
> >> +
> >> (double)(s->layer_rates[layno] * 8 * scale);
> >> +} else {
> >> +tile->layer_rates[layno] = 0.0f;
> >> +}
> >> +}
> >> +}
> >> +}
> >> +}
> >> +
> >> +}
> >> +
> >>  /**
> >>   * compute the sizes of tiles, resolution levels, bands, etc.
> >>   * allocate memory for them
> >> @@ -448,6 +478,10 @@ static int init_tiles(Jpeg2000EncoderContext *s)
> >>  for (j = 0; j < 2; j++)
> >>  comp->coord[i][j] = comp->coord_o[i][j] =
> >> ff_jpeg2000_ceildivpow2(comp->coord[i][j], s->chroma_shift[i]);
> >>
> >> +tile->layer_rates = av_mallocz_array(s->ncomponents,
> >> sizeof(*tile->layer_rates));
> >> +if (!tile->layer_rates)
> >> +return AVERROR(ENOMEM);
> >> +
> >>  if ((ret = ff_jpeg2000_init_component(comp,
> >>  codsty,
> >>  qntsty,
> >> @@ -459,6 +493,7 @@ static int init_tiles(Jpeg2000EncoderContext *s)
> >>  return ret;
> >>  }
> >>  }
> >> +compute_rates(s);
> >>  return 0;
> >>  }
> >>
> >> @@ -701,6 +736,8 @@ static void encode_cblk(Jpeg2000EncoderContext *s,
> >> Jpeg2000T1Context *t1, Jpeg20
> >>  }
> >>
> >>  cblk->passes[passno].rate = ff_mqc_flush_to(>mqc,
> >> cblk->passes[passno].flushed, >passes[passno].flushed_len);
> >> +cblk->passes[passno].rate -= cblk->passes[passno].flushed_len;
> >> +
> >>  wmsedec += (int64_t)nmsedec 

Re: [FFmpeg-devel] [PATCH] configure: Add additional glslang libraries to make linking work

2020-08-20 Thread Christopher Degawa
This patch is needed to fix compilation on windows using the git
master branches of both glslang and ffmpeg, although I don't know what
version or commit of glslang started to require it, the earliest
record I have of this issue is july 5th.
___
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 1/2] ffmpeg: add disable_all_auto_conversion_filters option.

2020-08-20 Thread Nicolas George
Alexander Strasser (12020-08-17):
> I think the pendulum can swing in both direction here. So the overall
> effect is not clear to me. E.g. one developer may think
> 
> "hey what's this -> i need to fix it"
> 
> another might think
> 
> "hey what's this -> better just copy and not look into it"
> 
> and a third might think
> 
> "hey what's this -> just another idiosyncrasy :("

Fortunately, patches are not accepted without review: they will do that,
the reviewer will ask them to fix the test and re-submit.

> Here are some suggestions in no particular order:
> 
> * auto_conversion_filters (from Marton)

I can be ok with this one. I really dislike boolean options that default
to yes and have to be disabled with no, because it requires remembering
what the default is, but if that is what everybody else prefers.

> * lavfi_auto_conversion
> * lavfi_autoconv
> * lavfi_sample_format_conversion
> * lavfi_fmt_conversion (in reference to pix_fmt and sample_fmt)
> * lavfi_fmt_conv

The last three lack the "auto" bit. Explicit conversions are still
supported.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 4/4] lavfi: remove request_samples.

2020-08-20 Thread Nicolas George
Paul B Mahol (12020-08-19):
> On 8/12/20, Nicolas George  wrote:
> > Filters can use min_samples/max_samples if the number is constant
> > or activate and ff_inlink_consume_samples().
> >
> 
> LGTM

Thanks. Series pushed.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH V4] dnn_backend_openvino.c: parse options in openvino backend

2020-08-20 Thread Alexander Strasser
On 2020-08-20 01:10 +, Guo, Yejun wrote:
>
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Alexander Strasser
> > Sent: 2020年8月20日 4:06
> > To: FFmpeg development discussions and patches 
> > Subject: Re: [FFmpeg-devel] [PATCH V4] dnn_backend_openvino.c: parse options
> > in openvino backend
> >
> > On 2020-08-18 23:08 +0800, Guo, Yejun wrote:
> > > Signed-off-by: Guo, Yejun 
> > > ---
> > > v3: use AVOption
> > > v4: don't add new file dnn_common.h/c
> > >
> > >  libavfilter/dnn/dnn_backend_openvino.c | 50
> > > +-
> > >  1 file changed, 49 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/libavfilter/dnn/dnn_backend_openvino.c
> > > b/libavfilter/dnn/dnn_backend_openvino.c
> > > index d343bf2..277c313 100644
> > > --- a/libavfilter/dnn/dnn_backend_openvino.c
> > > +++ b/libavfilter/dnn/dnn_backend_openvino.c
> > > @@ -26,9 +26,37 @@
> > >  #include "dnn_backend_openvino.h"
> > >  #include "libavformat/avio.h"
> > >  #include "libavutil/avassert.h"
> > > +#include "libavutil/opt.h"
> > >  #include 
> > >
> > > +typedef struct OVOptions{
> > > +uint32_t batch_size;
> > > +uint32_t req_num;
> > > +} OVOptions;
> > > +
> > > +typedef struct OvContext {
> > > +const AVClass *class;
> > > +OVOptions options;
> > > +} OvContext;
> > > +
> > > +#define OFFSET(x) offsetof(OvContext, x) #define FLAGS
> > > +AV_OPT_FLAG_FILTERING_PARAM static const AVOption dnn_ov_options[] =
> > > +{
> > > +{ "batch",   "batch size",OFFSET(options.batch_size),
> > AV_OPT_TYPE_INT,  { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS },
> > > +{ "nireq",   "number of request", OFFSET(options.req_num),
> > AV_OPT_TYPE_INT,  { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS },
> > > +{ NULL },
> > > +};
> >
> > If I'm not mistaken, you must use type int when using AV_OPT_TYPE_INT .
> >
> > AFAIK we have these integer types
> >
> > * AV_OPT_TYPE_INT -> int
> > * AV_OPT_TYPE_INT64 -> int64_t
> > * AV_OPT_TYPE_UINT64 -> uint64_t
> >
> > and you can assume int to be at least 32 bits wide.
> >
>
> thanks, I'll change from uint32_t to int.

Sounds about right.

Though as I'm looking at the code again, you should correct the
allowed range as well. I assume full signed int range was never
intended, since the original type was uint32_t .


> > > @@ -186,7 +235,6 @@ DNNModel *ff_dnn_load_model_ov(const char
> > *model_filename, const char *options)
> > >  model->model = (void *)ov_model;
> > >  model->set_input_output = _input_output_ov;
> > >  model->get_input = _input_ov;
> > > -model->options = options;
> > >
> > >  return model;
> > >
> > > --
> >
> > Sorry, if I missed it, are the values set from the options used anywhere?
>
> You are right, the options are not used.
>
> My teammates and I are working on the dnn backend performance
> improvement, we have done locally many quick dirty code to verify our ideas 
> and
> found it requires some changes in the DNN module including these options.
> (In our quick code, we are using fixed magic number for these options)

I feel you. It can be a long path, including back tracking at some
points, to properly include some quick hacks.


> So, as a collaboration, my idea is to separate the changes one patch by one 
> patch,
> and we can keep rebase locally, the final purpose is to upstream all our 
> local code with refinement.

Sounds like a good idea.

Would be good if you could do it in a way that the individual commits
are mostly understandable on their own. Like here: parsing the options
but not using them somewhere looks strange.

If it's not feasibly possible, it would at least be required to mention
the planned follow-ups in the commit message. So we can make sense of
it when looking at the commit message years from now.


  Alexander
___
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/proresenc: add support for PQ and HLG

2020-08-20 Thread Michael Bradshaw
On Wed, Aug 19, 2020 at 9:23 PM zhilizhao  wrote:

> > -static const int valid_trc[4]= { AVCOL_TRC_RESERVED0,
> AVCOL_TRC_BT709, AVCOL_TRC_UNSPECIFIED, INT_MAX };
> > +static const int valid_trc[6]= { AVCOL_TRC_RESERVED0,
> AVCOL_TRC_BT709, AVCOL_TRC_UNSPECIFIED, AVCOL_TRC_SMPTE2084,
> > + AVCOL_TRC_ARIB_STD_B67,
> INT_MAX };
>
> For future-proof, how about remove the array size?


Sure, but maybe as a follow-up patch? I'd like to remove the array size
from all of the arrays, but I don't want this particular patch to grow
beyond its original scope.
___
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] libavformat/http, tls: honor http_proxy command line variable for HTTPS

2020-08-20 Thread Moritz Barsnick
Hi,

I gave $SUBJECT a shot. It's a bit of a weird situation, as "https" has
an underlying protocol "tls" which handles HTTPS specific stuff, but I
guess that's the layer cake the protocols give us.

So I needed to add an HTTPS specific option to the "tls" protocol, in
order to hand the option through. It's handling is then now identical
to the "http" implementation.

I tested this (before and after patch, with and without command line
option, with and without environment variable, with and without
reachable proxy server) against a local installation of tinyproxy.

Please review.

Thanks,
Moritz
From 095bb727b2400a75d6bf8c74ab90831aaefbc5aa Mon Sep 17 00:00:00 2001
From: Moritz Barsnick 
Date: Thu, 20 Aug 2020 17:49:14 +0200
Subject: [PATCH] libavformat/http,tls: honor http_proxy command line variable
 for HTTPS

Add the "http_proxy" option and its handling to the "tls" protocol,
pass the option from the "https" protocol.

The "https" protocol already defines the "http_proxy" command line
option, like the "http" protocol does. The "http" protocol properly
honors that command line option in addition to the environment
variable. The "https" protocol doesn't, because the proxy is
evaluated in the underlying "tls" protocol, which doesn't have this
option, and thus only handles the environment variable, which it
has access to.

Documentation for the "tls" protocol is not changed, as the new
option is basically only useful together with the "https" protocol.

Fixes #7223.

Signed-off-by: Moritz Barsnick 
---
 libavformat/http.c | 6 ++
 libavformat/tls.c  | 2 +-
 libavformat/tls.h  | 2 ++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 6c39da1a8b..21584bdce9 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -213,6 +213,12 @@ static int http_open_cnx_internal(URLContext *h, 
AVDictionary **options)
 use_proxy   = 0;
 if (port < 0)
 port = 443;
+/* pass http_proxy to underlying protocol */
+if (s->http_proxy) {
+err = av_dict_set(options, "http_proxy", s->http_proxy, 0);
+if (err < 0)
+return err;
+}
 }
 if (port < 0)
 port = 80;
diff --git a/libavformat/tls.c b/libavformat/tls.c
index 10e0792e29..302c0f8d59 100644
--- a/libavformat/tls.c
+++ b/libavformat/tls.c
@@ -89,7 +89,7 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, 
const char *uri, AV
 if (!c->host && !(c->host = av_strdup(c->underlying_host)))
 return AVERROR(ENOMEM);

-proxy_path = getenv("http_proxy");
+proxy_path = c->http_proxy ? c->http_proxy : getenv("http_proxy");
 use_proxy = !ff_http_match_no_proxy(getenv("no_proxy"), 
c->underlying_host) &&
 proxy_path && av_strstart(proxy_path, "http://;, NULL);

diff --git a/libavformat/tls.h b/libavformat/tls.h
index beb19d6d55..0c52ff3be6 100644
--- a/libavformat/tls.h
+++ b/libavformat/tls.h
@@ -34,6 +34,7 @@ typedef struct TLSShared {
 int listen;

 char *host;
+char *http_proxy;

 char underlying_host[200];
 int numerichost;
@@ -49,6 +50,7 @@ typedef struct TLSShared {
 {"cert_file",  "Certificate file",offsetof(pstruct, 
options_field . cert_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
 {"key_file",   "Private key file",offsetof(pstruct, 
options_field . key_file),  AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
 {"listen", "Listen for incoming connections", offsetof(pstruct, 
options_field . listen),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = 
TLS_OPTFL }, \
+{"http_proxy", "set proxy to tunnel through when using HTTPS", 
offsetof(pstruct, options_field . http_proxy), AV_OPT_TYPE_STRING, .flags = 
TLS_OPTFL }, \
 {"verifyhost", "Verify against a specific hostname",  offsetof(pstruct, 
options_field . host),  AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }

 int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, 
AVDictionary **options);
--
2.26.2

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

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

[FFmpeg-devel] [PATCH v2] libavfilter/vf_libvmaf: document log_fmt = csv

2020-08-20 Thread Harry Mallon
Signed-off-by: Harry Mallon 
---
 doc/filters.texi | 2 +-
 libavfilter/vf_libvmaf.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index d8cd45066a..610cb09a8c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12870,7 +12870,7 @@ Default value: 
@code{"/usr/local/share/model/vmaf_v0.6.1.pkl"}
 Set the file path to be used to store logs.
 
 @item log_fmt
-Set the format of the log file (xml or json).
+Set the format of the log file (csv, json or xml).
 
 @item enable_transform
 This option can enable/disable the @code{score_transform} applied to the final 
predicted VMAF score,
diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c
index 14c3216b3a..4d49127efc 100644
--- a/libavfilter/vf_libvmaf.c
+++ b/libavfilter/vf_libvmaf.c
@@ -74,7 +74,7 @@ typedef struct LIBVMAFContext {
 static const AVOption libvmaf_options[] = {
 {"model_path",  "Set the model to be used for computing vmaf.",
 OFFSET(model_path), AV_OPT_TYPE_STRING, 
{.str="/usr/local/share/model/vmaf_v0.6.1.pkl"}, 0, 1, FLAGS},
 {"log_path",  "Set the file path to be used to store logs.",   
 OFFSET(log_path), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
-{"log_fmt",  "Set the format of the log (xml or json).",   
 OFFSET(log_fmt), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
+{"log_fmt",  "Set the format of the log (csv, json or xml).",  
 OFFSET(log_fmt), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
 {"enable_transform",  "Enables transform for computing vmaf.", 
 OFFSET(enable_transform), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
 {"phone_model",  "Invokes the phone model that will generate higher VMAF 
scores.",  OFFSET(phone_model), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
 {"psnr",  "Enables computing psnr along with vmaf.",   
 OFFSET(psnr), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
-- 
2.28.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] [RFC PATCH 3/4] libavcodec/jpeg2000: Modify cleanup

2020-08-20 Thread Moritz Barsnick
On Thu, Aug 20, 2020 at 20:02:32 +0530, Gautam Ramakrishnan wrote:
> On Thu, Aug 20, 2020 at 3:02 PM Moritz Barsnick  wrote:
> > ... and what it does with this change. Looks like an NOP from the patch
> > file alone.
> It was done to provide functionality for the next patch in the series.

I then suggest squashing it with the next patch. Perhaps someone else
can comment.

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] libavfilter/vf_libvmaf: document log_fmt = csv

2020-08-20 Thread Gyan Doshi



On 20-08-2020 07:08 pm, Harry Mallon wrote:

Signed-off-by: Harry Mallon 
---
  libavfilter/vf_libvmaf.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c
index 14c3216b3a..4d49127efc 100644
--- a/libavfilter/vf_libvmaf.c
+++ b/libavfilter/vf_libvmaf.c
@@ -74,7 +74,7 @@ typedef struct LIBVMAFContext {
  static const AVOption libvmaf_options[] = {
  {"model_path",  "Set the model to be used for computing vmaf.", 
OFFSET(model_path), AV_OPT_TYPE_STRING, {.str="/usr/local/share/model/vmaf_v0.6.1.pkl"}, 0, 1, 
FLAGS},
  {"log_path",  "Set the file path to be used to store logs.",  
  OFFSET(log_path), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
-{"log_fmt",  "Set the format of the log (xml or json).",   
 OFFSET(log_fmt), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
+{"log_fmt",  "Set the format of the log (csv, json or xml).",  
 OFFSET(log_fmt), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
  {"enable_transform",  "Enables transform for computing vmaf.",
  OFFSET(enable_transform), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
  {"phone_model",  "Invokes the phone model that will generate higher VMAF 
scores.",  OFFSET(phone_model), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
  {"psnr",  "Enables computing psnr along with vmaf.",  
  OFFSET(psnr), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},


Update doc/filters as well.

Thanks,
Gyan
___
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/flvdec: RtmpSampleAccess no longer breaks stream detection

2020-08-20 Thread Peter van der Spek
I suppose that’s okay. It’s in the input stream as well after all.
On 20 Aug 2020, 13:19 +0200, Michael Niedermayer , 
wrote:
> On Wed, Aug 19, 2020 at 09:06:54AM +0200, Peter van der Spek wrote:
> > Since release 4.2, FFmpeg fails to detect the correct streams in an RTMP
> > stream that contains a |RtmpSampleAccess AMF object prior to the
> > onMetaData AMF object. In the debug log it would show "[flv] Unknown
> > type |RtmpSampleAccess".
> >
> > This functionality broke in commit d7638d8dfc3c4ffd0dc18a64937a5a07ed67b354
> > as unknown metadata packets now result in an opaque data stream, and the
> > |RtmpSampleAccess packet was an "unknown" metadata packet type.
> >
> > With this change the RTMP streams are correctly detected when there
> > is a |RtmpSampleAccess object prior to the onMetaData object.
> >
> > Signed-off-by: Peter van der Spek 
> > ---
> > libavformat/flvdec.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> > index 0862273..d480d0b 100644
> > --- a/libavformat/flvdec.c
> > +++ b/libavformat/flvdec.c
> > @@ -715,7 +715,7 @@ static int flv_read_metabody(AVFormatContext *s, 
> > int64_t next_pos)
> > if (!strcmp(buffer, "onCaptionInfo"))
> > return TYPE_ONCAPTIONINFO;
> >
> > - if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint")) {
> > + if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint") && 
> > strcmp(buffer, "|RtmpSampleAccess")) {
> > av_log(s, AV_LOG_DEBUG, "Unknown type %s\n", buffer);
> > return TYPE_UNKNOWN;
> > }
>
> when transcoding this will copy this "|RtmpSampleAccess" thing in the output
> is that intended ?
>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> It is what and why we do it that matters, not just one of them.
>
> ___
> 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".

Re: [FFmpeg-devel] [PATCH v2] Set AVSTREAM_PARSE_HEADERS flag for AV1 MP4 streams It help initialize chroma format and other info properly Chroma format wasn't correct if I use below code: avformat_fi

2020-08-20 Thread Jean-Baptiste Kempf
Please fix your commit log and commit title.

On Thu, 20 Aug 2020, at 09:43, Vikas Agrawal (Engrg-SW) wrote:
> ---
>  libavformat/mov.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 1532e74d67..4c8598c992 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -2423,6 +2423,9 @@ static int mov_finalize_stsd_codec(MOVContext *c, 
> AVIOContext *pb,
>  case AV_CODEC_ID_VP9:
>  st->need_parsing = AVSTREAM_PARSE_FULL;
>  break;
> +case AV_CODEC_ID_AV1:
> +st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +break;
>  default:
>  break;
>  }
> -- 
> 2.24.0.windows.2
> 
> ___
> 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".

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
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] [RFC PATCH 4/4] libavcodec/j2kenc: Support for multiple layers

2020-08-20 Thread Gautam Ramakrishnan
On Thu, Aug 20, 2020 at 8:25 PM Andreas Rheinhardt
 wrote:
>
> Gautam Ramakrishnan:
> > On Thu, Aug 20, 2020 at 12:55 AM Andreas Rheinhardt
> >  wrote:
> >>
> >> Gautam Ramakrishnan:
> >>> On Wed, Aug 19, 2020 at 5:51 PM  wrote:
> 
>  From: Gautam Ramakrishnan 
> 
>  This patch allows setting a compression ratio and to
>  set multiple layers. The user has to input a compression
>  ratio for each layer.
>  The per layer compression ration can be set as follows:
>  -layer_rates "r1,r2,...rn"
>  for to create 'n' layers.
>  ---
>   libavcodec/j2kenc.c   | 443 ++
>   libavcodec/jpeg2000.c |  13 +-
>   libavcodec/jpeg2000.h |  10 +
>   3 files changed, 384 insertions(+), 82 deletions(-)
> 
> >>
> >> [...]
> >>
>  +static int inline check_number(char* st, int* ret) {
>  +int stlen = strlen(st);
>  +int i;
>  +*ret = 0;
>  +if (stlen <= 0) {
>  +return AVERROR_INVALIDDATA;
>  +}
>  +for (i = 0; i < stlen; i++) {
>  +if (st[i] >= '0' && st[i] <= '9') {
>  +*ret = (*ret) * 10 + (st[i] - '0');
>  +} else {
>  +return AVERROR_INVALIDDATA;
>  +}
>  +}
>  +return 0;
>  +}
>  +
>  +static int parse_layer_rates(Jpeg2000EncoderContext *s)
>  +{
>  +int i;
>  +char* token;
>  +int rate;
>  +int nlayers = 0;
>  +if (!s->lr_str) {
>  +s->nlayers = 1;
>  +s->layer_rates[0] = 0;
>  +return 0;
>  +}
>  +
>  +token = strtok(s->lr_str, ",");
>  +if (!check_number(token, )) {
>  +s->layer_rates[0] = rate <= 1 ? 0:rate;
>  +nlayers++;
>  +} else {
>  +return AVERROR_INVALIDDATA;
>  +}
>  +
>  +while (1) {
>  +token = strtok(NULL, ",");
>  +if (!token)
>  +break;
>  +if (!check_number(token, )) {
>  +s->layer_rates[nlayers] = rate <= 1 ? 0:rate;
>  +nlayers++;
>  +} else {
>  +return AVERROR_INVALIDDATA;
>  +}
>  +}
>  +
>  +for (i = 1; i < nlayers; i++) {
>  +if (s->layer_rates[i] >= s->layer_rates[i-1]) {
>  +return AVERROR_INVALIDDATA;
>  +}
>  +}
>  +s->nlayers = nlayers;
>  +return 0;
>  +}
>  +
>   static av_cold int j2kenc_init(AVCodecContext *avctx)
>   {
>   int i, ret;
>  @@ -1388,6 +1664,11 @@ static av_cold int j2kenc_init(AVCodecContext 
>  *avctx)
> 
>   s->avctx = avctx;
>   av_log(s->avctx, AV_LOG_DEBUG, "init\n");
>  +if (parse_layer_rates(s)) {
>  +av_log(s, AV_LOG_WARNING, "Layer rates invalid. Shall encode 
>  with 1 layer.\n");
>  +s->nlayers = 1;
>  +s->layer_rates[0] = 0;
>  +}
> 
>   #if FF_API_PRIVATE_OPT
>   FF_DISABLE_DEPRECATION_WARNINGS
>  @@ -1408,6 +1689,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>   memset(codsty->log2_prec_heights, 15, 
>  sizeof(codsty->log2_prec_heights));
>   codsty->nreslevels2decode=
>   codsty->nreslevels   = 7;
>  +codsty->nlayers  = s->nlayers;
>   codsty->log2_cblk_width  = 4;
>   codsty->log2_cblk_height = 4;
>   codsty->transform= s->pred ? FF_DWT53 : FF_DWT97_INT;
>  @@ -1489,6 +1771,7 @@ static const AVOption options[] = {
>   { "rpcl",  NULL,OFFSET(prog),  
>  AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_RPCL}, 0,
>   0,   VE, "prog" },
>   { "pcrl",  NULL,OFFSET(prog),  
>  AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_PCRL}, 0,
>   0,   VE, "prog" },
>   { "cprl",  NULL,OFFSET(prog),  
>  AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_CPRL}, 0,
>   0,   VE, "prog" },
>  +{ "layer_rates",   "Layer Rates",   OFFSET(lr_str),
>  AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE },
>   { NULL }
>   };
> 
> 
>  --
>  2.17.1
> 
> >>>
> >>> This patch seems to be breaking FATE.
> >>> I believe that the error is because the patch modifies the encoder
> >>> such that the encoded files will be slightly different now.
> >>> How can this be handled?
> >>>
> >> Look at the created files and see if they are ok (ideally, they should
> >> show an improvement). If not, modify/drop your patch; otherwise update
> >> the reference files by running make fate GEN=1.
> >>
> >> Just by looking at https://patchwork.ffmpeg.org/check/15622/ (i.e.
> >> without taking a look at the actual 

Re: [FFmpeg-devel] [PATCH 6/7] avfilter/formats: Always keep longer references list when merging lists

2020-08-20 Thread Nicolas George
Andreas Rheinhardt (12020-08-20):
> The MERGE_REF() macro is asymmetric by design: The refs of the second
> argument are added to the refs of the first argument and the second
> argument is freed. The list of the first argument meanwhile is/ought to
> be preserved. When swapping, one therefore has to swap the
> non-ref-fields, too. But the MERGE_REF at the end of
> ff_merge_channel_layouts() is special. The list will be freed and
> replaced by a different list after the macro anyway, so one doesn't need
> to preserve the list at all. preserve_fmts exists so that the compiler
> can optimize this part of MERGE_REF() away for that invocation of the macro.

Thanks for the explanation. I had not realized that these are precisely
the functions that make the lists the same.

> It is certainly interesting (e.g. if I am not mistaken, it would mean
> that ff_merge_formats/samplerates() can't fail at all any more). I see

This is one of the benefits I expect, yes.

> two obvious downsides: Traversing the list for freeing is slower (but it
> should only be a constant factor) and it increases the size of the
> AVFilterLink even after merging. But I don't consider these obstacles to
> have much weight.

If we become worried about the size of the fields AVFilterLink used only
at initialization, we can move them all together in a separate structure
that gets freed once the filter is configured.

> Speaking of AVFilterLink: All ff_merge_*() as well as ff_can_merge_*()
> always use the in- and out-fields of one and the same AVFilterLink. I
> wonder whether these function should not just take the AVFilterLink * as
> parameter. It would also mean that ff_merge_formats() would have the
> same signature as the other functions, which simplifies macros.

Now that you mention it, it is probably something that can be done,
indeed.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/2] lavfi: regroup formats lists in a single structure.

2020-08-20 Thread Nicolas George
Andreas Rheinhardt (12020-08-18):
> 1. Adding this struct has also another benefit besides the ones in your
> two other patches: One can simplify the freeing process by adding a new
> ff_formatscfg_unref() (I'm not sure on the name). This could also be
> used in the uninit function of the aformat filter. If I am not mistaken,
> the only place outside of formats.c where one needs to unref an
> AVFilterContext/AVFilterChannelLayout is in hwdownload where one only
> needs ff_formats_unref() -- ff_channel_layouts_unref() can therefore be
> made static. (This presumes that redundant ff_*_unref() have been
> removed as is done in [1].)

Actually, I find the use of ff_formats_unref() in filter somewhat
suspicious. The functions are designed to free their arguments if
something fails, so as not to leak anything.

> 2. For the ease of backportability the double-frees/memleaks ([2] and
> the other patches from that patchset) should be applied before this one.

What is missing before applying this?

Anyway, one of the next steps I consider this is to merge
AVFilterChannelLayout into AVFilterFormats. Still with three versions of
the merge functions, but some other functions can be made generic.

That would allow to make the merge / can_merge and other functions part
of a structure of callback, and make the architecture of the negotiation
more nimble, paving the way for other media types and multi-level
negotiation.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [RFC PATCH 4/4] libavcodec/j2kenc: Support for multiple layers

2020-08-20 Thread Andreas Rheinhardt
Gautam Ramakrishnan:
> On Thu, Aug 20, 2020 at 12:55 AM Andreas Rheinhardt
>  wrote:
>>
>> Gautam Ramakrishnan:
>>> On Wed, Aug 19, 2020 at 5:51 PM  wrote:

 From: Gautam Ramakrishnan 

 This patch allows setting a compression ratio and to
 set multiple layers. The user has to input a compression
 ratio for each layer.
 The per layer compression ration can be set as follows:
 -layer_rates "r1,r2,...rn"
 for to create 'n' layers.
 ---
  libavcodec/j2kenc.c   | 443 ++
  libavcodec/jpeg2000.c |  13 +-
  libavcodec/jpeg2000.h |  10 +
  3 files changed, 384 insertions(+), 82 deletions(-)

>>
>> [...]
>>
 +static int inline check_number(char* st, int* ret) {
 +int stlen = strlen(st);
 +int i;
 +*ret = 0;
 +if (stlen <= 0) {
 +return AVERROR_INVALIDDATA;
 +}
 +for (i = 0; i < stlen; i++) {
 +if (st[i] >= '0' && st[i] <= '9') {
 +*ret = (*ret) * 10 + (st[i] - '0');
 +} else {
 +return AVERROR_INVALIDDATA;
 +}
 +}
 +return 0;
 +}
 +
 +static int parse_layer_rates(Jpeg2000EncoderContext *s)
 +{
 +int i;
 +char* token;
 +int rate;
 +int nlayers = 0;
 +if (!s->lr_str) {
 +s->nlayers = 1;
 +s->layer_rates[0] = 0;
 +return 0;
 +}
 +
 +token = strtok(s->lr_str, ",");
 +if (!check_number(token, )) {
 +s->layer_rates[0] = rate <= 1 ? 0:rate;
 +nlayers++;
 +} else {
 +return AVERROR_INVALIDDATA;
 +}
 +
 +while (1) {
 +token = strtok(NULL, ",");
 +if (!token)
 +break;
 +if (!check_number(token, )) {
 +s->layer_rates[nlayers] = rate <= 1 ? 0:rate;
 +nlayers++;
 +} else {
 +return AVERROR_INVALIDDATA;
 +}
 +}
 +
 +for (i = 1; i < nlayers; i++) {
 +if (s->layer_rates[i] >= s->layer_rates[i-1]) {
 +return AVERROR_INVALIDDATA;
 +}
 +}
 +s->nlayers = nlayers;
 +return 0;
 +}
 +
  static av_cold int j2kenc_init(AVCodecContext *avctx)
  {
  int i, ret;
 @@ -1388,6 +1664,11 @@ static av_cold int j2kenc_init(AVCodecContext 
 *avctx)

  s->avctx = avctx;
  av_log(s->avctx, AV_LOG_DEBUG, "init\n");
 +if (parse_layer_rates(s)) {
 +av_log(s, AV_LOG_WARNING, "Layer rates invalid. Shall encode with 
 1 layer.\n");
 +s->nlayers = 1;
 +s->layer_rates[0] = 0;
 +}

  #if FF_API_PRIVATE_OPT
  FF_DISABLE_DEPRECATION_WARNINGS
 @@ -1408,6 +1689,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
  memset(codsty->log2_prec_heights, 15, 
 sizeof(codsty->log2_prec_heights));
  codsty->nreslevels2decode=
  codsty->nreslevels   = 7;
 +codsty->nlayers  = s->nlayers;
  codsty->log2_cblk_width  = 4;
  codsty->log2_cblk_height = 4;
  codsty->transform= s->pred ? FF_DWT53 : FF_DWT97_INT;
 @@ -1489,6 +1771,7 @@ static const AVOption options[] = {
  { "rpcl",  NULL,OFFSET(prog),  
 AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_RPCL}, 0, 
 0,   VE, "prog" },
  { "pcrl",  NULL,OFFSET(prog),  
 AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_PCRL}, 0, 
 0,   VE, "prog" },
  { "cprl",  NULL,OFFSET(prog),  
 AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_CPRL}, 0, 
 0,   VE, "prog" },
 +{ "layer_rates",   "Layer Rates",   OFFSET(lr_str),
 AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE },
  { NULL }
  };


 --
 2.17.1

>>>
>>> This patch seems to be breaking FATE.
>>> I believe that the error is because the patch modifies the encoder
>>> such that the encoded files will be slightly different now.
>>> How can this be handled?
>>>
>> Look at the created files and see if they are ok (ideally, they should
>> show an improvement). If not, modify/drop your patch; otherwise update
>> the reference files by running make fate GEN=1.
>>
>> Just by looking at https://patchwork.ffmpeg.org/check/15622/ (i.e.
>> without taking a look at the actual files and without having run fate
>> with your patch myself) I can say that your patch is not ok:
>>
>> -8bb707e596f97451fd325dec2dd610a7 *tests/data/fate/vsynth1-jpeg2000-97.avi
>> -3654620 tests/data/fate/vsynth1-jpeg2000-97.avi
>> -5073771a78e1f5366a7eb0df341662fc
>> *tests/data/fate/vsynth1-jpeg2000-97.out.rawvideo
>> -stddev:4.23 

[FFmpeg-devel] [PATCH 2/4] lavfi/formats: simplify a macro parameters.

2020-08-20 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/formats.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)


Unchanged and trivial.


diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index c0daf198c8..64d94a374a 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -502,15 +502,15 @@ void ff_formats_changeref(AVFilterFormats **oldref, 
AVFilterFormats **newref)
 FORMATS_CHANGEREF(oldref, newref);
 }
 
-#define SET_COMMON_FORMATS(ctx, fmts, in_fmts, out_fmts, ref_fn, unref_fn, 
list) \
+#define SET_COMMON_FORMATS(ctx, fmts, ref_fn, unref_fn, list)   \
 int count = 0, i;   \
 \
 if (!fmts)  \
 return AVERROR(ENOMEM); \
 \
 for (i = 0; i < ctx->nb_inputs; i++) {  \
-if (ctx->inputs[i] && !ctx->inputs[i]->out_fmts) {  \
-int ret = ref_fn(fmts, >inputs[i]->out_fmts);  \
+if (ctx->inputs[i] && !ctx->inputs[i]->outcfg.fmts) {   \
+int ret = ref_fn(fmts, >inputs[i]->outcfg.fmts);   \
 if (ret < 0) {  \
 unref_fn();\
 if (fmts)   \
@@ -522,8 +522,8 @@ void ff_formats_changeref(AVFilterFormats **oldref, 
AVFilterFormats **newref)
 }   \
 }   \
 for (i = 0; i < ctx->nb_outputs; i++) { \
-if (ctx->outputs[i] && !ctx->outputs[i]->in_fmts) { \
-int ret = ref_fn(fmts, >outputs[i]->in_fmts);  \
+if (ctx->outputs[i] && !ctx->outputs[i]->incfg.fmts) {  \
+int ret = ref_fn(fmts, >outputs[i]->incfg.fmts);   \
 if (ret < 0) {  \
 unref_fn();\
 if (fmts)   \
@@ -544,16 +544,16 @@ void ff_formats_changeref(AVFilterFormats **oldref, 
AVFilterFormats **newref)
 return 0;
 
 int ff_set_common_channel_layouts(AVFilterContext *ctx,
-  AVFilterChannelLayouts *layouts)
+  AVFilterChannelLayouts *channel_layouts)
 {
-SET_COMMON_FORMATS(ctx, layouts, incfg.channel_layouts, 
outcfg.channel_layouts,
+SET_COMMON_FORMATS(ctx, channel_layouts,
ff_channel_layouts_ref, ff_channel_layouts_unref, 
channel_layouts);
 }
 
 int ff_set_common_samplerates(AVFilterContext *ctx,
   AVFilterFormats *samplerates)
 {
-SET_COMMON_FORMATS(ctx, samplerates, incfg.samplerates, outcfg.samplerates,
+SET_COMMON_FORMATS(ctx, samplerates,
ff_formats_ref, ff_formats_unref, formats);
 }
 
@@ -564,7 +564,7 @@ int ff_set_common_samplerates(AVFilterContext *ctx,
  */
 int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
 {
-SET_COMMON_FORMATS(ctx, formats, incfg.formats, outcfg.formats,
+SET_COMMON_FORMATS(ctx, formats,
ff_formats_ref, ff_formats_unref, formats);
 }
 
-- 
2.28.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] lavfi: regroup formats lists in a single structure.

2020-08-20 Thread Nicolas George
It will allow to refernce it as a whole without clunky macros.

Most of the changes have been automatically made with sed:

sed -i '
  s/-> *in_formats/->incfg.formats/g;
  s/-> *out_formats/->outcfg.formats/g;
  s/-> *in_channel_layouts/->incfg.channel_layouts/g;
  s/-> *out_channel_layouts/->outcfg.channel_layouts/g;
  s/-> *in_samplerates/->incfg.samplerates/g;
  s/-> *out_samplerates/->outcfg.samplerates/g;
  ' src/libavfilter/*(.)

Signed-off-by: Nicolas George 
---


Made the changes suggested by Andreas about alignment, spacing and
declaring the structure.


 libavfilter/aeval.c|   4 +-
 libavfilter/af_afir.c  |   8 +-
 libavfilter/af_agate.c |  10 +-
 libavfilter/af_aiir.c  |   2 +-
 libavfilter/af_amerge.c|  12 +-
 libavfilter/af_anequalizer.c   |  14 +-
 libavfilter/af_aresample.c |  12 +-
 libavfilter/af_asetrate.c  |   2 +-
 libavfilter/af_channelmap.c|   4 +-
 libavfilter/af_channelsplit.c  |   4 +-
 libavfilter/af_hdcd.c  |   4 +-
 libavfilter/af_headphone.c |   8 +-
 libavfilter/af_join.c  |   4 +-
 libavfilter/af_ladspa.c|   6 +-
 libavfilter/af_loudnorm.c  |   4 +-
 libavfilter/af_lv2.c   |   6 +-
 libavfilter/af_pan.c   |   4 +-
 libavfilter/af_resample.c  |  12 +-
 libavfilter/af_sidechaincompress.c |  10 +-
 libavfilter/af_sofalizer.c |   4 +-
 libavfilter/af_surround.c  |   4 +-
 libavfilter/avf_abitscope.c|   8 +-
 libavfilter/avf_ahistogram.c   |   8 +-
 libavfilter/avf_aphasemeter.c  |  14 +-
 libavfilter/avf_avectorscope.c |   8 +-
 libavfilter/avf_concat.c   |  12 +-
 libavfilter/avf_showcqt.c  |   8 +-
 libavfilter/avf_showfreqs.c|   8 +-
 libavfilter/avf_showspatial.c  |   8 +-
 libavfilter/avf_showspectrum.c |   8 +-
 libavfilter/avf_showvolume.c   |   8 +-
 libavfilter/avf_showwaves.c|   8 +-
 libavfilter/avfilter.c |  30 ++---
 libavfilter/avfilter.h |  60 ++---
 libavfilter/avfiltergraph.c| 210 ++---
 libavfilter/f_drawgraph.c  |   2 +-
 libavfilter/f_ebur128.c|  14 +-
 libavfilter/f_graphmonitor.c   |   2 +-
 libavfilter/formats.c  |   6 +-
 libavfilter/src_movie.c|   8 +-
 libavfilter/tests/filtfmts.c   |   6 +-
 libavfilter/vaapi_vpp.c|   4 +-
 libavfilter/vaf_spectrumsynth.c|  10 +-
 libavfilter/vf_alphamerge.c|   6 +-
 libavfilter/vf_ciescope.c  |   4 +-
 libavfilter/vf_colorspace.c|   4 +-
 libavfilter/vf_coreimage.m |   6 +-
 libavfilter/vf_elbg.c  |   4 +-
 libavfilter/vf_extractplanes.c |  12 +-
 libavfilter/vf_fieldmatch.c|   6 +-
 libavfilter/vf_fieldorder.c|   4 +-
 libavfilter/vf_histogram.c |  12 +-
 libavfilter/vf_hwdownload.c|   4 +-
 libavfilter/vf_hwmap.c |   4 +-
 libavfilter/vf_hwupload.c  |   4 +-
 libavfilter/vf_hwupload_cuda.c |   4 +-
 libavfilter/vf_lut2.c  |   4 +-
 libavfilter/vf_mergeplanes.c   |   4 +-
 libavfilter/vf_overlay.c   |   6 +-
 libavfilter/vf_overlay_qsv.c   |   4 +-
 libavfilter/vf_palettegen.c|   4 +-
 libavfilter/vf_paletteuse.c|   6 +-
 libavfilter/vf_remap.c |   8 +-
 libavfilter/vf_scale.c |   4 +-
 libavfilter/vf_showpalette.c   |   4 +-
 libavfilter/vf_vectorscope.c   |  12 +-
 libavfilter/vf_vpp_qsv.c   |   4 +-
 libavfilter/vf_waveform.c  |  14 +-
 libavfilter/vf_yadif_cuda.c|   4 +-
 libavfilter/vf_zscale.c|   4 +-
 70 files changed, 383 insertions(+), 361 deletions(-)

diff --git a/libavfilter/aeval.c b/libavfilter/aeval.c
index c7a8cd6550..4c62c98097 100644
--- a/libavfilter/aeval.c
+++ b/libavfilter/aeval.c
@@ -362,7 +362,7 @@ static int aeval_query_formats(AVFilterContext *ctx)
 
 // inlink supports any channel layout
 layouts = ff_all_channel_counts();
-if ((ret = ff_channel_layouts_ref(layouts, >out_channel_layouts)) 
< 0)
+if ((ret = ff_channel_layouts_ref(layouts, 
>outcfg.channel_layouts)) < 0)
 return ret;
 
 if (eval->same_chlayout) {
@@ -376,7 +376,7 @@ static int aeval_query_formats(AVFilterContext *ctx)
   eval->out_channel_layout ? 
eval->out_channel_layout :
   FF_COUNT2LAYOUT(eval->nb_channels))) < 0)
 return ret;
-if ((ret = ff_channel_layouts_ref(layouts, 
>in_channel_layouts)) < 0)
+if ((ret = ff_channel_layouts_ref(layouts, 
>incfg.channel_layouts)) < 0)
 return ret;
 }
 
diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index 6cbc7a00a1..94e68a4824 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -727,7 +727,7 @@ static int query_formats(AVFilterContext 

[FFmpeg-devel] [PATCH 3/4] lavfi: check the validity of formats lists.

2020-08-20 Thread Nicolas George
Part of the code expect valid lists, in particular no duplicates.
These tests allow to catch bugs in filters (unlikely but possible)
and to give a clear message when the error comes from the user
((a)formats) or the application (buffersink).

Signed-off-by: Nicolas George 
---
 libavfilter/avfiltergraph.c | 50 ++
 libavfilter/formats.c   | 71 +
 libavfilter/formats.h   | 28 +++
 3 files changed, 149 insertions(+)


Unchanged, but should not trigger a bug anymore.


diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 1d1012c669..14b4883c94 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -313,6 +313,53 @@ static void sanitize_channel_layouts(void *log, 
AVFilterChannelLayouts *l)
 }
 }
 
+static int filter_link_check_formats(void *log, AVFilterLink *link, 
AVFilterFormatsConfig *cfg)
+{
+int ret;
+
+switch (link->type) {
+
+case AVMEDIA_TYPE_VIDEO:
+if ((ret = ff_formats_check_pixel_formats(log, cfg->formats)) < 0)
+return ret;
+break;
+
+case AVMEDIA_TYPE_AUDIO:
+if ((ret = ff_formats_check_sample_formats(log, cfg->formats)) < 0 
||
+(ret = ff_formats_check_sample_rates(log, cfg->samplerates)) < 
0 ||
+(ret = ff_formats_check_channel_layouts(log, 
cfg->channel_layouts)) < 0)
+return ret;
+break;
+
+default:
+av_assert0(!"reached");
+}
+return 0;
+}
+
+/**
+ * Check the validity of the formats / etc. lists set by query_formats().
+ *
+ * In particular, check they do not contain any redundant element.
+ */
+static int filter_check_formats(AVFilterContext *ctx)
+{
+unsigned i;
+int ret;
+
+for (i = 0; i < ctx->nb_inputs; i++) {
+ret = filter_link_check_formats(ctx, ctx->inputs[i], 
>inputs[i]->outcfg);
+if (ret < 0)
+return ret;
+}
+for (i = 0; i < ctx->nb_outputs; i++) {
+ret = filter_link_check_formats(ctx, ctx->outputs[i], 
>outputs[i]->incfg);
+if (ret < 0)
+return ret;
+}
+return 0;
+}
+
 static int filter_query_formats(AVFilterContext *ctx)
 {
 int ret, i;
@@ -329,6 +376,9 @@ static int filter_query_formats(AVFilterContext *ctx)
ctx->name, av_err2str(ret));
 return ret;
 }
+ret = filter_check_formats(ctx);
+if (ret < 0)
+return ret;
 
 for (i = 0; i < ctx->nb_inputs; i++)
 sanitize_channel_layouts(ctx, ctx->inputs[i]->outcfg.channel_layouts);
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 64d94a374a..cff82196eb 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -676,3 +676,74 @@ int ff_parse_channel_layout(int64_t *ret, int *nret, const 
char *arg,
 
 return 0;
 }
+
+static int check_list(void *log, const char *name, const AVFilterFormats *fmts)
+{
+unsigned i, j;
+
+if (!fmts)
+return 0;
+if (!fmts->nb_formats) {
+av_log(log, AV_LOG_ERROR, "Empty %s list\n", name);
+return AVERROR(EINVAL);
+}
+for (i = 0; i < fmts->nb_formats; i++) {
+for (j = i + 1; j < fmts->nb_formats; j++) {
+if (fmts->formats[i] == fmts->formats[j]) {
+av_log(log, AV_LOG_ERROR, "Duplicated %s\n", name);
+return AVERROR(EINVAL);
+}
+}
+}
+return 0;
+}
+
+int ff_formats_check_pixel_formats(void *log, const AVFilterFormats *fmts)
+{
+return check_list(log, "pixel format", fmts);
+}
+
+int ff_formats_check_sample_formats(void *log, const AVFilterFormats *fmts)
+{
+return check_list(log, "sample format", fmts);
+}
+
+int ff_formats_check_sample_rates(void *log, const AVFilterFormats *fmts)
+{
+if (!fmts || !fmts->nb_formats)
+return 0;
+return check_list(log, "sample rate", fmts);
+}
+
+static int layouts_compatible(uint64_t a, uint64_t b)
+{
+return a == b ||
+   (KNOWN(a) && !KNOWN(b) && av_get_channel_layout_nb_channels(a) == 
FF_LAYOUT2COUNT(b)) ||
+   (KNOWN(b) && !KNOWN(a) && av_get_channel_layout_nb_channels(b) == 
FF_LAYOUT2COUNT(a));
+}
+
+int ff_formats_check_channel_layouts(void *log, const AVFilterChannelLayouts 
*fmts)
+{
+unsigned i, j;
+
+if (!fmts)
+return 0;
+if (fmts->all_layouts < fmts->all_counts ||
+(!fmts->all_layouts && !fmts->nb_channel_layouts)) {
+av_log(log, AV_LOG_ERROR, "Inconsistent generic list\n");
+return AVERROR(EINVAL);
+}
+if (!fmts->all_layouts && !fmts->nb_channel_layouts) {
+av_log(log, AV_LOG_ERROR, "Empty channel layout list\n");
+return AVERROR(EINVAL);
+}
+for (i = 0; i < fmts->nb_channel_layouts; i++) {
+for (j = i + 1; j < fmts->nb_channel_layouts; j++) {
+if (layouts_compatible(fmts->channel_layouts[i], 
fmts->channel_layouts[j])) {
+

[FFmpeg-devel] [PATCH 4/4] lavfi/buffersink: remove redundant channel layouts.

2020-08-20 Thread Nicolas George
The channel_layouts and channel_counts options set what buffersink
is supposed to accept. If channel_counts contains 2, then stereo is
already accepted, there is no point in having it in channel_layouts
too. This was not properly documented until now, so only print a
warning.

Signed-off-by: Nicolas George 
---
 libavfilter/buffersink.c | 23 +++
 1 file changed, 23 insertions(+)


Added an explanation requested by Paul.


diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 76a46f6678..c58daf6124 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -62,6 +62,28 @@ typedef struct BufferSinkContext {
 
 #define NB_ITEMS(list) (list ## _size / sizeof(*list))
 
+static void cleanup_redundant_layouts(AVFilterContext *ctx)
+{
+BufferSinkContext *buf = ctx->priv;
+int nb_layouts = NB_ITEMS(buf->channel_layouts);
+int nb_counts = NB_ITEMS(buf->channel_counts);
+int l, lc, c, n;
+
+for (l = lc = 0; l < nb_layouts; l++) {
+n = av_get_channel_layout_nb_channels(buf->channel_layouts[l]);
+for (c = 0; c < nb_counts; c++)
+if (n == buf->channel_counts[c])
+break;
+if (c < nb_counts)
+av_log(ctx, AV_LOG_WARNING,
+   "Removing channel layout 0x%"PRIx64", redundant with %d 
channels\n",
+   buf->channel_layouts[l], buf->channel_counts[c]);
+else
+buf->channel_layouts[lc++] = buf->channel_layouts[l];
+}
+buf->channel_layouts_size = lc * sizeof(*buf->channel_layouts);
+}
+
 int attribute_align_arg av_buffersink_get_frame(AVFilterContext *ctx, AVFrame 
*frame)
 {
 return av_buffersink_get_frame_flags(ctx, frame, 0);
@@ -253,6 +275,7 @@ static int asink_query_formats(AVFilterContext *ctx)
 
 if (buf->channel_layouts_size || buf->channel_counts_size ||
 buf->all_channel_counts) {
+cleanup_redundant_layouts(ctx);
 for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++)
 if ((ret = ff_add_channel_layout(, 
buf->channel_layouts[i])) < 0)
 return ret;
-- 
2.28.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 v4] avformat/libsrt: Close listen fd in listener mode

2020-08-20 Thread Marton Balint



On Thu, 13 Aug 2020, Nicolas Sugino wrote:


In listener mode the first fd is not closed when libsrt_close() is called 
because it is overwritten by the new accept fd.
Added the listen_fd to the context to properly close it when libsrt_close() is 
called.
Fixes trac ticket #8372


Thanks, applied.

Regards,
Marton



Signed-off-by: Nicolas Sugino 
---
libavformat/libsrt.c | 12 +++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index 4719ce0d4b..4025b24976 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -53,6 +53,7 @@ enum SRTMode {
typedef struct SRTContext {
const AVClass *class;
int fd;
+int listen_fd;
int eid;
int64_t rw_timeout;
int64_t listen_timeout;
@@ -362,7 +363,7 @@ static int libsrt_set_options_pre(URLContext *h, int fd)
static int libsrt_setup(URLContext *h, const char *uri, int flags)
{
struct addrinfo hints = { 0 }, *ai, *cur_ai;
-int port, fd = -1;
+int port, fd = -1, listen_fd = -1;
SRTContext *s = h->priv_data;
const char *p;
char buf[256];
@@ -439,6 +440,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int 
flags)
// multi-client
if ((ret = libsrt_listen(s->eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, 
s->listen_timeout)) < 0)
goto fail1;
+listen_fd = fd;
fd = ret;
} else {
if (s->mode == SRT_MODE_RENDEZVOUS) {
@@ -471,6 +473,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int 
flags)

h->is_streamed = 1;
s->fd = fd;
+s->listen_fd = listen_fd;

freeaddrinfo(ai);
return 0;
@@ -481,12 +484,16 @@ static int libsrt_setup(URLContext *h, const char *uri, 
int flags)
cur_ai = cur_ai->ai_next;
if (fd >= 0)
srt_close(fd);
+if (listen_fd >= 0)
+srt_close(listen_fd);
ret = 0;
goto restart;
}
 fail1:
if (fd >= 0)
srt_close(fd);
+if (listen_fd >= 0)
+srt_close(listen_fd);
freeaddrinfo(ai);
return ret;
}
@@ -676,6 +683,9 @@ static int libsrt_close(URLContext *h)

srt_close(s->fd);

+if (s->listen_fd >= 0)
+srt_close(s->listen_fd);
+
srt_epoll_release(s->eid);

srt_cleanup();
--
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 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 v4]libavfilter/asrc_atone.c : generate algorithmic music

2020-08-20 Thread Ashutosh Pradhan
On Thu, Aug 20, 2020 at 7:58 PM Nicolas George  wrote:

> Ashutosh Pradhan (12020-08-20):
> > But, for that, we need to store the frequency information of each
> > instrument hence would be the same as reading SoundFont files, I think.
> > Also, the duration output would be the same as a note-on and note-off
> event.
>
> Les me rephrase the question: how hard would it be to use another
> synthesizer library with a slightly different API?
> Not much I think.
> Regards,
>
> --
>   Nicolas George
> ___
> 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".

Re: [FFmpeg-devel] [RFC PATCH 3/4] libavcodec/jpeg2000: Modify cleanup

2020-08-20 Thread Gautam Ramakrishnan
On Thu, Aug 20, 2020 at 3:02 PM Moritz Barsnick  wrote:
>
> On Wed, Aug 19, 2020 at 17:51:01 +0530, gautamr...@gmail.com wrote:
> > From: Gautam Ramakrishnan 
> >
> > This patch makes the ff_jpeg2000_cleanup
> > function take in an extra parameter which
> > indicates whether it is called from the
> > encoder or decoder.
>
> I fail to see an explanation why, ...
>
> > -void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle 
> > *codsty)
> > +void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle 
> > *codsty, int isencoder)
> >  {
> >  int reslevelno, bandno, precno;
> >  for (reslevelno = 0;
> > diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h
> > index ad58b1ae88..fee9607e86 100644
> > --- a/libavcodec/jpeg2000.h
> > +++ b/libavcodec/jpeg2000.h
>
> ... and what it does with this change. Looks like an NOP from the patch
> file alone.
It was done to provide functionality for the next patch in the series.
>
> 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".



-- 
-
Gautam |
___
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 v5 1/3] [RFC] lavc: add FLIF decoding support

2020-08-20 Thread Anamitra Ghorui
Hello,

On Wed, 19 Aug 2020 21:05:41 +0200
Paul B Mahol  wrote:

[...]

> >
> >
> > All these corrections have been made by me locally, but I would
> > like to wait for some further review (self and otherwise) before
> > posting again. 
> 
> Please make use of av_clip and FFMIN/FFMAX macros.
> 

We have looked through the code again and have not been able to notice a
situation where these macros will be required aside from where they are
already used. They have been largely used in the transform code and
sparsely used everywhere else. Can you please point to a portion where
their use is warranted?

Thanks,
Anamitra

___
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 v4]libavfilter/asrc_atone.c : generate algorithmic music

2020-08-20 Thread Nicolas George
Ashutosh Pradhan (12020-08-20):
> But, for that, we need to store the frequency information of each
> instrument hence would be the same as reading SoundFont files, I think.
> Also, the duration output would be the same as a note-on and note-off event.

Les me rephrase the question: how hard would it be to use another
synthesizer library with a slightly different API?

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-20 Thread James Almer
On 8/20/2020 7:53 AM, Moritz Barsnick wrote:
> On Sun, Aug 16, 2020 at 18:25:12 +0200, Paul B Mahol wrote:
>> On 8/16/20, Paul B Mahol  wrote:
>>> Please help porting this to linux and 64bit calling convention.
>>
>> New patch attached.
>>
>> This one does not allocate stack on x32.
> 
> I wanted to benchmark on several machines (newest I have is a Haswell,
> I also have an "Intel(R) Atom(TM) CPU D525   @ 1.80GHz" x86_64, and the
> below is a Pentium 4 x86), but got stuck on the ancient x86.
> 
> Firstly, superficial benchmark result on the Pentium 4:
> $ time ffmpeg -i bigger_res.mov -map 0:v -f null -
> 
> Without patchset: speed=0.0331x (plus/minus a bit)
> Withpatchset: speed=0.0577x (plus/minus a bit)
> 
> I'll add benchmarks with my other systems, if desired.
> 
> Alas, with the patchset, the following command quickly terminates with
> Illegal instruction in ff_cfhd_horiz_filter_clip10_sse2 ():
> 
> $ ffmpeg -i MT_BeartoothHighway_1min_Cineform.avi -map 0:v -f null -
> 
> (and obviously doesn't terminate with "-cpuflags 0", or without the
> patchset).
> 
> See assembler dump below.
> Compilier: icc (ICC) 14.0.3 20140422
> Assembler: nasm-2.13.02
> 
> Assembly dump from gdb:
> Dump of assembler code from 0x919572f to 0x919576f:
>0x0919572f :movl   
> $0xbf0f03ff,(%ecx,%eax,8)
>0x09195736 :xor(%ecx),%al
>0x09195738 :not%ecx
>0x0919573a :jmp*0xf(%esi)
>0x0919573d :outsb  
> %ds:(%esi),(%dx)
>0x0919573e :(bad)
>0x0919573f :pmaxsw 0x99e6da0,%xmm0
>0x09195747 :pminsw 0x99e6db0,%xmm0
> => 0x0919574f :pextrw 
> $0x0,%xmm0,(%eax)

Yeah, pextrw with a memory address as dest argument is sse4.1. sse2 is
only for gpr as dest argument.
___
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 v4]libavfilter/asrc_atone.c : generate algorithmic music

2020-08-20 Thread Ashutosh Pradhan
On Thu, Aug 20, 2020 at 1:10 PM Nicolas George  wrote:

> Ashutosh Pradhan (12020-08-20):
> > I think it would be a bit difficult considering we have to read SoundFont
> > files, read and write midi events, code for the sequencer, synth, etc.
>
> I mean precisely without doing all that. Your code produces notes at
> certain times: can they be made available, their pitch and duration,
> directly?
>
But, for that, we need to store the frequency information of each
instrument hence would be the same as reading SoundFont files, I think.
Also, the duration output would be the same as a note-on and note-off event.

> Regards,
>
> --
>   Nicolas George
> ___
> 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 v5 1/2] avformat/mxfdec: Read video range from CDCIEssenceDescriptor

2020-08-20 Thread Harry Mallon
* Capture black_ref, white_ref and color_range and recognise
  full and narrow range.

Signed-off-by: Harry Mallon 
---
 libavformat/mxfdec.c   | 37 ++
 tests/ref/fate/mxf-probe-dnxhd |  2 +-
 tests/ref/fate/mxf-probe-dv25  |  2 +-
 3 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 4b56984b77..7e1686f0df 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -199,6 +199,9 @@ typedef struct MXFDescriptor {
 int bits_per_sample;
 int64_t duration; /* ContainerDuration optional property */
 unsigned int component_depth;
+unsigned int black_ref_level;
+unsigned int white_ref_level;
+unsigned int color_range;
 unsigned int horiz_subsampling;
 unsigned int vert_subsampling;
 UID *sub_descriptors_refs;
@@ -1222,6 +1225,15 @@ static int mxf_read_generic_descriptor(void *arg, 
AVIOContext *pb, int tag, int
 case 0x3302:
 descriptor->horiz_subsampling = avio_rb32(pb);
 break;
+case 0x3304:
+descriptor->black_ref_level = avio_rb32(pb);
+break;
+case 0x3305:
+descriptor->white_ref_level = avio_rb32(pb);
+break;
+case 0x3306:
+descriptor->color_range = avio_rb32(pb);
+break;
 case 0x3308:
 descriptor->vert_subsampling = avio_rb32(pb);
 break;
@@ -2157,6 +2169,30 @@ static int mxf_add_metadata_stream(MXFContext *mxf, 
MXFTrack *track)
 return 0;
 }
 
+static enum AVColorRange mxf_get_color_range(MXFContext *mxf, MXFDescriptor 
*descriptor)
+{
+if (descriptor->black_ref_level || descriptor->white_ref_level || 
descriptor->color_range) {
+/* CDCI range metadata */
+if (!descriptor->component_depth)
+return AVCOL_RANGE_UNSPECIFIED;
+if (descriptor->black_ref_level == 0 &&
+descriptor->white_ref_level == ((1color_range== (1color_range== ((1component_depth >= 8 &&
+descriptor->black_ref_level == (1  <<(descriptor->component_depth 
- 4)) &&
+descriptor->white_ref_level == (235<<(descriptor->component_depth 
- 8)) &&
+descriptor->color_range == ((14<<(descriptor->component_depth 
- 4)) + 1))
+return AVCOL_RANGE_MPEG;
+avpriv_request_sample(mxf->fc, "Unrecognized CDCI color range (color 
diff range %d, b %d, w %d, depth %d)",
+  descriptor->color_range, 
descriptor->black_ref_level,
+  descriptor->white_ref_level, 
descriptor->component_depth);
+}
+
+return AVCOL_RANGE_UNSPECIFIED;
+}
+
 static int mxf_parse_structural_metadata(MXFContext *mxf)
 {
 MXFPackage *material_package = NULL;
@@ -2492,6 +2528,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
 }
 if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den)
 st->display_aspect_ratio = descriptor->aspect_ratio;
+st->codecpar->color_range = mxf_get_color_range(mxf, 
descriptor);
 st->codecpar->color_primaries = 
mxf_get_codec_ul(ff_mxf_color_primaries_uls, 
>color_primaries_ul)->id;
 st->codecpar->color_trc   = 
mxf_get_codec_ul(ff_mxf_color_trc_uls, >color_trc_ul)->id;
 st->codecpar->color_space = 
mxf_get_codec_ul(ff_mxf_color_space_uls, >color_space_ul)->id;
diff --git a/tests/ref/fate/mxf-probe-dnxhd b/tests/ref/fate/mxf-probe-dnxhd
index 012d3ea1d9..5a6221b1d5 100644
--- a/tests/ref/fate/mxf-probe-dnxhd
+++ b/tests/ref/fate/mxf-probe-dnxhd
@@ -124,7 +124,7 @@ sample_aspect_ratio=1:1
 display_aspect_ratio=4:3
 pix_fmt=yuv422p
 level=-99
-color_range=unknown
+color_range=tv
 color_space=bt709
 color_transfer=bt709
 color_primaries=bt709
diff --git a/tests/ref/fate/mxf-probe-dv25 b/tests/ref/fate/mxf-probe-dv25
index 810f145f41..ffd26c4dfd 100644
--- a/tests/ref/fate/mxf-probe-dv25
+++ b/tests/ref/fate/mxf-probe-dv25
@@ -16,7 +16,7 @@ sample_aspect_ratio=16:15
 display_aspect_ratio=4:3
 pix_fmt=yuv420p
 level=-99
-color_range=unknown
+color_range=tv
 color_space=unknown
 color_transfer=bt470m
 color_primaries=unknown
-- 
2.28.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 v5 2/2] libavformat/mxfenc: color_range should be inclusive

2020-08-20 Thread Harry Mallon
MXF CDCI color range was being set to (1codecpar->color_range != AVCOL_RANGE_UNSPECIFIED) {
 int black = 0,
 white = (1codecpar->color_range == AVCOL_RANGE_MPEG) {
 black = 1   << (sc->component_depth - 4);
 white = 235 << (sc->component_depth - 8);
-- 
2.28.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] libavfilter/vf_libvmaf: document log_fmt = csv

2020-08-20 Thread Harry Mallon
Signed-off-by: Harry Mallon 
---
 libavfilter/vf_libvmaf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c
index 14c3216b3a..4d49127efc 100644
--- a/libavfilter/vf_libvmaf.c
+++ b/libavfilter/vf_libvmaf.c
@@ -74,7 +74,7 @@ typedef struct LIBVMAFContext {
 static const AVOption libvmaf_options[] = {
 {"model_path",  "Set the model to be used for computing vmaf.",
 OFFSET(model_path), AV_OPT_TYPE_STRING, 
{.str="/usr/local/share/model/vmaf_v0.6.1.pkl"}, 0, 1, FLAGS},
 {"log_path",  "Set the file path to be used to store logs.",   
 OFFSET(log_path), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
-{"log_fmt",  "Set the format of the log (xml or json).",   
 OFFSET(log_fmt), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
+{"log_fmt",  "Set the format of the log (csv, json or xml).",  
 OFFSET(log_fmt), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
 {"enable_transform",  "Enables transform for computing vmaf.", 
 OFFSET(enable_transform), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
 {"phone_model",  "Invokes the phone model that will generate higher VMAF 
scores.",  OFFSET(phone_model), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
 {"psnr",  "Enables computing psnr along with vmaf.",   
 OFFSET(psnr), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
-- 
2.28.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] [RFC PATCH 4/4] libavcodec/j2kenc: Support for multiple layers

2020-08-20 Thread Gautam Ramakrishnan
On Thu, Aug 20, 2020 at 3:36 PM Moritz Barsnick  wrote:
>
> On Wed, Aug 19, 2020 at 17:51:02 +0530, gautamr...@gmail.com wrote:
>
> Minor nits:
>
> > +static void compute_rates(Jpeg2000EncoderContext* s)
> > +{
> > +int i, j;
> > +int layno, compno;
> > +for (i = 0; i < s->numYtiles; i++) {
> > +for (j = 0; j < s->numXtiles; j++) {
> > +Jpeg2000Tile *tile = >tile[s->numXtiles * i + j];
> > +for (compno = 0; compno < s->ncomponents; compno++) {
> > +int tilew = tile->comp[compno].coord[0][1] - 
> > tile->comp[compno].coord[0][0];
> > +int tileh = tile->comp[compno].coord[1][1] - 
> > tile->comp[compno].coord[1][0];
> > +int scale = (compno?1 << s->chroma_shift[0]:1) * (compno?1 
> > << s->chroma_shift[1]:1);
> > +for (layno = 0; layno < s->nlayers; layno++) {
> > +if (s->layer_rates[layno] > 0.0f) {
>
> Isn't this left hand an array of ints? Why compare an int against a
> float? (And even if it were a double: Why compare a double against a
> float?)
>
> > +tile->layer_rates[layno] = 0.0f;
>
> This left hand is a double. Why assign an explicit float, which the
> compiler (or preprocessor?) needs to convert back to double? (I.e. just
> "0.0", that's double.)
>
> > +for (bandno = 0; bandno < rlevel->nbands; bandno++){
>
> Missing space before bracket.
>
> > +&&  rlevel->band[bandno].coord[1][0] < 
> > rlevel->band[bandno].coord[1][1]){
>
> Missing space before bracket.
>
>  +Jpeg2000Band *band = rlevel->band + bandno;
>
> Couldn't this also be "= rlevel->band[bandno]", as above?
>
> > +if (layno == nlayers - 1 && cblk->layers->cum_passes){
>
> Missing space before bracket.
>
> > +if (cblk->layers[layno].npasses){
>
> Missing space before bracket.
>
> >  // lay-rlevel-comp-pos progression
> > -switch (s->prog) {
> > +switch (s->prog) {
> >  case JPEG2000_PGOD_LRCP:
>
> Stray incorrect indentation change.
>
> > +if ((ret = encode_packet(s, reslevel, layno, precno, 
> > qntsty->expn + (reslevelno ? 3*reslevelno-2 : 0),
> > +qntsty->nguardbits, packetno++, nlayers)) 
> > < 0)
>
> Peculiar indentation, and consider shorting the first line even more.
>
> > +for (precno = 0; precno < reslevel->num_precincts_x * 
> > reslevel->num_precincts_y; precno++){
> > +if ((ret = encode_packet(s, reslevel, layno, precno, 
> > qntsty->expn + (reslevelno ? 3*reslevelno-2 : 0),
> > +qntsty->nguardbits, packetno++, nlayers)) 
> > < 0)
>
> Ditto.
>
> > +for (layno = 0; layno < nlayers; layno++){
> > +if ((ret = encode_packet(s, reslevel, layno, 
> > precno, qntsty->expn + (reslevelno ? 3*reslevelno-2 : 0),
> > +qntsty->nguardbits, packetno++, nlayers)) 
> > < 0)
>
> Ditto.
>
> > +for (layno = 0; layno < nlayers; layno++){
> > +if ((ret = encode_packet(s, reslevel, layno, 
> > precno, qntsty->expn + (reslevelno ? 3*reslevelno-2 : 0),
> > +qntsty->nguardbits, packetno++, 
> > nlayers)) < 0)
>
> Ditto.
> Also missing space before bracket.
> Also please use whitespace around operators.
>
> (This functionality seems repetetive, perhaps this can be refactored?
> Just wondering.)
This was a part of a previous patch. I'll try working on refactoring
this separately.
>
> > +for (layno = 0; layno < nlayers; layno++){
> > +if ((ret = encode_packet(s, reslevel, layno, 
> > precno, qntsty->expn + (reslevelno ? 3*reslevelno-2 : 0),
> > +qntsty->nguardbits, packetno++, 
> > nlayers)) < 0)
>
> Again. ;)
>
> > +if (n == 0) {
> > +dr = pass->rate;
> > +dd = (double)pass->disto;
>
> Redundant typecast from int32_t to double.
>
> > +} else {
> > +dr = pass->rate - cblk->passes[n - 
> > 1].rate;
> > +dd = (double)pass->disto - 
> > (double)cblk->passes[n-1].disto;
>
> Are you casting these ints to double before subtracting them? why not
> afterwards (and make the typecast implicit again on assignment)?
>
> > +if (!dr) {
> > +if (dd) {
> > +n = passno + 1;
>
> You're comparing a double against 0.0, in this case it might be
> appropriate to make this explicit.
>
> > +dr = (int32_t)pass->rate;
> > +dd = (double)pass->disto;
> > +} else {
> > +  

Re: [FFmpeg-devel] [RFC PATCH 4/4] libavcodec/j2kenc: Support for multiple layers

2020-08-20 Thread Gautam Ramakrishnan
On Thu, Aug 20, 2020 at 12:55 AM Andreas Rheinhardt
 wrote:
>
> Gautam Ramakrishnan:
> > On Wed, Aug 19, 2020 at 5:51 PM  wrote:
> >>
> >> From: Gautam Ramakrishnan 
> >>
> >> This patch allows setting a compression ratio and to
> >> set multiple layers. The user has to input a compression
> >> ratio for each layer.
> >> The per layer compression ration can be set as follows:
> >> -layer_rates "r1,r2,...rn"
> >> for to create 'n' layers.
> >> ---
> >>  libavcodec/j2kenc.c   | 443 ++
> >>  libavcodec/jpeg2000.c |  13 +-
> >>  libavcodec/jpeg2000.h |  10 +
> >>  3 files changed, 384 insertions(+), 82 deletions(-)
> >>
>
> [...]
>
> >> +static int inline check_number(char* st, int* ret) {
> >> +int stlen = strlen(st);
> >> +int i;
> >> +*ret = 0;
> >> +if (stlen <= 0) {
> >> +return AVERROR_INVALIDDATA;
> >> +}
> >> +for (i = 0; i < stlen; i++) {
> >> +if (st[i] >= '0' && st[i] <= '9') {
> >> +*ret = (*ret) * 10 + (st[i] - '0');
> >> +} else {
> >> +return AVERROR_INVALIDDATA;
> >> +}
> >> +}
> >> +return 0;
> >> +}
> >> +
> >> +static int parse_layer_rates(Jpeg2000EncoderContext *s)
> >> +{
> >> +int i;
> >> +char* token;
> >> +int rate;
> >> +int nlayers = 0;
> >> +if (!s->lr_str) {
> >> +s->nlayers = 1;
> >> +s->layer_rates[0] = 0;
> >> +return 0;
> >> +}
> >> +
> >> +token = strtok(s->lr_str, ",");
> >> +if (!check_number(token, )) {
> >> +s->layer_rates[0] = rate <= 1 ? 0:rate;
> >> +nlayers++;
> >> +} else {
> >> +return AVERROR_INVALIDDATA;
> >> +}
> >> +
> >> +while (1) {
> >> +token = strtok(NULL, ",");
> >> +if (!token)
> >> +break;
> >> +if (!check_number(token, )) {
> >> +s->layer_rates[nlayers] = rate <= 1 ? 0:rate;
> >> +nlayers++;
> >> +} else {
> >> +return AVERROR_INVALIDDATA;
> >> +}
> >> +}
> >> +
> >> +for (i = 1; i < nlayers; i++) {
> >> +if (s->layer_rates[i] >= s->layer_rates[i-1]) {
> >> +return AVERROR_INVALIDDATA;
> >> +}
> >> +}
> >> +s->nlayers = nlayers;
> >> +return 0;
> >> +}
> >> +
> >>  static av_cold int j2kenc_init(AVCodecContext *avctx)
> >>  {
> >>  int i, ret;
> >> @@ -1388,6 +1664,11 @@ static av_cold int j2kenc_init(AVCodecContext 
> >> *avctx)
> >>
> >>  s->avctx = avctx;
> >>  av_log(s->avctx, AV_LOG_DEBUG, "init\n");
> >> +if (parse_layer_rates(s)) {
> >> +av_log(s, AV_LOG_WARNING, "Layer rates invalid. Shall encode with 
> >> 1 layer.\n");
> >> +s->nlayers = 1;
> >> +s->layer_rates[0] = 0;
> >> +}
> >>
> >>  #if FF_API_PRIVATE_OPT
> >>  FF_DISABLE_DEPRECATION_WARNINGS
> >> @@ -1408,6 +1689,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >>  memset(codsty->log2_prec_heights, 15, 
> >> sizeof(codsty->log2_prec_heights));
> >>  codsty->nreslevels2decode=
> >>  codsty->nreslevels   = 7;
> >> +codsty->nlayers  = s->nlayers;
> >>  codsty->log2_cblk_width  = 4;
> >>  codsty->log2_cblk_height = 4;
> >>  codsty->transform= s->pred ? FF_DWT53 : FF_DWT97_INT;
> >> @@ -1489,6 +1771,7 @@ static const AVOption options[] = {
> >>  { "rpcl",  NULL,OFFSET(prog),  
> >> AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_RPCL}, 0, 
> >> 0,   VE, "prog" },
> >>  { "pcrl",  NULL,OFFSET(prog),  
> >> AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_PCRL}, 0, 
> >> 0,   VE, "prog" },
> >>  { "cprl",  NULL,OFFSET(prog),  
> >> AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_CPRL}, 0, 
> >> 0,   VE, "prog" },
> >> +{ "layer_rates",   "Layer Rates",   OFFSET(lr_str),
> >> AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE },
> >>  { NULL }
> >>  };
> >>
> >>
> >> --
> >> 2.17.1
> >>
> >
> > This patch seems to be breaking FATE.
> > I believe that the error is because the patch modifies the encoder
> > such that the encoded files will be slightly different now.
> > How can this be handled?
> >
> Look at the created files and see if they are ok (ideally, they should
> show an improvement). If not, modify/drop your patch; otherwise update
> the reference files by running make fate GEN=1.
>
> Just by looking at https://patchwork.ffmpeg.org/check/15622/ (i.e.
> without taking a look at the actual files and without having run fate
> with your patch myself) I can say that your patch is not ok:
>
> -8bb707e596f97451fd325dec2dd610a7 *tests/data/fate/vsynth1-jpeg2000-97.avi
> -3654620 tests/data/fate/vsynth1-jpeg2000-97.avi
> -5073771a78e1f5366a7eb0df341662fc
> *tests/data/fate/vsynth1-jpeg2000-97.out.rawvideo
> -stddev:4.23 PSNR: 35.59 MAXDIFF:   53 bytes:  7603200/  

Re: [FFmpeg-devel] [PATCH v2 2/3] lavf/davs2.c: Rename as avs2dec.c for better understanding

2020-08-20 Thread James Almer
On 8/20/2020 6:11 AM, hwr...@126.com wrote:
> From: hwren 
> 
> Signed-off-by: hwren 
> ---
>  libavformat/Makefile   | 2 +-
>  libavformat/{davs2.c => avs2dec.c} | 0
>  2 files changed, 1 insertion(+), 1 deletion(-)
>  rename libavformat/{davs2.c => avs2dec.c} (100%)
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index cbb33fe37c..8587197f66 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -120,7 +120,7 @@ OBJS-$(CONFIG_AVI_MUXER) += avienc.o 
> mpegtsenc.o avlanguage.o ra
>  OBJS-$(CONFIG_AVM2_MUXER)+= swfenc.o swf.o
>  OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
>  OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
> -OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
> +OBJS-$(CONFIG_AVS2_DEMUXER)  += avs2dec.o rawdec.o
>  OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
>  OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
>  OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
> diff --git a/libavformat/davs2.c b/libavformat/avs2dec.c
> similarity index 100%
> rename from libavformat/davs2.c
> rename to libavformat/avs2dec.c

Should be ok.
___
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] libavformat/r3d.c: Fix Use-of-uninitialized-value in filename.

2020-08-20 Thread Michael Niedermayer
On Wed, Aug 19, 2020 at 03:51:02PM -0700, Thierry Foucu wrote:
> While reading the filename tag, it mays return a EOF and we are still
> copying the file with uninitialized value.
> ---
>  libavformat/r3d.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/r3d.c b/libavformat/r3d.c
> index 7aa0c5a2c3..d013b8c30e 100644
> --- a/libavformat/r3d.c
> +++ b/libavformat/r3d.c
> @@ -56,6 +56,7 @@ static int r3d_read_red1(AVFormatContext *s)
>  R3DContext *r3d = s->priv_data;
>  char filename[258];
>  int tmp;
> +int ret;
>  int av_unused tmp2;
>  AVRational framerate;
>  
> @@ -97,7 +98,9 @@ static int r3d_read_red1(AVFormatContext *s)
>  r3d->audio_channels = avio_r8(s->pb); // audio channels
>  av_log(s, AV_LOG_TRACE, "audio channels %d\n", tmp);
>  
> -avio_read(s->pb, filename, 257);
> +ret = avio_read(s->pb, filename, 257);
> +if (ret < 257)
> +return AVERROR_EOF;

will apply with a modification so the error code is not lost if theres
is one

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavcodec/proresdec2: Setup qmat_chroma according to RDD36

2020-08-20 Thread Michael Niedermayer
On Wed, Aug 19, 2020 at 09:32:47PM +0100, Harry Mallon wrote:
> Signed-off-by: Harry Mallon 
> ---
>  libavcodec/proresdec2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avformat/flvdec: RtmpSampleAccess no longer breaks stream detection

2020-08-20 Thread Michael Niedermayer
On Wed, Aug 19, 2020 at 09:06:54AM +0200, Peter van der Spek wrote:
> Since release 4.2, FFmpeg fails to detect the correct streams in an RTMP
> stream that contains a |RtmpSampleAccess AMF object prior to the
> onMetaData AMF object. In the debug log it would show "[flv] Unknown
> type |RtmpSampleAccess".
> 
> This functionality broke in commit d7638d8dfc3c4ffd0dc18a64937a5a07ed67b354
> as unknown metadata packets now result in an opaque data stream, and the
> |RtmpSampleAccess packet was an "unknown" metadata packet type.
> 
> With this change the RTMP streams are correctly detected when there
> is a |RtmpSampleAccess object prior to the onMetaData object.
> 
> Signed-off-by: Peter van der Spek 
> ---
>  libavformat/flvdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index 0862273..d480d0b 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -715,7 +715,7 @@ static int flv_read_metabody(AVFormatContext *s, int64_t 
> next_pos)
>  if (!strcmp(buffer, "onCaptionInfo"))
>  return TYPE_ONCAPTIONINFO;
>  
> -if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint")) {
> +if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint") && 
> strcmp(buffer, "|RtmpSampleAccess")) {
>  av_log(s, AV_LOG_DEBUG, "Unknown type %s\n", buffer);
>  return TYPE_UNKNOWN;
>  }

when transcoding this will copy this "|RtmpSampleAccess" thing in the output
is that intended ?

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is what and why we do it that matters, not just one of them.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 4/4] ffplay: do not set redundant channel count on abuffersink.

2020-08-20 Thread Nicolas George
Marton Balint (12020-08-20):
> > It is how the API was supposed to be used from the start: these values
> > set the formats list for buffersink. If you said you accept anything
> > with two channels, then you do not need to say you accept stereo, it is
> > already said. It was already documented in formats.h:
> > 
> > * - The list must not contain a layout with a known disposition and a
> > *   channel count with unknown disposition with the same number of channels
> > *   (e.g. AV_CH_LAYOUT_STEREO and FF_COUNT2LAYOUT(2).
> > 
> > Of course, a private header is not the proper place to document a public
> > API, which is what I correct in patch #2.
> > 
> > In practice, applications know if they want a number of channels or a
> > specific channel layout, and should only set one. In this case I am not
> > familiar enough with SDL's API to be sure, so I made the minimal change.
> 
> LGTM, thanks.

Thanks, pushed.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/4] lavfi/buffersink: clearly document that the Params struct are unused.

2020-08-20 Thread Nicolas George
Paul B Mahol (12020-08-19):
> On 8/14/20, Nicolas George  wrote:
> > Signed-off-by: Nicolas George 
> > ---
> >  libavfilter/buffersink.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> LGTM

Thanks, pushed.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 3/4] lavfi/buffersink: add a summary documentation of the API.

2020-08-20 Thread Nicolas George
Paul B Mahol (12020-08-19):
> On 8/14/20, Nicolas George  wrote:
> > Signed-off-by: Nicolas George 
> > ---
> >  libavfilter/buffersink.h | 36 
> >  1 file changed, 36 insertions(+)
> >
> 
> LGTM

Thanks. Pushed.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-20 Thread Moritz Barsnick
On Sun, Aug 16, 2020 at 18:25:12 +0200, Paul B Mahol wrote:
> On 8/16/20, Paul B Mahol  wrote:
> > Please help porting this to linux and 64bit calling convention.
>
> New patch attached.
>
> This one does not allocate stack on x32.

I wanted to benchmark on several machines (newest I have is a Haswell,
I also have an "Intel(R) Atom(TM) CPU D525   @ 1.80GHz" x86_64, and the
below is a Pentium 4 x86), but got stuck on the ancient x86.

Firstly, superficial benchmark result on the Pentium 4:
$ time ffmpeg -i bigger_res.mov -map 0:v -f null -

Without patchset: speed=0.0331x (plus/minus a bit)
Withpatchset: speed=0.0577x (plus/minus a bit)

I'll add benchmarks with my other systems, if desired.

Alas, with the patchset, the following command quickly terminates with
Illegal instruction in ff_cfhd_horiz_filter_clip10_sse2 ():

$ ffmpeg -i MT_BeartoothHighway_1min_Cineform.avi -map 0:v -f null -

(and obviously doesn't terminate with "-cpuflags 0", or without the
patchset).

See assembler dump below.
Compilier: icc (ICC) 14.0.3 20140422
Assembler: nasm-2.13.02

Assembly dump from gdb:
Dump of assembler code from 0x919572f to 0x919576f:
   0x0919572f :movl   
$0xbf0f03ff,(%ecx,%eax,8)
   0x09195736 :xor(%ecx),%al
   0x09195738 :not%ecx
   0x0919573a :jmp*0xf(%esi)
   0x0919573d :outsb  %ds:(%esi),(%dx)
   0x0919573e :(bad)
   0x0919573f :pmaxsw 0x99e6da0,%xmm0
   0x09195747 :pminsw 0x99e6db0,%xmm0
=> 0x0919574f :pextrw $0x0,%xmm0,(%eax)
   0x09195755 :movswl (%ecx),%esi
   0x09195758 :imul   $0x5,%esi,%esi
   0x0919575b :movswl 0x2(%ecx),%edi
   0x0919575f :imul   $0x4,%edi,%edi
   0x09195762 :add%esi,%edi
   0x09195764 :   movswl 0x4(%ecx),%esi
   0x09195768 :   sub%esi,%edi
   0x0919576a :   add$0x4,%edi
   0x0919576d :   sar$0x3,%edi
End of assembler dump.

CPU info:
barsnick@sunshine:~ > hwinfo --cpu
01: None 00.0: 10103 CPU
  [Created at cpu.457]
  Unique ID: rdCR.j8NaKXDZtZ6
  Hardware Class: cpu
  Arch: Intel
  Vendor: "GenuineIntel"
  Model: 15.2.9 "Intel(R) Pentium(R) 4 CPU 2.80GHz"
  Features: 
fpu,vme,de,pse,tsc,msr,pae,mce,cx8,apic,mtrr,pge,mca,cmov,pat,pse36,clflush,dts,acpi,mmx,fxsr,sse,sse2,ss,ht,tm,pbe,pebs,bts,cid,xtpr
  Clock: 2800 MHz
  BogoMips: 5597.27
  Cache: 512 kb
  Units/Processor: 2
  Config Status: cfg=new, avail=yes, need=no, active=unknown

02: None 01.0: 10103 CPU
  [Created at cpu.457]
  Unique ID: wkFv.j8NaKXDZtZ6
  Hardware Class: cpu
  Arch: Intel
  Vendor: "GenuineIntel"
  Model: 15.2.9 "Intel(R) Pentium(R) 4 CPU 2.80GHz"
  Features: 
fpu,vme,de,pse,tsc,msr,pae,mce,cx8,apic,mtrr,pge,mca,cmov,pat,pse36,clflush,dts,acpi,mmx,fxsr,sse,sse2,ss,ht,tm,pbe,pebs,bts,cid,xtpr
  Clock: 2800 MHz
  BogoMips: 27198.67
  Cache: 512 kb
  Units/Processor: 2
  Config Status: cfg=new, avail=yes, need=no, active=unknown

Cheers,
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/avidec: Fix memleak when error happens after creating DV stream

2020-08-20 Thread Andreas Rheinhardt
Michael Niedermayer:
> On Wed, Aug 19, 2020 at 12:00:37AM +0200, Andreas Rheinhardt wrote:
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>> The memleak can be reproduced with e.g. the first 163 bytes of
>> https://samples.ffmpeg.org/archive/all/avi+dvvideo+pcm_s16le++ffmpeg-avidec554-crash.avi
>>
>>  libavformat/avidec.c | 31 +--
>>  1 file changed, 17 insertions(+), 14 deletions(-)
>>
>> diff --git a/libavformat/avidec.c b/libavformat/avidec.c
>> index 5fc3e01aa9..08b864f19a 100644
>> --- a/libavformat/avidec.c
>> +++ b/libavformat/avidec.c
>> @@ -113,6 +113,7 @@ static const AVMetadataConv avi_metadata_conv[] = {
>>  { 0 },
>>  };
>>  
>> +static int avi_read_close(AVFormatContext *s);
>>  static int avi_load_index(AVFormatContext *s);
>>  static int guess_ni_flag(AVFormatContext *s);
>>  
>> @@ -464,6 +465,7 @@ static int calculate_bitrate(AVFormatContext *s)
>>  return 1;
>>  }
>>  
>> +#define RETURN_ERROR(code) do { ret = (code); goto fail; } while (0)
>>  static int avi_read_header(AVFormatContext *s)
>>  {
>>  AVIContext *avi = s->priv_data;
>> @@ -499,7 +501,7 @@ static int avi_read_header(AVFormatContext *s)
>>  frame_period = 0;
>>  for (;;) {
>>  if (avio_feof(pb))
>> -goto fail;
>> +RETURN_ERROR(AVERROR_INVALIDDATA);
> 
> this macro is messy
> it replaces writing 
> {ret = AVERROR_INVALIDDATA; goto fail;}
> by
> RETURN_ERROR(AVERROR_INVALIDDATA);
> 
> this is almost the same length but the first is directly understood C code
> the 2nd is harder to understand for someone reading the code so i  
> suggest to avoid the 2nd and use something else, not saying that needs to
> be the first
> 
The only reason this macro exists is because it allows me to add code
that can easily be removed lateron when cleaning up after read_header
failure will be automatic, whereas an

if (foo) {
ret = bar;
goto fail;
}

leads to a bigger diff now and later. If you want to, I could of course use
if (foo)
{ ret = bar; goto fail; }

- Andreas
___
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] libavformat/mxfenc: Allow more bitrates for NTSC IMX50

2020-08-20 Thread Tomas Härdin
tis 2020-08-18 klockan 15:21 +0100 skrev Mark Himsley:
> Sorry to drag up this old thread:
> 
> On Mon, 19 Aug 2019 at 17:55, Thomas Mundt 
> wrote:
> ...
> > I can give you the parameters that I use for IMX50. Not sure if these are
> > the best. Got the intra matrix values from an original imx file.
> > 
> > NTSC: -c:v mpeg2video -pix_fmt yuv422p -aspect 16:9 -top 1 -flags
> > +ildct+ilme+low_delay -color_range tv -color_trc smpte170m -color_primaries
> > smpte170m -colorspace smpte170m -chroma_sample_location topleft
> > -signal_standard bt601 -dc 10 -intra_vlc 1 -non_linear_quant 1 -ps 1 -g 1
> > -qscale:v 1 -qmin 1 -qmax 12 -b:v 4841 -minrate 4841 -maxrate
> > 4841 -bufsize 1668329 -rc_init_occupancy 1668329 -rc_min_vbv_use 1
> > -rc_max_vbv_use 1 -profile:v 0 -level:v 5 -intra_matrix
> > 8,16,16,17,19,22,23,31,16,16,17,19,20,23,29,29,19,17,19,22,19,25,28
> > ,35,17,19,19,20,25,28,25,33,17,19,22,25,26,25,31,31,17,19,17,20,26,
> > 28,35,36,19,19,19,20,22,29,32,35,16,17,19,22,25,31,28,45
> > 
> > PAL: -c:v mpeg2video -pix_fmt yuv422p -aspect 16:9 -top 1 -flags
> > +ildct+ilme+low_delay -color_range tv -color_trc smpte170m -color_primaries
> > bt470bg -colorspace bt470bg -chroma_sample_location topleft
> > -signal_standard bt601 -dc 10 -intra_vlc 1 -non_linear_quant 1 -ps 1 -g 1
> > -qscale:v 1 -qmin 1 -qmax 12 -b:v 5000 -minrate 5000 -maxrate
> > 5000 -bufsize 200 -rc_init_occupancy 200 -rc_min_vbv_use 1
> > -rc_max_vbv_use 1 -profile:v 0 -level:v 5 -intra_matrix
> > 8,16,16,17,19,22,23,31,16,16,17,19,20,23,29,29,19,17,19,22,19,25,28
> > ,35,17,19,19,20,25,28,25,33,17,19,22,25,26,25,31,31,17,19,17,20,26,
> > 28,35,36,19,19,19,20,22,29,32,35,16,17,19,22,25,31,28,45
> > 
> > Regards,
> > Thomas
> 
> As it stands, FFmpeg from `master` cannot create 3/1001 FPS IMX50,
> and it has to be patched to allow 4841 to be the valid bitrate,
> not 48410 which is in the source code.
> Is there any movement on this issue?
> Why is 4840 in the source code as a variant on 5000 when it
> just does not work?
> Is it not better to put 4841 into the source code?

The problem is that bitrate is an integer, whereas CBR NTSC bitrate is
fractional. The muxer could be made to accept a narrow range of bitrate
metadata values of course.

The real problem is rate control in the MPEG-2 encoder. It is currently
not possible to create 50 Mbps CBR NTSC essence with lavc, so this
whole discussion became moot. The proper fix for this is to implement
CBR encoding via a "bytes per packet" field.

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

Re: [FFmpeg-devel] [PATCH] avformat/avidec: Fix memleak when error happens after creating DV stream

2020-08-20 Thread Michael Niedermayer
On Wed, Aug 19, 2020 at 12:00:37AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
> The memleak can be reproduced with e.g. the first 163 bytes of
> https://samples.ffmpeg.org/archive/all/avi+dvvideo+pcm_s16le++ffmpeg-avidec554-crash.avi
> 
>  libavformat/avidec.c | 31 +--
>  1 file changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/libavformat/avidec.c b/libavformat/avidec.c
> index 5fc3e01aa9..08b864f19a 100644
> --- a/libavformat/avidec.c
> +++ b/libavformat/avidec.c
> @@ -113,6 +113,7 @@ static const AVMetadataConv avi_metadata_conv[] = {
>  { 0 },
>  };
>  
> +static int avi_read_close(AVFormatContext *s);
>  static int avi_load_index(AVFormatContext *s);
>  static int guess_ni_flag(AVFormatContext *s);
>  
> @@ -464,6 +465,7 @@ static int calculate_bitrate(AVFormatContext *s)
>  return 1;
>  }
>  
> +#define RETURN_ERROR(code) do { ret = (code); goto fail; } while (0)
>  static int avi_read_header(AVFormatContext *s)
>  {
>  AVIContext *avi = s->priv_data;
> @@ -499,7 +501,7 @@ static int avi_read_header(AVFormatContext *s)
>  frame_period = 0;
>  for (;;) {
>  if (avio_feof(pb))
> -goto fail;
> +RETURN_ERROR(AVERROR_INVALIDDATA);

this macro is messy
it replaces writing 
{ret = AVERROR_INVALIDDATA; goto fail;}
by
RETURN_ERROR(AVERROR_INVALIDDATA);

this is almost the same length but the first is directly understood C code
the 2nd is harder to understand for someone reading the code so i  
suggest to avoid the 2nd and use something else, not saying that needs to
be the first

thanks


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v4] avformat/mxfdec: Read video range from PictureDescriptor

2020-08-20 Thread Tomas Härdin
sön 2020-08-16 klockan 11:43 +0100 skrev Harry Mallon:
> > > > http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4328/01_Bad_Frame_2.24.mxf
> > > >  
> > > > is not detected correctly for some reason.
> > > > 
> > > > The MXF specs seems ambigous:
> > > > 
> > > > Color Range is a Property, whose unsigned 32-bit integer value shall 
> > > > specify the number of distinct values allowed for color difference 
> > > > samples.
> > > > 
> > > > So probably 2^depth color range should also be accepted as full range.
> > > 
> > > This sounds correct. Do we have any sample using 2^depth-1? If not then
> > > we should just go with 2^depth until such a sample emerges.
> > > 
> > > /Tomas
> > 
> > I based it on what mxfenc.c already did, I can try to find some other 
> > samples.
> > 
> > Harry
> > 
> 
> OK, I have checked back with the docs. 
> 
> * I agree that 2^depth is correct for mxf color_range 
> * 2^depth-1 has been used in FFMPEG since n4.1 (avformat/mxfenc: add
> white/black ref /color range
> 6d0339096e10f6753049f2a5cbfd7ba69e5f8bcd) so maybe we should keep the
> off-by-one case, I don't mind either way.

Ah crap. Yeah, then we do need to accept off-by-one. We could limit
that to files that have been produced by mxfenc.c if we like. Might be
more effort than it's worth. mxfenc should be fixed either way.

> I was checking some other MXF files I have here and one is full-range 
> RGB J2K, rather than YUV. There are separate range metadata in
> RGBAEssenceDescriptor compared to CDCIEssenceDescriptor. Is there a
> way to get the stream component depth from this area of code (as RGBA
> only has component_max and component_min, no component_depth like
> CDCI) or somehow to pass the min/max to the codec to parse?
> 
> e.g in my file (RGB J2K with RGBAEssenceDesc) component_max is 4095
> and component_min is 0, but I don't think the pixel format has been
> set to 12bit yet so it would seem premature to set the range to full.

I don't know anything about J2K so I can't say

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

Re: [FFmpeg-devel] [RFC PATCH 4/4] libavcodec/j2kenc: Support for multiple layers

2020-08-20 Thread Moritz Barsnick
On Wed, Aug 19, 2020 at 17:51:02 +0530, gautamr...@gmail.com wrote:

Minor nits:

> +static void compute_rates(Jpeg2000EncoderContext* s)
> +{
> +int i, j;
> +int layno, compno;
> +for (i = 0; i < s->numYtiles; i++) {
> +for (j = 0; j < s->numXtiles; j++) {
> +Jpeg2000Tile *tile = >tile[s->numXtiles * i + j];
> +for (compno = 0; compno < s->ncomponents; compno++) {
> +int tilew = tile->comp[compno].coord[0][1] - 
> tile->comp[compno].coord[0][0];
> +int tileh = tile->comp[compno].coord[1][1] - 
> tile->comp[compno].coord[1][0];
> +int scale = (compno?1 << s->chroma_shift[0]:1) * (compno?1 
> << s->chroma_shift[1]:1);
> +for (layno = 0; layno < s->nlayers; layno++) {
> +if (s->layer_rates[layno] > 0.0f) {

Isn't this left hand an array of ints? Why compare an int against a
float? (And even if it were a double: Why compare a double against a
float?)

> +tile->layer_rates[layno] = 0.0f;

This left hand is a double. Why assign an explicit float, which the
compiler (or preprocessor?) needs to convert back to double? (I.e. just
"0.0", that's double.)

> +for (bandno = 0; bandno < rlevel->nbands; bandno++){

Missing space before bracket.

> +&&  rlevel->band[bandno].coord[1][0] < 
> rlevel->band[bandno].coord[1][1]){

Missing space before bracket.

 +Jpeg2000Band *band = rlevel->band + bandno;

Couldn't this also be "= rlevel->band[bandno]", as above?

> +if (layno == nlayers - 1 && cblk->layers->cum_passes){

Missing space before bracket.

> +if (cblk->layers[layno].npasses){

Missing space before bracket.

>  // lay-rlevel-comp-pos progression
> -switch (s->prog) {
> +switch (s->prog) {
>  case JPEG2000_PGOD_LRCP:

Stray incorrect indentation change.

> +if ((ret = encode_packet(s, reslevel, layno, precno, 
> qntsty->expn + (reslevelno ? 3*reslevelno-2 : 0),
> +qntsty->nguardbits, packetno++, nlayers)) < 
> 0)

Peculiar indentation, and consider shorting the first line even more.

> +for (precno = 0; precno < reslevel->num_precincts_x * 
> reslevel->num_precincts_y; precno++){
> +if ((ret = encode_packet(s, reslevel, layno, precno, 
> qntsty->expn + (reslevelno ? 3*reslevelno-2 : 0),
> +qntsty->nguardbits, packetno++, nlayers)) < 
> 0)

Ditto.

> +for (layno = 0; layno < nlayers; layno++){
> +if ((ret = encode_packet(s, reslevel, layno, precno, 
> qntsty->expn + (reslevelno ? 3*reslevelno-2 : 0),
> +qntsty->nguardbits, packetno++, nlayers)) < 
> 0)

Ditto.

> +for (layno = 0; layno < nlayers; layno++){
> +if ((ret = encode_packet(s, reslevel, layno, 
> precno, qntsty->expn + (reslevelno ? 3*reslevelno-2 : 0),
> +qntsty->nguardbits, packetno++, 
> nlayers)) < 0)

Ditto.
Also missing space before bracket.
Also please use whitespace around operators.

(This functionality seems repetetive, perhaps this can be refactored?
Just wondering.)

> +for (layno = 0; layno < nlayers; layno++){
> +if ((ret = encode_packet(s, reslevel, layno, 
> precno, qntsty->expn + (reslevelno ? 3*reslevelno-2 : 0),
> +qntsty->nguardbits, packetno++, 
> nlayers)) < 0)

Again. ;)

> +if (n == 0) {
> +dr = pass->rate;
> +dd = (double)pass->disto;

Redundant typecast from int32_t to double.

> +} else {
> +dr = pass->rate - cblk->passes[n - 
> 1].rate;
> +dd = (double)pass->disto - 
> (double)cblk->passes[n-1].disto;

Are you casting these ints to double before subtracting them? why not
afterwards (and make the typecast implicit again on assignment)?

> +if (!dr) {
> +if (dd) {
> +n = passno + 1;

You're comparing a double against 0.0, in this case it might be
appropriate to make this explicit.

> +dr = (int32_t)pass->rate;
> +dd = (double)pass->disto;
> +} else {
> +dr = (int32_t)(pass->rate) - 
> cblk->passes[passno - 1].rate;
> +dd = (double)pass->disto - 
> (double)cblk->passes[passno - 1].disto;

Ditto.

> +double lo = min;
> +double hi = max;
> +double stable_thresh = 0;
> +double good_thresh = 0;

Cosmetic: 0.0

> +good_thresh = -1;


Re: [FFmpeg-devel] [PATCH] avutil/video_enc_params: fix code comment

2020-08-20 Thread Steven Liu
leozhang  于2020年8月20日周四 下午1:53写道:
>
> zhilizhao  于2020年8月13日周四 下午12:55写道:
> >
> >
> >
> > > On Aug 13, 2020, at 11:57 AM, leozhang  wrote:
> > >
> > > Signed-off-by: leozhang 
> > > ---
> > > libavutil/video_enc_params.h | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/libavutil/video_enc_params.h b/libavutil/video_enc_params.h
> > > index 43fa443..e3b422d 100644
> > > --- a/libavutil/video_enc_params.h
> > > +++ b/libavutil/video_enc_params.h
> > > @@ -153,7 +153,7 @@ AVVideoEncParams *av_video_enc_params_alloc(enum 
> > > AVVideoEncParamsType type,
> > > /**
> > >  * Allocates memory for AVEncodeInfoFrame plus an array of
> > >  * {@code nb_blocks} AVEncodeInfoBlock in the given AVFrame {@code frame}
> > > - * as AVFrameSideData of type AV_FRAME_DATA_ENCODE_INFO
> > > + * as AVFrameSideData of type AV_FRAME_DATA_VIDEO_ENC_PARAMS
> > >  * and initializes the variables.
> > >  */
> > > AVVideoEncParams*
> >
> > LGTM.
> Thanks for the review. So could someone help to push it?
Applied!


Thanks
Steven
___
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] [RFC PATCH 3/4] libavcodec/jpeg2000: Modify cleanup

2020-08-20 Thread Moritz Barsnick
On Wed, Aug 19, 2020 at 17:51:01 +0530, gautamr...@gmail.com wrote:
> From: Gautam Ramakrishnan 
>
> This patch makes the ff_jpeg2000_cleanup
> function take in an extra parameter which
> indicates whether it is called from the
> encoder or decoder.

I fail to see an explanation why, ...

> -void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle 
> *codsty)
> +void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle 
> *codsty, int isencoder)
>  {
>  int reslevelno, bandno, precno;
>  for (reslevelno = 0;
> diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h
> index ad58b1ae88..fee9607e86 100644
> --- a/libavcodec/jpeg2000.h
> +++ b/libavcodec/jpeg2000.h

... and what it does with this change. Looks like an NOP from the patch
file alone.

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/siff: Reject audio packets without audio stream

2020-08-20 Thread Michael Niedermayer
On Wed, Aug 19, 2020 at 09:36:38PM +0200, Paul B Mahol wrote:
> On 8/13/20, Michael Niedermayer  wrote:
> > Fixes: Assertion failure
> > Fixes:
> > 24612/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6600899842277376.fuzz
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/siff.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> 
> LGTM

will apply

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their rights and freedoms. to be continued


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v2 2/3] lavf/davs2.c: Rename as avs2dec.c for better understanding

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavformat/Makefile   | 2 +-
 libavformat/{davs2.c => avs2dec.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename libavformat/{davs2.c => avs2dec.c} (100%)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index cbb33fe37c..8587197f66 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -120,7 +120,7 @@ OBJS-$(CONFIG_AVI_MUXER) += avienc.o 
mpegtsenc.o avlanguage.o ra
 OBJS-$(CONFIG_AVM2_MUXER)+= swfenc.o swf.o
 OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
 OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
-OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
+OBJS-$(CONFIG_AVS2_DEMUXER)  += avs2dec.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
diff --git a/libavformat/davs2.c b/libavformat/avs2dec.c
similarity index 100%
rename from libavformat/davs2.c
rename to libavformat/avs2dec.c
-- 
2.23.0.windows.1

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

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

[FFmpeg-devel] [PATCH v2 1/3] lavc/avs2_parser.c, lavf/davs2.c: Add AVS2_* prefix

2020-08-20 Thread hwrenx
From: hwren 

Add AVS2_* prefix to macro definitions to avoid confusion

Signed-off-by: hwren 
---
 libavcodec/avs2_parser.c | 10 +-
 libavformat/davs2.c  | 20 ++--
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 1c9b3423ff..02af08f079 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -21,10 +21,10 @@
 
 #include "parser.h"
 
-#define SLICE_MAX_START_CODE0x01af
+#define AVS2_SLICE_MAX_START_CODE 0x01AF
 
-#define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
-#define ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB2 || ISPIC(x))
+#define AVS2_ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
+#define AVS2_ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB2 || 
AVS2_ISPIC(x))
 
 static int avs2_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
 {
@@ -35,7 +35,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 if (!pic_found) {
 for (; cur < buf_size; ++cur) {
 state = (state<<8) | buf[cur];
-if (ISUNIT(buf[cur])){
+if (AVS2_ISUNIT(buf[cur])){
 ++cur;
 pic_found = 1;
 break;
@@ -48,7 +48,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 return END_NOT_FOUND;
 for (; cur < buf_size; ++cur) {
 state = (state << 8) | buf[cur];
-if ((state & 0xFF00) == 0x100 && state > SLICE_MAX_START_CODE) 
{
+if ((state & 0xFF00) == 0x100 && state > 
AVS2_SLICE_MAX_START_CODE) {
 pc->frame_start_found = 0;
 pc->state = -1;
 return cur - 3;
diff --git a/libavformat/davs2.c b/libavformat/davs2.c
index 59f41fd499..f8337ea500 100644
--- a/libavformat/davs2.c
+++ b/libavformat/davs2.c
@@ -25,11 +25,11 @@
 #include "libavcodec/internal.h"
 #include "libavutil/intreadwrite.h"
 
-#define ISSQH(x)  ((x) == 0xB0 )
-#define ISEND(x)  ((x) == 0xB1 )
-#define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
-#define ISUNIT(x) ( ISSQH(x) || ISEND(x) || (x) == 0xB2 || ISPIC(x) || (x) == 
0xB5 || (x) == 0xB7 )
-#define ISAVS2(x) ((x) == 0x20 || (x) == 0x22 || (x) == 0x30 || (x) == 0x32 )
+#define AVS2_ISSQH(x)  ((x) == 0xB0)
+#define AVS2_ISEND(x)  ((x) == 0xB1)
+#define AVS2_ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
+#define AVS2_ISUNIT(x) (AVS2_ISSQH(x) || AVS2_ISEND(x) || (x) == 0xB2 || 
AVS2_ISPIC(x) || (x) == 0xB5 || (x) == 0xB7)
+#define AVS2_ISPROFILE(x) ((x) == 0x20 || (x) == 0x22 || (x) == 0x30 || (x) == 
0x32)
 
 static int avs2_probe(const AVProbeData *p)
 {
@@ -44,18 +44,18 @@ static int avs2_probe(const AVProbeData *p)
 ptr = avpriv_find_start_code(ptr, end, );
 state = code & 0xFF;
 if ((code & 0xff00) == 0x100) {
-if (ISUNIT(state)) {
+if (AVS2_ISUNIT(state)) {
 if (sqb && !hds) {
 hds = ptr - sqb;
 }
-if (ISSQH(state)) {
-if (!ISAVS2(*ptr))
+if (AVS2_ISSQH(state)) {
+if (!AVS2_ISPROFILE(*ptr))
 return 0;
 sqb = ptr;
 seq++;
-} else if (ISPIC(state)) {
+} else if (AVS2_ISPIC(state)) {
 pic++;
-} else if (ISEND(state)) {
+} else if (AVS2_ISEND(state)) {
 break;
 }
 }
-- 
2.23.0.windows.1

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

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

[FFmpeg-devel] [PATCH v2 3/3] lavc/avs2_parser.c, lavf/avs2dec.c: fix code style

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavcodec/avs2_parser.c | 6 +++---
 libavformat/avs2dec.c| 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 02af08f079..54f687142f 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -34,9 +34,9 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 
 if (!pic_found) {
 for (; cur < buf_size; ++cur) {
-state = (state<<8) | buf[cur];
+state = (state << 8) | buf[cur];
 if (AVS2_ISUNIT(buf[cur])){
-++cur;
+cur++;
 pic_found = 1;
 break;
 }
@@ -46,7 +46,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 if (pic_found) {
 if (!buf_size)
 return END_NOT_FOUND;
-for (; cur < buf_size; ++cur) {
+for (; cur < buf_size; cur++) {
 state = (state << 8) | buf[cur];
 if ((state & 0xFF00) == 0x100 && state > 
AVS2_SLICE_MAX_START_CODE) {
 pc->frame_start_found = 0;
diff --git a/libavformat/avs2dec.c b/libavformat/avs2dec.c
index f8337ea500..51908d2b63 100644
--- a/libavformat/avs2dec.c
+++ b/libavformat/avs2dec.c
@@ -33,9 +33,9 @@
 
 static int avs2_probe(const AVProbeData *p)
 {
-uint32_t code= -1, hds=0, pic=0, seq=0;
-uint8_t state=0;
-const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size, *sqb=0;
+uint32_t code = -1, hds = 0, pic = 0, seq = 0;
+uint8_t state = 0;
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size, *sqb = 0;
 if (AV_RB32(p->buf) != 0x1B0){
 return 0;
 }
-- 
2.23.0.windows.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 2/3] lavf/davs2.c: Rename as avs2dec.c for better understanding

2020-08-20 Thread hwren



Incomplete submission. Please refer to the new version patches.














At 2020-08-20 15:05:14, hwr...@126.com wrote:
>From: hwren 
>
>Signed-off-by: hwren 
>---
> libavformat/{davs2.c => avs2dec.c} | 0
> 1 file changed, 0 insertions(+), 0 deletions(-)
> rename libavformat/{davs2.c => avs2dec.c} (100%)
>
>diff --git a/libavformat/davs2.c b/libavformat/avs2dec.c
>similarity index 100%
>rename from libavformat/davs2.c
>rename to libavformat/avs2dec.c
>-- 
>2.23.0.windows.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 1/4] avcodec/tiff: Check the linearization table size

2020-08-20 Thread Michael Niedermayer
Fixes: out of array access
Fixes: 
24604/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4843529818603520

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

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 08dbca9d60..8c0b6f0853 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1434,7 +1434,9 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
 s->sub_ifd = ff_tget(>gb, TIFF_LONG, s->le); /** Only get the 
first SubIFD */
 break;
 case DNG_LINEARIZATION_TABLE:
-for (int i = 0; i < FFMIN(count, 1 << s->bpp); i++)
+if (count > FF_ARRAY_ELEMS(s->dng_lut))
+return AVERROR_INVALIDDATA;
+for (int i = 0; i < count; i++)
 s->dng_lut[i] = ff_tget(>gb, type, s->le);
 break;
 case DNG_BLACK_LEVEL:
-- 
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 3/4] avcodec/tiff: Restrict tag order based on specification

2020-08-20 Thread Michael Niedermayer
"The entries in an IFD must be sorted in ascending order by Tag. Note that this 
is
 not the order in which the fields are described in this document."

This way various dimensions, sample and bit sizes cannot be changed at
arbitrary times which reduces the potential for bugs.
The tag reading code also on various places assumes that numerically previous
tags have already been parsed, so this needs to be enforced one way or another.

If this commit causes problems with real world files which are not easy to fix
then some other form of checks are needed to ensure the various dependencies
in the tag reading are not violated.

Fixes: out of array access
Fixes: 
24825/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6326925027704832

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

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 8a5f6e030d..86f8487086 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -79,6 +79,7 @@ typedef struct TiffContext {
 int fill_order;
 uint32_t res[4];
 int is_thumbnail;
+unsigned last_tag;
 
 int is_bayer;
 uint8_t pattern[4];
@@ -1252,6 +1253,12 @@ static int tiff_decode_tag(TiffContext *s, AVFrame 
*frame)
 if (ret < 0) {
 goto end;
 }
+if (tag <= s->last_tag)
+return AVERROR_INVALIDDATA;
+
+// We ignore TIFF_STRIP_SIZE as it is sometimes in the logic but wrong 
order around TIFF_STRIP_OFFS
+if (tag != TIFF_STRIP_SIZE)
+s->last_tag = tag;
 
 off = bytestream2_tell(>gb);
 if (count == 1) {
@@ -1807,6 +1814,7 @@ again:
 s->is_tiled= 0;
 s->is_jpeg = 0;
 s->cur_page= 0;
+s->last_tag= 0;
 
 for (i = 0; i < 65536; i++)
 s->dng_lut[i] = i;
-- 
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/4] avcodec/tiff: Avoid abort with DNG RAW TIFF with YA8

2020-08-20 Thread Michael Niedermayer
Fixes: Assertion failure
Fixes: 
24707/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5179910197608448

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

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 8c0b6f0853..8a5f6e030d 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -709,7 +709,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 if (is_dng) {
 int is_u16, pixel_size_bytes, pixel_size_bits, elements;
 
-is_u16 = (s->bpp > 8);
+is_u16 = (s->bpp / s->bppcount > 8);
 pixel_size_bits = (is_u16 ? 16 : 8);
 pixel_size_bytes = (is_u16 ? sizeof(uint16_t) : 
sizeof(uint8_t));
 
-- 
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] avcodec/tiff: Check jpeg context against jpeg frame parameters

2020-08-20 Thread Michael Niedermayer
Fixes: out of array access
Fixes: 
24825/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6326925027704832

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

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 86f8487086..8a42e677ce 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -919,6 +919,11 @@ static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame 
*frame,
 
 /* Copy the outputted tile's pixels from 'jpgframe' to 'frame' (final 
buffer) */
 
+if (s->jpgframe->width  != s->avctx_mjpeg->width  ||
+s->jpgframe->height != s->avctx_mjpeg->height ||
+s->jpgframe->format != s->avctx_mjpeg->pix_fmt)
+return AVERROR_INVALIDDATA;
+
 /* See dng_blit for explanation */
 if (s->avctx_mjpeg->width  == w * 2 &&
 s->avctx_mjpeg->height == h / 2 &&
-- 
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] avfilter: add shufflepixels video filter

2020-08-20 Thread Paul B Mahol
Hi,

patch attached.


0001-avfilter-add-shufflepixels-video-filter.patch
Description: Binary data
___
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/qsv: fix transcode with interlaced clip

2020-08-20 Thread Fei Wang
1. qsvdec: set output surface info correctly.
2. qsvvpp: set output surface/frame's picture struct according to
input if deinterlace option is not enabled.

This fix will make interlace transcode works:
ffmpeg -init_hw_device qsv=hw:/dev/dri/renderD128 -filter_hw_device  \
hw -hwaccel_output_format qsv -hwaccel qsv -v debug -c:v h264_qsv -i \
1920x1080_interlace.mp4 -vf "vpp_qsv=w=1280:h=720" -c:v h264_qsv \
-flags +ildct+ilme -preset medium -b:v 10M -y 1280x720_interlace.mp4

Signed-off-by: Fei Wang 
---
 libavcodec/qsvdec.c  |  2 +-
 libavfilter/qsvvpp.c | 32 ++--
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index fc25dc73e5..4dadc3de07 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -521,7 +521,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 frame->key_frame = !!(out_frame->dec_info.FrameType & 
MFX_FRAMETYPE_IDR);
 
 /* update the surface properties */
-if (avctx->pix_fmt == AV_PIX_FMT_QSV)
+if (frame->format == AV_PIX_FMT_QSV)
 ((mfxFrameSurface1*)frame->data[3])->Info = outsurf->Info;
 
 *got_frame = 1;
diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 8d5ff2eb65..3de98ca475 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -61,6 +61,7 @@ struct QSVVPPContext {
 int nb_surface_ptrs_out;
 mfxFrameSurface1  **surface_ptrs_in;
 mfxFrameSurface1  **surface_ptrs_out;
+int out_frame_deinterlaced;
 
 /* MFXVPP extern parameters */
 mfxExtOpaqueSurfaceAlloc opaque_alloc;
@@ -347,7 +348,7 @@ static QSVFrame *submit_frame(QSVVPPContext *s, 
AVFilterLink *inlink, AVFrame *p
 }
 
 /* get the output surface */
-static QSVFrame *query_frame(QSVVPPContext *s, AVFilterLink *outlink)
+static QSVFrame *query_frame(QSVVPPContext *s, AVFilterLink *outlink, AVFrame 
*picref)
 {
 AVFilterContext *ctx = outlink->src;
 QSVFrame*out_frame;
@@ -395,6 +396,27 @@ static QSVFrame *query_frame(QSVVPPContext *s, 
AVFilterLink *outlink)
 
 out_frame->surface->Info = s->vpp_param.vpp.Out;
 
+if (!s->out_frame_deinterlaced) {
+/* copy picture info from input to out_frame */
+out_frame->frame->repeat_pict = picref->repeat_pict;
+out_frame->frame->top_field_first = picref->top_field_first;
+out_frame->frame->interlaced_frame = picref->interlaced_frame;
+out_frame->frame->pict_type = picref->pict_type;
+
+/* surfaces in pool is inited with MFX_PICSTRUCT_PROGRESSIVE, update
+ * it base on input frame info. */
+out_frame->surface->Info.PicStruct =
+!picref->interlaced_frame ? MFX_PICSTRUCT_PROGRESSIVE :
+(picref->top_field_first ? MFX_PICSTRUCT_FIELD_TFF :
+   MFX_PICSTRUCT_FIELD_BFF);
+if (picref->repeat_pict == 1)
+out_frame->surface->Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
+else if (picref->repeat_pict == 2)
+out_frame->surface->Info.PicStruct |= MFX_PICSTRUCT_FRAME_DOUBLING;
+else if (picref->repeat_pict == 4)
+out_frame->surface->Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING;
+}
+
 return out_frame;
 }
 
@@ -612,6 +634,12 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext 
**vpp, QSVVPPParam *p
 goto failed;
 }
 
+/* Update output's interlace state according to params */
+for (i = 0; i < param->num_ext_buf; i++) {
+if (param->ext_buf[i]->BufferId == MFX_EXTBUFF_VPP_DEINTERLACING)
+s->out_frame_deinterlaced = 1;
+}
+
 if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) 
{
 s->nb_ext_buffers = param->num_ext_buf + 1;
 s->ext_buffers = av_mallocz_array(s->nb_ext_buffers, 
sizeof(*s->ext_buffers));
@@ -701,7 +729,7 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink 
*inlink, AVFrame *picr
 }
 
 do {
-out_frame = query_frame(s, outlink);
+out_frame = query_frame(s, outlink, picref);
 if (!out_frame) {
 av_log(ctx, AV_LOG_ERROR, "Failed to query an output frame.\n");
 return AVERROR(ENOMEM);
-- 
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".

Re: [FFmpeg-devel] [PATCH 4/4] ffplay: do not set redundant channel count on abuffersink.

2020-08-20 Thread Marton Balint



On Thu, 20 Aug 2020, Nicolas George wrote:


Marton Balint (12020-08-20):

Why it is better if we don't set it?


It is how the API was supposed to be used from the start: these values
set the formats list for buffersink. If you said you accept anything
with two channels, then you do not need to say you accept stereo, it is
already said. It was already documented in formats.h:

* - The list must not contain a layout with a known disposition and a
*   channel count with unknown disposition with the same number of channels
*   (e.g. AV_CH_LAYOUT_STEREO and FF_COUNT2LAYOUT(2).

Of course, a private header is not the proper place to document a public
API, which is what I correct in patch #2.

In practice, applications know if they want a number of channels or a
specific channel layout, and should only set one. In this case I am not
familiar enough with SDL's API to be sure, so I made the minimal change.


LGTM, thanks.

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 4/4] ffplay: do not set redundant channel count on abuffersink.

2020-08-20 Thread Nicolas George
Marton Balint (12020-08-20):
> Why it is better if we don't set it?

It is how the API was supposed to be used from the start: these values
set the formats list for buffersink. If you said you accept anything
with two channels, then you do not need to say you accept stereo, it is
already said. It was already documented in formats.h:

 * - The list must not contain a layout with a known disposition and a
 *   channel count with unknown disposition with the same number of channels
 *   (e.g. AV_CH_LAYOUT_STEREO and FF_COUNT2LAYOUT(2).

Of course, a private header is not the proper place to document a public
API, which is what I correct in patch #2.

In practice, applications know if they want a number of channels or a
specific channel layout, and should only set one. In this case I am not
familiar enough with SDL's API to be sure, so I made the minimal change.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v4]libavfilter/asrc_atone.c : generate algorithmic music

2020-08-20 Thread Nicolas George
Paul B Mahol (12020-08-19):
> Disagree, beside, you have already written correct, always bitexact 
> synthesizer
> that does not depend on external tools. So use that for testing?

You mean asrc_sine? It is not enough to exercise various code paths,
this is precisely the issue.

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v2] Set AVSTREAM_PARSE_HEADERS flag for AV1 MP4 streams It help initialize chroma format and other info properly Chroma format wasn't correct if I use below code: avformat_find_s

2020-08-20 Thread Vikas Agrawal (Engrg-SW)
---
 libavformat/mov.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1532e74d67..4c8598c992 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2423,6 +2423,9 @@ static int mov_finalize_stsd_codec(MOVContext *c, 
AVIOContext *pb,
 case AV_CODEC_ID_VP9:
 st->need_parsing = AVSTREAM_PARSE_FULL;
 break;
+case AV_CODEC_ID_AV1:
+st->need_parsing = AVSTREAM_PARSE_HEADERS;
+break;
 default:
 break;
 }
-- 
2.24.0.windows.2

___
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 v4]libavfilter/asrc_atone.c : generate algorithmic music

2020-08-20 Thread Nicolas George
Ashutosh Pradhan (12020-08-20):
> I think it would be a bit difficult considering we have to read SoundFont
> files, read and write midi events, code for the sequencer, synth, etc.

I mean precisely without doing all that. Your code produces notes at
certain times: can they be made available, their pitch and duration,
directly?

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 1/3] lavc/avs2_parser.c, lavf/davs2.c: Add AVS2_* prefix

2020-08-20 Thread hwrenx
From: hwren 

Add AVS2_* prefix to macro definitions to avoid confusion

Signed-off-by: hwren 
---
 libavcodec/avs2_parser.c | 10 +-
 libavformat/davs2.c  | 20 ++--
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 1c9b3423ff..02af08f079 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -21,10 +21,10 @@
 
 #include "parser.h"
 
-#define SLICE_MAX_START_CODE0x01af
+#define AVS2_SLICE_MAX_START_CODE 0x01AF
 
-#define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
-#define ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB2 || ISPIC(x))
+#define AVS2_ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
+#define AVS2_ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB2 || 
AVS2_ISPIC(x))
 
 static int avs2_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
 {
@@ -35,7 +35,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 if (!pic_found) {
 for (; cur < buf_size; ++cur) {
 state = (state<<8) | buf[cur];
-if (ISUNIT(buf[cur])){
+if (AVS2_ISUNIT(buf[cur])){
 ++cur;
 pic_found = 1;
 break;
@@ -48,7 +48,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 return END_NOT_FOUND;
 for (; cur < buf_size; ++cur) {
 state = (state << 8) | buf[cur];
-if ((state & 0xFF00) == 0x100 && state > SLICE_MAX_START_CODE) 
{
+if ((state & 0xFF00) == 0x100 && state > 
AVS2_SLICE_MAX_START_CODE) {
 pc->frame_start_found = 0;
 pc->state = -1;
 return cur - 3;
diff --git a/libavformat/davs2.c b/libavformat/davs2.c
index 59f41fd499..f8337ea500 100644
--- a/libavformat/davs2.c
+++ b/libavformat/davs2.c
@@ -25,11 +25,11 @@
 #include "libavcodec/internal.h"
 #include "libavutil/intreadwrite.h"
 
-#define ISSQH(x)  ((x) == 0xB0 )
-#define ISEND(x)  ((x) == 0xB1 )
-#define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
-#define ISUNIT(x) ( ISSQH(x) || ISEND(x) || (x) == 0xB2 || ISPIC(x) || (x) == 
0xB5 || (x) == 0xB7 )
-#define ISAVS2(x) ((x) == 0x20 || (x) == 0x22 || (x) == 0x30 || (x) == 0x32 )
+#define AVS2_ISSQH(x)  ((x) == 0xB0)
+#define AVS2_ISEND(x)  ((x) == 0xB1)
+#define AVS2_ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
+#define AVS2_ISUNIT(x) (AVS2_ISSQH(x) || AVS2_ISEND(x) || (x) == 0xB2 || 
AVS2_ISPIC(x) || (x) == 0xB5 || (x) == 0xB7)
+#define AVS2_ISPROFILE(x) ((x) == 0x20 || (x) == 0x22 || (x) == 0x30 || (x) == 
0x32)
 
 static int avs2_probe(const AVProbeData *p)
 {
@@ -44,18 +44,18 @@ static int avs2_probe(const AVProbeData *p)
 ptr = avpriv_find_start_code(ptr, end, );
 state = code & 0xFF;
 if ((code & 0xff00) == 0x100) {
-if (ISUNIT(state)) {
+if (AVS2_ISUNIT(state)) {
 if (sqb && !hds) {
 hds = ptr - sqb;
 }
-if (ISSQH(state)) {
-if (!ISAVS2(*ptr))
+if (AVS2_ISSQH(state)) {
+if (!AVS2_ISPROFILE(*ptr))
 return 0;
 sqb = ptr;
 seq++;
-} else if (ISPIC(state)) {
+} else if (AVS2_ISPIC(state)) {
 pic++;
-} else if (ISEND(state)) {
+} else if (AVS2_ISEND(state)) {
 break;
 }
 }
-- 
2.23.0.windows.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] lavf/davs2.c: Rename as avs2dec.c for better understanding

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavformat/{davs2.c => avs2dec.c} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename libavformat/{davs2.c => avs2dec.c} (100%)

diff --git a/libavformat/davs2.c b/libavformat/avs2dec.c
similarity index 100%
rename from libavformat/davs2.c
rename to libavformat/avs2dec.c
-- 
2.23.0.windows.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 3/3] lavc/avs2_parser.c, lavf/avs2dec.c: fix code style

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavcodec/avs2_parser.c | 6 +++---
 libavformat/avs2dec.c| 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 02af08f079..54f687142f 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -34,9 +34,9 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 
 if (!pic_found) {
 for (; cur < buf_size; ++cur) {
-state = (state<<8) | buf[cur];
+state = (state << 8) | buf[cur];
 if (AVS2_ISUNIT(buf[cur])){
-++cur;
+cur++;
 pic_found = 1;
 break;
 }
@@ -46,7 +46,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 if (pic_found) {
 if (!buf_size)
 return END_NOT_FOUND;
-for (; cur < buf_size; ++cur) {
+for (; cur < buf_size; cur++) {
 state = (state << 8) | buf[cur];
 if ((state & 0xFF00) == 0x100 && state > 
AVS2_SLICE_MAX_START_CODE) {
 pc->frame_start_found = 0;
diff --git a/libavformat/avs2dec.c b/libavformat/avs2dec.c
index f8337ea500..51908d2b63 100644
--- a/libavformat/avs2dec.c
+++ b/libavformat/avs2dec.c
@@ -33,9 +33,9 @@
 
 static int avs2_probe(const AVProbeData *p)
 {
-uint32_t code= -1, hds=0, pic=0, seq=0;
-uint8_t state=0;
-const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size, *sqb=0;
+uint32_t code = -1, hds = 0, pic = 0, seq = 0;
+uint8_t state = 0;
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size, *sqb = 0;
 if (AV_RB32(p->buf) != 0x1B0){
 return 0;
 }
-- 
2.23.0.windows.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 3/5] lavf/libkvazaar: export encoded frame stats

2020-08-20 Thread myp...@gmail.com
On Tue, Aug 18, 2020 at 10:41 AM myp...@gmail.com  wrote:
>
> On Mon, Aug 17, 2020 at 7:08 PM Joose Sainio  wrote:
> >
> > On 7.8.2020 5.40, myp...@gmail.com wrote:
> > > On Sun, Jul 26, 2020 at 8:45 PM Jun Zhao  wrote:
> > >> From: Jun Zhao 
> > >>
> > >> Export choosen pict_type and qp.
> > >>
> > >> Signed-off-by: Jun Zhao 
> > >> ---
> > >> libavcodec/libkvazaar.c | 30 ++
> > >> 1 file changed, 30 insertions(+)
> > >>
> > >> diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
> > >> index 71c9c8f..9032547 100644
> > >> --- a/libavcodec/libkvazaar.c
> > >> +++ b/libavcodec/libkvazaar.c
> > >> @@ -37,6 +37,7 @@
> > >>
> > >> #include "avcodec.h"
> > >> #include "internal.h"
> > >> +#include "packet_internal.h"
> > >>
> > >> typedef struct LibkvazaarContext {
> > >> const AVClass *class;
> > >> @@ -170,6 +171,7 @@ static int libkvazaar_encode(AVCodecContext *avctx,
> > >> kvz_data_chunk *data_out = NULL;
> > >> uint32_t len_out = 0;
> > >> int retval = 0;
> > >> + int pict_type;
> > >>
> > >> *got_packet_ptr = 0;
> > >>
> > >> @@ -257,6 +259,34 @@ static int libkvazaar_encode(AVCodecContext *avctx,
> > >> avpkt->flags |= AV_PKT_FLAG_KEY;
> > >> }
> > >>
> > >> + switch (frame_info.slice_type) {
> > >> + case KVZ_SLICE_I:
> > >> + pict_type = AV_PICTURE_TYPE_I;
> > >> + break;
> > >> + case KVZ_SLICE_P:
> > >> + pict_type = AV_PICTURE_TYPE_P;
> > >> + break;
> > >> + case KVZ_SLICE_B:
> > >> + pict_type = AV_PICTURE_TYPE_B;
> > >> + break;
> > >> + default:
> > >> + av_log(avctx, AV_LOG_ERROR, "Unknown picture type encountered.\n");
> > >> + return AVERROR_EXTERNAL;
> > >> + }
> > >> +#if FF_API_CODED_FRAME
> > >> +FF_DISABLE_DEPRECATION_WARNINGS
> > >> + avctx->coded_frame->pict_type = pict_type;
> > >> +FF_ENABLE_DEPRECATION_WARNINGS
> > >> +#endif
> > >> +
> > >> + ff_side_data_set_encoder_stats(avpkt, frame_info.qp * FF_QP2LAMBDA,
> > >> NULL, 0, pict_type);
> > >> +
> > >> +#if FF_API_CODED_FRAME
> > >> +FF_DISABLE_DEPRECATION_WARNINGS
> > >> + avctx->coded_frame->quality = frame_info.qp * FF_QP2LAMBDA;
> > >> +FF_ENABLE_DEPRECATION_WARNINGS
> > >> +#endif
> > >> +
> > >> *got_packet_ptr = 1;
> > >> }
> > >>
> > >> --
> > >> 2.7.4
> > >>
> > > ping ?
> > Sorry, I forgot I was subscribed to the list on the old organization
> > so the message didn't go through originally.
> >
> > In terms of Kvazaar this seems ok but the QP to lambda conversion will
> > result
> > in vastly different lambda value than what Kvazaar would have used
> > internally (and in fact the FF_QP2LAMBDA macro states it is for h.263).
> > I can't comment whether this is problem on the ffmpeg side.
> >
> > The correct formula for hevc/h.265 would be
> > lambda = 0.57 * pow(2.0, (qp - 12 / 3.0))
> This is the other issue, I think, will try to fix it.
After grep and dig in the ff_side_data_set_encoder_stats, I think use
frame_info.qp * FF_QP2LAMBDA (Avg frame QP as frame quality number
with scale number FF_QP2LAMBDA ) is Ok in this case.

In fact, the function int ff_side_data_set_encoder_stats(AVPacket
*pkt, int quality, int64_t *error, int error_count, int pict_type);
we just give a inaccuracy quality number for encoded Frame and depend
on the  specific codec
___
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 v6 0/5] Supplement AVS3-P2/IEEE1857.10 video decoding via libuavs3d

2020-08-20 Thread hwrenx
From: hwren 

=== Version1 ===
These patches are to supplement the third generation of Audio Video Coding 
Standard,
part 2: video (AVS3-P2), aka IEEE1857.10, decoding support via libuavs3d 
wrapper.

The uAVS3d decoder could be found in https://github.com/uavs3/uavs3d
AVS3 sample streams could be found in https://github.com/uavs3/avs3stream

=== Version 2 ===
Fix conflict with CAVS streams. Considering that there is no direct version 
flag in AVS.
AVS3 demuxer only supports raw streams in format <*.avs3>.

Fix API function conflict.

=== Version 3 ===
Rename parameter names that may be confused with AVS2
Reorder header files.

=== Version 4 ===
Add avs3_parser.h for some reusable definitions in AVS3
Refine avs3_parser.c and libuavs3d.c
Fix some vague definitions and potential risks

=== Version 5 ===
Fix the wrong codec order in lavc/codec_desc.c
Use additional lavc/avs3.h and lavc/avs3.c for common definitions
Remove redundant description in the long name of libuavs3d.
Update iteration information in lavf/version.h and lavc/version.h.

=== Version 6 ===
Fix incorrect code style problems.
Remove confused comments.
Add missing demuxer entry in Changelog.
Add value check in lavc/libuavs3d.c

Thanks.

hwren (5):
  lavc: add AVS3 codec id and desc
  lavc/avs3: add AVS3 related definitions
  lavc/avs3_parser: add avs3 parser
  lavf/avs3dec: add raw avs3 demuxer
  lavc,doc: add libuavs3d video decoder wrapper

 Changelog|   2 +
 configure|   4 +
 doc/decoders.texi|  21 
 doc/general.texi |   8 ++
 libavcodec/Makefile  |   4 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avs3.c|  95 +++
 libavcodec/avs3.h|  52 +
 libavcodec/avs3_parser.c | 179 +
 libavcodec/codec_desc.c  |   7 ++
 libavcodec/codec_id.h|   1 +
 libavcodec/libuavs3d.c   | 241 +++
 libavcodec/parsers.c |   1 +
 libavcodec/version.h |   2 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/avs3dec.c|  68 +++
 libavformat/version.h|   2 +-
 18 files changed, 688 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/avs3.c
 create mode 100644 libavcodec/avs3.h
 create mode 100644 libavcodec/avs3_parser.c
 create mode 100644 libavcodec/libuavs3d.c
 create mode 100644 libavformat/avs3dec.c

-- 
2.23.0.windows.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 v6 1/5] lavc: add AVS3 codec id and desc

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0ae6aee63b..61473178fc 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1412,6 +1412,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("PGX (JPEG2000 Test Format)"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_AVS3,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "avs3",
+.long_name = NULL_IF_CONFIG_SMALL("AVS3-P2/IEEE1857.10"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 {
 .id= AV_CODEC_ID_Y41P,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 896ecb0ce0..47aa0787b6 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -242,6 +242,7 @@ enum AVCodecID {
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
 AV_CODEC_ID_PGX,
+AV_CODEC_ID_AVS3,
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
-- 
2.23.0.windows.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 v6 5/5] lavc, doc: add libuavs3d video decoder wrapper

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog  |   1 +
 configure  |   4 +
 doc/decoders.texi  |  21 
 doc/general.texi   |   8 ++
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libuavs3d.c | 255 +
 libavcodec/version.h   |   2 +-
 8 files changed, 292 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/libuavs3d.c

diff --git a/Changelog b/Changelog
index f70ed4927a..a0e171d496 100644
--- a/Changelog
+++ b/Changelog
@@ -15,6 +15,7 @@ version :
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
 - AVS3 bitstream format demuxer
+- AVS3 video decoder via libuavs3d
 
 
 version 4.3:
diff --git a/configure b/configure
index 6faff9bc7b..0fde821742 100755
--- a/configure
+++ b/configure
@@ -277,6 +277,7 @@ External library support:
   --enable-libtls  enable LibreSSL (via libtls), needed for https 
support
if openssl, gnutls or mbedtls is not used [no]
   --enable-libtwolame  enable MP2 encoding via libtwolame [no]
+  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
   --enable-libv4l2 enable libv4l2/v4l-utils [no]
   --enable-libvidstab  enable video stabilization using vid.stab [no]
   --enable-libvmaf enable vmaf filter via libvmaf [no]
@@ -1811,6 +1812,7 @@ EXTERNAL_LIBRARY_LIST="
 libtesseract
 libtheora
 libtwolame
+libuavs3d
 libv4l2
 libvmaf
 libvorbis
@@ -3253,6 +3255,7 @@ libspeex_encoder_select="audio_frame_queue"
 libsvtav1_encoder_deps="libsvtav1"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
+libuavs3d_decoder_deps="libuavs3d"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
 libvorbis_decoder_deps="libvorbis"
 libvorbis_encoder_deps="libvorbis libvorbisenc"
@@ -6416,6 +6419,7 @@ enabled libtls&& require_pkg_config libtls 
libtls tls.h tls_configur
 enabled libtwolame&& require libtwolame twolame.h twolame_init 
-ltwolame &&
  { check_lib libtwolame twolame.h 
twolame_encode_buffer_float32_interleaved -ltwolame ||
die "ERROR: libtwolame must be installed and 
version must be >= 0.3.10"; }
+enabled libuavs3d && require_pkg_config libuavs3d "uavs3d >= 1.1.41" 
uavs3d.h uavs3d_decode
 enabled libv4l2   && require_pkg_config libv4l2 libv4l2 libv4l2.h 
v4l2_ioctl
 enabled libvidstab&& require_pkg_config libvidstab "vidstab >= 0.98" 
vid.stab/libvidstab.h vsMotionDetectInit
 enabled libvmaf   && require_pkg_config libvmaf "libvmaf >= 1.5.2" 
libvmaf.h compute_vmaf
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 9005714e3c..42b46fe153 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -88,6 +88,27 @@ This decoder allows libavcodec to decode AVS2 streams with 
davs2 library.
 
 @c man end VIDEO DECODERS
 
+@section libuavs3d
+
+AVS3-P2/IEEE1857.10 video decoder.
+
+libuavs3d allows libavcodec to decode AVS3 streams.
+Requires the presence of the libuavs3d headers and library during 
configuration.
+You need to explicitly configure the build with @code{--enable-libuavs3d}.
+
+@subsection Options
+
+The following option is supported by the libuavs3d wrapper.
+
+@table @option
+
+@item frame_threads
+Set amount of frame threads to use during decoding. The default value is 0 
(autodetect).
+
+@end table
+
+@c man end VIDEO DECODERS
+
 @chapter Audio Decoders
 @c man begin AUDIO DECODERS
 
diff --git a/doc/general.texi b/doc/general.texi
index fac5377504..233f69d349 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -125,6 +125,14 @@ Go to @url{https://github.com/pkuvcl/davs2} and follow the 
instructions for
 installing the library. Then pass @code{--enable-libdavs2} to configure to
 enable it.
 
+@section uavs3d
+
+FFmpeg can make use of the uavs3d library for AVS3-P2/IEEE1857.10 video 
decoding.
+
+Go to @url{https://github.com/uavs3/uavs3d} and follow the instructions for
+installing the library. Then pass @code{--enable-libuavs3d} to configure to
+enable it.
+
 @float NOTE
 libdavs2 is under the GNU Public License Version 2 or later
 (see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 4c596515ee..5654b3 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1034,6 +1034,7 @@ OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
 OBJS-$(CONFIG_LIBSVTAV1_ENCODER)  += libsvtav1.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
+OBJS-$(CONFIG_LIBUAVS3D_DECODER)  += libuavs3d.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
 OBJS-$(CONFIG_LIBVORBIS_DECODER)  += libvorbisdec.o
 OBJS-$(CONFIG_LIBVORBIS_ENCODER)  += libvorbisenc.o \
diff --git a/libavcodec/allcodecs.c 

[FFmpeg-devel] [PATCH v6 2/5] lavc/avs3: add AVS3 related definitions

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavcodec/Makefile |  2 +
 libavcodec/avs3.c   | 95 +
 libavcodec/avs3.h   | 52 +
 3 files changed, 149 insertions(+)
 create mode 100644 libavcodec/avs3.c
 create mode 100644 libavcodec/avs3.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3431ba2dca..e1e0c4629d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -6,6 +6,7 @@ HEADERS = ac3_parser.h  
\
   avcodec.h \
   avdct.h   \
   avfft.h   \
+  avs3.h\
   bsf.h \
   codec.h   \
   codec_desc.h  \
@@ -32,6 +33,7 @@ OBJS = ac3_parser.o   
  \
avdct.o  \
avpacket.o   \
avpicture.o  \
+   avs3.o   \
bitstream.o  \
bitstream_filter.o   \
bitstream_filters.o  \
diff --git a/libavcodec/avs3.c b/libavcodec/avs3.c
new file mode 100644
index 00..411a6c39a0
--- /dev/null
+++ b/libavcodec/avs3.c
@@ -0,0 +1,95 @@
+/*
+ * AVS3 related definitions
+ *
+ * Copyright (C) 2020 Huiwen Ren, 
+ *
+ * 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 "avs3.h"
+
+const AVRational ff_avs3_frame_rate_tab[16] = {
+{ 0, 0   }, // forbid
+{ 24000, 1001},
+{ 24   , 1   },
+{ 25   , 1   },
+{ 3, 1001},
+{ 30   , 1   },
+{ 50   , 1   },
+{ 6, 1001},
+{ 60   , 1   },
+{ 100  , 1   },
+{ 120  , 1   },
+{ 200  , 1   },
+{ 240  , 1   },
+{ 300  , 1   },
+{ 0, 0   }, // reserved
+{ 0, 0   }  // reserved
+};
+
+const int ff_avs3_color_primaries_tab[10] = {
+AVCOL_PRI_RESERVED0   ,// 0
+AVCOL_PRI_BT709   ,// 1
+AVCOL_PRI_UNSPECIFIED ,// 2
+AVCOL_PRI_RESERVED,// 3
+AVCOL_PRI_BT470M  ,// 4
+AVCOL_PRI_BT470BG ,// 5
+AVCOL_PRI_SMPTE170M   ,// 6
+AVCOL_PRI_SMPTE240M   ,// 7
+AVCOL_PRI_FILM,// 8
+AVCOL_PRI_BT2020   // 9
+};
+
+const int ff_avs3_color_transfer_tab[15] = {
+AVCOL_TRC_RESERVED0, // 0
+AVCOL_TRC_BT709, // 1
+AVCOL_TRC_UNSPECIFIED  , // 2
+AVCOL_TRC_RESERVED , // 3
+AVCOL_TRC_GAMMA22  , // 4
+AVCOL_TRC_GAMMA28  , // 5
+AVCOL_TRC_SMPTE170M, // 6
+AVCOL_TRC_SMPTE240M, // 7
+AVCOL_TRC_LINEAR   , // 8
+AVCOL_TRC_LOG  , // 9
+AVCOL_TRC_LOG_SQRT , // 10
+AVCOL_TRC_BT2020_12, // 11
+AVCOL_TRC_SMPTE2084, // 12
+AVCOL_TRC_UNSPECIFIED  , // 13
+AVCOL_TRC_ARIB_STD_B67   // 14
+};
+
+const int ff_avs3_color_matrix_tab[12] = {
+AVCOL_SPC_RESERVED , // 0
+AVCOL_SPC_BT709, // 1
+AVCOL_SPC_UNSPECIFIED  , // 2
+AVCOL_SPC_RESERVED , // 3
+AVCOL_SPC_FCC  , // 4
+AVCOL_SPC_BT470BG  , // 5
+AVCOL_SPC_SMPTE170M, // 6
+AVCOL_SPC_SMPTE240M, // 7
+AVCOL_SPC_BT2020_NCL   , // 8
+AVCOL_SPC_BT2020_CL, // 9
+AVCOL_SPC_UNSPECIFIED  , // 10
+AVCOL_SPC_UNSPECIFIED// 11
+};
+
+const enum AVPictureType ff_avs3_image_type[4] = {
+AV_PICTURE_TYPE_NONE,
+AV_PICTURE_TYPE_I,
+AV_PICTURE_TYPE_P,
+AV_PICTURE_TYPE_B
+};
diff --git a/libavcodec/avs3.h b/libavcodec/avs3.h
new file mode 100644
index 00..8653e7c476
--- /dev/null
+++ b/libavcodec/avs3.h
@@ -0,0 +1,52 @@
+/*
+ *  AVS3 related definitions
+ *
+ * Copyright (C) 2020 Huiwen Ren, 

[FFmpeg-devel] [PATCH v6 3/5] lavc/avs3_parser: add avs3 parser

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/Makefile  |   1 +
 libavcodec/avs3_parser.c | 179 +++
 libavcodec/parsers.c |   1 +
 3 files changed, 181 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e1e0c4629d..4c596515ee 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1061,6 +1061,7 @@ OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o 
aac_ac3_parser.o
 OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
 OBJS-$(CONFIG_AV1_PARSER)  += av1_parser.o av1_parse.o
 OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o
+OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o
 OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
 OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c
new file mode 100644
index 00..bf97f75db6
--- /dev/null
+++ b/libavcodec/avs3_parser.c
@@ -0,0 +1,179 @@
+/*
+ * AVS3-P2/IEEE1857.10 video parser.
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * 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 "avs3.h"
+#include "get_bits.h"
+#include "parser.h"
+
+static int avs3_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
+{
+int pic_found  = pc->frame_start_found;
+uint32_t state = pc->state;
+int cur = 0;
+
+if (!pic_found) {
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if (AVS3_ISPIC(buf[cur])){
+cur++;
+pic_found = 1;
+break;
+}
+}
+}
+
+if (pic_found) {
+if (!buf_size)
+return END_NOT_FOUND;
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if ((state & 0xFF00) == 0x100 && AVS3_ISUNIT(state & 0xFF)) {
+pc->frame_start_found = 0;
+pc->state = -1;
+return cur - 3;
+}
+}
+}
+
+pc->frame_start_found = pic_found;
+pc->state = state;
+
+return END_NOT_FOUND;
+}
+
+static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
+   int buf_size, AVCodecContext *avctx)
+{
+if (buf_size < 5) {
+return;
+}
+
+if (buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1) {
+if (buf[3] == AVS3_SEQ_START_CODE) {
+GetBitContext gb;
+int profile, ratecode;
+
+init_get_bits(, buf + 4, buf_size - 4);
+
+s->key_frame = 1;
+s->pict_type = AV_PICTURE_TYPE_I;
+
+profile = get_bits(, 8);
+// Skip bits: level(8)
+//progressive(1)
+//field(1)
+//library(2)
+//resv(1)
+//width(14)
+//resv(1)
+//height(14)
+//chroma(2)
+//sampe_precision(3)
+skip_bits(, 47);
+
+if (profile == AVS3_PROFILE_BASELINE_MAIN10) {
+int sample_precision = get_bits(, 3);
+if (sample_precision == 1) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+} else if (sample_precision == 2) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE;
+} else {
+avctx->pix_fmt = AV_PIX_FMT_NONE;
+}
+}
+
+// Skip bits: resv(1)
+//aspect(4)
+skip_bits(, 5);
+
+ratecode = get_bits(, 4);
+
+// Skip bits: resv(1)
+//bitrate_low(18)
+//resv(1)
+//bitrate_high(12)
+skip_bits(, 32);
+
+avctx->has_b_frames = !get_bits(, 1);
+
+avctx->framerate.num = avctx->time_base.den = 
ff_avs3_frame_rate_tab[ratecode].num;
+avctx->framerate.den = avctx->time_base.num = 

[FFmpeg-devel] [PATCH v6 4/5] lavf/avs3dec: add raw avs3 demuxer

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog|  1 +
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/avs3dec.c| 68 
 libavformat/version.h|  2 +-
 5 files changed, 72 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/avs3dec.c

diff --git a/Changelog b/Changelog
index 1efc768387..f70ed4927a 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@ version :
 - ADPCM Argonaut Games encoder
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
+- AVS3 bitstream format demuxer
 
 
 version 4.3:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index cbb33fe37c..8ddab3aee5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -122,6 +122,7 @@ OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
 OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
 OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
+OBJS-$(CONFIG_AVS3_DEMUXER)  += avs3dec.o rawdec.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
 OBJS-$(CONFIG_BINK_DEMUXER)  += bink.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0aa9dd7198..7f41c12d7c 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -84,6 +84,7 @@ extern AVInputFormat  ff_avr_demuxer;
 extern AVInputFormat  ff_avs_demuxer;
 extern AVInputFormat  ff_avs2_demuxer;
 extern AVOutputFormat ff_avs2_muxer;
+extern AVInputFormat  ff_avs3_demuxer;
 extern AVInputFormat  ff_bethsoftvid_demuxer;
 extern AVInputFormat  ff_bfi_demuxer;
 extern AVInputFormat  ff_bintext_demuxer;
diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c
new file mode 100644
index 00..a85f6f6c0b
--- /dev/null
+++ b/libavformat/avs3dec.c
@@ -0,0 +1,68 @@
+/*
+ * RAW AVS3-P2/IEEE1857.10 video demuxer
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * 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 "libavcodec/avs3.h"
+#include "libavcodec/internal.h"
+#include "avformat.h"
+#include "rawdec.h"
+
+static int avs3video_probe(const AVProbeData *p)
+{
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
+uint32_t code = -1;
+uint8_t state = 0;
+int pic = 0, seq = 0, slice_pos = 0;
+int ret = 0;
+
+while (ptr < end) {
+ptr = avpriv_find_start_code(ptr, end, );
+state = code & 0xFF;
+if ((code & 0xFF00) == 0x100) {
+if (state < AVS3_SEQ_START_CODE) {
+if (code < slice_pos)
+return 0;
+slice_pos = code;
+} else {
+slice_pos = 0;
+}
+if (state == AVS3_SEQ_START_CODE) {
+seq++;
+if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != 
AVS3_PROFILE_BASELINE_MAIN10)
+return 0;
+} else if (AVS3_ISPIC(state)) {
+pic++;
+} else if ((state == AVS3_UNDEF_START_CODE) ||
+   (state > AVS3_VIDEO_EDIT_CODE)) {
+return 0;
+}
+}
+}
+
+if (seq && pic && av_match_ext(p->filename, "avs3")) {
+ret = AVPROBE_SCORE_MAX;
+}
+
+return ret;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, 
"avs3", AV_CODEC_ID_AVS3)
\ No newline at end of file
diff --git a/libavformat/version.h b/libavformat/version.h
index aa309ecc77..146db09d1b 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  51
+#define LIBAVFORMAT_VERSION_MINOR  52
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

Re: [FFmpeg-devel] [PATCH v5 2/5] lavc/avs3: add AVS3 related definitions

2020-08-20 Thread hwren



















At 2020-08-19 21:15:32, "Andreas Rheinhardt"  
wrote:
>hwr...@126.com:
>> From: hwren 
>> 
>> Signed-off-by: hwren 
>> ---
>>  libavcodec/Makefile |  2 +
>>  libavcodec/avs3.c   | 95 +
>>  libavcodec/avs3.h   | 52 +
>>  3 files changed, 149 insertions(+)
>>  create mode 100644 libavcodec/avs3.c
>>  create mode 100644 libavcodec/avs3.h
>> 
>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
>> index 3431ba2dca..e1e0c4629d 100644
>> --- a/libavcodec/Makefile
>> +++ b/libavcodec/Makefile
>> @@ -6,6 +6,7 @@ HEADERS = ac3_parser.h   
>>\
>>avcodec.h \
>>avdct.h   \
>>avfft.h   \
>> +  avs3.h\
>>bsf.h \
>>codec.h   \
>>codec_desc.h  \
>> @@ -32,6 +33,7 @@ OBJS = ac3_parser.o
>>  \
>> avdct.o  \
>> avpacket.o   \
>> avpicture.o  \
>> +   avs3.o   \
>> bitstream.o  \
>> bitstream_filter.o   \
>> bitstream_filters.o  \
>> diff --git a/libavcodec/avs3.c b/libavcodec/avs3.c
>> new file mode 100644
>> index 00..8587e36def
>> --- /dev/null
>> +++ b/libavcodec/avs3.c
>> @@ -0,0 +1,95 @@
>> +/*
>> + * AVS3 related definition
>> + *
>> + * Copyright (C) 2020 Huiwen Ren, 
>> + *
>> + * 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 "avs3.h"
>> +
>> +const AVRational ff_avs3_frame_rate_tab[16] = {
>> +{ 0, 0   }, // forbid
>> +{ 24000, 1001},
>> +{ 24   , 1   },
>> +{ 25   , 1   },
>> +{ 3, 1001},
>> +{ 30   , 1   },
>> +{ 50   , 1   },
>> +{ 6, 1001},
>> +{ 60   , 1   },
>> +{ 100  , 1   },
>> +{ 120  , 1   },
>> +{ 200  , 1   },
>> +{ 240  , 1   },
>> +{ 300  , 1   },
>> +{ 0, 0   }, // reserved
>> +{ 0, 0   }  // reserved
>> +};
>> +
>> +const int ff_avs3_color_primaries_tab[10] = {
>> +AVCOL_PRI_RESERVED0   ,// 0
>> +AVCOL_PRI_BT709   ,// 1
>> +AVCOL_PRI_UNSPECIFIED ,// 2
>> +AVCOL_PRI_RESERVED,// 3
>> +AVCOL_PRI_BT470M  ,// 4
>> +AVCOL_PRI_BT470BG ,// 5
>> +AVCOL_PRI_SMPTE170M   ,// 6
>> +AVCOL_PRI_SMPTE240M   ,// 7
>> +AVCOL_PRI_FILM,// 8
>> +AVCOL_PRI_BT2020   // 9
>> +};
>> +
>> +const enum AVPictureType ff_avs3_image_type[4] = {
>> +AV_PICTURE_TYPE_NONE,
>> +AV_PICTURE_TYPE_I,
>> +AV_PICTURE_TYPE_P,
>> +AV_PICTURE_TYPE_B
>> +};
>
>These two coincide with the values of the constants, so they could be
>removed.

Indeed. But I prefer to keep these mappings in case any side changes their 
related tables,
and ensure the completeness of the group of definitions. These table may also 
help to
check the validity of the type value and describe supported range in AVS3.

Thanks.

>
>> \ No newline at end of file
>
>This should be fixed.

Will be fixed. Thanks.

Regards,
Huiwen Ren

>
>- Andreas
>___
>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 

Re: [FFmpeg-devel] [PATCH v4]libavfilter/asrc_atone.c : generate algorithmic music

2020-08-20 Thread Ashutosh Pradhan
On Wed, Aug 19, 2020 at 6:12 PM Nicolas George  wrote:

> Ashutosh Pradhan (12020-08-18):
> > Generate algorithmic music using riffs, lindenmayer systems, cellular
> automaton and rhythm algorithms.
> > Fixed the error that was causing segmentation fault in the previous
> patch.
>
> Thanks. (But this last sentence should be below the --- in the mail, not
> in the commit message.)
>
> I also notice that the output with the options given in example is much
> more interesting than the default, and can justify the usefulness of the
> filter. Good job!
>
> Two points:
>
> - Since it uses fluidsynth, the filter would probably better be called
>   like that, especially since it does not produces tones but almost-real
>   instrument sounds. Let us keep "atone" for a 100% internal
>   implementation.
>
> - I would really appreciate an answer to this question:
>
> >> Since you know the API best, could you say in a few words how hard it
> >> would be to get rid of fluidsynth and use an internal synthesizer
> >> instead?
>
I think it would be a bit difficult considering we have to read SoundFont
files, read and write midi events, code for the sequencer, synth, etc.

>
> Regards,
>
> --
>   Nicolas George
>
___
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".