; FILE: fmt_4x4bin.ips ; PURPOSE: To perform a 4x4 binning of an image ; METHOD: ; Inputs ; $IPRL_BIN_PARAM - Holds: source page(l,h) and dest page(l,h) ; Pages: ; 19 == the intermediate 4x4 binning product ; RESTRICTION: ; The 1024x1024 extract needs to have already been performed ; HISTORY: Written 5-Sep-95 by M.Morrison ; 16-Oct-95 (MDM) - Changed to use page 14 for 4x4 bin list ; 19-Oct-95 (MDM) - Modified to not use R168 or R170 ; 19-Oct-95 (MDM0 - Major reconstruction to be more general ; TODO - look at the scaling factors of the ROWBIN instruction list ; 20-Oct-95 (MDM) - Corrected the logic - it wasn't counting loops properly ; 24-Oct-95 (MDM) - Removed fixed register reference to R6000 ; 16-Nov-95 (MDM) - Changed the subroutine call for the debug statement ; from QSR_DUMP_IPREG to QSR_DEBUG_IPREG ; 7-Dec-95 (MDM) - Modified to not do SETREGS for the ROWBIN, LRBIN and DPC setting ; Do a copy from another regiser list instead ; 1-Aug-96 (MDM) - Added logic to increase the K value depending on the binning ; QSR_FMT_2X2BIN:: ;SETREGS $IPRL_BIN_ROWBIN+2 9 19:0x0000 1024 2 1024 512 16 1 $IPRL_LONG_ZERO ;SETREGS $IPRL_BIN_LRBIN+3 5 0 4 14:0xffe60 $IPRL_BIN_LR_OFFSET ;SETREG $IPRL_BIN_DPC 0x1001 COPYRD2D $IPRL_BIN_ROWBIN2X2 $IPRL_BIN_ROWBIN+2 6 COPYREG $IPRL_BIN_LRBIN2X2 $IPRL_BIN_LRBIN+5 ;get low word address of bin-list COPYREG $IPRL_BIN_DPC2X2 $IPRL_BIN_DPC SETREGS $IPRL_BIN_LR_NWORDS 2 0x4000L ;number of input pixels processed per LRBIN call SETREGS $IPRL_BIN_NWORDS 2 0x40000L SETREG $IPRL_BIN_DONE_ADDR 0x0008 ;address of source page high word when done SETREG $IPRL_BIN_K_SHIFT 1 ;amount to increase K by GOTO &COMMON_CODE QSR_FMT_4X4BIN:: ;SETREGS $IPRL_BIN_ROWBIN+2 9 19:0x0000 1024 4 1024 256 16 1 $IPRL_LONG_ZERO ;SETREGS $IPRL_BIN_LRBIN+3 5 0 4 14:0xffe00 $IPRL_BIN_LR_OFFSET ;SETREG $IPRL_BIN_DPC 0x1002 COPYRD2D $IPRL_BIN_ROWBIN4X4 $IPRL_BIN_ROWBIN+2 6 COPYREG $IPRL_BIN_LRBIN4X4 $IPRL_BIN_LRBIN+5 ;get low word address of bin-list COPYREG $IPRL_BIN_DPC4X4 $IPRL_BIN_DPC SETREGS $IPRL_BIN_LR_NWORDS 2 0x8000L ;number of input pixels processed per LRBIN call SETREGS $IPRL_BIN_NWORDS 2 0x10000L SETREG $IPRL_BIN_DONE_ADDR 0x0004 ;address of source page high word when done SETREG $IPRL_BIN_K_SHIFT 2 ;amount to increase K by GOTO &COMMON_CODE QSR_FMT_8X8BIN:: ;SETREGS $IPRL_BIN_ROWBIN+2 9 19:0x0000 1024 8 1024 128 16 1 $IPRL_LONG_ZERO ;SETREGS $IPRL_BIN_LRBIN+3 5 0 4 14:0xffe30 $IPRL_BIN_LR_OFFSET ;SETREG $IPRL_BIN_DPC 0x1003 COPYRD2D $IPRL_BIN_ROWBIN8X8 $IPRL_BIN_ROWBIN+2 6 COPYREG $IPRL_BIN_LRBIN8X8 $IPRL_BIN_LRBIN+5 ;get low word address of bin-list COPYREG $IPRL_BIN_DPC8X8 $IPRL_BIN_DPC SETREGS $IPRL_BIN_LR_NWORDS 2 0x8000L ;number of input pixels processed per LRBIN call SETREGS $IPRL_BIN_NWORDS 2 0x4000L SETREG $IPRL_BIN_DONE_ADDR 0x0002 ;address of source page high word when done SETREG $IPRL_BIN_K_SHIFT 3 ;amount to increase K by ; GOTO &COMMON_CODE COMMON_CODE: GETQADR $IPRL_DEBUG_ADDR CALLQUE $QSR_DEBUG_IPREG ;get the IP register status COPYREG $IPRL_BIN_PARAM $IPRL_BIN_ROWBIN ;copy the source page info into the ROWBIN instruction reg list COPYREG $IPRL_BIN_PARAM+1 $IPRL_BIN_ROWBIN+1 ;copy the source page info into the ROWBIN instruction reg list ROWBIN $IPRL_BIN_ROWBIN ;do the binning in one direction COPYREG $IPRL_BIN_PARAM+2 $IPRL_BIN_LRBIN+1 ;copy the low word of the dest addr into LRBIN instruction reg COPYREG $IPRL_BIN_PARAM+3 $IPRL_BIN_LRBIN+2 ;copy the high word of the dest addr into LRBIN instruction reg GETQADR $IPRL_DEBUG_ADDR CALLQUE $QSR_DEBUG_IPREG ;get the IP register status SETREGS $IPRL_BIN_LR_OFFSET 2 0 0 ;initialize the offset RPT: SETREG $IPRL_BIN_LRBIN+3 0 ;set list pointer to zero LRBIN $IPRL_BIN_LRBIN ;do one set of binning ADDADR $IPRL_BIN_LR_OFFSET $IPRL_BIN_LR_NWORDS $IPRL_BIN_LR_OFFSET ;New Offset REGSUB $IPRL_BIN_DONE_ADDR $IPRL_BIN_LR_OFFSET+1 $IPRL_BIN_DONE_ADDR+1 BRANCHNE $IPRL_BIN_DONE_ADDR+1 0 &RPT ;--- do the decoding of the destination page GETQADR $IPRL_DEBUG_ADDR CALLQUE $QSR_DEBUG_IPREG ;get the IP register status COPYREG $IPRL_BIN_PARAM+1 $IPRL_HDECODE_PARAM ;copy the source page high word into a known fixed parameter place COPYREG $IPRL_BIN_PARAM+3 $IPRL_HDECODE_PARAM+1 ;copy the dest page high word into a known fixed parameter place CALLQUE $QSR_DO_HDECODE ;decode the value ;--- now copy the relevant info to the hrdinit slot COPYRI2D $IPRP_HDECODE_ADDR+1 $IPRL_HEAD_WORK 10 ;copy the register list to a fixed working area COPYREG $IPRL_BIN_PARAM+2 $IPRL_HEAD_WORK+6 ;copy the final dest(l) COPYREG $IPRL_BIN_PARAM+3 $IPRL_HEAD_WORK+7 ;copy the final dest(h) COPYREG $IPRL_BIN_DPC $IPRL_HEAD_WORK+5 ;overwrite dpc(l) COPYREG $IPRL_BIN_NWORDS $IPRL_HEAD_WORK+8 ;set the output number of pixels (l,h) COPYREG $IPRL_BIN_NWORDS+1 $IPRL_HEAD_WORK+9 ; BRANCHEQ $IPRL_HEAD_WORK+3 0 &SKIP_K_SHIFT ;if sending it raw, don't mess with the k REGADD $IPRL_HEAD_WORK+3 $IPRL_BIN_K_SHIFT $IPRL_HEAD_WORK+3 ;increase the K value SKIP_K_SHIFT: COPYRD2I $IPRL_HEAD_WORK $IPRP_HDECODE_ADDR+1 10 ;copy the register list back to the slot GETQADR $IPRL_DEBUG_ADDR CALLQUE $QSR_DEBUG_IPREG ;get the IP register status CALLQUE $QSR_DO_HEADER RTNQUE