4 * Maybe opts, adds comma on the left side
6 {% macro maybe_opts_l(opts) %}{% if opts %}, {{ opts }}{% endif %}{% endmacro %}
9 * Maybe opts, adds comma on the right side.
11 {% macro maybe_opts_r(opts) %}{% if opts %}{{ opts }}, {% endif %}{% endmacro %}
14 * Converts channels to params
16 {% macro expand_chanslist(pt, pref="", suff="") %}{{ pref+pt.chanslist[0][0]+suff }}{% for c in pt.chanslist[1:] %}, {{ pref+c[0]+suff }}{% endfor %}{% endmacro %}
20 %%macro clamp_val(val, bits)
21 if ({{ val }} > {{ 2 ** bits - 1 }}) {{ val }} = {{ 2 ** bits - 1}};
24 {% macro gamma_in_bits(size) %}{% if size + 2 > 8 %}16{% else %}8{% endif %}{% endmacro %}
25 {% macro gamma_out_bits(size) %}{% if size > 8 %}16{% else %}8{% endif %}{% endmacro %}
28 * Prepares pointers to Gamma tables.
30 %% macro fetch_gamma_tables(pt, ctx, pref="", suff="")
31 /* prepare Gamma tables */
32 %% for c in pt.chanslist
33 uint{{ gamma_in_bits(c[2]) }}_t *{{ pref+c[0] }}_2_LIN{{ suff }} = NULL;
36 %% for c in pt.chanslist
37 uint{{ gamma_out_bits(c[2]) }}_t *{{ pref+c[0] }}_2_GAMMA{{ suff }} = NULL;
41 if ({{ ctx }}->gamma) {
42 %% for c in pt.chanslist
43 {{ pref+c[0] }}_2_LIN{{ suff }} = {{ ctx }}->gamma->tables[{{ i }}]->u{{ gamma_in_bits(c[2]) }};
47 %% set i = len(pt.chanslist)
48 %% for c in pt.chanslist
49 {{ pref+c[0] }}_2_GAMMA{{ suff }} = {{ ctx }}->gamma->tables[{{ i }}]->u{{ gamma_out_bits(c[2]) }};