⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jquant2.txt

📁 STM32F103ZET6+UCOSII+UCGUI源码
💻 TXT
📖 第 1 页 / 共 5 页
字号:
;;;794      /* This array holds the distance to the nearest-so-far color for each cell */
;;;795      INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS];
;;;796    
;;;797      /* Initialize best-distance for each cell of the update box */
;;;798      bptr = bestdist;
000008  4669              MOV      r1,sp
;;;799      for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--)
00000a  207f              MOVS     r0,#0x7f
;;;800        *bptr++ = 0x7FFFFFFFL;
00000c  f06f4200          MVN      r2,#0x80000000
                  |L3.16|
000010  c104              STM      r1!,{r2}
000012  1e40              SUBS     r0,r0,#1              ;799
000014  d5fc              BPL      |L3.16|
;;;801      
;;;802      /* For each color selected by find_nearby_colors,
;;;803       * compute its distance to the center of each cell in the box.
;;;804       * If that's less than best-so-far, update best distance and color number.
;;;805       */
;;;806      
;;;807      /* Nominal steps between cell centers ("x" in Thomas article) */
;;;808    #define STEP_C0  ((1 << C0_SHIFT) * C0_SCALE)
;;;809    #define STEP_C1  ((1 << C1_SHIFT) * C1_SCALE)
;;;810    #define STEP_C2  ((1 << C2_SHIFT) * C2_SCALE)
;;;811      
;;;812      for (i = 0; i < numcolors; i++) {
000016  2000              MOVS     r0,#0
000018  e052              B        |L3.192|
                  |L3.26|
;;;813        icolor = GETJSAMPLE(colorlist[i]);
00001a  9891              LDR      r0,[sp,#0x244]
;;;814        /* Compute (square of) distance from minc0/c1/c2 to this color */
;;;815        inc0 = (minc0 - GETJSAMPLE(cinfo->colormap[0][icolor])) * C0_SCALE;
;;;816        dist0 = inc0*inc0;
;;;817        inc1 = (minc1 - GETJSAMPLE(cinfo->colormap[1][icolor])) * C1_SCALE;
00001c  9d85              LDR      r5,[sp,#0x214]
00001e  f810800b          LDRB     r8,[r0,r11]           ;813
000022  9883              LDR      r0,[sp,#0x20c]        ;815
;;;818        dist0 += inc1*inc1;
;;;819        inc2 = (minc2 - GETJSAMPLE(cinfo->colormap[2][icolor])) * C2_SCALE;
;;;820        dist0 += inc2*inc2;
;;;821        /* Form the initial difference increments */
;;;822        inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0;
;;;823        inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1;
;;;824        inc2 = inc2 * (2 * STEP_C2) + STEP_C2 * STEP_C2;
;;;825        /* Now loop over all cells in box, updating distance per Thomas method */
;;;826        bptr = bestdist;
;;;827        cptr = bestcolor;
;;;828        xx0 = inc0;
;;;829        for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) {
000024  f04f0e03          MOV      lr,#3
000028  f8d01088          LDR      r1,[r0,#0x88]         ;815
00002c  9884              LDR      r0,[sp,#0x210]        ;815
00002e  680a              LDR      r2,[r1,#0]            ;815
000030  f8122008          LDRB     r2,[r2,r8]            ;815
000034  1a80              SUBS     r0,r0,r2              ;815
000036  0042              LSLS     r2,r0,#1              ;815
000038  6848              LDR      r0,[r1,#4]            ;817
00003a  fb02f302          MUL      r3,r2,r2              ;816
00003e  f8100008          LDRB     r0,[r0,r8]            ;817
000042  1a28              SUBS     r0,r5,r0              ;817
000044  688d              LDR      r5,[r1,#8]            ;819
000046  eb000040          ADD      r0,r0,r0,LSL #1       ;817
00004a  f8154008          LDRB     r4,[r5,r8]            ;819
00004e  9986              LDR      r1,[sp,#0x218]        ;819
000050  fb003300          MLA      r3,r0,r0,r3           ;818
000054  1b09              SUBS     r1,r1,r4              ;819
000056  fb013a01          MLA      r10,r1,r1,r3          ;820
00005a  f44f7380          MOV      r3,#0x100             ;822
00005e  eb031942          ADD      r9,r3,r2,LSL #5       ;822
000062  eb000040          ADD      r0,r0,r0,LSL #1       ;823
000066  2390              MOVS     r3,#0x90              ;823
000068  eb0300c0          ADD      r0,r3,r0,LSL #3       ;823
00006c  9081              STR      r0,[sp,#0x204]        ;824
00006e  2040              MOVS     r0,#0x40              ;824
000070  eb001001          ADD      r0,r0,r1,LSL #4       ;824
000074  9c92              LDR      r4,[sp,#0x248]
000076  4669              MOV      r1,sp                 ;826
000078  9080              STR      r0,[sp,#0x200]        ;827
                  |L3.122|
;;;830          dist1 = dist0;
;;;831          xx1 = inc1;
;;;832          for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) {
;;;833    	dist2 = dist1;
;;;834    	xx2 = inc2;
;;;835    	for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) {
;;;836    	  if (dist2 < *bptr) {
;;;837    	    *bptr = dist2;
;;;838    	    *cptr = (JSAMPLE) icolor;
00007a  f00800ff          AND      r0,r8,#0xff
00007e  f8ddc204          LDR      r12,[sp,#0x204]
000082  4655              MOV      r5,r10                ;830
000084  2607              MOVS     r6,#7                 ;832
000086  9082              STR      r0,[sp,#0x208]
                  |L3.136|
000088  9b80              LDR      r3,[sp,#0x200]        ;835
00008a  4628              MOV      r0,r5                 ;833
00008c  2203              MOVS     r2,#3                 ;835
                  |L3.142|
00008e  680f              LDR      r7,[r1,#0]            ;836
000090  4287              CMP      r7,r0                 ;836
000092  dd02              BLE      |L3.154|
000094  6008              STR      r0,[r1,#0]            ;837
000096  9f82              LDR      r7,[sp,#0x208]
000098  7027              STRB     r7,[r4,#0]
                  |L3.154|
;;;839    	  }
;;;840    	  dist2 += xx2;
00009a  4418              ADD      r0,r0,r3
;;;841    	  xx2 += 2 * STEP_C2 * STEP_C2;
00009c  3380              ADDS     r3,r3,#0x80
;;;842    	  bptr++;
00009e  1d09              ADDS     r1,r1,#4
;;;843    	  cptr++;
0000a0  1c64              ADDS     r4,r4,#1
0000a2  1e52              SUBS     r2,r2,#1              ;835
0000a4  d5f3              BPL      |L3.142|
;;;844    	}
;;;845    	dist1 += xx1;
0000a6  4465              ADD      r5,r5,r12
;;;846    	xx1 += 2 * STEP_C1 * STEP_C1;
0000a8  f50c7c90          ADD      r12,r12,#0x120
0000ac  1e76              SUBS     r6,r6,#1              ;832
0000ae  d5eb              BPL      |L3.136|
;;;847          }
;;;848          dist0 += xx0;
0000b0  44ca              ADD      r10,r10,r9
;;;849          xx0 += 2 * STEP_C0 * STEP_C0;
0000b2  f5097900          ADD      r9,r9,#0x200
0000b6  f1be0e01          SUBS     lr,lr,#1              ;829
0000ba  d5de              BPL      |L3.122|
0000bc  f10b0001          ADD      r0,r11,#1             ;812
                  |L3.192|
0000c0  9990              LDR      r1,[sp,#0x240]        ;812
0000c2  4683              MOV      r11,r0                ;812
0000c4  4288              CMP      r0,r1                 ;812
0000c6  dba8              BLT      |L3.26|
;;;850        }
;;;851      }
;;;852    }
0000c8  f50d7d07          ADD      sp,sp,#0x21c
0000cc  e8bd8ff0          POP      {r4-r11,pc}
;;;853    
                          ENDP


                          AREA ||i.find_nearby_colors||, CODE, READONLY, ALIGN=1

                  find_nearby_colors PROC
;;;646    LOCAL(int)
;;;647    find_nearby_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
000000  e92d4fff          PUSH     {r0-r11,lr}
;;;648    		    JSAMPLE colorlist[])
;;;649    /* Locate the colormap entries close enough to an update box to be candidates
;;;650     * for the nearest entry to some cell(s) in the update box.  The update box
;;;651     * is specified by the center coordinates of its first cell.  The number of
;;;652     * candidate colormap entries is returned, and their colormap indexes are
;;;653     * placed in colorlist[].
;;;654     * This routine uses Heckbert's "locally sorted search" criterion to select
;;;655     * the colors that need further consideration.
;;;656     */
;;;657    {
000004  f2ad4d0c          SUB      sp,sp,#0x40c
;;;658      int numcolors = cinfo->actual_number_of_colors;
000008  f8dd040c          LDR      r0,[sp,#0x40c]
;;;659      int maxc0, maxc1, maxc2;
;;;660      int centerc0, centerc1, centerc2;
;;;661      int i, x, ncolors;
;;;662      INT32 minmaxdist, min_dist, max_dist, tdist;
;;;663      INT32 mindist[MAXNUMCOLORS];	/* min distance to colormap entry i */
;;;664    
;;;665      /* Compute true coordinates of update box's upper corner and center.
;;;666       * Actually we compute the coordinates of the center of the upper-corner
;;;667       * histogram cell, which are the upper bounds of the volume we care about.
;;;668       * Note that since ">>" rounds down, the "center" values may be closer to
;;;669       * min than to max; hence comparisons to them must be "<=", not "<".
;;;670       */
;;;671      maxc0 = minc0 + ((1 << BOX_C0_SHIFT) - (1 << C0_SHIFT));
00000c  f1010e18          ADD      lr,r1,#0x18
;;;672      centerc0 = (minc0 + maxc0) >> 1;
000010  f8d0b084          LDR      r11,[r0,#0x84]
000014  eb01000e          ADD      r0,r1,lr
000018  1040              ASRS     r0,r0,#1
;;;673      maxc1 = minc1 + ((1 << BOX_C1_SHIFT) - (1 << C1_SHIFT));
00001a  f102071c          ADD      r7,r2,#0x1c
;;;674      centerc1 = (minc1 + maxc1) >> 1;
00001e  f8cd0408          STR      r0,[sp,#0x408]
000022  19d0              ADDS     r0,r2,r7
000024  1040              ASRS     r0,r0,#1
;;;675      maxc2 = minc2 + ((1 << BOX_C2_SHIFT) - (1 << C2_SHIFT));
000026  f1030818          ADD      r8,r3,#0x18
;;;676      centerc2 = (minc2 + maxc2) >> 1;
00002a  f8cd0404          STR      r0,[sp,#0x404]
00002e  eb030008          ADD      r0,r3,r8
000032  1040              ASRS     r0,r0,#1
;;;677    
;;;678      /* For each color in colormap, find:
;;;679       *  1. its minimum squared-distance to any point in the update box
;;;680       *     (zero if color is within update box);
;;;681       *  2. its maximum squared-distance to any point in the update box.
;;;682       * Both of these can be found by considering only the corners of the box.
;;;683       * We save the minimum distance for each color in mindist[];
;;;684       * only the smallest maximum distance is of interest.
;;;685       */
;;;686      minmaxdist = 0x7FFFFFFFL;
000034  f06f4900          MVN      r9,#0x80000000
;;;687    
;;;688      for (i = 0; i < numcolors; i++) {
000038  2600              MOVS     r6,#0
00003a  f8cd0400          STR      r0,[sp,#0x400]
00003e  e05f              B        |L4.256|
                  |L4.64|
;;;689        /* We compute the squared-c0-distance term, then add in the other two. */
;;;690        x = GETJSAMPLE(cinfo->colormap[0][i]);
000040  f8dd040c          LDR      r0,[sp,#0x40c]
000044  f8d00088          LDR      r0,[r0,#0x88]
000048  4682              MOV      r10,r0
00004a  6800              LDR      r0,[r0,#0]
00004c  5d84              LDRB     r4,[r0,r6]
;;;691        if (x < minc0) {
00004e  428c              CMP      r4,r1
000050  da03              BGE      |L4.90|
;;;692          tdist = (x - minc0) * C0_SCALE;
000052  1a60              SUBS     r0,r4,r1
000054  0040              LSLS     r0,r0,#1
;;;693          min_dist = tdist*tdist;
000056  4340              MULS     r0,r0,r0
;;;694          tdist = (x - maxc0) * C0_SCALE;
;;;695          max_dist = tdist*tdist;
000058  e00b              B        |L4.114|
                  |L4.90|
;;;696        } else if (x > maxc0) {
00005a  4574              CMP      r4,lr
00005c  dd04              BLE      |L4.104|
;;;697          tdist = (x - maxc0) * C0_SCALE;
00005e  eba4000e          SUB      r0,r4,lr
000062  0040              LSLS     r0,r0,#1
;;;698          min_dist = tdist*tdist;
000064  4340              MULS     r0,r0,r0
;;;699          tdist = (x - minc0) * C0_SCALE;
;;;700          max_dist = tdist*tdist;
000066  e007              B        |L4.120|
                  |L4.104|
;;;701        } else {
;;;702          /* within cell range so no contribution to min_dist */
;;;703          min_dist = 0;
;;;704          if (x <= centerc0) {
000068  f8dd5408          LDR      r5,[sp,#0x408]
00006c  2000              MOVS     r0,#0                 ;703
00006e  42ac              CMP      r4,r5
000070  dc02              BGT      |L4.120|
                  |L4.114|
;;;705    	tdist = (x - maxc0) * C0_SCALE;
000072  eba4040e          SUB      r4,r4,lr
;;;706    	max_dist = tdist*tdist;
000076  e000              B        |L4.122|
                  |L4.120|
;;;707          } else {
;;;708    	tdist = (x - minc0) * C0_SCALE;
000078  1a64              SUBS     r4,r4,r1
                  |L4.122|
00007a  0065              LSLS     r5,r4,#1              ;705
;;;709    	max_dist = tdist*tdist;
;;;710          }
;;;711        }
;;;712    
;;;713        x = GETJSAMPLE(cinfo->colormap[1][i]);
00007c  f8da4004          LDR      r4,[r10,#4]
000080  436d              MULS     r5,r5,r5              ;706
000082  5da4              LDRB     r4,[r4,r6]
;;;714        if (x < minc1) {
000084  4294              CMP      r4,r2
000086  da06              BGE      |L4.150|
;;;715          tdist = (x - minc1) * C1_SCALE;
000088  eba40c02          SUB      r12,r4,r2

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -