Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile
@ 2024-06-05 11:37 Andreas Rheinhardt
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 2/7] avformat/vvc: Use put_bytes_output() Andreas Rheinhardt
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: Andreas Rheinhardt @ 2024-06-05 11:37 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

If any of these files (say A) would be changed in such a way
that A acquires a new dependency on another file B, building B
would need to be added to all the rules that lead to A being built.
Yet currently the rules for several files are spread over
the lavc Makefile and the Makefile of the lavc/hevc subdir, making
it more likely to be forgotten. So move the rules for these files
to the lavc/Makefile.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/Makefile      | 4 ++++
 libavcodec/hevc/Makefile | 8 --------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 8ab4398b6c..1a44352906 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -106,6 +106,9 @@ OBJS-$(CONFIG_H264PARSE)               += h264_parse.o h264_ps.o h264data.o \
 OBJS-$(CONFIG_H264PRED)                += h264pred.o
 OBJS-$(CONFIG_H264QPEL)                += h264qpel.o
 OBJS-$(CONFIG_H264_SEI)                += h264_sei.o h2645_sei.o
+OBJS-$(CONFIG_HEVCPARSE)               += h2645data.o h2645_parse.o h2645_vui.o
+OBJS-$(CONFIG_HEVC_SEI)                += h2645_sei.o aom_film_grain.o \
+                                          dynamic_hdr_vivid.o
 OBJS-$(CONFIG_HPELDSP)                 += hpeldsp.o
 OBJS-$(CONFIG_HUFFMAN)                 += huffman.o
 OBJS-$(CONFIG_HUFFYUVDSP)              += huffyuvdsp.o
@@ -427,6 +430,7 @@ OBJS-$(CONFIG_HCA_DECODER)             += hcadec.o
 OBJS-$(CONFIG_HCOM_DECODER)            += hcom.o
 OBJS-$(CONFIG_HDR_DECODER)             += hdrdec.o
 OBJS-$(CONFIG_HDR_ENCODER)             += hdrenc.o
+OBJS-$(CONFIG_HEVC_DECODER)            += aom_film_grain.o h274.o
 OBJS-$(CONFIG_HEVC_AMF_ENCODER)        += amfenc_hevc.o
 OBJS-$(CONFIG_HEVC_CUVID_DECODER)      += cuviddec.o
 OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o
diff --git a/libavcodec/hevc/Makefile b/libavcodec/hevc/Makefile
index 9c385ef3da..93ed4213f6 100644
--- a/libavcodec/hevc/Makefile
+++ b/libavcodec/hevc/Makefile
@@ -2,8 +2,6 @@ clean::
 	$(RM) $(CLEANSUFFIXES:%=libavcodec/hevc/%)
 
 OBJS-$(CONFIG_HEVC_DECODER) += \
-    aom_film_grain.o           \
-    h274.o                     \
     hevc/cabac.o               \
     hevc/data.o                \
     hevc/dsp.o                 \
@@ -18,9 +16,6 @@ OBJS-$(CONFIG_HEVC_PARSER) += \
 
 
 OBJS-$(CONFIG_HEVCPARSE) += \
-    h2645data.o             \
-    h2645_parse.o           \
-    h2645_vui.o             \
     hevc/data.o             \
     hevc/parse.o            \
     hevc/ps.o               \
@@ -28,9 +23,6 @@ OBJS-$(CONFIG_HEVCPARSE) += \
 
 OBJS-$(CONFIG_HEVC_SEI) +=  \
     hevc/sei.o              \
-    h2645_sei.o             \
-    dynamic_hdr_vivid.o     \
-    aom_film_grain.o        \
 
 
 libavcodec/hevc/%.o: CPPFLAGS += -I$(SRC_PATH)/libavcodec/
-- 
2.40.1

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [FFmpeg-devel] [PATCH 2/7] avformat/vvc: Use put_bytes_output()
  2024-06-05 11:37 [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile Andreas Rheinhardt
@ 2024-06-05 11:40 ` Andreas Rheinhardt
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 3/7] avformat/vvc: Don't use ff_copy_bits() Andreas Rheinhardt
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Andreas Rheinhardt @ 2024-06-05 11:40 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

The PutBitContext has just been flushed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/vvc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index ac3209a01b..d8195f0fd2 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -761,7 +761,7 @@ static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc)
             ff_copy_bits(&pbc, vvcc->ptl.general_constraint_info, (vvcc->ptl.num_bytes_constraint_info - 1) * 8);
         put_bits(&pbc, 6, vvcc->ptl.general_constraint_info[vvcc->ptl.num_bytes_constraint_info - 1] & 0x3f);
         flush_put_bits(&pbc);
-        avio_write(pb, buf, put_bytes_count(&pbc, 1));
+        avio_write(pb, buf, put_bytes_output(&pbc));
 
         if (vvcc->num_sublayers > 1) {
             uint8_t ptl_sublayer_level_present_flags = 0;
-- 
2.40.1

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [FFmpeg-devel] [PATCH 3/7] avformat/vvc: Don't use ff_copy_bits()
  2024-06-05 11:37 [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile Andreas Rheinhardt
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 2/7] avformat/vvc: Use put_bytes_output() Andreas Rheinhardt
@ 2024-06-05 11:40 ` Andreas Rheinhardt
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations Andreas Rheinhardt
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Andreas Rheinhardt @ 2024-06-05 11:40 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

There is no benefit in using it: The fast path of copying
is not taken because of misalignment; furthermore we are
only dealing with a few byte here anyway, so simply copy
the bytes manually, avoiding the dependency on bitstream.c
in lavf (which also contains a function that is completely
unused in lavf).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/Makefile    | 1 -
 libavformat/bitstream.c | 1 -
 libavformat/vvc.c       | 4 ++--
 tests/ref/fate/source   | 1 -
 4 files changed, 2 insertions(+), 5 deletions(-)
 delete mode 100644 libavformat/bitstream.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 1c4d9deccd..af31d6f795 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -728,7 +728,6 @@ OBJS-$(CONFIG_LIBZMQ_PROTOCOL)           += libzmq.o
 # Objects duplicated from other libraries for shared builds
 SHLIBOBJS                                += log2_tab.o to_upper4.o
 SHLIBOBJS-$(CONFIG_ISO_MEDIA)            += mpegaudiotabs.o
-SHLIBOBJS-$(CONFIG_ISO_WRITER)           += bitstream.o
 SHLIBOBJS-$(CONFIG_FLV_MUXER)            += mpeg4audio_sample_rates.o
 SHLIBOBJS-$(CONFIG_HLS_DEMUXER)          += ac3_channel_layout_tab.o
 SHLIBOBJS-$(CONFIG_IMAGE_JPEGXL_PIPE_DEMUXER)    += jpegxl_parse.o
diff --git a/libavformat/bitstream.c b/libavformat/bitstream.c
deleted file mode 100644
index 2afda37c30..0000000000
--- a/libavformat/bitstream.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "libavcodec/bitstream.c"
diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index d8195f0fd2..679bb07a4d 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -757,8 +757,8 @@ static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc)
         put_bits(&pbc, 1, vvcc->ptl.ptl_frame_only_constraint_flag);
         put_bits(&pbc, 1, vvcc->ptl.ptl_multilayer_enabled_flag);
         av_assert0(vvcc->ptl.num_bytes_constraint_info);
-        if (vvcc->ptl.num_bytes_constraint_info > 1)
-            ff_copy_bits(&pbc, vvcc->ptl.general_constraint_info, (vvcc->ptl.num_bytes_constraint_info - 1) * 8);
+        for (int i = 0; i < vvcc->ptl.num_bytes_constraint_info - 1; i++)
+            put_bits(&pbc, 8, vvcc->ptl.general_constraint_info[i]);
         put_bits(&pbc, 6, vvcc->ptl.general_constraint_info[vvcc->ptl.num_bytes_constraint_info - 1] & 0x3f);
         flush_put_bits(&pbc);
         avio_write(pb, buf, put_bytes_output(&pbc));
diff --git a/tests/ref/fate/source b/tests/ref/fate/source
index a3beb35093..d7b48a8b85 100644
--- a/tests/ref/fate/source
+++ b/tests/ref/fate/source
@@ -7,7 +7,6 @@ libavdevice/file_open.c
 libavdevice/reverse.c
 libavfilter/file_open.c
 libavfilter/log2_tab.c
-libavformat/bitstream.c
 libavformat/file_open.c
 libavformat/golomb_tab.c
 libavformat/log2_tab.c
-- 
2.40.1

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [FFmpeg-devel] [PATCH 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations
  2024-06-05 11:37 [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile Andreas Rheinhardt
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 2/7] avformat/vvc: Use put_bytes_output() Andreas Rheinhardt
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 3/7] avformat/vvc: Don't use ff_copy_bits() Andreas Rheinhardt
@ 2024-06-05 11:40 ` Andreas Rheinhardt
  2024-06-05 11:53   ` Andreas Rheinhardt
  2024-06-06 13:26   ` Nuo Mi
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 5/7] avformat/vvc: Reindent after the previous commit Andreas Rheinhardt
                   ` (5 subsequent siblings)
  8 siblings, 2 replies; 15+ messages in thread
From: Andreas Rheinhardt @ 2024-06-05 11:40 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

This is the VVC version of 8b5d15530127fea54e934043a64653859de07353.

(Hint: This ensures that the order of NALU arrays is OPI-VPS-SPS-PPS-
Prefix-SEI-Suffix-SEI, regardless of the order in the original
extradata. I hope this is right.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/vvc.c | 169 ++++++++++++++++++++--------------------------
 1 file changed, 73 insertions(+), 96 deletions(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 679bb07a4d..819ee02e2c 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -32,6 +32,16 @@
 #include "avio_internal.h"
 #include "vvc.h"
 
+enum {
+    OPI_INDEX,
+    VPS_INDEX,
+    SPS_INDEX,
+    PPS_INDEX,
+    SEI_PREFIX_INDEX,
+    SEI_SUFFIX_INDEX,
+    NB_ARRAYS
+};
+
 typedef struct VVCCNALUnitArray {
     uint8_t array_completeness;
     uint8_t NAL_unit_type;
@@ -67,7 +77,7 @@ typedef struct VVCDecoderConfigurationRecord {
     uint16_t max_picture_height;
     uint16_t avg_frame_rate;
     uint8_t num_of_arrays;
-    VVCCNALUnitArray *array;
+    VVCCNALUnitArray arrays[NB_ARRAYS];
 } VVCDecoderConfigurationRecord;
 
 static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc,
@@ -432,32 +442,11 @@ static void nal_unit_parse_header(GetBitContext *gb, uint8_t *nal_type)
 
 static int vvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
                                    uint8_t nal_type, int ps_array_completeness,
-                                   VVCDecoderConfigurationRecord *vvcc)
+                                   VVCCNALUnitArray *array)
 {
     int ret;
-    uint8_t index;
     uint16_t num_nalus;
-    VVCCNALUnitArray *array;
-
-    for (index = 0; index < vvcc->num_of_arrays; index++)
-        if (vvcc->array[index].NAL_unit_type == nal_type)
-            break;
-
-    if (index >= vvcc->num_of_arrays) {
-        uint8_t i;
-
-        ret =
-            av_reallocp_array(&vvcc->array, index + 1,
-                              sizeof(VVCCNALUnitArray));
-        if (ret < 0)
-            return ret;
-
-        for (i = vvcc->num_of_arrays; i <= index; i++)
-            memset(&vvcc->array[i], 0, sizeof(VVCCNALUnitArray));
-        vvcc->num_of_arrays = index + 1;
-    }
 
-    array = &vvcc->array[index];
     num_nalus = array->num_nalus;
 
     ret = av_reallocp_array(&array->nal_unit, num_nalus + 1, sizeof(uint8_t *));
@@ -504,7 +493,8 @@ static int vvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
 
 static int vvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
                              int ps_array_completeness,
-                             VVCDecoderConfigurationRecord *vvcc)
+                             VVCDecoderConfigurationRecord *vvcc,
+                             unsigned array_idx)
 {
     int ret = 0;
     GetBitContext gbc;
@@ -529,18 +519,15 @@ static int vvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
      * vvcc. Perhaps the SEI playload type should be checked
      * and non-declarative SEI messages discarded?
      */
-    switch (nal_type) {
-    case VVC_OPI_NUT:
-    case VVC_VPS_NUT:
-    case VVC_SPS_NUT:
-    case VVC_PPS_NUT:
-    case VVC_PREFIX_SEI_NUT:
-    case VVC_SUFFIX_SEI_NUT:
-        ret = vvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
-                                      ps_array_completeness, vvcc);
-        if (ret < 0)
-            goto end;
-        else if (nal_type == VVC_VPS_NUT)
+    ret = vvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
+                                  ps_array_completeness,
+                                  &vvcc->arrays[array_idx]);
+    if (ret < 0)
+        goto end;
+    if (vvcc->arrays[array_idx].num_nalus == 1)
+        vvcc->num_of_arrays++;
+
+        if (nal_type == VVC_VPS_NUT)
             ret = vvcc_parse_vps(&gbc, vvcc);
         else if (nal_type == VVC_SPS_NUT)
             ret = vvcc_parse_sps(&gbc, vvcc);
@@ -551,11 +538,6 @@ static int vvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
         }
         if (ret < 0)
             goto end;
-        break;
-    default:
-        ret = AVERROR_INVALIDDATA;
-        goto end;
-    }
 
   end:
     av_free(rbsp_buf);
@@ -572,22 +554,21 @@ static void vvcc_init(VVCDecoderConfigurationRecord *vvcc)
 
 static void vvcc_close(VVCDecoderConfigurationRecord *vvcc)
 {
-    uint8_t i;
+    for (unsigned i = 0; i < FF_ARRAY_ELEMS(vvcc->arrays); i++) {
+        VVCCNALUnitArray *const array = &vvcc->arrays[i];
 
-    for (i = 0; i < vvcc->num_of_arrays; i++) {
-        vvcc->array[i].num_nalus = 0;
-        av_freep(&vvcc->array[i].nal_unit);
-        av_freep(&vvcc->array[i].nal_unit_length);
+        array->num_nalus = 0;
+        av_freep(&array->nal_unit);
+        av_freep(&array->nal_unit_length);
     }
 
     vvcc->num_of_arrays = 0;
-    av_freep(&vvcc->array);
 }
 
 static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc)
 {
     uint8_t i;
-    uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0;
+    uint16_t vps_count = 0, sps_count = 0, pps_count = 0;
     /*
      * It's unclear how to properly compute these fields, so
      * let's always set them to values meaning 'unspecified'.
@@ -672,40 +653,33 @@ static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc)
     av_log(NULL, AV_LOG_TRACE,
            "num_of_arrays:                       %" PRIu8 "\n",
            vvcc->num_of_arrays);
-    for (i = 0; i < vvcc->num_of_arrays; i++) {
+    for (unsigned i = 0; i < FF_ARRAY_ELEMS(vvcc->arrays); i++) {
+        const VVCCNALUnitArray *const array = &vvcc->arrays[i];
+
+        if (array->num_nalus == 0)
+            continue;
+
         av_log(NULL, AV_LOG_TRACE,
-               "array_completeness[%" PRIu8 "]:               %" PRIu8 "\n", i,
-               vvcc->array[i].array_completeness);
+               "array_completeness[%u]:               %" PRIu8 "\n", i,
+               array->array_completeness);
         av_log(NULL, AV_LOG_TRACE,
-               "NAL_unit_type[%" PRIu8 "]:                    %" PRIu8 "\n", i,
-               vvcc->array[i].NAL_unit_type);
+               "NAL_unit_type[%u]:                    %" PRIu8 "\n", i,
+               array->NAL_unit_type);
         av_log(NULL, AV_LOG_TRACE,
-               "num_nalus[%" PRIu8 "]:                        %" PRIu16 "\n", i,
-               vvcc->array[i].num_nalus);
-        for (j = 0; j < vvcc->array[i].num_nalus; j++)
+               "num_nalus[%u]:                        %" PRIu16 "\n", i,
+               array->num_nalus);
+        for (unsigned j = 0; j < array->num_nalus; j++)
             av_log(NULL, AV_LOG_TRACE,
-                   "nal_unit_length[%" PRIu8 "][%" PRIu16 "]:               %"
-                   PRIu16 "\n", i, j, vvcc->array[i].nal_unit_length[j]);
+                   "nal_unit_length[%u][%u]:               %"
+                   PRIu16 "\n", i, j, array->nal_unit_length[j]);
     }
 
     /*
      * We need at least one of each: VPS and SPS.
      */
-    for (i = 0; i < vvcc->num_of_arrays; i++)
-        switch (vvcc->array[i].NAL_unit_type) {
-        case VVC_VPS_NUT:
-            vps_count += vvcc->array[i].num_nalus;
-            break;
-        case VVC_SPS_NUT:
-            sps_count += vvcc->array[i].num_nalus;
-            break;
-        case VVC_PPS_NUT:
-            pps_count += vvcc->array[i].num_nalus;
-            break;
-        default:
-            break;
-        }
-
+    vps_count = vvcc->arrays[VPS_INDEX].num_nalus;
+    sps_count = vvcc->arrays[SPS_INDEX].num_nalus;
+    pps_count = vvcc->arrays[PPS_INDEX].num_nalus;
     if (vps_count > VVC_MAX_VPS_COUNT)
         return AVERROR_INVALIDDATA;
     if (!sps_count || sps_count > VVC_MAX_SPS_COUNT)
@@ -804,25 +778,29 @@ static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc)
     /* unsigned int(8) num_of_arrays; */
     avio_w8(pb, vvcc->num_of_arrays);
 
-    for (i = 0; i < vvcc->num_of_arrays; i++) {
+    for (unsigned i = 0; i < FF_ARRAY_ELEMS(vvcc->arrays); i++) {
+        const VVCCNALUnitArray *const array = &vvcc->arrays[i];
+
+        if (!array->num_nalus)
+            continue;
         /*
          * bit(1) array_completeness;
          * unsigned int(2) reserved = 0;
          * unsigned int(5) NAL_unit_type;
          */
-        avio_w8(pb, vvcc->array[i].array_completeness << 7 |
-                vvcc->array[i].NAL_unit_type & 0x1f);
+        avio_w8(pb, array->array_completeness << 7 |
+                array->NAL_unit_type & 0x1f);
         /* unsigned int(16) num_nalus; */
-        if (vvcc->array[i].NAL_unit_type != VVC_DCI_NUT &&
-            vvcc->array[i].NAL_unit_type != VVC_OPI_NUT)
-            avio_wb16(pb, vvcc->array[i].num_nalus);
-        for (j = 0; j < vvcc->array[i].num_nalus; j++) {
+        if (array->NAL_unit_type != VVC_DCI_NUT &&
+            array->NAL_unit_type != VVC_OPI_NUT)
+            avio_wb16(pb, array->num_nalus);
+        for (int j = 0; j < array->num_nalus; j++) {
             /* unsigned int(16) nal_unit_length; */
-            avio_wb16(pb, vvcc->array[i].nal_unit_length[j]);
+            avio_wb16(pb, array->nal_unit_length[j]);
 
             /* bit(8*nal_unit_length) nal_unit; */
-            avio_write(pb, vvcc->array[i].nal_unit[j],
-                       vvcc->array[i].nal_unit_length[j]);
+            avio_write(pb, array->nal_unit[j],
+                       array->nal_unit_length[j]);
         }
     }
 
@@ -932,19 +910,18 @@ int ff_isom_write_vvcc(AVIOContext *pb, const uint8_t *data,
 
         buf += 4;
 
-        switch (type) {
-        case VVC_OPI_NUT:
-        case VVC_VPS_NUT:
-        case VVC_SPS_NUT:
-        case VVC_PPS_NUT:
-        case VVC_PREFIX_SEI_NUT:
-        case VVC_SUFFIX_SEI_NUT:
-            ret = vvcc_add_nal_unit(buf, len, ps_array_completeness, &vvcc);
-            if (ret < 0)
-                goto end;
-            break;
-        default:
-            break;
+        for (unsigned i = 0; i < FF_ARRAY_ELEMS(vvcc.arrays); i++) {
+            static const uint8_t array_idx_to_type[] =
+                { VVC_OPI_NUT, VVC_VPS_NUT, VVC_SPS_NUT,
+                  VVC_PPS_NUT, VVC_PREFIX_SEI_NUT, VVC_SUFFIX_SEI_NUT };
+
+            if (type == array_idx_to_type[i]) {
+                ret = vvcc_add_nal_unit(buf, len, ps_array_completeness,
+                                        &vvcc, i);
+                if (ret < 0)
+                    goto end;
+                break;
+            }
         }
 
         buf += len;
-- 
2.40.1

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [FFmpeg-devel] [PATCH 5/7] avformat/vvc: Reindent after the previous commit
  2024-06-05 11:37 [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile Andreas Rheinhardt
                   ` (2 preceding siblings ...)
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations Andreas Rheinhardt
@ 2024-06-05 11:40 ` Andreas Rheinhardt
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 6/7] avformat/evc: Fix format specifiers Andreas Rheinhardt
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Andreas Rheinhardt @ 2024-06-05 11:40 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/vvc.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 819ee02e2c..3821de7812 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -527,17 +527,17 @@ static int vvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
     if (vvcc->arrays[array_idx].num_nalus == 1)
         vvcc->num_of_arrays++;
 
-        if (nal_type == VVC_VPS_NUT)
-            ret = vvcc_parse_vps(&gbc, vvcc);
-        else if (nal_type == VVC_SPS_NUT)
-            ret = vvcc_parse_sps(&gbc, vvcc);
-        else if (nal_type == VVC_PPS_NUT)
-            ret = vvcc_parse_pps(&gbc, vvcc);
-        else if (nal_type == VVC_OPI_NUT) {
-            // not yet supported
-        }
-        if (ret < 0)
-            goto end;
+    if (nal_type == VVC_VPS_NUT)
+        ret = vvcc_parse_vps(&gbc, vvcc);
+    else if (nal_type == VVC_SPS_NUT)
+        ret = vvcc_parse_sps(&gbc, vvcc);
+    else if (nal_type == VVC_PPS_NUT)
+        ret = vvcc_parse_pps(&gbc, vvcc);
+    else if (nal_type == VVC_OPI_NUT) {
+        // not yet supported
+    }
+    if (ret < 0)
+        goto end;
 
   end:
     av_free(rbsp_buf);
-- 
2.40.1

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [FFmpeg-devel] [PATCH 6/7] avformat/evc: Fix format specifiers
  2024-06-05 11:37 [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile Andreas Rheinhardt
                   ` (3 preceding siblings ...)
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 5/7] avformat/vvc: Reindent after the previous commit Andreas Rheinhardt
@ 2024-06-05 11:40 ` Andreas Rheinhardt
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 7/7] avcodec/cbs_h266_syntax_template: Use correct format specifier Andreas Rheinhardt
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Andreas Rheinhardt @ 2024-06-05 11:40 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Fixes -Wformat warnings; see e.g.
https://fate.ffmpeg.org/log.cgi?slot=aarch64-osx-clang-1200.0.32.29&time=20240604151047&log=compile

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/evc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/evc.c b/libavformat/evc.c
index 2f4c74fe51..0b72a6441e 100644
--- a/libavformat/evc.c
+++ b/libavformat/evc.c
@@ -208,15 +208,15 @@ static int evcc_write(AVIOContext *pb, EVCDecoderConfigurationRecord *evcc)
         if(array->numNalus == 0)
             continue;
 
-        av_log(NULL, AV_LOG_TRACE, "array_completeness[%"PRIu8"]:               %"PRIu8"\n",
+        av_log(NULL, AV_LOG_TRACE, "array_completeness[%u]:               %"PRIu8"\n",
                i, array->array_completeness);
-        av_log(NULL, AV_LOG_TRACE, "NAL_unit_type[%"PRIu8"]:                    %"PRIu8"\n",
+        av_log(NULL, AV_LOG_TRACE, "NAL_unit_type[%u]:                    %"PRIu8"\n",
                i, array->NAL_unit_type);
-        av_log(NULL, AV_LOG_TRACE, "numNalus[%"PRIu8"]:                         %"PRIu16"\n",
+        av_log(NULL, AV_LOG_TRACE, "numNalus[%u]:                         %"PRIu16"\n",
                i, array->numNalus);
         for ( unsigned j = 0; j < array->numNalus; j++)
             av_log(NULL, AV_LOG_TRACE,
-                   "nalUnitLength[%"PRIu8"][%"PRIu16"]:                 %"PRIu16"\n",
+                   "nalUnitLength[%u][%u]:                 %"PRIu16"\n",
                    i, j, array->nalUnitLength[j]);
     }
 
-- 
2.40.1

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [FFmpeg-devel] [PATCH 7/7] avcodec/cbs_h266_syntax_template: Use correct format specifier
  2024-06-05 11:37 [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile Andreas Rheinhardt
                   ` (4 preceding siblings ...)
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 6/7] avformat/evc: Fix format specifiers Andreas Rheinhardt
@ 2024-06-05 11:40 ` Andreas Rheinhardt
  2024-06-08 21:13 ` [FFmpeg-devel] [PATCH 8/9] avformat/vvc: Fix comment Andreas Rheinhardt
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Andreas Rheinhardt @ 2024-06-05 11:40 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

H266RawSliceHeader.num_entry_points is an uint32_t.
Fixes -Wformat warnings:
https://fate.ffmpeg.org/log.cgi?slot=aarch64-osx-clang-1200.0.32.29&time=20240604151047&log=compile

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/cbs_h266_syntax_template.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c
index 38685704c5..53c4b60b0d 100644
--- a/libavcodec/cbs_h266_syntax_template.c
+++ b/libavcodec/cbs_h266_syntax_template.c
@@ -3426,7 +3426,7 @@ static int FUNC(slice_header) (CodedBitstreamContext *ctx, RWContext *rw,
         current->num_entry_points--;
         if (current->num_entry_points > VVC_MAX_ENTRY_POINTS) {
             av_log(ctx->log_ctx, AV_LOG_ERROR, "Too many entry points: "
-                   "%" PRIu16 ".\n", current->num_entry_points);
+                   "%" PRIu32 ".\n", current->num_entry_points);
             return AVERROR_PATCHWELCOME;
         }
         if (current->num_entry_points > 0) {
-- 
2.40.1

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [FFmpeg-devel] [PATCH 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations Andreas Rheinhardt
@ 2024-06-05 11:53   ` Andreas Rheinhardt
  2024-06-06 13:11     ` Nuo Mi
  2024-06-06 13:26   ` Nuo Mi
  1 sibling, 1 reply; 15+ messages in thread
From: Andreas Rheinhardt @ 2024-06-05 11:53 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> This is the VVC version of 8b5d15530127fea54e934043a64653859de07353.
> 
> (Hint: This ensures that the order of NALU arrays is OPI-VPS-SPS-PPS-
> Prefix-SEI-Suffix-SEI, regardless of the order in the original
> extradata. I hope this is right.)
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavformat/vvc.c | 169 ++++++++++++++++++++--------------------------
>  1 file changed, 73 insertions(+), 96 deletions(-)
> 

Even after these patches, there are some strange things going in vvc.c:
1. There are at least 71 bits in general_constraint_info (if present),
yet only 70 of these are written (the
gci_no_chroma_qp_offset_constraint_flag is not).
2. The code contains checks for VVC_DCI_NUT, yet these are dead, because
these NALU type is filtered out before.
3. A comment claims to need at least one VPS and SPS, but it actually
checks for SPS and PPS. Does someone know what was intended?

- Andreas

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [FFmpeg-devel] [PATCH 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations
  2024-06-05 11:53   ` Andreas Rheinhardt
@ 2024-06-06 13:11     ` Nuo Mi
  0 siblings, 0 replies; 15+ messages in thread
From: Nuo Mi @ 2024-06-06 13:11 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Wed, Jun 5, 2024 at 7:53 PM Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:

> Andreas Rheinhardt:
> > This is the VVC version of 8b5d15530127fea54e934043a64653859de07353.
> >
> > (Hint: This ensures that the order of NALU arrays is OPI-VPS-SPS-PPS-
> > Prefix-SEI-Suffix-SEI, regardless of the order in the original
> > extradata. I hope this is right.)
> >
> > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> > ---
> >  libavformat/vvc.c | 169 ++++++++++++++++++++--------------------------
> >  1 file changed, 73 insertions(+), 96 deletions(-)
> >
>
> Even after these patches, there are some strange things going in vvc.c:
> 1. There are at least 71 bits in general_constraint_info (if present),
> yet only 70 of these are written (the
> gci_no_chroma_qp_offset_constraint_flag is not).
>
Not sure why this happened, but 14496-15 said  this
see the comment:
        /*
         * 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 */
 8*9-2 = 70.
vvcc_parse_ptl parses the information from vps or sps.
vvcc_write writes VvcDecoderConfigurationRecord, it's not a bit-to-bit map.
I guess.

2. The code contains checks for VVC_DCI_NUT, yet these are dead, because
> these NALU type is filtered out before.
>
it's from the spec, see "if (NAL_unit_type != DCI_NUT  &&  NAL_unit_type !=
OPI_NUT)" in  https://cloud.tencent.com/developer/article/2227294
num_nalus is inferred as 1 if it does not exist. Maybe we can add a check

3. A comment claims to need at least one VPS and SPS, but it actually
> checks for SPS and PPS. Does someone know what was intended?
>
it's a typo. VPS is optional, SPS and PPS are mandatory.

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [FFmpeg-devel] [PATCH 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations Andreas Rheinhardt
  2024-06-05 11:53   ` Andreas Rheinhardt
@ 2024-06-06 13:26   ` Nuo Mi
  2024-06-08 21:13     ` Andreas Rheinhardt
  1 sibling, 1 reply; 15+ messages in thread
From: Nuo Mi @ 2024-06-06 13:26 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Wed, Jun 5, 2024 at 7:41 PM Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:

> This is the VVC version of 8b5d15530127fea54e934043a64653859de07353.
>
> (Hint: This ensures that the order of NALU arrays is OPI-VPS-SPS-PPS-
> Prefix-SEI-Suffix-SEI, regardless of the order in the original
> extradata. I hope this is right.)
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavformat/vvc.c | 169 ++++++++++++++++++++--------------------------
>  1 file changed, 73 insertions(+), 96 deletions(-)
>
> diff --git a/libavformat/vvc.c b/libavformat/vvc.c
> index 679bb07a4d..819ee02e2c 100644
> --- a/libavformat/vvc.c
> +++ b/libavformat/vvc.c
> @@ -32,6 +32,16 @@
>  #include "avio_internal.h"
>  #include "vvc.h"
>
> +enum {
> +    OPI_INDEX,
> +    VPS_INDEX,
> +    SPS_INDEX,
> +    PPS_INDEX,
> +    SEI_PREFIX_INDEX,
> +    SEI_SUFFIX_INDEX,
> +    NB_ARRAYS
> +};
> +
>  typedef struct VVCCNALUnitArray {
>      uint8_t array_completeness;
>      uint8_t NAL_unit_type;
> @@ -67,7 +77,7 @@ typedef struct VVCDecoderConfigurationRecord {
>      uint16_t max_picture_height;
>      uint16_t avg_frame_rate;
>      uint8_t num_of_arrays;
> -    VVCCNALUnitArray *array;
> +    VVCCNALUnitArray arrays[NB_ARRAYS];
>  } VVCDecoderConfigurationRecord;
>
>  static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc,
> @@ -432,32 +442,11 @@ static void nal_unit_parse_header(GetBitContext *gb,
> uint8_t *nal_type)
>
>  static int vvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
>                                     uint8_t nal_type, int
> ps_array_completeness,
> -                                   VVCDecoderConfigurationRecord *vvcc)
> +                                   VVCCNALUnitArray *array)
>  {
>      int ret;
> -    uint8_t index;
>      uint16_t num_nalus;
> -    VVCCNALUnitArray *array;
> -
> -    for (index = 0; index < vvcc->num_of_arrays; index++)
> -        if (vvcc->array[index].NAL_unit_type == nal_type)
> -            break;
> -
> -    if (index >= vvcc->num_of_arrays) {
> -        uint8_t i;
> -
> -        ret =
> -            av_reallocp_array(&vvcc->array, index + 1,
> -                              sizeof(VVCCNALUnitArray));
> -        if (ret < 0)
> -            return ret;
> -
> -        for (i = vvcc->num_of_arrays; i <= index; i++)
> -            memset(&vvcc->array[i], 0, sizeof(VVCCNALUnitArray));
> -        vvcc->num_of_arrays = index + 1;
> -    }
>
> -    array = &vvcc->array[index];
>      num_nalus = array->num_nalus;
>
>      ret = av_reallocp_array(&array->nal_unit, num_nalus + 1,
> sizeof(uint8_t *));
> @@ -504,7 +493,8 @@ static int vvcc_array_add_nal_unit(uint8_t *nal_buf,
> uint32_t nal_size,
>
>  static int vvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
>                               int ps_array_completeness,
> -                             VVCDecoderConfigurationRecord *vvcc)
> +                             VVCDecoderConfigurationRecord *vvcc,
> +                             unsigned array_idx)
>  {
>      int ret = 0;
>      GetBitContext gbc;
> @@ -529,18 +519,15 @@ static int vvcc_add_nal_unit(uint8_t *nal_buf,
> uint32_t nal_size,
>       * vvcc. Perhaps the SEI playload type should be checked
>       * and non-declarative SEI messages discarded?
>       */
> -    switch (nal_type) {
> -    case VVC_OPI_NUT:
> -    case VVC_VPS_NUT:
> -    case VVC_SPS_NUT:
> -    case VVC_PPS_NUT:
> -    case VVC_PREFIX_SEI_NUT:
> -    case VVC_SUFFIX_SEI_NUT:
> -        ret = vvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
> -                                      ps_array_completeness, vvcc);
> -        if (ret < 0)
> -            goto end;
> -        else if (nal_type == VVC_VPS_NUT)
> +    ret = vvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
> +                                  ps_array_completeness,
> +                                  &vvcc->arrays[array_idx]);
> +    if (ret < 0)
> +        goto end;
> +    if (vvcc->arrays[array_idx].num_nalus == 1)
> +        vvcc->num_of_arrays++;
> +
> +        if (nal_type == VVC_VPS_NUT)
>              ret = vvcc_parse_vps(&gbc, vvcc);
>          else if (nal_type == VVC_SPS_NUT)
>              ret = vvcc_parse_sps(&gbc, vvcc);
> @@ -551,11 +538,6 @@ static int vvcc_add_nal_unit(uint8_t *nal_buf,
> uint32_t nal_size,
>          }
>          if (ret < 0)
>              goto end;
> -        break;
> -    default:
> -        ret = AVERROR_INVALIDDATA;
> -        goto end;
> -    }
>
>    end:
>      av_free(rbsp_buf);
> @@ -572,22 +554,21 @@ static void vvcc_init(VVCDecoderConfigurationRecord
> *vvcc)
>
>  static void vvcc_close(VVCDecoderConfigurationRecord *vvcc)
>  {
> -    uint8_t i;
> +    for (unsigned i = 0; i < FF_ARRAY_ELEMS(vvcc->arrays); i++) {
> +        VVCCNALUnitArray *const array = &vvcc->arrays[i];
>
> -    for (i = 0; i < vvcc->num_of_arrays; i++) {
> -        vvcc->array[i].num_nalus = 0;
> -        av_freep(&vvcc->array[i].nal_unit);
> -        av_freep(&vvcc->array[i].nal_unit_length);
> +        array->num_nalus = 0;
> +        av_freep(&array->nal_unit);
> +        av_freep(&array->nal_unit_length);
>      }
>
>      vvcc->num_of_arrays = 0;
> -    av_freep(&vvcc->array);
>  }
>
>  static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord
> *vvcc)
>  {
>      uint8_t i;
> -    uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0;
> +    uint16_t vps_count = 0, sps_count = 0, pps_count = 0;
>      /*
>       * It's unclear how to properly compute these fields, so
>       * let's always set them to values meaning 'unspecified'.
> @@ -672,40 +653,33 @@ static int vvcc_write(AVIOContext *pb,
> VVCDecoderConfigurationRecord *vvcc)
>      av_log(NULL, AV_LOG_TRACE,
>             "num_of_arrays:                       %" PRIu8 "\n",
>             vvcc->num_of_arrays);
> -    for (i = 0; i < vvcc->num_of_arrays; i++) {
> +    for (unsigned i = 0; i < FF_ARRAY_ELEMS(vvcc->arrays); i++) {
>
this will shadow the "uint8_t i"

> +        const VVCCNALUnitArray *const array = &vvcc->arrays[i];
> +
> +        if (array->num_nalus == 0)
> +            continue;
> +
>          av_log(NULL, AV_LOG_TRACE,
> -               "array_completeness[%" PRIu8 "]:               %" PRIu8
> "\n", i,
> -               vvcc->array[i].array_completeness);
> +               "array_completeness[%u]:               %" PRIu8 "\n", i,
> +               array->array_completeness);
>          av_log(NULL, AV_LOG_TRACE,
> -               "NAL_unit_type[%" PRIu8 "]:                    %" PRIu8
> "\n", i,
> -               vvcc->array[i].NAL_unit_type);
> +               "NAL_unit_type[%u]:                    %" PRIu8 "\n", i,
> +               array->NAL_unit_type);
>          av_log(NULL, AV_LOG_TRACE,
> -               "num_nalus[%" PRIu8 "]:                        %" PRIu16
> "\n", i,
> -               vvcc->array[i].num_nalus);
> -        for (j = 0; j < vvcc->array[i].num_nalus; j++)
> +               "num_nalus[%u]:                        %" PRIu16 "\n", i,
> +               array->num_nalus);
> +        for (unsigned j = 0; j < array->num_nalus; j++)
>              av_log(NULL, AV_LOG_TRACE,
> -                   "nal_unit_length[%" PRIu8 "][%" PRIu16 "]:
>    %"
> -                   PRIu16 "\n", i, j, vvcc->array[i].nal_unit_length[j]);
> +                   "nal_unit_length[%u][%u]:               %"
> +                   PRIu16 "\n", i, j, array->nal_unit_length[j]);
>      }
>
>      /*
>       * We need at least one of each: VPS and SPS.
>       */
> -    for (i = 0; i < vvcc->num_of_arrays; i++)
> -        switch (vvcc->array[i].NAL_unit_type) {
> -        case VVC_VPS_NUT:
> -            vps_count += vvcc->array[i].num_nalus;
> -            break;
> -        case VVC_SPS_NUT:
> -            sps_count += vvcc->array[i].num_nalus;
> -            break;
> -        case VVC_PPS_NUT:
> -            pps_count += vvcc->array[i].num_nalus;
> -            break;
> -        default:
> -            break;
> -        }
> -
> +    vps_count = vvcc->arrays[VPS_INDEX].num_nalus;
> +    sps_count = vvcc->arrays[SPS_INDEX].num_nalus;
> +    pps_count = vvcc->arrays[PPS_INDEX].num_nalus;
>      if (vps_count > VVC_MAX_VPS_COUNT)
>          return AVERROR_INVALIDDATA;
>      if (!sps_count || sps_count > VVC_MAX_SPS_COUNT)
> @@ -804,25 +778,29 @@ static int vvcc_write(AVIOContext *pb,
> VVCDecoderConfigurationRecord *vvcc)
>      /* unsigned int(8) num_of_arrays; */
>      avio_w8(pb, vvcc->num_of_arrays);
>
> -    for (i = 0; i < vvcc->num_of_arrays; i++) {
> +    for (unsigned i = 0; i < FF_ARRAY_ELEMS(vvcc->arrays); i++) {
> +        const VVCCNALUnitArray *const array = &vvcc->arrays[i];
> +
> +        if (!array->num_nalus)
> +            continue;
>          /*
>           * bit(1) array_completeness;
>           * unsigned int(2) reserved = 0;
>           * unsigned int(5) NAL_unit_type;
>           */
> -        avio_w8(pb, vvcc->array[i].array_completeness << 7 |
> -                vvcc->array[i].NAL_unit_type & 0x1f);
> +        avio_w8(pb, array->array_completeness << 7 |
> +                array->NAL_unit_type & 0x1f);
>          /* unsigned int(16) num_nalus; */
> -        if (vvcc->array[i].NAL_unit_type != VVC_DCI_NUT &&
> -            vvcc->array[i].NAL_unit_type != VVC_OPI_NUT)
> -            avio_wb16(pb, vvcc->array[i].num_nalus);
> -        for (j = 0; j < vvcc->array[i].num_nalus; j++) {
> +        if (array->NAL_unit_type != VVC_DCI_NUT &&
> +            array->NAL_unit_type != VVC_OPI_NUT)
> +            avio_wb16(pb, array->num_nalus);
> +        for (int j = 0; j < array->num_nalus; j++) {
>              /* unsigned int(16) nal_unit_length; */
> -            avio_wb16(pb, vvcc->array[i].nal_unit_length[j]);
> +            avio_wb16(pb, array->nal_unit_length[j]);
>
>              /* bit(8*nal_unit_length) nal_unit; */
> -            avio_write(pb, vvcc->array[i].nal_unit[j],
> -                       vvcc->array[i].nal_unit_length[j]);
> +            avio_write(pb, array->nal_unit[j],
> +                       array->nal_unit_length[j]);
>          }
>      }
>
> @@ -932,19 +910,18 @@ int ff_isom_write_vvcc(AVIOContext *pb, const
> uint8_t *data,
>
>          buf += 4;
>
> -        switch (type) {
> -        case VVC_OPI_NUT:
> -        case VVC_VPS_NUT:
> -        case VVC_SPS_NUT:
> -        case VVC_PPS_NUT:
> -        case VVC_PREFIX_SEI_NUT:
> -        case VVC_SUFFIX_SEI_NUT:
> -            ret = vvcc_add_nal_unit(buf, len, ps_array_completeness,
> &vvcc);
> -            if (ret < 0)
> -                goto end;
> -            break;
> -        default:
> -            break;
> +        for (unsigned i = 0; i < FF_ARRAY_ELEMS(vvcc.arrays); i++) {
> +            static const uint8_t array_idx_to_type[] =
> +                { VVC_OPI_NUT, VVC_VPS_NUT, VVC_SPS_NUT,
> +                  VVC_PPS_NUT, VVC_PREFIX_SEI_NUT, VVC_SUFFIX_SEI_NUT };
> +
> +            if (type == array_idx_to_type[i]) {
> +                ret = vvcc_add_nal_unit(buf, len, ps_array_completeness,
> +                                        &vvcc, i);
> +                if (ret < 0)
> +                    goto end;
> +                break;
> +            }
>          }
>
>          buf += len;
> --
> 2.40.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [FFmpeg-devel] [PATCH 8/9] avformat/vvc: Fix comment
  2024-06-05 11:37 [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile Andreas Rheinhardt
                   ` (5 preceding siblings ...)
  2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 7/7] avcodec/cbs_h266_syntax_template: Use correct format specifier Andreas Rheinhardt
@ 2024-06-08 21:13 ` Andreas Rheinhardt
  2024-06-08 21:13 ` [FFmpeg-devel] [PATCH 9/9] avformat/vvc: Don't use uint8_t iterators, fix shadowing Andreas Rheinhardt
  2024-06-08 21:20 ` [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile Andreas Rheinhardt
  8 siblings, 0 replies; 15+ messages in thread
From: Andreas Rheinhardt @ 2024-06-08 21:13 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/vvc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 3821de7812..595492cd1e 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -675,7 +675,7 @@ static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc)
     }
 
     /*
-     * We need at least one of each: VPS and SPS.
+     * We need at least one of each: SPS and PPS.
      */
     vps_count = vvcc->arrays[VPS_INDEX].num_nalus;
     sps_count = vvcc->arrays[SPS_INDEX].num_nalus;
-- 
2.40.1

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [FFmpeg-devel] [PATCH 9/9] avformat/vvc: Don't use uint8_t iterators, fix shadowing
  2024-06-05 11:37 [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile Andreas Rheinhardt
                   ` (6 preceding siblings ...)
  2024-06-08 21:13 ` [FFmpeg-devel] [PATCH 8/9] avformat/vvc: Fix comment Andreas Rheinhardt
@ 2024-06-08 21:13 ` Andreas Rheinhardt
  2024-06-08 21:20 ` [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile Andreas Rheinhardt
  8 siblings, 0 replies; 15+ messages in thread
From: Andreas Rheinhardt @ 2024-06-08 21:13 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/vvc.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 595492cd1e..3a686c9910 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -567,7 +567,6 @@ static void vvcc_close(VVCDecoderConfigurationRecord *vvcc)
 
 static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc)
 {
-    uint8_t i;
     uint16_t vps_count = 0, sps_count = 0, pps_count = 0;
     /*
      * It's unclear how to properly compute these fields, so
@@ -615,18 +614,18 @@ static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc)
     av_log(NULL, AV_LOG_TRACE,
            "ptl_multilayer_enabled_flag:         %" PRIu8 "\n",
            vvcc->ptl.ptl_multilayer_enabled_flag);
-    for (i = 0; i < vvcc->ptl.num_bytes_constraint_info; i++) {
+    for (int i = 0; i < vvcc->ptl.num_bytes_constraint_info; i++) {
         av_log(NULL, AV_LOG_TRACE,
                "general_constraint_info[%d]:          %" PRIu8 "\n", i,
                vvcc->ptl.general_constraint_info[i]);
     }
 
-    for (i = 0; i < vvcc->num_sublayers - 1; i++) {
+    for (int i = 0; i < vvcc->num_sublayers - 1; i++) {
         av_log(NULL, AV_LOG_TRACE,
-               "ptl_sublayer_level_present_flag[%" PRIu8 "]:  %" PRIu8 "\n", i,
+               "ptl_sublayer_level_present_flag[%d]:  %" PRIu8 "\n", i,
                vvcc->ptl.ptl_sublayer_level_present_flag[i]);
         av_log(NULL, AV_LOG_TRACE,
-               "sublayer_level_idc[%" PRIu8 "]: %" PRIu8 "\n", i,
+               "sublayer_level_idc[%d]: %" PRIu8 "\n", i,
                vvcc->ptl.sublayer_level_idc[i]);
     }
 
@@ -634,9 +633,9 @@ static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc)
            "num_sub_profiles:                    %" PRIu8 "\n",
            vvcc->ptl.ptl_num_sub_profiles);
 
-    for (i = 0; i < vvcc->ptl.ptl_num_sub_profiles; i++) {
+    for (unsigned i = 0; i < vvcc->ptl.ptl_num_sub_profiles; i++) {
         av_log(NULL, AV_LOG_TRACE,
-               "general_sub_profile_idc[%" PRIu8 "]:         %" PRIx32 "\n", i,
+               "general_sub_profile_idc[%u]:         %" PRIx32 "\n", i,
                vvcc->ptl.general_sub_profile_idc[i]);
     }
 
-- 
2.40.1

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [FFmpeg-devel] [PATCH 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations
  2024-06-06 13:26   ` Nuo Mi
@ 2024-06-08 21:13     ` Andreas Rheinhardt
  2024-06-09  0:25       ` Nuo Mi
  0 siblings, 1 reply; 15+ messages in thread
From: Andreas Rheinhardt @ 2024-06-08 21:13 UTC (permalink / raw)
  To: ffmpeg-devel

Nuo Mi:
> On Wed, Jun 5, 2024 at 7:41 PM Andreas Rheinhardt <
> andreas.rheinhardt@outlook.com> wrote:
> 
>> This is the VVC version of 8b5d15530127fea54e934043a64653859de07353.
>>
>> (Hint: This ensures that the order of NALU arrays is OPI-VPS-SPS-PPS-
>> Prefix-SEI-Suffix-SEI, regardless of the order in the original
>> extradata. I hope this is right.)
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>>  libavformat/vvc.c | 169 ++++++++++++++++++++--------------------------
>>  1 file changed, 73 insertions(+), 96 deletions(-)
>>
>> diff --git a/libavformat/vvc.c b/libavformat/vvc.c
>> index 679bb07a4d..819ee02e2c 100644
>> --- a/libavformat/vvc.c
>> +++ b/libavformat/vvc.c
>> @@ -32,6 +32,16 @@
>>  #include "avio_internal.h"
>>  #include "vvc.h"
>>
>> +enum {
>> +    OPI_INDEX,
>> +    VPS_INDEX,
>> +    SPS_INDEX,
>> +    PPS_INDEX,
>> +    SEI_PREFIX_INDEX,
>> +    SEI_SUFFIX_INDEX,
>> +    NB_ARRAYS
>> +};
>> +
>>  typedef struct VVCCNALUnitArray {
>>      uint8_t array_completeness;
>>      uint8_t NAL_unit_type;
>> @@ -67,7 +77,7 @@ typedef struct VVCDecoderConfigurationRecord {
>>      uint16_t max_picture_height;
>>      uint16_t avg_frame_rate;
>>      uint8_t num_of_arrays;
>> -    VVCCNALUnitArray *array;
>> +    VVCCNALUnitArray arrays[NB_ARRAYS];
>>  } VVCDecoderConfigurationRecord;
>>
>>  static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc,
>> @@ -432,32 +442,11 @@ static void nal_unit_parse_header(GetBitContext *gb,
>> uint8_t *nal_type)
>>
>>  static int vvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
>>                                     uint8_t nal_type, int
>> ps_array_completeness,
>> -                                   VVCDecoderConfigurationRecord *vvcc)
>> +                                   VVCCNALUnitArray *array)
>>  {
>>      int ret;
>> -    uint8_t index;
>>      uint16_t num_nalus;
>> -    VVCCNALUnitArray *array;
>> -
>> -    for (index = 0; index < vvcc->num_of_arrays; index++)
>> -        if (vvcc->array[index].NAL_unit_type == nal_type)
>> -            break;
>> -
>> -    if (index >= vvcc->num_of_arrays) {
>> -        uint8_t i;
>> -
>> -        ret =
>> -            av_reallocp_array(&vvcc->array, index + 1,
>> -                              sizeof(VVCCNALUnitArray));
>> -        if (ret < 0)
>> -            return ret;
>> -
>> -        for (i = vvcc->num_of_arrays; i <= index; i++)
>> -            memset(&vvcc->array[i], 0, sizeof(VVCCNALUnitArray));
>> -        vvcc->num_of_arrays = index + 1;
>> -    }
>>
>> -    array = &vvcc->array[index];
>>      num_nalus = array->num_nalus;
>>
>>      ret = av_reallocp_array(&array->nal_unit, num_nalus + 1,
>> sizeof(uint8_t *));
>> @@ -504,7 +493,8 @@ static int vvcc_array_add_nal_unit(uint8_t *nal_buf,
>> uint32_t nal_size,
>>
>>  static int vvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
>>                               int ps_array_completeness,
>> -                             VVCDecoderConfigurationRecord *vvcc)
>> +                             VVCDecoderConfigurationRecord *vvcc,
>> +                             unsigned array_idx)
>>  {
>>      int ret = 0;
>>      GetBitContext gbc;
>> @@ -529,18 +519,15 @@ static int vvcc_add_nal_unit(uint8_t *nal_buf,
>> uint32_t nal_size,
>>       * vvcc. Perhaps the SEI playload type should be checked
>>       * and non-declarative SEI messages discarded?
>>       */
>> -    switch (nal_type) {
>> -    case VVC_OPI_NUT:
>> -    case VVC_VPS_NUT:
>> -    case VVC_SPS_NUT:
>> -    case VVC_PPS_NUT:
>> -    case VVC_PREFIX_SEI_NUT:
>> -    case VVC_SUFFIX_SEI_NUT:
>> -        ret = vvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
>> -                                      ps_array_completeness, vvcc);
>> -        if (ret < 0)
>> -            goto end;
>> -        else if (nal_type == VVC_VPS_NUT)
>> +    ret = vvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
>> +                                  ps_array_completeness,
>> +                                  &vvcc->arrays[array_idx]);
>> +    if (ret < 0)
>> +        goto end;
>> +    if (vvcc->arrays[array_idx].num_nalus == 1)
>> +        vvcc->num_of_arrays++;
>> +
>> +        if (nal_type == VVC_VPS_NUT)
>>              ret = vvcc_parse_vps(&gbc, vvcc);
>>          else if (nal_type == VVC_SPS_NUT)
>>              ret = vvcc_parse_sps(&gbc, vvcc);
>> @@ -551,11 +538,6 @@ static int vvcc_add_nal_unit(uint8_t *nal_buf,
>> uint32_t nal_size,
>>          }
>>          if (ret < 0)
>>              goto end;
>> -        break;
>> -    default:
>> -        ret = AVERROR_INVALIDDATA;
>> -        goto end;
>> -    }
>>
>>    end:
>>      av_free(rbsp_buf);
>> @@ -572,22 +554,21 @@ static void vvcc_init(VVCDecoderConfigurationRecord
>> *vvcc)
>>
>>  static void vvcc_close(VVCDecoderConfigurationRecord *vvcc)
>>  {
>> -    uint8_t i;
>> +    for (unsigned i = 0; i < FF_ARRAY_ELEMS(vvcc->arrays); i++) {
>> +        VVCCNALUnitArray *const array = &vvcc->arrays[i];
>>
>> -    for (i = 0; i < vvcc->num_of_arrays; i++) {
>> -        vvcc->array[i].num_nalus = 0;
>> -        av_freep(&vvcc->array[i].nal_unit);
>> -        av_freep(&vvcc->array[i].nal_unit_length);
>> +        array->num_nalus = 0;
>> +        av_freep(&array->nal_unit);
>> +        av_freep(&array->nal_unit_length);
>>      }
>>
>>      vvcc->num_of_arrays = 0;
>> -    av_freep(&vvcc->array);
>>  }
>>
>>  static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord
>> *vvcc)
>>  {
>>      uint8_t i;
>> -    uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0;
>> +    uint16_t vps_count = 0, sps_count = 0, pps_count = 0;
>>      /*
>>       * It's unclear how to properly compute these fields, so
>>       * let's always set them to values meaning 'unspecified'.
>> @@ -672,40 +653,33 @@ static int vvcc_write(AVIOContext *pb,
>> VVCDecoderConfigurationRecord *vvcc)
>>      av_log(NULL, AV_LOG_TRACE,
>>             "num_of_arrays:                       %" PRIu8 "\n",
>>             vvcc->num_of_arrays);
>> -    for (i = 0; i < vvcc->num_of_arrays; i++) {
>> +    for (unsigned i = 0; i < FF_ARRAY_ELEMS(vvcc->arrays); i++) {
>>
> this will shadow the "uint8_t i"
> 

I just sent a patch for this (and for fixing the comment).

- Andreas

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile
  2024-06-05 11:37 [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile Andreas Rheinhardt
                   ` (7 preceding siblings ...)
  2024-06-08 21:13 ` [FFmpeg-devel] [PATCH 9/9] avformat/vvc: Don't use uint8_t iterators, fix shadowing Andreas Rheinhardt
@ 2024-06-08 21:20 ` Andreas Rheinhardt
  8 siblings, 0 replies; 15+ messages in thread
From: Andreas Rheinhardt @ 2024-06-08 21:20 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> If any of these files (say A) would be changed in such a way
> that A acquires a new dependency on another file B, building B
> would need to be added to all the rules that lead to A being built.
> Yet currently the rules for several files are spread over
> the lavc Makefile and the Makefile of the lavc/hevc subdir, making
> it more likely to be forgotten. So move the rules for these files
> to the lavc/Makefile.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/Makefile      | 4 ++++
>  libavcodec/hevc/Makefile | 8 --------
>  2 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 8ab4398b6c..1a44352906 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -106,6 +106,9 @@ OBJS-$(CONFIG_H264PARSE)               += h264_parse.o h264_ps.o h264data.o \
>  OBJS-$(CONFIG_H264PRED)                += h264pred.o
>  OBJS-$(CONFIG_H264QPEL)                += h264qpel.o
>  OBJS-$(CONFIG_H264_SEI)                += h264_sei.o h2645_sei.o
> +OBJS-$(CONFIG_HEVCPARSE)               += h2645data.o h2645_parse.o h2645_vui.o
> +OBJS-$(CONFIG_HEVC_SEI)                += h2645_sei.o aom_film_grain.o \
> +                                          dynamic_hdr_vivid.o
>  OBJS-$(CONFIG_HPELDSP)                 += hpeldsp.o
>  OBJS-$(CONFIG_HUFFMAN)                 += huffman.o
>  OBJS-$(CONFIG_HUFFYUVDSP)              += huffyuvdsp.o
> @@ -427,6 +430,7 @@ OBJS-$(CONFIG_HCA_DECODER)             += hcadec.o
>  OBJS-$(CONFIG_HCOM_DECODER)            += hcom.o
>  OBJS-$(CONFIG_HDR_DECODER)             += hdrdec.o
>  OBJS-$(CONFIG_HDR_ENCODER)             += hdrenc.o
> +OBJS-$(CONFIG_HEVC_DECODER)            += aom_film_grain.o h274.o
>  OBJS-$(CONFIG_HEVC_AMF_ENCODER)        += amfenc_hevc.o
>  OBJS-$(CONFIG_HEVC_CUVID_DECODER)      += cuviddec.o
>  OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o
> diff --git a/libavcodec/hevc/Makefile b/libavcodec/hevc/Makefile
> index 9c385ef3da..93ed4213f6 100644
> --- a/libavcodec/hevc/Makefile
> +++ b/libavcodec/hevc/Makefile
> @@ -2,8 +2,6 @@ clean::
>  	$(RM) $(CLEANSUFFIXES:%=libavcodec/hevc/%)
>  
>  OBJS-$(CONFIG_HEVC_DECODER) += \
> -    aom_film_grain.o           \
> -    h274.o                     \
>      hevc/cabac.o               \
>      hevc/data.o                \
>      hevc/dsp.o                 \
> @@ -18,9 +16,6 @@ OBJS-$(CONFIG_HEVC_PARSER) += \
>  
>  
>  OBJS-$(CONFIG_HEVCPARSE) += \
> -    h2645data.o             \
> -    h2645_parse.o           \
> -    h2645_vui.o             \
>      hevc/data.o             \
>      hevc/parse.o            \
>      hevc/ps.o               \
> @@ -28,9 +23,6 @@ OBJS-$(CONFIG_HEVCPARSE) += \
>  
>  OBJS-$(CONFIG_HEVC_SEI) +=  \
>      hevc/sei.o              \
> -    h2645_sei.o             \
> -    dynamic_hdr_vivid.o     \
> -    aom_film_grain.o        \
>  
>  
>  libavcodec/hevc/%.o: CPPFLAGS += -I$(SRC_PATH)/libavcodec/

Will apply patches 1-7 tomorrow unless there are objections.

- Andreas

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [FFmpeg-devel] [PATCH 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations
  2024-06-08 21:13     ` Andreas Rheinhardt
@ 2024-06-09  0:25       ` Nuo Mi
  0 siblings, 0 replies; 15+ messages in thread
From: Nuo Mi @ 2024-06-09  0:25 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sun, Jun 9, 2024 at 5:14 AM Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:

> Nuo Mi:
> > On Wed, Jun 5, 2024 at 7:41 PM Andreas Rheinhardt <
> > andreas.rheinhardt@outlook.com> wrote:
> >
> >> This is the VVC version of 8b5d15530127fea54e934043a64653859de07353.
> >>
> >> (Hint: This ensures that the order of NALU arrays is OPI-VPS-SPS-PPS-
> >> Prefix-SEI-Suffix-SEI, regardless of the order in the original
> >> extradata. I hope this is right.)
> >>
> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> ---
> >>  libavformat/vvc.c | 169 ++++++++++++++++++++--------------------------
> >>  1 file changed, 73 insertions(+), 96 deletions(-)
> >>
> >> diff --git a/libavformat/vvc.c b/libavformat/vvc.c
> >> index 679bb07a4d..819ee02e2c 100644
> >> --- a/libavformat/vvc.c
> >> +++ b/libavformat/vvc.c
> >> @@ -32,6 +32,16 @@
> >>  #include "avio_internal.h"
> >>  #include "vvc.h"
> >>
> >> +enum {
> >> +    OPI_INDEX,
> >> +    VPS_INDEX,
> >> +    SPS_INDEX,
> >> +    PPS_INDEX,
> >> +    SEI_PREFIX_INDEX,
> >> +    SEI_SUFFIX_INDEX,
> >> +    NB_ARRAYS
> >> +};
> >> +
> >>  typedef struct VVCCNALUnitArray {
> >>      uint8_t array_completeness;
> >>      uint8_t NAL_unit_type;
> >> @@ -67,7 +77,7 @@ typedef struct VVCDecoderConfigurationRecord {
> >>      uint16_t max_picture_height;
> >>      uint16_t avg_frame_rate;
> >>      uint8_t num_of_arrays;
> >> -    VVCCNALUnitArray *array;
> >> +    VVCCNALUnitArray arrays[NB_ARRAYS];
> >>  } VVCDecoderConfigurationRecord;
> >>
> >>  static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc,
> >> @@ -432,32 +442,11 @@ static void nal_unit_parse_header(GetBitContext
> *gb,
> >> uint8_t *nal_type)
> >>
> >>  static int vvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
> >>                                     uint8_t nal_type, int
> >> ps_array_completeness,
> >> -                                   VVCDecoderConfigurationRecord *vvcc)
> >> +                                   VVCCNALUnitArray *array)
> >>  {
> >>      int ret;
> >> -    uint8_t index;
> >>      uint16_t num_nalus;
> >> -    VVCCNALUnitArray *array;
> >> -
> >> -    for (index = 0; index < vvcc->num_of_arrays; index++)
> >> -        if (vvcc->array[index].NAL_unit_type == nal_type)
> >> -            break;
> >> -
> >> -    if (index >= vvcc->num_of_arrays) {
> >> -        uint8_t i;
> >> -
> >> -        ret =
> >> -            av_reallocp_array(&vvcc->array, index + 1,
> >> -                              sizeof(VVCCNALUnitArray));
> >> -        if (ret < 0)
> >> -            return ret;
> >> -
> >> -        for (i = vvcc->num_of_arrays; i <= index; i++)
> >> -            memset(&vvcc->array[i], 0, sizeof(VVCCNALUnitArray));
> >> -        vvcc->num_of_arrays = index + 1;
> >> -    }
> >>
> >> -    array = &vvcc->array[index];
> >>      num_nalus = array->num_nalus;
> >>
> >>      ret = av_reallocp_array(&array->nal_unit, num_nalus + 1,
> >> sizeof(uint8_t *));
> >> @@ -504,7 +493,8 @@ static int vvcc_array_add_nal_unit(uint8_t *nal_buf,
> >> uint32_t nal_size,
> >>
> >>  static int vvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
> >>                               int ps_array_completeness,
> >> -                             VVCDecoderConfigurationRecord *vvcc)
> >> +                             VVCDecoderConfigurationRecord *vvcc,
> >> +                             unsigned array_idx)
> >>  {
> >>      int ret = 0;
> >>      GetBitContext gbc;
> >> @@ -529,18 +519,15 @@ static int vvcc_add_nal_unit(uint8_t *nal_buf,
> >> uint32_t nal_size,
> >>       * vvcc. Perhaps the SEI playload type should be checked
> >>       * and non-declarative SEI messages discarded?
> >>       */
> >> -    switch (nal_type) {
> >> -    case VVC_OPI_NUT:
> >> -    case VVC_VPS_NUT:
> >> -    case VVC_SPS_NUT:
> >> -    case VVC_PPS_NUT:
> >> -    case VVC_PREFIX_SEI_NUT:
> >> -    case VVC_SUFFIX_SEI_NUT:
> >> -        ret = vvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
> >> -                                      ps_array_completeness, vvcc);
> >> -        if (ret < 0)
> >> -            goto end;
> >> -        else if (nal_type == VVC_VPS_NUT)
> >> +    ret = vvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
> >> +                                  ps_array_completeness,
> >> +                                  &vvcc->arrays[array_idx]);
> >> +    if (ret < 0)
> >> +        goto end;
> >> +    if (vvcc->arrays[array_idx].num_nalus == 1)
> >> +        vvcc->num_of_arrays++;
> >> +
> >> +        if (nal_type == VVC_VPS_NUT)
> >>              ret = vvcc_parse_vps(&gbc, vvcc);
> >>          else if (nal_type == VVC_SPS_NUT)
> >>              ret = vvcc_parse_sps(&gbc, vvcc);
> >> @@ -551,11 +538,6 @@ static int vvcc_add_nal_unit(uint8_t *nal_buf,
> >> uint32_t nal_size,
> >>          }
> >>          if (ret < 0)
> >>              goto end;
> >> -        break;
> >> -    default:
> >> -        ret = AVERROR_INVALIDDATA;
> >> -        goto end;
> >> -    }
> >>
> >>    end:
> >>      av_free(rbsp_buf);
> >> @@ -572,22 +554,21 @@ static void
> vvcc_init(VVCDecoderConfigurationRecord
> >> *vvcc)
> >>
> >>  static void vvcc_close(VVCDecoderConfigurationRecord *vvcc)
> >>  {
> >> -    uint8_t i;
> >> +    for (unsigned i = 0; i < FF_ARRAY_ELEMS(vvcc->arrays); i++) {
> >> +        VVCCNALUnitArray *const array = &vvcc->arrays[i];
> >>
> >> -    for (i = 0; i < vvcc->num_of_arrays; i++) {
> >> -        vvcc->array[i].num_nalus = 0;
> >> -        av_freep(&vvcc->array[i].nal_unit);
> >> -        av_freep(&vvcc->array[i].nal_unit_length);
> >> +        array->num_nalus = 0;
> >> +        av_freep(&array->nal_unit);
> >> +        av_freep(&array->nal_unit_length);
> >>      }
> >>
> >>      vvcc->num_of_arrays = 0;
> >> -    av_freep(&vvcc->array);
> >>  }
> >>
> >>  static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord
> >> *vvcc)
> >>  {
> >>      uint8_t i;
> >> -    uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0;
> >> +    uint16_t vps_count = 0, sps_count = 0, pps_count = 0;
> >>      /*
> >>       * It's unclear how to properly compute these fields, so
> >>       * let's always set them to values meaning 'unspecified'.
> >> @@ -672,40 +653,33 @@ static int vvcc_write(AVIOContext *pb,
> >> VVCDecoderConfigurationRecord *vvcc)
> >>      av_log(NULL, AV_LOG_TRACE,
> >>             "num_of_arrays:                       %" PRIu8 "\n",
> >>             vvcc->num_of_arrays);
> >> -    for (i = 0; i < vvcc->num_of_arrays; i++) {
> >> +    for (unsigned i = 0; i < FF_ARRAY_ELEMS(vvcc->arrays); i++) {
> >>
> > this will shadow the "uint8_t i"
> >
>
> I just sent a patch for this (and for fixing the comment).
>
LGTM
Thank you, Andreas.


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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-06-09  0:25 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-05 11:37 [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile Andreas Rheinhardt
2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 2/7] avformat/vvc: Use put_bytes_output() Andreas Rheinhardt
2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 3/7] avformat/vvc: Don't use ff_copy_bits() Andreas Rheinhardt
2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations Andreas Rheinhardt
2024-06-05 11:53   ` Andreas Rheinhardt
2024-06-06 13:11     ` Nuo Mi
2024-06-06 13:26   ` Nuo Mi
2024-06-08 21:13     ` Andreas Rheinhardt
2024-06-09  0:25       ` Nuo Mi
2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 5/7] avformat/vvc: Reindent after the previous commit Andreas Rheinhardt
2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 6/7] avformat/evc: Fix format specifiers Andreas Rheinhardt
2024-06-05 11:40 ` [FFmpeg-devel] [PATCH 7/7] avcodec/cbs_h266_syntax_template: Use correct format specifier Andreas Rheinhardt
2024-06-08 21:13 ` [FFmpeg-devel] [PATCH 8/9] avformat/vvc: Fix comment Andreas Rheinhardt
2024-06-08 21:13 ` [FFmpeg-devel] [PATCH 9/9] avformat/vvc: Don't use uint8_t iterators, fix shadowing Andreas Rheinhardt
2024-06-08 21:20 ` [FFmpeg-devel] [PATCH 1/7] avcodec/hevc/Makefile: Move rules for lavc/* files to lavc/Makefile Andreas Rheinhardt

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git