[ML][Pipeline][Single] Fix SVACE issues 11/254911/4
authorPawel Wasowski <p.wasowski2@samsung.com>
Wed, 10 Mar 2021 10:31:04 +0000 (11:31 +0100)
committerPawel Wasowski <p.wasowski2@samsung.com>
Wed, 10 Mar 2021 11:11:18 +0000 (11:11 +0000)
commite84dcf1d46b9e524380b6d05fb4192b23678093a
treeeb4c4e223e4157da6064623ec5bc9759cc5c1bbc
parentb43639de6e01c15c6d31fbc058bb0b6f1b01a4ea
[ML][Pipeline][Single] Fix SVACE issues

This commit fixes the following issues reported on
analysishub.sec.samsung.net (WGIDs):
- 457566
- 457567
- 457568

[Verification] Code compiles. SVACE analysis after
applying the patch
(https://analysishub.sec.samsung.net/service/analyses/394936)
found no errors.

CustomFilter tested in Chrome DevTools with the
snippet below works fine

// Valid CustomFilter callback - the happy scenario
var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenAndSet123 = function(input, output) {
    console.log("Custom filter called");

    var rawOutputData = new Uint8Array(1200);
    for (var i = 0; i < rawOutputData.length; ++i) {
        rawOutputData[i] = 123;
    }

    output.setTensorRawData(0, rawOutputData);
    return 0;
}

tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenAndSet123, inputTI,
    outputTI, function errorCallback(error) {
        console.warn('custom filter error:') ; console.warn(error);
    });

var pipeline_def = "videotestsrc num-buffers=3 "
                   + "! video/x-raw,width=20,height=15,format=BGRA "
                   + "! tensor_converter "
                   + "! tensor_filter framework=custom-easy model=testfilter2 "
                   + "! appsink name=mysink";

var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
                                                state => {console.log(state);})

pipeline.registerSinkListener('mysink', function(sinkName, data) {
    console.log('SinkListener for "' + sinkName + '" sink called');
    console.log(data);
})

// READY
// Custom filter called
// PAUSED

pipeline.start()

// PLAYING
// <CustomFilter and SinkListener callbacks' outputs 3 times>

Change-Id: Id1d35167532c3aeecbd3c73c3546b80e31e8f76c
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
src/ml/ml_pipeline_custom_filter.cc
src/ml/ml_singleshot.cc