From 60fd8374c689a72e46b22b8c2b588c44917d82c4 Mon Sep 17 00:00:00 2001
From: CaiYuHan <240947104@qq.com>
Date: Wed, 15 Sep 2021 10:08:27 +0800
Subject: [PATCH] libavcodec/h2645_parse.c:Add SVC decoding function based on
 Temporal scalability for H.264/AVC

Signed-off-by: CaiYuHan <240947104@qq.com>
---
 libavcodec/h2645_parse.c | 41 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 mode change 100644 => 100755 libavcodec/h2645_parse.c

diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
old mode 100644
new mode 100755
index 6fbe97a..f780755
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -313,12 +313,53 @@ static int hevc_parse_nal_header(H2645NAL *nal, void *logctx)
 static int h264_parse_nal_header(H2645NAL *nal, void *logctx)
 {
     GetBitContext *gb = &nal->gb;
+/**
+ *Add SVC decoding function based on Temporal scalability for H.264/AVC
+*/
+#if SVC_DEC_H264
+	int idr_svc;
+#endif
 
     if (get_bits1(gb) != 0)
         return AVERROR_INVALIDDATA;
 
     nal->ref_idc = get_bits(gb, 2);
     nal->type    = get_bits(gb, 5);
+/**
+ *Add SVC decoding function based on Temporal scalability for H.264/AVC
+*/
+#if SVC_DEC_H264
+	if(nal->type == H264_NAL_EXTEN_SLICE || nal->type == H264_NAL_DEPTH_EXTEN_SLICE)
+	{
+		nal->svc_ext_flag = get_bits1(gb); //svc_extension_flag
+		if(nal->svc_ext_flag)
+		{
+			nal->idr_flag = get_bits1(gb);
+			nal->priority_id = get_bits(gb, 6);
+			nal->no_inter_layer_pred_flag = get_bits1(gb);
+			nal->dependency_id	= get_bits(gb, 3);
+			nal->quality_id = get_bits(gb, 4);
+			nal->itemporal_id = get_bits(gb, 3);
+			nal->use_ref_base_pic_flag = get_bits1(gb);
+			nal->discardable_flag = get_bits1(gb);
+			nal->output_flag = get_bits1(gb);
+			skip_bits(gb,2); //reserved_three_2bits
+		}
+		else //for mvc
+		{
+			nal->idr_flag = -1;
+			nal->priority_id = -1;
+			nal->no_inter_layer_pred_flag = -1;
+			nal->dependency_id	= -1;
+			nal->quality_id = -1;
+			nal->itemporal_id = -1;
+			nal->use_ref_base_pic_flag = -1;
+			nal->discardable_flag = -1;
+			nal->output_flag = -1;
+			skip_bits(gb, 23); //skip 23 bits
+		}
+	}
+#endif
 
     av_log(logctx, AV_LOG_DEBUG,
            "nal_unit_type: %d(%s), nal_ref_idc: %d\n",
-- 
2.29.2

