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