Scale

This sample demonstrates the scale function of the PPE peripheral.

Requirements

For requirements, please refer to the Requirements.

Wiring

No physical connection is required in this sample.

Configurations

The following parameter can be changed to modify scaling result.

Scale Ratio

Scale ratio for both horizontal and vertical can be set in following parameters:

float horizontal_ratio = 2.5;
float vertical_ratio = 0.8;

Building and Downloading

For building and downloading, please refer to the Building and Downloading.

Experimental Verification

Scale Successfully

After the sample is executed, result from PPE will be compared with simulation data. Observing the following log in the DebugAnalyzer window indicates successful scaling:

PPE scale test passed 0

Scale Failed

After the sample is executed, result from PPE will be compared with simulation data. Observing the following log in the DebugAnalyzer window indicates failure of scaling:

Data mismatch at offset 179, expect 0x%40406427, actual 0x%12345678
PPE scale test failed {error code}

Description of {error code} can be found in PPE_ERR.

Code Overview

This section introduces the code and process description for initialization and corresponding function implementation in the sample.

Source Code Directory

The directories for project file and source code are as follows:

  • Project directory: sdk\samples\peripheral\ppe\scale\proj

  • Source code directory: sdk\samples\peripheral\ppe\scale\src

Initialization

The initialization process is included in PPE_test().

  1. Initialize data of image to be scaled and output image in ppe_buffer_t structures.

ppe_buffer_t target, source;
memset(&target, 0, sizeof(ppe_buffer_t));
memset(&source, 0, sizeof(ppe_buffer_t));
  1. Initialize ppe_buffer_t structures that contain information of the image to be scaled.

source.address = (uint32_t) source_buffer;
source.memory = source_buffer;
source.format = PPE_ABGR8888;
source.width = 64;
source.height = 64;
source.stride = source.width;
  1. Initialize ppe_buffer_t structures that contain information of background.

target.address = (uint32_t) target_buffer;
target.memory = target_buffer;
target.format = PPE_ABGR8888;
  1. After determining scale ratio, call API PPE_Scale() to start PPE work.

float horizontal_ratio = 2.5;
float vertical_ratio = 0.8;
PPE_ERR err = PPE_Scale(&source, &target, horizontal_ratio, vertical_ratio);

Functional Implementation

After PPE_Scale() is completed, result of PPE will be compared with simulation data. If any error occurs, false data will be displayed in DebugAnalyzer Tool as demonstrated in Experimental Verification.