Mercurial > mplayer.hg
comparison postproc/swscale_template.c @ 4297:29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
x/yInc bugfix (bug was introduced during the global var removial)
more emms & no messing with ARCH_X86 (=workaround against not cleared mmx state somewhere)
sharpening filter (-ssf cs=<int> & -ssf ls=<int>)
author | michael |
---|---|
date | Mon, 21 Jan 2002 22:11:09 +0000 |
parents | 67c56df76a44 |
children | f002407e298d |
comparison
equal
deleted
inserted
replaced
4296:a20c333d6c09 | 4297:29fef3982238 |
---|---|
1161 } | 1161 } |
1162 } | 1162 } |
1163 else if(dstFormat==IMGFMT_BGR16) | 1163 else if(dstFormat==IMGFMT_BGR16) |
1164 { | 1164 { |
1165 int i; | 1165 int i; |
1166 #ifdef DITHER1XBPP | |
1167 static int ditherb1=1<<14; | |
1168 static int ditherg1=1<<13; | |
1169 static int ditherr1=2<<14; | |
1170 static int ditherb2=3<<14; | |
1171 static int ditherg2=3<<13; | |
1172 static int ditherr2=0<<14; | |
1173 | |
1174 ditherb1 ^= (1^2)<<14; | |
1175 ditherg1 ^= (1^2)<<13; | |
1176 ditherr1 ^= (1^2)<<14; | |
1177 ditherb2 ^= (3^0)<<14; | |
1178 ditherg2 ^= (3^0)<<13; | |
1179 ditherr2 ^= (3^0)<<14; | |
1180 #else | |
1181 const int ditherb1=0; | |
1182 const int ditherg1=0; | |
1183 const int ditherr1=0; | |
1184 const int ditherb2=0; | |
1185 const int ditherg2=0; | |
1186 const int ditherr2=0; | |
1187 #endif | |
1166 for(i=0; i<dstW-1; i+=2){ | 1188 for(i=0; i<dstW-1; i+=2){ |
1167 // vertical linear interpolation && yuv2rgb in a single step: | 1189 // vertical linear interpolation && yuv2rgb in a single step: |
1168 int Y1=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; | 1190 int Y1=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; |
1169 int Y2=yuvtab_2568[((buf0[i+1]*yalpha1+buf1[i+1]*yalpha)>>19)]; | 1191 int Y2=yuvtab_2568[((buf0[i+1]*yalpha1+buf1[i+1]*yalpha)>>19)]; |
1170 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); | 1192 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); |
1173 int Cb= yuvtab_40cf[U]; | 1195 int Cb= yuvtab_40cf[U]; |
1174 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; | 1196 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; |
1175 int Cr= yuvtab_3343[V]; | 1197 int Cr= yuvtab_3343[V]; |
1176 | 1198 |
1177 ((uint16_t*)dest)[i] = | 1199 ((uint16_t*)dest)[i] = |
1178 clip_table16b[(Y1 + Cb) >>13] | | 1200 clip_table16b[(Y1 + Cb + ditherb1) >>13] | |
1179 clip_table16g[(Y1 + Cg) >>13] | | 1201 clip_table16g[(Y1 + Cg + ditherg1) >>13] | |
1180 clip_table16r[(Y1 + Cr) >>13]; | 1202 clip_table16r[(Y1 + Cr + ditherr1) >>13]; |
1181 | 1203 |
1182 ((uint16_t*)dest)[i+1] = | 1204 ((uint16_t*)dest)[i+1] = |
1183 clip_table16b[(Y2 + Cb) >>13] | | 1205 clip_table16b[(Y2 + Cb + ditherb2) >>13] | |
1184 clip_table16g[(Y2 + Cg) >>13] | | 1206 clip_table16g[(Y2 + Cg + ditherg2) >>13] | |
1185 clip_table16r[(Y2 + Cr) >>13]; | 1207 clip_table16r[(Y2 + Cr + ditherr2) >>13]; |
1186 } | 1208 } |
1187 } | 1209 } |
1188 else if(dstFormat==IMGFMT_BGR15) | 1210 else if(dstFormat==IMGFMT_BGR15) |
1189 { | 1211 { |
1190 int i; | 1212 int i; |
1213 #ifdef DITHER1XBPP | |
1214 static int ditherb1=1<<14; | |
1215 static int ditherg1=1<<14; | |
1216 static int ditherr1=2<<14; | |
1217 static int ditherb2=3<<14; | |
1218 static int ditherg2=3<<14; | |
1219 static int ditherr2=0<<14; | |
1220 | |
1221 ditherb1 ^= (1^2)<<14; | |
1222 ditherg1 ^= (1^2)<<14; | |
1223 ditherr1 ^= (1^2)<<14; | |
1224 ditherb2 ^= (3^0)<<14; | |
1225 ditherg2 ^= (3^0)<<14; | |
1226 ditherr2 ^= (3^0)<<14; | |
1227 #else | |
1228 const int ditherb1=0; | |
1229 const int ditherg1=0; | |
1230 const int ditherr1=0; | |
1231 const int ditherb2=0; | |
1232 const int ditherg2=0; | |
1233 const int ditherr2=0; | |
1234 #endif | |
1191 for(i=0; i<dstW-1; i+=2){ | 1235 for(i=0; i<dstW-1; i+=2){ |
1192 // vertical linear interpolation && yuv2rgb in a single step: | 1236 // vertical linear interpolation && yuv2rgb in a single step: |
1193 int Y1=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; | 1237 int Y1=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; |
1194 int Y2=yuvtab_2568[((buf0[i+1]*yalpha1+buf1[i+1]*yalpha)>>19)]; | 1238 int Y2=yuvtab_2568[((buf0[i+1]*yalpha1+buf1[i+1]*yalpha)>>19)]; |
1195 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); | 1239 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); |
1198 int Cb= yuvtab_40cf[U]; | 1242 int Cb= yuvtab_40cf[U]; |
1199 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; | 1243 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; |
1200 int Cr= yuvtab_3343[V]; | 1244 int Cr= yuvtab_3343[V]; |
1201 | 1245 |
1202 ((uint16_t*)dest)[i] = | 1246 ((uint16_t*)dest)[i] = |
1203 clip_table15b[(Y1 + Cb) >>13] | | 1247 clip_table15b[(Y1 + Cb + ditherb1) >>13] | |
1204 clip_table15g[(Y1 + Cg) >>13] | | 1248 clip_table15g[(Y1 + Cg + ditherg1) >>13] | |
1205 clip_table15r[(Y1 + Cr) >>13]; | 1249 clip_table15r[(Y1 + Cr + ditherr1) >>13]; |
1206 | 1250 |
1207 ((uint16_t*)dest)[i+1] = | 1251 ((uint16_t*)dest)[i+1] = |
1208 clip_table15b[(Y2 + Cb) >>13] | | 1252 clip_table15b[(Y2 + Cb + ditherb2) >>13] | |
1209 clip_table15g[(Y2 + Cg) >>13] | | 1253 clip_table15g[(Y2 + Cg + ditherg2) >>13] | |
1210 clip_table15r[(Y2 + Cr) >>13]; | 1254 clip_table15r[(Y2 + Cr + ditherr2) >>13]; |
1211 } | 1255 } |
1212 } | 1256 } |
1213 #endif | 1257 #endif |
1214 } //!FULL_UV_IPOL | 1258 } //!FULL_UV_IPOL |
1215 } | 1259 } |
1395 } | 1439 } |
1396 } | 1440 } |
1397 else if(dstFormat==IMGFMT_BGR16) | 1441 else if(dstFormat==IMGFMT_BGR16) |
1398 { | 1442 { |
1399 int i; | 1443 int i; |
1444 #ifdef DITHER1XBPP | |
1445 static int ditherb1=1<<14; | |
1446 static int ditherg1=1<<13; | |
1447 static int ditherr1=2<<14; | |
1448 static int ditherb2=3<<14; | |
1449 static int ditherg2=3<<13; | |
1450 static int ditherr2=0<<14; | |
1451 | |
1452 ditherb1 ^= (1^2)<<14; | |
1453 ditherg1 ^= (1^2)<<13; | |
1454 ditherr1 ^= (1^2)<<14; | |
1455 ditherb2 ^= (3^0)<<14; | |
1456 ditherg2 ^= (3^0)<<13; | |
1457 ditherr2 ^= (3^0)<<14; | |
1458 #else | |
1459 const int ditherb1=0; | |
1460 const int ditherg1=0; | |
1461 const int ditherr1=0; | |
1462 const int ditherb2=0; | |
1463 const int ditherg2=0; | |
1464 const int ditherr2=0; | |
1465 #endif | |
1400 for(i=0; i<dstW-1; i+=2){ | 1466 for(i=0; i<dstW-1; i+=2){ |
1401 // vertical linear interpolation && yuv2rgb in a single step: | 1467 // vertical linear interpolation && yuv2rgb in a single step: |
1402 int Y1=yuvtab_2568[buf0[i]>>7]; | 1468 int Y1=yuvtab_2568[buf0[i]>>7]; |
1403 int Y2=yuvtab_2568[buf0[i+1]>>7]; | 1469 int Y2=yuvtab_2568[buf0[i+1]>>7]; |
1404 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); | 1470 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); |
1407 int Cb= yuvtab_40cf[U]; | 1473 int Cb= yuvtab_40cf[U]; |
1408 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; | 1474 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; |
1409 int Cr= yuvtab_3343[V]; | 1475 int Cr= yuvtab_3343[V]; |
1410 | 1476 |
1411 ((uint16_t*)dest)[i] = | 1477 ((uint16_t*)dest)[i] = |
1412 clip_table16b[(Y1 + Cb) >>13] | | 1478 clip_table16b[(Y1 + Cb + ditherb1) >>13] | |
1413 clip_table16g[(Y1 + Cg) >>13] | | 1479 clip_table16g[(Y1 + Cg + ditherg1) >>13] | |
1414 clip_table16r[(Y1 + Cr) >>13]; | 1480 clip_table16r[(Y1 + Cr + ditherr1) >>13]; |
1415 | 1481 |
1416 ((uint16_t*)dest)[i+1] = | 1482 ((uint16_t*)dest)[i+1] = |
1417 clip_table16b[(Y2 + Cb) >>13] | | 1483 clip_table16b[(Y2 + Cb + ditherb2) >>13] | |
1418 clip_table16g[(Y2 + Cg) >>13] | | 1484 clip_table16g[(Y2 + Cg + ditherg2) >>13] | |
1419 clip_table16r[(Y2 + Cr) >>13]; | 1485 clip_table16r[(Y2 + Cr + ditherr2) >>13]; |
1420 } | 1486 } |
1421 } | 1487 } |
1422 else if(dstFormat==IMGFMT_BGR15) | 1488 else if(dstFormat==IMGFMT_BGR15) |
1423 { | 1489 { |
1424 int i; | 1490 int i; |
1491 #ifdef DITHER1XBPP | |
1492 static int ditherb1=1<<14; | |
1493 static int ditherg1=1<<14; | |
1494 static int ditherr1=2<<14; | |
1495 static int ditherb2=3<<14; | |
1496 static int ditherg2=3<<14; | |
1497 static int ditherr2=0<<14; | |
1498 | |
1499 ditherb1 ^= (1^2)<<14; | |
1500 ditherg1 ^= (1^2)<<14; | |
1501 ditherr1 ^= (1^2)<<14; | |
1502 ditherb2 ^= (3^0)<<14; | |
1503 ditherg2 ^= (3^0)<<14; | |
1504 ditherr2 ^= (3^0)<<14; | |
1505 #else | |
1506 const int ditherb1=0; | |
1507 const int ditherg1=0; | |
1508 const int ditherr1=0; | |
1509 const int ditherb2=0; | |
1510 const int ditherg2=0; | |
1511 const int ditherr2=0; | |
1512 #endif | |
1425 for(i=0; i<dstW-1; i+=2){ | 1513 for(i=0; i<dstW-1; i+=2){ |
1426 // vertical linear interpolation && yuv2rgb in a single step: | 1514 // vertical linear interpolation && yuv2rgb in a single step: |
1427 int Y1=yuvtab_2568[buf0[i]>>7]; | 1515 int Y1=yuvtab_2568[buf0[i]>>7]; |
1428 int Y2=yuvtab_2568[buf0[i+1]>>7]; | 1516 int Y2=yuvtab_2568[buf0[i+1]>>7]; |
1429 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); | 1517 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); |
1432 int Cb= yuvtab_40cf[U]; | 1520 int Cb= yuvtab_40cf[U]; |
1433 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; | 1521 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; |
1434 int Cr= yuvtab_3343[V]; | 1522 int Cr= yuvtab_3343[V]; |
1435 | 1523 |
1436 ((uint16_t*)dest)[i] = | 1524 ((uint16_t*)dest)[i] = |
1437 clip_table15b[(Y1 + Cb) >>13] | | 1525 clip_table15b[(Y1 + Cb + ditherb1) >>13] | |
1438 clip_table15g[(Y1 + Cg) >>13] | | 1526 clip_table15g[(Y1 + Cg + ditherg1) >>13] | |
1439 clip_table15r[(Y1 + Cr) >>13]; | 1527 clip_table15r[(Y1 + Cr + ditherr1) >>13]; |
1440 | 1528 |
1441 ((uint16_t*)dest)[i+1] = | 1529 ((uint16_t*)dest)[i+1] = |
1442 clip_table15b[(Y2 + Cb) >>13] | | 1530 clip_table15b[(Y2 + Cb + ditherb2) >>13] | |
1443 clip_table15g[(Y2 + Cg) >>13] | | 1531 clip_table15g[(Y2 + Cg + ditherg2) >>13] | |
1444 clip_table15r[(Y2 + Cr) >>13]; | 1532 clip_table15r[(Y2 + Cr + ditherr2) >>13]; |
1445 } | 1533 } |
1446 } | 1534 } |
1447 #endif | 1535 #endif |
1448 } | 1536 } |
1449 | 1537 |