In the rotational video stabilization use case, consecutive frames capturing the same scene are aligned to minimize camera shake. Camera motions cause the frames to have translation or rotation differences. Thus, the frames need to be aligned to maintain a stable output video. The affine transform offers control to account for scaling, rotation, and translation transforms. For example, the rotation use case can be parameterized with the following affine transform parameters:
where theta is the angle of rotation. In the scaling case, the affine transform uses:
where alpha is the scale factor. Translation uses an identity matrix along with the translation vector as the affine transform parameters, as in:
where Th and Tv are the translation parameters. More complex transforms can be derived and the affine transformation is general so that optimization routines may be used to provide the best parameters to align two frames. In all affine transforms, the perspective warp parameters, g and h, should be set to 0.
The following steps need to be performed by the application to initialize and run LDC to perform affine transform.
- Check and wait for VPAC_LDC_CTRL[2] BUSY to
become IDLE (0).
- Set VPAC_LDC_CTRL[4-3] IP_DATAMODE and
VPAC_LDC_CTRL[6-5] IP_DFMT to required data mode and format.
- If lens distortion correction is performed at the
same time as the affine transform, set VPAC_LDC_CTRL[1] LDMAPEN = 1. Otherwise,
set VPAC_LDC_CTRL[1] LDMAPEN = 0.
- Set the input frame base address in
VPAC_LDC_RD_BASE_H / VPAC_LDC_RD_BASE_l. Note that the frame base address must
be aligned on a 16-byte boundary.
- Set the input frame line offset in
VPAC_LDC_RD_OFST[15-0] OFST.
- If reading the input image from a circular buffer:
- Set VPAC_LDC_CTRL[9] IP_CIRCEN = 1.
- If using row address, LDC computes the row number
and applies a modulo operation. The absolute address in the buffer is
computed from this wrap-around row and the column number and then data
is fetched from the circular buffer. Set the circular buffer size in
VPAC_LDC_RD_OFST[29-16] MOD. In YUV420 modes, the number of rows in the
Y buffer is MOD and the number of rows in the Cb/Cr buffers is MOD/2. In
others modes, the number of rows in the buffer is MOD for both Y buffer
and Cb/Cr buffer.
- Set the tile size in VPAC_LDC_OUT_BLKSZ[15-8] OBH
and VPAC_LDC_OUT_BLKSZ[7-0] OBW. Note the constraints on OBW in Table 6-156.
- Set the pixel pad in VPAC_LDC_OUT_BLKSZ[19-16]
PIXPAD.
- Set the input frame size in
VPAC_LDC_INPUT_FRSZ[29-16] H and VPAC_LDC_INPUT_FRSZ[13-0] W.
- Set the output frame size in
VPAC_LDC_MESH_FRSZ[29-16] H and VPAC_LDC_MESH_FRSZ[13-0] W. Mesh data has to be
present for entire frame after transform.
- Set the output compute frame size in
VPAC_LDC_COMPUTE_FRSZ[29-16] H and VPAC_LDC_COMPUTE_FRSZ[13-0] W.
- Set the starting output point in
VPAC_LDC_INITXY[12-0] INITX and VPAC_LDC_INITXY[28-16] INITY.
- Configure SL2 Interface programming registers. Details of LSE configuration is captured in Section 6.7.4.3.4.
- If the data format is NV12, set the 420 UV input
plane base address in VPAC_LDC_RD_420C_BASE_H / VPAC_LDC_RD_420C_BASE_l. This
address must be 16-byte aligned.
- Set the mesh offset table pointer to the correct
address (VPAC_LDC_MESH_BASE_H / VPAC_LDC_MESH_BASE_l and VPAC_LDC_MESH_OFST. Set
the table down sampling factor for MxM down sampling in MESHTABLE_CFG.M.
- Set the Y plane interpolation type to bilinear or
bicubic in VPAC_LDC_CFG[6] YINT_TYP.
- Set the six affine transform parameters in
VPAC_LDC_AFF_AB.A, VPAC_LDC_AFF_AB.B, VPAC_LDC_AFF_CD.C, VPAC_LDC_AFF_CD.D,
VPAC_LDC_AFF_EF.E, and VPAC_LDC_AFF_EF.F. If affine transform is not used, then
these need to be set to the following values: A = 4096, B = 0, C = 0, D = 0, E =
4096, and F = 0.
- Disable perspective warp transform with
VPAC_LDC_CTRL[7] PWARPEN = 0. Set the two perspective transform parameters
VPAC_LDC_PWARP_GH[15-0] G = 0 and VPAC_LDC_PWARP_GH[31-16] H = 0.
- Set VPAC_LDC_CTRL[0] LDC_EN = 1 to start the LDC
operation.
- Start the HTS init sequencing. LDC fetch/processing is gated with hts_init.
- Wait for VPAC_LDC_CTRL[2] BUSY to become IDLE (0)
or wait for the end of frame completion interrupt.