Re: [FFmpeg-devel] [PATCH 4/4] avcodec/videotoolboxenc: fix error code

2023-01-03 Thread Steven Liu
Zhao Zhili  于2023年1月4日周三 10:35写道:
>
> From: Zhao Zhili 
>
> 1. Fix return 0 on success.
> 2. Fix return OS error code passthrough.
> ---
>  libavcodec/videotoolboxenc.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 3b00e542cb..56971471e4 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -2555,6 +2555,7 @@ static int vtenc_populate_extradata(AVCodecContext   
> *avctx,
>  pool = VTCompressionSessionGetPixelBufferPool(vtctx->session);
>  if(!pool){
>  av_log(avctx, AV_LOG_ERROR, "Error getting pixel buffer pool.\n");
> +status = AVERROR_EXTERNAL;
>  goto pe_cleanup;
>  }
>
> @@ -2564,6 +2565,7 @@ static int vtenc_populate_extradata(AVCodecContext   
> *avctx,
>
>  if(status != kCVReturnSuccess){
>  av_log(avctx, AV_LOG_ERROR, "Error creating frame from pool: %d\n", 
> status);
> +status = AVERROR_EXTERNAL;
>  goto pe_cleanup;
>  }
>
> @@ -2581,7 +2583,7 @@ static int vtenc_populate_extradata(AVCodecContext   
> *avctx,
> AV_LOG_ERROR,
> "Error sending frame for extradata: %d\n",
> status);
> -
> +status = AVERROR_EXTERNAL;
>  goto pe_cleanup;
>  }
>
> @@ -2589,8 +2591,10 @@ static int vtenc_populate_extradata(AVCodecContext   
> *avctx,
>  status = VTCompressionSessionCompleteFrames(vtctx->session,
>  kCMTimeIndefinite);
>
> -if (status)
> +if (status) {
> +status = AVERROR_EXTERNAL;
>  goto pe_cleanup;
> +}
>
>  status = vtenc_q_pop(vtctx, 0, , NULL);
>  if (status) {
> --
> 2.35.3
>
> ___
> 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".


LGTM

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

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


[FFmpeg-devel] [PATCH v2 4/4] avcodec/videotoolboxenc: fix error code

2023-01-03 Thread Zhao Zhili
From: Zhao Zhili 

1. Fix return 0 on error.
2. Fix return OS error code passthrough.
---
v2: fix commit message

 libavcodec/videotoolboxenc.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 3b00e542cb..56971471e4 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -2555,6 +2555,7 @@ static int vtenc_populate_extradata(AVCodecContext   
*avctx,
 pool = VTCompressionSessionGetPixelBufferPool(vtctx->session);
 if(!pool){
 av_log(avctx, AV_LOG_ERROR, "Error getting pixel buffer pool.\n");
+status = AVERROR_EXTERNAL;
 goto pe_cleanup;
 }
 
@@ -2564,6 +2565,7 @@ static int vtenc_populate_extradata(AVCodecContext   
*avctx,
 
 if(status != kCVReturnSuccess){
 av_log(avctx, AV_LOG_ERROR, "Error creating frame from pool: %d\n", 
status);
+status = AVERROR_EXTERNAL;
 goto pe_cleanup;
 }
 
@@ -2581,7 +2583,7 @@ static int vtenc_populate_extradata(AVCodecContext   
*avctx,
AV_LOG_ERROR,
"Error sending frame for extradata: %d\n",
status);
-
+status = AVERROR_EXTERNAL;
 goto pe_cleanup;
 }
 
@@ -2589,8 +2591,10 @@ static int vtenc_populate_extradata(AVCodecContext   
*avctx,
 status = VTCompressionSessionCompleteFrames(vtctx->session,
 kCMTimeIndefinite);
 
-if (status)
+if (status) {
+status = AVERROR_EXTERNAL;
 goto pe_cleanup;
+}
 
 status = vtenc_q_pop(vtctx, 0, , NULL);
 if (status) {
-- 
2.35.3

___
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] Update for my hls and dash patches?

2023-01-03 Thread Steven Liu
Basel Sayeh  于2023年1月4日周三 01:12写道:
>
> Hello,
>
>
> Any update or comment on these patch sets?
>
>
> Enable HTTP persistent connections for hls_delete_file &
> dashenc_delete_file:
> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8033

https://patchwork.ffmpeg.org/project/ffmpeg/patch/db9p191mb14827461396938910246ace9fe...@db9p191mb1482.eurp191.prod.outlook.com/

You should check the first patch of this series.

>
>
> Use http_read_header in http_shutdown to react to response errors:
> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8058
Is it will use block mode of socket?
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/3] avcodec/videotoolboxenc: pass error code through

2023-01-03 Thread zhilizhao(赵志立)


> On Jan 4, 2023, at 02:11, Tomas Härdin  wrote:
> 
> tis 2023-01-03 klockan 18:18 +0800 skrev Zhao Zhili:
>> From: Zhao Zhili 
>> 
>> Signed-off-by: Zhao Zhili 
>> ---
>>  libavcodec/videotoolboxenc.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/libavcodec/videotoolboxenc.c
>> b/libavcodec/videotoolboxenc.c
>> index 27db4e0d5e..3b00e542cb 100644
>> --- a/libavcodec/videotoolboxenc.c
>> +++ b/libavcodec/videotoolboxenc.c
>> @@ -2156,7 +2156,7 @@ static int get_cv_pixel_info(
>>  
>>  status = get_cv_pixel_format(avctx, av_format, av_color_range,
>> color, _guessed);
>>  if (status)
>> -return AVERROR(EINVAL);
>> +return status;
>>  
>>  if (range_guessed) {
>>  if (!vtctx->warned_color_range) {
>> @@ -2338,7 +2338,7 @@ static int
>> create_cv_pixel_buffer(AVCodecContext   *avctx,
>>  status
>>  );
>>  
>> -return AVERROR_EXTERNAL;
>> +return status;
> 
> Are these guaranteed to always be negative?

Yes.

> 
> /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 4/4] avcodec/videotoolboxenc: fix error code

2023-01-03 Thread Zhao Zhili
From: Zhao Zhili 

1. Fix return 0 on success.
2. Fix return OS error code passthrough.
---
 libavcodec/videotoolboxenc.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 3b00e542cb..56971471e4 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -2555,6 +2555,7 @@ static int vtenc_populate_extradata(AVCodecContext   
*avctx,
 pool = VTCompressionSessionGetPixelBufferPool(vtctx->session);
 if(!pool){
 av_log(avctx, AV_LOG_ERROR, "Error getting pixel buffer pool.\n");
+status = AVERROR_EXTERNAL;
 goto pe_cleanup;
 }
 
@@ -2564,6 +2565,7 @@ static int vtenc_populate_extradata(AVCodecContext   
*avctx,
 
 if(status != kCVReturnSuccess){
 av_log(avctx, AV_LOG_ERROR, "Error creating frame from pool: %d\n", 
status);
+status = AVERROR_EXTERNAL;
 goto pe_cleanup;
 }
 
@@ -2581,7 +2583,7 @@ static int vtenc_populate_extradata(AVCodecContext   
*avctx,
AV_LOG_ERROR,
"Error sending frame for extradata: %d\n",
status);
-
+status = AVERROR_EXTERNAL;
 goto pe_cleanup;
 }
 
@@ -2589,8 +2591,10 @@ static int vtenc_populate_extradata(AVCodecContext   
*avctx,
 status = VTCompressionSessionCompleteFrames(vtctx->session,
 kCMTimeIndefinite);
 
-if (status)
+if (status) {
+status = AVERROR_EXTERNAL;
 goto pe_cleanup;
+}
 
 status = vtenc_q_pop(vtctx, 0, , NULL);
 if (status) {
-- 
2.35.3

___
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/rtpproto: add support for RTP/UDP socket reuse

2023-01-03 Thread Nicolas George
Camille Oudot (12023-01-03):
> Why does the "reuse" option exists on the "udp" protocol in the first
> place?

Because it is an useful option. Only not for this use case.

Because nobody noticed it was badly named when it was applied.

> Why would it not apply to "rtp" also?

Because nobody made the UDP socket context a child object of the RTP
context.

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] get_cabac_inline_x86: Don't inline if 32-bit Windows

2023-01-03 Thread Christopher Degawa
On Tue, Jan 3, 2023 at 12:51 PM Christopher Degawa 
wrote:

>
>
> On Tue, Jan 3, 2023 at 4:16 AM Andreas Rheinhardt <
> andreas.rheinha...@outlook.com> wrote:
>
>> Christopher Degawa:
>> > previouslly, it only was an issue with 32-bit clang from msys2's
>> > mingw32 repo, however, at some point with an update to gcc 12.2.0,
>> > the same issue popped up. Tested with a clean clone of ffmpeg, and even
>> > tested with n5.0, but the issue persists, so I presume it's a compiler
>> > issue.
>>
>> Have these presumed compiler bugs ever been reported upstream?
>>
>> - Andreas
>>
>
>  I'm not sure if it's necessarily a compiler bug, rather I'm suspecting
> something was changed in msys2's i686 gcc's. Based on my small findings, it
> might be related to what “generic” means for -mtune for the 32-bit
> compiler. I was asking around msys2's channels to see if anyone else could
> reproduce it, but nobody has responded yet.
>

Seems some of them have encountered it
https://github.com/msys2/MINGW-packages/pull/11683
___
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/rtpproto: add support for RTP/UDP socket reuse

2023-01-03 Thread Camille Oudot
Why does the "reuse" option exists on the "udp" protocol in the first
place? Why would it not apply to "rtp" also?

Here is the original patch proposal on udp:
http://ffmpeg.org/pipermail/ffmpeg-devel/2006-October/thread.html#18946

> Sure. But then that does not solve the problem of RTCP mux and SDP
> bundle, which normally would use the exact same IP address and port
> number on the local end (and also on the far end, if set).

I confirm the requirement is to send several RTP streams with FFmpeg
with identical proto/src_ip/src_port/dst_ip/dst_port.

> > 
> It's not that simple. The semantics of REUSEPORT varies between Linux
> and BSD. IIRC, REUSEPORT was originally meant by BSD to allow
> multiple processes to listen on the same multicast group, but then
> Linux redefined it with radically different semantics, for receive
> load-balancing purpose.

They added SO_REUSEPORT_LB in BSD to mimic the Linux behavior.

> 
> Repeating myself, but I don't see how that solves the problem. You
> don't need REUSEADDR for two sockets to send to the same remote
> IP/port, and you cannot rely on it to send from the same local
> IP/port.

It *does* work, at least on Linux: I can send several RTP streams from
the exact same local IP/port (and _to_ the same IP/port too but that's
not a problem in general as you point it) with either REUSEADDR or
REUSEPORT options set.

Here are ffmpeg strace traces for local RTCP port == local RTP port.
The command sends a video stream to the following RTP URL (RTP and are
sent from the same local source port):

rtp://127.0.0.1:4?localaddr=127.0.0.1=22300
=22300=4

without SO_REUSEPORT

...
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_IP) = 4
bind(4, {sa_family=AF_INET, sin_port=htons(22300),
sin_addr=inet_addr("127.0.0.1")}, 16) = 0
getsockname(4, {sa_family=AF_INET, sin_port=htons(22300),
in_addr=inet_addr("127.0.0.1")}, [128->16]) = 0
setsockopt(4, SOL_SOCKET, SO_SNDBUF, [32768], 4) = 0
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_IP) = 5
bind(5, {sa_family=AF_INET, sin_port=htons(22300),
in_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address
already in use)

with SO_REUSEPORT
=
...
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_IP) = 4
setsockopt(4, SOL_SOCKET, SO_REUSEPORT, [1], 4) = 0
bind(4, {sa_family=AF_INET, sin_port=htons(22300),
sin_addr=inet_addr("127.0.0.1")}, 16) = 0
getsockname(4, {sa_family=AF_INET, sin_port=htons(22300),
sin_addr=inet_addr("127.0.0.1")}, [128->16]) = 0
setsockopt(4, SOL_SOCKET, SO_SNDBUF, [32768], 4) = 0
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_IP) = 5
setsockopt(5, SOL_SOCKET, SO_REUSEPORT, [1], 4) = 0
bind(5, {sa_family=AF_INET, sin_port=htons(22300),
sin_addr=inet_addr("127.0.0.1")}, 16) = 0


Regards

-- 
Camille

___
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 02/32] avfilter/palette{gen, use}: revert support palettes with alpha

2023-01-03 Thread Paul B Mahol
Please add alpha support back.

On Wed, Dec 28, 2022 at 12:18 AM Clément Bœsch  wrote:

> This reverts commit dea673d0d548c864ec85f9260d8900d944ef7a2a.
>
> This change cannot work for several reasons, the most obvious ones are:
>
> - the alpha is being part of the scoring of the color difference, even
>   though we can not interpret the alpha as part of the perception of the
>   color (we don't even know if it's premultiplied or postmultiplied)
> - the colors are averaged with their alpha value which simply cannot
>   work
>
> The command proposed in the original thread of the patch actually
> produces a completely broken file:
>
> ffmpeg -y -loglevel verbose -i fate-suite/apng/o_sample.png
> -filter_complex
> "split[split1][split2];[split1]palettegen=max_colors=254:use_alpha=1[pal1];[split2][pal1]paletteuse=use_alpha=1"
> -frames:v 1 out.png
>
> We can see that many color pixels are off, but more importantly some
> colors have a random alpha value: https://imgur.com/eFQ2UK7
>
> I don't see any easy fix for this unfortunately, the approach appears to
> be flawed by design.
> ---
>  doc/filters.texi|   8 --
>  libavfilter/vf_palettegen.c | 127 +++-
>  libavfilter/vf_paletteuse.c | 225 +++-
>  3 files changed, 138 insertions(+), 222 deletions(-)
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 9b866de5ae..f51623d16a 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -18474,9 +18474,6 @@ Compute new histogram for each frame.
>  @end table
>
>  Default value is @var{full}.
> -@item use_alpha
> -Create a palette of colors with alpha components.
> -Setting this, will automatically disable 'reserve_transparent'.
>  @end table
>
>  The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
> @@ -18555,11 +18552,6 @@ will be treated as completely opaque, and values
> below this threshold will be
>  treated as completely transparent.
>
>  The option must be an integer value in the range [0,255]. Default is
> @var{128}.
> -
> -@item use_alpha
> -Apply the palette by taking alpha values into account. Only useful with
> -palettes that are containing multiple colors with alpha components.
> -Setting this will automatically disable 'alpha_treshold'.
>  @end table
>
>  @subsection Examples
> diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c
> index c03f62b942..bea3292796 100644
> --- a/libavfilter/vf_palettegen.c
> +++ b/libavfilter/vf_palettegen.c
> @@ -59,7 +59,7 @@ enum {
>  };
>
>  #define NBITS 5
> -#define HIST_SIZE (1<<(4*NBITS))
> +#define HIST_SIZE (1<<(3*NBITS))
>
>  typedef struct PaletteGenContext {
>  const AVClass *class;
> @@ -67,7 +67,6 @@ typedef struct PaletteGenContext {
>  int max_colors;
>  int reserve_transparent;
>  int stats_mode;
> -int use_alpha;
>
>  AVFrame *prev_frame;// previous frame used for
> the diff stats_mode
>  struct hist_node histogram[HIST_SIZE];  // histogram/hashtable of the
> colors
> @@ -89,7 +88,6 @@ static const AVOption palettegen_options[] = {
>  { "full", "compute full frame histograms", 0, AV_OPT_TYPE_CONST,
> {.i64=STATS_MODE_ALL_FRAMES}, INT_MIN, INT_MAX, FLAGS, "mode" },
>  { "diff", "compute histograms only for the part that differs from
> previous frame", 0, AV_OPT_TYPE_CONST, {.i64=STATS_MODE_DIFF_FRAMES},
> INT_MIN, INT_MAX, FLAGS, "mode" },
>  { "single", "compute new histogram for each frame", 0,
> AV_OPT_TYPE_CONST, {.i64=STATS_MODE_SINGLE_FRAMES}, INT_MIN, INT_MAX,
> FLAGS, "mode" },
> -{ "use_alpha", "create a palette including alpha values",
> OFFSET(use_alpha), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
>  { NULL }
>  };
>
> @@ -115,16 +113,15 @@ static int cmp_##name(const void *pa, const void
> *pb)   \
>  {   \
>  const struct color_ref * const *a = pa; \
>  const struct color_ref * const *b = pb; \
> -return   (int)((*a)->color >> (8 * (3 - (pos))) & 0xff)  \
> -   - (int)((*b)->color >> (8 * (3 - (pos))) & 0xff); \
> +return   (int)((*a)->color >> (8 * (2 - (pos))) & 0xff)  \
> +   - (int)((*b)->color >> (8 * (2 - (pos))) & 0xff); \
>  }
>
> -DECLARE_CMP_FUNC(a, 0)
> -DECLARE_CMP_FUNC(r, 1)
> -DECLARE_CMP_FUNC(g, 2)
> -DECLARE_CMP_FUNC(b, 3)
> +DECLARE_CMP_FUNC(r, 0)
> +DECLARE_CMP_FUNC(g, 1)
> +DECLARE_CMP_FUNC(b, 2)
>
> -static const cmp_func cmp_funcs[] = {cmp_a, cmp_r, cmp_g, cmp_b};
> +static const cmp_func cmp_funcs[] = {cmp_r, cmp_g, cmp_b};
>
>  /**
>   * Simple color comparison for sorting the final palette
> @@ -146,17 +143,6 @@ static av_always_inline int diff(const uint32_t a,
> const uint32_t b)
>  return dr*dr + dg*dg + db*db;
>  }
>
> -static av_always_inline int diff_alpha(const uint32_t a, const uint32_t b)
> -{
> -const uint8_t c1[] = {a >> 24 & 0xff, a >> 16 & 0xff, a >> 8 & 0xff,
> a & 0xff};
> -const uint8_t c2[] 

Re: [FFmpeg-devel] [PATCH v2 01/32] avfilter/palettegen: allow a minimum of 2 colors

2023-01-03 Thread Tomas Härdin
ons 2022-12-28 klockan 22:23 +0100 skrev Clément Bœsch:
> On Wed, Dec 28, 2022 at 10:04:26PM +0100, Tomas Härdin wrote:
> [...]
> > Does this mean all-black with transparent is disallowed?
> 
> Yes a single color with or without an extra transparency slot makes
> no
> sense.
> 
> > Shouldn't it be max_colors + reserve < 2?
> 
> max_colors accounts for the transparent color as well. So if you
> specify
> 256 colors with reserve_transparent (default settings), you'll get
> 255
> color slots and 1 for transparency.
> 
> It also means that if want to go as low as 2 colors in your palette
> you
> can do max_colors=3 with reserve_transparent=1, or max_colors=2 with
> reserve_transparent=0
> 
>   3-1 → 2
>   2-0 → 2
> 
> These are the minimums.

Right, because there's no "0bpp" pixel format with 1bpp alpha.. yet!
Something similar actually exists with GoldSrc .spr files, especially
the indexalpha mode. It is effectively "0bpp" with 8-bit alpha:
https://the303.org/tutorials/gold_sprite_p3.htm

> 
> PS: sorry for the double answer Tomas!

No problem :)

/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] get_cabac_inline_x86: Don't inline if 32-bit Windows

2023-01-03 Thread Christopher Degawa
On Tue, Jan 3, 2023 at 4:16 AM Andreas Rheinhardt <
andreas.rheinha...@outlook.com> wrote:

> Christopher Degawa:
> > previouslly, it only was an issue with 32-bit clang from msys2's
> > mingw32 repo, however, at some point with an update to gcc 12.2.0,
> > the same issue popped up. Tested with a clean clone of ffmpeg, and even
> > tested with n5.0, but the issue persists, so I presume it's a compiler
> > issue.
>
> Have these presumed compiler bugs ever been reported upstream?
>
> - Andreas
>

 I'm not sure if it's necessarily a compiler bug, rather I'm suspecting
something was changed in msys2's i686 gcc's. Based on my small findings, it
might be related to what “generic” means for -mtune for the 32-bit
compiler. I was asking around msys2's channels to see if anyone else could
reproduce it, but nobody has responded yet.
___
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] Rework color quantization in palette{gen,use}

2023-01-03 Thread Michael Niedermayer
On Tue, Jan 03, 2023 at 12:05:22AM +0100, Clément Bœsch wrote:
> On Mon, Jan 02, 2023 at 10:57:33PM +0100, Michael Niedermayer wrote:
> [...]
> > > So I did a lot of experiments, and the explanation for the desaturated
> > > output at low number of colors can be found at the end of this article:
> > > http://blog.pkh.me/p/39-improving-color-quantization-heuristics.html
> > 
> > interresting and its impressive how much reseacrh you did here
> > i hope this will get applied
> 
> Thanks. I was actually planning to push in the next 12 hours or so, unless
> there is an objection.
> 
> > also i hape a bit that it will get
> > extended to include clustering as in ELBG cuz it seems a bit odd
> > to have this sort of alternative filters neither does all 
> 
> Yeah at some point we probably want to group the clustering and vector
> quantization logics in a common module. But there are lot of questions API
> wise wrt its relationship with perceptual and other color systems.
> 
> > > I still think it's acceptable to lean toward desaturated colors when
> > > reducing the number of colors, but you may disagree.
> > 
> > I think a key aspect of desaturation has not been mentioned.
> > That is mixing, i mean dithering is some sort of mixing, in the sense of
> > an artist mixing several pigment/dyes/colors.
> > If you have black and white a 50% mixture gives 50% gray. other ratios
> > would give us all values between white and black though with dithering
> > some ratios work better like 50% looks good while ratios very close to
> > 0 and 100% but not exacty 0 and 100 look bad with few highly vissible
> > black or white pixels in a see of the opposing color.
> > 
> > Now this results in 2 things at least.
> > 1. We should be able to improve color quantization by this.
> >  If we have colors A and B the (A+B)/2 point is basically free, its dither
> >  pattern looks good on any high resolution display and if we consider such
> >  points there are more of course like maybe (A+B+C+D)/4 we can cover more
> >  output colors with a smaller palette.
> 
> That's interesting. Basically you'd free certain slots of the palette if
> you detect that this particular color is at the mid point of two others in
> the palette? And so you could use that slot for another tint…
> 
> Yeah I don't know what to do with this information, it looks not trivial
> to implement.

If we simplify the problem a bit and instead of considering 3d we just look at 
1d
then for example to represent all colors between 0 and 128 either as a
solid color or by 2 colors 50:50% then we need only 19 colors of these values
{0,2,6,8,10,16,28,40,52,64,76,88,100,112,118,120,122,126,128}

if we have fewer colors in 1d we can cover these

Full n= 4 cover=9 avg=2.67 {0,2,6,8}
Full n= 5 cover=13 avg=3.769231 {0,2,6,10,12}
Full n= 6 cover=17 avg=4.823529 {0,2,6,10,14,16}
Full n= 7 cover=21 avg=5.857143 {0,2,4,10,16,18,20}
Full n= 8 cover=27 avg=6.89 {0,2,6,8,18,20,24,26}
Full n= 9 cover=33 avg= 9.969697 {0,2,4,10,16,22,28,30,32}
Full n=10 cover=41 avg=10.878049 {0,2,6,8,18,22,32,34,38,40}
Full n=11 cover=45 avg=10.64 {0,2,6,8,18,22,26,36,38,42,44}
Full n=12 cover=55 avg=14.727273 {0,2,6,8,18,22,32,36,46,48,52,54}
Full n=13 cover=65 avg=18.415385 {0,2,6,8,18,22,32,42,46,56,58,62,64}
Full n=14 cover=73 avg=18.931507 {0,2,6,8,18,22,32,40,50,54,64,66,70,72}
Full n=15 cover=81 avg=25.172840 {0,2,6,8,10,16,28,40,52,64,70,72,74,78,80}
Full n=16 cover=93 avg=30.193548 {0,2,6,8,10,16,28,40,52,64,76,82,84,86,90,92}
Full n=17 cover=105 avg=35.209524 
{0,2,6,8,10,16,28,40,52,64,76,88,94,96,98,102,104}
Full n=18 cover=111 avg=33.261261 
{0,2,6,10,14,18,20,42,44,66,68,90,92,96,100,104,108,110}

so what about 3d ?
if we have a 3d cube and we create a palette with the 1d list from above for
6 colors we end up with a 6x6x6 palette of 216 colors where with the 50:50 mixes
we cover the full 17x17x17=4913 cube, all points of it that is. same for the 
6x6x7
 (17x17x21=6069) cases. this might be an interresting alternative to the 332 
palette
or maybe it could be used as start point for some optimized palette, remocing 
unused
colors and adding new by some clustering

I didnt try any of this on an actual image. Its not as simple as using that 
palette
as the dither algorithm also needs to be redesigned to actually use the right
color pairs. Dither would generally use the closest color and thats not true 
here
for many pairs

also gamma needs to be handled correctly for all this because mixing white and
black pixels will only look like 50% gray when gamma is handled correctly
As i didnt try it, i have 0 idea how bad it would look. I was primarly 
interrested
in the nummeric/math aspect behind this which is why i played a bit with these
numbers

thx

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

The day soldiers stop bringing you their problems is the day you have stopped 
leading them. They have either lost confidence that you can help or 

Re: [FFmpeg-devel] [PATCH] get_cabac_inline_x86: Don't inline if 32-bit Windows

2023-01-03 Thread Christopher Degawa
On Tue, Jan 3, 2023 at 12:32 PM Christopher Degawa 
wrote:

>
>
> On Mon, Jan 2, 2023 at 5:36 PM Hendrik Leppkes 
> wrote:
>
>> On Tue, Jan 3, 2023 at 12:01 AM Christopher Degawa 
>> wrote:
>> >
>>
>> I regularly build with 12.2 on win32 and its fine.
>>
>> In fact, there is a fate station for that:
>>
>> https://fate.ffmpeg.org/report.cgi?slot=x86_32-mingw-w64-dll-windows-native=20230102232810
>>
>> So if you are seeing this issue, more details that trigger it will be
>> required, and maybe a more targeted fix.
>>
>> - Hendrik
>
> I will try to see which flag in that configure line causes the issues to
> disappear
>

Seems I got it to disappear with just "--cpu=i686", so "ARCH
   x86 (generic)" fails but "ARCH  x86 (i686)"
passes
___
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] get_cabac_inline_x86: Don't inline if 32-bit Windows

2023-01-03 Thread Christopher Degawa
On Mon, Jan 2, 2023 at 5:36 PM Hendrik Leppkes  wrote:

> On Tue, Jan 3, 2023 at 12:01 AM Christopher Degawa 
> wrote:
> >
>
> I regularly build with 12.2 on win32 and its fine.
>
> In fact, there is a fate station for that:
>
> https://fate.ffmpeg.org/report.cgi?slot=x86_32-mingw-w64-dll-windows-native=20230102232810
>
> So if you are seeing this issue, more details that trigger it will be
> required, and maybe a more targeted fix.
>
> - Hendrik

I can try to see if I can narrow down the configuration more, and try the
one used in fate, but for now, I was reproducing it by using ../configure
&& make -j 12

As additional information for now, I'm using

Target: i686-w64-mingw32
gcc version 12.2.0 (Rev7, Built by MSYS2 project)

with no notable environment variables like CFLAGS etc.
I did make sure to update my packages from msys2.

Interestingly, when I ran "../configure  --enable-gpl
--enable-memory-poisoning --arch=x86 --cpu=i686 --enable-shared" there were
no errors, but did confirm that with just "../configure
 && make libavcodec/h264_cabac.o" the error reappeared.

CC  libavcodec/h264_cabac.o
In file included from C:/Users/cddeg/FFmpeg/libavcodec/cabac_functions.h:49,
 from C:/Users/cddeg/FFmpeg/libavcodec/h264_cabac.c:36:
In function 'get_cabac_inline_x86',
inlined from 'get_cabac' at
C:/Users/cddeg/FFmpeg/libavcodec/cabac_functions.h:145:12,
inlined from 'decode_cabac_mb_intra4x4_pred_mode' at
C:/Users/cddeg/FFmpeg/libavcodec/h264_cabac.c:1377:9,
inlined from 'ff_h264_decode_mb_cabac' at
C:/Users/cddeg/FFmpeg/libavcodec/h264_cabac.c:2081:32:
C:/Users/cddeg/FFmpeg/libavcodec/x86/cabac.h:199:5: error: 'asm' operand
has impossible constraints
  199 | __asm__ volatile(
  | ^~~
C:/Users/cddeg/FFmpeg/libavcodec/x86/cabac.h:199:5: error: 'asm' operand
has impossible constraints
C:/Users/cddeg/FFmpeg/libavcodec/x86/cabac.h:199:5: error: 'asm' operand
has impossible constraints
C:/Users/cddeg/FFmpeg/libavcodec/x86/cabac.h:199:5: error: 'asm' operand
has impossible constraints
make: *** [/c/Users/cddeg/FFmpeg/ffbuild/common.mak:81:
libavcodec/h264_cabac.o] Error 1


I will try to see which flag in that configure line causes the issues to
disappear
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/3] avcodec/videotoolboxenc: pass error code through

2023-01-03 Thread Tomas Härdin
tis 2023-01-03 klockan 18:18 +0800 skrev Zhao Zhili:
> From: Zhao Zhili 
> 
> Signed-off-by: Zhao Zhili 
> ---
>  libavcodec/videotoolboxenc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/videotoolboxenc.c
> b/libavcodec/videotoolboxenc.c
> index 27db4e0d5e..3b00e542cb 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -2156,7 +2156,7 @@ static int get_cv_pixel_info(
>  
>  status = get_cv_pixel_format(avctx, av_format, av_color_range,
> color, _guessed);
>  if (status)
> -    return AVERROR(EINVAL);
> +    return status;
>  
>  if (range_guessed) {
>  if (!vtctx->warned_color_range) {
> @@ -2338,7 +2338,7 @@ static int
> create_cv_pixel_buffer(AVCodecContext   *avctx,
>  status
>  );
>  
> -    return AVERROR_EXTERNAL;
> +    return status;

Are these guaranteed to always be negative?

/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] Update for my hls and dash patches?

2023-01-03 Thread Basel Sayeh

Hello,


Any update or comment on these patch sets?


Enable HTTP persistent connections for hls_delete_file & 
dashenc_delete_file: 
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8033



Use http_read_header in http_shutdown to react to response errors: 
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8058



___
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] 3 more dithering mode in paletteuse

2023-01-03 Thread Clément Bœsch
On Fri, Dec 30, 2022 at 12:34:51PM +0100, Clément Bœsch wrote:
[...]

Patchset applied

-- 
Clément B.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] New iteration for the color quantization in palette{gen, use}

2023-01-03 Thread Clément Bœsch
On Wed, Dec 28, 2022 at 12:17:42AM +0100, Clément Bœsch wrote:
[...]

Patchset applied

-- 
Clément B.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avformat/rtpproto: add support for RTP/UDP socket reuse

2023-01-03 Thread Rémi Denis-Courmont
Le tiistaina 3. tammikuuta 2023, 11.03.30 EET Camille Oudot a écrit :
> Hi, I'm back on the topic. Thanks to all of you for your comments.
> 
> > So I agree that SO_REUSEADDR is "absolutely not a hack"... if you use
> > it to recycle IP/port pair without waiting for the time-out. But
> > that's mainly of interest of listening/receiving sockets.
> 
> That is indeed the case for TCP sockets, but as far as I know this does
> not apply to UDP as there is no TIME_WAIT state associated to datagram
> sockets.
> 
> The classical use of this option would be for having a process binding
> on udp:0.0.0.0:1234 then another one binding on e.g.
> udp:192.168.1.10:1234 without triggering a "address in use" error. This
> is indeed a matter of listening socket.

Sure. But then that does not solve the problem of RTCP mux and SDP bundle, 
which normally would use the exact same IP address and port number on the 
local end (and also on the far end, if set).

> > If you use it to bind two concurrent sockets on the same IP/port
> > pair, then it is absolutely not just a hack but a platform-dependent
> > non-portable hack and a latent vulnerability in the OS (since one
> > process can hijack datagrams for another).
> 
> The use of REUSEPORT instead of REUSEADDR is meant to mitigate this
> risk (but it's far from perfect).

It's not that simple. The semantics of REUSEPORT varies between Linux and BSD. 
IIRC, REUSEPORT was originally meant by BSD to allow multiple processes to 
listen on the same multicast group, but then Linux redefined it with radically 
different semantics, for receive load-balancing purpose.

> I definitely agree that using these options instead of refactoring or
> rewriting the RTP protocol to support RTP bundle and RTCP mux is a
> hack. I should take some time in the future to look into a proper
> solution. In the meantime, several people are looking for this feature:
> 
> - http://ffmpeg.org/pipermail/ffmpeg-user/2018-September/041393.html
> - https://trac.ffmpeg.org/ticket/1774

Repeating myself, but I don't see how that solves the problem. You don't need 
REUSEADDR for two sockets to send to the same remote IP/port, and you cannot 
rely on it to send from the same local IP/port.

-- 
レミ・デニ-クールモン
http://www.remlab.net/



___
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 v1 00/11] Add support for H266/VVC

2023-01-03 Thread Thomas Siedel
On Thu, 15 Dec 2022 at 10:11, Thomas Siedel 
wrote:

> On Tue, 13 Dec 2022 at 07:19, Nuo Mi  wrote:
>
>> Hi Thomas,
>> Thank you for sending the patch set.
>> It seems the patchset is based on
>> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=3487
>> Please do not change the author's name.
>>
>> thank you
>>
>
> Some code regarding VVC parsing is based on another FFmpeg fork. This fork
> had been based on your patch set, it seems.
> On top of this, I did additional modifications to the parsing code and
> added the other code regarding format support and the decoder and encoder
> integration.
>
> It was not my intent to hide you as an author of the parsing code.
> Your patch set has been in an unmerged state for over 1.5 years now
> without new progress, so I assumed that these patches are kind of
> discontinued.
> Therefore I started submitting my own patchset to get VVC integrated into
> FFmpeg.
> I kept your original copyright notices in libavformat/vvcdec.c and
> livavcodec/vvc_parser.c.
> Apart from this, I am not sure how / where else this could be documented
> and how other authors can be appropriately referenced.
>
> Could you explain in more detail what you mean by changing the author's
> name?
> Do you have any suggestions on what to do in this case or how to change it?
>
>
I just submitted a new version of the patch set.
Among other changes, I now put you as the author of the first three
patches, as most of their content is based on your original patch set.
I made some modifications to them, so I added myself as a co-author.
For patches 4 and 5, I put you as the co-author because some of their
content is based on your original patch set, but only to a smaller extent.
All other patches are independent.

I hope that this solution is OK for you. If not, please let me know.


>
> On Wed, Oct 19, 2022 at 3:26 PM  wrote:
>>
>>> From: Thomas Siedel 
>>>
>>> This patch set adds H266/VVC support.
>>> This includes parsing, muxing, demuxing, decoding and encoding.
>>> Decoding is done using the external library VVdeC
>>> (https://github.com/fraunhoferhhi/vvdec.git) and can be enabled with
>>> --enable-libvvdec.
>>> Encoding is done using the external library VVenC
>>> (https://github.com/fraunhoferhhi/vvenc.git) and can be enabled with
>>> --enable-libvvenc.
>>>
>>> Thomas Siedel (11):
>>>   avcodec: add enum types for H266/VVC
>>>   avcodec: add cbs for H266/VVC
>>>   avcodec: enable cbs for H266/VVC
>>>   avcodec: add bitstream parser for H266/VVC
>>>   avcodec: add MP4 to annexb support for H266/VVC
>>>   avformat: add demuxer and probe support for H266/VVC
>>>   avformat: add muxer support for H266/VVC
>>>   avcodec: add external decoder libvvdec for H266/VVC
>>>   avcodec: add external encoder libvvenc for H266/VVC
>>>   avformat: add ts stream types for H266/VVC
>>>   avcodec: increase minor version for H266/VVC
>>>
>>>  configure |   16 +-
>>>  libavcodec/Makefile   |6 +
>>>  libavcodec/allcodecs.c|2 +
>>>  libavcodec/bitstream_filters.c|2 +
>>>  libavcodec/cbs.c  |6 +
>>>  libavcodec/cbs_h2645.c|  384 +++-
>>>  libavcodec/cbs_h266.h |  791 +++
>>>  libavcodec/cbs_h266_syntax_template.c | 3010 +
>>>  libavcodec/cbs_internal.h |3 +-
>>>  libavcodec/cbs_sei.c  |   29 +
>>>  libavcodec/h2645_parse.c  |   71 +-
>>>  libavcodec/h266_metadata_bsf.c|  145 ++
>>>  libavcodec/libvvdec.c |  511 +
>>>  libavcodec/libvvenc.c |  432 
>>>  libavcodec/parsers.c  |1 +
>>>  libavcodec/version.h  |2 +-
>>>  libavcodec/vvc.h  |  142 ++
>>>  libavcodec/vvc_mp4toannexb_bsf.c  |  318 +++
>>>  libavcodec/vvc_paramset.c |  972 
>>>  libavcodec/vvc_paramset.h |  429 
>>>  libavcodec/vvc_parse_extradata.c  |  241 ++
>>>  libavcodec/vvc_parse_extradata.h  |   36 +
>>>  libavcodec/vvc_parser.c   |  588 +
>>>  libavformat/Makefile  |8 +-
>>>  libavformat/allformats.c  |2 +
>>>  libavformat/demux.c   |7 +-
>>>  libavformat/isom.c|1 +
>>>  libavformat/isom_tags.c   |3 +
>>>  libavformat/mov.c |6 +
>>>  libavformat/movenc.c  |   41 +-
>>>  libavformat/mpeg.c|3 +
>>>  libavformat/mpeg.h|1 +
>>>  libavformat/mpegts.c  |2 +
>>>  libavformat/mpegts.h  |1 +
>>>  libavformat/mpegtsenc.c   |   65 +
>>>  libavformat/rawenc.c  |   23 +
>>>  libavformat/vvc.c |  918 
>>>  libavformat/vvc.h |   99 +
>>>  libavformat/vvcdec.c  |   61 +
>>>  39 files 

[FFmpeg-devel] [PATCH v5 09/10] avformat: add ts stream types for H266/VVC

2023-01-03 Thread Thomas Siedel
Add transport stream stream type 0x33 for vvc.
Add STREAM_TYPE_VIDEO_VVC to MPEG-1/2 and MPEG-2 transport stream.
Add basic transport stream support for TS mux/demux.
---
 configure   |  2 +-
 libavformat/mpeg.c  |  3 ++
 libavformat/mpeg.h  |  1 +
 libavformat/mpegts.c|  2 ++
 libavformat/mpegts.h|  1 +
 libavformat/mpegtsenc.c | 65 +
 6 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index c89c42241a..e648a88c1a 100755
--- a/configure
+++ b/configure
@@ -3470,7 +3470,7 @@ mp3_demuxer_select="mpegaudio_parser"
 mp3_muxer_select="mpegaudioheader"
 mp4_muxer_select="mov_muxer"
 mpegts_demuxer_select="iso_media"
-mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf"
+mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf vvc_mp4toannexb_bsf"
 mpegtsraw_demuxer_select="mpegts_demuxer"
 mxf_muxer_select="pcm_rechunk_bsf"
 mxf_d10_muxer_select="mxf_muxer"
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 864b08d8f8..970926df6b 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -546,6 +546,9 @@ redo:
 } else if (es_type == STREAM_TYPE_VIDEO_HEVC) {
 codec_id = AV_CODEC_ID_HEVC;
 type = AVMEDIA_TYPE_VIDEO;
+} else if (es_type == STREAM_TYPE_VIDEO_VVC) {
+codec_id = AV_CODEC_ID_VVC;
+type = AVMEDIA_TYPE_VIDEO;
 } else if (es_type == STREAM_TYPE_AUDIO_AC3) {
 codec_id = AV_CODEC_ID_AC3;
 type = AVMEDIA_TYPE_AUDIO;
diff --git a/libavformat/mpeg.h b/libavformat/mpeg.h
index b635295776..20592eb184 100644
--- a/libavformat/mpeg.h
+++ b/libavformat/mpeg.h
@@ -56,6 +56,7 @@
 #define STREAM_TYPE_VIDEO_MPEG4 0x10
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 
 #define STREAM_TYPE_AUDIO_AC3   0x81
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index d97702fcd7..61a800c85f 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -811,6 +811,7 @@ static const StreamType ISO_types[] = {
 { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264   },
 { 0x21, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_JPEG2000   },
 { 0x24, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC   },
+{ 0x33, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC},
 { 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS   },
 { 0xd1, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_DIRAC  },
 { 0xd2, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_AVS2   },
@@ -865,6 +866,7 @@ static const StreamType REGD_types[] = {
 { MKTAG('D', 'T', 'S', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_DTS   },
 { MKTAG('E', 'A', 'C', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_EAC3  },
 { MKTAG('H', 'E', 'V', 'C'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC  },
+{ MKTAG('V', 'V', 'C', ' '), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC   },
 { MKTAG('K', 'L', 'V', 'A'), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_SMPTE_KLV },
 { MKTAG('I', 'D', '3', ' '), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_TIMED_ID3 },
 { MKTAG('V', 'C', '-', '1'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VC1   },
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index a48f14e768..14ae312c50 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -128,6 +128,7 @@
 #define STREAM_TYPE_METADATA0x15
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 #define STREAM_TYPE_VIDEO_AVS2  0xd2
 #define STREAM_TYPE_VIDEO_AVS3  0xd4
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 48d39e6a7d..85546f6a49 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -366,6 +366,9 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream 
*st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+stream_type = STREAM_TYPE_VIDEO_VVC;
+break;
 case AV_CODEC_ID_CAVS:
 stream_type = STREAM_TYPE_VIDEO_CAVS;
 break;
@@ -462,6 +465,11 @@ static int get_m2ts_stream_type(AVFormatContext *s, 
AVStream *st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+av_log(s, AV_LOG_ERROR,
+"MPEGTS VVC %s.\n", avcodec_get_name(st->codecpar->codec_id));
+stream_type = STREAM_TYPE_VIDEO_VVC;
+break;
 case AV_CODEC_ID_PCM_BLURAY:
 stream_type = 0x80;
 break;
@@ -1783,6 +1791,21 @@ static int check_hevc_startcode(AVFormatContext *s, 
const AVStream *st, const AV
 return 0;
 }
 
+static int check_vvc_startcode(AVFormatContext *s, const AVStream *st, const 
AVPacket *pkt)
+{
+if (pkt->size < 5 || AV_RB32(pkt->data) != 0x001 && AV_RB24(pkt->data) 
!= 0x01) {
+if 

[FFmpeg-devel] [PATCH v5 07/10] avcodec: add external decoder libvvdec for H266/VVC

2023-01-03 Thread Thomas Siedel
Add external decoder VVdeC for H266/VVC decoding.
Register new decoder libvvdec.
Add vvc_parse_extradata to support parse/probe of vvcC stream input.
Add vvc_paramset that implements the parser of vvcC configuration boxes.
Add libvvdec to wrap the vvdec interface.
Enable decoder by adding --enable-libvvdec in configure step.
---
 configure|5 +
 libavcodec/Makefile  |1 +
 libavcodec/allcodecs.c   |1 +
 libavcodec/libvvdec.c|  548 
 libavcodec/vvc_paramset.c| 1005 ++
 libavcodec/vvc_paramset.h|  429 +
 libavcodec/vvc_parse_extradata.c |  249 
 libavcodec/vvc_parse_extradata.h |   36 ++
 8 files changed, 2274 insertions(+)
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/vvc_paramset.c
 create mode 100644 libavcodec/vvc_paramset.h
 create mode 100644 libavcodec/vvc_parse_extradata.c
 create mode 100644 libavcodec/vvc_parse_extradata.h

diff --git a/configure b/configure
index 776a972663..d62cd579b6 100755
--- a/configure
+++ b/configure
@@ -288,6 +288,7 @@ External library support:
   --enable-libvorbis   enable Vorbis en/decoding via libvorbis,
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
+  --enable-libvvdecenable VVC decoding via vvdec [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1861,6 +1862,7 @@ EXTERNAL_LIBRARY_LIST="
 libvmaf
 libvorbis
 libvpx
+libvvdec
 libwebp
 libxml2
 libzimg
@@ -3389,6 +3391,8 @@ libvpx_vp8_decoder_deps="libvpx"
 libvpx_vp8_encoder_deps="libvpx"
 libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
+libvvdec_decoder_deps="libvvdec"
+libvvdec_decoder_select="vvc_mp4toannexb_bsf"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6711,6 +6715,7 @@ enabled libvpx&& {
 die "libvpx enabled but no supported decoders found"
 fi
 }
+enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version
 
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 2dee099f25..79f363b129 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1114,6 +1114,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
+OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o vvc_parse_extradata.o 
vvc_paramset.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index b009848a44..b73939f6be 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -794,6 +794,7 @@ extern const FFCodec ff_libvpx_vp8_encoder;
 extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern FFCodec ff_libvpx_vp9_decoder;
+extern const FFCodec ff_libvvdec_decoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvdec.c b/libavcodec/libvvdec.c
new file mode 100644
index 00..bd16d15571
--- /dev/null
+++ b/libavcodec/libvvdec.c
@@ -0,0 +1,548 @@
+/*
+ * H.266 decoding using the VVdeC library
+ *
+ * Copyright (C) 2022, Thomas Siedel
+ *
+ * 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 "config_components.h"
+
+#include 
+
+#include "libavutil/common.h"
+#include "libavutil/avutil.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/opt.h"
+#include "libavutil/imgutils.h"
+#include 

[FFmpeg-devel] [PATCH v5 08/10] avcodec: add external encoder libvvenc for H266/VVC

2023-01-03 Thread Thomas Siedel
Add external encoder VVenC for H266/VVC encoding.
Register new encoder libvvenc.
Add libvvenc to wrap the vvenc interface.
libvvenc implements encoder option: preset,qp,period,subjopt,
vvenc-params,levelidc,tier.
Enable encoder by adding --enable-libvvenc in configure step.
---
 configure  |   5 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libvvenc.c  | 469 +
 4 files changed, 476 insertions(+)
 create mode 100644 libavcodec/libvvenc.c

diff --git a/configure b/configure
index d62cd579b6..c89c42241a 100755
--- a/configure
+++ b/configure
@@ -289,6 +289,7 @@ External library support:
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
   --enable-libvvdecenable VVC decoding via vvdec [no]
+  --enable-libvvencenable VVC encoding via vvenc [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1863,6 +1864,7 @@ EXTERNAL_LIBRARY_LIST="
 libvorbis
 libvpx
 libvvdec
+libvvenc
 libwebp
 libxml2
 libzimg
@@ -3393,6 +3395,8 @@ libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
 libvvdec_decoder_deps="libvvdec"
 libvvdec_decoder_select="vvc_mp4toannexb_bsf"
+libvvenc_encoder_deps="libvvenc"
+libvvenc_encoder_select="atsc_a53"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6716,6 +6720,7 @@ enabled libvpx&& {
 fi
 }
 enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version
+enabled libvvenc  && require_pkg_config libvvenc "libvvenc >= 1.6.1" 
"vvenc/vvenc.h" vvenc_get_version
 
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 79f363b129..4a40419656 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1115,6 +1115,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
 OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o vvc_parse_extradata.o 
vvc_paramset.o
+OBJS-$(CONFIG_LIBVVENC_ENCODER)   += libvvenc.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index b73939f6be..cc56ebe400 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -795,6 +795,7 @@ extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern FFCodec ff_libvpx_vp9_decoder;
 extern const FFCodec ff_libvvdec_decoder;
+extern const FFCodec ff_libvvenc_encoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvenc.c b/libavcodec/libvvenc.c
new file mode 100644
index 00..a503a6ff0d
--- /dev/null
+++ b/libavcodec/libvvenc.c
@@ -0,0 +1,469 @@
+/*
+ * H.266 encoding using the VVenC library
+ *
+ * Copyright (C) 2022, Thomas Siedel
+ *
+ * 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 "config_components.h"
+
+#include 
+#include 
+
+#include "avcodec.h"
+#include "codec_internal.h"
+#include "encode.h"
+#include "internal.h"
+#include "packet_internal.h"
+#include "profiles.h"
+
+#include "libavutil/avutil.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/opt.h"
+#include "libavutil/common.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/frame.h"
+#include "libavutil/log.h"
+
+typedef struct VVenCOptions {
+int preset; // preset 0: faster  4: slower
+int qp; // quantization parameter 0-63
+int subjectiveOptimization; // perceptually motivated QP adaptation, XPSNR 

[FFmpeg-devel] [PATCH v5 06/10] avformat: add muxer support for H266/VVC

2023-01-03 Thread Thomas Siedel
Add muxer for vvcc byte stream format.
Add AV_CODEC_ID_VVC to ff_mp4_obj_type.
Add AV_CODEC_ID_VVC to ISO Media codec (VvcConfigurationBox vvi1,
vvc1 defined in ISO/IEC 14496-15:2021).
Add VvcConfigurationBox vvcC which extends FullBox type in
ISO/IEC 14496-15:2021.
Add ff_vvc_muxer to RAW muxers.
---
 libavformat/Makefile |  7 ---
 libavformat/allformats.c |  1 +
 libavformat/isom.c   |  1 +
 libavformat/isom_tags.c  |  3 +++
 libavformat/mov.c|  6 ++
 libavformat/movenc.c | 41 +++-
 libavformat/rawenc.c | 23 ++
 7 files changed, 78 insertions(+), 4 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 00ab4ded89..9ee2526eef 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -336,7 +336,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER)  += matroskadec.o 
matroska.o  \
 oggparsevorbis.o vorbiscomment.o \
 qtpalette.o replaygain.o 
dovi_isom.o
 OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \
-av1.o avc.o hevc.o \
+av1.o avc.o hevc.o vvc.o\
 flacenc_header.o avlanguage.o \
 vorbiscomment.o wv.o dovi_isom.o
 OBJS-$(CONFIG_MCA_DEMUXER)   += mca.o
@@ -358,7 +358,7 @@ OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
 qtpalette.o replaygain.o 
dovi_isom.o
-OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vpcc.o 
\
+OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vvc.o 
vpcc.o \
 movenchint.o mov_chan.o rtp.o \
 movenccenc.o movenc_ttml.o 
rawutils.o \
 dovi_isom.o
@@ -508,7 +508,7 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o \
 rtpenc_vp8.o  \
 rtpenc_vp9.o\
 rtpenc_xiph.o \
-avc.o hevc.o
+avc.o hevc.o vvc.o
 OBJS-$(CONFIG_RTSP_DEMUXER)  += rtsp.o rtspdec.o httpauth.o \
 urldecode.o
 OBJS-$(CONFIG_RTSP_MUXER)+= rtsp.o rtspenc.o httpauth.o \
@@ -596,6 +596,7 @@ OBJS-$(CONFIG_VPK_DEMUXER)   += vpk.o
 OBJS-$(CONFIG_VPLAYER_DEMUXER)   += vplayerdec.o subtitles.o
 OBJS-$(CONFIG_VQF_DEMUXER)   += vqf.o
 OBJS-$(CONFIG_VVC_DEMUXER)   += vvcdec.o rawdec.o
+OBJS-$(CONFIG_VVC_MUXER) += rawenc.o
 OBJS-$(CONFIG_W64_DEMUXER)   += wavdec.o w64.o pcm.o
 OBJS-$(CONFIG_W64_MUXER) += wavenc.o w64.o
 OBJS-$(CONFIG_WAV_DEMUXER)   += wavdec.o pcm.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 5fce5b4774..9ca9e9e9eb 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -478,6 +478,7 @@ extern const AVInputFormat  ff_vpk_demuxer;
 extern const AVInputFormat  ff_vplayer_demuxer;
 extern const AVInputFormat  ff_vqf_demuxer;
 extern const AVInputFormat  ff_vvc_demuxer;
+extern const AVOutputFormat ff_vvc_muxer;
 extern const AVInputFormat  ff_w64_demuxer;
 extern const AVOutputFormat ff_w64_muxer;
 extern const AVInputFormat  ff_wav_demuxer;
diff --git a/libavformat/isom.c b/libavformat/isom.c
index 6d019881e5..9fbccd4437 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -36,6 +36,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
 { AV_CODEC_ID_MPEG4   , 0x20 },
 { AV_CODEC_ID_H264, 0x21 },
 { AV_CODEC_ID_HEVC, 0x23 },
+{ AV_CODEC_ID_VVC , 0x33 },
 { AV_CODEC_ID_AAC , 0x40 },
 { AV_CODEC_ID_MP4ALS  , 0x40 }, /* 14496-3 ALS */
 { AV_CODEC_ID_MPEG2VIDEO  , 0x61 }, /* MPEG-2 Main */
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index e2b80405cc..ec93bdc363 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -123,6 +123,9 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based Dolby 
Vision derived from hev1 */
  /* dvh1 is handled within 
mov.c */
 
+{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'i', '1') },  /* VVC/H.266 which 
indicates parameter sets may be in ES */
+{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'c', '1') },  /* VVC/H.266 which 
indicates parameter shall not be in ES */
+
 { AV_CODEC_ID_H264, 

[FFmpeg-devel] [PATCH v5 05/10] avformat: add demuxer and probe support for H266/VVC

2023-01-03 Thread Thomas Siedel
Add demuxer to probe raw vvc and parse vvcc byte stream format.

Co-authored-by: Nuo Mi 
---
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/demux.c  |   7 +-
 libavformat/vvc.c| 984 +++
 libavformat/vvc.h|  99 
 libavformat/vvcdec.c |  61 +++
 6 files changed, 1151 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/vvc.c
 create mode 100644 libavformat/vvc.h
 create mode 100644 libavformat/vvcdec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index d7f198bf39..00ab4ded89 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -595,6 +595,7 @@ OBJS-$(CONFIG_VOC_MUXER) += vocenc.o voc.o
 OBJS-$(CONFIG_VPK_DEMUXER)   += vpk.o
 OBJS-$(CONFIG_VPLAYER_DEMUXER)   += vplayerdec.o subtitles.o
 OBJS-$(CONFIG_VQF_DEMUXER)   += vqf.o
+OBJS-$(CONFIG_VVC_DEMUXER)   += vvcdec.o rawdec.o
 OBJS-$(CONFIG_W64_DEMUXER)   += wavdec.o w64.o pcm.o
 OBJS-$(CONFIG_W64_MUXER) += wavenc.o w64.o
 OBJS-$(CONFIG_WAV_DEMUXER)   += wavdec.o pcm.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 62262ae935..5fce5b4774 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -477,6 +477,7 @@ extern const AVOutputFormat ff_voc_muxer;
 extern const AVInputFormat  ff_vpk_demuxer;
 extern const AVInputFormat  ff_vplayer_demuxer;
 extern const AVInputFormat  ff_vqf_demuxer;
+extern const AVInputFormat  ff_vvc_demuxer;
 extern const AVInputFormat  ff_w64_demuxer;
 extern const AVOutputFormat ff_w64_muxer;
 extern const AVInputFormat  ff_wav_demuxer;
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 2dfd82a63c..8dbde23fcd 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -120,6 +120,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, 
AVStream *st,
 { "mp3",AV_CODEC_ID_MP3,  AVMEDIA_TYPE_AUDIO},
 { "mpegvideo",  AV_CODEC_ID_MPEG2VIDEO,   AVMEDIA_TYPE_VIDEO},
 { "truehd", AV_CODEC_ID_TRUEHD,   AVMEDIA_TYPE_AUDIO},
+{ "vvc",AV_CODEC_ID_VVC,  AVMEDIA_TYPE_VIDEO},
 { 0 }
 };
 int score;
@@ -743,7 +744,8 @@ static int64_t select_from_pts_buffer(AVStream *st, int64_t 
*pts_buffer, int64_t
 {
 FFStream *const sti = ffstream(st);
 int onein_oneout = st->codecpar->codec_id != AV_CODEC_ID_H264 &&
-   st->codecpar->codec_id != AV_CODEC_ID_HEVC;
+   st->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+   st->codecpar->codec_id != AV_CODEC_ID_VVC;
 
 if (!onein_oneout) {
 int delay = sti->avctx->has_b_frames;
@@ -933,7 +935,8 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream 
*st,
 int64_t offset;
 AVRational duration;
 int onein_oneout = st->codecpar->codec_id != AV_CODEC_ID_H264 &&
-   st->codecpar->codec_id != AV_CODEC_ID_HEVC;
+   st->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+   st->codecpar->codec_id != AV_CODEC_ID_VVC;
 
 if (s->flags & AVFMT_FLAG_NOFILLIN)
 return;
diff --git a/libavformat/vvc.c b/libavformat/vvc.c
new file mode 100644
index 00..ce112705c3
--- /dev/null
+++ b/libavformat/vvc.c
@@ -0,0 +1,984 @@
+/*
+ * VVC helper functions for muxers
+ *
+ * Copyright (C) 2022, Thomas Siedel
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/get_bits.h"
+#include "libavcodec/golomb.h"
+#include "libavcodec/vvc.h"
+#include "libavutil/intreadwrite.h"
+#include "avc.h"
+#include "avio.h"
+#include "avio_internal.h"
+#include "vvc.h"
+
+typedef struct VVCCNALUnitArray {
+uint8_t array_completeness;
+uint8_t NAL_unit_type;
+uint16_t num_nalus;
+uint16_t *nal_unit_length;
+uint8_t **nal_unit;
+} VVCCNALUnitArray;
+
+typedef struct VVCPTLRecord {
+uint8_t num_bytes_constraint_info;
+uint8_t general_profile_idc;
+uint8_t general_tier_flag;
+uint8_t general_level_idc;
+uint8_t ptl_frame_only_constraint_flag;
+uint8_t ptl_multilayer_enabled_flag;
+uint8_t general_constraint_info[9];
+uint8_t 

[FFmpeg-devel] [PATCH v5 10/10] avcodec: increase minor version for H266/VVC

2023-01-03 Thread Thomas Siedel
Increase avcodec minor version for vvc support.
---
 libavcodec/version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/version.h b/libavcodec/version.h
index 6b8a1dbb79..dfd3d5d7e5 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  56
+#define LIBAVCODEC_VERSION_MINOR  57
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
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] [PATCH v5 04/10] avcodec: add MP4 to annexb support for H266/VVC

2023-01-03 Thread Thomas Siedel
Add parser for VVC MP4 to Annex B byte stream format.

Co-authored-by: Nuo Mi 
---
 configure|   1 +
 libavcodec/Makefile  |   2 +
 libavcodec/bitstream_filters.c   |   2 +
 libavcodec/h266_metadata_bsf.c   | 146 ++
 libavcodec/vvc_mp4toannexb_bsf.c | 329 +++
 5 files changed, 480 insertions(+)
 create mode 100644 libavcodec/h266_metadata_bsf.c
 create mode 100644 libavcodec/vvc_mp4toannexb_bsf.c

diff --git a/configure b/configure
index 2408dca0f5..776a972663 100755
--- a/configure
+++ b/configure
@@ -3286,6 +3286,7 @@ mjpeg2jpeg_bsf_select="jpegtables"
 mpeg2_metadata_bsf_select="cbs_mpeg2"
 trace_headers_bsf_select="cbs"
 vp9_metadata_bsf_select="cbs_vp9"
+vvc_metadata_bsf_select="cbs_h266"
 
 # external libraries
 aac_at_decoder_deps="audiotoolbox"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3e858b200b..2dee099f25 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1236,6 +1236,8 @@ OBJS-$(CONFIG_VP9_METADATA_BSF)   += 
vp9_metadata_bsf.o
 OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)+= vp9_raw_reorder_bsf.o
 OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o
 OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF)   += vp9_superframe_split_bsf.o
+OBJS-$(CONFIG_VVC_METADATA_BSF)   += h266_metadata_bsf.o
+OBJS-$(CONFIG_VVC_MP4TOANNEXB_BSF)+= vvc_mp4toannexb_bsf.o
 
 # thread libraries
 OBJS-$(HAVE_LIBC_MSVCRT)   += file_open.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index a3bebefe5f..403884f3d7 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -64,6 +64,8 @@ extern const FFBitStreamFilter ff_vp9_metadata_bsf;
 extern const FFBitStreamFilter ff_vp9_raw_reorder_bsf;
 extern const FFBitStreamFilter ff_vp9_superframe_bsf;
 extern const FFBitStreamFilter ff_vp9_superframe_split_bsf;
+extern const FFBitStreamFilter ff_vvc_mp4toannexb_bsf;
+extern const FFBitStreamFilter ff_vvc_metadata_bsf;
 
 #include "libavcodec/bsf_list.c"
 
diff --git a/libavcodec/h266_metadata_bsf.c b/libavcodec/h266_metadata_bsf.c
new file mode 100644
index 00..f2bd2f31f3
--- /dev/null
+++ b/libavcodec/h266_metadata_bsf.c
@@ -0,0 +1,146 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "cbs.h"
+#include "cbs_bsf.h"
+#include "cbs_h266.h"
+#include "vvc.h"
+
+#define IS_SLICE(nut) (nut <= VVC_RASL_NUT || (nut >= VVC_IDR_W_RADL && nut <= 
VVC_GDR_NUT))
+#define IS_PH(nut) (nut == VVC_PH_NUT)
+
+typedef struct VVCMetadataContext {
+CBSBSFContext common;
+
+H266RawAUD aud_nal;
+
+int aud;
+} VVCMetadataContext;
+
+static int h266_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
+ CodedBitstreamFragment *pu)
+{
+VVCMetadataContext *ctx = bsf->priv_data;
+int err, i;
+
+// If an AUD is present, it must be the first NAL unit.
+if (pu->units[0].type == VVC_AUD_NUT) {
+if (ctx->aud == BSF_ELEMENT_REMOVE)
+ff_cbs_delete_unit(pu, 0);
+} else {
+if (ctx->aud == BSF_ELEMENT_INSERT) {
+const H266RawSlice *first_slice = NULL;
+const H266RawPH *ph = NULL;
+H266RawAUD *aud = >aud_nal;
+int pic_type = 0, temporal_id = 8, layer_id = 0;
+for (i = 0; i < pu->nb_units; i++) {
+const H266RawNALUnitHeader *nal = pu->units[i].content;
+if (!nal)
+continue;
+if (nal->nuh_temporal_id_plus1 < temporal_id + 1)
+temporal_id = nal->nuh_temporal_id_plus1 - 1;
+if (IS_PH(nal->nal_unit_type)) {
+ph = pu->units[i].content;
+} else if (IS_SLICE(nal->nal_unit_type)) {
+const H266RawSlice *slice = pu->units[i].content;
+layer_id = nal->nuh_layer_id;
+if (slice->header.sh_slice_type == VVC_SLICE_TYPE_B &&
+pic_type < 2)
+pic_type = 2;
+if (slice->header.sh_slice_type == VVC_SLICE_TYPE_P &&
+ 

[FFmpeg-devel] [PATCH v5 03/10] avcodec: add bitstream parser for H266/VVC

2023-01-03 Thread Thomas Siedel
From: Nuo Mi 

Add nal parser ff_vvc_parser to parse vvc elementary bitstreams.

Co-authored-by: Thomas Siedel 
---
 configure|   1 +
 libavcodec/Makefile  |   2 +
 libavcodec/h2645_parse.c |  71 -
 libavcodec/parsers.c |   1 +
 libavcodec/vvc_parser.c  | 603 +++
 5 files changed, 677 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/vvc_parser.c

diff --git a/configure b/configure
index 3cb2936901..2408dca0f5 100755
--- a/configure
+++ b/configure
@@ -3268,6 +3268,7 @@ hevc_parser_select="hevcparse hevc_sei"
 mpegaudio_parser_select="mpegaudioheader"
 mpeg4video_parser_select="h263dsp mpegvideodec qpeldsp"
 vc1_parser_select="vc1dsp"
+vvc_parser_select="cbs_h266"
 
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header mpeg4audio"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3ab448dd49..3e858b200b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -76,6 +76,7 @@ OBJS-$(CONFIG_CBS) += cbs.o cbs_bsf.o
 OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
 OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H266)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o
 OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
 OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
@@ -1184,6 +1185,7 @@ OBJS-$(CONFIG_VC1_PARSER)  += vc1_parser.o 
vc1.o vc1data.o  \
 OBJS-$(CONFIG_VP3_PARSER)  += vp3_parser.o
 OBJS-$(CONFIG_VP8_PARSER)  += vp8_parser.o
 OBJS-$(CONFIG_VP9_PARSER)  += vp9_parser.o
+OBJS-$(CONFIG_VVC_PARSER)  += vvc_parser.o
 OBJS-$(CONFIG_WEBP_PARSER) += webp_parser.o
 OBJS-$(CONFIG_XBM_PARSER)  += xbm_parser.o
 OBJS-$(CONFIG_XMA_PARSER)  += xma_parser.o
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 90944177c7..9fbeee3edd 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -27,6 +27,7 @@
 #include "libavutil/mem.h"
 
 #include "bytestream.h"
+#include "vvc.h"
 #include "hevc.h"
 #include "h264.h"
 #include "h2645_parse.h"
@@ -145,6 +146,47 @@ nsc:
 return si;
 }
 
+static const char *const vvc_nal_type_name[32] = {
+"TRAIL_NUT", // VVC_TRAIL_NUT
+"STSA_NUT", // VVC_STSA_NUT
+"RADL_NUT", // VVC_RADL_NUT
+"RASL_NUT", // VVC_RASL_NUT
+"RSV_VCL_4", // VVC_RSV_VCL_4
+"RSV_VCL_5", // VVC_RSV_VCL_5
+"RSV_VCL_6", // VVC_RSV_VCL_6
+"IDR_W_RADL", // VVC_IDR_W_RADL
+"IDR_N_LP", // VVC_IDR_N_LP
+"CRA_NUT", // VVC_CRA_NUT
+"GDR_NUT", // VVC_GDR_NUT
+"RSV_IRAP_11", // VVC_RSV_IRAP_11
+"OPI_NUT", // VVC_OPI_NUT
+"DCI_NUT", // VVC_DCI_NUT
+"VPS_NUT", // VVC_VPS_NUT
+"SPS_NUT", // VVC_SPS_NUT
+"PPS_NUT", // VVC_PPS_NUT
+"PREFIX_APS_NUT",// VVC_PREFIX_APS_NUT
+"SUFFIX_APS_NUT",// VVC_SUFFIX_APS_NUT
+"PH_NUT", // VVC_PH_NUT
+"AUD_NUT", // VVC_AUD_NUT
+"EOS_NUT", // VVC_EOS_NUT
+"EOB_NUT", // VVC_EOB_NUT
+"PREFIX_SEI_NUT",// VVC_PREFIX_SEI_NUT
+"SUFFIX_SEI_NUT",// VVC_SUFFIX_SEI_NUT
+"FD_NUT", // VVC_FD_NUT
+"RSV_NVCL_26", // VVC_RSV_NVCL_26
+"RSV_NVCL_27", // VVC_RSV_NVCL_27
+"UNSPEC_28", // VVC_UNSPEC_28
+"UNSPEC_29", // VVC_UNSPEC_29
+"UNSPEC_30", // VVC_UNSPEC_30
+"UNSPEC_31", // VVC_UNSPEC_31
+};
+
+static const char *vvc_nal_unit_name(int nal_type)
+{
+av_assert0(nal_type >= 0 && nal_type < 32);
+return vvc_nal_type_name[nal_type];
+}
+
 static const char *const hevc_nal_type_name[64] = {
 "TRAIL_N", // HEVC_NAL_TRAIL_N
 "TRAIL_R", // HEVC_NAL_TRAIL_R
@@ -293,6 +335,31 @@ static int get_bit_length(H2645NAL *nal, int min_size, int 
skip_trailing_zeros)
  * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit,
  * 0 otherwise
  */
+static int vvc_parse_nal_header(H2645NAL *nal, void *logctx)
+{
+GetBitContext *gb = >gb;
+
+if (get_bits1(gb) != 0) //forbidden_zero_bit
+return AVERROR_INVALIDDATA;
+
+skip_bits1(gb); //nuh_reserved_zero_bit
+
+nal->nuh_layer_id = get_bits(gb, 6);
+nal->type = get_bits(gb, 5);
+nal->temporal_id = get_bits(gb, 3) - 1;
+if (nal->temporal_id < 0)
+return AVERROR_INVALIDDATA;
+
+if ((nal->type >= VVC_IDR_W_RADL && nal->type <= VVC_RSV_IRAP_11) && 
nal->temporal_id)
+return AVERROR_INVALIDDATA;
+
+av_log(logctx, AV_LOG_DEBUG,
+  "nal_unit_type: %d(%s), nuh_layer_id: %d, temporal_id: %d\n",
+   nal->type, vvc_nal_unit_name(nal->type), nal->nuh_layer_id, 
nal->temporal_id);
+
+return 0;
+}
+
 static int hevc_parse_nal_header(H2645NAL *nal, void *logctx)
 {
 GetBitContext *gb = >gb;
@@ -509,7 +576,9 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t 
*buf, int length,
 /* Reset type in case 

[FFmpeg-devel] [PATCH v5 01/10] avcodec: add enum types for H266/VVC

2023-01-03 Thread Thomas Siedel
From: Nuo Mi 

Add types as nal unit types, slice types and vvc typedefs needed
for parsing vvc high-level syntax.
---
 libavcodec/vvc.h | 142 +++
 1 file changed, 142 insertions(+)
 create mode 100644 libavcodec/vvc.h

diff --git a/libavcodec/vvc.h b/libavcodec/vvc.h
new file mode 100644
index 00..586934a7bf
--- /dev/null
+++ b/libavcodec/vvc.h
@@ -0,0 +1,142 @@
+/*
+ * VVC shared code
+ *
+ * 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_VVC_H
+#define AVCODEC_VVC_H
+
+/**
+ * Table 5 – NAL unit type codes and NAL unit type classes
+ * in T-REC-H.266-202008
+ */
+enum VVCNALUnitType {
+VVC_TRAIL_NUT  = 0,
+VVC_STSA_NUT   = 1,
+VVC_RADL_NUT   = 2,
+VVC_RASL_NUT   = 3,
+VVC_RSV_VCL_4  = 4,
+VVC_RSV_VCL_5  = 5,
+VVC_RSV_VCL_6  = 6,
+VVC_IDR_W_RADL = 7,
+VVC_IDR_N_LP   = 8,
+VVC_CRA_NUT= 9,
+VVC_GDR_NUT= 10,
+VVC_RSV_IRAP_11= 11,
+VVC_OPI_NUT= 12,
+VVC_DCI_NUT= 13,
+VVC_VPS_NUT= 14,
+VVC_SPS_NUT= 15,
+VVC_PPS_NUT= 16,
+VVC_PREFIX_APS_NUT = 17,
+VVC_SUFFIX_APS_NUT = 18,
+VVC_PH_NUT = 19,
+VVC_AUD_NUT= 20,
+VVC_EOS_NUT= 21,
+VVC_EOB_NUT= 22,
+VVC_PREFIX_SEI_NUT = 23,
+VVC_SUFFIX_SEI_NUT = 24,
+VVC_FD_NUT = 25,
+VVC_RSV_NVCL_26= 26,
+VVC_RSV_NVCL_27= 27,
+VVC_UNSPEC_28  = 28,
+VVC_UNSPEC_29  = 29,
+VVC_UNSPEC_30  = 30,
+VVC_UNSPEC_31  = 31,
+};
+
+enum VVCSliceType {
+VVC_SLICE_TYPE_B = 0,
+VVC_SLICE_TYPE_P = 1,
+VVC_SLICE_TYPE_I = 2,
+};
+
+enum {
+//6.2 we can have 3 sample arrays
+VVC_MAX_SAMPLE_ARRAYS = 3,
+
+//7.4.3.3 vps_max_layers_minus1 is u(6)
+VVC_MAX_LAYERS = 64,
+
+//7.4.3.3 The value of vps_max_sublayers_minus1 shall be in the range of 0 
to 6, inclusive
+VVC_MAX_SUBLAYERS = 7,
+
+//7.4.3.3 vps_num_ptls_minus1 is u(8)
+VVC_MAX_PTLS = 256,
+
+//7.4.3.3 vps_num_output_layer_sets_minus2 is u(8)
+VVC_MAX_TOTAL_NUM_OLSS = 257,
+
+// 7.3.2.3: vps_video_parameter_set_id is u(4).
+VVC_MAX_VPS_COUNT = 16,
+// 7.3.2.4: sps_seq_parameter_set_id is u(4)
+VVC_MAX_SPS_COUNT = 16,
+// 7.3.2.5: pps_pic_parameter_set_id is u(6)
+VVC_MAX_PPS_COUNT = 64,
+
+// 7.4.4.1: ptl_num_sub_profiles is u(8)
+VVC_MAX_SUB_PROFILES = 256,
+
+// A.4.2: according to (1577), MaxDpbSize is bounded above by 2 * 
maxDpbPicBuf(8)
+VVC_MAX_DPB_SIZE = 16,
+
+//7.4.3.4 sps_num_ref_pic_lists in range [0, 64]
+VVC_MAX_REF_PIC_LISTS = 64,
+
+//7.4.11 num_ref_entries in range [0, MaxDpbSize + 13]
+VVC_MAX_REF_ENTRIES = VVC_MAX_DPB_SIZE + 13,
+
+//7.4.3.3 sps_num_points_in_qp_table_minus1[i] in range [0, 36 − 
sps_qp_table_start_minus26[i]],
+//sps_qp_table_start_minus26[i] in range [sps_qp_table_start_minus26[i] 
−26 − QpBdOffset, 36]
+//for 10 bitsQpBdOffset is 12, so sps_num_points_in_qp_table_minus1[i] in 
range [0, 74]
+VVC_MAX_POINTS_IN_QP_TABLE = 75,
+
+// 7.4.6.1: hrd_cpb_cnt_minus1 is in [0, 31].
+VVC_MAX_CPB_CNT = 32,
+
+// A.4.1: the highest level allows a MaxLumaPs of 35 651 584.
+VVC_MAX_LUMA_PS = 35651584,
+
+// A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are
+// constrained to be not greater than sqrt(MaxLumaPs * 8).  Hence height/
+// width are bounded above by sqrt(8 * 35651584) = 16888.2 samples.
+VVC_MAX_WIDTH  = 16888,
+VVC_MAX_HEIGHT = 16888,
+
+// A.4.1: table A.1 allows at most 440 tiles per au for any level.
+VVC_MAX_TILES_PER_AU = 440,
+// A.4.1: table A.1 did not define max tile rows.
+// in worest a case, we can have 1x440 tiles picture.
+VVC_MAX_TILE_ROWS= VVC_MAX_TILES_PER_AU,
+// A.4.1: table A.1 allows at most 20 tile columns for any level.
+VVC_MAX_TILE_COLUMNS = 20,
+
+// A.4.1 table A.1 allows at most 600 slice for any level.
+VVC_MAX_SLICES = 600,
+
+// 7.4.8: in the worst case (!pps_no_pic_partition_flag and
+// sps_entropy_coding_sync_enabled_flag are both true), entry points can be
+// placed at the beginning of 

[FFmpeg-devel] [PATCH v5 00/10] Add support for H266/VVC

2023-01-03 Thread Thomas Siedel
This patch set adds H266/VVC support.
This includes parsing, muxing, demuxing, decoding and encoding.
Decoding is done using the external library VVdeC
(https://github.com/fraunhoferhhi/vvdec.git) and can be enabled with
--enable-libvvdec.
Encoding is done using the external library VVenC
(https://github.com/fraunhoferhhi/vvenc.git) and can be enabled with
--enable-libvvenc.

Changes since v4:

General:
- Add original author to patches 01-03
- Add co-author to patches 04 and 05

PATCH 02/10 configure / cbs_h266_syntax_template
- bugfix: add cbs_h266, cbs_h266_select (moved from patch 03/10)
- bugfix: parsing multilayer in cbs_h265_syntax_template

PATCH 03/10 libavcodec/vvc_parser.c
- bugfix: check startcode length (3 or 4 byte) to 
  find correct frame end position

PATCH 06/10 libavformat/movenc.c
- merge movenc.c with upstream

PATCH 07/10 libavcodec/libvvdec.c
- bugfix: set correct avframe pts for decoded picture
- bugfix: print additional info if decoding fails

Nuo Mi (3):
  avcodec: add enum types for H266/VVC
  avcodec: add cbs for H266/VVC
  avcodec: add bitstream parser for H266/VVC

Thomas Siedel (7):
  avcodec: add MP4 to annexb support for H266/VVC
  avformat: add demuxer and probe support for H266/VVC
  avformat: add muxer support for H266/VVC
  avcodec: add external decoder libvvdec for H266/VVC
  avcodec: add external encoder libvvenc for H266/VVC
  avformat: add ts stream types for H266/VVC
  avcodec: increase minor version for H266/VVC

 configure |   16 +-
 libavcodec/Makefile   |6 +
 libavcodec/allcodecs.c|2 +
 libavcodec/bitstream_filters.c|2 +
 libavcodec/cbs.c  |6 +
 libavcodec/cbs_h2645.c|  373 ++-
 libavcodec/cbs_h266.h |  791 +++
 libavcodec/cbs_h266_syntax_template.c | 3096 +
 libavcodec/cbs_internal.h |1 +
 libavcodec/cbs_sei.c  |   29 +
 libavcodec/h2645_parse.c  |   71 +-
 libavcodec/h266_metadata_bsf.c|  146 ++
 libavcodec/libvvdec.c |  548 +
 libavcodec/libvvenc.c |  469 
 libavcodec/parsers.c  |1 +
 libavcodec/version.h  |2 +-
 libavcodec/vvc.h  |  142 ++
 libavcodec/vvc_mp4toannexb_bsf.c  |  329 +++
 libavcodec/vvc_paramset.c | 1005 
 libavcodec/vvc_paramset.h |  429 
 libavcodec/vvc_parse_extradata.c  |  249 ++
 libavcodec/vvc_parse_extradata.h  |   36 +
 libavcodec/vvc_parser.c   |  603 +
 libavformat/Makefile  |8 +-
 libavformat/allformats.c  |2 +
 libavformat/demux.c   |7 +-
 libavformat/isom.c|1 +
 libavformat/isom_tags.c   |3 +
 libavformat/mov.c |6 +
 libavformat/movenc.c  |   41 +-
 libavformat/mpeg.c|3 +
 libavformat/mpeg.h|1 +
 libavformat/mpegts.c  |2 +
 libavformat/mpegts.h  |1 +
 libavformat/mpegtsenc.c   |   65 +
 libavformat/rawenc.c  |   23 +
 libavformat/vvc.c |  984 
 libavformat/vvc.h |   99 +
 libavformat/vvcdec.c  |   61 +
 39 files changed, 9648 insertions(+), 11 deletions(-)
 create mode 100644 libavcodec/cbs_h266.h
 create mode 100644 libavcodec/cbs_h266_syntax_template.c
 create mode 100644 libavcodec/h266_metadata_bsf.c
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/libvvenc.c
 create mode 100644 libavcodec/vvc.h
 create mode 100644 libavcodec/vvc_mp4toannexb_bsf.c
 create mode 100644 libavcodec/vvc_paramset.c
 create mode 100644 libavcodec/vvc_paramset.h
 create mode 100644 libavcodec/vvc_parse_extradata.c
 create mode 100644 libavcodec/vvc_parse_extradata.h
 create mode 100644 libavcodec/vvc_parser.c
 create mode 100644 libavformat/vvc.c
 create mode 100644 libavformat/vvc.h
 create mode 100644 libavformat/vvcdec.c

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


Re: [FFmpeg-devel] [PATCH v2 09/13] lavc/vaapi_hevc: Add vaapi profile parse support for SCC

2023-01-03 Thread Wang, Fei W
On Tue, 2023-01-03 at 07:08 +, Xiang, Haihao wrote:
> On Ma, 2022-12-05 at 14:09 +0800, Fei Wang wrote:
> > From: Linjie Fu 
> > 
> > Note that Screen-Extended Main 4:4:4 and 4:4:4 10 supports
> > chroma_format_idc from 0, 1 or 3, hence both 420 and 444 are
> > supported.
> > 
> > Signed-off-by: Linjie Fu 
> > Signed-off-by: Fei Wang 
> > ---
> >  libavcodec/vaapi_decode.c |  4 +++-
> >  libavcodec/vaapi_hevc.c   | 14 --
> >  libavcodec/vaapi_hevc.h   |  2 +-
> >  3 files changed, 16 insertions(+), 4 deletions(-)
> > 
> > diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
> > index 134f10eca5..29ac439b36 100644
> > --- a/libavcodec/vaapi_decode.c
> > +++ b/libavcodec/vaapi_decode.c
> > @@ -410,7 +410,9 @@ static const struct {
> >  #endif
> >  #if VA_CHECK_VERSION(1, 2, 0) && CONFIG_HEVC_VAAPI_HWACCEL
> >  MAP(HEVC,HEVC_REXT,   None,
> > - ff_vaapi_parse_hevc_rext_profile ),
> > + ff_vaapi_parse_hevc_profile ),
> > +MAP(HEVC,HEVC_SCC,None,
> > + ff_vaapi_parse_hevc_profile ),
> >  #endif
> >  MAP(MJPEG,   MJPEG_HUFFMAN_BASELINE_DCT,
> >JPEGBaseline),
> > diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
> > index 750738d36e..6ce1e17fa8 100644
> > --- a/libavcodec/vaapi_hevc.c
> > +++ b/libavcodec/vaapi_hevc.c
> > @@ -586,9 +586,9 @@ static int ptl_convert(const PTLCommon
> > *general_ptl,
> > H265RawProfileTierLevel *h2
> >  }
> >  
> >  /*
> > - * Find exact va_profile for HEVC Range Extension
> > + * Find exact va_profile for HEVC Range Extension and Screen
> > Content Coding
> > Extension
> >   */
> > -VAProfile ff_vaapi_parse_hevc_rext_profile(AVCodecContext *avctx)
> > +VAProfile ff_vaapi_parse_hevc_profile(AVCodecContext *avctx)
> 
> It sounds to me the new function is for all hevc profiles, how about
> to use
> ff_vaapi_parse_hevc_rext_scc_profile instead ? 

Fixed in V3. Thanks.

Fei

> 
> Thanks
> Haihao
> 
> 
> > @@ -627,6 +627,16 @@ VAProfile
> > ff_vaapi_parse_hevc_rext_profile(AVCodecContext
> > *avctx)
> >  else if (!strcmp(profile->name, "Main 4:4:4 12") ||
> >   !strcmp(profile->name, "Main 4:4:4 12 Intra"))
> >  return VAProfileHEVCMain444_12;
> > +else if (!strcmp(profile->name, "Screen-Extended Main"))
> > +return VAProfileHEVCSccMain;
> > +else if (!strcmp(profile->name, "Screen-Extended Main 10"))
> > +return VAProfileHEVCSccMain10;
> > +else if (!strcmp(profile->name, "Screen-Extended Main 4:4:4"))
> > +return VAProfileHEVCSccMain444;
> > +#if VA_CHECK_VERSION(1, 8, 0)
> > +else if (!strcmp(profile->name, "Screen-Extended Main 4:4:4
> > 10"))
> > +return VAProfileHEVCSccMain444_10;
> > +#endif
> >  #else
> >  av_log(avctx, AV_LOG_WARNING, "HEVC profile %s is "
> > "not supported with this VA version.\n", profile-
> > >name);
> > diff --git a/libavcodec/vaapi_hevc.h b/libavcodec/vaapi_hevc.h
> > index b3b0e6fc1e..7662dca510 100644
> > --- a/libavcodec/vaapi_hevc.h
> > +++ b/libavcodec/vaapi_hevc.h
> > @@ -22,6 +22,6 @@
> >  #include 
> >  #include "avcodec.h"
> >  
> > -VAProfile ff_vaapi_parse_hevc_rext_profile(AVCodecContext *avctx);
> > +VAProfile ff_vaapi_parse_hevc_profile(AVCodecContext *avctx);
> >  
> >  #endif /* AVCODEC_VAAPI_HEVC_H */
___
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 v3 08/11] lavc/vaapi_hevc: Pass SCC parameters Through VA-API

2023-01-03 Thread Fei Wang
From: Linjie Fu 

Including sps/pps/slice parameters.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_hevc.c | 52 +
 1 file changed, 47 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 20fb36adfa..73a8f5b4ce 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -124,7 +124,7 @@ static int vaapi_hevc_start_frame(AVCodecContext  
*avctx,
 const HEVCPPS  *pps = h->ps.pps;
 
 const ScalingList *scaling_list = NULL;
-int pic_param_size, err, i;
+int pic_param_size, num_comps, pre_palette_size, err, i;
 
 VAPictureParameterBufferHEVC *pic_param = (VAPictureParameterBufferHEVC 
*)>pic_param;
 
@@ -245,8 +245,46 @@ static int vaapi_hevc_start_frame(AVCodecContext  
*avctx,
 for (i = 0; i < 6; i++)
 pic->pic_param.rext.cr_qp_offset_list[i]= 
pps->cr_qp_offset_list[i];
 }
+
+pre_palette_size = pps->pps_palette_predictor_initializers_present_flag ?
+   pps->pps_num_palette_predictor_initializers :
+   (sps->sps_palette_predictor_initializers_present_flag ?
+   sps->sps_num_palette_predictor_initializers_minus1 + 1 :
+   0);
+
+if (avctx->profile == FF_PROFILE_HEVC_SCC) {
+pic->pic_param.scc = (VAPictureParameterBufferHEVCScc) {
+.screen_content_pic_fields.bits = {
+.pps_curr_pic_ref_enabled_flag  = 
pps->pps_curr_pic_ref_enabled_flag,
+.palette_mode_enabled_flag  = 
sps->palette_mode_enabled_flag,
+.motion_vector_resolution_control_idc   = 
sps->motion_vector_resolution_control_idc,
+.intra_boundary_filtering_disabled_flag = 
sps->intra_boundary_filtering_disabled_flag,
+.residual_adaptive_colour_transform_enabled_flag
+= 
pps->residual_adaptive_colour_transform_enabled_flag,
+.pps_slice_act_qp_offsets_present_flag  = 
pps->pps_slice_act_qp_offsets_present_flag,
+},
+.palette_max_size   = 
sps->palette_max_size,
+.delta_palette_max_predictor_size   = 
sps->delta_palette_max_predictor_size,
+.predictor_palette_size = pre_palette_size,
+.pps_act_y_qp_offset_plus5  = 
pps->residual_adaptive_colour_transform_enabled_flag ?
+  
pps->pps_act_y_qp_offset + 5 : 0,
+.pps_act_cb_qp_offset_plus5 = 
pps->residual_adaptive_colour_transform_enabled_flag ?
+  
pps->pps_act_cb_qp_offset + 5 : 0,
+.pps_act_cr_qp_offset_plus3 = 
pps->residual_adaptive_colour_transform_enabled_flag ?
+  
pps->pps_act_cr_qp_offset + 3 : 0,
+};
+
+num_comps = pps->monochrome_palette_flag ? 1 : 3;
+for (int comp = 0; comp < num_comps; comp++)
+for (int j = 0; j < pre_palette_size; j++)
+pic->pic_param.scc.predictor_palette_entries[comp][j] =
+pps->pps_palette_predictor_initializers_present_flag ?
+pps->pps_palette_predictor_initializer[comp][j]:
+sps->sps_palette_predictor_initializer[comp][j];
+}
+
 #endif
-pic_param_size = avctx->profile == FF_PROFILE_HEVC_REXT ?
+pic_param_size = avctx->profile >= FF_PROFILE_HEVC_REXT ?
 sizeof(pic->pic_param) : 
sizeof(VAPictureParameterBufferHEVC);
 
 err = ff_vaapi_decode_make_param_buffer(avctx, >pic,
@@ -299,7 +337,7 @@ static int vaapi_hevc_end_frame(AVCodecContext *avctx)
 VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC 
*)>last_slice_param;
 int ret;
 
-int slice_param_size = avctx->profile == FF_PROFILE_HEVC_REXT ?
+int slice_param_size = avctx->profile >= FF_PROFILE_HEVC_REXT ?
 sizeof(pic->last_slice_param) : 
sizeof(VASliceParameterBufferHEVC);
 
 if (pic->last_size) {
@@ -413,7 +451,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
 VAAPIDecodePictureHEVC *pic = h->ref->hwaccel_picture_private;
 VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC 
*)>last_slice_param;
 
-int slice_param_size = avctx->profile == FF_PROFILE_HEVC_REXT ?
+int slice_param_size = avctx->profile >= FF_PROFILE_HEVC_REXT ?
 sizeof(pic->last_slice_param) : 
sizeof(VASliceParameterBufferHEVC);
 
 int nb_list = (sh->slice_type == HEVC_SLICE_B) ?
@@ -478,11 +516,15 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
 

[FFmpeg-devel] [PATCH v3 11/11] lavc/vaapi_hevc: Loose the restricts for SCC decoding

2023-01-03 Thread Fei Wang
From: Linjie Fu 

Allow current picture as the reference picture.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_hevc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 29c75e88f0..42e1b62fc3 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -104,7 +104,8 @@ static void fill_vaapi_reference_frames(const HEVCContext 
*h, VAPictureParameter
 const HEVCFrame *frame = NULL;
 
 while (!frame && j < FF_ARRAY_ELEMS(h->DPB)) {
-if (>DPB[j] != current_picture && (h->DPB[j].flags & 
(HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF)))
+if ((>DPB[j] != current_picture || 
h->ps.pps->pps_curr_pic_ref_enabled_flag) &&
+(h->DPB[j].flags & (HEVC_FRAME_FLAG_LONG_REF | 
HEVC_FRAME_FLAG_SHORT_REF)))
 frame = >DPB[j];
 j++;
 }
@@ -222,7 +223,8 @@ static int vaapi_hevc_start_frame(AVCodecContext  
*avctx,
 }
 
 #if VA_CHECK_VERSION(1, 2, 0)
-if (avctx->profile == FF_PROFILE_HEVC_REXT) {
+if (avctx->profile == FF_PROFILE_HEVC_REXT ||
+avctx->profile == FF_PROFILE_HEVC_SCC) {
 pic->pic_param.rext = (VAPictureParameterBufferHEVCRext) {
 .range_extension_pic_fields.bits  = {
 .transform_skip_rotation_enabled_flag   = 
sps->transform_skip_rotation_enabled_flag,
-- 
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] [PATCH v3 07/11] lavc/hevc: Update reference list for SCC

2023-01-03 Thread Fei Wang
From: Linjie Fu 

Screen Content Coding allows non-intra slice in an IRAP frame which can
reference the frame itself, and would mark the current decoded picture
as "used for long-term reference", no matter TwoVersionsOfCurrDecPicFlag(8.1.3),
hence some previous restricts are not suitable any more.

Constructe RefPicListTemp and RefPicList according to 8-8/9/10. Disable
slice decoding for SCC profile to avoid unexpected error in hevc native
decoder and patch welcome.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/hevc_refs.c | 21 -
 libavcodec/hevcdec.c   | 10 +-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 811e8feff8..96153a2459 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -322,7 +322,7 @@ int ff_hevc_slice_rpl(HEVCContext *s)
 return ret;
 
 if (!(s->rps[ST_CURR_BEF].nb_refs + s->rps[ST_CURR_AFT].nb_refs +
-  s->rps[LT_CURR].nb_refs)) {
+  s->rps[LT_CURR].nb_refs) && 
!s->ps.pps->pps_curr_pic_ref_enabled_flag) {
 av_log(s->avctx, AV_LOG_ERROR, "Zero refs in the frame RPS.\n");
 return AVERROR_INVALIDDATA;
 }
@@ -349,6 +349,13 @@ int ff_hevc_slice_rpl(HEVCContext *s)
 rpl_tmp.nb_refs++;
 }
 }
+// Construct RefPicList0, RefPicList1 (8-8, 8-10)
+if (s->ps.pps->pps_curr_pic_ref_enabled_flag) {
+rpl_tmp.list[rpl_tmp.nb_refs]   = s->ref->poc;
+rpl_tmp.ref[rpl_tmp.nb_refs]= s->ref;
+rpl_tmp.isLongTerm[rpl_tmp.nb_refs] = 1;
+rpl_tmp.nb_refs++;
+}
 }
 
 /* reorder the references if necessary */
@@ -371,6 +378,14 @@ int ff_hevc_slice_rpl(HEVCContext *s)
 rpl->nb_refs = FFMIN(rpl->nb_refs, sh->nb_refs[list_idx]);
 }
 
+// 8-9
+if (s->ps.pps->pps_curr_pic_ref_enabled_flag &&
+!sh->rpl_modification_flag[list_idx] &&
+rpl_tmp.nb_refs > sh->nb_refs[L0]) {
+rpl->list[sh->nb_refs[L0] - 1] = s->ref->poc;
+rpl->ref[sh->nb_refs[L0] - 1]  = s->ref;
+}
+
 if (sh->collocated_list == list_idx &&
 sh->collocated_ref_idx < rpl->nb_refs)
 s->ref->collocated_ref = rpl->ref[sh->collocated_ref_idx];
@@ -541,5 +556,9 @@ int ff_hevc_frame_nb_refs(const HEVCContext *s)
 for (i = 0; i < long_rps->nb_refs; i++)
 ret += !!long_rps->used[i];
 }
+
+if (s->ps.pps->pps_curr_pic_ref_enabled_flag)
+ret++;
+
 return ret;
 }
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 52fa627133..121ceb4e75 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -668,7 +668,8 @@ static int hls_slice_header(HEVCContext *s)
sh->slice_type);
 return AVERROR_INVALIDDATA;
 }
-if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I) {
+if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I &&
+!s->ps.pps->pps_curr_pic_ref_enabled_flag) {
 av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n");
 return AVERROR_INVALIDDATA;
 }
@@ -3123,6 +3124,13 @@ static int decode_nal_unit(HEVCContext *s, const 
H2645NAL *nal)
 if (ret < 0)
 goto fail;
 } else {
+if (s->avctx->profile == FF_PROFILE_HEVC_SCC) {
+av_log(s->avctx, AV_LOG_ERROR,
+   "SCC profile is not yet implemented in hevc native 
decoder.\n");
+ret = AVERROR_PATCHWELCOME;
+goto fail;
+}
+
 if (s->threads_number > 1 && s->sh.num_entry_point_offsets > 0)
 ctb_addr_ts = hls_slice_data_wpp(s, nal);
 else
-- 
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] [PATCH v3 10/11] lavc/vaapi_hevc: Set correct rps type for scc

2023-01-03 Thread Fei Wang
From: Linjie Fu 

According to 8.1.3 and 8.3.2.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_hevc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index c10617a81a..29c75e88f0 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -71,6 +71,7 @@ static void fill_vaapi_pic(VAPictureHEVC *va_pic, const 
HEVCFrame *pic, int rps_
 static int find_frame_rps_type(const HEVCContext *h, const HEVCFrame *pic)
 {
 VASurfaceID pic_surf = ff_vaapi_get_surface_id(pic->frame);
+const HEVCFrame *current_picture = h->ref;
 int i;
 
 for (i = 0; i < h->rps[ST_CURR_BEF].nb_refs; i++) {
@@ -88,6 +89,9 @@ static int find_frame_rps_type(const HEVCContext *h, const 
HEVCFrame *pic)
 return VA_PICTURE_HEVC_RPS_LT_CURR;
 }
 
+if (h->ps.pps->pps_curr_pic_ref_enabled_flag && current_picture->poc == 
pic->poc)
+return VA_PICTURE_HEVC_LONG_TERM_REFERENCE;
+
 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] [PATCH v3 09/11] lavc/vaapi_hevc: Add vaapi profile parse support for SCC

2023-01-03 Thread Fei Wang
From: Linjie Fu 

Note that Screen-Extended Main 4:4:4 and 4:4:4 10 supports
chroma_format_idc from 0, 1 or 3, hence both 420 and 444 are
supported.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_decode.c |  4 +++-
 libavcodec/vaapi_hevc.c   | 14 --
 libavcodec/vaapi_hevc.h   |  2 +-
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 134f10eca5..ab8c12e364 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -410,7 +410,9 @@ static const struct {
 #endif
 #if VA_CHECK_VERSION(1, 2, 0) && CONFIG_HEVC_VAAPI_HWACCEL
 MAP(HEVC,HEVC_REXT,   None,
- ff_vaapi_parse_hevc_rext_profile ),
+ ff_vaapi_parse_hevc_rext_scc_profile ),
+MAP(HEVC,HEVC_SCC,None,
+ ff_vaapi_parse_hevc_rext_scc_profile ),
 #endif
 MAP(MJPEG,   MJPEG_HUFFMAN_BASELINE_DCT,
   JPEGBaseline),
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 73a8f5b4ce..c10617a81a 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -586,9 +586,9 @@ static int ptl_convert(const PTLCommon *general_ptl, 
H265RawProfileTierLevel *h2
 }
 
 /*
- * Find exact va_profile for HEVC Range Extension
+ * Find exact va_profile for HEVC Range Extension and Screen Content Coding 
Extension
  */
-VAProfile ff_vaapi_parse_hevc_rext_profile(AVCodecContext *avctx)
+VAProfile ff_vaapi_parse_hevc_rext_scc_profile(AVCodecContext *avctx)
 {
 const HEVCContext *h = avctx->priv_data;
 const HEVCSPS *sps = h->ps.sps;
@@ -627,6 +627,16 @@ VAProfile ff_vaapi_parse_hevc_rext_profile(AVCodecContext 
*avctx)
 else if (!strcmp(profile->name, "Main 4:4:4 12") ||
  !strcmp(profile->name, "Main 4:4:4 12 Intra"))
 return VAProfileHEVCMain444_12;
+else if (!strcmp(profile->name, "Screen-Extended Main"))
+return VAProfileHEVCSccMain;
+else if (!strcmp(profile->name, "Screen-Extended Main 10"))
+return VAProfileHEVCSccMain10;
+else if (!strcmp(profile->name, "Screen-Extended Main 4:4:4"))
+return VAProfileHEVCSccMain444;
+#if VA_CHECK_VERSION(1, 8, 0)
+else if (!strcmp(profile->name, "Screen-Extended Main 4:4:4 10"))
+return VAProfileHEVCSccMain444_10;
+#endif
 #else
 av_log(avctx, AV_LOG_WARNING, "HEVC profile %s is "
"not supported with this VA version.\n", profile->name);
diff --git a/libavcodec/vaapi_hevc.h b/libavcodec/vaapi_hevc.h
index b3b0e6fc1e..449635d0d7 100644
--- a/libavcodec/vaapi_hevc.h
+++ b/libavcodec/vaapi_hevc.h
@@ -22,6 +22,6 @@
 #include 
 #include "avcodec.h"
 
-VAProfile ff_vaapi_parse_hevc_rext_profile(AVCodecContext *avctx);
+VAProfile ff_vaapi_parse_hevc_rext_scc_profile(AVCodecContext *avctx);
 
 #endif /* AVCODEC_VAAPI_HEVC_H */
-- 
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] [PATCH v3 06/11] lavc/hevcdec: Set max_num_merge_cand to uint8_t

2023-01-03 Thread Fei Wang
From: Linjie Fu 

uint8_t is big enough and keep consistent with the definition in
cbs_h265.h.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/hevcdec.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index a7fc669bcb..aab816791e 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -304,7 +304,7 @@ typedef struct SliceHeader {
 int beta_offset;///< beta_offset_div2 * 2
 int tc_offset;  ///< tc_offset_div2 * 2
 
-unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
+uint8_t max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
 uint8_t use_integer_mv_flag;
 
 unsigned *entry_point_offset;
-- 
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] [PATCH v3 05/11] lavc/hevcdec: Fix the parsing for use_integer_mv_flag

2023-01-03 Thread Fei Wang
From: Linjie Fu 

According to 7.3.6.1, use_integer_mv_flag should be parsed if
motion_vector_resolution_control_idc equals to 2. If not present, it
equals to motion_vector_resolution_control_idc.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/hevcdec.c | 8 
 libavcodec/hevcdec.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index f9a97ac7f5..52fa627133 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -839,6 +839,14 @@ static int hls_slice_header(HEVCContext *s)
sh->max_num_merge_cand);
 return AVERROR_INVALIDDATA;
 }
+
+// Syntax in 7.3.6.1
+if (s->ps.sps->motion_vector_resolution_control_idc == 2)
+sh->use_integer_mv_flag = get_bits1(gb);
+else
+// Inferred to be equal to 
motion_vector_resolution_control_idc if not present
+sh->use_integer_mv_flag = 
s->ps.sps->motion_vector_resolution_control_idc;
+
 }
 
 sh->slice_qp_delta = get_se_golomb(gb);
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 7841ba8565..a7fc669bcb 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -305,6 +305,7 @@ typedef struct SliceHeader {
 int tc_offset;  ///< tc_offset_div2 * 2
 
 unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
+uint8_t use_integer_mv_flag;
 
 unsigned *entry_point_offset;
 int * offset;
-- 
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] [PATCH v3 04/11] lavc/hevcdec: Add slice parse support for HEVC SCC extension

2023-01-03 Thread Fei Wang
From: Linjie Fu 

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/hevcdec.c | 6 ++
 libavcodec/hevcdec.h | 4 
 2 files changed, 10 insertions(+)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 567e8d81d4..f9a97ac7f5 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -856,6 +856,12 @@ static int hls_slice_header(HEVCContext *s)
 sh->slice_cr_qp_offset = 0;
 }
 
+if (s->ps.pps->pps_slice_act_qp_offsets_present_flag) {
+sh->slice_act_y_qp_offset  = get_se_golomb(gb);
+sh->slice_act_cb_qp_offset = get_se_golomb(gb);
+sh->slice_act_cr_qp_offset = get_se_golomb(gb);
+}
+
 if (s->ps.pps->chroma_qp_offset_list_enabled_flag)
 sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb);
 else
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 9d3f4adbb3..7841ba8565 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -295,6 +295,10 @@ typedef struct SliceHeader {
 int slice_cb_qp_offset;
 int slice_cr_qp_offset;
 
+int slice_act_y_qp_offset;
+int slice_act_cb_qp_offset;
+int slice_act_cr_qp_offset;
+
 uint8_t cu_chroma_qp_offset_enabled_flag;
 
 int beta_offset;///< beta_offset_div2 * 2
-- 
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] [PATCH v3 03/11] lavc/hevc_ps: Add SPS/PPS parse support for HEVC extension syntax

2023-01-03 Thread Fei Wang
From: Linjie Fu 

1. Add extension syntax according to 7.3.2.2.3/7.3.2.3.3 in T-REC-H.265-201911.
2. Keep using parsed PPS when bitstream overread for compatibility. For
example, the clip PS_A_VIDYO_3.bit in FATE test has incomplete extension
syntax which will be overread and un-decodable if without this change.
3. Format brace in pps_range_extensions().

Signed-off-by: Linjie Fu 
Signed-off-by: Haihao Xiang 
Signed-off-by: Fei Wang 
---
 libavcodec/hevc.h|   3 +
 libavcodec/hevc_ps.c | 287 +--
 libavcodec/hevc_ps.h |  69 +++
 3 files changed, 348 insertions(+), 11 deletions(-)

diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index 1804755327..6b454a75c1 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -154,6 +154,9 @@ enum {
 // get near that, though, so set a lower limit here with the maximum
 // possible value for 4K video (at most 135 16x16 Ctb rows).
 HEVC_MAX_ENTRY_POINT_OFFSETS = HEVC_MAX_TILE_COLUMNS * 135,
+
+// A.3.7: Screen content coding extensions
+HEVC_MAX_PALETTE_PREDICTOR_SIZE = 128,
 };
 
 
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index ad92b6bcbc..0672acb706 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -853,7 +853,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 HEVCWindow *ow;
 int ret = 0;
 int log2_diff_max_min_transform_block_size;
-int bit_depth_chroma, start, vui_present, sublayer_ordering_info;
+int bit_depth_chroma, start, vui_present, sublayer_ordering_info, 
num_comps;
 int i;
 
 // Coded parameters
@@ -1074,8 +1074,12 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 decode_vui(gb, avctx, apply_defdispwin, sps);
 
 if (get_bits1(gb)) { // sps_extension_flag
-sps->sps_range_extension_flag = get_bits1(gb);
-skip_bits(gb, 7); //sps_extension_7bits = get_bits(gb, 7);
+sps->sps_range_extension_flag  = get_bits1(gb);
+sps->sps_multilayer_extension_flag = get_bits1(gb);
+sps->sps_3d_extension_flag = get_bits1(gb);
+sps->sps_scc_extension_flag= get_bits1(gb);
+skip_bits(gb, 4); // sps_extension_4bits
+
 if (sps->sps_range_extension_flag) {
 sps->transform_skip_rotation_enabled_flag = get_bits1(gb);
 sps->transform_skip_context_enabled_flag  = get_bits1(gb);
@@ -1101,6 +1105,57 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 av_log(avctx, AV_LOG_WARNING,
"cabac_bypass_alignment_enabled_flag not yet 
implemented\n");
 }
+
+if (sps->sps_multilayer_extension_flag) {
+skip_bits1(gb); // inter_view_mv_vert_constraint_flag
+av_log(avctx, AV_LOG_WARNING,
+   "sps_multilayer_extension_flag not yet implemented\n");
+}
+
+if (sps->sps_3d_extension_flag) {
+for (i = 0; i <= 1; i++) {
+skip_bits1(gb); // iv_di_mc_enabled_flag
+skip_bits1(gb); // iv_mv_scal_enabled_flag
+if (i == 0) {
+get_ue_golomb_long(gb); // log2_ivmc_sub_pb_size_minus3
+skip_bits1(gb); // iv_res_pred_enabled_flag
+skip_bits1(gb); // depth_ref_enabled_flag
+skip_bits1(gb); // vsp_mc_enabled_flag
+skip_bits1(gb); // dbbp_enabled_flag
+} else {
+skip_bits1(gb); // tex_mc_enabled_flag
+get_ue_golomb_long(gb); // log2_ivmc_sub_pb_size_minus3
+skip_bits1(gb); // intra_contour_enabled_flag
+skip_bits1(gb); // intra_dc_only_wedge_enabled_flag
+skip_bits1(gb); // cqt_cu_part_pred_enabled_flag
+skip_bits1(gb); // inter_dc_only_enabled_flag
+skip_bits1(gb); // skip_intra_enabled_flag
+}
+}
+av_log(avctx, AV_LOG_WARNING,
+   "sps_3d_extension_flag not yet implemented\n");
+}
+
+if (sps->sps_scc_extension_flag) {
+sps->sps_curr_pic_ref_enabled_flag = get_bits1(gb);
+sps->palette_mode_enabled_flag = get_bits1(gb);
+if (sps->palette_mode_enabled_flag) {
+sps->palette_max_size = get_ue_golomb_long(gb);
+sps->delta_palette_max_predictor_size = get_ue_golomb_long(gb);
+sps->sps_palette_predictor_initializers_present_flag = 
get_bits1(gb);
+
+if (sps->sps_palette_predictor_initializers_present_flag) {
+sps->sps_num_palette_predictor_initializers_minus1 = 
get_ue_golomb_long(gb);
+num_comps = !sps->chroma_format_idc ? 1 : 3;
+for (int comp = 0; comp < num_comps; comp++)
+for (i = 0; i <= 

[FFmpeg-devel] [PATCH v3 02/11] lavc/avcodec: Add HEVC Screen Content Coding Extensions profile

2023-01-03 Thread Fei Wang
From: Linjie Fu 

Described in HEVC spec A.3.7.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/avcodec.h  | 1 +
 libavcodec/hevc_ps.c  | 2 ++
 libavcodec/profiles.c | 1 +
 3 files changed, 4 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 0ac581d660..8d77b05ba0 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1639,6 +1639,7 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_HEVC_MAIN_10 2
 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE  3
 #define FF_PROFILE_HEVC_REXT4
+#define FF_PROFILE_HEVC_SCC 9
 
 #define FF_PROFILE_VVC_MAIN_10  1
 #define FF_PROFILE_VVC_MAIN_10_444 33
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 537a3ff99b..ad92b6bcbc 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -259,6 +259,8 @@ static int decode_profile_tier_level(GetBitContext *gb, 
AVCodecContext *avctx,
 av_log(avctx, AV_LOG_DEBUG, "Main Still Picture profile bitstream\n");
 else if (ptl->profile_idc == FF_PROFILE_HEVC_REXT)
 av_log(avctx, AV_LOG_DEBUG, "Range Extension profile bitstream\n");
+else if (ptl->profile_idc == FF_PROFILE_HEVC_SCC)
+av_log(avctx, AV_LOG_DEBUG, "Screen Content Coding Extension profile 
bitstream\n");
 else
 av_log(avctx, AV_LOG_WARNING, "Unknown HEVC profile: %d\n", 
ptl->profile_idc);
 
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 7af7fbeb13..2230fc5415 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -85,6 +85,7 @@ const AVProfile ff_hevc_profiles[] = {
 { FF_PROFILE_HEVC_MAIN_10,  "Main 10" },
 { FF_PROFILE_HEVC_MAIN_STILL_PICTURE,   "Main Still Picture"  },
 { FF_PROFILE_HEVC_REXT, "Rext"},
+{ FF_PROFILE_HEVC_SCC,  "Scc" },
 { FF_PROFILE_UNKNOWN },
 };
 
-- 
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] [PATCH v3 01/11] lavc/hevc_ps: remove profile limitation of pps_range_extensions()

2023-01-03 Thread Fei Wang
Follow spec 7.3.2.3.1.

Signed-off-by: Fei Wang 
---
update:
1. fix some code style.
2. seperate patchset into 2.

 libavcodec/hevc_ps.c |  2 +-
 tests/ref/fate/hevc-conformance-PS_A_VIDYO_3 | 50 ++--
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 5fe62ec35b..537a3ff99b 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1658,7 +1658,7 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, 
AVCodecContext *avctx,
 if (get_bits1(gb)) { // pps_extension_present_flag
 pps->pps_range_extensions_flag = get_bits1(gb);
 skip_bits(gb, 7); // pps_extension_7bits
-if (sps->ptl.general_ptl.profile_idc == FF_PROFILE_HEVC_REXT && 
pps->pps_range_extensions_flag) {
+if (pps->pps_range_extensions_flag) {
 if ((ret = pps_range_extensions(gb, avctx, pps, sps)) < 0)
 goto err;
 }
diff --git a/tests/ref/fate/hevc-conformance-PS_A_VIDYO_3 
b/tests/ref/fate/hevc-conformance-PS_A_VIDYO_3
index 59b82b72bb..d1d86b2dc9 100644
--- a/tests/ref/fate/hevc-conformance-PS_A_VIDYO_3
+++ b/tests/ref/fate/hevc-conformance-PS_A_VIDYO_3
@@ -3,28 +3,28 @@
 #codec_id 0: rawvideo
 #dimensions 0: 416x240
 #sar 0: 0/1
-0,  0,  0,1,   149760, 0x88619f80
-0,  1,  1,1,   149760, 0x550bdaf0
-0,  2,  2,1,   149760, 0x4121f7a2
-0,  3,  3,1,   149760, 0x210b1d07
-0,  4,  4,1,   149760, 0x731b7758
-0,  5,  5,1,   149760, 0x17adb789
-0,  6,  6,1,   149760, 0x98b2f080
-0,  7,  7,1,   149760, 0xc0be1f2a
-0,  8,  8,1,   149760, 0xc01e387a
-0,  9,  9,1,   149760, 0xd932822b
-0, 10, 10,1,   149760, 0x16c0a1df
-0, 11, 11,1,   149760, 0x5aa6c005
-0, 12, 12,1,   149760, 0xd3aab602
-0, 13, 13,1,   149760, 0x4e6ecab1
-0, 14, 14,1,   149760, 0x8a86f1f2
-0, 15, 15,1,   149760, 0x2ed21e1b
-0, 16, 16,1,   149760, 0x80892f24
-0, 17, 17,1,   149760, 0xb8a952ef
-0, 18, 18,1,   149760, 0x557e57fb
-0, 19, 19,1,   149760, 0x2b825b2c
-0, 20, 20,1,   149760, 0x30b69b5e
-0, 21, 21,1,   149760, 0x802ebf08
-0, 22, 22,1,   149760, 0x95aadc8e
-0, 23, 23,1,   149760, 0x4d4c02b7
-0, 24, 24,1,   149760, 0x3fdd1762
+0,  0,  0,1,   149760, 0x5c4f70f4
+0,  1,  1,1,   149760, 0xf4628e59
+0,  2,  2,1,   149760, 0xa28e5bdc
+0,  3,  3,1,   149760, 0xda0e53d7
+0,  4,  4,1,   149760, 0x42dd334a
+0,  5,  5,1,   149760, 0x25ba9dfe
+0,  6,  6,1,   149760, 0x8854d8ca
+0,  7,  7,1,   149760, 0xc04505d4
+0,  8,  8,1,   149760, 0xd3fce146
+0,  9,  9,1,   149760, 0x8bfd88bd
+0, 10, 10,1,   149760, 0x33d965b2
+0, 11, 11,1,   149760, 0x12746b7a
+0, 12, 12,1,   149760, 0xb7642694
+0, 13, 13,1,   149760, 0x32b5035f
+0, 14, 14,1,   149760, 0x7bea0af1
+0, 15, 15,1,   149760, 0x577d4fc8
+0, 16, 16,1,   149760, 0x023a9c66
+0, 17, 17,1,   149760, 0x9abe76c4
+0, 18, 18,1,   149760, 0x2b14dba5
+0, 19, 19,1,   149760, 0x7b8affcf
+0, 20, 20,1,   149760, 0x21e4c323
+0, 21, 21,1,   149760, 0xf0b7d9cd
+0, 22, 22,1,   149760, 0x4db0c5bc
+0, 23, 23,1,   149760, 0xf455f752
+0, 24, 24,1,   149760, 0x569fec99
-- 
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".


Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_ffplay_ffprobe_cmdutils: add -mask_url to replace the protocol address in the command with the asterisk (*)

2023-01-03 Thread Nicolas George
Wujian(Chin) (12023-01-03):
> Please review it again, thanks!!

You still treat the option differently without a good reason.

You still do not protect credentials in options.

Not acceptable.

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


[FFmpeg-devel] [PATCH] fftools/ffmpeg_ffplay_ffprobe_cmdutils: add -mask_url to replace the protocol address in the command with the asterisk (*)

2023-01-03 Thread Wujian(Chin)
Please review it again, thanks!!

Signed-off-by: wujian_nanjing 
---
 doc/fftools-common-opts.texi | 11 +
 fftools/cmdutils.c   | 57 
 fftools/cmdutils.h   | 21 
 fftools/ffmpeg.c |  7 +++---
 fftools/ffplay.c |  6 +++--
 fftools/ffprobe.c|  7 +++---
 fftools/opt_common.h |  1 +
 7 files changed, 102 insertions(+), 8 deletions(-)

diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
index d914570..724c028 100644
--- a/doc/fftools-common-opts.texi
+++ b/doc/fftools-common-opts.texi
@@ -363,6 +363,17 @@ for testing. Do not use it unless you know what you're 
doing.
 ffmpeg -cpucount 2
 @end example
 
+@item -mask_url -i @var{url} (@emph{output})
+If the protocol address contains the user name and password, the ps -ef
+command exposes plaintext. You can add the -mask_url parameter option is
+added to replace the protocol address in the command line with the
+asterisk (*). Because other users can run the ps -ef command to view sensitive
+information such as the user name and password in the protocol address,
+which is insecure.
+@example
+ffmpeg -mask_url -i rtsp://username:password-ip:port/stream/test
+@end example
+
 @item -max_alloc @var{bytes}
 Set the maximum size limit for allocating a block on the heap by ffmpeg's
 family of malloc functions. Exercise @strong{extreme caution} when using
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index a1de621..7946303 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -60,6 +60,59 @@ AVDictionary *swr_opts;
 AVDictionary *format_opts, *codec_opts;
 
 int hide_banner = 0;
+int mask_url = 0;
+
+void mask_param(int argc, char **argv)
+{
+int i, j;
+for (i = 1; i < argc; i++) {
+char *match = strstr(argv[i], "://");
+if (match) {
+int total = strlen(argv[i]);
+for (j = 0; j < total; j++) {
+argv[i][j] = '*';
+}
+}
+}
+}
+
+char **copy_argv(int argc, char **argv)
+{
+char **argv_copy;
+argv_copy = av_mallocz((argc + 1) * sizeof(char *));
+if (!argv_copy) {
+av_log(NULL, AV_LOG_FATAL, "argv_copy malloc failed\n");
+exit_program(1);
+}
+
+for (int i = 0; i < argc; i++) {
+int length = strlen(argv[i]) + 1;
+argv_copy[i] = av_mallocz(length * sizeof(*argv_copy));
+if (!argv_copy[i]) {
+av_log(NULL, AV_LOG_FATAL, "argv_copy[%d] malloc failed\n", i);
+exit_program(1);
+}
+memcpy(argv_copy[i], argv[i], length);
+}
+argv_copy[argc] = NULL;
+return argv_copy;
+}
+
+char **handle_arg_param(int argc, char **argv)
+{
+char **argv_copy;
+argv_copy = copy_argv(argc, argv);
+if (mask_url)
+mask_param(argc, argv);
+return argv_copy;
+}
+
+void free_argv_copy(int argc, char **argv)
+{
+for (int i = 0; i < argc; i++)
+av_free(argv[i]);
+av_free(argv);
+}
 
 void uninit_opts(void)
 {
@@ -501,6 +554,10 @@ void parse_loglevel(int argc, char **argv, const OptionDef 
*options)
 idx = locate_option(argc, argv, options, "hide_banner");
 if (idx)
 hide_banner = 1;
+
+idx = locate_option(argc, argv, options, "mask_url");
+if (idx)
+mask_url = 1;
 }
 
 static const AVOption *opt_find(void *obj, const char *name, const char *unit,
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index 4496221..66babbd 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -48,6 +48,27 @@ extern AVDictionary *sws_dict;
 extern AVDictionary *swr_opts;
 extern AVDictionary *format_opts, *codec_opts;
 extern int hide_banner;
+extern int mask_url;
+
+/**
+ * Using to mask sensitive info.
+ */
+void mask_param(int argc, char **argv);
+
+/**
+ * Using to copy ori argv.
+ */
+char **copy_argv(int argc, char **argv);
+
+/**
+ * Handle argv and argv_copy.
+ */
+char **handle_arg_param(int argc, char **argv);
+
+/**
+ * Free argv.
+ */
+void free_argv_copy(int argc, char **argv);
 
 /**
  * Register a program-specific cleanup routine.
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 881d6f0..9f3b261 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3867,7 +3867,7 @@ int main(int argc, char **argv)
 {
 int ret;
 BenchmarkTimeStamps ti;
-
+char **argv_copy;
 init_dynload();
 
 register_exit(ffmpeg_cleanup);
@@ -3883,9 +3883,10 @@ int main(int argc, char **argv)
 avformat_network_init();
 
 show_banner(argc, argv, options);
-
+argv_copy = handle_arg_param(argc, argv);
 /* parse options and open all input/output files */
-ret = ffmpeg_parse_options(argc, argv);
+ret = ffmpeg_parse_options(argc, argv_copy);
+free_argv_copy(argc, argv_copy);
 if (ret < 0)
 exit_program(1);
 
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index fc7e1c2..203db5e 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3664,6 +3664,7 @@ void 

Re: [FFmpeg-devel] AVX512 NUCs for FATE and development

2023-01-03 Thread Kieran Kunhya
On Sun, 18 Dec 2022 at 10:41, Stefano Sabatini  wrote:

> On Sat, Dec 17, 2022 at 9:46 PM Michael Niedermayer
>  wrote:
> >
> > On Sat, Dec 17, 2022 at 07:57:06PM +, Kieran Kunhya wrote:
> > > On Sat, 10 Dec 2022 at 18:12, Carl Eugen Hoyos 
> wrote:
> > >
> > > > Am Fr., 9. Dez. 2022 um 18:07 Uhr schrieb Michael Niedermayer
> > > > :
> > > > >
> > > > > On Thu, Dec 08, 2022 at 09:40:12PM +, Kieran Kunhya wrote:
> > > > > > I intend to buy this RAM:
> > > > > >
> > > >
> https://www.amazon.co.uk/Crucial-CT2K16G4SFRA32A-PC4-25600-SODIMM-260-Pin/dp/B08C4X9VR5
> > > > > >
> > > > > > 2x £529 for NUCs
> > > > > > 2x £102.48 for RAM
> > > > > > 2x £69 for M.2 NVMe SSD
> > > > > >
> > > > > > £1400 total.
> > > > >
> > > > > iam in favor of this too
> > > >
> > > > +1
> > >
> > >
> > > Just to confirm, by the time I got approval to buy this the discount
> was
> > > over and the price of the NUC had increased to £599 and I had to buy a
> > > slightly more expensive SSD as the original one I had proposed was not
> > > available. This came to a total of £1560.94, not too far from my
> original
> > > estimate of £1500.
> >
> > LGTM
> >
> > thx
>
> Approved on my side, sorry for the delay.
>

Please email me privately if you want access to the development machine.

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 v4 1/4] lavc: add standalone cached bitstream reader

2023-01-03 Thread Anton Khirnov
Will push in a few days if nobody has further comments.

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

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


Re: [FFmpeg-devel] [PATCH] avformat: Add support for embedding cover art in Ogg files

2023-01-03 Thread Zsolt Vadász
On Sunday, January 1st, 2023 at 10:41 AM, Jean-Baptiste Kempf 
 wrote:


> On Thu, 29 Dec 2022, at 22:05, Zsolt Vadász wrote:
> 
> > It's done similarly to how the flac muxer does it, so I reused most of
> > the code and adapted it.
> 
> 
> Would a common function make sense here?

Yes, I named it ff_flac_write_picture and put it in libavformat/flac_picture.c, 
here is the revised patch:

Signed-off-by: Zsolt Vadasz 
---
 libavformat/flac_picture.c | 132 +++
 libavformat/flac_picture.h |   5 +
 libavformat/flacenc.c  |  90 +---
 libavformat/oggenc.c   | 207 ++---
 4 files changed, 308 insertions(+), 126 deletions(-)

diff --git a/libavformat/flac_picture.c b/libavformat/flac_picture.c
index b33fee75b4..30152a2ba9 100644
--- a/libavformat/flac_picture.c
+++ b/libavformat/flac_picture.c
@@ -20,6 +20,9 @@
  */
 
 #include "libavutil/intreadwrite.h"
+#include "libavutil/avstring.h"
+#include "libavutil/base64.h"
+#include "libavutil/pixdesc.h"
 #include "libavcodec/bytestream.h"
 #include "libavcodec/png.h"
 #include "avformat.h"
@@ -188,3 +191,132 @@ fail:
 
 return ret;
 }
+
+int ff_flac_write_picture(struct AVFormatContext *s,
+  int isogg,
+  unsigned *attached_types,
+  int audio_stream_idx, // unused if !isogg
+  AVPacket *pkt)
+{
+AVIOContext *pb = s->pb;
+const AVPixFmtDescriptor *pixdesc;
+const CodecMime *mime = ff_id3v2_mime_tags;
+AVDictionaryEntry *e;
+const char *mimetype = NULL, *desc = "";
+const AVStream *st = s->streams[pkt->stream_index];
+int i, mimelen, desclen, type = 0, blocklen;
+
+if (!pkt->data)
+return 0;
+
+while (mime->id != AV_CODEC_ID_NONE) {
+if (mime->id == st->codecpar->codec_id) {
+mimetype = mime->str;
+break;
+}
+mime++;
+}
+if (!mimetype) {
+av_log(s, AV_LOG_ERROR, "No mimetype is known for stream %d, cannot "
+   "write an attached picture.\n", st->index);
+return AVERROR(EINVAL);
+}
+mimelen = strlen(mimetype);
+
+/* get the picture type */
+e = av_dict_get(st->metadata, "comment", NULL, 0);
+for (i = 0; e && i < FF_ARRAY_ELEMS(ff_id3v2_picture_types); i++) {
+if (!av_strcasecmp(e->value, ff_id3v2_picture_types[i])) {
+type = i;
+break;
+}
+}
+
+if (((*attached_types) & (1 << type)) & 0x6) {
+av_log(s, AV_LOG_ERROR, "Duplicate attachment for type '%s'\n", 
ff_id3v2_picture_types[type]);
+return AVERROR(EINVAL);
+}
+
+if (type == 1 && (st->codecpar->codec_id != AV_CODEC_ID_PNG ||
+  st->codecpar->width != 32 ||
+  st->codecpar->height != 32)) {
+av_log(s, AV_LOG_ERROR, "File icon attachment must be a 32x32 PNG");
+return AVERROR(EINVAL);
+}
+
+*attached_types |= (1 << type);
+
+/* get the description */
+if ((e = av_dict_get(st->metadata, "title", NULL, 0)))
+desc = e->value;
+desclen = strlen(desc);
+
+blocklen = 4 + 4 + mimelen + 4 + desclen + 4 + 4 + 4 + 4 + 4 + pkt->size;
+if (blocklen >= 1<<24) {
+av_log(s, AV_LOG_ERROR, "Picture block too big %d >= %d\n", blocklen, 
1<<24);
+return AVERROR(EINVAL);
+}
+
+if(!isogg) {
+avio_w8(pb, 0x06);
+avio_wb24(pb, blocklen);
+
+avio_wb32(pb, type);
+
+avio_wb32(pb, mimelen);
+avio_write(pb, mimetype, mimelen);
+
+avio_wb32(pb, desclen);
+avio_write(pb, desc, desclen);
+
+avio_wb32(pb, st->codecpar->width);
+avio_wb32(pb, st->codecpar->height);
+if ((pixdesc = av_pix_fmt_desc_get(st->codecpar->format)))
+avio_wb32(pb, av_get_bits_per_pixel(pixdesc));
+else
+avio_wb32(pb, 0);
+avio_wb32(pb, 0);
+
+avio_wb32(pb, pkt->size);
+avio_write(pb, pkt->data, pkt->size);
+} else {
+uint8_t *metadata_block_picture, *ptr;
+int encoded_len, ret;
+char *encoded;
+AVStream *audio_stream = s->streams[audio_stream_idx];
+
+metadata_block_picture = av_mallocz(blocklen);
+ptr = metadata_block_picture;
+bytestream_put_be32(, type);
+
+bytestream_put_be32(, mimelen);
+bytestream_put_buffer(, mimetype, mimelen);
+
+bytestream_put_be32(, desclen);
+bytestream_put_buffer(, desc, desclen);
+
+bytestream_put_be32(, st->codecpar->width);
+bytestream_put_be32(, st->codecpar->height);
+if ((pixdesc = av_pix_fmt_desc_get(st->codecpar->format)))
+bytestream_put_be32(, av_get_bits_per_pixel(pixdesc));
+else
+bytestream_put_be32(, 0);
+bytestream_put_be32(, 0);
+
+bytestream_put_be32(, pkt->size);
+bytestream_put_buffer(, pkt->data, pkt->size);
+
+

[FFmpeg-devel] [PATCH] ffmpeg: apply discontinuity adjustment per-stream

2023-01-03 Thread Gyan Doshi
At present, the offset for discontinuity adjustment is applied per-file but
the check for discontinuity is intra-stream so the same discontinuity when
seen in multiple streams with copyts, leads to compounded adjustment of the
discontinuity offset. This introduces gaps in streams, leading to loss of sync
or even de facto loss of stream.

The ts_offset_discont parameter is transferred to InputStream and adjusted
based on intra-stream gaps.
---
Here's a simulated example to demonstrate the issue:
1) generate input
ffmpeg -f lavfi -i nullsrc=s=32x32:r=1,format=gray -f lavfi -i 
anullsrc=cl=mono:r=8000 -c:v libx264 -preset superfast -bf 0 -crf 50 -c:a aac 
-b:a 64k -muxpreload 0 -muxdelay 0 -output_ts_offset 95000 -t 10 
src-10s.ts

2) demo
ffmpeg -copyts -i "src-10.ts" -vf "showinfo=checksum=0" -af "ashowinfo" -f 
null - -report

==Before patch==

timestamp discontinuity for stream #0:1 (id=257, type=audio): -95443717689, new 
offset= 95443717689
timestamp discontinuity for stream #0:0 (id=256, type=video): -95443717689, new 
offset= 190887435378

[Parsed_ashowinfo_0 @ 02700af98800] n:0 pts:759998976 pts_time:94999.9
[Parsed_ashowinfo_0 @ 02700af98800] n:1 pts:76000 pts_time:95000
 ... 
[Parsed_ashowinfo_0 @ 02700af98800] n:745202 pts:1523085824 pts_time:190386
[Parsed_ashowinfo_0 @ 02700af98800] n:745203 pts:1523086848 pts_time:190386
[Parsed_ashowinfo_0 @ 02700af98800] n:745204 pts:2286637614 pts_time:285830
[Parsed_ashowinfo_0 @ 02700af98800] n:745205 pts:2286638638 pts_time:285830


[Parsed_showinfo_0 @ 02700ec34700] n:   0 pts:855000 pts_time:95000
[Parsed_showinfo_0 @ 02700ec34700] n:   1 pts:855009 pts_time:95001
 ... 
[Parsed_showinfo_0 @ 02700ec34700] n:95380 pts:1713420 pts_time:190380
[Parsed_showinfo_0 @ 02700ec34700] n:95381 pts:1713429 pts_time:190381
[Parsed_showinfo_0 @ 02700ec34700] n:95382 pts:25724314592 pts_time:285826
[Parsed_showinfo_0 @ 02700ec34700] n:95383 pts:25724404592 pts_time:285827

==After patch==

timestamp discontinuity for stream #0:1 (id=257, type=audio): -95443717689, new 
stream offset= 95443717689
timestamp discontinuity for stream #0:0 (id=256, type=video): -95443717689, new 
stream offset= 95443717689

[Parsed_ashowinfo_0 @ 023c773c8880] n:0 pts:759998976 pts_time:94999.9
[Parsed_ashowinfo_0 @ 023c773c8880] n:1 pts:76000 pts_time:95000
 ... 
[Parsed_ashowinfo_0 @ 023c773c8880] n:745202 pts:1523085824 pts_time:190386
[Parsed_ashowinfo_0 @ 023c773c8880] n:745203 pts:1523086848 pts_time:190386
[Parsed_ashowinfo_0 @ 023c773c8880] n:745204 pts:1523087872 pts_time:190386
[Parsed_ashowinfo_0 @ 023c773c8880] n:745205 pts:1523088896 pts_time:190386


[Parsed_showinfo_0 @ 023c795d07c0] n:   0 pts:855000 pts_time:95000
[Parsed_showinfo_0 @ 023c795d07c0] n:   1 pts:855009 pts_time:95001
 ... 
[Parsed_showinfo_0 @ 023c795d07c0] n:95380 pts:1713420 pts_time:190380
[Parsed_showinfo_0 @ 023c795d07c0] n:95381 pts:1713429 pts_time:190381
[Parsed_showinfo_0 @ 023c795d07c0] n:95382 pts:1713438 pts_time:190382
[Parsed_showinfo_0 @ 023c795d07c0] n:95383 pts:1713447 pts_time:190383



 fftools/ffmpeg.c | 12 ++--
 fftools/ffmpeg.h |  8 
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 881d6f0af2..b967055059 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3418,13 +3418,13 @@ static void ts_discontinuity_detect(InputFile *ifile, 
InputStream *ist,
 if (fmt_is_discont) {
 if (FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE ||
 pkt_dts + AV_TIME_BASE/10 < FFMAX(ist->pts, ist->dts)) {
-ifile->ts_offset_discont -= delta;
+ist->ts_offset_discont -= delta;
 av_log(NULL, AV_LOG_DEBUG,
"timestamp discontinuity for stream #%d:%d "
-   "(id=%d, type=%s): %"PRId64", new offset= %"PRId64"\n",
+   "(id=%d, type=%s): %"PRId64", new stream offset= 
%"PRId64"\n",
ist->file_index, ist->st->index, ist->st->id,
av_get_media_type_string(ist->par->codec_type),
-   delta, ifile->ts_offset_discont);
+   delta, ist->ts_offset_discont);
 pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, 
ist->st->time_base);
 if (pkt->pts != AV_NOPTS_VALUE)
 pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, 
ist->st->time_base);
@@ -3447,10 +3447,10 @@ static void ts_discontinuity_detect(InputFile *ifile, 
InputStream *ist,
fmt_is_discont && ifile->last_ts != AV_NOPTS_VALUE) {
 int64_t delta = pkt_dts - ifile->last_ts;
 if (FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE) {
-ifile->ts_offset_discont -= delta;
+ist->ts_offset_discont -= delta;

[FFmpeg-devel] [PATCH 3/3] avutil/hwcontext_videotoolbox: BGRA should be full range

2023-01-03 Thread Zhao Zhili
From: Zhao Zhili 

HEVC alpha layer encoding is broken without the patch.

Signed-off-by: Zhao Zhili 
---
 libavutil/hwcontext_videotoolbox.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_videotoolbox.c 
b/libavutil/hwcontext_videotoolbox.c
index e442a95007..b8e6bb407f 100644
--- a/libavutil/hwcontext_videotoolbox.c
+++ b/libavutil/hwcontext_videotoolbox.c
@@ -44,7 +44,7 @@ static const struct {
 } cv_pix_fmts[] = {
 { kCVPixelFormatType_420YpCbCr8Planar,  false, 
AV_PIX_FMT_YUV420P },
 { kCVPixelFormatType_422YpCbCr8,false, 
AV_PIX_FMT_UYVY422 },
-{ kCVPixelFormatType_32BGRA,false, AV_PIX_FMT_BGRA 
},
+{ kCVPixelFormatType_32BGRA,true,  AV_PIX_FMT_BGRA 
},
 #ifdef kCFCoreFoundationVersionNumber10_7
 { kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange,  false, AV_PIX_FMT_NV12 
},
 { kCVPixelFormatType_420YpCbCr8BiPlanarFullRange,   true,  AV_PIX_FMT_NV12 
},
-- 
2.35.3

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

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


[FFmpeg-devel] [PATCH 2/3] avcodec/videotoolboxenc: pass error code through

2023-01-03 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavcodec/videotoolboxenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 27db4e0d5e..3b00e542cb 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -2156,7 +2156,7 @@ static int get_cv_pixel_info(
 
 status = get_cv_pixel_format(avctx, av_format, av_color_range, color, 
_guessed);
 if (status)
-return AVERROR(EINVAL);
+return status;
 
 if (range_guessed) {
 if (!vtctx->warned_color_range) {
@@ -2338,7 +2338,7 @@ static int create_cv_pixel_buffer(AVCodecContext   *avctx,
 status
 );
 
-return AVERROR_EXTERNAL;
+return status;
 }
 
 pix_buf_pool = VTCompressionSessionGetPixelBufferPool(vtctx->session);
-- 
2.35.3

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

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


[FFmpeg-devel] [PATCH 1/3] avcodec/videotoolboxenc: log when get_cv_pixel_format failed

2023-01-03 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavcodec/videotoolboxenc.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index aec98ade4f..27db4e0d5e 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -847,13 +847,22 @@ static int get_cv_pixel_format(AVCodecContext* avctx,
int* av_pixel_format,
int* range_guessed)
 {
+const char *range_name;
 if (range_guessed) *range_guessed = range != AVCOL_RANGE_MPEG &&
 range != AVCOL_RANGE_JPEG;
 
 //MPEG range is used when no range is set
 *av_pixel_format = av_map_videotoolbox_format_from_pixfmt2(fmt, range == 
AVCOL_RANGE_JPEG);
+if (*av_pixel_format)
+return 0;
+
+range_name = av_color_range_name(range);
+av_log(avctx, AV_LOG_ERROR,
+"Could not get pixel format for color format '%s' range '%s'.\n",
+av_get_pix_fmt_name(fmt),
+range_name ? range_name : "Unknown");
 
-return *av_pixel_format ? 0 : AVERROR(EINVAL);
+return AVERROR(EINVAL);
 }
 
 static void add_color_attr(AVCodecContext *avctx, CFMutableDictionaryRef dict) 
{
@@ -2146,18 +2155,8 @@ static int get_cv_pixel_info(
 return AVERROR(EINVAL);
 
 status = get_cv_pixel_format(avctx, av_format, av_color_range, color, 
_guessed);
-if (status) {
-av_log(avctx,
-AV_LOG_ERROR,
-"Could not get pixel format for color format '%s' range '%s'.\n",
-av_get_pix_fmt_name(av_format),
-av_color_range > AVCOL_RANGE_UNSPECIFIED &&
-av_color_range < AVCOL_RANGE_NB ?
-   av_color_range_name(av_color_range) :
-   "Unknown");
-
+if (status)
 return AVERROR(EINVAL);
-}
 
 if (range_guessed) {
 if (!vtctx->warned_color_range) {
-- 
2.35.3

___
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] get_cabac_inline_x86: Don't inline if 32-bit Windows

2023-01-03 Thread Andreas Rheinhardt
Christopher Degawa:
> previouslly, it only was an issue with 32-bit clang from msys2's
> mingw32 repo, however, at some point with an update to gcc 12.2.0,
> the same issue popped up. Tested with a clean clone of ffmpeg, and even
> tested with n5.0, but the issue persists, so I presume it's a compiler
> issue.
> 
> Related: https://trac.ffmpeg.org/ticket/8903
> 
> Signed-off-by: Christopher Degawa 
> ---
>  libavcodec/x86/cabac.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h
> index b046a56a6b..70f990db8d 100644
> --- a/libavcodec/x86/cabac.h
> +++ b/libavcodec/x86/cabac.h
> @@ -178,7 +178,7 @@
>  #if HAVE_7REGS && !BROKEN_COMPILER
>  #define get_cabac_inline get_cabac_inline_x86
>  static
> -#if defined(_WIN32) && !defined(_WIN64) && defined(__clang__)
> +#if defined(_WIN32) && !defined(_WIN64)
>  av_noinline
>  #else
>  av_always_inline

Have these presumed compiler bugs ever been reported upstream?

- Andreas

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

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


Re: [FFmpeg-devel] [PATCH 2/2] lavfi/dnn: Remove DNN native backend

2023-01-03 Thread Fu, Ting



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Marton Balint
> Sent: Sunday, January 1, 2023 06:20 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 2/2] lavfi/dnn: Remove DNN native
> backend
> 
> 
> 
> On Fri, 30 Dec 2022, Ting Fu wrote:
> 
> > According to discussion in
> > https://etherpad.mit.edu/p/FF_dev_meeting_20221202.
> > The DNN native backend should be removed at first step.
> > All the DNN native backend related code is deleted.
> 
> You should explain why it is being removed. The cited URL is not giving
> any explanations.
> 
> Thanks,
> Marton
> 
Hi Marton,

Hope the email here can explain: 
http://ffmpeg.org/pipermail/ffmpeg-devel/2022-December/304534.html
As I noticed, the native backend only supports a few models, which was an 
outcome after many layers' implementation in FFmpeg DNN module. Naturally, it 
would take many other works to support other models.
What's more, due to its' ordinary, unsatisfied performance, almost users choose 
other well-developed DNN framework for inference.

I believe that's the main reason to remove native from DNN module.

Thank you
Ting Fu
> 
> >
> > Signed-off-by: Ting Fu 
> > ---
> > libavfilter/dnn/Makefile  |  10 -
> > libavfilter/dnn/dnn_backend_native.c  | 561 --
> > libavfilter/dnn/dnn_backend_native.h  | 149 -
> > .../dnn/dnn_backend_native_layer_avgpool.c| 147 -
> > .../dnn/dnn_backend_native_layer_avgpool.h|  69 ---
> > .../dnn/dnn_backend_native_layer_conv2d.c | 265 -
> > .../dnn/dnn_backend_native_layer_conv2d.h |  68 ---
> > .../dnn/dnn_backend_native_layer_dense.c  | 151 -
> > .../dnn/dnn_backend_native_layer_dense.h  |  65 --
> > .../dnn_backend_native_layer_depth2space.c| 102 
> > .../dnn_backend_native_layer_depth2space.h|  72 ---
> > .../dnn/dnn_backend_native_layer_mathbinary.c | 193 --
> > .../dnn/dnn_backend_native_layer_mathbinary.h |  54 --
> > .../dnn/dnn_backend_native_layer_mathunary.c  | 156 -
> > .../dnn/dnn_backend_native_layer_mathunary.h  |  92 ---
> > .../dnn/dnn_backend_native_layer_maximum.c|  83 ---
> > .../dnn/dnn_backend_native_layer_maximum.h|  44 --
> > .../dnn/dnn_backend_native_layer_pad.c| 268 -
> > .../dnn/dnn_backend_native_layer_pad.h|  43 --
> > libavfilter/dnn/dnn_backend_native_layers.c   |  42 --
> > libavfilter/dnn/dnn_backend_native_layers.h   |  38 --
> > libavfilter/dnn/dnn_backend_tf.c  | 368 +---
> > libavfilter/dnn/dnn_interface.c   |  10 +-
> > libavfilter/tests/dnn-layer-avgpool.c | 197 --
> > libavfilter/tests/dnn-layer-conv2d.c  | 248 
> > libavfilter/tests/dnn-layer-dense.c   | 131 
> > libavfilter/tests/dnn-layer-depth2space.c | 102 
> > libavfilter/tests/dnn-layer-mathbinary.c  | 214 ---
> > libavfilter/tests/dnn-layer-mathunary.c   | 148 -
> > libavfilter/tests/dnn-layer-maximum.c |  71 ---
> > libavfilter/tests/dnn-layer-pad.c | 239 
> > tests/Makefile|   1 -
> > tests/fate/dnn.mak|  45 --
> > 33 files changed, 6 insertions(+), 4440 deletions(-)
> > delete mode 100644 libavfilter/dnn/dnn_backend_native.c
> > delete mode 100644 libavfilter/dnn/dnn_backend_native.h
> > delete mode 100644 libavfilter/dnn/dnn_backend_native_layer_avgpool.c
> > delete mode 100644 libavfilter/dnn/dnn_backend_native_layer_avgpool.h
> > delete mode 100644 libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> > delete mode 100644 libavfilter/dnn/dnn_backend_native_layer_conv2d.h
> > delete mode 100644 libavfilter/dnn/dnn_backend_native_layer_dense.c
> > delete mode 100644 libavfilter/dnn/dnn_backend_native_layer_dense.h
> > delete mode 100644
> libavfilter/dnn/dnn_backend_native_layer_depth2space.c
> > delete mode 100644
> libavfilter/dnn/dnn_backend_native_layer_depth2space.h
> > delete mode 100644
> libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
> > delete mode 100644
> libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
> > delete mode 100644
> libavfilter/dnn/dnn_backend_native_layer_mathunary.c
> > delete mode 100644
> libavfilter/dnn/dnn_backend_native_layer_mathunary.h
> > delete mode 100644
> libavfilter/dnn/dnn_backend_native_layer_maximum.c
> > delete mode 100644
> libavfilter/dnn/dnn_backend_native_layer_maximum.h
> > delete mode 100644 libavfilter/dnn/dnn_backend_native_layer_pad.c
> > delete mode 100644 libavfilter/dnn/dnn_backend_native_layer_pad.h
> > delete mode 100644 libavfilter/dnn/dnn_backend_native_layers.c
> > delete mode 100644 libavfilter/dnn/dnn_backend_native_layers.h
> > delete mode 100644 libavfilter/tests/dnn-layer-avgpool.c
> > delete mode 100644 libavfilter/tests/dnn-layer-conv2d.c
> > delete mode 100644 libavfilter/tests/dnn-layer-dense.c
> > delete mode 100644 

Re: [FFmpeg-devel] [PATCH] avformat/rtpproto: add support for RTP/UDP socket reuse

2023-01-03 Thread Camille Oudot
Hi, I'm back on the topic. Thanks to all of you for your comments.

> So I agree that SO_REUSEADDR is "absolutely not a hack"... if you use
> it to recycle IP/port pair without waiting for the time-out. But
> that's mainly of interest of listening/receiving sockets.

That is indeed the case for TCP sockets, but as far as I know this does
not apply to UDP as there is no TIME_WAIT state associated to datagram
sockets.

The classical use of this option would be for having a process binding
on udp:0.0.0.0:1234 then another one binding on e.g.
udp:192.168.1.10:1234 without triggering a "address in use" error. This
is indeed a matter of listening socket.

> If you use it to bind two concurrent sockets on the same IP/port
> pair, then it is absolutely not just a hack but a platform-dependent
> non-portable hack and a latent vulnerability in the OS (since one
> process can hijack datagrams for another).

The use of REUSEPORT instead of REUSEADDR is meant to mitigate this
risk (but it's far from perfect).


I definitely agree that using these options instead of refactoring or
rewriting the RTP protocol to support RTP bundle and RTCP mux is a
hack. I should take some time in the future to look into a proper
solution. In the meantime, several people are looking for this feature:

- http://ffmpeg.org/pipermail/ffmpeg-user/2018-September/041393.html
- https://trac.ffmpeg.org/ticket/1774
-
https://mediasoup.discourse.group/t/simulcast-with-plainrtptransport-and-ffmpeg/863


When the REUSEADDR option was added in FFmpeg UDP protocol what was the
reason back then? And wouldn't this reason also apply for RTP? If we
enable it for some legit reason, this could provide a (hacky and OS-
dependent) solution for RTP bundle and RTCP mux, until the RTP protocol
is properly refactored.

Regards

-- 
Camille

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