gst_plugins_base/gst/videoscale/vs_image.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    47   int i;
    47   int i;
    48   int j;
    48   int j;
    49   int x;
    49   int x;
    50   int xacc;
    50   int xacc;
    51 
    51 
    52   if (dest->height == 1)
    52   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
    53     y_increment = 0;
    53   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
    54   else
       
    55     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
       
    56 
       
    57   if (dest->width == 1)
       
    58     x_increment = 0;
       
    59   else
       
    60     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
    61 
       
    62 
    54 
    63   acc = 0;
    55   acc = 0;
    64   for (i = 0; i < dest->height; i++) {
    56   for (i = 0; i < dest->height; i++) {
    65     j = acc >> 16;
    57     j = acc >> 16;
    66     x = acc & 0xffff;
    58     x = acc & 0xffff;
    67 
    59 
    68     xacc = 0;
    60     xacc = 0;
    69     vs_scanline_resample_nearest_RGBA (dest->pixels + i * dest->stride,
    61     vs_scanline_resample_nearest_RGBA (dest->pixels + i * dest->stride,
    70         src->pixels + j * src->stride, src->width, dest->width, &xacc,
    62         src->pixels + j * src->stride, dest->width, &xacc, x_increment);
    71         x_increment);
       
    72 
    63 
    73     acc += y_increment;
    64     acc += y_increment;
    74   }
    65   }
    75 }
    66 }
    76 #ifdef __SYMBIAN32__
    67 #ifdef __SYMBIAN32__
    93   int j;
    84   int j;
    94   int x;
    85   int x;
    95   int dest_size;
    86   int dest_size;
    96   int xacc;
    87   int xacc;
    97 
    88 
    98   if (dest->height == 1)
    89   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
    99     y_increment = 0;
    90   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
   100   else
       
   101     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
       
   102 
       
   103   if (dest->width == 1)
       
   104     x_increment = 0;
       
   105   else
       
   106     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
   107 
    91 
   108   dest_size = dest->width * 4;
    92   dest_size = dest->width * 4;
   109 
    93 
   110   tmp1 = tmpbuf;
    94   tmp1 = tmpbuf;
   111   tmp2 = tmpbuf + dest_size;
    95   tmp2 = tmpbuf + dest_size;
   112 
    96 
   113   acc = 0;
    97   acc = 0;
   114   xacc = 0;
    98   xacc = 0;
   115   y2 = -1;
    99   y2 = -1;
   116   vs_scanline_resample_linear_RGBA (tmp1, src->pixels, src->width, dest->width,
   100   vs_scanline_resample_linear_RGBA (tmp1, src->pixels, dest->width, &xacc,
   117       &xacc, x_increment);
   101       x_increment);
   118   y1 = 0;
   102   y1 = 0;
   119   for (i = 0; i < dest->height; i++) {
   103   for (i = 0; i < dest->height; i++) {
   120     j = acc >> 16;
   104     j = acc >> 16;
   121     x = acc & 0xffff;
   105     x = acc & 0xffff;
   122 
   106 
   126       } else if (j == y2) {
   110       } else if (j == y2) {
   127         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   111         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   128       } else {
   112       } else {
   129         xacc = 0;
   113         xacc = 0;
   130         vs_scanline_resample_linear_RGBA (tmp1, src->pixels + j * src->stride,
   114         vs_scanline_resample_linear_RGBA (tmp1, src->pixels + j * src->stride,
   131             src->width, dest->width, &xacc, x_increment);
   115             dest->width, &xacc, x_increment);
   132         y1 = j;
   116         y1 = j;
   133         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   117         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   134       }
   118       }
   135     } else {
   119     } else {
   136       if (j == y1) {
   120       if (j == y1) {
   137         if (j + 1 != y2) {
   121         if (j + 1 != y2) {
   138           xacc = 0;
   122           xacc = 0;
   139           vs_scanline_resample_linear_RGBA (tmp2,
   123           vs_scanline_resample_linear_RGBA (tmp2,
   140               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   124               src->pixels + (j + 1) * src->stride, dest->width, &xacc,
   141               &xacc, x_increment);
   125               x_increment);
   142           y2 = j + 1;
   126           y2 = j + 1;
   143         }
   127         }
   144         vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride,
   128         vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride,
   145             tmp1, tmp2, dest->width, x);
   129             tmp1, tmp2, dest->width, x);
   146       } else if (j == y2) {
   130       } else if (j == y2) {
   147         if (j + 1 != y1) {
   131         if (j + 1 != y1) {
   148           xacc = 0;
   132           xacc = 0;
   149           vs_scanline_resample_linear_RGBA (tmp1,
   133           vs_scanline_resample_linear_RGBA (tmp1,
   150               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   134               src->pixels + (j + 1) * src->stride, dest->width, &xacc,
   151               &xacc, x_increment);
   135               x_increment);
   152           y1 = j + 1;
   136           y1 = j + 1;
   153         }
   137         }
   154         vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride,
   138         vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride,
   155             tmp2, tmp1, dest->width, x);
   139             tmp2, tmp1, dest->width, x);
   156       } else {
   140       } else {
   157         xacc = 0;
   141         xacc = 0;
   158         vs_scanline_resample_linear_RGBA (tmp1, src->pixels + j * src->stride,
   142         vs_scanline_resample_linear_RGBA (tmp1, src->pixels + j * src->stride,
   159             src->width, dest->width, &xacc, x_increment);
   143             dest->width, &xacc, x_increment);
   160         y1 = j;
   144         y1 = j;
   161         xacc = 0;
   145         xacc = 0;
   162         vs_scanline_resample_linear_RGBA (tmp2,
   146         vs_scanline_resample_linear_RGBA (tmp2,
   163             src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc,
   147             src->pixels + (j + 1) * src->stride, dest->width, &xacc,
   164             x_increment);
   148             x_increment);
   165         y2 = (j + 1);
   149         y2 = (j + 1);
   166         vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride,
   150         vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride,
   167             tmp1, tmp2, dest->width, x);
   151             tmp1, tmp2, dest->width, x);
   168       }
   152       }
   187   int i;
   171   int i;
   188   int j;
   172   int j;
   189   int x;
   173   int x;
   190   int xacc;
   174   int xacc;
   191 
   175 
   192   if (dest->height == 1)
   176   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   193     y_increment = 0;
   177   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
   194   else
       
   195     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
       
   196 
       
   197   if (dest->width == 1)
       
   198     x_increment = 0;
       
   199   else
       
   200     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
   201 
   178 
   202   acc = 0;
   179   acc = 0;
   203   for (i = 0; i < dest->height; i++) {
   180   for (i = 0; i < dest->height; i++) {
   204     j = acc >> 16;
   181     j = acc >> 16;
   205     x = acc & 0xffff;
   182     x = acc & 0xffff;
   206 
   183 
   207     xacc = 0;
   184     xacc = 0;
   208     vs_scanline_resample_nearest_RGB (dest->pixels + i * dest->stride,
   185     vs_scanline_resample_nearest_RGB (dest->pixels + i * dest->stride,
   209         src->pixels + j * src->stride, src->width, dest->width, &xacc,
   186         src->pixels + j * src->stride, dest->width, &xacc, x_increment);
   210         x_increment);
       
   211 
   187 
   212     acc += y_increment;
   188     acc += y_increment;
   213   }
   189   }
   214 }
   190 }
   215 #ifdef __SYMBIAN32__
   191 #ifdef __SYMBIAN32__
   232   int j;
   208   int j;
   233   int x;
   209   int x;
   234   int dest_size;
   210   int dest_size;
   235   int xacc;
   211   int xacc;
   236 
   212 
   237   if (dest->height == 1)
   213   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   238     y_increment = 0;
   214   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
   239   else
       
   240     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
       
   241 
       
   242   if (dest->width == 1)
       
   243     x_increment = 0;
       
   244   else
       
   245     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
   246 
   215 
   247   dest_size = dest->width * 3;
   216   dest_size = dest->width * 3;
   248 
   217 
   249   tmp1 = tmpbuf;
   218   tmp1 = tmpbuf;
   250   tmp2 = tmpbuf + dest_size;
   219   tmp2 = tmpbuf + dest_size;
   251 
   220 
   252   acc = 0;
   221   acc = 0;
   253   xacc = 0;
   222   xacc = 0;
   254   y2 = -1;
   223   y2 = -1;
   255   vs_scanline_resample_linear_RGB (tmp1, src->pixels, src->width, dest->width,
   224   vs_scanline_resample_linear_RGB (tmp1, src->pixels, dest->width, &xacc,
   256       &xacc, x_increment);
   225       x_increment);
   257   y1 = 0;
   226   y1 = 0;
   258   for (i = 0; i < dest->height; i++) {
   227   for (i = 0; i < dest->height; i++) {
   259     j = acc >> 16;
   228     j = acc >> 16;
   260     x = acc & 0xffff;
   229     x = acc & 0xffff;
   261 
   230 
   265       } else if (j == y2) {
   234       } else if (j == y2) {
   266         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   235         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   267       } else {
   236       } else {
   268         xacc = 0;
   237         xacc = 0;
   269         vs_scanline_resample_linear_RGB (tmp1, src->pixels + j * src->stride,
   238         vs_scanline_resample_linear_RGB (tmp1, src->pixels + j * src->stride,
   270             src->width, dest->width, &xacc, x_increment);
   239             dest->width, &xacc, x_increment);
   271         y1 = j;
   240         y1 = j;
   272         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   241         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   273       }
   242       }
   274     } else {
   243     } else {
   275       if (j == y1) {
   244       if (j == y1) {
   276         if (j + 1 != y2) {
   245         if (j + 1 != y2) {
   277           xacc = 0;
   246           xacc = 0;
   278           vs_scanline_resample_linear_RGB (tmp2,
   247           vs_scanline_resample_linear_RGB (tmp2,
   279               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   248               src->pixels + (j + 1) * src->stride, dest->width, &xacc,
   280               &xacc, x_increment);
   249               x_increment);
   281           y2 = j + 1;
   250           y2 = j + 1;
   282         }
   251         }
   283         vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride,
   252         vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride,
   284             tmp1, tmp2, dest->width, x);
   253             tmp1, tmp2, dest->width, x);
   285       } else if (j == y2) {
   254       } else if (j == y2) {
   286         if (j + 1 != y1) {
   255         if (j + 1 != y1) {
   287           xacc = 0;
   256           xacc = 0;
   288           vs_scanline_resample_linear_RGB (tmp1,
   257           vs_scanline_resample_linear_RGB (tmp1,
   289               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   258               src->pixels + (j + 1) * src->stride, dest->width, &xacc,
   290               &xacc, x_increment);
   259               x_increment);
   291           y1 = j + 1;
   260           y1 = j + 1;
   292         }
   261         }
   293         vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride,
   262         vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride,
   294             tmp2, tmp1, dest->width, x);
   263             tmp2, tmp1, dest->width, x);
   295       } else {
   264       } else {
   296         xacc = 0;
   265         xacc = 0;
   297         vs_scanline_resample_linear_RGB (tmp1, src->pixels + j * src->stride,
   266         vs_scanline_resample_linear_RGB (tmp1, src->pixels + j * src->stride,
   298             src->width, dest->width, &xacc, x_increment);
   267             dest->width, &xacc, x_increment);
   299         y1 = j;
   268         y1 = j;
   300         xacc = 0;
   269         xacc = 0;
   301         vs_scanline_resample_linear_RGB (tmp2,
   270         vs_scanline_resample_linear_RGB (tmp2,
   302             src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc,
   271             src->pixels + (j + 1) * src->stride, dest->width, &xacc,
   303             x_increment);
   272             x_increment);
   304         y2 = (j + 1);
   273         y2 = (j + 1);
   305         vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride,
   274         vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride,
   306             tmp1, tmp2, dest->width, x);
   275             tmp1, tmp2, dest->width, x);
   307       }
   276       }
   326   int x_increment;
   295   int x_increment;
   327   int i;
   296   int i;
   328   int j;
   297   int j;
   329   int x;
   298   int x;
   330   int xacc;
   299   int xacc;
   331 
   300   int n_quads;
   332   if (dest->height == 1)
   301 
   333     y_increment = 0;
   302   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   334   else
   303   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
   335     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   304 
   336 
   305   n_quads = ROUND_UP_2 (dest->width) / 2;
   337   if (dest->width == 1)
       
   338     x_increment = 0;
       
   339   else
       
   340     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
   341 
       
   342   acc = 0;
   306   acc = 0;
   343   for (i = 0; i < dest->height; i++) {
   307   for (i = 0; i < dest->height; i++) {
   344     j = acc >> 16;
   308     j = acc >> 16;
   345     x = acc & 0xffff;
   309     x = acc & 0xffff;
   346 
   310 
   347     xacc = 0;
   311     xacc = 0;
   348     vs_scanline_resample_nearest_YUYV (dest->pixels + i * dest->stride,
   312     vs_scanline_resample_nearest_YUYV (dest->pixels + i * dest->stride,
   349         src->pixels + j * src->stride, src->width, dest->width, &xacc,
   313         src->pixels + j * src->stride, n_quads, &xacc, x_increment);
   350         x_increment);
       
   351 
   314 
   352     acc += y_increment;
   315     acc += y_increment;
   353   }
   316   }
   354 }
   317 }
   355 #ifdef __SYMBIAN32__
   318 #ifdef __SYMBIAN32__
   370   int y2;
   333   int y2;
   371   int i;
   334   int i;
   372   int j;
   335   int j;
   373   int x;
   336   int x;
   374   int dest_size;
   337   int dest_size;
   375   int xacc;
   338   int n_quads;
   376 
   339   int xacc;
   377   if (dest->height == 1)
   340 
   378     y_increment = 0;
   341   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   379   else
   342   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
   380     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
       
   381 
       
   382   if (dest->width == 1)
       
   383     x_increment = 0;
       
   384   else
       
   385     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
   386 
   343 
   387   dest_size = ROUND_UP_4 (dest->width * 2);
   344   dest_size = ROUND_UP_4 (dest->width * 2);
       
   345   n_quads = ROUND_UP_2 (dest->width) / 2;
   388 
   346 
   389   tmp1 = tmpbuf;
   347   tmp1 = tmpbuf;
   390   tmp2 = tmpbuf + dest_size;
   348   tmp2 = tmpbuf + dest_size;
   391 
   349 
   392   acc = 0;
   350   acc = 0;
   393   xacc = 0;
   351   xacc = 0;
   394   y2 = -1;
   352   y2 = -1;
   395   vs_scanline_resample_linear_YUYV (tmp1, src->pixels, src->width, dest->width,
   353   vs_scanline_resample_linear_YUYV (tmp1, src->pixels, n_quads, &xacc,
   396       &xacc, x_increment);
   354       x_increment);
   397   y1 = 0;
   355   y1 = 0;
   398   for (i = 0; i < dest->height; i++) {
   356   for (i = 0; i < dest->height; i++) {
   399     j = acc >> 16;
   357     j = acc >> 16;
   400     x = acc & 0xffff;
   358     x = acc & 0xffff;
   401 
   359 
   405       } else if (j == y2) {
   363       } else if (j == y2) {
   406         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   364         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   407       } else {
   365       } else {
   408         xacc = 0;
   366         xacc = 0;
   409         vs_scanline_resample_linear_YUYV (tmp1, src->pixels + j * src->stride,
   367         vs_scanline_resample_linear_YUYV (tmp1, src->pixels + j * src->stride,
   410             src->width, dest->width, &xacc, x_increment);
   368             n_quads, &xacc, x_increment);
   411         y1 = j;
   369         y1 = j;
   412         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   370         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   413       }
   371       }
   414     } else {
   372     } else {
   415       if (j == y1) {
   373       if (j == y1) {
   416         if (j + 1 != y2) {
   374         if (j + 1 != y2) {
   417           xacc = 0;
   375           xacc = 0;
   418           vs_scanline_resample_linear_YUYV (tmp2,
   376           vs_scanline_resample_linear_YUYV (tmp2,
   419               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   377               src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment);
   420               &xacc, x_increment);
       
   421           y2 = j + 1;
   378           y2 = j + 1;
   422         }
   379         }
   423         vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride,
   380         vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride,
   424             tmp1, tmp2, dest->width, x);
   381             tmp1, tmp2, n_quads, x);
   425       } else if (j == y2) {
   382       } else if (j == y2) {
   426         if (j + 1 != y1) {
   383         if (j + 1 != y1) {
   427           xacc = 0;
   384           xacc = 0;
   428           vs_scanline_resample_linear_YUYV (tmp1,
   385           vs_scanline_resample_linear_YUYV (tmp1,
   429               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   386               src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment);
   430               &xacc, x_increment);
       
   431           y1 = j + 1;
   387           y1 = j + 1;
   432         }
   388         }
   433         vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride,
   389         vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride,
   434             tmp2, tmp1, dest->width, x);
   390             tmp2, tmp1, n_quads, x);
   435       } else {
   391       } else {
   436         xacc = 0;
   392         xacc = 0;
   437         vs_scanline_resample_linear_YUYV (tmp1, src->pixels + j * src->stride,
   393         vs_scanline_resample_linear_YUYV (tmp1, src->pixels + j * src->stride,
   438             src->width, dest->width, &xacc, x_increment);
   394             n_quads, &xacc, x_increment);
   439         y1 = j;
   395         y1 = j;
   440         xacc = 0;
   396         xacc = 0;
   441         vs_scanline_resample_linear_YUYV (tmp2,
   397         vs_scanline_resample_linear_YUYV (tmp2,
   442             src->pixels + (j + 1) * src->stride, src->width, dest->width,
   398             src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment);
   443             &xacc, x_increment);
       
   444         y2 = (j + 1);
   399         y2 = (j + 1);
   445         vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride,
   400         vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride,
   446             tmp1, tmp2, dest->width, x);
   401             tmp1, tmp2, n_quads, x);
   447       }
   402       }
   448     }
   403     }
   449 
   404 
   450     acc += y_increment;
   405     acc += y_increment;
   451   }
   406   }
   466   int x_increment;
   421   int x_increment;
   467   int i;
   422   int i;
   468   int j;
   423   int j;
   469   int x;
   424   int x;
   470   int xacc;
   425   int xacc;
   471 
   426   int n_quads;
   472   if (dest->height == 1)
   427 
   473     y_increment = 0;
   428   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   474   else
   429   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
   475     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   430 
   476 
   431   n_quads = (dest->width + 1) / 2;
   477   if (dest->width == 1)
       
   478     x_increment = 0;
       
   479   else
       
   480     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
   481 
       
   482   acc = 0;
   432   acc = 0;
   483   for (i = 0; i < dest->height; i++) {
   433   for (i = 0; i < dest->height; i++) {
   484     j = acc >> 16;
   434     j = acc >> 16;
   485     x = acc & 0xffff;
   435     x = acc & 0xffff;
   486 
   436 
   487     xacc = 0;
   437     xacc = 0;
   488     vs_scanline_resample_nearest_UYVY (dest->pixels + i * dest->stride,
   438     vs_scanline_resample_nearest_UYVY (dest->pixels + i * dest->stride,
   489         src->pixels + j * src->stride, src->width, dest->width, &xacc,
   439         src->pixels + j * src->stride, n_quads, &xacc, x_increment);
   490         x_increment);
       
   491 
   440 
   492     acc += y_increment;
   441     acc += y_increment;
   493   }
   442   }
   494 }
   443 }
   495 #ifdef __SYMBIAN32__
   444 #ifdef __SYMBIAN32__
   510   int y2;
   459   int y2;
   511   int i;
   460   int i;
   512   int j;
   461   int j;
   513   int x;
   462   int x;
   514   int dest_size;
   463   int dest_size;
   515   int xacc;
   464   int n_quads;
   516 
   465   int xacc;
   517   if (dest->height == 1)
   466 
   518     y_increment = 0;
   467   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   519   else
   468   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
   520     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
       
   521 
       
   522   if (dest->width == 1)
       
   523     x_increment = 0;
       
   524   else
       
   525     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
   526 
   469 
   527   dest_size = ROUND_UP_4 (dest->width * 2);
   470   dest_size = ROUND_UP_4 (dest->width * 2);
       
   471   n_quads = ROUND_UP_2 (dest->width) / 2;
   528 
   472 
   529   tmp1 = tmpbuf;
   473   tmp1 = tmpbuf;
   530   tmp2 = tmpbuf + dest_size;
   474   tmp2 = tmpbuf + dest_size;
   531 
   475 
   532   acc = 0;
   476   acc = 0;
   533   xacc = 0;
   477   xacc = 0;
   534   y2 = -1;
   478   y2 = -1;
   535   vs_scanline_resample_linear_UYVY (tmp1, src->pixels, src->width, dest->width,
   479   vs_scanline_resample_linear_UYVY (tmp1, src->pixels, n_quads, &xacc,
   536       &xacc, x_increment);
   480       x_increment);
   537   y1 = 0;
   481   y1 = 0;
   538   for (i = 0; i < dest->height; i++) {
   482   for (i = 0; i < dest->height; i++) {
   539     j = acc >> 16;
   483     j = acc >> 16;
   540     x = acc & 0xffff;
   484     x = acc & 0xffff;
   541 
   485 
   545       } else if (j == y2) {
   489       } else if (j == y2) {
   546         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   490         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   547       } else {
   491       } else {
   548         xacc = 0;
   492         xacc = 0;
   549         vs_scanline_resample_linear_UYVY (tmp1, src->pixels + j * src->stride,
   493         vs_scanline_resample_linear_UYVY (tmp1, src->pixels + j * src->stride,
   550             src->width, dest->width, &xacc, x_increment);
   494             n_quads, &xacc, x_increment);
   551         y1 = j;
   495         y1 = j;
   552         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   496         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   553       }
   497       }
   554     } else {
   498     } else {
   555       if (j == y1) {
   499       if (j == y1) {
   556         if (j + 1 != y2) {
   500         if (j + 1 != y2) {
   557           xacc = 0;
   501           xacc = 0;
   558           vs_scanline_resample_linear_UYVY (tmp2,
   502           vs_scanline_resample_linear_UYVY (tmp2,
   559               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   503               src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment);
   560               &xacc, x_increment);
       
   561           y2 = j + 1;
   504           y2 = j + 1;
   562         }
   505         }
   563         vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride,
   506         vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride,
   564             tmp1, tmp2, dest->width, x);
   507             tmp1, tmp2, n_quads, x);
   565       } else if (j == y2) {
   508       } else if (j == y2) {
   566         if (j + 1 != y1) {
   509         if (j + 1 != y1) {
   567           xacc = 0;
   510           xacc = 0;
   568           vs_scanline_resample_linear_UYVY (tmp1,
   511           vs_scanline_resample_linear_UYVY (tmp1,
   569               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   512               src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment);
   570               &xacc, x_increment);
       
   571           y1 = j + 1;
   513           y1 = j + 1;
   572         }
   514         }
   573         vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride,
   515         vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride,
   574             tmp2, tmp1, dest->width, x);
   516             tmp2, tmp1, n_quads, x);
   575       } else {
   517       } else {
   576         xacc = 0;
   518         xacc = 0;
   577         vs_scanline_resample_linear_UYVY (tmp1, src->pixels + j * src->stride,
   519         vs_scanline_resample_linear_UYVY (tmp1, src->pixels + j * src->stride,
   578             src->width, dest->width, &xacc, x_increment);
   520             n_quads, &xacc, x_increment);
   579         y1 = j;
   521         y1 = j;
   580         xacc = 0;
   522         xacc = 0;
   581         vs_scanline_resample_linear_UYVY (tmp2,
   523         vs_scanline_resample_linear_UYVY (tmp2,
   582             src->pixels + (j + 1) * src->stride, src->width, dest->width,
   524             src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment);
   583             &xacc, x_increment);
       
   584         y2 = (j + 1);
   525         y2 = (j + 1);
   585         vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride,
   526         vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride,
   586             tmp1, tmp2, dest->width, x);
   527             tmp1, tmp2, n_quads, x);
   587       }
   528       }
   588     }
   529     }
   589 
   530 
   590     acc += y_increment;
   531     acc += y_increment;
   591   }
   532   }
   607   int i;
   548   int i;
   608   int j;
   549   int j;
   609   int x;
   550   int x;
   610   int xacc;
   551   int xacc;
   611 
   552 
   612   if (dest->height == 1)
   553   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   613     y_increment = 0;
   554   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
   614   else
       
   615     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
       
   616 
       
   617   if (dest->width == 1)
       
   618     x_increment = 0;
       
   619   else
       
   620     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
   621 
   555 
   622   acc = 0;
   556   acc = 0;
   623   for (i = 0; i < dest->height; i++) {
   557   for (i = 0; i < dest->height; i++) {
   624     j = acc >> 16;
   558     j = acc >> 16;
   625     x = acc & 0xffff;
   559     x = acc & 0xffff;
   626 
   560 
   627     xacc = 0;
   561     xacc = 0;
   628     vs_scanline_resample_nearest_Y (dest->pixels + i * dest->stride,
   562     vs_scanline_resample_nearest_Y (dest->pixels + i * dest->stride,
   629         src->pixels + j * src->stride, src->width, dest->width, &xacc,
   563         src->pixels + j * src->stride, dest->width, &xacc, x_increment);
   630         x_increment);
       
   631 
   564 
   632     acc += y_increment;
   565     acc += y_increment;
   633   }
   566   }
   634 }
   567 }
   635 #ifdef __SYMBIAN32__
   568 #ifdef __SYMBIAN32__
   652   int j;
   585   int j;
   653   int x;
   586   int x;
   654   int dest_size;
   587   int dest_size;
   655   int xacc;
   588   int xacc;
   656 
   589 
   657   if (dest->height == 1)
   590   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   658     y_increment = 0;
   591   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
   659   else
       
   660     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
       
   661 
       
   662   if (dest->width == 1)
       
   663     x_increment = 0;
       
   664   else
       
   665     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
   666 
   592 
   667   dest_size = dest->width;
   593   dest_size = dest->width;
   668 
   594 
   669   tmp1 = tmpbuf;
   595   tmp1 = tmpbuf;
   670   tmp2 = tmpbuf + dest_size;
   596   tmp2 = tmpbuf + dest_size;
   671 
   597 
   672   acc = 0;
   598   acc = 0;
   673   xacc = 0;
   599   xacc = 0;
   674   y2 = -1;
   600   y2 = -1;
   675   vs_scanline_resample_linear_Y (tmp1, src->pixels, src->width, dest->width,
   601   vs_scanline_resample_linear_Y (tmp1, src->pixels, dest->width, &xacc,
   676       &xacc, x_increment);
   602       x_increment);
   677   y1 = 0;
   603   y1 = 0;
   678   for (i = 0; i < dest->height; i++) {
   604   for (i = 0; i < dest->height; i++) {
   679     j = acc >> 16;
   605     j = acc >> 16;
   680     x = acc & 0xffff;
   606     x = acc & 0xffff;
   681 
   607 
   685       } else if (j == y2) {
   611       } else if (j == y2) {
   686         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   612         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   687       } else {
   613       } else {
   688         xacc = 0;
   614         xacc = 0;
   689         vs_scanline_resample_linear_Y (tmp1, src->pixels + j * src->stride,
   615         vs_scanline_resample_linear_Y (tmp1, src->pixels + j * src->stride,
   690             src->width, dest->width, &xacc, x_increment);
   616             dest->width, &xacc, x_increment);
   691         y1 = j;
   617         y1 = j;
   692         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   618         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   693       }
   619       }
   694     } else {
   620     } else {
   695       if (j == y1) {
   621       if (j == y1) {
   696         if (j + 1 != y2) {
   622         if (j + 1 != y2) {
   697           xacc = 0;
   623           xacc = 0;
   698           vs_scanline_resample_linear_Y (tmp2,
   624           vs_scanline_resample_linear_Y (tmp2,
   699               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   625               src->pixels + (j + 1) * src->stride, dest->width, &xacc,
   700               &xacc, x_increment);
   626               x_increment);
   701           y2 = j + 1;
   627           y2 = j + 1;
   702         }
   628         }
   703         vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride,
   629         vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride,
   704             tmp1, tmp2, dest->width, x);
   630             tmp1, tmp2, dest->width, x);
   705       } else if (j == y2) {
   631       } else if (j == y2) {
   706         if (j + 1 != y1) {
   632         if (j + 1 != y1) {
   707           xacc = 0;
   633           xacc = 0;
   708           vs_scanline_resample_linear_Y (tmp1,
   634           vs_scanline_resample_linear_Y (tmp1,
   709               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   635               src->pixels + (j + 1) * src->stride, dest->width, &xacc,
   710               &xacc, x_increment);
   636               x_increment);
   711           y1 = j + 1;
   637           y1 = j + 1;
   712         }
   638         }
   713         vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride,
   639         vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride,
   714             tmp2, tmp1, dest->width, x);
   640             tmp2, tmp1, dest->width, x);
   715       } else {
   641       } else {
   716         xacc = 0;
   642         xacc = 0;
   717         vs_scanline_resample_linear_Y (tmp1, src->pixels + j * src->stride,
   643         vs_scanline_resample_linear_Y (tmp1, src->pixels + j * src->stride,
   718             src->width, dest->width, &xacc, x_increment);
   644             dest->width, &xacc, x_increment);
   719         y1 = j;
   645         y1 = j;
   720         xacc = 0;
   646         xacc = 0;
   721         vs_scanline_resample_linear_Y (tmp2,
   647         vs_scanline_resample_linear_Y (tmp2,
   722             src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc,
   648             src->pixels + (j + 1) * src->stride, dest->width, &xacc,
   723             x_increment);
   649             x_increment);
   724         y2 = (j + 1);
   650         y2 = (j + 1);
   725         vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride,
   651         vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride,
   726             tmp1, tmp2, dest->width, x);
   652             tmp1, tmp2, dest->width, x);
   727       }
   653       }
   728     }
   654     }
   729 
   655 
   730     acc += y_increment;
   656     acc += y_increment;
   731   }
   657   }
   732 }
   658 }
   733 #ifdef __SYMBIAN32__
   659 
   734 EXPORT_C
   660 /* RGB565 */
   735 #endif
   661 #ifdef __SYMBIAN32__
   736 
   662 EXPORT_C
   737 void
   663 #endif
   738 vs_image_scale_nearest_Y16 (const VSImage * dest, const VSImage * src,
   664 
   739     uint8_t * tmpbuf)
   665 
   740 {
   666 void
   741   int acc;
   667 vs_image_scale_nearest_RGB565 (const VSImage * dest, const VSImage * src,
   742   int y_increment;
   668     uint8_t * tmpbuf)
   743   int x_increment;
   669 {
   744   int i;
   670   int acc;
   745   int j;
   671   int y_increment;
   746   int x;
   672   int x_increment;
   747   int xacc;
   673   int i;
   748 
   674   int j;
   749   if (dest->height == 1)
   675   int x;
   750     y_increment = 0;
   676   int xacc;
   751   else
   677 
   752     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   678   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   753 
   679   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
   754   if (dest->width == 1)
       
   755     x_increment = 0;
       
   756   else
       
   757     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
   758 
   680 
   759   acc = 0;
   681   acc = 0;
   760   for (i = 0; i < dest->height; i++) {
   682   for (i = 0; i < dest->height; i++) {
   761     j = acc >> 16;
   683     j = acc >> 16;
   762     x = acc & 0xffff;
   684     x = acc & 0xffff;
   763 
   685 
   764     xacc = 0;
   686     xacc = 0;
   765     vs_scanline_resample_nearest_Y16 (dest->pixels + i * dest->stride,
   687     vs_scanline_resample_nearest_RGB565 (dest->pixels + i * dest->stride,
   766         src->pixels + j * src->stride, src->width, dest->width, &xacc,
   688         src->pixels + j * src->stride, dest->width, &xacc, x_increment);
   767         x_increment);
   689 
   768 
   690     acc += y_increment;
   769     acc += y_increment;
   691   }
   770   }
   692 }
   771 }
   693 #ifdef __SYMBIAN32__
   772 #ifdef __SYMBIAN32__
   694 EXPORT_C
   773 EXPORT_C
   695 #endif
   774 #endif
   696 
   775 
   697 
   776 void
   698 void
   777 vs_image_scale_linear_Y16 (const VSImage * dest, const VSImage * src,
   699 vs_image_scale_linear_RGB565 (const VSImage * dest, const VSImage * src,
   778     uint8_t * tmpbuf)
   700     uint8_t * tmpbuf)
   779 {
   701 {
   780   int acc;
   702   int acc;
   781   int y_increment;
   703   int y_increment;
   782   int x_increment;
   704   int x_increment;
   788   int j;
   710   int j;
   789   int x;
   711   int x;
   790   int dest_size;
   712   int dest_size;
   791   int xacc;
   713   int xacc;
   792 
   714 
   793   if (dest->height == 1)
   715   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   794     y_increment = 0;
   716   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
   795   else
   717 
   796     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   718   dest_size = dest->width * 2;
   797 
       
   798   if (dest->width == 1)
       
   799     x_increment = 0;
       
   800   else
       
   801     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
   802 
       
   803   dest_size = 2 * dest->width;
       
   804 
   719 
   805   tmp1 = tmpbuf;
   720   tmp1 = tmpbuf;
   806   tmp2 = tmpbuf + dest_size;
   721   tmp2 = tmpbuf + dest_size;
   807 
   722 
   808   acc = 0;
   723   acc = 0;
   809   xacc = 0;
   724   xacc = 0;
   810   y2 = -1;
   725   y2 = -1;
   811   vs_scanline_resample_linear_Y16 (tmp1, src->pixels, src->width, dest->width,
   726   vs_scanline_resample_linear_RGB565 (tmp1, src->pixels, dest->width, &xacc,
   812       &xacc, x_increment);
   727       x_increment);
   813   y1 = 0;
   728   y1 = 0;
   814   for (i = 0; i < dest->height; i++) {
   729   for (i = 0; i < dest->height; i++) {
   815     j = acc >> 16;
   730     j = acc >> 16;
   816     x = acc & 0xffff;
   731     x = acc & 0xffff;
   817 
   732 
   820         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   735         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   821       } else if (j == y2) {
   736       } else if (j == y2) {
   822         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   737         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   823       } else {
   738       } else {
   824         xacc = 0;
   739         xacc = 0;
   825         vs_scanline_resample_linear_Y16 (tmp1, src->pixels + j * src->stride,
   740         vs_scanline_resample_linear_RGB565 (tmp1, src->pixels + j * src->stride,
   826             src->width, dest->width, &xacc, x_increment);
   741             dest->width, &xacc, x_increment);
   827         y1 = j;
   742         y1 = j;
   828         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   743         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   829       }
   744       }
   830     } else {
   745     } else {
   831       if (j == y1) {
   746       if (j == y1) {
   832         if (j + 1 != y2) {
   747         if (j + 1 != y2) {
   833           xacc = 0;
   748           xacc = 0;
   834           vs_scanline_resample_linear_Y16 (tmp2,
   749           vs_scanline_resample_linear_RGB565 (tmp2,
   835               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   750               src->pixels + (j + 1) * src->stride, dest->width, &xacc,
   836               &xacc, x_increment);
   751               x_increment);
   837           y2 = j + 1;
   752           y2 = j + 1;
   838         }
   753         }
   839         vs_scanline_merge_linear_Y16 (dest->pixels + i * dest->stride,
   754         vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride,
   840             tmp1, tmp2, dest->width, x);
   755             tmp1, tmp2, dest->width, x);
   841       } else if (j == y2) {
   756       } else if (j == y2) {
   842         if (j + 1 != y1) {
   757         if (j + 1 != y1) {
   843           xacc = 0;
   758           xacc = 0;
   844           vs_scanline_resample_linear_Y16 (tmp1,
   759           vs_scanline_resample_linear_RGB565 (tmp1,
   845               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   760               src->pixels + (j + 1) * src->stride, dest->width, &xacc,
   846               &xacc, x_increment);
   761               x_increment);
   847           y1 = j + 1;
   762           y1 = j + 1;
   848         }
   763         }
   849         vs_scanline_merge_linear_Y16 (dest->pixels + i * dest->stride,
   764         vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride,
   850             tmp2, tmp1, dest->width, x);
   765             tmp2, tmp1, dest->width, x);
   851       } else {
   766       } else {
   852         xacc = 0;
   767         xacc = 0;
   853         vs_scanline_resample_linear_Y16 (tmp1, src->pixels + j * src->stride,
   768         vs_scanline_resample_linear_RGB565 (tmp1, src->pixels + j * src->stride,
   854             src->width, dest->width, &xacc, x_increment);
   769             dest->width, &xacc, x_increment);
   855         y1 = j;
   770         y1 = j;
   856         xacc = 0;
   771         xacc = 0;
   857         vs_scanline_resample_linear_Y16 (tmp2,
   772         vs_scanline_resample_linear_RGB565 (tmp2,
   858             src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc,
   773             src->pixels + (j + 1) * src->stride, dest->width, &xacc,
   859             x_increment);
   774             x_increment);
   860         y2 = (j + 1);
   775         y2 = (j + 1);
   861         vs_scanline_merge_linear_Y16 (dest->pixels + i * dest->stride,
   776         vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride,
   862             tmp1, tmp2, dest->width, x);
   777             tmp1, tmp2, dest->width, x);
   863       }
   778       }
   864     }
   779     }
   865 
   780 
   866     acc += y_increment;
   781     acc += y_increment;
   867   }
   782   }
   868 }
   783 }
   869 
   784 
   870 /* RGB565 */
   785 /* RGB555 */
   871 #ifdef __SYMBIAN32__
   786 #ifdef __SYMBIAN32__
   872 EXPORT_C
   787 EXPORT_C
   873 #endif
   788 #endif
   874 
   789 
   875 
   790 
   876 void
   791 void
   877 vs_image_scale_nearest_RGB565 (const VSImage * dest, const VSImage * src,
   792 vs_image_scale_nearest_RGB555 (const VSImage * dest, const VSImage * src,
   878     uint8_t * tmpbuf)
   793     uint8_t * tmpbuf)
   879 {
   794 {
   880   int acc;
   795   int acc;
   881   int y_increment;
   796   int y_increment;
   882   int x_increment;
   797   int x_increment;
   883   int i;
   798   int i;
   884   int j;
   799   int j;
   885   int x;
   800   int x;
   886   int xacc;
   801   int xacc;
   887 
   802 
   888   if (dest->height == 1)
   803   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   889     y_increment = 0;
   804   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
   890   else
       
   891     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
       
   892 
       
   893   if (dest->width == 1)
       
   894     x_increment = 0;
       
   895   else
       
   896     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
   897 
   805 
   898   acc = 0;
   806   acc = 0;
   899   for (i = 0; i < dest->height; i++) {
   807   for (i = 0; i < dest->height; i++) {
   900     j = acc >> 16;
   808     j = acc >> 16;
   901     x = acc & 0xffff;
   809     x = acc & 0xffff;
   902 
   810 
   903     xacc = 0;
   811     xacc = 0;
   904     vs_scanline_resample_nearest_RGB565 (dest->pixels + i * dest->stride,
   812     vs_scanline_resample_nearest_RGB555 (dest->pixels + i * dest->stride,
   905         src->pixels + j * src->stride, src->width, dest->width, &xacc,
   813         src->pixels + j * src->stride, dest->width, &xacc, x_increment);
   906         x_increment);
   814 
   907 
   815     acc += y_increment;
   908     acc += y_increment;
   816   }
   909   }
   817 }
   910 }
   818 #ifdef __SYMBIAN32__
   911 #ifdef __SYMBIAN32__
   819 EXPORT_C
   912 EXPORT_C
   820 #endif
   913 #endif
   821 
   914 
   822 
   915 
   823 void
   916 void
   824 vs_image_scale_linear_RGB555 (const VSImage * dest, const VSImage * src,
   917 vs_image_scale_linear_RGB565 (const VSImage * dest, const VSImage * src,
       
   918     uint8_t * tmpbuf)
   825     uint8_t * tmpbuf)
   919 {
   826 {
   920   int acc;
   827   int acc;
   921   int y_increment;
   828   int y_increment;
   922   int x_increment;
   829   int x_increment;
   928   int j;
   835   int j;
   929   int x;
   836   int x;
   930   int dest_size;
   837   int dest_size;
   931   int xacc;
   838   int xacc;
   932 
   839 
   933   if (dest->height == 1)
   840   y_increment = ((src->height - 1) << 16) / (dest->height - 1);
   934     y_increment = 0;
   841   x_increment = ((src->width - 1) << 16) / (dest->width - 1);
   935   else
       
   936     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
       
   937 
       
   938   if (dest->width == 1)
       
   939     x_increment = 0;
       
   940   else
       
   941     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
   942 
   842 
   943   dest_size = dest->width * 2;
   843   dest_size = dest->width * 2;
   944 
   844 
   945   tmp1 = tmpbuf;
   845   tmp1 = tmpbuf;
   946   tmp2 = tmpbuf + dest_size;
   846   tmp2 = tmpbuf + dest_size;
   947 
   847 
   948   acc = 0;
   848   acc = 0;
   949   xacc = 0;
   849   xacc = 0;
   950   y2 = -1;
   850   y2 = -1;
   951   vs_scanline_resample_linear_RGB565 (tmp1, src->pixels, src->width,
   851   vs_scanline_resample_linear_RGB555 (tmp1, src->pixels, dest->width, &xacc,
   952       dest->width, &xacc, x_increment);
   852       x_increment);
   953   y1 = 0;
   853   y1 = 0;
   954   for (i = 0; i < dest->height; i++) {
   854   for (i = 0; i < dest->height; i++) {
   955     j = acc >> 16;
   855     j = acc >> 16;
   956     x = acc & 0xffff;
   856     x = acc & 0xffff;
   957 
   857 
   960         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   860         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   961       } else if (j == y2) {
   861       } else if (j == y2) {
   962         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   862         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
   963       } else {
   863       } else {
   964         xacc = 0;
   864         xacc = 0;
   965         vs_scanline_resample_linear_RGB565 (tmp1, src->pixels + j * src->stride,
   865         vs_scanline_resample_linear_RGB555 (tmp1, src->pixels + j * src->stride,
   966             src->width, dest->width, &xacc, x_increment);
   866             dest->width, &xacc, x_increment);
   967         y1 = j;
   867         y1 = j;
   968         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   868         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
   969       }
   869       }
   970     } else {
   870     } else {
   971       if (j == y1) {
   871       if (j == y1) {
   972         if (j + 1 != y2) {
   872         if (j + 1 != y2) {
   973           xacc = 0;
   873           xacc = 0;
   974           vs_scanline_resample_linear_RGB565 (tmp2,
       
   975               src->pixels + (j + 1) * src->stride, src->width, dest->width,
       
   976               &xacc, x_increment);
       
   977           y2 = j + 1;
       
   978         }
       
   979         vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride,
       
   980             tmp1, tmp2, dest->width, x);
       
   981       } else if (j == y2) {
       
   982         if (j + 1 != y1) {
       
   983           xacc = 0;
       
   984           vs_scanline_resample_linear_RGB565 (tmp1,
       
   985               src->pixels + (j + 1) * src->stride, src->width, dest->width,
       
   986               &xacc, x_increment);
       
   987           y1 = j + 1;
       
   988         }
       
   989         vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride,
       
   990             tmp2, tmp1, dest->width, x);
       
   991       } else {
       
   992         xacc = 0;
       
   993         vs_scanline_resample_linear_RGB565 (tmp1, src->pixels + j * src->stride,
       
   994             src->width, dest->width, &xacc, x_increment);
       
   995         y1 = j;
       
   996         xacc = 0;
       
   997         vs_scanline_resample_linear_RGB565 (tmp2,
       
   998             src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc,
       
   999             x_increment);
       
  1000         y2 = (j + 1);
       
  1001         vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride,
       
  1002             tmp1, tmp2, dest->width, x);
       
  1003       }
       
  1004     }
       
  1005 
       
  1006     acc += y_increment;
       
  1007   }
       
  1008 }
       
  1009 
       
  1010 /* RGB555 */
       
  1011 #ifdef __SYMBIAN32__
       
  1012 EXPORT_C
       
  1013 #endif
       
  1014 
       
  1015 
       
  1016 void
       
  1017 vs_image_scale_nearest_RGB555 (const VSImage * dest, const VSImage * src,
       
  1018     uint8_t * tmpbuf)
       
  1019 {
       
  1020   int acc;
       
  1021   int y_increment;
       
  1022   int x_increment;
       
  1023   int i;
       
  1024   int j;
       
  1025   int x;
       
  1026   int xacc;
       
  1027 
       
  1028   if (dest->height == 1)
       
  1029     y_increment = 0;
       
  1030   else
       
  1031     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
       
  1032 
       
  1033   if (dest->width == 1)
       
  1034     x_increment = 0;
       
  1035   else
       
  1036     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
  1037 
       
  1038   acc = 0;
       
  1039   for (i = 0; i < dest->height; i++) {
       
  1040     j = acc >> 16;
       
  1041     x = acc & 0xffff;
       
  1042 
       
  1043     xacc = 0;
       
  1044     vs_scanline_resample_nearest_RGB555 (dest->pixels + i * dest->stride,
       
  1045         src->pixels + j * src->stride, src->width, dest->width, &xacc,
       
  1046         x_increment);
       
  1047 
       
  1048     acc += y_increment;
       
  1049   }
       
  1050 }
       
  1051 #ifdef __SYMBIAN32__
       
  1052 EXPORT_C
       
  1053 #endif
       
  1054 
       
  1055 
       
  1056 void
       
  1057 vs_image_scale_linear_RGB555 (const VSImage * dest, const VSImage * src,
       
  1058     uint8_t * tmpbuf)
       
  1059 {
       
  1060   int acc;
       
  1061   int y_increment;
       
  1062   int x_increment;
       
  1063   uint8_t *tmp1;
       
  1064   uint8_t *tmp2;
       
  1065   int y1;
       
  1066   int y2;
       
  1067   int i;
       
  1068   int j;
       
  1069   int x;
       
  1070   int dest_size;
       
  1071   int xacc;
       
  1072 
       
  1073   if (dest->height == 1)
       
  1074     y_increment = 0;
       
  1075   else
       
  1076     y_increment = ((src->height - 1) << 16) / (dest->height - 1);
       
  1077 
       
  1078   if (dest->width == 1)
       
  1079     x_increment = 0;
       
  1080   else
       
  1081     x_increment = ((src->width - 1) << 16) / (dest->width - 1);
       
  1082 
       
  1083   dest_size = dest->width * 2;
       
  1084 
       
  1085   tmp1 = tmpbuf;
       
  1086   tmp2 = tmpbuf + dest_size;
       
  1087 
       
  1088   acc = 0;
       
  1089   xacc = 0;
       
  1090   y2 = -1;
       
  1091   vs_scanline_resample_linear_RGB555 (tmp1, src->pixels, src->width,
       
  1092       dest->width, &xacc, x_increment);
       
  1093   y1 = 0;
       
  1094   for (i = 0; i < dest->height; i++) {
       
  1095     j = acc >> 16;
       
  1096     x = acc & 0xffff;
       
  1097 
       
  1098     if (x == 0) {
       
  1099       if (j == y1) {
       
  1100         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
       
  1101       } else if (j == y2) {
       
  1102         memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
       
  1103       } else {
       
  1104         xacc = 0;
       
  1105         vs_scanline_resample_linear_RGB555 (tmp1, src->pixels + j * src->stride,
       
  1106             src->width, dest->width, &xacc, x_increment);
       
  1107         y1 = j;
       
  1108         memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
       
  1109       }
       
  1110     } else {
       
  1111       if (j == y1) {
       
  1112         if (j + 1 != y2) {
       
  1113           xacc = 0;
       
  1114           vs_scanline_resample_linear_RGB555 (tmp2,
   874           vs_scanline_resample_linear_RGB555 (tmp2,
  1115               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   875               src->pixels + (j + 1) * src->stride, dest->width, &xacc,
  1116               &xacc, x_increment);
   876               x_increment);
  1117           y2 = j + 1;
   877           y2 = j + 1;
  1118         }
   878         }
  1119         vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride,
   879         vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride,
  1120             tmp1, tmp2, dest->width, x);
   880             tmp1, tmp2, dest->width, x);
  1121       } else if (j == y2) {
   881       } else if (j == y2) {
  1122         if (j + 1 != y1) {
   882         if (j + 1 != y1) {
  1123           xacc = 0;
   883           xacc = 0;
  1124           vs_scanline_resample_linear_RGB555 (tmp1,
   884           vs_scanline_resample_linear_RGB555 (tmp1,
  1125               src->pixels + (j + 1) * src->stride, src->width, dest->width,
   885               src->pixels + (j + 1) * src->stride, dest->width, &xacc,
  1126               &xacc, x_increment);
   886               x_increment);
  1127           y1 = j + 1;
   887           y1 = j + 1;
  1128         }
   888         }
  1129         vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride,
   889         vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride,
  1130             tmp2, tmp1, dest->width, x);
   890             tmp2, tmp1, dest->width, x);
  1131       } else {
   891       } else {
  1132         xacc = 0;
   892         xacc = 0;
  1133         vs_scanline_resample_linear_RGB555 (tmp1, src->pixels + j * src->stride,
   893         vs_scanline_resample_linear_RGB555 (tmp1, src->pixels + j * src->stride,
  1134             src->width, dest->width, &xacc, x_increment);
   894             dest->width, &xacc, x_increment);
  1135         y1 = j;
   895         y1 = j;
  1136         xacc = 0;
   896         xacc = 0;
  1137         vs_scanline_resample_linear_RGB555 (tmp2,
   897         vs_scanline_resample_linear_RGB555 (tmp2,
  1138             src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc,
   898             src->pixels + (j + 1) * src->stride, dest->width, &xacc,
  1139             x_increment);
   899             x_increment);
  1140         y2 = (j + 1);
   900         y2 = (j + 1);
  1141         vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride,
   901         vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride,
  1142             tmp1, tmp2, dest->width, x);
   902             tmp1, tmp2, dest->width, x);
  1143       }
   903       }