| 2325 | } |
| 2326 | |
| 2327 | static av_cold int decode_init(AVCodecContext *avctx) |
| 2328 | { |
| 2329 | EXRContext *s = avctx->priv_data; |
| 2330 | #if FF_API_EXR_GAMMA |
| 2331 | uint32_t i; |
| 2332 | union av_intfloat32 t; |
| 2333 | float one_gamma = 1.0f / s->gamma; |
| 2334 | av_csp_trc_function trc_func = NULL; |
| 2335 | #endif |
| 2336 | |
| 2337 | ff_init_float2half_tables(&s->f2h_tables); |
| 2338 | ff_init_half2float_tables(&s->h2f_tables); |
| 2339 | |
| 2340 | s->avctx = avctx; |
| 2341 | |
| 2342 | ff_exrdsp_init(&s->dsp); |
| 2343 | |
| 2344 | #if HAVE_BIGENDIAN |
| 2345 | ff_bswapdsp_init(&s->bbdsp); |
| 2346 | #endif |
| 2347 | |
| 2348 | #if FF_API_EXR_GAMMA |
| 2349 | trc_func = av_csp_trc_func_from_id(s->apply_trc_type); |
| 2350 | if (trc_func) { |
| 2351 | for (i = 0; i < 65536; ++i) { |
| 2352 | t.i = half2float(i, &s->h2f_tables); |
| 2353 | t.f = trc_func(t.f); |
| 2354 | s->gamma_table[i] = float2half(av_float2int(t.f), &s->f2h_tables); |
| 2355 | } |
| 2356 | } else if (one_gamma != 1.0f) { |
| 2357 | for (i = 0; i < 65536; ++i) { |
| 2358 | t.i = half2float(i, &s->h2f_tables); |
| 2359 | /* If negative value we reuse half value */ |
| 2360 | if (t.f <= 0.0f) { |
| 2361 | s->gamma_table[i] = i; |
| 2362 | } else { |
| 2363 | t.f = powf(t.f, one_gamma); |
| 2364 | s->gamma_table[i] = float2half(t.i, &s->f2h_tables); |
| 2365 | } |
| 2366 | } |
| 2367 | } |
| 2368 | #endif |
| 2369 | |
| 2370 | // allocate thread data, used for non EXR_RAW compression types |
| 2371 | s->thread_data = av_calloc(avctx->thread_count, sizeof(*s->thread_data)); |
| 2372 | if (!s->thread_data) |
| 2373 | return AVERROR(ENOMEM); |
| 2374 | |
| 2375 | return 0; |
| 2376 | } |
| 2377 | |
| 2378 | static av_cold int decode_end(AVCodecContext *avctx) |
| 2379 | { |
nothing calls this directly
no test coverage detected