Do not throw exception when facial image file is invalid. 33/311433/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 21 May 2024 04:30:41 +0000 (13:30 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Tue, 21 May 2024 05:51:30 +0000 (14:51 +0900)
Let we do not throw exception if facial animation file is invalid.
Instead, just return empty animation data.

Change-Id: I16b464f73db44c6653a9d2145630d0891731ee25
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/resources/test-invalid-facial-animation0.json [new file with mode: 0755]
automated-tests/resources/test-invalid-facial-animation1.json [new file with mode: 0755]
automated-tests/resources/test-invalid-facial-animation2.json [new file with mode: 0755]
automated-tests/resources/test-invalid-facial-animation3.json [new file with mode: 0755]
automated-tests/resources/test-invalid-facial-animation4.json [new file with mode: 0755]
automated-tests/resources/test-invalid-facial-animation5.json [new file with mode: 0755]
automated-tests/src/dali-scene3d/utc-Dali-FacialAnimation.cpp
dali-scene3d/public-api/loader/facial-animation-loader.cpp

diff --git a/automated-tests/resources/test-invalid-facial-animation0.json b/automated-tests/resources/test-invalid-facial-animation0.json
new file mode 100755 (executable)
index 0000000..813569d
--- /dev/null
@@ -0,0 +1,3 @@
+{
+  "name": "Facial_Blendshape_Animation",
+}
diff --git a/automated-tests/resources/test-invalid-facial-animation1.json b/automated-tests/resources/test-invalid-facial-animation1.json
new file mode 100755 (executable)
index 0000000..31e08c5
--- /dev/null
@@ -0,0 +1,304 @@
+{
+  "name": "Facial_Blendshape_Animation",
+  "version": "1.2.3",
+  "blendShapes": [
+    {
+      "name": "GEO_1",
+      "fullName": "Facial_Blendshape_Animation:GEO_1",
+      "blendShapeVersion": "3.0",
+      "morphtarget": 68,
+      "morphname": [
+        "EyeBlink_Left",
+        "EyeBlink_Right",
+        "EyeSquint_Left",
+        "EyeSquint_Right",
+        "EyeDown_Left",
+        "EyeDown_Right",
+        "EyeIn_Left",
+        "EyeIn_Right",
+        "EyeOpen_Left",
+        "EyeOpen_Right",
+        "EyeOut_Left",
+        "EyeOut_Right",
+        "EyeUp_Left",
+        "EyeUp_Right",
+        "BrowsDown_Left",
+        "BrowsDown_Right",
+        "BrowsUp_Center",
+        "BrowsUp_Left",
+        "BrowsUp_Right",
+        "JawFwd",
+        "JawLeft",
+        "JawOpen",
+        "JawChew",
+        "JawRight",
+        "MouthLeft",
+        "MouthRight",
+        "MouthFrown_Left",
+        "MouthFrown_Right",
+        "MouthSmile_Left",
+        "MouthSmile_Right",
+        "MouthDimple_Left",
+        "MouthDimple_Right",
+        "LipsStretch_Left",
+        "LipsStretch_Right",
+        "LipsUpperClose",
+        "LipsLowerClose",
+        "LipsUpperUp",
+        "LipsLowerDown",
+        "LipsUpperOpen",
+        "LipsLowerOpen",
+        "LipsFunnel",
+        "LipsPucker",
+        "ChinLowerRaise",
+        "ChinUpperRaise",
+        "Sneer",
+        "Puff",
+        "CheekSquint_Left",
+        "CheekSquint_Right",
+        "HAPPY_48",
+        "HAPPY_49",
+        "HAPPY_50",
+        "HAPPY_51",
+        "HAPPY_52",
+        "ANGRY_53",
+        "ANGRY_54",
+        "ANGRY_55",
+        "DISGUST_56",
+        "DISGUST_57",
+        "SAD_58",
+        "SURPRISE_59",
+        "SURPRISE_60",
+        "Puff_Left",
+        "Puff_Right",
+        "Tongue_Out",
+        "Tongue_Up",
+        "Tongue_Down",
+        "Tongue_Left",
+        "Tongue_Right"
+      ],
+      "key": [
+        [
+          0.05009999871253967,
+          0.05009999871253967,
+          0.25,
+          0.25,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.20000000298023224,
+          0.20000000298023224,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.02250000089406967,
+          0.800000011920929,
+          1.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.8017492890357971,
+          0.6000000238418579,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.30000001192092896,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0
+        ],
+        [
+          0.05530000105500221,
+          0.05530000105500221,
+          0.2759999930858612,
+          0.2759999930858612,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.2207999974489212,
+          0.2207999974489212,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.02742336131632328,
+          0.77920001745224,
+          1.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.8004528880119324,
+          0.6000000238418579,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.3003687560558319,
+          0.0,
+          0.0,
+          0.00038519964437000453,
+          0.001843750011175871,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0
+        ]
+      ]
+    },
+    {
+      "name": "GEO_5",
+      "fullName": "Facial_Blendshape_Animation:GEO_5",
+      "blendShapeVersion": "3.0",
+      "morphtarget": 20,
+      "morphname": [
+        "EyeBlink_Left",
+        "EyeBlink_Right",
+        "EyeSquint_Left",
+        "EyeSquint_Right",
+        "EyeDown_Left",
+        "EyeDown_Right",
+        "EyeIn_Left",
+        "EyeIn_Right",
+        "EyeOpen_Left",
+        "EyeOpen_Right",
+        "EyeOut_Left",
+        "EyeOut_Right",
+        "EyeUp_Left",
+        "EyeUp_Right",
+        "CheekSquint_Left",
+        "CheekSquint_Right",
+        "HAPPY_48",
+        "ANGRY_54",
+        "SAD_58",
+        "SURPRISE_59"
+      ],
+      "key": [
+        [
+          0.05009999871253967,
+          0.05009999871253967,
+          0.25,
+          0.25,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.20000000298023224,
+          0.20000000298023224,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.30000001192092896,
+          0.0,
+          0.0,
+          0.0
+        ],
+        [
+          0.05530000105500221,
+          0.05530000105500221,
+          0.2759999930858612,
+          0.2759999930858612,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.2207999974489212,
+          0.2207999974489212,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.3003687560558319,
+          0.0,
+          0.0,
+          0.0
+        ]
+      ]
+    }
+  ],
+  "shapesAmount": 2,
+  "time": [
+    0,
+    33
+  ],
+  "frames": 3
+}
diff --git a/automated-tests/resources/test-invalid-facial-animation2.json b/automated-tests/resources/test-invalid-facial-animation2.json
new file mode 100755 (executable)
index 0000000..6999a27
--- /dev/null
@@ -0,0 +1,304 @@
+{
+  "name": "Facial_Blendshape_Animation",
+  "version": "1.2.3",
+  "blendShapes": [
+    {
+      "name": "GEO_1",
+      "fullName": "Facial_Blendshape_Animation:GEO_1",
+      "blendShapeVersion": "3.0",
+      "morphtarget": 69,
+      "morphname": [
+        "EyeBlink_Left",
+        "EyeBlink_Right",
+        "EyeSquint_Left",
+        "EyeSquint_Right",
+        "EyeDown_Left",
+        "EyeDown_Right",
+        "EyeIn_Left",
+        "EyeIn_Right",
+        "EyeOpen_Left",
+        "EyeOpen_Right",
+        "EyeOut_Left",
+        "EyeOut_Right",
+        "EyeUp_Left",
+        "EyeUp_Right",
+        "BrowsDown_Left",
+        "BrowsDown_Right",
+        "BrowsUp_Center",
+        "BrowsUp_Left",
+        "BrowsUp_Right",
+        "JawFwd",
+        "JawLeft",
+        "JawOpen",
+        "JawChew",
+        "JawRight",
+        "MouthLeft",
+        "MouthRight",
+        "MouthFrown_Left",
+        "MouthFrown_Right",
+        "MouthSmile_Left",
+        "MouthSmile_Right",
+        "MouthDimple_Left",
+        "MouthDimple_Right",
+        "LipsStretch_Left",
+        "LipsStretch_Right",
+        "LipsUpperClose",
+        "LipsLowerClose",
+        "LipsUpperUp",
+        "LipsLowerDown",
+        "LipsUpperOpen",
+        "LipsLowerOpen",
+        "LipsFunnel",
+        "LipsPucker",
+        "ChinLowerRaise",
+        "ChinUpperRaise",
+        "Sneer",
+        "Puff",
+        "CheekSquint_Left",
+        "CheekSquint_Right",
+        "HAPPY_48",
+        "HAPPY_49",
+        "HAPPY_50",
+        "HAPPY_51",
+        "HAPPY_52",
+        "ANGRY_53",
+        "ANGRY_54",
+        "ANGRY_55",
+        "DISGUST_56",
+        "DISGUST_57",
+        "SAD_58",
+        "SURPRISE_59",
+        "SURPRISE_60",
+        "Puff_Left",
+        "Puff_Right",
+        "Tongue_Out",
+        "Tongue_Up",
+        "Tongue_Down",
+        "Tongue_Left",
+        "Tongue_Right"
+      ],
+      "key": [
+        [
+          0.05009999871253967,
+          0.05009999871253967,
+          0.25,
+          0.25,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.20000000298023224,
+          0.20000000298023224,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.02250000089406967,
+          0.800000011920929,
+          1.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.8017492890357971,
+          0.6000000238418579,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.30000001192092896,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0
+        ],
+        [
+          0.05530000105500221,
+          0.05530000105500221,
+          0.2759999930858612,
+          0.2759999930858612,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.2207999974489212,
+          0.2207999974489212,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.02742336131632328,
+          0.77920001745224,
+          1.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.8004528880119324,
+          0.6000000238418579,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.3003687560558319,
+          0.0,
+          0.0,
+          0.00038519964437000453,
+          0.001843750011175871,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0
+        ]
+      ]
+    },
+    {
+      "name": "GEO_5",
+      "fullName": "Facial_Blendshape_Animation:GEO_5",
+      "blendShapeVersion": "3.0",
+      "morphtarget": 20,
+      "morphname": [
+        "EyeBlink_Left",
+        "EyeBlink_Right",
+        "EyeSquint_Left",
+        "EyeSquint_Right",
+        "EyeDown_Left",
+        "EyeDown_Right",
+        "EyeIn_Left",
+        "EyeIn_Right",
+        "EyeOpen_Left",
+        "EyeOpen_Right",
+        "EyeOut_Left",
+        "EyeOut_Right",
+        "EyeUp_Left",
+        "EyeUp_Right",
+        "CheekSquint_Left",
+        "CheekSquint_Right",
+        "HAPPY_48",
+        "ANGRY_54",
+        "SAD_58",
+        "SURPRISE_59"
+      ],
+      "key": [
+        [
+          0.05009999871253967,
+          0.05009999871253967,
+          0.25,
+          0.25,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.20000000298023224,
+          0.20000000298023224,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.30000001192092896,
+          0.0,
+          0.0,
+          0.0
+        ],
+        [
+          0.05530000105500221,
+          0.05530000105500221,
+          0.2759999930858612,
+          0.2759999930858612,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.2207999974489212,
+          0.2207999974489212,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.3003687560558319,
+          0.0,
+          0.0,
+          0.0
+        ]
+      ]
+    }
+  ],
+  "shapesAmount": 2,
+  "time": [
+    0,
+    33
+  ],
+  "frames": 2
+}
diff --git a/automated-tests/resources/test-invalid-facial-animation3.json b/automated-tests/resources/test-invalid-facial-animation3.json
new file mode 100755 (executable)
index 0000000..2067b28
--- /dev/null
@@ -0,0 +1,303 @@
+{
+  "name": "Facial_Blendshape_Animation",
+  "version": "1.2.3",
+  "blendShapes": [
+    {
+      "name": "GEO_1",
+      "fullName": "Facial_Blendshape_Animation:GEO_1",
+      "blendShapeVersion": "3.0",
+      "morphtarget": 68,
+      "morphname": [
+        "EyeBlink_Left",
+        "EyeBlink_Right",
+        "EyeSquint_Left",
+        "EyeSquint_Right",
+        "EyeDown_Left",
+        "EyeDown_Right",
+        "EyeIn_Left",
+        "EyeIn_Right",
+        "EyeOpen_Left",
+        "EyeOpen_Right",
+        "EyeOut_Left",
+        "EyeOut_Right",
+        "EyeUp_Left",
+        "EyeUp_Right",
+        "BrowsDown_Left",
+        "BrowsDown_Right",
+        "BrowsUp_Center",
+        "BrowsUp_Left",
+        "BrowsUp_Right",
+        "JawFwd",
+        "JawLeft",
+        "JawOpen",
+        "JawChew",
+        "JawRight",
+        "MouthLeft",
+        "MouthRight",
+        "MouthFrown_Left",
+        "MouthFrown_Right",
+        "MouthSmile_Left",
+        "MouthSmile_Right",
+        "MouthDimple_Left",
+        "MouthDimple_Right",
+        "LipsStretch_Left",
+        "LipsStretch_Right",
+        "LipsUpperClose",
+        "LipsLowerClose",
+        "LipsUpperUp",
+        "LipsLowerDown",
+        "LipsUpperOpen",
+        "LipsLowerOpen",
+        "LipsFunnel",
+        "LipsPucker",
+        "ChinLowerRaise",
+        "ChinUpperRaise",
+        "Sneer",
+        "Puff",
+        "CheekSquint_Left",
+        "CheekSquint_Right",
+        "HAPPY_48",
+        "HAPPY_49",
+        "HAPPY_50",
+        "HAPPY_51",
+        "HAPPY_52",
+        "ANGRY_53",
+        "ANGRY_54",
+        "ANGRY_55",
+        "DISGUST_56",
+        "DISGUST_57",
+        "SAD_58",
+        "SURPRISE_59",
+        "SURPRISE_60",
+        "Puff_Left",
+        "Puff_Right",
+        "Tongue_Out",
+        "Tongue_Up",
+        "Tongue_Down",
+        "Tongue_Left",
+        "Tongue_Right"
+      ],
+      "key": [
+        [
+          0.05009999871253967,
+          0.05009999871253967,
+          0.25,
+          0.25,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.20000000298023224,
+          0.20000000298023224,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.02250000089406967,
+          0.800000011920929,
+          1.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.8017492890357971,
+          0.6000000238418579,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.30000001192092896,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0
+        ],
+        [
+          0.05530000105500221,
+          0.05530000105500221,
+          0.2759999930858612,
+          0.2759999930858612,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.2207999974489212,
+          0.2207999974489212,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.02742336131632328,
+          0.77920001745224,
+          1.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.8004528880119324,
+          0.6000000238418579,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.3003687560558319,
+          0.0,
+          0.0,
+          0.00038519964437000453,
+          0.001843750011175871,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0
+        ]
+      ]
+    },
+    {
+      "name": "GEO_5",
+      "fullName": "Facial_Blendshape_Animation:GEO_5",
+      "blendShapeVersion": "3.0",
+      "morphtarget": 20,
+      "morphname": [
+        "EyeBlink_Left",
+        "EyeBlink_Right",
+        "EyeSquint_Left",
+        "EyeSquint_Right",
+        "EyeDown_Left",
+        "EyeDown_Right",
+        "EyeIn_Left",
+        "EyeIn_Right",
+        "EyeOpen_Left",
+        "EyeOpen_Right",
+        "EyeOut_Left",
+        "EyeOut_Right",
+        "EyeUp_Left",
+        "EyeUp_Right",
+        "CheekSquint_Left",
+        "CheekSquint_Right",
+        "HAPPY_48",
+        "ANGRY_54",
+        "SAD_58",
+        "SURPRISE_59"
+      ],
+      "key": [
+        [
+          0.05009999871253967,
+          0.05009999871253967,
+          0.25,
+          0.25,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.20000000298023224,
+          0.20000000298023224,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.30000001192092896,
+          0.0,
+          0.0,
+          0.0
+        ],
+        [
+          0.05530000105500221,
+          0.05530000105500221,
+          0.2759999930858612,
+          0.2759999930858612,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.2207999974489212,
+          0.2207999974489212,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.3003687560558319,
+          0.0,
+          0.0,
+          0.0
+        ]
+      ]
+    }
+  ],
+  "shapesAmount": 2,
+  "time": [
+    0,
+    33
+  ],
+  "frames": 2
+}
diff --git a/automated-tests/resources/test-invalid-facial-animation4.json b/automated-tests/resources/test-invalid-facial-animation4.json
new file mode 100755 (executable)
index 0000000..709cfdd
--- /dev/null
@@ -0,0 +1,234 @@
+{
+  "name": "Facial_Blendshape_Animation",
+  "version": "1.2.3",
+  "blendShapes": [
+    {
+      "name": "GEO_1",
+      "fullName": "Facial_Blendshape_Animation:GEO_1",
+      "blendShapeVersion": "3.0",
+      "morphtarget": 68,
+      "morphname": [
+        "EyeBlink_Left",
+        "EyeBlink_Right",
+        "EyeSquint_Left",
+        "EyeSquint_Right",
+        "EyeDown_Left",
+        "EyeDown_Right",
+        "EyeIn_Left",
+        "EyeIn_Right",
+        "EyeOpen_Left",
+        "EyeOpen_Right",
+        "EyeOut_Left",
+        "EyeOut_Right",
+        "EyeUp_Left",
+        "EyeUp_Right",
+        "BrowsDown_Left",
+        "BrowsDown_Right",
+        "BrowsUp_Center",
+        "BrowsUp_Left",
+        "BrowsUp_Right",
+        "JawFwd",
+        "JawLeft",
+        "JawOpen",
+        "JawChew",
+        "JawRight",
+        "MouthLeft",
+        "MouthRight",
+        "MouthFrown_Left",
+        "MouthFrown_Right",
+        "MouthSmile_Left",
+        "MouthSmile_Right",
+        "MouthDimple_Left",
+        "MouthDimple_Right",
+        "LipsStretch_Left",
+        "LipsStretch_Right",
+        "LipsUpperClose",
+        "LipsLowerClose",
+        "LipsUpperUp",
+        "LipsLowerDown",
+        "LipsUpperOpen",
+        "LipsLowerOpen",
+        "LipsFunnel",
+        "LipsPucker",
+        "ChinLowerRaise",
+        "ChinUpperRaise",
+        "Sneer",
+        "Puff",
+        "CheekSquint_Left",
+        "CheekSquint_Right",
+        "HAPPY_48",
+        "HAPPY_49",
+        "HAPPY_50",
+        "HAPPY_51",
+        "HAPPY_52",
+        "ANGRY_53",
+        "ANGRY_54",
+        "ANGRY_55",
+        "DISGUST_56",
+        "DISGUST_57",
+        "SAD_58",
+        "SURPRISE_59",
+        "SURPRISE_60",
+        "Puff_Left",
+        "Puff_Right",
+        "Tongue_Out",
+        "Tongue_Up",
+        "Tongue_Down",
+        "Tongue_Left",
+        "Tongue_Right"
+      ],
+      "key": [
+        [
+          0.05009999871253967,
+          0.05009999871253967,
+          0.25,
+          0.25,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.20000000298023224,
+          0.20000000298023224,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.02250000089406967,
+          0.800000011920929,
+          1.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.8017492890357971,
+          0.6000000238418579,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.30000001192092896,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0
+        ]
+      ]
+    },
+    {
+      "name": "GEO_5",
+      "fullName": "Facial_Blendshape_Animation:GEO_5",
+      "blendShapeVersion": "3.0",
+      "morphtarget": 20,
+      "morphname": [
+        "EyeBlink_Left",
+        "EyeBlink_Right",
+        "EyeSquint_Left",
+        "EyeSquint_Right",
+        "EyeDown_Left",
+        "EyeDown_Right",
+        "EyeIn_Left",
+        "EyeIn_Right",
+        "EyeOpen_Left",
+        "EyeOpen_Right",
+        "EyeOut_Left",
+        "EyeOut_Right",
+        "EyeUp_Left",
+        "EyeUp_Right",
+        "CheekSquint_Left",
+        "CheekSquint_Right",
+        "HAPPY_48",
+        "ANGRY_54",
+        "SAD_58",
+        "SURPRISE_59"
+      ],
+      "key": [
+        [
+          0.05009999871253967,
+          0.05009999871253967,
+          0.25,
+          0.25,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.20000000298023224,
+          0.20000000298023224,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.30000001192092896,
+          0.0,
+          0.0,
+          0.0
+        ],
+        [
+          0.05530000105500221,
+          0.05530000105500221,
+          0.2759999930858612,
+          0.2759999930858612,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.2207999974489212,
+          0.2207999974489212,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          0.3003687560558319,
+          0.0,
+          0.0,
+          0.0
+        ]
+      ]
+    }
+  ],
+  "shapesAmount": 2,
+  "time": [
+    0,
+    33
+  ],
+  "frames": 2
+}
diff --git a/automated-tests/resources/test-invalid-facial-animation5.json b/automated-tests/resources/test-invalid-facial-animation5.json
new file mode 100755 (executable)
index 0000000..4c7c9c0
--- /dev/null
@@ -0,0 +1,115 @@
+{
+  "name": "Facial_Blendshape_Animation",
+  "version": "1.2.3",
+  "blendShapes": [
+    {
+      "name": "GEO_1",
+      "fullName": "Facial_Blendshape_Animation:GEO_1",
+      "blendShapeVersion": "3.0",
+      "morphtarget": 68,
+      "morphname": [
+        "EyeBlink_Left",
+        "EyeBlink_Right",
+        "EyeSquint_Left",
+        "EyeSquint_Right",
+        "EyeDown_Left",
+        "EyeDown_Right",
+        "EyeIn_Left",
+        "EyeIn_Right",
+        "EyeOpen_Left",
+        "EyeOpen_Right",
+        "EyeOut_Left",
+        "EyeOut_Right",
+        "EyeUp_Left",
+        "EyeUp_Right",
+        "BrowsDown_Left",
+        "BrowsDown_Right",
+        "BrowsUp_Center",
+        "BrowsUp_Left",
+        "BrowsUp_Right",
+        "JawFwd",
+        "JawLeft",
+        "JawOpen",
+        "JawChew",
+        "JawRight",
+        "MouthLeft",
+        "MouthRight",
+        "MouthFrown_Left",
+        "MouthFrown_Right",
+        "MouthSmile_Left",
+        "MouthSmile_Right",
+        "MouthDimple_Left",
+        "MouthDimple_Right",
+        "LipsStretch_Left",
+        "LipsStretch_Right",
+        "LipsUpperClose",
+        "LipsLowerClose",
+        "LipsUpperUp",
+        "LipsLowerDown",
+        "LipsUpperOpen",
+        "LipsLowerOpen",
+        "LipsFunnel",
+        "LipsPucker",
+        "ChinLowerRaise",
+        "ChinUpperRaise",
+        "Sneer",
+        "Puff",
+        "CheekSquint_Left",
+        "CheekSquint_Right",
+        "HAPPY_48",
+        "HAPPY_49",
+        "HAPPY_50",
+        "HAPPY_51",
+        "HAPPY_52",
+        "ANGRY_53",
+        "ANGRY_54",
+        "ANGRY_55",
+        "DISGUST_56",
+        "DISGUST_57",
+        "SAD_58",
+        "SURPRISE_59",
+        "SURPRISE_60",
+        "Puff_Left",
+        "Puff_Right",
+        "Tongue_Out",
+        "Tongue_Up",
+        "Tongue_Down",
+        "Tongue_Left",
+        "Tongue_Right"
+      ],
+      "key": []
+    },
+    {
+      "name": "GEO_5",
+      "fullName": "Facial_Blendshape_Animation:GEO_5",
+      "blendShapeVersion": "3.0",
+      "morphtarget": 20,
+      "morphname": [
+        "EyeBlink_Left",
+        "EyeBlink_Right",
+        "EyeSquint_Left",
+        "EyeSquint_Right",
+        "EyeDown_Left",
+        "EyeDown_Right",
+        "EyeIn_Left",
+        "EyeIn_Right",
+        "EyeOpen_Left",
+        "EyeOpen_Right",
+        "EyeOut_Left",
+        "EyeOut_Right",
+        "EyeUp_Left",
+        "EyeUp_Right",
+        "CheekSquint_Left",
+        "CheekSquint_Right",
+        "HAPPY_48",
+        "ANGRY_54",
+        "SAD_58",
+        "SURPRISE_59"
+      ],
+      "key": []
+    }
+  ],
+  "shapesAmount": 2,
+  "time": [],
+  "frames": 0
+}
index c130b2e..3d12208 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -137,3 +137,38 @@ int UtcDaliLoadFacialAnimation(void)
 
   END_TEST;
 }
+
+int UtcDaliLoadFacialAnimationFailed01(void)
+{
+  TestApplication application;
+
+  AnimationDefinition animDef = LoadFacialAnimation("/nothing.json");
+  DALI_TEST_EQUALS(0u, animDef.GetPropertyCount(), TEST_LOCATION);
+  END_TEST;
+}
+
+int UtcDaliLoadFacialAnimationFailed02(void)
+{
+  TestApplication application;
+
+  AnimationDefinition animDef = LoadFacialAnimationFromBuffer(nullptr, 0);
+  DALI_TEST_EQUALS(0u, animDef.GetPropertyCount(), TEST_LOCATION);
+  END_TEST;
+}
+
+int UtcDaliLoadFacialAnimationFailed03(void)
+{
+  TestApplication application;
+
+  tet_infoline("Parse error for invalid json");
+  uint32_t caseCount = 6;
+  for(uint32_t tc = 0; tc < caseCount; ++tc)
+  {
+    tet_printf("Parse error for json %u\n", tc);
+    std::ostringstream oss;
+    oss << TEST_RESOURCE_DIR << "/test-invalid-facial-animation" << tc << ".json";
+    AnimationDefinition animDef = LoadFacialAnimation(oss.str());
+    DALI_TEST_EQUALS(0u, animDef.GetPropertyCount(), TEST_LOCATION);
+  }
+  END_TEST;
+}
\ No newline at end of file
index 4f1d5e1..81b42fd 100644 (file)
@@ -20,6 +20,7 @@
 \r
 // EXTERNAL INCLUDES\r
 #include <dali/devel-api/animation/key-frames-devel.h>\r
+#include <dali/integration-api/debug.h>\r
 #include <sstream>\r
 \r
 // INTERNAL INCLUDES\r
@@ -37,22 +38,22 @@ const float MILLISECONDS_TO_SECONDS = 0.001f;
 \r
 struct BlendShape\r
 {\r
-  std::vector<std::vector<float>> mKeys;\r
-  std::string_view                mNodeName;\r
-  uint32_t                        mNumberOfMorphTarget;\r
-  std::string_view                mVersion;\r
-  std::string_view                mFullName;\r
-  std::vector<std::string_view>   mMorphNames;\r
+  std::vector<std::vector<float>> mKeys{{}};\r
+  std::string_view                mNodeName{};\r
+  uint32_t                        mNumberOfMorphTarget{0u};\r
+  std::string_view                mVersion{};\r
+  std::string_view                mFullName{};\r
+  std::vector<std::string_view>   mMorphNames{};\r
 };\r
 \r
 struct FacialAnimation\r
 {\r
-  std::string_view        mName;\r
-  std::vector<BlendShape> mBlendShapes;\r
-  std::string_view        mVersion;\r
-  uint32_t                mNumberOfShapes;\r
-  std::vector<uint32_t>   mTime;\r
-  uint32_t                mNumberOfFrames;\r
+  std::string_view        mName{};\r
+  std::vector<BlendShape> mBlendShapes{{}};\r
+  std::string_view        mVersion{};\r
+  uint32_t                mNumberOfShapes{0u};\r
+  std::vector<uint32_t>   mTime{};\r
+  uint32_t                mNumberOfFrames{0u};\r
 };\r
 \r
 std::vector<std::vector<float>> ReadBlendShapeKeys(const json_value_s& j)\r
@@ -112,15 +113,43 @@ Dali::Scene3D::Loader::AnimationDefinition LoadFacialAnimationInternal(json::uni
   GetFacialAnimationReader().Read(rootObj, facialAnimation);\r
 \r
   Dali::Scene3D::Loader::AnimationDefinition animationDefinition;\r
-  animationDefinition.SetName(facialAnimation.mName.data());\r
-  animationDefinition.SetDuration(MILLISECONDS_TO_SECONDS * static_cast<float>(facialAnimation.mTime[facialAnimation.mNumberOfFrames - 1u]));\r
+\r
+  // Check validation of the facial animation data.\r
+  if(facialAnimation.mNumberOfFrames == 0u)\r
+  {\r
+    DALI_LOG_ERROR("The number of frames is zero! return empty animation.\n");\r
+    return animationDefinition;\r
+  }\r
+  if(facialAnimation.mTime.size() != static_cast<size_t>(facialAnimation.mNumberOfFrames))\r
+  {\r
+    DALI_LOG_ERROR("The number of frames does not match the number of time values.\n");\r
+    return animationDefinition;\r
+  }\r
 \r
   // Calculate the number of animated properties.\r
   uint32_t numberOfAnimatedProperties = 0u;\r
   for(const auto& blendShape : facialAnimation.mBlendShapes)\r
   {\r
     numberOfAnimatedProperties += blendShape.mNumberOfMorphTarget;\r
+\r
+    if(blendShape.mKeys.size() != static_cast<uint32_t>(facialAnimation.mNumberOfFrames))\r
+    {\r
+      DALI_LOG_ERROR("The number of frames does not match the number of node[%s]'s keys.\n", std::string(blendShape.mNodeName).c_str());\r
+      return animationDefinition;\r
+    }\r
+\r
+    for(const auto& keyframes : blendShape.mKeys)\r
+    {\r
+      if(keyframes.size() != static_cast<size_t>(blendShape.mNumberOfMorphTarget))\r
+      {\r
+        DALI_LOG_ERROR("The number of keys does not match the number of node[%s]'s values.\n", std::string(blendShape.mNodeName).c_str());\r
+        return animationDefinition;\r
+      }\r
+    }\r
   }\r
+\r
+  animationDefinition.SetName(facialAnimation.mName.data());\r
+  animationDefinition.SetDuration(MILLISECONDS_TO_SECONDS * static_cast<float>(facialAnimation.mTime[facialAnimation.mNumberOfFrames - 1u]));\r
   animationDefinition.ReserveSize(numberOfAnimatedProperties);\r
 \r
   uint32_t targets = 0u;\r
@@ -138,7 +167,7 @@ Dali::Scene3D::Loader::AnimationDefinition LoadFacialAnimationInternal(json::uni
       animatedProperty.mKeyFrames = Dali::KeyFrames::New();\r
       for(uint32_t timeIndex = 0u; timeIndex < facialAnimation.mNumberOfFrames; ++timeIndex)\r
       {\r
-        const float progress = MILLISECONDS_TO_SECONDS * static_cast<float>(facialAnimation.mTime[timeIndex]) / animationDefinition.GetDuration();\r
+        const float progress = Dali::EqualsZero(animationDefinition.GetDuration()) ? 0.0f : MILLISECONDS_TO_SECONDS * static_cast<float>(facialAnimation.mTime[timeIndex]) / animationDefinition.GetDuration();\r
         animatedProperty.mKeyFrames.Add(progress, blendShape.mKeys[timeIndex][morphTargetIndex]);\r
       }\r
       // Optimize keyframes, for heuristic!\r
@@ -163,13 +192,17 @@ AnimationDefinition LoadFacialAnimation(const std::string& url)
   auto jsonData = LoadTextFile(url.c_str(), &failed);\r
   if(failed)\r
   {\r
-    ExceptionFlinger(ASSERT_LOCATION) << "Failed to load " << url << ".";\r
+    DALI_LOG_ERROR("Failed to load file. url : %s\n", url.c_str());\r
+    AnimationDefinition animationDefinition;\r
+    return animationDefinition;\r
   }\r
 \r
   json::unique_ptr root(json_parse(jsonData.c_str(), jsonData.size()));\r
   if(!root)\r
   {\r
-    ExceptionFlinger(ASSERT_LOCATION) << "Failed to parse json " << url << ".";\r
+    DALI_LOG_ERROR("Failed to parse json. url : %s\n", url.c_str());\r
+    AnimationDefinition animationDefinition;\r
+    return animationDefinition;\r
   }\r
 \r
   return LoadFacialAnimationInternal(root);\r
@@ -180,7 +213,9 @@ AnimationDefinition LoadFacialAnimationFromBuffer(const uint8_t* rawBuffer, int
   json::unique_ptr root(json_parse(rawBuffer, static_cast<size_t>(static_cast<uint32_t>(rawBufferLength))));\r
   if(!root)\r
   {\r
-    ExceptionFlinger(ASSERT_LOCATION) << "Failed to parse json from buffer.";\r
+    DALI_LOG_ERROR("Failed to parse json from buffer.\n");\r
+    AnimationDefinition animationDefinition;\r
+    return animationDefinition;\r
   }\r
 \r
   return LoadFacialAnimationInternal(root);\r