This has the downside of requiring these tables to be recomputed on every init, but saves ~270 kB of static data.
Unified · Split
| @@ -951,29 +951,42 @@ static int fill_xyztables(SwsInternal *c) · 950 unmodified lines | |||
| 951 | {1689, 1464, 739}, | 951 | {1689, 1464, 739}, |
| 952 | { 871, 2929, 296}, | 952 | { 871, 2929, 296}, |
| 953 | { 79, 488, 3891} }; | 953 | { 79, 488, 3891} }; |
| 954 | #if !CONFIG_SMALL | ||
| 954 | static uint16_t xyzgamma_tab[4096], rgbgammainv_tab[4096]; | 955 | static uint16_t xyzgamma_tab[4096], rgbgammainv_tab[4096]; |
| 955 | static uint16_t rgbgamma_tab[65536], xyzgammainv_tab[65536]; | 956 | static uint16_t rgbgamma_tab[65536], xyzgammainv_tab[65536]; |
| 957 | #endif | ||
| 958 | if (c->xyzgamma) | ||
| 959 | return 0; | ||
| 956 | 960 | ||
| 957 | memcpy(c->xyz2rgb_matrix, xyz2rgb_matrix, sizeof(c->xyz2rgb_matrix)); | 961 | memcpy(c->xyz2rgb_matrix, xyz2rgb_matrix, sizeof(c->xyz2rgb_matrix)); |
| 958 | memcpy(c->rgb2xyz_matrix, rgb2xyz_matrix, sizeof(c->rgb2xyz_matrix)); | 962 | memcpy(c->rgb2xyz_matrix, rgb2xyz_matrix, sizeof(c->rgb2xyz_matrix)); |
| 963 | |||
| 964 | #if CONFIG_SMALL | ||
| 965 | c->xyzgamma = av_malloc(sizeof(uint16_t) * 2 * (4096 + 65536)); | ||
| 966 | if (!c->xyzgamma) | ||
| 967 | return AVERROR(ENOMEM); | ||
| 968 | c->rgbgammainv = c->xyzgamma + 4096; | ||
| 969 | c->rgbgamma = c->rgbgammainv + 4096; | ||
| 970 | c->xyzgammainv = c->rgbgamma + 65536; | ||
| 971 | #else | ||
| 959 | c->xyzgamma = xyzgamma_tab; | 972 | c->xyzgamma = xyzgamma_tab; |
| 960 | c->rgbgamma = rgbgamma_tab; | 973 | c->rgbgamma = rgbgamma_tab; |
| 961 | c->xyzgammainv = xyzgammainv_tab; | 974 | c->xyzgammainv = xyzgammainv_tab; |
| 962 | c->rgbgammainv = rgbgammainv_tab; | 975 | c->rgbgammainv = rgbgammainv_tab; |
| 963 | |||
| 964 | if (xyzgamma_tab[4095]) | 976 | if (xyzgamma_tab[4095]) |
| 965 | return 0; | 977 | return 0; |
| 978 | #endif | ||
| 966 | 979 | ||
| 967 | /* set input gamma vectors */ | 980 | /* set input gamma vectors */ |
| 968 | for (i = 0; i < 4096; i++) { | 981 | for (i = 0; i < 4096; i++) { |
| 969 | xyzgamma_tab[i] = lrint(pow(i / 4095.0, xyzgamma) * 65535.0); | 982 | c->xyzgamma[i] = lrint(pow(i / 4095.0, xyzgamma) * 65535.0); |
| 970 | rgbgammainv_tab[i] = lrint(pow(i / 4095.0, rgbgammainv) * 65535.0); | 983 | c->rgbgammainv[i] = lrint(pow(i / 4095.0, rgbgammainv) * 65535.0); |
| 971 | } | 984 | } |
| 972 | 985 | ||
| 973 | /* set output gamma vectors */ | 986 | /* set output gamma vectors */ |
| 974 | for (i = 0; i < 65536; i++) { | 987 | for (i = 0; i < 65536; i++) { |
| 975 | rgbgamma_tab[i] = lrint(pow(i / 65535.0, rgbgamma) * 4095.0); | 988 | c->rgbgamma[i] = lrint(pow(i / 65535.0, rgbgamma) * 4095.0); |
| 976 | xyzgammainv_tab[i] = lrint(pow(i / 65535.0, xyzgammainv) * 4095.0); | 989 | c->xyzgammainv[i] = lrint(pow(i / 65535.0, xyzgammainv) * 4095.0); |
| 977 | } | 990 | } |
| 978 | return 0; | 991 | return 0; |
| 979 | } | 992 | } |
| @@ -2529,6 +2542,9 @@ void sws_freeContext(SwsContext *sws) · 1549 unmodified lines | |||
| 2529 | 2542 | ||
| 2530 | av_freep(&c->gamma); | 2543 | av_freep(&c->gamma); |
| 2531 | av_freep(&c->inv_gamma); | 2544 | av_freep(&c->inv_gamma); |
| 2545 | #if CONFIG_SMALL | ||
| 2546 | av_freep(&c->xyzgamma); | ||
| 2547 | #endif | ||
| 2532 | 2548 | ||
| 2533 | av_freep(&c->rgb0_scratch); | 2549 | av_freep(&c->rgb0_scratch); |
| 2534 | av_freep(&c->xyz_scratch); | 2550 | av_freep(&c->xyz_scratch); |