mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-10 17:35:59 +00:00
cog: Add quality setting to cogscale
This commit is contained in:
parent
06c3d2e93c
commit
960f418378
5 changed files with 723 additions and 141 deletions
516
ext/cog/cogtables.c
Normal file
516
ext/cog/cogtables.c
Normal file
|
@ -0,0 +1,516 @@
|
||||||
|
/* This file is autogenerated. Do not edit.*/
|
||||||
|
#include <glib.h>
|
||||||
|
gint8 cog_resample_table_4tap[256][4] = {
|
||||||
|
{0, 64, 0, 0}
|
||||||
|
, /* 0.000 0.000 0.000 -0.000 64 */
|
||||||
|
{0, 64, 0, 0}
|
||||||
|
, /* -0.248 -0.002 0.251 -0.001 64 */
|
||||||
|
{0, 64, 0, 0}
|
||||||
|
, /* -0.492 -0.008 0.504 -0.004 64 */
|
||||||
|
{-1, 64, 1, 0}
|
||||||
|
, /* 0.267 -0.017 -0.241 -0.009 64 */
|
||||||
|
{-1, 64, 1, 0}
|
||||||
|
, /* 0.031 -0.031 0.015 -0.015 64 */
|
||||||
|
{-1, 64, 1, 0}
|
||||||
|
, /* -0.202 -0.048 0.274 -0.024 64 */
|
||||||
|
{-1, 64, 1, 0}
|
||||||
|
, /* -0.431 -0.069 0.534 -0.034 64 */
|
||||||
|
{-2, 64, 2, 0}
|
||||||
|
, /* 0.344 -0.094 -0.203 -0.047 64 */
|
||||||
|
{-2, 64, 2, 0}
|
||||||
|
, /* 0.123 -0.123 0.061 -0.061 64 */
|
||||||
|
{-2, 64, 2, 0}
|
||||||
|
, /* -0.095 -0.155 0.326 -0.076 64 */
|
||||||
|
{-2, 64, 2, 0}
|
||||||
|
, /* -0.309 -0.191 0.594 -0.094 64 */
|
||||||
|
{-3, 64, 3, 0}
|
||||||
|
, /* 0.481 -0.231 -0.137 -0.113 64 */
|
||||||
|
{-3, 64, 3, 0}
|
||||||
|
, /* 0.275 -0.275 0.134 -0.134 64 */
|
||||||
|
{-3, 64, 3, 0}
|
||||||
|
, /* 0.072 -0.322 0.407 -0.157 64 */
|
||||||
|
{-3, 63, 4, 0}
|
||||||
|
, /* -0.128 0.628 -0.319 -0.181 64 */
|
||||||
|
{-3, 63, 4, 0}
|
||||||
|
, /* -0.323 0.573 -0.043 -0.207 64 */
|
||||||
|
{-4, 64, 4, 0}
|
||||||
|
, /* 0.484 -0.484 0.234 -0.234 64 */
|
||||||
|
{-4, 63, 5, 0}
|
||||||
|
, /* 0.296 0.454 -0.487 -0.263 64 */
|
||||||
|
{-4, 63, 5, 0}
|
||||||
|
, /* 0.111 0.389 -0.206 -0.294 64 */
|
||||||
|
{-4, 63, 5, 0}
|
||||||
|
, /* -0.071 0.321 0.076 -0.326 64 */
|
||||||
|
{-4, 63, 5, 0}
|
||||||
|
, /* -0.249 0.249 0.360 -0.360 64 */
|
||||||
|
{-5, 63, 6, 0}
|
||||||
|
, /* 0.576 0.174 -0.355 -0.395 64 */
|
||||||
|
{-5, 63, 6, 0}
|
||||||
|
, /* 0.405 0.095 -0.068 -0.432 64 */
|
||||||
|
{-5, 63, 6, 0}
|
||||||
|
, /* 0.237 0.013 0.220 -0.470 64 */
|
||||||
|
{-5, 63, 7, -1}
|
||||||
|
, /* 0.072 -0.072 -0.490 0.490 64 */
|
||||||
|
{-5, 63, 7, -1}
|
||||||
|
, /* -0.089 -0.161 -0.199 0.449 64 */
|
||||||
|
{-5, 63, 7, -1}
|
||||||
|
, /* -0.247 -0.253 0.093 0.407 64 */
|
||||||
|
{-5, 63, 7, -1}
|
||||||
|
, /* -0.401 -0.349 0.387 0.363 64 */
|
||||||
|
{-6, 63, 8, -1}
|
||||||
|
, /* 0.448 -0.448 -0.318 0.318 64 */
|
||||||
|
{-6, 63, 8, -1}
|
||||||
|
, /* 0.300 -0.550 -0.022 0.272 64 */
|
||||||
|
{-6, 63, 8, -1}
|
||||||
|
, /* 0.155 -0.655 0.276 0.224 64 */
|
||||||
|
{-6, 62, 9, -1}
|
||||||
|
, /* 0.013 0.237 -0.425 0.175 64 */
|
||||||
|
{-6, 62, 9, -1}
|
||||||
|
, /* -0.125 0.125 -0.125 0.125 64 */
|
||||||
|
{-6, 62, 9, -1}
|
||||||
|
, /* -0.260 0.010 0.176 0.074 64 */
|
||||||
|
{-6, 62, 9, -1}
|
||||||
|
, /* -0.392 -0.108 0.479 0.021 64 */
|
||||||
|
{-7, 62, 10, -1}
|
||||||
|
, /* 0.479 -0.229 -0.217 -0.033 64 */
|
||||||
|
{-7, 62, 10, -1}
|
||||||
|
, /* 0.353 -0.353 0.088 -0.088 64 */
|
||||||
|
{-7, 62, 10, -1}
|
||||||
|
, /* 0.231 -0.481 0.394 -0.144 64 */
|
||||||
|
{-7, 61, 11, -1}
|
||||||
|
, /* 0.111 0.389 -0.299 -0.201 64 */
|
||||||
|
{-7, 61, 11, -1}
|
||||||
|
, /* -0.006 0.256 0.009 -0.259 64 */
|
||||||
|
{-7, 61, 11, -1}
|
||||||
|
, /* -0.119 0.119 0.318 -0.318 64 */
|
||||||
|
{-7, 61, 12, -2}
|
||||||
|
, /* -0.230 -0.020 -0.371 0.621 64 */
|
||||||
|
{-7, 61, 12, -2}
|
||||||
|
, /* -0.337 -0.163 -0.060 0.560 64 */
|
||||||
|
{-7, 61, 12, -2}
|
||||||
|
, /* -0.442 -0.308 0.252 0.498 64 */
|
||||||
|
{-8, 61, 13, -2}
|
||||||
|
, /* 0.456 -0.456 -0.434 0.434 64 */
|
||||||
|
{-8, 61, 13, -2}
|
||||||
|
, /* 0.357 -0.607 -0.120 0.370 64 */
|
||||||
|
{-8, 60, 13, -1}
|
||||||
|
, /* 0.262 0.238 0.195 -0.695 64 */
|
||||||
|
{-8, 60, 14, -2}
|
||||||
|
, /* 0.168 0.082 -0.489 0.239 64 */
|
||||||
|
{-8, 60, 14, -2}
|
||||||
|
, /* 0.078 -0.078 -0.172 0.172 64 */
|
||||||
|
{-8, 60, 14, -2}
|
||||||
|
, /* -0.009 -0.241 0.146 0.104 64 */
|
||||||
|
{-8, 60, 14, -2}
|
||||||
|
, /* -0.094 -0.406 0.465 0.035 64 */
|
||||||
|
{-8, 59, 15, -2}
|
||||||
|
, /* -0.176 0.426 -0.216 -0.034 64 */
|
||||||
|
{-8, 59, 15, -2}
|
||||||
|
, /* -0.255 0.255 0.104 -0.104 64 */
|
||||||
|
{-8, 59, 15, -2}
|
||||||
|
, /* -0.332 0.082 0.425 -0.175 64 */
|
||||||
|
{-9, 59, 16, -2}
|
||||||
|
, /* 0.595 -0.095 -0.253 -0.247 64 */
|
||||||
|
{-9, 59, 16, -2}
|
||||||
|
, /* 0.524 -0.274 0.069 -0.319 64 */
|
||||||
|
{-9, 59, 16, -2}
|
||||||
|
, /* 0.455 -0.455 0.393 -0.393 64 */
|
||||||
|
{-9, 58, 17, -2}
|
||||||
|
, /* 0.389 0.361 -0.284 -0.466 64 */
|
||||||
|
{-9, 58, 17, -2}
|
||||||
|
, /* 0.326 0.174 0.041 -0.541 64 */
|
||||||
|
{-9, 58, 17, -2}
|
||||||
|
, /* 0.265 -0.015 0.366 -0.616 64 */
|
||||||
|
{-9, 58, 18, -3}
|
||||||
|
, /* 0.207 -0.207 -0.308 0.308 64 */
|
||||||
|
{-9, 58, 18, -3}
|
||||||
|
, /* 0.152 -0.402 0.018 0.232 64 */
|
||||||
|
{-9, 58, 18, -3}
|
||||||
|
, /* 0.099 -0.599 0.345 0.155 64 */
|
||||||
|
{-9, 57, 19, -3}
|
||||||
|
, /* 0.048 0.202 -0.328 0.078 64 */
|
||||||
|
{-9, 57, 19, -3}
|
||||||
|
, /* 0.000 0.000 0.000 0.000 64 */
|
||||||
|
{-9, 57, 19, -3}
|
||||||
|
, /* -0.046 -0.204 0.328 -0.078 64 */
|
||||||
|
{-9, 56, 20, -3}
|
||||||
|
, /* -0.089 0.589 -0.343 -0.157 64 */
|
||||||
|
{-9, 56, 20, -3}
|
||||||
|
, /* -0.130 0.380 -0.014 -0.236 64 */
|
||||||
|
{-9, 56, 20, -3}
|
||||||
|
, /* -0.168 0.168 0.316 -0.316 64 */
|
||||||
|
{-9, 56, 21, -4}
|
||||||
|
, /* -0.204 -0.046 -0.354 0.604 64 */
|
||||||
|
{-9, 56, 21, -4}
|
||||||
|
, /* -0.238 -0.262 -0.023 0.523 64 */
|
||||||
|
{-9, 56, 21, -4}
|
||||||
|
, /* -0.270 -0.480 0.308 0.442 64 */
|
||||||
|
{-9, 55, 22, -4}
|
||||||
|
, /* -0.299 0.299 -0.361 0.361 64 */
|
||||||
|
{-9, 55, 22, -4}
|
||||||
|
, /* -0.326 0.076 -0.030 0.280 64 */
|
||||||
|
{-9, 55, 22, -4}
|
||||||
|
, /* -0.350 -0.150 0.302 0.198 64 */
|
||||||
|
{-9, 54, 23, -4}
|
||||||
|
, /* -0.373 0.623 -0.366 0.116 64 */
|
||||||
|
{-9, 54, 23, -4}
|
||||||
|
, /* -0.393 0.393 -0.034 0.034 64 */
|
||||||
|
{-9, 54, 23, -4}
|
||||||
|
, /* -0.411 0.161 0.299 -0.049 64 */
|
||||||
|
{-10, 54, 24, -4}
|
||||||
|
, /* 0.573 -0.073 -0.369 -0.131 64 */
|
||||||
|
{-10, 54, 24, -4}
|
||||||
|
, /* 0.559 -0.309 -0.036 -0.214 64 */
|
||||||
|
{-9, 53, 24, -4}
|
||||||
|
, /* -0.453 0.453 0.297 -0.297 64 */
|
||||||
|
{-10, 53, 25, -4}
|
||||||
|
, /* 0.537 0.213 -0.370 -0.380 64 */
|
||||||
|
{-10, 53, 25, -4}
|
||||||
|
, /* 0.530 -0.030 -0.037 -0.463 64 */
|
||||||
|
{-9, 53, 25, -5}
|
||||||
|
, /* -0.476 -0.274 0.296 0.454 64 */
|
||||||
|
{-9, 52, 26, -5}
|
||||||
|
, /* -0.480 0.480 -0.370 0.370 64 */
|
||||||
|
{-9, 52, 26, -5}
|
||||||
|
, /* -0.481 0.231 -0.037 0.287 64 */
|
||||||
|
{-9, 52, 26, -5}
|
||||||
|
, /* -0.481 -0.019 0.296 0.204 64 */
|
||||||
|
{-10, 52, 27, -5}
|
||||||
|
, /* 0.521 -0.271 -0.370 0.120 64 */
|
||||||
|
{-9, 51, 27, -5}
|
||||||
|
, /* -0.475 0.475 -0.037 0.037 64 */
|
||||||
|
{-9, 51, 27, -5}
|
||||||
|
, /* -0.469 0.219 0.296 -0.046 64 */
|
||||||
|
{-10, 51, 28, -5}
|
||||||
|
, /* 0.539 -0.039 -0.371 -0.129 64 */
|
||||||
|
{-10, 51, 28, -5}
|
||||||
|
, /* 0.549 -0.299 -0.038 -0.212 64 */
|
||||||
|
{-9, 50, 28, -5}
|
||||||
|
, /* -0.439 0.439 0.295 -0.295 64 */
|
||||||
|
{-10, 50, 29, -5}
|
||||||
|
, /* 0.574 0.176 -0.372 -0.378 64 */
|
||||||
|
{-9, 50, 29, -6}
|
||||||
|
, /* -0.411 -0.089 -0.040 0.540 64 */
|
||||||
|
{-9, 50, 29, -6}
|
||||||
|
, /* -0.394 -0.356 0.293 0.457 64 */
|
||||||
|
{-9, 49, 30, -6}
|
||||||
|
, /* -0.375 0.375 -0.375 0.375 64 */
|
||||||
|
{-9, 49, 30, -6}
|
||||||
|
, /* -0.355 0.105 -0.043 0.293 64 */
|
||||||
|
{-9, 49, 30, -6}
|
||||||
|
, /* -0.333 -0.167 0.289 0.211 64 */
|
||||||
|
{-9, 48, 31, -6}
|
||||||
|
, /* -0.309 0.559 -0.380 0.130 64 */
|
||||||
|
{-9, 48, 31, -6}
|
||||||
|
, /* -0.283 0.283 -0.049 0.049 64 */
|
||||||
|
{-9, 48, 31, -6}
|
||||||
|
, /* -0.256 0.006 0.282 -0.032 64 */
|
||||||
|
{-9, 48, 31, -6}
|
||||||
|
, /* -0.228 -0.272 0.612 -0.112 64 */
|
||||||
|
{-9, 47, 32, -6}
|
||||||
|
, /* -0.198 0.448 -0.058 -0.192 64 */
|
||||||
|
{-9, 47, 32, -6}
|
||||||
|
, /* -0.166 0.166 0.271 -0.271 64 */
|
||||||
|
{-9, 47, 32, -6}
|
||||||
|
, /* -0.133 -0.117 0.601 -0.351 64 */
|
||||||
|
{-9, 47, 33, -7}
|
||||||
|
, /* -0.098 -0.402 -0.071 0.571 64 */
|
||||||
|
{-9, 46, 33, -6}
|
||||||
|
, /* -0.062 0.312 0.257 -0.507 64 */
|
||||||
|
{-9, 46, 34, -7}
|
||||||
|
, /* -0.024 0.024 -0.415 0.415 64 */
|
||||||
|
{-9, 46, 34, -7}
|
||||||
|
, /* 0.015 -0.265 -0.088 0.338 64 */
|
||||||
|
{-9, 46, 34, -7}
|
||||||
|
, /* 0.055 -0.555 0.239 0.261 64 */
|
||||||
|
{-9, 45, 35, -7}
|
||||||
|
, /* 0.097 0.153 -0.435 0.185 64 */
|
||||||
|
{-9, 45, 35, -7}
|
||||||
|
, /* 0.141 -0.141 -0.109 0.109 64 */
|
||||||
|
{-9, 45, 35, -7}
|
||||||
|
, /* 0.185 -0.435 0.216 0.034 64 */
|
||||||
|
{-9, 44, 36, -7}
|
||||||
|
, /* 0.231 0.269 -0.460 -0.040 64 */
|
||||||
|
{-9, 44, 36, -7}
|
||||||
|
, /* 0.278 -0.028 -0.137 -0.113 64 */
|
||||||
|
{-9, 44, 36, -7}
|
||||||
|
, /* 0.327 -0.327 0.186 -0.186 64 */
|
||||||
|
{-9, 43, 37, -7}
|
||||||
|
, /* 0.377 0.373 -0.492 -0.258 64 */
|
||||||
|
{-9, 43, 37, -7}
|
||||||
|
, /* 0.428 0.072 -0.170 -0.330 64 */
|
||||||
|
{-9, 43, 37, -7}
|
||||||
|
, /* 0.480 -0.230 0.151 -0.401 64 */
|
||||||
|
{-8, 42, 37, -7}
|
||||||
|
, /* -0.467 0.467 0.471 -0.471 64 */
|
||||||
|
{-8, 42, 38, -8}
|
||||||
|
, /* -0.412 0.162 -0.210 0.460 64 */
|
||||||
|
{-8, 42, 38, -8}
|
||||||
|
, /* -0.357 -0.143 0.108 0.392 64 */
|
||||||
|
{-8, 42, 38, -8}
|
||||||
|
, /* -0.300 -0.450 0.426 0.324 64 */
|
||||||
|
{-8, 41, 39, -8}
|
||||||
|
, /* -0.242 0.242 -0.258 0.258 64 */
|
||||||
|
{-8, 41, 39, -8}
|
||||||
|
, /* -0.183 -0.067 0.058 0.192 64 */
|
||||||
|
{-8, 41, 39, -8}
|
||||||
|
, /* -0.123 -0.377 0.373 0.127 64 */
|
||||||
|
{-8, 40, 40, -8}
|
||||||
|
, /* -0.062 0.312 -0.313 0.063 64 */
|
||||||
|
{-8, 40, 40, -8}
|
||||||
|
, /* 0.000 0.000 0.000 0.000 64 */
|
||||||
|
{-8, 40, 40, -8}
|
||||||
|
, /* 0.063 -0.313 0.312 -0.062 64 */
|
||||||
|
{-8, 39, 41, -8}
|
||||||
|
, /* 0.127 0.373 -0.377 -0.123 64 */
|
||||||
|
{-8, 39, 41, -8}
|
||||||
|
, /* 0.192 0.058 -0.067 -0.183 64 */
|
||||||
|
{-8, 39, 41, -8}
|
||||||
|
, /* 0.258 -0.258 0.242 -0.242 64 */
|
||||||
|
{-8, 38, 42, -8}
|
||||||
|
, /* 0.324 0.426 -0.450 -0.300 64 */
|
||||||
|
{-8, 38, 42, -8}
|
||||||
|
, /* 0.392 0.108 -0.143 -0.357 64 */
|
||||||
|
{-8, 38, 42, -8}
|
||||||
|
, /* 0.460 -0.210 0.162 -0.412 64 */
|
||||||
|
{-7, 37, 42, -8}
|
||||||
|
, /* -0.471 0.471 0.467 -0.467 64 */
|
||||||
|
{-7, 37, 43, -9}
|
||||||
|
, /* -0.401 0.151 -0.230 0.480 64 */
|
||||||
|
{-7, 37, 43, -9}
|
||||||
|
, /* -0.330 -0.170 0.072 0.428 64 */
|
||||||
|
{-7, 37, 43, -9}
|
||||||
|
, /* -0.258 -0.492 0.373 0.377 64 */
|
||||||
|
{-7, 36, 44, -9}
|
||||||
|
, /* -0.186 0.186 -0.327 0.327 64 */
|
||||||
|
{-7, 36, 44, -9}
|
||||||
|
, /* -0.113 -0.137 -0.028 0.278 64 */
|
||||||
|
{-7, 36, 44, -9}
|
||||||
|
, /* -0.040 -0.460 0.269 0.231 64 */
|
||||||
|
{-7, 35, 45, -9}
|
||||||
|
, /* 0.034 0.216 -0.435 0.185 64 */
|
||||||
|
{-7, 35, 45, -9}
|
||||||
|
, /* 0.109 -0.109 -0.141 0.141 64 */
|
||||||
|
{-7, 35, 45, -9}
|
||||||
|
, /* 0.185 -0.435 0.153 0.097 64 */
|
||||||
|
{-7, 34, 46, -9}
|
||||||
|
, /* 0.261 0.239 -0.555 0.055 64 */
|
||||||
|
{-7, 34, 46, -9}
|
||||||
|
, /* 0.338 -0.088 -0.265 0.015 64 */
|
||||||
|
{-7, 34, 46, -9}
|
||||||
|
, /* 0.415 -0.415 0.024 -0.024 64 */
|
||||||
|
{-6, 33, 46, -9}
|
||||||
|
, /* -0.507 0.257 0.312 -0.062 64 */
|
||||||
|
{-7, 33, 47, -9}
|
||||||
|
, /* 0.571 -0.071 -0.402 -0.098 64 */
|
||||||
|
{-6, 32, 47, -9}
|
||||||
|
, /* -0.351 0.601 -0.117 -0.133 64 */
|
||||||
|
{-6, 32, 47, -9}
|
||||||
|
, /* -0.271 0.271 0.166 -0.166 64 */
|
||||||
|
{-6, 32, 47, -9}
|
||||||
|
, /* -0.192 -0.058 0.448 -0.198 64 */
|
||||||
|
{-6, 31, 48, -9}
|
||||||
|
, /* -0.112 0.612 -0.272 -0.228 64 */
|
||||||
|
{-6, 31, 48, -9}
|
||||||
|
, /* -0.032 0.282 0.006 -0.256 64 */
|
||||||
|
{-6, 31, 48, -9}
|
||||||
|
, /* 0.049 -0.049 0.283 -0.283 64 */
|
||||||
|
{-6, 31, 48, -9}
|
||||||
|
, /* 0.130 -0.380 0.559 -0.309 64 */
|
||||||
|
{-6, 30, 49, -9}
|
||||||
|
, /* 0.211 0.289 -0.167 -0.333 64 */
|
||||||
|
{-6, 30, 49, -9}
|
||||||
|
, /* 0.293 -0.043 0.105 -0.355 64 */
|
||||||
|
{-6, 30, 49, -9}
|
||||||
|
, /* 0.375 -0.375 0.375 -0.375 64 */
|
||||||
|
{-6, 29, 50, -9}
|
||||||
|
, /* 0.457 0.293 -0.356 -0.394 64 */
|
||||||
|
{-6, 29, 50, -9}
|
||||||
|
, /* 0.540 -0.040 -0.089 -0.411 64 */
|
||||||
|
{-5, 29, 50, -10}
|
||||||
|
, /* -0.378 -0.372 0.176 0.574 64 */
|
||||||
|
{-5, 28, 50, -9}
|
||||||
|
, /* -0.295 0.295 0.439 -0.439 64 */
|
||||||
|
{-5, 28, 51, -10}
|
||||||
|
, /* -0.212 -0.038 -0.299 0.549 64 */
|
||||||
|
{-5, 28, 51, -10}
|
||||||
|
, /* -0.129 -0.371 -0.039 0.539 64 */
|
||||||
|
{-5, 27, 51, -9}
|
||||||
|
, /* -0.046 0.296 0.219 -0.469 64 */
|
||||||
|
{-5, 27, 51, -9}
|
||||||
|
, /* 0.037 -0.037 0.475 -0.475 64 */
|
||||||
|
{-5, 27, 52, -10}
|
||||||
|
, /* 0.120 -0.370 -0.271 0.521 64 */
|
||||||
|
{-5, 26, 52, -9}
|
||||||
|
, /* 0.204 0.296 -0.019 -0.481 64 */
|
||||||
|
{-5, 26, 52, -9}
|
||||||
|
, /* 0.287 -0.037 0.231 -0.481 64 */
|
||||||
|
{-5, 26, 52, -9}
|
||||||
|
, /* 0.370 -0.370 0.480 -0.480 64 */
|
||||||
|
{-5, 25, 53, -9}
|
||||||
|
, /* 0.454 0.296 -0.274 -0.476 64 */
|
||||||
|
{-4, 25, 53, -10}
|
||||||
|
, /* -0.463 -0.037 -0.030 0.530 64 */
|
||||||
|
{-4, 25, 53, -10}
|
||||||
|
, /* -0.380 -0.370 0.213 0.537 64 */
|
||||||
|
{-4, 24, 53, -9}
|
||||||
|
, /* -0.297 0.297 0.453 -0.453 64 */
|
||||||
|
{-4, 24, 54, -10}
|
||||||
|
, /* -0.214 -0.036 -0.309 0.559 64 */
|
||||||
|
{-4, 24, 54, -10}
|
||||||
|
, /* -0.131 -0.369 -0.073 0.573 64 */
|
||||||
|
{-4, 23, 54, -9}
|
||||||
|
, /* -0.049 0.299 0.161 -0.411 64 */
|
||||||
|
{-4, 23, 54, -9}
|
||||||
|
, /* 0.034 -0.034 0.393 -0.393 64 */
|
||||||
|
{-4, 23, 54, -9}
|
||||||
|
, /* 0.116 -0.366 0.623 -0.373 64 */
|
||||||
|
{-4, 22, 55, -9}
|
||||||
|
, /* 0.198 0.302 -0.150 -0.350 64 */
|
||||||
|
{-4, 22, 55, -9}
|
||||||
|
, /* 0.280 -0.030 0.076 -0.326 64 */
|
||||||
|
{-4, 22, 55, -9}
|
||||||
|
, /* 0.361 -0.361 0.299 -0.299 64 */
|
||||||
|
{-4, 21, 56, -9}
|
||||||
|
, /* 0.442 0.308 -0.480 -0.270 64 */
|
||||||
|
{-4, 21, 56, -9}
|
||||||
|
, /* 0.523 -0.023 -0.262 -0.238 64 */
|
||||||
|
{-4, 21, 56, -9}
|
||||||
|
, /* 0.604 -0.354 -0.046 -0.204 64 */
|
||||||
|
{-3, 20, 56, -9}
|
||||||
|
, /* -0.316 0.316 0.168 -0.168 64 */
|
||||||
|
{-3, 20, 56, -9}
|
||||||
|
, /* -0.236 -0.014 0.380 -0.130 64 */
|
||||||
|
{-3, 20, 56, -9}
|
||||||
|
, /* -0.157 -0.343 0.589 -0.089 64 */
|
||||||
|
{-3, 19, 57, -9}
|
||||||
|
, /* -0.078 0.328 -0.204 -0.046 64 */
|
||||||
|
{-3, 19, 57, -9}
|
||||||
|
, /* 0.000 0.000 0.000 0.000 64 */
|
||||||
|
{-3, 19, 57, -9}
|
||||||
|
, /* 0.078 -0.328 0.202 0.048 64 */
|
||||||
|
{-3, 18, 58, -9}
|
||||||
|
, /* 0.155 0.345 -0.599 0.099 64 */
|
||||||
|
{-3, 18, 58, -9}
|
||||||
|
, /* 0.232 0.018 -0.402 0.152 64 */
|
||||||
|
{-3, 18, 58, -9}
|
||||||
|
, /* 0.308 -0.308 -0.207 0.207 64 */
|
||||||
|
{-2, 17, 58, -9}
|
||||||
|
, /* -0.616 0.366 -0.015 0.265 64 */
|
||||||
|
{-2, 17, 58, -9}
|
||||||
|
, /* -0.541 0.041 0.174 0.326 64 */
|
||||||
|
{-2, 17, 58, -9}
|
||||||
|
, /* -0.466 -0.284 0.361 0.389 64 */
|
||||||
|
{-2, 16, 59, -9}
|
||||||
|
, /* -0.393 0.393 -0.455 0.455 64 */
|
||||||
|
{-2, 16, 59, -9}
|
||||||
|
, /* -0.319 0.069 -0.274 0.524 64 */
|
||||||
|
{-2, 16, 59, -9}
|
||||||
|
, /* -0.247 -0.253 -0.095 0.595 64 */
|
||||||
|
{-2, 15, 59, -8}
|
||||||
|
, /* -0.175 0.425 0.082 -0.332 64 */
|
||||||
|
{-2, 15, 59, -8}
|
||||||
|
, /* -0.104 0.104 0.255 -0.255 64 */
|
||||||
|
{-2, 15, 59, -8}
|
||||||
|
, /* -0.034 -0.216 0.426 -0.176 64 */
|
||||||
|
{-2, 14, 60, -8}
|
||||||
|
, /* 0.035 0.465 -0.406 -0.094 64 */
|
||||||
|
{-2, 14, 60, -8}
|
||||||
|
, /* 0.104 0.146 -0.241 -0.009 64 */
|
||||||
|
{-2, 14, 60, -8}
|
||||||
|
, /* 0.172 -0.172 -0.078 0.078 64 */
|
||||||
|
{-2, 14, 60, -8}
|
||||||
|
, /* 0.239 -0.489 0.082 0.168 64 */
|
||||||
|
{-1, 13, 60, -8}
|
||||||
|
, /* -0.695 0.195 0.238 0.262 64 */
|
||||||
|
{-2, 13, 61, -8}
|
||||||
|
, /* 0.370 -0.120 -0.607 0.357 64 */
|
||||||
|
{-2, 13, 61, -8}
|
||||||
|
, /* 0.434 -0.434 -0.456 0.456 64 */
|
||||||
|
{-2, 12, 61, -7}
|
||||||
|
, /* 0.498 0.252 -0.308 -0.442 64 */
|
||||||
|
{-2, 12, 61, -7}
|
||||||
|
, /* 0.560 -0.060 -0.163 -0.337 64 */
|
||||||
|
{-2, 12, 61, -7}
|
||||||
|
, /* 0.621 -0.371 -0.020 -0.230 64 */
|
||||||
|
{-1, 11, 61, -7}
|
||||||
|
, /* -0.318 0.318 0.119 -0.119 64 */
|
||||||
|
{-1, 11, 61, -7}
|
||||||
|
, /* -0.259 0.009 0.256 -0.006 64 */
|
||||||
|
{-1, 11, 61, -7}
|
||||||
|
, /* -0.201 -0.299 0.389 0.111 64 */
|
||||||
|
{-1, 10, 62, -7}
|
||||||
|
, /* -0.144 0.394 -0.481 0.231 64 */
|
||||||
|
{-1, 10, 62, -7}
|
||||||
|
, /* -0.088 0.088 -0.353 0.353 64 */
|
||||||
|
{-1, 10, 62, -7}
|
||||||
|
, /* -0.033 -0.217 -0.229 0.479 64 */
|
||||||
|
{-1, 9, 62, -6}
|
||||||
|
, /* 0.021 0.479 -0.108 -0.392 64 */
|
||||||
|
{-1, 9, 62, -6}
|
||||||
|
, /* 0.074 0.176 0.010 -0.260 64 */
|
||||||
|
{-1, 9, 62, -6}
|
||||||
|
, /* 0.125 -0.125 0.125 -0.125 64 */
|
||||||
|
{-1, 9, 62, -6}
|
||||||
|
, /* 0.175 -0.425 0.237 0.013 64 */
|
||||||
|
{-1, 8, 63, -6}
|
||||||
|
, /* 0.224 0.276 -0.655 0.155 64 */
|
||||||
|
{-1, 8, 63, -6}
|
||||||
|
, /* 0.272 -0.022 -0.550 0.300 64 */
|
||||||
|
{-1, 8, 63, -6}
|
||||||
|
, /* 0.318 -0.318 -0.448 0.448 64 */
|
||||||
|
{-1, 7, 63, -5}
|
||||||
|
, /* 0.363 0.387 -0.349 -0.401 64 */
|
||||||
|
{-1, 7, 63, -5}
|
||||||
|
, /* 0.407 0.093 -0.253 -0.247 64 */
|
||||||
|
{-1, 7, 63, -5}
|
||||||
|
, /* 0.449 -0.199 -0.161 -0.089 64 */
|
||||||
|
{-1, 7, 63, -5}
|
||||||
|
, /* 0.490 -0.490 -0.072 0.072 64 */
|
||||||
|
{0, 6, 63, -5}
|
||||||
|
, /* -0.470 0.220 0.013 0.237 64 */
|
||||||
|
{0, 6, 63, -5}
|
||||||
|
, /* -0.432 -0.068 0.095 0.405 64 */
|
||||||
|
{0, 6, 63, -5}
|
||||||
|
, /* -0.395 -0.355 0.174 0.576 64 */
|
||||||
|
{0, 5, 63, -4}
|
||||||
|
, /* -0.360 0.360 0.249 -0.249 64 */
|
||||||
|
{0, 5, 63, -4}
|
||||||
|
, /* -0.326 0.076 0.321 -0.071 64 */
|
||||||
|
{0, 5, 63, -4}
|
||||||
|
, /* -0.294 -0.206 0.389 0.111 64 */
|
||||||
|
{0, 5, 63, -4}
|
||||||
|
, /* -0.263 -0.487 0.454 0.296 64 */
|
||||||
|
{0, 4, 64, -4}
|
||||||
|
, /* -0.234 0.234 -0.484 0.484 64 */
|
||||||
|
{0, 4, 63, -3}
|
||||||
|
, /* -0.207 -0.043 0.573 -0.323 64 */
|
||||||
|
{0, 4, 63, -3}
|
||||||
|
, /* -0.181 -0.319 0.628 -0.128 64 */
|
||||||
|
{0, 3, 64, -3}
|
||||||
|
, /* -0.157 0.407 -0.322 0.072 64 */
|
||||||
|
{0, 3, 64, -3}
|
||||||
|
, /* -0.134 0.134 -0.275 0.275 64 */
|
||||||
|
{0, 3, 64, -3}
|
||||||
|
, /* -0.113 -0.137 -0.231 0.481 64 */
|
||||||
|
{0, 2, 64, -2}
|
||||||
|
, /* -0.094 0.594 -0.191 -0.309 64 */
|
||||||
|
{0, 2, 64, -2}
|
||||||
|
, /* -0.076 0.326 -0.155 -0.095 64 */
|
||||||
|
{0, 2, 64, -2}
|
||||||
|
, /* -0.061 0.061 -0.123 0.123 64 */
|
||||||
|
{0, 2, 64, -2}
|
||||||
|
, /* -0.047 -0.203 -0.094 0.344 64 */
|
||||||
|
{0, 1, 64, -1}
|
||||||
|
, /* -0.034 0.534 -0.069 -0.431 64 */
|
||||||
|
{0, 1, 64, -1}
|
||||||
|
, /* -0.024 0.274 -0.048 -0.202 64 */
|
||||||
|
{0, 1, 64, -1}
|
||||||
|
, /* -0.015 0.015 -0.031 0.031 64 */
|
||||||
|
{0, 1, 64, -1}
|
||||||
|
, /* -0.009 -0.241 -0.017 0.267 64 */
|
||||||
|
{0, 0, 64, 0}
|
||||||
|
, /* -0.004 0.504 -0.008 -0.492 64 */
|
||||||
|
{0, 0, 64, 0}
|
||||||
|
, /* -0.001 0.251 -0.002 -0.248 64 */
|
||||||
|
};
|
|
@ -506,12 +506,14 @@ cog_virt_frame_render_resample_vert_1tap (CogFrame * frame, void *_dest,
|
||||||
uint8_t *dest = _dest;
|
uint8_t *dest = _dest;
|
||||||
uint8_t *src1;
|
uint8_t *src1;
|
||||||
int n_src;
|
int n_src;
|
||||||
double *scale = (double *) frame->virt_priv;
|
int scale = frame->param1;
|
||||||
double x;
|
int acc;
|
||||||
|
int x;
|
||||||
int src_i;
|
int src_i;
|
||||||
|
|
||||||
x = (*scale) * i;
|
acc = scale * i;
|
||||||
src_i = floor (x);
|
src_i = acc >> 8;
|
||||||
|
x = acc & 0xff;
|
||||||
|
|
||||||
n_src = frame->virt_frame1->components[component].height;
|
n_src = frame->virt_frame1->components[component].height;
|
||||||
src1 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
src1 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
||||||
|
@ -528,13 +530,14 @@ cog_virt_frame_render_resample_vert_2tap (CogFrame * frame, void *_dest,
|
||||||
uint8_t *src1;
|
uint8_t *src1;
|
||||||
uint8_t *src2;
|
uint8_t *src2;
|
||||||
int n_src;
|
int n_src;
|
||||||
double *scale = (double *) frame->virt_priv;
|
int scale = frame->param1;
|
||||||
double x;
|
int acc;
|
||||||
|
int x;
|
||||||
int src_i;
|
int src_i;
|
||||||
|
|
||||||
x = (*scale) * i;
|
acc = scale * i;
|
||||||
src_i = floor (x);
|
src_i = acc >> 8;
|
||||||
x -= floor (x);
|
x = acc & 0xff;
|
||||||
|
|
||||||
n_src = frame->virt_frame1->components[component].height;
|
n_src = frame->virt_frame1->components[component].height;
|
||||||
src1 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
src1 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
||||||
|
@ -542,8 +545,12 @@ cog_virt_frame_render_resample_vert_2tap (CogFrame * frame, void *_dest,
|
||||||
src2 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
src2 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
||||||
CLAMP (src_i + 1, 0, n_src - 1));
|
CLAMP (src_i + 1, 0, n_src - 1));
|
||||||
|
|
||||||
cogorc_combine2_u8 (dest, src1, src2,
|
if (x == 0) {
|
||||||
rint (256 * (1 - x)), rint (256 * x), frame->components[component].width);
|
memcpy (dest, src1, frame->components[component].width);
|
||||||
|
} else {
|
||||||
|
cogorc_combine2_u8 (dest, src1, src2,
|
||||||
|
256 - x, x, frame->components[component].width);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -556,53 +563,55 @@ cog_virt_frame_render_resample_vert_4tap (CogFrame * frame, void *_dest,
|
||||||
uint8_t *src3;
|
uint8_t *src3;
|
||||||
uint8_t *src4;
|
uint8_t *src4;
|
||||||
int n_src;
|
int n_src;
|
||||||
double *scale = (double *) frame->virt_priv;
|
int scale = frame->param1;
|
||||||
double x;
|
int acc;
|
||||||
|
int x;
|
||||||
int src_i;
|
int src_i;
|
||||||
int y;
|
|
||||||
|
|
||||||
x = (*scale) * i;
|
acc = scale * i;
|
||||||
src_i = floor (x);
|
src_i = acc >> 8;
|
||||||
y = 256 * (x - floor (x));
|
x = acc & 0xff;
|
||||||
|
|
||||||
n_src = frame->virt_frame1->components[component].height;
|
n_src = frame->virt_frame1->components[component].height;
|
||||||
src1 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
if (src_i < 1 || src_i >= n_src - 3) {
|
||||||
CLAMP (src_i - 1, 0, n_src - 1));
|
src1 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
||||||
src2 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
CLAMP (src_i - 1, 0, n_src - 1));
|
||||||
CLAMP (src_i + 0, 0, n_src - 1));
|
src2 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
||||||
src3 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
CLAMP (src_i + 0, 0, n_src - 1));
|
||||||
CLAMP (src_i + 1, 0, n_src - 1));
|
src3 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
||||||
src4 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
CLAMP (src_i + 1, 0, n_src - 1));
|
||||||
CLAMP (src_i + 2, 0, n_src - 1));
|
src4 = cog_virt_frame_get_line (frame->virt_frame1, component,
|
||||||
|
CLAMP (src_i + 2, 0, n_src - 1));
|
||||||
|
} else {
|
||||||
|
src1 = cog_virt_frame_get_line (frame->virt_frame1, component, src_i - 1);
|
||||||
|
src2 = cog_virt_frame_get_line (frame->virt_frame1, component, src_i + 0);
|
||||||
|
src3 = cog_virt_frame_get_line (frame->virt_frame1, component, src_i + 1);
|
||||||
|
src4 = cog_virt_frame_get_line (frame->virt_frame1, component, src_i + 2);
|
||||||
|
}
|
||||||
|
|
||||||
cogorc_combine4_u8 (dest, src1, src2, src3, src4,
|
cogorc_combine4_u8 (dest, src1, src2, src3, src4,
|
||||||
cog_resample_table_4tap[y][0],
|
cog_resample_table_4tap[x][0],
|
||||||
cog_resample_table_4tap[y][1],
|
cog_resample_table_4tap[x][1],
|
||||||
cog_resample_table_4tap[y][2],
|
cog_resample_table_4tap[x][2],
|
||||||
cog_resample_table_4tap[y][3], frame->components[component].width);
|
cog_resample_table_4tap[x][3], frame->components[component].width);
|
||||||
}
|
}
|
||||||
|
|
||||||
CogFrame *
|
CogFrame *
|
||||||
cog_virt_frame_new_vert_resample (CogFrame * vf, int height)
|
cog_virt_frame_new_vert_resample (CogFrame * vf, int height, int n_taps)
|
||||||
{
|
{
|
||||||
CogFrame *virt_frame;
|
CogFrame *virt_frame;
|
||||||
double *scale;
|
|
||||||
int taps = 4;
|
|
||||||
|
|
||||||
virt_frame = cog_frame_new_virtual (NULL, vf->format, vf->width, height);
|
virt_frame = cog_frame_new_virtual (NULL, vf->format, vf->width, height);
|
||||||
virt_frame->virt_frame1 = vf;
|
virt_frame->virt_frame1 = vf;
|
||||||
if (taps == 1) {
|
if (n_taps == 1) {
|
||||||
virt_frame->render_line = cog_virt_frame_render_resample_vert_1tap;
|
virt_frame->render_line = cog_virt_frame_render_resample_vert_1tap;
|
||||||
} else if (taps == 2) {
|
} else if (n_taps == 2) {
|
||||||
virt_frame->render_line = cog_virt_frame_render_resample_vert_2tap;
|
virt_frame->render_line = cog_virt_frame_render_resample_vert_2tap;
|
||||||
} else {
|
} else {
|
||||||
virt_frame->render_line = cog_virt_frame_render_resample_vert_4tap;
|
virt_frame->render_line = cog_virt_frame_render_resample_vert_4tap;
|
||||||
}
|
}
|
||||||
|
|
||||||
scale = malloc (sizeof (double));
|
virt_frame->param1 = 256 * vf->height / height;
|
||||||
virt_frame->virt_priv = scale;
|
|
||||||
|
|
||||||
*scale = (double) vf->height / height;
|
|
||||||
|
|
||||||
return virt_frame;
|
return virt_frame;
|
||||||
}
|
}
|
||||||
|
@ -628,6 +637,53 @@ cog_virt_frame_render_resample_horiz_1tap (CogFrame * frame, void *_dest,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cog_virt_frame_render_resample_horiz_2tap (CogFrame * frame, void *_dest,
|
||||||
|
int component, int i)
|
||||||
|
{
|
||||||
|
uint8_t *dest = _dest;
|
||||||
|
uint8_t *src;
|
||||||
|
int j;
|
||||||
|
int n_src;
|
||||||
|
int scale = frame->param1;
|
||||||
|
int acc;
|
||||||
|
|
||||||
|
n_src = frame->virt_frame1->components[component].width;
|
||||||
|
src = cog_virt_frame_get_line (frame->virt_frame1, component, i);
|
||||||
|
|
||||||
|
acc = 0;
|
||||||
|
for (j = 0; j < frame->components[component].width - 2; j++) {
|
||||||
|
int src_i;
|
||||||
|
int y;
|
||||||
|
int z;
|
||||||
|
|
||||||
|
src_i = acc >> 8;
|
||||||
|
y = acc & 255;
|
||||||
|
|
||||||
|
z = 128;
|
||||||
|
z += (256 - y) * src[src_i + 0];
|
||||||
|
z += y * src[src_i + 1];
|
||||||
|
z >>= 8;
|
||||||
|
dest[j] = CLAMP (z, 0, 255);
|
||||||
|
acc += scale;
|
||||||
|
}
|
||||||
|
for (; j < frame->components[component].width; j++) {
|
||||||
|
int src_i;
|
||||||
|
int y;
|
||||||
|
int z;
|
||||||
|
|
||||||
|
src_i = acc >> 8;
|
||||||
|
y = acc & 255;
|
||||||
|
|
||||||
|
z = 128;
|
||||||
|
z += (256 - y) * src[CLAMP (src_i + 0, 0, n_src - 1)];
|
||||||
|
z += y * src[CLAMP (src_i + 1, 0, n_src - 1)];
|
||||||
|
z >>= 8;
|
||||||
|
dest[j] = CLAMP (z, 0, 255);
|
||||||
|
acc += scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cog_virt_frame_render_resample_horiz_4tap (CogFrame * frame, void *_dest,
|
cog_virt_frame_render_resample_horiz_4tap (CogFrame * frame, void *_dest,
|
||||||
int component, int i)
|
int component, int i)
|
||||||
|
@ -697,25 +753,21 @@ cog_virt_frame_render_resample_horiz_4tap (CogFrame * frame, void *_dest,
|
||||||
}
|
}
|
||||||
|
|
||||||
CogFrame *
|
CogFrame *
|
||||||
cog_virt_frame_new_horiz_resample (CogFrame * vf, int width)
|
cog_virt_frame_new_horiz_resample (CogFrame * vf, int width, int n_taps)
|
||||||
{
|
{
|
||||||
CogFrame *virt_frame;
|
CogFrame *virt_frame;
|
||||||
double *scale;
|
|
||||||
int taps = 4;
|
|
||||||
|
|
||||||
virt_frame = cog_frame_new_virtual (NULL, vf->format, width, vf->height);
|
virt_frame = cog_frame_new_virtual (NULL, vf->format, width, vf->height);
|
||||||
virt_frame->virt_frame1 = vf;
|
virt_frame->virt_frame1 = vf;
|
||||||
if (taps == 1) {
|
if (n_taps == 1) {
|
||||||
virt_frame->render_line = cog_virt_frame_render_resample_horiz_1tap;
|
virt_frame->render_line = cog_virt_frame_render_resample_horiz_1tap;
|
||||||
|
} else if (n_taps == 2) {
|
||||||
|
virt_frame->render_line = cog_virt_frame_render_resample_horiz_2tap;
|
||||||
} else {
|
} else {
|
||||||
virt_frame->render_line = cog_virt_frame_render_resample_horiz_4tap;
|
virt_frame->render_line = cog_virt_frame_render_resample_horiz_4tap;
|
||||||
}
|
}
|
||||||
|
|
||||||
scale = malloc (sizeof (double));
|
virt_frame->param1 = 256 * vf->width / width;
|
||||||
virt_frame->virt_priv = scale;
|
|
||||||
|
|
||||||
*scale = (double) vf->width / width;
|
|
||||||
virt_frame->param1 = 256.0 * (*scale);
|
|
||||||
|
|
||||||
return virt_frame;
|
return virt_frame;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ void cog_virt_frame_render (CogFrame *frame, CogFrame *dest);
|
||||||
|
|
||||||
CogFrame *cog_virt_frame_new_horiz_downsample (CogFrame *vf, int n_taps);
|
CogFrame *cog_virt_frame_new_horiz_downsample (CogFrame *vf, int n_taps);
|
||||||
CogFrame *cog_virt_frame_new_vert_downsample (CogFrame *vf, int n_taps);
|
CogFrame *cog_virt_frame_new_vert_downsample (CogFrame *vf, int n_taps);
|
||||||
CogFrame *cog_virt_frame_new_vert_resample (CogFrame *vf, int height);
|
CogFrame *cog_virt_frame_new_vert_resample (CogFrame *vf, int height, int n_taps);
|
||||||
CogFrame *cog_virt_frame_new_horiz_resample (CogFrame *vf, int width);
|
CogFrame *cog_virt_frame_new_horiz_resample (CogFrame *vf, int width, int n_taps);
|
||||||
CogFrame *cog_virt_frame_new_unpack (CogFrame *vf);
|
CogFrame *cog_virt_frame_new_unpack (CogFrame *vf);
|
||||||
CogFrame *cog_virt_frame_new_pack_YUY2 (CogFrame *vf);
|
CogFrame *cog_virt_frame_new_pack_YUY2 (CogFrame *vf);
|
||||||
CogFrame *cog_virt_frame_new_pack_UYVY (CogFrame *vf);
|
CogFrame *cog_virt_frame_new_pack_UYVY (CogFrame *vf);
|
||||||
|
|
70
ext/cog/generate_tables.c
Normal file
70
ext/cog/generate_tables.c
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#define SCALE 256
|
||||||
|
|
||||||
|
void
|
||||||
|
get_taps (double *taps, double x)
|
||||||
|
{
|
||||||
|
taps[3] = x * x * (x - 1);
|
||||||
|
taps[2] = x * (-x * x + x + 1);
|
||||||
|
x = 1 - x;
|
||||||
|
taps[1] = x * (-x * x + x + 1);
|
||||||
|
taps[0] = x * x * (x - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
g_print ("/* This file is autogenerated. Do not edit.*/\n");
|
||||||
|
g_print ("#include <glib.h>\n");
|
||||||
|
g_print ("gint8 cog_resample_table_4tap[256][4] = {\n");
|
||||||
|
for (i = 0; i < 256; i++) {
|
||||||
|
double x = i / 256.0;
|
||||||
|
double taps[4];
|
||||||
|
int t[4];
|
||||||
|
int sum;
|
||||||
|
|
||||||
|
get_taps (taps, x);
|
||||||
|
taps[0] *= SCALE;
|
||||||
|
taps[1] *= SCALE;
|
||||||
|
taps[2] *= SCALE;
|
||||||
|
taps[3] *= SCALE;
|
||||||
|
|
||||||
|
t[0] = floor (taps[0]);
|
||||||
|
t[1] = floor (taps[1]);
|
||||||
|
t[2] = floor (taps[2]);
|
||||||
|
t[3] = floor (taps[3]);
|
||||||
|
sum = t[0] + t[1] + t[2] + t[3];
|
||||||
|
|
||||||
|
for (; sum < SCALE; sum++) {
|
||||||
|
int i;
|
||||||
|
double max = 0;
|
||||||
|
int max_i = -1;
|
||||||
|
for (i = 0; i < 4; i++) {
|
||||||
|
if (max_i == -1 || (t[i] < taps[i] && (taps[i] - t[i]) > max)) {
|
||||||
|
max_i = i;
|
||||||
|
max = taps[i] - t[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t[max_i]++;
|
||||||
|
}
|
||||||
|
sum = t[0] + t[1] + t[2] + t[3];
|
||||||
|
|
||||||
|
g_print (" { %d, %d, %d, %d }, /* %d %d */\n",
|
||||||
|
t[0], t[1], t[2], t[3], t[2] + t[0], t[1] + t[3]);
|
||||||
|
#if 0
|
||||||
|
g_print ("/* %.3f %.3f %.3f %.3f %d */\n",
|
||||||
|
taps[0] - t[0], taps[1] - t[1], taps[2] - t[2], taps[3] - t[3], sum);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
g_print ("};\n");
|
||||||
|
g_print ("\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -83,21 +83,6 @@ GST_DEBUG_CATEGORY_STATIC (cog_scale_debug);
|
||||||
#define GST_IS_COG_SCALE_CLASS(klass) \
|
#define GST_IS_COG_SCALE_CLASS(klass) \
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_COG_SCALE))
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_COG_SCALE))
|
||||||
|
|
||||||
/**
|
|
||||||
* GstCogScaleMethod:
|
|
||||||
* @GST_COG_SCALE_NEAREST: use nearest neighbour scaling (fast and ugly)
|
|
||||||
* @GST_COG_SCALE_BILINEAR: use bilinear scaling (slower but prettier).
|
|
||||||
* @GST_COG_SCALE_4TAP: use a 4-tap filter for scaling (slow).
|
|
||||||
*
|
|
||||||
* The videoscale method to use.
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
GST_COG_SCALE_NEAREST,
|
|
||||||
GST_COG_SCALE_BILINEAR,
|
|
||||||
GST_COG_SCALE_4TAP
|
|
||||||
} GstCogScaleMethod;
|
|
||||||
|
|
||||||
typedef struct _GstCogScale GstCogScale;
|
typedef struct _GstCogScale GstCogScale;
|
||||||
typedef struct _GstCogScaleClass GstCogScaleClass;
|
typedef struct _GstCogScaleClass GstCogScaleClass;
|
||||||
|
|
||||||
|
@ -110,7 +95,7 @@ struct _GstCogScale
|
||||||
{
|
{
|
||||||
GstBaseTransform element;
|
GstBaseTransform element;
|
||||||
|
|
||||||
GstCogScaleMethod method;
|
int quality;
|
||||||
|
|
||||||
/* negotiated stuff */
|
/* negotiated stuff */
|
||||||
GstVideoFormat format;
|
GstVideoFormat format;
|
||||||
|
@ -139,13 +124,12 @@ GST_ELEMENT_DETAILS ("Video scaler",
|
||||||
"Resizes video",
|
"Resizes video",
|
||||||
"Wim Taymans <wim.taymans@chello.be>");
|
"Wim Taymans <wim.taymans@chello.be>");
|
||||||
|
|
||||||
#define DEFAULT_PROP_METHOD GST_COG_SCALE_NEAREST
|
#define DEFAULT_QUALITY 5
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_METHOD
|
PROP_QUALITY
|
||||||
/* FILL ME */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* can't handle width/height of 1 yet, since we divide a lot by (n-1) */
|
/* can't handle width/height of 1 yet, since we divide a lot by (n-1) */
|
||||||
|
@ -167,61 +151,43 @@ GST_VIDEO_CAPS_RGBx
|
||||||
GST_VIDEO_CAPS_ABGR GST_VIDEO_CAPS_RGB GST_VIDEO_CAPS_BGR
|
GST_VIDEO_CAPS_ABGR GST_VIDEO_CAPS_RGB GST_VIDEO_CAPS_BGR
|
||||||
GST_VIDEO_CAPS_YUV ("{ Y41B, YVYU }")
|
GST_VIDEO_CAPS_YUV ("{ Y41B, YVYU }")
|
||||||
#endif
|
#endif
|
||||||
#define GST_TYPE_COG_SCALE_METHOD (gst_cog_scale_method_get_type())
|
static GstStaticPadTemplate gst_cog_scale_src_template =
|
||||||
static GType gst_cog_scale_method_get_type (void)
|
GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
{
|
|
||||||
static GType cog_scale_method_type = 0;
|
|
||||||
static const GEnumValue cog_scale_methods[] = {
|
|
||||||
{GST_COG_SCALE_NEAREST, "Nearest Neighbour", "nearest-neighbour"},
|
|
||||||
{GST_COG_SCALE_BILINEAR, "Bilinear", "bilinear"},
|
|
||||||
{GST_COG_SCALE_4TAP, "4-tap", "4-tap"},
|
|
||||||
{0, NULL, NULL},
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!cog_scale_method_type) {
|
|
||||||
cog_scale_method_type =
|
|
||||||
g_enum_register_static ("GstCogScaleMethod", cog_scale_methods);
|
|
||||||
}
|
|
||||||
return cog_scale_method_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_cog_scale_src_template =
|
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
TEMPLATE_CAPS);
|
TEMPLATE_CAPS);
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_cog_scale_sink_template =
|
static GstStaticPadTemplate gst_cog_scale_sink_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
TEMPLATE_CAPS);
|
TEMPLATE_CAPS);
|
||||||
|
|
||||||
static void gst_cog_scale_base_init (gpointer g_class);
|
static void gst_cog_scale_base_init (gpointer g_class);
|
||||||
static void gst_cog_scale_class_init (GstCogScaleClass * klass);
|
static void gst_cog_scale_class_init (GstCogScaleClass * klass);
|
||||||
static void gst_cog_scale_init (GstCogScale * videoscale);
|
static void gst_cog_scale_init (GstCogScale * videoscale);
|
||||||
static void gst_cog_scale_finalize (GstCogScale * videoscale);
|
static void gst_cog_scale_finalize (GstCogScale * videoscale);
|
||||||
static gboolean gst_cog_scale_src_event (GstBaseTransform * trans,
|
static gboolean gst_cog_scale_src_event (GstBaseTransform * trans,
|
||||||
GstEvent * event);
|
GstEvent * event);
|
||||||
|
|
||||||
/* base transform vmethods */
|
/* base transform vmethods */
|
||||||
static GstCaps *gst_cog_scale_transform_caps (GstBaseTransform * trans,
|
static GstCaps *gst_cog_scale_transform_caps (GstBaseTransform * trans,
|
||||||
GstPadDirection direction, GstCaps * caps);
|
GstPadDirection direction, GstCaps * caps);
|
||||||
static gboolean gst_cog_scale_set_caps (GstBaseTransform * trans,
|
static gboolean gst_cog_scale_set_caps (GstBaseTransform * trans,
|
||||||
GstCaps * in, GstCaps * out);
|
GstCaps * in, GstCaps * out);
|
||||||
static gboolean gst_cog_scale_get_unit_size (GstBaseTransform * trans,
|
static gboolean gst_cog_scale_get_unit_size (GstBaseTransform * trans,
|
||||||
GstCaps * caps, guint * size);
|
GstCaps * caps, guint * size);
|
||||||
static GstFlowReturn gst_cog_scale_transform (GstBaseTransform * trans,
|
static GstFlowReturn gst_cog_scale_transform (GstBaseTransform * trans,
|
||||||
GstBuffer * in, GstBuffer * out);
|
GstBuffer * in, GstBuffer * out);
|
||||||
static void gst_cog_scale_fixate_caps (GstBaseTransform * base,
|
static void gst_cog_scale_fixate_caps (GstBaseTransform * base,
|
||||||
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
|
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
|
||||||
|
|
||||||
static void gst_cog_scale_set_property (GObject * object, guint prop_id,
|
static void gst_cog_scale_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_cog_scale_get_property (GObject * object, guint prop_id,
|
static void gst_cog_scale_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
GType
|
GType
|
||||||
|
@ -277,10 +243,9 @@ gst_cog_scale_class_init (GstCogScaleClass * klass)
|
||||||
gobject_class->set_property = gst_cog_scale_set_property;
|
gobject_class->set_property = gst_cog_scale_set_property;
|
||||||
gobject_class->get_property = gst_cog_scale_get_property;
|
gobject_class->get_property = gst_cog_scale_get_property;
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_METHOD,
|
g_object_class_install_property (gobject_class, PROP_QUALITY,
|
||||||
g_param_spec_enum ("method", "method", "method",
|
g_param_spec_int ("quality", "quality", "Scaling Quality",
|
||||||
GST_TYPE_COG_SCALE_METHOD, DEFAULT_PROP_METHOD,
|
0, 10, DEFAULT_QUALITY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
trans_class->transform_caps =
|
trans_class->transform_caps =
|
||||||
GST_DEBUG_FUNCPTR (gst_cog_scale_transform_caps);
|
GST_DEBUG_FUNCPTR (gst_cog_scale_transform_caps);
|
||||||
|
@ -299,7 +264,7 @@ static void
|
||||||
gst_cog_scale_init (GstCogScale * videoscale)
|
gst_cog_scale_init (GstCogScale * videoscale)
|
||||||
{
|
{
|
||||||
gst_base_transform_set_qos_enabled (GST_BASE_TRANSFORM (videoscale), TRUE);
|
gst_base_transform_set_qos_enabled (GST_BASE_TRANSFORM (videoscale), TRUE);
|
||||||
videoscale->method = DEFAULT_PROP_METHOD;
|
videoscale->quality = DEFAULT_QUALITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -315,9 +280,9 @@ gst_cog_scale_set_property (GObject * object, guint prop_id,
|
||||||
GstCogScale *vscale = GST_COG_SCALE (object);
|
GstCogScale *vscale = GST_COG_SCALE (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_METHOD:
|
case PROP_QUALITY:
|
||||||
GST_OBJECT_LOCK (vscale);
|
GST_OBJECT_LOCK (vscale);
|
||||||
vscale->method = g_value_get_enum (value);
|
vscale->quality = g_value_get_int (value);
|
||||||
GST_OBJECT_UNLOCK (vscale);
|
GST_OBJECT_UNLOCK (vscale);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -333,9 +298,9 @@ gst_cog_scale_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
GstCogScale *vscale = GST_COG_SCALE (object);
|
GstCogScale *vscale = GST_COG_SCALE (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_METHOD:
|
case PROP_QUALITY:
|
||||||
GST_OBJECT_LOCK (vscale);
|
GST_OBJECT_LOCK (vscale);
|
||||||
g_value_set_enum (value, vscale->method);
|
g_value_set_int (value, vscale->quality);
|
||||||
GST_OBJECT_UNLOCK (vscale);
|
GST_OBJECT_UNLOCK (vscale);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -352,32 +317,14 @@ gst_cog_scale_transform_caps (GstBaseTransform * trans,
|
||||||
GstCaps *ret;
|
GstCaps *ret;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
const GValue *par;
|
const GValue *par;
|
||||||
gint method;
|
|
||||||
|
|
||||||
/* this function is always called with a simple caps */
|
/* this function is always called with a simple caps */
|
||||||
g_return_val_if_fail (GST_CAPS_IS_SIMPLE (caps), NULL);
|
g_return_val_if_fail (GST_CAPS_IS_SIMPLE (caps), NULL);
|
||||||
|
|
||||||
videoscale = GST_COG_SCALE (trans);
|
videoscale = GST_COG_SCALE (trans);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (videoscale);
|
|
||||||
method = videoscale->method;
|
|
||||||
GST_OBJECT_UNLOCK (videoscale);
|
|
||||||
|
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
structure = gst_caps_get_structure (caps, 0);
|
||||||
|
|
||||||
/* check compatibility of format and method before we copy the input caps */
|
|
||||||
if (method == GST_COG_SCALE_4TAP) {
|
|
||||||
guint32 fourcc;
|
|
||||||
|
|
||||||
if (!gst_structure_has_name (structure, "video/x-raw-yuv"))
|
|
||||||
goto method_not_implemented_for_format;
|
|
||||||
if (!gst_structure_get_fourcc (structure, "format", &fourcc))
|
|
||||||
goto method_not_implemented_for_format;
|
|
||||||
if (fourcc != GST_MAKE_FOURCC ('I', '4', '2', '0') &&
|
|
||||||
fourcc != GST_MAKE_FOURCC ('Y', 'V', '1', '2'))
|
|
||||||
goto method_not_implemented_for_format;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gst_caps_copy (caps);
|
ret = gst_caps_copy (caps);
|
||||||
structure = gst_caps_get_structure (ret, 0);
|
structure = gst_caps_get_structure (ret, 0);
|
||||||
|
|
||||||
|
@ -406,13 +353,6 @@ gst_cog_scale_transform_caps (GstBaseTransform * trans,
|
||||||
GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret);
|
GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
method_not_implemented_for_format:
|
|
||||||
{
|
|
||||||
GST_DEBUG_OBJECT (trans, "method %d not implemented for format %"
|
|
||||||
GST_PTR_FORMAT ", returning empty caps", method, caps);
|
|
||||||
return gst_caps_new_empty ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -619,13 +559,15 @@ gst_cog_scale_transform (GstBaseTransform * trans, GstBuffer * in,
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
CogFrame *outframe;
|
CogFrame *outframe;
|
||||||
CogFrame *frame;
|
CogFrame *frame;
|
||||||
gint method;
|
|
||||||
int w, h;
|
int w, h;
|
||||||
|
int quality;
|
||||||
|
static const int n_vert_taps[11] = { 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4 };
|
||||||
|
static const int n_horiz_taps[11] = { 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4 };
|
||||||
|
|
||||||
videoscale = GST_COG_SCALE (trans);
|
videoscale = GST_COG_SCALE (trans);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (videoscale);
|
GST_OBJECT_LOCK (videoscale);
|
||||||
method = videoscale->method;
|
quality = videoscale->quality;
|
||||||
GST_OBJECT_UNLOCK (videoscale);
|
GST_OBJECT_UNLOCK (videoscale);
|
||||||
|
|
||||||
frame = gst_cog_buffer_wrap (gst_buffer_ref (in), videoscale->format,
|
frame = gst_cog_buffer_wrap (gst_buffer_ref (in), videoscale->format,
|
||||||
|
@ -648,10 +590,12 @@ gst_cog_scale_transform (GstBaseTransform * trans, GstBuffer * in,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (w != videoscale->to_width) {
|
if (w != videoscale->to_width) {
|
||||||
frame = cog_virt_frame_new_horiz_resample (frame, videoscale->to_width);
|
frame = cog_virt_frame_new_horiz_resample (frame, videoscale->to_width,
|
||||||
|
n_horiz_taps[quality]);
|
||||||
}
|
}
|
||||||
if (h != videoscale->to_height) {
|
if (h != videoscale->to_height) {
|
||||||
frame = cog_virt_frame_new_vert_resample (frame, videoscale->to_height);
|
frame = cog_virt_frame_new_vert_resample (frame, videoscale->to_height,
|
||||||
|
n_vert_taps[quality]);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (videoscale->format) {
|
switch (videoscale->format) {
|
||||||
|
|
Loading…
Reference in a new issue