mv_3d: fix bug which gives a base source regardless formats when mv_3d_run() invokes...
authorTae-Young Chung <ty83.chung@samsung.com>
Mon, 24 Apr 2023 07:05:29 +0000 (16:05 +0900)
committerKwanghoon Son <k.son@samsung.com>
Wed, 14 Jun 2023 02:14:28 +0000 (11:14 +0900)
[Version] 0.28.2
[Issue type] bug fix

in case of side-by-side or top-bottom stereo format is given as a base
source, the only left should be invoked with a callback.

Change-Id: I568df71fc8e20780fd612bdabf2978f1546e65c6
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
mv_3d/3d/src/Mv3d.cpp

index 27d7b7c4379841cd12abed3ded710dfa4cdb74d3..c3f9a81e576280040c6b1b396d5c40d2a3c33e42 100644 (file)
@@ -321,21 +321,33 @@ int Mv3d::Run(mv_source_h baseSource, mv_source_h extraSource)
                        mDfsAsyncQueue = nullptr;
                }
 
-               if (mInternalSource) {
-                       int ret = mv_destroy_source(mInternalSource);
-                       if (ret != MEDIA_VISION_ERROR_NONE) {
-                               LOGE("Fail to destroy intern source. But keep going..");
-                       }
-                       mInternalSource = nullptr;
-               }
-
                GetDfsDataFromSources(baseSource, extraSource, input);
 
                mDfsAdaptor->run(input);
                auto depthData = mDfsAdaptor->getOutputData();
-
-               mDepthCallback(baseSource, static_cast<DepthTypePtr>(depthData.data), depthData.width, depthData.height,
-                                          mDepthUserData);
+               if (input.format != DFS_DATA_INPUT_FORMAT_DECOUPLED_SBS) {
+                       if (!mInternalSource) {
+                               int ret = mv_create_source(&mInternalSource);
+                               if (ret != MEDIA_VISION_ERROR_NONE) {
+                                       LOGE("Fail to create internal source");
+                                       return MEDIA_VISION_ERROR_INTERNAL;
+                               }
+                       }
+                       auto leftData = mDfsAdaptor->getLeftData();
+                       auto ret = mv_source_fill_by_buffer(mInternalSource, static_cast<unsigned char *>(leftData.data),
+                                                                                               leftData.stride * leftData.height, leftData.width, leftData.height,
+                                                                                               leftData.type == DFS_DATA_TYPE_UINT8C3 ?
+                                                                                                               MEDIA_VISION_COLORSPACE_RGB888 :
+                                                                                                               MEDIA_VISION_COLORSPACE_Y800);
+                       if (MEDIA_VISION_ERROR_NONE != ret) {
+                               LOGE("Errors were occurred during source filling %i, but continue", ret);
+                       }
+                       mDepthCallback(mInternalSource, static_cast<DepthTypePtr>(depthData.data), depthData.width,
+                                                  depthData.height, mDepthUserData);
+               } else {
+                       mDepthCallback(baseSource, static_cast<DepthTypePtr>(depthData.data), depthData.width, depthData.height,
+                                                  mDepthUserData);
+               }
 #ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
                if (mPointcloudCallback) {
                        mv_3d_pointcloud_s p { .type = MV_3D_POINTCLOUD_TYPE_PCD_BIN,
@@ -346,6 +358,7 @@ int Mv3d::Run(mv_source_h baseSource, mv_source_h extraSource)
 #endif
                delete[] static_cast<unsigned char *>(input.data);
                delete[] static_cast<unsigned char *>(input.extraData);
+               mv_source_clear(mInternalSource);
        } catch (const std::exception &e) {
                LOGE("Failed to Run with %s", e.what());
                return MEDIA_VISION_ERROR_INVALID_OPERATION;