Camera motions cause the frames to have translation or rotation differences. The affine transform offers control to account for scaling, rotation, and translation transforms.
For example, the rotation use case can be parameterized with the affine transform parameters shown in Figure 9-221.
where theta is the angle of rotation. In the scaling case, the affine transform uses the parameters shown in Figure 9-222.
where alpha is the scale factor. Translation uses an identity matrix with the translation vector as the affine transform parameters, as in Figure 9-223, where Th and Tv are the translation parameters. More complex transforms can be derived and the affine transformation is general so that optimization routines can be used to provide the best parameters to align two frames.
To initialize and run the LDC to perform affine transform, the application must:
- Check and wait for the LDC_PCR[2] BUSY bit to become IDLE (0x0).
- Set the LDC_PCR[4:3] MODE bit field for UYVY (0x0) or NV12 data (0x2).
- If lens distortion correction is performed at the same time as the affine transform, set the LDC_PCR[2] LDMAPEN bit to 1. Otherwise, set the LDC_PCR[1] LDMAPEN bit to 0.
- Set the input frame base address in the LDC_RD_BASE[31:0] RBASE bit field. The frame base address must be aligned on a 16-byte boundary.
- Set the input frame line offset in the LDC_RD_OFST[15:0] ROFST bit field.
- If reading the input from a circular buffer:
- Set LDC_PCR[9] CIRCEN = 1
- b. 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 LDC_RD_OFST.MOD. In UYVY mode, the number of rows in the buffer is LDC_RD_OFST.MOD. In NV12 and NV21 modes, the number of rows in the Y buffer is LDC_RD_OFST.MOD and the number of rows in the Cb/Cr buffers is (LDC_RD_OFST.MOD / 2).
- Set the tile size in the LDC_BLOCK[15:8] OBH and LDC_BLOCK[7:0] OBW bit fields. See constraints on OBW in Table 9-2739
- Set the pixel pad in the LDC_BLOCK[19:16] PIXPAD bit field.
- Set the input frame size in LDC_INPUT_FRAME_SIZE[29:16] H and LDC_INPUT_FRAME_SIZE[13:0] W.
- Set the output frame size in the LDC_FRAME_SIZE[29:16] H and LDC_FRAME_SIZE[13:0] W bit fields. H and W values must be multiples of OBH and OBW, respectively.
- Set the starting output point in the LDC_INITXY[13:0] INITX and LDC_INITXY[29:16] INITY bit fields.
- Set the output frame starting address in the LDC_WR_BASE[31:0] WBASE bit field. The output frame must be 16-byte aligned.
- Set the output frame line offset in the LDC_WR_OFST[15:0] WOFST bit field.
- If the data format is NV12, set the 4:2:0 UV input plane base address in the LDC_420C_RD_BASE[31:0] RBASE bit field. This address must be 16-byte aligned.
- If the data format is NV12, set the 4:2:0 UV output plane base address in the LDC_420C_WR_BASE[31:0] WBASE bit field. This address must be 16-byte aligned.
- Set the mesh offset table pointer to the correct address ( LDC_MESHTABLE_BASE[31:0] BASE and LDC_MESHTABLE_OFST[15:0] OFST). Set the table downsampling factor for MxM downsampling in LDC_MESHTABLE_CONFIG[2:0] M.
- If the LDC is connected to image buffers where the output address is not updated for each tile, set the constant mode to 0x1 in the LDC_CONFIG[7] CNST_MD bit.
- Set the Y plane interpolation type to bilinear or bicubic in the LDC_CONFIG[6] YINT_TYP bit.
- Set the six affine transform parameters in the following bit fields:
- Disable perspective warp transform with LDC_PCR.PWARPEN = 0. Set the two perspective transform parameters LDC_GH.G = 0 and LDC_GH.H = 0.
- Set the LDC_PCR[0] EN bit to 1 to start the LDC operation.
- Wait for the LDC_PCR[2] BUSY bit to become IDLE (0x0) or wait for the completion interrupt.