[Test/decoder] Add test cases for direct video decoer
authorgichan2-jang <gichan2.jang@samsung.com>
Mon, 4 Sep 2023 09:07:38 +0000 (18:07 +0900)
committerwooksong <wook16.song@samsung.com>
Wed, 6 Sep 2023 02:52:29 +0000 (11:52 +0900)
 - Add test case of all supported video format of direct video decoder.
 - Apply default video foramt when video format is not given.

Signed-off-by: gichan2-jang <gichan2.jang@samsung.com>
ext/nnstreamer/tensor_decoder/tensordec-directvideo.c
tests/nnstreamer_decoder/runTest.sh

index f438355..df1f4a7 100644 (file)
@@ -190,12 +190,10 @@ dv_getOutCaps (void **pdata, const GstTensorsConfig * config)
         format = GST_VIDEO_FORMAT_GRAY16_LE;
         break;
       case DIRECT_VIDEO_FORMAT_UNKNOWN:
+      default:
         GST_WARNING ("Default format has been applied: GRAY8");
         format = GST_VIDEO_FORMAT_GRAY8;
         break;
-      default:
-        GST_ERROR ("Invalid format. Please check the video format");
-        return NULL;
     }
   } else if (channel == 3) {
     switch (ddata->format) {
@@ -206,12 +204,9 @@ dv_getOutCaps (void **pdata, const GstTensorsConfig * config)
         format = GST_VIDEO_FORMAT_BGR;
         break;
       case DIRECT_VIDEO_FORMAT_UNKNOWN:
+      default:
         GST_WARNING ("Default format has been applied: RGB");
         format = GST_VIDEO_FORMAT_RGB;
-        break;
-      default:
-        GST_ERROR ("Invalid format. Please check the video format");
-        return NULL;
     }
   } else if (channel == 4) {
     switch (ddata->format) {
@@ -240,12 +235,10 @@ dv_getOutCaps (void **pdata, const GstTensorsConfig * config)
         format = GST_VIDEO_FORMAT_ABGR;
         break;
       case DIRECT_VIDEO_FORMAT_UNKNOWN:
+      default:
         GST_WARNING ("Default format has been applied: BGRx");
         format = GST_VIDEO_FORMAT_BGRx;
         break;
-      default:
-        GST_ERROR ("Invalid format. Please check the video format");
-        return NULL;
     }
   } else {
     GST_ERROR ("%d channel is not supported", channel);
index c8116d4..a750fc3 100644 (file)
@@ -103,6 +103,20 @@ callCompareTest testcase7_origin.raw testcase7_dv.raw 7 "Compare for case 7" 0 0
 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! videoconvert ! videoscale ! video/x-raw, width=160, height=120, framerate=5/1,format=GRAY16_LE ! tee name =t t. ! queue ! tensor_converter ! tensor_decoder mode=direct_video option1=GRAY16_LE ! filesink location=\"testcase8_dv.raw\" sync=true t. ! queue ! filesink location=\"testcase8_origin.raw\" sync=true" 8 0 0 $PERFORMANCE
 callCompareTest testcase8_origin.raw testcase8_dv.raw 8 "Compare for case 8" 0 0
 
+# Test all supported video formats of direct video
+function video_format_test() {
+    gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! videoconvert ! videoscale ! video/x-raw,format=${1},width=640,height=480,framerate=0/1 ! filesink location=\"testcase09_${1}.golden.raw\" sync=true" "Generate golden test for ${1}" 0 0 $PERFORMANCE
+
+    gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! videoconvert ! videoscale ! video/x-raw,format=${1},width=640,height=480,framerate=0/1 ! tensor_converter ! tensor_decoder mode=direct_video option1=${1} ! filesink location=\"testcase09_${1}.log\" sync=true" "direct video conversion result ${1}" 0 0 $PERFORMANCE
+
+    callCompareTest testcase09_${1}.golden.raw testcase09_${1}.log 1 "Test ${1} comparison" 0 0
+}
+
+VIDEO_FORMAT=("GRAY8" "GRAY16_LE" "GRAY16_BE" "RGB" "BGR" "RGBx" "BGRx" "xRGB" "xBGR" "RGBA" "BGRA" "ARGB" "ABGR")
+for FORMAT in ${VIDEO_FORMAT[@]}; do
+    video_format_test ${FORMAT}
+done
+
 rm *.log *.bmp *.png *.golden *.raw
 
 report