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

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

diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
old mode 100644
new mode 100755
index dae8bd2..54b731a
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -837,8 +837,12 @@ int ff_h264_decode_ref_pic_marking(H264SliceContext *sl, GetBitContext *gb,
     int i;
     MMCO *mmco = sl->mmco;
     int nb_mmco = 0;
-
-    if (nal->type == H264_NAL_IDR_SLICE) { // FIXME fields
+/**
+ *Add SVC decoding function based on Temporal scalability for H.264/AVC
+*/
+#if SVC_DEC_H264
+    if (nal->type == H264_NAL_IDR_SLICE || (nal->type==H264_NAL_EXTEN_SLICE && nal->svc_ext_flag==1 && nal->idr_flag==1)) { // FIXME fields
+#endif
         skip_bits1(gb); // broken_link
         if (get_bits1(gb)) {
             mmco[0].opcode   = MMCO_LONG;
@@ -892,3 +896,38 @@ int ff_h264_decode_ref_pic_marking(H264SliceContext *sl, GetBitContext *gb,
 
     return 0;
 }
+/**
+ *Add SVC decoding function based on Temporal scalability for H.264/AVC
+*/
+#if SVC_DEC_H264
+int ff_h264_decode_ref_base_pic_marking(H264SliceContext *sl, GetBitContext *gb,
+                                   const H2645NAL *nal, void *logctx)
+{
+    int i;
+    MMCO *mmco = sl->mmco;
+    int nb_mmco = 0;
+
+    sl->explicit_ref_marking = get_bits1(gb);
+    if (sl->explicit_ref_marking) {
+        for (i = 0; i < MAX_MMCO_COUNT; i++) {
+            MMCOOpcode opcode = get_ue_golomb_31(gb);
+
+            if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_LONG2UNUSED ) {
+                unsigned int long_arg = get_ue_golomb_31(gb);
+            }
+
+            if (opcode > (unsigned) MMCO_LONG) {
+                av_log(logctx, AV_LOG_ERROR,
+                       "illegal memory management control operation %d\n",
+                       opcode);
+                return -1;
+            }
+            if (opcode == MMCO_END)
+                break;
+        }
+        nb_mmco = i;
+    }
+
+    return 0;
+}
+#endif
\ No newline at end of file
-- 
2.29.2

