[FFmpeg-devel] [PATCH] qsv: add ${includedir}/mfx to the search path for old version of libmfx

2020-08-18 Thread Haihao Xiang
${inludedir}/mfx has been added to Cflags in libmfx.pc in new versions
of libmfx. We may add ${includedir}/mfx to the search path for old
version of libmfx so that we may inlcude mxfxxx.h instead of
mfx/mf.h in FFmpeg

If your libmfx comes without pkg-config support, this patch requires a
small change to your environment setting (e.g. adding
/opt/intel/mediasdk/include/mfx instead of /opt/intel/mediasdk/include
to CFLAGS) so that the build can find the headers
---
 configure| 15 ---
 fftools/ffmpeg_qsv.c |  2 +-
 libavcodec/qsv.c |  8 
 libavcodec/qsv.h |  2 +-
 libavcodec/qsv_internal.h|  2 +-
 libavcodec/qsvdec.c  |  2 +-
 libavcodec/qsvdec.h  |  2 +-
 libavcodec/qsvdec_h2645.c|  2 +-
 libavcodec/qsvdec_other.c|  2 +-
 libavcodec/qsvenc.c  |  2 +-
 libavcodec/qsvenc.h  |  2 +-
 libavcodec/qsvenc_h264.c |  2 +-
 libavcodec/qsvenc_hevc.c |  2 +-
 libavcodec/qsvenc_jpeg.c |  2 +-
 libavcodec/qsvenc_mpeg2.c|  2 +-
 libavcodec/qsvenc_vp9.c  |  2 +-
 libavfilter/qsvvpp.h |  2 +-
 libavfilter/vf_deinterlace_qsv.c |  2 +-
 libavfilter/vf_scale_qsv.c   |  2 +-
 libavutil/hwcontext_opencl.c |  2 +-
 libavutil/hwcontext_qsv.c|  2 +-
 libavutil/hwcontext_qsv.h|  2 +-
 22 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/configure b/configure
index 6faff9bc7b..c01dcb279b 100755
--- a/configure
+++ b/configure
@@ -1458,6 +1458,14 @@ check_pkg_config(){
 eval add_cflags \$${name}_cflags
 }
 
+append_subdir_to_pkg_includedir(){
+log append_subdir_to_pkg_includedir "$@"
+name="$1"
+subdir="$2"
+incdir=$($pkg_config --variable=includedir $name)
+add_cflags -I$incdir/$subdir
+}
+
 test_exec(){
 test_ld "cc" "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
 }
@@ -6362,10 +6370,11 @@ enabled liblensfun&& require_pkg_config 
liblensfun lensfun lensfun.h lf_
 # Media SDK or Intel Media Server Studio, these don't come with
 # pkg-config support.  Instead, users should make sure that the build
 # can find the libraries and headers through other means.
-enabled libmfx&& { check_pkg_config libmfx libmfx "mfx/mfxvideo.h" 
MFXInit ||
-   { require libmfx "mfx/mfxvideo.h" MFXInit 
"-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } }
+enabled libmfx&& { check_pkg_config libmfx libmfx "mfxvideo.h" 
MFXInit ||
+   { check_pkg_config libmfx libmfx 
"mfx/mfxvideo.h" MFXInit && append_subdir_to_pkg_includedir libmfx mfx; } ||
+   { require libmfx "mfxvideo.h" MFXInit "-llibmfx 
$advapi32_extralibs" && warn "using libmfx without pkg-config"; } }
 if enabled libmfx; then
-   check_cc MFX_CODEC_VP9 "mfx/mfxvp9.h mfx/mfxstructures.h" "MFX_CODEC_VP9"
+   check_cc MFX_CODEC_VP9 "mfxvp9.h mfxstructures.h" "MFX_CODEC_VP9"
 fi
 
 enabled libmodplug&& require_pkg_config libmodplug libmodplug 
libmodplug/modplug.h ModPlug_Load
diff --git a/fftools/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c
index 960c88b69d..0df0b5832c 100644
--- a/fftools/ffmpeg_qsv.c
+++ b/fftools/ffmpeg_qsv.c
@@ -16,7 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include 
+#include 
 #include 
 
 #include "libavutil/dict.h"
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 17720070f1..55184e075a 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -18,9 +18,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -37,7 +37,7 @@
 #include "qsv_internal.h"
 
 #if QSV_VERSION_ATLEAST(1, 12)
-#include "mfx/mfxvp8.h"
+#include "mfxvp8.h"
 #endif
 
 int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
diff --git a/libavcodec/qsv.h b/libavcodec/qsv.h
index b77158ec26..04ae0d6f34 100644
--- a/libavcodec/qsv.h
+++ b/libavcodec/qsv.h
@@ -21,7 +21,7 @@
 #ifndef AVCODEC_QSV_H
 #define AVCODEC_QSV_H
 
-#include 
+#include 
 
 #include "libavutil/buffer.h"
 
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 6b2fbbe252..4609e7a53b 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -39,7 +39,7 @@
 #include "libavutil/hwcontext_vaapi.h"
 #endif
 
-#include 
+#include 
 
 #include "libavutil/frame.h"
 
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index fc25dc73e5..9e319ae709 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -24,7 +24,7 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #include "libavutil/common.h"
 #include "libavutil/hwcontext.h"
diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
index cb948f516d..435e8eae3e 100644
--- a/libavcodec/qsvdec.h
+++ b/libavcodec/qsvdec.h
@@ -26,7 +26,7 @@
 

Re: [FFmpeg-devel] [PATCH 1/1] Added avs2 tags for MKV

2020-08-18 Thread Ze Yuan
>>The ordinary versions of these players don't use libavformat's Matroska
>>demuxer at all, so I presume that your patch intends to fix the problem
>>by changing how the files are muxed.

Right. Without avs2 tag, MKV will use AVI compatible mode automatically I think.

>>Matroska does not support AVS2 natively at all atm. If you want to
>>change that, you should open an issue/pull request at [1]. And you
>>should refrain from already creating such files (or use a CodecID like
>>"V_AVS2/EXPERIMENTAL"). As long as there is no official support for AVS2
>>in Matroska, there won't be support for it in FFmpeg.

I think we can still try. It seems HEVC was supported by many tools before MKV 
mapping added. Also the encoder (ffmpeg) and the popular players 
(ffplay/vlc/mpc-hc) all work perfectly with this change.

More information:
Standard document:
   1857.4-2018 - IEEE Standard for Second-Generation IEEE 1857 Video 
Coding (https://ieeexplore.ieee.org/document/8821610)

Encoding tool:
  Ffmpeg with avs2 enabled: 
https://github.com/xatabhk/FFmpeg-avs2-avs3/releases/tag/v4.3.1-avs-avs3-0812
  Command line: ffmpeg -i .mp4 -vcodec avs2 -acodec copy 
_avs2.mkv

Video payers:
(1) Ffmpeg with avs2 enabled: 
(https://github.com/xatabhk/FFmpeg-avs2-avs3/releases/tag/v4.3.1-avs-avs3-0812):
  Command line: ffplay _avs2.mkv
(2) VLC 3.0.x with avs2 enabled: 
https://github.com/xatabhk/vlc-3.0-avs2-avs3/releases/tag/v3.0-avs2-avs3-200812
(3) Mpc-hc 1.9.x with avs2 enabled: 
https://gitee.com/zhengtianbo/cavs-avs2-avs3_decoder_added_to_mpc_hc/releases

Avs2-MKV samples:
   https://github.com/xatabhk/avs2-avs3-video-samples

From: Andreas Rheinhardt
Sent: Wednesday, August 19, 2020 6:19 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 1/1] Added avs2 tags for MKV

Ze Yuan:
> From d4ae49d8fabdb70435c92457c153a869dc55a980 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?=E9=83=91=E5=A4=A9=E6=B3=A2?= 
> Date: Wed, 19 Aug 2020 05:20:18 +0800
> Subject: [PATCH] Added avs2 tags for MKV container.
>
> Before the patch, an avs2 encoded MKV video results in dropped frames in asv2 
> enabled video players.
>
> Here are the asv2/avs3 enabled video players:
> VLC 3: 
> https://github.com/xatabhk/vlc-3.0-avs2-avs3/releases/tag/v3.0-avs2-avs3-200812
> Mpc-hc: 
> https://gitee.com/zhengtianbo/cavs-avs2-avs3_decoder_added_to_mpc_hc/releases

The ordinary versions of these players don't use libavformat's Matroska
demuxer at all, so I presume that your patch intends to fix the problem
by changing how the files are muxed. This information should actually be
directly included in the commit message so that one doesn't have to guess.

>
> ---
> libavformat/isom.c | 3 ++-
> libavformat/matroska.c | 1 +
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/isom.c b/libavformat/isom.c
> index 209bbac5d1..080a457a4e 100644
> --- a/libavformat/isom.c
> +++ b/libavformat/isom.c
> @@ -255,7 +255,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
>  { AV_CODEC_ID_PNG,   MKTAG('M', 'N', 'G', ' ') },
>
>  { AV_CODEC_ID_VC1, MKTAG('v', 'c', '-', '1') }, /* SMPTE RP 2025 */
> -{ AV_CODEC_ID_CAVS, MKTAG('a', 'v', 's', '2') },
> +{ AV_CODEC_ID_CAVS, MKTAG('c', 'a', 'v', 's') },
> +{ AV_CODEC_ID_AVS2, MKTAG('a', 'v', 's', '2') },

By changing ff_codec_movvideo_tags you are changing more than just
Matroska in contradiction to what the commit message states.

>
>  { AV_CODEC_ID_DIRAC, MKTAG('d', 'r', 'a', 'c') },
>  { AV_CODEC_ID_DNXHD, MKTAG('A', 'V', 'd', 'n') }, /* AVID DNxHD */
> diff --git a/libavformat/matroska.c b/libavformat/matroska.c
> index 7c56aba403..2ce60c6277 100644
> --- a/libavformat/matroska.c
> +++ b/libavformat/matroska.c
> @@ -78,6 +78,7 @@ const CodecTags ff_mkv_codec_tags[]={
>  {"S_HDMV/TEXTST", AV_CODEC_ID_HDMV_TEXT_SUBTITLE},
>
>  {"V_AV1", AV_CODEC_ID_AV1},
> +{"V_AVS2"   , AV_CODEC_ID_AVS2},

Matroska does not support AVS2 natively at all atm. If you want to
change that, you should open an issue/pull request at [1]. And you
should refrain from already creating such files (or use a CodecID like
"V_AVS2/EXPERIMENTAL"). As long as there is no official support for AVS2
in Matroska, there won't be support for it in FFmpeg.

- Andreas

[1]: https://github.com/cellar-wg/matroska-specification/
___
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 1/1] Added avs2 tags for MKV

2020-08-18 Thread Ze Yuan
>>The ordinary versions of these players don't use libavformat's Matroska
>>demuxer at all, so I presume that your patch intends to fix the problem
>>by changing how the files are muxed. 

Right. Without avs2 tag, MKV will use AVI compatible mode automatically I think.

>>Matroska does not support AVS2 natively at all atm. If you want to
>>change that, you should open an issue/pull request at [1]. And you
>>should refrain from already creating such files (or use a CodecID like
>>"V_AVS2/EXPERIMENTAL"). As long as there is no official support for AVS2
>>in Matroska, there won't be support for it in FFmpeg.

I think we can still try. It seems HEVC was supported by many tools before MKV 
mapping added. Also the encoder (ffmpeg) and the popular 
players(ffplay/vlc/mpc-hc) all work perfectly with this change.

More information:
Standard document: 
   1857.4-2018 - IEEE Standard for Second-Generation IEEE 1857 Video 
Coding (https://ieeexplore.ieee.org/document/8821610)

Encoding tool:
  Ffmpeg with avs2 enabled: 
https://github.com/xatabhk/FFmpeg-avs2-avs3/releases/tag/v4.3.1-avs-avs3-0812
  Command line: ffmpeg -i .mp4 -vcodec avs2 -acodec copy 
_avs2.mkv

Video payers:
(1) Ffmpeg with avs2 enabled: 
(https://github.com/xatabhk/FFmpeg-avs2-avs3/releases/tag/v4.3.1-avs-avs3-0812):
  Command line: ffplay _avs2.mkv
(2) VLC 3.0.x with avs2 enabled: 
https://github.com/xatabhk/vlc-3.0-avs2-avs3/releases/tag/v3.0-avs2-avs3-200812
(3) Mpc-hc 1.9.x with avs2 enabled: 
https://gitee.com/zhengtianbo/cavs-avs2-avs3_decoder_added_to_mpc_hc/releases

Avs2-MKV samples:
   https://github.com/xatabhk/avs2-avs3-video-samples

From: Andreas Rheinhardt 
Sent: Wednesday, August 19, 2020 6:19 AM
To: ffmpeg-devel@ffmpeg.org 
Subject: Re: [FFmpeg-devel] [PATCH 1/1] Added avs2 tags for MKV

Ze Yuan:
> From d4ae49d8fabdb70435c92457c153a869dc55a980 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?=E9=83=91=E5=A4=A9=E6=B3=A2?= 
> Date: Wed, 19 Aug 2020 05:20:18 +0800
> Subject: [PATCH] Added avs2 tags for MKV container.
> 
> Before the patch, an avs2 encoded MKV video results in dropped frames in asv2 
> enabled video players.
> 
> Here are the asv2/avs3 enabled video players:
> VLC 3: 
> https://github.com/xatabhk/vlc-3.0-avs2-avs3/releases/tag/v3.0-avs2-avs3-200812
> Mpc-hc: 
> https://gitee.com/zhengtianbo/cavs-avs2-avs3_decoder_added_to_mpc_hc/releases

The ordinary versions of these players don't use libavformat's Matroska
demuxer at all, so I presume that your patch intends to fix the problem
by changing how the files are muxed. This information should actually be
directly included in the commit message so that one doesn't have to guess.

> 
> ---
> libavformat/isom.c | 3 ++-
> libavformat/matroska.c | 1 +
> 2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/isom.c b/libavformat/isom.c
> index 209bbac5d1..080a457a4e 100644
> --- a/libavformat/isom.c
> +++ b/libavformat/isom.c
> @@ -255,7 +255,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
>  { AV_CODEC_ID_PNG,   MKTAG('M', 'N', 'G', ' ') },
> 
>  { AV_CODEC_ID_VC1, MKTAG('v', 'c', '-', '1') }, /* SMPTE RP 2025 */
> -{ AV_CODEC_ID_CAVS, MKTAG('a', 'v', 's', '2') },
> +{ AV_CODEC_ID_CAVS, MKTAG('c', 'a', 'v', 's') },
> +{ AV_CODEC_ID_AVS2, MKTAG('a', 'v', 's', '2') },

By changing ff_codec_movvideo_tags you are changing more than just
Matroska in contradiction to what the commit message states.

> 
>  { AV_CODEC_ID_DIRAC, MKTAG('d', 'r', 'a', 'c') },
>  { AV_CODEC_ID_DNXHD, MKTAG('A', 'V', 'd', 'n') }, /* AVID DNxHD */
> diff --git a/libavformat/matroska.c b/libavformat/matroska.c
> index 7c56aba403..2ce60c6277 100644
> --- a/libavformat/matroska.c
> +++ b/libavformat/matroska.c
> @@ -78,6 +78,7 @@ const CodecTags ff_mkv_codec_tags[]={
>  {"S_HDMV/TEXTST", AV_CODEC_ID_HDMV_TEXT_SUBTITLE},
> 
>  {"V_AV1", AV_CODEC_ID_AV1},
> +{"V_AVS2"   , AV_CODEC_ID_AVS2},

Matroska does not support AVS2 natively at all atm. If you want to
change that, you should open an issue/pull request at [1]. And you
should refrain from already creating such files (or use a CodecID like
"V_AVS2/EXPERIMENTAL"). As long as there is no official support for AVS2
in Matroska, there won't be support for it in FFmpeg.

- Andreas

[1]: https://github.com/cellar-wg/matroska-specification/
___
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 1/1] Added avs2 tags for MKV

2020-08-18 Thread Andreas Rheinhardt
Ze Yuan:
> From d4ae49d8fabdb70435c92457c153a869dc55a980 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?=E9=83=91=E5=A4=A9=E6=B3=A2?= 
> Date: Wed, 19 Aug 2020 05:20:18 +0800
> Subject: [PATCH] Added avs2 tags for MKV container.
> 
> Before the patch, an avs2 encoded MKV video results in dropped frames in asv2 
> enabled video players.
> 
> Here are the asv2/avs3 enabled video players:
> VLC 3: 
> https://github.com/xatabhk/vlc-3.0-avs2-avs3/releases/tag/v3.0-avs2-avs3-200812
> Mpc-hc: 
> https://gitee.com/zhengtianbo/cavs-avs2-avs3_decoder_added_to_mpc_hc/releases

The ordinary versions of these players don't use libavformat's Matroska
demuxer at all, so I presume that your patch intends to fix the problem
by changing how the files are muxed. This information should actually be
directly included in the commit message so that one doesn't have to guess.

> 
> ---
> libavformat/isom.c | 3 ++-
> libavformat/matroska.c | 1 +
> 2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/isom.c b/libavformat/isom.c
> index 209bbac5d1..080a457a4e 100644
> --- a/libavformat/isom.c
> +++ b/libavformat/isom.c
> @@ -255,7 +255,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
>  { AV_CODEC_ID_PNG,   MKTAG('M', 'N', 'G', ' ') },
> 
>  { AV_CODEC_ID_VC1, MKTAG('v', 'c', '-', '1') }, /* SMPTE RP 2025 */
> -{ AV_CODEC_ID_CAVS, MKTAG('a', 'v', 's', '2') },
> +{ AV_CODEC_ID_CAVS, MKTAG('c', 'a', 'v', 's') },
> +{ AV_CODEC_ID_AVS2, MKTAG('a', 'v', 's', '2') },

By changing ff_codec_movvideo_tags you are changing more than just
Matroska in contradiction to what the commit message states.

> 
>  { AV_CODEC_ID_DIRAC, MKTAG('d', 'r', 'a', 'c') },
>  { AV_CODEC_ID_DNXHD, MKTAG('A', 'V', 'd', 'n') }, /* AVID DNxHD */
> diff --git a/libavformat/matroska.c b/libavformat/matroska.c
> index 7c56aba403..2ce60c6277 100644
> --- a/libavformat/matroska.c
> +++ b/libavformat/matroska.c
> @@ -78,6 +78,7 @@ const CodecTags ff_mkv_codec_tags[]={
>  {"S_HDMV/TEXTST", AV_CODEC_ID_HDMV_TEXT_SUBTITLE},
> 
>  {"V_AV1", AV_CODEC_ID_AV1},
> +{"V_AVS2"   , AV_CODEC_ID_AVS2},

Matroska does not support AVS2 natively at all atm. If you want to
change that, you should open an issue/pull request at [1]. And you
should refrain from already creating such files (or use a CodecID like
"V_AVS2/EXPERIMENTAL"). As long as there is no official support for AVS2
in Matroska, there won't be support for it in FFmpeg.

- Andreas

[1]: https://github.com/cellar-wg/matroska-specification/
___
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/avidec: Fix memleak when error happens after creating DV stream

2020-08-18 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
The memleak can be reproduced with e.g. the first 163 bytes of
https://samples.ffmpeg.org/archive/all/avi+dvvideo+pcm_s16le++ffmpeg-avidec554-crash.avi

 libavformat/avidec.c | 31 +--
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 5fc3e01aa9..08b864f19a 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -113,6 +113,7 @@ static const AVMetadataConv avi_metadata_conv[] = {
 { 0 },
 };
 
+static int avi_read_close(AVFormatContext *s);
 static int avi_load_index(AVFormatContext *s);
 static int guess_ni_flag(AVFormatContext *s);
 
@@ -464,6 +465,7 @@ static int calculate_bitrate(AVFormatContext *s)
 return 1;
 }
 
+#define RETURN_ERROR(code) do { ret = (code); goto fail; } while (0)
 static int avi_read_header(AVFormatContext *s)
 {
 AVIContext *avi = s->priv_data;
@@ -499,7 +501,7 @@ static int avi_read_header(AVFormatContext *s)
 frame_period = 0;
 for (;;) {
 if (avio_feof(pb))
-goto fail;
+RETURN_ERROR(AVERROR_INVALIDDATA);
 tag  = avio_rl32(pb);
 size = avio_rl32(pb);
 
@@ -571,12 +573,12 @@ static int avi_read_header(AVFormatContext *s)
 stream_index++;
 st = avformat_new_stream(s, NULL);
 if (!st)
-goto fail;
+RETURN_ERROR(AVERROR(ENOMEM));
 
 st->id = stream_index;
 ast= av_mallocz(sizeof(AVIStream));
 if (!ast)
-goto fail;
+RETURN_ERROR(AVERROR(ENOMEM));
 st->priv_data = ast;
 }
 if (amv_file_format)
@@ -592,12 +594,12 @@ static int avi_read_header(AVFormatContext *s)
 /* After some consideration -- I don't think we
  * have to support anything but DV in type1 AVIs. */
 if (s->nb_streams != 1)
-goto fail;
+RETURN_ERROR(AVERROR_INVALIDDATA);
 
 if (handler != MKTAG('d', 'v', 's', 'd') &&
 handler != MKTAG('d', 'v', 'h', 'd') &&
 handler != MKTAG('d', 'v', 's', 'l'))
-goto fail;
+return AVERROR_INVALIDDATA;
 
 if (!CONFIG_DV_DEMUXER)
 return AVERROR_DEMUXER_NOT_FOUND;
@@ -697,7 +699,7 @@ static int avi_read_header(AVFormatContext *s)
"Invalid sample_size %d at stream %d\n",
ast->sample_size,
stream_index);
-goto fail;
+RETURN_ERROR(AVERROR_INVALIDDATA);
 }
 av_log(s, AV_LOG_WARNING,
"Invalid sample_size %d at stream %d "
@@ -927,7 +929,7 @@ static int avi_read_header(AVFormatContext *s)
 av_log(s, AV_LOG_WARNING, "New extradata in strd 
chunk, freeing previous one.\n");
 }
 if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 
0)
-return ret;
+goto fail;
 }
 
 if (st->codecpar->extradata_size & 1) //FIXME check if the 
encoder really did this correctly
@@ -945,7 +947,7 @@ static int avi_read_header(AVFormatContext *s)
 avi->use_odml &&
 read_odml_index(s, 0) < 0 &&
 (s->error_recognition & AV_EF_EXPLODE))
-goto fail;
+RETURN_ERROR(AVERROR_INVALIDDATA);
 avio_seek(pb, pos + size, SEEK_SET);
 break;
 case MKTAG('v', 'p', 'r', 'p'):
@@ -980,7 +982,7 @@ static int avi_read_header(AVFormatContext *s)
 if (s->nb_streams) {
 ret = avi_read_tag(s, s->streams[s->nb_streams - 1], tag, 
size);
 if (ret < 0)
-return ret;
+goto fail;
 break;
 }
 default:
@@ -991,7 +993,7 @@ static int avi_read_header(AVFormatContext *s)
"I will ignore it and try to continue anyway.\n",
av_fourcc2str(tag), size);
 if (s->error_recognition & AV_EF_EXPLODE)
-goto fail;
+RETURN_ERROR(AVERROR_INVALIDDATA);
 avi->movi_list = avio_tell(pb) - 4;
 avi->movi_end  = avi->fsize;
 goto end_of_header;
@@ -1008,9 +1010,7 @@ static int avi_read_header(AVFormatContext *s)
 end_of_header:
 /* check stream number */
 if (stream_index != s->nb_streams - 1) {
-
-fail:
-return AVERROR_INVALIDDATA;
+RETURN_ERROR(AVERROR_INVALIDDATA);
 }
 
 if (!avi->index_loaded && (pb->seekable & AVIO_SEEKABLE_NORMAL))
@@ -1019,7 +1019,7 @@ fail:
 avi->index_loaded|= 1;
 
 if ((ret = 

[FFmpeg-devel] [PATCH 1/1] Added avs2 tags for MKV

2020-08-18 Thread Ze Yuan
>From d4ae49d8fabdb70435c92457c153a869dc55a980 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=83=91=E5=A4=A9=E6=B3=A2?= 
Date: Wed, 19 Aug 2020 05:20:18 +0800
Subject: [PATCH] Added avs2 tags for MKV container.

Before the patch, an avs2 encoded MKV video results in dropped frames in asv2 
enabled video players.

Here are the asv2/avs3 enabled video players:
VLC 3: 
https://github.com/xatabhk/vlc-3.0-avs2-avs3/releases/tag/v3.0-avs2-avs3-200812
Mpc-hc: 
https://gitee.com/zhengtianbo/cavs-avs2-avs3_decoder_added_to_mpc_hc/releases

---
libavformat/isom.c | 3 ++-
libavformat/matroska.c | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/isom.c b/libavformat/isom.c
index 209bbac5d1..080a457a4e 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -255,7 +255,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 { AV_CODEC_ID_PNG,   MKTAG('M', 'N', 'G', ' ') },

 { AV_CODEC_ID_VC1, MKTAG('v', 'c', '-', '1') }, /* SMPTE RP 2025 */
-{ AV_CODEC_ID_CAVS, MKTAG('a', 'v', 's', '2') },
+{ AV_CODEC_ID_CAVS, MKTAG('c', 'a', 'v', 's') },
+{ AV_CODEC_ID_AVS2, MKTAG('a', 'v', 's', '2') },

 { AV_CODEC_ID_DIRAC, MKTAG('d', 'r', 'a', 'c') },
 { AV_CODEC_ID_DNXHD, MKTAG('A', 'V', 'd', 'n') }, /* AVID DNxHD */
diff --git a/libavformat/matroska.c b/libavformat/matroska.c
index 7c56aba403..2ce60c6277 100644
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -78,6 +78,7 @@ const CodecTags ff_mkv_codec_tags[]={
 {"S_HDMV/TEXTST", AV_CODEC_ID_HDMV_TEXT_SUBTITLE},

 {"V_AV1", AV_CODEC_ID_AV1},
+{"V_AVS2"   , AV_CODEC_ID_AVS2},
 {"V_DIRAC"  , AV_CODEC_ID_DIRAC},
 {"V_FFV1"   , AV_CODEC_ID_FFV1},
 {"V_MJPEG"  , AV_CODEC_ID_MJPEG},
-- 
2.25.1


0001-Added-avs2-tags-for-MKV-container.patch
Description: 0001-Added-avs2-tags-for-MKV-container.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] fate: add fate-sub-dvb test

2020-08-18 Thread Michael Niedermayer
On Tue, Aug 18, 2020 at 10:45:50PM +0200, Clément Bœsch wrote:
> On Tue, Aug 11, 2020 at 02:19:01PM +0200, Clément Bœsch wrote:
> [...]
> > +FATE_SUBTITLES-$(call ALLYES, MPEGTS_DEMUXER DVBSUB_DECODER 
> > DVBSUB_ENCODER) += fate-sub-dvb
> > +fate-sub-dvb: CMD = framecrc -i $(TARGET_SAMPLES)/sub/dvbsubtest_filter.ts 
> > -map s:0 -c dvbsub
> 
> Can someone upload that sample¹ to fate-samples/sub/dvbsubtest_filter.ts
> so we can apply this patch now that JEEB fixed MPEG-TS DVB demuxing?
> 
> [1]: https://trac.ffmpeg.org/raw-attachment/ticket/8844/dvbsubtest_filter.ts

Uplaod requests are best sent to or CC-ed to samples-requ...@ffmpeg.org 
(already added to CC)

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.


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 3/4] libavcodec/jpeg2000: Modify cleanup

2020-08-18 Thread gautamramk
From: Gautam Ramakrishnan 

This patch makes the ff_jpeg2000_cleanup
function take in an extra parameter which
indicates whether it is called from the
encoder or decoder.
---
 libavcodec/j2kenc.c  | 2 +-
 libavcodec/jpeg2000.c| 2 +-
 libavcodec/jpeg2000.h| 2 +-
 libavcodec/jpeg2000dec.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 1c31e48d61..264bae3f73 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1218,7 +1218,7 @@ static void cleanup(Jpeg2000EncoderContext *s)
 for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){
 for (compno = 0; compno < s->ncomponents; compno++){
 Jpeg2000Component *comp = s->tile[tileno].comp + compno;
-ff_jpeg2000_cleanup(comp, codsty);
+ff_jpeg2000_cleanup(comp, codsty, 1);
 }
 av_freep(>tile[tileno].comp);
 }
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 7a34a36121..88e6ebc8b3 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -580,7 +580,7 @@ void ff_jpeg2000_reinit(Jpeg2000Component *comp, 
Jpeg2000CodingStyle *codsty)
 }
 }
 
-void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
+void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, 
int isencoder)
 {
 int reslevelno, bandno, precno;
 for (reslevelno = 0;
diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h
index e9f4a51261..611aea1665 100644
--- a/libavcodec/jpeg2000.h
+++ b/libavcodec/jpeg2000.h
@@ -272,7 +272,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
 
 void ff_jpeg2000_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty);
 
-void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty);
+void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, 
int isencoder);
 
 static inline int needs_termination(int style, int passno) {
 if (style & JPEG2000_CBLK_BYPASS) {
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 624542c2f8..c5192d007f 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2123,7 +2123,7 @@ static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext 
*s)
 Jpeg2000Component *comp = s->tile[tileno].comp   + compno;
 Jpeg2000CodingStyle *codsty = s->tile[tileno].codsty + compno;
 
-ff_jpeg2000_cleanup(comp, codsty);
+ff_jpeg2000_cleanup(comp, codsty, 0);
 }
 av_freep(>tile[tileno].comp);
 av_freep(>tile[tileno].packed_headers);
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 4/5] avcodec/dvbsubdec: request samples for missing coding methods

2020-08-18 Thread Clément Bœsch
---
 libavcodec/dvbsubdec.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index c179f6461c..1b75a2a46b 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -1032,9 +1032,10 @@ static int dvbsub_parse_object_segment(AVCodecContext 
*avctx,
 dvbsub_parse_pixel_data_block(avctx, display, block, bfl, 1,
 non_modifying_color);
 }
-
-/*  } else if (coding_method == 1) {*/
-
+} else if (coding_method == 1) {
+avpriv_report_missing_feature(avctx, "coded as a string of 
characters");
+} else if (coding_method == 2) {
+avpriv_report_missing_feature(avctx, "progressive coding of pixels");
 } else {
 av_log(avctx, AV_LOG_ERROR, "Unknown object coding %d\n", 
coding_method);
 }
-- 
2.28.0

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

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

[FFmpeg-devel] [PATCH 3/5] avcodec/dvbsubenc: fix onject/object typo

2020-08-18 Thread Clément Bœsch
---
 libavcodec/dvbsubenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/dvbsubenc.c b/libavcodec/dvbsubenc.c
index f6cf1d869f..d1620e0c50 100644
--- a/libavcodec/dvbsubenc.c
+++ b/libavcodec/dvbsubenc.c
@@ -449,7 +449,7 @@ static int dvbsub_encode(AVCodecContext *avctx, uint8_t 
*outbuf, int buf_size,
 
 bytestream_put_be16(, object_id);
 *q++ = (s->object_version << 4) | (0 << 2) | (0 << 1) | 1; /* 
version = 0,
-   
onject_coding_method,
+   
object_coding_method,

non_modifying_color_flag */
 {
 uint8_t *ptop_field_len, *pbottom_field_len, *top_ptr, 
*bottom_ptr;
-- 
2.28.0

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

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

[FFmpeg-devel] [PATCH 2/5] avcodec/dvbsubenc: reindent after previous commit

2020-08-18 Thread Clément Bœsch
---
 libavcodec/dvbsubenc.c | 78 +-
 1 file changed, 39 insertions(+), 39 deletions(-)

diff --git a/libavcodec/dvbsubenc.c b/libavcodec/dvbsubenc.c
index ce6de4a774..f6cf1d869f 100644
--- a/libavcodec/dvbsubenc.c
+++ b/libavcodec/dvbsubenc.c
@@ -375,48 +375,48 @@ static int dvbsub_encode(AVCodecContext *avctx, uint8_t 
*outbuf, int buf_size,
 buf_size -= 6 + h->rects[clut_id]->nb_colors * 6;
 }
 
-if (buf_size < h->num_rects * 22)
-return AVERROR_BUFFER_TOO_SMALL;
-for (region_id = 0; region_id < h->num_rects; region_id++) {
+if (buf_size < h->num_rects * 22)
+return AVERROR_BUFFER_TOO_SMALL;
+for (region_id = 0; region_id < h->num_rects; region_id++) {
 
-/* region composition segment */
-
-if (h->rects[region_id]->nb_colors <= 4) {
-/* 2 bpp, some decoders do not support it correctly */
-bpp_index = 0;
-} else if (h->rects[region_id]->nb_colors <= 16) {
-/* 4 bpp, standard encoding */
-bpp_index = 1;
-} else if (h->rects[region_id]->nb_colors <= 256) {
-/* 8 bpp, standard encoding */
-bpp_index = 2;
-} else {
-return AVERROR(EINVAL);
-}
+/* region composition segment */
 
-*q++ = 0x0f; /* sync_byte */
-*q++ = 0x11; /* segment_type */
-bytestream_put_be16(, page_id);
-pseg_len = q;
-q += 2; /* segment length */
-*q++ = region_id;
-*q++ = (s->object_version << 4) | (0 << 3) | 0x07; /* version , no 
fill */
-bytestream_put_be16(, h->rects[region_id]->w); /* region width */
-bytestream_put_be16(, h->rects[region_id]->h); /* region height */
-*q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03;
-*q++ = region_id; /* clut_id == region_id */
-*q++ = 0; /* 8 bit fill colors */
-*q++ = 0x03; /* 4 bit and 2 bit fill colors */
-
-bytestream_put_be16(, region_id); /* object_id == region_id */
-*q++ = (0 << 6) | (0 << 4);
-*q++ = 0;
-*q++ = 0xf0;
-*q++ = 0;
+if (h->rects[region_id]->nb_colors <= 4) {
+/* 2 bpp, some decoders do not support it correctly */
+bpp_index = 0;
+} else if (h->rects[region_id]->nb_colors <= 16) {
+/* 4 bpp, standard encoding */
+bpp_index = 1;
+} else if (h->rects[region_id]->nb_colors <= 256) {
+/* 8 bpp, standard encoding */
+bpp_index = 2;
+} else {
+return AVERROR(EINVAL);
+}
 
-bytestream_put_be16(_len, q - pseg_len - 2);
-}
-buf_size -= h->num_rects * 22;
+*q++ = 0x0f; /* sync_byte */
+*q++ = 0x11; /* segment_type */
+bytestream_put_be16(, page_id);
+pseg_len = q;
+q += 2; /* segment length */
+*q++ = region_id;
+*q++ = (s->object_version << 4) | (0 << 3) | 0x07; /* version , no 
fill */
+bytestream_put_be16(, h->rects[region_id]->w); /* region width */
+bytestream_put_be16(, h->rects[region_id]->h); /* region height 
*/
+*q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03;
+*q++ = region_id; /* clut_id == region_id */
+*q++ = 0; /* 8 bit fill colors */
+*q++ = 0x03; /* 4 bit and 2 bit fill colors */
+
+bytestream_put_be16(, region_id); /* object_id == region_id */
+*q++ = (0 << 6) | (0 << 4);
+*q++ = 0;
+*q++ = 0xf0;
+*q++ = 0;
+
+bytestream_put_be16(_len, q - pseg_len - 2);
+}
+buf_size -= h->num_rects * 22;
 
 for (object_id = 0; object_id < h->num_rects; object_id++) {
 int (*dvb_encode_rle)(uint8_t **pq, int buf_size,
-- 
2.28.0

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

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

[FFmpeg-devel] [PATCH 5/5] avcodec/dvbsubdec: error out on unsupported coding methods

2020-08-18 Thread Clément Bœsch
---
 libavcodec/dvbsubdec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index 1b75a2a46b..9bee33e4a2 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -1034,10 +1034,13 @@ static int dvbsub_parse_object_segment(AVCodecContext 
*avctx,
 }
 } else if (coding_method == 1) {
 avpriv_report_missing_feature(avctx, "coded as a string of 
characters");
+return AVERROR_PATCHWELCOME;
 } else if (coding_method == 2) {
 avpriv_report_missing_feature(avctx, "progressive coding of pixels");
+return AVERROR_PATCHWELCOME;
 } else {
 av_log(avctx, AV_LOG_ERROR, "Unknown object coding %d\n", 
coding_method);
+return AVERROR_INVALIDDATA;
 }
 
 return 0;
-- 
2.28.0

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

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

[FFmpeg-devel] [PATCH 1/5] avcodec/dvbsubenc: merge rectangle encode code blocks

2020-08-18 Thread Clément Bœsch
---
 libavcodec/dvbsubenc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavcodec/dvbsubenc.c b/libavcodec/dvbsubenc.c
index 7b8ef41a7e..ce6de4a774 100644
--- a/libavcodec/dvbsubenc.c
+++ b/libavcodec/dvbsubenc.c
@@ -374,7 +374,6 @@ static int dvbsub_encode(AVCodecContext *avctx, uint8_t 
*outbuf, int buf_size,
 bytestream_put_be16(_len, q - pseg_len - 2);
 buf_size -= 6 + h->rects[clut_id]->nb_colors * 6;
 }
-}
 
 if (buf_size < h->num_rects * 22)
 return AVERROR_BUFFER_TOO_SMALL;
@@ -419,8 +418,6 @@ static int dvbsub_encode(AVCodecContext *avctx, uint8_t 
*outbuf, int buf_size,
 }
 buf_size -= h->num_rects * 22;
 
-if (h->num_rects) {
-
 for (object_id = 0; object_id < h->num_rects; object_id++) {
 int (*dvb_encode_rle)(uint8_t **pq, int buf_size,
   const uint8_t *bitmap, int linesize,
-- 
2.28.0

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

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

Re: [FFmpeg-devel] [PATCH 1/4] libavcodec/jpeg2000: Make tag tree functions non static

2020-08-18 Thread Carl Eugen Hoyos


> Am 18.08.2020 um 21:40 schrieb gautamr...@gmail.com:
> 
> From: Gautam Ramakrishnan 
> 
> This patch makes the tag_tree_zero() and tag_tree_size()
> functions non static and callable from other files.

Missing ff_ prefix.

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

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

Re: [FFmpeg-devel] [PATCH] fate: add fate-sub-dvb test

2020-08-18 Thread Clément Bœsch
On Tue, Aug 11, 2020 at 02:19:01PM +0200, Clément Bœsch wrote:
[...]
> +FATE_SUBTITLES-$(call ALLYES, MPEGTS_DEMUXER DVBSUB_DECODER DVBSUB_ENCODER) 
> += fate-sub-dvb
> +fate-sub-dvb: CMD = framecrc -i $(TARGET_SAMPLES)/sub/dvbsubtest_filter.ts 
> -map s:0 -c dvbsub

Can someone upload that sample¹ to fate-samples/sub/dvbsubtest_filter.ts
so we can apply this patch now that JEEB fixed MPEG-TS DVB demuxing?

[1]: https://trac.ffmpeg.org/raw-attachment/ticket/8844/dvbsubtest_filter.ts

Regards,

-- 
Clément B.
___
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] avcodec/decode: use a packet list to store packet properties

2020-08-18 Thread James Almer
On 8/18/2020 5:15 PM, Andreas Rheinhardt wrote:
> James Almer:
>> Keeping only the latest packet fed to the decoder works only for decoders 
>> that
>> return a frame immediately after every consumed packet. Decoders that consume
>> several packets before they return a frame will fill said frame with 
>> properties
>> taken from the last consumed packet instead of the earliest.
>>
>> Signed-off-by: James Almer 
>> ---
>> This essentially enables decoders implementing the AVCodec.receive_frame API 
>> to
>> not require having to deal with timestamps and such properties internally, 
>> and
>> letting ff_decode_frame_props() do all the work instead (See libdav1d, which
>> i'll adapt once this goes in).
>>
>> As an example, this fixes the timestamps for the audio track in
>> bink/binkaudio_rdft.bik from the FATE suite, where the decoder wrongly 
>> assumed
>> ff_decode_frame_props() alone would handle them right.
>> The reason the relevant fate test is unaffected is because it just compares 
>> the
>> decoded output with a reference pcm file.
>>
>> Haven't looked too much into it, but i assume this change could simplify some
>> AV_CODEC_CAP_DELAY decoders that keep track of timestamps, even those using 
>> the
>> old AVCodec.decode() API.
>>
>>  libavcodec/decode.c   | 34 +-
>>  libavcodec/internal.h |  2 ++
>>  libavcodec/utils.c|  3 +++
>>  3 files changed, 30 insertions(+), 9 deletions(-)
>>
>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> index da587ac1f6..de36e28d3c 100644
>> --- a/libavcodec/decode.c
>> +++ b/libavcodec/decode.c
>> @@ -43,6 +43,7 @@
>>  #include "decode.h"
>>  #include "hwconfig.h"
>>  #include "internal.h"
>> +#include "packet_internal.h"
>>  #include "thread.h"
>>  
>>  typedef struct FramePool {
>> @@ -142,15 +143,22 @@ fail2:
>>  return 0;
>>  }
>>  
>> -static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt)
>> +#define IS_EMPTY(pkt) (!(pkt)->data && !(pkt)->side_data_elems)
>> +
>> +static int extract_packet_props(AVCodecInternal *avci, AVPacket *pkt)
>>  {
>>  int ret = 0;
>>  
>> -av_packet_unref(avci->last_pkt_props);
>> -if (pkt) {
>> -ret = av_packet_copy_props(avci->last_pkt_props, pkt);
>> -if (!ret)
>> -avci->last_pkt_props->size = pkt->size; // HACK: Needed for 
>> ff_decode_frame_props().
>> +ret = avpriv_packet_list_put(>pkt_props, >pkt_props_tail, 
>> pkt,
>> + FF_PACKETLIST_FLAG_REF_PACKET);
>> +if (ret < 0)
>> +return ret;
>> +
>> +if (IS_EMPTY(avci->last_pkt_props)) {
>> +ret = avpriv_packet_list_get(>pkt_props,
>> + >pkt_props_tail,
>> + avci->last_pkt_props);
>> +av_assert0(ret != AVERROR(EAGAIN));
>>  }
>>  return ret;
>>  }
>> @@ -512,6 +520,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  
>>  if (ret >= pkt->size || ret < 0) {
>>  av_packet_unref(pkt);
>> +av_packet_unref(avci->last_pkt_props);
>>  } else {
>>  int consumed = ret;
>>  
>> @@ -550,9 +559,11 @@ static int decode_receive_frame_internal(AVCodecContext 
>> *avctx, AVFrame *frame)
>>  
>>  av_assert0(!frame->buf[0]);
>>  
>> -if (avctx->codec->receive_frame)
>> +if (avctx->codec->receive_frame) {
>>  ret = avctx->codec->receive_frame(avctx, frame);
>> -else
>> +if (ret != AVERROR(EAGAIN))
>> +av_packet_unref(avci->last_pkt_props);
>> +} else
>>  ret = decode_simple_receive_frame(avctx, frame);
>>  
>>  if (ret == AVERROR_EOF)
>> @@ -1683,7 +1694,7 @@ static int add_metadata_from_side_data(const AVPacket 
>> *avpkt, AVFrame *frame)
>>  
>>  int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
>>  {
>> -const AVPacket *pkt = avctx->internal->last_pkt_props;
>> +AVPacket *pkt = avctx->internal->last_pkt_props;
>>  int i;
>>  static const struct {
>>  enum AVPacketSideDataType packet;
>> @@ -1701,6 +1712,11 @@ int ff_decode_frame_props(AVCodecContext *avctx, 
>> AVFrame *frame)
>>  { AV_PKT_DATA_S12M_TIMECODE,  
>> AV_FRAME_DATA_S12M_TIMECODE },
>>  };
>>  
>> +if (IS_EMPTY(pkt))
>> +avpriv_packet_list_get(>internal->pkt_props,
>> +   >internal->pkt_props_tail,
>> +   pkt);
>> +
> 
> The check below indicates that pkt might be NULL, yet IS_EMPTY(pkt)
> already dereferences it.

That check is bogus even in the current state, anyway. pkt is always
true because avctx->internal->last_pkt_props is allocated and freed with
the AVCodecContext.

> 
>>  if (pkt) {
>>  frame->pts = pkt->pts;
>>  #if FF_API_PKT_PTS
>> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
>> index 5d0e6e7831..ce4dbbc2b9 100644
>> --- a/libavcodec/internal.h
>> +++ b/libavcodec/internal.h
>> @@ -145,6 +145,8 @@ typedef struct AVCodecInternal {
>>   * 

[FFmpeg-devel] [PATCH 1/2][RFC] avcodec/packet: move AVPacketList definition and function helpers over from libavformat

2020-08-18 Thread James Almer
Signed-off-by: James Almer 
---
Not making these public because someone mentioned that the current signature
for these helpers was ugly (two AVPacketList pointers the caller needs to keep
around to track the list), and changing it would either require modifying a
public struct, introducing a new one, or making incredibly inefficient function
helpers that navigate the entire list to reach the end every time a new entry is
added.

A possible approach could be something like:

[libavcodec/packet.h]
typedef struct AVPacketList AVPacketList; // Opaque struct, API change

[libavcodec/packet_internal.h]
typedef struct PacketListEntry {
AVPacket pkt;
struct PacketListEntry *next;
} PacketListEntry; // Essentially what's currently AVPacketList

struct AVPacketList {
PacketListEntry *head;
PacketListEntry *tail;
};

AVPacketList *avpriv_packet_list_alloc(void);
int av_packet_list_put(AVPacketList *pktl, AVPacket *pkt, int flags);
int av_packet_list_get(AVPacketList *pktl, AVPacket *pkt);
int av_packet_list_peek(AVPacketList *pktl, AVPacket *pkt);
void av_packet_list_free(AVPacketList **pktl);

But special care would need to be given to some lists used in
libavformat/mux.c and libavformat/utils.c, one of which is even exposed in
avformat.h

Also, I'd rather not bikeshed too much about this API for the sake of the
following patch.

 libavcodec/avpacket.c| 64 ++
 libavcodec/packet.h  |  5 ++
 libavcodec/packet_internal.h | 45 ++
 libavformat/aiffenc.c|  5 +-
 libavformat/avformat.h   |  6 ---
 libavformat/flacenc.c|  7 +--
 libavformat/internal.h   | 42 -
 libavformat/matroskadec.c| 11 +++--
 libavformat/mp3enc.c |  7 +--
 libavformat/ttaenc.c |  7 +--
 libavformat/utils.c  | 88 ++--
 11 files changed, 148 insertions(+), 139 deletions(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 4801163227..473ce01227 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -726,6 +726,70 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 }
 
+int avpriv_packet_list_put(AVPacketList **packet_buffer,
+   AVPacketList **plast_pktl,
+   AVPacket  *pkt, int flags)
+{
+AVPacketList *pktl = av_mallocz(sizeof(AVPacketList));
+int ret;
+
+if (!pktl)
+return AVERROR(ENOMEM);
+
+if (flags & FF_PACKETLIST_FLAG_REF_PACKET) {
+if ((ret = av_packet_ref(>pkt, pkt)) < 0) {
+av_free(pktl);
+return ret;
+}
+} else {
+ret = av_packet_make_refcounted(pkt);
+if (ret < 0) {
+av_free(pktl);
+return ret;
+}
+av_packet_move_ref(>pkt, pkt);
+}
+
+if (*packet_buffer)
+(*plast_pktl)->next = pktl;
+else
+*packet_buffer = pktl;
+
+/* Add the packet in the buffered packet list. */
+*plast_pktl = pktl;
+return 0;
+}
+
+int avpriv_packet_list_get(AVPacketList **pkt_buffer,
+   AVPacketList **pkt_buffer_end,
+   AVPacket  *pkt)
+{
+AVPacketList *pktl;
+if (!*pkt_buffer)
+return AVERROR(EAGAIN);
+pktl= *pkt_buffer;
+*pkt= pktl->pkt;
+*pkt_buffer = pktl->next;
+if (!pktl->next)
+*pkt_buffer_end = NULL;
+av_freep();
+return 0;
+}
+
+void avpriv_packet_list_free(AVPacketList **pkt_buf, AVPacketList 
**pkt_buf_end)
+{
+AVPacketList *tmp = *pkt_buf;
+
+while (tmp) {
+AVPacketList *pktl = tmp;
+tmp = pktl->next;
+av_packet_unref(>pkt);
+av_freep();
+}
+*pkt_buf = NULL;
+*pkt_buf_end = NULL;
+}
+
 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, 
int error_count, int pict_type)
 {
 uint8_t *side_data;
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index 0a19a0eff3..b9d4c9c2c8 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -393,6 +393,11 @@ typedef struct AVPacket {
 #endif
 } AVPacket;
 
+typedef struct AVPacketList {
+AVPacket pkt;
+struct AVPacketList *next;
+} AVPacketList;
+
 #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
 /**
diff --git a/libavcodec/packet_internal.h b/libavcodec/packet_internal.h
index cdb9a27f2f..387b63169a 100644
--- a/libavcodec/packet_internal.h
+++ b/libavcodec/packet_internal.h
@@ -23,6 +23,51 @@
 
 #include "packet.h"
 
+
+/** Create a new reference for the packet instead of
+ * transferring the ownership of the existing one to the
+ * list.
+ */
+#define FF_PACKETLIST_FLAG_REF_PACKET (1 << 0)
+
+/**
+ * Append an AVPacket to the list.
+ *
+ * @param head  List head element
+ * @param tail  List tail element
+ * @param pkt   The packet being appended. The data described in it will
+ *  be made 

[FFmpeg-devel] [PATCH 0/2] avcodec/decode: use a packet list for last_pkt_props

2020-08-18 Thread James Almer
More details within each patch.

James Almer (2):
  avcodec/packet: move AVPacketList definition and function helpers over
from libavformat
  avcodec/decode: use a packet list to store copies of packets fed to
the decoder

 libavcodec/avpacket.c| 64 ++
 libavcodec/decode.c  | 34 ++
 libavcodec/internal.h|  2 +
 libavcodec/packet.h  |  5 ++
 libavcodec/packet_internal.h | 45 ++
 libavcodec/utils.c   |  3 ++
 libavformat/aiffenc.c|  5 +-
 libavformat/avformat.h   |  6 ---
 libavformat/flacenc.c|  7 +--
 libavformat/internal.h   | 42 -
 libavformat/matroskadec.c| 11 +++--
 libavformat/mp3enc.c |  7 +--
 libavformat/ttaenc.c |  7 +--
 libavformat/utils.c  | 88 ++--
 14 files changed, 178 insertions(+), 148 deletions(-)

-- 
2.27.0

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

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

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/decode: use a packet list to store packet properties

2020-08-18 Thread Andreas Rheinhardt
James Almer:
> Keeping only the latest packet fed to the decoder works only for decoders that
> return a frame immediately after every consumed packet. Decoders that consume
> several packets before they return a frame will fill said frame with 
> properties
> taken from the last consumed packet instead of the earliest.
> 
> Signed-off-by: James Almer 
> ---
> This essentially enables decoders implementing the AVCodec.receive_frame API 
> to
> not require having to deal with timestamps and such properties internally, and
> letting ff_decode_frame_props() do all the work instead (See libdav1d, which
> i'll adapt once this goes in).
> 
> As an example, this fixes the timestamps for the audio track in
> bink/binkaudio_rdft.bik from the FATE suite, where the decoder wrongly assumed
> ff_decode_frame_props() alone would handle them right.
> The reason the relevant fate test is unaffected is because it just compares 
> the
> decoded output with a reference pcm file.
> 
> Haven't looked too much into it, but i assume this change could simplify some
> AV_CODEC_CAP_DELAY decoders that keep track of timestamps, even those using 
> the
> old AVCodec.decode() API.
> 
>  libavcodec/decode.c   | 34 +-
>  libavcodec/internal.h |  2 ++
>  libavcodec/utils.c|  3 +++
>  3 files changed, 30 insertions(+), 9 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index da587ac1f6..de36e28d3c 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -43,6 +43,7 @@
>  #include "decode.h"
>  #include "hwconfig.h"
>  #include "internal.h"
> +#include "packet_internal.h"
>  #include "thread.h"
>  
>  typedef struct FramePool {
> @@ -142,15 +143,22 @@ fail2:
>  return 0;
>  }
>  
> -static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt)
> +#define IS_EMPTY(pkt) (!(pkt)->data && !(pkt)->side_data_elems)
> +
> +static int extract_packet_props(AVCodecInternal *avci, AVPacket *pkt)
>  {
>  int ret = 0;
>  
> -av_packet_unref(avci->last_pkt_props);
> -if (pkt) {
> -ret = av_packet_copy_props(avci->last_pkt_props, pkt);
> -if (!ret)
> -avci->last_pkt_props->size = pkt->size; // HACK: Needed for 
> ff_decode_frame_props().
> +ret = avpriv_packet_list_put(>pkt_props, >pkt_props_tail, 
> pkt,
> + FF_PACKETLIST_FLAG_REF_PACKET);
> +if (ret < 0)
> +return ret;
> +
> +if (IS_EMPTY(avci->last_pkt_props)) {
> +ret = avpriv_packet_list_get(>pkt_props,
> + >pkt_props_tail,
> + avci->last_pkt_props);
> +av_assert0(ret != AVERROR(EAGAIN));
>  }
>  return ret;
>  }
> @@ -512,6 +520,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  
>  if (ret >= pkt->size || ret < 0) {
>  av_packet_unref(pkt);
> +av_packet_unref(avci->last_pkt_props);
>  } else {
>  int consumed = ret;
>  
> @@ -550,9 +559,11 @@ static int decode_receive_frame_internal(AVCodecContext 
> *avctx, AVFrame *frame)
>  
>  av_assert0(!frame->buf[0]);
>  
> -if (avctx->codec->receive_frame)
> +if (avctx->codec->receive_frame) {
>  ret = avctx->codec->receive_frame(avctx, frame);
> -else
> +if (ret != AVERROR(EAGAIN))
> +av_packet_unref(avci->last_pkt_props);
> +} else
>  ret = decode_simple_receive_frame(avctx, frame);
>  
>  if (ret == AVERROR_EOF)
> @@ -1683,7 +1694,7 @@ static int add_metadata_from_side_data(const AVPacket 
> *avpkt, AVFrame *frame)
>  
>  int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
>  {
> -const AVPacket *pkt = avctx->internal->last_pkt_props;
> +AVPacket *pkt = avctx->internal->last_pkt_props;
>  int i;
>  static const struct {
>  enum AVPacketSideDataType packet;
> @@ -1701,6 +1712,11 @@ int ff_decode_frame_props(AVCodecContext *avctx, 
> AVFrame *frame)
>  { AV_PKT_DATA_S12M_TIMECODE,  
> AV_FRAME_DATA_S12M_TIMECODE },
>  };
>  
> +if (IS_EMPTY(pkt))
> +avpriv_packet_list_get(>internal->pkt_props,
> +   >internal->pkt_props_tail,
> +   pkt);
> +

The check below indicates that pkt might be NULL, yet IS_EMPTY(pkt)
already dereferences it.

>  if (pkt) {
>  frame->pts = pkt->pts;
>  #if FF_API_PKT_PTS
> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
> index 5d0e6e7831..ce4dbbc2b9 100644
> --- a/libavcodec/internal.h
> +++ b/libavcodec/internal.h
> @@ -145,6 +145,8 @@ typedef struct AVCodecInternal {
>   * for decoding.
>   */
>  AVPacket *last_pkt_props;
> +AVPacketList *pkt_props;
> +AVPacketList *pkt_props_tail;
>  
>  /**
>   * temporary buffer used for encoders to store their bitstream
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 14cb5cf1aa..4a180a1500 100644
> --- a/libavcodec/utils.c
> +++ 

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

2020-08-18 Thread gautamramk
From: Gautam Ramakrishnan 

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

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 264bae3f73..3882fa8474 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -100,6 +100,7 @@ static const int dwt_norms[2][4][10] = { // 
[dwt_type][band][rlevel] (multiplied
 
 typedef struct {
Jpeg2000Component *comp;
+   double *layer_rates;
 } Jpeg2000Tile;
 
 typedef struct {
@@ -126,12 +127,15 @@ typedef struct {
 Jpeg2000QuantStyle  qntsty;
 
 Jpeg2000Tile *tile;
+int layer_rates[100];
 
 int format;
 int pred;
 int sop;
 int eph;
 int prog;
+int nlayers;
+char *lr_str;
 } Jpeg2000EncoderContext;
 
 
@@ -239,7 +243,7 @@ static void j2k_flush(Jpeg2000EncoderContext *s)
 /* tag tree routines */
 
 /** code the value stored in node */
-static void tag_tree_code(Jpeg2000EncoderContext *s, Jpeg2000TgtNode *node, 
int threshold, int log)
+static void tag_tree_code(Jpeg2000EncoderContext *s, Jpeg2000TgtNode *node, 
int threshold)
 {
 Jpeg2000TgtNode *stack[30];
 int sp = -1, curval = 0;
@@ -332,7 +336,7 @@ static int put_cod(Jpeg2000EncoderContext *s)
 bytestream_put_byte(>buf, scod);  // Scod
 // SGcod
 bytestream_put_byte(>buf, s->prog); // progression level
-bytestream_put_be16(>buf, 1); // num of layers
+bytestream_put_be16(>buf, s->nlayers); // num of layers
 if(s->avctx->pix_fmt == AV_PIX_FMT_YUV444P){
 bytestream_put_byte(>buf, 0); // unspecified
 }else{
@@ -411,6 +415,28 @@ static uint8_t *put_sot(Jpeg2000EncoderContext *s, int 
tileno)
 return psotptr;
 }
 
+static void compute_rates(Jpeg2000EncoderContext* s)
+{
+int i, j;
+int layno;
+for (i = 0; i < s->numYtiles; i++) {
+for (j = 0; j < s->numXtiles; j++) {
+Jpeg2000Tile *tile = >tile[s->numXtiles * i + j];
+int tilew = tile->comp->coord[0][1] - tile->comp->coord[0][0];
+int tileh = tile->comp->coord[1][1] - tile->comp->coord[1][0];
+for (layno = 0; layno < s->nlayers; layno++) {
+if (s->layer_rates[layno] > 0.0f) {
+tile->layer_rates[layno] = (double)(tilew * tileh) * 
s->ncomponents * s->cbps[0] / (s->layer_rates[layno] * 8);
+//av_log(s, AV_LOG_WARNING, "Layer %d rate is %lf\n", 
layno, tile->layer_rates[layno]);
+} else {
+tile->layer_rates[layno] = 0;
+}
+}
+}
+}
+
+}
+
 /**
  * compute the sizes of tiles, resolution levels, bands, etc.
  * allocate memory for them
@@ -448,6 +474,10 @@ static int init_tiles(Jpeg2000EncoderContext *s)
 for (j = 0; j < 2; j++)
 comp->coord[i][j] = comp->coord_o[i][j] = 
ff_jpeg2000_ceildivpow2(comp->coord[i][j], s->chroma_shift[i]);
 
+tile->layer_rates = av_mallocz_array(s->ncomponents, 
sizeof(*tile->layer_rates));
+if (!tile->layer_rates)
+return AVERROR(ENOMEM);
+
 if ((ret = ff_jpeg2000_init_component(comp,
 codsty,
 qntsty,
@@ -459,6 +489,7 @@ static int init_tiles(Jpeg2000EncoderContext *s)
 return ret;
 }
 }
+compute_rates(s);
 return 0;
 }
 
@@ -701,6 +732,8 @@ static void encode_cblk(Jpeg2000EncoderContext *s, 
Jpeg2000T1Context *t1, Jpeg20
 }
 
 cblk->passes[passno].rate = ff_mqc_flush_to(>mqc, 
cblk->passes[passno].flushed, >passes[passno].flushed_len);
+cblk->passes[passno].rate -= cblk->passes[passno].flushed_len;
+
 wmsedec += (int64_t)nmsedec << (2*bpno);
 cblk->passes[passno].disto = wmsedec;
 
@@ -733,10 +766,12 @@ static void putnumpasses(Jpeg2000EncoderContext *s, int n)
 }
 
 
-static int encode_packet(Jpeg2000EncoderContext *s, Jpeg2000ResLevel *rlevel, 
int precno,
-  uint8_t *expn, int numgbits, int packetno)
+static int encode_packet(Jpeg2000EncoderContext *s, Jpeg2000ResLevel *rlevel, 
int layno,
+ int precno, uint8_t *expn, int numgbits, int packetno,
+ int nlayers)
 {
 int bandno, empty = 1;
+int i;
 // init bitstream
 *s->buf = 0;
 s->bit_index = 0;
@@ -748,18 +783,61 @@ static int encode_packet(Jpeg2000EncoderContext *s, 
Jpeg2000ResLevel *rlevel, in
 }
 // header
 
+if (!layno) {
+for (bandno = 0; bandno < rlevel->nbands; bandno++){
+Jpeg2000Band 

Re: [FFmpeg-devel] [PATCH] swresample/rematrix: handle 22.2 as a 9 channel layout

2020-08-18 Thread Jan Ekström
On Fri, Aug 14, 2020 at 8:36 PM Michael Niedermayer
 wrote:
>
> On Thu, Aug 13, 2020 at 01:26:58AM +0300, Jan Ekström wrote:
> > This is as far as 22.2 follows the same channel order as
> > WaveFormatExtensible's channel mask (and the AV_CH_* defines).
> >
> > After LFE2 the side channels would follow, but that offset of
> > one stops us from utilizing them without further tweaks.
> >
> > This change was verified by using swresample to downmix to 5.1,
> > and then feeding that to WASAPI.
> > ---
> >  libswresample/rematrix.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
>
> probably ok
>

Applied as 1c7e55dd504245d71444fac1a73e5370cc76fede .

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

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

[FFmpeg-devel] [PATCH 2/2] avcodec/decode: use a packet list to store packet properties

2020-08-18 Thread James Almer
Keeping only the latest packet fed to the decoder works only for decoders that
return a frame immediately after every consumed packet. Decoders that consume
several packets before they return a frame will fill said frame with properties
taken from the last consumed packet instead of the earliest.

Signed-off-by: James Almer 
---
This essentially enables decoders implementing the AVCodec.receive_frame API to
not require having to deal with timestamps and such properties internally, and
letting ff_decode_frame_props() do all the work instead (See libdav1d, which
i'll adapt once this goes in).

As an example, this fixes the timestamps for the audio track in
bink/binkaudio_rdft.bik from the FATE suite, where the decoder wrongly assumed
ff_decode_frame_props() alone would handle them right.
The reason the relevant fate test is unaffected is because it just compares the
decoded output with a reference pcm file.

Haven't looked too much into it, but i assume this change could simplify some
AV_CODEC_CAP_DELAY decoders that keep track of timestamps, even those using the
old AVCodec.decode() API.

 libavcodec/decode.c   | 34 +-
 libavcodec/internal.h |  2 ++
 libavcodec/utils.c|  3 +++
 3 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index da587ac1f6..de36e28d3c 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -43,6 +43,7 @@
 #include "decode.h"
 #include "hwconfig.h"
 #include "internal.h"
+#include "packet_internal.h"
 #include "thread.h"
 
 typedef struct FramePool {
@@ -142,15 +143,22 @@ fail2:
 return 0;
 }
 
-static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt)
+#define IS_EMPTY(pkt) (!(pkt)->data && !(pkt)->side_data_elems)
+
+static int extract_packet_props(AVCodecInternal *avci, AVPacket *pkt)
 {
 int ret = 0;
 
-av_packet_unref(avci->last_pkt_props);
-if (pkt) {
-ret = av_packet_copy_props(avci->last_pkt_props, pkt);
-if (!ret)
-avci->last_pkt_props->size = pkt->size; // HACK: Needed for 
ff_decode_frame_props().
+ret = avpriv_packet_list_put(>pkt_props, >pkt_props_tail, pkt,
+ FF_PACKETLIST_FLAG_REF_PACKET);
+if (ret < 0)
+return ret;
+
+if (IS_EMPTY(avci->last_pkt_props)) {
+ret = avpriv_packet_list_get(>pkt_props,
+ >pkt_props_tail,
+ avci->last_pkt_props);
+av_assert0(ret != AVERROR(EAGAIN));
 }
 return ret;
 }
@@ -512,6 +520,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 if (ret >= pkt->size || ret < 0) {
 av_packet_unref(pkt);
+av_packet_unref(avci->last_pkt_props);
 } else {
 int consumed = ret;
 
@@ -550,9 +559,11 @@ static int decode_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
 
 av_assert0(!frame->buf[0]);
 
-if (avctx->codec->receive_frame)
+if (avctx->codec->receive_frame) {
 ret = avctx->codec->receive_frame(avctx, frame);
-else
+if (ret != AVERROR(EAGAIN))
+av_packet_unref(avci->last_pkt_props);
+} else
 ret = decode_simple_receive_frame(avctx, frame);
 
 if (ret == AVERROR_EOF)
@@ -1683,7 +1694,7 @@ static int add_metadata_from_side_data(const AVPacket 
*avpkt, AVFrame *frame)
 
 int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
 {
-const AVPacket *pkt = avctx->internal->last_pkt_props;
+AVPacket *pkt = avctx->internal->last_pkt_props;
 int i;
 static const struct {
 enum AVPacketSideDataType packet;
@@ -1701,6 +1712,11 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame 
*frame)
 { AV_PKT_DATA_S12M_TIMECODE,  AV_FRAME_DATA_S12M_TIMECODE 
},
 };
 
+if (IS_EMPTY(pkt))
+avpriv_packet_list_get(>internal->pkt_props,
+   >internal->pkt_props_tail,
+   pkt);
+
 if (pkt) {
 frame->pts = pkt->pts;
 #if FF_API_PKT_PTS
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 5d0e6e7831..ce4dbbc2b9 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -145,6 +145,8 @@ typedef struct AVCodecInternal {
  * for decoding.
  */
 AVPacket *last_pkt_props;
+AVPacketList *pkt_props;
+AVPacketList *pkt_props_tail;
 
 /**
  * temporary buffer used for encoders to store their bitstream
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 14cb5cf1aa..4a180a1500 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -50,6 +50,7 @@
 #include "thread.h"
 #include "frame_thread_encoder.h"
 #include "internal.h"
+#include "packet_internal.h"
 #include "put_bits.h"
 #include "raw.h"
 #include "bytestream.h"
@@ -1149,6 +1150,8 @@ av_cold int avcodec_close(AVCodecContext *avctx)
 av_packet_free(>internal->compat_encode_packet);
 av_packet_free(>internal->buffer_pkt);
 

Re: [FFmpeg-devel] [PATCH] avformat/mpegts: only reset timestamps to NOPTS for DVB teletext

2020-08-18 Thread Jan Ekström
On Thu, Aug 13, 2020 at 12:52 PM Jan Ekström  wrote:
>
> On Thu, Aug 13, 2020 at 10:34 AM Marton Balint  wrote:
> >
> >
> >
> > On Thu, 13 Aug 2020, Jan Ekström wrote:
> >
> > > While having the possibility of non-NOPTS values that can suddenly
> > > jump in time due to adjustments to match PCR is not nice for DVB
> > > subtitles, apparently the parser for this format bases its behavior on
> > > whether the packets' timestamps are NOPTS or not.
> >
> > Actually what matters is that the parser separates packets which have
> > different PTS values. Having a DVB subtitle packet with no PTS is not even
> > valid based on what I read from the specs:
> >
> > "Each PES header shall carry a PTS, associated with all the subtitle data
> > contained within that PES packet. "
> >
> > So I guess current code assumes that if a packet has no PTS then it is
> > also part of the previous packet, but this also seems like a workaround
> > for bad streams...
> >
>
> Yup, it's layers upon layers of fun :) Just like a box of chocolates
> or an onion.
>
> I posted this patch to get a discussion rolling, as I was highlighted
> on the parser being broken with NOPTS.
>
> > > Thus while we can adjust timestamps, we should exclude DVB subtitles
> > > from the timestamp unsetting logic.
> >
> > Ok, but to be frank the timestamp setting logic (even when it is
> > used with PCR) also breaks the parser, because it might assign different
> > PTS to PES packets which have the same PTS...
> >
>
> Yup. Cascades of things and all that jazz are fun. I just addressed
> the most obvious bit which I caused by my unsetting of timestamps
> (which in turn was to make sure that the time line doesn't suddenly
> jump X hours back or so).
>
> On trac reverting
> http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=42aa02418e43802b4ebcca373d2413ab63a0307e
> was mentioned, but that seems to have been a case fixing
> https://trac.ffmpeg.org/ticket/4200 . The ticket lacks exact details,
> but I expect there to be a bad mux with the subtitle timestamps not
> matching the general time line according to PCR.
>
> > >
> > > Fixes #8844
> > > ---
> > > libavformat/mpegts.c | 3 ++-
> > > 1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> > > index f71f18a57d..50d4d5e9bc 100644
> > > --- a/libavformat/mpegts.c
> > > +++ b/libavformat/mpegts.c
> > > @@ -1343,7 +1343,8 @@ skip:
> > > }
> > > }
> > >
> > > -if (!pcr_found) {
> > > +if (pes->st->codecpar->codec_id == 
> > > AV_CODEC_ID_DVB_TELETEXT &&
> > > +!pcr_found) {
> > > av_log(pes->stream, AV_LOG_VERBOSE,
> > >"Forcing DTS/PTS to be unset for a "
> > >"non-trustworthy PES packet for PID %d as "
> >
> > Patch LGTM, I am just saying that the problems lies more deep...
> >
>
> Thanks. Unless people have a better idea of how to go forward with
> this, I'll apply this patch.
>

As no better ideas were brought up, applied this as
c820c2d4bfb7e2573f7bf8e2a3544a98e5a11343 .

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

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

[FFmpeg-devel] [PATCH 2/4] libavcodec/j2kenc: Fix tag tree coding

2020-08-18 Thread gautamramk
From: Gautam Ramakrishnan 

This patch fixes tag tree coding for JPEG2000
encoder.
---
 libavcodec/j2kenc.c   | 43 +--
 libavcodec/jpeg2000.c |  1 +
 libavcodec/jpeg2000.h |  1 +
 3 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 16863f8e8c..1c31e48d61 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -239,30 +239,37 @@ static void j2k_flush(Jpeg2000EncoderContext *s)
 /* tag tree routines */
 
 /** code the value stored in node */
-static void tag_tree_code(Jpeg2000EncoderContext *s, Jpeg2000TgtNode *node, 
int threshold)
+static void tag_tree_code(Jpeg2000EncoderContext *s, Jpeg2000TgtNode *node, 
int threshold, int log)
 {
 Jpeg2000TgtNode *stack[30];
-int sp = 1, curval = 0;
-stack[0] = node;
+int sp = -1, curval = 0;
 
-node = node->parent;
-while(node){
-if (node->vis){
-curval = node->val;
-break;
-}
-node->vis++;
-stack[sp++] = node;
+while(node->parent){
+stack[++sp] = node;
 node = node->parent;
 }
-while(--sp >= 0){
-if (stack[sp]->val >= threshold){
-put_bits(s, 0, threshold - curval);
-break;
+
+while (1) {
+if (curval > node->temp_val)
+node->temp_val = curval;
+else {
+curval = node->temp_val;
 }
-put_bits(s, 0, stack[sp]->val - curval);
-put_bits(s, 1, 1);
-curval = stack[sp]->val;
+while (curval < threshold) {
+if (curval >= node->val) {
+if (!node->vis) {
+node->vis = 1;
+put_bits(s, 1, 1);
+}
+break;
+}
+put_bits(s, 0, 1);
+curval++;
+}
+node->temp_val = curval;
+if (sp < 0)
+break;
+node = stack[sp--];
 }
 }
 
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 35e21f54a4..7a34a36121 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -88,6 +88,7 @@ void tag_tree_zero(Jpeg2000TgtNode *t, int w, int h)
 
 for (i = 0; i < siz; i++) {
 t[i].val = 0;
+t[i].temp_val = 0;
 t[i].vis = 0;
 }
 }
diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h
index 4ea7daa5da..e9f4a51261 100644
--- a/libavcodec/jpeg2000.h
+++ b/libavcodec/jpeg2000.h
@@ -127,6 +127,7 @@ typedef struct Jpeg2000T1Context {
 
 typedef struct Jpeg2000TgtNode {
 uint8_t val;
+uint8_t temp_val;
 uint8_t vis;
 struct Jpeg2000TgtNode *parent;
 } Jpeg2000TgtNode;
-- 
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 1/4] libavcodec/jpeg2000: Make tag tree functions non static

2020-08-18 Thread gautamramk
From: Gautam Ramakrishnan 

This patch makes the tag_tree_zero() and tag_tree_size()
functions non static and callable from other files.
---
 libavcodec/jpeg2000.c | 4 ++--
 libavcodec/jpeg2000.h | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 1aca31ffa4..35e21f54a4 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -39,7 +39,7 @@
 /* tag tree routines */
 
 /* allocate the memory for tag tree */
-static int32_t tag_tree_size(int w, int h)
+int32_t tag_tree_size(int w, int h)
 {
 int64_t res = 0;
 while (w > 1 || h > 1) {
@@ -82,7 +82,7 @@ static Jpeg2000TgtNode *ff_jpeg2000_tag_tree_init(int w, int 
h)
 return res;
 }
 
-static void tag_tree_zero(Jpeg2000TgtNode *t, int w, int h)
+void tag_tree_zero(Jpeg2000TgtNode *t, int w, int h)
 {
 int i, siz = tag_tree_size(w, h);
 
diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h
index 5b0627c3dc..4ea7daa5da 100644
--- a/libavcodec/jpeg2000.h
+++ b/libavcodec/jpeg2000.h
@@ -290,4 +290,7 @@ static inline int needs_termination(int style, int passno) {
 return 0;
 }
 
+int32_t tag_tree_size(int w, int h);
+void tag_tree_zero(Jpeg2000TgtNode *t, int w, int h);
+
 #endif /* AVCODEC_JPEG2000_H */
-- 
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 0/3] avcodec/aacdec_template: improvements to 22.2 layout logic

2020-08-18 Thread Jan Ekström
The first two commits fix both of the fuzzing samples I have on hand.
One being from #8845, and another provided privately by Michael. Changes have
been tested both with clang 10's ASAN as well as standard valgrind.

The latter 22.2 check could be simplified to just the layout (since if the
stream passes all checks to that point, it probably is 22.2), but I
decided to post the first version this way to show that I haven't just
been sitting on my backside.

The last commit is general debug logging that I found helpful during
adding support of 22.2 by logging the element order before/after reorder.
This one, if found non-interesting, can just be ignored. I decided to
post it as it was part of my verification.

Jan Ekström (3):
  avcodec/aacdec_template: keep tabs on layout in sniff_channel_order
  avcodec/aacdec_template: add more checks to make sure only 22.2 gets
to 22.2
  avcodec/aacdec_template: log the element order before/after reordering

 libavcodec/aacdec_template.c | 119 ---
 1 file changed, 96 insertions(+), 23 deletions(-)

-- 
2.26.2

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

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

[FFmpeg-devel] [PATCH 2/3] avcodec/aacdec_template: add more checks to make sure only 22.2 gets to 22.2

2020-08-18 Thread Jan Ekström
This way we can check that we have exactly the required things for 22.2.

Fixes #8845
---
 libavcodec/aacdec_template.c | 40 ++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 9eef1c0158..1e112ccf76 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -263,6 +263,7 @@ static int count_paired_channels(uint8_t (*layout_map)[3], 
int tags, int pos,
 return num_pos_channels;
 }
 
+#define PREFIX_FOR_22POINT2 
(AV_CH_LAYOUT_7POINT1_WIDE_BACK|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_LOW_FREQUENCY_2)
 static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags)
 {
 int i, n, total_non_cc_elements;
@@ -399,46 +400,78 @@ static uint64_t sniff_channel_order(uint8_t 
(*layout_map)[3], int tags)
 }
 
 // The previous checks would end up at 8 at this point for 22.2
-if (tags == 16 && i == 8) {
+if (layout == PREFIX_FOR_22POINT2 && tags == 16 && i == 8) {
+if (layout_map[i][2] != AAC_CHANNEL_FRONT)
+goto end_of_layout_definition;
+
 e2c_vec[i] = (struct elem_to_channel) {
 .av_position  = AV_CH_TOP_FRONT_CENTER,
 .syn_ele  = layout_map[i][0],
 .elem_id  = layout_map[i][1],
 .aac_position = layout_map[i][2]
 }; layout |= e2c_vec[i].av_position; i++;
+
+if (layout_map[i][2] != AAC_CHANNEL_FRONT)
+goto end_of_layout_definition;
+
 i += assign_pair(e2c_vec, layout_map, i,
  AV_CH_TOP_FRONT_LEFT,
  AV_CH_TOP_FRONT_RIGHT,
  AAC_CHANNEL_FRONT,
  );
+
+if (layout_map[i][2] != AAC_CHANNEL_SIDE)
+goto end_of_layout_definition;
+
 i += assign_pair(e2c_vec, layout_map, i,
  AV_CH_TOP_SIDE_LEFT,
  AV_CH_TOP_SIDE_RIGHT,
  AAC_CHANNEL_SIDE,
  );
+
+if (layout_map[i][2] != AAC_CHANNEL_FRONT)
+goto end_of_layout_definition;
+
 e2c_vec[i] = (struct elem_to_channel) {
 .av_position  = AV_CH_TOP_CENTER,
 .syn_ele  = layout_map[i][0],
 .elem_id  = layout_map[i][1],
 .aac_position = layout_map[i][2]
 }; layout |= e2c_vec[i].av_position; i++;
+
+if (layout_map[i][2] != AAC_CHANNEL_BACK)
+goto end_of_layout_definition;
+
 i += assign_pair(e2c_vec, layout_map, i,
  AV_CH_TOP_BACK_LEFT,
  AV_CH_TOP_BACK_RIGHT,
  AAC_CHANNEL_BACK,
  );
+
+if (layout_map[i][2] != AAC_CHANNEL_BACK)
+goto end_of_layout_definition;
+
 e2c_vec[i] = (struct elem_to_channel) {
 .av_position  = AV_CH_TOP_BACK_CENTER,
 .syn_ele  = layout_map[i][0],
 .elem_id  = layout_map[i][1],
 .aac_position = layout_map[i][2]
 }; layout |= e2c_vec[i].av_position; i++;
+
+
+if (layout_map[i][2] != AAC_CHANNEL_FRONT)
+goto end_of_layout_definition;
+
 e2c_vec[i] = (struct elem_to_channel) {
 .av_position  = AV_CH_BOTTOM_FRONT_CENTER,
 .syn_ele  = layout_map[i][0],
 .elem_id  = layout_map[i][1],
 .aac_position = layout_map[i][2]
 }; layout |= e2c_vec[i].av_position; i++;
+
+if (layout_map[i][2] != AAC_CHANNEL_FRONT)
+goto end_of_layout_definition;
+
 i += assign_pair(e2c_vec, layout_map, i,
  AV_CH_BOTTOM_FRONT_LEFT,
  AV_CH_BOTTOM_FRONT_RIGHT,
@@ -446,9 +479,12 @@ static uint64_t sniff_channel_order(uint8_t 
(*layout_map)[3], int tags)
  );
 }
 
+end_of_layout_definition:
+
 total_non_cc_elements = n = i;
 
-if (tags == 16 && total_non_cc_elements == 16) {
+if (layout == AV_CH_LAYOUT_22POINT2 &&
+tags == 16 && total_non_cc_elements == 16) {
 // For 22.2 reorder the result as needed
 FFSWAP(struct elem_to_channel, e2c_vec[2], e2c_vec[0]);   // FL & FR 
first (final), FC third
 FFSWAP(struct elem_to_channel, e2c_vec[2], e2c_vec[1]);   // FC second 
(final), FLc & FRc third
-- 
2.26.2

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

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

[FFmpeg-devel] [PATCH 1/3] avcodec/aacdec_template: keep tabs on layout in sniff_channel_order

2020-08-18 Thread Jan Ekström
This way the layout set at various points can be checked instead
of only having the layout at the end.
---
 libavcodec/aacdec_template.c | 53 ++--
 1 file changed, 32 insertions(+), 21 deletions(-)

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 8c5048cc13..9eef1c0158 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -198,7 +198,7 @@ struct elem_to_channel {
 
 static int assign_pair(struct elem_to_channel e2c_vec[MAX_ELEM_ID],
uint8_t (*layout_map)[3], int offset, uint64_t left,
-   uint64_t right, int pos)
+   uint64_t right, int pos, uint64_t *layout)
 {
 if (layout_map[offset][0] == TYPE_CPE) {
 e2c_vec[offset] = (struct elem_to_channel) {
@@ -207,6 +207,9 @@ static int assign_pair(struct elem_to_channel 
e2c_vec[MAX_ELEM_ID],
 .elem_id  = layout_map[offset][1],
 .aac_position = pos
 };
+if (e2c_vec[offset].av_position != UINT64_MAX)
+*layout |= e2c_vec[offset].av_position;
+
 return 1;
 } else {
 e2c_vec[offset] = (struct elem_to_channel) {
@@ -221,6 +224,9 @@ static int assign_pair(struct elem_to_channel 
e2c_vec[MAX_ELEM_ID],
 .elem_id  = layout_map[offset + 1][1],
 .aac_position = pos
 };
+if ((left|right) != UINT64_MAX)
+*layout |= (left|right);
+
 return 2;
 }
 }
@@ -262,7 +268,7 @@ static uint64_t sniff_channel_order(uint8_t 
(*layout_map)[3], int tags)
 int i, n, total_non_cc_elements;
 struct elem_to_channel e2c_vec[4 * MAX_ELEM_ID] = { { 0 } };
 int num_front_channels, num_side_channels, num_back_channels;
-uint64_t layout;
+uint64_t layout = 0;
 
 if (FF_ARRAY_ELEMS(e2c_vec) < tags)
 return 0;
@@ -294,6 +300,7 @@ static uint64_t sniff_channel_order(uint8_t 
(*layout_map)[3], int tags)
 .elem_id  = layout_map[i][1],
 .aac_position = AAC_CHANNEL_FRONT
 };
+layout |= e2c_vec[i].av_position;
 i++;
 num_front_channels--;
 }
@@ -301,21 +308,21 @@ static uint64_t sniff_channel_order(uint8_t 
(*layout_map)[3], int tags)
 i += assign_pair(e2c_vec, layout_map, i,
  AV_CH_FRONT_LEFT_OF_CENTER,
  AV_CH_FRONT_RIGHT_OF_CENTER,
- AAC_CHANNEL_FRONT);
+ AAC_CHANNEL_FRONT, );
 num_front_channels -= 2;
 }
 if (num_front_channels >= 2) {
 i += assign_pair(e2c_vec, layout_map, i,
  AV_CH_FRONT_LEFT,
  AV_CH_FRONT_RIGHT,
- AAC_CHANNEL_FRONT);
+ AAC_CHANNEL_FRONT, );
 num_front_channels -= 2;
 }
 while (num_front_channels >= 2) {
 i += assign_pair(e2c_vec, layout_map, i,
  UINT64_MAX,
  UINT64_MAX,
- AAC_CHANNEL_FRONT);
+ AAC_CHANNEL_FRONT, );
 num_front_channels -= 2;
 }
 
@@ -323,14 +330,14 @@ static uint64_t sniff_channel_order(uint8_t 
(*layout_map)[3], int tags)
 i += assign_pair(e2c_vec, layout_map, i,
  AV_CH_SIDE_LEFT,
  AV_CH_SIDE_RIGHT,
- AAC_CHANNEL_FRONT);
+ AAC_CHANNEL_FRONT, );
 num_side_channels -= 2;
 }
 while (num_side_channels >= 2) {
 i += assign_pair(e2c_vec, layout_map, i,
  UINT64_MAX,
  UINT64_MAX,
- AAC_CHANNEL_SIDE);
+ AAC_CHANNEL_SIDE, );
 num_side_channels -= 2;
 }
 
@@ -338,14 +345,14 @@ static uint64_t sniff_channel_order(uint8_t 
(*layout_map)[3], int tags)
 i += assign_pair(e2c_vec, layout_map, i,
  UINT64_MAX,
  UINT64_MAX,
- AAC_CHANNEL_BACK);
+ AAC_CHANNEL_BACK, );
 num_back_channels -= 2;
 }
 if (num_back_channels >= 2) {
 i += assign_pair(e2c_vec, layout_map, i,
  AV_CH_BACK_LEFT,
  AV_CH_BACK_RIGHT,
- AAC_CHANNEL_BACK);
+ AAC_CHANNEL_BACK, );
 num_back_channels -= 2;
 }
 if (num_back_channels) {
@@ -355,6 +362,7 @@ static uint64_t sniff_channel_order(uint8_t 
(*layout_map)[3], int tags)
 .elem_id  = layout_map[i][1],
 .aac_position = AAC_CHANNEL_BACK
 };
+layout |= e2c_vec[i].av_position;
 i++;
 num_back_channels--;
 }
@@ -366,6 +374,7 @@ static uint64_t sniff_channel_order(uint8_t 
(*layout_map)[3], int tags)
 .elem_id  = layout_map[i][1],
 .aac_position = 

[FFmpeg-devel] [PATCH 3/3] avcodec/aacdec_template: log the element order before/after reordering

2020-08-18 Thread Jan Ekström
This was quite useful to verify that 22.2 got properly handled,
among other things.
---
 libavcodec/aacdec_template.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 1e112ccf76..4662bbe41a 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -263,6 +263,22 @@ static int count_paired_channels(uint8_t (*layout_map)[3], 
int tags, int pos,
 return num_pos_channels;
 }
 
+static void log_e2c(int num, struct elem_to_channel e2c) {
+char buf[128] = { 0 };
+
+av_get_channel_layout_string(buf, sizeof(buf), -1, e2c.av_position);
+
+av_log(NULL, AV_LOG_DEBUG,
+   "tag %d = { position(s): %s (0x%"PRIx64"), syn_elem: %s, elem_id: 
%"PRIu8" }\n",
+   num,
+   e2c.av_position == UINT64_MAX ? "Unset/Ignored" : buf,
+   e2c.av_position,
+   e2c.syn_ele == TYPE_SCE ? "SCE" :
+   e2c.syn_ele == TYPE_CPE ? "CPE" :
+   e2c.syn_ele == TYPE_LFE ? "LFE" : "",
+   e2c.elem_id);
+}
+
 #define PREFIX_FOR_22POINT2 
(AV_CH_LAYOUT_7POINT1_WIDE_BACK|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_LOW_FREQUENCY_2)
 static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags)
 {
@@ -483,6 +499,11 @@ end_of_layout_definition:
 
 total_non_cc_elements = n = i;
 
+av_log(NULL, AV_LOG_DEBUG, "Element order before reorder:\n");
+for (i = 0; i < n; i++) {
+log_e2c(i, e2c_vec[i]);
+}
+
 if (layout == AV_CH_LAYOUT_22POINT2 &&
 tags == 16 && total_non_cc_elements == 16) {
 // For 22.2 reorder the result as needed
@@ -510,6 +531,11 @@ end_of_layout_definition:
 
 }
 
+av_log(NULL, AV_LOG_DEBUG, "Element order after reorder:\n");
+for (i = 0; i < total_non_cc_elements; i++) {
+log_e2c(i, e2c_vec[i]);
+}
+
 for (i = 0; i < total_non_cc_elements; i++) {
 layout_map[i][0] = e2c_vec[i].syn_ele;
 layout_map[i][1] = e2c_vec[i].elem_id;
-- 
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 07/21] avfilter/af_afir: Fix leak of AVFilterChannelLayout in case of error

2020-08-18 Thread Paul B Mahol
On 8/18/20, Andreas Rheinhardt  wrote:
> Andreas Rheinhardt:
>> If an error happens between the allocation of an AVFilterChannelLayout
>> and its usage (which involves attaching said object to a more permanent
>> object), the channel layout array leaks. This can simply be fixed by
>> making sure that nothing is between the allocation and the
>> aforementioned usage.
>>
>> Fixes Coverity issue #1250334.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavfilter/af_afir.c | 8 
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
>> index 5ba880f10b..6cbc7a00a1 100644
>> --- a/libavfilter/af_afir.c
>> +++ b/libavfilter/af_afir.c
>> @@ -742,14 +742,14 @@ static int query_formats(AVFilterContext *ctx)
>>  } else {
>>  AVFilterChannelLayouts *mono = NULL;
>>
>> -ret = ff_add_channel_layout(, AV_CH_LAYOUT_MONO);
>> -if (ret)
>> -return ret;
>> -
>>  if ((ret = ff_channel_layouts_ref(layouts,
>> >inputs[0]->out_channel_layouts)) < 0)
>>  return ret;
>>  if ((ret = ff_channel_layouts_ref(layouts,
>> >outputs[0]->in_channel_layouts)) < 0)
>>  return ret;
>> +
>> +ret = ff_add_channel_layout(, AV_CH_LAYOUT_MONO);
>> +if (ret)
>> +return ret;
>>  for (int i = 1; i < ctx->nb_inputs; i++) {
>>  if ((ret = ff_channel_layouts_ref(mono,
>> >inputs[i]->out_channel_layouts)) < 0)
>>  return ret;
>>
> Ping for this and the other outstanding patches of this patchset.

LGTM

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

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

Re: [FFmpeg-devel] [PATCH 07/21] avfilter/af_afir: Fix leak of AVFilterChannelLayout in case of error

2020-08-18 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> If an error happens between the allocation of an AVFilterChannelLayout
> and its usage (which involves attaching said object to a more permanent
> object), the channel layout array leaks. This can simply be fixed by
> making sure that nothing is between the allocation and the
> aforementioned usage.
> 
> Fixes Coverity issue #1250334.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavfilter/af_afir.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
> index 5ba880f10b..6cbc7a00a1 100644
> --- a/libavfilter/af_afir.c
> +++ b/libavfilter/af_afir.c
> @@ -742,14 +742,14 @@ static int query_formats(AVFilterContext *ctx)
>  } else {
>  AVFilterChannelLayouts *mono = NULL;
>  
> -ret = ff_add_channel_layout(, AV_CH_LAYOUT_MONO);
> -if (ret)
> -return ret;
> -
>  if ((ret = ff_channel_layouts_ref(layouts, 
> >inputs[0]->out_channel_layouts)) < 0)
>  return ret;
>  if ((ret = ff_channel_layouts_ref(layouts, 
> >outputs[0]->in_channel_layouts)) < 0)
>  return ret;
> +
> +ret = ff_add_channel_layout(, AV_CH_LAYOUT_MONO);
> +if (ret)
> +return ret;
>  for (int i = 1; i < ctx->nb_inputs; i++) {
>  if ((ret = ff_channel_layouts_ref(mono, 
> >inputs[i]->out_channel_layouts)) < 0)
>  return ret;
> 
Ping for this and the other outstanding patches of this patchset.

- 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] lavfi: regroup formats lists in a single structure.

2020-08-18 Thread Andreas Rheinhardt
Nicolas George:
> It will allow to refernce it as a whole without clunky macros.
> 
> Most of the changes have been automatically made with sed:
> 
> sed -i '
>   s/-> *in_formats/->incfg.formats/g;
>   s/-> *out_formats/->outcfg.formats/g;
>   s/-> *in_channel_layouts/->incfg.channel_layouts/g;
>   s/-> *out_channel_layouts/->outcfg.channel_layouts/g;
>   s/-> *in_samplerates/->incfg.samplerates/g;
>   s/-> *out_samplerates/->outcfg.samplerates/g;
>   ' src/libavfilter/*(.)
> 
> Signed-off-by: Nicolas George 
> ---
> 
> 
> I would appreciate quick feed-back on this one, because I need to build
> on it (test the validity of the config), and it is the kind of patch
> that is nightmarish to rebase because it can create many conflicts.
> 
> Andreas?
> 
> 
>  libavfilter/aeval.c|   4 +-
>  libavfilter/af_afir.c  |   8 +-
>  libavfilter/af_agate.c |  10 +-
>  libavfilter/af_aiir.c  |   2 +-
>  libavfilter/af_amerge.c|  12 +-
>  libavfilter/af_anequalizer.c   |  14 +-
>  libavfilter/af_aresample.c |  12 +-
>  libavfilter/af_asetrate.c  |   2 +-
>  libavfilter/af_channelmap.c|   4 +-
>  libavfilter/af_channelsplit.c  |   4 +-
>  libavfilter/af_hdcd.c  |   4 +-
>  libavfilter/af_headphone.c |   8 +-
>  libavfilter/af_join.c  |   4 +-
>  libavfilter/af_ladspa.c|   6 +-
>  libavfilter/af_loudnorm.c  |   4 +-
>  libavfilter/af_lv2.c   |   6 +-
>  libavfilter/af_pan.c   |   4 +-
>  libavfilter/af_resample.c  |  12 +-
>  libavfilter/af_sidechaincompress.c |  10 +-
>  libavfilter/af_sofalizer.c |   4 +-
>  libavfilter/af_surround.c  |   4 +-
>  libavfilter/avf_abitscope.c|   8 +-
>  libavfilter/avf_ahistogram.c   |   8 +-
>  libavfilter/avf_aphasemeter.c  |  14 +-
>  libavfilter/avf_avectorscope.c |   8 +-
>  libavfilter/avf_concat.c   |  12 +-
>  libavfilter/avf_showcqt.c  |   8 +-
>  libavfilter/avf_showfreqs.c|   8 +-
>  libavfilter/avf_showspatial.c  |   8 +-
>  libavfilter/avf_showspectrum.c |   8 +-
>  libavfilter/avf_showvolume.c   |   8 +-
>  libavfilter/avf_showwaves.c|   8 +-
>  libavfilter/avfilter.c |  30 ++---
>  libavfilter/avfilter.h |  59 +---
>  libavfilter/avfiltergraph.c| 208 ++---
>  libavfilter/f_drawgraph.c  |   2 +-
>  libavfilter/f_ebur128.c|  14 +-
>  libavfilter/f_graphmonitor.c   |   2 +-
>  libavfilter/formats.c  |   6 +-
>  libavfilter/src_movie.c|   8 +-
>  libavfilter/tests/filtfmts.c   |   6 +-
>  libavfilter/vaapi_vpp.c|   4 +-
>  libavfilter/vaf_spectrumsynth.c|  10 +-
>  libavfilter/vf_alphamerge.c|   6 +-
>  libavfilter/vf_ciescope.c  |   4 +-
>  libavfilter/vf_colorspace.c|   4 +-
>  libavfilter/vf_coreimage.m |   6 +-
>  libavfilter/vf_elbg.c  |   4 +-
>  libavfilter/vf_extractplanes.c |  12 +-
>  libavfilter/vf_fieldmatch.c|   6 +-
>  libavfilter/vf_fieldorder.c|   4 +-
>  libavfilter/vf_histogram.c |  12 +-
>  libavfilter/vf_hwdownload.c|   4 +-
>  libavfilter/vf_hwmap.c |   4 +-
>  libavfilter/vf_hwupload.c  |   4 +-
>  libavfilter/vf_hwupload_cuda.c |   4 +-
>  libavfilter/vf_lut2.c  |   4 +-
>  libavfilter/vf_mergeplanes.c   |   4 +-
>  libavfilter/vf_overlay.c   |   6 +-
>  libavfilter/vf_overlay_qsv.c   |   4 +-
>  libavfilter/vf_palettegen.c|   4 +-
>  libavfilter/vf_paletteuse.c|   6 +-
>  libavfilter/vf_remap.c |   8 +-
>  libavfilter/vf_scale.c |   4 +-
>  libavfilter/vf_showpalette.c   |   4 +-
>  libavfilter/vf_vectorscope.c   |  12 +-
>  libavfilter/vf_vpp_qsv.c   |   4 +-
>  libavfilter/vf_waveform.c  |  14 +-
>  libavfilter/vf_yadif_cuda.c|   4 +-
>  libavfilter/vf_zscale.c|   4 +-
>  70 files changed, 381 insertions(+), 360 deletions(-)
> 
> diff --git a/libavfilter/af_asetrate.c b/libavfilter/af_asetrate.c
> index 50a5f43749..71643a36d0 100644
> --- a/libavfilter/af_asetrate.c
> +++ b/libavfilter/af_asetrate.c
> @@ -52,7 +52,7 @@ static av_cold int query_formats(AVFilterContext *ctx)
>  int sample_rates[] = { sr->sample_rate, -1 };
>  
>  return ff_formats_ref(ff_make_format_list(sample_rates),
> -   >outputs[0]->in_samplerates);
> +   >outputs[0]->incfg.samplerates);

Missed opportunity for proper alignment.

>  }
>  
>  static av_cold int config_props(AVFilterLink *outlink)
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index dd8074e462..c2d3e9b38a 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -261,15 +261,15 @@ int avfilter_insert_filter(AVFilterLink *link, 
> AVFilterContext *filt,
> 

[FFmpeg-devel] [aarch64] yuv2planeX - unroll outer loop by 4 to increase performance by 6.3%

2020-08-18 Thread Sebastian Pop
Hi,

Unrolling by 4 the outer loop in yuv2planeX reduces the number of cache
accesses by 7.5%.
The values loaded for the filter are used in the 4 unrolled iterations and
avoids reloading 3 times the same values.
The performance was measured on an Arm64 Neoverse-N1 Graviton2 c6g.metal
instance with the following command:
$ perf stat -e cache-references ./ffmpeg_g -nostats -f lavfi -i
testsrc2=4k:d=2 -vf bench=start,scale=1024x1024,bench=stop -f null -

before: 1551591469  cache-references
after:  1436140431  cache-references

before: [bench @ 0xc62b7d30] t:0.013226 avg:0.013219 max:0.013537
min:0.012975
after:  [bench @ 0xd84f3d30] t:0.012355 avg:0.012381 max:0.013164
min:0.012158

Ok to commit?

Thanks,
Sebastian


0001-aarch64-yuv2planeX-unroll-outer-loop-by-4-increases-.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v4 2/4] lavc/avs3_parser: add avs3 parser

2020-08-18 Thread Andreas Rheinhardt
hwr...@126.com:
> From: hwren 
> 
> Signed-off-by: hbj 
> Signed-off-by: hwren 
> ---
> diff --git a/libavcodec/avs3_parser.h b/libavcodec/avs3_parser.h
> new file mode 100644
> index 00..afc6d235b9
> --- /dev/null
> +++ b/libavcodec/avs3_parser.h
> @@ -0,0 +1,64 @@
> +/*
> + * AVS3-P2/IEEE1857.10 video parser.
> + * Copyright (c) 2020 Zhenyu Wang 
> + *Bingjie Han 
> + *Huiwen Ren  
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#ifndef AVCODEC_AVS3PARSER_H
> +#define AVCODEC_AVS3PARSER_H
> +
> +#include "parser.h"
> +
> +#define AVS3_NAL_START_CODE  0x01
> +#define AVS3_SEQ_START_CODE  0xB0
> +#define AVS3_SEQ_END_CODE0xB1
> +#define AVS3_USER_DATA_START_CODE0xB2
> +#define AVS3_INTRA_PIC_START_CODE0xB3
> +#define AVS3_UNDEF_START_CODE0xB4
> +#define AVS3_EXTENSION_START_CODE0xB5
> +#define AVS3_INTER_PIC_START_CODE0xB6
> +#define AVS3_VIDEO_EDIT_CODE 0xB7
> +#define AVS3_FIRST_SLICE_START_CODE  0x00
> +#define AVS3_PROFILE_BASELINE_MAIN   0x20
> +#define AVS3_PROFILE_BASELINE_MAIN10 0x22
> +
> +#define ISPIC(x) ((x) == AVS3_INTRA_PIC_START_CODE || (x) == 
> AVS3_INTER_PIC_START_CODE)
> +#define ISUNIT(x) ((x) == AVS3_SEQ_START_CODE || ISPIC(x))
> +
> +static const AVRational avs3_frame_rate_tab[16] = {
> +{ 0, 0   }, // forbid
> +{ 24000, 1001},
> +{ 24   , 1   },
> +{ 25   , 1   },
> +{ 3, 1001},
> +{ 30   , 1   },
> +{ 50   , 1   },
> +{ 6, 1001},
> +{ 60   , 1   },
> +{ 100  , 1   },
> +{ 120  , 1   },
> +{ 200  , 1   },
> +{ 240  , 1   },
> +{ 300  , 1   },
> +{ 0, 0   }, // reserved
> +{ 0, 0   }  // reserved
> +};
> +
> +#endif /* AVCODEC_AVS3PARSER_H */

None of the stuff in this header file (except the '#include "parser.h"')
is parser-specific. It should be part of a generic avs3 header file. And
the frame rate table should not be defined in said header file, as this
will lead to duplications of the table. If it is used in more than one
place, it should be declared via extern in this header file; if not, it
should just be declared inside the file that uses it (right now, only
the parser uses it).
(If it is used in more than one library, then it needs to exist in these
libraries separately (or it needs to be avpriv).)

- 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 v4 4/4] lavc, doc: add libuavs3d video decoder wrapper

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

[FFmpeg-devel] [PATCH v4 2/4] lavc/avs3_parser: add avs3 parser

2020-08-18 Thread hwrenx
From: hwren 

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

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3431ba2dca..5c031f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1059,6 +1059,7 @@ OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o 
aac_ac3_parser.o
 OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
 OBJS-$(CONFIG_AV1_PARSER)  += av1_parser.o av1_parse.o
 OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o
+OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o
 OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
 OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c
new file mode 100644
index 00..f04f696a89
--- /dev/null
+++ b/libavcodec/avs3_parser.c
@@ -0,0 +1,179 @@
+/*
+ * AVS3-P2/IEEE1857.10 video parser.
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avs3_parser.h"
+#include "get_bits.h"
+
+static int avs3_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
+{
+int pic_found  = pc->frame_start_found;
+uint32_t state = pc->state;
+int cur = 0;
+
+if (!pic_found) {
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if (ISPIC(buf[cur])){
+++cur;
+pic_found = 1;
+break;
+}
+}
+}
+
+if (pic_found) {
+if (!buf_size)
+return END_NOT_FOUND;
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if ((state & 0xFF00) == 0x100 && ISUNIT(state & 0xFF)) {
+pc->frame_start_found = 0;
+pc->state = -1;
+return cur - 3;
+}
+}
+}
+
+pc->frame_start_found = pic_found;
+pc->state = state;
+
+return END_NOT_FOUND;
+}
+
+static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
+   int buf_size, AVCodecContext *avctx)
+{
+if (buf_size < 5) {
+return;
+}
+
+if (buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1) {
+if (buf[3] == AVS3_SEQ_START_CODE) {
+GetBitContext gb;
+int profile, ratecode;
+
+init_get_bits(, buf + 4, buf_size - 4);
+
+s->key_frame = 1;
+s->pict_type = AV_PICTURE_TYPE_I;
+
+profile = get_bits(, 8);
+// Skip bits: level(8)
+//progressive(1)
+//field(1)
+//library(2)
+//resv(1)
+//width(14)
+//resv(1)
+//height(14)
+//chroma(2)
+//sampe_precision(3)
+skip_bits(, 47);
+
+if (profile == AVS3_PROFILE_BASELINE_MAIN10) {
+int sample_precision = get_bits(, 3);
+if (sample_precision == 1) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+} else if (sample_precision == 2) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE;
+} else {
+avctx->pix_fmt = AV_PIX_FMT_NONE;
+}
+}
+
+// Skip bits: resv(1)
+//aspect(4)
+skip_bits(, 5);
+
+ratecode = get_bits(, 4);
+
+// Skip bits: resv(1)
+//bitrate_low(18)
+//resv(1)
+//bitrate_high(12)
+//low_delay
+skip_bits(, 32);
+
+avctx->has_b_frames = !get_bits(, 1);
+
+avctx->framerate.num = 

[FFmpeg-devel] [PATCH v4 0/4] Supplement AVS3-P2/IEEE1857.10 video decoding via libuavs3d

2020-08-18 Thread hwrenx
From: hwren 

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

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

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

Fix API function conflict.

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

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

Thanks.

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

 Changelog|   1 +
 configure|   4 +
 doc/decoders.texi|  21 +++
 doc/general.texi |   8 ++
 libavcodec/Makefile  |   2 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avs3_parser.c | 179 
 libavcodec/avs3_parser.h |  64 +
 libavcodec/codec_desc.c  |   7 +
 libavcodec/codec_id.h|   1 +
 libavcodec/libuavs3d.c   | 294 +++
 libavcodec/parsers.c |   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/avs3dec.c|  69 +
 15 files changed, 654 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c
 create mode 100644 libavcodec/avs3_parser.h
 create mode 100644 libavcodec/libuavs3d.c
 create mode 100644 libavformat/avs3dec.c

-- 
2.23.0.windows.1

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

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

[FFmpeg-devel] [PATCH v4 4/4] lavc, doc: add libuavs3d video decoder wrapper

2020-08-18 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog  |   1 +
 configure  |   4 +
 doc/decoders.texi  |  21 +++
 doc/general.texi   |   8 ++
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libuavs3d.c | 294 +
 7 files changed, 330 insertions(+)
 create mode 100644 libavcodec/libuavs3d.c

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

[FFmpeg-devel] [PATCH v4 1/4] lavc: add AVS3 codec id and desc

2020-08-18 Thread hwrenx
From: hwren 

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

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0ae6aee63b..c5259bf824 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1405,6 +1405,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("AVS2-P2/IEEE1857.4"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_AVS3,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "avs3",
+.long_name = NULL_IF_CONFIG_SMALL("AVS3-P2/IEEE1857.10"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 {
 .id= AV_CODEC_ID_PGX,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 896ecb0ce0..47aa0787b6 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -242,6 +242,7 @@ enum AVCodecID {
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
 AV_CODEC_ID_PGX,
+AV_CODEC_ID_AVS3,
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
-- 
2.23.0.windows.1

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

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

[FFmpeg-devel] [PATCH v4 3/4] lavf/avs3dec: add raw avs3 demuxer

2020-08-18 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/avs3dec.c| 68 
 3 files changed, 70 insertions(+)
 create mode 100644 libavformat/avs3dec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index cbb33fe37c..8ddab3aee5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -122,6 +122,7 @@ OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
 OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
 OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
+OBJS-$(CONFIG_AVS3_DEMUXER)  += avs3dec.o rawdec.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
 OBJS-$(CONFIG_BINK_DEMUXER)  += bink.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0aa9dd7198..7f41c12d7c 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -84,6 +84,7 @@ extern AVInputFormat  ff_avr_demuxer;
 extern AVInputFormat  ff_avs_demuxer;
 extern AVInputFormat  ff_avs2_demuxer;
 extern AVOutputFormat ff_avs2_muxer;
+extern AVInputFormat  ff_avs3_demuxer;
 extern AVInputFormat  ff_bethsoftvid_demuxer;
 extern AVInputFormat  ff_bfi_demuxer;
 extern AVInputFormat  ff_bintext_demuxer;
diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c
new file mode 100644
index 00..21c24893a9
--- /dev/null
+++ b/libavformat/avs3dec.c
@@ -0,0 +1,68 @@
+/*
+ * RAW AVS3-P2/IEEE1857.10 video demuxer
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/avs3_parser.h"
+#include "libavcodec/internal.h"
+#include "avformat.h"
+#include "rawdec.h"
+
+static int avs3video_probe(const AVProbeData *p)
+{
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
+uint32_t code = -1;
+uint8_t state = 0;
+int pic = 0, seq = 0, slice_pos = 0;
+int ret = 0;
+
+while (ptr < end) {
+ptr = avpriv_find_start_code(ptr, end, );
+state = code & 0xFF;
+if ((code & 0xFF00) == 0x100) {
+if (state < AVS3_SEQ_START_CODE) {
+if (code < slice_pos)
+return 0;
+slice_pos = code;
+} else {
+slice_pos = 0;
+}
+if (state == AVS3_SEQ_START_CODE) {
+seq++;
+if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != 
AVS3_PROFILE_BASELINE_MAIN10)
+return 0;
+} else if (ISPIC(state)) {
+pic++;
+} else if ((state == AVS3_UNDEF_START_CODE) ||
+   (state > AVS3_VIDEO_EDIT_CODE)) {
+return 0;
+}
+}
+}
+
+if (seq && pic && av_match_ext(p->filename, "avs3")) {
+ret = AVPROBE_SCORE_MAX;
+}
+
+return ret;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, 
"avs3", AV_CODEC_ID_AVS3)
\ No newline at end of file
-- 
2.23.0.windows.1

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

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

Re: [FFmpeg-devel] [PATCH 7/7] avcodec/aacdec_template: add support for 22.2 / channel_config 13

2020-08-18 Thread Paul B Mahol
On 8/18/20, Jan Ekström  wrote:
> On Tue, Aug 18, 2020 at 12:45 PM Jan Ekström  wrote:
>>
>> On Tue, Aug 18, 2020 at 12:17 PM Paul B Mahol  wrote:
>> >
>> > I think there is open bug report about SEGV regarding this commit on
>> > trac.
>> >
>> > Please revert or fix ASAP!
>> >
>>
>> Thank you for letting me know about this. I will take a look at this
>> after work. Please do not yell at me, I am not your enemy.
>>
>> Jan
>>
>
> If this is about https://trac.ffmpeg.org/ticket/8845 , that is a
> *fuzzer* sample causing issues.
>
> While it is not nice, and I *am* now looking at it, why on earth do
> you have to go to this "revert or fix ASAP!" drama?

Because open security issues are never ok.
Sorry for disturbing you.

>
> It is not a normal stream, nor is it a FATE test I happened to break
> (I did check before pushing that my code passes existing FATE tests,
> and I was planning on adding a new one as I got through everything
> else I've been poking around). Thus, I think you can bring such things
> to my knowledge in a less aggressive way. I hope you understand this
> point.
>
> Jan
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
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/ac3dec: detect fairplay encryption

2020-08-18 Thread Niki Bowe
On Wed, Mar 4, 2020 at 10:47 AM Carl Eugen Hoyos  wrote:

> Am Mi., 4. März 2020 um 18:57 Uhr schrieb James Almer :
> >
> > On 3/4/2020 1:56 PM, Carl Eugen Hoyos wrote:
> > > Am Mi., 4. März 2020 um 17:53 Uhr schrieb Sebastian Hubbard
> > > :
> > >>
> > >> I knew this was an ABI change and probably wasn't going to be
> > >> acceptable, but I decided to share it for consideration anyway.
> > >> There's special code in av_probe_input_format3 to skip over id3 tags
> > >> for the purposes of format detection, but Apple uses id3 tags to
> > >> signal information for HLS audio only tracks. Maybe this change
> > >> shouldn't be made, but if it could ever be helpful for another format
> > >> prober to know about leading id3 tags this is the only way I could
> > >> imagine it.
> > >
> > > If the additional fields are necessary (I don't know), they could be
> > > added to the end of the struct where they do not break abi.
> > >
> > > Carl Eugen
> >
> > sizeof(AVProbeData) is part of the ABI because its doxy doesn't strictly
> > state otherwise. This means we can't add new fields to it, even at the
> > end, until a major bump. Else we'll be breaking ABI.
>
> Thank you both for the explanation!
>
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Hi everyone.

What is the recommended path forward here?
To get past the ABI break I think this patch needs:
 * libavformat minor version number bump (and reset of micro version)
 * soname version bump
Is there any other changes needed?


-- 

Nikolas Bowe |  SWE |  nb...@google.com |  408-565-5137 <(408)%20565-5137>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

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

2020-08-18 Thread Andreas Rheinhardt
Peter van der Spek:
> Since release 4.2, FFmpeg fails to detect the correct streams in an RTMP
> stream that contains a |RtmpSampleAccess AMF object prior to the
> onMetaData AMF object. In the debug log it would show "[flv] Unknown
> type |RtmpSampleAccess".
> 
> With this change the RTMP streams are correctly detected when there
> is a |RtmpSampleAccess object prior to the onMetaData object.
> 
> Signed-off-by: Peter van der Spek 
> ---
>  libavformat/flvdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index 0862273..d480d0b 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -715,7 +715,7 @@ static int flv_read_metabody(AVFormatContext *s, int64_t 
> next_pos)
>  if (!strcmp(buffer, "onCaptionInfo"))
>  return TYPE_ONCAPTIONINFO;
>  
> -if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint")) {
> +if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint") && 
> strcmp(buffer, "|RtmpSampleAccess")) {
>  av_log(s, AV_LOG_DEBUG, "Unknown type %s\n", buffer);
>  return TYPE_UNKNOWN;
>  }
> 
Which commit broke it? (That should be included in the commit message.)

- Andreas

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

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

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

2020-08-18 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
v3: use AVOption
v4: don't add new file dnn_common.h/c

 libavfilter/dnn/dnn_backend_openvino.c | 50 +-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index d343bf2..277c313 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -26,9 +26,37 @@
 #include "dnn_backend_openvino.h"
 #include "libavformat/avio.h"
 #include "libavutil/avassert.h"
+#include "libavutil/opt.h"
 #include 
 
+typedef struct OVOptions{
+uint32_t batch_size;
+uint32_t req_num;
+} OVOptions;
+
+typedef struct OvContext {
+const AVClass *class;
+OVOptions options;
+} OvContext;
+
+#define OFFSET(x) offsetof(OvContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
+static const AVOption dnn_ov_options[] = {
+{ "batch",   "batch size",OFFSET(options.batch_size), 
AV_OPT_TYPE_INT,  { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS },
+{ "nireq",   "number of request", OFFSET(options.req_num),
AV_OPT_TYPE_INT,  { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS },
+{ NULL },
+};
+
+static const AVClass dnn_ov_class = {
+.class_name = "dnn_ov",
+.item_name  = av_default_item_name,
+.option = dnn_ov_options,
+.version= LIBAVUTIL_VERSION_INT,
+.category   = AV_CLASS_CATEGORY_FILTER,
+};
+
 typedef struct OVModel{
+OvContext ctx;
 ie_core_t *core;
 ie_network_t *network;
 ie_executable_network_t *exe_network;
@@ -155,6 +183,22 @@ err:
 return DNN_ERROR;
 }
 
+static int dnn_parse_options(void *ctx, const char *options)
+{
+AVDictionary *dict = NULL;
+int err = av_dict_parse_string(, options, "=", "&", 0);
+if (err < 0) {
+av_dict_free();
+return err;
+}
+
+av_opt_set_defaults(ctx);
+err = av_opt_set_dict(ctx, );
+
+av_dict_free();
+return err;
+}
+
 DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options)
 {
 DNNModel *model = NULL;
@@ -171,6 +215,11 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, 
const char *options)
 if (!ov_model)
 goto err;
 
+ov_model->ctx.class = _ov_class;
+model->options = options;
+if (dnn_parse_options(_model->ctx, model->options) < 0)
+goto err;
+
 status = ie_core_create("", _model->core);
 if (status != OK)
 goto err;
@@ -186,7 +235,6 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, 
const char *options)
 model->model = (void *)ov_model;
 model->set_input_output = _input_output_ov;
 model->get_input = _input_ov;
-model->options = options;
 
 return model;
 
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH] avfilter/f_sidedata: Add SEI_UNREGISTERED frame side data type

2020-08-18 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavfilter/f_sidedata.c b/libavfilter/f_sidedata.c
index 4210dca..3757723 100644
--- a/libavfilter/f_sidedata.c
+++ b/libavfilter/f_sidedata.c
@@ -71,6 +71,7 @@ static const AVOption filt_name##_options[] = { \
 {   "S12M_TIMECOD",   "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_S12M_TIMECODE  }, 0, 0, FLAGS, "type" }, \
 {   "DYNAMIC_HDR_PLUS",   "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_DYNAMIC_HDR_PLUS   }, 0, 0, FLAGS, "type" }, \
 {   "REGIONS_OF_INTEREST","", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_REGIONS_OF_INTEREST}, 0, 0, FLAGS, "type" }, \
+{   "SEI_UNREGISTERED",   "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_SEI_UNREGISTERED   }, 0, 0, FLAGS, "type" }, \
 { NULL } \
 }
 #else
@@ -99,6 +100,7 @@ static const AVOption filt_name##_options[] = { \
 {   "S12M_TIMECOD",   "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_S12M_TIMECODE  }, 0, 0, FLAGS, "type" }, \
 {   "DYNAMIC_HDR_PLUS",   "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_DYNAMIC_HDR_PLUS   }, 0, 0, FLAGS, "type" }, \
 {   "REGIONS_OF_INTEREST","", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_REGIONS_OF_INTEREST}, 0, 0, FLAGS, "type" }, \
+{   "SEI_UNREGISTERED",   "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_SEI_UNREGISTERED   }, 0, 0, FLAGS, "type" }, \
 { NULL } \
 }
 #endif
-- 
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] [PATCH] libavformat/mxfenc: Allow more bitrates for NTSC IMX50

2020-08-18 Thread Mark Himsley
Sorry to drag up this old thread:

On Mon, 19 Aug 2019 at 17:55, Thomas Mundt  wrote:
...
> I can give you the parameters that I use for IMX50. Not sure if these are
> the best. Got the intra matrix values from an original imx file.
>
> NTSC: -c:v mpeg2video -pix_fmt yuv422p -aspect 16:9 -top 1 -flags
> +ildct+ilme+low_delay -color_range tv -color_trc smpte170m -color_primaries
> smpte170m -colorspace smpte170m -chroma_sample_location topleft
> -signal_standard bt601 -dc 10 -intra_vlc 1 -non_linear_quant 1 -ps 1 -g 1
> -qscale:v 1 -qmin 1 -qmax 12 -b:v 4841 -minrate 4841 -maxrate
> 4841 -bufsize 1668329 -rc_init_occupancy 1668329 -rc_min_vbv_use 1
> -rc_max_vbv_use 1 -profile:v 0 -level:v 5 -intra_matrix
> 8,16,16,17,19,22,23,31,16,16,17,19,20,23,29,29,19,17,19,22,19,25,28,35,17,19,19,20,25,28,25,33,17,19,22,25,26,25,31,31,17,19,17,20,26,28,35,36,19,19,19,20,22,29,32,35,16,17,19,22,25,31,28,45
>
> PAL: -c:v mpeg2video -pix_fmt yuv422p -aspect 16:9 -top 1 -flags
> +ildct+ilme+low_delay -color_range tv -color_trc smpte170m -color_primaries
> bt470bg -colorspace bt470bg -chroma_sample_location topleft
> -signal_standard bt601 -dc 10 -intra_vlc 1 -non_linear_quant 1 -ps 1 -g 1
> -qscale:v 1 -qmin 1 -qmax 12 -b:v 5000 -minrate 5000 -maxrate
> 5000 -bufsize 200 -rc_init_occupancy 200 -rc_min_vbv_use 1
> -rc_max_vbv_use 1 -profile:v 0 -level:v 5 -intra_matrix
> 8,16,16,17,19,22,23,31,16,16,17,19,20,23,29,29,19,17,19,22,19,25,28,35,17,19,19,20,25,28,25,33,17,19,22,25,26,25,31,31,17,19,17,20,26,28,35,36,19,19,19,20,22,29,32,35,16,17,19,22,25,31,28,45
>
> Regards,
> Thomas

As it stands, FFmpeg from `master` cannot create 3/1001 FPS IMX50,
and it has to be patched to allow 4841 to be the valid bitrate,
not 48410 which is in the source code.
Is there any movement on this issue?
Why is 4840 in the source code as a variant on 5000 when it
just does not work?
Is it not better to put 4841 into the source code?

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

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

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

2020-08-18 Thread Peter van der Spek
It took me some time to figure out where this |RtmpSampleAccess packet came 
from. It turns out that this is an undocumented AMF packet that is used to 
transfer the state of the documented Client.audioSampleAccess and 
Client.videoSampleAccess state to the client.

This post gave me some clues: 
https://nicolas.brousse.info/blog/flash-how-to-fix-the-security-sandbox-violation-bitmapdata-draw/

These sampleAccess states are used to allow a (Flash) client to access the raw 
video and audio data. The states are pushed by the server as a 
IRtmpSampleAccess packet.

Adobe FMS, Wowza, Red5, etc… all support this mechanism.

I’m able to reproduce this issue with RTMP streams pulled from a Nginx-RTMP 
server (https://github.com/arut/nginx-rtmp-module).

Client.audioSampleAccess and Client.videoSampleAccess are documented here:
https://helpx.adobe.com/adobe-media-server/ssaslr/client-class.html#client_audiosampleaccess
https://helpx.adobe.com/adobe-media-server/ssaslr/client-class.html#client_videosampleaccess

Best,
Peter
On 18 Aug 2020, 14:46 +0200, Michael Niedermayer , 
wrote:
>
> Do you have a testcase?
> Is this documented somewhere?
>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> In a rich man's house there is no place to spit but his face.
> -- Diogenes of Sinope
>
> ___
> 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 7/7] avcodec/aacdec_template: add support for 22.2 / channel_config 13

2020-08-18 Thread Jan Ekström
On Tue, Aug 18, 2020 at 12:45 PM Jan Ekström  wrote:
>
> On Tue, Aug 18, 2020 at 12:17 PM Paul B Mahol  wrote:
> >
> > I think there is open bug report about SEGV regarding this commit on trac.
> >
> > Please revert or fix ASAP!
> >
>
> Thank you for letting me know about this. I will take a look at this
> after work. Please do not yell at me, I am not your enemy.
>
> Jan
>

If this is about https://trac.ffmpeg.org/ticket/8845 , that is a
*fuzzer* sample causing issues.

While it is not nice, and I *am* now looking at it, why on earth do
you have to go to this "revert or fix ASAP!" drama?

It is not a normal stream, nor is it a FATE test I happened to break
(I did check before pushing that my code passes existing FATE tests,
and I was planning on adding a new one as I got through everything
else I've been poking around). Thus, I think you can bring such things
to my knowledge in a less aggressive way. I hope you understand this
point.

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

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

Re: [FFmpeg-devel] [PATCH] dnn_backend_native_layer_mathbinary: add floormod support

2020-08-18 Thread Yin, Mingyu
Thank you for your suggestion, we will try this method, and if it is 
successful, a new patch will be sent later.

> -Original Message-
> From: ffmpeg-devel  On Behalf Of Xu,
> Guangxin
> Sent: Friday, August 14, 2020 8:01 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH]
> dnn_backend_native_layer_mathbinary: add floormod support
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Mingyu Yin
> > Sent: Friday, August 14, 2020 6:11 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: [FFmpeg-devel] [PATCH] dnn_backend_native_layer_mathbinary:
> > add floormod support
> >
> > Signed-off-by: Mingyu Yin 
> > ---
> >  .../dnn/dnn_backend_native_layer_mathbinary.c   | 17
> +
> >  .../dnn/dnn_backend_native_layer_mathbinary.h   |  1 +
> >  tests/dnn/dnn-layer-mathbinary-test.c   |  5 +
> >  tools/python/convert_from_tensorflow.py |  2 +-
> >  tools/python/convert_header.py  |  2 +-
> >  5 files changed, 25 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
> > b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
> > index dd42c329a9..6876aaf2c6 100644
> > --- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
> > +++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
> > @@ -175,6 +175,23 @@ int
> dnn_execute_layer_math_binary(DnnOperand
> > *operands, const int32_t *input_ope
> >  }
> >  }
> >  return 0;
> > +case DMBO_FLOORMOD:
> > +if (params->input0_broadcast) {
> > +for (int i = 0; i < dims_count; ++i) {
> > +dst[i] = (int)(params->v) % (int)(src[i]);
> > +}
> > +} else if (params->input1_broadcast) {
> > +for (int i = 0; i < dims_count; ++i) {
> > +dst[i] = (int)(src[i]) % (int)(params->v);
> > +}
> > +} else {
> > +const DnnOperand *input1 =
> [input_operand_indexes[1]];
> > +const float *src1 = input1->data;
> > +for (int i = 0; i < dims_count; ++i) {
> > +dst[i] = (int)(src[i]) % (int)(src1[i]);
> > +}
> > +}
> Nearly same code as DMBO_SUB.
> Only the op is different, how about define a function pass op as a inline
> function.
> 
> > +return 0;
> >  default:
> >  return -1;
> >  }
> > diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
> > b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
> > index 0acf3b0ea0..9525685afa 100644
> > --- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
> > +++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
> > @@ -36,6 +36,7 @@ typedef enum {
> >  DMBO_MUL = 2,
> >  DMBO_REALDIV = 3,
> >  DMBO_MINIMUM = 4,
> > +DMBO_FLOORMOD = 5,
> >  DMBO_COUNT
> >  } DNNMathBinaryOperation;
> >
> > diff --git a/tests/dnn/dnn-layer-mathbinary-test.c
> > b/tests/dnn/dnn-layer- mathbinary-test.c index e7f8f8557c..e5f6a12939
> > 100644
> > --- a/tests/dnn/dnn-layer-mathbinary-test.c
> > +++ b/tests/dnn/dnn-layer-mathbinary-test.c
> > @@ -40,6 +40,8 @@ static float get_expected(float f1, float f2,
> > DNNMathBinaryOperation op)
> >  return f1 / f2;
> >  case DMBO_MINIMUM:
> >  return (f1 < f2) ? f1 : f2;
> > +case DMBO_FLOORMOD:
> > +return (int)(f1) % (int)(f2);
> >  default:
> >  av_assert0(!"not supported yet");
> >  return 0.f;
> > @@ -205,5 +207,8 @@ int main(int argc, char **argv)
> >  if (test(DMBO_MINIMUM))
> >  return 1;
> >
> > +if (test(DMBO_FLOORMOD))
> > +return 1;
> > +
> >  return 0;
> >  }
> > diff --git a/tools/python/convert_from_tensorflow.py
> > b/tools/python/convert_from_tensorflow.py
> > index 65fdbc5d43..2ed0f66829 100644
> > --- a/tools/python/convert_from_tensorflow.py
> > +++ b/tools/python/convert_from_tensorflow.py
> > @@ -71,7 +71,7 @@ class TFConverter:
> >  self.conv2d_scope_names = set()
> >  self.conv2d_scopename_inputname_dict = {}
> >  self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3,
> > 'Maximum':4, 'MathBinary':5, 'MathUnary':6}
> > -self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3,
> 'Minimum':4}
> > +self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3,
> > + 'Minimum':4, 'FloorMod':5}
> >  self.mathun2code  = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4,
> >  'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9, 
> > 'Asinh':10,
> >  'Acosh':11, 'Atanh':12, 'Ceil':13, 'Floor':14,
> > 'Round':15} diff --git a/tools/python/convert_header.py
> > b/tools/python/convert_header.py index
> > 747c8776eb..782a6341f9 100644
> > --- a/tools/python/convert_header.py
> > +++ b/tools/python/convert_header.py
> > @@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE'
> >  major = 1
> >
> >  # increase 

Re: [FFmpeg-devel] [mov] See if mfra makes up the difference for an incomplete sidx.

2020-08-18 Thread Derek Buitenhuis
On 18/08/2020 04:57, Dale Curtis wrote:
> Can't be an else statement since the prior clause modifies is_complete.

Ah, you're right.

New version LGTM.

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

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

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

2020-08-18 Thread Michael Niedermayer
On Mon, Aug 17, 2020 at 11:25:08AM +0200, Peter van der Spek wrote:
> Since release 4.2, FFmpeg fails to detect the correct streams in an RTMP
> stream that contains a |RtmpSampleAccess AMF object prior to the
> onMetaData AMF object. In the debug log it would show "[flv] Unknown
> type |RtmpSampleAccess".
> 
> With this change the RTMP streams are correctly detected when there
> is a |RtmpSampleAccess object prior to the onMetaData object.
> 
> Signed-off-by: Peter van der Spek 
> ---
>  libavformat/flvdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Do you have a testcase?
Is this documented somewhere?

thx

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

In a rich man's house there is no place to spit but his face.
-- 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 1/2] tools/target_dec_fuzzer: Adjust threshold for DST

2020-08-18 Thread Michael Niedermayer
On Mon, Aug 17, 2020 at 07:19:43AM +1000, Peter Ross wrote:
> On Sun, Aug 16, 2020 at 08:04:08PM +0200, Michael Niedermayer wrote:
> > Fixes: Timeout (too long -> 3sec)
> > Fixes: 
> > 24239/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DST_fuzzer-5189061015502848
> > 
> > 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(-)
> > 
> > diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
> > index 476103750b..5a4fcf6b62 100644
> > --- a/tools/target_dec_fuzzer.c
> > +++ b/tools/target_dec_fuzzer.c
> > @@ -149,7 +149,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
> > size) {
> >  case AV_CODEC_ID_BINKVIDEO:   maxpixels  /= 32;break;
> >  case AV_CODEC_ID_CFHD:maxpixels  /= 128;   break;
> >  case AV_CODEC_ID_DIRAC:   maxpixels  /= 8192;  break;
> > -case AV_CODEC_ID_DST: maxsamples /= 8192;  break;
> > +case AV_CODEC_ID_DST: maxsamples /= 1<<20; break;
> 
> approve.

will apply

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"


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 7/7] avcodec/aacdec_template: add support for 22.2 / channel_config 13

2020-08-18 Thread Michael Niedermayer
On Tue, Aug 18, 2020 at 12:45:17PM +0300, Jan Ekström wrote:
> On Sun, Aug 16, 2020 at 2:15 AM Michael Niedermayer
>  wrote:
> >
> > On Sat, Aug 01, 2020 at 02:07:30PM +0300, Jan Ekström wrote:
> > > ---
> > >  libavcodec/aacdec_template.c | 89 +++-
> > >  1 file changed, 78 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
> > > index 21db12fdab..8c5048cc13 100644
> > > --- a/libavcodec/aacdec_template.c
> > > +++ b/libavcodec/aacdec_template.c
> > > @@ -387,17 +387,77 @@ static uint64_t sniff_channel_order(uint8_t 
> > > (*layout_map)[3], int tags)
> > >  i++;
> > >  }
> > >
> > > -// Must choose a stable sort
> > > +// The previous checks would end up at 8 at this point for 22.2
> > > +if (tags == 16 && i == 8) {
> > > +e2c_vec[i] = (struct elem_to_channel) {
> > > +.av_position  = AV_CH_TOP_FRONT_CENTER,
> > > +.syn_ele  = layout_map[i][0],
> > > +.elem_id  = layout_map[i][1],
> > > +.aac_position = layout_map[i][2]
> > > +}; i++;
> > > +i += assign_pair(e2c_vec, layout_map, i,
> > > + AV_CH_TOP_FRONT_LEFT,
> > > + AV_CH_TOP_FRONT_RIGHT,
> > > + AAC_CHANNEL_FRONT);
> > > +i += assign_pair(e2c_vec, layout_map, i,
> > > + AV_CH_TOP_SIDE_LEFT,
> > > + AV_CH_TOP_SIDE_RIGHT,
> > > + AAC_CHANNEL_SIDE);
> > > +e2c_vec[i] = (struct elem_to_channel) {
> > > +.av_position  = AV_CH_TOP_CENTER,
> > > +.syn_ele  = layout_map[i][0],
> > > +.elem_id  = layout_map[i][1],
> > > +.aac_position = layout_map[i][2]
> > > +}; i++;
> > > +i += assign_pair(e2c_vec, layout_map, i,
> > > + AV_CH_TOP_BACK_LEFT,
> > > + AV_CH_TOP_BACK_RIGHT,
> > > + AAC_CHANNEL_BACK);
> > > +e2c_vec[i] = (struct elem_to_channel) {
> > > +.av_position  = AV_CH_TOP_BACK_CENTER,
> > > +.syn_ele  = layout_map[i][0],
> >
> > Does this code assume all types are CPE ?
> > because if thats not true i can exceed the tags
> >
> 
> Sorry for responding late, I have been tired and didn't find a good
> spot to write things down.
> 
> No, it should not assume that all types are CPE. 22.2 utilizes both
> CPE, SCE as well as LFE. The full definition of 22.2 was added in
> 93a2913ac8a3aa25c05fd30036da89cb493e68ee with each coding element
> being documented as it is in the spec.
> 
> OK, then I did misunderstand what exactly the `tags` variable means
> and how it can go over (if that is a problem other than 22.2 with more
> coding elements than in standard samples not hitting this logic).

the fuzzer found a case where the layout_map beyond tags seems to contain
apparent bad values (different in each run and way too large)
the code then eventually crashes. 
I did not investigate this further as you seem to be activly working on
22.2. 
I think you already have some testcases but i can provide the fuzzer testcase
if you want another one

thx

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

The worst form of inequality is to try to make unequal things equal.
-- 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 2/2] avcodec/dvbsub: add "enc" suffix to encoder

2020-08-18 Thread Michael Niedermayer
On Mon, Aug 17, 2020 at 05:09:12PM +0200, Carl Eugen Hoyos wrote:
> 
> 
> > Am 17.08.2020 um 17:03 schrieb Clément Bœsch :
> > 
> > ---
> > libavcodec/Makefile  | 2 +-
> > libavcodec/{dvbsub.c => dvbsubenc.c} | 0
> > 2 files changed, 1 insertion(+), 1 deletion(-)
> > rename libavcodec/{dvbsub.c => dvbsubenc.c} (100%)
> 
> Doesn’t this make using git blame harder?

git blame has -C / -M options to adjust copy/move following theres also a
diff.renames so this should not be a problem i think

thx

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

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.


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] examples/decode_video: flush parser to fix missing frame

2020-08-18 Thread quinkblack
From: Zhao Zhili 

To reproduce, run decode_video with a single frame sample. No frame
was decoded before the patch.
---
 doc/examples/decode_video.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/doc/examples/decode_video.c b/doc/examples/decode_video.c
index 169188a4b9..ba753c6dc1 100644
--- a/doc/examples/decode_video.c
+++ b/doc/examples/decode_video.c
@@ -92,6 +92,7 @@ int main(int argc, char **argv)
 uint8_t *data;
 size_t   data_size;
 int ret;
+int eof;
 AVPacket *pkt;
 
 if (argc <= 2) {
@@ -150,15 +151,14 @@ int main(int argc, char **argv)
 exit(1);
 }
 
-while (!feof(f)) {
+do {
 /* read raw data from the input file */
 data_size = fread(inbuf, 1, INBUF_SIZE, f);
-if (!data_size)
-break;
+eof = !data_size;
 
 /* use the parser to split the data into frames */
 data = inbuf;
-while (data_size > 0) {
+while (data_size > 0 || eof) {
 ret = av_parser_parse2(parser, c, >data, >size,
data, data_size, AV_NOPTS_VALUE, 
AV_NOPTS_VALUE, 0);
 if (ret < 0) {
@@ -170,8 +170,10 @@ int main(int argc, char **argv)
 
 if (pkt->size)
 decode(c, frame, pkt, outfilename);
+if (eof)
+break;
 }
-}
+} while (!eof);
 
 /* flush the decoder */
 decode(c, frame, NULL, outfilename);
-- 
2.28.0

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

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

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

2020-08-18 Thread Ashutosh Pradhan
Generate algorithmic music using riffs, lindenmayer systems, cellular automaton 
and rhythm algorithms.
Fixed the error that was causing segmentation fault in the previous patch.

 Changelog|1 +
 configure|4 +
 doc/filters.texi |  146 +
 libavfilter/Makefile |1 +
 libavfilter/allfilters.c |1 +
 libavfilter/asrc_atone.c | 1343 ++
 libavfilter/notedef.h|  269 ++
 libavfilter/version.h|2 +-
 8 files changed, 1766 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 0108f8f1a8..0d759b7eb7 100644
--- a/Changelog
+++ b/Changelog
@@ -89,6 +89,7 @@ version 4.3:
 - PFM decoder
 - dblur video filter
 - Real War KVAG muxer
+- atone filter
 
 
 version 4.2:
diff --git a/configure b/configure
index 8de1afcb99..783bae8a03 100755
--- a/configure
+++ b/configure
@@ -233,6 +233,7 @@ External library support:
and libraw1394 [no]
   --enable-libfdk-aac  enable AAC de/encoding via libfdk-aac [no]
   --enable-libfliteenable flite (voice synthesis) support via libflite 
[no]
+  --enable-libfluidsynth   enable libfluidsynth support for atone source 
filter [no]
   --enable-libfontconfig   enable libfontconfig, useful for drawtext filter 
[no]
   --enable-libfreetype enable libfreetype, needed for drawtext filter [no]
   --enable-libfribidi  enable libfribidi, improves drawtext filter [no]
@@ -1774,6 +1775,7 @@ EXTERNAL_LIBRARY_LIST="
 libdc1394
 libdrm
 libflite
+libfluidsynth
 libfontconfig
 libfreetype
 libfribidi
@@ -3493,6 +3495,7 @@ asr_filter_deps="pocketsphinx"
 ass_filter_deps="libass"
 atempo_filter_deps="avcodec"
 atempo_filter_select="rdft"
+atone_filter_deps="libfluidsynth"
 avgblur_opencl_filter_deps="opencl"
 avgblur_vulkan_filter_deps="vulkan libglslang"
 azmq_filter_deps="libzmq"
@@ -6336,6 +6339,7 @@ enabled libfdk_aac&& { check_pkg_config 
libfdk_aac fdk-aac "fdk-aac/aace
  warn "using libfdk without pkg-config"; } }
 flite_extralibs="-lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal 
-lflite_cmu_us_kal16 -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish 
-lflite_cmulex -lflite"
 enabled libflite  && require libflite "flite/flite.h" flite_init 
$flite_extralibs
+enabled libfluidsynth && require_pkg_config libfluidsynth fluidsynth 
"fluidsynth.h" fluid_log
 enabled fontconfig&& enable libfontconfig
 enabled libfontconfig && require_pkg_config libfontconfig fontconfig 
"fontconfig/fontconfig.h" FcInit
 enabled libfreetype   && require_pkg_config libfreetype freetype2 
"ft2build.h FT_FREETYPE_H" FT_Init_FreeType
diff --git a/doc/filters.texi b/doc/filters.texi
index d8cd45066a..f21b30ca47 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -6128,6 +6128,152 @@ anoisesrc=d=60:c=pink:r=44100:a=0.5
 @end example
 @end itemize
 
+@section atone
+
+Generate nice listenable algorithmic music.
+To compile filter configure ffmpeg with @code{--enable-libfluidsynth} 
+
+The filter accepts the following options:
+
+@table @option
+@item sample_rate, r
+Specify the sample rate. Default value is 44100 Hz.
+
+@item nb_samples
+Set the number of samples per each output frame. Default is 1024.
+
+@item sfont
+Specify the location of soundfont file. Default value is 
+"/usr/share/sounds/sf2/FluidR3_GM.sf2"(for ubuntu linux). Recommended to 
+use the FluidR3_GM general midi soundfont file.
+
+@item duration, d
+Specify the duration of the generated audio stream. Not specifying this option
+results in playing tones for infinite length.
+
+@item velocity, v
+Specify the velocity of key press between 0 to 127. Default value is 80.
+
+@item p_velocity
+Specify the velocity of key press for percussion track between 0 to 127. 
+Default value is 80.
+
+@item bpm
+Specify the beats per minute. Default is 80.
+
+@item seed
+Specify the seed for random number generator, must be an integer included 
between 0 and
+UINT32_MAX. If not specified, or if explicitly set to -1, the filter will use 
a random seed.
+
+@item algo
+Specify the algorithm type. Available options are riffs, lsystem, 
ca(cellular_automaton)
+and rhythm. Default is ca.
+
+@item instrument
+Specify the instrument for riffs and Lindenmayer system. Available instruments 
are Acoustic-Grand, 
+Bright-Acoustic, ... as defined in the General Midi specifications. Default is 
Acoustic-Grand.
+
+@item percussion
+Specify the percussion track for beats. Available options are Jazz1, 
+Jazz2, ..., Jazz6, Rock1...4, Shuffle, Metronome. Default is Metronome.
+
+@item numbars
+Set the number of bars in which riff energy will change between 0 to 8. 
Default is 2.
+
+@item scale
+Set the scale for Lindenmayer system and cellular automaton. Specify as root 
note_scale type.
+Specify scale types as major, n_minor for natural minor, m_minor for melodic 
minor, h_minor 
+as harmonic minor, 

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

2020-08-18 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Paul B
> Mahol
> Sent: 2020年8月18日 17:20
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V3] dnn_backend_openvino.c: parse options
> in openvino backend
> 
> On 8/18/20, Guo, Yejun  wrote:
> > Signed-off-by: Guo, Yejun 
> > ---
> > v3: change to AVOption method
> >
> >  libavfilter/dnn/Makefile   |  1 +
> >  libavfilter/dnn/dnn_backend_openvino.c | 35
> ++-
> >  libavfilter/dnn/dnn_common.c   | 43
> > ++
> >  libavfilter/dnn/dnn_common.h   | 32
> +
> >  4 files changed, 110 insertions(+), 1 deletion(-)  create mode 100644
> > libavfilter/dnn/dnn_common.c  create mode 100644
> > libavfilter/dnn/dnn_common.h
> >
> > diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile index
> > e095707..4b7d10b 100644
> > --- a/libavfilter/dnn/Makefile
> > +++ b/libavfilter/dnn/Makefile
> > @@ -1,4 +1,5 @@
> >  OBJS-$(CONFIG_DNN)   +=
> dnn/dnn_interface.o
> > +OBJS-$(CONFIG_DNN)   +=
> dnn/dnn_common.o
> >  OBJS-$(CONFIG_DNN)   +=
> dnn/dnn_backend_native.o
> >  OBJS-$(CONFIG_DNN)   +=
> > dnn/dnn_backend_native_layers.o
> >  OBJS-$(CONFIG_DNN)   +=
> > dnn/dnn_backend_native_layer_avgpool.o
> > diff --git a/libavfilter/dnn/dnn_backend_openvino.c
> > b/libavfilter/dnn/dnn_backend_openvino.c
> > index d343bf2..b8a1b06 100644
> > --- a/libavfilter/dnn/dnn_backend_openvino.c
> > +++ b/libavfilter/dnn/dnn_backend_openvino.c
> > @@ -24,11 +24,40 @@
> >   */
> >
> >  #include "dnn_backend_openvino.h"
> > +#include "dnn_common.h"
> >  #include "libavformat/avio.h"
> >  #include "libavutil/avassert.h"
> > +#include "libavutil/opt.h"
> >  #include 
> >
> > +typedef struct OVOptions{
> > +uint32_t batch_size;
> > +uint32_t req_num;
> > +} OVOptions;
> > +
> > +typedef struct OvContext {
> > +const AVClass *class;
> > +OVOptions options;
> > +} OvContext;
> > +
> > +#define OFFSET(x) offsetof(OvContext, x) #define FLAGS
> > +AV_OPT_FLAG_FILTERING_PARAM static const AVOption dnn_ov_options[] =
> > +{
> > +{ "batch",   "batch size",OFFSET(options.batch_size),
> > AV_OPT_TYPE_INT,  { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS },
> > +{ "nireq",   "number of request", OFFSET(options.req_num),
> > AV_OPT_TYPE_INT,  { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS },
> > +{ NULL },
> > +};
> > +
> > +static const AVClass dnn_ov_class = {
> > +.class_name = "dnn_ov",
> > +.item_name  = av_default_item_name,
> > +.option = dnn_ov_options,
> > +.version= LIBAVUTIL_VERSION_INT,
> > +.category   = AV_CLASS_CATEGORY_FILTER,
> > +};
> > +
> >  typedef struct OVModel{
> > +OvContext ctx;
> >  ie_core_t *core;
> >  ie_network_t *network;
> >  ie_executable_network_t *exe_network; @@ -171,6 +200,11 @@
> > DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char
> > *options)
> >  if (!ov_model)
> >  goto err;
> >
> > +ov_model->ctx.class = _ov_class;
> > +model->options = options;
> > +if (dnn_parse_options(_model->ctx, model->options) < 0)
> > +goto err;
> > +
> >  status = ie_core_create("", _model->core);
> >  if (status != OK)
> >  goto err;
> > @@ -186,7 +220,6 @@ DNNModel *ff_dnn_load_model_ov(const char
> > *model_filename, const char *options)
> >  model->model = (void *)ov_model;
> >  model->set_input_output = _input_output_ov;
> >  model->get_input = _input_ov;
> > -model->options = options;
> >
> >  return model;
> >
> > diff --git a/libavfilter/dnn/dnn_common.c
> > b/libavfilter/dnn/dnn_common.c new file mode 100644 index
> > 000..be6301f
> > --- /dev/null
> > +++ b/libavfilter/dnn/dnn_common.c
> > @@ -0,0 +1,43 @@
> > +/*
> > + * Copyright (c) 2020
> > + *
> > + * 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
> > + * DNN common functions
> > + */
> > +
> > +#include "dnn_common.h"
> > +#include "libavutil/opt.h"
> > +
> > +int 

Re: [FFmpeg-devel] [PATCH 7/7] avcodec/aacdec_template: add support for 22.2 / channel_config 13

2020-08-18 Thread Jan Ekström
On Sun, Aug 16, 2020 at 2:15 AM Michael Niedermayer
 wrote:
>
> On Sat, Aug 01, 2020 at 02:07:30PM +0300, Jan Ekström wrote:
> > ---
> >  libavcodec/aacdec_template.c | 89 +++-
> >  1 file changed, 78 insertions(+), 11 deletions(-)
> >
> > diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
> > index 21db12fdab..8c5048cc13 100644
> > --- a/libavcodec/aacdec_template.c
> > +++ b/libavcodec/aacdec_template.c
> > @@ -387,17 +387,77 @@ static uint64_t sniff_channel_order(uint8_t 
> > (*layout_map)[3], int tags)
> >  i++;
> >  }
> >
> > -// Must choose a stable sort
> > +// The previous checks would end up at 8 at this point for 22.2
> > +if (tags == 16 && i == 8) {
> > +e2c_vec[i] = (struct elem_to_channel) {
> > +.av_position  = AV_CH_TOP_FRONT_CENTER,
> > +.syn_ele  = layout_map[i][0],
> > +.elem_id  = layout_map[i][1],
> > +.aac_position = layout_map[i][2]
> > +}; i++;
> > +i += assign_pair(e2c_vec, layout_map, i,
> > + AV_CH_TOP_FRONT_LEFT,
> > + AV_CH_TOP_FRONT_RIGHT,
> > + AAC_CHANNEL_FRONT);
> > +i += assign_pair(e2c_vec, layout_map, i,
> > + AV_CH_TOP_SIDE_LEFT,
> > + AV_CH_TOP_SIDE_RIGHT,
> > + AAC_CHANNEL_SIDE);
> > +e2c_vec[i] = (struct elem_to_channel) {
> > +.av_position  = AV_CH_TOP_CENTER,
> > +.syn_ele  = layout_map[i][0],
> > +.elem_id  = layout_map[i][1],
> > +.aac_position = layout_map[i][2]
> > +}; i++;
> > +i += assign_pair(e2c_vec, layout_map, i,
> > + AV_CH_TOP_BACK_LEFT,
> > + AV_CH_TOP_BACK_RIGHT,
> > + AAC_CHANNEL_BACK);
> > +e2c_vec[i] = (struct elem_to_channel) {
> > +.av_position  = AV_CH_TOP_BACK_CENTER,
> > +.syn_ele  = layout_map[i][0],
>
> Does this code assume all types are CPE ?
> because if thats not true i can exceed the tags
>

Sorry for responding late, I have been tired and didn't find a good
spot to write things down.

No, it should not assume that all types are CPE. 22.2 utilizes both
CPE, SCE as well as LFE. The full definition of 22.2 was added in
93a2913ac8a3aa25c05fd30036da89cb493e68ee with each coding element
being documented as it is in the spec.

OK, then I did misunderstand what exactly the `tags` variable means
and how it can go over (if that is a problem other than 22.2 with more
coding elements than in standard samples not hitting this logic).

>
> > +.elem_id  = layout_map[i][1],
> > +.aac_position = layout_map[i][2]
> > +}; i++;
> > +e2c_vec[i] = (struct elem_to_channel) {
> > +.av_position  = AV_CH_BOTTOM_FRONT_CENTER,
> > +.syn_ele  = layout_map[i][0],
> > +.elem_id  = layout_map[i][1],
> > +.aac_position = layout_map[i][2]
> > +}; i++;
> > +i += assign_pair(e2c_vec, layout_map, i,
> > + AV_CH_BOTTOM_FRONT_LEFT,
> > + AV_CH_BOTTOM_FRONT_RIGHT,
> > + AAC_CHANNEL_FRONT);
> > +}
> > +
> >  total_non_cc_elements = n = i;
> > -do {
> > -int next_n = 0;
> > -for (i = 1; i < n; i++)
> > -if (e2c_vec[i - 1].av_position > e2c_vec[i].av_position) {
> > -FFSWAP(struct elem_to_channel, e2c_vec[i - 1], e2c_vec[i]);
> > -next_n = i;
> > -}
> > -n = next_n;
> > -} while (n > 0);
> > +
> > +if (tags == 16 && total_non_cc_elements == 16) {
> > +// For 22.2 reorder the result as needed
> > +FFSWAP(struct elem_to_channel, e2c_vec[2], e2c_vec[0]);   // FL & 
> > FR first (final), FC third
> > +FFSWAP(struct elem_to_channel, e2c_vec[2], e2c_vec[1]);   // FC 
> > second (final), FLc & FRc third
> > +FFSWAP(struct elem_to_channel, e2c_vec[6], e2c_vec[2]);   // LFE1 
> > third (final), FLc & FRc seventh
> > +FFSWAP(struct elem_to_channel, e2c_vec[4], e2c_vec[3]);   // BL & 
> > BR fourth (final), SiL & SiR fifth
> > +FFSWAP(struct elem_to_channel, e2c_vec[6], e2c_vec[4]);   // FLc & 
> > FRc fifth (final), SiL & SiR seventh
> > +FFSWAP(struct elem_to_channel, e2c_vec[7], e2c_vec[6]);   // LFE2 
> > seventh (final), SiL & SiR eight (final)
> > +FFSWAP(struct elem_to_channel, e2c_vec[9], e2c_vec[8]);   // TpFL 
> > & TpFR ninth (final), TFC tenth (final)
> > +FFSWAP(struct elem_to_channel, e2c_vec[11], e2c_vec[10]); // TC 
> > eleventh (final), TpSiL & TpSiR twelth
> > +FFSWAP(struct elem_to_channel, e2c_vec[12], e2c_vec[11]); // TpBL 
> > & TpBR twelth (final), TpSiL & TpSiR thirteenth (final)
>
> Does this not need to check the 

Re: [FFmpeg-devel] [PATCH 7/7] avcodec/aacdec_template: add support for 22.2 / channel_config 13

2020-08-18 Thread Jan Ekström
On Tue, Aug 18, 2020 at 12:17 PM Paul B Mahol  wrote:
>
> I think there is open bug report about SEGV regarding this commit on trac.
>
> Please revert or fix ASAP!
>

Thank you for letting me know about this. I will take a look at this
after work. Please do not yell at me, I am not your enemy.

Jan

> On 8/16/20, Michael Niedermayer  wrote:
> > On Sat, Aug 01, 2020 at 02:07:30PM +0300, Jan Ekström wrote:
> >> ---
> >>  libavcodec/aacdec_template.c | 89 +++-
> >>  1 file changed, 78 insertions(+), 11 deletions(-)
> >>
> >> diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
> >> index 21db12fdab..8c5048cc13 100644
> >> --- a/libavcodec/aacdec_template.c
> >> +++ b/libavcodec/aacdec_template.c
> >> @@ -387,17 +387,77 @@ static uint64_t sniff_channel_order(uint8_t
> >> (*layout_map)[3], int tags)
> >>  i++;
> >>  }
> >>
> >> -// Must choose a stable sort
> >> +// The previous checks would end up at 8 at this point for 22.2
> >> +if (tags == 16 && i == 8) {
> >> +e2c_vec[i] = (struct elem_to_channel) {
> >> +.av_position  = AV_CH_TOP_FRONT_CENTER,
> >> +.syn_ele  = layout_map[i][0],
> >> +.elem_id  = layout_map[i][1],
> >> +.aac_position = layout_map[i][2]
> >> +}; i++;
> >> +i += assign_pair(e2c_vec, layout_map, i,
> >> + AV_CH_TOP_FRONT_LEFT,
> >> + AV_CH_TOP_FRONT_RIGHT,
> >> + AAC_CHANNEL_FRONT);
> >> +i += assign_pair(e2c_vec, layout_map, i,
> >> + AV_CH_TOP_SIDE_LEFT,
> >> + AV_CH_TOP_SIDE_RIGHT,
> >> + AAC_CHANNEL_SIDE);
> >> +e2c_vec[i] = (struct elem_to_channel) {
> >> +.av_position  = AV_CH_TOP_CENTER,
> >> +.syn_ele  = layout_map[i][0],
> >> +.elem_id  = layout_map[i][1],
> >> +.aac_position = layout_map[i][2]
> >> +}; i++;
> >> +i += assign_pair(e2c_vec, layout_map, i,
> >> + AV_CH_TOP_BACK_LEFT,
> >> + AV_CH_TOP_BACK_RIGHT,
> >> + AAC_CHANNEL_BACK);
> >> +e2c_vec[i] = (struct elem_to_channel) {
> >> +.av_position  = AV_CH_TOP_BACK_CENTER,
> >> +.syn_ele  = layout_map[i][0],
> >
> > Does this code assume all types are CPE ?
> > because if thats not true i can exceed the tags
> >
> >
> >> +.elem_id  = layout_map[i][1],
> >> +.aac_position = layout_map[i][2]
> >> +}; i++;
> >> +e2c_vec[i] = (struct elem_to_channel) {
> >> +.av_position  = AV_CH_BOTTOM_FRONT_CENTER,
> >> +.syn_ele  = layout_map[i][0],
> >> +.elem_id  = layout_map[i][1],
> >> +.aac_position = layout_map[i][2]
> >> +}; i++;
> >> +i += assign_pair(e2c_vec, layout_map, i,
> >> + AV_CH_BOTTOM_FRONT_LEFT,
> >> + AV_CH_BOTTOM_FRONT_RIGHT,
> >> + AAC_CHANNEL_FRONT);
> >> +}
> >> +
> >>  total_non_cc_elements = n = i;
> >> -do {
> >> -int next_n = 0;
> >> -for (i = 1; i < n; i++)
> >> -if (e2c_vec[i - 1].av_position > e2c_vec[i].av_position) {
> >> -FFSWAP(struct elem_to_channel, e2c_vec[i - 1],
> >> e2c_vec[i]);
> >> -next_n = i;
> >> -}
> >> -n = next_n;
> >> -} while (n > 0);
> >> +
> >> +if (tags == 16 && total_non_cc_elements == 16) {
> >> +// For 22.2 reorder the result as needed
> >> +FFSWAP(struct elem_to_channel, e2c_vec[2], e2c_vec[0]);   // FL &
> >> FR first (final), FC third
> >> +FFSWAP(struct elem_to_channel, e2c_vec[2], e2c_vec[1]);   // FC
> >> second (final), FLc & FRc third
> >> +FFSWAP(struct elem_to_channel, e2c_vec[6], e2c_vec[2]);   // LFE1
> >> third (final), FLc & FRc seventh
> >> +FFSWAP(struct elem_to_channel, e2c_vec[4], e2c_vec[3]);   // BL &
> >> BR fourth (final), SiL & SiR fifth
> >> +FFSWAP(struct elem_to_channel, e2c_vec[6], e2c_vec[4]);   // FLc
> >> & FRc fifth (final), SiL & SiR seventh
> >> +FFSWAP(struct elem_to_channel, e2c_vec[7], e2c_vec[6]);   // LFE2
> >> seventh (final), SiL & SiR eight (final)
> >> +FFSWAP(struct elem_to_channel, e2c_vec[9], e2c_vec[8]);   // TpFL
> >> & TpFR ninth (final), TFC tenth (final)
> >> +FFSWAP(struct elem_to_channel, e2c_vec[11], e2c_vec[10]); // TC
> >> eleventh (final), TpSiL & TpSiR twelth
> >> +FFSWAP(struct elem_to_channel, e2c_vec[12], e2c_vec[11]); // TpBL
> >> & TpBR twelth (final), TpSiL & TpSiR thirteenth (final)
> >
> > Does this not need to check the assumtations from the comments ?
> >
> > thx
> >
> > [...]
> > --
> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > Awnsering 

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

2020-08-18 Thread Paul B Mahol
On 8/18/20, Guo, Yejun  wrote:
> Signed-off-by: Guo, Yejun 
> ---
> v3: change to AVOption method
>
>  libavfilter/dnn/Makefile   |  1 +
>  libavfilter/dnn/dnn_backend_openvino.c | 35 ++-
>  libavfilter/dnn/dnn_common.c   | 43
> ++
>  libavfilter/dnn/dnn_common.h   | 32 +
>  4 files changed, 110 insertions(+), 1 deletion(-)
>  create mode 100644 libavfilter/dnn/dnn_common.c
>  create mode 100644 libavfilter/dnn/dnn_common.h
>
> diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
> index e095707..4b7d10b 100644
> --- a/libavfilter/dnn/Makefile
> +++ b/libavfilter/dnn/Makefile
> @@ -1,4 +1,5 @@
>  OBJS-$(CONFIG_DNN)   += dnn/dnn_interface.o
> +OBJS-$(CONFIG_DNN)   += dnn/dnn_common.o
>  OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native.o
>  OBJS-$(CONFIG_DNN)   +=
> dnn/dnn_backend_native_layers.o
>  OBJS-$(CONFIG_DNN)   +=
> dnn/dnn_backend_native_layer_avgpool.o
> diff --git a/libavfilter/dnn/dnn_backend_openvino.c
> b/libavfilter/dnn/dnn_backend_openvino.c
> index d343bf2..b8a1b06 100644
> --- a/libavfilter/dnn/dnn_backend_openvino.c
> +++ b/libavfilter/dnn/dnn_backend_openvino.c
> @@ -24,11 +24,40 @@
>   */
>
>  #include "dnn_backend_openvino.h"
> +#include "dnn_common.h"
>  #include "libavformat/avio.h"
>  #include "libavutil/avassert.h"
> +#include "libavutil/opt.h"
>  #include 
>
> +typedef struct OVOptions{
> +uint32_t batch_size;
> +uint32_t req_num;
> +} OVOptions;
> +
> +typedef struct OvContext {
> +const AVClass *class;
> +OVOptions options;
> +} OvContext;
> +
> +#define OFFSET(x) offsetof(OvContext, x)
> +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
> +static const AVOption dnn_ov_options[] = {
> +{ "batch",   "batch size",OFFSET(options.batch_size),
> AV_OPT_TYPE_INT,  { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS },
> +{ "nireq",   "number of request", OFFSET(options.req_num),
> AV_OPT_TYPE_INT,  { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS },
> +{ NULL },
> +};
> +
> +static const AVClass dnn_ov_class = {
> +.class_name = "dnn_ov",
> +.item_name  = av_default_item_name,
> +.option = dnn_ov_options,
> +.version= LIBAVUTIL_VERSION_INT,
> +.category   = AV_CLASS_CATEGORY_FILTER,
> +};
> +
>  typedef struct OVModel{
> +OvContext ctx;
>  ie_core_t *core;
>  ie_network_t *network;
>  ie_executable_network_t *exe_network;
> @@ -171,6 +200,11 @@ DNNModel *ff_dnn_load_model_ov(const char
> *model_filename, const char *options)
>  if (!ov_model)
>  goto err;
>
> +ov_model->ctx.class = _ov_class;
> +model->options = options;
> +if (dnn_parse_options(_model->ctx, model->options) < 0)
> +goto err;
> +
>  status = ie_core_create("", _model->core);
>  if (status != OK)
>  goto err;
> @@ -186,7 +220,6 @@ DNNModel *ff_dnn_load_model_ov(const char
> *model_filename, const char *options)
>  model->model = (void *)ov_model;
>  model->set_input_output = _input_output_ov;
>  model->get_input = _input_ov;
> -model->options = options;
>
>  return model;
>
> diff --git a/libavfilter/dnn/dnn_common.c b/libavfilter/dnn/dnn_common.c
> new file mode 100644
> index 000..be6301f
> --- /dev/null
> +++ b/libavfilter/dnn/dnn_common.c
> @@ -0,0 +1,43 @@
> +/*
> + * Copyright (c) 2020
> + *
> + * 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
> + * DNN common functions
> + */
> +
> +#include "dnn_common.h"
> +#include "libavutil/opt.h"
> +
> +int dnn_parse_options(void *ctx, const char *options)
> +{
> +AVDictionary *dict = NULL;
> +int err = av_dict_parse_string(, options, "=", "&", 0);
> +if (err < 0) {
> +av_dict_free();
> +return err;
> +}
> +
> +av_opt_set_defaults(ctx);
> +err = av_opt_set_dict(ctx, );
> +
> +av_dict_free();
> +return err;
> +}

Is such function really needed?

> diff --git a/libavfilter/dnn/dnn_common.h b/libavfilter/dnn/dnn_common.h
> new file mode 100644
> index 000..dc0f823
> --- /dev/null
> +++ 

Re: [FFmpeg-devel] [PATCH 7/7] avcodec/aacdec_template: add support for 22.2 / channel_config 13

2020-08-18 Thread Paul B Mahol
I think there is open bug report about SEGV regarding this commit on trac.

Please revert or fix ASAP!

On 8/16/20, Michael Niedermayer  wrote:
> On Sat, Aug 01, 2020 at 02:07:30PM +0300, Jan Ekström wrote:
>> ---
>>  libavcodec/aacdec_template.c | 89 +++-
>>  1 file changed, 78 insertions(+), 11 deletions(-)
>>
>> diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
>> index 21db12fdab..8c5048cc13 100644
>> --- a/libavcodec/aacdec_template.c
>> +++ b/libavcodec/aacdec_template.c
>> @@ -387,17 +387,77 @@ static uint64_t sniff_channel_order(uint8_t
>> (*layout_map)[3], int tags)
>>  i++;
>>  }
>>
>> -// Must choose a stable sort
>> +// The previous checks would end up at 8 at this point for 22.2
>> +if (tags == 16 && i == 8) {
>> +e2c_vec[i] = (struct elem_to_channel) {
>> +.av_position  = AV_CH_TOP_FRONT_CENTER,
>> +.syn_ele  = layout_map[i][0],
>> +.elem_id  = layout_map[i][1],
>> +.aac_position = layout_map[i][2]
>> +}; i++;
>> +i += assign_pair(e2c_vec, layout_map, i,
>> + AV_CH_TOP_FRONT_LEFT,
>> + AV_CH_TOP_FRONT_RIGHT,
>> + AAC_CHANNEL_FRONT);
>> +i += assign_pair(e2c_vec, layout_map, i,
>> + AV_CH_TOP_SIDE_LEFT,
>> + AV_CH_TOP_SIDE_RIGHT,
>> + AAC_CHANNEL_SIDE);
>> +e2c_vec[i] = (struct elem_to_channel) {
>> +.av_position  = AV_CH_TOP_CENTER,
>> +.syn_ele  = layout_map[i][0],
>> +.elem_id  = layout_map[i][1],
>> +.aac_position = layout_map[i][2]
>> +}; i++;
>> +i += assign_pair(e2c_vec, layout_map, i,
>> + AV_CH_TOP_BACK_LEFT,
>> + AV_CH_TOP_BACK_RIGHT,
>> + AAC_CHANNEL_BACK);
>> +e2c_vec[i] = (struct elem_to_channel) {
>> +.av_position  = AV_CH_TOP_BACK_CENTER,
>> +.syn_ele  = layout_map[i][0],
>
> Does this code assume all types are CPE ?
> because if thats not true i can exceed the tags
>
>
>> +.elem_id  = layout_map[i][1],
>> +.aac_position = layout_map[i][2]
>> +}; i++;
>> +e2c_vec[i] = (struct elem_to_channel) {
>> +.av_position  = AV_CH_BOTTOM_FRONT_CENTER,
>> +.syn_ele  = layout_map[i][0],
>> +.elem_id  = layout_map[i][1],
>> +.aac_position = layout_map[i][2]
>> +}; i++;
>> +i += assign_pair(e2c_vec, layout_map, i,
>> + AV_CH_BOTTOM_FRONT_LEFT,
>> + AV_CH_BOTTOM_FRONT_RIGHT,
>> + AAC_CHANNEL_FRONT);
>> +}
>> +
>>  total_non_cc_elements = n = i;
>> -do {
>> -int next_n = 0;
>> -for (i = 1; i < n; i++)
>> -if (e2c_vec[i - 1].av_position > e2c_vec[i].av_position) {
>> -FFSWAP(struct elem_to_channel, e2c_vec[i - 1],
>> e2c_vec[i]);
>> -next_n = i;
>> -}
>> -n = next_n;
>> -} while (n > 0);
>> +
>> +if (tags == 16 && total_non_cc_elements == 16) {
>> +// For 22.2 reorder the result as needed
>> +FFSWAP(struct elem_to_channel, e2c_vec[2], e2c_vec[0]);   // FL &
>> FR first (final), FC third
>> +FFSWAP(struct elem_to_channel, e2c_vec[2], e2c_vec[1]);   // FC
>> second (final), FLc & FRc third
>> +FFSWAP(struct elem_to_channel, e2c_vec[6], e2c_vec[2]);   // LFE1
>> third (final), FLc & FRc seventh
>> +FFSWAP(struct elem_to_channel, e2c_vec[4], e2c_vec[3]);   // BL &
>> BR fourth (final), SiL & SiR fifth
>> +FFSWAP(struct elem_to_channel, e2c_vec[6], e2c_vec[4]);   // FLc
>> & FRc fifth (final), SiL & SiR seventh
>> +FFSWAP(struct elem_to_channel, e2c_vec[7], e2c_vec[6]);   // LFE2
>> seventh (final), SiL & SiR eight (final)
>> +FFSWAP(struct elem_to_channel, e2c_vec[9], e2c_vec[8]);   // TpFL
>> & TpFR ninth (final), TFC tenth (final)
>> +FFSWAP(struct elem_to_channel, e2c_vec[11], e2c_vec[10]); // TC
>> eleventh (final), TpSiL & TpSiR twelth
>> +FFSWAP(struct elem_to_channel, e2c_vec[12], e2c_vec[11]); // TpBL
>> & TpBR twelth (final), TpSiL & TpSiR thirteenth (final)
>
> Does this not need to check the assumtations from the comments ?
>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Awnsering whenever a program halts or runs forever is
> On a turing machine, in general impossible (turings halting problem).
> On any real computer, always possible as a real computer has a finite
> number
> of states N, and will either halt in less than N cycles or never halt.
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

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

2020-08-18 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
v3: change to AVOption method

 libavfilter/dnn/Makefile   |  1 +
 libavfilter/dnn/dnn_backend_openvino.c | 35 ++-
 libavfilter/dnn/dnn_common.c   | 43 ++
 libavfilter/dnn/dnn_common.h   | 32 +
 4 files changed, 110 insertions(+), 1 deletion(-)
 create mode 100644 libavfilter/dnn/dnn_common.c
 create mode 100644 libavfilter/dnn/dnn_common.h

diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
index e095707..4b7d10b 100644
--- a/libavfilter/dnn/Makefile
+++ b/libavfilter/dnn/Makefile
@@ -1,4 +1,5 @@
 OBJS-$(CONFIG_DNN)   += dnn/dnn_interface.o
+OBJS-$(CONFIG_DNN)   += dnn/dnn_common.o
 OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native.o
 OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native_layers.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_avgpool.o
diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index d343bf2..b8a1b06 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -24,11 +24,40 @@
  */
 
 #include "dnn_backend_openvino.h"
+#include "dnn_common.h"
 #include "libavformat/avio.h"
 #include "libavutil/avassert.h"
+#include "libavutil/opt.h"
 #include 
 
+typedef struct OVOptions{
+uint32_t batch_size;
+uint32_t req_num;
+} OVOptions;
+
+typedef struct OvContext {
+const AVClass *class;
+OVOptions options;
+} OvContext;
+
+#define OFFSET(x) offsetof(OvContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
+static const AVOption dnn_ov_options[] = {
+{ "batch",   "batch size",OFFSET(options.batch_size), 
AV_OPT_TYPE_INT,  { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS },
+{ "nireq",   "number of request", OFFSET(options.req_num),
AV_OPT_TYPE_INT,  { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS },
+{ NULL },
+};
+
+static const AVClass dnn_ov_class = {
+.class_name = "dnn_ov",
+.item_name  = av_default_item_name,
+.option = dnn_ov_options,
+.version= LIBAVUTIL_VERSION_INT,
+.category   = AV_CLASS_CATEGORY_FILTER,
+};
+
 typedef struct OVModel{
+OvContext ctx;
 ie_core_t *core;
 ie_network_t *network;
 ie_executable_network_t *exe_network;
@@ -171,6 +200,11 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, 
const char *options)
 if (!ov_model)
 goto err;
 
+ov_model->ctx.class = _ov_class;
+model->options = options;
+if (dnn_parse_options(_model->ctx, model->options) < 0)
+goto err;
+
 status = ie_core_create("", _model->core);
 if (status != OK)
 goto err;
@@ -186,7 +220,6 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, 
const char *options)
 model->model = (void *)ov_model;
 model->set_input_output = _input_output_ov;
 model->get_input = _input_ov;
-model->options = options;
 
 return model;
 
diff --git a/libavfilter/dnn/dnn_common.c b/libavfilter/dnn/dnn_common.c
new file mode 100644
index 000..be6301f
--- /dev/null
+++ b/libavfilter/dnn/dnn_common.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2020
+ *
+ * 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
+ * DNN common functions
+ */
+
+#include "dnn_common.h"
+#include "libavutil/opt.h"
+
+int dnn_parse_options(void *ctx, const char *options)
+{
+AVDictionary *dict = NULL;
+int err = av_dict_parse_string(, options, "=", "&", 0);
+if (err < 0) {
+av_dict_free();
+return err;
+}
+
+av_opt_set_defaults(ctx);
+err = av_opt_set_dict(ctx, );
+
+av_dict_free();
+return err;
+}
diff --git a/libavfilter/dnn/dnn_common.h b/libavfilter/dnn/dnn_common.h
new file mode 100644
index 000..dc0f823
--- /dev/null
+++ b/libavfilter/dnn/dnn_common.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2020
+ *
+ * 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 

[FFmpeg-devel] [v2] dnn_backend_native_layer_mathbinary: add floormod support

2020-08-18 Thread Mingyu Yin
Signed-off-by: Mingyu Yin 
---
 .../dnn/dnn_backend_native_layer_mathbinary.c   | 17 +
 .../dnn/dnn_backend_native_layer_mathbinary.h   |  1 +
 tests/dnn/dnn-layer-mathbinary-test.c   |  5 +
 tools/python/convert_from_tensorflow.py |  2 +-
 tools/python/convert_header.py  |  2 +-
 5 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c 
b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
index dd42c329a9..6876aaf2c6 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
@@ -175,6 +175,23 @@ int dnn_execute_layer_math_binary(DnnOperand *operands, 
const int32_t *input_ope
 }
 }
 return 0;
+case DMBO_FLOORMOD:
+if (params->input0_broadcast) {
+for (int i = 0; i < dims_count; ++i) {
+dst[i] = (int)(params->v) % (int)(src[i]);
+}
+} else if (params->input1_broadcast) {
+for (int i = 0; i < dims_count; ++i) {
+dst[i] = (int)(src[i]) % (int)(params->v);
+}
+} else {
+const DnnOperand *input1 = [input_operand_indexes[1]];
+const float *src1 = input1->data;
+for (int i = 0; i < dims_count; ++i) {
+dst[i] = (int)(src[i]) % (int)(src1[i]);
+}
+}
+return 0;
 default:
 return -1;
 }
diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h 
b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
index 0acf3b0ea0..9525685afa 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
@@ -36,6 +36,7 @@ typedef enum {
 DMBO_MUL = 2,
 DMBO_REALDIV = 3,
 DMBO_MINIMUM = 4,
+DMBO_FLOORMOD = 5,
 DMBO_COUNT
 } DNNMathBinaryOperation;
 
diff --git a/tests/dnn/dnn-layer-mathbinary-test.c 
b/tests/dnn/dnn-layer-mathbinary-test.c
index e7f8f8557c..e5f6a12939 100644
--- a/tests/dnn/dnn-layer-mathbinary-test.c
+++ b/tests/dnn/dnn-layer-mathbinary-test.c
@@ -40,6 +40,8 @@ static float get_expected(float f1, float f2, 
DNNMathBinaryOperation op)
 return f1 / f2;
 case DMBO_MINIMUM:
 return (f1 < f2) ? f1 : f2;
+case DMBO_FLOORMOD:
+return (int)(f1) % (int)(f2);
 default:
 av_assert0(!"not supported yet");
 return 0.f;
@@ -205,5 +207,8 @@ int main(int argc, char **argv)
 if (test(DMBO_MINIMUM))
 return 1;
 
+if (test(DMBO_FLOORMOD))
+return 1;
+
 return 0;
 }
diff --git a/tools/python/convert_from_tensorflow.py 
b/tools/python/convert_from_tensorflow.py
index 3c14bed487..1762091fdd 100644
--- a/tools/python/convert_from_tensorflow.py
+++ b/tools/python/convert_from_tensorflow.py
@@ -73,7 +73,7 @@ class TFConverter:
 self.conv2d_scopename_inputname_dict = {}
 self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3, 
'Maximum':4,
 'MathBinary':5, 'MathUnary':6, 'AvgPool':7}
-self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 
'Minimum':4}
+self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 
'Minimum':4, 'FloorMod':5}
 self.mathun2code  = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4,
 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9, 'Asinh':10,
 'Acosh':11, 'Atanh':12, 'Ceil':13, 'Floor':14, 'Round':15}
diff --git a/tools/python/convert_header.py b/tools/python/convert_header.py
index 747c8776eb..782a6341f9 100644
--- a/tools/python/convert_header.py
+++ b/tools/python/convert_header.py
@@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE'
 major = 1
 
 # increase minor when we don't have to re-convert the model file
-minor = 21
+minor = 22
-- 
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".