Perspective transforms are used to align the image data of two different cameras viewing the same scene from different positions. It can also be used in the case of stereo image rectification to align the epipolar lines of the left/right image pair with their scanlines.
The following steps need to be performed by the application to initialize and run LDC to perform perspective transform.
- Check and wait for LDC_PCR[2] BUSY to become IDLE (0x0).
- Set LDC_PCR[4:3] MODE for UYVY (0x0) or NV12 data (0x2).
- If lens distortion correction is performed at the same time as the perspective transform, set LDC_PCR[1] LDMAPEN = 0x1. Otherwise, set LDC_PCR[1] LDMAPEN = 0x0.
- Set the input frame base address in LDC_RD_BASE[31:0] RBASE. Note that the frame base address must be aligned on a 16-byte boundary.
- Set the input frame line offset in LDC_RD_OFST[15:0] ROFST.
- Set the tile size in LDC_BLOCK[15:8] OBH and LDC_BLOCK[7:0] OBW. Note the constraints on OBW in Table 9-2739.
- Set the pixel pad in LDC_BLOCK[19:16] PIXPAD.
- 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 LDC_FRAME_SIZE[29:16] H and LDC_FRAME_SIZE[13:0] W. These values must be a multiple of OBH and OBW respectively.
- Set the starting output point in LDC_INITXY[13:0] INITX and LDC_INITXY[29:16] INITY.
- Set the output frame starting address in LDC_WR_BASE[31:0] WBASE. The output frame must be 16-byte aligned.
- Set the output frame line offset in LDC_WR_OFST[15:0] WOFST.
- If the data format is NV12, set the 420 UV input plane base address in LDC_420C_RD_BASE[31:0] RBASE. This address must be 16-byte aligned.
- If the data format is NV12, set the 420 UV output plane base address in LDC_420C_WR_BASE[31:0] WBASE. 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 LDC module is connected to image buffers where the output address is not updated for each tile, set constant mode = 0x1 in LDC_CONFIG[7] CNST_MD.
- Set the Y plane interpolation type to bilinear or bicubic in LDC_CONFIG[8] YINT_TYP.
- Set the eight perspective transform parameters in the following bit fields:
- If smart codec statistics are desired:
- Enable by setting LDC_PCR[8] SCSEN = 1.
- Set the number of regions in LDC_SCS_CTL[6:5] REGION (0=1x1, 1=2x2, 2=3x3, 3=4x4).
- Set the division factor for the sum and sum of squares statistics in LDC_SCS_CTL[4:0] ACCSHIFT. The division is a power-of-two division, so this value is the right shift parameter.
- Program the number of lines computed before the row macroblock statistics are transferred to memory in LDC_SCS_CTL[29:16] SLICE_SIZE. This feature is useful for slice-based processing to ensure that statistics for the macroblock rows are available at the same time that the LDC output data is available. This must be a multiple of 16.
- Set LDC_PCR[0] EN = 0x1 to start the LDC operation.
- Wait for LDC_PCR[2] BUSY to become IDLE (`0x0) or wait for the end of frame completion interrupt.