[FFmpeg-devel] [PATCH 8/8] vfilter/pp: Add VPE post processing filter

2020-05-27 Thread Zhang, Guiyong
VPE(Video Pipeline Engine) is VeriSilicon's hardware engine for multi
formats video encoding and decoding.

This filter uses VPI(VPE Interface) API and library for raw video
frame post-processing.

The input of this filter is raw video data, it supports most of the
popular raw data formats like NV12, YUV420P, YUV420P10BE etc.

Signed-off-by: Guiyong.zhang 
---
 configure|   1 +
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/vf_pp_vpe.c  | 391 +++
 4 files changed, 394 insertions(+)
 create mode 100755 libavfilter/vf_pp_vpe.c

diff --git a/configure b/configure
index ab5d3e2328..7110546326 100755
--- a/configure
+++ b/configure
@@ -3642,6 +3642,7 @@ xfade_opencl_filter_deps="opencl"
 yadif_cuda_filter_deps="ffnvcodec"
 yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
 spliter_vpe_filter_deps="vpe"
+pp_vpe_filter_deps="vpe"
 
 # examples
 avio_list_dir_deps="avformat avutil"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 3e03f2b75b..c5a0dbce5d 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -466,6 +466,7 @@ OBJS-$(CONFIG_ZMQ_FILTER)+= f_zmq.o
 OBJS-$(CONFIG_ZOOMPAN_FILTER)+= vf_zoompan.o
 OBJS-$(CONFIG_ZSCALE_FILTER) += vf_zscale.o
 OBJS-$(CONFIG_SPLITER_VPE_FILTER)+= vf_spliter_vpe.o
+OBJS-$(CONFIG_PP_VPE_FILTER) += vf_pp_vpe.o
 
 OBJS-$(CONFIG_ALLRGB_FILTER) += vsrc_testsrc.o
 OBJS-$(CONFIG_ALLYUV_FILTER) += vsrc_testsrc.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 68f3b3597c..0a6d376a51 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -444,6 +444,7 @@ extern AVFilter ff_vf_zmq;
 extern AVFilter ff_vf_zoompan;
 extern AVFilter ff_vf_zscale;
 extern AVFilter ff_vf_spliter_vpe;
+extern AVFilter ff_vf_pp_vpe;
 
 extern AVFilter ff_vsrc_allrgb;
 extern AVFilter ff_vsrc_allyuv;
diff --git a/libavfilter/vf_pp_vpe.c b/libavfilter/vf_pp_vpe.c
new file mode 100755
index 00..ea718cc104
--- /dev/null
+++ b/libavfilter/vf_pp_vpe.c
@@ -0,0 +1,391 @@
+/*
+ * Verisilicon VPE Post Processing Filter
+ *
+ * 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
+ * MERC`ABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include 
+#include 
+
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "libavutil/pixfmt.h"
+#include "libavutil/buffer.h"
+#include "libavutil/hwcontext.h"
+#include "libavutil/opt.h"
+#include "libavutil/frame.h"
+#include "libavfilter/filters.h"
+#include "libavutil/hwcontext_vpe.h"
+
+typedef struct VpePPFilter {
+const AVClass *av_class;
+AVBufferRef *hw_device;
+AVBufferRef *hw_frame;
+
+VpiCtx ctx;
+VpiApi *vpi;
+
+int nb_outputs;
+int force_10bit;
+char *low_res;
+VpiPPOpition cfg;
+} VpePPFilter;
+
+static const enum AVPixelFormat input_pix_fmts[] = {
+AV_PIX_FMT_NV12,AV_PIX_FMT_P010LE,  AV_PIX_FMT_YUV420P,
+AV_PIX_FMT_YUV422P, AV_PIX_FMT_NV21,AV_PIX_FMT_YUV420P10LE,
+AV_PIX_FMT_YUV420P10BE, AV_PIX_FMT_YUV422P10LE, AV_PIX_FMT_YUV422P10BE,
+AV_PIX_FMT_P010BE,  AV_PIX_FMT_YUV444P, AV_PIX_FMT_RGB24,
+AV_PIX_FMT_BGR24,   AV_PIX_FMT_ARGB,AV_PIX_FMT_RGBA,
+AV_PIX_FMT_ABGR,AV_PIX_FMT_BGRA,AV_PIX_FMT_NONE,
+};
+
+typedef struct PixelMapTable {
+enum AVPixelFormat src;
+VpiPixsFmt des;
+} PixelMapTable;
+
+static PixelMapTable ptable[] = {
+{ AV_PIX_FMT_YUV420P, VPI_FMT_YUV420P },
+{ AV_PIX_FMT_YUV422P, VPI_FMT_YUV422P },
+{ AV_PIX_FMT_NV12, VPI_FMT_NV12 },
+{ AV_PIX_FMT_NV21, VPI_FMT_NV21 },
+{ AV_PIX_FMT_YUV420P10LE, VPI_FMT_YUV420P10LE },
+{ AV_PIX_FMT_YUV420P10BE, VPI_FMT_YUV420P10BE },
+{ AV_PIX_FMT_YUV422P10LE, VPI_FMT_YUV422P10LE },
+{ AV_PIX_FMT_YUV422P10BE, VPI_FMT_YUV422P10BE },
+{ AV_PIX_FMT_P010LE, VPI_FMT_P010LE },
+{ AV_PIX_FMT_P010BE, VPI_FMT_P010BE },
+{ AV_PIX_FMT_YUV444P, VPI_FMT_YUV444P },
+{ AV_PIX_FMT_RGB24, VPI_FMT_RGB24 },
+{ AV_PIX_FMT_BGR24, VPI_FMT_BGR24 },
+{ AV_PIX_FMT_ARGB, VPI_FMT_ARGB },
+{ AV_PIX_FMT_RGBA, VPI_FMT_RGBA },
+{ AV_PIX_FMT_ABGR, VPI_FMT_ABGR },
+{ AV_PIX_FMT_BGRA, VPI_FMT_BGRA },
+};
+
+static const e

[FFmpeg-devel] [PATCH 7/8] avfilter/spliter: Add VPE spliter filter

2020-05-27 Thread Zhang, Guiyong
VPE(Video Pipeline Engine) is VeriSilicon's hardware engine
for multi formats video encoding and decoding.
This filter splite one input to multi output with different picture data.

Signed-off-by: Qin.Wang 
---
 configure|   1 +
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/version.h|   2 +-
 libavfilter/vf_spliter_vpe.c | 319 +++
 5 files changed, 323 insertions(+), 1 deletion(-)
 create mode 100755 libavfilter/vf_spliter_vpe.c

diff --git a/configure b/configure
index 7de94de265..ab5d3e2328 100755
--- a/configure
+++ b/configure
@@ -3641,6 +3641,7 @@ vpp_qsv_filter_select="qsvvpp"
 xfade_opencl_filter_deps="opencl"
 yadif_cuda_filter_deps="ffnvcodec"
 yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
+spliter_vpe_filter_deps="vpe"
 
 # examples
 avio_list_dir_deps="avformat avutil"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 994a4172a3..3e03f2b75b 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -465,6 +465,7 @@ OBJS-$(CONFIG_YAEPBLUR_FILTER)   += 
vf_yaepblur.o
 OBJS-$(CONFIG_ZMQ_FILTER)+= f_zmq.o
 OBJS-$(CONFIG_ZOOMPAN_FILTER)+= vf_zoompan.o
 OBJS-$(CONFIG_ZSCALE_FILTER) += vf_zscale.o
+OBJS-$(CONFIG_SPLITER_VPE_FILTER)+= vf_spliter_vpe.o
 
 OBJS-$(CONFIG_ALLRGB_FILTER) += vsrc_testsrc.o
 OBJS-$(CONFIG_ALLYUV_FILTER) += vsrc_testsrc.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index f2a44b0090..68f3b3597c 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -443,6 +443,7 @@ extern AVFilter ff_vf_yaepblur;
 extern AVFilter ff_vf_zmq;
 extern AVFilter ff_vf_zoompan;
 extern AVFilter ff_vf_zscale;
+extern AVFilter ff_vf_spliter_vpe;
 
 extern AVFilter ff_vsrc_allrgb;
 extern AVFilter ff_vsrc_allyuv;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index a820d0bbbf..980d9baca3 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFILTER_VERSION_MAJOR   7
-#define LIBAVFILTER_VERSION_MINOR  83
+#define LIBAVFILTER_VERSION_MINOR  84
 #define LIBAVFILTER_VERSION_MICRO 100
 
 
diff --git a/libavfilter/vf_spliter_vpe.c b/libavfilter/vf_spliter_vpe.c
new file mode 100755
index 00..0be2b0916a
--- /dev/null
+++ b/libavfilter/vf_spliter_vpe.c
@@ -0,0 +1,319 @@
+/*
+ * Verisilicon VPE H264 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 
+
+#include "avfilter.h"
+#include "filters.h"
+#include "internal.h"
+#include "libavutil/mem.h"
+#include "libavutil/opt.h"
+#include "libavutil/frame.h"
+#include "libavutil/buffer.h"
+#include "libavutil/internal.h"
+#include "libavutil/hwcontext.h"
+#include "libavutil/hwcontext_vpe.h"
+
+typedef struct SpliterVpeContext {
+const AVClass *class;
+int nb_outputs;
+struct {
+int enabled;
+int out_index;
+int flag;
+int width;
+int height;
+struct {
+int enabled;
+int x;
+int y;
+int w;
+int h;
+} crop;
+struct {
+int enabled;
+int w;
+int h;
+} scale;
+} pic_info[PIC_INDEX_MAX_NUMBER];
+} SpliterVpeContext;
+
+static int spliter_vpe_out_config_props(AVFilterLink *outlink);
+
+static av_cold int spliter_vpe_init(AVFilterContext *ctx)
+{
+SpliterVpeContext *s = ctx->priv;
+int i, ret;
+
+for (i = 0; i < s->nb_outputs; i++) {
+char name[32];
+AVFilterPad pad = { 0 };
+
+snprintf(name, sizeof(name), "output%d", i);
+pad.type = AVMEDIA_TYPE_VIDEO;
+pad.name = av_strdup(name);
+if (!pad.name) {
+return AVERROR(ENOMEM);
+}
+pad.config_props = spliter_vpe_out_config_props;
+
+if ((ret = ff_insert_outpad(ctx, i, &pad)) < 0) {
+av_freep(&pad.name);
+return ret;
+}
+}
+
+for (i = 0; i < PIC_INDEX_MAX_NUMBER; i++) {
+s->pic_info[i].out_index = -1;
+}
+
+return 0;
+}
+
+static av_cold void spliter_vpe_uninit(AVFilterContext *ctx)
+{
+int i;
+
+for

[FFmpeg-devel] [PATCH 6/8] vcodec/vp9enc: Add vp9 VPE HW encoder

2020-05-27 Thread Zhang, Guiyong
VPE(Video Pipeline Engine) is VeriSilicon's hardware engine for multi
formats video encoding and decoding.
This encoder uses VPI(VPE Interface) API and library for vp9 encoding.

Signed-off-by: Guiyong.zhang 
---
 configure   |   1 +
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/vpe_vp9enc.c | 536 
 libavcodec/vpe_vp9enc.h |  83 +++
 5 files changed, 622 insertions(+)
 create mode 100755 libavcodec/vpe_vp9enc.c
 create mode 100755 libavcodec/vpe_vp9enc.h

diff --git a/configure b/configure
index 7314acf86a..7de94de265 100755
--- a/configure
+++ b/configure
@@ -3133,6 +3133,7 @@ vp9_qsv_encoder_deps="libmfx MFX_CODEC_VP9"
 vp9_qsv_encoder_select="qsvenc"
 vp9_v4l2m2m_decoder_deps="v4l2_m2m vp9_v4l2_m2m"
 vp9_vpe_decoder_deps="vpe"
+vp9_vpe_encoder_deps="vpe"
 wmv3_crystalhd_decoder_select="crystalhd"
 
 # parsers
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 06dbebec55..c303c9dfc0 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -765,6 +765,7 @@ OBJS-$(CONFIG_HEVC_VPE_DECODER)+= vpe_hevcdec.o 
vpe_dec_common.o
 OBJS-$(CONFIG_VP9_VPE_DECODER) += vpe_vp9dec.o vpe_dec_common.o
 OBJS-$(CONFIG_H264_VPE_ENCODER)+= vpe_h26xenc.o
 OBJS-$(CONFIG_HEVC_VPE_ENCODER)+= vpe_h26xenc.o
+OBJS-$(CONFIG_VP9_VPE_ENCODER) += vpe_vp9enc.o
 
 # (AD)PCM decoders/encoders
 OBJS-$(CONFIG_PCM_ALAW_DECODER)   += pcm.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index f5598aa3ac..1e9b333f41 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -811,6 +811,7 @@ extern AVCodec ff_hevc_vpe_decoder;
 extern AVCodec ff_vp9_vpe_decoder;
 extern AVCodec ff_h264_vpe_encoder;
 extern AVCodec ff_hevc_vpe_encoder;
+extern AVCodec ff_vp9_vpe_encoder;
 
 // The iterate API is not usable with ossfuzz due to the excessive size of 
binaries created
 #if CONFIG_OSSFUZZ
diff --git a/libavcodec/vpe_vp9enc.c b/libavcodec/vpe_vp9enc.c
new file mode 100755
index 00..087ddc56c6
--- /dev/null
+++ b/libavcodec/vpe_vp9enc.c
@@ -0,0 +1,536 @@
+/*
+ * Verisilicon VPE VP9 Encoder
+ *
+ * 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 "libavutil/pixfmt.h"
+#include "vpe_vp9enc.h"
+
+#define OFFSET(x) (offsetof(VpeEncVp9Ctx, x))
+#define FLAGS \
+(AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_EXPORT)
+
+const static AVOption vpe_enc_vp9_options[] = {
+{ "preset",
+  "Set the encoding preset, superfast/fast/medium/slow/superslow",
+  OFFSET(preset),
+  AV_OPT_TYPE_STRING,
+  { .str = "fast" },
+  0,
+  0,
+  FLAGS },
+{ "effort",
+  "Encoder effort level, 0=fastest, 5=best quality",
+  OFFSET(effort),
+  AV_OPT_TYPE_INT,
+  { .i64 = 0 },
+  0,
+  5,
+  FLAGS },
+{ "lag_in_frames",
+  "Number of frames to lag. Up to 25. [0]",
+  OFFSET(lag_in_frames),
+  AV_OPT_TYPE_INT,
+  { .i64 = 0 },
+  0,
+  25,
+  FLAGS },
+{ "passes",
+  "Number of passes (1/2). [1]",
+  OFFSET(passes),
+  AV_OPT_TYPE_INT,
+  { .i64 = 1 },
+  1,
+  2,
+  FLAGS },
+
+/*Detail parameters described in
+  https://github.com/VeriSilicon/VPE/blob/master/doc/enc_params_vp9.md */
+{ "enc_params",
+  "Override the enc configuration",
+  OFFSET(enc_params),
+  AV_OPT_TYPE_STRING,
+  { 0 },
+  0,
+  0,
+  FLAGS },
+{ NULL },
+};
+
+static int vpe_vp9enc_init_hwctx(AVCodecContext *avctx)
+{
+int ret = 0;
+AVHWFramesContext *hwframe_ctx;
+VpeEncVp9Ctx *ctx = avctx->priv_data;
+
+if (avctx->hw_frames_ctx) {
+ctx->hw_frame = av_buffer_ref(avctx->hw_frames_ctx);
+if (!ctx->hw_frame) {
+ret = AVERROR(ENOMEM);
+goto error;
+}
+
+hwframe_ctx= (AVHWFramesContext *)ctx->hw_frame->data;
+ctx->hw_device = av_buffer_ref(hwframe_ctx->device_ref);
+if (!ctx->hw_device) {
+ret = AVERROR(ENOMEM);
+goto error;
+}
+} else {
+if (avctx->hw_device_ctx) {
+ctx->hw_device = av_buffer_ref(avctx->hw_device_ctx);
+if (!ctx->hw_device) {
+ret =

[FFmpeg-devel] [PATCH 5/8] avcodec/h26xenc: Add h264/hevc VPE HW encoder

2020-05-27 Thread Zhang, Guiyong
VPE(Video Pipeline Engine) is VeriSilicon's hardware engine for multi
formats video encoding and decoding.
This encoder uses VPI(VPE Interface) API and library for h264 and hevc
encoding.

Signed-off-by: rxchen 
---
 configure|   2 +
 libavcodec/Makefile  |   2 +
 libavcodec/allcodecs.c   |   2 +
 libavcodec/vpe_h26xenc.c | 633 +++
 libavcodec/vpe_h26xenc.h |  83 +
 5 files changed, 722 insertions(+)
 create mode 100644 libavcodec/vpe_h26xenc.c
 create mode 100755 libavcodec/vpe_h26xenc.h

diff --git a/configure b/configure
index 1ae89b09bc..7314acf86a 100755
--- a/configure
+++ b/configure
@@ -3064,6 +3064,7 @@ h264_v4l2m2m_decoder_deps="v4l2_m2m h264_v4l2_m2m"
 h264_v4l2m2m_decoder_select="h264_mp4toannexb_bsf"
 h264_v4l2m2m_encoder_deps="v4l2_m2m h264_v4l2_m2m"
 h264_vpe_decoder_deps="vpe"
+h264_vpe_encoder_deps="vpe"
 hevc_amf_encoder_deps="amf"
 hevc_cuvid_decoder_deps="cuvid"
 hevc_cuvid_decoder_select="hevc_mp4toannexb_bsf"
@@ -3081,6 +3082,7 @@ hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
 hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf"
 hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"
 hevc_vpe_decoder_deps="vpe"
+hevc_vpe_encoder_deps="vpe"
 mjpeg_cuvid_decoder_deps="cuvid"
 mjpeg_qsv_decoder_select="qsvdec"
 mjpeg_qsv_encoder_deps="libmfx"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3631c54473..06dbebec55 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -763,6 +763,8 @@ OBJS-$(CONFIG_ZMBV_ENCODER)+= zmbvenc.o
 OBJS-$(CONFIG_H264_VPE_DECODER)+= vpe_h264dec.o vpe_dec_common.o
 OBJS-$(CONFIG_HEVC_VPE_DECODER)+= vpe_hevcdec.o vpe_dec_common.o
 OBJS-$(CONFIG_VP9_VPE_DECODER) += vpe_vp9dec.o vpe_dec_common.o
+OBJS-$(CONFIG_H264_VPE_ENCODER)+= vpe_h26xenc.o
+OBJS-$(CONFIG_HEVC_VPE_ENCODER)+= vpe_h26xenc.o
 
 # (AD)PCM decoders/encoders
 OBJS-$(CONFIG_PCM_ALAW_DECODER)   += pcm.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index a3c189762a..f5598aa3ac 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -809,6 +809,8 @@ extern AVCodec ff_vp9_qsv_encoder;
 extern AVCodec ff_h264_vpe_decoder;
 extern AVCodec ff_hevc_vpe_decoder;
 extern AVCodec ff_vp9_vpe_decoder;
+extern AVCodec ff_h264_vpe_encoder;
+extern AVCodec ff_hevc_vpe_encoder;
 
 // The iterate API is not usable with ossfuzz due to the excessive size of 
binaries created
 #if CONFIG_OSSFUZZ
diff --git a/libavcodec/vpe_h26xenc.c b/libavcodec/vpe_h26xenc.c
new file mode 100644
index 00..aff772e5c8
--- /dev/null
+++ b/libavcodec/vpe_h26xenc.c
@@ -0,0 +1,633 @@
+/*
+ * Verisilicon VPE H264/HEVC Encoder
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include 
+#include 
+#include 
+#include "libavutil/opt.h"
+#include "libavcodec/internal.h"
+#include "vpe_h26xenc.h"
+#include "libavutil/hwcontext_vpe.h"
+
+static av_cold int vpe_h26x_encode_close(AVCodecContext *avctx);
+
+/**
+ * Output the ES data in VpiPacket to AVPacket
+ */
+static int vpe_h26xe_output_es_to_avpacket(AVPacket *av_packet,
+   VpiPacket *vpi_packet)
+{
+int ret = 0;
+if (av_new_packet(av_packet, vpi_packet->size))
+return AVERROR(ENOMEM);
+
+memcpy(av_packet->data, (uint8_t *)vpi_packet->data, vpi_packet->size);
+av_packet->pts = vpi_packet->pts;
+av_packet->dts = vpi_packet->pkt_dts;
+
+return ret;
+}
+
+/**
+ * Output the ES data in VpiPacket to AVPacket and control the encoder to
+ * update the statistic
+ */
+static int vpe_h26xe_output_es_update_statis(AVCodecContext *avctx,
+ AVPacket *av_packet,
+ VpiPacket *vpi_packet)
+{
+int ret= 0;
+VpeH26xEncCtx *enc_ctx = NULL;
+int stream_size= vpi_packet->size;
+VpiCtrlCmdParam cmd;
+
+if ((ret = vpe_h26xe_output_es_to_avpacket(av_packet, vpi_packet)) < 0) {
+return ret;
+}
+
+enc_ctx  = (VpeH26xEncCtx *)avctx->priv_data;
+cmd.cmd  = VPI_CMD_H26xENC_UPDATE_STATISTIC;
+cmd.data = &stream_size;
+ret  = enc_ctx->api->control(enc_ctx->ctx, (void *)&cmd, NULL);
+if (ret != 0) {
+ 

[FFmpeg-devel] [PATCH 3/8] avcodec/hevcdec: Add hevc VPE HW decoder

2020-05-27 Thread Zhang, Guiyong
VPE(Video Pipeline Engine) is VeriSilicon's hardware engine
for multi formats video encoding and decoding.
This decoder uses VPI(VPE Interface) API and library for hevc decoding.

Signed-off-by: Qin.Wang 
---
 configure|  1 +
 libavcodec/Makefile  |  1 +
 libavcodec/allcodecs.c   |  1 +
 libavcodec/vpe_hevcdec.c | 69 
 4 files changed, 72 insertions(+)
 create mode 100755 libavcodec/vpe_hevcdec.c

diff --git a/configure b/configure
index a913b6fc68..c020c4dd56 100755
--- a/configure
+++ b/configure
@@ -3080,6 +3080,7 @@ hevc_vaapi_encoder_select="cbs_h265 vaapi_encode"
 hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
 hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf"
 hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"
+hevc_vpe_decoder_deps="vpe"
 mjpeg_cuvid_decoder_deps="cuvid"
 mjpeg_qsv_decoder_select="qsvdec"
 mjpeg_qsv_encoder_deps="libmfx"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 28d5b21cb5..3b0b754417 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -761,6 +761,7 @@ OBJS-$(CONFIG_ZLIB_ENCODER)+= lclenc.o
 OBJS-$(CONFIG_ZMBV_DECODER)+= zmbv.o
 OBJS-$(CONFIG_ZMBV_ENCODER)+= zmbvenc.o
 OBJS-$(CONFIG_H264_VPE_DECODER)+= vpe_h264dec.o vpe_dec_common.o
+OBJS-$(CONFIG_HEVC_VPE_DECODER)+= vpe_hevcdec.o vpe_dec_common.o
 
 # (AD)PCM decoders/encoders
 OBJS-$(CONFIG_PCM_ALAW_DECODER)   += pcm.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 0742c228e2..a864939f95 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -807,6 +807,7 @@ extern AVCodec ff_vp9_qsv_decoder;
 extern AVCodec ff_vp9_vaapi_encoder;
 extern AVCodec ff_vp9_qsv_encoder;
 extern AVCodec ff_h264_vpe_decoder;
+extern AVCodec ff_hevc_vpe_decoder;
 
 // The iterate API is not usable with ossfuzz due to the excessive size of 
binaries created
 #if CONFIG_OSSFUZZ
diff --git a/libavcodec/vpe_hevcdec.c b/libavcodec/vpe_hevcdec.c
new file mode 100755
index 00..0c5a9df9d2
--- /dev/null
+++ b/libavcodec/vpe_hevcdec.c
@@ -0,0 +1,69 @@
+/*
+ * Verisilicon VPE HEVC 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 "hwconfig.h"
+#include "internal.h"
+#include "libavutil/pixfmt.h"
+
+#include "vpe_dec_common.h"
+
+static av_cold int vpe_hevc_decode_init(AVCodecContext *avctx)
+{
+return ff_vpe_decode_init(avctx, HEVCDEC_VPE);
+}
+
+static const AVClass vpe_hevc_decode_class = {
+.class_name = "hevcd_vpe",
+.item_name  = av_default_item_name,
+.option = vpe_decode_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+static const AVCodecHWConfigInternal *vpe_hw_configs[] =
+{ &(const AVCodecHWConfigInternal){
+  .public =
+  {
+  .pix_fmt = AV_PIX_FMT_VPE,
+  .methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
+ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX,
+  .device_type = AV_HWDEVICE_TYPE_VPE,
+  },
+  .hwaccel = NULL,
+  },
+  NULL };
+
+AVCodec ff_hevc_vpe_decoder = {
+.name   = "hevc_vpe",
+.long_name  = NULL_IF_CONFIG_SMALL("HEVC (VPE VC8000D)"),
+.type   = AVMEDIA_TYPE_VIDEO,
+.id = AV_CODEC_ID_HEVC,
+.priv_data_size = sizeof(VpeDecCtx),
+.init   = &vpe_hevc_decode_init,
+.receive_frame  = &ff_vpe_decode_receive_frame,
+.close  = &ff_vpe_decode_close,
+.priv_class = &vpe_hevc_decode_class,
+.capabilities =
+AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | 
AV_CODEC_CAP_AVOID_PROBING,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_VPE, 
AV_PIX_FMT_NONE },
+.hw_configs = vpe_hw_configs,
+.wrapper_name   = "vpe",
+.bsfs   = "hevc_mp4toannexb",
+};
-- 
2.19.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/8] avcodec/vp9dec: Add vp9 VPE HW decoder

2020-05-27 Thread Zhang, Guiyong
VPE(Video Pipeline Engine) is VeriSilicon's hardware engine
for multi formats video encoding and decoding.
This decoder uses VPI(VPE Interface) API and library for vp9 decoding.

Signed-off-by: Qin.Wang 
---
 configure   |  1 +
 libavcodec/Makefile |  1 +
 libavcodec/allcodecs.c  |  1 +
 libavcodec/vpe_vp9dec.c | 67 +
 4 files changed, 70 insertions(+)
 create mode 100755 libavcodec/vpe_vp9dec.c

diff --git a/configure b/configure
index c020c4dd56..1ae89b09bc 100755
--- a/configure
+++ b/configure
@@ -3130,6 +3130,7 @@ vp9_vaapi_encoder_select="vaapi_encode"
 vp9_qsv_encoder_deps="libmfx MFX_CODEC_VP9"
 vp9_qsv_encoder_select="qsvenc"
 vp9_v4l2m2m_decoder_deps="v4l2_m2m vp9_v4l2_m2m"
+vp9_vpe_decoder_deps="vpe"
 wmv3_crystalhd_decoder_select="crystalhd"
 
 # parsers
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3b0b754417..3631c54473 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -762,6 +762,7 @@ OBJS-$(CONFIG_ZMBV_DECODER)+= zmbv.o
 OBJS-$(CONFIG_ZMBV_ENCODER)+= zmbvenc.o
 OBJS-$(CONFIG_H264_VPE_DECODER)+= vpe_h264dec.o vpe_dec_common.o
 OBJS-$(CONFIG_HEVC_VPE_DECODER)+= vpe_hevcdec.o vpe_dec_common.o
+OBJS-$(CONFIG_VP9_VPE_DECODER) += vpe_vp9dec.o vpe_dec_common.o
 
 # (AD)PCM decoders/encoders
 OBJS-$(CONFIG_PCM_ALAW_DECODER)   += pcm.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index a864939f95..a3c189762a 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -808,6 +808,7 @@ extern AVCodec ff_vp9_vaapi_encoder;
 extern AVCodec ff_vp9_qsv_encoder;
 extern AVCodec ff_h264_vpe_decoder;
 extern AVCodec ff_hevc_vpe_decoder;
+extern AVCodec ff_vp9_vpe_decoder;
 
 // The iterate API is not usable with ossfuzz due to the excessive size of 
binaries created
 #if CONFIG_OSSFUZZ
diff --git a/libavcodec/vpe_vp9dec.c b/libavcodec/vpe_vp9dec.c
new file mode 100755
index 00..9fd773dabc
--- /dev/null
+++ b/libavcodec/vpe_vp9dec.c
@@ -0,0 +1,67 @@
+/*
+ * Verisilicon VPE VP9 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 "hwconfig.h"
+#include "internal.h"
+#include "libavutil/pixfmt.h"
+
+#include "vpe_dec_common.h"
+
+static av_cold int vpe_vp9_decode_init(AVCodecContext *avctx)
+{
+return ff_vpe_decode_init(avctx, VP9DEC_VPE);
+}
+
+static const AVClass vpe_vp9_decode_class = {
+.class_name = "vp9d_vpe",
+.item_name  = av_default_item_name,
+.option = vpe_decode_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+static const AVCodecHWConfigInternal *vpe_hw_configs[] =
+{ &(const AVCodecHWConfigInternal){
+  .public =
+  {
+  .pix_fmt = AV_PIX_FMT_VPE,
+  .methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
+ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX,
+  .device_type = AV_HWDEVICE_TYPE_VPE,
+  },
+  .hwaccel = NULL,
+  },
+  NULL };
+
+AVCodec ff_vp9_vpe_decoder = {
+.name   = "vp9_vpe",
+.long_name  = NULL_IF_CONFIG_SMALL("VP9 (VPE VC8000D)"),
+.type   = AVMEDIA_TYPE_VIDEO,
+.id = AV_CODEC_ID_VP9,
+.priv_data_size = sizeof(VpeDecCtx),
+.init   = &vpe_vp9_decode_init,
+.receive_frame  = &ff_vpe_decode_receive_frame,
+.close  = &ff_vpe_decode_close,
+.priv_class = &vpe_vp9_decode_class,
+.capabilities =
+AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | 
AV_CODEC_CAP_AVOID_PROBING,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_VPE, 
AV_PIX_FMT_NONE },
+.hw_configs = vpe_hw_configs,
+};
-- 
2.19.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/8] avcodec/h264dec: Add h264 VPE HW decoder

2020-05-27 Thread Zhang, Guiyong
VPE(Video Pipeline Engine) is VeriSilicon's hardware engine
for multi formats video encoding and decoding.
This decoder uses VPI(VPE Interface) API and library for h264 decoding.

Signed-off-by: Qin.Wang 
---
 configure   |   1 +
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/version.h|   2 +-
 libavcodec/vpe_dec_common.c | 476 
 libavcodec/vpe_dec_common.h |  81 ++
 libavcodec/vpe_h264dec.c|  69 ++
 7 files changed, 630 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/vpe_dec_common.c
 create mode 100644 libavcodec/vpe_dec_common.h
 create mode 100644 libavcodec/vpe_h264dec.c

diff --git a/configure b/configure
index cf7d1d9fcc..a913b6fc68 100755
--- a/configure
+++ b/configure
@@ -3063,6 +3063,7 @@ h264_vaapi_encoder_select="cbs_h264 vaapi_encode"
 h264_v4l2m2m_decoder_deps="v4l2_m2m h264_v4l2_m2m"
 h264_v4l2m2m_decoder_select="h264_mp4toannexb_bsf"
 h264_v4l2m2m_encoder_deps="v4l2_m2m h264_v4l2_m2m"
+h264_vpe_decoder_deps="vpe"
 hevc_amf_encoder_deps="amf"
 hevc_cuvid_decoder_deps="cuvid"
 hevc_cuvid_decoder_select="hevc_mp4toannexb_bsf"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6d816308c7..28d5b21cb5 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -760,6 +760,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_H264_VPE_DECODER)+= vpe_h264dec.o vpe_dec_common.o
 
 # (AD)PCM decoders/encoders
 OBJS-$(CONFIG_PCM_ALAW_DECODER)   += pcm.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index eb5044f80e..0742c228e2 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -806,6 +806,7 @@ extern AVCodec ff_vp9_mediacodec_decoder;
 extern AVCodec ff_vp9_qsv_decoder;
 extern AVCodec ff_vp9_vaapi_encoder;
 extern AVCodec ff_vp9_qsv_encoder;
+extern AVCodec ff_h264_vpe_decoder;
 
 // The iterate API is not usable with ossfuzz due to the excessive size of 
binaries created
 #if CONFIG_OSSFUZZ
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 2d2cc69ab6..91002dc0b9 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  58
-#define LIBAVCODEC_VERSION_MINOR  88
+#define LIBAVCODEC_VERSION_MINOR  89
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavcodec/vpe_dec_common.c b/libavcodec/vpe_dec_common.c
new file mode 100644
index 00..c4d99472a7
--- /dev/null
+++ b/libavcodec/vpe_dec_common.c
@@ -0,0 +1,476 @@
+/*
+ * Verisilicon VPE Video Decoder Common interface
+ *
+ * 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 "libavutil/pixfmt.h"
+#include "decode.h"
+#include "internal.h"
+
+#include "vpe_dec_common.h"
+
+/**
+ * Initialize hw frame and device
+ *
+ * The avctx->hw_frames_ctx is the reference to the AVHWFramesContext.
+ * If it exists, get its data, otherwise create the hw_frame_ctx
+ * then initialize hw_frame_ctx.
+ */
+static int vpe_dec_init_hwctx(AVCodecContext *avctx)
+{
+int ret = 0;
+AVHWFramesContext *hwframe_ctx;
+
+if (!avctx->hw_frames_ctx) {
+if (avctx->hw_device_ctx) {
+avctx->hw_frames_ctx = av_hwframe_ctx_alloc(avctx->hw_device_ctx);
+if (!avctx->hw_frames_ctx) {
+av_log(avctx, AV_LOG_ERROR, "av_hwframe_ctx_alloc failed\n");
+ret = AVERROR(ENOMEM);
+goto error;
+}
+} else {
+av_log(avctx, AV_LOG_ERROR, "No hw frame/device available\n");
+ret = AVERROR(EINVAL);
+goto error;
+}
+}
+
+hwframe_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
+hwframe_ctx->format = AV_PIX_FMT_VPE;
+if (avctx->bits_per_raw_sample == 10) {
+hwframe_ctx->sw_format = AV_PIX_FMT_P010LE;
+} else {
+hwframe_ctx->sw_format = AV_PIX_FMT_NV12;
+}
+hwframe_ctx->width  = avctx->width;
+hwframe_ctx->height = avctx->height;
+if ((ret = av_hwfr

[FFmpeg-devel] [PATCH 1/8] avutil/hwcontext: Add VPE implementation

2020-05-27 Thread Zhang, Guiyong
VPE(Video Pipeline Engine) is VeriSilicon's hardware engine for multi
formats video encoding and decoding.

It is used with the VPE hwaccel codec API and library to initialize and
use a VPE device which is within the hwcontext libavutil framework.

These VPE codecs are used in transcoding project - multiple transcoding
boards are installed on one x86 server VIA PCIE interface to do video
transcoding job, FFmpeg will run on the x86 server to control the codes
which exist on transcoding board.

Signed-off-by: Qin.Wang 
---
 configure  |   3 +
 libavutil/Makefile |   3 +
 libavutil/hwcontext.c  |   4 +
 libavutil/hwcontext.h  |   1 +
 libavutil/hwcontext_internal.h |   1 +
 libavutil/hwcontext_vpe.c  | 402 +
 libavutil/hwcontext_vpe.h  |  52 +
 libavutil/pixdesc.c|   4 +
 libavutil/pixfmt.h |   7 +
 libavutil/version.h|   2 +-
 10 files changed, 478 insertions(+), 1 deletion(-)
 create mode 100644 libavutil/hwcontext_vpe.c
 create mode 100644 libavutil/hwcontext_vpe.h

diff --git a/configure b/configure
index f97cad0298..cf7d1d9fcc 100755
--- a/configure
+++ b/configure
@@ -322,6 +322,7 @@ External library support:
   --enable-vulkan  enable Vulkan code [no]
   --disable-xlib   disable xlib [autodetect]
   --disable-zlib   disable zlib [autodetect]
+  --enable-vpe enable vpe codec [no]
 
   The following libraries provide various hardware acceleration features:
   --disable-amfdisable AMF video encoding code [autodetect]
@@ -1822,6 +1823,7 @@ EXTERNAL_LIBRARY_LIST="
 opengl
 pocketsphinx
 vapoursynth
+vpe
 "
 
 HWACCEL_AUTODETECT_LIBRARY_LIST="
@@ -6475,6 +6477,7 @@ enabled rkmpp && { require_pkg_config rkmpp 
rockchip_mpp  rockchip/r
  die "ERROR: rkmpp requires --enable-libdrm"; }
  }
 enabled vapoursynth   && require_pkg_config vapoursynth 
"vapoursynth-script >= 42" VSScript.h vsscript_init
+enabled vpe   && require_pkg_config libvpi libvpi "vpe/vpi_types.h 
vpe/vpi_api.h" vpi_create
 
 
 if enabled gcrypt; then
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 9b08372eb2..5809b38591 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -46,6 +46,7 @@ HEADERS = adler32.h   
  \
   hwcontext_videotoolbox.h  \
   hwcontext_vdpau.h \
   hwcontext_vulkan.h\
+  hwcontext_vpe.h   \
   imgutils.h\
   intfloat.h\
   intreadwrite.h\
@@ -184,6 +185,7 @@ OBJS-$(CONFIG_VAAPI)+= hwcontext_vaapi.o
 OBJS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.o
 OBJS-$(CONFIG_VDPAU)+= hwcontext_vdpau.o
 OBJS-$(CONFIG_VULKAN)   += hwcontext_vulkan.o
+OBJS-$(CONFIG_VPE)  += hwcontext_vpe.o
 
 OBJS += $(COMPAT_OBJS:%=../compat/%)
 
@@ -201,6 +203,7 @@ SKIPHEADERS-$(CONFIG_VAAPI)+= hwcontext_vaapi.h
 SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.h
 SKIPHEADERS-$(CONFIG_VDPAU)+= hwcontext_vdpau.h
 SKIPHEADERS-$(CONFIG_VULKAN)   += hwcontext_vulkan.h
+SKIPHEADERS-$(CONFIG_VPE)  += hwcontext_vpe.h
 
 TESTPROGS = adler32 \
 aes \
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index d13d0f7c9b..5b12013286 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -61,6 +61,9 @@ static const HWContextType * const hw_table[] = {
 #endif
 #if CONFIG_VULKAN
 &ff_hwcontext_type_vulkan,
+#endif
+#if CONFIG_VPE
+&ff_hwcontext_type_vpe,
 #endif
 NULL,
 };
@@ -77,6 +80,7 @@ static const char *const hw_type_names[] = {
 [AV_HWDEVICE_TYPE_VIDEOTOOLBOX] = "videotoolbox",
 [AV_HWDEVICE_TYPE_MEDIACODEC] = "mediacodec",
 [AV_HWDEVICE_TYPE_VULKAN] = "vulkan",
+[AV_HWDEVICE_TYPE_VPE] = "vpe",
 };
 
 enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
index 04d19d89c2..62d948ec6c 100644
--- a/libavutil/hwcontext.h
+++ b/libavutil/hwcontext.h
@@ -37,6 +37,7 @@ enum AVHWDeviceType {
 AV_HWDEVICE_TYPE_OPENCL,
 AV_HWDEVICE_TYPE_MEDIACODEC,
 AV_HWDEVICE_TYPE_VULKAN,
+AV_HWDEVICE_TYPE_VPE,
 };
 
 typedef struct AVHWDeviceInternal AVHWDeviceInternal;
diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h
index e6266494ac..3190a3a80f

[FFmpeg-devel] 答复: aubmit Verisilicon VPE hardware codec implementation

2020-05-27 Thread Zhang, Guiyong
Sorry the way sent this patch is incorrect, so please stop reviewing this patch 
in this thread, I will re-submit it in another email.

-邮件原件-
发件人: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] 代表 Zhang, Guiyong
发送时间: 2020年5月28日 10:12
收件人: ffmpeg-devel@ffmpeg.org
主题: [FFmpeg-devel] aubmit Verisilicon VPE hardware codec implementation


___
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] hevc_refs: reduce code duplication in find_ref_idx()

2020-05-27 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Anton Khirnov
> Sent: Wednesday, May 27, 2020 16:48
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH] hevc_refs: reduce code duplication in
> find_ref_idx()
> 
> ---
>  libavcodec/hevc_refs.c | 22 ++
>  1 file changed, 6 insertions(+), 16 deletions(-)
> 
> diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
> index 73aa6d8caf..4f6d985ae6 100644
> --- a/libavcodec/hevc_refs.c
> +++ b/libavcodec/hevc_refs.c
> @@ -360,24 +360,14 @@ int ff_hevc_slice_rpl(HEVCContext *s)
> 
>  static HEVCFrame *find_ref_idx(HEVCContext *s, int poc, uint8_t use_msb)
>  {
> +int mask = use_msb ? ~0 : (1 << s->ps.sps->log2_max_poc_lsb) - 1;
>  int i;
> 
> -if (use_msb) {
> -for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
> -HEVCFrame *ref = &s->DPB[i];
> -if (ref->frame->buf[0] && (ref->sequence == s->seq_decode)) {
> -if (ref->poc == poc)
> -return ref;
> -}
> -}
> -} else {
> -int LtMask = (1 << s->ps.sps->log2_max_poc_lsb) - 1;
> -for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
> -HEVCFrame *ref = &s->DPB[i];
> -if (ref->frame->buf[0] && ref->sequence == s->seq_decode) {
> -if ((ref->poc & LtMask) == poc)
> -return ref;
> -}
> +for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
> +HEVCFrame *ref = &s->DPB[i];
> +if (ref->frame->buf[0] && ref->sequence == s->seq_decode) {
> +if ((ref->poc & mask) == poc)
> +return ref;
>  }
>  }
> 
> --
Thanks for the refine, it's more precise now, lgtm.

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

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

[FFmpeg-devel] 答复: 答复: 答复: aubmit Verisilicon VPE hardware codec implementation

2020-05-27 Thread Zhang, Guiyong
They specifically focused on transcoding only:)

-邮件原件-
发件人: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] 代表 Soft Works
发送时间: 2020年5月28日 11:04
收件人: FFmpeg development discussions and patches
主题: Re: [FFmpeg-devel] 答复: 答复: aubmit Verisilicon VPE hardware codec 
implementation



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Zhang, Guiyong
> Sent: Thursday, May 28, 2020 4:58 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: [FFmpeg-devel] 答复: 答复: aubmit Verisilicon VPE hardware codec
> implementation
> 
> Hi softworkz,
> 
> Currently no- but similar module maybe possible in further.
> 

Last question... :-)

Are those boards more like 3D GPU boards as we know from Nvidia
or AMD or are they specifically focused on transcoding?

Thanks again,
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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/2] dnn-layer-mathunary-test: add unit test for abs

2020-05-27 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Ting Fu
> Sent: 2020年5月25日 22:46
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 2/2] dnn-layer-mathunary-test: add unit test 
> for
> abs
> 
> Signed-off-by: Ting Fu 
> ---
>  tests/dnn/.gitignore |  1 +
>  tests/dnn/Makefile   |  1 +
>  tests/dnn/dnn-layer-mathunary-test.c | 81 
>  tests/fate/dnn.mak   |  5 ++
>  4 files changed, 88 insertions(+)
>  create mode 100644 tests/dnn/dnn-layer-mathunary-test.c
> 

Thanks, LGTM, will push soon.
___
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] 答复: 答复: aubmit Verisilicon VPE hardware codec implementation

2020-05-27 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Zhang, Guiyong
> Sent: Thursday, May 28, 2020 4:58 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: [FFmpeg-devel] 答复: 答复: aubmit Verisilicon VPE hardware codec
> implementation
> 
> Hi softworkz,
> 
> Currently no- but similar module maybe possible in further.
> 

Last question... :-)

Are those boards more like 3D GPU boards as we know from Nvidia
or AMD or are they specifically focused on transcoding?

Thanks again,
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] 答复: 答复: aubmit Verisilicon VPE hardware codec implementation

2020-05-27 Thread Zhang, Guiyong
Hi softworkz,

Currently no- but similar module maybe possible in further.

Thanks,
GY

-邮件原件-
发件人: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] 代表 Soft Works
发送时间: 2020年5月28日 10:47
收件人: FFmpeg development discussions and patches
主题: Re: [FFmpeg-devel] 答复: aubmit Verisilicon VPE hardware codec implementation



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Zhang, Guiyong
> Sent: Thursday, May 28, 2020 4:38 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: [FFmpeg-devel] 答复: aubmit Verisilicon VPE hardware codec
> implementation
> 
> Hi softworkz,
> 
> This serial patches are Verislicon Hantro hardware codecs which include
> decoder/encoder/transcoding/post processing functions.
> 
> It's used in Facebook transcoding project - multiple transcoding boards
> installed on a x86 server VIA PCIE interface to do video transcoding job.
> FFmpeg will run on the x86 server to control the codes which exist on
> transcoding board.

Hi Guiyong,

that's interesting. I suppose, those "transcoding boards" are not available
for regular purchase - I mean like an off-the-shelf product?

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 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] aubmit Verisilicon VPE hardware codec implementation

2020-05-27 Thread Fu, Linjie
Squash new pixel format into the ENUM structure would lead to an ABI break.
Would be better to append at the end. (Before AV_PIX_FMT_NB)

-Linjie

From: ffmpeg-devel  On Behalf Of Zhang, Guiyong
Sent: Thursday, May 28, 2020 10:12
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] aubmit Verisilicon VPE hardware codec implementation
___
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] 答复: aubmit Verisilicon VPE hardware codec implementation

2020-05-27 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Zhang, Guiyong
> Sent: Thursday, May 28, 2020 4:38 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: [FFmpeg-devel] 答复: aubmit Verisilicon VPE hardware codec
> implementation
> 
> Hi softworkz,
> 
> This serial patches are Verislicon Hantro hardware codecs which include
> decoder/encoder/transcoding/post processing functions.
> 
> It's used in Facebook transcoding project - multiple transcoding boards
> installed on a x86 server VIA PCIE interface to do video transcoding job.
> FFmpeg will run on the x86 server to control the codes which exist on
> transcoding board.

Hi Guiyong,

that's interesting. I suppose, those "transcoding boards" are not available
for regular purchase - I mean like an off-the-shelf product?

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] 答复: aubmit Verisilicon VPE hardware codec implementation

2020-05-27 Thread Zhang, Guiyong
Hi softworkz,

Yes you are right, the FFmpeg VPE codecs work together with VPI:
https://github.com/VeriSilicon/VPI

VPI includes source code(vpi/src) and some so library(sdk_libs).

Thanks,
GY

-邮件原件-
发件人: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] 代表 myp...@gmail.com
发送时间: 2020年5月28日 10:32
收件人: FFmpeg development discussions and patches
主题: Re: [FFmpeg-devel] aubmit Verisilicon VPE hardware codec implementation

On Thu, May 28, 2020 at 10:22 AM Soft Works  wrote:
>
>
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Zhang, Guiyong
> > Sent: Thursday, May 28, 2020 4:12 AM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: [FFmpeg-devel] aubmit Verisilicon VPE hardware codec
> > implementation
> >
>
> Hello Guiyong,
>
> I'm curious - which actual products does that support and on which
> operating systems?
>
I guess it is based on https://github.com/VeriSilicon/VPI, but I just
find some so library

> Best 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 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/2] avformat/url: check return value of strchr

2020-05-27 Thread Steven Liu
fix ticket: 8687
workflow should return if there have no value of strchr

Signed-off-by: Steven Liu 
---
 libavformat/url.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/url.c b/libavformat/url.c
index 6956f6dc10..20463a6674 100644
--- a/libavformat/url.c
+++ b/libavformat/url.c
@@ -90,6 +90,8 @@ static void trim_double_dot_url(char *buf, const char *rel, 
int size)
 if (p && (sep = strstr(p, "://"))) {
 sep += 3;
 root = strchr(sep, '/');
+if (!root)
+return;
 }
 
 /* set new current position if the root node is changed */
@@ -150,6 +152,7 @@ void ff_make_absolute_url(char *buf, int size, const char 
*base,
 }
 /* If rel actually is an absolute url, just copy it */
 if (!base || strstr(rel, "://") || rel[0] == '/') {
+memset(buf, 0, size);
 trim_double_dot_url(buf, rel, size);
 return;
 }
@@ -177,6 +180,8 @@ void ff_make_absolute_url(char *buf, int size, const char 
*base,
 if (sep) {
 sep += 3;
 root = strchr(sep, '/');
+if (!root)
+return;
 }
 }
 
-- 
2.25.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 2/2] avformat/hls: check output string is usable of ff_make_absolute_url

2020-05-27 Thread Steven Liu
fix ticket: 8688
should goto failed workflow if cannot get usable string by ff_make_absolute_url

Signed-off-by: Steven Liu 
---
 libavformat/hls.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3e35d157ad..a9592dea5e 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -311,6 +311,8 @@ static struct playlist *new_playlist(HLSContext *c, const 
char *url,
 return NULL;
 reset_packet(&pls->pkt);
 ff_make_absolute_url(pls->url, sizeof(pls->url), base, url);
+if (!pls->url[0])
+return NULL;
 pls->seek_timestamp = AV_NOPTS_VALUE;
 
 pls->is_id3_timestamped = -1;
@@ -416,6 +418,10 @@ static struct segment *new_init_section(struct playlist 
*pls,
 ptr = info->uri;
 } else {
 ff_make_absolute_url(tmp_str, sizeof(tmp_str), url_base, info->uri);
+if (!tmp_str[0]) {
+av_free(sec);
+return NULL;
+}
 }
 sec->url = av_strdup(ptr);
 if (!sec->url) {
@@ -841,6 +847,11 @@ static int parse_playlist(HLSContext *c, const char *url,
 
 if (key_type != KEY_NONE) {
 ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key);
+if (!tmp_str[0]) {
+av_free(cur_init_section);
+ret = AVERROR_INVALIDDATA;
+goto fail;
+}
 cur_init_section->key = av_strdup(tmp_str);
 if (!cur_init_section->key) {
 av_free(cur_init_section);
@@ -895,6 +906,11 @@ static int parse_playlist(HLSContext *c, const char *url,
 
 if (key_type != KEY_NONE) {
 ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key);
+if (!tmp_str[0]) {
+ret = AVERROR_INVALIDDATA;
+av_free(seg);
+goto fail;
+}
 seg->key = av_strdup(tmp_str);
 if (!seg->key) {
 av_free(seg);
@@ -906,6 +922,13 @@ static int parse_playlist(HLSContext *c, const char *url,
 }
 
 ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, line);
+if (!tmp_str[0]) {
+ret = AVERROR_INVALIDDATA;
+if (seg->key)
+av_free(seg->key);
+av_free(seg);
+goto fail;
+}
 seg->url = av_strdup(tmp_str);
 if (!seg->url) {
 av_free(seg->key);
-- 
2.25.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] aubmit Verisilicon VPE hardware codec implementation

2020-05-27 Thread myp...@gmail.com
On Thu, May 28, 2020 at 10:22 AM Soft Works  wrote:
>
>
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Zhang, Guiyong
> > Sent: Thursday, May 28, 2020 4:12 AM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: [FFmpeg-devel] aubmit Verisilicon VPE hardware codec
> > implementation
> >
>
> Hello Guiyong,
>
> I'm curious - which actual products does that support and on which
> operating systems?
>
I guess it is based on https://github.com/VeriSilicon/VPI, but I just
find some so library

> Best 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] 答复: aubmit Verisilicon VPE hardware codec implementation

2020-05-27 Thread Zhang, Guiyong
Hi softworkz,

This serial patches are Verislicon Hantro hardware codecs which include 
decoder/encoder/transcoding/post processing functions.

It's used in Facebook transcoding project - multiple transcoding boards 
installed on a x86 server VIA PCIE interface to do video transcoding job. 
FFmpeg will run on the x86 server to control the codes which exist on 
transcoding board.

Thanks,
GY

-邮件原件-
发件人: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] 代表 Soft Works
发送时间: 2020年5月28日 10:22
收件人: FFmpeg development discussions and patches
主题: Re: [FFmpeg-devel] aubmit Verisilicon VPE hardware codec implementation


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Zhang, Guiyong
> Sent: Thursday, May 28, 2020 4:12 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] aubmit Verisilicon VPE hardware codec
> implementation
> 

Hello Guiyong,

I'm curious - which actual products does that support and on which 
operating systems?

Best 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 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] aubmit Verisilicon VPE hardware codec implementation

2020-05-27 Thread Soft Works

> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Zhang, Guiyong
> Sent: Thursday, May 28, 2020 4:12 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] aubmit Verisilicon VPE hardware codec
> implementation
> 

Hello Guiyong,

I'm curious - which actual products does that support and on which 
operating systems?

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

Re: [FFmpeg-devel] suspicious unconditional `goto fail` in decode.c:1892

2020-05-27 Thread James Almer
On 5/27/2020 3:55 PM, Pavel Koshevoy wrote:
> Hi,
> 
> I've run into a regression that I've tracked down to this snippet of
> code in libavcodec/decode.c
> ```
> if (hwaccel) {
> if (hwaccel->alloc_frame) {
> ret = hwaccel->alloc_frame(avctx, frame);
> goto fail;
> }
> } else
> avctx->sw_pix_fmt = avctx->pix_fmt;
> ```
> 
> The `goto fail` is unconditional, and was introduced in commit a1133db30ef
> I'd like to confirm whether it is intentional.
> 
> Thank you,
> Pavel.

Should be fixed in b6d6597bef.
___
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] aubmit Verisilicon VPE hardware codec implementation - hw spliter

2020-05-27 Thread Zhang, Guiyong



0007-avfilter-spliter-Add-VPE-spliter-filter.patch
Description: 0007-avfilter-spliter-Add-VPE-spliter-filter.patch
___
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] aubmit Verisilicon VPE hardware codec implementation - hw pp

2020-05-27 Thread Zhang, Guiyong



0008-vfilter-pp-Add-VPE-post-processing-filter.patch
Description: 0008-vfilter-pp-Add-VPE-post-processing-filter.patch
___
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] aubmit Verisilicon VPE hardware codec implementation - vp9dec

2020-05-27 Thread Zhang, Guiyong



0004-avcodec-vp9dec-Add-vp9-VPE-HW-decoder.patch
Description: 0004-avcodec-vp9dec-Add-vp9-VPE-HW-decoder.patch
___
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] aubmit Verisilicon VPE hardware codec implementation - vp9enc

2020-05-27 Thread Zhang, Guiyong



0006-vcodec-vp9enc-Add-VP9-VPE-HW-encoder.patch
Description: 0006-vcodec-vp9enc-Add-VP9-VPE-HW-encoder.patch
___
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] aubmit Verisilicon VPE hardware codec implementation - hevcdec

2020-05-27 Thread Zhang, Guiyong



0003-avcodec-hevcdec-Add-hevc-VPE-HW-decoder.patch
Description: 0003-avcodec-hevcdec-Add-hevc-VPE-HW-decoder.patch
___
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] aubmit Verisilicon VPE hardware codec implementation - h264enc

2020-05-27 Thread Zhang, Guiyong



0005-avcodec-h26xenc-Add-h264-hevc-VPE-HW-encoder.patch
Description: 0005-avcodec-h26xenc-Add-h264-hevc-VPE-HW-encoder.patch
___
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] aubmit Verisilicon VPE hardware codec implementation

2020-05-27 Thread Zhang, Guiyong



0001-avutil-hwcontext-Add-VPE-implementation.patch
Description: 0001-avutil-hwcontext-Add-VPE-implementation.patch
___
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] aubmit Verisilicon VPE hardware codec implementation - h264dec

2020-05-27 Thread Zhang, Guiyong



0002-avcodec-h264dec-Add-h264-VPE-HW-decoder.patch
Description: 0002-avcodec-h264dec-Add-h264-VPE-HW-decoder.patch
___
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/4] avcodec/adpcmenc: add capabilities argument to ADPCM_ENCODER()

2020-05-27 Thread Zane van Iperen
On Wed, 27 May 2020 22:11:41 +0200
"Michael Niedermayer"  wrote:

> 
> will apply
> 
> thx
> 
Thanks! Could you please also apply part 4 (the muxer)? The encoder's
useless without it.

Zane

___
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] doc: add dia_size option documentation

2020-05-27 Thread lance . lmwang
On Wed, May 27, 2020 at 09:37:00PM +0200, Michael Niedermayer wrote:
> On Wed, May 27, 2020 at 12:20:39PM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  doc/codecs.texi | 18 ++
> >  1 file changed, 18 insertions(+)
> 
> probably correct

will apply.

> 
> thx
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Whats the most studid thing your enemy could do ? Blow himself up
> Whats the most studid thing you could do ? Give up your rights and
> freedom because your enemy blew himself up.
> 



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


-- 
Thanks,
Limin Wang
___
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] avformat/ogg: Add partial support for OggPCM demuxing

2020-05-27 Thread A G
This adds partial support for OggPCM muxing.

It is effectively just an updated version of this:
https://ffmpeg.org/pipermail/ffmpeg-devel/2013-July/145556.html
---
 libavformat/Makefile  |   1 +
 libavformat/oggdec.c  |   1 +
 libavformat/oggdec.h  |   1 +
 libavformat/oggparsepcm.c | 123 ++
 4 files changed, 126 insertions(+)
 create mode 100644 libavformat/oggparsepcm.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index efe82f9f08..145407bb40 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -364,6 +364,7 @@ OBJS-$(CONFIG_OGG_DEMUXER)   += oggdec.o
 \
 oggparseflac.o   \
 oggparseogm.o\
 oggparseopus.o   \
+oggparsepcm.o\
 oggparseskeleton.o \
 oggparsespeex.o  \
 oggparsetheora.o \
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 1a3acbb55e..6a95485680 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -49,6 +49,7 @@ static const struct ogg_codec * const ogg_codecs[] = {
 &ff_flac_codec,
 &ff_celt_codec,
 &ff_opus_codec,
+&ff_pcm_codec,
 &ff_vp8_codec,
 &ff_old_dirac_codec,
 &ff_old_flac_codec,
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index 629a1d6262..ae001b4ded 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -124,6 +124,7 @@ extern const struct ogg_codec ff_ogm_video_codec;
 extern const struct ogg_codec ff_old_dirac_codec;
 extern const struct ogg_codec ff_old_flac_codec;
 extern const struct ogg_codec ff_opus_codec;
+extern const struct ogg_codec ff_pcm_codec;
 extern const struct ogg_codec ff_skeleton_codec;
 extern const struct ogg_codec ff_speex_codec;
 extern const struct ogg_codec ff_theora_codec;
diff --git a/libavformat/oggparsepcm.c b/libavformat/oggparsepcm.c
new file mode 100644
index 00..3a1470ac99
--- /dev/null
+++ b/libavformat/oggparsepcm.c
@@ -0,0 +1,123 @@
+/*
+ * PCM parser for Ogg
+ * Copyright (c) 2013 James Almer
+ *
+ * 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 "libavutil/intreadwrite.h"
+#include "avformat.h"
+#include "internal.h"
+#include "oggdec.h"
+
+struct oggpcm_private {
+int vorbis_comment;
+uint32_t extra_headers;
+};
+
+static const struct ogg_pcm_codec {
+uint32_t codec_id;
+uint32_t format_id;
+} ogg_pcm_codecs[] = {
+{ AV_CODEC_ID_PCM_S8,0x00 },
+{ AV_CODEC_ID_PCM_U8,0x01 },
+{ AV_CODEC_ID_PCM_S16LE, 0x02 },
+{ AV_CODEC_ID_PCM_S16BE, 0x03 },
+{ AV_CODEC_ID_PCM_S24LE, 0x04 },
+{ AV_CODEC_ID_PCM_S24BE, 0x05 },
+{ AV_CODEC_ID_PCM_S32LE, 0x06 },
+{ AV_CODEC_ID_PCM_S32BE, 0x07 },
+{ AV_CODEC_ID_PCM_F32LE, 0x20 },
+{ AV_CODEC_ID_PCM_F32BE, 0x21 },
+{ AV_CODEC_ID_PCM_F64LE, 0x22 },
+{ AV_CODEC_ID_PCM_F64BE, 0x23 },
+};
+
+static const struct ogg_pcm_codec *ogg_get_pcm_codec_id(uint32_t format_id)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(ogg_pcm_codecs); i++)
+if (ogg_pcm_codecs[i].format_id == format_id)
+return &ogg_pcm_codecs[i];
+
+return NULL;
+}
+
+static int pcm_header(AVFormatContext *as, int idx)
+{
+struct ogg *ogg = as->priv_data;
+struct ogg_stream *os = ogg->streams + idx;
+struct oggpcm_private *priv = os->private;
+const struct ogg_pcm_codec *pcm;
+AVStream *st = as->streams[idx];
+uint8_t *p = os->buf + os->pstart;
+uint16_t major, minor;
+uint32_t format_id;
+
+if (!priv) {
+priv = os->private = av_mallocz(sizeof(*priv));
+if (!priv)
+return AVERROR(ENOMEM);
+}
+
+if (os->flags & OGG_FLAG_BOS) {
+if (os->psize < 28) {
+av_log(as, AV_LOG_ERROR, "Invalid OggPCM header packet");
+return AVERROR_INVALIDDATA;
+}
+
+major = AV_RB16(p + 8);
+minor = AV_RB16(p + 10);
+if (major) {
+av_log(as, AV_LOG_ERROR, "Unsupported OggPCM version %u.%u\n", 
major, minor);
+return AVERROR_

[FFmpeg-devel] [PATCH] avformat/oggenc: Add partial support for OggPCM muxing

2020-05-27 Thread A G
From 81cf2038424e483e60ed9747f965ec452d357773 Mon Sep 17 00:00:00 2001
From: oreo639 <31916379+oreo...@users.noreply.github.com>
Date: Wed, 27 May 2020 17:18:03 -0700
Subject: [PATCH] avformat/oggenc: Add partial support for OggPCM muxing

This adds partial support for OggPCM demuxing.
Heavily based on the work here:
https://ffmpeg.org/pipermail/ffmpeg-devel/2013-July/145556.html
and here:
http://www.on2.com/media/gpl/mplayer/

---
 libavformat/oggenc.c | 85 
 1 file changed, 79 insertions(+), 6 deletions(-)

diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index f5032759a6..5f03b4d9b7 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -99,6 +99,36 @@ static const AVClass flavor ## _muxer_class = {\
 .version= LIBAVUTIL_VERSION_INT,\
 };

+
+static const struct ogg_pcm_codec {
+uint32_t codec_id;
+uint32_t format_id;
+} ogg_pcm_codecs[] = {
+{ AV_CODEC_ID_PCM_S8,0x00 },
+{ AV_CODEC_ID_PCM_U8,0x01 },
+{ AV_CODEC_ID_PCM_S16LE, 0x02 },
+{ AV_CODEC_ID_PCM_S16BE, 0x03 },
+{ AV_CODEC_ID_PCM_S24LE, 0x04 },
+{ AV_CODEC_ID_PCM_S24BE, 0x05 },
+{ AV_CODEC_ID_PCM_S32LE, 0x06 },
+{ AV_CODEC_ID_PCM_S32BE, 0x07 },
+{ AV_CODEC_ID_PCM_F32LE, 0x20 },
+{ AV_CODEC_ID_PCM_F32BE, 0x21 },
+{ AV_CODEC_ID_PCM_F64LE, 0x22 },
+{ AV_CODEC_ID_PCM_F64BE, 0x23 },
+};
+
+static inline uint32_t ogg_get_pcm_format_id(uint32_t codec_id)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(ogg_pcm_codecs); i++)
+if (ogg_pcm_codecs[i].codec_id == codec_id)
+return ogg_pcm_codecs[i].format_id;
+
+return 0;
+}
+
 static void ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
 {
 OGGStreamContext *oggstream = s->streams[page->stream_index]->priv_data;
@@ -363,6 +393,39 @@ static int ogg_build_speex_headers(AVCodecParameters *par,
 return 0;
 }

+#define OGGPCM_HEADER_SIZE 224
+
+static int ogg_build_pcm_headers(AVCodecParameters *par,
+   OGGStreamContext *oggstream, int bitexact,
+   AVDictionary **m)
+{
+uint8_t *p;
+
+// first packet: OggPCM header
+p = av_mallocz(OGGPCM_HEADER_SIZE);
+if (!p)
+return AVERROR(ENOMEM);
+oggstream->header[0] = p;
+oggstream->header_len[0] = OGGPCM_HEADER_SIZE;
+bytestream_put_buffer(&p, "PCM ", 8); // Identifier
+bytestream_put_be16(&p, 0x00); // VMAJ
+bytestream_put_be16(&p, 0x00); // VMIN
+bytestream_put_be32(&p, ogg_get_pcm_format_id(par->codec_id)); // PCM fmt
+bytestream_put_be32(&p, par->sample_rate); // Sample rate
+bytestream_put_byte(&p, 0); // Significant bits (0 == Same as fmt)
+bytestream_put_byte(&p, par->channels); // Channels
+bytestream_put_be16(&p, 0); // Max frames per packet TODO:// Actually 
calculate max frames per packet
+bytestream_put_be32(&p, 0); // Number of extra headers
+
+// second packet: VorbisComment
+p = ogg_write_vorbiscomment(0, bitexact, &oggstream->header_len[1], m, 0, 
NULL, 0);
+if (!p)
+return AVERROR(ENOMEM);
+oggstream->header[1] = p;
+
+return 0;
+}
+
 #define OPUS_HEADER_SIZE 19

 static int ogg_build_opus_headers(AVCodecParameters *par,
@@ -487,18 +550,20 @@ static int ogg_init(AVFormatContext *s)
 avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
 }

-if (st->codecpar->codec_id != AV_CODEC_ID_VORBIS &&
-st->codecpar->codec_id != AV_CODEC_ID_THEORA &&
-st->codecpar->codec_id != AV_CODEC_ID_SPEEX  &&
-st->codecpar->codec_id != AV_CODEC_ID_FLAC   &&
-st->codecpar->codec_id != AV_CODEC_ID_OPUS   &&
+if (st->codecpar->codec_id != AV_CODEC_ID_VORBIS   &&
+st->codecpar->codec_id != AV_CODEC_ID_THEORA   &&
+st->codecpar->codec_id != AV_CODEC_ID_SPEEX&&
+st->codecpar->codec_id != AV_CODEC_ID_FLAC &&
+st->codecpar->codec_id != AV_CODEC_ID_OPUS &&
+!ogg_get_pcm_format_id(st->codecpar->codec_id) &&
 st->codecpar->codec_id != AV_CODEC_ID_VP8) {
 av_log(s, AV_LOG_ERROR, "Unsupported codec id in stream %d\n", i);
 return AVERROR(EINVAL);
 }

 if ((!st->codecpar->extradata || !st->codecpar->extradata_size) &&
-st->codecpar->codec_id != AV_CODEC_ID_VP8) {
+st->codecpar->codec_id != AV_CODEC_ID_VP8  &&
+!ogg_get_pcm_format_id(st->codecpar->codec_id)) {
 av_log(s, AV_LOG_ERROR, "No extradata present\n");
 return AVERROR_INVALIDDATA;
 }
@@ -553,6 +618,14 @@ static int ogg_init(AVFormatContext *s)
 av_log(s, AV_LOG_ERROR, "Error writing VP8 headers\n");
 return err;
 }
+} else if (ogg_get_pcm_format_id(st->codecpar->codec_id)) {
+int err = ogg_build_pcm_headers(st->codecpar, oggstream,
+   

Re: [FFmpeg-devel] [PATCH] avformat/ogg: Add partial support for demuxing

2020-05-27 Thread A G

> this time you didn't even include the relevant disclaimer.

That was a mistake, sorry.


___
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/ogg: Add partial support for demuxing

2020-05-27 Thread James Almer
On 5/27/2020 9:10 PM, A G wrote:
> From dad3ee4f5e396bf90d4cd43562e238920ad84f02 Mon Sep 17 00:00:00 2001
> From: oreo639 <31916379+oreo...@users.noreply.github.com>
> Date: Wed, 27 May 2020 16:54:19 -0700
> Subject: [PATCH] avformat/ogg: Add partial support for demuxing

This patch is barely different than the one you based it on that i wrote
long ago, and unlike in the first version you sent earlier today, this
time you didn't even include the relevant disclaimer.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] avformat/ogg: Add partial support for demuxing

2020-05-27 Thread A G
From dad3ee4f5e396bf90d4cd43562e238920ad84f02 Mon Sep 17 00:00:00 2001
From: oreo639 <31916379+oreo...@users.noreply.github.com>
Date: Wed, 27 May 2020 16:54:19 -0700
Subject: [PATCH] avformat/ogg: Add partial support for demuxing

---
 libavformat/Makefile  |   1 +
 libavformat/oggdec.c  |   1 +
 libavformat/oggdec.h  |   1 +
 libavformat/oggparsepcm.c | 123 ++
 4 files changed, 126 insertions(+)
 create mode 100644 libavformat/oggparsepcm.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index efe82f9f08..145407bb40 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -364,6 +364,7 @@ OBJS-$(CONFIG_OGG_DEMUXER)   += oggdec.o
 \
 oggparseflac.o   \
 oggparseogm.o\
 oggparseopus.o   \
+oggparsepcm.o\
 oggparseskeleton.o \
 oggparsespeex.o  \
 oggparsetheora.o \
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 1a3acbb55e..6a95485680 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -49,6 +49,7 @@ static const struct ogg_codec * const ogg_codecs[] = {
 &ff_flac_codec,
 &ff_celt_codec,
 &ff_opus_codec,
+&ff_pcm_codec,
 &ff_vp8_codec,
 &ff_old_dirac_codec,
 &ff_old_flac_codec,
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index 629a1d6262..ae001b4ded 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -124,6 +124,7 @@ extern const struct ogg_codec ff_ogm_video_codec;
 extern const struct ogg_codec ff_old_dirac_codec;
 extern const struct ogg_codec ff_old_flac_codec;
 extern const struct ogg_codec ff_opus_codec;
+extern const struct ogg_codec ff_pcm_codec;
 extern const struct ogg_codec ff_skeleton_codec;
 extern const struct ogg_codec ff_speex_codec;
 extern const struct ogg_codec ff_theora_codec;
diff --git a/libavformat/oggparsepcm.c b/libavformat/oggparsepcm.c
new file mode 100644
index 00..3a1470ac99
--- /dev/null
+++ b/libavformat/oggparsepcm.c
@@ -0,0 +1,123 @@
+/*
+ * PCM parser for Ogg
+ * Copyright (c) 2013 James Almer
+ *
+ * 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 "libavutil/intreadwrite.h"
+#include "avformat.h"
+#include "internal.h"
+#include "oggdec.h"
+
+struct oggpcm_private {
+int vorbis_comment;
+uint32_t extra_headers;
+};
+
+static const struct ogg_pcm_codec {
+uint32_t codec_id;
+uint32_t format_id;
+} ogg_pcm_codecs[] = {
+{ AV_CODEC_ID_PCM_S8,0x00 },
+{ AV_CODEC_ID_PCM_U8,0x01 },
+{ AV_CODEC_ID_PCM_S16LE, 0x02 },
+{ AV_CODEC_ID_PCM_S16BE, 0x03 },
+{ AV_CODEC_ID_PCM_S24LE, 0x04 },
+{ AV_CODEC_ID_PCM_S24BE, 0x05 },
+{ AV_CODEC_ID_PCM_S32LE, 0x06 },
+{ AV_CODEC_ID_PCM_S32BE, 0x07 },
+{ AV_CODEC_ID_PCM_F32LE, 0x20 },
+{ AV_CODEC_ID_PCM_F32BE, 0x21 },
+{ AV_CODEC_ID_PCM_F64LE, 0x22 },
+{ AV_CODEC_ID_PCM_F64BE, 0x23 },
+};
+
+static const struct ogg_pcm_codec *ogg_get_pcm_codec_id(uint32_t format_id)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(ogg_pcm_codecs); i++)
+if (ogg_pcm_codecs[i].format_id == format_id)
+return &ogg_pcm_codecs[i];
+
+return NULL;
+}
+
+static int pcm_header(AVFormatContext *as, int idx)
+{
+struct ogg *ogg = as->priv_data;
+struct ogg_stream *os = ogg->streams + idx;
+struct oggpcm_private *priv = os->private;
+const struct ogg_pcm_codec *pcm;
+AVStream *st = as->streams[idx];
+uint8_t *p = os->buf + os->pstart;
+uint16_t major, minor;
+uint32_t format_id;
+
+if (!priv) {
+priv = os->private = av_mallocz(sizeof(*priv));
+if (!priv)
+return AVERROR(ENOMEM);
+}
+
+if (os->flags & OGG_FLAG_BOS) {
+if (os->psize < 28) {
+av_log(as, AV_LOG_ERROR, "Invalid OggPCM header packet");
+return AVERROR_INVALIDDATA;
+}
+
+major = AV_RB16(p + 8);
+minor = AV_RB16(p + 10);
+if (major) {
+av_log(as, AV_LOG_ERROR, "Unsupporte

Re: [FFmpeg-devel] [PATCH 2/4] tools/target_dec_fuzzer: Do not test AV_CODEC_FLAG2_FAST with AV_CODEC_ID_H264

2020-05-27 Thread Kieran Kunhya
On Wed, 27 May 2020 at 22:53, Michael Niedermayer 
wrote:

> On Sun, Mar 15, 2020 at 10:20:56PM +0100, Michael Niedermayer wrote:
> > This combination skips allocating large padding which can read out of
> array
> >
> > Fixes:
> 20978/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5746381832847360
> >
> > Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  tools/target_dec_fuzzer.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
>
> will apply
>

Shouldn't there be warnings about FAST mode if it causes security issues?

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

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

Re: [FFmpeg-devel] [PATCH 2/2] tools/target_dec_fuzzer: Reduce maxpixels for HEVC

2020-05-27 Thread Michael Niedermayer
On Mon, Apr 20, 2020 at 12:21:22AM +0200, Michael Niedermayer wrote:
> high resolutions with only small blocks appear to be rather
> slow with the fuzzer + sanitizers.
> A solution which makes this run faster is welcome.
> 
> Fixes: Timeout (did not wait -> 17sec)
> Fixes: 
> 21006/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-6002552539971584
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  tools/target_dec_fuzzer.c | 1 +
>  1 file changed, 1 insertion(+)

will apply

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

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin


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] tools/target_dec_fuzzer: Adjust max_pixels for AV_CODEC_ID_HAP

2020-05-27 Thread Michael Niedermayer
On Sun, Mar 15, 2020 at 10:20:58PM +0100, Michael Niedermayer wrote:
> Fixes: Timeout (170sec -> 6sec)
> Fixes: 
> 20956/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5713643025203200
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  tools/target_dec_fuzzer.c | 1 +
>  1 file changed, 1 insertion(+)

will apply

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

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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] tools/target_dec_fuzzer: Do not test AV_CODEC_FLAG2_FAST with AV_CODEC_ID_H264

2020-05-27 Thread Michael Niedermayer
On Sun, Mar 15, 2020 at 10:20:56PM +0100, Michael Niedermayer wrote:
> This combination skips allocating large padding which can read out of array
> 
> Fixes: 
> 20978/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5746381832847360
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  tools/target_dec_fuzzer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

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

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates


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/mpegts: use get_packet_size in mpegts_resync for determining raw_packet_size

2020-05-27 Thread Marton Balint



On Wed, 27 May 2020, lance.lmw...@gmail.com wrote:


On Wed, May 27, 2020 at 08:47:54AM +0200, Marton Balint wrote:



On Wed, 27 May 2020, lance.lmw...@gmail.com wrote:

> On Tue, May 26, 2020 at 09:52:45PM +0200, Marton Balint wrote:
> > 
> > 
> > On Wed, 20 May 2020, Marton Balint wrote:
> > 
> > > The old resync logic had some bugs, for example the packet size could stuck

> > > into 192 bytes, because pos47_full was not updated for every packet, and 
for
> > > unseekable inputs the resync logic simply skipped some 0x47 sync bytes,
> > > therefore the calculated distance between sync bytes was a multiple of 188
> > > bytes.
> > > > AVIO only buffers a single packet (for UDP/mpegts, that usually
> > means 1316
> > > bytes), so for every ten consecutive 188-byte MPEGTS packets there was 
always a
> > > seek failure, and that caused the old code to not find the 188 byte 
pattern
> > > across 10 consecutive packets.
> > > > This patch changes the custom logic to the one which is used
> > when probing to
> > > determine the packet size. This was already proposed as a FIXME for a long
> > > time...
> > 
> > Ping, will apply soon.
> > 
> > Regards,

> > Marton
> > 
> > > ---

> > > libavformat/mpegts.c | 51 ++--
> > > 1 file changed, 11 insertions(+), 40 deletions(-)
> > > > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> > > index a065c61c40..c6fd3e1cef 100644
> > > --- a/libavformat/mpegts.c
> > > +++ b/libavformat/mpegts.c
> > > @@ -123,10 +123,6 @@ struct MpegTSContext {
> > > /** raw packet size, including FEC if present */
> > > int raw_packet_size;
> > > > -int size_stat[3];
> > > -int size_stat_count;
> > > -#define SIZE_STAT_THRESHOLD 10
> > > -
> > > int64_t pos47_full;
> > > > /** if true, all pids are analyzed to find streams */
> > > @@ -2840,41 +2836,6 @@ static int handle_packet(MpegTSContext *ts, const 
uint8_t *packet, int64_t pos)
> > > return 0;
> > > }
> > > > -static void reanalyze(MpegTSContext *ts) {
> > > -AVIOContext *pb = ts->stream->pb;
> > > -int64_t pos = avio_tell(pb);
> > > -if (pos < 0)
> > > -return;
> > > -pos -= ts->pos47_full;
> > > -if (pos == TS_PACKET_SIZE) {
> > > -ts->size_stat[0] ++;
> > > -} else if (pos == TS_DVHS_PACKET_SIZE) {
> > > -ts->size_stat[1] ++;
> > > -} else if (pos == TS_FEC_PACKET_SIZE) {
> > > -ts->size_stat[2] ++;
> > > -}
> > > -
> > > -ts->size_stat_count ++;
> > > -if (ts->size_stat_count > SIZE_STAT_THRESHOLD) {
> > > -int newsize = 0;
> > > -if (ts->size_stat[0] > SIZE_STAT_THRESHOLD) {
> > > -newsize = TS_PACKET_SIZE;
> > > -} else if (ts->size_stat[1] > SIZE_STAT_THRESHOLD) {
> > > -newsize = TS_DVHS_PACKET_SIZE;
> > > -} else if (ts->size_stat[2] > SIZE_STAT_THRESHOLD) {
> > > -newsize = TS_FEC_PACKET_SIZE;
> > > -}
> > > -if (newsize && newsize != ts->raw_packet_size) {
> > > -av_log(ts->stream, AV_LOG_WARNING, "changing packet size to 
%d\n", newsize);
> > > -ts->raw_packet_size = newsize;
> > > -}
> > > -ts->size_stat_count = 0;
> > > -memset(ts->size_stat, 0, sizeof(ts->size_stat));
> > > -}
> > > -}
> > > -
> > > -/* XXX: try to find a better synchro over several packets (use
> > > - * get_packet_size() ?) */
> > > static int mpegts_resync(AVFormatContext *s, int seekback, const uint8_t 
*current_packet)
> > > {
> > > MpegTSContext *ts = s->priv_data;
> > > @@ -2896,8 +2857,18 @@ static int mpegts_resync(AVFormatContext *s, int 
seekback, const uint8_t *curren
> > > if (avio_feof(pb))
> > > return AVERROR_EOF;
> > > if (c == 0x47) {
> > > +int new_packet_size, ret;
> > > avio_seek(pb, -1, SEEK_CUR);
> > > -reanalyze(s->priv_data);
> > > +pos = avio_tell(pb);
> > > +ret = ffio_ensure_seekback(pb, PROBE_PACKET_MAX_BUF);
> 
> PROBE_PACKET_MAX_BUF is about 8K, maybe it'll cost too much for the detection with get_packet_size()

> during the runtime.

But the function uses avio_read_partial which only reads the amount which is
already in the input buffer, and only continues if the result is
inconclusive.

> How about to detect the next 3 sync byte with the probe size? it's used by 
vlc,
> refer to DetectPacketSize() in modules/demux/mpeg/ts.c

If you check the probing function, it uses PROBE_PACKET_MARGIN (5), which
means that 6 sync bytres are needed. Not much difference, so I'd rather keep
things as is.

Practically this only waits for at most one additional UDP packet, and even
that is not lost, because we ensure the buffer is seekable even for
non-streamed input.


Thanks for the explanation, I'm fine with the patch.


Thanks, applied.

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

Re: [FFmpeg-devel] [PATCH 2/2] Use gcc/clang builtins for av_sat_(add|sub)_64_c if available.

2020-05-27 Thread Michael Niedermayer
On Wed, May 27, 2020 at 11:27:14AM -0700, Dale Curtis wrote:
> On Wed, May 27, 2020 at 11:10 AM Michael Niedermayer 
> wrote:
> 
> > so the builtin does better and both locally do better than clang on the web
> > tool
> >
> 
> Ah, sorry I forgot godbolt is compiling without any options, if you type
> -O9 in the compiler options fields you get:
> clang: https://godbolt.org/z/CAMXer
> gcc:  https://godbolt.org/z/EKqGt6
> 
> Which is similar to what you've gotten above; with the builtin having the
> smallest code.

good, i think this has been tested quite well now ...
will apply

thx

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

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle


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 v5 1/4] avcodec/adpcmenc: add capabilities argument to ADPCM_ENCODER()

2020-05-27 Thread Michael Niedermayer
On Sat, May 16, 2020 at 06:48:08PM +0200, Paul B Mahol wrote:
> On 5/16/20, Zane van Iperen  wrote:
> > On Sat, 16 May 2020 15:03:22 +0200
> > "Paul B Mahol"  wrote:
> >
> >>
> >> Why sending this kind of patches?
> >>
> >> I see no point in this patch?
> >>
> >
> > Michael suggested it here
> > https://ffmpeg.org/pipermail/ffmpeg-devel/2020-May/262730.html
> >
> >
> >
> 
> Ah, one of them use small last frame capability.
> Everything is ok then.

will apply

thx

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

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope


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] doc: add dia_size option documentation

2020-05-27 Thread Michael Niedermayer
On Wed, May 27, 2020 at 12:20:39PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  doc/codecs.texi | 18 ++
>  1 file changed, 18 insertions(+)

probably correct

thx

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

Whats the most studid thing your enemy could do ? Blow himself up
Whats the most studid thing you could do ? Give up your rights and
freedom because your enemy blew himself up.



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] Don't adjust start time for MP3 files; packets are not adjusted.

2020-05-27 Thread Dale Curtis
On Wed, May 27, 2020 at 8:29 AM Michael Niedermayer 
wrote:

> what id like to point out here is that the audio stream no
> longer starts at the same time as the video
> also the duration from adding the durations before is
> exact but not afterwards
>

I'm not sure about the duration issue, I'd assume it's just an accounting
error since the change only affects start_time. As noted in the change
description, if you want to keep start_time adjusted for skip samples all
packet timestamps need to be changed too. Doing that broke many test cases
at the time, so we opted to just revert the patch. I.e., basically every
mp3 changes to having its first PTS be ~26ms due to the common 1152 skip
sample amount.

- dale
___
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] suspicious unconditional `goto fail` in decode.c:1892

2020-05-27 Thread Pavel Koshevoy
Hi,

I've run into a regression that I've tracked down to this snippet of
code in libavcodec/decode.c
```
if (hwaccel) {
if (hwaccel->alloc_frame) {
ret = hwaccel->alloc_frame(avctx, frame);
goto fail;
}
} else
avctx->sw_pix_fmt = avctx->pix_fmt;
```

The `goto fail` is unconditional, and was introduced in commit a1133db30ef
I'd like to confirm whether it is intentional.

Thank you,
Pavel.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/2] Use gcc/clang builtins for av_sat_(add|sub)_64_c if available.

2020-05-27 Thread Dale Curtis
On Wed, May 27, 2020 at 11:10 AM Michael Niedermayer 
wrote:

> so the builtin does better and both locally do better than clang on the web
> tool
>

Ah, sorry I forgot godbolt is compiling without any options, if you type
-O9 in the compiler options fields you get:
clang: https://godbolt.org/z/CAMXer
gcc:  https://godbolt.org/z/EKqGt6

Which is similar to what you've gotten above; with the builtin having the
smallest code.

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

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

Re: [FFmpeg-devel] [PATCH 2/2] Use gcc/clang builtins for av_sat_(add|sub)_64_c if available.

2020-05-27 Thread Michael Niedermayer
On Tue, May 26, 2020 at 12:23:41PM -0700, Dale Curtis wrote:
> On Fri, May 22, 2020 at 1:34 PM Michael Niedermayer 
> wrote:
> 
> >
> > does this produce faster / better code ?
> > that is do compilers actually fail to optimize this from plain
> > clean C code ?
> >
> 
> Here's the difference:
> clang trunk: https://godbolt.org/z/6SHmEo

interresting tool

but I tried it locally (plain C version with -O9)

av_sat_add64_c: # @av_sat_add64_c
.cfi_startproc
movabsq $9223372036854775807, %rax # imm = 0x7FFF
testq   %rsi, %rsi
js  .LBB0_2
movq%rax, %rcx
subq%rsi, %rcx
cmpq%rdi, %rcx
jg  .LBB0_2
retq
.LBB0_2:
addq$1, %rax
movq%rax, %rcx
subq%rsi, %rcx
leaq(%rsi,%rdi), %rdx
cmpq%rdi, %rcx
cmovlq  %rdx, %rax
testq   %rsi, %rsi
cmovgq  %rdx, %rax
retq
.Lfunc_end0:
.size   av_sat_add64_c, .Lfunc_end0-av_sat_add64_c
.cfi_endproc
# -- End function

.ident  "clang version 9.0.0 (https://github.com/llvm/llvm-project/ 
49b965079b18f8aa485dd1156dd088d40b7ee465)"

and the builtin one:
av_sat_add64_c: # @av_sat_add64_c
.cfi_startproc
leaq(%rdi,%rsi), %rcx
movabsq $9223372036854775807, %rax # imm = 0x7FFF
leaq1(%rax), %rdx
testq   %rcx, %rcx
cmovnsq %rdx, %rax
addq%rsi, %rdi
cmovnoq %rdi, %rax
retq

so the builtin does better and both locally do better than clang on the web
tool



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

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad


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/libaomenc: remove the experimental flag when using libaom 2.0.0 or newer

2020-05-27 Thread James Zern
On Tue, May 26, 2020 at 6:40 PM James Almer  wrote:
>
> Signed-off-by: James Almer 
> ---
> Alternatively, we could remove support for libaom 1.0.0, since it's pretty 
> much
> unusable. But unfortunately both current Debian Stable and latest Ubuntu LTS
> ship it, so i'm not sure if it would be wise.
>
> Any opinions?
>

Those were based off of the normative branch so I agree with you it's
pretty unusable. For LTS at least if there has been an incompatible
ffmpeg release since their snapshot I don't think a new one with
libaom disabled would get pulled in. That said, I'm ok with leaving
1.0.0 support through another release and when we see 2.0 get picked
up by distros. This patch is lgtm depending on other people's
preferences.
___
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] Don't adjust start time for MP3 files; packets are not adjusted.

2020-05-27 Thread Michael Niedermayer
On Thu, Apr 23, 2020 at 04:33:21PM -0700, Dale Curtis wrote:
> This is a patch Chromium has carried for a while, we forgot to send it
> upstream. 7546ac2fee4 made it so that the start_time for mp3 files is
> adjusted for skip_samples. However, this appears incorrect because
> subsequent packet timestamps are not adjusted and skip_samples are
> applied by deleting data from a packet without changing the timestamp.
> 
> E.g., we are told the start_time is ~25ms and we get a packet with a
> timestamp of 0 that has had the skip_samples discarded from it. As such
> rendering engines may incorrectly discard everything prior to the
> 25ms thinking that is where playback should officially start. Since the
> samples were deleted without adjusting timestamps though, the true
> start_time is still 0.
> 
> Other formats like MP4 with edit lists will adjust both the start
> time and the timestamps of subsequent packets to avoid this issue.
> 
> Signed-off-by: Dale Curtis 

> 173f45ece85db7ccb5f242043b1d029bfbdbd28b  no_start_time_adjust_v0.patch
> From 1f551502a2e271da044f7e4be4be7ddca7f30bc1 Mon Sep 17 00:00:00 2001
> From: Dale Curtis 
> Date: Thu, 23 Apr 2020 16:18:18 -0700
> Subject: [PATCH] Don't adjust start time for MP3 files; packets are not
>  adjusted.
> 
> This is a patch Chromium has carried for a while, we forgot to send it
> upstream. 7546ac2fee4 made it so that the start_time for mp3 files is
> adjusted for skip_samples. However, this appears incorrect because
> subsequent packet timestamps are not adjusted and skip_samples are
> applied by deleting data from a packet without changing the timestamp.
> 
> E.g., we are told the start_time is ~25ms and we get a packet with a
> timestamp of 0 that has had the skip_samples discarded from it. As such
> rendering engines may incorrectly discard everything prior to the
> 25ms thinking that is where playback should officially start. Since the
> samples were deleted without adjusting timestamps though, the true
> start_time is still 0.
> 
> Other formats like MP4 with edit lists will adjust both the start
> time and the timestamps of subsequent packets to avoid this issue.
> 
> Signed-off-by: Dale Curtis 
> ---
>  libavformat/mp3dec.c   | 4 
>  tests/ref/fate/gapless-mp3 | 2 +-
>  2 files changed, 1 insertion(+), 5 deletions(-)

this causes
./ffmpeg -i tickets//5205/example-with-error_cut.mp3 -t 0.11 -f framecrc before
to change this way:

--- before  2020-05-27 17:16:08.282813662 +0200
+++ after   2020-05-27 17:14:40.654886720 +0200
@@ -11,9 +11,8 @@
 #channel_layout 1: 3
 #channel_layout_name 1: stereo
 0,  0,  0,0,  300, 0x68775127
-1,  0,  0,   47,  188, 0x05b53e6d
-1, 47, 47, 1152, 4608, 0xaf804111
-1,   1199,   1199, 1152, 4608, 0xded29ae0
-1,   2351,   2351, 1152, 4608, 0x51b68940
-1,   3503,   3503, 1152, 4608, 0xa63e5ef7
-1,   4655,   4655,  196,  784, 0x9fd3a615
+1,   1105,   1105,   47,  188, 0x05b53e6d
+1,   1152,   1152, 1152, 4608, 0xaf804111
+1,   2304,   2304, 1152, 4608, 0xded29ae0
+1,   3456,   3456, 1152, 4608, 0x51b68940
+1,   4608,   4608, 1152, 4608, 0xa63e5ef7

what id like to point out here is that the audio stream no
longer starts at the same time as the video
also the duration from adding the durations before is
exact but not afterwards

i sadly didnt had the time to look into this before
it was applied. So ATM iam just reporting this change, i didnt look
at what exactly is going on

I assume the file is here:
https://trac.ffmpeg.org/raw-attachment/ticket/5205/example-with-error_cut.mp3

also i seem to have more files that appear to behave the same

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


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] avcodec: add PFM image decoder

2020-05-27 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/Makefile |  1 +
 libavcodec/allcodecs.c  |  1 +
 libavcodec/codec_desc.c |  7 ++
 libavcodec/codec_id.h   |  1 +
 libavcodec/pnm.c| 21 +---
 libavcodec/pnm.h|  2 ++
 libavcodec/pnmdec.c | 55 +
 libavformat/img2.c  |  1 +
 8 files changed, 85 insertions(+), 4 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6d816308c7..fa7bda4c5a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -530,6 +530,7 @@ OBJS-$(CONFIG_PBM_DECODER) += pnmdec.o pnm.o
 OBJS-$(CONFIG_PBM_ENCODER) += pnmenc.o
 OBJS-$(CONFIG_PCX_DECODER) += pcx.o
 OBJS-$(CONFIG_PCX_ENCODER) += pcxenc.o
+OBJS-$(CONFIG_PFM_DECODER) += pnmdec.o pnm.o
 OBJS-$(CONFIG_PGM_DECODER) += pnmdec.o pnm.o
 OBJS-$(CONFIG_PGM_ENCODER) += pnmenc.o
 OBJS-$(CONFIG_PGMYUV_DECODER)  += pnmdec.o pnm.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index eb5044f80e..f34ce35b42 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -233,6 +233,7 @@ extern AVCodec ff_pbm_encoder;
 extern AVCodec ff_pbm_decoder;
 extern AVCodec ff_pcx_encoder;
 extern AVCodec ff_pcx_decoder;
+extern AVCodec ff_pfm_decoder;
 extern AVCodec ff_pgm_encoder;
 extern AVCodec ff_pgm_decoder;
 extern AVCodec ff_pgmyuv_encoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index b94ad0b1e6..9f8847544f 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1770,6 +1770,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("NotchLC"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_PFM,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "pfm",
+.long_name = NULL_IF_CONFIG_SMALL("PFM (Portable FloatMap) image"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index f7cb0a6056..d885962c9c 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -294,6 +294,7 @@ enum AVCodecID {
 AV_CODEC_ID_CDTOONS,
 AV_CODEC_ID_MV30,
 AV_CODEC_ID_NOTCHLC,
+AV_CODEC_ID_PFM,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index b5c2881948..a6ae01b494 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -24,6 +24,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/avstring.h"
 #include "avcodec.h"
 #include "internal.h"
 #include "pnm.h"
@@ -69,8 +70,9 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * 
const s)
 
 if (s->bytestream_end - s->bytestream < 3 ||
 s->bytestream[0] != 'P' ||
-s->bytestream[1] < '1'  ||
-s->bytestream[1] > '7') {
+(s->bytestream[1] < '1' ||
+ s->bytestream[1] > '7' &&
+ s->bytestream[1] != 'F')) {
 s->bytestream += s->bytestream_end > s->bytestream;
 s->bytestream += s->bytestream_end > s->bytestream;
 return AVERROR_INVALIDDATA;
@@ -78,7 +80,9 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * 
const s)
 pnm_get(s, buf1, sizeof(buf1));
 s->type= buf1[1]-'0';
 
-if (s->type==1 || s->type==4) {
+if (buf1[1] == 'F') {
+avctx->pix_fmt = AV_PIX_FMT_GBRPF32;
+} else if (s->type==1 || s->type==4) {
 avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
 } else if (s->type==2 || s->type==5) {
 if (avctx->codec_id == AV_CODEC_ID_PGMYUV)
@@ -173,7 +177,16 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext 
* const s)
 if (ret < 0)
 return ret;
 
-if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE && avctx->pix_fmt != 
AV_PIX_FMT_MONOBLACK) {
+if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32) {
+pnm_get(s, buf1, sizeof(buf1));
+if (av_sscanf(buf1, "%f", &s->scale) != 1) {
+av_log(avctx, AV_LOG_ERROR, "Invalid scale.\n");
+return AVERROR_INVALIDDATA;
+}
+s->endian = s->scale < 0.f;
+s->scale = fabsf(s->scale);
+s->maxval = (1ULL << 32) - 1;
+} else if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE && avctx->pix_fmt != 
AV_PIX_FMT_MONOBLACK) {
 pnm_get(s, buf1, sizeof(buf1));
 s->maxval = atoi(buf1);
 if (s->maxval <= 0 || s->maxval > UINT16_MAX) {
diff --git a/libavcodec/pnm.h b/libavcodec/pnm.h
index 5bc0aad29f..89c3b5a2da 100644
--- a/libavcodec/pnm.h
+++ b/libavcodec/pnm.h
@@ -30,6 +30,8 @@ typedef struct PNMContext {
 uint8_t *bytestream_end;
 int maxval; ///< maximum value of a pixel
 int type;
+int endian;
+float scale;
 } PNMContext;
 
 int ff_pnm

[FFmpeg-devel] [PATCH] avformat/dashenc: use AVCodecContext timebase when computing missing bitrate

2020-05-27 Thread Przemysław Sobala
---
 libavformat/dashenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 0cf0df50ef..00a37b175d 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1959,7 +1959,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 
 if (!os->bit_rate) {
 // calculate average bitrate of first segment
-int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE / 
duration;
+int64_t bitrate = (int64_t) range_length * 8 * (c->use_timeline ? 
os->ctx->streams[0]->time_base.den : AV_TIME_BASE) / duration;
 if (bitrate >= 0)
 os->bit_rate = bitrate;
 }
-- 
2.25.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] avformat: fix apm makefile dependency

2020-05-27 Thread Michael Niedermayer
On Tue, May 26, 2020 at 01:06:11PM +0200, Paul B Mahol wrote:
> lgtm

will apply

thx

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

There will always be a question for which you do not know the correct answer.


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]lavu/log: Do not change the terminal background colour

2020-05-27 Thread Michael Niedermayer
On Sun, Mar 29, 2020 at 05:19:29PM +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes ticket #8587, not sure if we want this or not,
> but I do not consider the missing encircled / blinking effect (that is
> not used by our command line tools) an issue.
> 
> Please comment, Carl Eugen

> b14e07aba247cd696e0d9e3d718eb186f6cb555e  
> 0001-lavu-log-Always-use-the-default-background-color.patch
> From 64eeec19197fe7726f3bb103417ae3277b1cd8f9 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos 
> Date: Sun, 29 Mar 2020 14:32:38 +0200
> Subject: [PATCH] lavu/log: Always use the default background color.
> 
> Fixes ticket #8587.
> ---
>  libavutil/log.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

I can confirm this fixes an issue with messed up background color in some
terminals (not all)
not sure if this fix is the best solution but i dont have a better
suggestion ATM either

[...]


-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus


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] fate/vcodec: use the encoder private option for frame skip compare function

2020-05-27 Thread James Almer
Stop using the deprecated global option

Signed-off-by: James Almer 
---
 tests/fate/vcodec.mak | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index ec2a9c339d..1e9c0d5647 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -323,7 +323,7 @@ fate-vsynth%-mpeg4-nr:   ENCOPTS = -qscale 8 -flags 
+mv4 -mbd rd \
 
 fate-vsynth%-mpeg4-nsse: ENCOPTS = -qscale 7 -cmp nsse -subcmp nsse \
-mbcmp nsse -precmp nsse \
-   -skipcmp nsse
+   -skip_cmp nsse
 
 fate-vsynth%-mpeg4-qpel: ENCOPTS = -qscale 7 -flags +mv4+qpel -mbd 2 \
-bf 2 -cmp 1 -subcmp 2
-- 
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".

Re: [FFmpeg-devel] [PATCH 1/3] ffbuild: Refine MIPS handling

2020-05-27 Thread Shiyou Yin


>-Original Message-
>From: ffmpeg-devel-boun...@ffmpeg.org [mailto:ffmpeg-devel-boun...@ffmpeg.org] 
>On Behalf Of
>Jiaxun Yang
>Sent: Tuesday, May 26, 2020 5:48 PM
>To: ffmpeg-devel@ffmpeg.org
>Cc: yinshi...@loongson.cn; Jiaxun Yang
>Subject: [FFmpeg-devel] [PATCH 1/3] ffbuild: Refine MIPS handling
>
>To enable runtime detection for MIPS, we need to refine ffbuild
>part to support buildding these feature together.
>
>Firstly, we fixed configure, let it probe native ability of toolchain
>to decide wether a feature can to be enabled, also clearly marked
>the conflictions between loongson2 & loongson3 and Release 6 & rest.
>
>Secondly, we compile MMI and MSA C sources with their own flags to ensure
>their flags won't pollute the whole program and generate illegal code.
>
>Signed-off-by: Jiaxun Yang 
>---
> configure| 179 +++
> ffbuild/common.mak   |  10 ++-
> libavcodec/mips/Makefile |   3 +-
> 3 files changed, 117 insertions(+), 75 deletions(-)
>
>diff --git a/configure b/configure
>index f97cad0298..8dc3874642 100755
>--- a/configure
>+++ b/configure
>@@ -1113,6 +1113,26 @@ void foo(void){ __asm__ volatile($code); }
> EOF
> }
>
>+check_extra_inline_asm_flags(){
>+log check_extra_inline_asm_flags "$@"
>+name="$1"
>+extra=$2
>+code="$3"
>+flags=''
>+shift 3
>+while [ "$1" != "" ]; do
>+  append flags $1
>+  shift
>+done;
>+disable $name
>+cat > $TMPC <+void foo(void){ __asm__ volatile($code); }
>+EOF
>+log_file $TMPC
>+test_cmd $cc $CPPFLAGS $CFLAGS $flags "$@" $CC_C $(cc_o $TMPO) $TMPC &&
>+enable $name && append $extra "$flags"
>+}
>+
> check_inline_asm_flags(){
> log check_inline_asm_flags "$@"
> name="$1"
>@@ -2551,7 +2571,7 @@ mips64r6_deps="mips"
> mipsfpu_deps="mips"
> mipsdsp_deps="mips"
> mipsdspr2_deps="mips"
>-mmi_deps="mips"
>+mmi_deps_any="loongson2 loongson3"
> msa_deps="mipsfpu"
> msa2_deps="msa"
>
>@@ -4999,29 +5019,57 @@ elif enabled bfin; then
>
> elif enabled mips; then
>
>-cpuflags="-march=$cpu"
>-
> if [ "$cpu" != "generic" ]; then
>-disable mips32r2
>-disable mips32r5
>-disable mips64r2
>-disable mips32r6
>-disable mips64r6
>-disable loongson2
>-disable loongson3
>+# DSP is disabled by deafult as they can't be detected at runtime
>+disable mipsdsp
>+disable mipsdspr2
>+
>+cpuflags="-march=$cpu"
>
> case $cpu in
>-24kc|24kf*|24kec|34kc|1004kc|24kef*|34kf*|1004kf*|74kc|74kf)
>+# General ISA levels
>+mips1|mips3)
>+disable msa
>+;;
>+mips32r2)
> enable mips32r2
>+;;
>+mips32r5)
>+enable mips32r5
>+;;
>+mips64r2|mips64r5)
>+enable mips64r2
>+;;
>+# Cores from MIPS(MTI)
>+24kc)
>+disable mipsfpu
>+;;
>+24kf*|24kec|34kc|74Kc|1004kc)
>+disable mmi
> disable msa
> ;;
>-p5600|i6400|p6600)
>-disable mipsdsp
>-disable mipsdspr2
>+24kef*|34kf*|1004kf*)
>+disable mmi
>+disable msa
>+enable mipsdsp
>+;;
>+p5600)
>+disable mmi
>+enable mips32r5
>+check_cflags "-mtune=p5600" && check_cflags "-msched-weight 
>-mload-store-pairs
>-funroll-loops"
>+;;
>+i6400)
>+disable mmi
>+enable mips64r6
>+check_cflags "-mtune=i6400 -mabi=64" && check_cflags 
>"-msched-weight
>-mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64"
>+;;
>+p6600)
>+disable mmi
>+enable mips64r6
>+check_cflags "-mtune=p6600 -mabi=64" && check_cflags 
>"-msched-weight
>-mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64"
> ;;
>+# Cores from Loongson
> loongson*)
>-enable loongson2
>-enable loongson3
> enable local_aligned
> enable simd_align_16
> enable fast_64bit
>@@ -5029,8 +5077,6 @@ elif enabled mips; then
> enable fast_cmov
> enable fast_unaligned
> disable aligned_stack
>-disable mipsdsp
>-disable mipsdspr2
> # When gcc version less than 5.3.0, add 
> -fno-expensive-optimizations flag.
> if [ $cc == gcc ]; then
> gcc_version=$(gcc -dumpversion)
>@@ -5042,62 +5088,26 @@ elif enabled mips; then
> fi
> case $cpu in
> loongson3*)
>+enable loongson3
>+ 

Re: [FFmpeg-devel] [PATCH] hevc_parser: drop the use of SliceHeader

2020-05-27 Thread James Almer
On 5/27/2020 6:03 AM, Anton Khirnov wrote:
> It is only used to store a few local variables within one function,
> which is better accomplished by just declaring them on stack explicitly.
> 
> Move SliceHeader back from hevc_ps.h to hevdec.h, since it is not
> related to parameters sets.
> ---
>  libavcodec/hevc_parser.c | 57 +++--
>  libavcodec/hevc_ps.h | 77 
>  libavcodec/hevcdec.h | 77 
>  3 files changed, 107 insertions(+), 104 deletions(-)
> 
> diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
> index 84f19b485c..5af4b788d5 100644
> --- a/libavcodec/hevc_parser.c
> +++ b/libavcodec/hevc_parser.c
> @@ -42,7 +42,6 @@ typedef struct HEVCParserContext {
>  H2645Packet pkt;
>  HEVCParamSets ps;
>  HEVCSEI sei;
> -SliceHeader sh;
>  
>  int is_avc;
>  int nal_length_size;
> @@ -58,26 +57,28 @@ static int hevc_parse_slice_header(AVCodecParserContext 
> *s, H2645NAL *nal,
>  HEVCParserContext *ctx = s->priv_data;
>  HEVCParamSets *ps = &ctx->ps;
>  HEVCSEI *sei = &ctx->sei;
> -SliceHeader *sh = &ctx->sh;
>  GetBitContext *gb = &nal->gb;
>  const HEVCWindow *ow;
>  int i, num = 0, den = 0;
>  
> -sh->first_slice_in_pic_flag = get_bits1(gb);
> +unsigned int pps_id, first_slice_in_pic_flag, 
> dependent_slice_segment_flag;
> +enum HEVCSliceType slice_type;
> +
> +first_slice_in_pic_flag = get_bits1(gb);
>  s->picture_structure = sei->picture_timing.picture_struct;
>  s->field_order = sei->picture_timing.picture_struct;
>  
>  if (IS_IRAP_NAL(nal)) {
>  s->key_frame = 1;
> -sh->no_output_of_prior_pics_flag = get_bits1(gb);
> +skip_bits1(gb); // no_output_of_prior_pics_flag
>  }
>  
> -sh->pps_id = get_ue_golomb(gb);
> -if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) {
> -av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
> +pps_id = get_ue_golomb(gb);
> +if (pps_id >= HEVC_MAX_PPS_COUNT || !ps->pps_list[pps_id]) {
> +av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
>  return AVERROR_INVALIDDATA;
>  }
> -ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data;
> +ps->pps = (HEVCPPS*)ps->pps_list[pps_id]->data;
>  
>  if (ps->pps->sps_id >= HEVC_MAX_SPS_COUNT || 
> !ps->sps_list[ps->pps->sps_id]) {
>  av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", 
> ps->pps->sps_id);
> @@ -109,51 +110,53 @@ static int hevc_parse_slice_header(AVCodecParserContext 
> *s, H2645NAL *nal,
>  av_reduce(&avctx->framerate.den, &avctx->framerate.num,
>num, den, 1 << 30);
>  
> -if (!sh->first_slice_in_pic_flag) {
> +if (!first_slice_in_pic_flag) {
> +unsigned int slice_segment_addr;
>  int slice_address_length;
>  
>  if (ps->pps->dependent_slice_segments_enabled_flag)
> -sh->dependent_slice_segment_flag = get_bits1(gb);
> +dependent_slice_segment_flag = get_bits1(gb);
>  else
> -sh->dependent_slice_segment_flag = 0;
> +dependent_slice_segment_flag = 0;
>  
>  slice_address_length = av_ceil_log2_c(ps->sps->ctb_width *
>ps->sps->ctb_height);
> -sh->slice_segment_addr = get_bitsz(gb, slice_address_length);
> -if (sh->slice_segment_addr >= ps->sps->ctb_width * 
> ps->sps->ctb_height) {
> +slice_segment_addr = get_bitsz(gb, slice_address_length);
> +if (slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) {
>  av_log(avctx, AV_LOG_ERROR, "Invalid slice segment address: 
> %u.\n",
> -   sh->slice_segment_addr);
> +   slice_segment_addr);
>  return AVERROR_INVALIDDATA;
>  }
>  } else
> -sh->dependent_slice_segment_flag = 0;
> +dependent_slice_segment_flag = 0;
>  
> -if (sh->dependent_slice_segment_flag)
> +if (dependent_slice_segment_flag)
>  return 0; /* break; */
>  
>  for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++)
>  skip_bits(gb, 1); // slice_reserved_undetermined_flag[]
>  
> -sh->slice_type = get_ue_golomb(gb);
> -if (!(sh->slice_type == HEVC_SLICE_I || sh->slice_type == HEVC_SLICE_P ||
> -  sh->slice_type == HEVC_SLICE_B)) {
> +slice_type = get_ue_golomb(gb);
> +if (!(slice_type == HEVC_SLICE_I || slice_type == HEVC_SLICE_P ||
> +  slice_type == HEVC_SLICE_B)) {
>  av_log(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
> -   sh->slice_type);
> +   slice_type);
>  return AVERROR_INVALIDDATA;
>  }
> -s->pict_type = sh->slice_type == HEVC_SLICE_B ? AV_PICTURE_TYPE_B :
> -   sh->slice_type == HEVC_SLICE_P ? AV_PICTURE_TYPE_P :
> - 

Re: [FFmpeg-devel] [PATCH 2/3] avcodec.h: split AVCodec API into its own header

2020-05-27 Thread James Almer
On 5/27/2020 5:08 AM, Anton Khirnov wrote:
> Quoting James Almer (2020-05-25 15:41:57)
>> On 5/25/2020 10:31 AM, Anton Khirnov wrote:
>>> Quoting James Almer (2020-05-25 15:21:12)
 On 5/25/2020 10:12 AM, Anton Khirnov wrote:
> -/**
> - * Iterate over all registered codecs.
> - *
> - * @param opaque a pointer where libavcodec will store the iteration 
> state. Must
> - *   point to NULL to start the iteration.
> - *
> - * @return the next registered codec or NULL when the iteration is
> - * finished
> - */
> -const AVCodec *av_codec_iterate(void **opaque);
> -
>  #if FF_API_NEXT

 Why are you not moving the deprecated functions as well? They are
 AVCodec related and should remain with the rest until they are
 effectively removed.
>>>
>>> Why?
>>> Seems better to me to make the new headers "clean", since new users
>>> should only use the non-deprecated API. No need to distract them with
>>> obsolete cruft.
>>
>> Ok, that's reasonable. But why did you move the AVPacket ones, then? If
>> anything, those should be hidden since they are the most confusing, like
>> av_packet_free() and av_free_packet() in the same header, or pretty much
>> broken and potentially dangerous, like av_dup_packet().
> 
> What can I say, I am not perfectly consistent in everything. I think I
> just didn't consider this at that point. Want me to move them back?

It's not important, but it would certainly make packet.h look nicer
until the major bump, so up to you.
___
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 dblur video filter

2020-05-27 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi |  23 +++
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/vf_dblur.c   | 307 +++
 4 files changed, 332 insertions(+)
 create mode 100644 libavfilter/vf_dblur.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 7675a0e9b1..c5fc2da8bc 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8633,6 +8633,29 @@ Set background opacity.
 Set display number format. Can be @code{hex}, or @code{dec}. Default is 
@code{hex}.
 @end table
 
+@section dblur
+Apply Directional blur filter.
+
+The filter accepts the following options:
+
+@table @option
+@item angle
+Set angle of directional blur. Default is @code{45}.
+
+@item radius
+Set radius of directional blur. Default is @code{5}.
+
+@item planes
+Set which planes to filter. By default all planes are filtered.
+@end table
+
+@subsection Commands
+This filter supports same @ref{commands} as options.
+The command accepts the same syntax of the corresponding option.
+
+If the specified expression is not valid, it is kept at its current
+value.
+
 @section dctdnoiz
 
 Denoise frames using 2D DCT (frequency domain filtering).
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 497297d0a6..6ffad8381b 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -206,6 +206,7 @@ OBJS-$(CONFIG_CROPDETECT_FILTER) += 
vf_cropdetect.o
 OBJS-$(CONFIG_CUE_FILTER)+= f_cue.o
 OBJS-$(CONFIG_CURVES_FILTER) += vf_curves.o
 OBJS-$(CONFIG_DATASCOPE_FILTER)  += vf_datascope.o
+OBJS-$(CONFIG_DBLUR_FILTER)  += vf_dblur.o
 OBJS-$(CONFIG_DCTDNOIZ_FILTER)   += vf_dctdnoiz.o
 OBJS-$(CONFIG_DEBAND_FILTER) += vf_deband.o
 OBJS-$(CONFIG_DEBLOCK_FILTER)+= vf_deblock.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 9605ce9367..520816be5e 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -194,6 +194,7 @@ extern AVFilter ff_vf_cropdetect;
 extern AVFilter ff_vf_cue;
 extern AVFilter ff_vf_curves;
 extern AVFilter ff_vf_datascope;
+extern AVFilter ff_vf_dblur;
 extern AVFilter ff_vf_dctdnoiz;
 extern AVFilter ff_vf_deband;
 extern AVFilter ff_vf_deblock;
diff --git a/libavfilter/vf_dblur.c b/libavfilter/vf_dblur.c
new file mode 100644
index 00..cc127da73f
--- /dev/null
+++ b/libavfilter/vf_dblur.c
@@ -0,0 +1,307 @@
+/*
+ * Copyright (c) 2020 Paul B Mahol
+ *
+ * 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 "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct DBlurContext {
+const AVClass *class;
+
+float angle;
+float radius;
+int planes;
+
+float b0, b1, q, c, R3;
+
+int depth;
+int planewidth[4];
+int planeheight[4];
+float *buffer;
+int nb_planes;
+void (*horiz_slice)(float *buffer, int width, int height, int steps, float 
nu, float bscale);
+} DBlurContext;
+
+#define OFFSET(x) offsetof(DBlurContext, x)
+#define FLAGS 
AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+
+static const AVOption dblur_options[] = {
+{ "angle",  "set angle",OFFSET(angle),  AV_OPT_TYPE_FLOAT, 
{.dbl=45},  0.0,  360, FLAGS },
+{ "radius", "set radius",   OFFSET(radius), AV_OPT_TYPE_FLOAT, 
{.dbl=5}, 1, 8192, FLAGS },
+{ "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT,   
{.i64=0xF},   0,  0xF, FLAGS },
+{ NULL }
+};
+
+AVFILTER_DEFINE_CLASS(dblur);
+
+#define f(n, m) (dst[(n) * width + (m)])
+
+static int filter_horizontally(AVFilterContext *ctx, int width, int height)
+{
+DBlurContext *s = ctx->priv;
+const float b0 = s->b0;
+const float b1 = s->b1;
+const float q = s->q;
+const float c = s->c;
+float *dst = s->buffer;
+float g;
+
+if (s->R3 > 0) {
+for (int y = 1; y < height - 1; y++) {
+g = q * f(0, 0) + c * f(0, 0);
+for (int x = 0; x < width; x++) {
+f(y, x) = b0 * f(y, x) + b1 * f(y - 1, x) + g;
+g = q * f(y, x) + c *

[FFmpeg-devel] [PATCH v2 3/3] avformat/prompeg: av_dict_set() -> av_dict_set_int()

2020-05-27 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/prompeg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/prompeg.c b/libavformat/prompeg.c
index 9770a91..7b2e5e8 100644
--- a/libavformat/prompeg.c
+++ b/libavformat/prompeg.c
@@ -291,8 +291,7 @@ static int prompeg_open(URLContext *h, const char *uri, int 
flags) {
 }
 
 if (s->ttl > 0) {
-snprintf(buf, sizeof (buf), "%d", s->ttl);
-av_dict_set(&udp_opts, "ttl", buf, 0);
+av_dict_set_int(&udp_opts, "ttl", s->ttl, 0);
 }
 
 ff_url_join(buf, sizeof (buf), "udp", NULL, hostname, rtp_port + 2, NULL);
-- 
1.8.3.1

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

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

[FFmpeg-devel] [PATCH v2 1/3] avformat/rtspdec: av_dict_set() -> av_dict_set_int()

2020-05-27 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/rtspdec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index bd2e8f4..dfa2991 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -289,9 +289,7 @@ static int rtsp_read_setup(AVFormatContext *s, char* host, 
char *controlurl)
 } else {
 do {
 AVDictionary *opts = NULL;
-char buf[256];
-snprintf(buf, sizeof(buf), "%d", rt->buffer_size);
-av_dict_set(&opts, "buffer_size", buf, 0);
+av_dict_set_int(&opts, "buffer_size", rt->buffer_size, 0);
 ff_url_join(url, sizeof(url), "rtp", NULL, host, localport, NULL);
 av_log(s, AV_LOG_TRACE, "Opening: %s", url);
 ret = ffurl_open_whitelist(&rtsp_st->rtp_handle, url, 
AVIO_FLAG_READ_WRITE,
-- 
1.8.3.1

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

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

[FFmpeg-devel] [PATCH v2 2/3] avformat/rtpproto: av_dict_set() -> av_dict_set_int()

2020-05-27 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/rtpproto.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index ca63c16..19e940d 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -301,8 +301,7 @@ static int rtp_open(URLContext *h, const char *uri, int 
flags)
 goto fail;
 }
 if (s->ttl > 0) {
-snprintf(buf, sizeof (buf), "%d", s->ttl);
-av_dict_set(&fec_opts, "ttl", buf, 0);
+av_dict_set_int(&fec_opts, "ttl", s->ttl, 0);
 }
 }
 
-- 
1.8.3.1

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

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

Re: [FFmpeg-devel] [RFC] avcodec/bsf: support operations on side data in AVBSFContext

2020-05-27 Thread Andreas Rheinhardt
leozhang:
> Signed-off-by: leozhang 
> ---
> Please note that this is not a formal patch firstly. I send this to sincerely 
> request your suggestions/objections. 
> 
> And why need operating side data in AVBSFContext? Because I'm planning to 
> create a bitstream filter which inject AV_PKT_DATA_SPHERICAL info, and 
> transfer to AVCodecContext/AVStream.

The bsf API does not work with AVStreams. The best you could do is
attach the side data to the first packet. And to do this in a bsf, you
do not need additional fields in AVBSFContext. It can be done with an
ordinary option of the bsf you intend to create.

> 
>  libavcodec/bsf.h | 18 ++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/libavcodec/bsf.h b/libavcodec/bsf.h
> index 7ed5167..740fa78 100644
> --- a/libavcodec/bsf.h
> +++ b/libavcodec/bsf.h
> @@ -93,6 +93,12 @@ typedef struct AVBSFContext {
>   * filter in av_bsf_init().
>   */
>  AVRational time_base_out;
> +
> +/**
> + * Additional data associated with the entire bitstream.
> + */
> +AVPacketSideData *side_data;
> +size_t nb_side_data;>  } AVBSFContext;
>  
>  typedef struct AVBitStreamFilter {
> @@ -318,6 +324,18 @@ int av_bsf_list_parse_str(const char *str, AVBSFContext 
> **bsf);
>   */
>  int av_bsf_get_null_filter(AVBSFContext **bsf);
>  
> +/*
> + * functions To Be Implement
> +int av_bsf_add_side_data(AVBSFContext *bsf, enum AVPacketSideDataType type,
> +uint8_t *data, size_t size);
> +
> +uint8_t *av_bsf_new_side_data(AVBSFContext *bsf, 
> +  enum AVPacketSideDataType type, size_t size);
> +
> +uint8_t *av_bsf_get_side_data(const AVBSFContext *bsf,
> +  enum AVPacketSideDataType type, size_t *size);

Nowadays side data consists mostly of structures and not of plain
buffers, so these should return void *.

- 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 1/2] avformat/mpegtsenc: simplify code by using OFFSET() and ENC macros

2020-05-27 Thread lance . lmwang
On Wed, May 27, 2020 at 09:06:34AM +0200, Marton Balint wrote:
> 
> 
> On Wed, 27 May 2020, lance.lmw...@gmail.com wrote:
> 
> > On Wed, May 20, 2020 at 10:31:13PM +0800, lance.lmw...@gmail.com wrote:
> > > From: Limin Wang 
> > > 
> > > Signed-off-by: Limin Wang 
> > > ---
> > >  libavformat/mpegtsenc.c | 92 
> > > +
> > >  1 file changed, 47 insertions(+), 45 deletions(-)
> > > 
> > > diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> > > index bf1a7ee..9909d25 100644
> > > --- a/libavformat/mpegtsenc.c
> > > +++ b/libavformat/mpegtsenc.c
> > > @@ -1962,94 +1962,96 @@ static int mpegts_check_bitstream(struct 
> > > AVFormatContext *s, const AVPacket *pkt
> > >  return ret;
> > >  }
> > > 
> > > +#define OFFSET(x) offsetof(MpegTSWrite, x)
> > > +#define ENC AV_OPT_FLAG_ENCODING_PARAM
> > >  static const AVOption options[] = {
> > >  { "mpegts_transport_stream_id", "Set transport_stream_id field.",
> > > -  offsetof(MpegTSWrite, transport_stream_id), AV_OPT_TYPE_INT,
> > > -  { .i64 = 0x0001 }, 0x0001, 0x, AV_OPT_FLAG_ENCODING_PARAM },
> > > +  OFFSET(transport_stream_id), AV_OPT_TYPE_INT,
> > > +  { .i64 = 0x0001 }, 0x0001, 0x, ENC },
> > >  { "mpegts_original_network_id", "Set original_network_id field.",
> > > -  offsetof(MpegTSWrite, original_network_id), AV_OPT_TYPE_INT,
> > > -  { .i64 = DVB_PRIVATE_NETWORK_START }, 0x0001, 0x, 
> > > AV_OPT_FLAG_ENCODING_PARAM },
> > > +  OFFSET(original_network_id), AV_OPT_TYPE_INT,
> > > +  { .i64 = DVB_PRIVATE_NETWORK_START }, 0x0001, 0x, ENC },
> > >  { "mpegts_service_id", "Set service_id field.",
> > > -  offsetof(MpegTSWrite, service_id), AV_OPT_TYPE_INT,
> > > -  { .i64 = 0x0001 }, 0x0001, 0x, AV_OPT_FLAG_ENCODING_PARAM },
> > > +  OFFSET(service_id), AV_OPT_TYPE_INT,
> > > +  { .i64 = 0x0001 }, 0x0001, 0x, ENC },
> > >  { "mpegts_service_type", "Set service_type field.",
> > > -  offsetof(MpegTSWrite, service_type), AV_OPT_TYPE_INT,
> > > -  { .i64 = 0x01 }, 0x01, 0xff, AV_OPT_FLAG_ENCODING_PARAM, 
> > > "mpegts_service_type" },
> > > +  OFFSET(service_type), AV_OPT_TYPE_INT,
> > > +  { .i64 = 0x01 }, 0x01, 0xff, ENC, "mpegts_service_type" },
> > >  { "digital_tv", "Digital Television.",
> > >0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_DIGITAL_TV }, 
> > > 0x01, 0xff,
> > > -  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
> > > +  ENC, "mpegts_service_type" },
> > >  { "digital_radio", "Digital Radio.",
> > >0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_DIGITAL_RADIO 
> > > }, 0x01, 0xff,
> > > -  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
> > > +  ENC, "mpegts_service_type" },
> > >  { "teletext", "Teletext.",
> > >0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_TELETEXT }, 
> > > 0x01, 0xff,
> > > -  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
> > > +  ENC, "mpegts_service_type" },
> > >  { "advanced_codec_digital_radio", "Advanced Codec Digital Radio.",
> > >0, AV_OPT_TYPE_CONST, { .i64 = 
> > > MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_RADIO }, 0x01, 0xff,
> > > -  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
> > > +  ENC, "mpegts_service_type" },
> > >  { "mpeg2_digital_hdtv", "MPEG2 Digital HDTV.",
> > >0, AV_OPT_TYPE_CONST, { .i64 = 
> > > MPEGTS_SERVICE_TYPE_MPEG2_DIGITAL_HDTV }, 0x01, 0xff,
> > > -  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
> > > +  ENC, "mpegts_service_type" },
> > >  { "advanced_codec_digital_sdtv", "Advanced Codec Digital SDTV.",
> > >0, AV_OPT_TYPE_CONST, { .i64 = 
> > > MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_SDTV }, 0x01, 0xff,
> > > -  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
> > > +  ENC, "mpegts_service_type" },
> > >  { "advanced_codec_digital_hdtv", "Advanced Codec Digital HDTV.",
> > >0, AV_OPT_TYPE_CONST, { .i64 = 
> > > MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_HDTV }, 0x01, 0xff,
> > > -  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
> > > +  ENC, "mpegts_service_type" },
> > >  { "hevc_digital_hdtv", "HEVC Digital Television Service.",
> > >0, AV_OPT_TYPE_CONST, { .i64 = 
> > > MPEGTS_SERVICE_TYPE_HEVC_DIGITAL_HDTV }, 0x01, 0xff,
> > > -  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
> > > +  ENC, "mpegts_service_type" },
> > >  { "mpegts_pmt_start_pid", "Set the first pid of the PMT.",
> > > -  offsetof(MpegTSWrite, pmt_start_pid), AV_OPT_TYPE_INT,
> > > -  { .i64 = 0x1000 }, FIRST_OTHER_PID, LAST_OTHER_PID, 
> > > AV_OPT_FLAG_ENCODING_PARAM },
> > > +  OFFSET(pmt_start_pid), AV_OPT_TYPE_INT,
> > > +  { .i64 = 0x1000 }, FIRST_OTHER_PID, LAST_OTHER_PID, ENC },
> > >  { "mpegts_start_pid", "Set the first pid.",
> > > -  offsetof(MpegTSWrite, start_pid), AV_OPT_TYPE_INT,
> > > 

Re: [FFmpeg-devel] [PATCH v3 3/3] avcodec/h264dec: Add FF_CODEC_CAP_INIT_CLEANUP

2020-05-27 Thread lance . lmwang
On Wed, May 27, 2020 at 10:29:21AM +0200, Anton Khirnov wrote:
> Quoting lance.lmw...@gmail.com (2020-05-27 06:40:45)
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> 
> The patch looks ok, but it is really unclear why is there a third
> version of this patch and what is different about it.

Sorry, I always scp the patch to other host for git send-mail and
notice it's the wrong version after got the mail. So please ignore
the old version.

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

-- 
Thanks,
Limin Wang
___
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] avformat/rtspdec: use av_dict_set_int() instead

2020-05-27 Thread lance . lmwang
On Wed, May 27, 2020 at 10:06:59AM +0200, Anton Khirnov wrote:
> >[FFmpeg-devel] [PATCH 1/3] avformat/rtspdec: use av_dict_set_int()   instead
> doesn't make sense: instead of what?
> 
> Something like
> avformat/rtspdec: av_dict_set() -> av_dict_set_int()
> would be more clear IMO

Yes, it's more clear, I'll update the patch.


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

-- 
Thanks,
Limin Wang
___
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/mpegts: use get_packet_size in mpegts_resync for determining raw_packet_size

2020-05-27 Thread lance . lmwang
On Wed, May 27, 2020 at 08:47:54AM +0200, Marton Balint wrote:
> 
> 
> On Wed, 27 May 2020, lance.lmw...@gmail.com wrote:
> 
> > On Tue, May 26, 2020 at 09:52:45PM +0200, Marton Balint wrote:
> > > 
> > > 
> > > On Wed, 20 May 2020, Marton Balint wrote:
> > > 
> > > > The old resync logic had some bugs, for example the packet size could 
> > > > stuck
> > > > into 192 bytes, because pos47_full was not updated for every packet, 
> > > > and for
> > > > unseekable inputs the resync logic simply skipped some 0x47 sync bytes,
> > > > therefore the calculated distance between sync bytes was a multiple of 
> > > > 188
> > > > bytes.
> > > > > AVIO only buffers a single packet (for UDP/mpegts, that usually
> > > means 1316
> > > > bytes), so for every ten consecutive 188-byte MPEGTS packets there was 
> > > > always a
> > > > seek failure, and that caused the old code to not find the 188 byte 
> > > > pattern
> > > > across 10 consecutive packets.
> > > > > This patch changes the custom logic to the one which is used
> > > when probing to
> > > > determine the packet size. This was already proposed as a FIXME for a 
> > > > long
> > > > time...
> > > 
> > > Ping, will apply soon.
> > > 
> > > Regards,
> > > Marton
> > > 
> > > > ---
> > > > libavformat/mpegts.c | 51 ++--
> > > > 1 file changed, 11 insertions(+), 40 deletions(-)
> > > > > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> > > > index a065c61c40..c6fd3e1cef 100644
> > > > --- a/libavformat/mpegts.c
> > > > +++ b/libavformat/mpegts.c
> > > > @@ -123,10 +123,6 @@ struct MpegTSContext {
> > > > /** raw packet size, including FEC if present */
> > > > int raw_packet_size;
> > > > > -int size_stat[3];
> > > > -int size_stat_count;
> > > > -#define SIZE_STAT_THRESHOLD 10
> > > > -
> > > > int64_t pos47_full;
> > > > > /** if true, all pids are analyzed to find streams */
> > > > @@ -2840,41 +2836,6 @@ static int handle_packet(MpegTSContext *ts, 
> > > > const uint8_t *packet, int64_t pos)
> > > > return 0;
> > > > }
> > > > > -static void reanalyze(MpegTSContext *ts) {
> > > > -AVIOContext *pb = ts->stream->pb;
> > > > -int64_t pos = avio_tell(pb);
> > > > -if (pos < 0)
> > > > -return;
> > > > -pos -= ts->pos47_full;
> > > > -if (pos == TS_PACKET_SIZE) {
> > > > -ts->size_stat[0] ++;
> > > > -} else if (pos == TS_DVHS_PACKET_SIZE) {
> > > > -ts->size_stat[1] ++;
> > > > -} else if (pos == TS_FEC_PACKET_SIZE) {
> > > > -ts->size_stat[2] ++;
> > > > -}
> > > > -
> > > > -ts->size_stat_count ++;
> > > > -if (ts->size_stat_count > SIZE_STAT_THRESHOLD) {
> > > > -int newsize = 0;
> > > > -if (ts->size_stat[0] > SIZE_STAT_THRESHOLD) {
> > > > -newsize = TS_PACKET_SIZE;
> > > > -} else if (ts->size_stat[1] > SIZE_STAT_THRESHOLD) {
> > > > -newsize = TS_DVHS_PACKET_SIZE;
> > > > -} else if (ts->size_stat[2] > SIZE_STAT_THRESHOLD) {
> > > > -newsize = TS_FEC_PACKET_SIZE;
> > > > -}
> > > > -if (newsize && newsize != ts->raw_packet_size) {
> > > > -av_log(ts->stream, AV_LOG_WARNING, "changing packet size 
> > > > to %d\n", newsize);
> > > > -ts->raw_packet_size = newsize;
> > > > -}
> > > > -ts->size_stat_count = 0;
> > > > -memset(ts->size_stat, 0, sizeof(ts->size_stat));
> > > > -}
> > > > -}
> > > > -
> > > > -/* XXX: try to find a better synchro over several packets (use
> > > > - * get_packet_size() ?) */
> > > > static int mpegts_resync(AVFormatContext *s, int seekback, const 
> > > > uint8_t *current_packet)
> > > > {
> > > > MpegTSContext *ts = s->priv_data;
> > > > @@ -2896,8 +2857,18 @@ static int mpegts_resync(AVFormatContext *s, int 
> > > > seekback, const uint8_t *curren
> > > > if (avio_feof(pb))
> > > > return AVERROR_EOF;
> > > > if (c == 0x47) {
> > > > +int new_packet_size, ret;
> > > > avio_seek(pb, -1, SEEK_CUR);
> > > > -reanalyze(s->priv_data);
> > > > +pos = avio_tell(pb);
> > > > +ret = ffio_ensure_seekback(pb, PROBE_PACKET_MAX_BUF);
> > 
> > PROBE_PACKET_MAX_BUF is about 8K, maybe it'll cost too much for the 
> > detection with get_packet_size()
> > during the runtime.
> 
> But the function uses avio_read_partial which only reads the amount which is
> already in the input buffer, and only continues if the result is
> inconclusive.
> 
> > How about to detect the next 3 sync byte with the probe size? it's used by 
> > vlc,
> > refer to DetectPacketSize() in modules/demux/mpeg/ts.c
> 
> If you check the probing function, it uses PROBE_PACKET_MARGIN (5), which
> means that 6 sync bytres are needed. Not much difference, so I'd rather keep
> things as is.
> 
> Practically this only waits for at most one additional UDP packet, and even
> that is not lost, because we ensure th

[FFmpeg-devel] [PATCH v2 1/2] Add constants for KLV pseudo-profile.

2020-05-27 Thread Brad Hards
There are two different ways KLV is used in MISB specs - sync and async.
The corresponding text (in ST1401) says:

ISO/IEC 13818-1 Table-34 defines a stream_type = 0x15 for “Metadata carried in 
PES packets,”
and Table 2-22 defines a stream_id = 0xFC for “metadata stream.”

and

In ISO/IEC 13818-1, Table-34 defines a stream_type = 0x06 for “PES packets 
containing private
data,” and Table 2-22 defines a stream_id = 0xBD for “private_stream_1.”

These constants allow us to distinguish the two cases, as codec profiles.
---
 libavcodec/avcodec.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index f10b7a06ec..f2734bbb1e 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2102,6 +2102,9 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_ARIB_PROFILE_A 0
 #define FF_PROFILE_ARIB_PROFILE_C 1
 
+#define FF_PROFILE_KLVA_SYNC 0
+#define FF_PROFILE_KLVA_ASYNC 1
+
 /**
  * level
  * - encoding: Set by user.
-- 
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 v2 2/2] Set stream_id correctly based on KLV profile selected.

2020-05-27 Thread Brad Hards
Previously we always set STREAM_TYPE_PRIVATE_DATA, and that remains
the default value.
---
 libavformat/mpegtsenc.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index bf1a7ee13f..c4e435647d 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -353,6 +353,13 @@ static int get_dvb_stream_type(AVFormatContext *s, 
AVStream *st)
 case AV_CODEC_ID_DVB_TELETEXT:
 stream_type = STREAM_TYPE_PRIVATE_DATA;
 break;
+case AV_CODEC_ID_SMPTE_KLV:
+if (st->codecpar->profile == FF_PROFILE_KLVA_SYNC) {
+stream_type = STREAM_TYPE_METADATA;
+} else {
+stream_type = STREAM_TYPE_PRIVATE_DATA;
+}
+break;
 default:
 av_log_once(s, AV_LOG_WARNING, AV_LOG_DEBUG, &ts_st->data_st_warning,
 "Stream %d, codec %s, is muxed as a private data stream "
-- 
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] hevc_parser: drop the use of SliceHeader

2020-05-27 Thread Anton Khirnov
It is only used to store a few local variables within one function,
which is better accomplished by just declaring them on stack explicitly.

Move SliceHeader back from hevc_ps.h to hevdec.h, since it is not
related to parameters sets.
---
 libavcodec/hevc_parser.c | 57 +++--
 libavcodec/hevc_ps.h | 77 
 libavcodec/hevcdec.h | 77 
 3 files changed, 107 insertions(+), 104 deletions(-)

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 84f19b485c..5af4b788d5 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -42,7 +42,6 @@ typedef struct HEVCParserContext {
 H2645Packet pkt;
 HEVCParamSets ps;
 HEVCSEI sei;
-SliceHeader sh;
 
 int is_avc;
 int nal_length_size;
@@ -58,26 +57,28 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, 
H2645NAL *nal,
 HEVCParserContext *ctx = s->priv_data;
 HEVCParamSets *ps = &ctx->ps;
 HEVCSEI *sei = &ctx->sei;
-SliceHeader *sh = &ctx->sh;
 GetBitContext *gb = &nal->gb;
 const HEVCWindow *ow;
 int i, num = 0, den = 0;
 
-sh->first_slice_in_pic_flag = get_bits1(gb);
+unsigned int pps_id, first_slice_in_pic_flag, dependent_slice_segment_flag;
+enum HEVCSliceType slice_type;
+
+first_slice_in_pic_flag = get_bits1(gb);
 s->picture_structure = sei->picture_timing.picture_struct;
 s->field_order = sei->picture_timing.picture_struct;
 
 if (IS_IRAP_NAL(nal)) {
 s->key_frame = 1;
-sh->no_output_of_prior_pics_flag = get_bits1(gb);
+skip_bits1(gb); // no_output_of_prior_pics_flag
 }
 
-sh->pps_id = get_ue_golomb(gb);
-if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) {
-av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
+pps_id = get_ue_golomb(gb);
+if (pps_id >= HEVC_MAX_PPS_COUNT || !ps->pps_list[pps_id]) {
+av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
 return AVERROR_INVALIDDATA;
 }
-ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data;
+ps->pps = (HEVCPPS*)ps->pps_list[pps_id]->data;
 
 if (ps->pps->sps_id >= HEVC_MAX_SPS_COUNT || 
!ps->sps_list[ps->pps->sps_id]) {
 av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", 
ps->pps->sps_id);
@@ -109,51 +110,53 @@ static int hevc_parse_slice_header(AVCodecParserContext 
*s, H2645NAL *nal,
 av_reduce(&avctx->framerate.den, &avctx->framerate.num,
   num, den, 1 << 30);
 
-if (!sh->first_slice_in_pic_flag) {
+if (!first_slice_in_pic_flag) {
+unsigned int slice_segment_addr;
 int slice_address_length;
 
 if (ps->pps->dependent_slice_segments_enabled_flag)
-sh->dependent_slice_segment_flag = get_bits1(gb);
+dependent_slice_segment_flag = get_bits1(gb);
 else
-sh->dependent_slice_segment_flag = 0;
+dependent_slice_segment_flag = 0;
 
 slice_address_length = av_ceil_log2_c(ps->sps->ctb_width *
   ps->sps->ctb_height);
-sh->slice_segment_addr = get_bitsz(gb, slice_address_length);
-if (sh->slice_segment_addr >= ps->sps->ctb_width * 
ps->sps->ctb_height) {
+slice_segment_addr = get_bitsz(gb, slice_address_length);
+if (slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) {
 av_log(avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n",
-   sh->slice_segment_addr);
+   slice_segment_addr);
 return AVERROR_INVALIDDATA;
 }
 } else
-sh->dependent_slice_segment_flag = 0;
+dependent_slice_segment_flag = 0;
 
-if (sh->dependent_slice_segment_flag)
+if (dependent_slice_segment_flag)
 return 0; /* break; */
 
 for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++)
 skip_bits(gb, 1); // slice_reserved_undetermined_flag[]
 
-sh->slice_type = get_ue_golomb(gb);
-if (!(sh->slice_type == HEVC_SLICE_I || sh->slice_type == HEVC_SLICE_P ||
-  sh->slice_type == HEVC_SLICE_B)) {
+slice_type = get_ue_golomb(gb);
+if (!(slice_type == HEVC_SLICE_I || slice_type == HEVC_SLICE_P ||
+  slice_type == HEVC_SLICE_B)) {
 av_log(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
-   sh->slice_type);
+   slice_type);
 return AVERROR_INVALIDDATA;
 }
-s->pict_type = sh->slice_type == HEVC_SLICE_B ? AV_PICTURE_TYPE_B :
-   sh->slice_type == HEVC_SLICE_P ? AV_PICTURE_TYPE_P :
-   AV_PICTURE_TYPE_I;
+s->pict_type = slice_type == HEVC_SLICE_B ? AV_PICTURE_TYPE_B :
+   slice_type == HEVC_SLICE_P ? AV_PICTURE_TYPE_P :
+AV_PICTURE_TYPE_I;
 
 if (ps->pps->output_flag_presen

[FFmpeg-devel] [PATCH] hevc_refs: reduce code duplication in find_ref_idx()

2020-05-27 Thread Anton Khirnov
---
 libavcodec/hevc_refs.c | 22 ++
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 73aa6d8caf..4f6d985ae6 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -360,24 +360,14 @@ int ff_hevc_slice_rpl(HEVCContext *s)
 
 static HEVCFrame *find_ref_idx(HEVCContext *s, int poc, uint8_t use_msb)
 {
+int mask = use_msb ? ~0 : (1 << s->ps.sps->log2_max_poc_lsb) - 1;
 int i;
 
-if (use_msb) {
-for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
-HEVCFrame *ref = &s->DPB[i];
-if (ref->frame->buf[0] && (ref->sequence == s->seq_decode)) {
-if (ref->poc == poc)
-return ref;
-}
-}
-} else {
-int LtMask = (1 << s->ps.sps->log2_max_poc_lsb) - 1;
-for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
-HEVCFrame *ref = &s->DPB[i];
-if (ref->frame->buf[0] && ref->sequence == s->seq_decode) {
-if ((ref->poc & LtMask) == poc)
-return ref;
-}
+for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
+HEVCFrame *ref = &s->DPB[i];
+if (ref->frame->buf[0] && ref->sequence == s->seq_decode) {
+if ((ref->poc & mask) == poc)
+return ref;
 }
 }
 
-- 
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".

Re: [FFmpeg-devel] [PATCH v3 3/3] avcodec/h264dec: Add FF_CODEC_CAP_INIT_CLEANUP

2020-05-27 Thread Anton Khirnov
Quoting lance.lmw...@gmail.com (2020-05-27 06:40:45)
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---

The patch looks ok, but it is really unclear why is there a third
version of this patch and what is different about it.

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

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

Re: [FFmpeg-devel] [PATCH 2/3] avcodec.h: split AVCodec API into its own header

2020-05-27 Thread Anton Khirnov
Quoting James Almer (2020-05-25 15:41:57)
> On 5/25/2020 10:31 AM, Anton Khirnov wrote:
> > Quoting James Almer (2020-05-25 15:21:12)
> >> On 5/25/2020 10:12 AM, Anton Khirnov wrote:
> >>> -/**
> >>> - * Iterate over all registered codecs.
> >>> - *
> >>> - * @param opaque a pointer where libavcodec will store the iteration 
> >>> state. Must
> >>> - *   point to NULL to start the iteration.
> >>> - *
> >>> - * @return the next registered codec or NULL when the iteration is
> >>> - * finished
> >>> - */
> >>> -const AVCodec *av_codec_iterate(void **opaque);
> >>> -
> >>>  #if FF_API_NEXT
> >>
> >> Why are you not moving the deprecated functions as well? They are
> >> AVCodec related and should remain with the rest until they are
> >> effectively removed.
> > 
> > Why?
> > Seems better to me to make the new headers "clean", since new users
> > should only use the non-deprecated API. No need to distract them with
> > obsolete cruft.
> 
> Ok, that's reasonable. But why did you move the AVPacket ones, then? If
> anything, those should be hidden since they are the most confusing, like
> av_packet_free() and av_free_packet() in the same header, or pretty much
> broken and potentially dangerous, like av_dup_packet().

What can I say, I am not perfectly consistent in everything. I think I
just didn't consider this at that point. Want me to move them back?

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

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

Re: [FFmpeg-devel] [PATCH 1/3] avformat/rtspdec: use av_dict_set_int() instead

2020-05-27 Thread Anton Khirnov
>[FFmpeg-devel] [PATCH 1/3] avformat/rtspdec: use av_dict_set_int() instead
doesn't make sense: instead of what?

Something like
avformat/rtspdec: av_dict_set() -> av_dict_set_int()
would be more clear IMO

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

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

Re: [FFmpeg-devel] [PATCH] lavc/vaapi_hevc: add missing max_8bit_constraint_flag

2020-05-27 Thread Fu, Linjie
> From: Fu, Linjie 
> Sent: Tuesday, May 12, 2020 21:47
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [PATCH] lavc/vaapi_hevc: add missing max_8bit_constraint_flag
> 
> This is accidentally missed while rebasing.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/vaapi_hevc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
> index c83d481..9083331 100644
> --- a/libavcodec/vaapi_hevc.c
> +++ b/libavcodec/vaapi_hevc.c
> @@ -505,6 +505,7 @@ static int ptl_convert(const PTLCommon *general_ptl,
> H265RawProfileTierLevel *h2
>  copy_field(frame_only_constraint_flag);
>  copy_field(max_12bit_constraint_flag);
>  copy_field(max_10bit_constraint_flag);
> +copy_field(max_8bit_constraint_flag);
>  copy_field(max_422chroma_constraint_flag);
>  copy_field(max_420chroma_constraint_flag);
>  copy_field(max_monochrome_constraint_flag);
> --
> 2.7.4
Applied, thx.

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avformat/mpegtsenc: simplify code by using OFFSET() and ENC macros

2020-05-27 Thread Marton Balint



On Wed, 27 May 2020, lance.lmw...@gmail.com wrote:


On Wed, May 20, 2020 at 10:31:13PM +0800, lance.lmw...@gmail.com wrote:

From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/mpegtsenc.c | 92 +
 1 file changed, 47 insertions(+), 45 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index bf1a7ee..9909d25 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1962,94 +1962,96 @@ static int mpegts_check_bitstream(struct 
AVFormatContext *s, const AVPacket *pkt
 return ret;
 }

+#define OFFSET(x) offsetof(MpegTSWrite, x)
+#define ENC AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
 { "mpegts_transport_stream_id", "Set transport_stream_id field.",
-  offsetof(MpegTSWrite, transport_stream_id), AV_OPT_TYPE_INT,
-  { .i64 = 0x0001 }, 0x0001, 0x, AV_OPT_FLAG_ENCODING_PARAM },
+  OFFSET(transport_stream_id), AV_OPT_TYPE_INT,
+  { .i64 = 0x0001 }, 0x0001, 0x, ENC },
 { "mpegts_original_network_id", "Set original_network_id field.",
-  offsetof(MpegTSWrite, original_network_id), AV_OPT_TYPE_INT,
-  { .i64 = DVB_PRIVATE_NETWORK_START }, 0x0001, 0x, 
AV_OPT_FLAG_ENCODING_PARAM },
+  OFFSET(original_network_id), AV_OPT_TYPE_INT,
+  { .i64 = DVB_PRIVATE_NETWORK_START }, 0x0001, 0x, ENC },
 { "mpegts_service_id", "Set service_id field.",
-  offsetof(MpegTSWrite, service_id), AV_OPT_TYPE_INT,
-  { .i64 = 0x0001 }, 0x0001, 0x, AV_OPT_FLAG_ENCODING_PARAM },
+  OFFSET(service_id), AV_OPT_TYPE_INT,
+  { .i64 = 0x0001 }, 0x0001, 0x, ENC },
 { "mpegts_service_type", "Set service_type field.",
-  offsetof(MpegTSWrite, service_type), AV_OPT_TYPE_INT,
-  { .i64 = 0x01 }, 0x01, 0xff, AV_OPT_FLAG_ENCODING_PARAM, 
"mpegts_service_type" },
+  OFFSET(service_type), AV_OPT_TYPE_INT,
+  { .i64 = 0x01 }, 0x01, 0xff, ENC, "mpegts_service_type" },
 { "digital_tv", "Digital Television.",
   0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_DIGITAL_TV }, 0x01, 
0xff,
-  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+  ENC, "mpegts_service_type" },
 { "digital_radio", "Digital Radio.",
   0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_DIGITAL_RADIO }, 
0x01, 0xff,
-  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+  ENC, "mpegts_service_type" },
 { "teletext", "Teletext.",
   0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_TELETEXT }, 0x01, 
0xff,
-  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+  ENC, "mpegts_service_type" },
 { "advanced_codec_digital_radio", "Advanced Codec Digital Radio.",
   0, AV_OPT_TYPE_CONST, { .i64 = 
MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_RADIO }, 0x01, 0xff,
-  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+  ENC, "mpegts_service_type" },
 { "mpeg2_digital_hdtv", "MPEG2 Digital HDTV.",
   0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_MPEG2_DIGITAL_HDTV }, 
0x01, 0xff,
-  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+  ENC, "mpegts_service_type" },
 { "advanced_codec_digital_sdtv", "Advanced Codec Digital SDTV.",
   0, AV_OPT_TYPE_CONST, { .i64 = 
MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_SDTV }, 0x01, 0xff,
-  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+  ENC, "mpegts_service_type" },
 { "advanced_codec_digital_hdtv", "Advanced Codec Digital HDTV.",
   0, AV_OPT_TYPE_CONST, { .i64 = 
MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_HDTV }, 0x01, 0xff,
-  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+  ENC, "mpegts_service_type" },
 { "hevc_digital_hdtv", "HEVC Digital Television Service.",
   0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_HEVC_DIGITAL_HDTV }, 
0x01, 0xff,
-  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+  ENC, "mpegts_service_type" },
 { "mpegts_pmt_start_pid", "Set the first pid of the PMT.",
-  offsetof(MpegTSWrite, pmt_start_pid), AV_OPT_TYPE_INT,
-  { .i64 = 0x1000 }, FIRST_OTHER_PID, LAST_OTHER_PID, 
AV_OPT_FLAG_ENCODING_PARAM },
+  OFFSET(pmt_start_pid), AV_OPT_TYPE_INT,
+  { .i64 = 0x1000 }, FIRST_OTHER_PID, LAST_OTHER_PID, ENC },
 { "mpegts_start_pid", "Set the first pid.",
-  offsetof(MpegTSWrite, start_pid), AV_OPT_TYPE_INT,
-  { .i64 = 0x0100 }, FIRST_OTHER_PID, LAST_OTHER_PID, 
AV_OPT_FLAG_ENCODING_PARAM },
+  OFFSET(start_pid), AV_OPT_TYPE_INT,
+  { .i64 = 0x0100 }, FIRST_OTHER_PID, LAST_OTHER_PID, ENC },
 { "mpegts_m2ts_mode", "Enable m2ts mode.",
-  offsetof(MpegTSWrite, m2ts_mode), AV_OPT_TYPE_BOOL,
-  { .i64 = -1 }, -1, 1, AV_OPT_FLAG_ENCODING_PARAM },
+  OFFSET(m2ts_mode), AV_OPT_TYPE_BOOL,
+  { .i64 = -1 }, -1, 1, ENC },
 { "muxrate", NULL,
-  offsetof(MpegTSWrite, mux_rate), AV_OPT_TYPE_INT,
-  { .i64 = 1 }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+  OFFSET(mux_rate), AV_OP

Re: [FFmpeg-devel] [PATCH 2/2] lavc/hevc_refs: Fix the logic of find_ref_idx()

2020-05-27 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of Fu,
> Linjie
> Sent: Thursday, May 21, 2020 14:38
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Cc: Xu, Guangxin 
> Subject: Re: [FFmpeg-devel] [PATCH 2/2] lavc/hevc_refs: Fix the logic of
> find_ref_idx()
> 
> > From: ffmpeg-devel  On Behalf Of
> Fu,
> > Linjie
> > Sent: Monday, May 18, 2020 15:17
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Xu, Guangxin 
> > Subject: Re: [FFmpeg-devel] [PATCH 2/2] lavc/hevc_refs: Fix the logic of
> > find_ref_idx()
> >
> > > From: Fu, Linjie 
> > > Sent: Tuesday, May 12, 2020 21:44
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Xu, Guangxin ; Fu, Linjie
> 
> > > Subject: [PATCH 2/2] lavc/hevc_refs: Fix the logic of find_ref_idx()
> > >
> > > From: Xu Guangxin 
> > >
> > > Currently find_ref_idx() would trigger 2 scans in DPB to find the
> > > requested POC:
> > > 1. Firstly, ignore MSB of ref->poc and search for the requested POC;
> > > 2. Secondly, compare the entire ref->poc with requested POC;
> > >
> > > For long term reference, we are able to only check LSB if MSB is not
> > > presented(e.g. delta_poc_msb_present_flag == 0). However, for short
> > > term reference, we should never ignore poc's MSB and it should be
> > > kind of bit-exact. (Details in 8.3.2)
> > >
> > > Otherwise this leads to decoding failures like:
> > > [hevc @ 0x5638f4328600] Error constructing the frame RPS.
> > > [hevc @ 0x5638f4328600] Error parsing NAL unit #2.
> > > [hevc @ 0x5638f4338a80] Could not find ref with POC 21
> > > Error while decoding stream #0:0: Invalid data found when processing
> input
> > >
> > > Search the requested POC based on whether MSB is used, and avoid
> > > the 2-times scan for DPB buffer. This benefits both native HEVC
> > > decoder and integrated HW decoders.
> > >
> > > Signed-off-by: Linjie Fu 
> > > ---
> > >
> > > Since it's kind of difficult to generate an identical bitstream for
> > > fate or test, I'd like to elaborate more about one of the failures:
> > >
> > > requested POC = 5;
> > > LtMask = (1 << 4) - 1 = 15;
> > > ref[0]->poc = 21; // unexpected ref for poc = 5 (short term)
> > > ref[1]->poc = 5;  // expected ref for poc = 5 (short term)
> > >
> > > Hence find_ref_idx() would wrongly return a ref with poc = 21, which
> > > leads to the decoding error.
> > >
> > >  libavcodec/hevc_refs.c | 38 --
> > >  1 file changed, 20 insertions(+), 18 deletions(-)
> > >
> > > diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
> > > index 7870a72..73aa6d8 100644
> > > --- a/libavcodec/hevc_refs.c
> > > +++ b/libavcodec/hevc_refs.c
> > > @@ -358,24 +358,26 @@ int ff_hevc_slice_rpl(HEVCContext *s)
> > >  return 0;
> > >  }
> > >
> > > -static HEVCFrame *find_ref_idx(HEVCContext *s, int poc)
> > > +static HEVCFrame *find_ref_idx(HEVCContext *s, int poc, uint8_t
> > use_msb)
> > >  {
> > >  int i;
> > > -int LtMask = (1 << s->ps.sps->log2_max_poc_lsb) - 1;
> > >
> > > -for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
> > > -HEVCFrame *ref = &s->DPB[i];
> > > -if (ref->frame->buf[0] && (ref->sequence == s->seq_decode)) {
> > > -if ((ref->poc & LtMask) == poc)
> > > -return ref;
> > > +if (use_msb) {
> > > +for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
> > > +HEVCFrame *ref = &s->DPB[i];
> > > +if (ref->frame->buf[0] && (ref->sequence == s->seq_decode)) {
> > > +if (ref->poc == poc)
> > > +return ref;
> > > +}
> > >  }
> > > -}
> > > -
> > > -for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
> > > -HEVCFrame *ref = &s->DPB[i];
> > > -if (ref->frame->buf[0] && ref->sequence == s->seq_decode) {
> > > -if (ref->poc == poc || (ref->poc & LtMask) == poc)
> > > -return ref;
> > > +} else {
> > > +int LtMask = (1 << s->ps.sps->log2_max_poc_lsb) - 1;
> > > +for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
> > > +HEVCFrame *ref = &s->DPB[i];
> > > +if (ref->frame->buf[0] && ref->sequence == s->seq_decode) {
> > > +if ((ref->poc & LtMask) == poc)
> > > +return ref;
> > > +}
> > >  }
> > >  }
> > >
> > > @@ -427,9 +429,9 @@ static HEVCFrame
> > > *generate_missing_ref(HEVCContext *s, int poc)
> > >
> > >  /* add a reference with the given poc to the list and mark it as used in
> DPB
> > > */
> > >  static int add_candidate_ref(HEVCContext *s, RefPicList *list,
> > > - int poc, int ref_flag)
> > > + int poc, int ref_flag, uint8_t use_msb)
> > >  {
> > > -HEVCFrame *ref = find_ref_idx(s, poc);
> > > +HEVCFrame *ref = find_ref_idx(s, poc, use_msb);
> > >
> > >  if (ref == s->ref || list->nb_refs >= HEVC_MAX_REFS)
> > >  return AVERROR_INVALIDDATA;
> > > @@ -485,7 +487,7 @@ int ff_hevc_frame_rps(HEVCConte