mirror of
https://github.com/openharmony/multimedia_video_processing_engine.git
synced 2026-07-19 19:13:31 -04:00
@@ -140,8 +140,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);
|
||||
}
|
||||
uint8_t val = OH_VIDEO_HDR_VIVID;
|
||||
err = OH_NativeWindow_SetMetadataValue(inWindow, OH_HDR_METADATA_TYPE, sizeof(uint8_t), &val);
|
||||
if (err != 0) {
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef VIDEO_SAMPLE_H
|
||||
#define VIDEO_SAMPLE_H
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@@ -173,3 +177,5 @@ int32_t VideoSample::StartProcess()
|
||||
CHECK_AND_RETURN_RET(ret == VIDEO_PROCESSING_SUCCESS, ret, "OH_VideoProcessing_Start failed.");
|
||||
return VIDEO_PROCESSING_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -25,8 +25,12 @@ 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;
|
||||
constexpr int TWO = 2;
|
||||
|
||||
static int64_t GetSystemTimeUs()
|
||||
namespace OHOS {
|
||||
int64_t GetSystemTimeUs()
|
||||
{
|
||||
struct timespec now;
|
||||
(void)clock_gettime(CLOCK_BOOTTIME, &now);
|
||||
@@ -34,14 +38,14 @@ 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)
|
||||
{
|
||||
g_state = state;
|
||||
if (state == VIDEO_PROCESSING_STATE_STOPPED) {
|
||||
@@ -50,10 +54,11 @@ static void OnState(OH_VideoProcessing* videoProcessor, VideoProcessing_State st
|
||||
std::cout << "OnState callback called, new state is "<< state << std::endl;
|
||||
}
|
||||
|
||||
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:
|
||||
@@ -157,7 +162,7 @@ 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);
|
||||
const size_t bufferSize = config.stride * config.height * 3 / 2;
|
||||
const size_t bufferSize = config.stride * config.height * THREE / TWO;
|
||||
memcpy_s(addr, bufferSize, data, size);
|
||||
NativeWindowHandleOpt(inWindow, SET_UI_TIMESTAMP, GetSystemTimeUs());
|
||||
err = OH_NativeBuffer_Unmap(nativeBuffer);
|
||||
@@ -166,7 +171,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ 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;
|
||||
|
||||
namespace OHOS {
|
||||
@@ -166,7 +167,7 @@ int32_t VideoSample::InputFunc(const uint8_t *data, size_t size)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,17 @@ int32_t TestUnsupportedOutput(int32_t inColorSpace, int32_t inPixFmt)
|
||||
}
|
||||
}
|
||||
|
||||
bool ValidatePixelFormat(ImageProcessing_ColorSpaceInfo formatImage)
|
||||
{
|
||||
if (formatImage == nullptr) {
|
||||
return false;
|
||||
}
|
||||
bool ret = (formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_YCBCR_420_SP ||
|
||||
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP ||
|
||||
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_RGBA_8888);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : VPE_VIDEO_RELI_TEST_0010
|
||||
* @tc.name : test all unsupported convert options
|
||||
@@ -115,14 +126,12 @@ HWTEST_F(VpeVideoReliTest, METADATASUPPORT_001, TestSize.Level2)
|
||||
void CheckCapability(VideoProcessing_ColorSpaceInfo inputFormat)
|
||||
{
|
||||
if(formatImage.colorSpace == OH_COLORSPACE_SRGB_FULL ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_SRGB_LIMIT ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_LINEAR_SRGB ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_SRGB ||
|
||||
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.colorSpace == OH_COLORSPACE_SRGB_LIMIT ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_LINEAR_SRGB ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_SRGB ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_P3_SRGB ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_BT2020_SRGB) {
|
||||
if(ValidatePixelFormat(formatImage)) {
|
||||
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 +142,9 @@ 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) {
|
||||
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.colorSpace == OH_COLORSPACE_DISPLAY_P3_HLG ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_P3_PQ) {
|
||||
if(ValidatePixelFormat(formatImage)) {
|
||||
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 +155,8 @@ void CheckCapability(VideoProcessing_ColorSpaceInfo inputFormat)
|
||||
}
|
||||
}
|
||||
if(formatImage.colorSpace == OH_COLORSPACE_ADOBERGB_FULL ||
|
||||
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.colorSpace == OH_COLORSPACE_ADOBERGB_LIMIT) {
|
||||
if(ValidatePixelFormat(formatImage)) {
|
||||
if (!access("/system/lib64/ndk/libvideo_processing_capi_impl.so", 0)) {
|
||||
if (!access("/system/lib64/media/", 0)) {
|
||||
ASSERT_EQ(true, OH_ImageProcessing_IsMetadataGenerationSupported(formatImage));
|
||||
@@ -178,17 +183,6 @@ HWTEST_F(VpeVideoReliTest, METADATASUPPORT_002, TestSize.Level2)
|
||||
}
|
||||
}
|
||||
|
||||
bool ValidatePixelFormat(ImageProcessing_ColorSpaceInfo formatImage)
|
||||
{
|
||||
if (formatImage == nullptr) {
|
||||
return false;
|
||||
}
|
||||
bool ret = (formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_YCBCR_420_SP ||
|
||||
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP ||
|
||||
formatImage.pixelFormat == NATIVEBUFFER_PIXEL_FMT_RGBA_8888);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HWTEST_F(VpeVideoReliTest, METADATASUPPORT_003, TestSize.Level2)
|
||||
{
|
||||
ImageProcessing_ColorSpaceInfo formatImage;
|
||||
@@ -202,11 +196,11 @@ HWTEST_F(VpeVideoReliTest, METADATASUPPORT_003, TestSize.Level2)
|
||||
}
|
||||
}
|
||||
if (formatImage.colorSpace == OH_COLORSPACE_SRGB_FULL ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_SRGB_LIMIT ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_LINEAR_SRGB ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_SRGB ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_P3_SRGB ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_BT2020_SRGB) {
|
||||
formatImage.colorSpace == OH_COLORSPACE_SRGB_LIMIT ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_LINEAR_SRGB ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_SRGB ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_P3_SRGB ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_DISPLAY_BT2020_SRGB) {
|
||||
if(ValidatePixelFormat(formatImage)){
|
||||
if (!access("/system/lib64/ndk/libvideo_processing_capi_impl.so", 0)) {
|
||||
if (!access("/system/lib64/media/", 0)) {
|
||||
@@ -219,8 +213,8 @@ HWTEST_F(VpeVideoReliTest, METADATASUPPORT_003, TestSize.Level2)
|
||||
}
|
||||
}
|
||||
} else 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(ValidatePixelFormat(formatImage)){
|
||||
if (!access("/system/lib64/ndk/libvideo_processing_capi_impl.so", 0)) {
|
||||
if (!access("/system/lib64/media/", 0)) {
|
||||
@@ -233,7 +227,7 @@ HWTEST_F(VpeVideoReliTest, METADATASUPPORT_003, TestSize.Level2)
|
||||
}
|
||||
}
|
||||
} else if (formatImage.colorSpace == OH_COLORSPACE_ADOBERGB_FULL ||
|
||||
formatImage.colorSpace == OH_COLORSPACE_ADOBERGB_LIMIT) {
|
||||
formatImage.colorSpace == OH_COLORSPACE_ADOBERGB_LIMIT) {
|
||||
if (ValidatePixelFormat(formatImage)){
|
||||
if (!access("/system/lib64/ndk/libvideo_processing_capi_impl.so", 0)) {
|
||||
if (!access("/system/lib64/media/", 0)) {
|
||||
|
||||
Reference in New Issue
Block a user