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

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

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
old mode 100644
new mode 100755
index c7e8b28..aa34ed1
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -631,6 +631,14 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
         err = 0;
         switch (nal->type) {
         case H264_NAL_IDR_SLICE:
+/**
+ *Add SVC decoding function based on Temporal scalability for H.264/AVC
+*/
+#if SVC_DEC_H264
+		case H264_NAL_EXTEN_SLICE:
+			if(nal->type==H264_NAL_EXTEN_SLICE && nal->idr_flag!=1)//use for NONIDR of svc_ext
+				goto svc_no_idr;
+#endif
             if ((nal->data[1] & 0xFC) == 0x98) {
                 av_log(h->avctx, AV_LOG_ERROR, "Invalid inter IDR frame\n");
                 h->next_outputed_poc = INT_MIN;
@@ -642,6 +650,12 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
             }
             idr_cleared = 1;
             h->has_recovery_point = 1;
+/**
+ *Add SVC decoding function based on Temporal scalability for H.264/AVC
+*/
+#if SVC_DEC_H264
+svc_no_idr:
+#endif
         case H264_NAL_SLICE:
             h->has_slice = 1;
 
@@ -707,6 +721,18 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
             ff_h264_decode_seq_parameter_set(&nal->gb, avctx, &h->ps, 1);
             break;
         }
+/**
+ *Add SVC decoding function based on Temporal scalability for H.264/AVC
+*/
+#if SVC_DEC_H264
+		case H264_NAL_SUB_SPS:{
+			GetBitContext tmp_gb = nal->gb;
+			ret = ff_h264_decode_subset_seq_parameter_set(&tmp_gb, avctx, &h->ps, 0);
+			if(ret < 0)
+				goto end;
+			break;
+		}
+#endif
         case H264_NAL_PPS:
             if (avctx->hwaccel && avctx->hwaccel->decode_params) {
                 ret = avctx->hwaccel->decode_params(avctx,
-- 
2.29.2

