Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 07/11] avformat/hevc: store parameter set and layer IDs in HVCCNALUnit
Date: Wed,  3 Jul 2024 18:26:42 -0300
Message-ID: <20240703212648.48483-7-jamrial@gmail.com> (raw)
In-Reply-To: <20240703212648.48483-1-jamrial@gmail.com>

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/hevc.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/libavformat/hevc.c b/libavformat/hevc.c
index 6fe701032b..f3e5542699 100644
--- a/libavformat/hevc.c
+++ b/libavformat/hevc.c
@@ -45,6 +45,8 @@ enum {
 #define FLAG_IS_NALFF           (1 << 1)
 
 typedef struct HVCCNALUnit {
+    uint8_t nuh_layer_id;
+    uint8_t parameter_set_id;
     uint16_t nalUnitLength;
     const uint8_t *nalUnit;
 } HVCCNALUnit;
@@ -378,17 +380,17 @@ static void skip_sub_layer_ordering_info(GetBitContext *gb)
     get_ue_golomb_long(gb); // max_latency_increase_plus1
 }
 
-static int hvcc_parse_vps(GetBitContext *gb,
+static int hvcc_parse_vps(GetBitContext *gb, HVCCNALUnit *nal,
                           HEVCDecoderConfigurationRecord *hvcc)
 {
     unsigned int vps_max_sub_layers_minus1;
 
+    nal->parameter_set_id = get_bits(gb, 4);
     /*
-     * vps_video_parameter_set_id u(4)
      * vps_reserved_three_2bits   u(2)
      * vps_max_layers_minus1      u(6)
      */
-    skip_bits(gb, 12);
+    skip_bits(gb, 8);
 
     vps_max_sub_layers_minus1 = get_bits(gb, 3);
 
@@ -501,7 +503,7 @@ static int parse_rps(GetBitContext *gb, unsigned int rps_idx,
     return 0;
 }
 
-static int hvcc_parse_sps(GetBitContext *gb,
+static int hvcc_parse_sps(GetBitContext *gb, HVCCNALUnit *nal,
                           HEVCDecoderConfigurationRecord *hvcc)
 {
     unsigned int i, sps_max_sub_layers_minus1, log2_max_pic_order_cnt_lsb_minus4;
@@ -526,7 +528,7 @@ static int hvcc_parse_sps(GetBitContext *gb,
 
     hvcc_parse_ptl(gb, hvcc, sps_max_sub_layers_minus1);
 
-    get_ue_golomb_long(gb); // sps_seq_parameter_set_id
+    nal->parameter_set_id = get_ue_golomb_long(gb);
 
     hvcc->chromaFormat = get_ue_golomb_long(gb);
 
@@ -605,12 +607,12 @@ static int hvcc_parse_sps(GetBitContext *gb,
     return 0;
 }
 
-static int hvcc_parse_pps(GetBitContext *gb,
+static int hvcc_parse_pps(GetBitContext *gb, HVCCNALUnit *nal,
                           HEVCDecoderConfigurationRecord *hvcc)
 {
     uint8_t tiles_enabled_flag, entropy_coding_sync_enabled_flag;
 
-    get_ue_golomb_long(gb); // pps_pic_parameter_set_id
+    nal->parameter_set_id = get_ue_golomb_long(gb); // pps_pic_parameter_set_id
     get_ue_golomb_long(gb); // pps_seq_parameter_set_id
 
     /*
@@ -703,6 +705,7 @@ static int hvcc_add_nal_unit(const uint8_t *nal_buf, uint32_t nal_size,
     int is_nalff = !!(flags & FLAG_IS_NALFF);
     int ps_array_completeness = !!(flags & FLAG_ARRAY_COMPLETENESS);
     HVCCNALUnitArray *const array = &hvcc->arrays[array_idx];
+    HVCCNALUnit *nal;
     GetBitContext gbc;
     uint8_t nal_type, nuh_layer_id;
     uint8_t *rbsp_buf;
@@ -745,16 +748,19 @@ static int hvcc_add_nal_unit(const uint8_t *nal_buf, uint32_t nal_size,
             array->array_completeness = ps_array_completeness;
     }
 
+    nal = &array->nal[array->numNalus-1];
+    nal->nuh_layer_id = nuh_layer_id;
+
     /* Don't parse parameter sets. We already have the needed information*/
     if (is_nalff)
         goto end;
 
     if (nal_type == HEVC_NAL_VPS)
-        ret = hvcc_parse_vps(&gbc, hvcc);
+        ret = hvcc_parse_vps(&gbc, nal, hvcc);
     else if (nal_type == HEVC_NAL_SPS)
-        ret = hvcc_parse_sps(&gbc, hvcc);
+        ret = hvcc_parse_sps(&gbc, nal, hvcc);
     else if (nal_type == HEVC_NAL_PPS)
-        ret = hvcc_parse_pps(&gbc, hvcc);
+        ret = hvcc_parse_pps(&gbc, nal, hvcc);
     if (ret < 0)
         goto end;
 
-- 
2.45.2

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

  parent reply	other threads:[~2024-07-03 21:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-03 21:26 [FFmpeg-devel] [PATCH 01/11] avformat/mov: add support for lhvC box parsing James Almer
2024-07-03 21:26 ` [FFmpeg-devel] [PATCH 02/11] avformat: Add a new stream disposition for multilayer video James Almer
2024-07-03 21:26 ` [FFmpeg-devel] [PATCH 03/11] avformat/mov: Mark streams with a layered HEVC box as multilayer James Almer
2024-07-03 21:26 ` [FFmpeg-devel] [PATCH 04/11] avformat/hevc: don't write NALUs with nuh_layer_id > 0 in hvcC boxes James Almer
2024-07-07 15:46   ` Andreas Rheinhardt
2024-07-07 16:09     ` James Almer
2024-07-03 21:26 ` [FFmpeg-devel] [PATCH 05/11] avformat/hevc: don't write the same array values per nal addition James Almer
2024-07-03 21:26 ` [FFmpeg-devel] [PATCH 06/11] avformat/hevc: use a single array for per-PS NALUs James Almer
2024-07-03 21:26 ` James Almer [this message]
2024-07-03 21:26 ` [FFmpeg-devel] [PATCH 08/11] avformat/hevc: add a function to write a lhvC box James Almer
2024-07-03 21:26 ` [FFmpeg-devel] [PATCH 09/11] avformat/movenc: add support for writing lhvC boxes James Almer
2024-07-03 21:26 ` [FFmpeg-devel] [PATCH 10/11] avformat/movenc: add support for writting vexu boxes James Almer
2024-07-03 21:26 ` [FFmpeg-devel] [PATCH 11/11] avformat/movenc: add support for writting hfov boxes James Almer
2024-07-07 15:21 ` [FFmpeg-devel] [PATCH 01/11] avformat/mov: add support for lhvC box parsing James Almer
2024-07-07 15:43 ` Andreas Rheinhardt
2024-07-07 16:18   ` James Almer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240703212648.48483-7-jamrial@gmail.com \
    --to=jamrial@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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