[FFmpeg-cvslog] avcodec/nvenc: fix vbv buffer size in cq mode

2022-12-08 Thread Timo Rothenpieler
ffmpeg | branch: master | Timo Rothenpieler  | Thu Dec  
8 12:31:00 2022 +0100| [9ca139b2aa1e25b87072d8321402fa200edb894d] | committer: 
Timo Rothenpieler

avcodec/nvenc: fix vbv buffer size in cq mode

The CQ calculation gets thrown off and behaves very nonsensical
if it isn't set to 0.

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

 libavcodec/nvenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 8a776e5737..f6df7cb6ac 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1114,8 +1114,9 @@ static av_cold void 
nvenc_setup_rate_control(AVCodecContext *avctx)
 
 av_log(avctx, AV_LOG_VERBOSE, "CQ(%d) mode enabled.\n", tmp_quality);
 
-//CQ mode shall discard avg bitrate & honor max bitrate;
+// CQ mode shall discard avg bitrate/vbv buffer size and honor only 
max bitrate
 ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate = 0;
+ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size = 0;
 ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;
 }
 }

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

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


[FFmpeg-cvslog] avcodec/nvenc: fix vbv buffer size in cq mode

2022-12-08 Thread Timo Rothenpieler
ffmpeg | branch: release/5.1 | Timo Rothenpieler  | Thu 
Dec  8 12:31:00 2022 +0100| [807afa59cca8f6019c4be4043de87a52ee11741c] | 
committer: Timo Rothenpieler

avcodec/nvenc: fix vbv buffer size in cq mode

The CQ calculation gets thrown off and behaves very nonsensical
if it isn't set to 0.

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

 libavcodec/nvenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index e19378736f..4450df774c 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1083,8 +1083,9 @@ static av_cold void 
nvenc_setup_rate_control(AVCodecContext *avctx)
 
 av_log(avctx, AV_LOG_VERBOSE, "CQ(%d) mode enabled.\n", tmp_quality);
 
-//CQ mode shall discard avg bitrate & honor max bitrate;
+// CQ mode shall discard avg bitrate/vbv buffer size and honor only 
max bitrate
 ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate = 0;
+ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size = 0;
 ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;
 }
 }

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

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


[FFmpeg-cvslog] avcodec/nvenc: fix vbv buffer size in cq mode

2022-12-08 Thread Timo Rothenpieler
ffmpeg | branch: release/5.0 | Timo Rothenpieler  | Thu 
Dec  8 12:31:00 2022 +0100| [df2e08e4526a0c87d33cdc1fbddcc878857bf8af] | 
committer: Timo Rothenpieler

avcodec/nvenc: fix vbv buffer size in cq mode

The CQ calculation gets thrown off and behaves very nonsensical
if it isn't set to 0.

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

 libavcodec/nvenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 850c46022b..9386aadae2 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1078,8 +1078,9 @@ static av_cold void 
nvenc_setup_rate_control(AVCodecContext *avctx)
 
 av_log(avctx, AV_LOG_VERBOSE, "CQ(%d) mode enabled.\n", tmp_quality);
 
-//CQ mode shall discard avg bitrate & honor max bitrate;
+// CQ mode shall discard avg bitrate/vbv buffer size and honor only 
max bitrate
 ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate = 0;
+ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size = 0;
 ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;
 }
 }

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

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


[FFmpeg-cvslog] avcodec/nvenc: fix vbv buffer size in cq mode

2022-12-08 Thread Timo Rothenpieler
ffmpeg | branch: release/4.4 | Timo Rothenpieler  | Thu 
Dec  8 12:31:00 2022 +0100| [b48951bd29fbec166428efb5a0e27f51ff98fd84] | 
committer: Timo Rothenpieler

avcodec/nvenc: fix vbv buffer size in cq mode

The CQ calculation gets thrown off and behaves very nonsensical
if it isn't set to 0.

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

 libavcodec/nvenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 906915b5ca..0ce61041ef 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1025,8 +1025,9 @@ static av_cold void 
nvenc_setup_rate_control(AVCodecContext *avctx)
 
 av_log(avctx, AV_LOG_VERBOSE, "CQ(%d) mode enabled.\n", tmp_quality);
 
-//CQ mode shall discard avg bitrate & honor max bitrate;
+// CQ mode shall discard avg bitrate/vbv buffer size and honor only 
max bitrate
 ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate = 0;
+ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size = 0;
 ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;
 }
 }

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

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


[FFmpeg-cvslog] avcodec/nvenc: fix vbv buffer size in cq mode

2022-12-08 Thread Timo Rothenpieler
ffmpeg | branch: release/4.3 | Timo Rothenpieler  | Thu 
Dec  8 12:31:00 2022 +0100| [540b9826b3859e35a2df330a5912311843708e7c] | 
committer: Timo Rothenpieler

avcodec/nvenc: fix vbv buffer size in cq mode

The CQ calculation gets thrown off and behaves very nonsensical
if it isn't set to 0.

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

 libavcodec/nvenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 03fdd70029..bea4b5538c 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -956,8 +956,9 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext 
*avctx)
 
 av_log(avctx, AV_LOG_VERBOSE, "CQ(%d) mode enabled.\n", tmp_quality);
 
-//CQ mode shall discard avg bitrate & honor max bitrate;
+// CQ mode shall discard avg bitrate/vbv buffer size and honor only 
max bitrate
 ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate = 0;
+ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size = 0;
 ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;
 }
 }

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

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


[FFmpeg-cvslog] avcodec/nvenc: fix vbv buffer size in cq mode

2022-12-08 Thread Timo Rothenpieler
ffmpeg | branch: release/4.2 | Timo Rothenpieler  | Thu 
Dec  8 12:31:00 2022 +0100| [a1b534bf8320ddbd416a9a1c9feaf29448dd1fc9] | 
committer: Timo Rothenpieler

avcodec/nvenc: fix vbv buffer size in cq mode

The CQ calculation gets thrown off and behaves very nonsensical
if it isn't set to 0.

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

 libavcodec/nvenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 0b0b5d79bb..ff018fef5f 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -920,8 +920,9 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext 
*avctx)
 
 av_log(avctx, AV_LOG_VERBOSE, "CQ(%d) mode enabled.\n", tmp_quality);
 
-//CQ mode shall discard avg bitrate & honor max bitrate;
+// CQ mode shall discard avg bitrate/vbv buffer size and honor only 
max bitrate
 ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate = 0;
+ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size = 0;
 ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;
 }
 }

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

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


[FFmpeg-cvslog] avfilter: add corr video filter

2022-12-08 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Tue Dec  6 21:31:33 
2022 +0100| [f0f19f3d3d58eb9030fdf54884c5ea94e5481604] | committer: Paul B Mahol

avfilter: add corr video filter

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

 Changelog|   1 +
 doc/filters.texi |  24 
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/version.h|   2 +-
 libavfilter/vf_corr.c| 338 +++
 6 files changed, 366 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 8a3f3550a8..af2dd65f8f 100644
--- a/Changelog
+++ b/Changelog
@@ -26,6 +26,7 @@ version :
 - QSV AV1 encoder
 - QSV decoding and encoding for 10/12bit 422, 10/12bit 444 HEVC and VP9
 - showcwt multimedia filter
+- corr video filter
 
 
 version 5.1:
diff --git a/doc/filters.texi b/doc/filters.texi
index f45b579a69..1cb7fd94a7 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10110,6 +10110,30 @@ ffmpeg -f lavfi -i 
nullsrc=s=100x100,coreimage=filter=CIQRCodeGenerator@@inputMe
 @end example
 @end itemize
 
+@section corr
+
+Obtain the correlation between two input videos.
+
+This filter takes two input videos.
+
+Both input videos must have the same resolution and pixel format for
+this filter to work correctly. Also it assumes that both inputs
+have the same number of frames, which are compared one by one.
+
+The obtained per component, average, min and max correlation is printed through
+the logging system.
+
+The filter stores the calculated correlation of each frame in frame metadata.
+
+This filter also supports the @ref{framesync} options.
+
+In the below example the input file @file{main.mpg} being processed is compared
+with the reference file @file{ref.mpg}.
+
+@example
+ffmpeg -i main.mpg -i ref.mpg -lavfi corr -f null -
+@end example
+
 @section cover_rect
 
 Cover a rectangular object
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 3c6a7b03f4..172495a93b 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -241,6 +241,7 @@ OBJS-$(CONFIG_CONVOLUTION_OPENCL_FILTER) += 
vf_convolution_opencl.o opencl.o
 OBJS-$(CONFIG_CONVOLVE_FILTER)   += vf_convolve.o framesync.o
 OBJS-$(CONFIG_COPY_FILTER)   += vf_copy.o
 OBJS-$(CONFIG_COREIMAGE_FILTER)  += vf_coreimage.o
+OBJS-$(CONFIG_CORR_FILTER)   += vf_corr.o framesync.o
 OBJS-$(CONFIG_COVER_RECT_FILTER) += vf_cover_rect.o lavfutils.o
 OBJS-$(CONFIG_CROP_FILTER)   += vf_crop.o
 OBJS-$(CONFIG_CROPDETECT_FILTER) += vf_cropdetect.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 347afa787b..1c474dab0a 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -221,6 +221,7 @@ extern const AVFilter ff_vf_convolution_opencl;
 extern const AVFilter ff_vf_convolve;
 extern const AVFilter ff_vf_copy;
 extern const AVFilter ff_vf_coreimage;
+extern const AVFilter ff_vf_corr;
 extern const AVFilter ff_vf_cover_rect;
 extern const AVFilter ff_vf_crop;
 extern const AVFilter ff_vf_cropdetect;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 69f3af5a9d..a4710b253b 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #include "version_major.h"
 
-#define LIBAVFILTER_VERSION_MINOR  51
+#define LIBAVFILTER_VERSION_MINOR  52
 #define LIBAVFILTER_VERSION_MICRO 100
 
 
diff --git a/libavfilter/vf_corr.c b/libavfilter/vf_corr.c
new file mode 100644
index 00..65d8b09767
--- /dev/null
+++ b/libavfilter/vf_corr.c
@@ -0,0 +1,338 @@
+/*
+ * 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
+ */
+
+/**
+ * @file
+ * Calculate the correlation between two input videos.
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "avfilter.h"
+#include "drawutils.h"
+#include "formats.h"
+#include "framesync.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct CorrContext {
+const AVClass *class;
+FFFrameSync fs;
+double score, min_score, max_score, score_comp[4];
+uint64_t nb_frames;
+int is_rgb;
+uint8_t rgba_map[4];
+int max[4];
+char comps[4];
+in

[FFmpeg-cvslog] avcodec/mediacodecenc: check missing Surface

2022-12-08 Thread Zhao Zhili
ffmpeg | branch: master | Zhao Zhili  | Thu Nov 24 
00:49:26 2022 +0800| [567633895bafbf1fba26de937535ee35c135b814] | committer: 
Zhao Zhili

avcodec/mediacodecenc: check missing Surface

It's an invalid combination of Java MediaCodec with ANativeWindow.

Signed-off-by: Zhao Zhili 

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

 libavcodec/mediacodecenc.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index 7cdde59945..a4390a9df6 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -167,6 +167,16 @@ static av_cold int mediacodec_init(AVCodecContext *avctx)
 av_log(avctx, AV_LOG_ERROR, "Missing hw_device_ctx or 
hwaccel_context for AV_PIX_FMT_MEDIACODEC\n");
 goto bailout;
 }
+/* Although there is a method ANativeWindow_toSurface() introduced in
+ * API level 26, it's easier and safe to always require a Surface for
+ * Java MediaCodec.
+ */
+if (!s->use_ndk_codec && !s->window->surface) {
+ret = AVERROR(EINVAL);
+av_log(avctx, AV_LOG_ERROR, "Missing jobject Surface for 
AV_PIX_FMT_MEDIACODEC. "
+"Please note that Java MediaCodec doesn't work with 
ANativeWindow.\n");
+goto bailout;
+}
 }
 
 for (int i = 0; i < FF_ARRAY_ELEMS(color_formats); i++) {

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

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


[FFmpeg-cvslog] avcodec/mediacodecenc: add option to select codec by name

2022-12-08 Thread Zhao Zhili
ffmpeg | branch: master | Zhao Zhili  | Fri Nov 25 
12:01:29 2022 +0800| [3dcb630ca1906c66c3e8d042de46470b51659c27] | committer: 
Zhao Zhili

avcodec/mediacodecenc: add option to select codec by name

Signed-off-by: Zhao Zhili 

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

 libavcodec/mediacodecenc.c | 8 +++-
 libavcodec/version.h   | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index a4390a9df6..693faca118 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -43,6 +43,7 @@ typedef struct MediaCodecEncContext {
 AVClass *avclass;
 FFAMediaCodec *codec;
 int use_ndk_codec;
+const char *name;
 FFANativeWindow *window;
 
 int fps;
@@ -126,7 +127,10 @@ static av_cold int mediacodec_init(AVCodecContext *avctx)
 av_assert0(0);
 }
 
-s->codec = ff_AMediaCodec_createEncoderByType(codec_mime, 
s->use_ndk_codec);
+if (s->name)
+s->codec = ff_AMediaCodec_createCodecByName(s->name, s->use_ndk_codec);
+else
+s->codec = ff_AMediaCodec_createEncoderByType(codec_mime, 
s->use_ndk_codec);
 if (!s->codec) {
 av_log(avctx, AV_LOG_ERROR, "Failed to create encoder for type %s\n",
codec_mime);
@@ -474,6 +478,8 @@ static const AVCodecHWConfigInternal *const 
mediacodec_hw_configs[] = {
 static const AVOption common_options[] = {
 { "ndk_codec", "Use MediaCodec from NDK",
 OFFSET(use_ndk_codec), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 
1, VE },
+{ "codec_name", "Select codec by name",
+OFFSET(name), AV_OPT_TYPE_STRING, {0}, 0, 0, VE },
 { NULL },
 };
 
diff --git a/libavcodec/version.h b/libavcodec/version.h
index d149bc6c46..9e66920593 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
 #include "version_major.h"
 
 #define LIBAVCODEC_VERSION_MINOR  54
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \

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

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


[FFmpeg-cvslog] avcodec/mediacodec: fix missing crop info when use NDK MediaCodec

2022-12-08 Thread Zhao Zhili
ffmpeg | branch: master | Zhao Zhili  | Thu Nov 24 
00:49:25 2022 +0800| [a63834b236c17eae72faf23aebcba32f911809e6] | committer: 
Zhao Zhili

avcodec/mediacodec: fix missing crop info when use NDK MediaCodec

Signed-off-by: Zhao Zhili 

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

 libavcodec/mediacodec_wrapper.c   | 38 +++---
 libavcodec/mediacodec_wrapper.h   | 24 
 libavcodec/mediacodecdec_common.c |  4 
 3 files changed, 63 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c
index 555058e907..193eac8da6 100644
--- a/libavcodec/mediacodec_wrapper.c
+++ b/libavcodec/mediacodec_wrapper.c
@@ -1861,12 +1861,16 @@ typedef struct FFAMediaFormatNdk {
 bool (*getSize)(AMediaFormat*, const char *name, size_t *out);
 bool (*getBuffer)(AMediaFormat*, const char *name, void** data, size_t 
*size);
 bool (*getString)(AMediaFormat*, const char *name, const char **out);
+bool (*getRect)(AMediaFormat *, const char *name,
+int32_t *left, int32_t *top, int32_t *right, int32_t 
*bottom);
 
 void (*setInt32)(AMediaFormat*, const char* name, int32_t value);
 void (*setInt64)(AMediaFormat*, const char* name, int64_t value);
 void (*setFloat)(AMediaFormat*, const char* name, float value);
 void (*setString)(AMediaFormat*, const char* name, const char* value);
 void (*setBuffer)(AMediaFormat*, const char* name, const void* data, 
size_t size);
+void (*setRect)(AMediaFormat *, const char *name,
+int32_t left, int32_t top, int32_t right, int32_t bottom);
 } FFAMediaFormatNdk;
 
 typedef struct FFAMediaCodecNdk {
@@ -1940,9 +1944,12 @@ static FFAMediaFormat 
*mediaformat_ndk_create(AMediaFormat *impl)
 if (!format->libmedia)
 goto error;
 
-#define GET_SYMBOL(sym) \
-format->sym = dlsym(format->libmedia, "AMediaFormat_" #sym);\
-if (!format->sym)   \
+#define GET_OPTIONAL_SYMBOL(sym) \
+format->sym = dlsym(format->libmedia, "AMediaFormat_" #sym);
+
+#define GET_SYMBOL(sym) \
+GET_OPTIONAL_SYMBOL(sym)\
+if (!format->sym)   \
 goto error;
 
 GET_SYMBOL(new)
@@ -1956,14 +1963,17 @@ static FFAMediaFormat 
*mediaformat_ndk_create(AMediaFormat *impl)
 GET_SYMBOL(getSize)
 GET_SYMBOL(getBuffer)
 GET_SYMBOL(getString)
+GET_OPTIONAL_SYMBOL(getRect)
 
 GET_SYMBOL(setInt32)
 GET_SYMBOL(setInt64)
 GET_SYMBOL(setFloat)
 GET_SYMBOL(setString)
 GET_SYMBOL(setBuffer)
+GET_OPTIONAL_SYMBOL(setRect)
 
 #undef GET_SYMBOL
+#undef GET_OPTIONAL_SYMBOL
 
 if (impl) {
 format->impl = impl;
@@ -2047,6 +2057,15 @@ static int mediaformat_ndk_getString(FFAMediaFormat* 
ctx, const char *name, cons
 return ret;
 }
 
+static int mediaformat_ndk_getRect(FFAMediaFormat *ctx, const char *name,
+   int32_t *left, int32_t *top, int32_t 
*right, int32_t *bottom)
+{
+FFAMediaFormatNdk *format = (FFAMediaFormatNdk *)ctx;
+if (!format->getRect)
+return AVERROR_EXTERNAL;
+return format->getRect(format->impl, name, left, top, right, bottom);
+}
+
 static void mediaformat_ndk_setInt32(FFAMediaFormat* ctx, const char* name, 
int32_t value)
 {
 FFAMediaFormatNdk *format = (FFAMediaFormatNdk *)ctx;
@@ -2077,6 +2096,17 @@ static void mediaformat_ndk_setBuffer(FFAMediaFormat* 
ctx, const char* name, voi
 format->setBuffer(format->impl, name, data, size);
 }
 
+static void mediaformat_ndk_setRect(FFAMediaFormat *ctx, const char *name,
+ int32_t left, int32_t top, int32_t right, 
int32_t bottom)
+{
+FFAMediaFormatNdk *format = (FFAMediaFormatNdk *)ctx;
+if (!format->setRect) {
+av_log(ctx, AV_LOG_WARNING, "Doesn't support setRect\n");
+return;
+}
+format->setRect(format->impl, name, left, top, right, bottom);
+}
+
 static char *mediacodec_ndk_getName(FFAMediaCodec *ctx)
 {
 FFAMediaCodecNdk *codec = (FFAMediaCodecNdk *)ctx;
@@ -2433,12 +2463,14 @@ static const FFAMediaFormat media_format_ndk = {
 .getFloat = mediaformat_ndk_getFloat,
 .getBuffer = mediaformat_ndk_getBuffer,
 .getString = mediaformat_ndk_getString,
+.getRect = mediaformat_ndk_getRect,
 
 .setInt32 = mediaformat_ndk_setInt32,
 .setInt64 = mediaformat_ndk_setInt64,
 .setFloat = mediaformat_ndk_setFloat,
 .setString = mediaformat_ndk_setString,
 .setBuffer = mediaformat_ndk_setBuffer,
+.setRect = mediaformat_ndk_setRect,
 };
 
 static const FFAMediaCodec media_codec_ndk = {
diff --git a/libavcodec/mediacodec_wrapper.h b/libavcodec/mediacodec_wrapper.h
index f15ad66d83..1b81e6db84 100644
--- a/libavcodec/mediacodec_wrapper.h
+++ b/libavcodec/mediacodec_wrapper.h
@@ -73,12 +73,18 @@ struct FFAMediaFormat {
 int (*getFloat)(FFAM

[FFmpeg-cvslog] avcodec/mediacodec_wrapper: use hardcoded value of profiles from MediaCodecInfo

2022-12-08 Thread Zhao Zhili
ffmpeg | branch: master | Zhao Zhili  | Mon Nov 28 
00:40:04 2022 +0800| [0da8802e957783ba4131fbf306f1f53b4b78ab4e] | committer: 
Zhao Zhili

avcodec/mediacodec_wrapper: use hardcoded value of profiles from MediaCodecInfo

Those are static const values and documented at
https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel
No runtime query is needed. Now the method can be used without JVM.

Signed-off-by: Zhao Zhili 

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

 libavcodec/mediacodec_wrapper.c | 98 ++---
 1 file changed, 33 insertions(+), 65 deletions(-)

diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c
index 193eac8da6..7ddf93ccc7 100644
--- a/libavcodec/mediacodec_wrapper.c
+++ b/libavcodec/mediacodec_wrapper.c
@@ -57,19 +57,6 @@ struct JNIAMediaCodecListFields {
 jclass codec_profile_level_class;
 jfieldID profile_id;
 jfieldID level_id;
-
-jfieldID avc_profile_baseline_id;
-jfieldID avc_profile_main_id;
-jfieldID avc_profile_extended_id;
-jfieldID avc_profile_high_id;
-jfieldID avc_profile_high10_id;
-jfieldID avc_profile_high422_id;
-jfieldID avc_profile_high444_id;
-
-jfieldID hevc_profile_main_id;
-jfieldID hevc_profile_main10_id;
-jfieldID hevc_profile_main10_hdr10_id;
-
 };
 
 static const struct FFJniField jni_amediacodeclist_mapping[] = {
@@ -95,18 +82,6 @@ static const struct FFJniField jni_amediacodeclist_mapping[] 
= {
 { "android/media/MediaCodecInfo$CodecProfileLevel", "profile", "I", 
FF_JNI_FIELD, offsetof(struct JNIAMediaCodecListFields, profile_id), 1 },
 { "android/media/MediaCodecInfo$CodecProfileLevel", "level", "I", 
FF_JNI_FIELD, offsetof(struct JNIAMediaCodecListFields, level_id), 1 },
 
-{ "android/media/MediaCodecInfo$CodecProfileLevel", 
"AVCProfileBaseline", "I", FF_JNI_STATIC_FIELD, offsetof(struct 
JNIAMediaCodecListFields, avc_profile_baseline_id), 1 },
-{ "android/media/MediaCodecInfo$CodecProfileLevel", "AVCProfileMain", 
"I", FF_JNI_STATIC_FIELD, offsetof(struct JNIAMediaCodecListFields, 
avc_profile_main_id), 1 },
-{ "android/media/MediaCodecInfo$CodecProfileLevel", 
"AVCProfileExtended", "I", FF_JNI_STATIC_FIELD, offsetof(struct 
JNIAMediaCodecListFields, avc_profile_extended_id), 1 },
-{ "android/media/MediaCodecInfo$CodecProfileLevel", "AVCProfileHigh", 
"I", FF_JNI_STATIC_FIELD, offsetof(struct JNIAMediaCodecListFields, 
avc_profile_high_id), 1 },
-{ "android/media/MediaCodecInfo$CodecProfileLevel", 
"AVCProfileHigh10", "I", FF_JNI_STATIC_FIELD, offsetof(struct 
JNIAMediaCodecListFields, avc_profile_high10_id), 1 },
-{ "android/media/MediaCodecInfo$CodecProfileLevel", 
"AVCProfileHigh422", "I", FF_JNI_STATIC_FIELD, offsetof(struct 
JNIAMediaCodecListFields, avc_profile_high422_id), 1 },
-{ "android/media/MediaCodecInfo$CodecProfileLevel", 
"AVCProfileHigh444", "I", FF_JNI_STATIC_FIELD, offsetof(struct 
JNIAMediaCodecListFields, avc_profile_high444_id), 1 },
-
-{ "android/media/MediaCodecInfo$CodecProfileLevel", "HEVCProfileMain", 
"I", FF_JNI_STATIC_FIELD, offsetof(struct JNIAMediaCodecListFields, 
hevc_profile_main_id), 0 },
-{ "android/media/MediaCodecInfo$CodecProfileLevel", 
"HEVCProfileMain10", "I", FF_JNI_STATIC_FIELD, offsetof(struct 
JNIAMediaCodecListFields, hevc_profile_main10_id), 0 },
-{ "android/media/MediaCodecInfo$CodecProfileLevel", 
"HEVCProfileMain10HDR10", "I", FF_JNI_STATIC_FIELD, offsetof(struct 
JNIAMediaCodecListFields, hevc_profile_main10_hdr10_id), 0 },
-
 { NULL }
 };
 
@@ -326,71 +301,64 @@ static const FFAMediaCodec media_codec_jni;
 
 int ff_AMediaCodecProfile_getProfileFromAVCodecContext(AVCodecContext *avctx)
 {
-int ret = -1;
-
-JNIEnv *env = NULL;
-struct JNIAMediaCodecListFields jfields = { 0 };
-jfieldID field_id = 0;
-
-JNI_GET_ENV_OR_RETURN(env, avctx, -1);
-
-if (ff_jni_init_jfields(env, &jfields, jni_amediacodeclist_mapping, 0, 
avctx) < 0) {
-goto done;
-}
+// Copy and modified from MediaCodecInfo.java
+static const int AVCProfileBaseline = 0x01;
+static const int AVCProfileMain = 0x02;
+static const int AVCProfileExtended = 0x04;
+static const int AVCProfileHigh = 0x08;
+static const int AVCProfileHigh10   = 0x10;
+static const int AVCProfileHigh422  = 0x20;
+static const int AVCProfileHigh444  = 0x40;
+static const int AVCProfileConstrainedBaseline = 0x1;
+static const int AVCProfileConstrainedHigh = 0x8;
+
+static const int HEVCProfileMain= 0x01;
+static const int HEVCProfileMain10  = 0x02;
+static const int HEVCProfileMainStill   = 0x04;
+static const int HEVCProfileMain10HDR10 = 0x1000;
+static const int HEVCProfileMain10HDR10Plus = 0x2000;
+
+// Unused yet.
+(void)AVCProfileConstr

[FFmpeg-cvslog] avcodec/mediacodecenc: configure profile

2022-12-08 Thread Zhao Zhili
ffmpeg | branch: master | Zhao Zhili  | Mon Nov 28 
00:51:37 2022 +0800| [2401494e96446c7f9cedf73cee548932db0a6e2a] | committer: 
Zhao Zhili

avcodec/mediacodecenc: configure profile

Signed-off-by: Zhao Zhili 

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

 libavcodec/mediacodecenc.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index 693faca118..69246ad693 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -213,6 +213,11 @@ static av_cold int mediacodec_init(AVCodecContext *avctx)
 ff_AMediaFormat_setInt32(format, "frame-rate", s->fps);
 ff_AMediaFormat_setInt32(format, "i-frame-interval", gop);
 
+ret = ff_AMediaCodecProfile_getProfileFromAVCodecContext(avctx);
+if (ret > 0) {
+av_log(avctx, AV_LOG_DEBUG, "set profile to 0x%x\n", ret);
+ff_AMediaFormat_setInt32(format, "profile", ret);
+}
 
 ret = ff_AMediaCodec_getConfigureFlagEncode(s->codec);
 ret = ff_AMediaCodec_configure(s->codec, format, s->window, NULL, ret);

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

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


[FFmpeg-cvslog] avcodec/vqcdec: Check width & 15

2022-12-08 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed 
Nov 23 21:27:13 2022 +0100| [a9d15d43eb0f976b982bf2ad6ec1d8ac084c7ded] | 
committer: Michael Niedermayer

avcodec/vqcdec: Check width & 15

Various parts of the code assume that width can be divided by various powers of 
2
without rounding

Fixes: out of array access
Fixes: 
53623/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VQC_fuzzer-6209269924233216

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross 
Signed-off-by: Michael Niedermayer 

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

 libavcodec/vqcdec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/vqcdec.c b/libavcodec/vqcdec.c
index 18cd99462e..c3bce87974 100644
--- a/libavcodec/vqcdec.c
+++ b/libavcodec/vqcdec.c
@@ -71,6 +71,9 @@ static av_cold int vqc_decode_init(AVCodecContext * avctx)
 static AVOnce init_static_once = AV_ONCE_INIT;
 VqcContext *s = avctx->priv_data;
 
+if (avctx->width & 15)
+return AVERROR_PATCHWELCOME;
+
 s->vectors = av_malloc((avctx->width * avctx->height * 3) / 2);
 if (!s->vectors)
 return AVERROR(ENOMEM);

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

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


[FFmpeg-cvslog] avcodec/mjpegdec: check that component linesize is always valid

2022-12-08 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Thu Dec  8 23:49:33 
2022 +0100| [55753fc712622744093c8050b779c3d830c427cb] | committer: Paul B Mahol

avcodec/mjpegdec: check that component linesize is always valid

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

 libavcodec/mjpegdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 9b7465abe7..228d3077b9 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1512,7 +1512,7 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int 
nb_components, int Ah,
"error y=%d x=%d\n", mb_y, mb_x);
 return AVERROR_INVALIDDATA;
 }
-if (ptr) {
+if (ptr && linesize[c]) {
 s->idsp.idct_put(ptr, linesize[c], s->block);
 if (s->bits & 7)
 shift_output(s, ptr, linesize[c]);

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

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


[FFmpeg-cvslog] lavu/pixdesc: handle xv30be in av_[read|write]_image_line

2022-12-08 Thread Philip Langdale
ffmpeg | branch: master | Philip Langdale  | Sun Dec  4 
12:53:57 2022 -0800| [9651f873f8ce15c5d4380f49488900bbf6e6c731] | committer: 
Philip Langdale

lavu/pixdesc: handle xv30be in av_[read|write]_image_line

xv30be is an obnoxious format that I shouldn't have included in the
first place. xv30 packs 3 10bit channels into 32bits and while our
byte-oriented logic can handle Little Endian correctly, it cannot
handle Big Endian. To avoid that, I marked xv30be as a bitstream
format, but while that didn't produce FATE errors, it turns out that
the existing read/write code silently produces incorrect results, which
can be revealed via ubsan.

In all likelyhood, the correct fix here is to remove the format. As
this format is only used by Intel vaapi, it's only going to show up
in LE form, so we could just drop the BE version. But I don't want to
deal with creating a hole in the pixfmt list and all the weirdness that
comes from that. Instead, I decided to write the correct read/write
code for it.

And that code isn't too bad, as long as it's specialised for this
format, as the channels are all bit-aligned inside a 32bit word.

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

 libavutil/pixdesc.c | 70 ++---
 1 file changed, 50 insertions(+), 20 deletions(-)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index ca3e204a0b..62a2ae08d9 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -46,19 +46,35 @@ void av_read_image_line2(void *dst,
 uint32_t *dst32 = dst;
 
 if (flags & AV_PIX_FMT_FLAG_BITSTREAM) {
-int skip = x * step + comp.offset;
-const uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
-int shift = 8 - depth - (skip & 7);
+if (depth == 10) {
+// Assume all channels are packed into a 32bit value
+const uint8_t *byte_p = data[plane] + y * linesize[plane];
+const uint32_t *p = (uint32_t *)byte_p;
 
-while (w--) {
-int val = (*p >> shift) & mask;
-if (read_pal_component)
-val = data[1][4*val + c];
-shift -= step;
-p -= shift >> 3;
-shift &= 7;
-if (dst_element_size == 4) *dst32++ = val;
-else   *dst16++ = val;
+while (w--) {
+int val = AV_RB32(p);
+val = (val >> comp.offset) & mask;
+if (read_pal_component)
+val = data[1][4*val + c];
+if (dst_element_size == 4) *dst32++ = val;
+else   *dst16++ = val;
+p++;
+}
+} else {
+int skip = x * step + comp.offset;
+const uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
+int shift = 8 - depth - (skip & 7);
+
+while (w--) {
+int val = (*p >> shift) & mask;
+if (read_pal_component)
+val = data[1][4*val + c];
+shift -= step;
+p -= shift >> 3;
+shift &= 7;
+if (dst_element_size == 4) *dst32++ = val;
+else   *dst16++ = val;
+}
 }
 } else {
 const uint8_t *p = data[plane] + y * linesize[plane] +
@@ -109,15 +125,29 @@ void av_write_image_line2(const void *src,
 const uint16_t *src16 = src;
 
 if (flags & AV_PIX_FMT_FLAG_BITSTREAM) {
-int skip = x * step + comp.offset;
-uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
-int shift = 8 - depth - (skip & 7);
+if (depth == 10) {
+// Assume all channels are packed into a 32bit value
+const uint8_t *byte_p = data[plane] + y * linesize[plane];
+uint32_t *p = (uint32_t *)byte_p;
+int offset = comp.offset;
+uint32_t mask  = ((1ULL << depth) - 1) << offset;
 
-while (w--) {
-*p |= (src_element_size == 4 ? *src32++ : *src16++) << shift;
-shift -= step;
-p -= shift >> 3;
-shift &= 7;
+while (w--) {
+uint16_t val = src_element_size == 4 ? *src32++ : *src16++;
+AV_WB32(p, (AV_RB32(p) & ~mask) | (val << offset));
+p++;
+}
+} else {
+int skip = x * step + comp.offset;
+uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
+int shift = 8 - depth - (skip & 7);
+
+while (w--) {
+*p |= (src_element_size == 4 ? *src32++ : *src16++) << shift;
+shift -= step;
+p -= shift >> 3;
+shift &= 7;
+}
 }
 } else {
 int shift = comp.shift;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffm