From b2a9957a125967710c8eb52af375cc3cb4cd87ee Mon Sep 17 00:00:00 2001 From: Furong Zhang Date: Thu, 23 Mar 2023 17:14:29 +0800 Subject: [PATCH] Added rotation sample code. Signed-off-by: Furong Zhang --- videoprocess/process_rotation.cfg.template | 30 ++++++++++++++++++++++ videoprocess/vppscaling_csc.cpp | 22 +++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 videoprocess/process_rotation.cfg.template diff --git a/videoprocess/process_rotation.cfg.template b/videoprocess/process_rotation.cfg.template new file mode 100644 index 00000000..32692d2c --- /dev/null +++ b/videoprocess/process_rotation.cfg.template @@ -0,0 +1,30 @@ +# Configuration information for video process test case. +# This application will firstly load yuv frames to one type of surface(NV12/YV12/I420) +# you require. After video processing, the processed content (NV12/YV12/I420 surface) +# will be stored to frames(yv12 format in file). +# Supported features include scaling and implicit format conversion(NV12<->YV12<->I420). +# you can modify this configuration file to set the corresponding parameters. + +#1.Source YUV(RGB) file information +SRC_FILE_NAME: ./bigship_1280_720p_25fps_10frames_writer1280x720_noised.nv12 +SRC_FRAME_WIDTH: 1280 +SRC_FRAME_HEIGHT: 720 +SRC_FRAME_FORMAT: NV12 + +#Note .nv12 files are in NV12 format +SRC_FILE_FORMAT: NV12 + +#2.Destination YUV(RGB) file information +DST_FILE_NAME: ./scaling_out_720x1280.nv12 +DST_FRAME_WIDTH: 720 +DST_FRAME_HEIGHT: 1280 +DST_FRAME_FORMAT: NV12 + +DST_FILE_FORMAT: NV12 + +#3.How many frames to be processed +FRAME_SUM: 1 + +#4.How to use this template +ROTATION: 1 +#./vppscaling_csc process_rotation.cfg.template diff --git a/videoprocess/vppscaling_csc.cpp b/videoprocess/vppscaling_csc.cpp index 26227e05..9181e55b 100644 --- a/videoprocess/vppscaling_csc.cpp +++ b/videoprocess/vppscaling_csc.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009-2018, Intel Corporation +* Copyright (c) 2009-2023, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -74,6 +74,7 @@ static uint32_t g_src_file_fourcc = VA_FOURCC('I', '4', '2', '0'); static uint32_t g_dst_file_fourcc = VA_FOURCC('Y', 'V', '1', '2'); static uint32_t g_frame_count = 0; +static uint32_t g_rotation_angle = 0; static int8_t read_value_string(FILE *fp, const char* field_name, char* value) @@ -1003,6 +1004,10 @@ video_frame_process(VASurfaceID in_surface_id, pipeline_param.surface = in_surface_id; pipeline_param.surface_region = &surface_region; pipeline_param.output_region = &output_region; + if (g_rotation_angle == 1 ) + { + pipeline_param.rotation_state = VA_ROTATION_90; + } va_status = vaCreateBuffer(va_dpy, context_id, @@ -1105,6 +1110,20 @@ vpp_context_create() 1, &context_id); CHECK_VASTATUS(va_status, "vaCreateContext"); + + VABufferID *filters = nullptr; + unsigned int num_filters = 0; + VAProcPipelineCaps pipeline_caps = {}; + va_status = vaQueryVideoProcPipelineCaps(va_dpy, + context_id, + filters, + num_filters, + &pipeline_caps); + CHECK_VASTATUS(va_status, "vaQueryVideoProcPipeineCaps"); + if (pipeline_caps.rotation_flags & (1 << VA_ROTATION_90)) { + printf("Clockwise rotation by 90 degrees is supported!\n"); + } + return va_status; } @@ -1190,6 +1209,7 @@ parse_basic_parameters() parse_fourcc_and_format(str, &g_dst_file_fourcc, NULL); read_value_uint32(g_config_file_fd, "FRAME_SUM", &g_frame_count); + read_value_uint32(g_config_file_fd, "ROTATION", &g_rotation_angle); if (g_in_pic_width != g_out_pic_width || g_in_pic_height != g_out_pic_height)