| 2158 | } |
| 2159 | |
| 2160 | static void pack_float_sample(WavPackEncodeContext *s, int32_t *sample) |
| 2161 | { |
| 2162 | const int max_exp = s->float_max_exp; |
| 2163 | PutBitContext *pb = &s->pb; |
| 2164 | int32_t value, shift_count; |
| 2165 | |
| 2166 | if (get_exponent(*sample) == 255) { |
| 2167 | if (get_mantissa(*sample)) { |
| 2168 | put_bits(pb, 1, 1); |
| 2169 | put_bits(pb, 23, get_mantissa(*sample)); |
| 2170 | } else { |
| 2171 | put_bits(pb, 1, 0); |
| 2172 | } |
| 2173 | |
| 2174 | value = 0x1000000; |
| 2175 | shift_count = 0; |
| 2176 | } else if (get_exponent(*sample)) { |
| 2177 | shift_count = max_exp - get_exponent(*sample); |
| 2178 | value = 0x800000 + get_mantissa(*sample); |
| 2179 | } else { |
| 2180 | shift_count = max_exp ? max_exp - 1 : 0; |
| 2181 | value = get_mantissa(*sample); |
| 2182 | } |
| 2183 | |
| 2184 | if (shift_count < 25) |
| 2185 | value >>= shift_count; |
| 2186 | else |
| 2187 | value = 0; |
| 2188 | |
| 2189 | if (!value) { |
| 2190 | if (s->float_flags & FLOAT_ZEROS_SENT) { |
| 2191 | if (get_exponent(*sample) || get_mantissa(*sample)) { |
| 2192 | put_bits(pb, 1, 1); |
| 2193 | put_bits(pb, 23, get_mantissa(*sample)); |
| 2194 | |
| 2195 | if (max_exp >= 25) |
| 2196 | put_bits(pb, 8, get_exponent(*sample)); |
| 2197 | |
| 2198 | put_bits(pb, 1, get_sign(*sample)); |
| 2199 | } else { |
| 2200 | put_bits(pb, 1, 0); |
| 2201 | |
| 2202 | if (s->float_flags & FLOAT_NEG_ZEROS) |
| 2203 | put_bits(pb, 1, get_sign(*sample)); |
| 2204 | } |
| 2205 | } |
| 2206 | } else if (shift_count) { |
| 2207 | if (s->float_flags & FLOAT_SHIFT_SENT) { |
| 2208 | put_sbits(pb, shift_count, get_mantissa(*sample)); |
| 2209 | } else if (s->float_flags & FLOAT_SHIFT_SAME) { |
| 2210 | put_bits(pb, 1, get_mantissa(*sample) & 1); |
| 2211 | } |
| 2212 | } |
| 2213 | } |
| 2214 | |
| 2215 | static void pack_float(WavPackEncodeContext *s, |
| 2216 | int32_t *samples_l, int32_t *samples_r, |
no test coverage detected