gst_plugins_base/gst/videoscale/vs_scanline.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    25  * POSSIBILITY OF SUCH DAMAGE.
    25  * POSSIBILITY OF SUCH DAMAGE.
    26  */
    26  */
    27 
    27 
    28 #include "vs_scanline.h"
    28 #include "vs_scanline.h"
    29 
    29 #include <gst/liboil.h>
    30 #include <liboil/liboil.h>
       
    31 
    30 
    32 /* greyscale, i.e., single componenet */
    31 /* greyscale, i.e., single componenet */
    33 #ifdef __SYMBIAN32__
    32 #ifdef __SYMBIAN32__
    34 #include <liboil/globals.h>
       
    35 #endif
       
    36 #include <glib.h>
       
    37 #ifdef __SYMBIAN32__
       
    38 EXPORT_C
    33 EXPORT_C
    39 #endif
    34 #endif
    40 
    35 
    41 
    36 
    42 void
    37 void
    52 EXPORT_C
    47 EXPORT_C
    53 #endif
    48 #endif
    54 
    49 
    55 
    50 
    56 void
    51 void
    57 vs_scanline_resample_nearest_Y (uint8_t * dest, uint8_t * src, int src_width,
    52 vs_scanline_resample_nearest_Y (uint8_t * dest, uint8_t * src, int n,
    58     int n, int *accumulator, int increment)
    53     int *accumulator, int increment)
    59 {
    54 {
    60   int acc = *accumulator;
    55   int acc = *accumulator;
    61   int i;
    56   int i;
    62   int j;
    57   int j;
    63   int x;
    58   int x;
    64 
    59 
    65   for (i = 0; i < n; i++) {
    60   for (i = 0; i < n; i++) {
    66     j = acc >> 16;
    61     j = acc >> 16;
    67     x = acc & 0xffff;
    62     x = acc & 0xffff;
    68     dest[i] = (x < 32768 || j + 1 >= src_width) ? src[j] : src[j + 1];
    63     dest[i] = (x < 32768) ? src[j] : src[j + 1];
    69 
    64 
    70     acc += increment;
    65     acc += increment;
    71   }
    66   }
    72 
    67 
    73   *accumulator = acc;
    68   *accumulator = acc;
    74 }
    69 }
    75 #ifdef __SYMBIAN32__
    70 #ifdef __SYMBIAN32__
    76 EXPORT_C
    71 EXPORT_C
    77 #endif
    72 #endif
    78 
    73 
    79 void
    74 
    80 vs_scanline_resample_linear_Y (uint8_t * dest, uint8_t * src, int src_width,
    75 void
    81     int n, int *accumulator, int increment)
    76 vs_scanline_resample_linear_Y (uint8_t * dest, uint8_t * src, int n,
    82 {
    77     int *accumulator, int increment)
    83   int acc = *accumulator;
    78 {
    84   int i;
    79   uint32_t vals[2];
    85   int j;
    80 
    86   int x;
    81   vals[0] = *accumulator;
    87 
    82   vals[1] = increment;
    88   for (i = 0; i < n; i++) {
    83 
    89     j = acc >> 16;
    84   oil_resample_linear_u8 (dest, src, n, vals);
    90     x = acc & 0xffff;
    85 
    91 
    86   *accumulator = vals[0];
    92     if (j + 1 < src_width)
       
    93       dest[i] = (src[j] * (65536 - x) + src[j + 1] * x) >> 16;
       
    94     else
       
    95       dest[i] = src[j];
       
    96 
       
    97     acc += increment;
       
    98   }
       
    99 
       
   100   *accumulator = acc;
       
   101 }
    87 }
   102 #ifdef __SYMBIAN32__
    88 #ifdef __SYMBIAN32__
   103 EXPORT_C
    89 EXPORT_C
   104 #endif
    90 #endif
   105 
    91 
   110 {
    96 {
   111   uint32_t value = x >> 8;
    97   uint32_t value = x >> 8;
   112 
    98 
   113   oil_merge_linear_u8 (dest, src1, src2, &value, n);
    99   oil_merge_linear_u8 (dest, src1, src2, &value, n);
   114 }
   100 }
   115 #ifdef __SYMBIAN32__
   101 
   116 EXPORT_C
       
   117 #endif
       
   118 
       
   119 void
       
   120 vs_scanline_downsample_Y16 (uint8_t * dest, uint8_t * src, int n)
       
   121 {
       
   122   int i;
       
   123   uint16_t *d = (uint16_t *) dest, *s = (uint16_t *) src;
       
   124 
       
   125   for (i = 0; i < n; i++) {
       
   126     d[i] = (s[i * 2] + s[i * 2 + 1]) / 2;
       
   127   }
       
   128 }
       
   129 #ifdef __SYMBIAN32__
       
   130 EXPORT_C
       
   131 #endif
       
   132 
       
   133 void
       
   134 vs_scanline_resample_nearest_Y16 (uint8_t * dest, uint8_t * src, int src_width,
       
   135     int n, int *accumulator, int increment)
       
   136 {
       
   137   int acc = *accumulator;
       
   138   int i;
       
   139   int j;
       
   140   int x;
       
   141   uint16_t *d = (uint16_t *) dest, *s = (uint16_t *) src;
       
   142 
       
   143   for (i = 0; i < n; i++) {
       
   144     j = acc >> 16;
       
   145     x = acc & 0xffff;
       
   146     d[i] = (x < 32768 || j + 1 >= src_width) ? s[j] : s[j + 1];
       
   147 
       
   148     acc += increment;
       
   149   }
       
   150 
       
   151   *accumulator = acc;
       
   152 }
       
   153 
       
   154 #include <glib.h>
       
   155 
       
   156 #ifdef __SYMBIAN32__
       
   157 EXPORT_C
       
   158 #endif
       
   159 
       
   160 void
       
   161 vs_scanline_resample_linear_Y16 (uint8_t * dest, uint8_t * src, int src_width,
       
   162     int n, int *accumulator, int increment)
       
   163 {
       
   164   int acc = *accumulator;
       
   165   int i;
       
   166   int j;
       
   167   int x;
       
   168   uint16_t *d = (uint16_t *) dest, *s = (uint16_t *) src;
       
   169 
       
   170   for (i = 0; i < n; i++) {
       
   171     j = acc >> 16;
       
   172     x = acc & 0xffff;
       
   173 
       
   174     if (j + 1 < src_width)
       
   175       d[i] = (s[j] * (65536 - x) + s[j + 1] * x) >> 16;
       
   176     else
       
   177       d[i] = s[j];
       
   178 
       
   179     acc += increment;
       
   180   }
       
   181 
       
   182   *accumulator = acc;
       
   183 }
       
   184 #ifdef __SYMBIAN32__
       
   185 EXPORT_C
       
   186 #endif
       
   187 
       
   188 void
       
   189 vs_scanline_merge_linear_Y16 (uint8_t * dest, uint8_t * src1, uint8_t * src2,
       
   190     int n, int x)
       
   191 {
       
   192   int i;
       
   193   uint16_t *d = (uint16_t *) dest, *s1 = (uint16_t *) src1, *s2 =
       
   194       (uint16_t *) src2;
       
   195 
       
   196   for (i = 0; i < n; i++) {
       
   197     d[i] = (s1[i] * (65536 - x) + s2[i] * x) >> 16;
       
   198   }
       
   199 }
       
   200 
   102 
   201 /* RGBA */
   103 /* RGBA */
   202 #ifdef __SYMBIAN32__
   104 #ifdef __SYMBIAN32__
   203 EXPORT_C
   105 EXPORT_C
   204 #endif
   106 #endif
   220 EXPORT_C
   122 EXPORT_C
   221 #endif
   123 #endif
   222 
   124 
   223 
   125 
   224 void
   126 void
   225 vs_scanline_resample_nearest_RGBA (uint8_t * dest, uint8_t * src, int src_width,
   127 vs_scanline_resample_nearest_RGBA (uint8_t * dest, uint8_t * src, int n,
   226     int n, int *accumulator, int increment)
   128     int *accumulator, int increment)
   227 {
   129 {
   228   int acc = *accumulator;
   130   int acc = *accumulator;
   229   int i;
   131   int i;
   230   int j;
   132   int j;
   231   int x;
   133   int x;
   232 
   134 
   233   for (i = 0; i < n; i++) {
   135   for (i = 0; i < n; i++) {
   234     j = acc >> 16;
   136     j = acc >> 16;
   235     x = acc & 0xffff;
   137     x = acc & 0xffff;
   236 
   138     dest[i * 4 + 0] = (x < 32768) ? src[j * 4 + 0] : src[j * 4 + 4];
   237     if (j + 1 < src_width) {
   139     dest[i * 4 + 1] = (x < 32768) ? src[j * 4 + 1] : src[j * 4 + 5];
   238       dest[i * 4 + 0] = (x < 32768) ? src[j * 4 + 0] : src[j * 4 + 4];
   140     dest[i * 4 + 2] = (x < 32768) ? src[j * 4 + 2] : src[j * 4 + 6];
   239       dest[i * 4 + 1] = (x < 32768) ? src[j * 4 + 1] : src[j * 4 + 5];
   141     dest[i * 4 + 3] = (x < 32768) ? src[j * 4 + 3] : src[j * 4 + 7];
   240       dest[i * 4 + 2] = (x < 32768) ? src[j * 4 + 2] : src[j * 4 + 6];
   142 
   241       dest[i * 4 + 3] = (x < 32768) ? src[j * 4 + 3] : src[j * 4 + 7];
   143     acc += increment;
   242     } else {
   144   }
   243       dest[i * 4 + 0] = src[j * 4 + 0];
   145 
   244       dest[i * 4 + 1] = src[j * 4 + 1];
   146   *accumulator = acc;
   245       dest[i * 4 + 2] = src[j * 4 + 2];
   147 }
   246       dest[i * 4 + 3] = src[j * 4 + 3];
   148 #ifdef __SYMBIAN32__
   247     }
   149 EXPORT_C
   248 
   150 #endif
   249     acc += increment;
   151 
   250   }
   152 
   251 
   153 void
   252   *accumulator = acc;
   154 vs_scanline_resample_linear_RGBA (uint8_t * dest, uint8_t * src, int n,
   253 }
   155     int *accumulator, int increment)
   254 
       
   255 #include <stdio.h>
       
   256 #ifdef __SYMBIAN32__
       
   257 EXPORT_C
       
   258 #endif
       
   259 
       
   260 void
       
   261 vs_scanline_resample_linear_RGBA (uint8_t * dest, uint8_t * src, int src_width,
       
   262     int n, int *accumulator, int increment)
       
   263 {
   156 {
   264   uint32_t vals[2];
   157   uint32_t vals[2];
   265 
   158 
   266   vals[0] = *accumulator;
   159   vals[0] = *accumulator;
   267   vals[1] = increment;
   160   vals[1] = increment;
   268 
   161 
   269   if (src_width % 2 == 0) {
   162   oil_resample_linear_argb ((uint32_t *) dest, (uint32_t *) src, n, vals);
   270     oil_resample_linear_argb ((uint32_t *) dest, (uint32_t *) src, n, vals);
       
   271   } else if (src_width > 1) {
       
   272     if (n > 1)
       
   273       oil_resample_linear_argb ((uint32_t *) dest, (uint32_t *) src, n - 1,
       
   274           vals);
       
   275     dest[4 * (n - 1) + 0] = src[(vals[0] >> 16) + 0];
       
   276     dest[4 * (n - 1) + 1] = src[(vals[0] >> 16) + 1];
       
   277     dest[4 * (n - 1) + 2] = src[(vals[0] >> 16) + 2];
       
   278     dest[4 * (n - 1) + 3] = src[(vals[0] >> 16) + 3];
       
   279     vals[0] += increment;
       
   280   } else {
       
   281     int i;
       
   282 
       
   283     for (i = 0; i < n; i++) {
       
   284       dest[4 * i + 0] = src[0];
       
   285       dest[4 * i + 1] = src[1];
       
   286       dest[4 * i + 2] = src[2];
       
   287       dest[4 * i + 3] = src[3];
       
   288       vals[0] += increment;
       
   289     }
       
   290   }
       
   291 
   163 
   292   *accumulator = vals[0];
   164   *accumulator = vals[0];
   293 }
   165 }
   294 #ifdef __SYMBIAN32__
   166 #ifdef __SYMBIAN32__
   295 EXPORT_C
   167 EXPORT_C
   328 EXPORT_C
   200 EXPORT_C
   329 #endif
   201 #endif
   330 
   202 
   331 
   203 
   332 void
   204 void
   333 vs_scanline_resample_nearest_RGB (uint8_t * dest, uint8_t * src, int src_width,
   205 vs_scanline_resample_nearest_RGB (uint8_t * dest, uint8_t * src, int n,
   334     int n, int *accumulator, int increment)
   206     int *accumulator, int increment)
   335 {
   207 {
   336   int acc = *accumulator;
   208   int acc = *accumulator;
   337   int i;
   209   int i;
   338   int j;
   210   int j;
   339   int x;
   211   int x;
   340 
   212 
   341   for (i = 0; i < n; i++) {
   213   for (i = 0; i < n; i++) {
   342     j = acc >> 16;
   214     j = acc >> 16;
   343     x = acc & 0xffff;
   215     x = acc & 0xffff;
   344     dest[i * 3 + 0] = (x < 32768
   216     dest[i * 3 + 0] = (x < 32768) ? src[j * 3 + 0] : src[j * 3 + 3];
   345         || j + 1 >= src_width) ? src[j * 3 + 0] : src[j * 3 + 3];
   217     dest[i * 3 + 1] = (x < 32768) ? src[j * 3 + 1] : src[j * 3 + 4];
   346     dest[i * 3 + 1] = (x < 32768
   218     dest[i * 3 + 2] = (x < 32768) ? src[j * 3 + 2] : src[j * 3 + 5];
   347         || j + 1 >= src_width) ? src[j * 3 + 1] : src[j * 3 + 4];
   219 
   348     dest[i * 3 + 2] = (x < 32768
   220     acc += increment;
   349         || j + 1 >= src_width) ? src[j * 3 + 2] : src[j * 3 + 5];
   221   }
   350 
   222 
   351     acc += increment;
   223   *accumulator = acc;
   352   }
   224 }
   353 
   225 #ifdef __SYMBIAN32__
   354   *accumulator = acc;
   226 EXPORT_C
   355 }
   227 #endif
   356 #ifdef __SYMBIAN32__
   228 
   357 EXPORT_C
   229 
   358 #endif
   230 void
   359 
   231 vs_scanline_resample_linear_RGB (uint8_t * dest, uint8_t * src, int n,
   360 
   232     int *accumulator, int increment)
   361 void
   233 {
   362 vs_scanline_resample_linear_RGB (uint8_t * dest, uint8_t * src, int src_width,
   234   int acc = *accumulator;
   363     int n, int *accumulator, int increment)
   235   int i;
   364 {
   236   int j;
   365   int acc = *accumulator;
   237   int x;
   366   int i;
   238 
   367   int j;
   239   for (i = 0; i < n; i++) {
   368   int x;
   240     j = acc >> 16;
   369 
   241     x = acc & 0xffff;
   370   for (i = 0; i < n; i++) {
   242     dest[i * 3 + 0] = (src[j * 3 + 0] * (65536 - x) + src[j * 3 + 3] * x) >> 16;
   371     j = acc >> 16;
   243     dest[i * 3 + 1] = (src[j * 3 + 1] * (65536 - x) + src[j * 3 + 4] * x) >> 16;
   372     x = acc & 0xffff;
   244     dest[i * 3 + 2] = (src[j * 3 + 2] * (65536 - x) + src[j * 3 + 5] * x) >> 16;
   373 
       
   374     if (j + 1 < src_width) {
       
   375       dest[i * 3 + 0] =
       
   376           (src[j * 3 + 0] * (65536 - x) + src[j * 3 + 3] * x) >> 16;
       
   377       dest[i * 3 + 1] =
       
   378           (src[j * 3 + 1] * (65536 - x) + src[j * 3 + 4] * x) >> 16;
       
   379       dest[i * 3 + 2] =
       
   380           (src[j * 3 + 2] * (65536 - x) + src[j * 3 + 5] * x) >> 16;
       
   381     } else {
       
   382       dest[i * 3 + 0] = src[j * 3 + 0];
       
   383       dest[i * 3 + 1] = src[j * 3 + 1];
       
   384       dest[i * 3 + 2] = src[j * 3 + 2];
       
   385     }
       
   386 
   245 
   387     acc += increment;
   246     acc += increment;
   388   }
   247   }
   389 
   248 
   390   *accumulator = acc;
   249   *accumulator = acc;
   404 }
   263 }
   405 
   264 
   406 
   265 
   407 /* YUYV */
   266 /* YUYV */
   408 
   267 
   409 /* n is the number of pixels */
   268 /* n is the number of bi-pixels */
   410 /* increment is per Y pixel */
   269 /* increment is per Y pixel */
   411 #ifdef __SYMBIAN32__
   270 #ifdef __SYMBIAN32__
   412 EXPORT_C
   271 EXPORT_C
   413 #endif
   272 #endif
   414 
   273 
   429 EXPORT_C
   288 EXPORT_C
   430 #endif
   289 #endif
   431 
   290 
   432 
   291 
   433 void
   292 void
   434 vs_scanline_resample_nearest_YUYV (uint8_t * dest, uint8_t * src, int src_width,
   293 vs_scanline_resample_nearest_YUYV (uint8_t * dest, uint8_t * src, int n,
   435     int n, int *accumulator, int increment)
   294     int *accumulator, int increment)
   436 {
   295 {
   437   int acc = *accumulator;
   296   int acc = *accumulator;
   438   int i;
   297   int i;
   439   int j;
   298   int j;
   440   int x;
   299   int x;
   441   int quads = (n + 1) / 2;
   300 
   442 
   301   for (i = 0; i < n; i++) {
   443   for (i = 0; i < quads; i++) {
   302     j = acc >> 16;
   444     j = acc >> 16;
   303     x = acc & 0xffff;
   445     x = acc & 0xffff;
   304     dest[i * 4 + 0] = (x < 32768) ? src[j * 2 + 0] : src[j * 2 + 2];
   446     dest[i * 4 + 0] = (x < 32768
       
   447         || j + 1 >= src_width) ? src[j * 2 + 0] : src[j * 2 + 2];
       
   448 
   305 
   449     j = acc >> 17;
   306     j = acc >> 17;
   450     x = acc & 0x1ffff;
   307     x = acc & 0x1ffff;
   451     dest[i * 4 + 1] = (x < 65536
   308     dest[i * 4 + 1] = (x < 65536) ? src[j * 4 + 1] : src[j * 4 + 5];
   452         || 2 * (j + 2) >= src_width) ? src[j * 4 + 1] : src[j * 4 + 5];
   309     dest[i * 4 + 3] = (x < 65536) ? src[j * 4 + 3] : src[j * 4 + 7];
   453 
   310 
   454     if (2 * i + 1 < n && 2 * (j + 1) < src_width)
   311     acc += increment;
   455       dest[i * 4 + 3] = (x < 65536
   312 
   456           || 2 * (j + 3) >= src_width) ? src[j * 4 + 3] : src[j * 4 + 7];
   313     j = acc >> 16;
   457 
   314     x = acc & 0xffff;
   458     acc += increment;
   315     dest[i * 4 + 2] = (x < 32768) ? src[j * 2 + 0] : src[j * 2 + 2];
   459 
   316     acc += increment;
   460     j = acc >> 16;
   317   }
   461     x = acc & 0xffff;
   318 
   462 
   319   *accumulator = acc;
   463     if (2 * i + 1 < n && j < src_width) {
   320 }
   464       dest[i * 4 + 2] = (x < 32768
   321 #ifdef __SYMBIAN32__
   465           || j + 1 >= src_width) ? src[j * 2 + 0] : src[j * 2 + 2];
   322 EXPORT_C
   466       acc += increment;
   323 #endif
   467     }
   324 
   468   }
   325 
   469 
   326 void
   470   *accumulator = acc;
   327 vs_scanline_resample_linear_YUYV (uint8_t * dest, uint8_t * src, int n,
   471 }
   328     int *accumulator, int increment)
   472 #ifdef __SYMBIAN32__
   329 {
   473 EXPORT_C
   330   int acc = *accumulator;
   474 #endif
   331   int i;
   475 
   332   int j;
   476 
   333   int x;
   477 void
   334 
   478 vs_scanline_resample_linear_YUYV (uint8_t * dest, uint8_t * src, int src_width,
   335   for (i = 0; i < n; i++) {
   479     int n, int *accumulator, int increment)
   336     j = acc >> 16;
   480 {
   337     x = acc & 0xffff;
   481   int acc = *accumulator;
   338     dest[i * 4 + 0] = (src[j * 2 + 0] * (65536 - x) + src[j * 2 + 2] * x) >> 16;
   482   int i;
       
   483   int j;
       
   484   int x;
       
   485   int quads = (n + 1) / 2;
       
   486 
       
   487   for (i = 0; i < quads; i++) {
       
   488     j = acc >> 16;
       
   489     x = acc & 0xffff;
       
   490 
       
   491     if (j + 1 < src_width)
       
   492       dest[i * 4 + 0] =
       
   493           (src[j * 2 + 0] * (65536 - x) + src[j * 2 + 2] * x) >> 16;
       
   494     else
       
   495       dest[i * 4 + 0] = src[j * 2 + 0];
       
   496 
   339 
   497     j = acc >> 17;
   340     j = acc >> 17;
   498     x = acc & 0x1ffff;
   341     x = acc & 0x1ffff;
   499 
   342     dest[i * 4 + 1] =
   500     if (2 * (j + 2) < src_width)
   343         (src[j * 4 + 1] * (131072 - x) + src[j * 4 + 5] * x) >> 17;
   501       dest[i * 4 + 1] =
   344     dest[i * 4 + 3] =
   502           (src[j * 4 + 1] * (131072 - x) + src[j * 4 + 5] * x) >> 17;
   345         (src[j * 4 + 3] * (131072 - x) + src[j * 4 + 7] * x) >> 17;
   503     else
   346 
   504       dest[i * 4 + 1] = src[j * 4 + 1];
   347     acc += increment;
   505 
   348 
   506     if (2 * i + 1 < n && 2 * (j + 1) < src_width) {
   349     j = acc >> 16;
   507       if (2 * (j + 3) < src_width)
   350     x = acc & 0xffff;
   508         dest[i * 4 + 3] =
   351     dest[i * 4 + 2] = (src[j * 2 + 0] * (65536 - x) + src[j * 2 + 2] * x) >> 16;
   509             (src[j * 4 + 3] * (131072 - x) + src[j * 4 + 7] * x) >> 17;
   352     acc += increment;
   510       else
   353   }
   511         dest[i * 4 + 3] = src[j * 4 + 3];
       
   512     }
       
   513 
       
   514     acc += increment;
       
   515 
       
   516     j = acc >> 16;
       
   517     x = acc & 0xffff;
       
   518 
       
   519     if (2 * i + 1 < n && j < src_width) {
       
   520       if (j + 1 < src_width)
       
   521         dest[i * 4 + 2] =
       
   522             (src[j * 2 + 0] * (65536 - x) + src[j * 2 + 2] * x) >> 16;
       
   523       else
       
   524         dest[i * 4 + 2] = src[j * 2 + 0];
       
   525       acc += increment;
       
   526     }
       
   527   }
       
   528 
       
   529 
   354 
   530   *accumulator = acc;
   355   *accumulator = acc;
   531 }
   356 }
   532 #ifdef __SYMBIAN32__
   357 #ifdef __SYMBIAN32__
   533 EXPORT_C
   358 EXPORT_C
   537 void
   362 void
   538 vs_scanline_merge_linear_YUYV (uint8_t * dest, uint8_t * src1, uint8_t * src2,
   363 vs_scanline_merge_linear_YUYV (uint8_t * dest, uint8_t * src1, uint8_t * src2,
   539     int n, int x)
   364     int n, int x)
   540 {
   365 {
   541   int i;
   366   int i;
   542   int quads = (n + 1) / 2;
   367 
   543 
   368   for (i = 0; i < n; i++) {
   544   for (i = 0; i < quads; i++) {
       
   545     dest[i * 4 + 0] =
   369     dest[i * 4 + 0] =
   546         (src1[i * 4 + 0] * (65536 - x) + src2[i * 4 + 0] * x) >> 16;
   370         (src1[i * 4 + 0] * (65536 - x) + src2[i * 4 + 0] * x) >> 16;
   547     dest[i * 4 + 1] =
   371     dest[i * 4 + 1] =
   548         (src1[i * 4 + 1] * (65536 - x) + src2[i * 4 + 1] * x) >> 16;
   372         (src1[i * 4 + 1] * (65536 - x) + src2[i * 4 + 1] * x) >> 16;
   549 
   373     dest[i * 4 + 2] =
   550     if (2 * i + 1 < n) {
   374         (src1[i * 4 + 2] * (65536 - x) + src2[i * 4 + 2] * x) >> 16;
   551       dest[i * 4 + 2] =
   375     dest[i * 4 + 3] =
   552           (src1[i * 4 + 2] * (65536 - x) + src2[i * 4 + 2] * x) >> 16;
   376         (src1[i * 4 + 3] * (65536 - x) + src2[i * 4 + 3] * x) >> 16;
   553       dest[i * 4 + 3] =
       
   554           (src1[i * 4 + 3] * (65536 - x) + src2[i * 4 + 3] * x) >> 16;
       
   555     }
       
   556   }
   377   }
   557 }
   378 }
   558 
   379 
   559 
   380 
   560 /* UYVY */
   381 /* UYVY */
   582 EXPORT_C
   403 EXPORT_C
   583 #endif
   404 #endif
   584 
   405 
   585 
   406 
   586 void
   407 void
   587 vs_scanline_resample_nearest_UYVY (uint8_t * dest, uint8_t * src, int src_width,
   408 vs_scanline_resample_nearest_UYVY (uint8_t * dest, uint8_t * src, int n,
   588     int n, int *accumulator, int increment)
   409     int *accumulator, int increment)
   589 {
   410 {
   590   int acc = *accumulator;
   411   int acc = *accumulator;
   591   int i;
   412   int i;
   592   int j;
   413   int j;
   593   int x;
   414   int x;
   594   int quads = (n + 1) / 2;
   415 
   595 
   416   for (i = 0; i < n; i++) {
   596   for (i = 0; i < quads; i++) {
   417     j = acc >> 16;
   597     j = acc >> 16;
   418     x = acc & 0xffff;
   598     x = acc & 0xffff;
   419     dest[i * 4 + 1] = (x < 32768) ? src[j * 2 + 1] : src[j * 2 + 3];
   599 
       
   600     dest[i * 4 + 1] = (x < 32768
       
   601         || j + 1 >= src_width) ? src[j * 2 + 1] : src[j * 2 + 3];
       
   602 
   420 
   603     j = acc >> 17;
   421     j = acc >> 17;
   604     x = acc & 0x1ffff;
   422     x = acc & 0x1ffff;
   605 
   423     dest[i * 4 + 0] = (x < 65536) ? src[j * 4 + 0] : src[j * 4 + 4];
   606     dest[i * 4 + 0] = (x < 65536
   424     dest[i * 4 + 2] = (x < 65536) ? src[j * 4 + 2] : src[j * 4 + 6];
   607         || 2 * (j + 2) >= src_width) ? src[j * 4 + 0] : src[j * 4 + 4];
   425 
   608 
   426     acc += increment;
   609     if (2 * i + 1 < n && 2 * (j + 1) < src_width)
   427 
   610       dest[i * 4 + 2] = (x < 65536
   428     j = acc >> 16;
   611           || 2 * (j + 3) >= src_width) ? src[j * 4 + 2] : src[j * 4 + 6];
   429     x = acc & 0xffff;
   612 
   430     dest[i * 4 + 3] = (x < 32768) ? src[j * 2 + 1] : src[j * 2 + 3];
   613     acc += increment;
   431     acc += increment;
   614 
   432   }
   615     j = acc >> 16;
   433 
   616     x = acc & 0xffff;
   434   *accumulator = acc;
   617 
   435 }
   618     if (2 * i + 1 < n && j < src_width) {
   436 #ifdef __SYMBIAN32__
   619       dest[i * 4 + 3] = (x < 32768
   437 EXPORT_C
   620           || j + 1 >= src_width) ? src[j * 2 + 1] : src[j * 2 + 3];
   438 #endif
   621       acc += increment;
   439 
   622     }
   440 
   623   }
   441 void
   624 
   442 vs_scanline_resample_linear_UYVY (uint8_t * dest, uint8_t * src, int n,
   625   *accumulator = acc;
   443     int *accumulator, int increment)
   626 }
   444 {
   627 #ifdef __SYMBIAN32__
   445   int acc = *accumulator;
   628 EXPORT_C
   446   int i;
   629 #endif
   447   int j;
   630 
   448   int x;
   631 
   449 
   632 void
   450   for (i = 0; i < n; i++) {
   633 vs_scanline_resample_linear_UYVY (uint8_t * dest, uint8_t * src, int src_width,
   451     j = acc >> 16;
   634     int n, int *accumulator, int increment)
   452     x = acc & 0xffff;
   635 {
   453     dest[i * 4 + 1] = (src[j * 2 + 1] * (65536 - x) + src[j * 2 + 3] * x) >> 16;
   636   int acc = *accumulator;
       
   637   int i;
       
   638   int j;
       
   639   int x;
       
   640   int quads = (n + 1) / 2;
       
   641 
       
   642   for (i = 0; i < quads; i++) {
       
   643     j = acc >> 16;
       
   644     x = acc & 0xffff;
       
   645 
       
   646     if (j + 1 < src_width)
       
   647       dest[i * 4 + 1] =
       
   648           (src[j * 2 + 1] * (65536 - x) + src[j * 2 + 3] * x) >> 16;
       
   649     else
       
   650       dest[i * 4 + 1] = src[j * 2 + 1];
       
   651 
   454 
   652     j = acc >> 17;
   455     j = acc >> 17;
   653     x = acc & 0x1ffff;
   456     x = acc & 0x1ffff;
   654     if (2 * (j + 2) < src_width)
       
   655       dest[i * 4 + 0] =
       
   656           (src[j * 4 + 0] * (131072 - x) + src[j * 4 + 4] * x) >> 17;
       
   657     else
       
   658       dest[i * 4 + 0] = src[j * 4 + 0];
       
   659 
       
   660     if (i * 2 + 1 < n && 2 * (j + 1) < src_width) {
       
   661       if (2 * (j + 3) < src_width)
       
   662         dest[i * 4 + 2] =
       
   663             (src[j * 4 + 2] * (131072 - x) + src[j * 4 + 6] * x) >> 17;
       
   664       else
       
   665         dest[i * 4 + 2] = src[j * 4 + 2];
       
   666     }
       
   667 
       
   668     acc += increment;
       
   669 
       
   670     j = acc >> 16;
       
   671     x = acc & 0xffff;
       
   672 
       
   673     if (2 * i + 1 < n && j < src_width) {
       
   674       if (j + 1 < src_width)
       
   675         dest[i * 4 + 3] =
       
   676             (src[j * 2 + 1] * (65536 - x) + src[j * 2 + 3] * x) >> 16;
       
   677       else
       
   678         dest[i * 4 + 3] = src[j * 2 + 1];
       
   679       acc += increment;
       
   680     }
       
   681   }
       
   682 
       
   683   *accumulator = acc;
       
   684 }
       
   685 #ifdef __SYMBIAN32__
       
   686 EXPORT_C
       
   687 #endif
       
   688 
       
   689 
       
   690 void
       
   691 vs_scanline_merge_linear_UYVY (uint8_t * dest, uint8_t * src1,
       
   692     uint8_t * src2, int n, int x)
       
   693 {
       
   694   int i;
       
   695   int quads = (n + 1) / 2;
       
   696 
       
   697   for (i = 0; i < quads; i++) {
       
   698     dest[i * 4 + 0] =
   457     dest[i * 4 + 0] =
   699         (src1[i * 4 + 0] * (65536 - x) + src2[i * 4 + 0] * x) >> 16;
   458         (src[j * 4 + 0] * (131072 - x) + src[j * 4 + 4] * x) >> 17;
   700     dest[i * 4 + 1] =
   459     dest[i * 4 + 2] =
   701         (src1[i * 4 + 1] * (65536 - x) + src2[i * 4 + 1] * x) >> 16;
   460         (src[j * 4 + 2] * (131072 - x) + src[j * 4 + 6] * x) >> 17;
   702 
   461 
   703     if (2 * i + 1 < n) {
   462     acc += increment;
   704       dest[i * 4 + 2] =
   463 
   705           (src1[i * 4 + 2] * (65536 - x) + src2[i * 4 + 2] * x) >> 16;
   464     j = acc >> 16;
   706       dest[i * 4 + 3] =
   465     x = acc & 0xffff;
   707           (src1[i * 4 + 3] * (65536 - x) + src2[i * 4 + 3] * x) >> 16;
   466     dest[i * 4 + 3] = (src[j * 2 + 1] * (65536 - x) + src[j * 2 + 3] * x) >> 16;
   708     }
   467     acc += increment;
   709   }
   468   }
       
   469 
       
   470   *accumulator = acc;
       
   471 }
       
   472 #ifdef __SYMBIAN32__
       
   473 EXPORT_C
       
   474 #endif
       
   475 
       
   476 
       
   477 void
       
   478 vs_scanline_merge_linear_UYVY (uint8_t * dest, uint8_t * src1, uint8_t * src2,
       
   479     int n, int x)
       
   480 {
       
   481   uint32_t value = x >> 8;
       
   482 
       
   483   oil_merge_linear_argb ((uint32_t *) dest, (uint32_t *) src1,
       
   484       (uint32_t *) src2, &value, n);
   710 }
   485 }
   711 
   486 
   712 
   487 
   713 /* RGB565 */
   488 /* RGB565 */
   714 
   489 
   742 EXPORT_C
   517 EXPORT_C
   743 #endif
   518 #endif
   744 
   519 
   745 
   520 
   746 void
   521 void
   747 vs_scanline_resample_nearest_RGB565 (uint8_t * dest_u8, uint8_t * src_u8,
   522 vs_scanline_resample_nearest_RGB565 (uint8_t * dest_u8, uint8_t * src_u8, int n,
   748     int src_width, int n, int *accumulator, int increment)
   523     int *accumulator, int increment)
   749 {
   524 {
   750   uint16_t *dest = (uint16_t *) dest_u8;
   525   uint16_t *dest = (uint16_t *) dest_u8;
   751   uint16_t *src = (uint16_t *) src_u8;
   526   uint16_t *src = (uint16_t *) src_u8;
   752   int acc = *accumulator;
   527   int acc = *accumulator;
   753   int i;
   528   int i;
   755   int x;
   530   int x;
   756 
   531 
   757   for (i = 0; i < n; i++) {
   532   for (i = 0; i < n; i++) {
   758     j = acc >> 16;
   533     j = acc >> 16;
   759     x = acc & 0xffff;
   534     x = acc & 0xffff;
   760     dest[i] = (x < 32768 || j + 1 >= src_width) ? src[j] : src[j + 1];
   535     dest[i] = (x < 32768) ? src[j] : src[j + 1];
   761 
   536 
   762     acc += increment;
   537     acc += increment;
   763   }
   538   }
   764 
   539 
   765   *accumulator = acc;
   540   *accumulator = acc;
   766 }
   541 }
   767 #ifdef __SYMBIAN32__
   542 #ifdef __SYMBIAN32__
   768 EXPORT_C
   543 EXPORT_C
   769 #endif
   544 #endif
   770 
   545 
   771 
   546 
   772 void
   547 void
   773 vs_scanline_resample_linear_RGB565 (uint8_t * dest_u8, uint8_t * src_u8,
   548 vs_scanline_resample_linear_RGB565 (uint8_t * dest_u8, uint8_t * src_u8, int n,
   774     int src_width, int n, int *accumulator, int increment)
   549     int *accumulator, int increment)
   775 {
   550 {
   776   uint16_t *dest = (uint16_t *) dest_u8;
   551   uint16_t *dest = (uint16_t *) dest_u8;
   777   uint16_t *src = (uint16_t *) src_u8;
   552   uint16_t *src = (uint16_t *) src_u8;
   778   int acc = *accumulator;
   553   int acc = *accumulator;
   779   int i;
   554   int i;
   781   int x;
   556   int x;
   782 
   557 
   783   for (i = 0; i < n; i++) {
   558   for (i = 0; i < n; i++) {
   784     j = acc >> 16;
   559     j = acc >> 16;
   785     x = acc & 0xffff;
   560     x = acc & 0xffff;
   786 
   561     dest[i] = RGB565 (
   787     if (j + 1 < src_width) {
   562         (RGB565_R (src[j]) * (65536 - x) + RGB565_R (src[j + 1]) * x) >> 16,
   788       dest[i] = RGB565 (
   563         (RGB565_G (src[j]) * (65536 - x) + RGB565_G (src[j + 1]) * x) >> 16,
   789           (RGB565_R (src[j]) * (65536 - x) + RGB565_R (src[j + 1]) * x) >> 16,
   564         (RGB565_B (src[j]) * (65536 - x) + RGB565_B (src[j + 1]) * x) >> 16);
   790           (RGB565_G (src[j]) * (65536 - x) + RGB565_G (src[j + 1]) * x) >> 16,
       
   791           (RGB565_B (src[j]) * (65536 - x) + RGB565_B (src[j + 1]) * x) >> 16);
       
   792     } else {
       
   793       dest[i] = RGB565 (RGB565_R (src[j]),
       
   794           RGB565_G (src[j]), RGB565_B (src[j]));
       
   795     }
       
   796 
   565 
   797     acc += increment;
   566     acc += increment;
   798   }
   567   }
   799 
   568 
   800   *accumulator = acc;
   569   *accumulator = acc;
   854 EXPORT_C
   623 EXPORT_C
   855 #endif
   624 #endif
   856 
   625 
   857 
   626 
   858 void
   627 void
   859 vs_scanline_resample_nearest_RGB555 (uint8_t * dest_u8, uint8_t * src_u8,
   628 vs_scanline_resample_nearest_RGB555 (uint8_t * dest_u8, uint8_t * src_u8, int n,
   860     int src_width, int n, int *accumulator, int increment)
   629     int *accumulator, int increment)
   861 {
   630 {
   862   uint16_t *dest = (uint16_t *) dest_u8;
   631   uint16_t *dest = (uint16_t *) dest_u8;
   863   uint16_t *src = (uint16_t *) src_u8;
   632   uint16_t *src = (uint16_t *) src_u8;
   864   int acc = *accumulator;
   633   int acc = *accumulator;
   865   int i;
   634   int i;
   867   int x;
   636   int x;
   868 
   637 
   869   for (i = 0; i < n; i++) {
   638   for (i = 0; i < n; i++) {
   870     j = acc >> 16;
   639     j = acc >> 16;
   871     x = acc & 0xffff;
   640     x = acc & 0xffff;
   872     dest[i] = (x < 32768 || j + 1 >= src_width) ? src[j] : src[j + 1];
   641     dest[i] = (x < 32768) ? src[j] : src[j + 1];
   873 
   642 
   874     acc += increment;
   643     acc += increment;
   875   }
   644   }
   876 
   645 
   877   *accumulator = acc;
   646   *accumulator = acc;
   878 }
   647 }
   879 #ifdef __SYMBIAN32__
   648 #ifdef __SYMBIAN32__
   880 EXPORT_C
   649 EXPORT_C
   881 #endif
   650 #endif
   882 
   651 
   883 
   652 
   884 void
   653 void
   885 vs_scanline_resample_linear_RGB555 (uint8_t * dest_u8, uint8_t * src_u8,
   654 vs_scanline_resample_linear_RGB555 (uint8_t * dest_u8, uint8_t * src_u8, int n,
   886     int src_width, int n, int *accumulator, int increment)
   655     int *accumulator, int increment)
   887 {
   656 {
   888   uint16_t *dest = (uint16_t *) dest_u8;
   657   uint16_t *dest = (uint16_t *) dest_u8;
   889   uint16_t *src = (uint16_t *) src_u8;
   658   uint16_t *src = (uint16_t *) src_u8;
   890   int acc = *accumulator;
   659   int acc = *accumulator;
   891   int i;
   660   int i;
   893   int x;
   662   int x;
   894 
   663 
   895   for (i = 0; i < n; i++) {
   664   for (i = 0; i < n; i++) {
   896     j = acc >> 16;
   665     j = acc >> 16;
   897     x = acc & 0xffff;
   666     x = acc & 0xffff;
   898 
   667     dest[i] = RGB555 (
   899     if (j + 1 < src_width) {
   668         (RGB555_R (src[j]) * (65536 - x) + RGB555_R (src[j + 1]) * x) >> 16,
   900       dest[i] = RGB555 (
   669         (RGB555_G (src[j]) * (65536 - x) + RGB555_G (src[j + 1]) * x) >> 16,
   901           (RGB555_R (src[j]) * (65536 - x) + RGB555_R (src[j + 1]) * x) >> 16,
   670         (RGB555_B (src[j]) * (65536 - x) + RGB555_B (src[j + 1]) * x) >> 16);
   902           (RGB555_G (src[j]) * (65536 - x) + RGB555_G (src[j + 1]) * x) >> 16,
       
   903           (RGB555_B (src[j]) * (65536 - x) + RGB555_B (src[j + 1]) * x) >> 16);
       
   904     } else {
       
   905       dest[i] = RGB555 (RGB555_R (src[j]),
       
   906           RGB555_G (src[j]), RGB555_B (src[j]));
       
   907     }
       
   908 
   671 
   909     acc += increment;
   672     acc += increment;
   910   }
   673   }
   911 
   674 
   912   *accumulator = acc;
   675   *accumulator = acc;