Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rotation sample code. #321

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions videoprocess/process_rotation.cfg.template
Original file line number Diff line number Diff line change
@@ -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
22 changes: 21 additions & 1 deletion videoprocess/vppscaling_csc.cpp
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down