[FFmpeg-cvslog] avcodec/apedec: Fix 48khz 24bit below insane level

2023-08-25 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Aug 25 16:59:15 2023 +0200| [80ad0e2198df4e2961928d8304da58df6db77ec4] | 
committer: Michael Niedermayer

avcodec/apedec: Fix 48khz 24bit below insane level

Fixes: Ticket9816
Fixes: vlc.ape and APE_48K_24bit_2CH_02_01.ape

Regression since: ed0001482a74b60f3d5bc5cd7e304c9d65b2fcd5.

Signed-off-by: Michael Niedermayer 

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

 libavcodec/apedec.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 7bad8500e1..a9d5eb7f33 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -1184,7 +1184,8 @@ static void predictor_decode_mono_3930(APEContext *ctx, 
int count)
 static av_always_inline int predictor_update_filter(APEPredictor64 *p,
 const int decoded, const 
int filter,
 const int delayA,  const 
int delayB,
-const int adaptA,  const 
int adaptB)
+const int adaptA,  const 
int adaptB,
+int compression_level)
 {
 int64_t predictionA, predictionB;
 int32_t sign;
@@ -1212,7 +1213,13 @@ static av_always_inline int 
predictor_update_filter(APEPredictor64 *p,
   p->buf[delayB - 3] * p->coeffsB[filter][3] +
   p->buf[delayB - 4] * p->coeffsB[filter][4];
 
-p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA + 
(predictionB >> 1)) >> 10);
+if (compression_level < COMPRESSION_LEVEL_INSANE) {
+predictionA = (int32_t)predictionA;
+predictionB = (int32_t)predictionB;
+p->lastA[filter] = decoded + ((int32_t)(predictionA + (predictionB >> 
1)) >> 10);
+} else {
+p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA + 
(predictionB >> 1)) >> 10);
+}
 p->filterA[filter] = p->lastA[filter] + ((int64_t)(p->filterA[filter] * 
31ULL) >> 5);
 
 sign = APESIGN(decoded);
@@ -1240,10 +1247,12 @@ static void predictor_decode_stereo_3950(APEContext 
*ctx, int count)
 while (count--) {
 /* Predictor Y */
 *decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB,
-YADAPTCOEFFSA, YADAPTCOEFFSB);
+YADAPTCOEFFSA, YADAPTCOEFFSB,
+ctx->compression_level);
 decoded0++;
 *decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB,
-XADAPTCOEFFSA, XADAPTCOEFFSB);
+XADAPTCOEFFSA, XADAPTCOEFFSB,
+ctx->compression_level);
 decoded1++;
 
 /* Combined */

___
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/apedec: Fix CRC for 24bps and bigendian

2023-08-25 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Aug 25 00:24:21 2023 +0200| [696e161919f18f13be0f82f41715b445d31022d7] | 
committer: Michael Niedermayer

avcodec/apedec: Fix CRC for 24bps and bigendian

Fixes CRC for vlc.ape and APE_48K_24bit_2CH_02_01.ape

Signed-off-by: Michael Niedermayer 

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

 libavcodec/apedec.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 613c76df0b..7bad8500e1 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -1625,13 +1625,24 @@ static int ape_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 s->samples -= blockstodecode;
 
 if (avctx->err_recognition & AV_EF_CRCCHECK &&
-s->fileversion >= 3900 && s->bps < 24) {
+s->fileversion >= 3900) {
 uint32_t crc = s->CRC_state;
 const AVCRC *crc_tab = av_crc_get_table(AV_CRC_32_IEEE_LE);
+int stride = s->bps == 24 ? 4 : (s->bps>>3);
+int offset = s->bps == 24;
+int bytes  = s->bps >> 3;
+
 for (i = 0; i < blockstodecode; i++) {
 for (ch = 0; ch < s->channels; ch++) {
-uint8_t *smp = frame->data[ch] + (i*(s->bps >> 3));
-crc = av_crc(crc_tab, crc, smp, s->bps >> 3);
+#if HAVE_BIGENDIAN
+uint8_t *smp_native = frame->data[ch] + i*stride;
+uint8_t smp[4];
+for(int j = 0; jdata[ch] + i*stride;
+#endif
+crc = av_crc(crc_tab, crc, smp+offset, bytes);
 }
 }
 

___
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] lavfi/dnn: Add OpenVINO API 2.0 support

2023-08-25 Thread Wenbin Chen
ffmpeg | branch: master | Wenbin Chen  | Tue Aug 15 
16:26:31 2023 +0800| [e79bd1f1b158b84c4aa5083b5e2af2de8ede3b0e] | committer: 
Guo Yejun

lavfi/dnn: Add OpenVINO API 2.0 support

OpenVINO API 2.0 was released in March 2022, which introduced new
features.
This commit implements current OpenVINO features with new 2.0 APIs. And
will add other features in API 2.0.
Please add installation path, which include openvino.pc, to
PKG_CONFIG_PATH mannually for new OpenVINO libs config.

Signed-off-by: Ting Fu 
Signed-off-by: Wenbin Chen 

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

 configure  |   6 +-
 libavfilter/dnn/dnn_backend_openvino.c | 515 +++--
 2 files changed, 487 insertions(+), 34 deletions(-)

diff --git a/configure b/configure
index 04bb9fe9dd..c1e592729a 100755
--- a/configure
+++ b/configure
@@ -2459,6 +2459,7 @@ HAVE_LIST="
 texi2html
 xmllint
 zlib_gzip
+openvino2
 "
 
 # options emitted with CONFIG_ prefix but not available on the command line
@@ -6770,8 +6771,9 @@ enabled libopenh264   && require_pkg_config 
libopenh264 openh264 wels/codec_
 enabled libopenjpeg   && { check_pkg_config libopenjpeg "libopenjp2 >= 
2.1.0" openjpeg.h opj_version ||
{ require_pkg_config libopenjpeg "libopenjp2 >= 
2.1.0" openjpeg.h opj_version -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } }
 enabled libopenmpt&& require_pkg_config libopenmpt "libopenmpt >= 
0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create -lstdc++ && append 
libopenmpt_extralibs "-lstdc++"
-enabled libopenvino   && { check_pkg_config libopenvino openvino 
c_api/ie_c_api.h ie_c_api_version ||
-   require libopenvino c_api/ie_c_api.h 
ie_c_api_version -linference_engine_c_api; }
+enabled libopenvino   && { { check_pkg_config libopenvino openvino 
openvino/c/openvino.h ov_core_create && enable openvino2; } ||
+{ check_pkg_config libopenvino openvino 
c_api/ie_c_api.h ie_c_api_version ||
+  require libopenvino c_api/ie_c_api.h 
ie_c_api_version -linference_engine_c_api; } }
 enabled libopus   && {
 enabled libopus_decoder && {
 require_pkg_config libopus opus opus_multistream.h 
opus_multistream_decoder_create
diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 46cbe8270e..4922833b07 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -32,7 +32,11 @@
 #include "libavutil/detection_bbox.h"
 #include "../internal.h"
 #include "safe_queue.h"
+#if HAVE_OPENVINO2
+#include 
+#else
 #include 
+#endif
 #include "dnn_backend_common.h"
 
 typedef struct OVOptions{
@@ -51,9 +55,20 @@ typedef struct OVContext {
 typedef struct OVModel{
 OVContext ctx;
 DNNModel *model;
+#if HAVE_OPENVINO2
+ov_core_t *core;
+ov_model_t *ov_model;
+ov_compiled_model_t *compiled_model;
+ov_output_const_port_t* input_port;
+ov_preprocess_input_info_t* input_info;
+ov_output_const_port_t* output_port;
+ov_preprocess_output_info_t* output_info;
+ov_preprocess_prepostprocessor_t* preprocess;
+#else
 ie_core_t *core;
 ie_network_t *network;
 ie_executable_network_t *exe_network;
+#endif
 SafeQueue *request_queue;   // holds OVRequestItem
 Queue *task_queue;  // holds TaskItem
 Queue *lltask_queue; // holds LastLevelTaskItem
@@ -63,10 +78,15 @@ typedef struct OVModel{
 
 // one request for one call to openvino
 typedef struct OVRequestItem {
-ie_infer_request_t *infer_request;
 LastLevelTaskItem **lltasks;
 uint32_t lltask_count;
+#if HAVE_OPENVINO2
+ov_infer_request_t *infer_request;
+ov_callback_t callback;
+#else
 ie_complete_call_back_t callback;
+ie_infer_request_t *infer_request;
+#endif
 } OVRequestItem;
 
 #define APPEND_STRING(generated_string, iterate_string)
\
@@ -85,11 +105,61 @@ static const AVOption dnn_openvino_options[] = {
 
 AVFILTER_DEFINE_CLASS(dnn_openvino);
 
+#if HAVE_OPENVINO2
+static const struct {
+ov_status_e status;
+int av_err;
+const char *desc;
+} ov2_errors[] = {
+{ OK, 0,  "success"},
+{ GENERAL_ERROR,  AVERROR_EXTERNAL,   "general error"  },
+{ NOT_IMPLEMENTED,AVERROR(ENOSYS),"not implemented"},
+{ NETWORK_NOT_LOADED, AVERROR_EXTERNAL,   "network not loaded" },
+{ PARAMETER_MISMATCH, AVERROR(EINVAL),"parameter mismatch" },
+{ NOT_FOUND,  AVERROR_EXTERNAL,   "not found"  },
+{ OUT_OF_BOUNDS,  AVERROR(EOVERFLOW), "out of bounds"  },
+{ UNEXPECTED, AVERROR_EXTERNAL,   "unexpected" },
+{ REQUEST