[FFmpeg-cvslog] avcodec/aac/aacdec_usac: remove unnecessary cast

2024-06-02 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun Jun  2 20:14:17 
2024 -0300| [4d59d58ea68ad0b08cb2d4cc4d1b16c3a45a66c9] | committer: James Almer

avcodec/aac/aacdec_usac: remove unnecessary cast

Fixes "libavcodec/aac/aacdec_usac.c(543): error C2440: 'type cast': cannot 
convert from 'GetBitContext' to 'GetBitContext'"
from msvc.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4d59d58ea68ad0b08cb2d4cc4d1b16c3a45a66c9
---

 libavcodec/aac/aacdec_usac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 00ec74718b..c76d72d7a7 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -540,7 +540,7 @@ static int decode_spectrum_and_dequant_ac(AACDecContext *s, 
float coef[1024],
 c = ff_aac_ac_map_process(state, reset, N);
 
 /* Backup reader for rolling back by 14 bits at the end */
-gb2 = (GetBitContext)*gb;
+gb2 = *gb;
 gb_count = get_bits_count();
 
 for (i = 0; i < len/2; i++) {

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

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


[FFmpeg-cvslog] avcodec/aac/aacdec_usac: remove call to realloc

2024-06-02 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun Jun  2 15:32:04 
2024 -0300| [d8ffd65bfd07f8186bfaf14f27269e2441738e49] | committer: James Almer

avcodec/aac/aacdec_usac: remove call to realloc

Must be one of the lavu wrappers instead.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d8ffd65bfd07f8186bfaf14f27269e2441738e49
---

 libavcodec/aac/aacdec_usac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index c3c9137a2e..f63a67381b 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -1396,7 +1396,7 @@ static int parse_audio_preroll(AACDecContext *ac, 
GetBitContext *gb)
 if (au_len*8 > tmp_buf_size) {
 uint8_t *tmp2;
 tmp_buf = tmp_buf == temp_data ? NULL : tmp_buf;
-tmp2 = realloc(tmp_buf, au_len*8);
+tmp2 = av_realloc_array(tmp_buf, au_len, 8);
 if (!tmp2) {
 if (tmp_buf != temp_data)
 av_free(tmp_buf);

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

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


[FFmpeg-cvslog] avutil/float_dsp.h: fix doxy for scalarproduct_double

2024-06-01 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Jun  1 11:15:30 
2024 -0300| [7087da303f9ae638f54134b1ac5f621ecf7e1171] | committer: James Almer

avutil/float_dsp.h: fix doxy for scalarproduct_double

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7087da303f9ae638f54134b1ac5f621ecf7e1171
---

 libavutil/float_dsp.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavutil/float_dsp.h b/libavutil/float_dsp.h
index 8484075fa0..a99edc39bb 100644
--- a/libavutil/float_dsp.h
+++ b/libavutil/float_dsp.h
@@ -194,11 +194,11 @@ typedef struct AVFloatDSPContext {
  * Calculate the scalar product of two vectors of doubles.
  *
  * @param v1  first vector
- * constraints: 32-byte aligned
+ *constraints: 32-byte aligned
  * @param v2  second vector
- * constraints: 32-byte aligned
+ *constraints: 32-byte aligned
  * @param len length of vectors
- * constraints: 32-byte aligned
+ *constraints: multiple of 16
  *
  * @return inner product of the vectors
  */

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

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


[FFmpeg-cvslog] avutil/float_dsp: revert accidental doxy removal

2024-06-01 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Jun  1 11:14:28 
2024 -0300| [7736ca1d7bf2474a745caaa92436a667f6121092] | committer: James Almer

avutil/float_dsp: revert accidental doxy removal

done by accident in 6a7c4d60a1498929c2a366f2ef4ccc35621a4358.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7736ca1d7bf2474a745caaa92436a667f6121092
---

 libavutil/float_dsp.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavutil/float_dsp.h b/libavutil/float_dsp.h
index ca05fd9382..8484075fa0 100644
--- a/libavutil/float_dsp.h
+++ b/libavutil/float_dsp.h
@@ -179,8 +179,11 @@ typedef struct AVFloatDSPContext {
  * a vector of doubles.
  *
  * @param dst  output vector
+ * constraints: 32-byte aligned
  * @param src0 first input vector
+ * constraints: 32-byte aligned
  * @param src1 second input vector
+ * constraints: 32-byte aligned
  * @param len  number of elements in the input
  * constraints: multiple of 16
  */

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

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


[FFmpeg-cvslog] avcodec/videotoolbox: use the correct HEVCSPS field name

2024-06-01 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Jun  1 10:56:19 
2024 -0300| [7e182a8d92f8873778f4cfa60257510d425cbbd2] | committer: James Almer

avcodec/videotoolbox: use the correct HEVCSPS field name

Fixes compilation that was broken in 6fed1841a1f5dd3cdcf343f77925af0781ebe83a.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7e182a8d92f8873778f4cfa60257510d425cbbd2
---

 libavcodec/videotoolbox.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index d6990a39c0..0e3dfb934c 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -349,7 +349,7 @@ CFDataRef 
ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx)
  */
 AV_W8(p + 21, 0 << 6 |
   sps->max_sub_layers   << 3 |
-  sps->temporal_id_nesting_flag << 2 |
+  sps->temporal_id_nesting  << 2 |
   3);
 
 /* unsigned int(8) numOfArrays; */

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

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


[FFmpeg-cvslog] checkasm/lpc: use fixed length to bench apply_welch_window

2024-05-31 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri May 31 17:06:08 
2024 -0300| [0a949aacaedb7c3a503028c4c1a1067162483073] | committer: James Almer

checkasm/lpc: use fixed length to bench apply_welch_window

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0a949aacaedb7c3a503028c4c1a1067162483073
---

 tests/checkasm/lpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c
index cdd1b02698..514a2cdb3c 100644
--- a/tests/checkasm/lpc.c
+++ b/tests/checkasm/lpc.c
@@ -55,7 +55,7 @@ static void test_window(int len)
 }
 }
 
-bench_new(src, len, dst1);
+bench_new(src, 4608 + (len & 1), dst1);
 }
 
 static void test_compute_autocorr(ptrdiff_t len, int lag)

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

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


[FFmpeg-cvslog] avcodec/lpc: account for odd len values

2024-05-31 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri May 31 09:38:27 
2024 -0300| [e0db1f51d6ddf9eb2c1314c23d063a29255b607a] | committer: James Almer

avcodec/lpc: account for odd len values

Reviewed-by: RĂ©mi Denis-Courmont 
Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e0db1f51d6ddf9eb2c1314c23d063a29255b607a
---

 libavcodec/lpc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c
index dfd6114690..e793e54038 100644
--- a/libavcodec/lpc.c
+++ b/libavcodec/lpc.c
@@ -120,9 +120,8 @@ static void lpc_compute_autocorr_c(const double *data, 
ptrdiff_t len, int lag,
 
 if(j==lag){
 double sum = 1.0;
-for(i=j-1; ihttps://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] avcodec/packet: remove reference to old AV_SIDE_DATA_PARAM_CHANGE_ values

2024-05-31 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed May 29 20:49:44 
2024 -0300| [8a1c491354bca7fde10220a66840d458faf96476] | committer: James Almer

avcodec/packet: remove reference to old AV_SIDE_DATA_PARAM_CHANGE_ values

They were forgotten in 65ddc74988245a01421a63c5cffa4d900c47117c.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8a1c491354bca7fde10220a66840d458faf96476
---

 libavcodec/packet.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index a9a41576da..f05deb7950 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -59,10 +59,6 @@ enum AVPacketSideDataType {
  * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
  * @code
  * u32le param_flags
- * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
- * s32le channel_count
- * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
- * u64le channel_layout
  * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
  * s32le sample_rate
  * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)

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

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


[FFmpeg-cvslog] tests/checkasm/vvc_mc: don't zero the SAD buffers

2024-05-31 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed May 29 11:02:39 
2024 -0300| [4008a80c1bed313fb0e6cbe5098304cb152abad0] | committer: Nuo Mi

tests/checkasm/vvc_mc: don't zero the SAD buffers

They will be filled immediately after.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4008a80c1bed313fb0e6cbe5098304cb152abad0
---

 tests/checkasm/vvc_mc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/tests/checkasm/vvc_mc.c b/tests/checkasm/vvc_mc.c
index 40be837d68..bc6b580f42 100644
--- a/tests/checkasm/vvc_mc.c
+++ b/tests/checkasm/vvc_mc.c
@@ -333,9 +333,6 @@ static void check_vvc_sad(void)
 declare_func(int, const int16_t *src0, const int16_t *src1, int dx, int 
dy, int block_w, int block_h);
 
 ff_vvc_dsp_init(, bit_depth);
-memset(src0, 0, MAX_CTU_SIZE * MAX_CTU_SIZE * 4 * sizeof(uint16_t));
-memset(src1, 0, MAX_CTU_SIZE * MAX_CTU_SIZE * 4 * sizeof(uint16_t));
-
 randomize_pixels(src0, src1, MAX_CTU_SIZE * MAX_CTU_SIZE * 4);
 for (int h = 8; h <= 16; h *= 2) {
 for (int w = 8; w <= 16; w *= 2) {

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

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


[FFmpeg-cvslog] tests/checkasm/vvc_mc: fix indentation

2024-05-31 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed May 29 11:02:38 
2024 -0300| [b70289f35446ce79c25255a60bd91db69584c353] | committer: Nuo Mi

tests/checkasm/vvc_mc: fix indentation

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b70289f35446ce79c25255a60bd91db69584c353
---

 tests/checkasm/vvc_mc.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/checkasm/vvc_mc.c b/tests/checkasm/vvc_mc.c
index 09cac82edb..40be837d68 100644
--- a/tests/checkasm/vvc_mc.c
+++ b/tests/checkasm/vvc_mc.c
@@ -341,8 +341,10 @@ static void check_vvc_sad(void)
 for (int w = 8; w <= 16; w *= 2) {
 for(int offy = 0; offy <= 4; offy++) {
 for(int offx = 0; offx <= 4; offx++) {
-if(w * h >= 128) {
-if(check_func(c.inter.sad, "sad_%dx%d", w, h)) {
+if (w * h < 128)
+continue;
+
+if (check_func(c.inter.sad, "sad_%dx%d", w, h)) {
 int result0;
 int result1;
 
@@ -353,7 +355,6 @@ static void check_vvc_sad(void)
 fail();
 if(offx == 0 && offy == 0)
 bench_new(src0 + PIXEL_STRIDE * 2 + 2, src1 + 
PIXEL_STRIDE * 2 + 2, offx, offy, w, h);
-}
 }
 }
 }

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

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


[FFmpeg-cvslog] avformat/mov: store sample_sizes as unsigned ints

2024-05-24 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Sun May 19 
22:38:21 2024 -0300| [17674b150f69e87c15796e014feba069290abf39] | committer: 
James Almer

avformat/mov: store sample_sizes as unsigned ints

As defined in Section 8.7.3.2.1 of ISO 14496-12.
Any unsupported value will be rejected in mov_build_index() without outright
aborting demuxing.

Fixes ticket #11005.

Signed-off-by: James Almer 
(cherry picked from commit 3146b77a7d314f55b8ec5d8ce6fda2c5db049a27)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=17674b150f69e87c15796e014feba069290abf39
---

 libavformat/isom.h | 2 +-
 libavformat/mov.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 07f09d6eff..c0a5788e08 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -193,7 +193,7 @@ typedef struct MOVStreamContext {
 unsigned int sample_size; ///< may contain value calculated from stsd or 
value from stsz atom
 unsigned int stsz_sample_size; ///< always contains sample size from stsz 
atom
 unsigned int sample_count;
-int *sample_sizes;
+unsigned int *sample_sizes;
 int keyframe_absent;
 unsigned int keyframe_count;
 int *keyframes;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 6e3178f7c8..c2538a9681 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3305,9 +3305,9 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 for (i = 0; i < entries; i++) {
 sc->sample_sizes[i] = get_bits_long(, field_size);
-if (sc->sample_sizes[i] < 0) {
+if (sc->sample_sizes[i] > INT64_MAX - sc->data_size) {
 av_free(buf);
-av_log(c->fc, AV_LOG_ERROR, "Invalid sample size %d\n", 
sc->sample_sizes[i]);
+av_log(c->fc, AV_LOG_ERROR, "Sample size overflow in STSZ\n");
 return AVERROR_INVALIDDATA;
 }
 sc->data_size += sc->sample_sizes[i];

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

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


[FFmpeg-cvslog] avcodec/flacdsp: split off lpc33 into a dsp function

2024-05-24 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May 12 17:36:10 
2024 -0300| [0380a03f1f9d55e5690bb92bfa4897f2c728c1e5] | committer: James Almer

avcodec/flacdsp: split off lpc33 into a dsp function

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0380a03f1f9d55e5690bb92bfa4897f2c728c1e5
---

 libavcodec/flacdec.c |  7 +--
 libavcodec/flacdsp.c | 15 +++
 libavcodec/flacdsp.h |  2 ++
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 6e6a2896b4..460d3bc01e 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -509,12 +509,7 @@ static int decode_subframe_lpc_33bps(FLACContext *s, 
int64_t *decoded,
 if ((ret = decode_residuals(s, residual, pred_order)) < 0)
 return ret;
 
-for (i = pred_order; i < s->blocksize; i++, decoded++) {
-int64_t sum = 0;
-for (j = 0; j < pred_order; j++)
-sum += (int64_t)coeffs[j] * (uint64_t)decoded[j];
-decoded[j] = residual[i] + (sum >> qlevel);
-}
+s->dsp.lpc33(decoded, residual, coeffs, pred_order, qlevel, s->blocksize);
 
 return 0;
 }
diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
index 27d3e923ee..f5362bf66f 100644
--- a/libavcodec/flacdsp.c
+++ b/libavcodec/flacdsp.c
@@ -84,6 +84,20 @@ static void flac_lpc_32_c(int32_t *decoded, const int 
coeffs[32],
 
 }
 
+static void flac_lpc_33_c(int64_t *decoded, const int32_t *residual,
+  const int coeffs[32], int pred_order,
+  int qlevel, int len)
+{
+int i, j;
+
+for (i = pred_order; i < len; i++, decoded++) {
+int64_t sum = 0;
+for (j = 0; j < pred_order; j++)
+sum += (int64_t)coeffs[j] * (uint64_t)decoded[j];
+decoded[j] = residual[i] + (sum >> qlevel);
+}
+}
+
 static void flac_wasted_32_c(int32_t *decoded, int wasted, int len)
 {
 for (int i = 0; i < len; i++)
@@ -101,6 +115,7 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum 
AVSampleFormat fmt, int cha
 {
 c->lpc16= flac_lpc_16_c;
 c->lpc32= flac_lpc_32_c;
+c->lpc33= flac_lpc_33_c;
 
 c->wasted32 = flac_wasted_32_c;
 c->wasted33 = flac_wasted_33_c;
diff --git a/libavcodec/flacdsp.h b/libavcodec/flacdsp.h
index 5a59c0c864..3b7b35a112 100644
--- a/libavcodec/flacdsp.h
+++ b/libavcodec/flacdsp.h
@@ -30,6 +30,8 @@ typedef struct FLACDSPContext {
   int qlevel, int len);
 void (*lpc32)(int32_t *samples, const int coeffs[32], int order,
   int qlevel, int len);
+void (*lpc33)(int64_t *samples, const int32_t *residual, const int 
coeffs[32],
+  int pred_order, int qlevel, int len);
 void (*wasted32)(int32_t *decoded, int wasted, int len);
 void (*wasted33)(int64_t *decoded, const int32_t *residual,
  int wasted, int len);

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

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


[FFmpeg-cvslog] checkasm/flacdsp: add a test for lpc33

2024-05-24 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May 12 17:36:11 
2024 -0300| [0920f506a7826ad56e67207663e6a6064a3476cd] | committer: James Almer

checkasm/flacdsp: add a test for lpc33

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0920f506a7826ad56e67207663e6a6064a3476cd
---

 tests/checkasm/flacdsp.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c
index 96b7d05f7e..6f8e8817b5 100644
--- a/tests/checkasm/flacdsp.c
+++ b/tests/checkasm/flacdsp.c
@@ -83,6 +83,35 @@ static void check_lpc(int pred_order, int bps)
 bench_new(dst, coeffs, pred_order, qlevel, BUF_SIZE);
 }
 
+static void check_lpc33(int pred_order)
+{
+int qlevel = rnd() % 16;
+int coeff_prec = (rnd() % 15) + 1;
+LOCAL_ALIGNED_16(int64_t, dst,  [BUF_SIZE]);
+LOCAL_ALIGNED_16(int64_t, dst0, [BUF_SIZE]);
+LOCAL_ALIGNED_16(int64_t, dst1, [BUF_SIZE]);
+LOCAL_ALIGNED_16(int32_t, residuals, [BUF_SIZE]);
+LOCAL_ALIGNED_16(int32_t, coeffs, [32]);
+
+declare_func(void, int64_t *, const int32_t *, const int[32], int, int, 
int);
+
+for (int i = 0; i < 32; i++)
+coeffs[i] = sign_extend(rnd(), coeff_prec);
+
+for (int i = 0; i < BUF_SIZE; i++) {
+residuals[i] = sign_extend(rnd(), pred_order);
+dst[i] = sign_extend64(((int64_t)rnd() << 1) | (rnd() & 1), 33);
+}
+
+memcpy(dst0, dst, BUF_SIZE * sizeof (int64_t));
+memcpy(dst1, dst, BUF_SIZE * sizeof (int64_t));
+call_ref(dst0, residuals, coeffs, pred_order, qlevel, BUF_SIZE);
+call_new(dst1, residuals, coeffs, pred_order, qlevel, BUF_SIZE);
+if (memcmp(dst0, dst1, BUF_SIZE * sizeof (int64_t)) != 0)
+   fail();
+bench_new(dst, residuals, coeffs, pred_order, qlevel, BUF_SIZE);
+}
+
 static void check_wasted32(void)
 {
 int wasted = rnd() % 32;
@@ -165,6 +194,9 @@ void checkasm_check_flacdsp(void)
 for (i = 0; i < FF_ARRAY_ELEMS(pred_orders); i++)
 if (check_func(h.lpc32, "flac_lpc_32_%d", pred_orders[i]))
 check_lpc(pred_orders[i], 32);
+for (i = 0; i < FF_ARRAY_ELEMS(pred_orders); i++)
+if (check_func(h.lpc33, "flac_lpc_33_%d", pred_orders[i]))
+check_lpc33(pred_orders[i]);
 
 report("lpc");
 

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

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


[FFmpeg-cvslog] avformat/movenc: add support for writing SA3D boxes

2024-05-23 Thread James Almer
ffmpeg | branch: master | James Almer  | Mon May 13 21:10:19 
2024 -0300| [62397bcf6a5b4052388ab4898a747cda56abc082] | committer: James Almer

avformat/movenc: add support for writing SA3D boxes

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=62397bcf6a5b4052388ab4898a747cda56abc082
---

 libavformat/movenc.c  | 63 +++
 libavformat/version.h |  2 +-
 2 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index f907f67752..86c1b1da2c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -916,6 +916,64 @@ static int mov_write_dmlp_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tra
 return update_size(pb, pos);
 }
 
+static int mov_write_SA3D_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack 
*track)
+{
+const AVDictionaryEntry *str = av_dict_get(track->st->metadata, "SA3D", 
NULL, 0);
+AVChannelLayout ch_layout = { 0 };
+int64_t pos;
+int ambisonic_order, ambi_channels, non_diegetic_channels;
+int i, ret;
+
+if (!str)
+return 0;
+
+ret = av_channel_layout_from_string(_layout, str->value);
+if (ret < 0) {
+if (ret == AVERROR(EINVAL)) {
+invalid:
+av_log(s, AV_LOG_ERROR, "Invalid SA3D layout: \"%s\"\n", 
str->value);
+ret = 0;
+}
+av_channel_layout_uninit(_layout);
+return ret;
+}
+
+if (track->st->codecpar->ch_layout.nb_channels != ch_layout.nb_channels)
+goto invalid;
+
+ambisonic_order = av_channel_layout_ambisonic_order(_layout);
+if (ambisonic_order < 0)
+goto invalid;
+
+ambi_channels = (ambisonic_order + 1LL) * (ambisonic_order + 1LL);
+non_diegetic_channels = ch_layout.nb_channels - ambi_channels;
+if (non_diegetic_channels &&
+(non_diegetic_channels != 2 ||
+ av_channel_layout_subset(_layout, AV_CH_LAYOUT_STEREO) != 
AV_CH_LAYOUT_STEREO))
+goto invalid;
+
+av_log(s, AV_LOG_VERBOSE, "Inserting SA3D box with layout: \"%s\"\n", 
str->value);
+
+pos = avio_tell(pb);
+
+avio_wb32(pb, 0); // Size
+ffio_wfourcc(pb, "SA3D");
+avio_w8(pb, 0); // version
+avio_w8(pb, (!!non_diegetic_channels) << 7); // head_locked_stereo and 
ambisonic_type
+avio_wb32(pb, ambisonic_order); // ambisonic_order
+avio_w8(pb, 0); // ambisonic_channel_ordering
+avio_w8(pb, 0); // ambisonic_normalization
+avio_wb32(pb, ch_layout.nb_channels); // num_channels
+for (i = 0; i < ambi_channels; i++)
+avio_wb32(pb, av_channel_layout_channel_from_index(_layout, i) - 
AV_CHAN_AMBISONIC_BASE);
+for (; i < ch_layout.nb_channels; i++)
+avio_wb32(pb, av_channel_layout_channel_from_index(_layout, i) + 
ambi_channels);
+
+av_channel_layout_uninit(_layout);
+
+return update_size(pb, pos);
+}
+
 static int mov_write_chan_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack 
*track)
 {
 uint32_t layout_tag, bitmap, *channel_desc;
@@ -1419,6 +1477,11 @@ static int mov_write_audio_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 if (ret < 0)
 return ret;
 
+if (track->mode == MODE_MP4 && track->par->codec_type == AVMEDIA_TYPE_AUDIO
+&& ((ret = mov_write_SA3D_tag(s, pb, track)) < 0)) {
+return ret;
+}
+
 if (track->mode == MODE_MOV && track->par->codec_type == AVMEDIA_TYPE_AUDIO
 && ((ret = mov_write_chan_tag(s, pb, track)) < 0)) {
 return ret;
diff --git a/libavformat/version.h b/libavformat/version.h
index 5310326bda..4687cd857c 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 #include "version_major.h"
 
 #define LIBAVFORMAT_VERSION_MINOR   3
-#define LIBAVFORMAT_VERSION_MICRO 103
+#define LIBAVFORMAT_VERSION_MICRO 104
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \

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

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


[FFmpeg-cvslog] avutil/channel_layout: add a helper function to get the ambisonic order of a layout

2024-05-23 Thread James Almer
ffmpeg | branch: master | James Almer  | Mon May 13 21:10:06 
2024 -0300| [8c974494822cdb59cbc271c5dfec4771a579d668] | committer: James Almer

avutil/channel_layout: add a helper function to get the ambisonic order of a 
layout

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8c974494822cdb59cbc271c5dfec4771a579d668
---

 doc/APIchanges |  3 +++
 libavutil/channel_layout.c | 17 -
 libavutil/channel_layout.h | 10 ++
 libavutil/version.h|  2 +-
 4 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 269fd36559..60f056b863 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-05-23 - xx - lavu 59.20.100 - channel_layout.h
+  Add av_channel_layout_ambisonic_order().
+
 2024-05-xx - xx - lavu 59.19.100 - hwcontext_qsv.h
   Add AVQSVFramesContext.info
 
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index fd6718e0e7..98839b7250 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -473,15 +473,14 @@ static int has_channel_names(const AVChannelLayout 
*channel_layout)
 return 0;
 }
 
-/**
- * If the layout is n-th order standard-order ambisonic, with optional
- * extra non-diegetic channels at the end, return the order.
- * Return a negative error code otherwise.
- */
-static int ambisonic_order(const AVChannelLayout *channel_layout)
+int av_channel_layout_ambisonic_order(const AVChannelLayout *channel_layout)
 {
 int i, highest_ambi, order;
 
+if (channel_layout->order != AV_CHANNEL_ORDER_AMBISONIC &&
+channel_layout->order != AV_CHANNEL_ORDER_CUSTOM)
+return AVERROR(EINVAL);
+
 highest_ambi = -1;
 if (channel_layout->order == AV_CHANNEL_ORDER_AMBISONIC)
 highest_ambi = channel_layout->nb_channels - 
av_popcount64(channel_layout->u.mask) - 1;
@@ -536,7 +535,7 @@ static enum AVChannelOrder canonical_order(AVChannelLayout 
*channel_layout)
 if (masked_description(channel_layout, 0) > 0)
 return AV_CHANNEL_ORDER_NATIVE;
 
-order = ambisonic_order(channel_layout);
+order = av_channel_layout_ambisonic_order(channel_layout);
 if (order >= 0 && masked_description(channel_layout, (order + 1) * (order 
+ 1)) >= 0)
 return AV_CHANNEL_ORDER_AMBISONIC;
 
@@ -551,7 +550,7 @@ static enum AVChannelOrder canonical_order(AVChannelLayout 
*channel_layout)
 static int try_describe_ambisonic(AVBPrint *bp, const AVChannelLayout 
*channel_layout)
 {
 int nb_ambi_channels;
-int order = ambisonic_order(channel_layout);
+int order = av_channel_layout_ambisonic_order(channel_layout);
 if (order < 0)
 return order;
 
@@ -945,7 +944,7 @@ int av_channel_layout_retype(AVChannelLayout 
*channel_layout, enum AVChannelOrde
 if (channel_layout->order == AV_CHANNEL_ORDER_CUSTOM) {
 int64_t mask;
 int nb_channels = channel_layout->nb_channels;
-int order = ambisonic_order(channel_layout);
+int order = av_channel_layout_ambisonic_order(channel_layout);
 if (order < 0)
 return AVERROR(ENOSYS);
 mask = masked_description(channel_layout, (order + 1) * (order + 
1));
diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
index 8a078d1601..b26b601065 100644
--- a/libavutil/channel_layout.h
+++ b/libavutil/channel_layout.h
@@ -679,6 +679,16 @@ int av_channel_layout_check(const AVChannelLayout 
*channel_layout);
  */
 int av_channel_layout_compare(const AVChannelLayout *chl, const 
AVChannelLayout *chl1);
 
+/**
+ * Return the order if the layout is n-th order standard-order ambisonic.
+ * The presence of optional extra non-diegetic channels at the end is not taken
+ * into account.
+ *
+ * @param channel_layout input channel layout
+ * @return the order of the layout, a negative error code otherwise.
+ */
+int av_channel_layout_ambisonic_order(const AVChannelLayout *channel_layout);
+
 /**
  * The conversion must be lossless.
  */
diff --git a/libavutil/version.h b/libavutil/version.h
index 3221c4c592..9c7146c228 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  59
-#define LIBAVUTIL_VERSION_MINOR  19
+#define LIBAVUTIL_VERSION_MINOR  20
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

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

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


[FFmpeg-cvslog] avformat/vvc: fix parsing sps_subpic_id

2024-05-22 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Sun May 19 
10:21:14 2024 -0300| [85d4df387347d63aee95e14a60cd9efa14e3c9d5] | committer: 
James Almer

avformat/vvc: fix parsing sps_subpic_id

The length of the sps_subpic_id[i] syntax element is sps_subpic_id_len_minus1 + 
1 bits.

Signed-off-by: James Almer 
(cherry picked from commit 2d84ee374528a8a8eed345a8147e146a0112e43a)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=85d4df387347d63aee95e14a60cd9efa14e3c9d5
---

 libavformat/vvc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 20be4bd8b8..d5b3237aeb 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -392,6 +392,7 @@ static int vvcc_parse_sps(GetBitContext *gb,
 const int tmp_height_val  = 
AV_CEIL_RSHIFT(sps_pic_height_max_in_luma_samples, ctb_log2_size_y);
 const int wlen= av_ceil_log2(tmp_width_val);
 const int hlen= av_ceil_log2(tmp_height_val);
+unsigned int sps_subpic_id_len;
 if (sps_num_subpics_minus1 > 0) {   // sps_num_subpics_minus1
 sps_independent_subpics_flag = get_bits1(gb);
 sps_subpic_same_size_flag = get_bits1(gb);
@@ -411,11 +412,11 @@ static int vvcc_parse_sps(GetBitContext *gb,
 skip_bits(gb, 2);   // sps_subpic_treated_as_pic_flag && 
sps_loop_filter_across_subpic_enabled_flag
 }
 }
-get_ue_golomb_long(gb); // sps_subpic_id_len_minus1
+sps_subpic_id_len = get_ue_golomb_long(gb) + 1;
 if (get_bits1(gb)) {// 
sps_subpic_id_mapping_explicitly_signalled_flag
 if (get_bits1(gb))  // sps_subpic_id_mapping_present_flag
 for (int i = 0; i <= sps_num_subpics_minus1; i++) {
-skip_bits1(gb); // sps_subpic_id[i]
+skip_bits_long(gb, sps_subpic_id_len); // sps_subpic_id[i]
 }
 }
 }

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

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


[FFmpeg-cvslog] avformat/vvc: initialize some ptl flags

2024-05-22 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Sat May 18 
16:50:55 2024 -0300| [1a6995c6d687666eefbedaaf040eeec5c754664f] | committer: 
James Almer

avformat/vvc: initialize some ptl flags

Signed-off-by: James Almer 
(cherry picked from commit 3bd7e3a336822c75865930f7fafb36d1a1c4c3c3)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1a6995c6d687666eefbedaaf040eeec5c754664f
---

 libavformat/vvc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index b1b519c92c..20be4bd8b8 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -586,6 +586,8 @@ static void vvcc_init(VVCDecoderConfigurationRecord *vvcc)
 {
 memset(vvcc, 0, sizeof(VVCDecoderConfigurationRecord));
 vvcc->lengthSizeMinusOne = 3;   // 4 bytes
+vvcc->ptl.ptl_frame_only_constraint_flag =
+vvcc->ptl.ptl_multilayer_enabled_flag = 1;
 }
 
 static void vvcc_close(VVCDecoderConfigurationRecord *vvcc)

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

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


[FFmpeg-cvslog] avformat/mov: store sample_sizes as unsigned ints

2024-05-22 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May 19 22:38:21 
2024 -0300| [3146b77a7d314f55b8ec5d8ce6fda2c5db049a27] | committer: James Almer

avformat/mov: store sample_sizes as unsigned ints

As defined in Section 8.7.3.2.1 of ISO 14496-12.
Any unsupported value will be rejected in mov_build_index() without outright
aborting demuxing.

Fixes ticket #11005.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3146b77a7d314f55b8ec5d8ce6fda2c5db049a27
---

 libavformat/isom.h | 2 +-
 libavformat/mov.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 07f09d6eff..c0a5788e08 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -193,7 +193,7 @@ typedef struct MOVStreamContext {
 unsigned int sample_size; ///< may contain value calculated from stsd or 
value from stsz atom
 unsigned int stsz_sample_size; ///< always contains sample size from stsz 
atom
 unsigned int sample_count;
-int *sample_sizes;
+unsigned int *sample_sizes;
 int keyframe_absent;
 unsigned int keyframe_count;
 int *keyframes;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 6174a04c31..45eca74d1d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3308,9 +3308,9 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 for (i = 0; i < entries; i++) {
 sc->sample_sizes[i] = get_bits_long(, field_size);
-if (sc->sample_sizes[i] < 0) {
+if (sc->sample_sizes[i] > INT64_MAX - sc->data_size) {
 av_free(buf);
-av_log(c->fc, AV_LOG_ERROR, "Invalid sample size %d\n", 
sc->sample_sizes[i]);
+av_log(c->fc, AV_LOG_ERROR, "Sample size overflow in STSZ\n");
 return AVERROR_INVALIDDATA;
 }
 sc->data_size += sc->sample_sizes[i];

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

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


[FFmpeg-cvslog] avformat/vvc: fix parsing sps_subpic_id

2024-05-22 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May 19 10:21:14 
2024 -0300| [2d84ee374528a8a8eed345a8147e146a0112e43a] | committer: James Almer

avformat/vvc: fix parsing sps_subpic_id

The length of the sps_subpic_id[i] syntax element is sps_subpic_id_len_minus1 + 
1 bits.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2d84ee374528a8a8eed345a8147e146a0112e43a
---

 libavformat/vvc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 34c0aaf58b..ac3209a01b 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -371,6 +371,7 @@ static int vvcc_parse_sps(GetBitContext *gb,
 const int tmp_height_val  = 
AV_CEIL_RSHIFT(sps_pic_height_max_in_luma_samples, ctb_log2_size_y);
 const int wlen= av_ceil_log2(tmp_width_val);
 const int hlen= av_ceil_log2(tmp_height_val);
+unsigned int sps_subpic_id_len;
 if (sps_num_subpics_minus1 > 0) {   // sps_num_subpics_minus1
 sps_independent_subpics_flag = get_bits1(gb);
 sps_subpic_same_size_flag = get_bits1(gb);
@@ -390,11 +391,11 @@ static int vvcc_parse_sps(GetBitContext *gb,
 skip_bits(gb, 2);   // sps_subpic_treated_as_pic_flag && 
sps_loop_filter_across_subpic_enabled_flag
 }
 }
-get_ue_golomb_long(gb); // sps_subpic_id_len_minus1
+sps_subpic_id_len = get_ue_golomb_long(gb) + 1;
 if (get_bits1(gb)) {// 
sps_subpic_id_mapping_explicitly_signalled_flag
 if (get_bits1(gb))  // sps_subpic_id_mapping_present_flag
 for (int i = 0; i <= sps_num_subpics_minus1; i++) {
-skip_bits1(gb); // sps_subpic_id[i]
+skip_bits_long(gb, sps_subpic_id_len); // sps_subpic_id[i]
 }
 }
 }

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

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


[FFmpeg-cvslog] avformat/vvc: initialize some ptl flags

2024-05-22 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat May 18 16:50:55 
2024 -0300| [3bd7e3a336822c75865930f7fafb36d1a1c4c3c3] | committer: James Almer

avformat/vvc: initialize some ptl flags

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3bd7e3a336822c75865930f7fafb36d1a1c4c3c3
---

 libavformat/vvc.c   | 2 ++
 tests/ref/lavf-fate/vvc.mp4 | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 449c933881..34c0aaf58b 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -565,6 +565,8 @@ static void vvcc_init(VVCDecoderConfigurationRecord *vvcc)
 {
 memset(vvcc, 0, sizeof(VVCDecoderConfigurationRecord));
 vvcc->lengthSizeMinusOne = 3;   // 4 bytes
+vvcc->ptl.ptl_frame_only_constraint_flag =
+vvcc->ptl.ptl_multilayer_enabled_flag = 1;
 }
 
 static void vvcc_close(VVCDecoderConfigurationRecord *vvcc)
diff --git a/tests/ref/lavf-fate/vvc.mp4 b/tests/ref/lavf-fate/vvc.mp4
index 240715884b..b237fe18cb 100644
--- a/tests/ref/lavf-fate/vvc.mp4
+++ b/tests/ref/lavf-fate/vvc.mp4
@@ -1,3 +1,3 @@
-30b856d289220b477b5a0935f60aa793 *tests/data/lavf-fate/lavf.vvc.mp4
+b5d5939890d3246475f990e5ebd58dc8 *tests/data/lavf-fate/lavf.vvc.mp4
 16625 tests/data/lavf-fate/lavf.vvc.mp4
 tests/data/lavf-fate/lavf.vvc.mp4 CRC=0x895790b1

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

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


[FFmpeg-cvslog] x86/vvc_alf: use the x86inc instruction macros

2024-05-22 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue May 21 10:52:56 
2024 -0300| [3d1597d3e2ff9a6625af23be63131142a910d403] | committer: Nuo Mi

x86/vvc_alf: use the x86inc instruction macros

Let its magic figure out the correct mnemonic based on target instruction set.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3d1597d3e2ff9a6625af23be63131142a910d403
---

 libavcodec/x86/vvc/vvc_alf.asm | 202 -
 1 file changed, 101 insertions(+), 101 deletions(-)

diff --git a/libavcodec/x86/vvc/vvc_alf.asm b/libavcodec/x86/vvc/vvc_alf.asm
index b3d118962f..71e821c27b 100644
--- a/libavcodec/x86/vvc/vvc_alf.asm
+++ b/libavcodec/x86/vvc/vvc_alf.asm
@@ -73,15 +73,15 @@ SECTION .text
 ;m%2 = 07 06 05 04
 ;m%3 = 11 10 09 08
 
-vshufpd m%5, m%1, m%2, 0011b;06 02 05 01
-vshufpd m%6, m%3, m%5, 1001b;06 10 01 09
+shufpd  m%5, m%1, m%2, 0011b;06 02 05 01
+shufpd  m%6, m%3, m%5, 1001b;06 10 01 09
 
-vshufpd m%1, m%1, m%6, 1100b;06 03 09 00
-vshufpd m%2, m%2, m%6, 0110b;10 07 01 04
-vshufpd m%3, m%3, m%5, 0110b;02 11 05 08
+shufpd  m%1, m%1, m%6, 1100b;06 03 09 00
+shufpd  m%2, m%2, m%6, 0110b;10 07 01 04
+shufpd  m%3, m%3, m%5, 0110b;02 11 05 08
 
 vpermpd m%1, m%1, 0000b ;09 06 03 00
-vshufpd m%2, m%2, m%2, 1001b;10 07 04 01
+shufpd  m%2, m%2, m%2, 1001b;10 07 04 01
 vpermpd m%3, m%3, 1111b ;11 08 05 02
 %endmacro
 
@@ -125,21 +125,21 @@ SECTION .text
 pxor m11, m11
 psubwm11, m12;-clip
 
-vpsubwm9, m2
+psubw m9, m2
 CLIPW m9, m11, m12
 
-vpsubw   m10, m2
+psubwm10, m2
 CLIPWm10, m11, m12
 
-vpunpckhwd   m13, m9, m10
-vpunpcklwdm9, m9, m10
+punpckhwdm13, m9, m10
+punpcklwd m9, m9, m10
 
 pshufb   m12, filters, [param_shuffe_ %+ i]   ;filter
-vpunpcklwd   m10, m12, m12
-vpunpckhwd   m12, m12, m12
+punpcklwdm10, m12, m12
+punpckhwdm12, m12, m12
 
-vpmaddwd  m9, m10
-vpmaddwd m12, m13
+pmaddwd   m9, m10
+pmaddwd  m12, m13
 
 paddd m0, m9
 paddd m1, m12
@@ -268,17 +268,17 @@ SECTION .text
 je %%near_vb
 %endif
 %%no_vb:
-vpsradm0, SHIFT
-vpsradm1, SHIFT
+psrad m0, SHIFT
+psrad m1, SHIFT
 jmp  %%shift_end
 %%near_vb:
 vpbroadcastd  m9, [dd448]
 paddd m0, m9
 paddd m1, m9
-vpsradm0, SHIFT + 3
-vpsradm1, SHIFT + 3
+psrad m0, SHIFT + 3
+psrad m1, SHIFT + 3
 %%shift_end:
-vpackssdw m0, m0, m1
+packssdw  m0, m0, m1
 %endmacro
 
 ; FILTER_VB(line)
@@ -320,7 +320,7 @@ SECTION .text
 %if ps == 2
 movu  %1, %2
 %else
-vpmovzxbw %1, %2
+pmovzxbw  %1, %2
 %endif
 %endmacro
 
@@ -329,7 +329,7 @@ SECTION .text
 %if ps == 2
 movu %1, m%2
 %else
-vpackuswb   m%2, m%2
+packuswbm%2, m%2
 vpermq  m%2, m%2, 0x8
 movu %1, xm%2
 %endif
@@ -489,43 +489,43 @@ cglobal vvc_alf_classify_grad_%1bpc, 6, 14, 16, 
gradient_sum, src, src_stride, w
 LOAD_PIXELS   m6, [s2q + 2 * ps]
 LOAD_PIXELS   m7, [s3q + 2 * ps]
 
-vpblendw  m8, m0, m1, 0xaa ; nw
-vpblendw  m9, m0, m5, 0x55 ; n
-vpblendw m10, m4, m5, 0xaa ; ne
-vpblendw m11, m1, m2, 0xaa ; w
-vpblendw m12, m5, m6, 0xaa ; e
-vpblendw m13, m2, m3, 0xaa ; sw
-vpblendw m14, m2, m7, 0x55 ; s
+pblendw   m8, m0, m1, 0xaa ; nw
+pblendw   m9, m0, m5, 0x55 ; n
+pblendw  m10, m4, m5, 0xaa ; ne
+pblendw  m11, m1, m2, 0xaa ; w
+pblendw  m12, m5, m6, 0xaa ; e
+pblendw  m13, m2, m3, 0xaa ; sw
+pblendw  m14, m2, m7, 0x55 ; s
 
-vpblendw  m0, m1, m6, 0x55
-vpaddwm0, m0   ; c
+pblendw   m0, m1, m6, 0x55
+paddw m0, m0   ; c
 
 movu  m1, [CLASSIFY_SHUFFE]
 pshufb   

[FFmpeg-cvslog] avcodec/cbs_h266: read vps_ptl_max_tid before using it

2024-05-20 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Sun May 19 
10:26:38 2024 -0300| [060d2ce8aed1a0ad37264c90bfce6738dc49511d] | committer: 
James Almer

avcodec/cbs_h266: read vps_ptl_max_tid before using it

Reviewed-by: Nuo Mi 
Signed-off-by: James Almer 
(cherry picked from commit b113050d96d9d36ac2e7f10b3af8b9c61684c33f)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=060d2ce8aed1a0ad37264c90bfce6738dc49511d
---

 libavcodec/cbs_h266_syntax_template.c | 28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/libavcodec/cbs_h266_syntax_template.c 
b/libavcodec/cbs_h266_syntax_template.c
index f56066d470..281069f06e 100644
--- a/libavcodec/cbs_h266_syntax_template.c
+++ b/libavcodec/cbs_h266_syntax_template.c
@@ -790,6 +790,21 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, 
RWContext *rw,
 infer(vps_each_layer_is_an_ols_flag, 1);
 infer(vps_num_ptls_minus1, 0);
 }
+
+for (i = 0; i <= current->vps_num_ptls_minus1; i++) {
+if (i > 0)
+flags(vps_pt_present_flag[i], 1, i);
+else
+infer(vps_pt_present_flag[i], 1);
+
+if (!current->vps_default_ptl_dpb_hrd_max_tid_flag)
+us(3, vps_ptl_max_tid[i], 0, current->vps_max_sublayers_minus1, 1, 
i);
+else
+infer(vps_ptl_max_tid[i], current->vps_max_sublayers_minus1);
+}
+while (byte_alignment(rw) != 0)
+fixed(1, vps_ptl_alignment_zero_bit, 0);
+
 {
 //calc NumMultiLayerOlss
 int m;
@@ -915,19 +930,6 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, 
RWContext *rw,
 return AVERROR_INVALIDDATA;
 }
 
-for (i = 0; i <= current->vps_num_ptls_minus1; i++) {
-if (i > 0)
-flags(vps_pt_present_flag[i], 1, i);
-else
-infer(vps_pt_present_flag[i], 1);
-
-if (!current->vps_default_ptl_dpb_hrd_max_tid_flag)
-us(3, vps_ptl_max_tid[i], 0, current->vps_max_sublayers_minus1, 1, 
i);
-else
-infer(vps_ptl_max_tid[i], current->vps_max_sublayers_minus1);
-}
-while (byte_alignment(rw) != 0)
-fixed(1, vps_ptl_alignment_zero_bit, 0);
 for (i = 0; i <= current->vps_num_ptls_minus1; i++) {
 CHECK(FUNC(profile_tier_level) (ctx, rw,
 current->vps_profile_tier_level + i,

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

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


[FFmpeg-cvslog] avformat/vvc: fix writing general_constraint_info bytes

2024-05-20 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Thu May 16 
11:55:00 2024 -0300| [5f23eecfba603402e3e3f7f31b1d284df9d4e962] | committer: 
James Almer

avformat/vvc: fix writing general_constraint_info bytes

The existing implementation was completely broken.

Signed-off-by: James Almer 
(cherry picked from commit 415dfa89e29686786085c207fdebcf2c97883a33)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5f23eecfba603402e3e3f7f31b1d284df9d4e962
---

 libavformat/Makefile|  2 +-
 libavformat/bitstream.c |  1 +
 libavformat/vvc.c   | 35 +++
 tests/ref/fate/source   |  1 +
 4 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index a89df7e9a3..ae86954e7c 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -723,7 +723,7 @@ OBJS-$(CONFIG_LIBSSH_PROTOCOL)   += libssh.o
 OBJS-$(CONFIG_LIBZMQ_PROTOCOL)   += libzmq.o
 
 # Objects duplicated from other libraries for shared builds
-SHLIBOBJS+= log2_tab.o to_upper4.o
+SHLIBOBJS+= log2_tab.o to_upper4.o bitstream.o
 SHLIBOBJS-$(CONFIG_ISO_MEDIA)+= mpegaudiotabs.o
 SHLIBOBJS-$(CONFIG_FLV_MUXER)+= mpeg4audio_sample_rates.o
 SHLIBOBJS-$(CONFIG_HLS_DEMUXER)  += ac3_channel_layout_tab.o
diff --git a/libavformat/bitstream.c b/libavformat/bitstream.c
new file mode 100644
index 00..2afda37c30
--- /dev/null
+++ b/libavformat/bitstream.c
@@ -0,0 +1 @@
+#include "libavcodec/bitstream.c"
diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 14a4c0a2f3..12a8ef6b0e 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -21,8 +21,10 @@
  */
 
 #include "libavcodec/get_bits.h"
+#include "libavcodec/put_bits.h"
 #include "libavcodec/golomb.h"
 #include "libavcodec/vvc.h"
+#include "libavutil/avassert.h"
 #include "libavutil/intreadwrite.h"
 #include "avc.h"
 #include "avio.h"
@@ -184,7 +186,7 @@ static void vvcc_parse_ptl(GetBitContext *gb,
unsigned int profileTierPresentFlag,
unsigned int max_sub_layers_minus1)
 {
-VVCCProfileTierLevel general_ptl;
+VVCCProfileTierLevel general_ptl = { 0 };
 int j;
 
 if (profileTierPresentFlag) {
@@ -325,6 +327,7 @@ static int vvcc_parse_vps(GetBitContext *gb,
 
 for (int i = 0; i <= vps_num_ptls_minus1; i++)
 vvcc_parse_ptl(gb, vvcc, vps_pt_present_flag[i], vps_ptl_max_tid[i]);
+vvcc->ptl_present_flag = 1;
 
 /* nothing useful for vvcc past this point */
 return 0;
@@ -355,8 +358,10 @@ static int vvcc_parse_sps(GetBitContext *gb,
 vvcc->chroma_format_idc = get_bits(gb, 2);
 sps_log2_ctu_size_minus5 = get_bits(gb, 2);
 
-if (get_bits1(gb))  // sps_ptl_dpb_hrd_params_present_flag
+if (get_bits1(gb)) {// sps_ptl_dpb_hrd_params_present_flag
+vvcc->ptl_present_flag = 1;
 vvcc_parse_ptl(gb, vvcc, 1, sps_max_sublayers_minus1);
+}
 
 skip_bits1(gb); // sps_gdr_enabled_flag
 if (get_bits(gb, 1))// sps_ref_pic_resampling_enabled_flag
@@ -578,10 +583,6 @@ static void vvcc_init(VVCDecoderConfigurationRecord *vvcc)
 {
 memset(vvcc, 0, sizeof(VVCDecoderConfigurationRecord));
 vvcc->lengthSizeMinusOne = 3;   // 4 bytes
-
-vvcc->ptl.num_bytes_constraint_info = 1;
-
-vvcc->ptl_present_flag = 1;
 }
 
 static void vvcc_close(VVCDecoderConfigurationRecord *vvcc)
@@ -602,7 +603,6 @@ static int vvcc_write(AVIOContext *pb, 
VVCDecoderConfigurationRecord *vvcc)
 {
 uint8_t i;
 uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0;
-unsigned char *buf = NULL;
 /*
  * It's unclear how to properly compute these fields, so
  * let's always set them to values meaning 'unspecified'.
@@ -734,6 +734,10 @@ static int vvcc_write(AVIOContext *pb, 
VVCDecoderConfigurationRecord *vvcc)
 avio_w8(pb, vvcc->lengthSizeMinusOne << 1 | vvcc->ptl_present_flag | 0xf8);
 
 if (vvcc->ptl_present_flag) {
+uint8_t buf[64];
+PutBitContext pbc;
+
+init_put_bits(, buf, sizeof(buf));
 /*
  * unsigned int(9) ols_idx;
  * unsigned int(3) num_sublayers;
@@ -765,15 +769,14 @@ static int vvcc_write(AVIOContext *pb, 
VVCDecoderConfigurationRecord *vvcc)
  * unsigned int (1) ptl_frame_only_constraint_flag
  * unsigned int (1) ptl_multilayer_enabled_flag
  * unsigned int (8*num_bytes_constraint_info -2) 
general_constraint_info */
-buf =
-(unsigned char *) malloc(sizeof(unsigned char) *
- vvcc->ptl.num_bytes_constraint_info);
-*buf = vvcc->ptl.ptl_frame_only_constraint_flag << vvcc->ptl.
-num_bytes_constraint_info * 8 - 1 | vvcc->ptl.
-ptl_mul

[FFmpeg-cvslog] avformat/vvc: fix parsing some early VPS bitstream values

2024-05-20 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Fri May 17 
16:23:41 2024 -0300| [a8b8b1042f9959416c8b08d3099a8e9bb6407deb] | committer: 
James Almer

avformat/vvc: fix parsing some early VPS bitstream values

vps_default_ptl_dpb_hrd_max_tid_flag needs to always be set, and
vps_direct_ref_layer_flag needs to be read even when
vps_max_tid_ref_present_flag is false.

Signed-off-by: James Almer 
(cherry picked from commit a48203d51aa4836150f9379448f6b2a1d5ca9d36)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a8b8b1042f9959416c8b08d3099a8e9bb6407deb
---

 libavformat/vvc.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 12a8ef6b0e..b1b519c92c 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -268,6 +268,8 @@ static int vvcc_parse_vps(GetBitContext *gb,
 
 if (vps_max_layers_minus1 > 0 && vps_max_sublayers_minus1 > 0)
 vps_default_ptl_dpb_hrd_max_tid_flag = get_bits1(gb);
+else
+vps_default_ptl_dpb_hrd_max_tid_flag = 0;
 if (vps_max_layers_minus1 > 0)
 vps_all_independent_layers_flag = get_bits1(gb);
 else
@@ -276,10 +278,11 @@ static int vvcc_parse_vps(GetBitContext *gb,
 for (int i = 0; i <= vps_max_layers_minus1; i++) {
 skip_bits(gb, 6);//vps_layer_id[i]
 if (i > 0 && !vps_all_independent_layers_flag) {
-if (get_bits1(gb)) {// vps_independent_layer_flag[i]
+if (!get_bits1(gb)) {   // vps_independent_layer_flag[i]
 unsigned int vps_max_tid_ref_present_flag = get_bits1(gb);
 for (int j = 0; j < i; j++) {
-if (vps_max_tid_ref_present_flag && get_bits1(gb))  // 
vps_direct_ref_layer_flag[i][j]
+unsigned int vps_direct_ref_layer_flag = get_bits1(gb);
+if (vps_max_tid_ref_present_flag && 
vps_direct_ref_layer_flag)
 skip_bits(gb, 3);   // 
vps_max_tid_il_ref_pics_plus1
 }
 }

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

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


[FFmpeg-cvslog] avcodec/cbs_h266: read vps_ptl_max_tid before using it

2024-05-20 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May 19 10:26:38 
2024 -0300| [b113050d96d9d36ac2e7f10b3af8b9c61684c33f] | committer: James Almer

avcodec/cbs_h266: read vps_ptl_max_tid before using it

Reviewed-by: Nuo Mi 
Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b113050d96d9d36ac2e7f10b3af8b9c61684c33f
---

 libavcodec/cbs_h266_syntax_template.c | 28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/libavcodec/cbs_h266_syntax_template.c 
b/libavcodec/cbs_h266_syntax_template.c
index 725cee5b03..38685704c5 100644
--- a/libavcodec/cbs_h266_syntax_template.c
+++ b/libavcodec/cbs_h266_syntax_template.c
@@ -790,6 +790,21 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, 
RWContext *rw,
 infer(vps_each_layer_is_an_ols_flag, 1);
 infer(vps_num_ptls_minus1, 0);
 }
+
+for (i = 0; i <= current->vps_num_ptls_minus1; i++) {
+if (i > 0)
+flags(vps_pt_present_flag[i], 1, i);
+else
+infer(vps_pt_present_flag[i], 1);
+
+if (!current->vps_default_ptl_dpb_hrd_max_tid_flag)
+us(3, vps_ptl_max_tid[i], 0, current->vps_max_sublayers_minus1, 1, 
i);
+else
+infer(vps_ptl_max_tid[i], current->vps_max_sublayers_minus1);
+}
+while (byte_alignment(rw) != 0)
+fixed(1, vps_ptl_alignment_zero_bit, 0);
+
 {
 //calc NumMultiLayerOlss
 int m;
@@ -915,19 +930,6 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, 
RWContext *rw,
 return AVERROR_INVALIDDATA;
 }
 
-for (i = 0; i <= current->vps_num_ptls_minus1; i++) {
-if (i > 0)
-flags(vps_pt_present_flag[i], 1, i);
-else
-infer(vps_pt_present_flag[i], 1);
-
-if (!current->vps_default_ptl_dpb_hrd_max_tid_flag)
-us(3, vps_ptl_max_tid[i], 0, current->vps_max_sublayers_minus1, 1, 
i);
-else
-infer(vps_ptl_max_tid[i], current->vps_max_sublayers_minus1);
-}
-while (byte_alignment(rw) != 0)
-fixed(1, vps_ptl_alignment_zero_bit, 0);
 for (i = 0; i <= current->vps_num_ptls_minus1; i++) {
 CHECK(FUNC(profile_tier_level) (ctx, rw,
 current->vps_profile_tier_level + i,

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

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


[FFmpeg-cvslog] fate/lavf-container: add a test for VVC in mp4 muxing

2024-05-18 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat May 18 13:26:29 
2024 -0300| [7e59f02c1417ab12694781f969a8247f5dfd7ea3] | committer: James Almer

fate/lavf-container: add a test for VVC in mp4 muxing

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7e59f02c1417ab12694781f969a8247f5dfd7ea3
---

 tests/fate/lavf-container.mak | 2 ++
 tests/ref/lavf-fate/vvc.mp4   | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/tests/fate/lavf-container.mak b/tests/fate/lavf-container.mak
index d89174d221..d84117c50f 100644
--- a/tests/fate/lavf-container.mak
+++ b/tests/fate/lavf-container.mak
@@ -74,6 +74,7 @@ FATE_LAVF_CONTAINER_FATE-$(call ALLYES, IVF_DEMUXER 
AV1_DECODER AV1_PARSER MOV_M
 FATE_LAVF_CONTAINER_FATE-$(call ALLYES, IVF_DEMUXER AV1_DECODER AV1_PARSER 
MATROSKA_MUXER) += av1.mkv
 FATE_LAVF_CONTAINER_FATE-$(call ALLYES, EVC_DEMUXER EVC_PARSER MOV_MUXER)  
+= evc.mp4
 FATE_LAVF_CONTAINER_FATE-$(call ALLYES, H264_DEMUXER H264_PARSER MOV_MUXER)
+= h264.mp4
+FATE_LAVF_CONTAINER_FATE-$(call ALLYES, VVC_DEMUXER VVC_PARSER MOV_MUXER)  
+= vvc.mp4
 FATE_LAVF_CONTAINER_FATE-$(call ALLYES, MATROSKA_DEMUXER   OGG_MUXER)  
+= vp3.ogg
 FATE_LAVF_CONTAINER_FATE-$(call ALLYES, MATROSKA_DEMUXER   OGV_MUXER)  
+= vp8.ogg
 FATE_LAVF_CONTAINER_FATE-$(call ALLYES, MOV_DEMUXERLATM_MUXER) 
+= latm
@@ -91,6 +92,7 @@ fate-lavf-fate-av1.mp4: CMD = lavf_container_fate 
"av1-test-vectors/av1-1-b8-05-
 fate-lavf-fate-av1.mkv: CMD = lavf_container_fate 
"av1-test-vectors/av1-1-b8-05-mv.ivf" "-c:v av1" "-c:v copy"
 fate-lavf-fate-evc.mp4: CMD = lavf_container_fate "evc/akiyo_cif.evc" "" "-c:v 
copy"
 fate-lavf-fate-h264.mp4: CMD = lavf_container_fate "h264/intra_refresh.h264" 
"" "-c:v copy"
+fate-lavf-fate-vvc.mp4: CMD = lavf_container_fate 
"vvc-conformance/VPS_A_3.bit" "" "-c:v copy"
 fate-lavf-fate-vp3.ogg: CMD = lavf_container_fate "vp3/coeff_level64.mkv" 
"-idct auto"
 fate-lavf-fate-vp8.ogg: CMD = lavf_container_fate "vp8/RRSF49-short.webm" "" 
"-acodec copy"
 fate-lavf-fate-latm: CMD = lavf_container_fate "aac/al04_44.mp4" "" "-acodec 
copy"
diff --git a/tests/ref/lavf-fate/vvc.mp4 b/tests/ref/lavf-fate/vvc.mp4
new file mode 100644
index 00..240715884b
--- /dev/null
+++ b/tests/ref/lavf-fate/vvc.mp4
@@ -0,0 +1,3 @@
+30b856d289220b477b5a0935f60aa793 *tests/data/lavf-fate/lavf.vvc.mp4
+16625 tests/data/lavf-fate/lavf.vvc.mp4
+tests/data/lavf-fate/lavf.vvc.mp4 CRC=0x895790b1

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

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


[FFmpeg-cvslog] configure: split ISOBMFF writer helpers into a separate component

2024-05-18 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri May 17 09:48:03 
2024 -0300| [3765305928bfd1a7c111d24314b07ab7f29cafbf] | committer: James Almer

configure: split ISOBMFF writer helpers into a separate component

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3765305928bfd1a7c111d24314b07ab7f29cafbf
---

 configure| 10 ++
 libavformat/Makefile | 16 
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/configure b/configure
index 275fa59bfd..b16722d83d 100755
--- a/configure
+++ b/configure
@@ -2587,6 +2587,7 @@ CONFIG_EXTRA="
 inflate_wrapper
 intrax8
 iso_media
+iso_writer
 ividsp
 jpegtables
 lgplv3
@@ -3611,7 +3612,7 @@ evc_demuxer_select="evc_frame_merge_bsf evc_parser"
 f4v_muxer_select="mov_muxer"
 fifo_muxer_deps="threads"
 flac_demuxer_select="flac_parser"
-flv_muxer_select="aac_adtstoasc_bsf"
+flv_muxer_select="aac_adtstoasc_bsf iso_writer"
 gxf_muxer_select="pcm_rechunk_bsf"
 hds_muxer_select="flv_muxer"
 hls_demuxer_select="aac_demuxer ac3_demuxer adts_header ac3_parser 
eac3_demuxer mov_demuxer mpegts_demuxer"
@@ -3629,12 +3630,12 @@ latm_muxer_select="aac_adtstoasc_bsf mpeg4audio"
 matroska_audio_muxer_select="matroska_muxer"
 matroska_demuxer_select="riffdec"
 matroska_demuxer_suggest="bzlib zlib"
-matroska_muxer_select="mpeg4audio riffenc aac_adtstoasc_bsf 
pgs_frame_merge_bsf vp9_superframe_bsf"
+matroska_muxer_select="iso_writer mpeg4audio riffenc aac_adtstoasc_bsf 
pgs_frame_merge_bsf vp9_superframe_bsf"
 mlp_demuxer_select="mlp_parser"
 mmf_muxer_select="riffenc"
 mov_demuxer_select="iso_media riffdec"
 mov_demuxer_suggest="iamfdec zlib"
-mov_muxer_select="iso_media riffenc rtpenc_chain vp9_superframe_bsf 
aac_adtstoasc_bsf ac3_parser"
+mov_muxer_select="iso_media iso_writer riffenc rtpenc_chain vp9_superframe_bsf 
aac_adtstoasc_bsf ac3_parser"
 mov_muxer_suggest="iamfenc"
 mp3_demuxer_select="mpegaudio_parser"
 mp3_muxer_select="mpegaudioheader"
@@ -3642,7 +3643,7 @@ mp4_muxer_select="mov_muxer"
 mpegts_demuxer_select="iso_media"
 mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf vvc_mp4toannexb_bsf"
 mpegtsraw_demuxer_select="mpegts_demuxer"
-mxf_muxer_select="pcm_rechunk_bsf rangecoder"
+mxf_muxer_select="iso_writer pcm_rechunk_bsf rangecoder"
 mxf_d10_muxer_select="mxf_muxer"
 mxf_opatom_muxer_select="mxf_muxer"
 nut_muxer_select="riffenc"
@@ -3655,6 +3656,7 @@ ogv_muxer_select="ogg_muxer"
 opus_muxer_select="ogg_muxer"
 psp_muxer_select="mov_muxer"
 rtp_demuxer_select="sdp_demuxer"
+rtp_muxer_select="iso_writer"
 rtp_mpegts_muxer_select="mpegts_muxer rtp_muxer"
 rtpdec_select="asf_demuxer mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol 
srtp"
 rtsp_demuxer_select="http_protocol rtpdec"
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 211ccf45e5..1c4d9deccd 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -35,6 +35,7 @@ OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o
 
 # subsystems
 OBJS-$(CONFIG_ISO_MEDIA) += isom.o
+OBJS-$(CONFIG_ISO_WRITER)+= av1.o avc.o hevc.o vvc.o vpcc.o
 OBJS-$(CONFIG_IAMFDEC)   += iamf_reader.o iamf_parse.o iamf.o
 OBJS-$(CONFIG_IAMFENC)   += iamf_writer.o iamf.o
 OBJS-$(CONFIG_NETWORK)   += network.o
@@ -220,7 +221,7 @@ OBJS-$(CONFIG_FLAC_MUXER)+= flacenc.o 
flacenc_header.o \
 OBJS-$(CONFIG_FLIC_DEMUXER)  += flic.o
 OBJS-$(CONFIG_FLV_DEMUXER)   += flvdec.o
 OBJS-$(CONFIG_LIVE_FLV_DEMUXER)  += flvdec.o
-OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o hevc.o av1.o vpcc.o
+OBJS-$(CONFIG_FLV_MUXER) += flvenc.o
 OBJS-$(CONFIG_FOURXM_DEMUXER)+= 4xm.o
 OBJS-$(CONFIG_FRAMECRC_MUXER)+= framecrcenc.o framehash.o
 OBJS-$(CONFIG_FRAMEHASH_MUXER)   += hashenc.o framehash.o
@@ -260,7 +261,7 @@ OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
 OBJS-$(CONFIG_EVC_DEMUXER)   += evcdec.o rawdec.o
 OBJS-$(CONFIG_EVC_MUXER) += rawenc.o
 OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_encryption.o
-OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
+OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o
 OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
 OBJS-$(CONFIG_IAMF_DEMUXER)  += iamfdec.o
 OBJS-$(CONFIG_IAMF_MUXER)+= iamfenc.o
@@ -349,7 +350,6 @@ OBJS-$(CONFIG_MATROSKA

[FFmpeg-cvslog] avformat/vvc: use align_get_bits() where useful

2024-05-18 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat May 18 11:49:43 
2024 -0300| [9ab8dddf1f2e1ffb7ee24b550173247f7c63c692] | committer: James Almer

avformat/vvc: use align_get_bits() where useful

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9ab8dddf1f2e1ffb7ee24b550173247f7c63c692
---

 libavformat/vvc.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 19143f85dd..449c933881 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -191,15 +191,13 @@ static void vvcc_parse_ptl(GetBitContext *gb,
 general_ptl.num_bytes_constraint_info = j;
 skip_bits(gb, gci_num_reserved_bits);
 }
-while (gb->index % 8 != 0)
-skip_bits1(gb);
+align_get_bits(gb);
 }
 
 for (int i = max_sub_layers_minus1 - 1; i >= 0; i--)
 general_ptl.ptl_sublayer_level_present_flag[i] = get_bits1(gb);
 
-while (gb->index % 8 != 0)
-skip_bits1(gb);
+align_get_bits(gb);
 
 for (int i = max_sub_layers_minus1 - 1; i >= 0; i--) {
 if (general_ptl.ptl_sublayer_level_present_flag[i])
@@ -307,8 +305,7 @@ static int vvcc_parse_vps(GetBitContext *gb,
 vps_ptl_max_tid[i] = vps_max_sublayers_minus1;
 }
 
-while (gb->index % 8 != 0)
-skip_bits1(gb);
+align_get_bits(gb);
 
 for (int i = 0; i <= vps_num_ptls_minus1; i++)
 vvcc_parse_ptl(gb, vvcc, vps_pt_present_flag[i], vps_ptl_max_tid[i]);

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

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


[FFmpeg-cvslog] avformat/vvc: fix parsing some early VPS bitstream values

2024-05-18 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri May 17 16:23:41 
2024 -0300| [a48203d51aa4836150f9379448f6b2a1d5ca9d36] | committer: James Almer

avformat/vvc: fix parsing some early VPS bitstream values

vps_default_ptl_dpb_hrd_max_tid_flag needs to always be set, and
vps_direct_ref_layer_flag needs to be read even when
vps_max_tid_ref_present_flag is false.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a48203d51aa4836150f9379448f6b2a1d5ca9d36
---

 libavformat/vvc.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 09a4aa52e8..b147f44683 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -252,6 +252,8 @@ static int vvcc_parse_vps(GetBitContext *gb,
 
 if (vps_max_layers_minus1 > 0 && vps_max_sublayers_minus1 > 0)
 vps_default_ptl_dpb_hrd_max_tid_flag = get_bits1(gb);
+else
+vps_default_ptl_dpb_hrd_max_tid_flag = 0;
 if (vps_max_layers_minus1 > 0)
 vps_all_independent_layers_flag = get_bits1(gb);
 else
@@ -260,10 +262,11 @@ static int vvcc_parse_vps(GetBitContext *gb,
 for (int i = 0; i <= vps_max_layers_minus1; i++) {
 skip_bits(gb, 6);//vps_layer_id[i]
 if (i > 0 && !vps_all_independent_layers_flag) {
-if (get_bits1(gb)) {// vps_independent_layer_flag[i]
+if (!get_bits1(gb)) {   // vps_independent_layer_flag[i]
 unsigned int vps_max_tid_ref_present_flag = get_bits1(gb);
 for (int j = 0; j < i; j++) {
-if (vps_max_tid_ref_present_flag && get_bits1(gb))  // 
vps_direct_ref_layer_flag[i][j]
+unsigned int vps_direct_ref_layer_flag = get_bits1(gb);
+if (vps_max_tid_ref_present_flag && 
vps_direct_ref_layer_flag)
 skip_bits(gb, 3);   // 
vps_max_tid_il_ref_pics_plus1
 }
 }

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

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


[FFmpeg-cvslog] avformat/vvc: reduce the scope of some variables

2024-05-18 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat May 18 11:41:27 
2024 -0300| [f00b23453ca522854b69bfcb81cc47765798b760] | committer: James Almer

avformat/vvc: reduce the scope of some variables

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f00b23453ca522854b69bfcb81cc47765798b760
---

 libavformat/vvc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index b147f44683..19143f85dd 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -224,8 +224,6 @@ static int vvcc_parse_vps(GetBitContext *gb,
 unsigned int vps_max_sublayers_minus1;
 unsigned int vps_default_ptl_dpb_hrd_max_tid_flag;
 unsigned int vps_all_independent_layers_flag;
-unsigned int vps_each_layer_is_an_ols_flag;
-unsigned int vps_ols_mode_idc;
 
 unsigned int vps_pt_present_flag[VVC_MAX_PTLS];
 unsigned int vps_ptl_max_tid[VVC_MAX_PTLS];
@@ -274,11 +272,13 @@ static int vvcc_parse_vps(GetBitContext *gb,
 }
 
 if (vps_max_layers_minus1 > 0) {
+unsigned int vps_each_layer_is_an_ols_flag;
 if (vps_all_independent_layers_flag)
 vps_each_layer_is_an_ols_flag = get_bits1(gb);
 else
 vps_each_layer_is_an_ols_flag = 0;
 if (!vps_each_layer_is_an_ols_flag) {
+unsigned int vps_ols_mode_idc;
 if (!vps_all_independent_layers_flag)
 vps_ols_mode_idc = get_bits(gb, 2);
 else
@@ -293,8 +293,6 @@ static int vvcc_parse_vps(GetBitContext *gb,
 }
 }
 vps_num_ptls_minus1 = get_bits(gb, 8);
-} else {
-vps_each_layer_is_an_ols_flag = 0;
 }
 
 for (int i = 0; i <= vps_num_ptls_minus1; i++) {

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

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


[FFmpeg-cvslog] avformat/vvc: remove duplicate struct

2024-05-18 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri May 17 19:15:09 
2024 -0300| [f121d52b3535278fe1bd406c4dc4797b11b96ddf] | committer: James Almer

avformat/vvc: remove duplicate struct

VVCCProfileTierLevel is the same as VVCPTLRecord since the previous commit.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f121d52b3535278fe1bd406c4dc4797b11b96ddf
---

 libavformat/vvc.c | 43 +--
 1 file changed, 13 insertions(+), 30 deletions(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index af25f137ee..09a4aa52e8 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -70,32 +70,15 @@ typedef struct VVCDecoderConfigurationRecord {
 VVCCNALUnitArray *array;
 } VVCDecoderConfigurationRecord;
 
-typedef struct VVCCProfileTierLevel {
-uint8_t profile_idc;
-uint8_t tier_flag;
-uint8_t general_level_idc;
-uint8_t ptl_frame_only_constraint_flag;
-uint8_t ptl_multilayer_enabled_flag;
-// general_constraint_info
-uint8_t gci_present_flag;
-uint8_t gci_general_constraints[9];
-uint8_t num_bytes_constraint_info;
-// end general_constraint_info
-uint8_t ptl_sublayer_level_present_flag[VVC_MAX_SUBLAYERS - 1];
-uint8_t sublayer_level_idc[VVC_MAX_SUBLAYERS - 1];
-uint8_t ptl_num_sub_profiles;
-uint32_t general_sub_profile_idc[VVC_MAX_SUB_PROFILES];
-} VVCCProfileTierLevel;
-
 static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc,
-VVCCProfileTierLevel *ptl)
+VVCPTLRecord *ptl)
 {
 /*
  * The level indication general_level_idc must indicate a level of
  * capability equal to or greater than the highest level indicated for the
  * highest tier in all the parameter sets.
  */
-if (vvcc->ptl.general_tier_flag < ptl->tier_flag)
+if (vvcc->ptl.general_tier_flag < ptl->general_tier_flag)
 vvcc->ptl.general_level_idc = ptl->general_level_idc;
 else
 vvcc->ptl.general_level_idc =
@@ -106,7 +89,7 @@ static void vvcc_update_ptl(VVCDecoderConfigurationRecord 
*vvcc,
  * greater than the highest tier indicated in all the parameter sets.
  */
 vvcc->ptl.general_tier_flag =
-FFMAX(vvcc->ptl.general_tier_flag, ptl->tier_flag);
+FFMAX(vvcc->ptl.general_tier_flag, ptl->general_tier_flag);
 
 /*
  * The profile indication general_profile_idc must indicate a profile to
@@ -123,7 +106,7 @@ static void vvcc_update_ptl(VVCDecoderConfigurationRecord 
*vvcc,
  * Note: set the profile to the highest value for the sake of simplicity.
  */
 vvcc->ptl.general_profile_idc =
-FFMAX(vvcc->ptl.general_profile_idc, ptl->profile_idc);
+FFMAX(vvcc->ptl.general_profile_idc, ptl->general_profile_idc);
 
 /*
  * Each bit in flags may only be set if all
@@ -136,10 +119,10 @@ static void vvcc_update_ptl(VVCDecoderConfigurationRecord 
*vvcc,
 /*
  * Constraints Info
  */
-if (ptl->gci_present_flag) {
+if (ptl->num_bytes_constraint_info) {
 vvcc->ptl.num_bytes_constraint_info = ptl->num_bytes_constraint_info;
 memcpy(>ptl.general_constraint_info[0],
-   >gci_general_constraints[0], 
ptl->num_bytes_constraint_info);
+   >general_constraint_info[0], 
ptl->num_bytes_constraint_info);
 } else {
 vvcc->ptl.num_bytes_constraint_info = 1;
 memset(>ptl.general_constraint_info[0], 0, 
sizeof(vvcc->ptl.general_constraint_info));
@@ -186,23 +169,23 @@ static void vvcc_parse_ptl(GetBitContext *gb,
unsigned int profileTierPresentFlag,
unsigned int max_sub_layers_minus1)
 {
-VVCCProfileTierLevel general_ptl = { 0 };
+VVCPTLRecord general_ptl = { 0 };
 
 if (profileTierPresentFlag) {
-general_ptl.profile_idc = get_bits(gb, 7);
-general_ptl.tier_flag = get_bits1(gb);
+general_ptl.general_profile_idc = get_bits(gb, 7);
+general_ptl.general_tier_flag = get_bits1(gb);
 }
 general_ptl.general_level_idc = get_bits(gb, 8);
 
 general_ptl.ptl_frame_only_constraint_flag = get_bits1(gb);
 general_ptl.ptl_multilayer_enabled_flag = get_bits1(gb);
 if (profileTierPresentFlag) {   // parse constraint info
-general_ptl.gci_present_flag = get_bits1(gb);
-if (general_ptl.gci_present_flag) {
+general_ptl.num_bytes_constraint_info = get_bits1(gb); // 
gci_present_flag
+if (general_ptl.num_bytes_constraint_info) {
 int gci_num_reserved_bits, j;
 for (j = 0; j < 8; j++)
-general_ptl.gci_general_constraints[j] = get_bits(gb, 8);
-general_ptl.gci_general_constraints[j++] = get_bits(gb, 7);
+general_ptl.general_constraint_info[j] = get_bits(gb, 8);
+general_ptl.ge

[FFmpeg-cvslog] avformat/vvc: fix writing general_constraint_info bytes

2024-05-18 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu May 16 11:55:00 
2024 -0300| [415dfa89e29686786085c207fdebcf2c97883a33] | committer: James Almer

avformat/vvc: fix writing general_constraint_info bytes

The existing implementation was completely broken.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=415dfa89e29686786085c207fdebcf2c97883a33
---

 libavformat/Makefile|  2 +-
 libavformat/bitstream.c |  1 +
 libavformat/vvc.c   | 35 +++
 tests/ref/fate/source   |  1 +
 4 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 2d4e0e0c95..211ccf45e5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -727,7 +727,7 @@ OBJS-$(CONFIG_LIBSSH_PROTOCOL)   += libssh.o
 OBJS-$(CONFIG_LIBZMQ_PROTOCOL)   += libzmq.o
 
 # Objects duplicated from other libraries for shared builds
-SHLIBOBJS+= log2_tab.o to_upper4.o
+SHLIBOBJS+= log2_tab.o to_upper4.o bitstream.o
 SHLIBOBJS-$(CONFIG_ISO_MEDIA)+= mpegaudiotabs.o
 SHLIBOBJS-$(CONFIG_FLV_MUXER)+= mpeg4audio_sample_rates.o
 SHLIBOBJS-$(CONFIG_HLS_DEMUXER)  += ac3_channel_layout_tab.o
diff --git a/libavformat/bitstream.c b/libavformat/bitstream.c
new file mode 100644
index 00..2afda37c30
--- /dev/null
+++ b/libavformat/bitstream.c
@@ -0,0 +1 @@
+#include "libavcodec/bitstream.c"
diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 3123cd8d83..92773579a8 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -21,8 +21,10 @@
  */
 
 #include "libavcodec/get_bits.h"
+#include "libavcodec/put_bits.h"
 #include "libavcodec/golomb.h"
 #include "libavcodec/vvc.h"
+#include "libavutil/avassert.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
 #include "avc.h"
@@ -185,7 +187,7 @@ static void vvcc_parse_ptl(GetBitContext *gb,
unsigned int profileTierPresentFlag,
unsigned int max_sub_layers_minus1)
 {
-VVCCProfileTierLevel general_ptl;
+VVCCProfileTierLevel general_ptl = { 0 };
 int j;
 
 if (profileTierPresentFlag) {
@@ -326,6 +328,7 @@ static int vvcc_parse_vps(GetBitContext *gb,
 
 for (int i = 0; i <= vps_num_ptls_minus1; i++)
 vvcc_parse_ptl(gb, vvcc, vps_pt_present_flag[i], vps_ptl_max_tid[i]);
+vvcc->ptl_present_flag = 1;
 
 /* nothing useful for vvcc past this point */
 return 0;
@@ -356,8 +359,10 @@ static int vvcc_parse_sps(GetBitContext *gb,
 vvcc->chroma_format_idc = get_bits(gb, 2);
 sps_log2_ctu_size_minus5 = get_bits(gb, 2);
 
-if (get_bits1(gb))  // sps_ptl_dpb_hrd_params_present_flag
+if (get_bits1(gb)) {// sps_ptl_dpb_hrd_params_present_flag
+vvcc->ptl_present_flag = 1;
 vvcc_parse_ptl(gb, vvcc, 1, sps_max_sublayers_minus1);
+}
 
 skip_bits1(gb); // sps_gdr_enabled_flag
 if (get_bits(gb, 1))// sps_ref_pic_resampling_enabled_flag
@@ -579,10 +584,6 @@ static void vvcc_init(VVCDecoderConfigurationRecord *vvcc)
 {
 memset(vvcc, 0, sizeof(VVCDecoderConfigurationRecord));
 vvcc->lengthSizeMinusOne = 3;   // 4 bytes
-
-vvcc->ptl.num_bytes_constraint_info = 1;
-
-vvcc->ptl_present_flag = 1;
 }
 
 static void vvcc_close(VVCDecoderConfigurationRecord *vvcc)
@@ -603,7 +604,6 @@ static int vvcc_write(AVIOContext *pb, 
VVCDecoderConfigurationRecord *vvcc)
 {
 uint8_t i;
 uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0;
-unsigned char *buf = NULL;
 /*
  * It's unclear how to properly compute these fields, so
  * let's always set them to values meaning 'unspecified'.
@@ -735,6 +735,10 @@ static int vvcc_write(AVIOContext *pb, 
VVCDecoderConfigurationRecord *vvcc)
 avio_w8(pb, vvcc->lengthSizeMinusOne << 1 | vvcc->ptl_present_flag | 0xf8);
 
 if (vvcc->ptl_present_flag) {
+uint8_t buf[64];
+PutBitContext pbc;
+
+init_put_bits(, buf, sizeof(buf));
 /*
  * unsigned int(9) ols_idx;
  * unsigned int(3) num_sublayers;
@@ -766,15 +770,14 @@ static int vvcc_write(AVIOContext *pb, 
VVCDecoderConfigurationRecord *vvcc)
  * unsigned int (1) ptl_frame_only_constraint_flag
  * unsigned int (1) ptl_multilayer_enabled_flag
  * unsigned int (8*num_bytes_constraint_info -2) 
general_constraint_info */
-buf =
-(unsigned char *) malloc(sizeof(unsigned char) *
- vvcc->ptl.num_bytes_constraint_info);
-*buf = vvcc->ptl.ptl_frame_only_constraint_flag << vvcc->ptl.
-num_bytes_constraint_info * 8 - 1 | vvcc->ptl.
-ptl_multilayer_enabled_flag << vvcc->ptl.num_bytes_constrain

[FFmpeg-cvslog] avformat/vvc: generalize calculating num_bytes_constraint_info

2024-05-18 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu May 16 20:51:38 
2024 -0300| [cba15ca0ec418fa169563ec63065a69ee191c1d5] | committer: James Almer

avformat/vvc: generalize calculating num_bytes_constraint_info

Will be useful for when the aditional bits are supported, as well as for the
next commit.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cba15ca0ec418fa169563ec63065a69ee191c1d5
---

 libavformat/vvc.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 92773579a8..af25f137ee 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -79,7 +79,7 @@ typedef struct VVCCProfileTierLevel {
 // general_constraint_info
 uint8_t gci_present_flag;
 uint8_t gci_general_constraints[9];
-uint8_t gci_num_reserved_bits;
+uint8_t num_bytes_constraint_info;
 // end general_constraint_info
 uint8_t ptl_sublayer_level_present_flag[VVC_MAX_SUBLAYERS - 1];
 uint8_t sublayer_level_idc[VVC_MAX_SUBLAYERS - 1];
@@ -137,13 +137,12 @@ static void vvcc_update_ptl(VVCDecoderConfigurationRecord 
*vvcc,
  * Constraints Info
  */
 if (ptl->gci_present_flag) {
-vvcc->ptl.num_bytes_constraint_info = 9;
+vvcc->ptl.num_bytes_constraint_info = ptl->num_bytes_constraint_info;
 memcpy(>ptl.general_constraint_info[0],
-   >gci_general_constraints[0], sizeof(uint8_t) * 9);
-
+   >gci_general_constraints[0], 
ptl->num_bytes_constraint_info);
 } else {
 vvcc->ptl.num_bytes_constraint_info = 1;
-memset(>ptl.general_constraint_info[0], 0, sizeof(uint8_t) * 9);
+memset(>ptl.general_constraint_info[0], 0, 
sizeof(vvcc->ptl.general_constraint_info));
 }
 
 /*
@@ -188,7 +187,6 @@ static void vvcc_parse_ptl(GetBitContext *gb,
unsigned int max_sub_layers_minus1)
 {
 VVCCProfileTierLevel general_ptl = { 0 };
-int j;
 
 if (profileTierPresentFlag) {
 general_ptl.profile_idc = get_bits(gb, 7);
@@ -201,12 +199,14 @@ static void vvcc_parse_ptl(GetBitContext *gb,
 if (profileTierPresentFlag) {   // parse constraint info
 general_ptl.gci_present_flag = get_bits1(gb);
 if (general_ptl.gci_present_flag) {
+int gci_num_reserved_bits, j;
 for (j = 0; j < 8; j++)
 general_ptl.gci_general_constraints[j] = get_bits(gb, 8);
-general_ptl.gci_general_constraints[8] = get_bits(gb, 7);
+general_ptl.gci_general_constraints[j++] = get_bits(gb, 7);
 
-general_ptl.gci_num_reserved_bits = get_bits(gb, 8);
-skip_bits(gb, general_ptl.gci_num_reserved_bits);
+gci_num_reserved_bits = get_bits(gb, 8);
+general_ptl.num_bytes_constraint_info = j;
+skip_bits(gb, gci_num_reserved_bits);
 }
 while (gb->index % 8 != 0)
 skip_bits1(gb);

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

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


[FFmpeg-cvslog] checkasm/h264dsp: use int64_t scale values

2024-05-17 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue May 14 23:28:50 
2024 -0300| [727a603158b466a3f11f419012856e845a0721b9] | committer: James Almer

checkasm/h264dsp: use int64_t scale values

Fixes "signed integer overflow: [varies] * 104858 cannot be represented in type 
'int'" errors
under ubsan.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=727a603158b466a3f11f419012856e845a0721b9
---

 tests/checkasm/h264dsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/checkasm/h264dsp.c b/tests/checkasm/h264dsp.c
index cb180cc44f..0cc1f32740 100644
--- a/tests/checkasm/h264dsp.c
+++ b/tests/checkasm/h264dsp.c
@@ -83,7 +83,7 @@ static void dct4x4_##size(dctcoef *coef)  
   \
 }\
 for (y = 0; y < 4; y++) {\
 for (x = 0; x < 4; x++) {\
-static const int scale[] = { 13107 * 10, 8066 * 13, 5243 * 16 }; \
+const int64_t scale[] = { 13107 * 10, 8066 * 13, 5243 * 16 };\
 const int idx = (y & 1) + (x & 1);   \
 coef[y*4 + x] = (coef[y*4 + x] * scale[idx] + (1 << 14)) >> 15;  \
 }\

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

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


[FFmpeg-cvslog] checkasm/h264dsp: add missing pixel_mask values

2024-05-14 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue May 14 23:17:30 
2024 -0300| [8670615743eb36d7b3e9b522266518796df7ec54] | committer: James Almer

checkasm/h264dsp: add missing pixel_mask values

Fixes "runtime error: index 4 out of bounds for type 'uint32_t [3]'" errors
after commit 4ced36744ee0bea5fb7a20d1b2926c588f89ea0b.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8670615743eb36d7b3e9b522266518796df7ec54
---

 tests/checkasm/h264dsp.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/checkasm/h264dsp.c b/tests/checkasm/h264dsp.c
index 30ac81e71e..cb180cc44f 100644
--- a/tests/checkasm/h264dsp.c
+++ b/tests/checkasm/h264dsp.c
@@ -27,17 +27,17 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem_internal.h"
 
-static const uint32_t pixel_mask[3] = { 0x, 0x01ff01ff, 0x03ff03ff };
+static const uint32_t pixel_mask[5] = { 0x, 0x01ff01ff, 0x03ff03ff, 
0x0fff0fff, 0x3fff3fff };
 static const uint32_t pixel_mask_lf[3] = { 0xff0fff0f, 0x01ff000f, 0x03ff000f 
};
 
 #define SIZEOF_PIXEL ((bit_depth + 7) / 8)
 #define SIZEOF_COEF  (2 * ((bit_depth + 7) / 8))
 #define PIXEL_STRIDE 16
 
-#define randomize_buffers()  \
+#define randomize_buffers(idx)   \
 do { \
 int x, y;\
-uint32_t mask = pixel_mask[bit_depth - 8];   \
+uint32_t mask = pixel_mask[(idx)];   \
 for (y = 0; y < sz; y++) {   \
 for (x = 0; x < PIXEL_STRIDE; x += 4) {  \
 AV_WN32A(src + y * PIXEL_STRIDE + x, rnd() & mask);  \
@@ -189,7 +189,7 @@ static void check_idct(void)
 bit_depth = depths[i];
 ff_h264dsp_init(, bit_depth, 1);
 for (sz = 4; sz <= 8; sz += 4) {
-randomize_buffers();
+randomize_buffers(i);
 
 if (sz == 4)
 dct4x4(coef, bit_depth);
@@ -277,7 +277,7 @@ static void check_idct_multiple(void)
 int offset = (block_y * 16 + block_x) * SIZEOF_PIXEL;
 int nnz = rnd() % 3;
 
-randomize_buffers();
+randomize_buffers(bit_depth - 8);
 if (sz == 4)
 dct4x4(coef, bit_depth);
 else

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

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


[FFmpeg-cvslog] fate/checkasm: test vvc_alf

2024-05-14 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue May 14 22:58:21 
2024 -0300| [e9741f1a6bc2c3be05e818b1d5d2cb6f6e1d857a] | committer: James Almer

fate/checkasm: test vvc_alf

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e9741f1a6bc2c3be05e818b1d5d2cb6f6e1d857a
---

 tests/fate/checkasm.mak | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index 9b5e2b0d98..d021e124d1 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -59,6 +59,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp   
  \
 fate-checkasm-vorbisdsp \
 fate-checkasm-vp8dsp\
 fate-checkasm-vp9dsp\
+fate-checkasm-vvc_alf   \
 fate-checkasm-vvc_mc\
 
 $(FATE_CHECKASM): tests/checkasm/checkasm$(EXESUF)

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

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


[FFmpeg-cvslog] x86/vvc/vvcdsp_init: coalesce function initializers

2024-05-14 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue May 14 11:17:54 
2024 -0300| [14aff7e45ec6a78a0e22b7debd9a407c6cfad69b] | committer: James Almer

x86/vvc/vvcdsp_init: coalesce function initializers

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=14aff7e45ec6a78a0e22b7debd9a407c6cfad69b
---

 libavcodec/x86/vvc/vvcdsp_init.c | 37 +++--
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/libavcodec/x86/vvc/vvcdsp_init.c b/libavcodec/x86/vvc/vvcdsp_init.c
index ce4660d933..0e68971b2c 100644
--- a/libavcodec/x86/vvc/vvcdsp_init.c
+++ b/libavcodec/x86/vvc/vvcdsp_init.c
@@ -318,48 +318,41 @@ void ff_vvc_dsp_init_x86(VVCDSPContext *const c, const 
int bd)
 #if ARCH_X86_64
 const int cpu_flags = av_get_cpu_flags();
 
-if (bd == 8) {
+switch (bd) {
+case 8:
 if (EXTERNAL_SSE4(cpu_flags)) {
 MC_LINK_SSE4(8);
 }
 if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ALF_INIT(8);
+AVG_INIT(8, avx2);
 MC_LINKS_AVX2(8);
 }
-} else if (bd == 10) {
+break;
+case 10:
 if (EXTERNAL_SSE4(cpu_flags)) {
 MC_LINK_SSE4(10);
 }
 if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ALF_INIT(10);
+AVG_INIT(10, avx2);
 MC_LINKS_AVX2(10);
 MC_LINKS_16BPC_AVX2(10);
 }
-} else if (bd == 12) {
+break;
+case 12:
 if (EXTERNAL_SSE4(cpu_flags)) {
 MC_LINK_SSE4(12);
 }
 if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ALF_INIT(12);
+AVG_INIT(12, avx2);
 MC_LINKS_AVX2(12);
 MC_LINKS_16BPC_AVX2(12);
 }
-}
-
-if (EXTERNAL_AVX2(cpu_flags)) {
-switch (bd) {
-case 8:
-ALF_INIT(8);
-AVG_INIT(8, avx2);
-break;
-case 10:
-ALF_INIT(10);
-AVG_INIT(10, avx2);
-break;
-case 12:
-ALF_INIT(12);
-AVG_INIT(12, avx2);
-break;
-default:
-break;
-}
+break;
+default:
+break;
 }
 #endif
 }

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

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


[FFmpeg-cvslog] x86/flacdsp: add an SSE4 version of wasted33

2024-05-13 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May 12 12:36:01 
2024 -0300| [eb5733f38f56ca79e3bbcf2e3c12483d219f0523] | committer: James Almer

x86/flacdsp: add an SSE4 version of wasted33

flac_wasted_33_c: 214.1
flac_wasted_33_sse4: 103.2

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eb5733f38f56ca79e3bbcf2e3c12483d219f0523
---

 libavcodec/x86/flacdsp.asm| 25 +
 libavcodec/x86/flacdsp_init.c |  2 ++
 2 files changed, 27 insertions(+)

diff --git a/libavcodec/x86/flacdsp.asm b/libavcodec/x86/flacdsp.asm
index 21b2439bc0..15fcec4f08 100644
--- a/libavcodec/x86/flacdsp.asm
+++ b/libavcodec/x86/flacdsp.asm
@@ -113,6 +113,31 @@ ALIGN 16
 jl .loop
 RET
 
+INIT_XMM sse4
+cglobal flac_wasted_33, 4,4,5, decoded, residuals, wasted, len
+shl   lend, 2
+lea   decodedq, [decodedq+lenq*2]
+add   residualsq, lenq
+neg   lenq
+movd  m4, wastedd
+ALIGN 16
+.loop:
+pmovsxdq  m0, [residualsq+lenq+mmsize*0]
+pmovsxdq  m1, [residualsq+lenq+mmsize/2]
+pmovsxdq  m2, [residualsq+lenq+mmsize*1]
+pmovsxdq  m3, [residualsq+lenq+mmsize*1+mmsize/2]
+psllq m0, m4
+psllq m1, m4
+psllq m2, m4
+psllq m3, m4
+mova  [decodedq+lenq*2+mmsize*0], m0
+mova  [decodedq+lenq*2+mmsize*1], m1
+mova  [decodedq+lenq*2+mmsize*2], m2
+mova  [decodedq+lenq*2+mmsize*3], m3
+add lenq, mmsize * 2
+jl .loop
+RET
+
 
;--
 ;void ff_flac_decorrelate_[lrm]s_16_sse2(uint8_t **out, int32_t **in, int 
channels,
 ;   int len, int shift);
diff --git a/libavcodec/x86/flacdsp_init.c b/libavcodec/x86/flacdsp_init.c
index 67aa118760..fa993d3466 100644
--- a/libavcodec/x86/flacdsp_init.c
+++ b/libavcodec/x86/flacdsp_init.c
@@ -31,6 +31,7 @@ void ff_flac_lpc_32_xop(int32_t *samples, const int 
coeffs[32], int order,
 int qlevel, int len);
 
 void ff_flac_wasted_32_sse2(int32_t *decoded, int wasted, int len);
+void ff_flac_wasted_33_sse4(int64_t *decoded, const int32_t *residual, int 
wasted, int len);
 
 #define DECORRELATE_FUNCS(fmt, opt)
  \
 void ff_flac_decorrelate_ls_##fmt##_##opt(uint8_t **out, int32_t **in, int 
channels, \
@@ -100,6 +101,7 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum 
AVSampleFormat fmt, int
 if (EXTERNAL_SSE4(cpu_flags)) {
 c->lpc16 = ff_flac_lpc_16_sse4;
 c->lpc32 = ff_flac_lpc_32_sse4;
+c->wasted33 = ff_flac_wasted_33_sse4;
 }
 if (EXTERNAL_AVX(cpu_flags)) {
 if (fmt == AV_SAMPLE_FMT_S16) {

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

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


[FFmpeg-cvslog] x86/flacdsp: remove unused parameters to pmacsdql macro

2024-05-13 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May 12 21:54:03 
2024 -0300| [b450c44630ba3b4166dac55e56cfd81a7b122837] | committer: James Almer

x86/flacdsp: remove unused parameters to pmacsdql macro

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b450c44630ba3b4166dac55e56cfd81a7b122837
---

 libavcodec/x86/flacdsp.asm | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/x86/flacdsp.asm b/libavcodec/x86/flacdsp.asm
index 15fcec4f08..9fc82ee9ae 100644
--- a/libavcodec/x86/flacdsp.asm
+++ b/libavcodec/x86/flacdsp.asm
@@ -29,7 +29,7 @@ vector:  db 
0,1,4,5,8,9,12,13,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,
 
 SECTION .text
 
-%macro PMACSDQL 5
+%macro PMACSDQL 3
 %if cpuflag(xop)
 pmacsdql %1, %2, %3, %1
 %else
@@ -59,21 +59,21 @@ ALIGN 16
 test   jq, jq
 jz .end_order
 .loop_order:
-PMACSDQL m2, m0, m1, m2, m0
+PMACSDQL m2, m0, m1
 movd   m0, [decodedq+jq*4]
-PMACSDQL m3, m1, m0, m3, m1
+PMACSDQL m3, m1, m0
 movd   m1, [coeffsq+jq*4]
 incjq
 jl .loop_order
 .end_order:
-PMACSDQL m2, m0, m1, m2, m0
+PMACSDQL m2, m0, m1
 %3 m2, m4
 movd   m0, [decodedq]
 paddd  m0, m2
 movd   [decodedq], m0
 sub  lend, 2
 jl .ret
-PMACSDQL m3, m1, m0, m3, m1
+PMACSDQL m3, m1, m0
 %3 m3, m4
 movd   m1, [decodedq+4]
 paddd  m1, m3

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

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


[FFmpeg-cvslog] checkasm/flacdsp: add a test for wasted33

2024-05-13 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May 12 12:35:29 
2024 -0300| [5ba6f4e63e49c815a2964a6e4139f62700eebf0a] | committer: James Almer

checkasm/flacdsp: add a test for wasted33

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5ba6f4e63e49c815a2964a6e4139f62700eebf0a
---

 tests/checkasm/flacdsp.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c
index ee0897ed01..96b7d05f7e 100644
--- a/tests/checkasm/flacdsp.c
+++ b/tests/checkasm/flacdsp.c
@@ -104,6 +104,25 @@ static void check_wasted32(void)
 bench_new(dst, wasted, BUF_SIZE);
 }
 
+static void check_wasted33(void)
+{
+int wasted = rnd() % 33;
+LOCAL_ALIGNED_16(int64_t, dst0, [BUF_SIZE]);
+LOCAL_ALIGNED_16(int64_t, dst1, [BUF_SIZE]);
+LOCAL_ALIGNED_16(int32_t, residuals, [BUF_SIZE]);
+
+declare_func(void, int64_t *, const int32_t *, int, int);
+
+for (int i = 0; i < BUF_SIZE; i++)
+residuals[i] = rnd();
+
+call_ref(dst0, residuals, wasted, BUF_SIZE);
+call_new(dst1, residuals, wasted, BUF_SIZE);
+if (memcmp(dst0, dst1, BUF_SIZE * sizeof (int64_t)) != 0)
+   fail();
+bench_new(dst0, residuals, wasted, BUF_SIZE);
+}
+
 void checkasm_check_flacdsp(void)
 {
 LOCAL_ALIGNED_16(uint8_t, ref_dst, [BUF_SIZE*MAX_CHANNELS]);
@@ -151,6 +170,8 @@ void checkasm_check_flacdsp(void)
 
 if (check_func(h.wasted32, "flac_wasted_32"))
 check_wasted32();
+if (check_func(h.wasted33, "flac_wasted_33"))
+check_wasted33();
 
 report("wasted");
 }

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

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


[FFmpeg-cvslog] x86/flacdsp: add a SSE2 version of wasted32

2024-05-12 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May 12 11:53:44 
2024 -0300| [0664cbd732fd9d95037d9110b64fb2a32360de2c] | committer: James Almer

x86/flacdsp: add a SSE2 version of wasted32

flac_wasted_32_c: 851.3
flac_wasted_32_sse2: 41.3

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0664cbd732fd9d95037d9110b64fb2a32360de2c
---

 libavcodec/x86/flacdsp.asm| 24 
 libavcodec/x86/flacdsp_init.c |  3 +++
 2 files changed, 27 insertions(+)

diff --git a/libavcodec/x86/flacdsp.asm b/libavcodec/x86/flacdsp.asm
index f38eb7db76..21b2439bc0 100644
--- a/libavcodec/x86/flacdsp.asm
+++ b/libavcodec/x86/flacdsp.asm
@@ -89,6 +89,30 @@ LPC_32 sse4, 32, psrlq
 LPC_32 xop,  32, psrlq
 %endif
 
+INIT_XMM sse2
+cglobal flac_wasted_32, 3,3,5, decoded, wasted, len
+shl   lend, 2
+add   decodedq, lenq
+neg   lenq
+movd  m4, wastedd
+ALIGN 16
+.loop:
+mova  m0, [decodedq+lenq+mmsize*0]
+mova  m1, [decodedq+lenq+mmsize*1]
+mova  m2, [decodedq+lenq+mmsize*2]
+mova  m3, [decodedq+lenq+mmsize*3]
+pslld m0, m4
+pslld m1, m4
+pslld m2, m4
+pslld m3, m4
+mova  [decodedq+lenq+mmsize*0], m0
+mova  [decodedq+lenq+mmsize*1], m1
+mova  [decodedq+lenq+mmsize*2], m2
+mova  [decodedq+lenq+mmsize*3], m3
+add lenq, mmsize * 4
+jl .loop
+RET
+
 
;--
 ;void ff_flac_decorrelate_[lrm]s_16_sse2(uint8_t **out, int32_t **in, int 
channels,
 ;   int len, int shift);
diff --git a/libavcodec/x86/flacdsp_init.c b/libavcodec/x86/flacdsp_init.c
index dee4bf88fc..67aa118760 100644
--- a/libavcodec/x86/flacdsp_init.c
+++ b/libavcodec/x86/flacdsp_init.c
@@ -30,6 +30,8 @@ void ff_flac_lpc_32_sse4(int32_t *samples, const int 
coeffs[32], int order,
 void ff_flac_lpc_32_xop(int32_t *samples, const int coeffs[32], int order,
 int qlevel, int len);
 
+void ff_flac_wasted_32_sse2(int32_t *decoded, int wasted, int len);
+
 #define DECORRELATE_FUNCS(fmt, opt)
  \
 void ff_flac_decorrelate_ls_##fmt##_##opt(uint8_t **out, int32_t **in, int 
channels, \
   int len, int shift); 
  \
@@ -63,6 +65,7 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum 
AVSampleFormat fmt, int
 int cpu_flags = av_get_cpu_flags();
 
 if (EXTERNAL_SSE2(cpu_flags)) {
+c->wasted32 = ff_flac_wasted_32_sse2;
 if (fmt == AV_SAMPLE_FMT_S16) {
 c->decorrelate[1] = ff_flac_decorrelate_ls_16_sse2;
 c->decorrelate[2] = ff_flac_decorrelate_rs_16_sse2;

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

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


[FFmpeg-cvslog] checkasm/flacdsp: add a test for wasted32

2024-05-12 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May 12 11:53:19 
2024 -0300| [5acec189afa300b28a581b7c4cfaa510d0f3a9c1] | committer: James Almer

checkasm/flacdsp: add a test for wasted32

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5acec189afa300b28a581b7c4cfaa510d0f3a9c1
---

 tests/checkasm/flacdsp.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c
index d694c1093b..ee0897ed01 100644
--- a/tests/checkasm/flacdsp.c
+++ b/tests/checkasm/flacdsp.c
@@ -83,6 +83,27 @@ static void check_lpc(int pred_order, int bps)
 bench_new(dst, coeffs, pred_order, qlevel, BUF_SIZE);
 }
 
+static void check_wasted32(void)
+{
+int wasted = rnd() % 32;
+LOCAL_ALIGNED_16(int32_t, dst,  [BUF_SIZE]);
+LOCAL_ALIGNED_16(int32_t, dst0, [BUF_SIZE]);
+LOCAL_ALIGNED_16(int32_t, dst1, [BUF_SIZE]);
+
+declare_func(void, int32_t *, int, int);
+
+for (int i = 0; i < BUF_SIZE; i++)
+dst[i] = rnd();
+
+memcpy(dst0, dst, BUF_SIZE * sizeof (int32_t));
+memcpy(dst1, dst, BUF_SIZE * sizeof (int32_t));
+call_ref(dst0, wasted, BUF_SIZE);
+call_new(dst1, wasted, BUF_SIZE);
+if (memcmp(dst0, dst1, BUF_SIZE * sizeof (int32_t)) != 0)
+   fail();
+bench_new(dst, wasted, BUF_SIZE);
+}
+
 void checkasm_check_flacdsp(void)
 {
 LOCAL_ALIGNED_16(uint8_t, ref_dst, [BUF_SIZE*MAX_CHANNELS]);
@@ -127,4 +148,9 @@ void checkasm_check_flacdsp(void)
 check_lpc(pred_orders[i], 32);
 
 report("lpc");
+
+if (check_func(h.wasted32, "flac_wasted_32"))
+check_wasted32();
+
+report("wasted");
 }

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

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


[FFmpeg-cvslog] avcodec/flacdsp: split off wasted bit handling into dsp functions

2024-05-12 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May 12 11:07:37 
2024 -0300| [1ba528769702e09ed2a7ce493ccc26190d8d4124] | committer: James Almer

avcodec/flacdsp: split off wasted bit handling into dsp functions

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1ba528769702e09ed2a7ce493ccc26190d8d4124
---

 libavcodec/flacdec.c |  8 ++--
 libavcodec/flacdsp.c | 16 
 libavcodec/flacdsp.h |  3 +++
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 91bbdc657d..6e6a2896b4 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -602,13 +602,9 @@ static inline int decode_subframe(FLACContext *s, int 
channel)
 
 if (wasted) {
 if (wasted+bps == 33) {
-int i;
-for (i = 0; i < s->blocksize; i++)
-s->decoded_33bps[i] = (uint64_t)decoded[i] << wasted;
+s->dsp.wasted33(s->decoded_33bps, decoded, wasted, s->blocksize);
 } else if (wasted < 32) {
-int i;
-for (i = 0; i < s->blocksize; i++)
-decoded[i] = (unsigned)decoded[i] << wasted;
+s->dsp.wasted32(decoded, wasted, s->blocksize);
 }
 }
 
diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
index 71b4ac44aa..27d3e923ee 100644
--- a/libavcodec/flacdsp.c
+++ b/libavcodec/flacdsp.c
@@ -84,11 +84,27 @@ static void flac_lpc_32_c(int32_t *decoded, const int 
coeffs[32],
 
 }
 
+static void flac_wasted_32_c(int32_t *decoded, int wasted, int len)
+{
+for (int i = 0; i < len; i++)
+decoded[i] = (unsigned)decoded[i] << wasted;
+}
+
+static void flac_wasted_33_c(int64_t *decoded, const int32_t *residual,
+ int wasted, int len)
+{
+for (int i = 0; i < len; i++)
+decoded[i] = (uint64_t)residual[i] << wasted;
+}
+
 av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int 
channels)
 {
 c->lpc16= flac_lpc_16_c;
 c->lpc32= flac_lpc_32_c;
 
+c->wasted32 = flac_wasted_32_c;
+c->wasted33 = flac_wasted_33_c;
+
 switch (fmt) {
 case AV_SAMPLE_FMT_S32:
 c->decorrelate[0] = flac_decorrelate_indep_c_32;
diff --git a/libavcodec/flacdsp.h b/libavcodec/flacdsp.h
index 15149c026e..5a59c0c864 100644
--- a/libavcodec/flacdsp.h
+++ b/libavcodec/flacdsp.h
@@ -30,6 +30,9 @@ typedef struct FLACDSPContext {
   int qlevel, int len);
 void (*lpc32)(int32_t *samples, const int coeffs[32], int order,
   int qlevel, int len);
+void (*wasted32)(int32_t *decoded, int wasted, int len);
+void (*wasted33)(int64_t *decoded, const int32_t *residual,
+ int wasted, int len);
 void (*lpc16_encode)(int32_t *res, const int32_t *smp, int len, int order,
  const int32_t coefs[32], int shift);
 void (*lpc32_encode)(int32_t *res, const int32_t *smp, int len, int order,

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

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


[FFmpeg-cvslog] x86/flacdsp: add a SSE4 version of lpc16

2024-05-12 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat May 11 23:57:57 
2024 -0300| [c00c8679ed35ccf053c3d0602932dda3adac752e] | committer: James Almer

x86/flacdsp: add a SSE4 version of lpc16

flac_lpc_16_13_c: 2841.3
flac_lpc_16_13_sse4: 2151.8
flac_lpc_16_16_c: 3382.8
flac_lpc_16_16_sse4: 2228.3
flac_lpc_16_29_c: 5800.3
flac_lpc_16_29_sse4: 3727.3
flac_lpc_16_32_c: 5972.8
flac_lpc_16_32_sse4: 4052.3

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c00c8679ed35ccf053c3d0602932dda3adac752e
---

 libavcodec/x86/flacdsp.asm| 13 +++--
 libavcodec/x86/flacdsp_init.c |  3 +++
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavcodec/x86/flacdsp.asm b/libavcodec/x86/flacdsp.asm
index 4b2fd65435..f38eb7db76 100644
--- a/libavcodec/x86/flacdsp.asm
+++ b/libavcodec/x86/flacdsp.asm
@@ -38,9 +38,9 @@ SECTION .text
 %endif
 %endmacro
 
-%macro LPC_32 1
+%macro LPC_32 3
 INIT_XMM %1
-cglobal flac_lpc_32, 5,6,5, decoded, coeffs, pred_order, qlevel, len, j
+cglobal flac_lpc_%2, 5,6,5, decoded, coeffs, pred_order, qlevel, len, j
 sublend, pred_orderd
 jle .ret
 movsxdifnidn pred_orderq, pred_orderd
@@ -67,14 +67,14 @@ ALIGN 16
 jl .loop_order
 .end_order:
 PMACSDQL m2, m0, m1, m2, m0
-psrlq  m2, m4
+%3 m2, m4
 movd   m0, [decodedq]
 paddd  m0, m2
 movd   [decodedq], m0
 sub  lend, 2
 jl .ret
 PMACSDQL m3, m1, m0, m3, m1
-psrlq  m3, m4
+%3 m3, m4
 movd   m1, [decodedq+4]
 paddd  m1, m3
 movd   [decodedq+4], m1
@@ -83,10 +83,11 @@ ALIGN 16
 RET
 %endmacro
 
+LPC_32 sse4, 16, psrad
+LPC_32 sse4, 32, psrlq
 %if HAVE_XOP_EXTERNAL
-LPC_32 xop
+LPC_32 xop,  32, psrlq
 %endif
-LPC_32 sse4
 
 
;--
 ;void ff_flac_decorrelate_[lrm]s_16_sse2(uint8_t **out, int32_t **in, int 
channels,
diff --git a/libavcodec/x86/flacdsp_init.c b/libavcodec/x86/flacdsp_init.c
index 87daed7005..dee4bf88fc 100644
--- a/libavcodec/x86/flacdsp_init.c
+++ b/libavcodec/x86/flacdsp_init.c
@@ -23,6 +23,8 @@
 #include "libavutil/x86/cpu.h"
 #include "config.h"
 
+void ff_flac_lpc_16_sse4(int32_t *samples, const int coeffs[32], int order,
+ int qlevel, int len);
 void ff_flac_lpc_32_sse4(int32_t *samples, const int coeffs[32], int order,
  int qlevel, int len);
 void ff_flac_lpc_32_xop(int32_t *samples, const int coeffs[32], int order,
@@ -93,6 +95,7 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum 
AVSampleFormat fmt, int
 }
 }
 if (EXTERNAL_SSE4(cpu_flags)) {
+c->lpc16 = ff_flac_lpc_16_sse4;
 c->lpc32 = ff_flac_lpc_32_sse4;
 }
 if (EXTERNAL_AVX(cpu_flags)) {

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

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


[FFmpeg-cvslog] checkasm/flacdsp: sanitize lpc arguments

2024-05-12 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat May 11 16:44:22 
2024 -0300| [479d26cea29e5b6c772878d5b7cd68e970a7a420] | committer: James Almer

checkasm/flacdsp: sanitize lpc arguments

Fixes signed integer overflows as reported by ubsan.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=479d26cea29e5b6c772878d5b7cd68e970a7a420
---

 tests/checkasm/flacdsp.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c
index 6561b4ed20..d694c1093b 100644
--- a/tests/checkasm/flacdsp.c
+++ b/tests/checkasm/flacdsp.c
@@ -21,6 +21,7 @@
 #include 
 #include "checkasm.h"
 #include "libavcodec/flacdsp.h"
+#include "libavcodec/mathops.h"
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
@@ -54,9 +55,10 @@ static void check_decorrelate(uint8_t **ref_dst, uint8_t 
**ref_src, uint8_t **ne
 bench_new(new_dst, (int32_t **)new_src, channels, BUF_SIZE / 
sizeof(int32_t), 8);
 }
 
-static void check_lpc(int pred_order)
+static void check_lpc(int pred_order, int bps)
 {
 int qlevel = rnd() % 16;
+int coeff_prec = (rnd() % 15) + 1;
 LOCAL_ALIGNED_16(int32_t, coeffs, [32]);
 LOCAL_ALIGNED_16(int32_t, dst,  [BUF_SIZE]);
 LOCAL_ALIGNED_16(int32_t, dst0, [BUF_SIZE]);
@@ -64,10 +66,13 @@ static void check_lpc(int pred_order)
 
 declare_func(void, int32_t *, const int[32], int, int, int);
 
+if (bps <= 16)
+coeff_prec = av_clip(coeff_prec, 0, 32 - bps - av_log2(pred_order));
+
 for (int i = 0; i < 32; i++)
-coeffs[i] = rnd();
+coeffs[i] = sign_extend(rnd(), coeff_prec);
 for (int i = 0; i < BUF_SIZE; i++)
-dst[i] = rnd();
+dst[i] = sign_extend(rnd(), bps);
 
 memcpy(dst0, dst, BUF_SIZE * sizeof (int32_t));
 memcpy(dst1, dst, BUF_SIZE * sizeof (int32_t));
@@ -116,10 +121,10 @@ void checkasm_check_flacdsp(void)
 
 for (i = 0; i < FF_ARRAY_ELEMS(pred_orders); i++)
 if (check_func(h.lpc16, "flac_lpc_16_%d", pred_orders[i]))
-check_lpc(pred_orders[i]);
+check_lpc(pred_orders[i], 16);
 for (i = 0; i < FF_ARRAY_ELEMS(pred_orders); i++)
 if (check_func(h.lpc32, "flac_lpc_32_%d", pred_orders[i]))
-check_lpc(pred_orders[i]);
+check_lpc(pred_orders[i], 32);
 
 report("lpc");
 }

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

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


[FFmpeg-cvslog] checkasm/flacdsp: run lpc benchmarks with an unmodified buffer

2024-05-12 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat May 11 16:12:32 
2024 -0300| [467d84a06d1b3535e24dbe5046936dc2ee439ea3] | committer: James Almer

checkasm/flacdsp: run lpc benchmarks with an unmodified buffer

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=467d84a06d1b3535e24dbe5046936dc2ee439ea3
---

 tests/checkasm/flacdsp.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c
index b308237db1..6561b4ed20 100644
--- a/tests/checkasm/flacdsp.c
+++ b/tests/checkasm/flacdsp.c
@@ -58,6 +58,7 @@ static void check_lpc(int pred_order)
 {
 int qlevel = rnd() % 16;
 LOCAL_ALIGNED_16(int32_t, coeffs, [32]);
+LOCAL_ALIGNED_16(int32_t, dst,  [BUF_SIZE]);
 LOCAL_ALIGNED_16(int32_t, dst0, [BUF_SIZE]);
 LOCAL_ALIGNED_16(int32_t, dst1, [BUF_SIZE]);
 
@@ -66,14 +67,15 @@ static void check_lpc(int pred_order)
 for (int i = 0; i < 32; i++)
 coeffs[i] = rnd();
 for (int i = 0; i < BUF_SIZE; i++)
-dst0[i] = rnd();
+dst[i] = rnd();
 
-memcpy(dst1, dst0, BUF_SIZE * sizeof (int32_t));
+memcpy(dst0, dst, BUF_SIZE * sizeof (int32_t));
+memcpy(dst1, dst, BUF_SIZE * sizeof (int32_t));
 call_ref(dst0, coeffs, pred_order, qlevel, BUF_SIZE);
 call_new(dst1, coeffs, pred_order, qlevel, BUF_SIZE);
 if (memcmp(dst0, dst1, BUF_SIZE * sizeof (int32_t)) != 0)
fail();
-bench_new(dst1, coeffs, pred_order, qlevel, BUF_SIZE);
+bench_new(dst, coeffs, pred_order, qlevel, BUF_SIZE);
 }
 
 void checkasm_check_flacdsp(void)

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

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


[FFmpeg-cvslog] x86/blockdsp: add sse2 and avx2 versions of fill_block_tab

2024-05-08 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue May  7 11:33:40 
2024 -0300| [214cbe29dc2c6aceb2167131137caa41cbd9f7b6] | committer: James Almer

x86/blockdsp: add sse2 and avx2 versions of fill_block_tab

blockdsp.fill_block_tab[0]_c: 34.1
blockdsp.fill_block_tab[0]_sse2: 11.1
blockdsp.fill_block_tab[0]_avx2: 10.1
blockdsp.fill_block_tab[1]_c: 10.1
blockdsp.fill_block_tab[1]_sse2: 6.1
blockdsp.fill_block_tab[1]_avx2: 5.6

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=214cbe29dc2c6aceb2167131137caa41cbd9f7b6
---

 libavcodec/x86/blockdsp.asm| 33 +
 libavcodec/x86/blockdsp_init.c | 13 +
 2 files changed, 46 insertions(+)

diff --git a/libavcodec/x86/blockdsp.asm b/libavcodec/x86/blockdsp.asm
index e380308d4a..9a801a 100644
--- a/libavcodec/x86/blockdsp.asm
+++ b/libavcodec/x86/blockdsp.asm
@@ -80,3 +80,36 @@ INIT_XMM sse
 CLEAR_BLOCKS 1
 INIT_YMM avx
 CLEAR_BLOCKS 1
+
+;-
+; void ff_fill_block_tab_%1(uint8_t *block, uint8_t value,
+;   ptrdiff_t line_size, int h);
+;-
+%macro FILL_BLOCK_TAB 2
+cglobal fill_block_tab_%1, 4, 5, 1, block, value, stride, h, stride3
+lea stride3q, [strideq + strideq * 2]
+%if cpuflag(avx2)
+movd m0, valued
+vpbroadcastb m0, m0
+%else
+SPLATB_REG m0, value, x
+%endif
+.loop:
+mov%2 [blockq], m0
+mov%2 [blockq + strideq], m0
+mov%2 [blockq + strideq * 2], m0
+mov%2 [blockq + stride3q], m0
+lea blockq, [blockq + strideq * 4]
+sub hd, 4
+jg .loop
+RET
+%endmacro
+
+INIT_XMM sse2
+FILL_BLOCK_TAB 8, q
+FILL_BLOCK_TAB 16, a
+%if HAVE_AVX2_EXTERNAL
+INIT_XMM avx2
+FILL_BLOCK_TAB 8, q
+FILL_BLOCK_TAB 16, a
+%endif
diff --git a/libavcodec/x86/blockdsp_init.c b/libavcodec/x86/blockdsp_init.c
index 996124114f..37f3bb6a84 100644
--- a/libavcodec/x86/blockdsp_init.c
+++ b/libavcodec/x86/blockdsp_init.c
@@ -29,6 +29,11 @@ void ff_clear_block_avx(int16_t *block);
 void ff_clear_blocks_sse(int16_t *blocks);
 void ff_clear_blocks_avx(int16_t *blocks);
 
+void ff_fill_block_tab_16_sse2(uint8_t *block, uint8_t value, ptrdiff_t 
line_size, int h);
+void ff_fill_block_tab_8_sse2(uint8_t *block, uint8_t value, ptrdiff_t 
line_size, int h);
+void ff_fill_block_tab_16_avx2(uint8_t *block, uint8_t value, ptrdiff_t 
line_size, int h);
+void ff_fill_block_tab_8_avx2(uint8_t *block, uint8_t value, ptrdiff_t 
line_size, int h);
+
 av_cold void ff_blockdsp_init_x86(BlockDSPContext *c)
 {
 #if HAVE_X86ASM
@@ -38,9 +43,17 @@ av_cold void ff_blockdsp_init_x86(BlockDSPContext *c)
 c->clear_block  = ff_clear_block_sse;
 c->clear_blocks = ff_clear_blocks_sse;
 }
+if (EXTERNAL_SSE2(cpu_flags)) {
+c->fill_block_tab[0] = ff_fill_block_tab_16_sse2;
+c->fill_block_tab[1] = ff_fill_block_tab_8_sse2;
+}
 if (EXTERNAL_AVX_FAST(cpu_flags)) {
 c->clear_block  = ff_clear_block_avx;
 c->clear_blocks = ff_clear_blocks_avx;
 }
+if (EXTERNAL_AVX2(cpu_flags)) {
+c->fill_block_tab[0] = ff_fill_block_tab_16_avx2;
+c->fill_block_tab[1] = ff_fill_block_tab_8_avx2;
+}
 #endif /* HAVE_X86ASM */
 }

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

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


[FFmpeg-cvslog] checkasm/blockdsp: use smallest allowed aligned buffers for fill_block_tab tests

2024-05-08 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue May  7 11:58:55 
2024 -0300| [b6054e57cb5fa7b6bad834dcfbf0f3dd934ba276] | committer: James Almer

checkasm/blockdsp: use smallest allowed aligned buffers for fill_block_tab tests

The requirement is either 8 or 16 bytes alignment, not 32.
This should help finding bugs in asm implementations.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b6054e57cb5fa7b6bad834dcfbf0f3dd934ba276
---

 tests/checkasm/blockdsp.c | 21 +++--
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/tests/checkasm/blockdsp.c b/tests/checkasm/blockdsp.c
index 1f02d02076..5f4d46b8fa 100644
--- a/tests/checkasm/blockdsp.c
+++ b/tests/checkasm/blockdsp.c
@@ -29,11 +29,6 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem_internal.h"
 
-typedef struct {
-const char *name;
-int size;
-} test;
-
 #define randomize_buffers(size) \
 do {\
 int i;  \
@@ -58,18 +53,16 @@ do {
\
 } while (0)
 
 static void check_fill(BlockDSPContext *h){
-const test tests[] = {
-{"fill_block_tab[0]", 16},
-{"fill_block_tab[1]", 8},
-};
-LOCAL_ALIGNED_32(uint8_t, buf0, [16 * 16]);
-LOCAL_ALIGNED_32(uint8_t, buf1, [16 * 16]);
+LOCAL_ALIGNED_16(uint8_t, buf0_16, [16 * 16]);
+LOCAL_ALIGNED_16(uint8_t, buf1_16, [16 * 16]);
 
-for (size_t t = 0; t < FF_ARRAY_ELEMS(tests); ++t) {
-int n = tests[t].size;
+for (int t = 0; t < 2; ++t) {
+uint8_t *buf0 = buf0_16 + t * /* force 8 byte alignment */ 8;
+uint8_t *buf1 = buf1_16 + t * /* force 8 byte alignment */ 8;
+int n = 16 - 8 * t;
 declare_func(void, uint8_t *block, uint8_t value,
  ptrdiff_t line_size, int h);
-if (check_func(h->fill_block_tab[t], "blockdsp.%s", tests[t].name)) {
+if (check_func(h->fill_block_tab[t], "blockdsp.fill_block_tab[%d]", 
t)) {
 uint8_t value = rnd();
 memset(buf0, 0, sizeof(*buf0) * n * n);
 memset(buf1, 0, sizeof(*buf1) * n * n);

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

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


[FFmpeg-cvslog] checkasm/blockdsp: don't randomize the buffers for fill_block_tab

2024-05-08 Thread James Almer
ffmpeg | branch: master | James Almer  | Mon May  6 21:27:13 
2024 -0300| [febd9271fc2a9e1244a9d6bbeeaa6ec3ec49a0ba] | committer: James Almer

checkasm/blockdsp: don't randomize the buffers for fill_block_tab

It ignores and overwrites the previous values.
Fixes running the test under ubsan.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=febd9271fc2a9e1244a9d6bbeeaa6ec3ec49a0ba
---

 tests/checkasm/blockdsp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/checkasm/blockdsp.c b/tests/checkasm/blockdsp.c
index 19d69b8687..1f02d02076 100644
--- a/tests/checkasm/blockdsp.c
+++ b/tests/checkasm/blockdsp.c
@@ -71,7 +71,8 @@ static void check_fill(BlockDSPContext *h){
  ptrdiff_t line_size, int h);
 if (check_func(h->fill_block_tab[t], "blockdsp.%s", tests[t].name)) {
 uint8_t value = rnd();
-randomize_buffers(tests[t].size);
+memset(buf0, 0, sizeof(*buf0) * n * n);
+memset(buf1, 0, sizeof(*buf1) * n * n);
 call_ref(buf0, value, n, n);
 call_new(buf1, value, n, n);
 if (memcmp(buf0, buf1, sizeof(*buf0) * n * n))

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

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


[FFmpeg-cvslog] avutil/opt: free the temporary layout in av_opt_is_set_to_default()

2024-05-07 Thread James Almer
ffmpeg | branch: master | James Almer  | Mon May  6 12:38:44 
2024 -0300| [4e069ba80abe81ed64b20125232ca5be3fdf6ceb] | committer: James Almer

avutil/opt: free the temporary layout in av_opt_is_set_to_default()

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4e069ba80abe81ed64b20125232ca5be3fdf6ceb
---

 libavutil/opt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index d31a8bfbf1..32a9e059e3 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -2309,7 +2309,9 @@ int av_opt_is_set_to_default(void *obj, const AVOption *o)
 if ((ret = av_channel_layout_from_string(_layout, 
o->default_val.str)) < 0)
 return ret;
 }
-return !av_channel_layout_compare((AVChannelLayout *)dst, _layout);
+ret = !av_channel_layout_compare((AVChannelLayout *)dst, _layout);
+av_channel_layout_uninit(_layout);
+return ret;
 }
 case AV_OPT_TYPE_STRING:
 str = *(char **)dst;

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

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


[FFmpeg-cvslog] avutil/opt: propagate av_dict_copy() errors in av_opt_{get,set}_dict_val()

2024-05-07 Thread James Almer
ffmpeg | branch: master | James Almer  | Mon May  6 12:24:47 
2024 -0300| [ae0293ee411f868d9665104a6678bebcf09d15b1] | committer: James Almer

avutil/opt: propagate av_dict_copy() errors in av_opt_{get,set}_dict_val()

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae0293ee411f868d9665104a6678bebcf09d15b1
---

 libavutil/opt.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 60b0c2a946..d31a8bfbf1 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -934,9 +934,8 @@ int av_opt_set_dict_val(void *obj, const char *name, const 
AVDictionary *val,
 
 dst = (AVDictionary **)(((uint8_t *)target_obj) + o->offset);
 av_dict_free(dst);
-av_dict_copy(dst, val, 0);
 
-return 0;
+return av_dict_copy(dst, val, 0);
 }
 
 int av_opt_set_chlayout(void *obj, const char *name,
@@ -1348,9 +1347,8 @@ int av_opt_get_dict_val(void *obj, const char *name, int 
search_flags, AVDiction
 return AVERROR(EINVAL);
 
 src = *(AVDictionary **)(((uint8_t *)target_obj) + o->offset);
-av_dict_copy(out_val, src, 0);
 
-return 0;
+return av_dict_copy(out_val, src, 0);
 }
 
 int av_opt_flag_is_set(void *obj, const char *field_name, const char 
*flag_name)

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

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


[FFmpeg-cvslog] avutil/opt: don't set a channel layout if the option is flagged as read only

2024-05-07 Thread James Almer
ffmpeg | branch: master | James Almer  | Mon May  6 12:24:17 
2024 -0300| [9614efc2586edb82cec847598c5abca0ce79dd25] | committer: James Almer

avutil/opt: don't set a channel layout if the option is flagged as read only

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9614efc2586edb82cec847598c5abca0ce79dd25
---

 libavutil/opt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index a892e056cb..60b0c2a946 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -949,6 +949,8 @@ int av_opt_set_chlayout(void *obj, const char *name,
 
 if (!o || !target_obj)
 return AVERROR_OPTION_NOT_FOUND;
+if (o->flags & AV_OPT_FLAG_READONLY)
+return AVERROR(EINVAL);
 
 dst = (AVChannelLayout*)((uint8_t*)target_obj + o->offset);
 

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

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


[FFmpeg-cvslog] avutil/opt: add a note about the av_opt_{get,set}_chlayout() behavior

2024-05-07 Thread James Almer
ffmpeg | branch: master | James Almer  | Mon May  6 12:23:30 
2024 -0300| [2987c65caabceab2eaf09185392f0d07027e788f] | committer: James Almer

avutil/opt: add a note about the av_opt_{get,set}_chlayout() behavior

Based on the one for av_opt_set_dict_val().

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2987c65caabceab2eaf09185392f0d07027e788f
---

 libavutil/opt.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavutil/opt.h b/libavutil/opt.h
index 2d76ec6105..07e27a9208 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -797,6 +797,10 @@ int av_opt_set_image_size(void *obj, const char *name, int 
w, int h, int search_
 int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, 
int search_flags);
 int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat 
fmt, int search_flags);
 int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int 
search_flags);
+/**
+ * @note Any old chlayout present is discarded and replaced with a copy of the 
new one. The
+ * caller still owns layout and is responsible for uninitializing it.
+ */
 int av_opt_set_chlayout(void *obj, const char *name, const AVChannelLayout 
*layout, int search_flags);
 /**
  * @note Any old dictionary present is discarded and replaced with a copy of 
the new one. The
@@ -858,6 +862,10 @@ int av_opt_get_image_size(void *obj, const char *name, int 
search_flags, int *w_
 int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum 
AVPixelFormat *out_fmt);
 int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum 
AVSampleFormat *out_fmt);
 int av_opt_get_video_rate(void *obj, const char *name, int search_flags, 
AVRational *out_val);
+/**
+ * @param[out] layout The returned layout is a copy of the actual value and 
must
+ * be freed with av_channel_layout_uninit() by the caller
+ */
 int av_opt_get_chlayout(void *obj, const char *name, int search_flags, 
AVChannelLayout *layout);
 /**
  * @param[out] out_val The returned dictionary is a copy of the actual value 
and must

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

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


[FFmpeg-cvslog] avformat/mov: don't use stream duration to calculate bitrate with fragmented input

2024-05-05 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Apr 30 23:08:46 
2024 -0300| [0ec8f3c55a7786d88935205db8244a4c4419fe7f] | committer: James Almer

avformat/mov: don't use stream duration to calculate bitrate with fragmented 
input

sc->data_size may contain the size of a single fragment after probing, and
using it alongside the duration of the entire stream to calculate bitrate
will result in a bogus small value.

Before:
  Duration: 00:00:05.00, start: 0.00, bitrate: 586 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), 
yuv420p(progressive), 640x360 [SAR 1:1 DAR 16:9], 112 kb/s, 60 fps, 60 tbr, 
15360 tbn (default)

After:
  Duration: 00:00:05.00, start: 0.00, bitrate: 586 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), 
yuv420p(progressive), 640x360 [SAR 1:1 DAR 16:9], 561 kb/s, 60 fps, 60 tbr, 
15360 tbn (default)

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0ec8f3c55a7786d88935205db8244a4c4419fe7f
---

 libavformat/mov.c | 20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index e8da6c2d65..b3fa748f27 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -9667,25 +9667,7 @@ static int mov_read_header(AVFormatContext *s)
 }
 }
 
-if (mov->trex_data) {
-for (i = 0; i < s->nb_streams; i++) {
-AVStream *st = s->streams[i];
-MOVStreamContext *sc = st->priv_data;
-if (st->duration > 0) {
-/* Akin to sc->data_size * 8 * sc->time_scale / st->duration 
but accounting for overflows. */
-st->codecpar->bit_rate = av_rescale(sc->data_size, ((int64_t) 
sc->time_scale) * 8, st->duration);
-if (st->codecpar->bit_rate == INT64_MIN) {
-av_log(s, AV_LOG_WARNING, "Overflow during bit rate 
calculation %"PRId64" * 8 * %d\n",
-   sc->data_size, sc->time_scale);
-st->codecpar->bit_rate = 0;
-if (s->error_recognition & AV_EF_EXPLODE)
-return AVERROR_INVALIDDATA;
-}
-}
-}
-}
-
-if (mov->use_mfra_for > 0) {
+if (mov->trex_data || mov->use_mfra_for > 0) {
 for (i = 0; i < s->nb_streams; i++) {
 AVStream *st = s->streams[i];
 MOVStreamContext *sc = st->priv_data;

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

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


[FFmpeg-cvslog] avfilter/vf_scale: properly reinitialize framesync

2024-05-05 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May  5 11:39:49 
2024 -0300| [82397084a9328d3f67caa9ce519304b714a132ea] | committer: James Almer

avfilter/vf_scale: properly reinitialize framesync

Fixes leaks as reported by ASAN and Valgrind.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=82397084a9328d3f67caa9ce519304b714a132ea
---

 libavfilter/vf_scale.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 07e9025335..841075193e 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -766,6 +766,7 @@ static int config_props(AVFilterLink *outlink)
 av_freep(_val);
 
 if (ctx->filter != _vf_scale2ref) {
+ff_framesync_uninit(>fs);
 ret = ff_framesync_init(>fs, ctx, ctx->nb_inputs);
 if (ret < 0)
 return ret;

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

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


[FFmpeg-cvslog] avformat/iamf_reader: split "if ((ret = ...) < 0)" line

2024-05-05 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May  5 13:56:52 
2024 -0300| [2e16285fe833e41890db33eb39b4a69f4370a5cf] | committer: James Almer

avformat/iamf_reader: split "if ((ret = ...) < 0)" line

Cosmetic change.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2e16285fe833e41890db33eb39b4a69f4370a5cf
---

 libavformat/iamf_reader.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/iamf_reader.c b/libavformat/iamf_reader.c
index 014e8e3ecc..cdb412f637 100644
--- a/libavformat/iamf_reader.c
+++ b/libavformat/iamf_reader.c
@@ -276,7 +276,8 @@ int ff_iamf_read_packet(AVFormatContext *s, 
IAMFDemuxContext *c,
 unsigned skip_samples, discard_padding;
 int ret, len, size, start_pos;
 
-if ((ret = ffio_ensure_seekback(pb, FFMIN(MAX_IAMF_OBU_HEADER_SIZE, 
max_size))) < 0)
+ret = ffio_ensure_seekback(pb, FFMIN(MAX_IAMF_OBU_HEADER_SIZE, 
max_size));
+if (ret < 0)
 return ret;
 size = avio_read(pb, header, FFMIN(MAX_IAMF_OBU_HEADER_SIZE, 
max_size));
 if (size < 0)

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

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


[FFmpeg-cvslog] avfilter/framesync: reset nb_in on allocation failure

2024-05-05 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May  5 11:38:28 
2024 -0300| [ccf395e8bde3e5d6b96be3e0ba25e2d162d4117e] | committer: James Almer

avfilter/framesync: reset nb_in on allocation failure

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ccf395e8bde3e5d6b96be3e0ba25e2d162d4117e
---

 libavfilter/framesync.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c
index a691136f34..535fbe9c7c 100644
--- a/libavfilter/framesync.c
+++ b/libavfilter/framesync.c
@@ -95,8 +95,11 @@ int ff_framesync_init(FFFrameSync *fs, AVFilterContext 
*parent, unsigned nb_in)
 fs->nb_in  = nb_in;
 
 fs->in = av_calloc(nb_in, sizeof(*fs->in));
-if (!fs->in)
+if (!fs->in) {
+fs->nb_in = 0;
 return AVERROR(ENOMEM);
+}
+
 return 0;
 }
 

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

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


[FFmpeg-cvslog] avfilter/vf_scale: don't expose framesync options in vf_scale2ref

2024-05-05 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun May  5 10:59:25 
2024 -0300| [eb392e41004c825551693d84db24666853950e4b] | committer: James Almer

avfilter/vf_scale: don't expose framesync options in vf_scale2ref

It doesn't use them.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eb392e41004c825551693d84db24666853950e4b
---

 libavfilter/vf_scale.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 60d301dcd8..07e9025335 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -1228,7 +1228,7 @@ static const AVOption scale_options[] = {
 };
 
 static const AVClass scale_class = {
-.class_name   = "scale(2ref)",
+.class_name   = "scale",
 .item_name= av_default_item_name,
 .option   = scale_options,
 .version  = LIBAVUTIL_VERSION_INT,
@@ -1268,6 +1268,31 @@ const AVFilter ff_vf_scale = {
 .flags   = AVFILTER_FLAG_DYNAMIC_INPUTS,
 };
 
+static const AVClass *scale2ref_child_class_iterate(void **iter)
+{
+const AVClass *c = *iter ? NULL : sws_get_class();
+*iter = (void*)(uintptr_t)c;
+return c;
+}
+
+static void *scale2ref_child_next(void *obj, void *prev)
+{
+ScaleContext *s = obj;
+if (!prev)
+return s->sws_opts;
+return NULL;
+}
+
+static const AVClass scale2ref_class = {
+.class_name   = "scale(2ref)",
+.item_name= av_default_item_name,
+.option   = scale_options,
+.version  = LIBAVUTIL_VERSION_INT,
+.category = AV_CLASS_CATEGORY_FILTER,
+.child_class_iterate = scale2ref_child_class_iterate,
+.child_next  = scale2ref_child_next,
+};
+
 static const AVFilterPad avfilter_vf_scale2ref_inputs[] = {
 {
 .name = "default",
@@ -1303,7 +1328,7 @@ const AVFilter ff_vf_scale2ref = {
 .init= init,
 .uninit  = uninit,
 .priv_size   = sizeof(ScaleContext),
-.priv_class  = _class,
+.priv_class  = _class,
 FILTER_INPUTS(avfilter_vf_scale2ref_inputs),
 FILTER_OUTPUTS(avfilter_vf_scale2ref_outputs),
 FILTER_QUERY_FUNC(query_formats),

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

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


[FFmpeg-cvslog] avutil/iamf: fix offsets for mix_gain options

2024-05-04 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Sat May  4 
21:20:35 2024 -0300| [a51c06b42c7b3f609b774983ee686ebe94186343] | committer: 
James Almer

avutil/iamf: fix offsets for mix_gain options

Signed-off-by: James Almer 
(cherry picked from commit d6e877bbcde2a0d1422d7b5c7339bb03891d19fc)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a51c06b42c7b3f609b774983ee686ebe94186343
---

 libavutil/iamf.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavutil/iamf.c b/libavutil/iamf.c
index c96100e7a0..14f49cba93 100644
--- a/libavutil/iamf.c
+++ b/libavutil/iamf.c
@@ -66,10 +66,10 @@ child_type *av_iamf_ ## parent_name ## _add_ ## 
child_name(parent_type *parent_n
 static const AVOption mix_gain_options[] = {
 { "subblock_duration", "set subblock_duration", OFFSET(subblock_duration), 
AV_OPT_TYPE_INT, {.i64 = 1 }, 1, UINT_MAX, FLAGS },
 { "animation_type", "set animation_type", OFFSET(animation_type), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FLAGS },
-{ "start_point_value", "set start_point_value", OFFSET(animation_type), 
AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS },
-{ "end_point_value", "set end_point_value", OFFSET(animation_type), 
AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS },
-{ "control_point_value", "set control_point_value", 
OFFSET(animation_type), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS 
},
-{ "control_point_relative_time", "set control_point_relative_time", 
OFFSET(animation_type), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, 0.0, 1.0, FLAGS },
+{ "start_point_value", "set start_point_value", OFFSET(start_point_value), 
AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS },
+{ "end_point_value", "set end_point_value", OFFSET(end_point_value), 
AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS },
+{ "control_point_value", "set control_point_value", 
OFFSET(control_point_value), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, 
FLAGS },
+{ "control_point_relative_time", "set control_point_relative_time", 
OFFSET(control_point_relative_time), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, 0.0, 
1.0, FLAGS },
 { NULL },
 };
 

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

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


[FFmpeg-cvslog] avutil/iamf: use AV_OPT_TYPE_UINT

2024-05-04 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat May  4 21:31:26 
2024 -0300| [088bf6e8c1ca99c7db2d250ca9b04bb2568f6ecb] | committer: James Almer

avutil/iamf: use AV_OPT_TYPE_UINT

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=088bf6e8c1ca99c7db2d250ca9b04bb2568f6ecb
---

 libavutil/iamf.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavutil/iamf.c b/libavutil/iamf.c
index 14f49cba93..791954d951 100644
--- a/libavutil/iamf.c
+++ b/libavutil/iamf.c
@@ -64,8 +64,8 @@ child_type *av_iamf_ ## parent_name ## _add_ ## 
child_name(parent_type *parent_n
 //
 #define OFFSET(x) offsetof(AVIAMFMixGain, x)
 static const AVOption mix_gain_options[] = {
-{ "subblock_duration", "set subblock_duration", OFFSET(subblock_duration), 
AV_OPT_TYPE_INT, {.i64 = 1 }, 1, UINT_MAX, FLAGS },
-{ "animation_type", "set animation_type", OFFSET(animation_type), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FLAGS },
+{ "subblock_duration", "set subblock_duration", OFFSET(subblock_duration), 
AV_OPT_TYPE_UINT, {.i64 = 1 }, 1, UINT_MAX, FLAGS },
+{ "animation_type", "set animation_type", OFFSET(animation_type), 
AV_OPT_TYPE_UINT, {.i64 = 0 }, 0, 2, FLAGS },
 { "start_point_value", "set start_point_value", OFFSET(start_point_value), 
AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS },
 { "end_point_value", "set end_point_value", OFFSET(end_point_value), 
AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS },
 { "control_point_value", "set control_point_value", 
OFFSET(control_point_value), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, 
FLAGS },
@@ -83,8 +83,8 @@ static const AVClass mix_gain_class = {
 #undef OFFSET
 #define OFFSET(x) offsetof(AVIAMFDemixingInfo, x)
 static const AVOption demixing_info_options[] = {
-{ "subblock_duration", "set subblock_duration", OFFSET(subblock_duration), 
AV_OPT_TYPE_INT, {.i64 = 1 }, 1, UINT_MAX, FLAGS },
-{ "dmixp_mode", "set dmixp_mode", OFFSET(dmixp_mode), AV_OPT_TYPE_INT, 
{.i64 = 0 }, 0, 6, FLAGS },
+{ "subblock_duration", "set subblock_duration", OFFSET(subblock_duration), 
AV_OPT_TYPE_UINT, {.i64 = 1 }, 1, UINT_MAX, FLAGS },
+{ "dmixp_mode", "set dmixp_mode", OFFSET(dmixp_mode), AV_OPT_TYPE_UINT, 
{.i64 = 0 }, 0, 6, FLAGS },
 { NULL },
 };
 
@@ -98,7 +98,7 @@ static const AVClass demixing_info_class = {
 #undef OFFSET
 #define OFFSET(x) offsetof(AVIAMFReconGain, x)
 static const AVOption recon_gain_options[] = {
-{ "subblock_duration", "set subblock_duration", OFFSET(subblock_duration), 
AV_OPT_TYPE_INT, {.i64 = 1 }, 1, UINT_MAX, FLAGS },
+{ "subblock_duration", "set subblock_duration", OFFSET(subblock_duration), 
AV_OPT_TYPE_UINT, {.i64 = 1 }, 1, UINT_MAX, FLAGS },
 { NULL },
 };
 
@@ -112,10 +112,10 @@ static const AVClass recon_gain_class = {
 #undef OFFSET
 #define OFFSET(x) offsetof(AVIAMFParamDefinition, x)
 static const AVOption param_definition_options[] = {
-{ "parameter_id", "set parameter_id", OFFSET(parameter_id), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, UINT_MAX, FLAGS },
-{ "parameter_rate", "set parameter_rate", OFFSET(parameter_rate), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, UINT_MAX, FLAGS },
-{ "duration", "set duration", OFFSET(duration), AV_OPT_TYPE_INT, {.i64 = 0 
}, 0, UINT_MAX, FLAGS },
-{ "constant_subblock_duration", "set constant_subblock_duration", 
OFFSET(constant_subblock_duration), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, UINT_MAX, 
FLAGS },
+{ "parameter_id", "set parameter_id", OFFSET(parameter_id), 
AV_OPT_TYPE_UINT, {.i64 = 0 }, 0, UINT_MAX, FLAGS },
+{ "parameter_rate", "set parameter_rate", OFFSET(parameter_rate), 
AV_OPT_TYPE_UINT, {.i64 = 0 }, 0, UINT_MAX, FLAGS },
+{ "duration", "set duration", OFFSET(duration), AV_OPT_TYPE_UINT, {.i64 = 
0 }, 0, UINT_MAX, FLAGS },
+{ "constant_subblock_duration", "set constant_subblock_duration", 
OFFSET(constant_subblock_duration), AV_OPT_TYPE_UINT, {.i64 = 0 }, 0, UINT_MAX, 
FLAGS },
 { NULL },
 };
 
@@ -289,7 +289,7 @@ static const AVOption audio_element_options[] = {
{ .i64 = AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL }, .unit = 
"audio_element_type" },
 { "scene",   NULL, 0, AV_OPT_TYPE_CONST,
{ .i64 = AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE },   .unit = 
"audio_element_type" },
-{ "default_w", "set default_w", OFFSET(default_w), AV_OPT_TYPE_INT, {.i64 
= 0 }, 0, 10, FLAGS },
+{ "default_w", "set default_w", OFFSET(default_w), AV_OPT_TYPE_UINT, {.i64 
= 0 }, 0, 10, FLAGS },
 { NULL },
 };
 

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

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


[FFmpeg-cvslog] avutil/opt: add an unsigned option type

2024-05-04 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Feb 27 17:30:40 
2024 -0300| [d053290d8dd4dfddebc7285628360b67e185d63d] | committer: James Almer

avutil/opt: add an unsigned option type

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d053290d8dd4dfddebc7285628360b67e185d63d
---

 doc/APIchanges|  3 +++
 libavutil/opt.c   | 17 +
 libavutil/opt.h   |  2 ++
 libavutil/tests/opt.c |  9 +
 libavutil/version.h   |  4 ++--
 tests/ref/fate/opt| 32 ++--
 6 files changed, 63 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 0566fcdcc5..824beec9d3 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-05-04 - xx - lavu 59.17.100 - opt.h
+  Add AV_OPT_TYPE_UINT and av_opt_eval_uint().
+
 2024-04-24 - 8616cfe0890 - lavu 59.16.100 - opt.h
   Add AV_OPT_SERIALIZE_SEARCH_CHILDREN.
 
diff --git a/libavutil/opt.c b/libavutil/opt.c
index ecbf7efe5f..a892e056cb 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -62,6 +62,7 @@ static const size_t opt_elem_size[] = {
 [AV_OPT_TYPE_FLAGS] = sizeof(unsigned),
 [AV_OPT_TYPE_INT]   = sizeof(int),
 [AV_OPT_TYPE_INT64] = sizeof(int64_t),
+[AV_OPT_TYPE_UINT]  = sizeof(unsigned),
 [AV_OPT_TYPE_UINT64]= sizeof(uint64_t),
 [AV_OPT_TYPE_DOUBLE]= sizeof(double),
 [AV_OPT_TYPE_FLOAT] = sizeof(float),
@@ -166,6 +167,9 @@ static int read_number(const AVOption *o, const void *dst, 
double *num, int *den
 case AV_OPT_TYPE_INT:
 *intnum = *(int *)dst;
 return 0;
+case AV_OPT_TYPE_UINT:
+*intnum = *(unsigned int *)dst;
+return 0;
 case AV_OPT_TYPE_DURATION:
 case AV_OPT_TYPE_INT64:
 case AV_OPT_TYPE_UINT64:
@@ -219,6 +223,7 @@ static int write_number(void *obj, const AVOption *o, void 
*dst, double num, int
 case AV_OPT_TYPE_BOOL:
 case AV_OPT_TYPE_FLAGS:
 case AV_OPT_TYPE_INT:
+case AV_OPT_TYPE_UINT:
 *(int *)dst = llrint(num / den) * intnum;
 break;
 case AV_OPT_TYPE_DURATION:
@@ -319,6 +324,7 @@ static int set_string(void *obj, const AVOption *o, const 
char *val, uint8_t **d
   opt->type == AV_OPT_TYPE_UINT64 || \
   opt->type == AV_OPT_TYPE_CONST || \
   opt->type == AV_OPT_TYPE_FLAGS || \
+  opt->type == AV_OPT_TYPE_UINT  || \
   opt->type == AV_OPT_TYPE_INT) \
  ? opt->default_val.i64 \
  : opt->default_val.dbl)
@@ -605,6 +611,7 @@ static int opt_set_elem(void *obj, void *target_obj, const 
AVOption *o,
 return set_string_binary(obj, o, val, dst);
 case AV_OPT_TYPE_FLAGS:
 case AV_OPT_TYPE_INT:
+case AV_OPT_TYPE_UINT:
 case AV_OPT_TYPE_INT64:
 case AV_OPT_TYPE_UINT64:
 case AV_OPT_TYPE_FLOAT:
@@ -767,6 +774,7 @@ int av_opt_eval_ ## name(void *obj, const AVOption *o,  
\
 
 OPT_EVAL_NUMBER(flags,  AV_OPT_TYPE_FLAGS,int)
 OPT_EVAL_NUMBER(int,AV_OPT_TYPE_INT,  int)
+OPT_EVAL_NUMBER(uint,   AV_OPT_TYPE_UINT, unsigned)
 OPT_EVAL_NUMBER(int64,  AV_OPT_TYPE_INT64,int64_t)
 OPT_EVAL_NUMBER(float,  AV_OPT_TYPE_FLOAT,float)
 OPT_EVAL_NUMBER(double, AV_OPT_TYPE_DOUBLE,   double)
@@ -997,6 +1005,9 @@ static int opt_get_elem(const AVOption *o, uint8_t **pbuf, 
size_t buf_len,
 case AV_OPT_TYPE_INT:
 ret = snprintf(*pbuf, buf_len, "%d", *(int *)dst);
 break;
+case AV_OPT_TYPE_UINT:
+ret = snprintf(*pbuf, buf_len, "%u", *(unsigned *)dst);
+break;
 case AV_OPT_TYPE_INT64:
 ret = snprintf(*pbuf, buf_len, "%"PRId64, *(int64_t *)dst);
 break;
@@ -1444,6 +1455,7 @@ static void log_type(void *av_log_obj, const AVOption *o,
 [AV_OPT_TYPE_FLAGS] = "",
 [AV_OPT_TYPE_INT]   = "",
 [AV_OPT_TYPE_INT64] = "",
+[AV_OPT_TYPE_UINT]  = "",
 [AV_OPT_TYPE_UINT64]= "",
 [AV_OPT_TYPE_DOUBLE]= "",
 [AV_OPT_TYPE_FLOAT] = "",
@@ -1515,6 +1527,7 @@ static void log_default(void *obj, void *av_log_obj, 
const AVOption *opt)
 av_log(av_log_obj, AV_LOG_INFO, "%s", buf);
 break;
 }
+case AV_OPT_TYPE_UINT:
 case AV_OPT_TYPE_INT:
 case AV_OPT_TYPE_UINT64:
 case AV_OPT_TYPE_INT64: {
@@ -1600,6 +1613,7 @@ static void opt_list(void *obj, void *av_log_obj, const 
char *unit,
 if (av_opt_query_ranges(, obj, opt->name, AV_OPT_SEARCH_FAKE_OBJ) >= 
0) {
 switch

[FFmpeg-cvslog] avutil/tests/opt: test values > INT_MAX for INT64 type

2024-05-04 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Feb 27 17:30:39 
2024 -0300| [9902fc550aec7215723e441edbe02f4dc40e6089] | committer: James Almer

avutil/tests/opt: test values > INT_MAX for INT64 type

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9902fc550aec7215723e441edbe02f4dc40e6089
---

 libavutil/tests/opt.c |  5 +++--
 tests/ref/fate/opt| 25 ++---
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/libavutil/tests/opt.c b/libavutil/tests/opt.c
index 58d5970cc4..7842b0567d 100644
--- a/libavutil/tests/opt.c
+++ b/libavutil/tests/opt.c
@@ -105,7 +105,7 @@ static const AVOption test_options[]= {
 {"bin","set binary value",   OFFSET(binary), 
AV_OPT_TYPE_BINARY, { .str="62696e00" },   0, 0, 1 
},
 {"bin1",   "set binary value",   OFFSET(binary1),
AV_OPT_TYPE_BINARY, { .str=NULL }, 0, 0, 1 
},
 {"bin2",   "set binary value",   OFFSET(binary2),
AV_OPT_TYPE_BINARY, { .str="" },   0, 0, 1 
},
-{"num64",  "set num 64bit",  OFFSET(num64),  
AV_OPT_TYPE_INT64,  { .i64 = 1 }, -1,   100, 1 
},
+{"num64",  "set num 64bit",  OFFSET(num64),  
AV_OPT_TYPE_INT64,  { .i64 = 1LL << 32 }, -1, 1LL << 32, 1 
},
 {"flt","set float",  OFFSET(flt),
AV_OPT_TYPE_FLOAT,  { .dbl = 1.0 / 3 },0,   100, 1 
},
 {"dbl","set double", OFFSET(dbl),
AV_OPT_TYPE_DOUBLE, { .dbl = 1.0 / 3 },0,   100, 1 
},
 {"bool1",  "set boolean value",  OFFSET(bool1),  
AV_OPT_TYPE_BOOL,   { .i64 = -1 },-1, 1, 1 
},
@@ -391,7 +391,8 @@ int main(void)
 "num64=44.4",
 "num64=-1",
 "num64=-2",
-"num64=101",
+"num64=4294967296",
+"num64=4294967297",
 "flt=bogus",
 "flt=2",
 "flt=2.2",
diff --git a/tests/ref/fate/opt b/tests/ref/fate/opt
index e90ec73e62..4e6112c8c5 100644
--- a/tests/ref/fate/opt
+++ b/tests/ref/fate/opt
@@ -14,7 +14,7 @@ color=255 192 203 255
 channel_layout=311=311
 binary=62 69 6e 0
 binary_size=4
-num64=1
+num64=4294967296
 flt=0.33
 dbl=0.33
 array_str[0]=str0
@@ -43,7 +43,7 @@ TestContext AVOptions:
   -binE.. set binary value
   -bin1   E.. set binary value
   -bin2   E.. set binary value
-  -num64   E.. set num 64bit (from -1 to 100) 
(default 1)
+  -num64   E.. set num 64bit (from -1 to 
4.29497e+09) (default 4294967296)
   -flt E.. set float (from 0 to 100) 
(default 0.33)
   -dblE.. set double (from 0 to 100) 
(default 0.33)
   -bool1 E.. set boolean value (default auto)
@@ -134,7 +134,7 @@ name: cl  get: hexagonalset: OK 
  get: hexagonal
 name: bin get: 62696E00 set: OK   get: 62696E00
 OK
 name: bin1get:  set: OK   get: 
 OK
 name: bin2get:  set: OK   get: 
 OK
-name: num64   get: 1set: OK   get: 1   
 OK
+name: num64   get: 4294967296   set: OK   get: 4294967296  
 OK
 name: flt get: 0.33 set: OK   get: 0.33
 OK
 name: dbl get: 0.33 set: OK   get: 0.33
 OK
 name: bool1   get: auto set: OK   get: auto
 OK
@@ -150,7 +150,7 @@ array_dict=NULL; nb_array_dict=0
 av_opt_get("array_dict") -> NULL
 
 Test av_opt_serialize()
-num=0,toggle=1,rational=1/1,string=default,escape=\\\=\,,flags=0x0001,size=200x300,pix_fmt=0bgr,sample_fmt=s16,video_rate=25/1,duration=0.001,color=0xffc0cbff,cl=hexagonal,bin=62696E00,bin1=,bin2=,num64=1,flt=0.33,dbl=0.33,bool1=auto,bool2=true,bool3=false,dict1=,dict2=happy\=\\:-),array_int=,array_str=str0|str\\|1|str2,array_dict=k00\=v00:k01\=v\\\,01\,k10\=v\=1:0
+num=0,toggle=1,rational=1/1,string=default,escape=\\\=\,,flags=0x0001,size=200x300,pix_fmt=0bgr,sample_fmt=s16,video_rate=25/1,duration=0.001,color=0xffc0cbff,cl=hexagonal,bin=62696E00,bin1=,bin2=,num64=4294967296,flt=0.33,dbl=0.33,bool1=auto,b

[FFmpeg-cvslog] avutil/tests/opt: test negative values for INT and INT64 types

2024-05-04 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Feb 27 10:59:46 
2024 -0300| [72ac4959606048343589efd282dd36b5dc9793e8] | committer: James Almer

avutil/tests/opt: test negative values for INT and INT64 types

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=72ac4959606048343589efd282dd36b5dc9793e8
---

 libavutil/tests/opt.c | 11 +--
 tests/ref/fate/opt| 35 ++-
 2 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/libavutil/tests/opt.c b/libavutil/tests/opt.c
index abe1b0dee4..58d5970cc4 100644
--- a/libavutil/tests/opt.c
+++ b/libavutil/tests/opt.c
@@ -86,7 +86,7 @@ static const AVOptionArrayDef array_dict = {
 };
 
 static const AVOption test_options[]= {
-{"num","set num",OFFSET(num),
AV_OPT_TYPE_INT,{ .i64 = 0 },  0,   100, 1 
},
+{"num","set num",OFFSET(num),
AV_OPT_TYPE_INT,{ .i64 = 0 }, -1,   100, 1 
},
 {"toggle", "set toggle", OFFSET(toggle), 
AV_OPT_TYPE_INT,{ .i64 = 1 },  0, 1, 1 
},
 {"rational",   "set rational",   OFFSET(rational),   
AV_OPT_TYPE_RATIONAL,   { .dbl = 1 },  0,10, 1 
},
 {"string", "set string", OFFSET(string), 
AV_OPT_TYPE_STRING, { .str = "default" },   CHAR_MIN,  CHAR_MAX, 1 
},
@@ -105,7 +105,7 @@ static const AVOption test_options[]= {
 {"bin","set binary value",   OFFSET(binary), 
AV_OPT_TYPE_BINARY, { .str="62696e00" },   0, 0, 1 
},
 {"bin1",   "set binary value",   OFFSET(binary1),
AV_OPT_TYPE_BINARY, { .str=NULL }, 0, 0, 1 
},
 {"bin2",   "set binary value",   OFFSET(binary2),
AV_OPT_TYPE_BINARY, { .str="" },   0, 0, 1 
},
-{"num64",  "set num 64bit",  OFFSET(num64),  
AV_OPT_TYPE_INT64,  { .i64 = 1 },  0,   100, 1 
},
+{"num64",  "set num 64bit",  OFFSET(num64),  
AV_OPT_TYPE_INT64,  { .i64 = 1 }, -1,   100, 1 
},
 {"flt","set float",  OFFSET(flt),
AV_OPT_TYPE_FLOAT,  { .dbl = 1.0 / 3 },0,   100, 1 
},
 {"dbl","set double", OFFSET(dbl),
AV_OPT_TYPE_DOUBLE, { .dbl = 1.0 / 3 },0,   100, 1 
},
 {"bool1",  "set boolean value",  OFFSET(bool1),  
AV_OPT_TYPE_BOOL,   { .i64 = -1 },-1, 1, 1 
},
@@ -380,10 +380,17 @@ int main(void)
 "bin=boguss",
 "bin=111",
 "bin=",
+"num=bogus",
+"num=44",
+"num=44.4",
+"num=-1",
+"num=-2",
+"num=101",
 "num64=bogus",
 "num64=44",
 "num64=44.4",
 "num64=-1",
+"num64=-2",
 "num64=101",
 "flt=bogus",
 "flt=2",
diff --git a/tests/ref/fate/opt b/tests/ref/fate/opt
index 0a3362e8fa..e90ec73e62 100644
--- a/tests/ref/fate/opt
+++ b/tests/ref/fate/opt
@@ -24,7 +24,7 @@ array_dict[0]: k00v\00
 array_dict[0]: k01 v,01
 array_dict[1]: k10 v=1:0
 TestContext AVOptions:
-  -num   E.. set num (from 0 to 100) (default 
0)
+  -num   E.. set num (from -1 to 100) 
(default 0)
   -toggleE.. set toggle (from 0 to 1) 
(default 1)
   -rational E.. set rational (from 0 to 10) 
(default 1/1)
   -string E.. set string (default "default")
@@ -43,7 +43,7 @@ TestContext AVOptions:
   -binE.. set binary value
   -bin1   E.. set binary value
   -bin2   E.. set binary value
-  -num64   E.. set num 64bit (from 0 to 100) 
(default 1)
+  -num64   E.. set num 64bit (from -1 to 100) 
(default 1)
   -flt E.. set float (from 0 to 100) 
(default 0.33)
   -dblE.. set double (from 0 to 100) 
(default 0.33)
   -bool1 E.. set boolean value (default auto)
@@ -337,6 +337,

[FFmpeg-cvslog] avutil/iamf: fix offsets for mix_gain options

2024-05-04 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat May  4 21:20:35 
2024 -0300| [d6e877bbcde2a0d1422d7b5c7339bb03891d19fc] | committer: James Almer

avutil/iamf: fix offsets for mix_gain options

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d6e877bbcde2a0d1422d7b5c7339bb03891d19fc
---

 libavutil/iamf.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavutil/iamf.c b/libavutil/iamf.c
index c96100e7a0..14f49cba93 100644
--- a/libavutil/iamf.c
+++ b/libavutil/iamf.c
@@ -66,10 +66,10 @@ child_type *av_iamf_ ## parent_name ## _add_ ## 
child_name(parent_type *parent_n
 static const AVOption mix_gain_options[] = {
 { "subblock_duration", "set subblock_duration", OFFSET(subblock_duration), 
AV_OPT_TYPE_INT, {.i64 = 1 }, 1, UINT_MAX, FLAGS },
 { "animation_type", "set animation_type", OFFSET(animation_type), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FLAGS },
-{ "start_point_value", "set start_point_value", OFFSET(animation_type), 
AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS },
-{ "end_point_value", "set end_point_value", OFFSET(animation_type), 
AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS },
-{ "control_point_value", "set control_point_value", 
OFFSET(animation_type), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS 
},
-{ "control_point_relative_time", "set control_point_relative_time", 
OFFSET(animation_type), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, 0.0, 1.0, FLAGS },
+{ "start_point_value", "set start_point_value", OFFSET(start_point_value), 
AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS },
+{ "end_point_value", "set end_point_value", OFFSET(end_point_value), 
AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS },
+{ "control_point_value", "set control_point_value", 
OFFSET(control_point_value), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, 
FLAGS },
+{ "control_point_relative_time", "set control_point_relative_time", 
OFFSET(control_point_relative_time), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, 0.0, 
1.0, FLAGS },
 { NULL },
 };
 

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

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


[FFmpeg-cvslog] avcodec/avcodec: free decoded_side_data in ff_codec_close()

2024-05-02 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed May  1 12:01:48 
2024 -0300| [86e418ffd7bbdc0530e1e4d5bd7534b6e03b5b05] | committer: James Almer

avcodec/avcodec: free decoded_side_data in ff_codec_close()

It's set by the library when decoding, so it should be freed when closing the
context.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=86e418ffd7bbdc0530e1e4d5bd7534b6e03b5b05
---

 libavcodec/avcodec.c | 2 ++
 libavcodec/options.c | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 888dd76228..214dca4566 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -462,6 +462,8 @@ av_cold void ff_codec_close(AVCodecContext *avctx)
 av_freep(>coded_side_data[i].data);
 av_freep(>coded_side_data);
 avctx->nb_coded_side_data = 0;
+av_frame_side_data_free(>decoded_side_data,
+>nb_decoded_side_data);
 
 av_buffer_unref(>hw_frames_ctx);
 av_buffer_unref(>hw_device_ctx);
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 0c3b40a186..f60c41bdc3 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -177,8 +177,6 @@ void avcodec_free_context(AVCodecContext **pavctx)
 av_freep(>inter_matrix);
 av_freep(>rc_override);
 av_channel_layout_uninit(>ch_layout);
-av_frame_side_data_free(
->decoded_side_data, >nb_decoded_side_data);
 
 av_freep(pavctx);
 }

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

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


[FFmpeg-cvslog] avformat/iamf_writer: reject duplicated stream ids in a stream group

2024-05-01 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Mon Apr 15 
18:06:01 2024 -0300| [5683aa6318d9e26f0d94002eaf2be71b79afe96c] | committer: 
James Almer

avformat/iamf_writer: reject duplicated stream ids in a stream group

Signed-off-by: James Almer 
(cherry picked from commit 6b6a0fc53df592183c69e518967841272ab4e862)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5683aa6318d9e26f0d94002eaf2be71b79afe96c
---

 libavformat/iamf_writer.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c
index 37ec8e732a..6d4e4082eb 100644
--- a/libavformat/iamf_writer.c
+++ b/libavformat/iamf_writer.c
@@ -275,6 +275,17 @@ int ff_iamf_add_audio_element(IAMFContext *iamf, const 
AVStreamGroup *stg, void
 }
 }
 
+for (int i = 0; i < audio_element->nb_substreams; i++) {
+for (int j = i + 1; j < audio_element->nb_substreams; j++)
+if (audio_element->substreams[i].audio_substream_id ==
+audio_element->substreams[j].audio_substream_id) {
+av_log(log_ctx, AV_LOG_ERROR, "Duplicate id %u in streams %u 
and %u from stream group %u\n",
+   audio_element->substreams[i].audio_substream_id, i, j, 
stg->index);
+ret = AVERROR(EINVAL);
+goto fail;
+}
+}
+
 if (iamf_audio_element->demixing_info) {
 AVIAMFParamDefinition *param = iamf_audio_element->demixing_info;
 const IAMFParamDefinition *param_definition = 
ff_iamf_get_param_definition(iamf, param->parameter_id);

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

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


[FFmpeg-cvslog] avformat/mov: free the infe allocated item data on failure

2024-05-01 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Fri Apr 26 
21:26:01 2024 -0300| [1e6382a6b78883e4e7597dadb20f066870b21845] | committer: 
James Almer

avformat/mov: free the infe allocated item data on failure

Fixes: memleak
Fixes: 
68212/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4963488540721152

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Tested-by: Michael Niedermayer 
Signed-off-by: James Almer 
(cherry picked from commit e09164940e4ff0b0ee9228f9d27385211160c6da)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1e6382a6b78883e4e7597dadb20f066870b21845
---

 libavformat/mov.c | 31 +--
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 056890c85b..6e3178f7c8 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -83,6 +83,7 @@ typedef struct MOVParseTableEntry {
 
 static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom);
 static int mov_read_mfra(MOVContext *c, AVIOContext *f);
+static void mov_free_stream_context(AVFormatContext *s, AVStream *st);
 static int64_t add_ctts_entry(MOVCtts** ctts_data, unsigned int* ctts_count, 
unsigned int* allocated_size,
   int count, int duration);
 
@@ -8131,6 +8132,7 @@ static int mov_read_infe(MOVContext *c, AVIOContext *pb, 
MOVAtom atom, int idx)
 
 if (version < 2) {
 avpriv_report_missing_feature(c->fc, "infe version < 2");
+avio_skip(pb, size);
 return 1;
 }
 
@@ -8174,7 +8176,7 @@ static int mov_read_iinf(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 {
 HEIFItem *heif_item;
 int entry_count;
-int version, ret;
+int version, got_stream = 0, ret, i;
 
 if (c->found_iinf) {
 av_log(c->fc, AV_LOG_WARNING, "Duplicate iinf box found\n");
@@ -8194,20 +8196,33 @@ static int mov_read_iinf(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
sizeof(*c->heif_item) * (entry_count - c->nb_heif_item));
 c->nb_heif_item = FFMAX(c->nb_heif_item, entry_count);
 
-for (int i = 0; i < entry_count; i++) {
+for (i = 0; i < entry_count; i++) {
 MOVAtom infe;
 
 infe.size = avio_rb32(pb) - 8;
 infe.type = avio_rl32(pb);
 ret = mov_read_infe(c, pb, infe, i);
 if (ret < 0)
-return ret;
-if (ret)
-return 0;
+goto fail;
+if (!ret)
+got_stream = 1;
 }
 
-c->found_iinf = 1;
+c->found_iinf = got_stream;
 return 0;
+fail:
+for (; i >= 0; i--) {
+HEIFItem *item = >heif_item[i];
+
+av_freep(>name);
+if (!item->st)
+continue;
+
+mov_free_stream_context(c->fc, item->st);
+ff_remove_stream(c->fc, item->st);
+item->st = NULL;
+}
+return ret;
 }
 
 static int mov_read_iref_dimg(MOVContext *c, AVIOContext *pb, int version)
@@ -9550,6 +9565,10 @@ static int mov_read_header(AVFormatContext *s)
 return err;
 }
 }
+// prevent iloc and iinf boxes from being parsed while reading packets.
+// this is needed because an iinf box may have been parsed but ignored
+// for having old infe boxes which create no streams.
+mov->found_iloc = mov->found_iinf = 1;
 
 if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
 if (mov->nb_chapter_tracks > 0 && !mov->ignore_chapters)

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

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


[FFmpeg-cvslog] avformat/mov: free the infe allocated item data on failure

2024-04-30 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Apr 26 21:26:01 
2024 -0300| [e09164940e4ff0b0ee9228f9d27385211160c6da] | committer: James Almer

avformat/mov: free the infe allocated item data on failure

Fixes: memleak
Fixes: 
68212/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4963488540721152

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Tested-by: Michael Niedermayer 
Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e09164940e4ff0b0ee9228f9d27385211160c6da
---

 libavformat/mov.c | 31 +--
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f903be216d..e8da6c2d65 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -84,6 +84,7 @@ typedef struct MOVParseTableEntry {
 
 static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom);
 static int mov_read_mfra(MOVContext *c, AVIOContext *f);
+static void mov_free_stream_context(AVFormatContext *s, AVStream *st);
 static int64_t add_ctts_entry(MOVCtts** ctts_data, unsigned int* ctts_count, 
unsigned int* allocated_size,
   int count, int duration);
 
@@ -8160,6 +8161,7 @@ static int mov_read_infe(MOVContext *c, AVIOContext *pb, 
MOVAtom atom, int idx)
 
 if (version < 2) {
 avpriv_report_missing_feature(c->fc, "infe version < 2");
+avio_skip(pb, size);
 return 1;
 }
 
@@ -8203,7 +8205,7 @@ static int mov_read_iinf(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 {
 HEIFItem *heif_item;
 int entry_count;
-int version, ret;
+int version, got_stream = 0, ret, i;
 
 if (c->found_iinf) {
 av_log(c->fc, AV_LOG_WARNING, "Duplicate iinf box found\n");
@@ -8223,20 +8225,33 @@ static int mov_read_iinf(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
sizeof(*c->heif_item) * (entry_count - c->nb_heif_item));
 c->nb_heif_item = FFMAX(c->nb_heif_item, entry_count);
 
-for (int i = 0; i < entry_count; i++) {
+for (i = 0; i < entry_count; i++) {
 MOVAtom infe;
 
 infe.size = avio_rb32(pb) - 8;
 infe.type = avio_rl32(pb);
 ret = mov_read_infe(c, pb, infe, i);
 if (ret < 0)
-return ret;
-if (ret)
-return 0;
+goto fail;
+if (!ret)
+got_stream = 1;
 }
 
-c->found_iinf = 1;
+c->found_iinf = got_stream;
 return 0;
+fail:
+for (; i >= 0; i--) {
+HEIFItem *item = >heif_item[i];
+
+av_freep(>name);
+if (!item->st)
+continue;
+
+mov_free_stream_context(c->fc, item->st);
+ff_remove_stream(c->fc, item->st);
+item->st = NULL;
+}
+return ret;
 }
 
 static int mov_read_iref_dimg(MOVContext *c, AVIOContext *pb, int version)
@@ -9583,6 +9598,10 @@ static int mov_read_header(AVFormatContext *s)
 return err;
 }
 }
+// prevent iloc and iinf boxes from being parsed while reading packets.
+// this is needed because an iinf box may have been parsed but ignored
+// for having old infe boxes which create no streams.
+mov->found_iloc = mov->found_iinf = 1;
 
 if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
 if (mov->nb_chapter_tracks > 0 && !mov->ignore_chapters)

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

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


[FFmpeg-cvslog] avformat/mov: support SpatialAudioBox ambisonic layouts with non-diegetic channels

2024-04-30 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Apr 26 11:50:09 
2024 -0300| [b7debef3cc84fc4cd68a39d37c8f347c8966dc69] | committer: James Almer

avformat/mov: support SpatialAudioBox ambisonic layouts with non-diegetic 
channels

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7debef3cc84fc4cd68a39d37c8f347c8966dc69
---

 libavformat/mov.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index d99c971999..f903be216d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7928,6 +7928,7 @@ static int mov_read_SA3D(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 AVChannelLayout ch_layout = { 0 };
 int ret, i, version, type;
 int ambisonic_order, channel_order, normalization, channel_count;
+int ambi_channels, non_diegetic_channels;
 
 if (c->fc->nb_streams < 1)
 return 0;
@@ -7946,11 +7947,12 @@ static int mov_read_SA3D(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 }
 
 type = avio_r8(pb);
-if (type) {
+if (type & 0x7f) {
 av_log(c->fc, AV_LOG_WARNING,
-   "Unsupported ambisonic type %d\n", type);
+   "Unsupported ambisonic type %d\n", type & 0x7f);
 return 0;
 }
+non_diegetic_channels = (type >> 7) * 2; // head_locked_stereo
 
 ambisonic_order = avio_rb32(pb);
 
@@ -7970,12 +7972,14 @@ static int mov_read_SA3D(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 
 channel_count = avio_rb32(pb);
 if (ambisonic_order < 0 || ambisonic_order > 31 ||
-channel_count != (ambisonic_order + 1LL) * (ambisonic_order + 1LL)) {
+channel_count != ((ambisonic_order + 1LL) * (ambisonic_order + 1LL) +
+   non_diegetic_channels)) {
 av_log(c->fc, AV_LOG_ERROR,
"Invalid number of channels (%d / %d)\n",
channel_count, ambisonic_order);
 return 0;
 }
+ambi_channels = channel_count - non_diegetic_channels;
 
 ret = av_channel_layout_custom_init(_layout, channel_count);
 if (ret < 0)
@@ -7990,7 +7994,10 @@ static int mov_read_SA3D(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 av_channel_layout_uninit(_layout);
 return 0;
 }
-ch_layout.u.map[i].id = AV_CHAN_AMBISONIC_BASE + channel;
+if (channel >= ambi_channels)
+ch_layout.u.map[i].id = channel - ambi_channels;
+else
+ch_layout.u.map[i].id = AV_CHAN_AMBISONIC_BASE + channel;
 }
 
 ret = av_channel_layout_retype(_layout, 0, 
AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL);

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

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


[FFmpeg-cvslog] avformat/mov: support SpatialAudioBox ambisonic layouts with arbitrary channel mapping

2024-04-30 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Apr 26 11:37:10 
2024 -0300| [37c8d93e56955638983d48e04f08d767eae265e1] | committer: James Almer

avformat/mov: support SpatialAudioBox ambisonic layouts with arbitrary channel 
mapping

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=37c8d93e56955638983d48e04f08d767eae265e1
---

 libavformat/mov.c | 29 ++---
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index ede25d3342..d99c971999 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7925,7 +7925,8 @@ cleanup:
 static int mov_read_SA3D(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 AVStream *st;
-int i, version, type;
+AVChannelLayout ch_layout = { 0 };
+int ret, i, version, type;
 int ambisonic_order, channel_order, normalization, channel_count;
 
 if (c->fc->nb_streams < 1)
@@ -7968,24 +7969,38 @@ static int mov_read_SA3D(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 }
 
 channel_count = avio_rb32(pb);
-if (ambisonic_order < 0 || channel_count != (ambisonic_order + 1LL) * 
(ambisonic_order + 1LL)) {
+if (ambisonic_order < 0 || ambisonic_order > 31 ||
+channel_count != (ambisonic_order + 1LL) * (ambisonic_order + 1LL)) {
 av_log(c->fc, AV_LOG_ERROR,
"Invalid number of channels (%d / %d)\n",
channel_count, ambisonic_order);
 return 0;
 }
 
+ret = av_channel_layout_custom_init(_layout, channel_count);
+if (ret < 0)
+return 0;
+
 for (i = 0; i < channel_count; i++) {
-if (i != avio_rb32(pb)) {
-av_log(c->fc, AV_LOG_WARNING,
-   "Ambisonic channel reordering is not supported\n");
+unsigned channel = avio_rb32(pb);
+
+if (channel >= channel_count) {
+av_log(c->fc, AV_LOG_ERROR, "Invalid channel index (%d / %d)\n",
+   channel, ambisonic_order);
+av_channel_layout_uninit(_layout);
 return 0;
 }
+ch_layout.u.map[i].id = AV_CHAN_AMBISONIC_BASE + channel;
+}
+
+ret = av_channel_layout_retype(_layout, 0, 
AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL);
+if (ret < 0) {
+av_channel_layout_uninit(_layout);
+return 0;
 }
 
 av_channel_layout_uninit(>codecpar->ch_layout);
-st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_AMBISONIC;
-st->codecpar->ch_layout.nb_channels = channel_count;
+st->codecpar->ch_layout = ch_layout;
 
 return 0;
 }

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

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


[FFmpeg-cvslog] avformat/mov: don't read key_size bytes twice in the keys atom

2024-04-29 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Mon Apr  1 
23:54:53 2024 -0300| [fb8f0ea7b31d78e8a14d79549a76fd71de390907] | committer: 
James Almer

avformat/mov: don't read key_size bytes twice in the keys atom

We only support mdta as type, yet we were not skipping other types,
but rather reading key_size worth of bytes twice per entry.

Signed-off-by: James Almer 
(cherry picked from commit 5a06d3810e41134ee9c2941cc0b371da62b539db)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fb8f0ea7b31d78e8a14d79549a76fd71de390907
---

 libavformat/mov.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index d551a0f8e0..056890c85b 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5048,6 +5048,7 @@ static int mov_read_keys(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 key_size -= 8;
 if (type != MKTAG('m','d','t','a')) {
 avio_skip(pb, key_size);
+continue;
 }
 c->meta_keys[i] = av_mallocz(key_size + 1);
 if (!c->meta_keys[i])

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

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


[FFmpeg-cvslog] avformat/mov: take into account the first eight bytes in the keys atom

2024-04-29 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Mon Apr  1 
23:52:53 2024 -0300| [0085da21b4ca67d9c1d4423d081f7139ba666dea] | committer: 
James Almer

avformat/mov: take into account the first eight bytes in the keys atom

Signed-off-by: James Almer 
(cherry picked from commit 3d12ba77d9a4660b2e71889d1c2f99e8f3ade98b)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0085da21b4ca67d9c1d4423d081f7139ba666dea
---

 libavformat/mov.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 9291195a8f..d551a0f8e0 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5023,6 +5023,7 @@ static int mov_read_keys(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 avio_skip(pb, 4);
 count = avio_rb32(pb);
+atom.size -= 8;
 if (count > UINT_MAX / sizeof(*c->meta_keys) - 1) {
 av_log(c->fc, AV_LOG_ERROR,
"The 'keys' atom with the invalid key count: %"PRIu32"\n", 
count);

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

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


[FFmpeg-cvslog] avformat/mov: fix the check for the heif item parsing loop

2024-04-29 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Sat Apr 27 
19:38:13 2024 -0300| [64a048d4cc0a2806c29348012165dea0c6a08613] | committer: 
James Almer

avformat/mov: fix the check for the heif item parsing loop

Fixes: Null pointer dereference
Fixes: 
67861/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5352628142800896

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer 
(cherry picked from commit 31327c2d075a413749c1461c06382993b9bba90e)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=64a048d4cc0a2806c29348012165dea0c6a08613
---

 libavformat/mov.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index d9009f2eab..9291195a8f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -9427,7 +9427,8 @@ static int mov_parse_tiles(AVFormatContext *s)
 break;
 }
 
-if (k == grid->nb_tiles) {
+if (k == mov->nb_heif_item) {
+av_assert0(loop);
 av_log(s, AV_LOG_WARNING, "HEIF item id %d referenced by grid 
id %d doesn't "
   "exist\n",
tile_id, grid->item->item_id);

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

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


[FFmpeg-cvslog] avformat/mov: fix the check for the heif item parsing loop

2024-04-27 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Apr 27 19:38:13 
2024 -0300| [31327c2d075a413749c1461c06382993b9bba90e] | committer: James Almer

avformat/mov: fix the check for the heif item parsing loop

Fixes: Null pointer dereference
Fixes: 
67861/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5352628142800896

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=31327c2d075a413749c1461c06382993b9bba90e
---

 libavformat/mov.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index ecd29a7d08..ede25d3342 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -9440,7 +9440,8 @@ static int mov_parse_tiles(AVFormatContext *s)
 break;
 }
 
-if (k == grid->nb_tiles) {
+if (k == mov->nb_heif_item) {
+av_assert0(loop);
 av_log(s, AV_LOG_WARNING, "HEIF item id %d referenced by grid 
id %d doesn't "
   "exist\n",
tile_id, grid->item->item_id);

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

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


[FFmpeg-cvslog] fate/iamf: don't demux packets in fate-iamf-5_1-{copy,demux}

2024-04-25 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu Apr 25 09:34:37 
2024 -0300| [5fc4a824db166823cd40eb8e16bce2a92af7abfd] | committer: James Almer

fate/iamf: don't demux packets in fate-iamf-5_1-{copy,demux}

They contain side data whose size is arch dependent.
This fixes fate failures on 32bit targets.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5fc4a824db166823cd40eb8e16bce2a92af7abfd
---

 tests/fate/iamf.mak   |   4 +-
 tests/ref/fate/iamf-5_1-copy  | 104 --
 tests/ref/fate/iamf-5_1-demux | 104 --
 3 files changed, 2 insertions(+), 210 deletions(-)

diff --git a/tests/fate/iamf.mak b/tests/fate/iamf.mak
index 394de0a904..164fd78bf6 100644
--- a/tests/fate/iamf.mak
+++ b/tests/fate/iamf.mak
@@ -39,12 +39,12 @@ fate-iamf-ambisonic_1: CMD = transcode wav $(SRC) iamf 
"-auto_conversion_filters
 
 FATE_IAMF_SAMPLES-$(call FRAMECRC, IAMF, OPUS) += fate-iamf-5_1-demux
 fate-iamf-5_1-demux: CMD = stream_demux iamf 
$(TARGET_SAMPLES)/iamf/test_59.iamf "" \
-  "-c:a copy -map 0" \
+  "-c:a copy -frames:a 0 -map 0" \
   "-show_entries 
stream_group=index,id,nb_streams,type:stream_group_components:stream_group_stream=index,id:stream_group_stream_disposition"
 
 FATE_IAMF_SAMPLES-$(call REMUX, IAMF, OPUS_DECODER) += fate-iamf-5_1-copy
 fate-iamf-5_1-copy: CMD = stream_remux iamf 
$(TARGET_SAMPLES)/iamf/test_59.iamf "" iamf \
-  "-map 0 -stream_group map=0=0:st=0:st=1:st=2:st=3 -stream_group 
map=0=1:stg=0 -streamid 0:0 -streamid 1:1 -streamid 2:2 -streamid 3:3" "" "-c:a 
copy -map 0" \
+  "-map 0 -stream_group map=0=0:st=0:st=1:st=2:st=3 -stream_group 
map=0=1:stg=0 -streamid 0:0 -streamid 1:1 -streamid 2:2 -streamid 3:3" "" "-c:a 
copy -frames:a 0 -map 0" \
   "-show_entries 
stream_group=index,id,nb_streams,type:stream_group_components:stream_group_stream=index,id:stream_group_stream_disposition"
 
 FATE_IAMF += $(FATE_IAMF-yes)
diff --git a/tests/ref/fate/iamf-5_1-copy b/tests/ref/fate/iamf-5_1-copy
index 1f0b67b1f7..d3530702ee 100644
--- a/tests/ref/fate/iamf-5_1-copy
+++ b/tests/ref/fate/iamf-5_1-copy
@@ -22,110 +22,6 @@
 #codec_id 3: opus
 #sample_rate 3: 48000
 #channel_layout_name 3: mono
-0,  0,  0,  960,  371, 0x552eba36, S=3,   10,  
 96,  136
-1,  0,  0,  960,  381, 0x6779b329, S=3,   10,  
 96,  136
-2,  0,  0,  960,   66, 0x4ce02142, S=3,   10,  
 96,  136
-3,  0,  0,  960,   67, 0x935223f9, S=3,   10,  
 96,  136
-0,960,960,  960,  313, 0xa5e19a4f, S=2,   96,  
136
-1,960,960,  960,  339, 0xf83daf6a, S=2,   96,  
136
-2,960,960,  960,   62, 0x80c91ca8, S=2,   96,  
136
-3,960,960,  960,   64, 0xaae41dd7, S=2,   96,  
136
-0,   1920,   1920,  960,  210, 0x5fc26f7a, S=2,   96,  
136
-1,   1920,   1920,  960,  207, 0xc8c768e8, S=2,   96,  
136
-2,   1920,   1920,  960,   75, 0x85012598, S=2,   96,  
136
-3,   1920,   1920,  960,   94, 0x5dc52d3b, S=2,   96,  
136
-0,   2880,   2880,  960,  211, 0x8f006c62, S=2,   96,  
136
-1,   2880,   2880,  960,  215, 0x30c8674d, S=2,   96,  
136
-2,   2880,   2880,  960,   88, 0x46772b87, S=2,   96,  
136
-3,   2880,   2880,  960,  105, 0x831c3191, S=2,   96,  
136
-0,   3840,   3840,  960,  340, 0x3c92a527, S=2,   96,  
136
-1,   3840,   3840,  960,  303, 0x65e09e91, S=2,   96,  
136
-2,   3840,   3840,  960,  121, 0xc45d3ec1, S=2,   96,  
136
-3,   3840,   3840,  960,  126, 0xff3a44d7, S=2,   96,  
136
-0,   4800,   4800,  960,  206, 0x3087662a, S=2,   96,  
136
-1,   4800,   4800,  960,  206, 0xd2b469de, S=2,   96,  
136
-2,   4800,   4800,  960,  124, 0xd9423baf, S=2,   96,  
136
-3,   4800,   4800,  960,  121, 0x24073ab0, S=2,   96,  
136
-0,   5760,   5760,  960,  212, 0x85686b01, S=2,   96,  
136
-1,   5760,   5760,  960,  230, 0x7ce56f22, S=2,   96,  
136
-2,   5760,   5760,  960,  128, 0xca6840ad, S=2,   96,  
136
-3,   5760,   5760,  960,  138, 0xa1f24207, S=2,   96,  
136
-0,   6720,   6720,  960,  220, 0xd40572ca, S=2,   96,  
136
-1,   6720,   6720,  960,  223, 0x760c74ce, S=2,   96,  
136
-2,   6720,

[FFmpeg-cvslog] avutil/iamf: fix mix_gain_class name

2024-04-24 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Wed Apr 24 
17:35:36 2024 -0300| [96d941b30ea1d7195ee13dbab192984efb5572b7] | committer: 
James Almer

avutil/iamf: fix mix_gain_class name

Signed-off-by: James Almer 
(cherry picked from commit b9af58184fd3bf6438924ce7e827ed198e517f7f)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=96d941b30ea1d7195ee13dbab192984efb5572b7
---

 libavutil/iamf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/iamf.c b/libavutil/iamf.c
index 84bed5a45e..c96100e7a0 100644
--- a/libavutil/iamf.c
+++ b/libavutil/iamf.c
@@ -74,7 +74,7 @@ static const AVOption mix_gain_options[] = {
 };
 
 static const AVClass mix_gain_class = {
-.class_name = "AVIAMFSubmixElement",
+.class_name = "AVIAMFMixGain",
 .item_name  = av_default_item_name,
 .version= LIBAVUTIL_VERSION_INT,
 .option = mix_gain_options,

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

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


[FFmpeg-cvslog] fate/iamf: add a demux text

2024-04-24 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed Apr 24 17:47:21 
2024 -0300| [1a8d50e379dfe48edc0d89183ded910717240a92] | committer: James Almer

fate/iamf: add a demux text

Using the same input sample as iamf-5_1-copy, in order to compare both test's 
output

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1a8d50e379dfe48edc0d89183ded910717240a92
---

 tests/fate/iamf.mak   |   5 +
 tests/ref/fate/iamf-5_1-demux | 409 ++
 2 files changed, 414 insertions(+)

diff --git a/tests/fate/iamf.mak b/tests/fate/iamf.mak
index c72c956358..394de0a904 100644
--- a/tests/fate/iamf.mak
+++ b/tests/fate/iamf.mak
@@ -37,6 +37,11 @@ fate-iamf-ambisonic_1: CMD = transcode wav $(SRC) iamf 
"-auto_conversion_filters
   -streamid 0:0 -streamid 1:1 -streamid 2:2 -streamid 3:3 -map [MONO0] -map 
[MONO1] -map [MONO2] -map [MONO3] -c:a flac -t 1" "-c:a copy -map 0" \
   "-show_entries 
stream_group=index,id,nb_streams,type:stream_group_components:stream_group_stream=index,id:stream_group_stream_disposition"
 
+FATE_IAMF_SAMPLES-$(call FRAMECRC, IAMF, OPUS) += fate-iamf-5_1-demux
+fate-iamf-5_1-demux: CMD = stream_demux iamf 
$(TARGET_SAMPLES)/iamf/test_59.iamf "" \
+  "-c:a copy -map 0" \
+  "-show_entries 
stream_group=index,id,nb_streams,type:stream_group_components:stream_group_stream=index,id:stream_group_stream_disposition"
+
 FATE_IAMF_SAMPLES-$(call REMUX, IAMF, OPUS_DECODER) += fate-iamf-5_1-copy
 fate-iamf-5_1-copy: CMD = stream_remux iamf 
$(TARGET_SAMPLES)/iamf/test_59.iamf "" iamf \
   "-map 0 -stream_group map=0=0:st=0:st=1:st=2:st=3 -stream_group 
map=0=1:stg=0 -streamid 0:0 -streamid 1:1 -streamid 2:2 -streamid 3:3" "" "-c:a 
copy -map 0" \
diff --git a/tests/ref/fate/iamf-5_1-demux b/tests/ref/fate/iamf-5_1-demux
new file mode 100644
index 00..1f0b67b1f7
--- /dev/null
+++ b/tests/ref/fate/iamf-5_1-demux
@@ -0,0 +1,409 @@
+#extradata 0:   19, 0x379c0490
+#extradata 1:   19, 0x379c0490
+#extradata 2:   19, 0x3792048f
+#extradata 3:   19, 0x3792048f
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: opus
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+#tb 1: 1/48000
+#media_type 1: audio
+#codec_id 1: opus
+#sample_rate 1: 48000
+#channel_layout_name 1: stereo
+#tb 2: 1/48000
+#media_type 2: audio
+#codec_id 2: opus
+#sample_rate 2: 48000
+#channel_layout_name 2: mono
+#tb 3: 1/48000
+#media_type 3: audio
+#codec_id 3: opus
+#sample_rate 3: 48000
+#channel_layout_name 3: mono
+0,  0,  0,  960,  371, 0x552eba36, S=3,   10,  
 96,  136
+1,  0,  0,  960,  381, 0x6779b329, S=3,   10,  
 96,  136
+2,  0,  0,  960,   66, 0x4ce02142, S=3,   10,  
 96,  136
+3,  0,  0,  960,   67, 0x935223f9, S=3,   10,  
 96,  136
+0,960,960,  960,  313, 0xa5e19a4f, S=2,   96,  
136
+1,960,960,  960,  339, 0xf83daf6a, S=2,   96,  
136
+2,960,960,  960,   62, 0x80c91ca8, S=2,   96,  
136
+3,960,960,  960,   64, 0xaae41dd7, S=2,   96,  
136
+0,   1920,   1920,  960,  210, 0x5fc26f7a, S=2,   96,  
136
+1,   1920,   1920,  960,  207, 0xc8c768e8, S=2,   96,  
136
+2,   1920,   1920,  960,   75, 0x85012598, S=2,   96,  
136
+3,   1920,   1920,  960,   94, 0x5dc52d3b, S=2,   96,  
136
+0,   2880,   2880,  960,  211, 0x8f006c62, S=2,   96,  
136
+1,   2880,   2880,  960,  215, 0x30c8674d, S=2,   96,  
136
+2,   2880,   2880,  960,   88, 0x46772b87, S=2,   96,  
136
+3,   2880,   2880,  960,  105, 0x831c3191, S=2,   96,  
136
+0,   3840,   3840,  960,  340, 0x3c92a527, S=2,   96,  
136
+1,   3840,   3840,  960,  303, 0x65e09e91, S=2,   96,  
136
+2,   3840,   3840,  960,  121, 0xc45d3ec1, S=2,   96,  
136
+3,   3840,   3840,  960,  126, 0xff3a44d7, S=2,   96,  
136
+0,   4800,   4800,  960,  206, 0x3087662a, S=2,   96,  
136
+1,   4800,   4800,  960,  206, 0xd2b469de, S=2,   96,  
136
+2,   4800,   4800,  960,  124, 0xd9423baf, S=2,   96,  
136
+3,   4800,   4800,  960,  121, 0x24073ab0, S=2,   96,  
136
+0,   5760,   5760,  960,  212, 0x85686b01, S=2,   96,  
136
+1,   5760,   5760,  960,  230, 0x7ce56f22, S=2,   96,  
136
+2,   5760,   5760,  960,  128, 0xca6840ad, S=2,   96,  
136
+3,   5760,   

[FFmpeg-cvslog] fftools/ffmpeg_mux_init: remove leftover debug log messages

2024-04-24 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed Apr 24 17:36:45 
2024 -0300| [f684228407c988c1789539be6945fe9dc939602f] | committer: James Almer

fftools/ffmpeg_mux_init: remove leftover debug log messages

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f684228407c988c1789539be6945fe9dc939602f
---

 fftools/ffmpeg_mux_init.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index a46b0628d8..3b3b22f7ed 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -2303,7 +2303,6 @@ static int of_map_group(Muxer *mux, AVDictionary **dict, 
AVBPrint *bp, const cha
 av_log(mux, AV_LOG_ERROR, "Error parsing mapped group specification 
%s\n", ptr);
 av_dict_set_int(dict, "type", stg->type, 0);
 
-av_log(mux, AV_LOG_VERBOSE, "stg %s\n", bp->str);
 av_bprint_clear(bp);
 switch(stg->type) {
 case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT: {
@@ -2353,7 +2352,6 @@ static int of_map_group(Muxer *mux, AVDictionary **dict, 
AVBPrint *bp, const cha
 ret = AVERROR(EINVAL);
 break;
 }
-av_log(mux, AV_LOG_VERBOSE, "extra %s\n", bp->str);
 return 0;
 }
 

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

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


[FFmpeg-cvslog] fftools/ffmpeg_mux_init: add missing IAMF Param Definition copies

2024-04-24 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed Apr 24 17:31:45 
2024 -0300| [8c27cdd2d47b2055cf73d530ce3b6a6e1dfde5ce] | committer: James Almer

fftools/ffmpeg_mux_init: add missing IAMF Param Definition copies

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8c27cdd2d47b2055cf73d530ce3b6a6e1dfde5ce
---

 fftools/ffmpeg_mux_init.c| 25 +
 tests/ref/fate/iamf-5_1-copy |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 3b3b22f7ed..8797265145 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -2257,6 +2257,15 @@ static int of_serialize_options(Muxer *mux, void *obj, 
AVBPrint *bp)
 return ret; \
 } while (0)
 
+#define SERIALIZE_LOOP_SUBBLOCK(obj) do {\
+for (int k = 0; k < obj->nb_subblocks; k++) {\
+ret = of_serialize_options(mux,  \
+  av_iamf_param_definition_get_subblock(obj, k), bp);\
+if (ret < 0) \
+return ret;  \
+}\
+} while (0)
+
 #define SERIALIZE_LOOP(parent, child, suffix, separator) do {\
 for (int j = 0; j < parent->nb_## child ## suffix; j++) {\
 av_bprintf(bp, separator#child "="); \
@@ -2309,12 +2318,20 @@ static int of_map_group(Muxer *mux, AVDictionary 
**dict, AVBPrint *bp, const cha
 AVIAMFAudioElement *audio_element = stg->params.iamf_audio_element;
 
 if (audio_element->demixing_info) {
+AVIAMFParamDefinition *demixing_info = 
audio_element->demixing_info;
 av_bprintf(bp, ",demixing=");
 SERIALIZE(audio_element, demixing_info);
+if (ret && demixing_info->nb_subblocks)
+av_bprintf(bp, ":");
+SERIALIZE_LOOP_SUBBLOCK(demixing_info);
 }
 if (audio_element->recon_gain_info) {
+AVIAMFParamDefinition *recon_gain_info = 
audio_element->recon_gain_info;
 av_bprintf(bp, ",recon_gain=");
 SERIALIZE(audio_element, recon_gain_info);
+if (ret && recon_gain_info->nb_subblocks)
+av_bprintf(bp, ":");
+SERIALIZE_LOOP_SUBBLOCK(recon_gain_info);
 }
 SERIALIZE_LOOP(audio_element, layer, s, ",");
 break;
@@ -2324,11 +2341,16 @@ static int of_map_group(Muxer *mux, AVDictionary 
**dict, AVBPrint *bp, const cha
 
 for (int i = 0; i < mix->nb_submixes; i++) {
 AVIAMFSubmix *submix = mix->submixes[i];
+AVIAMFParamDefinition *output_mix_config = 
submix->output_mix_config;
 
 av_bprintf(bp, ",submix=");
 SERIALIZE(mix, submixes[i]);
+if (ret && output_mix_config->nb_subblocks)
+av_bprintf(bp, ":");
+SERIALIZE_LOOP_SUBBLOCK(output_mix_config);
 for (int j = 0; j < submix->nb_elements; j++) {
 AVIAMFSubmixElement *element = submix->elements[j];
+AVIAMFParamDefinition *element_mix_config = 
element->element_mix_config;
 int64_t id = get_stream_group_index_from_id(mux, 
element->audio_element_id);
 
 if (id < 0) {
@@ -2339,6 +2361,9 @@ static int of_map_group(Muxer *mux, AVDictionary **dict, 
AVBPrint *bp, const cha
 
 av_bprintf(bp, "|element=");
 SERIALIZE(submix, elements[j]);
+if (ret && element_mix_config->nb_subblocks)
+av_bprintf(bp, ":");
+SERIALIZE_LOOP_SUBBLOCK(element_mix_config);
 if (ret)
 av_bprintf(bp, ":");
 av_bprintf(bp, "stg=%"PRId64, id);
diff --git a/tests/ref/fate/iamf-5_1-copy b/tests/ref/fate/iamf-5_1-copy
index 92409a43c7..1f0b67b1f7 100644
--- a/tests/ref/fate/iamf-5_1-copy
+++ b/tests/ref/fate/iamf-5_1-copy
@@ -155,7 +155,7 @@ duration=960
 constant_subblock_duration=960
 [PIECE]
 subblock_duration=960
-dmixp_mode=0
+dmixp_mode=1
 [/PIECE]
 [/SUBCOMPONENT]
 [SUBCOMPONENT]

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

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


[FFmpeg-cvslog] avutil/iamf: fix mix_gain_class name

2024-04-24 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed Apr 24 17:35:36 
2024 -0300| [b9af58184fd3bf6438924ce7e827ed198e517f7f] | committer: James Almer

avutil/iamf: fix mix_gain_class name

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b9af58184fd3bf6438924ce7e827ed198e517f7f
---

 libavutil/iamf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/iamf.c b/libavutil/iamf.c
index 84bed5a45e..c96100e7a0 100644
--- a/libavutil/iamf.c
+++ b/libavutil/iamf.c
@@ -74,7 +74,7 @@ static const AVOption mix_gain_options[] = {
 };
 
 static const AVClass mix_gain_class = {
-.class_name = "AVIAMFSubmixElement",
+.class_name = "AVIAMFMixGain",
 .item_name  = av_default_item_name,
 .version= LIBAVUTIL_VERSION_INT,
 .option = mix_gain_options,

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

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


[FFmpeg-cvslog] fate/iamf: add a remux test with stream group copying

2024-04-24 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed Apr 24 13:25:42 
2024 -0300| [8c0045f013be046ab9f13accf9c5322a9fa00e51] | committer: James Almer

fate/iamf: add a remux test with stream group copying

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8c0045f013be046ab9f13accf9c5322a9fa00e51
---

 tests/fate/iamf.mak  |   9 +-
 tests/ref/fate/iamf-5_1-copy | 409 +++
 2 files changed, 417 insertions(+), 1 deletion(-)

diff --git a/tests/fate/iamf.mak b/tests/fate/iamf.mak
index cf56a67e6f..c72c956358 100644
--- a/tests/fate/iamf.mak
+++ b/tests/fate/iamf.mak
@@ -37,8 +37,15 @@ fate-iamf-ambisonic_1: CMD = transcode wav $(SRC) iamf 
"-auto_conversion_filters
   -streamid 0:0 -streamid 1:1 -streamid 2:2 -streamid 3:3 -map [MONO0] -map 
[MONO1] -map [MONO2] -map [MONO3] -c:a flac -t 1" "-c:a copy -map 0" \
   "-show_entries 
stream_group=index,id,nb_streams,type:stream_group_components:stream_group_stream=index,id:stream_group_stream_disposition"
 
+FATE_IAMF_SAMPLES-$(call REMUX, IAMF, OPUS_DECODER) += fate-iamf-5_1-copy
+fate-iamf-5_1-copy: CMD = stream_remux iamf 
$(TARGET_SAMPLES)/iamf/test_59.iamf "" iamf \
+  "-map 0 -stream_group map=0=0:st=0:st=1:st=2:st=3 -stream_group 
map=0=1:stg=0 -streamid 0:0 -streamid 1:1 -streamid 2:2 -streamid 3:3" "" "-c:a 
copy -map 0" \
+  "-show_entries 
stream_group=index,id,nb_streams,type:stream_group_components:stream_group_stream=index,id:stream_group_stream_disposition"
+
 FATE_IAMF += $(FATE_IAMF-yes)
+FATE_IAMF_SAMPLES += $(FATE_IAMF_SAMPLES-yes)
 
 FATE_FFMPEG_FFPROBE += $(FATE_IAMF)
+FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_IAMF_SAMPLES)
 
-fate-iamf: $(FATE_IAMF)
+fate-iamf: $(FATE_IAMF) $(FATE_IAMF_SAMPLES)
diff --git a/tests/ref/fate/iamf-5_1-copy b/tests/ref/fate/iamf-5_1-copy
new file mode 100644
index 00..92409a43c7
--- /dev/null
+++ b/tests/ref/fate/iamf-5_1-copy
@@ -0,0 +1,409 @@
+#extradata 0:   19, 0x379c0490
+#extradata 1:   19, 0x379c0490
+#extradata 2:   19, 0x3792048f
+#extradata 3:   19, 0x3792048f
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: opus
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+#tb 1: 1/48000
+#media_type 1: audio
+#codec_id 1: opus
+#sample_rate 1: 48000
+#channel_layout_name 1: stereo
+#tb 2: 1/48000
+#media_type 2: audio
+#codec_id 2: opus
+#sample_rate 2: 48000
+#channel_layout_name 2: mono
+#tb 3: 1/48000
+#media_type 3: audio
+#codec_id 3: opus
+#sample_rate 3: 48000
+#channel_layout_name 3: mono
+0,  0,  0,  960,  371, 0x552eba36, S=3,   10,  
 96,  136
+1,  0,  0,  960,  381, 0x6779b329, S=3,   10,  
 96,  136
+2,  0,  0,  960,   66, 0x4ce02142, S=3,   10,  
 96,  136
+3,  0,  0,  960,   67, 0x935223f9, S=3,   10,  
 96,  136
+0,960,960,  960,  313, 0xa5e19a4f, S=2,   96,  
136
+1,960,960,  960,  339, 0xf83daf6a, S=2,   96,  
136
+2,960,960,  960,   62, 0x80c91ca8, S=2,   96,  
136
+3,960,960,  960,   64, 0xaae41dd7, S=2,   96,  
136
+0,   1920,   1920,  960,  210, 0x5fc26f7a, S=2,   96,  
136
+1,   1920,   1920,  960,  207, 0xc8c768e8, S=2,   96,  
136
+2,   1920,   1920,  960,   75, 0x85012598, S=2,   96,  
136
+3,   1920,   1920,  960,   94, 0x5dc52d3b, S=2,   96,  
136
+0,   2880,   2880,  960,  211, 0x8f006c62, S=2,   96,  
136
+1,   2880,   2880,  960,  215, 0x30c8674d, S=2,   96,  
136
+2,   2880,   2880,  960,   88, 0x46772b87, S=2,   96,  
136
+3,   2880,   2880,  960,  105, 0x831c3191, S=2,   96,  
136
+0,   3840,   3840,  960,  340, 0x3c92a527, S=2,   96,  
136
+1,   3840,   3840,  960,  303, 0x65e09e91, S=2,   96,  
136
+2,   3840,   3840,  960,  121, 0xc45d3ec1, S=2,   96,  
136
+3,   3840,   3840,  960,  126, 0xff3a44d7, S=2,   96,  
136
+0,   4800,   4800,  960,  206, 0x3087662a, S=2,   96,  
136
+1,   4800,   4800,  960,  206, 0xd2b469de, S=2,   96,  
136
+2,   4800,   4800,  960,  124, 0xd9423baf, S=2,   96,  
136
+3,   4800,   4800,  960,  121, 0x24073ab0, S=2,   96,  
136
+0,   5760,   5760,  960,  212, 0x85686b01, S=2,   96,  
136
+1,   5760,   5760,  960,  230, 0x7ce56f22, S=2,   96,  
136
+2,   5760,   5760,  960,  128, 0xca6840ad, S=2,   96,  
136
+3,   5760,   5760, 

[FFmpeg-cvslog] doc/APIchanges: fix date for the latest entry

2024-04-23 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed Apr 24 00:18:52 
2024 -0300| [725d3b6f170e40c526a832870c3837f52b4ba7e0] | committer: James Almer

doc/APIchanges: fix date for the latest entry

And add the commit hash while at it.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=725d3b6f170e40c526a832870c3837f52b4ba7e0
---

 doc/APIchanges | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 05912d2ed0..0566fcdcc5 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,7 +2,7 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
-2024-04-11 - xx - lavu 59.16.100 - opt.h
+2024-04-24 - 8616cfe0890 - lavu 59.16.100 - opt.h
   Add AV_OPT_SERIALIZE_SEARCH_CHILDREN.
 
 2024-04-11 - xx - lavc 61.5.102 - avcodec.h

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

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


[FFmpeg-cvslog] avcodec/codec_par: always clear extradata_size in avcodec_parameters_to_context()

2024-04-23 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Sat Apr 20 
20:26:24 2024 -0300| [506fbe681c178560cb4ca65b8645b81a143b7d61] | committer: 
James Almer

avcodec/codec_par: always clear extradata_size in 
avcodec_parameters_to_context()

Missed in d383ae43c266b160348db04f2fd17ccf30286784.

Signed-off-by: James Almer 
(cherry picked from commit c4e3d6cdb066425a5f5a2e05def9470a47a6082c)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=506fbe681c178560cb4ca65b8645b81a143b7d61
---

 libavcodec/codec_par.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/codec_par.c b/libavcodec/codec_par.c
index 212cb97d77..790ea01d10 100644
--- a/libavcodec/codec_par.c
+++ b/libavcodec/codec_par.c
@@ -250,6 +250,7 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
 }
 
 av_freep(>extradata);
+codec->extradata_size = 0;
 if (par->extradata) {
 codec->extradata = av_mallocz(par->extradata_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
 if (!codec->extradata)

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

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


[FFmpeg-cvslog] avformat/demux: extract extradata from packets when context update is requested

2024-04-23 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun Apr 21 12:18:51 
2024 -0300| [757367e068679e0f2884262ab7c1f53de490e6ad] | committer: James Almer

avformat/demux: extract extradata from packets when context update is requested

If the demuxer doesn't set extradata in the stream's codecpar, a
need_context_update request will delete the previously extracted extradata in
the stream's internal AVCodecContext.
As we can't ensure the old extradata is valid for the stream in its post
context update request state, try to get extradata from the new packet instead
of attempting to preserve the old in some form.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=757367e068679e0f2884262ab7c1f53de490e6ad
---

 libavformat/demux.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/libavformat/demux.c b/libavformat/demux.c
index abfd5fee7d..ecefe7e0a7 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -1319,6 +1319,8 @@ fail:
 return ret;
 }
 
+static int extract_extradata(FFFormatContext *si, AVStream *st, const AVPacket 
*pkt);
+
 static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
 {
 FFFormatContext *const si = ffformatcontext(s);
@@ -1373,6 +1375,16 @@ static int read_frame_internal(AVFormatContext *s, 
AVPacket *pkt)
 return ret;
 }
 
+if (!sti->avctx->extradata) {
+sti->extract_extradata.inited = 0;
+
+ret = extract_extradata(si, st, pkt);
+if (ret < 0) {
+av_packet_unref(pkt);
+return ret;
+}
+}
+
 sti->codec_desc = avcodec_descriptor_get(sti->avctx->codec_id);
 
 sti->need_context_update = 0;
@@ -2427,6 +2439,7 @@ static int extract_extradata_init(AVStream *st)
 if (!ret)
 goto finish;
 
+av_bsf_free(>extract_extradata.bsf);
 ret = av_bsf_alloc(f, >extract_extradata.bsf);
 if (ret < 0)
 return ret;

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

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


[FFmpeg-cvslog] avcodec/codec_par: always clear extradata_size in avcodec_parameters_to_context()

2024-04-23 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Apr 20 20:26:24 
2024 -0300| [c4e3d6cdb066425a5f5a2e05def9470a47a6082c] | committer: James Almer

avcodec/codec_par: always clear extradata_size in 
avcodec_parameters_to_context()

Missed in d383ae43c266b160348db04f2fd17ccf30286784.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c4e3d6cdb066425a5f5a2e05def9470a47a6082c
---

 libavcodec/codec_par.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/codec_par.c b/libavcodec/codec_par.c
index 212cb97d77..790ea01d10 100644
--- a/libavcodec/codec_par.c
+++ b/libavcodec/codec_par.c
@@ -250,6 +250,7 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
 }
 
 av_freep(>extradata);
+codec->extradata_size = 0;
 if (par->extradata) {
 codec->extradata = av_mallocz(par->extradata_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
 if (!codec->extradata)

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

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


[FFmpeg-cvslog] fftools/ffmpeg_mux_init: allow mapping a stream group from one of the inputs

2024-04-23 Thread James Almer
ffmpeg | branch: master | James Almer  | Mon Apr 15 12:04:07 
2024 -0300| [ecf87dd2309f809cf399421c33d2295c7bd0] | committer: James Almer

fftools/ffmpeg_mux_init: allow mapping a stream group from one of the inputs

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ecf87dd2309f809cf399421c33d2295c7bd0
---

 doc/ffmpeg.texi   |  28 -
 fftools/ffmpeg_mux_init.c | 154 +-
 2 files changed, 177 insertions(+), 5 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index e996ab945f..da37e3ad37 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -663,10 +663,11 @@ Not all muxers support embedded thumbnails, and those who 
do, only support a few
 Creates a program with the specified @var{title}, @var{program_num} and adds 
the specified
 @var{stream}(s) to it.
 
-@item -stream_group 
type=@var{type}:st=@var{stream}[:st=@var{stream}][:stg=@var{stream_group}][:id=@var{stream_group_id}...]
 (@emph{output})
+@item -stream_group 
[map=@var{input_file_id}=@var{stream_group}][type=@var{type}:]st=@var{stream}[:st=@var{stream}][:stg=@var{stream_group}][:id=@var{stream_group_id}...]
 (@emph{output})
 
-Creates a stream group of the specified @var{type}, @var{stream_group_id} and 
adds the specified
-@var{stream}(s) and/or previously defined @var{stream_group}(s) to it.
+Creates a stream group of the specified @var{type} and @var{stream_group_id}, 
or by
+@var{map}ping an input group, adding the specified @var{stream}(s) and/or 
previously
+defined @var{stream_group}(s) to it.
 
 @var{type} can be one of the following:
 @table @option
@@ -863,6 +864,27 @@ all sub-mix element's @var{annotations}s
 
 @end table
 
+E.g. to create an scalable 5.1 IAMF file from several WAV input files
+@example
+ffmpeg -i front.wav -i back.wav -i center.wav -i lfe.wav
+-map 0:0 -map 1:0 -map 2:0 -map 3:0 -c:a opus
+-stream_group type=iamf_audio_element:id=1:st=0:st=1:st=2:st=3,
+demixing=parameter_id=998,
+recon_gain=parameter_id=101,
+layer=ch_layout=stereo,
+layer=ch_layout=5.1,
+-stream_group 
type=iamf_mix_presentation:id=2:stg=0:annotations=en-us=Mix_Presentation,
+submix=parameter_id=100:parameter_rate=48000|element=stg=0:parameter_id=100:annotations=en-us=Scalable_Submix|layout=sound_system=stereo|layout=sound_system=5.1
+-streamid 0:0 -streamid 1:1 -streamid 2:2 -streamid 3:3 output.iamf
+@end example
+
+To copy the two stream groups (Audio Element and Mix Presentation) from an 
input IAMF file with four
+streams into an mp4 output
+@example
+ffmpeg -i input.iamf -c:a copy -stream_group map=0=0:st=0:st=1:st=2:st=3 
-stream_group map=0=1:stg=0
+-streamid 0:0 -streamid 1:1 -streamid 2:2 -streamid 3:3 output.mp4
+@end example
+
 @item -target @var{type} (@emph{output})
 Specify target file type (@code{vcd}, @code{svcd}, @code{dvd}, @code{dv},
 @code{dv50}). @var{type} may be prefixed with @code{pal-}, @code{ntsc-} or
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 6d8bd5bcdf..a46b0628d8 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -2232,11 +2232,137 @@ fail:
 return ret;
 }
 
+static int of_serialize_options(Muxer *mux, void *obj, AVBPrint *bp)
+{
+char *ptr;
+int ret;
+
+ret = av_opt_serialize(obj, 0, AV_OPT_SERIALIZE_SKIP_DEFAULTS | 
AV_OPT_SERIALIZE_SEARCH_CHILDREN,
+   , '=', ':');
+if (ret < 0) {
+av_log(mux, AV_LOG_ERROR, "Failed to serialize group\n");
+return ret;
+}
+
+av_bprintf(bp, "%s", ptr);
+ret = strlen(ptr);
+av_free(ptr);
+
+return ret;
+}
+
+#define SERIALIZE(parent, child) do {   \
+ret = of_serialize_options(mux, parent->child, bp); \
+if (ret < 0)\
+return ret; \
+} while (0)
+
+#define SERIALIZE_LOOP(parent, child, suffix, separator) do {\
+for (int j = 0; j < parent->nb_## child ## suffix; j++) {\
+av_bprintf(bp, separator#child "="); \
+SERIALIZE(parent, child ## suffix[j]);   \
+}\
+} while (0)
+
+static int64_t get_stream_group_index_from_id(Muxer *mux, int64_t id)
+{
+AVFormatContext *oc = mux->fc;
+
+for (unsigned i = 0; i < oc->nb_stream_groups; i++)
+if (oc->stream_groups[i]->id == id)
+return oc->stream_groups[i]->index;
+
+return AVERROR(EINVAL);
+}
+
+static int of_map_group(Muxer *mux, AVDictionary **dict, AVBPrint *bp, const 
char *map)
+{
+AVStreamGroup *stg;
+int ret, file_idx, stream_idx;
+char *ptr;
+
+file_idx = strtol(map, , 0);
+if (file_idx >= nb_input_files || file_idx < 0 || map == ptr) {
+av_log(mux, AV_LOG_ERROR, "Invalid input file ind

[FFmpeg-cvslog] avutil/opt: add support for children objects in av_opt_serialize

2024-04-23 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Apr 12 19:10:25 
2024 -0300| [8616cfe0890e49437d2b373f97a9c791eb1b7c4c] | committer: James Almer

avutil/opt: add support for children objects in av_opt_serialize

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8616cfe0890e49437d2b373f97a9c791eb1b7c4c
---

 doc/APIchanges|  3 +++
 libavutil/opt.c   | 65 ++-
 libavutil/opt.h   |  1 +
 libavutil/tests/opt.c | 49 +++---
 libavutil/version.h   |  2 +-
 tests/ref/fate/opt|  2 +-
 6 files changed, 96 insertions(+), 26 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 63e7a47126..05912d2ed0 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-04-11 - xx - lavu 59.16.100 - opt.h
+  Add AV_OPT_SERIALIZE_SEARCH_CHILDREN.
+
 2024-04-11 - xx - lavc 61.5.102 - avcodec.h
   AVCodecContext.decoded_side_data may now be set by libavcodec after
   calling avcodec_open2().
diff --git a/libavutil/opt.c b/libavutil/opt.c
index d11e9d2ac5..ecbf7efe5f 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -2386,26 +2386,22 @@ int av_opt_is_set_to_default_by_name(void *obj, const 
char *name, int search_fla
 return av_opt_is_set_to_default(target, o);
 }
 
-int av_opt_serialize(void *obj, int opt_flags, int flags, char **buffer,
- const char key_val_sep, const char pairs_sep)
+static int opt_serialize(void *obj, int opt_flags, int flags, int *cnt,
+ AVBPrint *bprint, const char key_val_sep, const char 
pairs_sep)
 {
 const AVOption *o = NULL;
+void *child = NULL;
 uint8_t *buf;
-AVBPrint bprint;
-int ret, cnt = 0;
+int ret;
 const char special_chars[] = {pairs_sep, key_val_sep, '\0'};
 
-if (pairs_sep == '\0' || key_val_sep == '\0' || pairs_sep == key_val_sep ||
-pairs_sep == '\\' || key_val_sep == '\\') {
-av_log(obj, AV_LOG_ERROR, "Invalid separator(s) found.");
-return AVERROR(EINVAL);
-}
-
-if (!obj || !buffer)
-return AVERROR(EINVAL);
-
-*buffer = NULL;
-av_bprint_init(, 64, AV_BPRINT_SIZE_UNLIMITED);
+if (flags & AV_OPT_SERIALIZE_SEARCH_CHILDREN)
+while (child = av_opt_child_next(obj, child)) {
+ret = opt_serialize(child, opt_flags, flags, cnt, bprint,
+key_val_sep, pairs_sep);
+if (ret < 0)
+return ret;
+}
 
 while (o = av_opt_next(obj, o)) {
 if (o->type == AV_OPT_TYPE_CONST)
@@ -2417,18 +2413,45 @@ int av_opt_serialize(void *obj, int opt_flags, int 
flags, char **buffer,
 if (flags & AV_OPT_SERIALIZE_SKIP_DEFAULTS && 
av_opt_is_set_to_default(obj, o) > 0)
 continue;
 if ((ret = av_opt_get(obj, o->name, 0, )) < 0) {
-av_bprint_finalize(, NULL);
+av_bprint_finalize(bprint, NULL);
 return ret;
 }
 if (buf) {
-if (cnt++)
-av_bprint_append_data(, _sep, 1);
-av_bprint_escape(, o->name, special_chars, 
AV_ESCAPE_MODE_BACKSLASH, 0);
-av_bprint_append_data(, _val_sep, 1);
-av_bprint_escape(, buf, special_chars, 
AV_ESCAPE_MODE_BACKSLASH, 0);
+if ((*cnt)++)
+av_bprint_append_data(bprint, _sep, 1);
+av_bprint_escape(bprint, o->name, special_chars, 
AV_ESCAPE_MODE_BACKSLASH, 0);
+av_bprint_append_data(bprint, _val_sep, 1);
+av_bprint_escape(bprint, buf, special_chars, 
AV_ESCAPE_MODE_BACKSLASH, 0);
 av_freep();
 }
 }
+
+return 0;
+}
+
+int av_opt_serialize(void *obj, int opt_flags, int flags, char **buffer,
+ const char key_val_sep, const char pairs_sep)
+{
+AVBPrint bprint;
+int ret, cnt = 0;
+
+if (pairs_sep == '\0' || key_val_sep == '\0' || pairs_sep == key_val_sep ||
+pairs_sep == '\\' || key_val_sep == '\\') {
+av_log(obj, AV_LOG_ERROR, "Invalid separator(s) found.");
+return AVERROR(EINVAL);
+}
+
+if (!obj || !buffer)
+return AVERROR(EINVAL);
+
+*buffer = NULL;
+av_bprint_init(, 64, AV_BPRINT_SIZE_UNLIMITED);
+
+ret = opt_serialize(obj, opt_flags, flags, , ,
+key_val_sep, pairs_sep);
+if (ret < 0)
+return ret;
+
 ret = av_bprint_finalize(, buffer);
 if (ret < 0)
 return ret;
diff --git a/libavutil/opt.h b/libavutil/opt.h
index e6013662f6..855e363091 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -929,6 +929,7 @@ int av_opt_flag_is_set(void *obj, const char *field_name, 
const char *flag_name)
 
 #define AV_OPT_SERIALIZE_SKIP_DEFAULTS  0x0001  ///<

[FFmpeg-cvslog] avutil/test/opt: test the AV_OPT_SERIALIZE_SKIP_DEFAULTS flag

2024-04-23 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Apr 12 19:51:13 
2024 -0300| [a9df9f95c43992d60c99cbd2f6bd28a104ed5d0b] | committer: James Almer

avutil/test/opt: test the AV_OPT_SERIALIZE_SKIP_DEFAULTS flag

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a9df9f95c43992d60c99cbd2f6bd28a104ed5d0b
---

 libavutil/tests/opt.c | 5 +
 tests/ref/fate/opt| 1 +
 2 files changed, 6 insertions(+)

diff --git a/libavutil/tests/opt.c b/libavutil/tests/opt.c
index ccf3a54f96..32301ba842 100644
--- a/libavutil/tests/opt.c
+++ b/libavutil/tests/opt.c
@@ -279,6 +279,11 @@ int main(void)
 if (av_opt_serialize(_ctx, 0, 0, , '=', ',') >= 0) {
 printf("%s\n", buf);
 av_free(buf);
+if (av_opt_serialize(_ctx, 0, 
AV_OPT_SERIALIZE_SKIP_DEFAULTS, , '=', ',') >= 0) {
+if (strlen(buf))
+printf("%s\n", buf);
+av_free(buf);
+}
 }
 }
 av_opt_free(_ctx);
diff --git a/tests/ref/fate/opt b/tests/ref/fate/opt
index f4fce1bd49..43bf0929a3 100644
--- a/tests/ref/fate/opt
+++ b/tests/ref/fate/opt
@@ -179,6 +179,7 @@ Setting entry with key 'array_int' to value ''
 Setting entry with key 'array_str' to value 'str0|str\|1|str\\2'
 Setting entry with key 'array_dict' to value 
'k00=v00:k01=v\,01,k10=v\\=1\\:0'
 
num=0,toggle=1,rational=1/1,string=default,escape=\\\=\,,flags=0x0001,size=200x300,pix_fmt=0bgr,sample_fmt=s16,video_rate=25/1,duration=0.001,color=0xffc0cbff,cl=hexagonal,bin=62696E00,bin1=,bin2=,num64=1,flt=0.33,dbl=0.33,bool1=auto,bool2=true,bool3=false,dict1=,dict2=happy\=\\:-),array_int=,array_str=str0|str\\|1|str2,array_dict=k00\=v00:k01\=v\\\,01\,k10\=v\=1:0
+flt=0.33,dbl=0.33,array_int=
 
 Testing av_set_options_string()
 Setting options string ''

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

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


[FFmpeg-cvslog] avutil/tests/opt: test av_opt_find2()

2024-04-23 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Apr 13 11:18:30 
2024 -0300| [855d4b52547b2f8fc38b400e5d18cf44e621e163] | committer: James Almer

avutil/tests/opt: test av_opt_find2()

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=855d4b52547b2f8fc38b400e5d18cf44e621e163
---

 libavutil/tests/opt.c | 49 +
 tests/ref/fate/opt|  7 +++
 2 files changed, 56 insertions(+)

diff --git a/libavutil/tests/opt.c b/libavutil/tests/opt.c
index 32301ba842..d43391025a 100644
--- a/libavutil/tests/opt.c
+++ b/libavutil/tests/opt.c
@@ -409,5 +409,54 @@ int main(void)
 av_opt_free(_ctx);
 }
 
+printf("\nTesting av_opt_find2()\n");
+{
+TestContext test_ctx = { 0 };
+ChildContext child_ctx = { 0 };
+void *target;
+const AVOption *opt;
+
+test_ctx.class = _class;
+child_ctx.class = _class;
+test_ctx.child = _ctx;
+
+av_log_set_level(AV_LOG_QUIET);
+
+// Should succeed. num exists and has opt_flags 1
+opt = av_opt_find2(_ctx, "num", NULL, 1, 0, );
+if (opt && target == _ctx)
+printf("OK'%s'\n", opt->name);
+else
+printf("Error 'num'\n");
+
+// Should fail. num64 exists but has opt_flags 1, not 2
+opt = av_opt_find(_ctx, "num64", NULL, 2, 0);
+if (opt)
+printf("OK'%s'\n", opt->name);
+else
+printf("Error 'num64'\n");
+
+// Should fail. child_num exists but in a child object we're not 
searching
+opt = av_opt_find(_ctx, "child_num", NULL, 0, 0);
+if (opt)
+printf("OK'%s'\n", opt->name);
+else
+printf("Error 'child_num'\n");
+
+// Should succeed. child_num exists in a child object we're searching
+opt = av_opt_find2(_ctx, "child_num", NULL, 0, 
AV_OPT_SEARCH_CHILDREN, );
+if (opt && target == _ctx)
+printf("OK'%s'\n", opt->name);
+else
+printf("Error 'child_num'\n");
+
+// Should fail. foo doesn't exist
+opt = av_opt_find(_ctx, "foo", NULL, 0, 0);
+if (opt)
+printf("OK'%s'\n", opt->name);
+else
+printf("Error 'foo'\n");
+}
+
 return 0;
 }
diff --git a/tests/ref/fate/opt b/tests/ref/fate/opt
index 43bf0929a3..f780097622 100644
--- a/tests/ref/fate/opt
+++ b/tests/ref/fate/opt
@@ -449,3 +449,10 @@ Setting options string 
'a_very_long_option_name_that_will_need_to_be_ellipsized_
 Setting 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here' 
to value '42'
 Option 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here' 
not found
 Error 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here=42'
+
+Testing av_opt_find2()
+OK'num'
+Error 'num64'
+Error 'child_num'
+OK'child_num'
+Error 'foo'

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

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


[FFmpeg-cvslog] avformat/movenc: remove one level of indentation

2024-04-23 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Apr 23 12:46:49 
2024 -0300| [ce33a5f16d7aebe18394c4f158a020da36055a23] | committer: James Almer

avformat/movenc: remove one level of indentation

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ce33a5f16d7aebe18394c4f158a020da36055a23
---

 libavformat/movenc.c | 57 
 1 file changed, 26 insertions(+), 31 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1a0502bbb1..e9bbfd67cf 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6672,6 +6672,7 @@ static int mov_write_subtitle_end_packet(AVFormatContext 
*s,
 #if CONFIG_IAMFENC
 static int mov_build_iamf_packet(AVFormatContext *s, MOVTrack *trk, AVPacket 
*pkt)
 {
+uint8_t *data;
 int ret;
 
 if (pkt->stream_index == trk->first_iamf_idx) {
@@ -6685,40 +6686,34 @@ static int mov_build_iamf_packet(AVFormatContext *s, 
MOVTrack *trk, AVPacket *pk
 if (ret < 0)
 return ret;
 
-if (pkt->stream_index == trk->last_iamf_idx) {
-uint8_t *data;
-
-ret = avio_close_dyn_buf(trk->iamf_buf, );
-trk->iamf_buf = NULL;
-
-if (!ret) {
-if (pkt->size) {
-// Either all or none of the packets for a single
-// IA Sample may be empty.
-av_log(s, AV_LOG_ERROR, "Unexpected packet from "
-"stream #%d\n", pkt->stream_index);
-ret = AVERROR_INVALIDDATA;
-}
-av_free(data);
-return ret;
-}
-av_buffer_unref(>buf);
-pkt->buf = av_buffer_create(data, ret, NULL, NULL, 0);
-if (!pkt->buf) {
-av_free(data);
-return AVERROR(ENOMEM);
+if (pkt->stream_index != trk->last_iamf_idx)
+return AVERROR(EAGAIN);
+
+ret = avio_close_dyn_buf(trk->iamf_buf, );
+trk->iamf_buf = NULL;
+if (!ret) {
+if (pkt->size) {
+// Either all or none of the packets for a single
+// IA Sample may be empty.
+av_log(s, AV_LOG_ERROR, "Unexpected packet from "
+ "stream #%d\n", pkt->stream_index);
+ret = AVERROR_INVALIDDATA;
 }
-pkt->data = data;
-pkt->size = ret;
-pkt->stream_index = trk->first_iamf_idx;
+av_free(data);
+return ret;
+}
 
-ret = avio_open_dyn_buf(>iamf_buf);
-if (ret < 0)
-return ret;
-} else
-ret = AVERROR(EAGAIN);
+av_buffer_unref(>buf);
+pkt->buf = av_buffer_create(data, ret, NULL, NULL, 0);
+if (!pkt->buf) {
+av_free(data);
+return AVERROR(ENOMEM);
+}
+pkt->data = data;
+pkt->size = ret;
+pkt->stream_index = trk->first_iamf_idx;
 
-return ret;
+return avio_open_dyn_buf(>iamf_buf);
 }
 #endif
 

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

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


[FFmpeg-cvslog] avcodec/aac/aacdec: remove double colon

2024-04-23 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Apr 23 11:02:00 
2024 -0300| [63702d5f9c92b69dcd07c84d4d870f4e4544bf9f] | committer: James Almer

avcodec/aac/aacdec: remove double colon

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=63702d5f9c92b69dcd07c84d4d870f4e4544bf9f
---

 libavcodec/aac/aacdec.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h
index 9d04f25108..4cf764e2e9 100644
--- a/libavcodec/aac/aacdec.h
+++ b/libavcodec/aac/aacdec.h
@@ -75,13 +75,13 @@ enum CouplingPoint {
 union { \
 int   RENAME_FIXED(name) elems; \
 float name   elems; \
-};
+}
 
 #define INTFLOAT_ALIGNED_UNION(alignment, name, nb_elems)\
 union {  \
 DECLARE_ALIGNED(alignment, int,   RENAME_FIXED(name))[nb_elems]; \
 DECLARE_ALIGNED(alignment, float, name)[nb_elems];   \
-};
+}
 /**
  * Long Term Prediction
  */

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

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


[FFmpeg-cvslog] avformat/mov: ignore old infe box versions

2024-04-18 Thread James Almer
ffmpeg | branch: release/7.0 | James Almer  | Sat Apr 13 
10:11:03 2024 -0300| [ed55219eddc96f6c41f88069d7e492976002f528] | committer: 
James Almer

avformat/mov: ignore old infe box versions

Some files with no image items have them, and were working prior to the recent
HEIF parsing overhaul.
Ignore such boxes instead, to recover the old behavior.

Fixes a regression since d9fed9df2a9e70c9375d3b2591db35c09303d369.

Tested-by: Wu Jianhua 
Signed-off-by: James Almer 
(cherry picked from commit 5b9db32ccc9426dc2aa37f21eee4c9efd1baf75b)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ed55219eddc96f6c41f88069d7e492976002f528
---

 libavformat/mov.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 50fbcd1f9b..d9009f2eab 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -8128,8 +8128,8 @@ static int mov_read_infe(MOVContext *c, AVIOContext *pb, 
MOVAtom atom, int idx)
 size -= 4;
 
 if (version < 2) {
-av_log(c->fc, AV_LOG_ERROR, "infe: version < 2 not supported\n");
-return AVERROR_PATCHWELCOME;
+avpriv_report_missing_feature(c->fc, "infe version < 2");
+return 1;
 }
 
 item_id = version > 2 ? avio_rb32(pb) : avio_rb16(pb);
@@ -8200,6 +8200,8 @@ static int mov_read_iinf(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 ret = mov_read_infe(c, pb, infe, i);
 if (ret < 0)
 return ret;
+if (ret)
+return 0;
 }
 
 c->found_iinf = 1;
@@ -9495,14 +9497,15 @@ static int mov_read_header(AVFormatContext *s)
 av_log(s, AV_LOG_ERROR, "error reading header\n");
 return err;
 }
-} while ((pb->seekable & AVIO_SEEKABLE_NORMAL) && !mov->found_moov && 
!mov->found_iloc && !mov->moov_retry++);
-if (!mov->found_moov && !mov->found_iloc) {
+} while ((pb->seekable & AVIO_SEEKABLE_NORMAL) &&
+ !mov->found_moov && (!mov->found_iloc || !mov->found_iinf) && 
!mov->moov_retry++);
+if (!mov->found_moov && !mov->found_iloc && !mov->found_iinf) {
 av_log(s, AV_LOG_ERROR, "moov atom not found\n");
 return AVERROR_INVALIDDATA;
 }
 av_log(mov->fc, AV_LOG_TRACE, "on_parse_exit_offset=%"PRId64"\n", 
avio_tell(pb));
 
-if (mov->found_iloc) {
+if (mov->found_iloc && mov->found_iinf) {
 for (i = 0; i < mov->nb_heif_item; i++) {
 HEIFItem *item = >heif_item[i];
 MOVStreamContext *sc;

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

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


[FFmpeg-cvslog] avformat/mov: ignore old infe box versions

2024-04-18 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Apr 13 10:11:03 
2024 -0300| [5b9db32ccc9426dc2aa37f21eee4c9efd1baf75b] | committer: James Almer

avformat/mov: ignore old infe box versions

Some files with no image items have them, and were working prior to the recent
HEIF parsing overhaul.
Ignore such boxes instead, to recover the old behavior.

Fixes a regression since d9fed9df2a9e70c9375d3b2591db35c09303d369.

Tested-by: Wu Jianhua 
Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5b9db32ccc9426dc2aa37f21eee4c9efd1baf75b
---

 libavformat/mov.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 0c892b56c8..ecd29a7d08 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -8137,8 +8137,8 @@ static int mov_read_infe(MOVContext *c, AVIOContext *pb, 
MOVAtom atom, int idx)
 size -= 4;
 
 if (version < 2) {
-av_log(c->fc, AV_LOG_ERROR, "infe: version < 2 not supported\n");
-return AVERROR_PATCHWELCOME;
+avpriv_report_missing_feature(c->fc, "infe version < 2");
+return 1;
 }
 
 item_id = version > 2 ? avio_rb32(pb) : avio_rb16(pb);
@@ -8209,6 +8209,8 @@ static int mov_read_iinf(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 ret = mov_read_infe(c, pb, infe, i);
 if (ret < 0)
 return ret;
+if (ret)
+return 0;
 }
 
 c->found_iinf = 1;
@@ -9508,14 +9510,15 @@ static int mov_read_header(AVFormatContext *s)
 av_log(s, AV_LOG_ERROR, "error reading header\n");
 return err;
 }
-} while ((pb->seekable & AVIO_SEEKABLE_NORMAL) && !mov->found_moov && 
!mov->found_iloc && !mov->moov_retry++);
-if (!mov->found_moov && !mov->found_iloc) {
+} while ((pb->seekable & AVIO_SEEKABLE_NORMAL) &&
+ !mov->found_moov && (!mov->found_iloc || !mov->found_iinf) && 
!mov->moov_retry++);
+if (!mov->found_moov && !mov->found_iloc && !mov->found_iinf) {
 av_log(s, AV_LOG_ERROR, "moov atom not found\n");
 return AVERROR_INVALIDDATA;
 }
 av_log(mov->fc, AV_LOG_TRACE, "on_parse_exit_offset=%"PRId64"\n", 
avio_tell(pb));
 
-if (mov->found_iloc) {
+if (mov->found_iloc && mov->found_iinf) {
 for (i = 0; i < mov->nb_heif_item; i++) {
 HEIFItem *item = >heif_item[i];
 MOVStreamContext *sc;

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

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


[FFmpeg-cvslog] avformat/iamf_writer: reject duplicated stream ids in a stream group

2024-04-16 Thread James Almer
ffmpeg | branch: master | James Almer  | Mon Apr 15 18:06:01 
2024 -0300| [6b6a0fc53df592183c69e518967841272ab4e862] | committer: James Almer

avformat/iamf_writer: reject duplicated stream ids in a stream group

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6b6a0fc53df592183c69e518967841272ab4e862
---

 libavformat/iamf_writer.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c
index 37ec8e732a..6d4e4082eb 100644
--- a/libavformat/iamf_writer.c
+++ b/libavformat/iamf_writer.c
@@ -275,6 +275,17 @@ int ff_iamf_add_audio_element(IAMFContext *iamf, const 
AVStreamGroup *stg, void
 }
 }
 
+for (int i = 0; i < audio_element->nb_substreams; i++) {
+for (int j = i + 1; j < audio_element->nb_substreams; j++)
+if (audio_element->substreams[i].audio_substream_id ==
+audio_element->substreams[j].audio_substream_id) {
+av_log(log_ctx, AV_LOG_ERROR, "Duplicate id %u in streams %u 
and %u from stream group %u\n",
+   audio_element->substreams[i].audio_substream_id, i, j, 
stg->index);
+ret = AVERROR(EINVAL);
+goto fail;
+}
+}
+
 if (iamf_audio_element->demixing_info) {
 AVIAMFParamDefinition *param = iamf_audio_element->demixing_info;
 const IAMFParamDefinition *param_definition = 
ff_iamf_get_param_definition(iamf, param->parameter_id);

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

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


[FFmpeg-cvslog] avutil/frame: free the old side data buffer before replacing it

2024-04-11 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu Apr 11 12:32:11 
2024 -0300| [dd5f665b4010f8a0142ce3cba3305b173eb37dfe] | committer: James Almer

avutil/frame: free the old side data buffer before replacing it

Fixes memleaks reported by ASAN/Valgrind.

Reported-by: Sean McGovern 
Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dd5f665b4010f8a0142ce3cba3305b173eb37dfe
---

 libavutil/frame.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index 10b9f7fa94..0775e2abd9 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -811,6 +811,7 @@ static AVFrameSideData 
*replace_side_data_from_buf(AVFrameSideData *dst,
 return NULL;
 
 av_dict_free(>metadata);
+av_buffer_unref(>buf);
 dst->buf  = buf;
 dst->data = buf->data;
 dst->size = buf->size;

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

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


[FFmpeg-cvslog] avcodec/hevcdec: export global side data in AVCodecContext

2024-04-11 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu Mar 28 12:50:54 
2024 -0300| [6d0c89980c78ffd3b112676186786334c915ace7] | committer: James Almer

avcodec/hevcdec: export global side data in AVCodecContext

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6d0c89980c78ffd3b112676186786334c915ace7
---

 doc/APIchanges |   4 +
 libavcodec/avcodec.h   |   2 +-
 libavcodec/h2645_sei.c | 214 ++---
 libavcodec/h2645_sei.h |   2 +
 libavcodec/hevcdec.c   |   4 +
 libavcodec/pthread_frame.c |  14 ++-
 libavcodec/version.h   |   2 +-
 7 files changed, 147 insertions(+), 95 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index d7c2056f0e..63e7a47126 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,10 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-04-11 - xx - lavc 61.5.102 - avcodec.h
+  AVCodecContext.decoded_side_data may now be set by libavcodec after
+  calling avcodec_open2().
+
 2024-04-11 - xx - lavu 59.15.100 - frame.h
   Add av_mastering_display_metadata_alloc_size().
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 83dc487251..968009a192 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2071,7 +2071,7 @@ typedef struct AVCodecContext {
  * - encoding: may be set by user before calling avcodec_open2() for
  * encoder configuration. Afterwards owned and freed by the
  * encoder.
- * - decoding: unused
+ * - decoding: may be set by libavcodec in avcodec_open2().
  */
 AVFrameSideData  **decoded_side_data;
 int nb_decoded_side_data;
diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index f0f107f73b..933975f076 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -529,6 +529,119 @@ static int is_frame_packing_type_valid(SEIFpaType type, 
enum AVCodecID codec_id)
type >= SEI_FPA_TYPE_SIDE_BY_SIDE;
 }
 
+static int h2645_sei_to_side_data(AVCodecContext *avctx, H2645SEI *sei,
+  AVFrameSideData ***sd, int *nb_sd)
+{
+int ret;
+
+for (unsigned i = 0; i < sei->unregistered.nb_buf_ref; i++) {
+H2645SEIUnregistered *unreg = >unregistered;
+
+if (unreg->buf_ref[i]) {
+AVFrameSideData *entry =
+av_frame_side_data_add(sd, nb_sd, 
AV_FRAME_DATA_SEI_UNREGISTERED,
+   >buf_ref[i], 0);
+if (!entry)
+av_buffer_unref(>buf_ref[i]);
+}
+}
+sei->unregistered.nb_buf_ref = 0;
+
+if (sei->ambient_viewing_environment.present) {
+H2645SEIAmbientViewingEnvironment *env = 
>ambient_viewing_environment;
+AVBufferRef *buf;
+size_t size;
+
+AVAmbientViewingEnvironment *dst_env =
+av_ambient_viewing_environment_alloc();
+if (!dst_env)
+return AVERROR(ENOMEM);
+
+buf = av_buffer_create((uint8_t *)dst_env, size, NULL, NULL, 0);
+if (!buf) {
+av_free(dst_env);
+return AVERROR(ENOMEM);
+}
+
+ret = ff_frame_new_side_data_from_buf_ext(avctx, sd, nb_sd,
+  
AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT, );
+
+if (ret < 0)
+return ret;
+
+dst_env->ambient_illuminance = av_make_q(env->ambient_illuminance, 
1);
+dst_env->ambient_light_x = av_make_q(env->ambient_light_x, 
5);
+dst_env->ambient_light_y = av_make_q(env->ambient_light_y, 
5);
+}
+
+if (sei->mastering_display.present) {
+// HEVC uses a g,b,r ordering, which we convert to a more natural r,g,b
+const int mapping[3] = {2, 0, 1};
+const int chroma_den = 5;
+const int luma_den = 1;
+int i;
+AVMasteringDisplayMetadata *metadata;
+
+ret = ff_decode_mastering_display_new_ext(avctx, sd, nb_sd, );
+if (ret < 0)
+return ret;
+
+if (metadata) {
+for (i = 0; i < 3; i++) {
+const int j = mapping[i];
+metadata->display_primaries[i][0].num = 
sei->mastering_display.display_primaries[j][0];
+metadata->display_primaries[i][0].den = chroma_den;
+metadata->display_primaries[i][1].num = 
sei->mastering_display.display_primaries[j][1];
+metadata->display_primaries[i][1].den = chroma_den;
+}
+metadata->white_point[0].num = 
sei->mastering_display.white_point[0];
+metadata->white_point[0].den = chroma_den;
+metadata->white_point[1].num = 
sei->mastering_display.white_point[1];
+metadata->white_point[1].den = chroma_den;
+
+  

[FFmpeg-cvslog] avutil/version: bump minor after recent AVFrame API additions

2024-04-11 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu Apr 11 11:43:26 
2024 -0300| [adb67bba064062489ee95fcee7bc3c6f8d33ab60] | committer: James Almer

avutil/version: bump minor after recent AVFrame API additions

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=adb67bba064062489ee95fcee7bc3c6f8d33ab60
---

 doc/APIchanges  | 4 
 libavutil/version.h | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 0a39b6d7ab..59855a6434 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,10 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-04-11 - xx - lavu 59.14.100 - frame.h
+  Add av_frame_side_data_add() and av_frame_side_data_remove().
+  Add AV_FRAME_SIDE_DATA_FLAG_REPLACE.
+
 2024-04-03 - xx - lavu 59.13.100 - pixfmt.h
   Add AVCOL_SPC_IPT_C2, AVCOL_SPC_YCGCO_RE and AVCOL_SPC_YCGCO_RO
   to map new matrix coefficients defined by H.273 v3.
diff --git a/libavutil/version.h b/libavutil/version.h
index da1a833255..78ee30dd08 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  59
-#define LIBAVUTIL_VERSION_MINOR  13
+#define LIBAVUTIL_VERSION_MINOR  14
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

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

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


[FFmpeg-cvslog] avutil/mastering_display_metadata: add a new allocator function that returns a size

2024-04-11 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Mar 22 18:42:05 
2024 -0300| [6d760c666d57ccbc95e85ef6fb9667fdd06854d1] | committer: James Almer

avutil/mastering_display_metadata: add a new allocator function that returns a 
size

av_mastering_display_metadata_alloc() is not useful in scenarios where you need 
to
know the runtime size of AVMasteringDisplayMetadata.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6d760c666d57ccbc95e85ef6fb9667fdd06854d1
---

 doc/APIchanges |  3 +++
 libavutil/mastering_display_metadata.c | 13 +
 libavutil/mastering_display_metadata.h |  9 +
 libavutil/version.h|  2 +-
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 59855a6434..d7c2056f0e 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-04-11 - xx - lavu 59.15.100 - frame.h
+  Add av_mastering_display_metadata_alloc_size().
+
 2024-04-11 - xx - lavu 59.14.100 - frame.h
   Add av_frame_side_data_add() and av_frame_side_data_remove().
   Add AV_FRAME_SIDE_DATA_FLAG_REPLACE.
diff --git a/libavutil/mastering_display_metadata.c 
b/libavutil/mastering_display_metadata.c
index 6069347617..ea41f13f9d 100644
--- a/libavutil/mastering_display_metadata.c
+++ b/libavutil/mastering_display_metadata.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include 
 #include 
 #include 
 
@@ -29,6 +30,18 @@ AVMasteringDisplayMetadata 
*av_mastering_display_metadata_alloc(void)
 return av_mallocz(sizeof(AVMasteringDisplayMetadata));
 }
 
+AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc_size(size_t 
*size)
+{
+AVMasteringDisplayMetadata *mastering = 
av_mallocz(sizeof(AVMasteringDisplayMetadata));
+if (!mastering)
+return NULL;
+
+if (size)
+*size = sizeof(*mastering);
+
+return mastering;
+}
+
 AVMasteringDisplayMetadata 
*av_mastering_display_metadata_create_side_data(AVFrame *frame)
 {
 AVFrameSideData *side_data = av_frame_new_side_data(frame,
diff --git a/libavutil/mastering_display_metadata.h 
b/libavutil/mastering_display_metadata.h
index c23b07c3cd..52fcef9e37 100644
--- a/libavutil/mastering_display_metadata.h
+++ b/libavutil/mastering_display_metadata.h
@@ -77,6 +77,15 @@ typedef struct AVMasteringDisplayMetadata {
  */
 AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void);
 
+/**
+ * Allocate an AVMasteringDisplayMetadata structure and set its fields to
+ * default values. The resulting struct can be freed using av_freep().
+ *
+ * @return An AVMasteringDisplayMetadata filled with default values or NULL
+ * on failure.
+ */
+AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc_size(size_t 
*size);
+
 /**
  * Allocate a complete AVMasteringDisplayMetadata and add it to the frame.
  *
diff --git a/libavutil/version.h b/libavutil/version.h
index 78ee30dd08..1f2bddc022 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  59
-#define LIBAVUTIL_VERSION_MINOR  14
+#define LIBAVUTIL_VERSION_MINOR  15
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

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

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


[FFmpeg-cvslog] avcodec/decode: add AVFrameSideData helper wrappers that don't depend on frames

2024-04-11 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu Mar 28 12:49:55 
2024 -0300| [6def8e3923f838a217c5e4567435b0e975b9aee7] | committer: James Almer

avcodec/decode: add AVFrameSideData helper wrappers that don't depend on frames

They will be useful to fill arrays stored in other structs.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6def8e3923f838a217c5e4567435b0e975b9aee7
---

 libavcodec/decode.c | 106 +++-
 libavcodec/decode.h |  24 
 2 files changed, 112 insertions(+), 18 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 255347766a..c4a21acdaf 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1785,16 +1785,16 @@ int ff_decode_preinit(AVCodecContext *avctx)
  * @retval 0 side data of this type can be added to frame
  * @retval 1 side data of this type should not be added to frame
  */
-static int side_data_pref(const AVCodecContext *avctx, AVFrame *frame,
-  enum AVFrameSideDataType type)
+static int side_data_pref(const AVCodecContext *avctx, AVFrameSideData ***sd,
+  int *nb_sd, enum AVFrameSideDataType type)
 {
 DecodeContext *dc = decode_ctx(avctx->internal);
 
 // Note: could be skipped for `type` without corresponding packet sd
-if (av_frame_get_side_data(frame, type)) {
+if (av_frame_side_data_get(*sd, *nb_sd, type)) {
 if (dc->side_data_pref_mask & (1ULL << type))
 return 1;
-av_frame_remove_side_data(frame, type);
+av_frame_side_data_remove(sd, nb_sd, type);
 }
 
 return 0;
@@ -1807,7 +1807,7 @@ int ff_frame_new_side_data(const AVCodecContext *avctx, 
AVFrame *frame,
 {
 AVFrameSideData *sd;
 
-if (side_data_pref(avctx, frame, type)) {
+if (side_data_pref(avctx, >side_data, >nb_side_data, type)) {
 if (psd)
 *psd = NULL;
 return 0;
@@ -1820,34 +1820,71 @@ int ff_frame_new_side_data(const AVCodecContext *avctx, 
AVFrame *frame,
 return sd ? 0 : AVERROR(ENOMEM);
 }
 
-int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx,
-AVFrame *frame, enum AVFrameSideDataType 
type,
-AVBufferRef **buf, AVFrameSideData **psd)
+int ff_frame_new_side_data_from_buf_ext(const AVCodecContext *avctx,
+AVFrameSideData ***sd, int *nb_sd,
+enum AVFrameSideDataType type,
+AVBufferRef **buf)
 {
-AVFrameSideData *sd = NULL;
 int ret = 0;
 
-if (side_data_pref(avctx, frame, type))
+if (side_data_pref(avctx, sd, nb_sd, type))
 goto finish;
 
-sd = av_frame_new_side_data_from_buf(frame, type, *buf);
-if (sd)
-*buf = NULL;
-else
+if (!av_frame_side_data_add(sd, nb_sd, type, buf, 0))
 ret = AVERROR(ENOMEM);
 
 finish:
 av_buffer_unref(buf);
-if (psd)
-*psd = sd;
 
 return ret;
 }
 
+int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx,
+AVFrame *frame, enum AVFrameSideDataType 
type,
+AVBufferRef **buf, AVFrameSideData **psd)
+{
+return ff_frame_new_side_data_from_buf_ext(avctx,
+   >side_data, 
>nb_side_data,
+   type, buf);
+}
+
+int ff_decode_mastering_display_new_ext(const AVCodecContext *avctx,
+AVFrameSideData ***sd, int *nb_sd,
+struct AVMasteringDisplayMetadata 
**mdm)
+{
+AVBufferRef *buf;
+size_t size;
+
+if (side_data_pref(avctx, sd, nb_sd, 
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA)) {
+*mdm = NULL;
+return 0;
+}
+
+*mdm = av_mastering_display_metadata_alloc_size();
+if (!*mdm)
+return AVERROR(ENOMEM);
+
+buf = av_buffer_create((uint8_t *)*mdm, size, NULL, NULL, 0);
+if (!buf) {
+av_freep(mdm);
+return AVERROR(ENOMEM);
+}
+
+if (!av_frame_side_data_add(sd, nb_sd, 
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA,
+, 0)) {
+*mdm = NULL;
+av_buffer_unref();
+return AVERROR(ENOMEM);
+}
+
+return 0;
+}
+
 int ff_decode_mastering_display_new(const AVCodecContext *avctx, AVFrame 
*frame,
 AVMasteringDisplayMetadata **mdm)
 {
-if (side_data_pref(avctx, frame, 
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA)) {
+if (side_data_pref(avctx, >side_data, >nb_side_data,
+   AV_FRAME_DATA_MASTERING_DISPLAY_METADATA)) {
 *mdm = NULL;
 return 0;
 }
@@ -1856,10 +1893,43 @@ int ff_decode_mastering_display_new(const 
AVCodecContext *avctx, AVFrame *frame,
 return 

[FFmpeg-cvslog] avutil/frame: add a flag to allow overwritting existing entries

2024-04-11 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu Mar 28 13:01:47 
2024 -0300| [55621f6fae766dd337b792a99ec0cae3a1e69cb9] | committer: James Almer

avutil/frame: add a flag to allow overwritting existing entries

Enable it only for side data types that don't allow more than one entry.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=55621f6fae766dd337b792a99ec0cae3a1e69cb9
---

 libavutil/frame.c | 59 +--
 libavutil/frame.h | 30 ++--
 libavutil/tests/side_data_array.c | 52 +++---
 tests/ref/fate/side_data_array| 22 +++
 4 files changed, 119 insertions(+), 44 deletions(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index f77e1986bf..d37f1511e8 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -804,15 +804,36 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
 return ret;
 }
 
+static AVFrameSideData *replace_side_data_from_buf(AVFrameSideData *dst,
+   AVBufferRef *buf, int flags)
+{
+if (!(flags & AV_FRAME_SIDE_DATA_FLAG_REPLACE))
+return NULL;
+
+av_dict_free(>metadata);
+dst->buf  = buf;
+dst->data = buf->data;
+dst->size = buf->size;
+return dst;
+}
+
 AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd,
 enum AVFrameSideDataType type,
 size_t size, unsigned int flags)
 {
+const AVSideDataDescriptor *desc = av_frame_side_data_desc(type);
 AVBufferRef *buf = av_buffer_alloc(size);
 AVFrameSideData *ret = NULL;
 
 if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE)
 remove_side_data(sd, nb_sd, type);
+if ((!desc || !(desc->props & AV_SIDE_DATA_PROP_MULTI)) &&
+(ret = (AVFrameSideData *)av_frame_side_data_get(*sd, *nb_sd, type))) {
+ret = replace_side_data_from_buf(ret, buf, flags);
+if (!ret)
+av_buffer_unref();
+return ret;
+}
 
 ret = add_side_data_from_buf(sd, nb_sd, type, buf);
 if (!ret)
@@ -831,6 +852,13 @@ AVFrameSideData *av_frame_side_data_add(AVFrameSideData 
***sd, int *nb_sd,
 
 if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE)
 remove_side_data(sd, nb_sd, type);
+if ((!desc || !(desc->props & AV_SIDE_DATA_PROP_MULTI)) &&
+(sd_dst = (AVFrameSideData *)av_frame_side_data_get(*sd, *nb_sd, 
type))) {
+sd_dst = replace_side_data_from_buf(sd_dst, buf, flags);
+if (sd_dst)
+*pbuf = NULL;
+return sd_dst;
+}
 
 sd_dst = add_side_data_from_buf(sd, nb_sd, type, buf);
 if (!sd_dst)
@@ -843,6 +871,7 @@ AVFrameSideData *av_frame_side_data_add(AVFrameSideData 
***sd, int *nb_sd,
 int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd,
  const AVFrameSideData *src, unsigned int flags)
 {
+const AVSideDataDescriptor *desc;
 AVBufferRef *buf= NULL;
 AVFrameSideData *sd_dst = NULL;
 int  ret= AVERROR_BUG;
@@ -850,13 +879,37 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int 
*nb_sd,
 if (!sd || !src || !nb_sd || (*nb_sd && !*sd))
 return AVERROR(EINVAL);
 
+desc = av_frame_side_data_desc(src->type);
+if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE)
+remove_side_data(sd, nb_sd, src->type);
+if ((!desc || !(desc->props & AV_SIDE_DATA_PROP_MULTI)) &&
+(sd_dst = (AVFrameSideData *)av_frame_side_data_get(*sd, *nb_sd, 
src->type))) {
+AVDictionary *dict = NULL;
+
+if (!(flags & AV_FRAME_SIDE_DATA_FLAG_REPLACE))
+return AVERROR(EEXIST);
+
+ret = av_dict_copy(, src->metadata, 0);
+if (ret < 0)
+return ret;
+
+ret = av_buffer_replace(_dst->buf, src->buf);
+if (ret < 0) {
+av_dict_free();
+return ret;
+}
+
+av_dict_free(_dst->metadata);
+sd_dst->metadata = dict;
+sd_dst->data = src->data;
+sd_dst->size = src->size;
+return 0;
+}
+
 buf = av_buffer_ref(src->buf);
 if (!buf)
 return AVERROR(ENOMEM);
 
-if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE)
-remove_side_data(sd, nb_sd, src->type);
-
 sd_dst = add_side_data_from_buf_ext(sd, nb_sd, src->type, buf,
 src->data, src->size);
 if (!sd_dst) {
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 8d16924432..4885600dce 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -1040,7 +1040,15 @@ const AVSideDataDescriptor *av_frame_side_data_desc(enum 
AVFrameSideDataType typ
  */
 void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd);
 
+/**
+ * Remov

  1   2   3   4   5   6   7   8   9   10   >