MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ff_ac3_encode_init

Function ff_ac3_encode_init

libavcodec/ac3enc.c:2472–2522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2470
2471
2472av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
2473{
2474 static AVOnce init_static_once = AV_ONCE_INIT;
2475 AC3EncodeContext *s = avctx->priv_data;
2476 int ret, frame_size_58;
2477
2478 s->avctx = avctx;
2479
2480 ret = validate_options(s);
2481 if (ret)
2482 return ret;
2483
2484 avctx->frame_size = AC3_BLOCK_SIZE * s->num_blocks;
2485 avctx->initial_padding = AC3_BLOCK_SIZE;
2486
2487 s->bitstream_mode = avctx->audio_service_type;
2488 if (s->bitstream_mode == AV_AUDIO_SERVICE_TYPE_KARAOKE)
2489 s->bitstream_mode = 0x7;
2490
2491 s->bits_written = 0;
2492 s->samples_written = 0;
2493
2494 /* calculate crc_inv for both possible frame sizes */
2495 frame_size_58 = (( s->frame_size >> 2) + ( s->frame_size >> 4)) << 1;
2496 s->crc_inv[0] = pow_poly((CRC16_POLY >> 1), (8 * frame_size_58) - 16, CRC16_POLY);
2497 if (s->bit_alloc.sr_code == 1) {
2498 frame_size_58 = (((s->frame_size+2) >> 2) + ((s->frame_size+2) >> 4)) << 1;
2499 s->crc_inv[1] = pow_poly((CRC16_POLY >> 1), (8 * frame_size_58) - 16, CRC16_POLY);
2500 }
2501
2502 if (!s->output_frame_header)
2503 s->output_frame_header = ac3_output_frame_header;
2504
2505 set_bandwidth(s);
2506
2507 bit_alloc_init(s);
2508
2509 ret = allocate_buffers(s);
2510 if (ret)
2511 return ret;
2512
2513 ff_audiodsp_init(&s->adsp);
2514 ff_me_cmp_init(&s->mecc, avctx);
2515 ff_ac3dsp_init(&s->ac3dsp);
2516
2517 dprint_options(s);
2518
2519 ff_thread_once(&init_static_once, exponent_init);
2520
2521 return 0;
2522}

Callers 2

ac3_fixed_encode_initFunction · 0.85
ff_ac3_float_encode_initFunction · 0.85

Calls 10

validate_optionsFunction · 0.85
pow_polyFunction · 0.85
set_bandwidthFunction · 0.85
bit_alloc_initFunction · 0.85
ff_audiodsp_initFunction · 0.85
ff_me_cmp_initFunction · 0.85
ff_ac3dsp_initFunction · 0.85
dprint_optionsFunction · 0.85
ff_thread_onceFunction · 0.85
allocate_buffersFunction · 0.70

Tested by

no test coverage detected