📄 img_errdif_bin.h64
字号:
* /* ------------------------------------------------------ */ *
* errA = 0; errE = 0; *
* errB = err_buf[0]; *
* *
* /* ------------------------------------------------------ */ *
* /* Step through pixels in each row. */ *
* /* ------------------------------------------------------ */ *
* for (x = 0; x < cols; x++, i++) *
* { *
* /* --------------------------------------------------- */ *
* /* Load the error being propagated from pixel 'C' */ *
* /* from our error buffer. This was calculated */ *
* /* during the previous line. */ *
* /* --------------------------------------------------- */ *
* errC = err_buf[x+1]; *
* *
* /* --------------------------------------------------- */ *
* /* Load our pixel value to quantize. */ *
* /* --------------------------------------------------- */ *
* F = errdif_data[i]; *
* *
* /* --------------------------------------------------- */ *
* /* Calculate our resulting pixel. If we assume */ *
* /* that this pixel will be set to zero, this also */ *
* /* doubles as our error term. */ *
* /* --------------------------------------------------- */ *
* errF = F + ((errE*7 + errA + errB*5 + errC*3) >> 4); *
* *
* /* --------------------------------------------------- */ *
* /* Set pixels that are larger than the threshold to */ *
* /* 255, and pixels that are smaller than the */ *
* /* threshold to 0. */ *
* /* --------------------------------------------------- */ *
* if (errF > thresh) errdif_data[i] = 0xFF; *
* else errdif_data[i] = 0; *
* *
* /* --------------------------------------------------- */ *
* /* If the pixel was larger than the threshold, then */ *
* /* we need subtract 255 from our error. In any */ *
* /* case, store the error to the error buffer. */ *
* /* --------------------------------------------------- */ *
* if (errF > thresh) err_buf[x] = errF = errF - 0xFF; *
* else err_buf[x] = errF; *
* *
* /* --------------------------------------------------- */ *
* /* Propagate error terms for the next pixel. */ *
* /* --------------------------------------------------- */ *
* errE = errF; *
* errA = errB; *
* errB = errC; *
* } *
* } *
* } *
* *
* TECHNIQUES *
* Constants, 7, 5, 3, 1 for multiplication are shifted left 12 to *
* avoid 'SHR 4' operation in the critical path. *
* *
* The processing of the filter itself is inverted so that the *
* errors from previous pixels "propagate into" a given pixel at *
* the time the pixel is processed, rather than "accumulate into" *
* a pixel as its neighbors are processed. This allows us to *
* keep our image as an 8-bit image, and reduces the number of *
* accesses to the image array. The inverted filter kernel *
* performs identically to the kernel's original form. In this *
* form, the weights specify the weighting assigned to the errors *
* coming from the neighboring pixels. *
* *
* +---+---+---+ *
* | 1 | 5 | 3 | *
* +---+---+---+ *
* | 7 | P *
* +---+ *
* *
* The inner loop is software-pipelined. *
* *
* The outer loop has been interleaved with the prolog and epilog *
* of the inner loop. *
* *
* ASSUMPTIONS *
* The number of columns must be at least 2. *
* *
* err_buf[] must be initialized to zeros for the first call and *
* the returned err_buf should be provided for the next call. *
* *
* MEMORY NOTE *
* No bank conflicts occur, regardless of the relative orientation *
* of errdif_data[] and err_buf[]. *
* *
* NOTES *
* This function is Endian neutral. *
* This function is interruptible. *
* Max interrupt delay is 4*cols + 9 cycles. *
* No checking is performed on the input arguments for correctness. *
* No special alignment of data arrays is expected. *
* *
* CYCLES *
* cycles = (4*cols + 11)*rows + 5 *
* *
* For an image of cols = 720, rows = 480, cycles = 1,387,687 *
* *
* CODESIZE *
* 276 Bytes *
* *
* SOURCE *
* Floyd-Steinberg Error Diffusion. *
* *
* ------------------------------------------------------------------------- *
* Copyright (c) 2003 Texas Instruments, Incorporated. *
* All Rights Reserved. *
* ========================================================================= *
.global _IMG_errdif_bin
* ========================================================================= *
* End of file: img_errdif_bin.h64 *
* ------------------------------------------------------------------------- *
* Copyright (c) 2003 Texas Instruments, Incorporated. *
* All Rights Reserved. *
* ========================================================================= *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -