Re: [FFmpeg-devel] [RFC/PATCH] MV-HEVC decoding

2024-09-14 Thread Anton Khirnov
Quoting Danny Hong (2024-09-13 19:58:53)
>  Quoting Anton Khirnov (2024-09-13 12:44:55)
> > Note that -view_ids is a decoder option and does nothing with
> > streamcopy.
> > Also, that option is intended for API users, with ffmpeg CLI you should
> > be using view specifiers instead.
> 
> Thanks!  Tried with "-map 0:v:view:all" and the result is the same.  The
> resulting elementary stream cannot be decoded by ffmpeg as the stream is
> not conformant.
> 
> > Use view specifiers to split the views into their own streams. I do not
> > want too much multiview-speficic logic into ffmpeg CLI, as it is a
> > rather obscure feature.
> 
> But the "-map 0:v:view:all" option is still available to output both views
> as a single stream with alternating views, no?

It is, but mainly as a testing/development aid, I do not expect it to be
generally useful. Or is there a particular reason you need to
interleave the views into one stream?

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

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


Re: [FFmpeg-devel] [PATCH v2 00/14] aarch64/vvc: Add SIMD

2024-09-14 Thread Nuo Mi
On Thu, Sep 12, 2024 at 6:59 PM Martin Storsjö  wrote:

> On Thu, 12 Sep 2024, Zhao Zhili wrote:
>
> > From: Zhao Zhili 
> >
> > Patches 1~9 has been updated according to Martin's review.
> >
> > Patches 10~14 are new.
> >
> > I have created a PR on github:
> > https://github.com/quink-black/FFmpeg/pull/2
>
> Thanks for testing it through that set of tests!
>
> No further comments from me on this set, it seems reasonable.
>
> // Martin
>
👍, 4K@30fps playback is smooth on M2.
Thank you, Zhili and Martin!

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

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


[FFmpeg-devel] [PATCH] MV-HEVC decoding

2024-09-14 Thread Anton Khirnov
Hi,
this second round of the MV-HEVC decoding set should be good enough for
inclusion. Changes since the previous set [1] are:
* Rebased against master.
* Addressed all the review comments.
* Now using C23 stdc_trailing_zeros() instead of POSIX-only ffs() (with
  a fallback for systems lacking stdbit.h, thanks to Rémi).
* View ID is now available in get_buffer2() as frame side data rather
  than via a special read-only decoder-private option, thanks to a patch
  by James.
* Dropped output layer set support. HEVC VPS can contain a number of
  layer-set definitions (i.e. layers that should be selected for output
  together). Previous version of this patchset had decoder options for
  querying the sets and selecting one of them for output. However, this
  feature does not seem useful as there is no way to ascribe semantics
  to the sets; I'm also not aware of anyone using it. So in the name of
  simplicity, I dropped the relevant options until and unless someone
  presents an actual use-case for this. The API for layer selection is
  now based only on view IDs.
* Added a test for decoding a real-world file/selecting view by
  position.

As before, you can fetch the code from git://git.khirnov.net/libav,
branch 'mv-hevc'.

My thanks to Vimeo, Meta, and FFlabs for supporting this work.

[1] https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2024-August/332693.html
Message-Id <20240827154041.13846-2-an...@khirnov.net>

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

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


[FFmpeg-devel] [PATCH 02/23] compat: add a fallback implementation of C23 stdbit.h

2024-09-14 Thread Anton Khirnov
From: Rémi Denis-Courmont 

Header contents taken from VLC commit 7a970a33329c9836d169727ddbaf49a33240d587.

Signed-off-by: Anton Khirnov 
---
 compat/stdbit/stdbit.h | 594 +
 configure  |   4 +
 tests/ref/fate/source  |   1 +
 3 files changed, 599 insertions(+)
 create mode 100644 compat/stdbit/stdbit.h

diff --git a/compat/stdbit/stdbit.h b/compat/stdbit/stdbit.h
new file mode 100644
index 00..b6a2c7e945
--- /dev/null
+++ b/compat/stdbit/stdbit.h
@@ -0,0 +1,594 @@
+/*
+ * Copyright (C) 2023 Rémi Denis-Courmont
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ */
+
+#ifndef __STDC_VERSION_STDBIT_H__
+#define __STDC_VERSION_STDBIT_H__ 202311L
+
+#include 
+#include  /* CHAR_BIT */
+
+#define __STDC_ENDIAN_LITTLE__ 1234
+#define __STDC_ENDIAN_BIG__4321
+
+#ifdef __BYTE_ORDER__
+# if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+#  define __STDC_ENDIAN_NATIVE__ __STDC_ENDIAN_LITTLE__
+# elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+#  define __STDC_ENDIAN_NATIVE__ __STDC_ENDIAN_BIG__
+# else
+#  define __STDC_ENDIAN_NATIVE__ 3412
+# endif
+#else
+# error Not implemented.
+#endif
+
+#define __stdbit_generic_type_func(func, value) \
+_Generic (value, \
+unsigned long long: stdc_##func##_ull((unsigned long long)(value)), \
+unsigned long:  stdc_##func##_ul((unsigned long)(value)), \
+unsigned int:   stdc_##func##_ui((unsigned int)(value)), \
+unsigned short: stdc_##func##_us((unsigned short)(value)), \
+unsigned char:  stdc_##func##_uc((unsigned char)(value)))
+
+#if defined (__GNUC__) || defined (__clang__)
+static inline unsigned int stdc_leading_zeros_ull(unsigned long long value)
+{
+return value ? __builtin_clzll(value) : (CHAR_BIT * sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_ul(unsigned long value)
+{
+return value ? __builtin_clzl(value) : (CHAR_BIT * sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_ui(unsigned int value)
+{
+return value ? __builtin_clz(value) : (CHAR_BIT * sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_us(unsigned short value)
+{
+return stdc_leading_zeros_ui(value)
+   - CHAR_BIT * (sizeof (int) - sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_uc(unsigned char value)
+{
+return stdc_leading_zeros_ui(value) - (CHAR_BIT * (sizeof (int) - 1));
+}
+#else
+static inline unsigned int __stdc_leading_zeros(unsigned long long value,
+unsigned int size)
+{
+unsigned int zeros = size * CHAR_BIT;
+
+while (value != 0) {
+value >>= 1;
+zeros--;
+}
+
+return zeros;
+}
+
+static inline unsigned int stdc_leading_zeros_ull(unsigned long long value)
+{
+return __stdc_leading_zeros(value, sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_ul(unsigned long value)
+{
+return __stdc_leading_zeros(value, sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_ui(unsigned int value)
+{
+return __stdc_leading_zeros(value, sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_us(unsigned short value)
+{
+return __stdc_leading_zeros(value, sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_uc(unsigned char value)
+{
+return __stdc_leading_zeros(value, sizeof (value));
+}
+#endif
+
+#define stdc_leading_zeros(value) \
+__stdbit_generic_type_func(leading_zeros, value)
+
+static inline unsigned int stdc_leading_ones_ull(unsigned long long value)
+{
+return stdc_leading_zeros_ull(~value);
+}
+
+static inline unsigned int stdc_leading_ones_ul(unsigned long value)
+{
+return stdc_leading_zeros_ul(~value);
+}
+
+static inline unsigned int stdc_leading_ones_ui(unsigned int value)
+{
+return stdc_leading_zeros_ui(~value);
+}
+
+static inline unsigned int stdc_leading_ones_us(unsigned short value)
+{
+return stdc_leading_zeros_us(~value);
+}
+
+static inline unsigned int stdc_leading_ones_uc(unsigned char value)
+{
+return stdc_leading_zeros_uc(~value);
+}
+
+#define stdc_leading_ones(value) \
+__stdbit_generic_type_func(leading_ones, value)
+
+#if defined (__GNUC__) || defined (__clang__)
+st

[FFmpeg-devel] [PATCH 07/23] lavc/hevc/ps: drop a warning for sps_multilayer_extension_flag

2024-09-14 Thread Anton Khirnov
SPS multilayer extension contains a single flag that we are free to
ignore, no reason to print a warning.
---
 libavcodec/hevc/ps.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c
index 35de26644c..81b3f9cd09 100644
--- a/libavcodec/hevc/ps.c
+++ b/libavcodec/hevc/ps.c
@@ -1425,8 +1425,6 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 
 if (sps->multilayer_extension) {
 skip_bits1(gb); // inter_view_mv_vert_constraint_flag
-av_log(avctx, AV_LOG_WARNING,
-   "sps_multilayer_extension_flag not yet implemented\n");
 }
 
 if (sps->sps_3d_extension) {
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 05/23] avcodec/hevc/sei: add support for 3D Reference Displays Information SEI

2024-09-14 Thread Anton Khirnov
From: James Almer 

Signed-off-by: James Almer 
Signed-off-by: Anton Khirnov 
---
 libavcodec/hevc/sei.c | 55 +++
 libavcodec/hevc/sei.h | 17 +
 2 files changed, 72 insertions(+)

diff --git a/libavcodec/hevc/sei.c b/libavcodec/hevc/sei.c
index b55ba71a8d..e11a33773c 100644
--- a/libavcodec/hevc/sei.c
+++ b/libavcodec/hevc/sei.c
@@ -150,6 +150,59 @@ static int decode_nal_sei_timecode(HEVCSEITimeCode *s, 
GetBitContext *gb)
 return 0;
 }
 
+static int decode_nal_sei_3d_reference_displays_info(HEVCSEITDRDI *s, 
GetBitContext *gb)
+{
+s->prec_ref_display_width = get_ue_golomb(gb);
+if (s->prec_ref_display_width > 31)
+return AVERROR_INVALIDDATA;
+s->ref_viewing_distance_flag = get_bits1(gb);
+if (s->ref_viewing_distance_flag) {
+s->prec_ref_viewing_dist = get_ue_golomb(gb);
+if (s->prec_ref_viewing_dist > 31)
+return AVERROR_INVALIDDATA;
+}
+s->num_ref_displays = get_ue_golomb(gb);
+if (s->num_ref_displays > 31)
+return AVERROR_INVALIDDATA;
+s->num_ref_displays += 1;
+
+for (int i = 0; i < s->num_ref_displays; i++) {
+int length;
+s->left_view_id[i] = get_ue_golomb(gb);
+s->right_view_id[i] = get_ue_golomb(gb);
+s->exponent_ref_display_width[i] = get_bits(gb, 6);
+if (s->exponent_ref_display_width[i] > 62)
+return AVERROR_INVALIDDATA;
+else if (!s->exponent_ref_display_width[i])
+length = FFMAX(0, (int)s->prec_ref_display_width - 30);
+else
+length = FFMAX(0, (int)s->exponent_ref_display_width[i] +
+  (int)s->prec_ref_display_width - 31);
+s->mantissa_ref_display_width[i] = get_bits_long(gb, length);
+if (s->ref_viewing_distance_flag) {
+s->exponent_ref_viewing_distance[i] = get_bits(gb, 6);
+if (s->exponent_ref_viewing_distance[i] > 62)
+return AVERROR_INVALIDDATA;
+else if (!s->exponent_ref_viewing_distance[i])
+length = FFMAX(0, (int)s->prec_ref_viewing_dist - 30);
+else
+length = FFMAX(0, (int)s->exponent_ref_viewing_distance[i] +
+  (int)s->prec_ref_viewing_dist - 31);
+s->mantissa_ref_viewing_distance[i] = get_bits_long(gb, length);
+}
+s->additional_shift_present_flag[i] = get_bits1(gb);
+if (s->additional_shift_present_flag[i]) {
+s->num_sample_shift[i] = get_bits(gb, 10);
+if (s->num_sample_shift[i] > 1023)
+return AVERROR_INVALIDDATA;
+s->num_sample_shift[i] -= 512;
+}
+}
+s->three_dimensional_reference_displays_extension_flag = get_bits1(gb);
+
+return 0;
+}
+
 static int decode_nal_sei_prefix(GetBitContext *gb, GetByteContext *gbyte,
  void *logctx, HEVCSEI *s,
  const HEVCParamSets *ps, int type)
@@ -163,6 +216,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, 
GetByteContext *gbyte,
 return decode_nal_sei_active_parameter_sets(s, gb, logctx);
 case SEI_TYPE_TIME_CODE:
 return decode_nal_sei_timecode(&s->timecode, gb);
+case SEI_TYPE_THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:
+return decode_nal_sei_3d_reference_displays_info(&s->tdrdi, gb);
 default: {
 int ret = ff_h2645_sei_message_decode(&s->common, type, 
AV_CODEC_ID_HEVC,
   gb, gbyte, logctx);
diff --git a/libavcodec/hevc/sei.h b/libavcodec/hevc/sei.h
index c97d22d423..a9d6a52080 100644
--- a/libavcodec/hevc/sei.h
+++ b/libavcodec/hevc/sei.h
@@ -79,12 +79,29 @@ typedef struct HEVCSEITimeCode {
 int32_t  time_offset_value[3];
 } HEVCSEITimeCode;
 
+typedef struct HEVCSEITDRDI {
+uint8_t prec_ref_display_width;
+uint8_t ref_viewing_distance_flag;
+uint8_t prec_ref_viewing_dist;
+uint8_t num_ref_displays;
+uint16_t left_view_id[31];
+uint16_t right_view_id[31];
+uint8_t exponent_ref_display_width[31];
+uint8_t mantissa_ref_display_width[31];
+uint8_t exponent_ref_viewing_distance[31];
+uint8_t mantissa_ref_viewing_distance[31];
+uint8_t additional_shift_present_flag[31];
+int16_t num_sample_shift[31];
+uint8_t three_dimensional_reference_displays_extension_flag;
+} HEVCSEITDRDI;
+
 typedef struct HEVCSEI {
 H2645SEI common;
 HEVCSEIPictureHash picture_hash;
 HEVCSEIPictureTiming picture_timing;
 int active_seq_parameter_set_id;
 HEVCSEITimeCode timecode;
+HEVCSEITDRDI tdrdi;
 } HEVCSEI;
 
 struct HEVCParamSets;
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 01/23] compat: drop gcc, suncc, and pthreads stdatomic emulation

2024-09-14 Thread Anton Khirnov
Since we now require a C11-compliant compiler, there should be no
supported configurations where any of these is used.
---
 compat/atomics/gcc/stdatomic.h | 173 -
 compat/atomics/pthread/stdatomic.c |  39 --
 compat/atomics/pthread/stdatomic.h | 197 -
 compat/atomics/suncc/stdatomic.h   | 186 ---
 configure  |  19 +--
 5 files changed, 1 insertion(+), 613 deletions(-)
 delete mode 100644 compat/atomics/gcc/stdatomic.h
 delete mode 100644 compat/atomics/pthread/stdatomic.c
 delete mode 100644 compat/atomics/pthread/stdatomic.h
 delete mode 100644 compat/atomics/suncc/stdatomic.h

diff --git a/compat/atomics/gcc/stdatomic.h b/compat/atomics/gcc/stdatomic.h
deleted file mode 100644
index e13ed0e068..00
--- a/compat/atomics/gcc/stdatomic.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * 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
- */
-
-/*
- * based on vlc_atomic.h from VLC
- * Copyright (C) 2010 Rémi Denis-Courmont
- */
-
-#ifndef COMPAT_ATOMICS_GCC_STDATOMIC_H
-#define COMPAT_ATOMICS_GCC_STDATOMIC_H
-
-#include 
-#include 
-
-#define ATOMIC_FLAG_INIT 0
-
-#define ATOMIC_VAR_INIT(value) (value)
-
-#define atomic_init(obj, value) \
-do {\
-*(obj) = (value);   \
-} while(0)
-
-#define kill_dependency(y) ((void)0)
-
-#define atomic_thread_fence(order) \
-__sync_synchronize()
-
-#define atomic_signal_fence(order) \
-((void)0)
-
-#define atomic_is_lock_free(obj) 0
-
-typedef _Bool  atomic_flag;
-typedef _Bool  atomic_bool;
-typedef  char  atomic_char;
-typedef   signed char  atomic_schar;
-typedef unsigned char  atomic_uchar;
-typedef  short atomic_short;
-typedef unsigned short atomic_ushort;
-typedef  int   atomic_int;
-typedef unsigned int   atomic_uint;
-typedef  long  atomic_long;
-typedef unsigned long  atomic_ulong;
-typedef  long long atomic_llong;
-typedef unsigned long long atomic_ullong;
-typedef  wchar_t   atomic_wchar_t;
-typedef   int_least8_t atomic_int_least8_t;
-typedef  uint_least8_t atomic_uint_least8_t;
-typedef  int_least16_t atomic_int_least16_t;
-typedef uint_least16_t atomic_uint_least16_t;
-typedef  int_least32_t atomic_int_least32_t;
-typedef uint_least32_t atomic_uint_least32_t;
-typedef  int_least64_t atomic_int_least64_t;
-typedef uint_least64_t atomic_uint_least64_t;
-typedef   int_fast8_t atomic_int_fast8_t;
-typedef  uint_fast8_t atomic_uint_fast8_t;
-typedef  int_fast16_t atomic_int_fast16_t;
-typedef uint_fast16_t atomic_uint_fast16_t;
-typedef  int_fast32_t atomic_int_fast32_t;
-typedef uint_fast32_t atomic_uint_fast32_t;
-typedef  int_fast64_t atomic_int_fast64_t;
-typedef uint_fast64_t atomic_uint_fast64_t;
-typedef  intptr_t atomic_intptr_t;
-typedef uintptr_t atomic_uintptr_t;
-typedefsize_t atomic_size_t;
-typedef ptrdiff_t atomic_ptrdiff_t;
-typedef  intmax_t atomic_intmax_t;
-typedef uintmax_t atomic_uintmax_t;
-
-#define atomic_store(object, desired)   \
-do {\
-*(object) = (desired);  \
-__sync_synchronize();   \
-} while (0)
-
-#define atomic_store_explicit(object, desired, order) \
-atomic_store(object, desired)
-
-#define atomic_load(object) \
-(__sync_synchronize(), *(object))
-
-#define atomic_load_explicit(object, order) \
-atomic_load(object)
-
-#define atomic_exchange(object, desired)\
-({  \
-__typeof__(object) _obj = (object); \
-__typeof__(*object) _old;   \
-do  \
-_old = atomic_load(_obj);   \
-while (!__sync_bool_compare_and_swap(_obj, _old, (desired)));   \
-_old;   \
-})
-
-#define atomic_exchange_explicit(object, desired, order) \
-atomic_exchange(object, desired)

[FFmpeg-devel] [PATCH 10/23] lavc/hevcdec/parse: process NALUs with nuh_layer_id>0

2024-09-14 Thread Anton Khirnov
Otherwise parameter sets from extradata with nuh_layer_id>0 would be
ignored. Needed for upcoming MV-HEVC support.
---
 libavcodec/hevc/parse.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavcodec/hevc/parse.c b/libavcodec/hevc/parse.c
index ad84b7b152..29f21a5966 100644
--- a/libavcodec/hevc/parse.c
+++ b/libavcodec/hevc/parse.c
@@ -38,9 +38,6 @@ static int hevc_decode_nal_units(const uint8_t *buf, int 
buf_size, HEVCParamSets
 
 for (i = 0; i < pkt.nb_nals; i++) {
 H2645NAL *nal = &pkt.nals[i];
-if (nal->nuh_layer_id > 0)
-continue;
-
 /* ignore everything except parameter sets and VCL NALUs */
 switch (nal->type) {
 case HEVC_NAL_VPS:
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 14/23] avcodec/decode: split ProgressFrame allocator into two functions

2024-09-14 Thread Anton Khirnov
From: James Almer 

Signed-off-by: James Almer 
Signed-off-by: Anton Khirnov 
---
 libavcodec/decode.c| 11 +++
 libavcodec/progressframe.h | 16 ++--
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 27dba8a1f3..5f6646ea4d 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1724,7 +1724,7 @@ static void check_progress_consistency(const 
ProgressFrame *f)
 av_assert1(!f->progress || f->progress->f == f->f);
 }
 
-static int progress_frame_get(AVCodecContext *avctx, ProgressFrame *f)
+int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f)
 {
 FFRefStructPool *pool = avctx->internal->progress_frame_pool;
 
@@ -1742,9 +1742,12 @@ int ff_progress_frame_get_buffer(AVCodecContext *avctx, 
ProgressFrame *f, int fl
 {
 int ret;
 
-ret = progress_frame_get(avctx, f);
-if (ret < 0)
-return ret;
+check_progress_consistency(f);
+if (!f->f) {
+ret = ff_progress_frame_alloc(avctx, f);
+if (ret < 0)
+return ret;
+}
 
 ret = ff_thread_get_buffer(avctx, f->progress->f, flags);
 if (ret < 0) {
diff --git a/libavcodec/progressframe.h b/libavcodec/progressframe.h
index 428a461659..32a345beec 100644
--- a/libavcodec/progressframe.h
+++ b/libavcodec/progressframe.h
@@ -102,12 +102,24 @@ void ff_progress_frame_report(ProgressFrame *f, int 
progress);
 void ff_progress_frame_await(const ProgressFrame *f, int progress);
 
 /**
- * This function sets up the ProgressFrame, i.e. gets ProgressFrame.f
- * and also calls ff_thread_get_buffer() on the frame.
+ * This function allocates ProgressFrame.f
+ * May be called before ff_progress_frame_get_buffer() in the cases where the
+ * AVFrame needs to be accessed before the ff_thread_get_buffer() call in
+ * ff_progress_frame_alloc().
  *
  * @note: This must only be called by codecs with the
  *FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
  */
+int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f);
+
+/**
+ * This function sets up the ProgressFrame, i.e. allocates ProgressFrame.f
+ * if needed, and also calls ff_thread_get_buffer() on the frame.
+ *
+ * @note: This must only be called by codecs with the
+ *FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
+ * @see ff_progress_frame_alloc
+ */
 int ff_progress_frame_get_buffer(struct AVCodecContext *avctx,
  ProgressFrame *f, int flags);
 
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 16/23] avcodec/hevc/refs: export Stereo 3D side data

2024-09-14 Thread Anton Khirnov
From: James Almer 

Use the 3D Reference Displays Info SEI message to link a view_id with
an eye.

Signed-off-by: James Almer 
---
 libavcodec/hevc/hevcdec.c |  1 +
 libavcodec/hevc/refs.c| 19 +++
 2 files changed, 20 insertions(+)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 692f19e97e..b784b10bcf 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3968,6 +3968,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
 s->sei.common.mastering_display= s0->sei.common.mastering_display;
 s->sei.common.content_light= s0->sei.common.content_light;
 s->sei.common.aom_film_grain   = s0->sei.common.aom_film_grain;
+s->sei.tdrdi   = s0->sei.tdrdi;
 
 return 0;
 }
diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index b9b08ca416..ac1b07a308 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -22,6 +22,7 @@
  */
 
 #include "libavutil/mem.h"
+#include "libavutil/stereo3d.h"
 
 #include "container_fifo.h"
 #include "decode.h"
@@ -94,6 +95,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)
 
 // add view ID side data if it's nontrivial
 if (vps->nb_layers > 1 || view_id) {
+HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
 AVFrameSideData *sd = av_frame_side_data_new(&frame->f->side_data,
  
&frame->f->nb_side_data,
  AV_FRAME_DATA_VIEW_ID,
@@ -101,6 +103,23 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)
 if (!sd)
 goto fail;
 *(int*)sd->data = view_id;
+
+if (tdrdi->num_ref_displays) {
+AVStereo3D *stereo_3d;
+
+av_frame_remove_side_data(frame->f, AV_FRAME_DATA_STEREO3D);
+stereo_3d = av_stereo3d_create_side_data(frame->f);
+if (!stereo_3d)
+goto fail;
+
+stereo_3d->type = AV_STEREO3D_FRAMESEQUENCE;
+if (tdrdi->left_view_id[0] == view_id)
+stereo_3d->view = AV_STEREO3D_VIEW_LEFT;
+else if (tdrdi->right_view_id[0] == view_id)
+stereo_3d->view = AV_STEREO3D_VIEW_RIGHT;
+else
+stereo_3d->view = AV_STEREO3D_VIEW_UNSPEC;
+}
 }
 
 if (!(s->layers_active_output & (1 << s->cur_layer)))
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 19/23] fftools/ffmpeg: add support for multiview video

2024-09-14 Thread Anton Khirnov
This extends the syntax for specifying input streams in -map and complex
filtergraph labels, to allow selecting a view by view ID, index, or
position. The corresponding decoder is then set up to decode the
appropriate view and send frames for that view to the correct
filtergraph input(s).
---
 doc/ffmpeg.texi   |  30 ++-
 fftools/cmdutils.c|   2 +-
 fftools/cmdutils.h|   2 +
 fftools/ffmpeg.h  |  45 -
 fftools/ffmpeg_dec.c  | 387 +-
 fftools/ffmpeg_demux.c|  24 ++-
 fftools/ffmpeg_filter.c   |  71 ---
 fftools/ffmpeg_mux_init.c |  34 ++--
 fftools/ffmpeg_opt.c  |  70 ++-
 9 files changed, 610 insertions(+), 55 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 842e92ad1a..34007f7ea2 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1799,7 +1799,7 @@ Set the size of the canvas used to render subtitles.
 @section Advanced options
 
 @table @option
-@item -map [-]@var{input_file_id}[:@var{stream_specifier}][?] | 
@var{[linklabel]} (@emph{output})
+@item -map 
[-]@var{input_file_id}[:@var{stream_specifier}][:@var{view_specifier}][?] | 
@var{[linklabel]} (@emph{output})
 
 Create one or more streams in the output file. This option has two forms for
 specifying the data source(s): the first selects one or more streams from some
@@ -1814,6 +1814,26 @@ only those streams that match the specifier are used 
(see the
 A @code{-} character before the stream identifier creates a "negative" mapping.
 It disables matching streams from already created mappings.
 
+An optional @var{view_specifier} may be given after the stream specifier, which
+for multiview video specifies the view to be used. The view specifier may have
+one of the following formats:
+@table @option
+@item view:@var{view_id}
+select a view by its ID; @var{view_id} may be set to 'all' to use all the views
+interleaved into one stream;
+
+@item vidx:@var{view_idx}
+select a view by its index; i.e. 0 is the base view, 1 is the first non-base
+view, etc.
+
+@item vpos:@var{position}
+select a view by its display position; @var{position} may be @code{left} or
+@code{right}
+@end table
+The default for transcoding is to only use the base view, i.e. the equivalent 
of
+@code{vidx:0}. For streamcopy, view specifiers are not supported and all views
+are always copied.
+
 A trailing @code{?} after the stream index will allow the map to be
 optional: if the map matches no streams the map will be ignored instead
 of failing. Note the map will still fail if an invalid input file index
@@ -2206,11 +2226,15 @@ distinguished by the format of the corresponding link 
label:
 @item
 To connect an input stream, use @code{[file_index:stream_specifier]} (i.e. the
 same syntax as @option{-map}). If @var{stream_specifier} matches multiple
-streams, the first one will be used.
+streams, the first one will be used. For multiview video, the stream specifier
+may be followed by the view specifier, see documentation for the @option{-map}
+option for its syntax.
 
 @item
 To connect a loopback decoder use [dec:@var{dec_idx}], where @var{dec_idx} is
-the index of the loopback decoder to be connected to given input.
+the index of the loopback decoder to be connected to given input. For multiview
+video, the decoder index may be followed by the view specifier, see
+documentation for the @option{-map} option for its syntax.
 
 @item
 To connect an output from another complex filtergraph, use its link label. E.g
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 1573106d8b..76e5721cb1 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -988,7 +988,7 @@ FILE *get_preset_file(char *filename, size_t filename_size,
 return f;
 }
 
-static int cmdutils_isalnum(char c)
+int cmdutils_isalnum(char c)
 {
 return (c >= '0' && c <= '9') ||
(c >= 'A' && c <= 'Z') ||
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index 9441d5726b..e7c8c9f86b 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -541,4 +541,6 @@ void remove_avoptions(AVDictionary **a, AVDictionary *b);
 /* Check if any keys exist in dictionary m */
 int check_avoptions(AVDictionary *m);
 
+int cmdutils_isalnum(char c);
+
 #endif /* FFTOOLS_CMDUTILS_H */
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index f4a10b2a66..733d551fa4 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -112,12 +112,32 @@ typedef struct HWDevice {
 AVBufferRef *device_ref;
 } HWDevice;
 
+enum ViewSpecifierType {
+// no specifier given
+VIEW_SPECIFIER_TYPE_NONE = 0,
+// val is view index
+VIEW_SPECIFIER_TYPE_IDX,
+// val is view ID
+VIEW_SPECIFIER_TYPE_ID,
+// specify view by its position, val is AV_STEREO3D_VIEW_LEFT/RIGHT
+VIEW_SPECIFIER_TYPE_POS,
+// use all views, val is ignored
+VIEW_SPECIFIER_TYPE_ALL,
+};
+
+typedef struct ViewSpecifier {
+enum ViewSpecifierType type;
+unsigned   val;
+} ViewSpecifier;
+
 /* select an input st

[FFmpeg-devel] [PATCH 08/23] lavc/hevc/ps: implement SPS parsing for nuh_layer_id>0

2024-09-14 Thread Anton Khirnov
Cf. F.7.3.2.2 "Sequence parameter set RBSP syntax", which extends normal
SPS parsing with special clauses depending on MultiLayerExtSpsFlag.
---
 libavcodec/hevc/hevcdec.c |  2 +-
 libavcodec/hevc/parse.c   |  3 +-
 libavcodec/hevc/parser.c  |  2 +-
 libavcodec/hevc/ps.c  | 65 +++
 libavcodec/hevc/ps.h  |  7 +++--
 libavcodec/qsvenc_hevc.c  |  2 +-
 6 files changed, 68 insertions(+), 13 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index d915d74d22..ebe2f5ad11 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3260,7 +3260,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL 
*nal)
 break;
 case HEVC_NAL_SPS:
 ret = ff_hevc_decode_nal_sps(&gb, s->avctx, &s->ps,
- s->apply_defdispwin);
+ nal->nuh_layer_id, s->apply_defdispwin);
 if (ret < 0)
 goto fail;
 break;
diff --git a/libavcodec/hevc/parse.c b/libavcodec/hevc/parse.c
index ec8d1aeacf..ad84b7b152 100644
--- a/libavcodec/hevc/parse.c
+++ b/libavcodec/hevc/parse.c
@@ -49,7 +49,8 @@ static int hevc_decode_nal_units(const uint8_t *buf, int 
buf_size, HEVCParamSets
 goto done;
 break;
 case HEVC_NAL_SPS:
-ret = ff_hevc_decode_nal_sps(&nal->gb, logctx, ps, 
apply_defdispwin);
+ret = ff_hevc_decode_nal_sps(&nal->gb, logctx, ps,
+ nal->nuh_layer_id, apply_defdispwin);
 if (ret < 0)
 goto done;
 break;
diff --git a/libavcodec/hevc/parser.c b/libavcodec/hevc/parser.c
index 2d14b4fae2..8c7444a162 100644
--- a/libavcodec/hevc/parser.c
+++ b/libavcodec/hevc/parser.c
@@ -209,7 +209,7 @@ static int parse_nal_units(AVCodecParserContext *s, const 
uint8_t *buf,
 ff_hevc_decode_nal_vps(gb, avctx, ps);
 break;
 case HEVC_NAL_SPS:
-ff_hevc_decode_nal_sps(gb, avctx, ps, 1);
+ff_hevc_decode_nal_sps(gb, avctx, ps, nal->nuh_layer_id, 1);
 break;
 case HEVC_NAL_PPS:
 ff_hevc_decode_nal_pps(gb, avctx, ps);
diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c
index 81b3f9cd09..2d09500278 100644
--- a/libavcodec/hevc/ps.c
+++ b/libavcodec/hevc/ps.c
@@ -1148,12 +1148,12 @@ static int map_pixel_format(AVCodecContext *avctx, 
HEVCSPS *sps)
 }
 
 int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
-  int apply_defdispwin, const HEVCVPS * const *vps_list,
-  AVCodecContext *avctx)
+  unsigned nuh_layer_id, int apply_defdispwin,
+  const HEVCVPS * const *vps_list, AVCodecContext *avctx)
 {
 HEVCWindow *ow;
 int ret = 0;
-int bit_depth_chroma, start, num_comps;
+int bit_depth_chroma, num_comps, multi_layer_ext;
 int i;
 
 // Coded parameters
@@ -1170,16 +1170,29 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 }
 
 sps->max_sub_layers = get_bits(gb, 3) + 1;
+multi_layer_ext = nuh_layer_id > 0 &&
+  sps->max_sub_layers == HEVC_MAX_SUB_LAYERS + 1;
+if (multi_layer_ext) {
+if (!sps->vps)
+return AVERROR(EINVAL);
+
+sps->max_sub_layers = sps->vps->vps_max_sub_layers;
+}
 if (sps->max_sub_layers > HEVC_MAX_SUB_LAYERS) {
 av_log(avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n",
sps->max_sub_layers);
 return AVERROR_INVALIDDATA;
 }
 
+if (!multi_layer_ext) {
 sps->temporal_id_nesting = get_bits(gb, 1);
 
 if ((ret = parse_ptl(gb, avctx, 1, &sps->ptl, sps->max_sub_layers)) < 0)
 return ret;
+} else {
+sps->temporal_id_nesting = sps->max_sub_layers > 1 ?
+   sps->vps->vps_max_sub_layers : 1;
+}
 
 *sps_id = get_ue_golomb_long(gb);
 if (*sps_id >= HEVC_MAX_SPS_COUNT) {
@@ -1187,6 +1200,28 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 return AVERROR_INVALIDDATA;
 }
 
+if (multi_layer_ext) {
+const RepFormat *rf = &sps->vps->rep_format;
+
+if (get_bits1(gb) &&// update_rep_format_flag
+get_bits(gb, 8)) {  // sps_rep_format_idx
+av_log(avctx, AV_LOG_ERROR, "sps_rep_format_idx!=0\n");
+return AVERROR_PATCHWELCOME;
+}
+
+sps->separate_colour_plane = rf->separate_colour_plane_flag;
+sps->chroma_format_idc = sps->separate_colour_plane ? 0 :
+ rf->chroma_format_idc;
+sps->bit_depth = rf->bit_depth_luma;
+sps->width = rf->pic_width_in_luma_samples;
+sps->height= rf->pic_height_in_luma_samples;
+
+sps->pic_conf_win.left_offset   = rf->conf_win_left_offset;

[FFmpeg-devel] [PATCH 06/23] lavc/hevc_ps: parse VPS extension

2024-09-14 Thread Anton Khirnov
From: Niklas Haas 

Only implementing what's needed for MV-HEVC with two views.

Signed-off-by: Anton Khirnov 
---
 libavcodec/hevc/hevc.h |   9 +-
 libavcodec/hevc/ps.c   | 307 +++--
 libavcodec/hevc/ps.h   |  62 +
 3 files changed, 364 insertions(+), 14 deletions(-)

diff --git a/libavcodec/hevc/hevc.h b/libavcodec/hevc/hevc.h
index 9fdbc0a224..8bd59142db 100644
--- a/libavcodec/hevc/hevc.h
+++ b/libavcodec/hevc/hevc.h
@@ -100,11 +100,14 @@ enum HEVCSliceType {
 
 enum {
 // 7.4.3.1: vps_max_layers_minus1 is in [0, 62].
-HEVC_MAX_LAYERS = 63,
+HEVC_MAX_LAYERS = 63,
 // 7.4.3.1: vps_max_sub_layers_minus1 is in [0, 6].
-HEVC_MAX_SUB_LAYERS = 7,
+HEVC_MAX_SUB_LAYERS = 7,
 // 7.4.3.1: vps_num_layer_sets_minus1 is in [0, 1023].
-HEVC_MAX_LAYER_SETS = 1024,
+HEVC_MAX_LAYER_SETS = 1024,
+// 7.4.3.1: vps_max_layer_id is in [0, 63].
+HEVC_MAX_LAYER_ID   = 63,
+HEVC_MAX_NUH_LAYER_ID   = 62,
 
 // 7.4.2.1: vps_video_parameter_set_id is u(4).
 HEVC_MAX_VPS_COUNT = 16,
diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c
index 2c3b335966..35de26644c 100644
--- a/libavcodec/hevc/ps.c
+++ b/libavcodec/hevc/ps.c
@@ -311,11 +311,17 @@ static int decode_profile_tier_level(GetBitContext *gb, 
AVCodecContext *avctx,
 }
 
 static int parse_ptl(GetBitContext *gb, AVCodecContext *avctx,
-  PTL *ptl, int max_num_sub_layers)
+ int profile_present, PTL *ptl, int max_num_sub_layers)
 {
-int i;
-if (decode_profile_tier_level(gb, avctx, &ptl->general_ptl) < 0 ||
-get_bits_left(gb) < 8 + (8*2 * (max_num_sub_layers - 1 > 0))) {
+int i, status = 0;
+
+if (profile_present) {
+status = decode_profile_tier_level(gb, avctx, &ptl->general_ptl);
+} else {
+memset(&ptl->general_ptl, 0, sizeof(ptl->general_ptl));
+}
+
+if (status < 0 || get_bits_left(gb) < 8 + (8*2 * (max_num_sub_layers - 1 > 
0))) {
 av_log(avctx, AV_LOG_ERROR, "PTL information too short\n");
 return -1;
 }
@@ -444,13 +450,273 @@ static void hevc_vps_free(FFRefStructOpaque opaque, void 
*obj)
 av_freep(&vps->data);
 }
 
+enum ScalabilityMask {
+HEVC_SCALABILITY_DEPTH  = 0,
+HEVC_SCALABILITY_MULTIVIEW  = 1,
+HEVC_SCALABILITY_SPATIAL= 2,
+HEVC_SCALABILITY_AUXILIARY  = 3,
+HEVC_SCALABILITY_MASK_MAX   = 15,
+};
+
+enum DependencyType {
+HEVC_DEP_TYPE_SAMPLE = 0,
+HEVC_DEP_TYPE_MV = 1,
+HEVC_DEP_TYPE_BOTH   = 2,
+};
+
+static int decode_vps_ext(GetBitContext *gb, AVCodecContext *avctx, HEVCVPS 
*vps,
+  uint64_t layer1_id_included)
+{
+PTL ptl_dummy;
+uint8_t max_sub_layers[HEVC_MAX_LAYERS];
+
+int splitting_flag, dimension_id_len, view_id_len, num_add_olss,
+default_output_layer_idc, direct_dep_type_len, direct_dep_type,
+sub_layers_max_present, sub_layer_flag_info_present_flag, nb_ptl;
+unsigned non_vui_extension_length;
+
+if (vps->vps_max_layers == 1 || vps->vps_num_layer_sets == 1) {
+av_log(avctx, AV_LOG_VERBOSE, "Ignoring VPS extensions with a single 
layer\n");
+return 0;
+}
+
+if (vps->vps_max_layers > 2) {
+av_log(avctx, AV_LOG_ERROR,
+   "VPS has %d layers, only 2 layers are supported\n",
+   vps->vps_max_layers);
+return AVERROR_PATCHWELCOME;
+}
+if (vps->vps_num_layer_sets > 2) {
+av_log(avctx, AV_LOG_ERROR,
+   "VPS has %d layer sets, only 2 layer sets are supported\n",
+   vps->vps_num_layer_sets);
+return AVERROR_PATCHWELCOME;
+}
+
+align_get_bits(gb);
+
+/**
+ * For stereoscopic MV-HEVC, the following simplifying assumptions are 
made:
+ *
+ * - vps_max_layers = 2 (one base layer, one multiview layer)
+ * - vps_num_layer_sets = 2 (one output layer set for each view)
+ * - NumScalabilityTypes = 1 (only HEVC_SCALABILITY_MULTIVIEW)
+ * - direct_dependency_flag[1][0] = 1 (second layer depends on first)
+ * - num_add_olss = 0 (no extra output layer sets)
+ * - default_output_layer_idc = 0 (1:1 mapping between OLSs and layers)
+ * - layer_id_included_flag[1] = {1, 1} (consequence of layer dependencies)
+ * - vps_num_rep_formats_minus1 = 0 (all layers have the same size)
+ *
+ * Which results in the following derived variables:
+ * - ViewOrderIdx = {0, 1}
+ * - NumViews = 2
+ * - DependencyFlag[1][0] = 1
+ * - NumDirectRefLayers = {0, 1}
+ * - NumRefLayers = {0, 1}
+ * - NumPredictedLayers = {1, 0}
+ * - NumIndependentLayers = 1
+ * - NumLayersInTreePartition = {2}
+ * - NumLayerSets = 2
+ * - NumOutputLayerSets = 2
+ * - OlsIdxToLsIdx = {0, 1}
+ * - LayerIdxInVps = {0, 1}
+ * - NumLayersInIdList = {1, 2}
+ * - NumNecessaryLayers = {1, 2}
+ * - NecessaryLayerFlag = {{1, 0}, {1, 1}}
+ * - NumOutputL

[FFmpeg-devel] [PATCH 09/23] lavc/hevc/ps: reindent

2024-09-14 Thread Anton Khirnov
---
 libavcodec/hevc/ps.c | 178 +--
 1 file changed, 89 insertions(+), 89 deletions(-)

diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c
index 2d09500278..f18b88489b 100644
--- a/libavcodec/hevc/ps.c
+++ b/libavcodec/hevc/ps.c
@@ -1185,10 +1185,10 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 }
 
 if (!multi_layer_ext) {
-sps->temporal_id_nesting = get_bits(gb, 1);
+sps->temporal_id_nesting = get_bits(gb, 1);
 
-if ((ret = parse_ptl(gb, avctx, 1, &sps->ptl, sps->max_sub_layers)) < 0)
-return ret;
+if ((ret = parse_ptl(gb, avctx, 1, &sps->ptl, sps->max_sub_layers)) < 
0)
+return ret;
 } else {
 sps->temporal_id_nesting = sps->max_sub_layers > 1 ?
sps->vps->vps_max_sub_layers : 1;
@@ -1222,69 +1222,69 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 sps->pic_conf_win.bottom_offset = rf->conf_win_bottom_offset;
 
 } else {
-sps->chroma_format_idc = get_ue_golomb_long(gb);
-if (sps->chroma_format_idc > 3U) {
-av_log(avctx, AV_LOG_ERROR, "chroma_format_idc %d is invalid\n", 
sps->chroma_format_idc);
-return AVERROR_INVALIDDATA;
-}
-
-if (sps->chroma_format_idc == 3)
-sps->separate_colour_plane = get_bits1(gb);
-
-if (sps->separate_colour_plane)
-sps->chroma_format_idc = 0;
-
-sps->width  = get_ue_golomb_long(gb);
-sps->height = get_ue_golomb_long(gb);
-if ((ret = av_image_check_size(sps->width,
-   sps->height, 0, avctx)) < 0)
-return ret;
-
-sps->conformance_window = get_bits1(gb);
-if (sps->conformance_window) {
-int vert_mult  = hevc_sub_height_c[sps->chroma_format_idc];
-int horiz_mult = hevc_sub_width_c[sps->chroma_format_idc];
-sps->pic_conf_win.left_offset   = get_ue_golomb_long(gb) * horiz_mult;
-sps->pic_conf_win.right_offset  = get_ue_golomb_long(gb) * horiz_mult;
-sps->pic_conf_win.top_offset= get_ue_golomb_long(gb) *  vert_mult;
-sps->pic_conf_win.bottom_offset = get_ue_golomb_long(gb) *  vert_mult;
-
-if (avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) {
-av_log(avctx, AV_LOG_DEBUG,
-   "discarding sps conformance window, "
-   "original values are l:%u r:%u t:%u b:%u\n",
-   sps->pic_conf_win.left_offset,
-   sps->pic_conf_win.right_offset,
-   sps->pic_conf_win.top_offset,
-   sps->pic_conf_win.bottom_offset);
-
-sps->pic_conf_win.left_offset   =
-sps->pic_conf_win.right_offset  =
-sps->pic_conf_win.top_offset=
-sps->pic_conf_win.bottom_offset = 0;
+sps->chroma_format_idc = get_ue_golomb_long(gb);
+if (sps->chroma_format_idc > 3U) {
+av_log(avctx, AV_LOG_ERROR, "chroma_format_idc %d is invalid\n", 
sps->chroma_format_idc);
+return AVERROR_INVALIDDATA;
 }
-}
 
-sps->bit_depth = get_ue_golomb_31(gb) + 8;
-if (sps->bit_depth > 16) {
-av_log(avctx, AV_LOG_ERROR, "Luma bit depth (%d) is out of range\n",
-   sps->bit_depth);
-return AVERROR_INVALIDDATA;
-}
-bit_depth_chroma = get_ue_golomb_31(gb) + 8;
-if (bit_depth_chroma > 16) {
-av_log(avctx, AV_LOG_ERROR, "Chroma bit depth (%d) is out of range\n",
-   bit_depth_chroma);
-return AVERROR_INVALIDDATA;
-}
-if (sps->chroma_format_idc && bit_depth_chroma != sps->bit_depth) {
-av_log(avctx, AV_LOG_ERROR,
-   "Luma bit depth (%d) is different from chroma bit depth (%d), "
-   "this is unsupported.\n",
-   sps->bit_depth, bit_depth_chroma);
-return AVERROR_INVALIDDATA;
-}
-sps->bit_depth_chroma = bit_depth_chroma;
+if (sps->chroma_format_idc == 3)
+sps->separate_colour_plane = get_bits1(gb);
+
+if (sps->separate_colour_plane)
+sps->chroma_format_idc = 0;
+
+sps->width  = get_ue_golomb_long(gb);
+sps->height = get_ue_golomb_long(gb);
+if ((ret = av_image_check_size(sps->width,
+   sps->height, 0, avctx)) < 0)
+return ret;
+
+sps->conformance_window = get_bits1(gb);
+if (sps->conformance_window) {
+int vert_mult  = hevc_sub_height_c[sps->chroma_format_idc];
+int horiz_mult = hevc_sub_width_c[sps->chroma_format_idc];
+sps->pic_conf_win.left_offset   = get_ue_golomb_long(gb) * 
horiz_mult;
+sps->pic_conf_win.right_offset  = get_ue_golomb_long(gb) * 
horiz_mult;
+sps->pic_conf_win.top_offset= get_ue_golomb_long(gb) *  
vert_mult;
+sps->pic_conf_win.bottom_offset = get_ue_golomb_long(gb) *  
vert_mult;
+
+if (avc

[FFmpeg-devel] [PATCH 11/23] lavc/hevc/parser: only split packets on NALUs with nuh_layer_id=0

2024-09-14 Thread Anton Khirnov
A packet should contain a full access unit, which for multilayer video
should contain all the layers.
---
 libavcodec/hevc/parser.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/hevc/parser.c b/libavcodec/hevc/parser.c
index 8c7444a162..16b40e2b10 100644
--- a/libavcodec/hevc/parser.c
+++ b/libavcodec/hevc/parser.c
@@ -262,7 +262,7 @@ static int hevc_find_frame_end(AVCodecParserContext *s, 
const uint8_t *buf,
 int i;
 
 for (i = 0; i < buf_size; i++) {
-int nut;
+int nut, layer_id;
 
 pc->state64 = (pc->state64 << 8) | buf[i];
 
@@ -270,6 +270,11 @@ static int hevc_find_frame_end(AVCodecParserContext *s, 
const uint8_t *buf,
 continue;
 
 nut = (pc->state64 >> 2 * 8 + 1) & 0x3F;
+
+layer_id = (pc->state64 >> 11) & 0x3F;
+if (layer_id > 0)
+continue;
+
 // Beginning of access unit
 if ((nut >= HEVC_NAL_VPS && nut <= HEVC_NAL_EOB_NUT) || nut == 
HEVC_NAL_SEI_PREFIX ||
 (nut >= 41 && nut <= 44) || (nut >= 48 && nut <= 55)) {
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 03/23] lavu/frame: add side data storing view ID for multi-view video

2024-09-14 Thread Anton Khirnov
---
 doc/APIchanges| 3 +++
 fftools/ffprobe.c | 2 ++
 libavfilter/vf_showinfo.c | 2 ++
 libavutil/frame.c | 1 +
 libavutil/frame.h | 9 +
 libavutil/version.h   | 2 +-
 6 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 830a38cd69..189932c99c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-xx-xx - xxx - lavu 59.37.100 - frame.h
+  Add AV_FRAME_DATA_VIEW_ID.
+
 2024-09-xx - xx - lavc 61.13.100 - avcodec.h
   Add avcodec_get_supported_config() and enum AVCodecConfig; deprecate
   AVCodec.pix_fmts, AVCodec.sample_fmts, AVCodec.supported_framerates,
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index bf5ebe3ce0..14b98d22a1 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2920,6 +2920,8 @@ static void print_frame_side_data(WriterContext *w,
 } else if (sd->type == AV_FRAME_DATA_FILM_GRAIN_PARAMS) {
 AVFilmGrainParams *fgp = (AVFilmGrainParams *)sd->data;
 print_film_grain_params(w, fgp);
+} else if (sd->type == AV_FRAME_DATA_VIEW_ID) {
+print_int("view_id", *(int*)sd->data);
 }
 writer_print_section_footer(w);
 }
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index f81df9d1bf..77082505f5 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -857,6 +857,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 case AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT:
 dump_ambient_viewing_environment(ctx, sd);
 break;
+case AV_FRAME_DATA_VIEW_ID:
+av_log(ctx, AV_LOG_INFO, "view id: %d\n", *(int*)sd->data);
 default:
 if (name)
 av_log(ctx, AV_LOG_INFO,
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 5cbfc6a48b..891909fc2a 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -46,6 +46,7 @@ static const AVSideDataDescriptor sd_props[] = {
 [AV_FRAME_DATA_DETECTION_BBOXES]= { "Bounding boxes for object 
detection and classification" },
 [AV_FRAME_DATA_DOVI_RPU_BUFFER] = { "Dolby Vision RPU Data" },
 [AV_FRAME_DATA_DOVI_METADATA]   = { "Dolby Vision Metadata" },
+[AV_FRAME_DATA_VIEW_ID] = { "View ID" },
 [AV_FRAME_DATA_STEREO3D]= { "Stereo 3D",   
 AV_SIDE_DATA_PROP_GLOBAL },
 [AV_FRAME_DATA_REPLAYGAIN]  = { "AVReplayGain",
 AV_SIDE_DATA_PROP_GLOBAL },
 [AV_FRAME_DATA_DISPLAYMATRIX]   = { "3x3 displaymatrix",   
 AV_SIDE_DATA_PROP_GLOBAL },
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 60bb966f8b..cea1c68df5 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -228,6 +228,15 @@ enum AVFrameSideDataType {
  * encoding.
  */
 AV_FRAME_DATA_VIDEO_HINT,
+
+/**
+ * This side data must be associated with a video frame.
+ * The presence of this side data indicates that the video stream is
+ * composed of multiple views (e.g. stereoscopic 3D content,
+ * cf. H.264 Annex H or H.265 Annex G).
+ * The data is an int storing the view ID.
+ */
+AV_FRAME_DATA_VIEW_ID,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/version.h b/libavutil/version.h
index 25a6f5531b..7900379c12 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  59
-#define LIBAVUTIL_VERSION_MINOR  36
+#define LIBAVUTIL_VERSION_MINOR  37
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 15/23] lavc/hevcdec: implement decoding MV-HEVC

2024-09-14 Thread Anton Khirnov
At most two layers are supported.

Aspects of this work were sponsored by Vimeo and Meta.
---
 Changelog |   1 +
 doc/decoders.texi |  45 ++
 libavcodec/hevc/hevcdec.c | 332 ++
 libavcodec/hevc/hevcdec.h |  34 +++-
 libavcodec/hevc/refs.c|  67 ++--
 5 files changed, 423 insertions(+), 56 deletions(-)

diff --git a/Changelog b/Changelog
index b6f91d7c8c..ff5d1b1bc8 100644
--- a/Changelog
+++ b/Changelog
@@ -21,6 +21,7 @@ version :
 - MediaCodec AAC/AMR-NB/AMR-WB/MP3 decoding
 - YUV colorspace negotiation for codecs and filters, obsoleting the
   YUVJ pixel format
+- MV-HEVC decoding
 
 
 version 7.0:
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 2fcc761d2f..17bb361ffa 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -38,6 +38,51 @@ Select an operating point of a scalable AV1 bitstream (0 - 
31). Default is 0.
 
 @end table
 
+@section hevc
+HEVC (AKA ITU-T H.265 or ISO/IEC 23008-2) decoder.
+
+The decoder supports MV-HEVC multiview streams with at most two views. Views to
+be output are selected by supplying a list of view IDs to the decoder (the
+@option{view_ids} option). This option may be set either statically before
+decoder init, or from the @code{get_format()} callback - useful for the case
+when the view count or IDs change dynamically during decoding.
+
+Only the base layer is decoded by default.
+
+Note that if you are using the @code{ffmpeg} CLI tool, you should be using view
+specifiers as documented in its manual, rather than the options documented 
here.
+
+@subsection Options
+
+@table @option
+
+@item view_ids (MV-HEVC)
+Specify a list of view IDs that should be output. This option can also be set 
to
+a single '-1', which will cause all views defined in the VPS to be decoded and
+output.
+
+@item view_ids_available (MV-HEVC)
+This option may be read by the caller to retrieve an array of view IDs 
available
+in the active VPS. The array is empty for single-layer video.
+
+The value of this option is guaranteed to be accurate when read from the
+@code{get_format()} callback. It may also be set at other times (e.g. after
+opening the decoder), but the value is informational only and may be incorrect
+(e.g. when the stream contains multiple distinct VPS NALUs).
+
+@item view_pos_available (MV-HEVC)
+This option may be read by the caller to retrieve an array of view positions
+(left, right, or unspecified) available in the active VPS, as
+@code{AVStereo3DView} values. When the array is available, its elements apply 
to
+the corresponding elements of @option{view_ids_available}, i.e.
+@code{view_pos_available[i]} contains the position of view with ID
+@code{view_ids_available[i]}.
+
+Same validity restrictions as for @option{view_ids_available} apply to
+this option.
+
+@end table
+
 @section rawvideo
 
 Raw video decoder.
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index cbf763b8be..692f19e97e 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -34,6 +34,7 @@
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/stereo3d.h"
 #include "libavutil/timecode.h"
 
 #include "aom_film_grain.h"
@@ -417,6 +418,109 @@ static int export_stream_params_from_sei(HEVCContext *s)
 return 0;
 }
 
+static int export_multilayer(HEVCContext *s, const HEVCVPS *vps)
+{
+const HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
+
+av_freep(&s->view_ids_available);
+s->nb_view_ids_available = 0;
+av_freep(&s->view_pos_available);
+s->nb_view_pos_available = 0;
+
+// don't export anything in the trivial case (1 layer, view id=0)
+if (vps->nb_layers < 2 && !vps->view_id[0])
+return 0;
+
+s->view_ids_available = av_calloc(vps->nb_layers, 
sizeof(*s->view_ids_available));
+if (!s->view_ids_available)
+return AVERROR(ENOMEM);
+
+if (tdrdi->num_ref_displays) {
+s->view_pos_available = av_calloc(vps->nb_layers, 
sizeof(*s->view_pos_available));
+if (!s->view_pos_available)
+return AVERROR(ENOMEM);
+}
+
+for (int i = 0; i < vps->nb_layers; i++) {
+s->view_ids_available[i] = vps->view_id[i];
+
+if (s->view_pos_available) {
+s->view_pos_available[i] = vps->view_id[i] == 
tdrdi->left_view_id[0]  ?
+   AV_STEREO3D_VIEW_LEFT   
   :
+   vps->view_id[i] == 
tdrdi->right_view_id[0] ?
+   AV_STEREO3D_VIEW_RIGHT : 
AV_STEREO3D_VIEW_UNSPEC;
+}
+}
+s->nb_view_ids_available = vps->nb_layers;
+s->nb_view_pos_available = s->view_pos_available ? vps->nb_layers : 0;
+
+return 0;
+}
+
+static int setup_multilayer(HEVCContext *s, const HEVCVPS *vps)
+{
+unsigned layers_active_output = 0, highest_layer;
+
+s->layers_active_output = 1;
+s->layers_active_decode = 1;
+
+// nothing requested -

[FFmpeg-devel] [PATCH 12/23] lavc/hevcdec: implement slice header parsing for nuh_layer_id>0

2024-09-14 Thread Anton Khirnov
Cf. F.7.3.6.1 "General slice segment header syntax"
---
 libavcodec/hevc/hevcdec.c | 36 
 libavcodec/hevc/hevcdec.h |  1 +
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index ebe2f5ad11..d3a47b65f4 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -584,7 +584,8 @@ static int hls_slice_header(SliceHeader *sh, const 
HEVCContext *s, GetBitContext
 {
 const HEVCPPS *pps;
 const HEVCSPS *sps;
-unsigned pps_id;
+const HEVCVPS *vps;
+unsigned pps_id, layer_idx;
 int i, ret;
 
 // Coded parameters
@@ -607,6 +608,8 @@ static int hls_slice_header(SliceHeader *sh, const 
HEVCContext *s, GetBitContext
 
 pps = s->ps.pps_list[pps_id];
 sps = pps->sps;
+vps = sps->vps;
+layer_idx = vps->layer_idx[s->nuh_layer_id];
 
 if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1)
 sh->no_output_of_prior_pics_flag = 1;
@@ -652,7 +655,8 @@ static int hls_slice_header(SliceHeader *sh, const 
HEVCContext *s, GetBitContext
 return AVERROR_INVALIDDATA;
 }
 if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I &&
-!pps->pps_curr_pic_ref_enabled_flag) {
+!pps->pps_curr_pic_ref_enabled_flag &&
+s->nuh_layer_id == 0) {
 av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n");
 return AVERROR_INVALIDDATA;
 }
@@ -665,8 +669,10 @@ static int hls_slice_header(SliceHeader *sh, const 
HEVCContext *s, GetBitContext
 if (sps->separate_colour_plane)
 sh->colour_plane_id = get_bits(gb, 2);
 
-if (!IS_IDR(s)) {
-int poc, pos;
+if (!IS_IDR(s) ||
+(s->nuh_layer_id > 0 &&
+ !(vps->poc_lsb_not_present & (1 << layer_idx {
+int poc;
 
 sh->pic_order_cnt_lsb = get_bits(gb, sps->log2_max_poc_lsb);
 poc = ff_hevc_compute_poc(sps, s->poc_tid0, sh->pic_order_cnt_lsb, 
s->nal_unit_type);
@@ -678,6 +684,10 @@ static int hls_slice_header(SliceHeader *sh, const 
HEVCContext *s, GetBitContext
 poc = sh->poc;
 }
 sh->poc = poc;
+}
+
+if (!IS_IDR(s)) {
+int pos;
 
 sh->short_term_ref_pic_set_sps_flag = get_bits1(gb);
 pos = get_bits_left(gb);
@@ -724,6 +734,23 @@ static int hls_slice_header(SliceHeader *sh, const 
HEVCContext *s, GetBitContext
 sh->slice_temporal_mvp_enabled_flag = 0;
 }
 
+sh->inter_layer_pred = 0;
+if (s->nuh_layer_id > 0) {
+int num_direct_ref_layers = vps->num_direct_ref_layers[layer_idx];
+
+if (vps->default_ref_layers_active)
+sh->inter_layer_pred = !!num_direct_ref_layers;
+else if (num_direct_ref_layers) {
+sh->inter_layer_pred = get_bits1(gb);
+
+if (sh->inter_layer_pred && num_direct_ref_layers > 1) {
+av_log(s->avctx, AV_LOG_ERROR,
+   "NumDirectRefLayers>1 not supported\n");
+return AVERROR_PATCHWELCOME;
+}
+}
+}
+
 if (sps->sao_enabled) {
 sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);
 if (sps->chroma_format_idc) {
@@ -3238,6 +3265,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL 
*nal)
 int ret;
 
 s->nal_unit_type = nal->type;
+s->nuh_layer_id  = nal->nuh_layer_id;
 s->temporal_id   = nal->temporal_id;
 
 if (FF_HW_HAS_CB(s->avctx, decode_params) &&
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index e3194fd87e..16b1d1ce92 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -215,6 +215,7 @@ typedef struct SliceHeader {
 uint8_t dependent_slice_segment_flag;
 uint8_t pic_output_flag;
 uint8_t colour_plane_id;
+uint8_t inter_layer_pred;
 
 ///< RPS coded in the slice header itself is stored here
 int short_term_ref_pic_set_sps_flag;
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 13/23] lavc/hevc/hevcdec: implement MV-HEVC inter-layer prediction

2024-09-14 Thread Anton Khirnov
The per-frame reference picture set contains two more lists -
INTER_LAYER[01]. Assuming at most two layers, INTER_LAYER1 is always
empty, but is added anyway for completeness.

When inter-layer prediction is enabled, INTER_LAYER0 for the
second-layer frame will contain the base-layer frame from the same
access unit, if it exists.

The new lists are then used in per-slice reference picture set
construction as per F.8.3.4 "Decoding process for reference picture
lists construction".
---
 libavcodec/hevc/hevcdec.c |  7 -
 libavcodec/hevc/hevcdec.h |  8 --
 libavcodec/hevc/refs.c| 58 ++-
 libavcodec/nvdec_hevc.c   |  2 +-
 libavcodec/vdpau_hevc.c   |  2 +-
 5 files changed, 59 insertions(+), 18 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index d3a47b65f4..cbf763b8be 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -784,7 +784,7 @@ static int hls_slice_header(SliceHeader *sh, const 
HEVCContext *s, GetBitContext
 
 sh->rpl_modification_flag[0] = 0;
 sh->rpl_modification_flag[1] = 0;
-nb_refs = ff_hevc_frame_nb_refs(sh, pps);
+nb_refs = ff_hevc_frame_nb_refs(sh, pps, layer_idx);
 if (!nb_refs) {
 av_log(s->avctx, AV_LOG_ERROR, "Zero refs for a frame with P 
or B slices.\n");
 return AVERROR_INVALIDDATA;
@@ -3356,6 +3356,11 @@ static int decode_nal_units(HEVCContext *s, const 
uint8_t *buf, int length)
 s->eos = 0;
 s->slice_initialized = 0;
 
+for (int i = 0; i < FF_ARRAY_ELEMS(s->layers); i++) {
+HEVCLayerContext *l = &s->layers[i];
+l->cur_frame = NULL;
+}
+
 /* split the input packet into NAL units, so we know the upper bound on the
  * number of slices in the frame */
 ret = ff_h2645_packet_split(&s->pkt, buf, length, s->avctx,
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index 16b1d1ce92..57bf5aa599 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -84,6 +84,8 @@ enum RPSType {
 ST_FOLL,
 LT_CURR,
 LT_FOLL,
+INTER_LAYER0,
+INTER_LAYER1,
 NB_RPS_TYPE,
 };
 
@@ -442,6 +444,7 @@ typedef struct HEVCLocalContext {
 
 typedef struct HEVCLayerContext {
 HEVCFrame   DPB[32];
+HEVCFrame  *cur_frame;
 
 const HEVCSPS  *sps; // RefStruct reference
 
@@ -498,7 +501,7 @@ typedef struct HEVCContext {
 struct AVMD5 *md5_ctx;
 
 ///< candidate references for the current frame
-RefPicList rps[5];
+RefPicList rps[NB_RPS_TYPE];
 
 const HEVCVPS *vps; ///< RefStruct reference
 const HEVCPPS *pps; ///< RefStruct reference
@@ -615,7 +618,8 @@ int ff_hevc_res_scale_sign_flag(HEVCLocalContext *lc, int 
idx);
 /**
  * Get the number of candidate references for the current frame.
  */
-int ff_hevc_frame_nb_refs(const SliceHeader *sh, const HEVCPPS *pps);
+int ff_hevc_frame_nb_refs(const SliceHeader *sh, const HEVCPPS *pps,
+  unsigned layer_idx);
 
 int ff_hevc_set_new_ref(HEVCContext *s, HEVCLayerContext *l, int poc);
 
diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index 20fdbb5794..625ac68aaa 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -149,6 +149,7 @@ int ff_hevc_set_new_ref(HEVCContext *s, HEVCLayerContext 
*l, int poc)
 return AVERROR(ENOMEM);
 
 s->cur_frame = ref;
+l->cur_frame = ref;
 s->collocated_ref = NULL;
 
 if (s->sh.pic_output_flag)
@@ -248,7 +249,9 @@ int ff_hevc_slice_rpl(HEVCContext *s)
 return ret;
 
 if (!(s->rps[ST_CURR_BEF].nb_refs + s->rps[ST_CURR_AFT].nb_refs +
-  s->rps[LT_CURR].nb_refs) && !s->pps->pps_curr_pic_ref_enabled_flag) {
+  s->rps[LT_CURR].nb_refs +
+  s->rps[INTER_LAYER0].nb_refs + s->rps[INTER_LAYER1].nb_refs) &&
+!s->pps->pps_curr_pic_ref_enabled_flag) {
 av_log(s->avctx, AV_LOG_ERROR, "Zero refs in the frame RPS.\n");
 return AVERROR_INVALIDDATA;
 }
@@ -258,11 +261,14 @@ int ff_hevc_slice_rpl(HEVCContext *s)
 RefPicList *rpl = &s->cur_frame->refPicList[list_idx];
 
 /* The order of the elements is
- * ST_CURR_BEF - ST_CURR_AFT - LT_CURR for the L0 and
- * ST_CURR_AFT - ST_CURR_BEF - LT_CURR for the L1 */
-int cand_lists[3] = { list_idx ? ST_CURR_AFT : ST_CURR_BEF,
-  list_idx ? ST_CURR_BEF : ST_CURR_AFT,
-  LT_CURR };
+ * ST_CURR_BEF - INTER_LAYER0 - ST_CURR_AFT - LT_CURR - INTER_LAYER1 
for the L0 and
+ * ST_CURR_AFT - INTER_LAYER1 - ST_CURR_BEF - LT_CURR - INTER_LAYER0 
for the L1 */
+int cand_lists[] = { list_idx ? ST_CURR_AFT : ST_CURR_BEF,
+ list_idx ? INTER_LAYER1 : INTER_LAYER0,
+ list_idx ? ST_CURR_BEF : ST_CURR_AFT,
+ LT_CURR,
+ 

[FFmpeg-devel] [PATCH 23/23] tests/fate/hevc: add a test for selecting view by position

2024-09-14 Thread Anton Khirnov
Using a real-world iPhone-recorded file.
---
 tests/fate/hevc.mak |  5 +
 tests/ref/fate/hevc-mv-position | 32 
 2 files changed, 37 insertions(+)
 create mode 100644 tests/ref/fate/hevc-mv-position

diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index 2511730edf..6d8865ea66 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -286,6 +286,11 @@ $(TARGET_SAMPLES)/hevc-conformance/MVHEVCS_A.bit
 fate-hevc-mv-switch: CMD = framecrc -i "concat:$(INPUT)" -fps_mode passthrough 
-map 0:vidx:0 -map 0:vidx:1
 FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, CONCAT_PROTOCOL) += fate-hevc-mv-switch
 
+# multiview stream, select view by position
+# (depends on Three Dimensional Reference Displays Information SEI)
+fate-hevc-mv-position: CMD = framecrc -i $(TARGET_SAMPLES)/hevc/multiview.mov 
-map 0:v:vpos:left -map 0:v:vpos:right
+FATE_HEVC-$(call FRAMECRC, MOV, HEVC) += fate-hevc-mv-position
+
 FATE_SAMPLES_AVCONV += $(FATE_HEVC-yes)
 FATE_SAMPLES_FFPROBE += $(FATE_HEVC_FFPROBE-yes)
 
diff --git a/tests/ref/fate/hevc-mv-position b/tests/ref/fate/hevc-mv-position
new file mode 100644
index 00..660789557c
--- /dev/null
+++ b/tests/ref/fate/hevc-mv-position
@@ -0,0 +1,32 @@
+#tb 0: 1/30
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 1920x1080
+#sar 0: 0/1
+#tb 1: 1/30
+#media_type 1: video
+#codec_id 1: rawvideo
+#dimensions 1: 1920x1080
+#sar 1: 0/1
+0,  0,  0,1,  3110400, 0xd0ce90de
+1,  0,  0,1,  3110400, 0x1859a3ba
+0,  1,  1,1,  3110400, 0x5ce1bc1a
+1,  1,  1,1,  3110400, 0x43cf57e5
+0,  2,  2,1,  3110400, 0x14cf9f7f
+1,  2,  2,1,  3110400, 0x4ffc98ea
+0,  3,  3,1,  3110400, 0x9a6bb93c
+1,  3,  3,1,  3110400, 0x96a2bcfb
+0,  4,  4,1,  3110400, 0x69e5377d
+1,  4,  4,1,  3110400, 0xec4561f0
+0,  5,  5,1,  3110400, 0x66b3bd5d
+1,  5,  5,1,  3110400, 0x633f23f5
+0,  6,  6,1,  3110400, 0x83a2ada2
+1,  6,  6,1,  3110400, 0xe10a2fe7
+0,  7,  7,1,  3110400, 0x503bbe42
+1,  7,  7,1,  3110400, 0x8ecd5c39
+0,  8,  8,1,  3110400, 0xaeb27981
+1,  8,  8,1,  3110400, 0xe571a478
+0,  9,  9,1,  3110400, 0xbe14bf1e
+1,  9,  9,1,  3110400, 0x87d4dbe3
+0, 10, 10,1,  3110400, 0xbd329d79
+1, 10, 10,1,  3110400, 0xc78097f4
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 17/23] fftools/cmdutils: tighten condition for media type stream specifiers

2024-09-14 Thread Anton Khirnov
Require the character indicating media type to be followed by a
non-alphanumeric character (or end of string).

Needed by future syntax extensions.
---
 fftools/cmdutils.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index a9a7ff4194..1573106d8b 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -988,6 +988,12 @@ FILE *get_preset_file(char *filename, size_t filename_size,
 return f;
 }
 
+static int cmdutils_isalnum(char c)
+{
+return (c >= '0' && c <= '9') ||
+   (c >= 'A' && c <= 'Z') ||
+   (c >= 'a' && c <= 'z');
+}
 
 void stream_specifier_uninit(StreamSpecifier *ss)
 {
@@ -1024,8 +1030,9 @@ int stream_specifier_parse(StreamSpecifier *ss, const 
char *spec,
 
 // this terminates the specifier
 break;
-} else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 
'd' ||
-   *spec == 't' || *spec == 'V') { /* opt:[vasdtV] */
+} else if ((*spec == 'v' || *spec == 'a' || *spec == 's' ||
+*spec == 'd' || *spec == 't' || *spec == 'V') &&
+   !cmdutils_isalnum(*(spec + 1))) { /* opt:[vasdtV] */
 if (ss->media_type != AVMEDIA_TYPE_UNKNOWN) {
 av_log(logctx, AV_LOG_ERROR, "Stream type specified multiple 
times\n");
 ret = AVERROR(EINVAL);
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 20/23] tests/fate/hevc: add MV-HEVC conformance sample tests

2024-09-14 Thread Anton Khirnov
Only those that can be decoded with our implementation, so excluding
* C and D - independent layers
* G, H, I - more than 2 layers

Frame hashes verified against the reference implementation from
https://hevc.hhi.fraunhofer.de/svn/svn_3DVCSoftware/
---
 tests/fate/hevc.mak   |  13 +-
 tests/ref/fate/hevc-conformance-MVHEVCS_A | 106 +
 tests/ref/fate/hevc-conformance-MVHEVCS_B | 138 ++
 tests/ref/fate/hevc-conformance-MVHEVCS_E | 106 +
 tests/ref/fate/hevc-conformance-MVHEVCS_F | 106 +
 5 files changed, 468 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/hevc-conformance-MVHEVCS_A
 create mode 100644 tests/ref/fate/hevc-conformance-MVHEVCS_B
 create mode 100644 tests/ref/fate/hevc-conformance-MVHEVCS_E
 create mode 100644 tests/ref/fate/hevc-conformance-MVHEVCS_F

diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index 88aeb9cebd..eb9d3a875c 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -178,7 +178,14 @@ HEVC_SAMPLES_444_12BIT =\
 PERSIST_RPARAM_A_RExt_Sony_3\
 $(if $(CONFIG_LARGE_TESTS), $(HEVC_SAMPLES_444_12BIT_LARGE))
 
-FATE_HEVC_VARS := 8BIT 10BIT 422_10BIT 422_10BIN 444_8BIT 444_12BIT
+HEVC_SAMPLES_MULTIVIEW =\
+MVHEVCS_A   \
+MVHEVCS_B   \
+MVHEVCS_E   \
+MVHEVCS_F   \
+
+
+FATE_HEVC_VARS := 8BIT 10BIT 422_10BIT 422_10BIN 444_8BIT 444_12BIT MULTIVIEW
 $(foreach VAR,$(FATE_HEVC_VARS), $(eval HEVC_TESTS_$(VAR) := $(addprefix 
fate-hevc-conformance-, $(HEVC_SAMPLES_$(VAR)
 
 # equivalent bitstreams
@@ -202,6 +209,8 @@ $(HEVC_TESTS_422_10BIT) $(HEVC_TESTS_422_10BIN): SCALE_OPTS 
:= -pix_fmt yuv422p1
 $(HEVC_TESTS_444_12BIT): SCALE_OPTS := -pix_fmt yuv444p12le -vf scale
 fate-hevc-conformance-%: CMD = framecrc -i 
$(TARGET_SAMPLES)/hevc-conformance/$(subst fate-hevc-conformance-,,$(@)).bit 
$(SCALE_OPTS)
 $(HEVC_TESTS_422_10BIN): CMD = framecrc -i 
$(TARGET_SAMPLES)/hevc-conformance/$(subst fate-hevc-conformance-,,$(@)).bin 
$(SCALE_OPTS)
+$(HEVC_TESTS_MULTIVIEW): CMD = framecrc -i 
$(TARGET_SAMPLES)/hevc-conformance/$(subst fate-hevc-conformance-,,$(@)).bit \
+   -pix_fmt yuv420p -map "0:view:0" -map "0:view:1" -vf setpts=N
 
 FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER) += $(HEVC_TESTS_8BIT) 
$(HEVC_TESTS_444_8BIT)
 FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER SCALE_FILTER) += \
@@ -210,6 +219,8 @@ FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER 
SCALE_FILTER) += \
 $(HEVC_TESTS_422_10BIN) \
 $(HEVC_TESTS_444_12BIT) \
 
+FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER SCALE_FILTER) += 
$(HEVC_TESTS_MULTIVIEW)
+
 fate-hevc-paramchange-yuv420p-yuv420p10: CMD = framecrc -i 
$(TARGET_SAMPLES)/hevc/paramchange_yuv420p_yuv420p10.hevc -fps_mode passthrough 
-sws_flags area+accurate_rnd+bitexact
 FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER SCALE_FILTER LARGE_TESTS) 
+= fate-hevc-paramchange-yuv420p-yuv420p10
 
diff --git a/tests/ref/fate/hevc-conformance-MVHEVCS_A 
b/tests/ref/fate/hevc-conformance-MVHEVCS_A
new file mode 100644
index 00..c919889207
--- /dev/null
+++ b/tests/ref/fate/hevc-conformance-MVHEVCS_A
@@ -0,0 +1,106 @@
+#tb 0: 1/120
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 1024x768
+#sar 0: 0/1
+#tb 1: 1/120
+#media_type 1: video
+#codec_id 1: rawvideo
+#dimensions 1: 1024x768
+#sar 1: 0/1
+0,  0,  0,0,  1179648, 0x4a15620e
+1,  0,  0,0,  1179648, 0x5b752453
+0,  1,  1,0,  1179648, 0xb33277fe
+1,  1,  1,0,  1179648, 0xacf4376d
+0,  2,  2,0,  1179648, 0x97b969bd
+1,  2,  2,0,  1179648, 0xa9d6e75d
+0,  3,  3,0,  1179648, 0x3c6b7b81
+1,  3,  3,0,  1179648, 0x2142cc59
+0,  4,  4,0,  1179648, 0xdf83fe63
+1,  4,  4,0,  1179648, 0x838d4f0a
+0,  5,  5,0,  1179648, 0x93fc3bdf
+1,  5,  5,0,  1179648, 0x29bc71c2
+0,  6,  6,0,  1179648, 0x18f90aa3
+1,  6,  6,0,  1179648, 0x3b25ee18
+0,  7,  7,0,  1179648, 0x84c730c5
+1,  7,  7,0,  1179648, 0x60ecae5b
+0,  8,  8,0,  1179648, 0x7b49f2b1
+1,  8,  8,0,  1179648, 0x8c3c635e
+0,  9,  9,0,  1179648, 0x71f1b862
+1,  9,  9,0,  1179648, 0x16c2a6fc
+0, 10, 10,0,  1179648, 0x92be991a
+1, 10, 10,0,  1179648, 0x092d6378
+0, 11, 11,0,  1179648, 0xa948322d
+1, 11, 11,0,  1179648, 0x5d977eec
+0, 12, 12,  

[FFmpeg-devel] [PATCH 21/23] tests/fate/hevc: add a test for nontrivial values of nuh_layer_id

2024-09-14 Thread Anton Khirnov
Typical files use 0 for the base layer and 1 for the secondary one, but
any value for the secondary layer should be supported.
---
 tests/fate/hevc.mak |  4 
 tests/ref/fate/hevc-mv-nuh-layer-id | 15 +++
 2 files changed, 19 insertions(+)
 create mode 100644 tests/ref/fate/hevc-mv-nuh-layer-id

diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index eb9d3a875c..df827d821f 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -272,6 +272,10 @@ FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER 
SCALE_FILTER) += fate-hevc-sm
 fate-hevc-pir: CMD = framecrc -i $(TARGET_SAMPLES)/hevc/pir.hevc
 FATE_HEVC-$(call FRAMECRC, HEVC, HEVC) += fate-hevc-pir
 
+# multiview stream, where the secondary layer has a nontrivial nuh_layer_id=6
+fate-hevc-mv-nuh-layer-id: CMD = framecrc -i 
$(TARGET_SAMPLES)/hevc/mv_nuh_layer_id.bit -map 0:view:all
+FATE_HEVC-$(call FRAMECRC, HEVC, HEVC) += fate-hevc-mv-nuh-layer-id
+
 FATE_SAMPLES_AVCONV += $(FATE_HEVC-yes)
 FATE_SAMPLES_FFPROBE += $(FATE_HEVC_FFPROBE-yes)
 
diff --git a/tests/ref/fate/hevc-mv-nuh-layer-id 
b/tests/ref/fate/hevc-mv-nuh-layer-id
new file mode 100644
index 00..3cbefe17f6
--- /dev/null
+++ b/tests/ref/fate/hevc-mv-nuh-layer-id
@@ -0,0 +1,15 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 128x128
+#sar 0: 0/1
+0,  0,  0,1,24576, 0xdfd350a6
+0,  1,  1,1,24576, 0xf8f638da
+0,  2,  2,1,24576, 0x8ac574d5
+0,  3,  3,1,24576, 0xd22675a4
+0,  4,  4,1,24576, 0xdd0f4704
+0,  5,  5,1,24576, 0x60da42e6
+0,  6,  6,1,24576, 0x8bf28fdd
+0,  7,  7,1,24576, 0xe0577f6e
+0,  8,  8,1,24576, 0x8b3e3c29
+0,  9,  9,1,24576, 0x8d9944bd
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 22/23] tests/fate/hevc: add a test for switching between single and multi-view

2024-09-14 Thread Anton Khirnov
---
 tests/fate/hevc.mak   |  10 ++
 tests/ref/fate/hevc-mv-switch | 172 ++
 2 files changed, 182 insertions(+)
 create mode 100644 tests/ref/fate/hevc-mv-switch

diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index df827d821f..2511730edf 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -276,6 +276,16 @@ FATE_HEVC-$(call FRAMECRC, HEVC, HEVC) += fate-hevc-pir
 fate-hevc-mv-nuh-layer-id: CMD = framecrc -i 
$(TARGET_SAMPLES)/hevc/mv_nuh_layer_id.bit -map 0:view:all
 FATE_HEVC-$(call FRAMECRC, HEVC, HEVC) += fate-hevc-mv-nuh-layer-id
 
+# NB: $\ at the end of line joins lines without adding whitespace;
+# this trick is recommended by GNU make manual
+fate-hevc-mv-switch: INPUT = \
+$(TARGET_SAMPLES)/hevc-conformance/LS_A_Orange_2.bit|$\
+$(TARGET_SAMPLES)/hevc/mv_nuh_layer_id.bit|$\
+$(TARGET_SAMPLES)/hevc-conformance/NoOutPrior_B_Qualcomm_1.bit|$\
+$(TARGET_SAMPLES)/hevc-conformance/MVHEVCS_A.bit
+fate-hevc-mv-switch: CMD = framecrc -i "concat:$(INPUT)" -fps_mode passthrough 
-map 0:vidx:0 -map 0:vidx:1
+FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, CONCAT_PROTOCOL) += fate-hevc-mv-switch
+
 FATE_SAMPLES_AVCONV += $(FATE_HEVC-yes)
 FATE_SAMPLES_FFPROBE += $(FATE_HEVC_FFPROBE-yes)
 
diff --git a/tests/ref/fate/hevc-mv-switch b/tests/ref/fate/hevc-mv-switch
new file mode 100644
index 00..0fc3630637
--- /dev/null
+++ b/tests/ref/fate/hevc-mv-switch
@@ -0,0 +1,172 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 416x240
+#sar 0: 0/1
+#tb 1: 1/25
+#media_type 1: video
+#codec_id 1: rawvideo
+#dimensions 1: 128x128
+#sar 1: 0/1
+0,  0,  0,1,   149760, 0x94a51701
+0,  1,  1,1,   149760, 0x67c71885
+0,  2,  2,1,   149760, 0x218f1751
+0,  3,  3,1,   149760, 0x56951bef
+0,  4,  4,1,   149760, 0x76aec81e
+0,  5,  5,1,   149760, 0x20df61ac
+0,  6,  6,1,   149760, 0x2eacf616
+0,  7,  7,1,   149760, 0x06322ce2
+0,  8,  8,1,   149760, 0xf14aa104
+0,  9,  9,1,   149760, 0xc948dcba
+1, 10, 10,1,24576, 0xf8f638da
+0, 11, 11,1,   149760, 0x674e34b1
+1, 12, 12,1,24576, 0xd22675a4
+0, 13, 13,1,   149760, 0x41d3acd6
+1, 14, 14,1,24576, 0x60da42e6
+0, 15, 15,1,   149760, 0x55a5b835
+1, 16, 16,1,24576, 0xe0577f6e
+0, 17, 17,1,   149760, 0xc6958049
+1, 18, 18,1,24576, 0x8d9944bd
+0, 19, 19,1,   149760, 0x94b37050
+0, 20, 20,1,   149760, 0xed72a560
+0, 21, 21,1,   149760, 0xd0ccac61
+0, 22, 22,1,   149760, 0x6cc2d7fa
+0, 23, 23,1,   149760, 0x3a02b5ba
+0, 24, 24,1,   149760, 0xce7ef09c
+0, 25, 25,1,   149760, 0xa518fc05
+0, 26, 26,1,   149760, 0x01d238fe
+0, 27, 27,1,   149760, 0x5f5012fa
+0, 28, 28,1,   149760, 0x5b8e7405
+0, 29, 29,1,   149760, 0xcc2e5b33
+0, 30, 30,1,   149760, 0x590a6890
+0, 31, 31,1,   149760, 0x9c7b189f
+0, 32, 32,1,   149760, 0xd0752ef4
+0, 33, 33,1,   149760, 0x367513ce
+0, 34, 34,1,   149760, 0xb64c209d
+0, 35, 35,1,   149760, 0x6e50994c
+0, 36, 36,1,   149760, 0x8276cce4
+0, 37, 37,1,   149760, 0xb292ac8f
+0, 38, 38,1,   149760, 0x57de9d2c
+0, 39, 39,1,   149760, 0xe8533f38
+0, 40, 40,1,   149760, 0xde9b536d
+0, 41, 41,1,   149760, 0x83173b1d
+0, 42, 42,1,   149760, 0x853a83a4
+0, 43, 43,1,   149760, 0x481af1bf
+0, 44, 44,1,   149760, 0x27221abb
+0, 45, 45,1,   149760, 0x094eac00
+0, 46, 46,1,   149760, 0x3f3a27c8
+0, 47, 47,1,   149760, 0x8f19b2af
+0, 48, 48,1,   149760, 0x93e7e591
+0, 49, 49,1,   149760, 0x0c531ab8
+0, 50, 50,1,   149760, 0x3456ef8a
+0, 51, 51,1,   149760, 0xfee2ec1e
+0, 52, 52,1,   149760, 0x76b4b750
+0, 53, 53,1,   149760, 0xa48bb670
+0, 54, 54,1,   149760, 0x3dee7cac
+0, 55, 55,1,   149760, 0x2b20561d
+0, 56, 56,1,   149760, 0xd3c5bf9f

[FFmpeg-devel] [PATCH 18/23] fftools/ffmpeg_sched: allow decoders to have multiple outputs

2024-09-14 Thread Anton Khirnov
Will be useful for multilayer video.
---
 fftools/ffmpeg_dec.c  |  10 ++--
 fftools/ffmpeg_demux.c|   2 +-
 fftools/ffmpeg_filter.c   |   4 +-
 fftools/ffmpeg_mux_init.c |   2 +-
 fftools/ffmpeg_sched.c| 102 --
 fftools/ffmpeg_sched.h|  21 ++--
 6 files changed, 100 insertions(+), 41 deletions(-)

diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index c2bcf784b0..54f7223f0f 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -578,7 +578,7 @@ static int process_subtitle(DecoderPriv *dp, AVFrame *frame)
 if (!subtitle)
 return 0;
 
-ret = sch_dec_send(dp->sch, dp->sch_idx, frame);
+ret = sch_dec_send(dp->sch, dp->sch_idx, 0, frame);
 if (ret < 0)
 av_frame_unref(frame);
 
@@ -620,7 +620,7 @@ static int transcode_subtitles(DecoderPriv *dp, const 
AVPacket *pkt,
 frame->time_base = pkt->time_base;
 frame->opaque= (void*)(intptr_t)FRAME_OPAQUE_SUB_HEARTBEAT;
 
-ret = sch_dec_send(dp->sch, dp->sch_idx, frame);
+ret = sch_dec_send(dp->sch, dp->sch_idx, 0, frame);
 return ret == AVERROR_EOF ? AVERROR_EXIT : ret;
 } else if (pkt && (intptr_t)pkt->opaque == PKT_OPAQUE_FIX_SUB_DURATION) {
 return fix_sub_duration_heartbeat(dp, av_rescale_q(pkt->pts, 
pkt->time_base,
@@ -773,7 +773,7 @@ static int packet_decode(DecoderPriv *dp, AVPacket *pkt, 
AVFrame *frame)
 
 dp->dec.frames_decoded++;
 
-ret = sch_dec_send(dp->sch, dp->sch_idx, frame);
+ret = sch_dec_send(dp->sch, dp->sch_idx, 0, frame);
 if (ret < 0) {
 av_frame_unref(frame);
 return ret == AVERROR_EOF ? AVERROR_EXIT : ret;
@@ -951,7 +951,7 @@ static int decoder_thread(void *arg)
   dp->last_frame_pts + dp->last_frame_duration_est;
 dt.frame->time_base = dp->last_frame_tb;
 
-ret = sch_dec_send(dp->sch, dp->sch_idx, dt.frame);
+ret = sch_dec_send(dp->sch, dp->sch_idx, 0, dt.frame);
 if (ret < 0 && ret != AVERROR_EOF) {
 av_log(dp, AV_LOG_FATAL,
"Error signalling EOF timestamp: %s\n", av_err2str(ret));
@@ -1355,7 +1355,7 @@ int dec_create(const OptionsContext *o, const char *arg, 
Scheduler *sch)
 return ret;
 enc_idx = ret;
 
-ret = sch_connect(sch, SCH_ENC(enc_idx), SCH_DEC(dp->sch_idx));
+ret = sch_connect(sch, SCH_ENC(enc_idx), SCH_DEC_IN(dp->sch_idx));
 if (ret < 0)
 return ret;
 
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 039ee0c785..476efff127 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -954,7 +954,7 @@ static int ist_use(InputStream *ist, int decoding_needed)
 ds->sch_idx_dec = ret;
 
 ret = sch_connect(d->sch, SCH_DSTREAM(d->f.index, ds->sch_idx_stream),
-  SCH_DEC(ds->sch_idx_dec));
+  SCH_DEC_IN(ds->sch_idx_dec));
 if (ret < 0)
 return ret;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 8b420e68ab..05f9b287fb 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -686,7 +686,7 @@ static int ifilter_bind_ist(InputFilter *ifilter, 
InputStream *ist)
 if (dec_idx < 0)
 return dec_idx;
 
-ret = sch_connect(fgp->sch, SCH_DEC(dec_idx),
+ret = sch_connect(fgp->sch, SCH_DEC_OUT(dec_idx, 0),
 SCH_FILTER_IN(fgp->sch_idx, ifp->index));
 if (ret < 0)
 return ret;
@@ -732,7 +732,7 @@ static int ifilter_bind_dec(InputFilterPriv *ifp, Decoder 
*dec)
 if (dec_idx < 0)
 return dec_idx;
 
-ret = sch_connect(fgp->sch, SCH_DEC(dec_idx),
+ret = sch_connect(fgp->sch, SCH_DEC_OUT(dec_idx, 0),
 SCH_FILTER_IN(fgp->sch_idx, ifp->index));
 if (ret < 0)
 return ret;
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 6d9029c9c3..771fb2ef7b 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1514,7 +1514,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 ms->sch_idx_src = sched_idx;
 
 if (ost->enc) {
-ret = sch_connect(mux->sch, SCH_DEC(sched_idx),
+ret = sch_connect(mux->sch, SCH_DEC_OUT(sched_idx, 0),
 SCH_ENC(ms->sch_idx_enc));
 if (ret < 0)
 goto fail;
diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c
index cff824340b..ef0b6e2897 100644
--- a/fftools/ffmpeg_sched.c
+++ b/fftools/ffmpeg_sched.c
@@ -71,13 +71,19 @@ typedef struct SchTask {
 int thread_running;
 } SchTask;
 
+typedef struct SchDecOutput {
+SchedulerNode  *dst;
+uint8_t*dst_finished;
+unsigned nb_dst;
+} SchDecOutput;
+
 typedef struct SchDec {
 const AVClass  *class;
 
 SchedulerNode   src;
-Schedul

[FFmpeg-devel] [PATCH 04/23] lavfi/f_select: allow selection based on view ID

2024-09-14 Thread Anton Khirnov
Can be used together with the split filter to decompose multiview video
into individual views.
---
 doc/filters.texi   | 3 +++
 libavfilter/f_select.c | 9 +
 2 files changed, 12 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index db2f4b7ea7..428986a1e9 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -3,6 +3,9 @@ Represents the width of the input video frame.
 @item ih @emph{(video only)}
 Represents the height of the input video frame.
 
+@item view @emph{(video only)}
+View ID for multi-view video.
+
 @end table
 
 The default value of the select expression is "1".
diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index 6ba96bd7c5..ba0ae31f1b 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -93,6 +93,8 @@ static const char *const var_names[] = {
 "ih",///< ih: Represents the height of the input video 
frame.
 "iw",///< iw: Represents the width of the input video 
frame.
 
+"view",
+
 NULL
 };
 
@@ -150,6 +152,8 @@ enum var_name {
 VAR_IH,
 VAR_IW,
 
+VAR_VIEW,
+
 VAR_VARS_NB
 };
 
@@ -343,6 +347,7 @@ static void select_frame(AVFilterContext *ctx, AVFrame 
*frame)
 SelectContext *select = ctx->priv;
 AVFilterLink *inlink = ctx->inputs[0];
 FilterLink  *inl = ff_filter_link(inlink);
+const AVFrameSideData *sd;
 double res;
 
 if (isnan(select->var_values[VAR_START_PTS]))
@@ -381,6 +386,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
 snprintf(buf, sizeof(buf), "%f", select->var_values[VAR_SCENE]);
 av_dict_set(&frame->metadata, "lavfi.scene_score", buf, 0);
 }
+
+sd = av_frame_side_data_get(frame->side_data, frame->nb_side_data,
+AV_FRAME_DATA_VIEW_ID);
+select->var_values[VAR_VIEW] = sd ? *(int*)sd->data : NAN;
 break;
 }
 
-- 
2.43.0

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

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


Re: [FFmpeg-devel] is libswscale maintained?

2024-09-14 Thread Andrew Randrianasulu
ср, 11 сент. 2024 г., 05:44 Stephen Hutchinson :

> On 9/10/24 7:45 PM, Andrew Randrianasulu wrote:
> > I often saw suggestion to use -vf zscale but this is not default, and
> z.img
> > upstream seems to be in suspended animation:
> >
> > https://github.com/sekrit-twc/zimg/issues/207
>
> Because that's not upstream?  It moved over a year ago.
> https://bitbucket.org/the-sekrit-twc/zimg/commits/branch/master



ah, thanks. May be leaving note about it on github will be nice


>
> Also, between
> http://git.videolan.org/?p=ffmpeg.git&a=search&h=HEAD&st=commit&s=swscale
> and https://ffmpeg.org//pipermail/ffmpeg-devel/2024-June/330076.html,
> swscale-related development doesn't look inactive
> to me at all.
> ___
> 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 02/23] compat: add a fallback implementation of C23 stdbit.h

2024-09-14 Thread James Almer

On 9/14/2024 7:45 AM, Anton Khirnov wrote:

From: Rémi Denis-Courmont 

Header contents taken from VLC commit 7a970a33329c9836d169727ddbaf49a33240d587.

Signed-off-by: Anton Khirnov 
---
  compat/stdbit/stdbit.h | 594 +
  configure  |   4 +
  tests/ref/fate/source  |   1 +
  3 files changed, 599 insertions(+)
  create mode 100644 compat/stdbit/stdbit.h

diff --git a/compat/stdbit/stdbit.h b/compat/stdbit/stdbit.h
new file mode 100644
index 00..b6a2c7e945
--- /dev/null
+++ b/compat/stdbit/stdbit.h
@@ -0,0 +1,594 @@
+/*
+ * Copyright (C) 2023 Rémi Denis-Courmont
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ */
+
+#ifndef __STDC_VERSION_STDBIT_H__
+#define __STDC_VERSION_STDBIT_H__ 202311L
+
+#include 
+#include  /* CHAR_BIT */
+
+#define __STDC_ENDIAN_LITTLE__ 1234
+#define __STDC_ENDIAN_BIG__4321
+
+#ifdef __BYTE_ORDER__


This doesn't seem to be defined in msvc. I looked at VLC and their CI 
seems to use gcc only for Windows, which would explain why it's written 
as is.


It should be safe to just hardcode little endian for it (or Windows in 
general, even for aarch64).




OpenPGP_signature.asc
Description: OpenPGP digital 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] is libswscale maintained?

2024-09-14 Thread Andrew Randrianasulu
On Wed, Sep 11, 2024 at 12:20 PM Niklas Haas  wrote:
>
> On Wed, 11 Sep 2024 02:45:59 +0300 Andrew Randrianasulu 
>  wrote:
> > I can't find entry about it in ffmpeg/MAINTAINERS
> >
> > bugs meanwhile exist
> >
> > https://trac.ffmpeg.org/ticket/3345
> > https://trac.ffmpeg.org/ticket/7978
>
> There is on ongoing effort to redesign swscale, as well as fixing all 
> currently
> open bugs, throughout the rest of 2024. Stay tuned for this.

I'm looking into your tree on github.

But I think something still off at the input side of ffmpeg git?

https://trac.ffmpeg.org/ticket/11182#comment:32

if I patched correct function it still calls limited to full range
conversion while y4m input was already in full range
(as far as I understand color range propagates in this case from
demuxer, not codec)

I updated my ffmpeg to 3f84d1d1fb75e4192c35664b4dd4741e8381b667 and it
still behaves the same

I also looked at internals of swscale, there is funny line:

https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD:/libswscale/utils.c#l876

   dstRange = 0; //FIXME range = 1 is handled elsewhere

does this mean that dst *range* is ignored as far as matrix
coefficient generation in fill_rgb2yuv_table is concerned?

I do not think our code [0], uses it directly, and commenting out this
line does not change outcome for 11182

I also hope new API  for avscale will be not very hard to use by
not-quite programmers :) like me.

as for signal theory and filter configurability .. I forced to read on
it because I want to understand
how it works both conceptually and in real-world, so I can have at
least SOME idea where bugs might be,

I tried to add some sws_flags ( int flags= SWS_BITEXACT |
SWS_ACCURATE_RND) outside of SWS_POINT to our code,
but this does not improve outcome for our bug -
https://www.cinelerra-gg.org/bugtracker/view.php?id=665 Avoiding whole
call to
sws_setColorspaceDetails for yuv8->yuv8 "solved" problem but then we
need to add some filters and properties on enc manually?

[0]
https://git.cinelerra-gg.org/git/?p=goodguy/cinelerra.git;a=blob;f=cinelerra-5.1/cinelerra/ffmpeg.C;h=9b8832dd718c94dd8b815edc7eb5c9d732953dd6;hb=HEAD#l1682
https://git.cinelerra-gg.org/git/?p=goodguy/cinelerra.git;a=blob;f=cinelerra-5.1/cinelerra/ffmpeg.C;h=9b8832dd718c94dd8b815edc7eb5c9d732953dd6;hb=HEAD#l1812

>
> >
> > I often saw suggestion to use -vf zscale but this is not default, and z.img
> > upstream seems to be in suspended animation:
> >
> > https://github.com/sekrit-twc/zimg/issues/207
> > ___
> > 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/vvc_mc: R-V V avg w_avg

2024-09-14 Thread Rémi Denis-Courmont
Hi,

LGTM for the RISC-V side. No clue about the VVC side.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2 02/23] compat: add a fallback implementation of C23 stdbit.h

2024-09-14 Thread Anton Khirnov
From: Rémi Denis-Courmont 

Header contents taken from VLC commit 7a970a33329c9836d169727ddbaf49a33240d587.

Signed-off-by: Anton Khirnov 
---
 compat/stdbit/stdbit.h | 596 +
 configure  |   4 +
 tests/ref/fate/source  |   1 +
 3 files changed, 601 insertions(+)
 create mode 100644 compat/stdbit/stdbit.h

diff --git a/compat/stdbit/stdbit.h b/compat/stdbit/stdbit.h
new file mode 100644
index 00..b434fc2357
--- /dev/null
+++ b/compat/stdbit/stdbit.h
@@ -0,0 +1,596 @@
+/*
+ * Copyright (C) 2023 Rémi Denis-Courmont
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ */
+
+#ifndef __STDC_VERSION_STDBIT_H__
+#define __STDC_VERSION_STDBIT_H__ 202311L
+
+#include 
+#include  /* CHAR_BIT */
+
+#define __STDC_ENDIAN_LITTLE__ 1234
+#define __STDC_ENDIAN_BIG__4321
+
+#ifdef __BYTE_ORDER__
+# if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+#  define __STDC_ENDIAN_NATIVE__ __STDC_ENDIAN_LITTLE__
+# elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+#  define __STDC_ENDIAN_NATIVE__ __STDC_ENDIAN_BIG__
+# else
+#  define __STDC_ENDIAN_NATIVE__ 3412
+# endif
+#elif defined(_MSC_VER)
+#  define __STDC_ENDIAN_NATIVE__ __STDC_ENDIAN_LITTLE__
+#else
+# error Not implemented.
+#endif
+
+#define __stdbit_generic_type_func(func, value) \
+_Generic (value, \
+unsigned long long: stdc_##func##_ull((unsigned long long)(value)), \
+unsigned long:  stdc_##func##_ul((unsigned long)(value)), \
+unsigned int:   stdc_##func##_ui((unsigned int)(value)), \
+unsigned short: stdc_##func##_us((unsigned short)(value)), \
+unsigned char:  stdc_##func##_uc((unsigned char)(value)))
+
+#if defined (__GNUC__) || defined (__clang__)
+static inline unsigned int stdc_leading_zeros_ull(unsigned long long value)
+{
+return value ? __builtin_clzll(value) : (CHAR_BIT * sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_ul(unsigned long value)
+{
+return value ? __builtin_clzl(value) : (CHAR_BIT * sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_ui(unsigned int value)
+{
+return value ? __builtin_clz(value) : (CHAR_BIT * sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_us(unsigned short value)
+{
+return stdc_leading_zeros_ui(value)
+   - CHAR_BIT * (sizeof (int) - sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_uc(unsigned char value)
+{
+return stdc_leading_zeros_ui(value) - (CHAR_BIT * (sizeof (int) - 1));
+}
+#else
+static inline unsigned int __stdc_leading_zeros(unsigned long long value,
+unsigned int size)
+{
+unsigned int zeros = size * CHAR_BIT;
+
+while (value != 0) {
+value >>= 1;
+zeros--;
+}
+
+return zeros;
+}
+
+static inline unsigned int stdc_leading_zeros_ull(unsigned long long value)
+{
+return __stdc_leading_zeros(value, sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_ul(unsigned long value)
+{
+return __stdc_leading_zeros(value, sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_ui(unsigned int value)
+{
+return __stdc_leading_zeros(value, sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_us(unsigned short value)
+{
+return __stdc_leading_zeros(value, sizeof (value));
+}
+
+static inline unsigned int stdc_leading_zeros_uc(unsigned char value)
+{
+return __stdc_leading_zeros(value, sizeof (value));
+}
+#endif
+
+#define stdc_leading_zeros(value) \
+__stdbit_generic_type_func(leading_zeros, value)
+
+static inline unsigned int stdc_leading_ones_ull(unsigned long long value)
+{
+return stdc_leading_zeros_ull(~value);
+}
+
+static inline unsigned int stdc_leading_ones_ul(unsigned long value)
+{
+return stdc_leading_zeros_ul(~value);
+}
+
+static inline unsigned int stdc_leading_ones_ui(unsigned int value)
+{
+return stdc_leading_zeros_ui(~value);
+}
+
+static inline unsigned int stdc_leading_ones_us(unsigned short value)
+{
+return stdc_leading_zeros_us(~value);
+}
+
+static inline unsigned int stdc_leading_ones_uc(unsigned char value)
+{
+return stdc_leading_zeros_uc(~value);
+}
+
+#define stdc_leading_ones(value) \
+__stdbit_generic_t

Re: [FFmpeg-devel] Procedure to enable the Windows on ARM64 FFMPEG Libraries

2024-09-14 Thread Kacper Michajlow
On Thu, 12 Sept 2024 at 09:21, Niranjan Kshatriya (QUIC)
 wrote:
>
> Hi team,
>
> I am working on Windows on ARM application development and wants to execute 
> FFMPEG on my device.
> On FFMPEG download page (Releases * BtbN/FFmpeg-Builds 
> (github.com)) "windows on 
> Arm" binary is not available (Other binaries(x64 and linux Arm64) are 
> generated and validated ).
>
> X64 version of FFMPEG binary is running successfully on my ARM device but 
> looking for ARM Native FFMPEG support for better experience as x64 is running 
> slow on my device compared to x64 device.
>
> I have downloaded the source from :  https://git.ffmpeg.org/ffmpeg.gitand 
> compiled locally ( on ARM using WSL ) for Arm with tool chain : GitHub - 
> Windows-on-ARM-Experiments/mingw-woarm64-build: Workflows and build scripts 
> for Windows on Arm64 GNU cross-compiler for `aarch64-w64-mingw32` 
> target.
>   with below configuration :
>
> ./configure --arch=arm64 --target-os=mingw32 
> --cross-prefix=aarch64-w64-mingw32- --prefix=/ffbuild/prefix 
> --pkg-config-flags=--static --pkg-config=pkg-config --enable-gpl 
> --enable-version3 --disable-debug --disable-w32threads --enable-pthreads 
> --disable-libpulse --disable-libxcb

Currently you have 3 ways to produce native Windows on ARM binaries.
Mentioned by Martin, LLVM based toolchain
https://github.com/mstorsjo/llvm-mingw/releases
Mentioned by You, GNU based toolchain
https://github.com/Windows-on-ARM-Experiments
And third option would be MSVC build, which I didn't specifically test
with FFmpeg on ARM, but should works just fine as MSVC is natively
supported by ./configure.

I would agree with Martin, that LLVM toolchain should be prefered if
possible as it is way more mature, than the GNU one. I cannot comment
on MSVC as I don't have first hand experience, but I suspect it works
just fine, with all standard MSVC limitations.

As for prebuilt binaries, it's fully up to contributors to decide to
include ARM pipelines in their auto build scripts.

- Kacper
___
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] Procedure to enable the Windows on ARM64 FFMPEG Libraries

2024-09-14 Thread Timo Rothenpieler




On 12.09.2024 09:21, Niranjan Kshatriya (QUIC) wrote:

Hi team,

I am working on Windows on ARM application development and wants to execute 
FFMPEG on my device.
On FFMPEG download page (Releases * BtbN/FFmpeg-Builds 
(github.com)) "windows on Arm" 
binary is not available (Other binaries(x64 and linux Arm64) are generated and validated ).

X64 version of FFMPEG binary is running successfully on my ARM device but 
looking for ARM Native FFMPEG support for better experience as x64 is running 
slow on my device compared to x64 device.

I have downloaded the source from :  https://git.ffmpeg.org/ffmpeg.gitand 
compiled locally ( on ARM using WSL ) for Arm with tool chain : GitHub - 
Windows-on-ARM-Experiments/mingw-woarm64-build: Workflows and build scripts for 
Windows on Arm64 GNU cross-compiler for `aarch64-w64-mingw32` 
target.
  with below configuration :

./configure --arch=arm64 --target-os=mingw32 
--cross-prefix=aarch64-w64-mingw32- --prefix=/ffbuild/prefix 
--pkg-config-flags=--static --pkg-config=pkg-config --enable-gpl 
--enable-version3 --disable-debug --disable-w32threads --enable-pthreads 
--disable-libpulse --disable-libxcb


It will be good to have Windows on ARM prebuilt libraries for FFMPEG as part of 
Download repository (Releases * BtbN/FFmpeg-Builds 
(github.com)).


I decided against it since it's highly experimental still and breaks 
every other weak for a multitude of reasons.



What it takes to generate Windows on ARM libraries?


Right now builds work fine, just grab my set of scripts and build away.
___
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 16/23] avcodec/hevc/refs: export Stereo 3D side data

2024-09-14 Thread James Almer

On 9/14/2024 7:45 AM, Anton Khirnov wrote:

From: James Almer 

Use the 3D Reference Displays Info SEI message to link a view_id with
an eye.

Signed-off-by: James Almer 
---
  libavcodec/hevc/hevcdec.c |  1 +
  libavcodec/hevc/refs.c| 19 +++
  2 files changed, 20 insertions(+)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 692f19e97e..b784b10bcf 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3968,6 +3968,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
  s->sei.common.mastering_display= s0->sei.common.mastering_display;
  s->sei.common.content_light= s0->sei.common.content_light;
  s->sei.common.aom_film_grain   = s0->sei.common.aom_film_grain;
+s->sei.tdrdi   = s0->sei.tdrdi;
  
  return 0;

  }
diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index b9b08ca416..ac1b07a308 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -22,6 +22,7 @@
   */
  
  #include "libavutil/mem.h"

+#include "libavutil/stereo3d.h"
  
  #include "container_fifo.h"

  #include "decode.h"
@@ -94,6 +95,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)
  
  // add view ID side data if it's nontrivial

  if (vps->nb_layers > 1 || view_id) {
+HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
  AVFrameSideData *sd = av_frame_side_data_new(&frame->f->side_data,
   
&frame->f->nb_side_data,
   
AV_FRAME_DATA_VIEW_ID,
@@ -101,6 +103,23 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)
  if (!sd)
  goto fail;
  *(int*)sd->data = view_id;
+
+if (tdrdi->num_ref_displays) {
+AVStereo3D *stereo_3d;
+
+av_frame_remove_side_data(frame->f, AV_FRAME_DATA_STEREO3D);


As this is now being called before ff_progress_frame_get_buffer() (is 
there a reason you wanted the view_id side data and this one applied to 
the frame before get_buffer()?), it became a no-op and any stereo 3d 
side data in the input packet will be appended to the frame, resulting 
in something like:



[Parsed_showinfo_0 @ 0281481551c0]   side data - View ID: view id: 0
[Parsed_showinfo_0 @ 0281481551c0]   side data - Stereo 3D: type - frame 
alternate, view - right, primary_eye - none
[Parsed_showinfo_0 @ 0281481551c0]   side data - Spherical Mapping: 
rectilinear
[Parsed_showinfo_0 @ 0281481551c0]   side data - Stereo 3D: type - 
unspecified, view - packed, primary_eye - none, baseline: 19240, 
horizontal_disparity_adjustment: 0.0200, horizontal_field_of_view: 63.400


We don't really want to lose the information that's coded in the 
container but not in the bitstream (Which happened in the previous 
version of the patch too), so we should instead amend the container 
level side data with the bitstream information.


Something like:


diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index ac1b07a308..f4c2b18e83 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -93,21 +93,32 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)
 if (ret < 0)
 return NULL;

+if (!(s->layers_active_output & (1 << s->cur_layer)))
+frame->f->flags |= AV_FRAME_FLAG_DISCARD;
+
+ret = ff_progress_frame_get_buffer(s->avctx, &frame->tf,
+   AV_GET_BUFFER_FLAG_REF);
+if (ret < 0)
+return NULL;
+
 // add view ID side data if it's nontrivial
 if (vps->nb_layers > 1 || view_id) {
 HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
-AVFrameSideData *sd = av_frame_side_data_new(&frame->f->side_data,
- 
&frame->f->nb_side_data,
- AV_FRAME_DATA_VIEW_ID,
- sizeof(int), 0);
+AVFrameSideData *sd;
+
+av_frame_remove_side_data(frame->f, AV_FRAME_DATA_VIEW_ID);
+sd = av_frame_new_side_data(frame->f, AV_FRAME_DATA_VIEW_ID, 
sizeof(int));
 if (!sd)
 goto fail;
 *(int*)sd->data = view_id;

 if (tdrdi->num_ref_displays) {
-AVStereo3D *stereo_3d;
+AVStereo3D *stereo_3d = NULL;

-av_frame_remove_side_data(frame->f, AV_FRAME_DATA_STEREO3D);
+sd = av_frame_get_side_data(frame->f, AV_FRAME_DATA_STEREO3D);
+if (sd)
+stereo_3d = (AVStereo3D *)sd->data;
+else
 stereo_3d = av_stereo3d_create_side_data(frame->f);
 if (!stereo_3d)
 goto fail;
@@ -122,14 +133,6 @@ static HEVCFrame *alloc_fra

Re: [FFmpeg-devel] [PATCH v2] avcodec/vvc: Fix output and unref a frame which isn't decoding yet

2024-09-14 Thread Nuo Mi
Hi Zhili
Thank you for the patch.


On Fri, Sep 13, 2024 at 2:35 PM Zhao Zhili  wrote:

> From: Zhao Zhili 
>
> ff_vvc_output_frame is called before actually decoding. It's possible
> for ff_vvc_output_frame to select current frame to output. If current
> frame is nonref frame, it will be released by ff_vvc_unref_frame.
>
> Fix this by always marking the current frame with
> VVC_FRAME_FLAG_SHORT_REF, as is done by the HEVC decoder.
> ---
> fate sample:
>
> https://drive.google.com/file/d/1U5WGWeSsMFiEkhsl_vL4NiMma-LLh02t/view?usp=drive_link
> md5sum
> 
> :
> 8054b4b8e62c0171476b40206d044590  Hierarchical.bit
>
>  libavcodec/vvc/refs.c   |  5 +--
>  tests/fate/vvc.mak  |  1 +
>  tests/ref/fate/vvc-conformance-Hierarchical | 35 +
>  3 files changed, 37 insertions(+), 4 deletions(-)
>  create mode 100644 tests/ref/fate/vvc-conformance-Hierarchical
>
> diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
> index bebcef7fd6..d5aa2ff28d 100644
> --- a/libavcodec/vvc/refs.c
> +++ b/libavcodec/vvc/refs.c
> @@ -193,10 +193,7 @@ int ff_vvc_set_new_ref(VVCContext *s, VVCFrameContext
> *fc, AVFrame **frame)
>  if (s->no_output_before_recovery_flag && (IS_RASL(s) ||
> !GDR_IS_RECOVERED(s)))
>  ref->flags = VVC_FRAME_FLAG_SHORT_REF;
>  else if (ph->r->ph_pic_output_flag)
> -ref->flags = VVC_FRAME_FLAG_OUTPUT;
> -
> -if (!ph->r->ph_non_ref_pic_flag)
> -ref->flags |= VVC_FRAME_FLAG_SHORT_REF;
>
Could you clarify why we need to remove the above line?
Not every frame needs to be an output frame; some are used solely for
reference

Could you help split this into two separate patches?
1.  Fix the issue.
2. Add the FATE test.

Thank you

> +ref->flags = VVC_FRAME_FLAG_OUTPUT | VVC_FRAME_FLAG_SHORT_REF;
>
>  ref->poc  = poc;
>  ref->sequence = s->seq_decode;
> diff --git a/tests/fate/vvc.mak b/tests/fate/vvc.mak
> index 5335460263..7fd0a47214 100644
> --- a/tests/fate/vvc.mak
> +++ b/tests/fate/vvc.mak
> @@ -1,5 +1,6 @@
>  VVC_SAMPLES_8BIT =\
>  CodingToolsSets_A_2   \
> +Hierarchical  \
>
>  VVC_SAMPLES_10BIT =   \
>  APSALF_A_2\
> diff --git a/tests/ref/fate/vvc-conformance-Hierarchical
> b/tests/ref/fate/vvc-conformance-Hierarchical
> new file mode 100644
> index 00..0797305b9a
> --- /dev/null
> +++ b/tests/ref/fate/vvc-conformance-Hierarchical
> @@ -0,0 +1,35 @@
> +#tb 0: 1/25
> +#media_type 0: video
> +#codec_id 0: rawvideo
> +#dimensions 0: 480x320
> +#sar 0: 0/1
> +0,  0,  0,1,   230400, 0x3293f7f1
> +0,  1,  1,1,   230400, 0xe2570fa4
> +0,  2,  2,1,   230400, 0xecd608fb
> +0,  3,  3,1,   230400, 0xea46f9f4
> +0,  4,  4,1,   230400, 0xb715d24a
> +0,  5,  5,1,   230400, 0x69faaf46
> +0,  6,  6,1,   230400, 0xf9a362db
> +0,  7,  7,1,   230400, 0x2dcd19ca
> +0,  8,  8,1,   230400, 0xf8fda185
> +0,  9,  9,1,   230400, 0x48a35bfd
> +0, 10, 10,1,   230400, 0x27efe832
> +0, 11, 11,1,   230400, 0x74279617
> +0, 12, 12,1,   230400, 0x91935248
> +0, 13, 13,1,   230400, 0x29b621e6
> +0, 14, 14,1,   230400, 0x89b1ec0b
> +0, 15, 15,1,   230400, 0x898fdba1
> +0, 16, 16,1,   230400, 0xc6d18e6f
> +0, 17, 17,1,   230400, 0xedff651b
> +0, 18, 18,1,   230400, 0x677e2260
> +0, 19, 19,1,   230400, 0x930918ef
> +0, 20, 20,1,   230400, 0x70da2c30
> +0, 21, 21,1,   230400, 0x699a3b9d
> +0, 22, 22,1,   230400, 0xff3b1b3a
> +0, 23, 23,1,   230400, 0xca11d9a5
> +0, 24, 24,1,   230400, 0x904394e0
> +0, 25, 25,1,   230400, 0x392e5445
> +0, 26, 26,1,   230400, 0x6191f4d8
> +0, 27, 27,1,   230400, 0xa7d7be12
> +0, 28, 28,1,   230400, 0xbb29752c
> +0, 29, 29,1,   230400, 0x14ff297e
> --
> 2.42.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 wit

Re: [FFmpeg-devel] [PATCH 16/23] avcodec/hevc/refs: export Stereo 3D side data

2024-09-14 Thread James Almer

On 9/14/2024 7:12 PM, James Almer wrote:

On 9/14/2024 7:45 AM, Anton Khirnov wrote:

From: James Almer 

Use the 3D Reference Displays Info SEI message to link a view_id with
an eye.

Signed-off-by: James Almer 
---
  libavcodec/hevc/hevcdec.c |  1 +
  libavcodec/hevc/refs.c    | 19 +++
  2 files changed, 20 insertions(+)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 692f19e97e..b784b10bcf 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3968,6 +3968,7 @@ static int 
hevc_update_thread_context(AVCodecContext *dst,
  s->sei.common.mastering_display    = s0- 
>sei.common.mastering_display;

  s->sei.common.content_light    = s0->sei.common.content_light;
  s->sei.common.aom_film_grain   = s0->sei.common.aom_film_grain;
+    s->sei.tdrdi   = s0->sei.tdrdi;
  return 0;
  }
diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index b9b08ca416..ac1b07a308 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -22,6 +22,7 @@
   */
  #include "libavutil/mem.h"
+#include "libavutil/stereo3d.h"
  #include "container_fifo.h"
  #include "decode.h"
@@ -94,6 +95,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)

  // add view ID side data if it's nontrivial
  if (vps->nb_layers > 1 || view_id) {
+    HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
  AVFrameSideData *sd = av_frame_side_data_new(&frame->f- 
>side_data,
   &frame->f- 
>nb_side_data,
   
AV_FRAME_DATA_VIEW_ID,
@@ -101,6 +103,23 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)

  if (!sd)
  goto fail;
  *(int*)sd->data = view_id;
+
+    if (tdrdi->num_ref_displays) {
+    AVStereo3D *stereo_3d;
+
+    av_frame_remove_side_data(frame->f, 
AV_FRAME_DATA_STEREO3D);


As this is now being called before ff_progress_frame_get_buffer() (is 
there a reason you wanted the view_id side data and this one applied to 
the frame before get_buffer()?), it became a no-op and any stereo 3d 
side data in the input packet will be appended to the frame, resulting 
in something like:



[Parsed_showinfo_0 @ 0281481551c0]   side data - View ID: view id: 0
[Parsed_showinfo_0 @ 0281481551c0]   side data - Stereo 3D: type - 
frame alternate, view - right, primary_eye - none
[Parsed_showinfo_0 @ 0281481551c0]   side data - Spherical 
Mapping: rectilinear
[Parsed_showinfo_0 @ 0281481551c0]   side data - Stereo 3D: type - 
unspecified, view - packed, primary_eye - none, baseline: 19240, 
horizontal_disparity_adjustment: 0.0200, horizontal_field_of_view: 63.400


We don't really want to lose the information that's coded in the 
container but not in the bitstream (Which happened in the previous 
version of the patch too), so we should instead amend the container 
level side data with the bitstream information.


Something like:


diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index ac1b07a308..f4c2b18e83 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -93,21 +93,32 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)

 if (ret < 0)
 return NULL;

+    if (!(s->layers_active_output & (1 << s->cur_layer)))
+    frame->f->flags |= AV_FRAME_FLAG_DISCARD;
+
+    ret = ff_progress_frame_get_buffer(s->avctx, &frame->tf,
+   AV_GET_BUFFER_FLAG_REF);
+    if (ret < 0)
+    return NULL;
+
 // add view ID side data if it's nontrivial
 if (vps->nb_layers > 1 || view_id) {
 HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
-    AVFrameSideData *sd = av_frame_side_data_new(&frame->f- 
>side_data,
- &frame->f- 
>nb_side_data,
- 
AV_FRAME_DATA_VIEW_ID,
- sizeof(int), 
0);

+    AVFrameSideData *sd;
+
+    av_frame_remove_side_data(frame->f, AV_FRAME_DATA_VIEW_ID);
+    sd = av_frame_new_side_data(frame->f, 
AV_FRAME_DATA_VIEW_ID, sizeof(int));

 if (!sd)
 goto fail;
 *(int*)sd->data = view_id;

 if (tdrdi->num_ref_displays) {
-    AVStereo3D *stereo_3d;
+    AVStereo3D *stereo_3d = NULL;

-    av_frame_remove_side_data(frame->f, 
AV_FRAME_DATA_STEREO3D);
+    sd = av_frame_get_side_data(frame->f, 
AV_FRAME_DATA_STEREO3D);

+    if (sd)
+    stereo_3d = (AVStereo3D *)sd->data;
+    else
 stereo_3d = av_stereo3d_create_side_data(frame->f);
 if (!stereo_3d)
 goto fail;
@

[FFmpeg-devel] [PATCH v3 1/2] avcodec/vvc: Fix output and unref a frame which isn't decoding yet

2024-09-14 Thread Zhao Zhili
From: Zhao Zhili 

ff_vvc_output_frame is called before actually decoding. It's possible
for ff_vvc_output_frame to select current frame to output. If current
frame is nonref frame, it will be released by ff_vvc_unref_frame.

Fix this by always marking the current frame with
VVC_FRAME_FLAG_SHORT_REF, as is done by the HEVC decoder.
---
 libavcodec/vvc/refs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
index bebcef7fd6..133ff9eaba 100644
--- a/libavcodec/vvc/refs.c
+++ b/libavcodec/vvc/refs.c
@@ -193,7 +193,7 @@ int ff_vvc_set_new_ref(VVCContext *s, VVCFrameContext *fc, 
AVFrame **frame)
 if (s->no_output_before_recovery_flag && (IS_RASL(s) || 
!GDR_IS_RECOVERED(s)))
 ref->flags = VVC_FRAME_FLAG_SHORT_REF;
 else if (ph->r->ph_pic_output_flag)
-ref->flags = VVC_FRAME_FLAG_OUTPUT;
+ref->flags = VVC_FRAME_FLAG_OUTPUT | VVC_FRAME_FLAG_SHORT_REF;
 
 if (!ph->r->ph_non_ref_pic_flag)
 ref->flags |= VVC_FRAME_FLAG_SHORT_REF;
-- 
2.42.0

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

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


[FFmpeg-devel] [PATCH v3 2/2] fate/vvc: Add a sample which lose frames before b02b411

2024-09-14 Thread Zhao Zhili
From: Zhao Zhili 

---
sample:
8054b4b8e62c0171476b40206d044590  Hierarchical.bit
https://drive.google.com/file/d/1U5WGWeSsMFiEkhsl_vL4NiMma-LLh02t/view?usp=sharing

 tests/fate/vvc.mak  |  1 +
 tests/ref/fate/vvc-conformance-Hierarchical | 35 +
 2 files changed, 36 insertions(+)
 create mode 100644 tests/ref/fate/vvc-conformance-Hierarchical

diff --git a/tests/fate/vvc.mak b/tests/fate/vvc.mak
index 5335460263..7fd0a47214 100644
--- a/tests/fate/vvc.mak
+++ b/tests/fate/vvc.mak
@@ -1,5 +1,6 @@
 VVC_SAMPLES_8BIT =\
 CodingToolsSets_A_2   \
+Hierarchical  \
 
 VVC_SAMPLES_10BIT =   \
 APSALF_A_2\
diff --git a/tests/ref/fate/vvc-conformance-Hierarchical 
b/tests/ref/fate/vvc-conformance-Hierarchical
new file mode 100644
index 00..0797305b9a
--- /dev/null
+++ b/tests/ref/fate/vvc-conformance-Hierarchical
@@ -0,0 +1,35 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 480x320
+#sar 0: 0/1
+0,  0,  0,1,   230400, 0x3293f7f1
+0,  1,  1,1,   230400, 0xe2570fa4
+0,  2,  2,1,   230400, 0xecd608fb
+0,  3,  3,1,   230400, 0xea46f9f4
+0,  4,  4,1,   230400, 0xb715d24a
+0,  5,  5,1,   230400, 0x69faaf46
+0,  6,  6,1,   230400, 0xf9a362db
+0,  7,  7,1,   230400, 0x2dcd19ca
+0,  8,  8,1,   230400, 0xf8fda185
+0,  9,  9,1,   230400, 0x48a35bfd
+0, 10, 10,1,   230400, 0x27efe832
+0, 11, 11,1,   230400, 0x74279617
+0, 12, 12,1,   230400, 0x91935248
+0, 13, 13,1,   230400, 0x29b621e6
+0, 14, 14,1,   230400, 0x89b1ec0b
+0, 15, 15,1,   230400, 0x898fdba1
+0, 16, 16,1,   230400, 0xc6d18e6f
+0, 17, 17,1,   230400, 0xedff651b
+0, 18, 18,1,   230400, 0x677e2260
+0, 19, 19,1,   230400, 0x930918ef
+0, 20, 20,1,   230400, 0x70da2c30
+0, 21, 21,1,   230400, 0x699a3b9d
+0, 22, 22,1,   230400, 0xff3b1b3a
+0, 23, 23,1,   230400, 0xca11d9a5
+0, 24, 24,1,   230400, 0x904394e0
+0, 25, 25,1,   230400, 0x392e5445
+0, 26, 26,1,   230400, 0x6191f4d8
+0, 27, 27,1,   230400, 0xa7d7be12
+0, 28, 28,1,   230400, 0xbb29752c
+0, 29, 29,1,   230400, 0x14ff297e
-- 
2.42.0

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

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


Re: [FFmpeg-devel] [PATCH v2] avcodec/vvc: Fix output and unref a frame which isn't decoding yet

2024-09-14 Thread Zhao Zhili


> On Sep 15, 2024, at 08:46, Nuo Mi  wrote:
> 
> Hi Zhili
> Thank you for the patch.
> 
> 
> On Fri, Sep 13, 2024 at 2:35 PM Zhao Zhili  > wrote:
> 
>> From: Zhao Zhili 
>> 
>> ff_vvc_output_frame is called before actually decoding. It's possible
>> for ff_vvc_output_frame to select current frame to output. If current
>> frame is nonref frame, it will be released by ff_vvc_unref_frame.
>> 
>> Fix this by always marking the current frame with
>> VVC_FRAME_FLAG_SHORT_REF, as is done by the HEVC decoder.
>> ---
>> fate sample:
>> 
>> https://drive.google.com/file/d/1U5WGWeSsMFiEkhsl_vL4NiMma-LLh02t/view?usp=drive_link
>> md5sum
>> 
>> :
>> 8054b4b8e62c0171476b40206d044590  Hierarchical.bit
>> 
>> libavcodec/vvc/refs.c   |  5 +--
>> tests/fate/vvc.mak  |  1 +
>> tests/ref/fate/vvc-conformance-Hierarchical | 35 +
>> 3 files changed, 37 insertions(+), 4 deletions(-)
>> create mode 100644 tests/ref/fate/vvc-conformance-Hierarchical
>> 
>> diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
>> index bebcef7fd6..d5aa2ff28d 100644
>> --- a/libavcodec/vvc/refs.c
>> +++ b/libavcodec/vvc/refs.c
>> @@ -193,10 +193,7 @@ int ff_vvc_set_new_ref(VVCContext *s, VVCFrameContext
>> *fc, AVFrame **frame)
>> if (s->no_output_before_recovery_flag && (IS_RASL(s) ||
>> !GDR_IS_RECOVERED(s)))
>> ref->flags = VVC_FRAME_FLAG_SHORT_REF;
>> else if (ph->r->ph_pic_output_flag)
>> -ref->flags = VVC_FRAME_FLAG_OUTPUT;
>> -
>> -if (!ph->r->ph_non_ref_pic_flag)
>> -ref->flags |= VVC_FRAME_FLAG_SHORT_REF;
>> 
> Could you clarify why we need to remove the above line?
> Not every frame needs to be an output frame; some are used solely for
> reference

It should be kept. Here is v3.

https://ffmpeg.org/pipermail/ffmpeg-devel/2024-September/333534.html

> 
> Could you help split this into two separate patches?
> 1.  Fix the issue.
> 2. Add the FATE test.
> 
> Thank you
> 
>> +ref->flags = VVC_FRAME_FLAG_OUTPUT | VVC_FRAME_FLAG_SHORT_REF;
>> 
>> ref->poc  = poc;
>> ref->sequence = s->seq_decode;
>> diff --git a/tests/fate/vvc.mak b/tests/fate/vvc.mak
>> index 5335460263..7fd0a47214 100644
>> --- a/tests/fate/vvc.mak
>> +++ b/tests/fate/vvc.mak
>> @@ -1,5 +1,6 @@
>> VVC_SAMPLES_8BIT =\
>> CodingToolsSets_A_2   \
>> +Hierarchical  \
>> 
>> VVC_SAMPLES_10BIT =   \
>> APSALF_A_2\
>> diff --git a/tests/ref/fate/vvc-conformance-Hierarchical
>> b/tests/ref/fate/vvc-conformance-Hierarchical
>> new file mode 100644
>> index 00..0797305b9a
>> --- /dev/null
>> +++ b/tests/ref/fate/vvc-conformance-Hierarchical
>> @@ -0,0 +1,35 @@
>> +#tb 0: 1/25
>> +#media_type 0: video
>> +#codec_id 0: rawvideo
>> +#dimensions 0: 480x320
>> +#sar 0: 0/1
>> +0,  0,  0,1,   230400, 0x3293f7f1
>> +0,  1,  1,1,   230400, 0xe2570fa4
>> +0,  2,  2,1,   230400, 0xecd608fb
>> +0,  3,  3,1,   230400, 0xea46f9f4
>> +0,  4,  4,1,   230400, 0xb715d24a
>> +0,  5,  5,1,   230400, 0x69faaf46
>> +0,  6,  6,1,   230400, 0xf9a362db
>> +0,  7,  7,1,   230400, 0x2dcd19ca
>> +0,  8,  8,1,   230400, 0xf8fda185
>> +0,  9,  9,1,   230400, 0x48a35bfd
>> +0, 10, 10,1,   230400, 0x27efe832
>> +0, 11, 11,1,   230400, 0x74279617
>> +0, 12, 12,1,   230400, 0x91935248
>> +0, 13, 13,1,   230400, 0x29b621e6
>> +0, 14, 14,1,   230400, 0x89b1ec0b
>> +0, 15, 15,1,   230400, 0x898fdba1
>> +0, 16, 16,1,   230400, 0xc6d18e6f
>> +0, 17, 17,1,   230400, 0xedff651b
>> +0, 18, 18,1,   230400, 0x677e2260
>> +0, 19, 19,1,   230400, 0x930918ef
>> +0, 20, 20,1,   230400, 0x70da2c30
>> +0, 21, 21,1,   230400, 0x699a3b9d
>> +0, 22, 22,1,   230400, 0xff3b1b3a
>> +0, 23, 23,1,   230400, 0xca11d9a5
>> +0, 24, 24,1,   230400, 0x904394e0
>> +0, 25, 25,1,   230400, 0x392e5445
>> +0, 26, 26,1,   230400, 0x6191f4d8
>> +0, 27, 27,1,   230400, 0xa7d7be12
>> +0, 28, 28,1,   230400, 0xbb29752c
>> +0, 29, 29,1,   230400, 0x14ff297e
>> --
>> 2.42.0
>> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org 
>> https://ffmpeg.org/mailman/listinfo/ffm

[FFmpeg-devel] [PATCH v3] libavutil/ppc: Make use of getauxval() and elf_aux_info() on ppc

2024-09-14 Thread Brad Smith
libavutil/ppc: Make use of getauxval() and elf_aux_info() on ppc

Modern Linux has getauxval() and FreeBSD/OpenBSD ppc have elf_aux_info().

Signed-off-by: Brad Smith 
---
v2: adjust to build with older glibc.
v3: freebsd/ppc requires machine/cpu.h header for feature flags.

 libavutil/ppc/cpu.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c
index 2b13cda662..9381272175 100644
--- a/libavutil/ppc/cpu.c
+++ b/libavutil/ppc/cpu.c
@@ -20,6 +20,11 @@
 
 #ifdef __APPLE__
 #include 
+#elif HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO
+#ifdef __FreeBSD__
+#include 
+#endif
+#include 
 #elif defined(__linux__)
 #include 
 #include 
@@ -56,6 +61,26 @@ int ff_get_cpu_flags_ppc(void)
 if (result == VECTORTYPE_ALTIVEC)
 return AV_CPU_FLAG_ALTIVEC;
 return 0;
+#elif HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO
+int flags = 0;
+
+unsigned long hwcap = ff_getauxval(AT_HWCAP);
+#ifdef PPC_FEATURE2_ARCH_2_07
+unsigned long hwcap2 = ff_getauxval(AT_HWCAP2);
+#endif
+
+if (hwcap & PPC_FEATURE_HAS_ALTIVEC)
+   flags |= AV_CPU_FLAG_ALTIVEC;
+#ifdef PPC_FEATURE_HAS_VSX
+if (hwcap & PPC_FEATURE_HAS_VSX)
+   flags |= AV_CPU_FLAG_VSX;
+#endif
+#ifdef PPC_FEATURE2_ARCH_2_07
+if (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+   flags |= AV_CPU_FLAG_POWER8;
+#endif
+
+return flags;
 #elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
 #if defined(__NetBSD__) || defined(__OpenBSD__)
 int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC};
-- 
2.46.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".