测试代码合入

Signed-off-by: wangyi <wangyi357@h-partners.com>
This commit is contained in:
wangyi
2025-03-12 10:12:58 +08:00
parent a78381c615
commit 2daf1919bd
25 changed files with 71 additions and 254 deletions
@@ -19,6 +19,11 @@
#include "native_color_space_manager.h"
#include <cstddef>
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
constexpr uint32_t DEFAULT_WIDTH = 3840;
constexpr uint32_t DEFAULT_HEIGHT = 2160;
@@ -1,26 +0,0 @@
/*
* Copyright (C) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IMAGE_COMPOSE_FUZZER_HEADER
#define IMAGE_COMPOSE_FUZZER_HEADER
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#endif
@@ -19,6 +19,11 @@
#include "native_color_space_manager.h"
#include <cstddef>
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
using namespace OHOS;
using namespace OHOS::Media;
@@ -1,26 +0,0 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IMAGE_SDR2HDR_FUZZER_HEADER
#define IMAGE_SDR2HDR_FUZZER_HEADER
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#endif
@@ -19,6 +19,11 @@
#include "native_color_space_manager.h"
#include <cstddef>
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
constexpr uint32_t DEFAULT_WIDTH = 3840;
constexpr uint32_t DEFAULT_HEIGHT = 2160;
@@ -1,26 +0,0 @@
/*
* Copyright (C) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IMAGE_DECOMPOSE_FUZZER_HEADER
#define IMAGE_DECOMPOSE_FUZZER_HEADER
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#endif
@@ -19,6 +19,11 @@
#include "native_color_space_manager.h"
#include <cstddef>
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
constexpr uint32_t DEFAULT_WIDTH = 3840;
constexpr uint32_t DEFAULT_HEIGHT = 2160;
@@ -1,26 +0,0 @@
/*
* Copyright (C) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IMAGE_HDR2HDR_FUZZER_HEADER
#define IMAGE_HDR2HDR_FUZZER_HEADER
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#endif
@@ -19,6 +19,11 @@
#include "native_color_space_manager.h"
#include <cstddef>
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
constexpr uint32_t DEFAULT_WIDTH = 3840;
constexpr uint32_t DEFAULT_HEIGHT = 2160;
@@ -1,26 +0,0 @@
/*
* Copyright (C) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IMAGE_METADATA_GEN_FUZZER_HEADER
#define IMAGE_METADATA_GEN_FUZZER_HEADER
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#endif
@@ -19,6 +19,11 @@
#include "native_color_space_manager.h"
#include <cstddef>
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
constexpr uint32_t DEFAULT_WIDTH = 3840;
constexpr uint32_t DEFAULT_HEIGHT = 2160;
@@ -1,26 +0,0 @@
/*
* Copyright (C) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IMAGE_SDR2SDR_FUZZER_HEADER
#define IMAGE_SDR2SDR_FUZZER_HEADER
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#endif
@@ -25,6 +25,7 @@ using namespace std;
constexpr int64_t NANOS_IN_SECOND = 1000000000L;
constexpr int64_t NANOS_IN_MICRO = 1000L;
constexpr int64_t SLEEP_MICROSECONDS = 33333L;
static int64_t GetSystemTimeUs()
{
@@ -165,7 +166,7 @@ int32_t VideoSample::InputFunc(const uint8_t *data, size_t size)
CHECK_AND_RETURN_RET(err == 0, err, "OH_NativeWindow_NativeWindowFlushBuffer failed.");
err = OH_NativeWindow_SetColorSpace(inWindow, param_.inColorSpace);
CHECK_AND_RETURN_RET(err == 0, err, "OH_NativeWindow_SetColorSpace failed.");
usleep(33333);
usleep(SLEEP_MICROSECONDS);
return err;
}
@@ -1,26 +0,0 @@
/*
* Copyright (C) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef VIDEO_HDRTOHDR_FUZZER_HEADER
#define VIDEO_HDRTOHDR_FUZZER_HEADER
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#endif
@@ -23,6 +23,8 @@ using namespace OHOS;
using namespace std;
constexpr int64_t NANOS_IN_SECOND = 1000000000L;
constexpr int64_t NANOS_IN_MICRO = 1000L;
constexpr int64_t SLEEP_MICROSECONDS = 33333L;
constexpr int THREE = 3;
static int64_t GetSystemTimeUs()
{
@@ -153,13 +155,13 @@ int32_t VideoSample::InputFunc(const uint8_t *data, size_t size)
err = OH_NativeBuffer_Map(nativeBuffer, &virAddr);
CHECK_AND_RETURN_RET(err == 0, err, "OH_NativeBuffer_Map failed.");
uint8_t *addr = reinterpret_cast<uint8_t *>(virAddr);
memcpy_s(addr, config.stride * config.height * 3, data, size);
memcpy_s(addr, config.stride * config.height * THREE, data, size);
NativeWindowHandleOpt(inWindow, SET_UI_TIMESTAMP, GetSystemTimeUs());
err = OH_NativeBuffer_Unmap(nativeBuffer);
CHECK_AND_RETURN_RET(err == 0, err, "OH_NativeBuffer_Unmap failed.");
err = OH_NativeWindow_NativeWindowFlushBuffer(inWindow, ohNativeWindowBuffer, -1, region);
CHECK_AND_RETURN_RET(err == 0, err, "OH_NativeWindow_NativeWindowFlushBuffer failed.");
usleep(33333);
usleep(SLEEP_MICROSECONDS);
return err;
}
@@ -17,6 +17,11 @@
#include "video_sample.h"
#include <cstddef>
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
namespace OHOS {
VideoSample *sample = nullptr;
@@ -1,26 +0,0 @@
/*
* Copyright (C) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef VIDEO_HDRVIVID_TO_HDR_FUZZERR_HEADER
#define VIDEO_HDRVIVID_TO_HDR_FUZZERR_HEADER
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#endif
@@ -17,6 +17,11 @@
#include "video_sample.h"
#include <cstddef>
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
namespace OHOS {
VideoSample *sample = nullptr;
@@ -1,26 +0,0 @@
/*
* Copyright (C) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef VIDEO_HDRVIVID_TO_SDR_FUZZER_HEADER
#define VIDEO_HDRVIVID_TO_SDR_FUZZER_HEADER
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#endif
@@ -26,7 +26,8 @@ constexpr int64_t NANOS_IN_MICRO = 1000L;
constexpr int64_t SLEEP_MICROSECONDS = 33333L;
constexpr int THREE = 3;
static int64_t GetSystemTimeUs()
namespace {
int64_t GetSystemTimeUs()
{
struct timespec now;
(void)clock_gettime(CLOCK_BOOTTIME, &now);
@@ -34,24 +35,25 @@ static int64_t GetSystemTimeUs()
return nanoTime / NANOS_IN_MICRO;
}
static void OnError(OH_VideoProcessing* videoProcessor, VideoProcessing_ErrorCode error, void* userData)
void OnError(OH_VideoProcessing* videoProcessor, VideoProcessing_ErrorCode error, void* userData)
{
(void)videoProcessor;
(void)error;
(void)userData;
}
static void OnState(OH_VideoProcessing* videoProcessor, VideoProcessing_State state, void* userData)
void OnState(OH_VideoProcessing* videoProcessor, VideoProcessing_State state, void* userData)
{
(void)videoProcessor;
(void)state;
(void)userData;
}
static void OnNewOutputBuffer(OH_VideoProcessing* videoProcessor, uint32_t index, void* userData)
void OnNewOutputBuffer(OH_VideoProcessing* videoProcessor, uint32_t index, void* userData)
{
OH_VideoProcessing_RenderOutputBuffer(videoProcessor, index);
}
}
class VPEConsumerListener : public IBufferConsumerListener {
public:
@@ -13,6 +13,10 @@
* limitations under the License.
*/
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <cstdint>
#include <fcntl.h>
+1 -1
View File
@@ -19,7 +19,7 @@
#include "surface/native_image.h"
#include "surface/native_buffer.h"
namespace OHOS {
class YuvViewer{
class YuvViewer {
public:
~YuvViewer();
OHNativeWindow *CreateWindow(uint32_t width, uint32_t height,
+9 -9
View File
@@ -121,8 +121,8 @@ void CheckCapability(VideoProcessing_ColorSpaceInfo inputFormat)
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_P3_SRGB ||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_BT2020_SRGB) {
if(formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_YCBCR_420_SP ||
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP ||
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_RGBA_8888){
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP ||
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_RGBA_8888) {
if (!access("/system/lib64/ndk/libvideo_processing_capi_impl.so", 0)) {
if (!access("/system/lib64/media/", 0)) {
ASSERT_EQ(true, OH_ImageProcessing_IsMetadataGenerationSupported(formatImage));
@@ -133,11 +133,11 @@ void CheckCapability(VideoProcessing_ColorSpaceInfo inputFormat)
}
}
if(formatImage.colorSpace == OH_COLORSPACE_DISPLAY_P3_SRGB ||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_P3_HLG ||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_P3_PQ) {
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_P3_HLG ||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_P3_PQ) {
if(formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_YCBCR_420_SP ||
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP ||
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_RGBA_8888) {
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP ||
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_RGBA_8888) {
if (!access("/system/lib64/ndk/libvideo_processing_capi_impl.so", 0)) {
if (!access("/system/lib64/media/", 0)) {
ASSERT_EQ(true, OH_ImageProcessing_IsMetadataGenerationSupported(formatImage));
@@ -148,10 +148,10 @@ void CheckCapability(VideoProcessing_ColorSpaceInfo inputFormat)
}
}
if(formatImage.colorSpace == OH_COLORSPACE_ADOBERGB_FULL ||
formatImage.colorSpace == OH_COLORSPACE_ADOBERGB_LIMIT) {
formatImage.colorSpace == OH_COLORSPACE_ADOBERGB_LIMIT) {
if(formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_YCBCR_420_SP ||
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP ||
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_RGBA_8888) {
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP ||
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_RGBA_8888) {
if (!access("/system/lib64/ndk/libvideo_processing_capi_impl.so", 0)) {
if (!access("/system/lib64/media/", 0)) {
ASSERT_EQ(true, OH_ImageProcessing_IsMetadataGenerationSupported(formatImage));
+4 -2
View File
@@ -150,8 +150,10 @@ void VideoSample::SetInputWindowParam()
metaDataFile->seekg(0, ios::end);
metadataSize = metaDataFile->tellg();
metaDataFile->seekg(0, ios::beg);
metaData = new uint8_t[metadataSize];
metaDataFile->read(reinterpret_cast<char*>(metaData), metadataSize);
if (metadataSize > 0) {
metaData = new uint8_t[metadataSize];
metaDataFile->read(reinterpret_cast<char*>(metaData), metadataSize);
}
}
rect = new Region::Rect();
rect->x = 0;
+1 -1
View File
@@ -25,7 +25,7 @@
#include "native_buffer.h"
inline int CheckAndRet(bool cond, int ret, char* msg) {
if (!(cond)) {
if (!cond) {
std::cout<< msg <<" ErrCode:"<< ret << std::endl;
return ret;
}