Re: [FFmpeg-devel] [PATCH] avdevice/decklink_dec: fix build with older SDK

2020-09-14 Thread Gyan Doshi



On 15-09-2020 12:54 am, Marton Balint wrote:

Apparently bmdFormatUnspecified needs SDK 11.0. It is just a fancy way of
checking for zero, so let's do that instead.

Fixes build issue since f1b908d20a8.

Signed-off-by: Marton Balint 
---
  libavdevice/decklink_dec.cpp | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 92b8feed14..6517b9df13 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -1232,7 +1232,7 @@ av_cold int ff_decklink_read_header(AVFormatContext 
*avctx)
  }
  av_log(avctx, AV_LOG_INFO, "Autodetected the input mode\n");
  }
-if (ctx->raw_format == bmdFormatUnspecified)
+if (ctx->raw_format == (BMDPixelFormat)0)
  ctx->raw_format = bmdFormat8BitYUV;
  if (ff_decklink_set_format(avctx, DIRECTION_IN) < 0) {
  av_log(avctx, AV_LOG_ERROR, "Could not set format code %s for %s\n",


LGTM.

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

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

Re: [FFmpeg-devel] [PATCH V2] Added MKV tag for AVS2 video codec

2020-09-14 Thread myp...@gmail.com
On Sun, Sep 6, 2020 at 6:40 PM Ze Yuan  wrote:
>
> From ea96e70874c87b003af1fb3fcd5c792b3292bf29 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?=E9=83=91=E5=A4=A9=E6=B3=A2?= 
> Date: Sun, 6 Sep 2020 18:35:51 +0800
> Subject: [PATCH] Added MKV tag for AVS2 video codec
>
> avs2 (IEEE 1857.4) video codec
>
> MKV spec: V_AVS2 Codec ID: V_AVS2 Codec Name: AVS2-P2/IEEE.1857.4
> (https://github.com/xatabhk/matroska-specification/blob/master/codec_specs.md)
>
> 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
> Command line:
>
>  ffmpeg -i .mp4 -vcodec avs2 -acodec copy _avs2.mkv
>  ffmpeg -i .mp4 -vcodec avs2 -speed_level 4 -acodec copy 
> _avs2.mkv`
>
> Players:
> (1) Ffmpeg with avs2 enabled: 
> (https://github.com/xatabhk/FFmpeg-avs2-avs3/releases):
> Command line:
>
>  ffplay _avs2.mkv`
> (2) VLC 3.0.x with avs2 enabled: 
> https://github.com/xatabhk/vlc-3.0-avs2-avs3/releases
> (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
>
> ---
> libavformat/matroska.c | 1 +
> 1 file changed, 1 insertion(+)
>
> 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

LGTM, now AVS2 supported by MKV spec from link
https://github.com/cellar-wg/matroska-specification/blob/master/codec_specs.md
___
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 v9 2/5] lavc/avs3: add AVS3 related definitions

2020-09-14 Thread myp...@gmail.com
On Mon, Aug 31, 2020 at 11:09 PM  wrote:
>
> From: hwren 
>
> Signed-off-by: hwren 
> ---
>  libavcodec/avs3.h | 118 ++
>  1 file changed, 118 insertions(+)
>  create mode 100644 libavcodec/avs3.h
>
> diff --git a/libavcodec/avs3.h b/libavcodec/avs3.h
> new file mode 100644
> index 00..4189d9b583
> --- /dev/null
> +++ b/libavcodec/avs3.h
> @@ -0,0 +1,118 @@
> +/*
> + *  AVS3 related definitions
> + *
> + * Copyright (C) 2020 Huiwen Ren, 
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#ifndef AVCODEC_AVS3_H
> +#define AVCODEC_AVS3_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 AVS3_ISPIC(x) ((x) == AVS3_INTRA_PIC_START_CODE || (x) == 
> AVS3_INTER_PIC_START_CODE)
> +#define AVS3_ISUNIT(x) ((x) == AVS3_SEQ_START_CODE || AVS3_ISPIC(x))
> +
> +#include "libavutil/avutil.h"
> +#include "libavutil/pixfmt.h"
> +#include "libavutil/rational.h"
> +
> +static const AVRational ff_avs3_frame_rate_tab[16] = {
> +{ 0, 0   }, // forbid
> +{ 24000, 1001},
> +{ 24   , 1   },
> +{ 25   , 1   },
> +{ 3, 1001},
> +{ 30   , 1   },
> +{ 50   , 1   },
> +{ 6, 1001},
> +{ 60   , 1   },
> +{ 100  , 1   },
> +{ 120  , 1   },
> +{ 200  , 1   },
> +{ 240  , 1   },
> +{ 300  , 1   },
> +{ 0, 0   }, // reserved
> +{ 0, 0   }  // reserved
> +};
> +
> +static const int ff_avs3_color_primaries_tab[10] = {
> +AVCOL_PRI_RESERVED0   ,// 0
> +AVCOL_PRI_BT709   ,// 1
> +AVCOL_PRI_UNSPECIFIED ,// 2
> +AVCOL_PRI_RESERVED,// 3
> +AVCOL_PRI_BT470M  ,// 4
> +AVCOL_PRI_BT470BG ,// 5
> +AVCOL_PRI_SMPTE170M   ,// 6
> +AVCOL_PRI_SMPTE240M   ,// 7
> +AVCOL_PRI_FILM,// 8
> +AVCOL_PRI_BT2020   // 9
> +};
> +
> +static const int ff_avs3_color_transfer_tab[15] = {
> +AVCOL_TRC_RESERVED0, // 0
> +AVCOL_TRC_BT709, // 1
> +AVCOL_TRC_UNSPECIFIED  , // 2
> +AVCOL_TRC_RESERVED , // 3
> +AVCOL_TRC_GAMMA22  , // 4
> +AVCOL_TRC_GAMMA28  , // 5
> +AVCOL_TRC_SMPTE170M, // 6
> +AVCOL_TRC_SMPTE240M, // 7
> +AVCOL_TRC_LINEAR   , // 8
> +AVCOL_TRC_LOG  , // 9
> +AVCOL_TRC_LOG_SQRT , // 10
> +AVCOL_TRC_BT2020_12, // 11
> +AVCOL_TRC_SMPTE2084, // 12
> +AVCOL_TRC_UNSPECIFIED  , // 13
> +AVCOL_TRC_ARIB_STD_B67   // 14
> +};
> +
> +static const int ff_avs3_color_matrix_tab[12] = {
> +AVCOL_SPC_RESERVED , // 0
> +AVCOL_SPC_BT709, // 1
> +AVCOL_SPC_UNSPECIFIED  , // 2
> +AVCOL_SPC_RESERVED , // 3
> +AVCOL_SPC_FCC  , // 4
> +AVCOL_SPC_BT470BG  , // 5
> +AVCOL_SPC_SMPTE170M, // 6
> +AVCOL_SPC_SMPTE240M, // 7
> +AVCOL_SPC_BT2020_NCL   , // 8
> +AVCOL_SPC_BT2020_CL, // 9
> +AVCOL_SPC_UNSPECIFIED  , // 10
> +AVCOL_SPC_UNSPECIFIED// 11
> +};
> +
> +static const enum AVPictureType ff_avs3_image_type[4] = {
> +AV_PICTURE_TYPE_NONE,
> +AV_PICTURE_TYPE_I,
> +AV_PICTURE_TYPE_P,
> +AV_PICTURE_TYPE_B
> +};
> +
> +#endif /* AVCODEC_AVS3_H */
> --
Now patchset is OK for me, no more comments
___
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] [PATCHv2] [RFC] libavcodec/hevc_refs: Clear DPB of old frames

2020-09-14 Thread Kieran Kunhya
On Mon, 14 Sep 2020 at 17:37, Kieran Kunhya  wrote:

> From 21bf6e5eac61d34f270534dd5a2a7229967c1ee9 Mon Sep 17 00:00:00 2001
> From: Kieran Kunhya 
> Date: Thu, 16 Jul 2020 20:29:24 +0100
> Subject: [PATCHv2] [RFC] libavcodec/hevc_refs: Clear DPB of old frames
>
> During glitching or looping streams, old frames remain in the DPB.
> The decoder incorrectly thinks that the DPB contains the right number
> of buffered frames to output and reordering breaks badly
>

It seems there are also legal streams that have jumps in POC.
So I am really not sure how one distinguishes between a glitch or stream
loop which requires cleaning out the DPB vs a genuine stream.

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

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

Re: [FFmpeg-devel] [PATCH] libavcodec/exr: fix incorrect translation of denorm mantissa

2020-09-14 Thread Mark Reid
On Mon, Sep 14, 2020 at 7:14 PM  wrote:

> From: Mark Reid 
>
> Hi,
> This fixes a very subtle error thats hard notice until up unpremultiply a
> image.
>
> This loop is suppose to stop at first 1, instead was stoping at first 0
> The comment is correct through!
>
> openexrs implementation is very similar.
>
> https://github.com/AcademySoftwareFoundation/openexr/blob/master/IlmBase/Half/toFloat.cpp#L85
>
> not all the exr tests needed to be fixed because only some have denorm
> values
>
> ---
>  libavcodec/exr.c   | 2 +-
>  tests/ref/fate/exr-rgba-multiscanline-half-b44 | 2 +-
>  tests/ref/fate/exr-slice-raw   | 2 +-
>  tests/ref/fate/exr-slice-rle   | 2 +-
>  tests/ref/fate/exr-slice-zip1  | 2 +-
>  tests/ref/fate/exr-slice-zip16 | 2 +-
>  6 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/exr.c b/libavcodec/exr.c
> index 829d38143d..216d216785 100644
> --- a/libavcodec/exr.c
> +++ b/libavcodec/exr.c
> @@ -201,7 +201,7 @@ static union av_intfloat32 exr_half2float(uint16_t hf)
>  mantissa <<= 1;
>  exp = HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
>  // check for leading 1 in denorm mantissa
> -while ((mantissa & (1 << 10))) {
> +while (!(mantissa & (1 << 10))) {
>  // for every leading 0, decrement single precision
> exponent by 1
>  // and shift half-float mantissa value to the left
>  mantissa <<= 1;
> diff --git a/tests/ref/fate/exr-rgba-multiscanline-half-b44
> b/tests/ref/fate/exr-rgba-multiscanline-half-b44
> index 964bf2e65e..24525b92a7 100644
> --- a/tests/ref/fate/exr-rgba-multiscanline-half-b44
> +++ b/tests/ref/fate/exr-rgba-multiscanline-half-b44
> @@ -3,4 +3,4 @@
>  #codec_id 0: rawvideo
>  #dimensions 0: 935x251
>  #sar 0: 1/1
> -0,  0,  0,1,  3754960, 0x4d48a1b2
> +0,  0,  0,1,  3754960, 0x8d9af112
> diff --git a/tests/ref/fate/exr-slice-raw b/tests/ref/fate/exr-slice-raw
> index c7096e4d2a..1e7d3825ea 100644
> --- a/tests/ref/fate/exr-slice-raw
> +++ b/tests/ref/fate/exr-slice-raw
> @@ -3,4 +3,4 @@
>  #codec_id 0: rawvideo
>  #dimensions 0: 587x675
>  #sar 0: 1/1
> -0,  0,  0,1,  6339600, 0x4f2b496b
> +0,  0,  0,1,  6339600, 0xda3e31df
> diff --git a/tests/ref/fate/exr-slice-rle b/tests/ref/fate/exr-slice-rle
> index c7096e4d2a..1e7d3825ea 100644
> --- a/tests/ref/fate/exr-slice-rle
> +++ b/tests/ref/fate/exr-slice-rle
> @@ -3,4 +3,4 @@
>  #codec_id 0: rawvideo
>  #dimensions 0: 587x675
>  #sar 0: 1/1
> -0,  0,  0,1,  6339600, 0x4f2b496b
> +0,  0,  0,1,  6339600, 0xda3e31df
> diff --git a/tests/ref/fate/exr-slice-zip1 b/tests/ref/fate/exr-slice-zip1
> index c7096e4d2a..1e7d3825ea 100644
> --- a/tests/ref/fate/exr-slice-zip1
> +++ b/tests/ref/fate/exr-slice-zip1
> @@ -3,4 +3,4 @@
>  #codec_id 0: rawvideo
>  #dimensions 0: 587x675
>  #sar 0: 1/1
> -0,  0,  0,1,  6339600, 0x4f2b496b
> +0,  0,  0,1,  6339600, 0xda3e31df
> diff --git a/tests/ref/fate/exr-slice-zip16
> b/tests/ref/fate/exr-slice-zip16
> index c7096e4d2a..1e7d3825ea 100644
> --- a/tests/ref/fate/exr-slice-zip16
> +++ b/tests/ref/fate/exr-slice-zip16
> @@ -3,4 +3,4 @@
>  #codec_id 0: rawvideo
>  #dimensions 0: 587x675
>  #sar 0: 1/1
> -0,  0,  0,1,  6339600, 0x4f2b496b
> +0,  0,  0,1,  6339600, 0xda3e31df
> --
> 2.27.0
>
>
to see the problem
ffmpeg_g -y -i premult_test.exr -vf unpremultiply=inplace=1 out.jpg

here is that test file, and a before and after patch pic

https://www.dropbox.com/s/pgdxzxo454r95jn/premult_test.zip
___
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] libavcodec/exr: fix incorrect translation of denorm mantissa

2020-09-14 Thread mindmark
From: Mark Reid 

Hi,
This fixes a very subtle error thats hard notice until up unpremultiply a image.

This loop is suppose to stop at first 1, instead was stoping at first 0
The comment is correct through!

openexrs implementation is very similar.
https://github.com/AcademySoftwareFoundation/openexr/blob/master/IlmBase/Half/toFloat.cpp#L85

not all the exr tests needed to be fixed because only some have denorm values

---
 libavcodec/exr.c   | 2 +-
 tests/ref/fate/exr-rgba-multiscanline-half-b44 | 2 +-
 tests/ref/fate/exr-slice-raw   | 2 +-
 tests/ref/fate/exr-slice-rle   | 2 +-
 tests/ref/fate/exr-slice-zip1  | 2 +-
 tests/ref/fate/exr-slice-zip16 | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 829d38143d..216d216785 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -201,7 +201,7 @@ static union av_intfloat32 exr_half2float(uint16_t hf)
 mantissa <<= 1;
 exp = HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
 // check for leading 1 in denorm mantissa
-while ((mantissa & (1 << 10))) {
+while (!(mantissa & (1 << 10))) {
 // for every leading 0, decrement single precision exponent by 
1
 // and shift half-float mantissa value to the left
 mantissa <<= 1;
diff --git a/tests/ref/fate/exr-rgba-multiscanline-half-b44 
b/tests/ref/fate/exr-rgba-multiscanline-half-b44
index 964bf2e65e..24525b92a7 100644
--- a/tests/ref/fate/exr-rgba-multiscanline-half-b44
+++ b/tests/ref/fate/exr-rgba-multiscanline-half-b44
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 935x251
 #sar 0: 1/1
-0,  0,  0,1,  3754960, 0x4d48a1b2
+0,  0,  0,1,  3754960, 0x8d9af112
diff --git a/tests/ref/fate/exr-slice-raw b/tests/ref/fate/exr-slice-raw
index c7096e4d2a..1e7d3825ea 100644
--- a/tests/ref/fate/exr-slice-raw
+++ b/tests/ref/fate/exr-slice-raw
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 587x675
 #sar 0: 1/1
-0,  0,  0,1,  6339600, 0x4f2b496b
+0,  0,  0,1,  6339600, 0xda3e31df
diff --git a/tests/ref/fate/exr-slice-rle b/tests/ref/fate/exr-slice-rle
index c7096e4d2a..1e7d3825ea 100644
--- a/tests/ref/fate/exr-slice-rle
+++ b/tests/ref/fate/exr-slice-rle
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 587x675
 #sar 0: 1/1
-0,  0,  0,1,  6339600, 0x4f2b496b
+0,  0,  0,1,  6339600, 0xda3e31df
diff --git a/tests/ref/fate/exr-slice-zip1 b/tests/ref/fate/exr-slice-zip1
index c7096e4d2a..1e7d3825ea 100644
--- a/tests/ref/fate/exr-slice-zip1
+++ b/tests/ref/fate/exr-slice-zip1
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 587x675
 #sar 0: 1/1
-0,  0,  0,1,  6339600, 0x4f2b496b
+0,  0,  0,1,  6339600, 0xda3e31df
diff --git a/tests/ref/fate/exr-slice-zip16 b/tests/ref/fate/exr-slice-zip16
index c7096e4d2a..1e7d3825ea 100644
--- a/tests/ref/fate/exr-slice-zip16
+++ b/tests/ref/fate/exr-slice-zip16
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 587x675
 #sar 0: 1/1
-0,  0,  0,1,  6339600, 0x4f2b496b
+0,  0,  0,1,  6339600, 0xda3e31df
-- 
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] libswcale/input: fix incorrect rgbf32 yuv conversions

2020-09-14 Thread Mark Reid
On Mon, Sep 14, 2020 at 2:44 PM Michael Niedermayer 
wrote:

> On Sun, Sep 13, 2020 at 04:04:42PM -0700, Mark Reid wrote:
> > On Sun, Sep 13, 2020 at 8:55 AM Michael Niedermayer
> 
> > wrote:
> >
> > > On Sat, Sep 12, 2020 at 02:07:14AM -0700, mindm...@gmail.com wrote:
> > > > From: Mark Reid 
> > > >
> > > > ---
> > > >  libswscale/input.c  | 12 +---
> > > >  tests/ref/fate/filter-pixfmts-scale |  8 
> > > >  2 files changed, 9 insertions(+), 11 deletions(-)
> > >
> > > Can you provide some tests that show that this is better ?
> > > Iam asking that because some of the numbers in some of the code
> > > (i dont remember which) where tuned to give more accurate overall
> results
> > >
> > > an example for tests would be converting from A->B->A then compare to
> the
> > > orig
> > >
> > > thx
> > >
> > >
> > Hopefully i can explain this clearly!
> >
> > It's easier to see the error if you run a black image through the old
> > conversion.
> > zero values don't get mapped to zero. (attached sample image)
> >
> > ffmpeg -i 4x4_zero.exr -pix_fmt rgb48le -f rawvideo 4x4_zero.rawvideo
> > The image should be rgb 0, 0, 0  everywhere but instead it's 353, 0, 407
> >
> >
> > I think this is a error in fixed point rounding, the issue is basically
> > boils down to
> >
> > 128 << 8 != 257 << 7
> > and
> > 16 << 8  != 33 << 7
> >
> > https://en.wikipedia.org/wiki/YUV#Studio_swing_for_BT.601
> > the 8 bit rgb to yuv formula is
> >
> > Y = ry*r + gy*g + by*b  + 16
> > U = ru*r + gu*g + bu*b + 128
> > V = rv*r + gv*g + bv*b + 128
> >
> > I think the studio swing offsets at the end are calculated wrong in the
> old
> > code.
> > (257 << (RGB2YUV_SHIFT + bpc - 9)))
> > 257 is correct for 8 bit rounding but not for 16-bit.
> >
> > the 257 i believe is from (128 << 1) + 1
> > the +1 is for rounding
> >
> > for rounding 16-bit (128 << 9) + 1 = 0x10001
> >
> > therefore I think the correct rounding any bit depth with the old formula
> > would be (untested)
> > (((128 << (bpc - 7)) + 1) << (RGB2YUV_SHIFT-1) )
> >
> > I just simplified it to
> > (0x10001 << (RGB2YUV_SHIFT - 1))
> >
> > The rgb48ToUV and rgb48ToY funcs in input.c use the formula I'm using.
>
> You quite possibly are correct, can you test that this actually works
> out. The test sample only covers 1 color (black)
> a testsample covering a wide range of the color cube would be more
> convincing that this change is needed and sufficient to fix this.
>
> thx
>

I wrote a small python script to compare the raw gbrpf32le images if that
works? I attached it and also a more colorful test pattern.

it runs these two commands and compares the 2 raw float images
ffmpeg -y -i test_pattern.exr -f rawvideo original.gbrpf32le
ffmpeg -y -i test_pattern.exr -vf
format=pix_fmts=rgb48le,format=pix_fmts=gbrpf32le -f rawvideo
converted.gbrpf32le

python gbrpf32le_diff.py test_pattern.exr

without patch:
avg error: 237.445495855
min error: 0.0
max error: 468.399102688

with patch:
avg error: 15.9312244829
min error: 0.0
max error: 69.467689991


These are floating points scaled to 16-bit values.
Even with my patch, I'm kinda disturbed how much error there is.


>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> There will always be a question for which you do not know the correct
> answer.
> ___
> 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".
from __future__ import print_function
import struct
import sys

import subprocess

FFMPEG = './ffmpeg'

def read_f32(f):
return struct.unpack("

test_pattern.exr
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 2/2] dnn_backend_native_layer_conv2d.c: refine code.

2020-09-14 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> xuju...@sjtu.edu.cn
> Sent: 2020年9月14日 19:32
> To: ffmpeg-devel@ffmpeg.org
> Cc: xuju...@sjtu.edu.cn
> Subject: [FFmpeg-devel] [PATCH 2/2] dnn_backend_native_layer_conv2d.c:
> refine code.
> 
> From: Xu Jun 
> 
> Move thread area allocate out of thread function into main thread.
> 
> Signed-off-by: Xu Jun 
> ---
>  .../dnn/dnn_backend_native_layer_conv2d.c | 29 +--
>  1 file changed, 13 insertions(+), 16 deletions(-)
> 
> diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> index 5ed1851512..57659a1283 100644
> --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> @@ -33,12 +33,11 @@ typedef struct thread_common_param{
>  const void *parameters;
>  NativeContext *ctx;
>  float *output_data;
> -int thread_num;
>  } thread_common_param;
> 
>  typedef struct thread_param{
>  thread_common_param *thread_common_param;
> -int thread_index;
> +int thread_start, thread_end;
>  } thread_param;
> 
>  int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int
> file_size, int operands_num) @@ -126,16 +125,12 @@ static void *
> dnn_execute_layer_conv2d_thread(void *threadarg)
>  int filter_size = conv_params->kernel_size * filter_linesize;
>  int pad_size = (conv_params->padding_method == VALID) ?
> (conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
> 
> -int thread_stride = (height - pad_size * 2) /
> thread_common_param->thread_num;
> -int thread_start = thread_stride * thread_param->thread_index +
> pad_size;
> -int thread_end = (thread_param->thread_index ==
> thread_common_param->thread_num - 1) ? (height - pad_size) : (thread_start
> + thread_stride);
> -
>  float *output = thread_common_param->output_data;
> -output += (conv_params->output_num) * (width - 2 * pad_size) *
> (thread_start - pad_size);
> +output += (conv_params->output_num) * (width - 2 * pad_size) *
> + (thread_param->thread_start - pad_size);
> 
>  av_assert0(channel == conv_params->input_num);
> 
> -for (int y = thread_start; y < thread_end; ++y) {
> +for (int y = thread_param->thread_start; y <
> + thread_param->thread_end; ++y) {
>  for (int x = pad_size; x < width - pad_size; ++x) {
>  for (int n_filter = 0; n_filter < conv_params->output_num;
> ++n_filter) {
>  if (conv_params->has_bias) @@ -207,11 +202,13 @@ int
> dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t
> *input_operand_
> 
>  //alloc memory
>  const ConvolutionalParams *conv_params = (const ConvolutionalParams
> *)(parameters);
> +int height = operands[input_operand_indexes[0]].dims[1];
> +int width = operands[input_operand_indexes[0]].dims[2];
>  int pad_size = (conv_params->padding_method == VALID) ?
> (conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
>  DnnOperand *output_operand = [output_operand_index];
>  output_operand->dims[0] = operands[input_operand_indexes[0]].dims[0];
> -output_operand->dims[1] = operands[input_operand_indexes[0]].dims[1] -
> pad_size * 2;
> -output_operand->dims[2] = operands[input_operand_indexes[0]].dims[2] -
> pad_size * 2;
> +output_operand->dims[1] = height - pad_size * 2;
> +output_operand->dims[2] = width - pad_size * 2;
>  output_operand->dims[3] = conv_params->output_num;
>  output_operand->data_type =
> operands[input_operand_indexes[0]].data_type;
>  output_operand->length =
> calculate_operand_data_length(output_operand);
> @@ -227,13 +224,13 @@ int dnn_execute_layer_conv2d(DnnOperand
> *operands, const int32_t *input_operand_
>  thread_common_param.output_data = output_operand->data;
> 
>  #if HAVE_PTHREAD_CANCEL
> -thread_common_param.thread_num = thread_num;
> -
> +int thread_stride = (height - pad_size * 2) / thread_num;
please fix the build warning, move 'int thread_stride' up.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] avformat/argo_asf: initialise file header inline

2020-09-14 Thread Zane van Iperen
Garbage was left-over in the ArgoASFFileHeader::name field if the url
was too short. This zero-initialises it.

Signed-off-by: Zane van Iperen 
---
 libavformat/argo_asf.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index c131207aa1..b1632f3ba5 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -314,14 +314,15 @@ static int argo_asf_write_header(AVFormatContext *s)
 {
 const AVCodecParameters  *par = s->streams[0]->codecpar;
 ArgoASFMuxContext*ctx = s->priv_data;
-ArgoASFFileHeader  fhdr;
 ArgoASFChunkHeader chdr;
+ArgoASFFileHeader  fhdr = {
+.magic = ASF_TAG,
+.version_major = (uint16_t)ctx->version_major,
+.version_minor = (uint16_t)ctx->version_minor,
+.num_chunks= 1,
+.chunk_offset  = ASF_FILE_HEADER_SIZE
+};
 
-fhdr.magic = ASF_TAG;
-fhdr.version_major = (uint16_t)ctx->version_major;
-fhdr.version_minor = (uint16_t)ctx->version_minor;
-fhdr.num_chunks= 1;
-fhdr.chunk_offset  = ASF_FILE_HEADER_SIZE;
 /*
  * If the user specified a name, use it as is. Otherwise take the
  * basename and lop off the extension (if any).
-- 
2.25.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".

Re: [FFmpeg-devel] [PATCH 2/2] libswcale/input: fix incorrect rgbf32 yuv conversions

2020-09-14 Thread Michael Niedermayer
On Sun, Sep 13, 2020 at 04:04:42PM -0700, Mark Reid wrote:
> On Sun, Sep 13, 2020 at 8:55 AM Michael Niedermayer 
> wrote:
> 
> > On Sat, Sep 12, 2020 at 02:07:14AM -0700, mindm...@gmail.com wrote:
> > > From: Mark Reid 
> > >
> > > ---
> > >  libswscale/input.c  | 12 +---
> > >  tests/ref/fate/filter-pixfmts-scale |  8 
> > >  2 files changed, 9 insertions(+), 11 deletions(-)
> >
> > Can you provide some tests that show that this is better ?
> > Iam asking that because some of the numbers in some of the code
> > (i dont remember which) where tuned to give more accurate overall results
> >
> > an example for tests would be converting from A->B->A then compare to the
> > orig
> >
> > thx
> >
> >
> Hopefully i can explain this clearly!
> 
> It's easier to see the error if you run a black image through the old
> conversion.
> zero values don't get mapped to zero. (attached sample image)
> 
> ffmpeg -i 4x4_zero.exr -pix_fmt rgb48le -f rawvideo 4x4_zero.rawvideo
> The image should be rgb 0, 0, 0  everywhere but instead it's 353, 0, 407
> 
> 
> I think this is a error in fixed point rounding, the issue is basically
> boils down to
> 
> 128 << 8 != 257 << 7
> and
> 16 << 8  != 33 << 7
> 
> https://en.wikipedia.org/wiki/YUV#Studio_swing_for_BT.601
> the 8 bit rgb to yuv formula is
> 
> Y = ry*r + gy*g + by*b  + 16
> U = ru*r + gu*g + bu*b + 128
> V = rv*r + gv*g + bv*b + 128
> 
> I think the studio swing offsets at the end are calculated wrong in the old
> code.
> (257 << (RGB2YUV_SHIFT + bpc - 9)))
> 257 is correct for 8 bit rounding but not for 16-bit.
> 
> the 257 i believe is from (128 << 1) + 1
> the +1 is for rounding
> 
> for rounding 16-bit (128 << 9) + 1 = 0x10001
> 
> therefore I think the correct rounding any bit depth with the old formula
> would be (untested)
> (((128 << (bpc - 7)) + 1) << (RGB2YUV_SHIFT-1) )
> 
> I just simplified it to
> (0x10001 << (RGB2YUV_SHIFT - 1))
> 
> The rgb48ToUV and rgb48ToY funcs in input.c use the formula I'm using.

You quite possibly are correct, can you test that this actually works
out. The test sample only covers 1 color (black)
a testsample covering a wide range of the color cube would be more
convincing that this change is needed and sufficient to fix this.

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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


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

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

Re: [FFmpeg-devel] [PATCH 2/4 v2] ffmpeg: move AVFrame time base adjustment into a function

2020-09-14 Thread Jan Ekström
On Mon, Sep 14, 2020 at 12:31 AM Jan Ekström  wrote:
>

Diff between v1 and v2 follows:

- Forgotten to be removed debug logs removed.
- Still log debug_ts even in case of nullptr AVFrame or AV_NOPTS_VALUE.

Decided against separating the logging because this way it's a
self-contained package and the goto lets us do an early exit.

Jan

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 5425ba245d..8874da9268 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -900,11 +900,11 @@ static int check_recording_time(OutputStream *ost)
 static double adjust_frame_pts_to_encoder_tb(OutputFile *of, OutputStream *ost,
  AVFrame *frame)
 {
+double float_pts = AV_NOPTS_VALUE; // this is identical to
frame.pts but with higher precision
 if (!frame || frame->pts == AV_NOPTS_VALUE ||
 !ost->filter || !ost->filter->graph->graph)
-return AV_NOPTS_VALUE;
+goto early_exit;

-double float_pts = AV_NOPTS_VALUE; // this is identical to
frame.pts but with higher precision
 AVFilterContext *filter = ost->filter->filter;
 AVCodecContext *enc = ost->enc_ctx;

@@ -914,13 +914,6 @@ static double
adjust_frame_pts_to_encoder_tb(OutputFile *of, OutputStream *ost,
 int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16);

 tb.den <<= extra_bits;
-av_log(NULL, AV_LOG_VERBOSE,
-   "%s: frame pts: %"PRId64" start_time: %"PRId64", "
-   "filter_tb: %d/%d, tb: %d/%d\n",
-   __FUNCTION__, frame->pts, start_time,
-   filter_tb.num, filter_tb.den,
-   tb.num, tb.den);
-
 float_pts =
 av_rescale_q(frame->pts, filter_tb, tb) -
 av_rescale_q(start_time, AV_TIME_BASE_Q, tb);
@@ -932,15 +925,14 @@ static double
adjust_frame_pts_to_encoder_tb(OutputFile *of, OutputStream *ost,
 av_rescale_q(frame->pts, filter_tb, enc->time_base) -
 av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base);

-av_log(NULL, AV_LOG_VERBOSE,
-   "%s: post-adjustment PTS: %"PRId64"\n",
-   __FUNCTION__, frame->pts);
+early_exit:

 if (debug_ts) {
 av_log(NULL, AV_LOG_INFO, "filter -> pts:%s pts_time:%s
exact:%f time_base:%d/%d\n",
-av_ts2str(frame->pts), av_ts2timestr(frame->pts,
>time_base),
-float_pts,
-enc->time_base.num, enc->time_base.den);
+   frame ? av_ts2str(frame->pts) : "NULL",
+   frame ? av_ts2timestr(frame->pts, >time_base) : "NULL",
+   float_pts,
+   enc->time_base.num, enc->time_base.den);
 }

 return float_pts;
___
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] [aarch64] yuv2planeX - unroll outer loop by 4 to increase performance by 6.3%

2020-09-14 Thread Martin Storsjö

Hi,

On Tue, 18 Aug 2020, Sebastian Pop wrote:


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


This function (like most in swscale) lacks a checkasm test; it'd be great 
to have one, to allow for proper microbenchmarks of different tunings on 
it. The existing tests in tests/checkasm/sw*.c serve as decent examples 
for how to write a test for it. This isn't a blocker, but checkasm is a 
great tool for testing asm, and I personally try to add tests for anything 
I'm writing asm for if there isn't already one.


When targeting linux, by default checkasm ends up using the perf cycle 
counter API. This is a bit inexact for finetuning of asm, so personally I 
also prefer configuring with --disable-linux-perf and loading a kernel 
module to allow usermode access to the raw cycle counter register - e.g. 
the module from https://code.videolan.org/janne/arm64-cycle-cnt should 
work fine.




diff --git a/libswscale/aarch64/output.S b/libswscale/aarch64/output.S
index af71de6050..2cba810e16 100644
--- a/libswscale/aarch64/output.S
+++ b/libswscale/aarch64/output.S
@@ -26,10 +26,13 @@ function ff_yuv2planeX_8_neon, export=1
 ext v0.8B, v0.8B, v0.8B, #3 // honor 
offsetting which can be 0 or 3 only
 1:  uxtlv0.8H, v0.8B// extend dither 
to 16-bit
 ushll   v1.4S, v0.4H, #12   // extend dither 
to 32-bit with left shift by 12 (part 1)
-ushll2  v2.4S, v0.8H, #12   // extend dither 
to 32-bit with left shift by 12 (part 2)
+ushll2  v0.4S, v0.8H, #12   // extend dither 
to 32-bit with left shift by 12 (part 2)
+tst w4, #0x1f   // check dstW % 32
 mov x7, #0  // i = 0
+b.eq4f  // jump to outer 
loop unrolled by 4
+
 2:  mov v3.16B, v1.16B  // initialize 
accumulator part 1 with dithering value
-mov v4.16B, v2.16B  // initialize 
accumulator part 2 with dithering value
+mov v4.16B, v0.16B  // initialize 
accumulator part 2 with dithering value
 mov w8, w1  // tmpfilterSize = 
filterSize
 mov x9, x2  // srcp= src
 mov x10, x0 // filterp = filter
@@ -55,4 +58,73 @@ function ff_yuv2planeX_8_neon, export=1
 add x7, x7, #8  // i += 8
 b.gt2b  // loop until 
width consumed
 ret
+
+// Outer loop unrolled by 4 to maximize reuse of filter values.
+4:  mov v2.16b, v0.16b  // initialize 
accumulator with dithering value
+mov v3.16b, v0.16b  // initialize 
accumulator with dithering value
+mov v4.16b, v0.16b  // initialize 
accumulator with dithering value
+mov v5.16b, v0.16b  // initialize 
accumulator with dithering value
+mov v6.16b, v1.16b  // initialize 
accumulator with dithering value
+mov v7.16b, v1.16b  // initialize 
accumulator with dithering value
+mov v16.16b, v1.16b // initialize 
accumulator with dithering value
+mov v17.16b, v1.16b // initialize 
accumulator with dithering value


For asm like this, I personally prefer to align the columns vertically. In 
this file, the existing code isn't already aligned, so there's not much 
example for follow, but I normally align columns that contain vector 
references like v16.16b according the max width of those, and GPR 
references (and references to the vector registers without the layout 
appended, like q19) against the max size for those (that is, 3 chars). 
Columns with other constructs (memory operands etc) is more ad-hoc 
aligned.


It makes the asm a bit more readable IMO.


+mov w8, w1  // tmpfilterSize 

Re: [FFmpeg-devel] [PATCH 3/4 v2] ffmpeg: move A/V non-streamcopy initialization to a later point

2020-09-14 Thread Jan Ekström
On Mon, Sep 14, 2020 at 12:33 AM Jan Ekström  wrote:
>
> - For video, this means a single initialization point in do_video_out.
> - For audio we unfortunately need to do it in two places just
>   before the buffer sink is utilized (if av_buffersink_get_samples
>   would still work according to its specification after a call to
>   avfilter_graph_request_oldest was made, we could at least remove
>   the one in transcode_step).
>
> Other adjustments to make things work:
> - As the AVFrame PTS adjustment to encoder time base needs the encoder
>   to be initialized, so it is now moved to do_{video,audio}_out,
>   right after the encoder has been initialized. Due to this,
>   the additional parameter in do_video_out is removed as it is no
>   longer necessary.
> ---

Diff between v1 and v2 follows:

- Basically fixed issues in the comments I had written down.

Jan

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 5425ba245d..8874da9268 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -4664,14 +4656,15 @@ static int transcode_step(void)
  * transcode_from_filter just down the line) peeks. Peeking already
  * puts one frame "ready to be given out", which means that any
  * update in filter buffer sink configuration afterwards will not
- * help us.
+ * help us. And yes, even if it would be utilized,
+ * av_buffersink_get_samples is affected, as it internally utilizes
+ * the same early exit for peeked frames.
  *
- * And yes, even av_buffersink_get_samples is affected,
- * As it internally utilizes the same early exit for peeked frames.
- * In other words, if either av_buffersink_get_samples with
- * avfilter_graph_request_oldest will start playing ball, or we add
- * our own audio buffering to handle frame size mismatches, both of
- * these early exits can be gotten rid of.
+ * In other words, if avfilter_graph_request_oldest would not make
+ * further filter chain configuration or usage of
+ * av_buffersink_get_samples useless (by just causing the return
+ * of the peeked AVFrame as-is), we could get rid of this additional
+ * early encoder initialization.
  */
 if (av_buffersink_get_type(ost->filter->filter) == AVMEDIA_TYPE_AUDIO)
 init_output_stream_wrapper(ost, NULL, 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] avformat/mxfdec: fix pixel format extraction for cinema j2k

2020-09-14 Thread Rémi Achard
>
> FATE works fine for me, at least with a default configuration. Can you
> provide what options you're using?


So the original patch I submitted errored in the test suite, you can see
the error here
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200913184510.85070-1-remiach...@gmail.com/

I managed to reproduce the error, just didn't rsync the fate-suite the
first time, what options do you want me to provide ?

You mean there's both a subdescriptor using local tag 0x3F01 and one
> using mxf_subdescriptor_array_smpte or mxf_subdescriptor_array_interop?
> In the same CDCIDescriptor?


 Just tried to dig a bit deeper and it appears to be a Multi Descriptor Set
that contains at least 6 (1 more for each additional audio tracks) Sub
Descriptors, including the mentioned CICD, and a Container Constraints Sub
Descriptor Set. For this Multi Descriptor, mxf_read_strong_ref_array is
called multiple times and the original patches mess things up. I'm sourcing
this info from both the XAVC spec and the mxfdec debug output that I ran on
the fate-suite MXF XAVC as well as some XAVC I've got lying around.

Do you think this array reallocation must move
outside mxf_read_strong_ref_array back to mxf_read_generic_descriptor or
this involve more structural changes ?

Le lun. 14 sept. 2020 à 11:37, Tomas Härdin  a écrit :

> mån 2020-09-14 klockan 10:48 +0100 skrev Rémi Achard:
> > > Why this added hunk? Appending strong refs like this is likely to have
> > > all sorts of unintended effects. The same MaterialPackages will appear
> > > multiple times for example.
> >
> > This is my attempt to fix an issue in the fate tests.
>
> FATE works fine for me, at least with a default configuration. Can you
> provide what options you're using?
>
> > If you look at mxf_read_generic_descriptor, there is two places where we
> > call mxf_read_strong_ref_array, if this happens on the same descriptor
> the
> > second call will override the first one. This happen in the test suite
> for
> > an XAVC file CDCI descriptor, see the previous post I made for the
> breaking
> > test example.
>
> You mean there's both a subdescriptor using local tag 0x3F01 and one
> using mxf_subdescriptor_array_smpte or mxf_subdescriptor_array_interop?
> In the same CDCIDescriptor?
>
> /Tomas
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] fate: add scale filters for big-endian architectures.

2020-09-14 Thread Nicolas George
Filters mostly work in native endianness, but they must output
a specified endianness, usually little: that requires a final
conversion for big endian.

I do not know what's the deal with gif-deal: inserting explicitly
the filters that are implicitly inserted result in less frames in
output. Probably a strange problem of duration.

Signed-off-by: Nicolas George 
---
 tests/fate/bmp.mak  |  6 +++---
 tests/fate/dnxhd.mak|  4 ++--
 tests/fate/filter-video.mak | 18 +-
 tests/fate/fits.mak |  8 
 tests/fate/gif.mak  | 10 +-
 tests/fate/h264.mak | 34 +-
 tests/fate/hevc.mak | 12 ++--
 tests/fate/image.mak|  2 +-
 tests/fate/microsoft.mak|  4 ++--
 tests/fate/pixlet.mak   |  2 +-
 tests/fate/prores.mak   | 16 
 tests/fate/video.mak| 16 
 tests/fate/vpx.mak  |  4 ++--
 13 files changed, 68 insertions(+), 68 deletions(-)

diff --git a/tests/fate/bmp.mak b/tests/fate/bmp.mak
index f7a7ed12ad..de27f19b15 100644
--- a/tests/fate/bmp.mak
+++ b/tests/fate/bmp.mak
@@ -14,13 +14,13 @@ FATE_BMP += fate-bmp-8bit-os2
 fate-bmp-8bit-os2: CMD = framecrc -i $(TARGET_SAMPLES)/bmp/test8os2.bmp 
-pix_fmt rgb24 -vf scale
 
 FATE_BMP += fate-bmp-15bit
-fate-bmp-15bit: CMD = framecrc -i $(TARGET_SAMPLES)/bmp/test16.bmp -pix_fmt 
rgb555le
+fate-bmp-15bit: CMD = framecrc -i $(TARGET_SAMPLES)/bmp/test16.bmp -pix_fmt 
rgb555le -vf scale
 
 FATE_BMP += fate-bmp-15bit-mask
-fate-bmp-15bit-mask: CMD = framecrc -i $(TARGET_SAMPLES)/bmp/test16bf555.bmp 
-pix_fmt rgb555le
+fate-bmp-15bit-mask: CMD = framecrc -i $(TARGET_SAMPLES)/bmp/test16bf555.bmp 
-pix_fmt rgb555le -vf scale
 
 FATE_BMP += fate-bmp-16bit-mask
-fate-bmp-16bit-mask: CMD = framecrc -i $(TARGET_SAMPLES)/bmp/test16bf565.bmp 
-pix_fmt rgb565le
+fate-bmp-16bit-mask: CMD = framecrc -i $(TARGET_SAMPLES)/bmp/test16bf565.bmp 
-pix_fmt rgb565le -vf scale
 
 FATE_BMP += fate-bmp-24bit
 fate-bmp-24bit: CMD = framecrc -i $(TARGET_SAMPLES)/bmp/test24.bmp
diff --git a/tests/fate/dnxhd.mak b/tests/fate/dnxhd.mak
index 2ed1d17efb..59f3f90e91 100644
--- a/tests/fate/dnxhd.mak
+++ b/tests/fate/dnxhd.mak
@@ -12,8 +12,8 @@ FATE_SAMPLES_AVCONV-$(call DEMDEC, MOV, DNXHD) += 
$(FATE_DNXHD)
 fate-dnxhd: $(FATE_DNXHD) $(FATE_VCODEC_DNXHD)
 
 fate-dnxhd-mbaff: CMD = framecrc -flags +bitexact -idct simple -i 
$(TARGET_SAMPLES)/dnxhd/dnxhd100_cid1260.mov -pix_fmt yuv422p10le -vf scale
-fate-dnxhr-444:   CMD = framecrc -flags +bitexact -idct simple -i 
$(TARGET_SAMPLES)/dnxhd/dnxhr444_cid1270.mov -pix_fmt yuv444p10le
-fate-dnxhr-12bit: CMD = framecrc -flags +bitexact -idct simple -i 
$(TARGET_SAMPLES)/dnxhd/dnxhr_cid1271_12bit.mov -pix_fmt yuv422p12le
+fate-dnxhr-444:   CMD = framecrc -flags +bitexact -idct simple -i 
$(TARGET_SAMPLES)/dnxhd/dnxhr444_cid1270.mov -pix_fmt yuv444p10le -vf scale
+fate-dnxhr-12bit: CMD = framecrc -flags +bitexact -idct simple -i 
$(TARGET_SAMPLES)/dnxhd/dnxhr_cid1271_12bit.mov -pix_fmt yuv422p12le -vf scale
 fate-dnxhr-parse: CMD = framecrc -flags +bitexact -idct simple -i 
$(TARGET_SAMPLES)/dnxhd/dnxhr_cid1274.dnxhr -pix_fmt yuv422p
 fate-dnxhr-prefix1: CMD = framecrc -flags +bitexact -idct simple -i 
$(TARGET_SAMPLES)/dnxhd/prefix-256x1536.dnxhr -pix_fmt yuv422p
 fate-dnxhr-prefix2: CMD = framecrc -flags +bitexact -idct simple -i 
$(TARGET_SAMPLES)/dnxhd/prefix-256x1716.dnxhr -pix_fmt yuv422p
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index a09fcd310b..639f957748 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -42,13 +42,13 @@ FATE_FILTER_SAMPLES-$(call ALLYES, CODECVIEW_FILTER 
RM_DEMUXER RV40_DECODER) +=
 fate-filter-codecview-mvs: CMD = framecrc -flags2 +export_mvs -i 
$(TARGET_SAMPLES)/real/spygames-2MB.rmvb -vf codecview=mv=pf+bf+bb -frames:v 60 
-an
 
 FATE_FILTER_SAMPLES-$(call ALLYES, SHOWPALETTE_FILTER FLIC_DEMUXER 
FLIC_DECODER) += fate-filter-showpalette
-fate-filter-showpalette: CMD = framecrc -i 
$(TARGET_SAMPLES)/fli/fli-engines.fli -vf showpalette=3 -pix_fmt bgra
+fate-filter-showpalette: CMD = framecrc -i 
$(TARGET_SAMPLES)/fli/fli-engines.fli -vf showpalette=3,scale -pix_fmt bgra
 
 FATE_FILTER_PALETTEGEN += fate-filter-palettegen-1
-fate-filter-palettegen-1: CMD = framecrc -i $(TARGET_SAMPLES)/filter/anim.mkv 
-vf scale,palettegen -pix_fmt bgra
+fate-filter-palettegen-1: CMD = framecrc -i $(TARGET_SAMPLES)/filter/anim.mkv 
-vf scale,palettegen,scale -pix_fmt bgra
 
 FATE_FILTER_PALETTEGEN += fate-filter-palettegen-2
-fate-filter-palettegen-2: CMD = framecrc -i $(TARGET_SAMPLES)/filter/anim.mkv 
-vf scale,palettegen=max_colors=128:reserve_transparent=0:stats_mode=diff 
-pix_fmt bgra
+fate-filter-palettegen-2: CMD = framecrc -i $(TARGET_SAMPLES)/filter/anim.mkv 
-vf scale,palettegen=max_colors=128:reserve_transparent=0:stats_mode=diff,scale 
-pix_fmt bgra
 
 fate-filter-palettegen: $(FATE_FILTER_PALETTEGEN)
 

[FFmpeg-devel] [PATCH] avdevice/decklink_dec: fix build with older SDK

2020-09-14 Thread Marton Balint
Apparently bmdFormatUnspecified needs SDK 11.0. It is just a fancy way of
checking for zero, so let's do that instead.

Fixes build issue since f1b908d20a8.

Signed-off-by: Marton Balint 
---
 libavdevice/decklink_dec.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 92b8feed14..6517b9df13 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -1232,7 +1232,7 @@ av_cold int ff_decklink_read_header(AVFormatContext 
*avctx)
 }
 av_log(avctx, AV_LOG_INFO, "Autodetected the input mode\n");
 }
-if (ctx->raw_format == bmdFormatUnspecified)
+if (ctx->raw_format == (BMDPixelFormat)0)
 ctx->raw_format = bmdFormat8BitYUV;
 if (ff_decklink_set_format(avctx, DIRECTION_IN) < 0) {
 av_log(avctx, AV_LOG_ERROR, "Could not set format code %s for %s\n",
-- 
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 3/4] avdevice/decklink_dec: add support for rgb/yuv pixel format autodetection

2020-09-14 Thread Marton Balint



On Mon, 14 Sep 2020, Gyan Doshi wrote:



Building with Decklink is broken, apparently due to f1b908d20a8

Error is



src/libavdevice/decklink_dec.cpp: In function 'int 
ff_decklink_read_header(AVFormatContext*)':


src/libavdevice/decklink_dec.cpp:1235:28: error: 'bmdFormatUnspecified' 
was not declared in this scope


1235 | if (ctx->raw_format == bmdFormatUnspecified)

| ^~~~

make: *** [/build/ffmpeg-git/ffbuild/common.mak:70: 
libavdevice/decklink_dec.o] Error 1


Shoot, I missed that the unspecified format also needs a newer SDK. Will 
send a patch shortly which should fix this.


Thanks,
Marton





Regards,
Gyan

On 08-09-2020 11:22 pm, Marton Balint wrote:

Signed-off-by: Marton Balint 
---
  doc/indevs.texi  | 15 +++
  libavdevice/decklink_dec.cpp |  8 +++-
  libavdevice/decklink_dec_c.c |  3 ++-
  3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 4d2312e201..7748232b26 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -296,16 +296,31 @@ supports it.
  Set the pixel format of the captured video.
  Available values are:
  @table @samp
+@item auto
+
+This is the default which means 8-bit YUV 422 or 8-bit ARGB if format
+autodetection is used, 8-bit YUV 422 otherwise.
+
  @item uyvy422

+8-bit YUV 422.
+
  @item yuv422p10

+10-bit YUV 422.
+
  @item argb

+8-bit RGB.
+
  @item bgra

+8-bit RGB.
+
  @item rgb10

+10-bit RGB.
+
  @end table

  @item teletext_lines
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index af0ef04c56..92b8feed14 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -1044,9 +1044,13 @@ HRESULT 

decklink_input_callback::VideoInputFrameArrived(


  HRESULT decklink_input_callback::VideoInputFormatChanged(
  BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *mode,
-BMDDetectedVideoInputFormatFlags)
+BMDDetectedVideoInputFormatFlags formatFlags)
  {
+struct decklink_cctx *cctx = (struct decklink_cctx *) 

avctx->priv_data;

  ctx->bmd_mode = mode->GetDisplayMode();
+// check the C context member to make sure we set both raw_format and 

bmd_mode with data from the same format change callback

+if (!cctx->raw_format)
+ctx->raw_format = (formatFlags & bmdDetectedVideoInputRGB444) ? 

bmdFormat8BitARGB : bmdFormat8BitYUV;

  return S_OK;
  }

@@ -1228,6 +1232,8 @@ av_cold int ff_decklink_read_header(AVFormatContext 

*avctx)

  }
  av_log(avctx, AV_LOG_INFO, "Autodetected the input mode\n");
  }
+if (ctx->raw_format == bmdFormatUnspecified)
+ctx->raw_format = bmdFormat8BitYUV;
  if (ff_decklink_set_format(avctx, DIRECTION_IN) < 0) {
  av_log(avctx, AV_LOG_ERROR, "Could not set format code %s for 

%s\n",
  cctx->format_code ? cctx->format_code : "(unset)", 

avctx->url);

diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
index 9f4b32088c..54cd681710 100644
--- a/libavdevice/decklink_dec_c.c
+++ b/libavdevice/decklink_dec_c.c
@@ -33,7 +33,8 @@ static const AVOption options[] = {
  { "list_devices", "list available devices"  , OFFSET(list_devices), 

AV_OPT_TYPE_INT   , { .i64 = 0   }, 0, 1, DEC },
  { "list_formats", "list supported formats"  , OFFSET(list_formats), 

AV_OPT_TYPE_INT   , { .i64 = 0   }, 0, 1, DEC },
  { "format_code",  "set format by fourcc", OFFSET(format_code), 

AV_OPT_TYPE_STRING, { .str = NULL}, 0, 0, DEC },
-{ "raw_format",   "pixel format to be returned by the card when 
capturing" , OFFSET(raw_format),  AV_OPT_TYPE_INT, { .i64 = 
MKBETAG('2','v','u','y')}, 0, UINT_MAX, DEC, "raw_format" },
+{ "raw_format",   "pixel format to be returned by the card when 
capturing" , OFFSET(raw_format),  AV_OPT_TYPE_INT, { .i64 = 0}, 0, UINT_MAX, 
DEC, "raw_format" },
+{ "auto",  NULL,   0,  AV_OPT_TYPE_CONST, { .i64 = 0 

}, 0, 0, DEC, "raw_format"},
  { "uyvy422",   NULL,   0,  AV_OPT_TYPE_CONST, { .i64 = 

MKBETAG('2','v','u','y') }, 0, 0, DEC, "raw_format"},
  { "yuv422p10", NULL,   0,  AV_OPT_TYPE_CONST, { .i64 = 

MKBETAG('v','2','1','0') }, 0, 0, DEC, "raw_format"},
  { "argb",  NULL,   0,  AV_OPT_TYPE_CONST, { .i64 = 32 

}, 0, 0, DEC, "raw_format"},

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

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

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

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

[FFmpeg-devel] [PATCH] libavformat/rmdec.c: Fix Use-of-uninitialized-value in ff_codec_get_id

2020-09-14 Thread Thierry Foucu
In case the pb does not contain 4 bytes, the buf[256] will not be
initialize before we pass it to ff_codec_get_id
---
 libavformat/rmdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index a36e693ab2..220aa8aee2 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -180,12 +180,12 @@ static int rm_read_audio_stream_info(AVFormatContext *s, 
AVIOContext *pb,
 st->codecpar->sample_rate = avio_rb16(pb);
 avio_rb32(pb);
 st->codecpar->channels = avio_rb16(pb);
+AV_WL32(buf, 0);
 if (version == 5) {
 ast->deint_id = avio_rl32(pb);
 avio_read(pb, buf, 4);
 buf[4] = 0;
 } else {
-AV_WL32(buf, 0);
 get_str8(pb, buf, sizeof(buf)); /* desc */
 ast->deint_id = AV_RL32(buf);
 get_str8(pb, buf, sizeof(buf)); /* desc */
-- 
2.28.0.618.gf4bc123cb7-goog

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

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

Re: [FFmpeg-devel] [PATCH 18/40] avcodec/alacenc: Don't free unnecessarily

2020-09-14 Thread Andreas Rheinhardt
Paul B Mahol:
> On Mon, Sep 14, 2020 at 07:27:25AM +0200, Andreas Rheinhardt wrote:
>> The init function of the ALAC encoder calls its own close function
>> if a call to ff_lpc_init() fails; yet nothing has been allocated before
>> that point (except extradata which is freed generically) and ff_lpc_init()
>> can be expected to clean up after itself on error (the documentation does
>> not say anything to the contrary and the current implementation can only
>> fail if the only allocation fails, so there is nothing to clean up on
>> error anyway), so this is unnecessary.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavcodec/alacenc.c | 20 ++--
>>  1 file changed, 6 insertions(+), 14 deletions(-)
>>
> 
> what about adding cleanup flag so if new stuff is added(unlikely) new bugs
> wont pop up?
> 

That is possible, but as you said yourself: It is unlikely that new
stuff will be added. Furthermore, I think that whoever adds new stuff
would be responsible to make sure that it is free of leaks.

- 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] [PATCHv2] [RFC] libavcodec/hevc_refs: Clear DPB of old frames

2020-09-14 Thread Kieran Kunhya
From 21bf6e5eac61d34f270534dd5a2a7229967c1ee9 Mon Sep 17 00:00:00 2001
From: Kieran Kunhya 
Date: Thu, 16 Jul 2020 20:29:24 +0100
Subject: [PATCHv2] [RFC] libavcodec/hevc_refs: Clear DPB of old frames

During glitching or looping streams, old frames remain in the DPB.
The decoder incorrectly thinks that the DPB contains the right number
of buffered frames to output and reordering breaks badly
---
 libavcodec/hevc_refs.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 4f6d985..6af0f6e 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -277,6 +277,10 @@ static int init_slice_rpl(HEVCContext *s)
 int ctb_addr_ts  = s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_segment_addr];
 int i;

+if(frame && !frame->rpl_buf) {
+return AVERROR_INVALIDDATA;
+}
+
 if (s->slice_idx >= frame->rpl_buf->size / sizeof(RefPicListTab))
 return AVERROR_INVALIDDATA;

@@ -462,6 +466,21 @@ int ff_hevc_frame_rps(HEVCContext *s)
 mark_ref(frame, 0);
 }

+/* Clear the DPB of any junk frames */
+for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
+HEVCFrame *frame = >DPB[i];
+if ((frame->flags & HEVC_FRAME_FLAG_OUTPUT) &&
+frame->sequence == s->seq_output) {
+int dpb_size = FF_ARRAY_ELEMS(s->DPB);
+if (frame->frame->buf[0] && ((frame->poc > s->poc +
dpb_size) || (frame->poc < s->poc - dpb_size))) {
+if(frame->poc == s->poc)
+continue;
+
+ff_hevc_unref_frame(s, frame, ~0);
+}
+}
+}
+
 for (i = 0; i < NB_RPS_TYPE; i++)
 rps[i].nb_refs = 0;

--
1.9.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 32/40] avcodec/dsicinvideo: Remove redundant code for freeing

2020-09-14 Thread Paul B Mahol
On Mon, Sep 14, 2020 at 07:27:39AM +0200, Andreas Rheinhardt wrote:
> The dsicinvideo decoder already has the FF_CODEC_CAP_INIT_CLEANUP flag
> set, so it is unnecessary to directly clean up some already allocated
> buffers in case another one could not be allocated in the init function,
> as all buffers will be freed anyway later in the decoder's close
> function.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/dsicinvideo.c | 1 -
>  1 file changed, 1 deletion(-)
> 

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

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

Re: [FFmpeg-devel] [PATCH 19/40] avcodec/atrac1: Check allocation of AVFloatDSPContext

2020-09-14 Thread Paul B Mahol
On Mon, Sep 14, 2020 at 07:27:26AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/atrac1.c | 4 
>  1 file changed, 4 insertions(+)
> 

lgtm
___
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 20/40] avcodec/atrac1: Cleanup generically after init failure

2020-09-14 Thread Paul B Mahol
On Mon, Sep 14, 2020 at 07:27:27AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/atrac1.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 

lgtm
___
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 18/40] avcodec/alacenc: Don't free unnecessarily

2020-09-14 Thread Paul B Mahol
On Mon, Sep 14, 2020 at 07:27:25AM +0200, Andreas Rheinhardt wrote:
> The init function of the ALAC encoder calls its own close function
> if a call to ff_lpc_init() fails; yet nothing has been allocated before
> that point (except extradata which is freed generically) and ff_lpc_init()
> can be expected to clean up after itself on error (the documentation does
> not say anything to the contrary and the current implementation can only
> fail if the only allocation fails, so there is nothing to clean up on
> error anyway), so this is unnecessary.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/alacenc.c | 20 ++--
>  1 file changed, 6 insertions(+), 14 deletions(-)
> 

what about adding cleanup flag so if new stuff is added(unlikely) new bugs
wont pop up?

> diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
> index fc5fa270e6..9d135d1350 100644
> --- a/libavcodec/alacenc.c
> +++ b/libavcodec/alacenc.c
> @@ -535,10 +535,8 @@ static av_cold int alac_encode_init(AVCodecContext 
> *avctx)
>   avctx->bits_per_raw_sample);
>  
>  avctx->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + 
> AV_INPUT_BUFFER_PADDING_SIZE);
> -if (!avctx->extradata) {
> -ret = AVERROR(ENOMEM);
> -goto error;
> -}
> +if (!avctx->extradata)
> +return AVERROR(ENOMEM);
>  avctx->extradata_size = ALAC_EXTRADATA_SIZE;
>  
>  alac_extradata = avctx->extradata;
> @@ -566,8 +564,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
> avctx->min_prediction_order > ALAC_MAX_LPC_ORDER) {
>  av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n",
> avctx->min_prediction_order);
> -ret = AVERROR(EINVAL);
> -goto error;
> +return AVERROR(EINVAL);
>  }
>  
>  s->min_prediction_order = avctx->min_prediction_order;
> @@ -578,8 +575,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
>  avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) {
>  av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n",
> avctx->max_prediction_order);
> -ret = AVERROR(EINVAL);
> -goto error;
> +return AVERROR(EINVAL);
>  }
>  
>  s->max_prediction_order = avctx->max_prediction_order;
> @@ -591,8 +587,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  av_log(avctx, AV_LOG_ERROR,
> "invalid prediction orders: min=%d max=%d\n",
> s->min_prediction_order, s->max_prediction_order);
> -ret = AVERROR(EINVAL);
> -goto error;
> +return AVERROR(EINVAL);
>  }
>  
>  s->avctx = avctx;
> @@ -600,13 +595,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  if ((ret = ff_lpc_init(>lpc_ctx, avctx->frame_size,
> s->max_prediction_order,
> FF_LPC_TYPE_LEVINSON)) < 0) {
> -goto error;
> +return ret;
>  }
>  
>  return 0;
> -error:
> -alac_encode_close(avctx);
> -return ret;
>  }
>  
>  static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
> -- 
> 2.25.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel 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 17/40] avcodec/alacenc: Remove redundant code to free extradata

2020-09-14 Thread Paul B Mahol
On Mon, Sep 14, 2020 at 07:27:24AM +0200, Andreas Rheinhardt wrote:
> It is already freed generically for encoders.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/alacenc.c | 2 --
>  1 file changed, 2 deletions(-)

lgtm

> 
> diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
> index 804cc7b17b..fc5fa270e6 100644
> --- a/libavcodec/alacenc.c
> +++ b/libavcodec/alacenc.c
> @@ -498,8 +498,6 @@ static av_cold int alac_encode_close(AVCodecContext 
> *avctx)
>  {
>  AlacEncodeContext *s = avctx->priv_data;
>  ff_lpc_end(>lpc_ctx);
> -av_freep(>extradata);
> -avctx->extradata_size = 0;
>  return 0;
>  }
>  
> -- 
> 2.25.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel 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 26/40] avcodec/avrndec: Check allocation for success

2020-09-14 Thread Paul B Mahol
On Mon, Sep 14, 2020 at 07:27:33AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/avrndec.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
lgtm
> diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c
> index f4ec490de5..a4b6fadfc8 100644
> --- a/libavcodec/avrndec.c
> +++ b/libavcodec/avrndec.c
> @@ -54,6 +54,8 @@ static av_cold int init(AVCodecContext *avctx)
>  }
>  
>  a->mjpeg_avctx = avcodec_alloc_context3(codec);
> +if (!a->mjpeg_avctx)
> +return AVERROR(ENOMEM);
>  
>  av_dict_set(_opt, "threads", "1", 0); // Is this needed ?
>  a->mjpeg_avctx->refcounted_frames = 1;
> -- 
> 2.25.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel 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 27/40] avcodec/avrndec: Fix memleak on error

2020-09-14 Thread Paul B Mahol
On Mon, Sep 14, 2020 at 07:27:34AM +0200, Andreas Rheinhardt wrote:
> If ff_codec_open2_recursive() fails, the already allocated
> AVCodecContext leaks. Fix this by setting the FF_CODEC_CAP_INIT_CLEANUP
> flag.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/avrndec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
lgtm
> diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c
> index a4b6fadfc8..c5a60acd4f 100644
> --- a/libavcodec/avrndec.c
> +++ b/libavcodec/avrndec.c
> @@ -170,5 +170,5 @@ AVCodec ff_avrn_decoder = {
>  .close  = end,
>  .decode = decode_frame,
>  .max_lowres = 3,
> -.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
> +.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | 
> FF_CODEC_CAP_INIT_CLEANUP,
>  };
> -- 
> 2.25.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 1/2] avcodec: add IPU Video decoder and parser

2020-09-14 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/Makefile |   2 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/codec_desc.c |   7 ++
 libavcodec/codec_id.h   |   1 +
 libavcodec/ipu_parser.c |  78 
 libavcodec/ipudec.c |   0
 libavcodec/mpeg12dec.c  | 155 
 libavcodec/parsers.c|   1 +
 8 files changed, 245 insertions(+)
 create mode 100644 libavcodec/ipu_parser.c
 create mode 100644 libavcodec/ipudec.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3239a752ac..b6b743133f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -419,6 +419,7 @@ OBJS-$(CONFIG_INDEO5_DECODER)  += indeo5.o ivi.o
 OBJS-$(CONFIG_INTERPLAY_ACM_DECODER)   += interplayacm.o
 OBJS-$(CONFIG_INTERPLAY_DPCM_DECODER)  += dpcm.o
 OBJS-$(CONFIG_INTERPLAY_VIDEO_DECODER) += interplayvideo.o
+OBJS-$(CONFIG_IPU_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
 OBJS-$(CONFIG_JACOSUB_DECODER) += jacosubdec.o ass.o
 OBJS-$(CONFIG_JPEG2000_ENCODER)+= j2kenc.o mqcenc.o mqc.o jpeg2000.o \
   jpeg2000dwt.o
@@ -1086,6 +1087,7 @@ OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
 OBJS-$(CONFIG_H263_PARSER) += h263_parser.o
 OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264_sei.o h264data.o
 OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_data.o
+OBJS-$(CONFIG_IPU_PARSER)  += ipu_parser.o
 OBJS-$(CONFIG_JPEG2000_PARSER) += jpeg2000_parser.o
 OBJS-$(CONFIG_MJPEG_PARSER)+= mjpeg_parser.o
 OBJS-$(CONFIG_MLP_PARSER)  += mlp_parse.o mlp_parser.o mlp.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 713c5686a4..17c88d6290 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -166,6 +166,7 @@ extern AVCodec ff_indeo3_decoder;
 extern AVCodec ff_indeo4_decoder;
 extern AVCodec ff_indeo5_decoder;
 extern AVCodec ff_interplay_video_decoder;
+extern AVCodec ff_ipu_decoder;
 extern AVCodec ff_jpeg2000_encoder;
 extern AVCodec ff_jpeg2000_decoder;
 extern AVCodec ff_jpegls_encoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 9e73dcba27..002ec86fa6 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1798,6 +1798,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("Kodak Photo CD"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_IPU,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "ipu",
+.long_name = NULL_IF_CONFIG_SMALL("IPU Video"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index e4eca5d580..e49ba1b28a 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -298,6 +298,7 @@ enum AVCodecID {
 AV_CODEC_ID_PFM,
 AV_CODEC_ID_MOBICLIP,
 AV_CODEC_ID_PHOTOCD,
+AV_CODEC_ID_IPU,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/ipu_parser.c b/libavcodec/ipu_parser.c
new file mode 100644
index 00..3cc6fdd1fe
--- /dev/null
+++ b/libavcodec/ipu_parser.c
@@ -0,0 +1,78 @@
+/*
+ * IPU parser
+ * Copyright (c) 2020 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * IPU parser
+ */
+
+#include "parser.h"
+#include "png.h"
+
+typedef struct IPUParseContext {
+ParseContext pc;
+} IPUParseContext;
+
+static int ipu_parse(AVCodecParserContext *s, AVCodecContext *avctx,
+ const uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size)
+{
+IPUParseContext *ipc = s->priv_data;
+uint32_t state = ipc->pc.state;
+int next = END_NOT_FOUND, i = 0;
+
+s->pict_type = AV_PICTURE_TYPE_NONE;
+s->duration  = 1;
+
+*poutbuf_size = 0;
+*poutbuf = NULL;
+
+if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
+next = buf_size;
+} else {
+for (; i < buf_size; i++) {
+state = (state << 8) | buf[i];
+if (state == 0x1b0) {

[FFmpeg-devel] [PATCH 2/2] avformat: add IPU demuxer

2020-09-14 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/ipudec.c | 89 
 3 files changed, 91 insertions(+)
 create mode 100644 libavformat/ipudec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 992d89a45f..213004cb45 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -278,6 +278,7 @@ OBJS-$(CONFIG_IMAGE_XPM_PIPE_DEMUXER) += img2dec.o 
img2.o
 OBJS-$(CONFIG_IMAGE_XWD_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_INGENIENT_DEMUXER) += ingenientdec.o rawdec.o
 OBJS-$(CONFIG_IPMOVIE_DEMUXER)   += ipmovie.o
+OBJS-$(CONFIG_IPU_DEMUXER)   += ipudec.o
 OBJS-$(CONFIG_IRCAM_DEMUXER) += ircamdec.o ircam.o pcm.o
 OBJS-$(CONFIG_IRCAM_MUXER)   += ircamenc.o ircam.o rawenc.o
 OBJS-$(CONFIG_ISS_DEMUXER)   += iss.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index ac154a3f31..2946a80dd7 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -210,6 +210,7 @@ extern AVInputFormat  ff_image2_alias_pix_demuxer;
 extern AVInputFormat  ff_image2_brender_pix_demuxer;
 extern AVInputFormat  ff_ingenient_demuxer;
 extern AVInputFormat  ff_ipmovie_demuxer;
+extern AVInputFormat  ff_ipu_demuxer;
 extern AVOutputFormat ff_ipod_muxer;
 extern AVInputFormat  ff_ircam_demuxer;
 extern AVOutputFormat ff_ircam_muxer;
diff --git a/libavformat/ipudec.c b/libavformat/ipudec.c
new file mode 100644
index 00..df53df00d9
--- /dev/null
+++ b/libavformat/ipudec.c
@@ -0,0 +1,89 @@
+/*
+ * IPU video demuxer
+ * Copyright (c) 2020 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "internal.h"
+#include "avio_internal.h"
+#include "rawdec.h"
+
+#include "libavutil/intreadwrite.h"
+#include "libavcodec/internal.h"
+
+static int ipu_read_probe(const AVProbeData *p)
+{
+if (AV_RB32(p->buf) != MKBETAG('i', 'p', 'u', 'm'))
+return 0;
+
+if (AV_RL32(p->buf + 4) == 0)
+return 0;
+
+if (AV_RL16(p->buf + 8) == 0)
+return 0;
+
+if (AV_RL16(p->buf + 10) == 0)
+return 0;
+
+if (AV_RL32(p->buf + 12) == 0)
+return 0;
+
+return AVPROBE_SCORE_MAX;
+}
+
+static int ipu_read_header(AVFormatContext *s)
+{
+AVIOContext *pb = s->pb;
+AVStream *st = avformat_new_stream(s, NULL);
+
+if (!st)
+return AVERROR(ENOMEM);
+avio_skip(pb, 8);
+st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+st->codecpar->codec_id = AV_CODEC_ID_IPU;
+st->codecpar->width= avio_rl16(pb);
+st->codecpar->height   = avio_rl16(pb);
+st->start_time = 0;
+st->duration   =
+st->nb_frames  = avio_rl32(pb);
+st->need_parsing   = AVSTREAM_PARSE_FULL_RAW;
+avpriv_set_pts_info(st, 64, 1, 25);
+
+return 0;
+}
+
+static const AVClass ipu_demuxer_class = {
+.class_name = "ipu demuxer",
+.item_name  = av_default_item_name,
+.option = ff_raw_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+AVInputFormat ff_ipu_demuxer = {
+.name   = "ipu",
+.long_name  = NULL_IF_CONFIG_SMALL("raw IPU Video"),
+.read_probe = ipu_read_probe,
+.read_header= ipu_read_header,
+.read_packet= ff_raw_read_partial_packet,
+.extensions = "ipu",
+.flags  = AVFMT_GENERIC_INDEX,
+.raw_codec_id   = AV_CODEC_ID_IPU,
+.priv_data_size = sizeof(FFRawDemuxerContext),
+.priv_class = _demuxer_class,
+};
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 2/2] dnn_backend_native_layer_conv2d.c: refine code.

2020-09-14 Thread xujunzz
From: Xu Jun 

Move thread area allocate out of thread function into
main thread.

Signed-off-by: Xu Jun 
---
 .../dnn/dnn_backend_native_layer_conv2d.c | 29 +--
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c 
b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index 5ed1851512..57659a1283 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -33,12 +33,11 @@ typedef struct thread_common_param{
 const void *parameters;
 NativeContext *ctx;
 float *output_data;
-int thread_num;
 } thread_common_param;
 
 typedef struct thread_param{
 thread_common_param *thread_common_param;
-int thread_index;
+int thread_start, thread_end;
 } thread_param;
 
 int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int 
file_size, int operands_num)
@@ -126,16 +125,12 @@ static void * dnn_execute_layer_conv2d_thread(void 
*threadarg)
 int filter_size = conv_params->kernel_size * filter_linesize;
 int pad_size = (conv_params->padding_method == VALID) ? 
(conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
 
-int thread_stride = (height - pad_size * 2) / 
thread_common_param->thread_num;
-int thread_start = thread_stride * thread_param->thread_index + pad_size;
-int thread_end = (thread_param->thread_index == 
thread_common_param->thread_num - 1) ? (height - pad_size) : (thread_start + 
thread_stride);
-
 float *output = thread_common_param->output_data;
-output += (conv_params->output_num) * (width - 2 * pad_size) * 
(thread_start - pad_size);
+output += (conv_params->output_num) * (width - 2 * pad_size) * 
(thread_param->thread_start - pad_size);
 
 av_assert0(channel == conv_params->input_num);
 
-for (int y = thread_start; y < thread_end; ++y) {
+for (int y = thread_param->thread_start; y < thread_param->thread_end; 
++y) {
 for (int x = pad_size; x < width - pad_size; ++x) {
 for (int n_filter = 0; n_filter < conv_params->output_num; 
++n_filter) {
 if (conv_params->has_bias)
@@ -207,11 +202,13 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 
 //alloc memory
 const ConvolutionalParams *conv_params = (const ConvolutionalParams 
*)(parameters);
+int height = operands[input_operand_indexes[0]].dims[1];
+int width = operands[input_operand_indexes[0]].dims[2];
 int pad_size = (conv_params->padding_method == VALID) ? 
(conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
 DnnOperand *output_operand = [output_operand_index];
 output_operand->dims[0] = operands[input_operand_indexes[0]].dims[0];
-output_operand->dims[1] = operands[input_operand_indexes[0]].dims[1] - 
pad_size * 2;
-output_operand->dims[2] = operands[input_operand_indexes[0]].dims[2] - 
pad_size * 2;
+output_operand->dims[1] = height - pad_size * 2;
+output_operand->dims[2] = width - pad_size * 2;
 output_operand->dims[3] = conv_params->output_num;
 output_operand->data_type = operands[input_operand_indexes[0]].data_type;
 output_operand->length = calculate_operand_data_length(output_operand);
@@ -227,13 +224,13 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 thread_common_param.output_data = output_operand->data;
 
 #if HAVE_PTHREAD_CANCEL
-thread_common_param.thread_num = thread_num;
-
+int thread_stride = (height - pad_size * 2) / thread_num;
 //create threads
 for (int i = 0; i < thread_num; i++){
 thread_param[i] = av_malloc(sizeof(**thread_param));
 thread_param[i]->thread_common_param = _common_param;
-thread_param[i]->thread_index = i;
+thread_param[i]->thread_start = thread_stride * i + pad_size;
+thread_param[i]->thread_end = (i == thread_num - 1) ? (height - 
pad_size) : (thread_param[i]->thread_start + thread_stride);
 pthread_create(_id[i], NULL, dnn_execute_layer_conv2d_thread, 
(void *)thread_param[i]);
 }
 
@@ -249,10 +246,10 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 av_free(thread_param[i]);
 }
 #else
-thread_common_param.thread_num = 1;
-thread_param[0] = av_malloc(sizeof(thread_param));
+thread_param[0] = av_malloc(sizeof(**thread_param));
 thread_param[0]->thread_common_param = _common_param;
-thread_param[0]->thread_index = 0;
+thread_param[0]->thread_start = 0;
+thread_param[0]->thread_end = height - pad_size;
 dnn_execute_layer_conv2d_thread((void *)thread_param[0]);
 av_free(thread_param[0]);
 #endif
-- 
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 

[FFmpeg-devel] [PATCH 1/2] dnn_backend_native_layer_conv2d.c: fix memory allocation bug in multithread function.

2020-09-14 Thread xujunzz
From: Xu Jun 

Before patch, memory was allocated in each thread functions,
which may cause more than one time of memory allocation and
cause crash.

After patch, memory is allocated in the main thread once,
an index was parsed into thread functions. Bug fixed.

Signed-off-by: Xu Jun 
---
 .../dnn/dnn_backend_native_layer_conv2d.c | 55 +--
 1 file changed, 27 insertions(+), 28 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c 
b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index c52725aa2b..5ed1851512 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -32,6 +32,7 @@ typedef struct thread_common_param{
 int32_t output_operand_index;
 const void *parameters;
 NativeContext *ctx;
+float *output_data;
 int thread_num;
 } thread_common_param;
 
@@ -111,7 +112,6 @@ static void * dnn_execute_layer_conv2d_thread(void 
*threadarg)
 thread_param *thread_param = (struct thread_param *)threadarg;
 thread_common_param *thread_common_param = 
thread_param->thread_common_param;
 DnnOperand *operands = thread_common_param->operands;
-float *output;
 int32_t input_operand_index = 
thread_common_param->input_operand_indexes[0];
 int number = operands[input_operand_index].dims[0];
 int height = operands[input_operand_index].dims[1];
@@ -130,24 +130,7 @@ static void * dnn_execute_layer_conv2d_thread(void 
*threadarg)
 int thread_start = thread_stride * thread_param->thread_index + pad_size;
 int thread_end = (thread_param->thread_index == 
thread_common_param->thread_num - 1) ? (height - pad_size) : (thread_start + 
thread_stride);
 
-DnnOperand *output_operand = 
[thread_common_param->output_operand_index];
-output_operand->dims[0] = number;
-output_operand->dims[1] = height - pad_size * 2;
-output_operand->dims[2] = width - pad_size * 2;
-output_operand->dims[3] = conv_params->output_num;
-output_operand->data_type = operands[input_operand_index].data_type;
-output_operand->length = calculate_operand_data_length(output_operand);
-if (output_operand->length <= 0) {
-av_log(thread_common_param->ctx, AV_LOG_ERROR, "The output data length 
overflow\n");
-return (void *)DNN_ERROR;
-}
-output_operand->data = av_realloc(output_operand->data, 
output_operand->length);
-if (!output_operand->data) {
-av_log(thread_common_param->ctx, AV_LOG_ERROR, "Failed to reallocate 
memory for output\n");
-return (void *)DNN_ERROR;
-}
-
-output = output_operand->data;
+float *output = thread_common_param->output_data;
 output += (conv_params->output_num) * (width - 2 * pad_size) * 
(thread_start - pad_size);
 
 av_assert0(channel == conv_params->input_num);
@@ -213,8 +196,6 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 pthread_t *thread_id = av_malloc(thread_num * sizeof(pthread_t));
 #endif
 thread_param **thread_param = av_malloc(thread_num * 
sizeof(*thread_param));
-void *res;
-int error_flag = DNN_SUCCESS;
 
 //struct used to pass parameters
 thread_common_param thread_common_param;
@@ -223,6 +204,28 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 thread_common_param.output_operand_index = output_operand_index;
 thread_common_param.parameters = parameters;
 thread_common_param.ctx = ctx;
+
+//alloc memory
+const ConvolutionalParams *conv_params = (const ConvolutionalParams 
*)(parameters);
+int pad_size = (conv_params->padding_method == VALID) ? 
(conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
+DnnOperand *output_operand = [output_operand_index];
+output_operand->dims[0] = operands[input_operand_indexes[0]].dims[0];
+output_operand->dims[1] = operands[input_operand_indexes[0]].dims[1] - 
pad_size * 2;
+output_operand->dims[2] = operands[input_operand_indexes[0]].dims[2] - 
pad_size * 2;
+output_operand->dims[3] = conv_params->output_num;
+output_operand->data_type = operands[input_operand_indexes[0]].data_type;
+output_operand->length = calculate_operand_data_length(output_operand);
+if (output_operand->length <= 0) {
+av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n");
+return DNN_ERROR;
+}
+output_operand->data = av_realloc(output_operand->data, 
output_operand->length);
+if (!output_operand->data) {
+av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n");
+return DNN_ERROR;
+}
+thread_common_param.output_data = output_operand->data;
+
 #if HAVE_PTHREAD_CANCEL
 thread_common_param.thread_num = thread_num;
 
@@ -236,9 +239,7 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 
 //join threads, res gets function return
 for (int i = 0; i < thread_num; i++){
-

Re: [FFmpeg-devel] [FFmpeg-cvslog] fate: disable automatic conversions on many tests.

2020-09-14 Thread Nicolas George
Nicolas George (12020-09-10):
> Anyway, I will try to find a big-endian arch and check.

I have tried on this:

Linux erpro8-fsf1 3.14.10-er8mod-00013-ge0fe977 #1 SMP PREEMPT Wed Jan
14 12:33:22 PST 2015 mips64 GNU/Linux

system type : UBNT_E200 (CN6120p1.1-1000-NSP)
machine : Unknown
processor   : 0
cpu model   : Cavium Octeon II V0.1
BogoMIPS: 2000.00

gcc (Debian 4.6.3-14) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.

(Yes, it's a bit old.)

And build fails:

CC  libavutil/mips/cpu.o
libavutil/mips/cpu.c:26:22: fatal error: sys/auxv.h: No such file or
directory
compilation terminated.
make: *** [libavutil/mips/cpu.o] Error 1

I think this needs to be addressed before I can consider fixing the FATE
tests.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH] avformat/mxfdec: fix pixel format extraction for cinema j2k

2020-09-14 Thread Tomas Härdin
mån 2020-09-14 klockan 10:48 +0100 skrev Rémi Achard:
> > Why this added hunk? Appending strong refs like this is likely to have
> > all sorts of unintended effects. The same MaterialPackages will appear
> > multiple times for example.
> 
> This is my attempt to fix an issue in the fate tests.

FATE works fine for me, at least with a default configuration. Can you
provide what options you're using?

> If you look at mxf_read_generic_descriptor, there is two places where we
> call mxf_read_strong_ref_array, if this happens on the same descriptor the
> second call will override the first one. This happen in the test suite for
> an XAVC file CDCI descriptor, see the previous post I made for the breaking
> test example.

You mean there's both a subdescriptor using local tag 0x3F01 and one
using mxf_subdescriptor_array_smpte or mxf_subdescriptor_array_interop?
In the same CDCIDescriptor?

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH v2 1/3] avformat/mxfdec: Read Mastering Display Colour Volume from MXF

2020-09-14 Thread Tomas Härdin
ons 2020-09-09 klockan 15:56 +0100 skrev Harry Mallon:
> Described in Annex B SMPTE ST 2067-21:2020
> 
> Signed-off-by: Harry Mallon 

>  av_freep(&((MXFDescriptor *)*ctx)->sub_descriptors_refs);
> @@ -1272,6 +1276,42 @@ static int mxf_read_generic_descriptor(void *arg, 
> AVIOContext *pb, int tag, int
>  rsiz == FF_PROFILE_JPEG2000_DCINEMA_4K)
>  descriptor->pix_fmt = AV_PIX_FMT_XYZ12;
>  }
> +if (IS_KLV_KEY(uid, ff_mxf_mastering_display_prefix)) {
> +if (!descriptor->mastering) {
> +descriptor->mastering = 
> av_mastering_display_metadata_alloc();
> +if (!descriptor->mastering)
> +return AVERROR(ENOMEM);
> +}
> +if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[0].uid)) 
> {
> +for (int i = 0; i < 3; i++) {
> +/* Order: large x, large y, other (i.e. RGB) */
> +descriptor->mastering->display_primaries[i][0] = 
> av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
> +descriptor->mastering->display_primaries[i][1] = 
> av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
> +}
> +/* Check we have seen 
> mxf_mastering_display_white_point_chromaticity */
> +if (descriptor->mastering->white_point[0].den != 0)
> +descriptor->mastering->has_primaries = 1;
> +}
> +if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[1].uid)) 
> {
> +descriptor->mastering->white_point[0] = 
> av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
> +descriptor->mastering->white_point[1] = 
> av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
> +/* Check we have seen mxf_mastering_display_primaries */
> +if (descriptor->mastering->display_primaries[0][0].den != 0)
> +descriptor->mastering->has_primaries = 1;
> +}
> +if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[2].uid)) 
> {
> +descriptor->mastering->max_luminance = 
> av_make_q(avio_rb32(pb), FF_MXF_MASTERING_LUMA_DEN);
> +/* Check we have seen 
> mxf_mastering_display_minimum_luminance */
> +if (descriptor->mastering->min_luminance.den != 0)
> +descriptor->mastering->has_luminance = 1;
> +}
> +if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[3].uid)) 
> {
> +descriptor->mastering->min_luminance = 
> av_make_q(avio_rb32(pb), FF_MXF_MASTERING_LUMA_DEN);
> +/* Check we have seen 
> mxf_mastering_display_maximum_luminance */
> +if (descriptor->mastering->max_luminance.den != 0)
> +descriptor->mastering->has_luminance = 1;
> +}
> +}

Much nicer :)

Patch looks OK to me

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/mxfenc: Write Mastering Display Colour Volume to MXF

2020-09-14 Thread Tomas Härdin
ons 2020-09-09 klockan 15:56 +0100 skrev Harry Mallon:
> Described in Annex B SMPTE ST 2067-21:2020
> 
> Signed-off-by: Harry Mallon 

Simple enough.

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH v2 3/3] avformat/mxfdec: Read Apple private Content Light Level from MXF

2020-09-14 Thread Tomas Härdin
ons 2020-09-09 klockan 15:56 +0100 skrev Harry Mallon:
> * As embedded by Apple Compressor
> 
> Signed-off-by: Harry Mallon 
> ---
>  libavformat/mxfdec.c|  27 +
>  tests/fate/mxf.mak  |   4 +
>  tests/ref/fate/mxf-probe-applehdr10 | 169 

Sweet, I don't have to write the test myself .)

Just ran FATE, the entire patch set works fine. We just need to get
that sample into the sample suite then all three of them can be pushed.
I'll see what I can do.

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH] avformat/mxfdec: fix pixel format extraction for cinema j2k

2020-09-14 Thread Rémi Achard
>
> Why this added hunk? Appending strong refs like this is likely to have
> all sorts of unintended effects. The same MaterialPackages will appear
> multiple times for example.


This is my attempt to fix an issue in the fate tests.

If you look at mxf_read_generic_descriptor, there is two places where we
call mxf_read_strong_ref_array, if this happens on the same descriptor the
second call will override the first one. This happen in the test suite for
an XAVC file CDCI descriptor, see the previous post I made for the breaking
test example.

I'll look into your concerns.

Le lun. 14 sept. 2020 à 10:40, Tomas Härdin  a écrit :

> sön 2020-09-13 klockan 23:42 +0100 skrev Rémi Achard:
> >
> > @@ -855,15 +857,19 @@ static int mxf_read_cryptographic_context(void
> *arg, AVIOContext *pb, int tag, i
> >
> >  static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int
> *count)
> >  {
> > -*count = avio_rb32(pb);
> > -av_free(*refs);
> > -*refs = av_calloc(*count, sizeof(UID));
> > +int local_count;
> > +
> > +local_count = avio_rb32(pb);
> > +*refs = av_realloc_array(*refs, *count + local_count, sizeof(UID));
> > +
> >  if (!*refs) {
> >  *count = 0;
> >  return AVERROR(ENOMEM);
> >  }
> >  avio_skip(pb, 4); /* useless size of objects, always 16 according
> to specs */
> > -avio_read(pb, (uint8_t *)*refs, *count * sizeof(UID));
> > +avio_read(pb, (uint8_t *)(*refs)[*count], local_count *
> sizeof(UID));
> > +*count += local_count;
> > +
> >  return 0;
> >  }
>
> Why this added hunk? Appending strong refs like this is likely to have
> all sorts of unintended effects. The same MaterialPackages will appear
> multiple times for example.
>
> /Tomas
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
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] avfilter/avf_concat: check for possible integer overflow

2020-09-14 Thread Nicolas George
Paul B Mahol (12020-09-13):
> Also check that segment delta pts is always bigger than input pts.
> 
> There is nothing much currently that can be done to recover from
> this situation so just return AVERROR_INVALIDDATA error code.

Looks ok.

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH] avfilter/af_amix: do not leave unset PTS for frames after first stream is over

2020-09-14 Thread Nicolas George
Paul B Mahol (12020-09-13):
> First stream is used only to get number of samples to put into each output 
> frame.
> 
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/af_amix.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

I cannot judge the change of the code since I do not know this code, but
based on the commit message, something like this is necessary in this
filter.

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH] avformat/mxfdec: fix pixel format extraction for cinema j2k

2020-09-14 Thread Tomas Härdin
sön 2020-09-13 klockan 23:42 +0100 skrev Rémi Achard:
> 
> @@ -855,15 +857,19 @@ static int mxf_read_cryptographic_context(void *arg, 
> AVIOContext *pb, int tag, i
>  
>  static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count)
>  {
> -*count = avio_rb32(pb);
> -av_free(*refs);
> -*refs = av_calloc(*count, sizeof(UID));
> +int local_count;
> +
> +local_count = avio_rb32(pb);
> +*refs = av_realloc_array(*refs, *count + local_count, sizeof(UID));
> +
>  if (!*refs) {
>  *count = 0;
>  return AVERROR(ENOMEM);
>  }
>  avio_skip(pb, 4); /* useless size of objects, always 16 according to 
> specs */
> -avio_read(pb, (uint8_t *)*refs, *count * sizeof(UID));
> +avio_read(pb, (uint8_t *)(*refs)[*count], local_count * sizeof(UID));
> +*count += local_count;
> +
>  return 0;
>  }

Why this added hunk? Appending strong refs like this is likely to have
all sorts of unintended effects. The same MaterialPackages will appear
multiple times for example.

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH 3/4] avdevice/decklink_dec: add support for rgb/yuv pixel format autodetection

2020-09-14 Thread Gyan Doshi


Building with Decklink is broken, apparently due to f1b908d20a8

Error is



src/libavdevice/decklink_dec.cpp: In function 'int 
ff_decklink_read_header(AVFormatContext*)':


src/libavdevice/decklink_dec.cpp:1235:28: error: 'bmdFormatUnspecified' 
was not declared in this scope


1235 | if (ctx->raw_format == bmdFormatUnspecified)

| ^~~~

make: *** [/build/ffmpeg-git/ffbuild/common.mak:70: 
libavdevice/decklink_dec.o] Error 1




Regards,
Gyan

On 08-09-2020 11:22 pm, Marton Balint wrote:

Signed-off-by: Marton Balint 
---
  doc/indevs.texi  | 15 +++
  libavdevice/decklink_dec.cpp |  8 +++-
  libavdevice/decklink_dec_c.c |  3 ++-
  3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 4d2312e201..7748232b26 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -296,16 +296,31 @@ supports it.
  Set the pixel format of the captured video.
  Available values are:
  @table @samp
+@item auto
+
+This is the default which means 8-bit YUV 422 or 8-bit ARGB if format
+autodetection is used, 8-bit YUV 422 otherwise.
+
  @item uyvy422
  
+8-bit YUV 422.

+
  @item yuv422p10
  
+10-bit YUV 422.

+
  @item argb
  
+8-bit RGB.

+
  @item bgra
  
+8-bit RGB.

+
  @item rgb10
  
+10-bit RGB.

+
  @end table
  
  @item teletext_lines

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index af0ef04c56..92b8feed14 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -1044,9 +1044,13 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
  
  HRESULT decklink_input_callback::VideoInputFormatChanged(

  BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *mode,
-BMDDetectedVideoInputFormatFlags)
+BMDDetectedVideoInputFormatFlags formatFlags)
  {
+struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
  ctx->bmd_mode = mode->GetDisplayMode();
+// check the C context member to make sure we set both raw_format and 
bmd_mode with data from the same format change callback
+if (!cctx->raw_format)
+ctx->raw_format = (formatFlags & bmdDetectedVideoInputRGB444) ? 
bmdFormat8BitARGB : bmdFormat8BitYUV;
  return S_OK;
  }
  
@@ -1228,6 +1232,8 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)

  }
  av_log(avctx, AV_LOG_INFO, "Autodetected the input mode\n");
  }
+if (ctx->raw_format == bmdFormatUnspecified)
+ctx->raw_format = bmdFormat8BitYUV;
  if (ff_decklink_set_format(avctx, DIRECTION_IN) < 0) {
  av_log(avctx, AV_LOG_ERROR, "Could not set format code %s for %s\n",
  cctx->format_code ? cctx->format_code : "(unset)", avctx->url);
diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
index 9f4b32088c..54cd681710 100644
--- a/libavdevice/decklink_dec_c.c
+++ b/libavdevice/decklink_dec_c.c
@@ -33,7 +33,8 @@ static const AVOption options[] = {
  { "list_devices", "list available devices"  , OFFSET(list_devices), 
AV_OPT_TYPE_INT   , { .i64 = 0   }, 0, 1, DEC },
  { "list_formats", "list supported formats"  , OFFSET(list_formats), 
AV_OPT_TYPE_INT   , { .i64 = 0   }, 0, 1, DEC },
  { "format_code",  "set format by fourcc", OFFSET(format_code),  
AV_OPT_TYPE_STRING, { .str = NULL}, 0, 0, DEC },
-{ "raw_format",   "pixel format to be returned by the card when capturing" , 
OFFSET(raw_format),  AV_OPT_TYPE_INT, { .i64 = MKBETAG('2','v','u','y')}, 0, UINT_MAX, DEC, 
"raw_format" },
+{ "raw_format",   "pixel format to be returned by the card when capturing" , 
OFFSET(raw_format),  AV_OPT_TYPE_INT, { .i64 = 0}, 0, UINT_MAX, DEC, "raw_format" },
+{ "auto",  NULL,   0,  AV_OPT_TYPE_CONST, { .i64 = 0
}, 0, 0, DEC, "raw_format"},
  { "uyvy422",   NULL,   0,  AV_OPT_TYPE_CONST, { .i64 = MKBETAG('2','v','u','y') 
}, 0, 0, DEC, "raw_format"},
  { "yuv422p10", NULL,   0,  AV_OPT_TYPE_CONST, { .i64 = MKBETAG('v','2','1','0') 
}, 0, 0, DEC, "raw_format"},
  { "argb",  NULL,   0,  AV_OPT_TYPE_CONST, { .i64 = 32   
}, 0, 0, DEC, "raw_format"},


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

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

Re: [FFmpeg-devel] [PATCH v2 4/4] avformat: add Argonaut Games BRP demuxer

2020-09-14 Thread Paul B Mahol
On Wed, Sep 09, 2020 at 12:05:03AM +, Zane van Iperen wrote:
> Used in FMVs for FX Fighter and Croc. Supports BVID and BASF streams,
> requests samples for anything else.
> 
> Due to the way BASF streams are contained in the file, only one is
> supported. I have yet to see a BRP file with multiple.
> 
> Signed-off-by: Zane van Iperen 
> ---
>  Changelog|   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/argo_brp.c   | 449 +++
>  libavformat/version.h|   2 +-
>  5 files changed, 453 insertions(+), 1 deletion(-)
>  create mode 100644 libavformat/argo_brp.c
> 
> diff --git a/Changelog b/Changelog
> index ff9ff2fcb8..2ccecfbcc9 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -21,6 +21,7 @@ version :
>  - MOFLEX demuxer
>  - MODS demuxer
>  - PhotoCD decoder
> +- Argonaut Games BRP demuxer
>  
>  
>  version 4.3:
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 2368bc15ac..062f3bd9c2 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -104,6 +104,7 @@ OBJS-$(CONFIG_APTX_HD_MUXER) += rawenc.o
>  OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
>  OBJS-$(CONFIG_ARGO_ASF_DEMUXER)  += argo_asf.o
>  OBJS-$(CONFIG_ARGO_ASF_MUXER)+= argo_asf.o
> +OBJS-$(CONFIG_ARGO_BRP_DEMUXER)  += argo_brp.o argo_asf.o
>  OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec_f.o asf.o asfcrypt.o \
>  avlanguage.o
>  OBJS-$(CONFIG_ASF_O_DEMUXER) += asfdec_o.o asf.o asfcrypt.o \
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 3438a14141..8e7556e529 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -65,6 +65,7 @@ extern AVOutputFormat ff_aptx_hd_muxer;
>  extern AVInputFormat  ff_aqtitle_demuxer;
>  extern AVInputFormat  ff_argo_asf_demuxer;
>  extern AVOutputFormat ff_argo_asf_muxer;
> +extern AVInputFormat  ff_argo_brp_demuxer;
>  extern AVInputFormat  ff_asf_demuxer;
>  extern AVOutputFormat ff_asf_muxer;
>  extern AVInputFormat  ff_asf_o_demuxer;
> diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
> new file mode 100644
> index 00..122f616ecc
> --- /dev/null
> +++ b/libavformat/argo_brp.c
> @@ -0,0 +1,449 @@
> +/*
> + * Argonaut Games BRP Demuxer
> + *
> + * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
> + *
> + * 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 "avformat.h"
> +#include "internal.h"
> +#include "libavutil/intreadwrite.h"
> +#include "libavutil/avassert.h"
> +#include "libavutil/internal.h"
> +#include "argo_asf.h"
> +
> +#define BRP_TAG MKTAG('B', 'R', 'P', 'P')
> +#define BRP_FILE_HEADER_SIZE12
> +#define BRP_BLOCK_HEADER_SIZE   12
> +#define BRP_STREAM_HEADER_SIZE  20
> +#define BRP_MAX_STREAMS 32 /* Soft cap, but even this is overkill. */
> +#define BVID_HEADER_SIZE16
> +#define BRP_MIN_BUFFER_SIZE FFMAX(FFMAX3(BRP_FILE_HEADER_SIZE,\
> + BRP_BLOCK_HEADER_SIZE,   \
> + BRP_STREAM_HEADER_SIZE), \
> +  BVID_HEADER_SIZE)
> +
> +#define BRP_CODEC_ID_BVID   MKTAG('B', 'V', 'I', 'D')
> +#define BRP_CODEC_ID_BASF   MKTAG('B', 'A', 'S', 'F')
> +
> +typedef struct ArgoBRPFileHeader {
> +uint32_t magic;
> +uint32_t num_streams;
> +uint32_t byte_rate;
> +} ArgoBRPFileHeader;
> +
> +typedef struct ArgoBRPBlockHeader {
> +int32_t  stream_id;
> +uint32_t start_ms;
> +uint32_t size;
> +} ArgoBRPBlockHeader;
> +
> +typedef struct ArgoBVIDHeader {
> +uint32_t num_frames;
> +uint32_t width;
> +uint32_t height;
> +uint32_t depth;
> +} ArgoBVIDHeader;
> +
> +typedef struct ArgoBRPStreamHeader {
> +uint32_t codec_id;
> +uint32_t id;
> +uint32_t duration_ms;
> +uint32_t byte_rate;
> +uint32_t extradata_size;
> +union
> +{
> +/* If codec_id == BRP_CODEC_ID_BVID */
> +ArgoBVIDHeaderbvid;
> +/* If codec_id == BRP_CODEC_ID_BASF */
> +ArgoASFFileHeader basf;
> +} 

Re: [FFmpeg-devel] [PATCH 2/2] libswcale/input: fix incorrect rgbf32 yuv conversions

2020-09-14 Thread Rémi Achard
> The rgb48ToUV and rgb48ToY funcs in input.c use the formula I'm using.

rgb64ToUV and rgb64ToY use it too, might be an opportunity to reduce code
duplication.

I ran into this while working on related precision issues (color range
conversion being precise only for 8bits) and just used the same formula as
the others templates to solve the issue like you.

Le lun. 14 sept. 2020 à 06:30, Mark Reid  a écrit :

> On Sun., Sep. 13, 2020, 4:04 p.m. Mark Reid,  wrote:
>
> >
> >
> > On Sun, Sep 13, 2020 at 8:55 AM Michael Niedermayer
> 
> > wrote:
> >
> >> On Sat, Sep 12, 2020 at 02:07:14AM -0700, mindm...@gmail.com wrote:
> >> > From: Mark Reid 
> >> >
> >> > ---
> >> >  libswscale/input.c  | 12 +---
> >> >  tests/ref/fate/filter-pixfmts-scale |  8 
> >> >  2 files changed, 9 insertions(+), 11 deletions(-)
> >>
> >> Can you provide some tests that show that this is better ?
> >> Iam asking that because some of the numbers in some of the code
> >> (i dont remember which) where tuned to give more accurate overall
> results
> >>
> >> an example for tests would be converting from A->B->A then compare to
> the
> >> orig
> >>
> >> thx
> >>
> >>
> > Hopefully i can explain this clearly!
> >
> > It's easier to see the error if you run a black image through the old
> > conversion.
> > zero values don't get mapped to zero. (attached sample image)
> >
> > ffmpeg -i 4x4_zero.exr -pix_fmt rgb48le -f rawvideo 4x4_zero.rawvideo
> > The image should be rgb 0, 0, 0  everywhere but instead it's 353, 0, 407
> >
> >
> > I think this is a error in fixed point rounding, the issue is basically
> > boils down to
> >
> > 128 << 8 != 257 << 7
> > and
> > 16 << 8  != 33 << 7
> >
> > https://en.wikipedia.org/wiki/YUV#Studio_swing_for_BT.601
> > the 8 bit rgb to yuv formula is
> >
> > Y = ry*r + gy*g + by*b  + 16
> > U = ru*r + gu*g + bu*b + 128
> > V = rv*r + gv*g + bv*b + 128
> >
> > I think the studio swing offsets at the end are calculated wrong in the
> > old code.
> > (257 << (RGB2YUV_SHIFT + bpc - 9)))
> > 257 is correct for 8 bit rounding but not for 16-bit.
> >
> > the 257 i believe is from (128 << 1) + 1
> > the +1 is for rounding
> >
> > for rounding 16-bit (128 << 9) + 1 = 0x10001
> >
> > therefore I think the correct rounding any bit depth with the old formula
> > would be (untested)
> > (((128 << (bpc - 7)) + 1) << (RGB2YUV_SHIFT-1) )
> >
> > I just simplified it to
> > (0x10001 << (RGB2YUV_SHIFT - 1))
> >
> > The rgb48ToUV and rgb48ToY funcs in input.c use the formula I'm using.
> >
>
> I'm still not sure if I'm correct about all this. The rounding stuff
> doesn't make 100% sense to me. But this is all I've gathered from reading
> the code.
>
>
>
> >
> >>
> >> [...]
> >> --
> >> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >>
> >> Everything should be made as simple as possible, but not simpler.
> >> -- Albert Einstein
> >> ___
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel@ffmpeg.org
> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>
> >> To unsubscribe, visit link above, or email
> >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> >
> >
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel 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] avfilter/vf_premultiply: add missing AV_PIX_FMT_YUVA444P12

2020-09-14 Thread Paul B Mahol
On Sun, Sep 13, 2020 at 07:55:01PM -0700, mindm...@gmail.com wrote:
> From: Mark Reid 
> 
> query_formats says its supported, but is missing from switch statement 
> leading to segfault
> 
> ---
>  libavfilter/vf_premultiply.c | 2 ++
>  1 file changed, 2 insertions(+)
> 

gonna apply.
___
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 29/40] avcodec/cfhdenc: Fix leaks on allocation errors

2020-09-14 Thread Paul B Mahol
On Mon, Sep 14, 2020 at 07:27:36AM +0200, Andreas Rheinhardt wrote:
> The CineForm HD encoder attempts to allocate several buffers in its init
> function; yet if only some of these allocations succeed, the
> successfully allocated buffers leak. This is fixed by setting the
> FF_CODEC_CAP_INIT_CLEANUP flag.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---

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

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

[FFmpeg-devel] [PATCH 4/4] dnn: add a new interface DNNModel.get_output

2020-09-14 Thread Guo, Yejun
for some cases (for example, super resolution), the DNN model changes
the frame size which impacts the filter behavior, so the filter needs
to know the out frame size at very beginning.

Currently, the filter reuses DNNModule.execute_model to query the
out frame size, it is not clear from interface perspective, so add
a new explict interface DNNModel.get_output for such query.

Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_native.c   | 66 ++
 libavfilter/dnn/dnn_backend_openvino.c | 66 ++
 libavfilter/dnn/dnn_backend_tf.c   | 66 ++
 libavfilter/dnn_interface.h|  3 ++
 libavfilter/vf_dnn_processing.c| 17 ++-
 libavfilter/vf_sr.c| 25 --
 6 files changed, 185 insertions(+), 58 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index dc47c9b542..d45e211f0c 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -44,6 +44,10 @@ const AVClass dnn_native_class = {
 .category   = AV_CLASS_CATEGORY_FILTER,
 };
 
+static DNNReturnType execute_model_native(const DNNModel *model, const char 
*input_name, AVFrame *in_frame,
+  const char **output_names, uint32_t 
nb_output, AVFrame *out_frame,
+  int do_ioproc);
+
 static DNNReturnType get_input_native(void *model, DNNData *input, const char 
*input_name)
 {
 NativeModel *native_model = (NativeModel *)model;
@@ -70,6 +74,25 @@ static DNNReturnType get_input_native(void *model, DNNData 
*input, const char *i
 return DNN_ERROR;
 }
 
+static DNNReturnType get_output_native(void *model, const char *input_name, 
int input_width, int input_height,
+   const char *output_name, int 
*output_width, int *output_height)
+{
+DNNReturnType ret;
+NativeModel *native_model = (NativeModel *)model;
+AVFrame *in_frame = av_frame_alloc();
+AVFrame *out_frame = av_frame_alloc();
+in_frame->width = input_width;
+in_frame->height = input_height;
+
+ret = execute_model_native(native_model->model, input_name, in_frame, 
_name, 1, out_frame, 0);
+*output_width = out_frame->width;
+*output_height = out_frame->height;
+
+av_frame_free(_frame);
+av_frame_free(_frame);
+return ret;
+}
+
 // Loads model and its parameters that are stored in a binary file with 
following structure:
 // layers_num,layer_type,layer_parameterss,layer_type,layer_parameters...
 // For CONV layer: activation_function, input_num, output_num, kernel_size, 
kernel, biases
@@ -216,6 +239,7 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename, const char *optio
 }
 
 model->get_input = _input_native;
+model->get_output = _output_native;
 model->userdata = userdata;
 
 return model;
@@ -226,8 +250,9 @@ fail:
 return NULL;
 }
 
-DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char 
*input_name, AVFrame *in_frame,
-  const char **output_names, uint32_t 
nb_output, AVFrame *out_frame)
+static DNNReturnType execute_model_native(const DNNModel *model, const char 
*input_name, AVFrame *in_frame,
+  const char **output_names, uint32_t 
nb_output, AVFrame *out_frame,
+  int do_ioproc)
 {
 NativeModel *native_model = (NativeModel *)model->model;
 NativeContext *ctx = _model->ctx;
@@ -276,10 +301,12 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel 
*model, const char *inp
 input.channels = oprd->dims[3];
 input.data = oprd->data;
 input.dt = oprd->data_type;
-if (native_model->model->pre_proc != NULL) {
-native_model->model->pre_proc(in_frame, , 
native_model->model->userdata);
-} else {
-proc_from_frame_to_dnn(in_frame, , ctx);
+if (do_ioproc) {
+if (native_model->model->pre_proc != NULL) {
+native_model->model->pre_proc(in_frame, , 
native_model->model->userdata);
+} else {
+proc_from_frame_to_dnn(in_frame, , ctx);
+}
 }
 
 if (nb_output != 1) {
@@ -322,21 +349,40 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel 
*model, const char *inp
 output.channels = oprd->dims[3];
 output.dt = oprd->data_type;
 
-if (out_frame->width != output.width || out_frame->height != 
output.height) {
-out_frame->width = output.width;
-out_frame->height = output.height;
-} else {
+if (do_ioproc) {
 if (native_model->model->post_proc != NULL) {
 native_model->model->post_proc(out_frame, , 
native_model->model->userdata);
 } else {
 proc_from_dnn_to_frame(out_frame, , ctx);
 }
+} else {
+out_frame->width = 

[FFmpeg-devel] [PATCH 1/4] dnn: add userdata for load model parameter

2020-09-14 Thread Guo, Yejun
the userdata will be used for the interaction between AVFrame and DNNData

Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_native.c   | 3 ++-
 libavfilter/dnn/dnn_backend_native.h   | 2 +-
 libavfilter/dnn/dnn_backend_openvino.c | 3 ++-
 libavfilter/dnn/dnn_backend_openvino.h | 2 +-
 libavfilter/dnn/dnn_backend_tf.c   | 5 +++--
 libavfilter/dnn/dnn_backend_tf.h   | 2 +-
 libavfilter/dnn_interface.h| 4 +++-
 libavfilter/vf_derain.c| 2 +-
 libavfilter/vf_dnn_processing.c| 2 +-
 libavfilter/vf_sr.c| 2 +-
 10 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index a9ecbdc88b..830ec19c80 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -123,7 +123,7 @@ static DNNReturnType set_input_native(void *model, DNNData 
*input, const char *i
 // layers_num,layer_type,layer_parameterss,layer_type,layer_parameters...
 // For CONV layer: activation_function, input_num, output_num, kernel_size, 
kernel, biases
 // For DEPTH_TO_SPACE layer: block_size
-DNNModel *ff_dnn_load_model_native(const char *model_filename, const char 
*options)
+DNNModel *ff_dnn_load_model_native(const char *model_filename, const char 
*options, void *userdata)
 {
 DNNModel *model = NULL;
 char header_expected[] = "FFMPEGDNNNATIVE";
@@ -265,6 +265,7 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename, const char *optio
 
 model->set_input = _input_native;
 model->get_input = _input_native;
+model->userdata = userdata;
 
 return model;
 
diff --git a/libavfilter/dnn/dnn_backend_native.h 
b/libavfilter/dnn/dnn_backend_native.h
index b1f8f3d6bf..33634118a8 100644
--- a/libavfilter/dnn/dnn_backend_native.h
+++ b/libavfilter/dnn/dnn_backend_native.h
@@ -125,7 +125,7 @@ typedef struct NativeModel{
 int32_t operands_num;
 } NativeModel;
 
-DNNModel *ff_dnn_load_model_native(const char *model_filename, const char 
*options);
+DNNModel *ff_dnn_load_model_native(const char *model_filename, const char 
*options, void *userdata);
 
 DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData 
*outputs, const char **output_names, uint32_t nb_output);
 
diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index e5842906d1..01e1a1d4c8 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -174,7 +174,7 @@ err:
 return DNN_ERROR;
 }
 
-DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options)
+DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char 
*options, void *userdata)
 {
 char *all_dev_names = NULL;
 DNNModel *model = NULL;
@@ -230,6 +230,7 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, 
const char *options)
 model->set_input = _input_ov;
 model->get_input = _input_ov;
 model->options = options;
+model->userdata = userdata;
 
 return model;
 
diff --git a/libavfilter/dnn/dnn_backend_openvino.h 
b/libavfilter/dnn/dnn_backend_openvino.h
index b2a86e0125..f69bc5ca0c 100644
--- a/libavfilter/dnn/dnn_backend_openvino.h
+++ b/libavfilter/dnn/dnn_backend_openvino.h
@@ -29,7 +29,7 @@
 
 #include "../dnn_interface.h"
 
-DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char 
*options);
+DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char 
*options, void *userdata);
 
 DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, DNNData *outputs, 
const char **output_names, uint32_t nb_output);
 
diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index 5e7f37bb12..bac7d8c420 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -502,7 +502,7 @@ static DNNReturnType load_native_model(TFModel *tf_model, 
const char *model_file
 DNNModel *model = NULL;
 NativeModel *native_model;
 
-model = ff_dnn_load_model_native(model_filename, NULL);
+model = ff_dnn_load_model_native(model_filename, NULL, NULL);
 if (!model){
 av_log(ctx, AV_LOG_ERROR, "Failed to load native model\n");
 return DNN_ERROR;
@@ -586,7 +586,7 @@ static DNNReturnType load_native_model(TFModel *tf_model, 
const char *model_file
 return DNN_SUCCESS;
 }
 
-DNNModel *ff_dnn_load_model_tf(const char *model_filename, const char *options)
+DNNModel *ff_dnn_load_model_tf(const char *model_filename, const char 
*options, void *userdata)
 {
 DNNModel *model = NULL;
 TFModel *tf_model = NULL;
@@ -616,6 +616,7 @@ DNNModel *ff_dnn_load_model_tf(const char *model_filename, 
const char *options)
 model->set_input = _input_tf;
 model->get_input = _input_tf;
 model->options = options;
+model->userdata = userdata;
 
 return model;
 }
diff --git a/libavfilter/dnn/dnn_backend_tf.h b/libavfilter/dnn/dnn_backend_tf.h
index 

[FFmpeg-devel] [PATCH 2/4] dnn: change dnn interface to replace DNNData* with AVFrame*

2020-09-14 Thread Guo, Yejun
Currently, every filter needs to provide code to transfer data from
AVFrame* to model input (DNNData*), and also from model output
(DNNData*) to AVFrame*. Actually, such transfer can be implemented
within DNN module, and so filter can focus on its own business logic.

DNN module also exports the function pointer pre_proc and post_proc
in struct DNNModel, just in case that a filter has its special logic
to transfer data between AVFrame* and DNNData*. The default implementation
within DNN module is used if the filter does not set pre/post_proc.

Signed-off-by: Guo, Yejun 
---
 configure  |   2 +-
 libavfilter/dnn/Makefile   |   1 +
 libavfilter/dnn/dnn_backend_native.c   |  53 --
 libavfilter/dnn/dnn_backend_native.h   |   3 +-
 libavfilter/dnn/dnn_backend_openvino.c |  71 +---
 libavfilter/dnn/dnn_backend_openvino.h |   2 +-
 libavfilter/dnn/dnn_backend_tf.c   |  90 ++
 libavfilter/dnn/dnn_backend_tf.h   |   2 +-
 libavfilter/dnn/dnn_io_proc.c  | 135 ++
 libavfilter/dnn/dnn_io_proc.h  |  36 
 libavfilter/dnn_interface.h|  17 +-
 libavfilter/vf_derain.c|  59 ++
 libavfilter/vf_dnn_processing.c| 240 +
 libavfilter/vf_sr.c| 166 +++--
 14 files changed, 451 insertions(+), 426 deletions(-)
 create mode 100644 libavfilter/dnn/dnn_io_proc.c
 create mode 100644 libavfilter/dnn/dnn_io_proc.h

diff --git a/configure b/configure
index 5d68695192..39fabb4ad5 100755
--- a/configure
+++ b/configure
@@ -2628,6 +2628,7 @@ cbs_vp9_select="cbs"
 dct_select="rdft"
 dirac_parse_select="golomb"
 dnn_suggest="libtensorflow libopenvino"
+dnn_deps="swscale"
 error_resilience_select="me_cmp"
 faandct_deps="faan"
 faandct_select="fdctdsp"
@@ -3532,7 +3533,6 @@ derain_filter_select="dnn"
 deshake_filter_select="pixelutils"
 deshake_opencl_filter_deps="opencl"
 dilation_opencl_filter_deps="opencl"
-dnn_processing_filter_deps="swscale"
 dnn_processing_filter_select="dnn"
 drawtext_filter_deps="libfreetype"
 drawtext_filter_suggest="libfontconfig libfribidi"
diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
index e0957073ee..ee08cc5243 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_io_proc.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_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 830ec19c80..14e878b6b8 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -27,6 +27,7 @@
 #include "libavutil/avassert.h"
 #include "dnn_backend_native_layer_conv2d.h"
 #include "dnn_backend_native_layers.h"
+#include "dnn_io_proc.h"
 
 #define OFFSET(x) offsetof(NativeContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM
@@ -69,11 +70,12 @@ static DNNReturnType get_input_native(void *model, DNNData 
*input, const char *i
 return DNN_ERROR;
 }
 
-static DNNReturnType set_input_native(void *model, DNNData *input, const char 
*input_name)
+static DNNReturnType set_input_native(void *model, AVFrame *frame, const char 
*input_name)
 {
 NativeModel *native_model = (NativeModel *)model;
 NativeContext *ctx = _model->ctx;
 DnnOperand *oprd = NULL;
+DNNData input;
 
 if (native_model->layers_num <= 0 || native_model->operands_num <= 0) {
 av_log(ctx, AV_LOG_ERROR, "No operands or layers in model\n");
@@ -97,10 +99,8 @@ static DNNReturnType set_input_native(void *model, DNNData 
*input, const char *i
 return DNN_ERROR;
 }
 
-oprd->dims[0] = 1;
-oprd->dims[1] = input->height;
-oprd->dims[2] = input->width;
-oprd->dims[3] = input->channels;
+oprd->dims[1] = frame->height;
+oprd->dims[2] = frame->width;
 
 av_freep(>data);
 oprd->length = calculate_operand_data_length(oprd);
@@ -114,7 +114,16 @@ static DNNReturnType set_input_native(void *model, DNNData 
*input, const char *i
 return DNN_ERROR;
 }
 
-input->data = oprd->data;
+input.height = oprd->dims[1];
+input.width = oprd->dims[2];
+input.channels = oprd->dims[3];
+input.data = oprd->data;
+input.dt = oprd->data_type;
+if (native_model->model->pre_proc != NULL) {
+native_model->model->pre_proc(frame, , 
native_model->model->userdata);
+} else {
+proc_from_frame_to_dnn(frame, , ctx);
+}
 
 return DNN_SUCCESS;
 }
@@ -185,6 +194,7 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename, const char *optio
 if (av_opt_set_from_string(_model->ctx, model->options, NULL, "=", 
"&") < 0)
 goto fail;
 

[FFmpeg-devel] [PATCH 3/4] dnn: put DNNModel.set_input and DNNModule.execute_model together

2020-09-14 Thread Guo, Yejun
suppose we have a detect and classify filter in the future, the
detect filter generates some bounding boxes (BBox) as AVFrame sidedata,
and the classify filter executes DNN model for each BBox. For each
BBox, we need to crop the AVFrame, copy data to DNN model input and do
the model execution. So we have to save the in_frame at DNNModel.set_input
and use it at DNNModule.execute_model, such saving is not feasible
when we support async execute_model.

This patch sets the in_frame as execution_model parameter, and so
all the information are put together within the same function for
each inference. It also makes easy to support BBox async inference.

Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_native.c   | 119 +++--
 libavfilter/dnn/dnn_backend_native.h   |   3 +-
 libavfilter/dnn/dnn_backend_openvino.c |  85 --
 libavfilter/dnn/dnn_backend_openvino.h |   3 +-
 libavfilter/dnn/dnn_backend_tf.c   | 118 ++--
 libavfilter/dnn/dnn_backend_tf.h   |   3 +-
 libavfilter/dnn_interface.h|   8 +-
 libavfilter/vf_derain.c|   9 +-
 libavfilter/vf_dnn_processing.c|  18 +---
 libavfilter/vf_sr.c|  25 ++
 10 files changed, 156 insertions(+), 235 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 14e878b6b8..dc47c9b542 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -70,64 +70,6 @@ static DNNReturnType get_input_native(void *model, DNNData 
*input, const char *i
 return DNN_ERROR;
 }
 
-static DNNReturnType set_input_native(void *model, AVFrame *frame, const char 
*input_name)
-{
-NativeModel *native_model = (NativeModel *)model;
-NativeContext *ctx = _model->ctx;
-DnnOperand *oprd = NULL;
-DNNData input;
-
-if (native_model->layers_num <= 0 || native_model->operands_num <= 0) {
-av_log(ctx, AV_LOG_ERROR, "No operands or layers in model\n");
-return DNN_ERROR;
-}
-
-/* inputs */
-for (int i = 0; i < native_model->operands_num; ++i) {
-oprd = _model->operands[i];
-if (strcmp(oprd->name, input_name) == 0) {
-if (oprd->type != DOT_INPUT) {
-av_log(ctx, AV_LOG_ERROR, "Found \"%s\" in model, but it is 
not input node\n", input_name);
-return DNN_ERROR;
-}
-break;
-}
-oprd = NULL;
-}
-if (!oprd) {
-av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model\n", 
input_name);
-return DNN_ERROR;
-}
-
-oprd->dims[1] = frame->height;
-oprd->dims[2] = frame->width;
-
-av_freep(>data);
-oprd->length = calculate_operand_data_length(oprd);
-if (oprd->length <= 0) {
-av_log(ctx, AV_LOG_ERROR, "The input data length overflow\n");
-return DNN_ERROR;
-}
-oprd->data = av_malloc(oprd->length);
-if (!oprd->data) {
-av_log(ctx, AV_LOG_ERROR, "Failed to malloc memory for input data\n");
-return DNN_ERROR;
-}
-
-input.height = oprd->dims[1];
-input.width = oprd->dims[2];
-input.channels = oprd->dims[3];
-input.data = oprd->data;
-input.dt = oprd->data_type;
-if (native_model->model->pre_proc != NULL) {
-native_model->model->pre_proc(frame, , 
native_model->model->userdata);
-} else {
-proc_from_frame_to_dnn(frame, , ctx);
-}
-
-return DNN_SUCCESS;
-}
-
 // Loads model and its parameters that are stored in a binary file with 
following structure:
 // layers_num,layer_type,layer_parameterss,layer_type,layer_parameters...
 // For CONV layer: activation_function, input_num, output_num, kernel_size, 
kernel, biases
@@ -273,7 +215,6 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename, const char *optio
 return NULL;
 }
 
-model->set_input = _input_native;
 model->get_input = _input_native;
 model->userdata = userdata;
 
@@ -285,26 +226,66 @@ fail:
 return NULL;
 }
 
-DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char 
**output_names, uint32_t nb_output, AVFrame *out_frame)
+DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char 
*input_name, AVFrame *in_frame,
+  const char **output_names, uint32_t 
nb_output, AVFrame *out_frame)
 {
 NativeModel *native_model = (NativeModel *)model->model;
 NativeContext *ctx = _model->ctx;
 int32_t layer;
-DNNData output;
+DNNData input, output;
+DnnOperand *oprd = NULL;
 
-if (nb_output != 1) {
-// currently, the filter does not need multiple outputs,
-// so we just pending the support until we really need it.
-av_log(ctx, AV_LOG_ERROR, "do not support multiple outputs\n");
+if (native_model->layers_num <= 0 || native_model->operands_num <= 0) {
+av_log(ctx, AV_LOG_ERROR, "No operands or layers