Re: [FFmpeg-devel] [PATCH v2] x86/tx_float: implement inverse MDCT AVX2 assembly

2022-09-01 Thread Lynne
Sep 2, 2022, 07:49 by d...@lynne.ee:

> Version 2 notes: halved the amount of loads and loops for the
> pre-transform loop by exploiting the symmetry.
>
> This commit implements an iMDCT in pure assembly.
>
> This is capable of processing any mod-8 transforms, rather than just
> power of two, but since power of two is all we have assembly for
> currently, that's what's supported.
> It would really benefit if we could somehow use the C code to decide
> which function to jump into, but exposing function labels from assebly
> into C is anything but easy.
> The post-transform loop could probably be improved.
>
> This was somewhat annoying to write, as we must support arbitrary
> strides during runtime. There's a fast branch for stride == 4 bytes
> and a slower one which uses vgatherdps.
>
> Zen 3 benchmarks for stride == 4 for old (av_imdct_half) vs new (av_tx):
>
> 128pt:
>    2815 decicycles in av_tx (imdct),16776766 runs,    450 skips
>    3097 decicycles in av_imdct_half,16776745 runs,    471 skips
>
> 256pt:
>    4931 decicycles in av_tx (imdct), 4193127 runs,   1177 skips
>    5401 decicycles in av_imdct_half, 2097058 runs, 94 skips
>
> 512pt:
>    9764 decicycles in av_tx (imdct), 4193929 runs,    375 skips
>   10690 decicycles in av_imdct_half, 2096948 runs,    204 skips
>
> 1024pt:
>   20113 decicycles in av_tx (imdct), 4194202 runs,    102 skips
>   21258 decicycles in av_imdct_half, 2097147 runs,  5 skips
>
> Patch attached.
>

Forgot to git add some minor reordering/fma changes.
W/e.

>From d29fe57522a7bc26452da7198afbda440e6aba1c Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Thu, 1 Sep 2022 23:26:29 +0200
Subject: [PATCH v2] x86/tx_float: implement inverse MDCT AVX2 assembly

This commit implements an iMDCT in pure assembly.

This is capable of processing any mod-8 transforms, rather than just
power of two, but since power of two is all we have assembly for
currently, that's what's supported.
It would really benefit if we could somehow use the C code to decide
which function to jump into, but exposing function labels from assebly
into C is anything but easy.
The post-transform loop could probably be improved.

This was somewhat annoying to write, as we must support arbitrary
strides during runtime. There's a fast branch for stride == 4 bytes
and a slower one which uses vgatherdps.

Zen 3 benchmarks for stride == 4 for old (av_imdct_half) vs new (av_tx):

128pt:
   2815 decicycles in av_tx (imdct),16776766 runs,450 skips
   3097 decicycles in av_imdct_half,16776745 runs,471 skips

256pt:
   4931 decicycles in av_tx (imdct), 4193127 runs,   1177 skips
   5401 decicycles in av_imdct_half, 2097058 runs, 94 skips

512pt:
   9764 decicycles in av_tx (imdct), 4193929 runs,375 skips
  10690 decicycles in av_imdct_half, 2096948 runs,204 skips

1024pt:
  20113 decicycles in av_tx (imdct), 4194202 runs,102 skips
  21258 decicycles in av_imdct_half, 2097147 runs,  5 skips
---
 libavutil/tx.c|  19 ++--
 libavutil/tx_priv.h   |   8 +-
 libavutil/x86/tx_float.asm| 192 +-
 libavutil/x86/tx_float_init.c |  29 -
 4 files changed, 233 insertions(+), 15 deletions(-)

diff --git a/libavutil/tx.c b/libavutil/tx.c
index 28e49a5d41..01f9cb7ea0 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -206,23 +206,24 @@ static void parity_revtab_generator(int *revtab, int n, int inv, int offset,
 1, 1, len >> 1, basis, dual_stride, inv_lookup);
 }
 
-int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int invert_lookup,
-int basis, int dual_stride)
+int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int len, int inv,
+int inv_lookup, int basis, int dual_stride)
 {
-int len = s->len;
-int inv = s->inv;
-
-if (!(s->map = av_mallocz(len*sizeof(*s->map
-return AVERROR(ENOMEM);
-
 basis >>= 1;
 if (len < basis)
 return AVERROR(EINVAL);
 
+if (!(s->map = av_mallocz((inv_lookup == -1 ? 2 : 1)*len*sizeof(*s->map
+return AVERROR(ENOMEM);
+
 av_assert0(!dual_stride || !(dual_stride & (dual_stride - 1)));
 av_assert0(dual_stride <= basis);
+
 parity_revtab_generator(s->map, len, inv, 0, 0, 0, len,
-basis, dual_stride, invert_lookup);
+basis, dual_stride, inv_lookup != 0);
+if (inv_lookup == -1)
+parity_revtab_generator(s->map + len, len, inv, 0, 0, 0, len,
+basis, dual_stride, 0);
 
 return 0;
 }
diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h
index e38490bd56..1688b69509 100644
--- a/libavutil/tx_priv.h
+++ b/libavutil/tx_priv.h
@@ -287,9 +287,13 @@ int ff_tx_gen_ptwo_inplace_revtab_idx(AVTXContext *s);
  * functions in AVX 

[FFmpeg-devel] [PATCH v2] x86/tx_float: implement inverse MDCT AVX2 assembly

2022-09-01 Thread Lynne
Version 2 notes: halved the amount of loads and loops for the
pre-transform loop by exploiting the symmetry.

This commit implements an iMDCT in pure assembly.

This is capable of processing any mod-8 transforms, rather than just
power of two, but since power of two is all we have assembly for
currently, that's what's supported.
It would really benefit if we could somehow use the C code to decide
which function to jump into, but exposing function labels from assebly
into C is anything but easy.
The post-transform loop could probably be improved.

This was somewhat annoying to write, as we must support arbitrary
strides during runtime. There's a fast branch for stride == 4 bytes
and a slower one which uses vgatherdps.

Zen 3 benchmarks for stride == 4 for old (av_imdct_half) vs new (av_tx):

128pt:
   2815 decicycles in av_tx (imdct),16776766 runs,    450 skips
   3097 decicycles in av_imdct_half,16776745 runs,    471 skips

256pt:
   4931 decicycles in av_tx (imdct), 4193127 runs,   1177 skips
   5401 decicycles in av_imdct_half, 2097058 runs, 94 skips

512pt:
   9764 decicycles in av_tx (imdct), 4193929 runs,    375 skips
  10690 decicycles in av_imdct_half, 2096948 runs,    204 skips

1024pt:
  20113 decicycles in av_tx (imdct), 4194202 runs,    102 skips
  21258 decicycles in av_imdct_half, 2097147 runs,  5 skips

Patch attached.

>From f882b039bd8875a8d392ebfe320ac46f9b3d083f Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Thu, 1 Sep 2022 23:26:29 +0200
Subject: [PATCH v2] x86/tx_float: implement inverse MDCT AVX2 assembly

This commit implements an iMDCT in pure assembly.

This is capable of processing any mod-8 transforms, rather than just
power of two, but since power of two is all we have assembly for
currently, that's what's supported.
It would really benefit if we could somehow use the C code to decide
which function to jump into, but exposing function labels from assebly
into C is anything but easy.
The post-transform loop could probably be improved.

This was somewhat annoying to write, as we must support arbitrary
strides during runtime. There's a fast branch for stride == 4 bytes
and a slower one which uses vgatherdps.

Zen 3 benchmarks for stride == 4 for old (av_imdct_half) vs new (av_tx):

128pt:
   2815 decicycles in av_tx (imdct),16776766 runs,450 skips
   3097 decicycles in av_imdct_half,16776745 runs,471 skips

256pt:
   4931 decicycles in av_tx (imdct), 4193127 runs,   1177 skips
   5401 decicycles in av_imdct_half, 2097058 runs, 94 skips

512pt:
   9764 decicycles in av_tx (imdct), 4193929 runs,375 skips
  10690 decicycles in av_imdct_half, 2096948 runs,204 skips

1024pt:
  20113 decicycles in av_tx (imdct), 4194202 runs,102 skips
  21258 decicycles in av_imdct_half, 2097147 runs,  5 skips
---
 libavutil/tx.c|  19 ++--
 libavutil/tx_priv.h   |   8 +-
 libavutil/x86/tx_float.asm| 193 +-
 libavutil/x86/tx_float_init.c |  29 -
 4 files changed, 234 insertions(+), 15 deletions(-)

diff --git a/libavutil/tx.c b/libavutil/tx.c
index 28e49a5d41..01f9cb7ea0 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -206,23 +206,24 @@ static void parity_revtab_generator(int *revtab, int n, int inv, int offset,
 1, 1, len >> 1, basis, dual_stride, inv_lookup);
 }
 
-int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int invert_lookup,
-int basis, int dual_stride)
+int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int len, int inv,
+int inv_lookup, int basis, int dual_stride)
 {
-int len = s->len;
-int inv = s->inv;
-
-if (!(s->map = av_mallocz(len*sizeof(*s->map
-return AVERROR(ENOMEM);
-
 basis >>= 1;
 if (len < basis)
 return AVERROR(EINVAL);
 
+if (!(s->map = av_mallocz((inv_lookup == -1 ? 2 : 1)*len*sizeof(*s->map
+return AVERROR(ENOMEM);
+
 av_assert0(!dual_stride || !(dual_stride & (dual_stride - 1)));
 av_assert0(dual_stride <= basis);
+
 parity_revtab_generator(s->map, len, inv, 0, 0, 0, len,
-basis, dual_stride, invert_lookup);
+basis, dual_stride, inv_lookup != 0);
+if (inv_lookup == -1)
+parity_revtab_generator(s->map + len, len, inv, 0, 0, 0, len,
+basis, dual_stride, 0);
 
 return 0;
 }
diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h
index e38490bd56..1688b69509 100644
--- a/libavutil/tx_priv.h
+++ b/libavutil/tx_priv.h
@@ -287,9 +287,13 @@ int ff_tx_gen_ptwo_inplace_revtab_idx(AVTXContext *s);
  * functions in AVX mode.
  *
  * If length is smaller than basis/2 this function will not do anything.
+ *
+ * If inv_lookup is set to 1, it will flip the lookup from out[map[i]] = 

Re: [FFmpeg-devel] [RFC] d3dva security hw+threads

2022-09-01 Thread Lynne
Sep 2, 2022, 01:46 by t...@rothenpieler.org:

> On 02.09.2022 01:32, Michael Niedermayer wrote:
>
>> Hi all
>>
>> Theres a use after free issue in H.264 Decoding on d3d11va with multiple 
>> threads
>> I dont have the hardware/platform nor do i know the hw decoding code so i 
>> made
>> no attempt to fix this beyond asking others to ...
>>
>
> hwaccel with multiple threads being broken is not exactly a surprise.
> So we could just disable that, and always have it be one single thread?
>

Is it an API problem or a lavc problem?
Vulkan does allow for threaded submission, so I'd rather keep the option open.
We could add a new codec cap.

___
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] [RFC] d3dva security hw+threads

2022-09-01 Thread Timo Rothenpieler

On 02.09.2022 01:32, Michael Niedermayer wrote:

Hi all

Theres a use after free issue in H.264 Decoding on d3d11va with multiple threads
I dont have the hardware/platform nor do i know the hw decoding code so i made
no attempt to fix this beyond asking others to ...


hwaccel with multiple threads being broken is not exactly a surprise.
So we could just disable that, and always have it be one single thread?
___
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] [RFC] d3dva security hw+threads

2022-09-01 Thread Michael Niedermayer
Hi all

Theres a use after free issue in H.264 Decoding on d3d11va with multiple threads
I dont have the hardware/platform nor do i know the hw decoding code so i made
no attempt to fix this beyond asking others to ...

There where 2 patches posted by the maintainer, neither really felt "right" and
also indepandently noone else applied either or approved either.

What is the preferred way of the community to handle this (and similar issues)?
ignore it and hope it will be handled by someone else ?
document it in release notes ?
disable the code ? (and which code)

And yes iam trying to be a bit annoying here, so this moves forward and
a fix or workaround can be in git master soon and then the next releases

Thanks

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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 3/3] avcodec/bink: disallow odd positioned scaled blocks

2022-09-01 Thread Michael Niedermayer
On Tue, Jul 12, 2022 at 08:20:18PM +0200, Michael Niedermayer wrote:
> On Tue, Jun 14, 2022 at 12:09:59AM +0200, Michael Niedermayer wrote:
> > On Tue, Jun 14, 2022 at 12:01:14AM +0200, Paul B Mahol wrote:
> > > On Mon, Jun 13, 2022 at 11:55 PM Michael Niedermayer 
> > > 
> > > wrote:
> > > 
> > > > On Mon, Jun 13, 2022 at 10:02:24AM +0200, Paul B Mahol wrote:
> > > > > Have you checked this with longer samples?
> > > >
> > > > ive tested it with the files in the bink directory on samples
> > > > anything else i should test it with ?
> > > >
> > > 
> > > Something longer, where is big gap between keyframes.
> > 
> > I would have thought that some of the 46 files in the samples archieve
> > would have adequate gaps.
> > Can you share some better test file ?
> 
> ping ?
> anyone has more files i should test ?
> if not, i suggest to apply this

google will publish this report in 5 days
just a reminder this is a out of array write and it will be very easily
searchable so anyone looking for unfixed bugs to exploit will try to
exploit this

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway


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] avcodec/libtheoraenc: Do not use invalid error code

2022-09-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/libtheoraenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c
index 22835553d6..92bf3a133c 100644
--- a/libavcodec/libtheoraenc.c
+++ b/libavcodec/libtheoraenc.c
@@ -119,7 +119,7 @@ static int get_stats(AVCodecContext *avctx, int eos)
 return 0;
 #else
 av_log(avctx, AV_LOG_ERROR, "libtheora too old to support 2pass\n");
-return AVERROR(ENOSUP);
+return AVERROR(ENOTSUP);
 #endif
 }
 
@@ -158,7 +158,7 @@ static int submit_stats(AVCodecContext *avctx)
 return 0;
 #else
 av_log(avctx, AV_LOG_ERROR, "libtheora too old to support 2pass\n");
-return AVERROR(ENOSUP);
+return AVERROR(ENOTSUP);
 #endif
 }
 
-- 
2.34.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] x86/tx_float: implement inverse MDCT AVX2 assembly

2022-09-01 Thread Lynne
This commit implements an iMDCT in pure assembly.

This is capable of processing any mod-8 transforms, rather than just
power of two, but since power of two is all we have assembly for
currently, that's what's supported.
It would really benefit if we could somehow use the C code to decide
which function to jump into, but exposing function labels from assebly
into C is anything but easy.
The post-transform loop could probably be improved.

This was somewhat annoying to write, as we must support arbitrary
strides during runtime. There's a fast branch for stride == 4 bytes
and a slower one which uses vgatherdps.

Benchmarks for stride == 4 for old (av_imdct_half) vs new (av_tx):

128pt:
   2791 decicycles in av_tx (imdct),16775675 runs,   1541 skips
   3024 decicycles in av_imdct_half,16776779 runs,    437 skips

256pt:
   5055 decicycles in av_tx (imdct), 2096602 runs,    550 skips
   5324 decicycles in av_imdct_half, 2097046 runs,    106 skips

512pt:
   9922 decicycles in av_tx (imdct), 2096983 runs,    169 skips
  10390 decicycles in av_imdct_half, 2097002 runs,    150 skips

1024pt:
  20482 decicycles in av_tx (imdct), 2097089 runs, 63 skips
  20662 decicycles in av_imdct_half, 2097115 runs, 37 skips

Patch attached.

>From 724dc202806a34995694f734ea20fc92c365ef6a Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Thu, 1 Sep 2022 23:26:29 +0200
Subject: [PATCH] x86/tx_float: implement inverse MDCT AVX2 assembly

This commit implements an iMDCT in pure assembly.

This is capable of processing any mod-8 transforms, rather than just
power of two, but since power of two is all we have assembly for
currently, that's what's supported.
It would really benefit if we could somehow use the C code to decide
which function to jump into, but exposing function labels from assebly
into C is anything but easy.
The post-transform loop could probably be improved.

This was somewhat annoying to write, as we must support arbitrary
strides during runtime. There's a fast branch for stride == 4 bytes
and a slower one which uses vgatherdps.

Benchmarks for stride == 4 for old (av_imdct_half) vs new (av_tx):

128pt:
   2791 decicycles in av_tx (imdct),16775675 runs,   1541 skips
   3024 decicycles in av_imdct_half,16776779 runs,437 skips

256pt:
   5055 decicycles in av_tx (imdct), 2096602 runs,550 skips
   5324 decicycles in av_imdct_half, 2097046 runs,106 skips

512pt:
   9922 decicycles in av_tx (imdct), 2096983 runs,169 skips
  10390 decicycles in av_imdct_half, 2097002 runs,150 skips

1024pt:
  20482 decicycles in av_tx (imdct), 2097089 runs, 63 skips
  20662 decicycles in av_imdct_half, 2097115 runs, 37 skips
---
 libavutil/tx.c|  19 ++--
 libavutil/tx_priv.h   |   8 +-
 libavutil/x86/tx_float.asm| 168 +-
 libavutil/x86/tx_float_init.c |  29 +-
 4 files changed, 209 insertions(+), 15 deletions(-)

diff --git a/libavutil/tx.c b/libavutil/tx.c
index 28e49a5d41..01f9cb7ea0 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -206,23 +206,24 @@ static void parity_revtab_generator(int *revtab, int n, int inv, int offset,
 1, 1, len >> 1, basis, dual_stride, inv_lookup);
 }
 
-int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int invert_lookup,
-int basis, int dual_stride)
+int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int len, int inv,
+int inv_lookup, int basis, int dual_stride)
 {
-int len = s->len;
-int inv = s->inv;
-
-if (!(s->map = av_mallocz(len*sizeof(*s->map
-return AVERROR(ENOMEM);
-
 basis >>= 1;
 if (len < basis)
 return AVERROR(EINVAL);
 
+if (!(s->map = av_mallocz((inv_lookup == -1 ? 2 : 1)*len*sizeof(*s->map
+return AVERROR(ENOMEM);
+
 av_assert0(!dual_stride || !(dual_stride & (dual_stride - 1)));
 av_assert0(dual_stride <= basis);
+
 parity_revtab_generator(s->map, len, inv, 0, 0, 0, len,
-basis, dual_stride, invert_lookup);
+basis, dual_stride, inv_lookup != 0);
+if (inv_lookup == -1)
+parity_revtab_generator(s->map + len, len, inv, 0, 0, 0, len,
+basis, dual_stride, 0);
 
 return 0;
 }
diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h
index e38490bd56..1688b69509 100644
--- a/libavutil/tx_priv.h
+++ b/libavutil/tx_priv.h
@@ -287,9 +287,13 @@ int ff_tx_gen_ptwo_inplace_revtab_idx(AVTXContext *s);
  * functions in AVX mode.
  *
  * If length is smaller than basis/2 this function will not do anything.
+ *
+ * If inv_lookup is set to 1, it will flip the lookup from out[map[i]] = src[i]
+ * to out[i] = src[map[i]]. If set to -1, will generate 2 maps, the first one
+ * flipped, the second one regular.
  

Re: [FFmpeg-devel] [PATCH] lavu: header and documentation for AVWriter

2022-09-01 Thread Stefano Sabatini
On date Thursday 2022-09-01 15:01:27 +0200, Nicolas George wrote:
[...] 
> Thanks for the review. I do not think it is necessary to send an updated
> patch for these changes, is it?

Not needed, thanks.
___
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 8/8] avformat/matroskaenc: Write CodecDelay for codecs != Opus

2022-09-01 Thread Andreas Rheinhardt
The field is not specific to Opus.
The mp2fixed encoder signals initial_padding and is used
by both the matroska-encoding-delay test as well as
the lavf-mkv tests which necessitated several FATE ref changes.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c  |  2 +-
 tests/ref/fate/matroska-encoding-delay | 81 +++---
 tests/ref/lavf/mkv |  4 +-
 tests/ref/lavf/mkv_attachment  |  4 +-
 tests/ref/seek/lavf-mkv| 44 +++---
 5 files changed, 74 insertions(+), 61 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 97dcff5607..ed1ad5039d 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1828,7 +1828,7 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 break;
 
 case AVMEDIA_TYPE_AUDIO:
-if (par->initial_padding && par->codec_id == AV_CODEC_ID_OPUS) {
+if (par->initial_padding) {
 int64_t codecdelay = av_rescale_q(par->initial_padding,
   (AVRational){ 1, 
par->sample_rate },
   (AVRational){ 1, 10 });
diff --git a/tests/ref/fate/matroska-encoding-delay 
b/tests/ref/fate/matroska-encoding-delay
index fb7909fe29..8dd3bf59e2 100644
--- a/tests/ref/fate/matroska-encoding-delay
+++ b/tests/ref/fate/matroska-encoding-delay
@@ -1,5 +1,5 @@
-df0524cac5393212ee103c1d1221f4b3 
*tests/data/fate/matroska-encoding-delay.matroska
-961215 tests/data/fate/matroska-encoding-delay.matroska
+b933b7b94de55ae029369312d48d8649 
*tests/data/fate/matroska-encoding-delay.matroska
+961221 tests/data/fate/matroska-encoding-delay.matroska
 #extradata 0:   22, 0x32ea0490
 #tb 0: 1/1000
 #media_type 0: video
@@ -11,67 +11,80 @@ df0524cac5393212ee103c1d1221f4b3 
*tests/data/fate/matroska-encoding-delay.matros
 #codec_id 1: mp2
 #sample_rate 1: 48000
 #channel_layout_name 1: stereo
-1,  0,  0,   24, 1152, 0x724077b8
-0, 10, 10,   40,   237628, 0xeff25579, S=1,   40
-1, 24, 24,   24, 1152, 0x80625572
-1, 48, 48,   24, 1152, 0x7d7f4dce
-0, 50, 50,   40,   238066, 0xb2265f41
-1, 72, 72,   24, 1152, 0xa6725739
-0, 90, 90,   40,   237723, 0x00d7cd24
-1, 96, 96,   24, 1152, 0xc9e85398
-1,120,120,   24, 1152, 0xda1287d3
-0,130,130,   40,   238290, 0xbe18b18f
-1,144,144,   24, 1152, 0x1c9a6102
+1,-10,-10,   24, 1152, 0x724077b8
+0,  0,  0,   40,   237628, 0xeff25579, S=1,   40
+1, 14, 14,   24, 1152, 0x80625572
+1, 38, 38,   24, 1152, 0x7d7f4dce
+0, 40, 40,   40,   238066, 0xb2265f41
+1, 62, 62,   24, 1152, 0xa6725739
+0, 80, 80,   40,   237723, 0x00d7cd24
+1, 86, 86,   24, 1152, 0xc9e85398
+1,110,110,   24, 1152, 0xda1287d3
+0,120,120,   40,   238290, 0xbe18b18f
+1,134,134,   24, 1152, 0x1c9a6102
 [PACKET]
 codec_type=audio
 stream_index=1
-pts=0
-pts_time=0.00
-dts=0
-dts_time=0.00
+pts=-10
+pts_time=-0.01
+dts=-10
+dts_time=-0.01
 duration=24
 duration_time=0.024000
 size=1152
-pos=1232
+pos=1238
 flags=K_
 [/PACKET]
 [PACKET]
 codec_type=video
 stream_index=0
-pts=10
-pts_time=0.01
-dts=10
-dts_time=0.01
+pts=0
+pts_time=0.00
+dts=0
+dts_time=0.00
 duration=40
 duration_time=0.04
 size=237628
-pos=2392
+pos=2398
 flags=K_
 [/PACKET]
 [PACKET]
 codec_type=audio
 stream_index=1
-pts=24
-pts_time=0.024000
-dts=24
-dts_time=0.024000
+pts=14
+pts_time=0.014000
+dts=14
+dts_time=0.014000
 duration=24
 duration_time=0.024000
 size=1152
-pos=240027
+pos=240033
 flags=K_
 [/PACKET]
 [PACKET]
 codec_type=audio
 stream_index=1
-pts=48
-pts_time=0.048000
-dts=48
-dts_time=0.048000
+pts=38
+pts_time=0.038000
+dts=38
+dts_time=0.038000
 duration=24
 duration_time=0.024000
 size=1152
-pos=241202
+pos=241208
+flags=K_
+[/PACKET]
+[PACKET]
+codec_type=video
+stream_index=0
+pts=40
+pts_time=0.04
+dts=40
+dts_time=0.04
+duration=40
+duration_time=0.04
+size=238066
+pos=242368
 flags=K_
 [/PACKET]
 [STREAM]
@@ -81,5 +94,5 @@ codec_name=mpeg2video
 [/STREAM]
 [STREAM]
 codec_name=mp2
-initial_padding=0
+initial_padding=481
 [/STREAM]
diff --git a/tests/ref/lavf/mkv b/tests/ref/lavf/mkv
index d9497a0a64..d54c44a647 100644
--- a/tests/ref/lavf/mkv
+++ b/tests/ref/lavf/mkv
@@ -1,3 +1,3 @@
-17e637fc06015fea86428840418ffea2 *tests/data/lavf/lavf.mkv
-320403 tests/data/lavf/lavf.mkv
+0934e35639b6735c1e26595e8f47ba70 *tests/data/lavf/lavf.mkv
+320409 tests/data/lavf/lavf.mkv
 tests/data/lavf/lavf.mkv 

[FFmpeg-devel] [PATCH 7/8] avformat/matroskaenc: Use custom min timestamp

2022-09-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c  |   1 +
 libavformat/webm_chunk.c   |   4 +
 tests/fate/matroska.mak|   2 +-
 tests/ref/fate/matroska-ogg-opus-remux | 108 ++--
 tests/ref/fate/matroska-opus-remux | 130 -
 5 files changed, 125 insertions(+), 120 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 0ded53dc21..97dcff5607 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1841,6 +1841,7 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 track->ts_offset = av_rescale_q(par->initial_padding,
 (AVRational){ 1, par->sample_rate 
},
 st->time_base);
+ffstream(st)->lowest_ts_allowed = -track->ts_offset;
 }
 if (par->codec_id == AV_CODEC_ID_OPUS)
 put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL);
diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c
index 9e71a1209d..916ed0cbab 100644
--- a/libavformat/webm_chunk.c
+++ b/libavformat/webm_chunk.c
@@ -127,6 +127,7 @@ fail:
 ffformatcontext(s)->avoid_negative_ts_use_pts =
 ffformatcontext(oc)->avoid_negative_ts_use_pts;
 oc->avoid_negative_ts = AVFMT_AVOID_NEG_TS_DISABLED;
+ffformatcontext(oc)->avoid_negative_ts_status = AVOID_NEGATIVE_TS_DISABLED;
 
 return 0;
 }
@@ -149,10 +150,13 @@ static int webm_chunk_write_header(AVFormatContext *s)
 {
 WebMChunkContext *wc = s->priv_data;
 AVFormatContext *oc = wc->avf;
+AVStream *st = s->streams[0], *ost = oc->streams[0];
 int ret;
 
 ret = avformat_write_header(oc, NULL);
 ff_format_io_close(s, >pb);
+ffstream(st)->lowest_ts_allowed = ffstream(ost)->lowest_ts_allowed;
+ffstream(ost)->lowest_ts_allowed = 0;
 wc->header_written = 1;
 if (ret < 0)
 return ret;
diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak
index 94532b31dc..63e81f121b 100644
--- a/tests/fate/matroska.mak
+++ b/tests/fate/matroska.mak
@@ -166,7 +166,7 @@ fate-matroska-mpegts-remux: CMD = transcode mpegts 
$(TARGET_SAMPLES)/mpegts/pmtc
 # Tests maintaining codec delay while remuxing from Matroska.
 # For some reason, ffmpeg shifts the timestamps of the input file
 # to make them zero before reaching the muxer while it does not
-# for the ogg-opus-remux test.
+# for the ogg-opus-remux test. -avoid_negative_ts make_zero counters this.
 FATE_MATROSKA_FFMPEG_FFPROBE-$(call REMUX, MATROSKA, OPUS_PARSER OPUS_DECODER) 
+= fate-matroska-opus-remux
 fate-matroska-opus-remux: CMD = transcode matroska 
$(TARGET_SAMPLES)/mkv/codec_delay_opus.mkv matroska "-avoid_negative_ts 
make_zero -c copy" "-copyts -c copy" "-show_packets -show_entries 
stream=codec_name,initial_padding -read_intervals %0.05"
 
diff --git a/tests/ref/fate/matroska-ogg-opus-remux 
b/tests/ref/fate/matroska-ogg-opus-remux
index da9c8d285b..1fa776ef01 100644
--- a/tests/ref/fate/matroska-ogg-opus-remux
+++ b/tests/ref/fate/matroska-ogg-opus-remux
@@ -1,4 +1,4 @@
-47b6b69c2ffdf5729557e90c72d241e9 
*tests/data/fate/matroska-ogg-opus-remux.matroska
+a3f98769fe55bc5234cf75fb1949749a 
*tests/data/fate/matroska-ogg-opus-remux.matroska
 10200 tests/data/fate/matroska-ogg-opus-remux.matroska
 #extradata 0:   19, 0x399c0471
 #tb 0: 1/1000
@@ -6,54 +6,54 @@
 #codec_id 0: opus
 #sample_rate 0: 48000
 #channel_layout_name 0: stereo
-0,  0,  0,   20,  402, 0x89b1c40f
-0, 20, 20,   20,  216, 0x7bf97146
-0, 40, 40,   20,  215, 0x6cb86d8b
-0, 60, 60,   20,  218, 0x9cfd691c
-0, 80, 80,   20,  218, 0xd7fe6a94
-0,100,100,   20,  194, 0x35735de6
-0,120,120,   20,  216, 0x3ee6705a
-0,140,140,   20,  218, 0x67eb6cb1
-0,160,160,   20,  218, 0x32d0700d
-0,180,180,   20,  219, 0xcb7f6c60
-0,200,200,   20,  218, 0x9c866b33
-0,220,220,   20,  217, 0xfe3e6a53
-0,240,240,   20,  218, 0x13586833
-0,260,260,   20,  222, 0xbcb2669e
-0,280,280,   20,  218, 0x8dfc6e33
-0,300,300,   20,  217, 0xf5957051
-0,320,320,   20,  210, 0xed126e6b
-0,340,340,   20,  216, 0xbf947249
-0,360,360,   20,  203, 0x6c7e680a
-0,380,380,   20,  209, 0xf78f6af4
-0,400,400,   20,  217, 0xd60c684d
-0,420,420,   20,  218, 0x89056a7a
-0,440,440,   20,  219, 0x0bc674ad
-0,460,460,   20,  217, 0xb1d86d1a
-0,480,480,   20,  220, 

[FFmpeg-devel] [PATCH 6/8] avformat/mux: Allow muxers to set custom min timestamp

2022-09-01 Thread Andreas Rheinhardt
Matroska requires pts to be >= 0 with a slight exception:
It has a mechanism to deal with codec delay, i.e. with
the data added at the beginning that does not correspond
to actual input data and should be discarded by the player.
Only the audio actually intended to be output needs to have
a timestamp >= 0.
In order to avoid unnecessary timestamp shifting, this patch
allows muxers to inform the shifting code about this so that
it can take it into account.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/internal.h | 7 +++
 libavformat/mux.c  | 7 +--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 9b07cfb271..23757dc4fc 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -310,6 +310,13 @@ typedef struct FFStream {
  */
 int64_t mux_ts_offset;
 
+/**
+ * This is the lowest ts allowed in this track; it may be set by the muxer
+ * during init or write_header and influences the automatic timestamp
+ * shifting code.
+ */
+int64_t lowest_ts_allowed;
+
 /**
  * Internal data to check for wrapping of the time stamp
  */
diff --git a/libavformat/mux.c b/libavformat/mux.c
index a3b50dadb6..5d89458f82 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -632,6 +632,8 @@ static void handle_avoid_negative_ts(FFFormatContext *si, 
FFStream *sti,
 if (ts == AV_NOPTS_VALUE)
 return;
 
+ts -= sti->lowest_ts_allowed;
+
 /* Peek into the muxing queue to improve our estimate
  * of the lowest timestamp if av_interleaved_write_frame() is used. */
 for (const PacketListEntry *pktl = si->packet_buffer.head;
@@ -640,6 +642,7 @@ static void handle_avoid_negative_ts(FFFormatContext *si, 
FFStream *sti,
 int64_t cmp_ts = use_pts ? pktl->pkt.pts : pktl->pkt.dts;
 if (cmp_ts == AV_NOPTS_VALUE)
 continue;
+cmp_ts -= 
ffstream(s->streams[pktl->pkt.stream_index])->lowest_ts_allowed;
 if (s->output_ts_offset)
 cmp_ts += av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, 
cmp_tb);
 if (av_compare_ts(cmp_ts, cmp_tb, ts, tb) < 0) {
@@ -669,7 +672,7 @@ static void handle_avoid_negative_ts(FFFormatContext *si, 
FFStream *sti,
 pkt->pts += offset;
 
 if (si->avoid_negative_ts_use_pts) {
-if (pkt->pts != AV_NOPTS_VALUE && pkt->pts < 0) {
+if (pkt->pts != AV_NOPTS_VALUE && pkt->pts < sti->lowest_ts_allowed) {
 av_log(s, AV_LOG_WARNING, "failed to avoid negative "
"pts %s in stream %d.\n"
"Try -avoid_negative_ts 1 as a possible workaround.\n",
@@ -678,7 +681,7 @@ static void handle_avoid_negative_ts(FFFormatContext *si, 
FFStream *sti,
 );
 }
 } else {
-if (pkt->dts != AV_NOPTS_VALUE && pkt->dts < 0) {
+if (pkt->dts != AV_NOPTS_VALUE && pkt->dts < sti->lowest_ts_allowed) {
 av_log(s, AV_LOG_WARNING,
"Packets poorly interleaved, failed to avoid negative "
"timestamp %s in stream %d.\n"
-- 
2.34.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 5/8] avformat/matroskaenc: Actually apply timestamp offset for Opus

2022-09-01 Thread Andreas Rheinhardt
Matroska generally requires timestamps to be nonnegative, but
there is an exception: Data that corresponds to encoder delay
and is not supposed to be output anyway can have a negative
timestamp. This is achieved by using the CodecDelay header
field: The demuxer has to subtract this value from the raw
(nonnegative) timestamps of the corresponding track.
Therefore the muxer has to add this value first to write
this raw timestamp.

Support for writing CodecDelay has been added in FFmpeg commit
d92b1b1babe69268971863649c225e1747358a74 and in Libav commit
a1aa37dd0b96710d4a17718198a3f56aea2040c1. The former simply
wrote the header field and did not apply any timestamp offsets,
leading to desynchronisation (if one uses multiple tracks).
The latter applied it at two places, but not at the one where
it actually matters, namely in mkv_write_block(), leading to
the same desynchronisation as with the former commit. It furthermore
used the wrong stream timebase to convert the delay to the
stream's timebase, as the conversion used the timebase from
before avpriv_set_pts_info().

When the latter was merged in 82e4f39883932c1b1e5c7792a1be12dec6ab603d,
it was only done in a deactivated state that still did not
offset the timestamps when muxing due to "assertion failures
and av sync errors". a1aa37dd0b96710d4a17718198a3f56aea2040c1
made it definitely more likely to run into assertion failures
(namely if the relative block timestamp doesn't fit into an int16_t).

Yet all of the above issues have been fixed (in commits
962d63157322466a9a82f9f9d84c1b6f1b582f65,
5d3953a5dcfd5f71391b7f34908517eb6f7e5146 and
4ebeab15b037a21f195696cef1f7522daf42f3ee. This commit therefore
enables applying CodecDelay, fixing ticket #7182.

There is just one slight regression from this: If one has input
with encoder delay where the first timestamp is negative, but
the pts of the part of the data that is actually intended to be
output is nonnegative, then the timestamps will currently by default
be shifted to make them nonnegative before they reach the muxer;
the muxer will then ensure that the shifted timestamps are retained.
Before this commit, the muxer did not ensure this; instead the
timestamps that the demuxer will output were shifted and
if the first timestamp of the actually intended output was zero
before shifting, then this unintentional shift just cancels
the shift performed before the packet reached the muxer.
(But notice that this only applies if all the tracks use the same
CodecDelay, or the relative sync between tracks will be impaired.)
This happens in the matroska-opus-remux and matroska-ogg-opus-remux
FATE tests. Future commits will forward the information that
the Matroska muxer has a limited capability to handle negative
timestamps so that the shifting in libavformat can take advantage
of it.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c  |   8 +-
 tests/ref/fate/matroska-ogg-opus-remux | 108 ++--
 tests/ref/fate/matroska-opus-remux | 130 -
 3 files changed, 123 insertions(+), 123 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index c525edb39f..0ded53dc21 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1836,11 +1836,11 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 av_log(s, AV_LOG_ERROR, "Initial padding is invalid\n");
 return AVERROR(EINVAL);
 }
-//track->ts_offset = av_rescale_q(par->initial_padding,
-//(AVRational){ 1, 
par->sample_rate },
-//st->time_base);
-
 put_ebml_uint(pb, MATROSKA_ID_CODECDELAY, codecdelay);
+
+track->ts_offset = av_rescale_q(par->initial_padding,
+(AVRational){ 1, par->sample_rate 
},
+st->time_base);
 }
 if (par->codec_id == AV_CODEC_ID_OPUS)
 put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL);
diff --git a/tests/ref/fate/matroska-ogg-opus-remux 
b/tests/ref/fate/matroska-ogg-opus-remux
index 1fa776ef01..da9c8d285b 100644
--- a/tests/ref/fate/matroska-ogg-opus-remux
+++ b/tests/ref/fate/matroska-ogg-opus-remux
@@ -1,4 +1,4 @@
-a3f98769fe55bc5234cf75fb1949749a 
*tests/data/fate/matroska-ogg-opus-remux.matroska
+47b6b69c2ffdf5729557e90c72d241e9 
*tests/data/fate/matroska-ogg-opus-remux.matroska
 10200 tests/data/fate/matroska-ogg-opus-remux.matroska
 #extradata 0:   19, 0x399c0471
 #tb 0: 1/1000
@@ -6,54 +6,54 @@ a3f98769fe55bc5234cf75fb1949749a 
*tests/data/fate/matroska-ogg-opus-remux.matros
 #codec_id 0: opus
 #sample_rate 0: 48000
 #channel_layout_name 0: stereo
-0, -7, -7,   20,  402, 0x89b1c40f
-0, 13, 13,   20,  216, 0x7bf97146
-0, 33, 33,   20,  215, 0x6cb86d8b

[FFmpeg-devel] [PATCH 4/8] avformat/matroskaenc: Don't override samplerate for CodecDelay

2022-09-01 Thread Andreas Rheinhardt
Opus can be decoded to multiple samplerates (namely 48kHz, 24KHz,
16Khz, 12 KHz and 8Khz); libopus as well as our encoder wrapper
support these sample rates. The OpusHead contains a field for
this original samplerate. Yet the pre-skip (and the granule-position
in the Ogg-Opus mapping in general) are always in the 48KHz clock,
irrespective of the original sample rate.

Before commit c3c22bee6362737cf290929b7f31df9fb88da983, our libopus
encoder was buggy: It did not account for the fact that the pre-skip
field is always according to a 48kHz clock and wrote a too small
value in case one uses the encoder with a sample rate other than 48kHz;
this discrepancy between CodecDelay and OpusHead led to Firefox
rejecting such streams.

In order to account for that, said commit made the muxer always use
48kHz instead of the actual sample rate to convert the initial_padding
(in samples in the stream's sample rate) to ns. This meant that both
fields are now off by the same factor, so Firefox was happy.

Then commit f4bdeddc3cab807e43e0450744dfe9a45661e1d7 fixed the issue
in libopusenc; so the OpusHead is correct, but the CodecDelay is
still off*. This commit fixes this by effectively reverting
c3c22bee6362737cf290929b7f31df9fb88da983.

*: Firefox seems to no longer abort when CodecDelay and OpusHead
are off.

Signed-off-by: Andreas Rheinhardt 
---
Non-48kHz Opus is also weird in the demuxer: avformat_find_stream_info()
sets the samplerate to 48kHz. Therefore 49b0246635 calculated
initial_padding based upon 48kHz for Opus, regardless of the actual
sample rate indicated in the TrackEntry. This is wrong if
avformat_find_stream_info() is not used. I think a better (but still
hacky) solution would be to just report the sample rate as 48kHz
for Opus regardless of what the header says.

(Trying to pass initial padding through the decoder is problematic:
The corresponding field of AVCodecContext is unused for decoding,
instead there is a delay field which is always set by libavcodec
whose semantics are unclear (there are two inconsistent definitions:
"Number of frames delay in addition to what a standard decoder
as specified in the spec would produce." and "the number of samples
the decoder needs to output before the decoder's output is valid".
The Opus decoders and parser are the only components that set delay
at all (based upon OpusHead). When converting
AVCodecParameters->AVCodecContext, initial_padding is mapped to both
delay and initial_padding; in the other direction, initial_padding
is taken from initial_padding (which is encoder-only). If one wants
to pass this value through the decoder, then the best way to do so
is probably to use initial_padding for decoding, too, and let the
user set it and let lavc update it if the decoder encounters
information about this in the bitstream/extradata. This includes
that lavc updates initial_padding if it changes the sample rate
(as it does for Opus). This would also fix delay (the second definition
would be deprecated).)


 libavformat/matroskaenc.c | 2 +-
 libavformat/version.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index de6c993e6a..c525edb39f 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1830,7 +1830,7 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 case AVMEDIA_TYPE_AUDIO:
 if (par->initial_padding && par->codec_id == AV_CODEC_ID_OPUS) {
 int64_t codecdelay = av_rescale_q(par->initial_padding,
-  (AVRational){ 1, 48000 },
+  (AVRational){ 1, 
par->sample_rate },
   (AVRational){ 1, 10 });
 if (codecdelay < 0) {
 av_log(s, AV_LOG_ERROR, "Initial padding is invalid\n");
diff --git a/libavformat/version.h b/libavformat/version.h
index 7b414039ad..a54ffd6c0e 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 #include "version_major.h"
 
 #define LIBAVFORMAT_VERSION_MINOR  30
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
-- 
2.34.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 3/8] avformat/matroskaenc: Only write DiscardPadding if nonzero

2022-09-01 Thread Andreas Rheinhardt
It is possible for the trailing padding to be zero, namely
e.g. if the AV_PKT_DATA_SKIP_SAMPLES side data is used
for leading padding. Matroska supports this (use a negative
DiscardPadding), but players do not; at least Firefox refuses
to play such a file. So for now only write DiscardPadding
if it is trailing padding and nonzero.
The fate-matroska-ogg-opus-remux was affected by this.

(I wish CodecDelay would not exist and DiscardPadding would
be used to instead trim the codec delay away (with the Block
timestamp corresponding to the time at which the actually
output audio is output).)

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c  | 12 +++-
 tests/ref/fate/matroska-ogg-opus-remux | 10 +-
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 1256bdfe36..de6c993e6a 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2591,7 +2591,6 @@ static int mkv_write_block(void *logctx, 
MatroskaMuxContext *mkv,
 uint8_t *side_data;
 size_t side_data_size;
 uint64_t additional_id;
-int64_t discard_padding = 0;
 unsigned track_number = track->track_num;
 EBML_WRITER(9);
 
@@ -2619,10 +2618,13 @@ static int mkv_write_block(void *logctx, 
MatroskaMuxContext *mkv,
 AV_PKT_DATA_SKIP_SAMPLES,
 _data_size);
 if (side_data && side_data_size >= 10) {
-discard_padding = av_rescale_q(AV_RL32(side_data + 4),
-   (AVRational){1, par->sample_rate},
-   (AVRational){1, 10});
-ebml_writer_add_sint(, MATROSKA_ID_DISCARDPADDING, 
discard_padding);
+int64_t discard_padding = AV_RL32(side_data + 4);
+if (discard_padding) {
+discard_padding = av_rescale_q(discard_padding,
+   (AVRational){1, par->sample_rate},
+   (AVRational){1, 10});
+ebml_writer_add_sint(, MATROSKA_ID_DISCARDPADDING, 
discard_padding);
+}
 }
 
 side_data = av_packet_get_side_data(pkt,
diff --git a/tests/ref/fate/matroska-ogg-opus-remux 
b/tests/ref/fate/matroska-ogg-opus-remux
index b69c29df8e..1fa776ef01 100644
--- a/tests/ref/fate/matroska-ogg-opus-remux
+++ b/tests/ref/fate/matroska-ogg-opus-remux
@@ -1,5 +1,5 @@
-605e8e89efb3028e261dd10255c7f59a 
*tests/data/fate/matroska-ogg-opus-remux.matroska
-10207 tests/data/fate/matroska-ogg-opus-remux.matroska
+a3f98769fe55bc5234cf75fb1949749a 
*tests/data/fate/matroska-ogg-opus-remux.matroska
+10200 tests/data/fate/matroska-ogg-opus-remux.matroska
 #extradata 0:   19, 0x399c0471
 #tb 0: 1/1000
 #media_type 0: audio
@@ -57,7 +57,7 @@ dts_time=-0.007000
 duration=20
 duration_time=0.02
 size=402
-pos=543
+pos=540
 flags=K_
 [/PACKET]
 [PACKET]
@@ -70,7 +70,7 @@ dts_time=0.013000
 duration=20
 duration_time=0.02
 size=216
-pos=956
+pos=949
 flags=K_
 [/PACKET]
 [PACKET]
@@ -83,7 +83,7 @@ dts_time=0.033000
 duration=20
 duration_time=0.02
 size=215
-pos=1179
+pos=1172
 flags=K_
 [/PACKET]
 [STREAM]
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 2/8] fate/matroska: Add tests for muxing with initial_padding

2022-09-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 tests/fate/matroska.mak|  19 +
 tests/ref/fate/matroska-encoding-delay |  85 
 tests/ref/fate/matroska-ogg-opus-remux |  92 ++
 tests/ref/fate/matroska-opus-remux | 103 +
 4 files changed, 299 insertions(+)
 create mode 100644 tests/ref/fate/matroska-encoding-delay
 create mode 100644 tests/ref/fate/matroska-ogg-opus-remux
 create mode 100644 tests/ref/fate/matroska-opus-remux

diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak
index b49ec761cf..94532b31dc 100644
--- a/tests/fate/matroska.mak
+++ b/tests/fate/matroska.mak
@@ -163,6 +163,25 @@ FATE_MATROSKA_FFMPEG_FFPROBE-$(call REMUX, MATROSKA, 
MPEGTS_DEMUXER AC3_DECODER)
+= fate-matroska-mpegts-remux
 fate-matroska-mpegts-remux: CMD = transcode mpegts 
$(TARGET_SAMPLES)/mpegts/pmtchange.ts matroska "-map 0:2 -map 0:2 -c copy 
-disposition:a:1 -visual_impaired+hearing_impaired -default_mode infer" "-map 0 
-c copy" "-show_entries stream_disposition:stream=index"
 
+# Tests maintaining codec delay while remuxing from Matroska.
+# For some reason, ffmpeg shifts the timestamps of the input file
+# to make them zero before reaching the muxer while it does not
+# for the ogg-opus-remux test.
+FATE_MATROSKA_FFMPEG_FFPROBE-$(call REMUX, MATROSKA, OPUS_PARSER OPUS_DECODER) 
+= fate-matroska-opus-remux
+fate-matroska-opus-remux: CMD = transcode matroska 
$(TARGET_SAMPLES)/mkv/codec_delay_opus.mkv matroska "-avoid_negative_ts 
make_zero -c copy" "-copyts -c copy" "-show_packets -show_entries 
stream=codec_name,initial_padding -read_intervals %0.05"
+
+# Tests maintaining codec delay while remuxing from ogg.
+FATE_MATROSKA_FFMPEG_FFPROBE-$(call REMUX, MATROSKA, OGG_DEMUXER OPUS_PARSER 
OPUS_DECODER) += fate-matroska-ogg-opus-remux
+fate-matroska-ogg-opus-remux: CMD = transcode ogg 
$(TARGET_SAMPLES)/ogg/intro-partial.opus matroska "-c copy" "-copyts -c copy" 
"-show_packets -show_entries stream=codec_name,initial_padding -read_intervals 
%0.05"
+
+# This tests reencoding with an audio encoder that adds initial padding.
+# The initial padding is currently not maintained.
+FATE_MATROSKA_FFMPEG_FFPROBE-$(call REMUX, MATROSKA, MXF_DEMUXER 
PCM_S16LE_DECODER \
+   MP2FIXED_ENCODER ARESAMPLE_FILTER   
\
+   MPEG2VIDEO_DECODER MPEGVIDEO_PARSER 
\
+   EXTRACT_EXTRADATA_BSF) += 
fate-matroska-encoding-delay
+fate-matroska-encoding-delay: CMD = transcode mxf 
$(TARGET_SAMPLES)/mxf/Sony-1.mxf matroska "-c:v copy -af aresample -c:a 
mp2fixed" "-copyts -c copy" "-show_packets -show_entries 
stream=codec_name,initial_padding -read_intervals %0.05"
+
 FATE_MATROSKA-$(call REMUX, MATROSKA, SUP_DEMUXER) += fate-matroska-pgs-remux
 fate-matroska-pgs-remux: CMD = transcode sup $(TARGET_SAMPLES)/sub/pgs_sub.sup 
matroska "-copyts -c:s copy" "-copyts -c:s copy"
 
diff --git a/tests/ref/fate/matroska-encoding-delay 
b/tests/ref/fate/matroska-encoding-delay
new file mode 100644
index 00..fb7909fe29
--- /dev/null
+++ b/tests/ref/fate/matroska-encoding-delay
@@ -0,0 +1,85 @@
+df0524cac5393212ee103c1d1221f4b3 
*tests/data/fate/matroska-encoding-delay.matroska
+961215 tests/data/fate/matroska-encoding-delay.matroska
+#extradata 0:   22, 0x32ea0490
+#tb 0: 1/1000
+#media_type 0: video
+#codec_id 0: mpeg2video
+#dimensions 0: 720x608
+#sar 0: 152/135
+#tb 1: 1/1000
+#media_type 1: audio
+#codec_id 1: mp2
+#sample_rate 1: 48000
+#channel_layout_name 1: stereo
+1,  0,  0,   24, 1152, 0x724077b8
+0, 10, 10,   40,   237628, 0xeff25579, S=1,   40
+1, 24, 24,   24, 1152, 0x80625572
+1, 48, 48,   24, 1152, 0x7d7f4dce
+0, 50, 50,   40,   238066, 0xb2265f41
+1, 72, 72,   24, 1152, 0xa6725739
+0, 90, 90,   40,   237723, 0x00d7cd24
+1, 96, 96,   24, 1152, 0xc9e85398
+1,120,120,   24, 1152, 0xda1287d3
+0,130,130,   40,   238290, 0xbe18b18f
+1,144,144,   24, 1152, 0x1c9a6102
+[PACKET]
+codec_type=audio
+stream_index=1
+pts=0
+pts_time=0.00
+dts=0
+dts_time=0.00
+duration=24
+duration_time=0.024000
+size=1152
+pos=1232
+flags=K_
+[/PACKET]
+[PACKET]
+codec_type=video
+stream_index=0
+pts=10
+pts_time=0.01
+dts=10
+dts_time=0.01
+duration=40
+duration_time=0.04
+size=237628
+pos=2392
+flags=K_
+[/PACKET]
+[PACKET]
+codec_type=audio
+stream_index=1
+pts=24
+pts_time=0.024000
+dts=24
+dts_time=0.024000
+duration=24
+duration_time=0.024000
+size=1152
+pos=240027
+flags=K_
+[/PACKET]
+[PACKET]
+codec_type=audio
+stream_index=1
+pts=48
+pts_time=0.048000
+dts=48
+dts_time=0.048000
+duration=24
+duration_time=0.024000
+size=1152

[FFmpeg-devel] [PATCH 1/8] fftools/ffprobe: Report initial and trailing padding

2022-09-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
trailing_padding seems to be unused and could actually be deprecated.

 doc/ffprobe.xsd | 2 ++
 fftools/ffprobe.c   | 3 +++
 tests/ref/fate/concat-demuxer-extended-lavf-mxf | 2 +-
 tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 | 2 +-
 tests/ref/fate/concat-demuxer-simple1-lavf-mxf  | 2 +-
 tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10  | 2 +-
 tests/ref/fate/concat-demuxer-simple2-lavf-ts   | 2 +-
 tests/ref/fate/ffprobe_compact  | 2 +-
 tests/ref/fate/ffprobe_csv  | 2 +-
 tests/ref/fate/ffprobe_default  | 2 ++
 tests/ref/fate/ffprobe_flat | 2 ++
 tests/ref/fate/ffprobe_ini  | 2 ++
 tests/ref/fate/ffprobe_json | 2 ++
 tests/ref/fate/ffprobe_xml  | 2 +-
 tests/ref/fate/flv-demux| 2 +-
 tests/ref/fate/gapless-mp3-side-data| 2 +-
 tests/ref/fate/mxf-probe-applehdr10 | 4 
 tests/ref/fate/mxf-probe-d10| 2 ++
 tests/ref/fate/mxf-probe-dv25   | 4 
 tests/ref/fate/oggopus-demux| 2 +-
 tests/ref/fate/ts-demux | 4 ++--
 tests/ref/fate/ts-opus-demux| 2 +-
 22 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/doc/ffprobe.xsd b/doc/ffprobe.xsd
index 6e678a9970..6052a5eff4 100644
--- a/doc/ffprobe.xsd
+++ b/doc/ffprobe.xsd
@@ -246,6 +246,8 @@
   
   
   
+  
+  
 
   
   
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 3344a06409..9eb20fa4cd 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3044,6 +3044,9 @@ static int show_stream(WriterContext *w, AVFormatContext 
*fmt_ctx, int stream_id
 }
 
 print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id));
+
+print_int("initial_padding",  par->initial_padding);
+print_int("trailing_padding", par->trailing_padding);
 break;
 
 case AVMEDIA_TYPE_SUBTITLE:
diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf 
b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
index 543c7d6a8c..973ce5d4a4 100644
--- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf
+++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
@@ -1 +1 @@
-d367d7f6df7292cbf454c6d07fca9b04 
*tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe
+3fa8632676f0e40c42be38b842794afc 
*tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe
diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 
b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
index 57b22848b9..905ae46343 100644
--- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
+++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
@@ -1 +1 @@
-1fac6962d4c5f1070d0d2db5ab7d86aa 
*tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe
+f88c5d6b16ec3ffd5d35b64a031489be 
*tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe
diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf 
b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
index dcc98e9bdb..c227fa534c 100644
--- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
+++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
@@ -100,4 +100,4 @@ 
video|0|33|1.32|33|1.32|1|0.04|12362|195072|__|1|Strings Metadata
 audio|1|65280|1.36|65280|1.36|1920|0.04|3840|207872|K_|1|Strings 
Metadata
 video|0|37|1.48|34|1.36|1|0.04|24786|212480|K_|1|Strings Metadata
 
0|mpeg2video|4|video|[0][0][0][0]|0x|352|288|0|0|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|1|N/A|25/1|25/1|1/25|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|51|22|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301|CPB
 properties|0|0|0|49152|-1
-1|pcm_s16le|unknown|audio|[0][0][0][0]|0x|s16|48000|1|unknown|16|N/A|0/0|0/0|1/48000|0|0.00|N/A|N/A|768000|N/A|N/A|N/A|N/A|50|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
+1|pcm_s16le|unknown|audio|[0][0][0][0]|0x|s16|48000|1|unknown|16|0|0|N/A|0/0|0/0|1/48000|0|0.00|N/A|N/A|768000|N/A|N/A|N/A|N/A|50|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 
b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
index 8937724ed1..f26e3c2e1b 100644
--- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
+++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
@@ -69,4 +69,4 @@ 
audio|1|63360|1.32|63360|1.32|1920|0.04|7680|1861632|K_|1|Strings Me
 video|0|34|1.36|34|1.36|1|0.04|15|1924096|K_|1|Strings Metadata
 audio|1|65280|1.36|65280|1.36|1920|0.04|7680|2074624|K_|1|Strings 
Metadata
 

[FFmpeg-devel] [PATCH]lavfi/rotate: Fix undefined behaviour

2022-09-01 Thread Carl Eugen Hoyos
Hi!

Attached patch fixes ticket #9799.

Please comment, Carl Eugen
From 2cce687961c3b56a92d88184269bf9fa075ae297 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Thu, 1 Sep 2022 20:55:54 +0200
Subject: [PATCH] lavfi/rotate: Avoid undefined behaviour.

Fixes the following integer overflows:
libavfilter/vf_rotate.c:273:13: runtime error: signed integer overflow: 92951468 + 2058533568 cannot be represented in type 'int'
libavfilter/vf_rotate.c:273:37: runtime error: signed integer overflow: 39684 * 54149 cannot be represented in type 'int'
libavfilter/vf_rotate.c:272:13: runtime error: signed integer overflow: 247587320 + 1900985032 cannot be represented in type 'int'
libavfilter/vf_rotate.c:272:37: runtime error: signed integer overflow: 42584 * 50430 cannot be represented in type 'int'
libavfilter/vf_rotate.c:272:50: runtime error: signed integer overflow: 65083 * 52912 cannot be represented in type 'int'
libavfilter/vf_rotate.c:273:50: runtime error: signed integer overflow: 65286 * 38044 cannot be represented in type 'int'

Fixes ticket #9799, different output with different compilers.
---
 libavfilter/vf_rotate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_rotate.c b/libavfilter/vf_rotate.c
index 4429e3d543..d319dfe3d9 100644
--- a/libavfilter/vf_rotate.c
+++ b/libavfilter/vf_rotate.c
@@ -269,8 +269,8 @@ static uint8_t *interpolate_bilinear16(uint8_t *dst_color,
 int s01 = AV_RL16([src_linestep * int_x1 + i + src_linesize * int_y ]);
 int s10 = AV_RL16([src_linestep * int_x  + i + src_linesize * int_y1]);
 int s11 = AV_RL16([src_linestep * int_x1 + i + src_linesize * int_y1]);
-int s0 = (((1<<16) - frac_x)*s00 + frac_x*s01);
-int s1 = (((1<<16) - frac_x)*s10 + frac_x*s11);
+int64_t s0 = (((int64_t)(1<<16) - frac_x)*s00 + (int64_t)frac_x*s01);
+int64_t s1 = (((int64_t)(1<<16) - frac_x)*s10 + (int64_t)frac_x*s11);
 
 AV_WL16(_color[i], ((int64_t)((1<<16) - frac_y)*s0 + (int64_t)frac_y*s1) >> 32);
 }
-- 
2.30.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 1/1] avcodec/mpegutils: add motion_vec debug mode

2022-09-01 Thread Chema Gonzalez
Hi Paul,

Can you please describe how you can get the MV values?

Thanks,
-Chema


On Thu, Sep 1, 2022 at 10:52 AM Paul B Mahol  wrote:
>
> On Thu, Sep 1, 2022 at 5:06 PM Chema Gonzalez  wrote:
>
> > Hi,
> >
> > All the other debug modes (qp, skip, mb_type) use the same approach.
> >
> >
> This adds to much code for something that is already possible.
>
>
> > -Chema
> >
> >
> > On Thu, Sep 1, 2022 at 6:30 AM Ronald S. Bultje 
> > wrote:
> > >
> > > Hi,
> > >
> > > On Wed, Aug 31, 2022 at 7:10 PM Chema Gonzalez  wrote:
> > >>
> > >> Add a new debug mode ("motion_vec") that prints the values of the
> > >> motion vectors (MV).
> > >
> > >
> > > Isn't this super-hacky? In a well-designed system, a codec might export
> > its MVs using designated structs (which we already have) and then use these
> > structs to print it in a codec-agnostic way using a filter (which IIRC we
> > already have?).
> > >
> > > Ronald
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> >
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH]lavc/tiff: Support multi-component files without RowsPerStrip tag

2022-09-01 Thread Carl Eugen Hoyos
Am Do., 1. Sept. 2022 um 04:10 Uhr schrieb Steven Liu :
>
> Carl Eugen Hoyos  于2022年9月1日周四 01:48写道:
> >
> > Hi!
> >
> > Attached patch fixes ticket #9514 for me.
> >
> > Please review, Carl Eugen
>
> lgtm

Patch applied.

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

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


Re: [FFmpeg-devel] [PATCH 1/1] avcodec/mpegutils: add motion_vec debug mode

2022-09-01 Thread Paul B Mahol
On Thu, Sep 1, 2022 at 5:06 PM Chema Gonzalez  wrote:

> Hi,
>
> All the other debug modes (qp, skip, mb_type) use the same approach.
>
>
This adds to much code for something that is already possible.


> -Chema
>
>
> On Thu, Sep 1, 2022 at 6:30 AM Ronald S. Bultje 
> wrote:
> >
> > Hi,
> >
> > On Wed, Aug 31, 2022 at 7:10 PM Chema Gonzalez  wrote:
> >>
> >> Add a new debug mode ("motion_vec") that prints the values of the
> >> motion vectors (MV).
> >
> >
> > Isn't this super-hacky? In a well-designed system, a codec might export
> its MVs using designated structs (which we already have) and then use these
> structs to print it in a codec-agnostic way using a filter (which IIRC we
> already have?).
> >
> > Ronald
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/1] avcodec/mpegutils: add motion_vec debug mode

2022-09-01 Thread Chema Gonzalez
Hi,

All the other debug modes (qp, skip, mb_type) use the same approach.

-Chema


On Thu, Sep 1, 2022 at 6:30 AM Ronald S. Bultje  wrote:
>
> Hi,
>
> On Wed, Aug 31, 2022 at 7:10 PM Chema Gonzalez  wrote:
>>
>> Add a new debug mode ("motion_vec") that prints the values of the
>> motion vectors (MV).
>
>
> Isn't this super-hacky? In a well-designed system, a codec might export its 
> MVs using designated structs (which we already have) and then use these 
> structs to print it in a codec-agnostic way using a filter (which IIRC we 
> already have?).
>
> Ronald
___
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 v11 9/9] Changes in Changelog and MAINTAINERS files

2022-09-01 Thread Dawid Kozinski
- Changelog update
- MAINTAINERS update

Signed-off-by: Dawid Kozinski 
---
 Changelog   | 4 ++--
 MAINTAINERS | 5 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index fa83786a20..9631262858 100644
--- a/Changelog
+++ b/Changelog
@@ -36,7 +36,8 @@ version 5.1:
 - PHM image format support
 - remap_opencl filter
 - added chromakey_cuda filter
-
+- eXtra-fast Essential Video Encoder (XEVE)
+- eXtra-fast Essential Video Decoder (XEVD)
 
 version 5.0:
 - ADPCM IMA Westwood encoder
@@ -83,7 +84,6 @@ version 5.0:
 - anlmf audio filter
 - IMF demuxer (experimental)
 
-
 version 4.4:
 - AudioToolbox output device
 - MacCaption demuxer
diff --git a/MAINTAINERS b/MAINTAINERS
index ed2ec0b90c..69fc04e1d6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -206,6 +206,8 @@ Codecs:
   libvpx*   James Zern
   libxavs.c Stefan Gehrer
   libxavs2.cHuiwen Ren
+  libxevd.c Dawid Kozinski
+  libxeve.c,Dawid Kozinski
   libzvbi-teletextdec.c Marton Balint
   lzo.h, lzo.c  Reimar Doeffinger
   mdec.cMichael Niedermayer
@@ -426,6 +428,9 @@ Muxers/Demuxers:
   dv.c  Roman Shaposhnik
   electronicarts.c  Peter Ross
   epafdec.c Paul B Mahol
+  evc.c, evc.h  Dawid Kozinski
+  evcdec.c  Dawid Kozinski
+  evc_parser.c  Dawid Kozinski
   ffm*  Baptiste Coudurier
   flic.cMike Melanson
   flvdec.c  Michael Niedermayer
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v11 8/9] Extended MOV demuxer to handle EVC video content

2022-09-01 Thread Dawid Kozinski
- Added evc extension to the list of extensions for ff_mov_demuxer

Signed-off-by: Dawid Kozinski 
---
 libavformat/mov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 35e2271b14..d537dfd434 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -9127,7 +9127,7 @@ const AVInputFormat ff_mov_demuxer = {
 .long_name  = NULL_IF_CONFIG_SMALL("QuickTime / MOV"),
 .priv_class = _class,
 .priv_data_size = sizeof(MOVContext),
-.extensions = "mov,mp4,m4a,3gp,3g2,mj2,psp,m4b,ism,ismv,isma,f4v,avif",
+.extensions = 
"mov,mp4,m4a,3gp,3g2,mj2,psp,m4b,ism,ismv,isma,f4v,avif,evc",
 .flags_internal = FF_FMT_INIT_CLEANUP,
 .read_probe = mov_probe,
 .read_header= mov_read_header,
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v11 7/9] Extended MOV muxer to handle EVC video content

2022-09-01 Thread Dawid Kozinski
- Changes in mov_write_video_tag function to handle EVC elementary stream
- Provided structure EVCDecoderConfigurationRecord that specifies the decoder 
configuration information for ISO/IEC 23094-1 video content

Signed-off-by: Dawid Kozinski 
---
 libavformat/Makefile|   2 +-
 libavformat/evc.c   | 461 
 libavformat/evc.h   |  44 
 libavformat/isom_tags.c |   2 +
 libavformat/movenc.c|  35 ++-
 5 files changed, 542 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/evc.c
 create mode 100644 libavformat/evc.h

diff --git a/libavformat/Makefile b/libavformat/Makefile
index a320cac22b..bb4e96e460 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -360,7 +360,7 @@ OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o 
mov_chan.o mov_esds.o \
 OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vpcc.o 
\
 movenchint.o mov_chan.o rtp.o \
 movenccenc.o movenc_ttml.o 
rawutils.o \
-dovi_isom.o
+dovi_isom.o evc.o
 OBJS-$(CONFIG_MP2_MUXER) += rawenc.o
 OBJS-$(CONFIG_MP3_DEMUXER)   += mp3dec.o replaygain.o
 OBJS-$(CONFIG_MP3_MUXER) += mp3enc.o rawenc.o id3v2enc.o
diff --git a/libavformat/evc.c b/libavformat/evc.c
new file mode 100644
index 00..7953ee299a
--- /dev/null
+++ b/libavformat/evc.c
@@ -0,0 +1,461 @@
+/*
+ * EVC helper functions for muxers
+ * Copyright (c) 2022 Dawid Kozinski 
+ *
+ * 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/intreadwrite.h"
+#include "libavcodec/get_bits.h"
+#include "libavcodec/golomb.h"
+#include "libavcodec/evc.h"
+#include "avformat.h"
+#include "avio.h"
+#include "evc.h"
+#include "avio_internal.h"
+
+// The length field that indicates the length in bytes of the following NAL 
unit is configured to be of 4 bytes
+#define EVC_NAL_UNIT_LENGTH_BYTE(4)  /* byte */
+#define EVC_NAL_HEADER_SIZE (2)  /* byte */
+
+// rpl structure
+typedef struct RefPicListStruct {
+int poc;
+int tid;
+int ref_pic_num;
+int ref_pic_active_num;
+int ref_pics[EVC_MAX_NUM_REF_PICS];
+char pic_type;
+
+} RefPicListStruct;
+
+// The sturcture reflects SPS RBSP(raw byte sequence payload) layout
+// @see ISO_IEC_23094-1 section 7.3.2.1
+//
+// The following descriptors specify the parsing process of each element
+// u(n) - unsigned integer using n bits
+// ue(v) - unsigned integer 0-th order Exp_Golomb-coded syntax element with 
the left bit first
+typedef struct EVCSPS {
+int sps_seq_parameter_set_id;   // ue(v)
+int profile_idc;// u(8)
+int level_idc;  // u(8)
+int toolset_idc_h;  // u(32)
+int toolset_idc_l;  // u(32)
+int chroma_format_idc;  // ue(v)
+int pic_width_in_luma_samples;  // ue(v)
+int pic_height_in_luma_samples; // ue(v)
+int bit_depth_luma_minus8;  // ue(v)
+int bit_depth_chroma_minus8;// ue(v)
+
+// @note
+// Currently the structure does not reflect the entire SPS RBSP layout.
+// It contains only the fields that are necessary to read from the NAL 
unit all the values
+// necessary for the correct initialization of 
EVCDecoderConfigurationRecord
+
+// @note
+// If necessary, add the missing fields to the structure to reflect
+// the contents of the entire NAL unit of the SPS type
+
+} EVCSPS;
+
+// @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: 
section 12.3.3.3
+typedef struct EVCNALUnitArray {
+uint8_t  array_completeness; // when equal to 1 indicates that all NAL 
units of the given type are in the following array
+uint8_t  NAL_unit_type;  // indicates the type of the NAL units in the 
following array
+uint16_t numNalus;   // indicates the number of NAL units of the 
indicated type
+uint16_t *nalUnitLength; // indicates the length in bytes of the NAL 
unit
+uint8_t  **nalUnit;  // contains an SPS, PPS, APS or a SEI NAL 
unit, as specified in ISO/IEC 23094-1
+} EVCNALUnitArray;
+
+/**
+ 

Re: [FFmpeg-devel] [PATCH 1/1] avcodec/mpegutils: add motion_vec debug mode

2022-09-01 Thread Ronald S. Bultje
Hi,

On Wed, Aug 31, 2022 at 7:10 PM Chema Gonzalez  wrote:

> Add a new debug mode ("motion_vec") that prints the values of the
> motion vectors (MV).
>

Isn't this super-hacky? In a well-designed system, a codec might export its
MVs using designated structs (which we already have) and then use these
structs to print it in a codec-agnostic way using a filter (which IIRC we
already have?).

Ronald
___
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 v11 6/9] Provided support for EVC decoder

2022-09-01 Thread Dawid Kozinski
- Added EVC decoder wrapper
- Changes in project configuration file and libavcodec Makefile
- Added documentation for xevd wrapper

Signed-off-by: Dawid Kozinski 
---
 configure |   4 +
 doc/decoders.texi |  24 +++
 doc/general_contents.texi |  10 +-
 libavcodec/Makefile   |   1 +
 libavcodec/allcodecs.c|   1 +
 libavcodec/libxevd.c  | 422 ++
 6 files changed, 461 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/libxevd.c

diff --git a/configure b/configure
index 8fe8bc0d49..b191d2d9db 100755
--- a/configure
+++ b/configure
@@ -292,6 +292,7 @@ External library support:
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
   --enable-libxeve enable EVC encoding via libxeve [no]
+  --enable-libxevd enable EVC decoding via libxevd [no]
   --enable-libxavs enable AVS encoding via xavs [no]
   --enable-libxavs2enable AVS2 encoding via xavs2 [no]
   --enable-libxcb  enable X11 grabbing using XCB [autodetect]
@@ -1876,6 +1877,7 @@ EXTERNAL_LIBRARY_LIST="
 libvorbis
 libvpx
 libwebp
+libxevd
 libxeve
 libxml2
 libzimg
@@ -3400,6 +3402,7 @@ libx264rgb_encoder_select="libx264_encoder"
 libx265_encoder_deps="libx265"
 libxavs_encoder_deps="libxavs"
 libxavs2_encoder_deps="libxavs2"
+libxevd_decoder_deps="libxevd"
 libxeve_encoder_deps="libxeve"
 libxvid_encoder_deps="libxvid"
 libzvbi_teletext_decoder_deps="libzvbi"
@@ -6722,6 +6725,7 @@ enabled libx265   && require_pkg_config libx265 
x265 x265.h x265_api_get
  require_cpp_condition libx265 x265.h "X265_BUILD 
>= 70"
 enabled libxavs   && require libxavs "stdint.h xavs.h" 
xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
 enabled libxavs2  && require_pkg_config libxavs2 "xavs2 >= 1.3.0" 
"stdint.h xavs2.h" xavs2_api_get
+enabled libxevd   && require_pkg_config libxevd "xevd >= 0.4.0" 
"xevd.h" xevd_decode
 enabled libxeve   && require_pkg_config libxeve "xeve >= 0.4.0" 
"xeve.h" xeve_encode
 enabled libxvid   && require libxvid xvid.h xvid_global -lxvidcore
 enabled libzimg   && require_pkg_config libzimg "zimg >= 2.7.0" zimg.h 
zimg_get_api_version
diff --git a/doc/decoders.texi b/doc/decoders.texi
index e2fcbf5dc9..0bd9096114 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -126,6 +126,30 @@ Set amount of frame threads to use during decoding. The 
default value is 0 (auto
 
 @end table
 
+@section libxevd
+
+eXtra-fast Essential Video Decoder (XEVD) MPEG-5 EVC decoder wrapper.
+
+This decoder requires the presence of the libxevd headers and library
+during configuration. You need to explicitly configure the build with
+@option{--enable-libxevd}.
+
+The xevd project website is at @url{https://github.com/mpeg5/xevd}.
+
+@subsection Options
+
+The following options are supported by the libxevd wrapper.
+The xevd-equivalent options or values are listed in parentheses for easy 
migration.
+
+To get a more accurate and extensive documentation of the libxevd options,
+invoke the command  @code{xevd_app --help} or consult the libxevd 
documentation.
+
+@table @option
+@item threads (@emph{threads})
+Force to use a specific number of threads
+
+@end table
+
 @section QSV Decoders
 
 The family of Intel QuickSync Video decoders (VC1, MPEG-2, H.264, HEVC,
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 3fb4aeb206..89236047ea 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -351,6 +351,14 @@ Go to @url{https://github.com/mpeg5/xeve} and follow the 
instructions for
 installing the XEVE library. Then pass @code{--enable-libxeve} to configure to
 enable it.
 
+@section eXtra-fast Essential Video Decoder (XEVD)
+
+FFmpeg can make use of the XEVD library for EVC video decoding.
+
+Go to @url{https://github.com/mpeg5/xevd} and follow the instructions for
+installing the XEVD library. Then pass @code{--enable-libxevd} to configure to
+enable it.
+
 @section ZVBI
 
 ZVBI is a VBI decoding library which can be used by FFmpeg to decode DVB
@@ -940,7 +948,7 @@ following image formats are supported:
 @item Escape 124 @tab @tab  X
 @item Escape 130 @tab @tab  X
 @item EVC / MPEG-5 Part 1@tab  X  @tab  X
-@tab encoding supported through external library libxeve
+@tab encoding and decoding supported through external libraries libxeve 
and libxevd
 @item FFmpeg video codec #1  @tab  X  @tab  X
 @tab lossless codec (fourcc: FFV1)
 @item Flash Screen Video v1  @tab  X  @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 24e58c77b4..ea9566b20c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1102,6 +1102,7 @@ OBJS-$(CONFIG_LIBX264_ENCODER)+= libx264.o
 OBJS-$(CONFIG_LIBX265_ENCODER)+= libx265.o
 

[FFmpeg-devel] [PATCH v11 5/9] Provided support for EVC encoder

2022-09-01 Thread Dawid Kozinski
- Added EVC encoder wrapper
- Changes in project configuration file and libavcodec Makefile
- Added documentation for xeve wrapper

Signed-off-by: Dawid Kozinski 
---
 configure |   4 +
 doc/encoders.texi |  69 +
 doc/general_contents.texi |  11 +
 libavcodec/Makefile   |   1 +
 libavcodec/allcodecs.c|   1 +
 libavcodec/libxeve.c  | 601 ++
 6 files changed, 687 insertions(+)
 create mode 100644 libavcodec/libxeve.c

diff --git a/configure b/configure
index 932ea5b553..8fe8bc0d49 100755
--- a/configure
+++ b/configure
@@ -291,6 +291,7 @@ External library support:
   --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]
+  --enable-libxeve enable EVC encoding via libxeve [no]
   --enable-libxavs enable AVS encoding via xavs [no]
   --enable-libxavs2enable AVS2 encoding via xavs2 [no]
   --enable-libxcb  enable X11 grabbing using XCB [autodetect]
@@ -1875,6 +1876,7 @@ EXTERNAL_LIBRARY_LIST="
 libvorbis
 libvpx
 libwebp
+libxeve
 libxml2
 libzimg
 libzmq
@@ -3398,6 +3400,7 @@ libx264rgb_encoder_select="libx264_encoder"
 libx265_encoder_deps="libx265"
 libxavs_encoder_deps="libxavs"
 libxavs2_encoder_deps="libxavs2"
+libxeve_encoder_deps="libxeve"
 libxvid_encoder_deps="libxvid"
 libzvbi_teletext_decoder_deps="libzvbi"
 vapoursynth_demuxer_deps="vapoursynth"
@@ -6719,6 +6722,7 @@ enabled libx265   && require_pkg_config libx265 
x265 x265.h x265_api_get
  require_cpp_condition libx265 x265.h "X265_BUILD 
>= 70"
 enabled libxavs   && require libxavs "stdint.h xavs.h" 
xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
 enabled libxavs2  && require_pkg_config libxavs2 "xavs2 >= 1.3.0" 
"stdint.h xavs2.h" xavs2_api_get
+enabled libxeve   && require_pkg_config libxeve "xeve >= 0.4.0" 
"xeve.h" xeve_encode
 enabled libxvid   && require libxvid xvid.h xvid_global -lxvidcore
 enabled libzimg   && require_pkg_config libzimg "zimg >= 2.7.0" zimg.h 
zimg_get_api_version
 enabled libzmq&& require_pkg_config libzmq "libzmq >= 4.2.1" zmq.h 
zmq_ctx_new
diff --git a/doc/encoders.texi b/doc/encoders.texi
index d36464d629..40496f760d 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2892,6 +2892,75 @@ ffmpeg -i input -c:v libxavs2 -xavs2-params RdoqLevel=0 
output.avs2
 @end example
 @end table
 
+@section libxeve
+
+eXtra-fast Essential Video Encoder (XEVE) MPEG-5 EVC encoder wrapper.
+The xeve-equivalent options or values are listed in parentheses for easy 
migration.
+
+This encoder requires the presence of the libxeve headers and library
+during configuration. You need to explicitly configure the build with
+@option{--enable-libxeve}.
+
+@float NOTE
+Many libxeve encoder options are mapped to FFmpeg global codec options,
+while unique encoder options are provided through private options.
+Additionally the xeve-params private options allows one to pass a list
+of key=value tuples as accepted by the libxeve @code{parse_xeve_params} 
function.
+@end float
+
+The xeve project website is at @url{https://github.com/mpeg5/xeve}.
+
+@subsection Options
+
+The following options are supported by the libxeve wrapper.
+The xeve-equivalent options or values are listed in parentheses for easy 
migration.
+
+@float NOTE
+To reduce the duplication of documentation, only the private options
+and some others requiring special attention are documented here. For
+the documentation of the undocumented generic options, see
+@ref{codec-options,,the Codec Options chapter}.
+@end float
+
+@float NOTE
+To get a more accurate and extensive documentation of the libxeve options,
+invoke the command  @code{xeve_app --help} or consult the libxeve 
documentation.
+@end float
+
+@table @option
+@item b (@emph{bitrate})
+Set target video bitrate in bits/s.
+Note that FFmpeg's b option is expressed in bits/s, while xeve's bitrate is in 
kilobits/s.
+
+@item bf (@emph{bframes})
+Set the maximum number of B frames (1,3,7,15).
+
+@item g (@emph{keyint})
+Set the GOP size (I-picture period).
+
+@item preset (@emph{preset})
+Set the xeve preset.
+Set the encoder preset value to determine encoding speed [fast, medium, slow, 
placebo]
+
+@item tune (@emph{tune})
+Set the encoder tune parameter [psnr, zerolatency]
+
+@item profile (@emph{profile})
+Set the encoder profile [0: baselie; 1: main]
+
+@item crf (@emph{crf})
+Set the quality for constant quality mode.
+Constant rate factor <10..49> [default: 32]
+
+@item qp (@emph{qp})
+Set constant quantization rate control method parameter.
+Quantization parameter qp <0..51> [default: 32]
+
+@item threads (@emph{threads})
+Force to use a specific number of threads
+
+@end table
+
 @section libxvid
 
 Xvid MPEG-4 Part 2 encoder wrapper.
diff 

[FFmpeg-devel] [PATCH v11 4/9] Added demuxer to handle reading EVC video files

2022-09-01 Thread Dawid Kozinski
- Provided AVInputFormat structure describing EVC input format (ff_evc_demuxer)

Signed-off-by: Dawid Kozinski 
---
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/evcdec.c | 124 +++
 3 files changed, 126 insertions(+)
 create mode 100644 libavformat/evcdec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 7e3f0e6794..a320cac22b 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -249,6 +249,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o pcm.o
 OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
 OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
 OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
+OBJS-$(CONFIG_EVC_DEMUXER)   += evcdec.o rawdec.o
 OBJS-$(CONFIG_EVC_MUXER) += rawenc.o
 OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_encryption.o
 OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 31508b69f0..dfce49d149 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -148,6 +148,7 @@ extern const AVInputFormat  ff_ea_cdata_demuxer;
 extern const AVInputFormat  ff_eac3_demuxer;
 extern const AVOutputFormat ff_eac3_muxer;
 extern const AVInputFormat  ff_epaf_demuxer;
+extern const AVInputFormat  ff_evc_demuxer;
 extern const AVOutputFormat ff_evc_muxer;
 extern const AVOutputFormat ff_f4v_muxer;
 extern const AVInputFormat  ff_ffmetadata_demuxer;
diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c
new file mode 100644
index 00..ffb7449c4d
--- /dev/null
+++ b/libavformat/evcdec.c
@@ -0,0 +1,124 @@
+/*
+ * RAW EVC video demuxer
+ *
+ * Copyright (c) 2021 Dawid Kozinski 
+ *
+ * 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/internal.h"
+#include "libavcodec/evc.h"
+
+#include "rawdec.h"
+#include "avformat.h"
+
+typedef struct EVCParserContext {
+int got_sps;
+int got_pps;
+int got_idr;
+int got_nonidr;
+} EVCParserContext;
+
+static int get_nalu_type(const uint8_t *bits, int bits_size)
+{
+int unit_type_plus1 = 0;
+
+if(bits_size >= EVC_NAL_HEADER_SIZE) {
+unsigned char *p = (unsigned char *)bits;
+// forbidden_zero_bit
+if ((p[0] & 0x80) != 0) { // Cannot get bitstream information. 
Malformed bitstream.
+return -1;
+}
+
+// nal_unit_type
+unit_type_plus1 = (p[0] >> 1) & 0x3F;
+}
+
+return unit_type_plus1 - 1;
+}
+
+static uint32_t read_nal_unit_length(const uint8_t *bits, int bits_size)
+{
+uint32_t nalu_len = 0;
+
+if(bits_size >= EVC_NAL_UNIT_LENGTH_BYTE) {
+
+int t = 0;
+unsigned char *p = (unsigned char *)bits;
+
+for(int i=0; ibuf;
+int bytes_to_read = p->buf_size;
+
+while(bytes_to_read > EVC_NAL_UNIT_LENGTH_BYTE) {
+
+nalu_size = read_nal_unit_length(bits, EVC_NAL_UNIT_LENGTH_BYTE);
+if(nalu_size == 0) break;
+
+bits += EVC_NAL_UNIT_LENGTH_BYTE;
+bytes_to_read -= EVC_NAL_UNIT_LENGTH_BYTE;
+
+if(bytes_to_read < nalu_size) break;
+
+nalu_type = get_nalu_type(bits, bytes_to_read);
+
+bits += nalu_size;
+bytes_to_read -= nalu_size;
+
+if (nalu_type == EVC_SPS_NUT)
+ev->got_sps++;
+else if (nalu_type == EVC_PPS_NUT)
+ev->got_pps++;
+else if (nalu_type == EVC_IDR_NUT )
+ev->got_idr++;
+else if (nalu_type == EVC_NOIDR_NUT)
+ev->got_nonidr++;
+}
+
+return 0;
+}
+
+static int evc_probe(const AVProbeData *p)
+{
+EVCParserContext ev = {0};
+int ret = parse_nal_units(p, );
+
+if (ret == 0 && ev.got_sps && ev.got_pps && (ev.got_idr || ev.got_nonidr > 
3))
+return AVPROBE_SCORE_EXTENSION + 1;  // 1 more than .mpg
+
+return 0;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(evc, "raw EVC video", evc_probe, "evc", 
AV_CODEC_ID_EVC)
-- 
2.17.1

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

To unsubscribe, visit link above, or email

[FFmpeg-devel] [PATCH v11 3/9] Added muxer to handle writing EVC encoded data into file or output bytestream

2022-09-01 Thread Dawid Kozinski
- Provided AVOutputFormat structure describing EVC output format (ff_evc_muxer)
- Added documentation for EVC muxer

Signed-off-by: Dawid Kozinski 
---
 doc/muxers.texi  |  6 ++
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/rawenc.c | 13 +
 4 files changed, 21 insertions(+)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index b2f4326aae..08ab20c09e 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -2124,6 +2124,12 @@ DTS Coherent Acoustics (DCA) audio.
 
 Dolby Digital Plus, also known as Enhanced AC-3, audio.
 
+@subsection evc
+
+MPEG-5 Essential Video Coding (EVC) / EVC / MPEG-5 Part 1 EVC video.
+
+Extensions: evc
+
 @subsection g722
 
 ITU-T G.722 audio.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index f67a99f839..7e3f0e6794 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -249,6 +249,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o pcm.o
 OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
 OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
 OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
+OBJS-$(CONFIG_EVC_MUXER) += rawenc.o
 OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_encryption.o
 OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
 OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index ae4479fb7a..31508b69f0 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -148,6 +148,7 @@ extern const AVInputFormat  ff_ea_cdata_demuxer;
 extern const AVInputFormat  ff_eac3_demuxer;
 extern const AVOutputFormat ff_eac3_muxer;
 extern const AVInputFormat  ff_epaf_demuxer;
+extern const AVOutputFormat ff_evc_muxer;
 extern const AVOutputFormat ff_f4v_muxer;
 extern const AVInputFormat  ff_ffmetadata_demuxer;
 extern const AVOutputFormat ff_ffmetadata_muxer;
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index 267fce252d..b7b2aff453 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -401,6 +401,19 @@ const AVOutputFormat ff_hevc_muxer = {
 };
 #endif
 
+#if CONFIG_EVC_MUXER
+AVOutputFormat ff_evc_muxer = {
+.name  = "evc",
+.long_name = NULL_IF_CONFIG_SMALL("raw EVC video"),
+.extensions= "evc",
+.audio_codec   = AV_CODEC_ID_NONE,
+.video_codec   = AV_CODEC_ID_EVC,
+.write_header  = force_one_stream,
+.write_packet  = ff_raw_write_packet,
+.flags = AVFMT_NOTIMESTAMPS,
+};
+#endif
+
 #if CONFIG_M4V_MUXER
 const AVOutputFormat ff_m4v_muxer = {
 .name  = "m4v",
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v11 2/9] Added parser implementaion for EVC format

2022-09-01 Thread Dawid Kozinski
Signed-off-by: Dawid Kozinski 
---
 libavcodec/Makefile |   1 +
 libavcodec/evc.h| 155 +
 libavcodec/evc_parser.c | 726 
 libavcodec/parsers.c|   1 +
 4 files changed, 883 insertions(+)
 create mode 100644 libavcodec/evc.h
 create mode 100644 libavcodec/evc_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index cb80f73d99..3d2e5d9bc2 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1129,6 +1129,7 @@ OBJS-$(CONFIG_DVAUDIO_PARSER)  += dvaudio_parser.o
 OBJS-$(CONFIG_DVBSUB_PARSER)   += dvbsub_parser.o
 OBJS-$(CONFIG_DVD_NAV_PARSER)  += dvd_nav_parser.o
 OBJS-$(CONFIG_DVDSUB_PARSER)   += dvdsub_parser.o
+OBJS-$(CONFIG_EVC_PARSER)  += evc_parser.o
 OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o
 OBJS-$(CONFIG_G723_1_PARSER)   += g723_1_parser.o
 OBJS-$(CONFIG_G729_PARSER) += g729_parser.o
diff --git a/libavcodec/evc.h b/libavcodec/evc.h
new file mode 100644
index 00..b3e648796c
--- /dev/null
+++ b/libavcodec/evc.h
@@ -0,0 +1,155 @@
+/*
+ * EVC definitions and enums
+ * Copyright (c) 2022 Dawid Kozinski 
+ *
+ * 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_EVC_H
+#define AVCODEC_EVC_H
+
+// The length field that indicates the length in bytes of the following NAL 
unit is configured to be of 4 bytes
+#define EVC_NAL_UNIT_LENGTH_BYTE(4)  /* byte */
+#define EVC_NAL_HEADER_SIZE (2)  /* byte */
+
+/**
+ * @see ISO_IEC_23094-1_2020, 7.4.2.2 NAL unit header semantic
+ *  Table 4 - NAL unit type codes and NAL unit type classes
+ */
+enum EVCNALUnitType {
+EVC_NOIDR_NUT= 0,   /* Coded slice of a non-IDR picture */
+EVC_IDR_NUT  = 1,   /* Coded slice of an IDR picture */
+EVC_RSV_VCL_NUT02= 2,
+EVC_RSV_VCL_NUT03= 3,
+EVC_RSV_VCL_NUT04= 4,
+EVC_RSV_VCL_NUT05= 5,
+EVC_RSV_VCL_NUT06= 6,
+EVC_RSV_VCL_NUT07= 7,
+EVC_RSV_VCL_NUT08= 8,
+EVC_RSV_VCL_NUT09= 9,
+EVC_RSV_VCL_NUT10= 10,
+EVC_RSV_VCL_NUT11= 11,
+EVC_RSV_VCL_NUT12= 12,
+EVC_RSV_VCL_NUT13= 13,
+EVC_RSV_VCL_NUT14= 14,
+EVC_RSV_VCL_NUT15= 15,
+EVC_RSV_VCL_NUT16= 16,
+EVC_RSV_VCL_NUT17= 17,
+EVC_RSV_VCL_NUT18= 18,
+EVC_RSV_VCL_NUT19= 19,
+EVC_RSV_VCL_NUT20= 20,
+EVC_RSV_VCL_NUT21= 21,
+EVC_RSV_VCL_NUT22= 22,
+EVC_RSV_VCL_NUT23= 23,
+EVC_SPS_NUT  = 24,  /* Sequence parameter set */
+EVC_PPS_NUT  = 25,  /* Picture paremeter set */
+EVC_APS_NUT  = 26,  /* Adaptation parameter set */
+EVC_FD_NUT   = 27,  /* Filler data */
+EVC_SEI_NUT  = 28,  /* Supplemental enhancement information */
+EVC_RSV_NONVCL29 = 29,
+EVC_RSV_NONVCL30 = 30,
+EVC_RSV_NONVCL31 = 31,
+EVC_RSV_NONVCL32 = 32,
+EVC_RSV_NONVCL33 = 33,
+EVC_RSV_NONVCL34 = 34,
+EVC_RSV_NONVCL35 = 35,
+EVC_RSV_NONVCL36 = 36,
+EVC_RSV_NONVCL37 = 37,
+EVC_RSV_NONVCL38 = 38,
+EVC_RSV_NONVCL39 = 39,
+EVC_RSV_NONVCL40 = 40,
+EVC_RSV_NONVCL41 = 41,
+EVC_RSV_NONVCL42 = 42,
+EVC_RSV_NONVCL43 = 43,
+EVC_RSV_NONVCL44 = 44,
+EVC_RSV_NONVCL45 = 45,
+EVC_RSV_NONVCL46 = 46,
+EVC_RSV_NONVCL47 = 47,
+EVC_RSV_NONVCL48 = 48,
+EVC_RSV_NONVCL49 = 49,
+EVC_RSV_NONVCL50 = 50,
+EVC_RSV_NONVCL51 = 51,
+EVC_RSV_NONVCL52 = 52,
+EVC_RSV_NONVCL53 = 53,
+EVC_RSV_NONVCL54 = 54,
+EVC_RSV_NONVCL55 = 55,
+EVC_UNSPEC_NUT56 = 56,
+EVC_UNSPEC_NUT57 = 57,
+EVC_UNSPEC_NUT58 = 58,
+EVC_UNSPEC_NUT59 = 59,
+EVC_UNSPEC_NUT60 = 60,
+EVC_UNSPEC_NUT61 = 61,
+EVC_UNSPEC_NUT62 = 62
+};
+
+// slice type
+// @see ISO_IEC_23094-1_2020 7.4.5 Slice header 

[FFmpeg-devel] [PATCH v11 1/9] MPEG-5 EVC codec registration

2022-09-01 Thread Dawid Kozinski
Added prerequisites that must be met before providing support for the MPEG-5 
EVC codec
- Added new entry to codec IDs list
- Added new entry to the codec descriptor list
- Bumped libavcodec minor version
- Added profiles for EVC codec

Signed-off-by: Dawid Kozinski 
---
 libavcodec/avcodec.h| 3 +++
 libavcodec/codec_desc.c | 8 
 libavcodec/codec_id.h   | 1 +
 libavcodec/profiles.c   | 6 ++
 libavcodec/profiles.h   | 1 +
 libavcodec/version.h| 2 +-
 6 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 65c8535359..7d56a03fca 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1674,6 +1674,9 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_KLVA_SYNC 0
 #define FF_PROFILE_KLVA_ASYNC 1
 
+#define FF_PROFILE_EVC_BASELINE 0
+#define FF_PROFILE_EVC_MAIN 1
+
 /**
  * level
  * - encoding: Set by user.
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 06dfe55d0f..d992374bb8 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1909,6 +1909,14 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("WBMP (Wireless Application Protocol 
Bitmap) image"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_EVC,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "evc",
+.long_name = NULL_IF_CONFIG_SMALL("MPEG-5 EVC (Essential Video 
Coding)"),
+.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_REORDER,
+.profiles  = NULL_IF_CONFIG_SMALL(ff_evc_profiles),
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 2247bc0309..ba32a33692 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -318,6 +318,7 @@ enum AVCodecID {
 AV_CODEC_ID_PHM,
 AV_CODEC_ID_RADIANCE_HDR,
 AV_CODEC_ID_WBMP,
+AV_CODEC_ID_EVC,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 7af7fbeb13..a31244e0db 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -181,4 +181,10 @@ const AVProfile ff_arib_caption_profiles[] = {
 { FF_PROFILE_UNKNOWN }
 };
 
+const AVProfile ff_evc_profiles[] = {
+{ FF_PROFILE_EVC_BASELINE, "Baseline"  },
+{ FF_PROFILE_EVC_MAIN, "Main"  },
+{ FF_PROFILE_UNKNOWN },
+};
+
 #endif /* !CONFIG_SMALL */
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 41a19aa9ad..cf92b5f126 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -72,5 +72,6 @@ extern const AVProfile ff_sbc_profiles[];
 extern const AVProfile ff_prores_profiles[];
 extern const AVProfile ff_mjpeg_profiles[];
 extern const AVProfile ff_arib_caption_profiles[];
+extern const AVProfile ff_evc_profiles[];
 
 #endif /* AVCODEC_PROFILES_H */
diff --git a/libavcodec/version.h b/libavcodec/version.h
index d7d5fca6b2..71a9882d82 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  42
+#define LIBAVCODEC_VERSION_MINOR  43
 #define LIBAVCODEC_VERSION_MICRO 103
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.17.1

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

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


Re: [FFmpeg-devel] [PATCH] lavu: header and documentation for AVWriter

2022-09-01 Thread Nicolas George
Stefano Sabatini (12022-09-01):
> serializeS

Locally fixed.

> This "something" is vague and can be confused with the "something" in
> "av_something_write", maybe something as:
> when presented with invalid arguments, if the flag is not set the
> called method should leave...

No, the first interpretation was exactly what it meant, it is the same
"something". For exemple, with "something" = "sample format",
av_get_sample_fmt_name(42) returns NULL, av_sample_fmt_write(wr, 42, 0)
writes nothing but av_sample_fmt_write(wr, 42, AV_WRITER_FALLBACK)
writes "invalid".

> what variable? => in the AVWriter data?

Locally changed to:

+ * The buffer is initially kept in the AVWriter data itself, it switches to
+ * heap allocation if it grows too large. In that case,
+ * av_writer_get_error() can return AVERROR(ENOMEM) if the allocation fails.

> > +char *av_dynbuf_writer_get_buffer(AVWriter wr, size_t size, size_t *rsize);

> > + * size must be <= *rsize on a previous call to
> > + * av_dynbuf_writer_get_buffer().
> what is *rsize?

One of the arguments to av_dynbuf_writer_get_buffer(), explained just
above.

> is called => if called

Fixed.

> > +#define av_buf_writer_array(array) \
> > +av_buf_writer(array, sizeof (array))
> av_buf_writer_from_array?

I would rather keep the name concise, but I will change if other agree
your version is better or if you insist.

> > +AVWriter av_stdio_writer(FILE *out);
> av_file_writer() ?

That would be ambiguous, it would suggest writing to an actual file.

> I'd use a verb for consistency/clarify.
> notify_impossibility or notify_impossible_op?

Locally changed to:

-void (*impossible)(AVWriter wr, const char *message);
+void (*notify_impossible)(AVWriter wr, const char *message);

> > + * If *size is returned < min_size, data may get discarded.
> If the returned *size is < min_size... ?

Locally changed to:

- * If *size is returned < min_size, data may get discarded.
+ * If the returned *size is < min_size, data may get discarded.

> > + * size is guaranteed <= the size value returned by get_buffer().
> size is or should be guaranteed?

Is. The documentation is written for somebody who implements the
methods, and it tells them they do not have to bother checking size
here (although an assert would not be bad in this kind of situation). I
added a paragraph in the introduction:

  * Applications that want to implement other kinds of AVWriter
  * need to create a structure with some of these methods implemented.
  *
+ * These methods should only be called directly by the implementation of
+ * AVWriter. Their documentation is written from the point of view of
+ * implementing them.
+ *
  * Every type of AVWriter is supposed to have a pair of functions:
  * av_something_writer_get_methods() returns the methods for that type.
  * av_something_writer_checks() returns 1 if the writer is of that type.

Thanks for the review. I do not think it is necessary to send an updated
patch for these changes, is it?

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 v2] fftools/ffplay: fix rotation incorrect when frame contains the displaymatrix

2022-09-01 Thread zhilizhao(赵志立)


> On Sep 1, 2022, at 12:53 PM, 1035567...@qq.com wrote:
> 
> From: Wang Yaqiang 
> 
> For example, if the jpeg contains exif information
> and the rotation direction is included in the exif,
> the displaymatrix will be set on the side_data of the frame when decoding.
> However, when ffplay is used to play the image,
> only the side data in the stream will be determined.
> It does not check whether the frame also contains rotation information,
> causing it to play in the wrong direction
> 

I’m OK with this strategy.

> Signed-off-by: Wang Yaqiang 
> ---
> fftools/ffplay.c | 7 ++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fftools/ffplay.c b/fftools/ffplay.c
> index 9242047f5c..5bda29169d 100644
> --- a/fftools/ffplay.c
> +++ b/fftools/ffplay.c
> @@ -1915,7 +1915,12 @@ static int configure_video_filters(AVFilterGraph 
> *graph, VideoState *is, const c
> } while (0)
> 
> if (autorotate) {
> -int32_t *displaymatrix = (int32_t 
> *)av_stream_get_side_data(is->video_st, AV_PKT_DATA_DISPLAYMATRIX, NULL);
> +int32_t *displaymatrix = NULL;
> +AVFrameSideData *sd = 
> av_frame_get_side_data(frame,AV_FRAME_DATA_DISPLAYMATRIX);

Coding style: missing a space after comma.

> +if (sd)
> +displaymatrix = (int32_t *)sd->data;
> +if (!displaymatrix)
> +displaymatrix = (int32_t *)av_stream_get_side_data(is->video_st, 
> AV_PKT_DATA_DISPLAYMATRIX, NULL);
> double theta = get_rotation(displaymatrix);
> 
> if (fabs(theta - 90) < 1.0) {

Mixed declaration and code.

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

___
ffmpeg-devel 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: fix av_display_rotation_set() type cast

2022-09-01 Thread Steven Liu
Zhao Zhili  于2022年9月1日周四 10:59写道:
>
> From: Zhao Zhili 
>
> Signed-off-by: Zhao Zhili 
> ---
>  fftools/ffmpeg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index fbabbe6ea2..ecaf3bd984 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -3263,7 +3263,7 @@ static int init_output_stream(OutputStream *ost, 
> AVFrame *frame,
>  return AVERROR(ENOMEM);
>  memcpy(dst, sd->data, sd->size);
>  if (ist->autorotate && sd->type == 
> AV_PKT_DATA_DISPLAYMATRIX)
> -av_display_rotation_set((uint32_t *)dst, 0);
> +av_display_rotation_set((int32_t *)dst, 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".

looks ok to me


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