MCPcopy Create free account
hub / github.com/Tracktion/choc / process_subframes_

Function process_subframes_

choc/audio/choc_AudioFileFormat_FLAC.h:15363–15605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15361}
15362
15363FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_fractional_block)
15364{
15365 FLAC__FrameHeader frame_header;
15366 unsigned channel, min_partition_order = encoder->protected_->min_residual_partition_order, max_partition_order;
15367 FLAC__bool do_independent, do_mid_side;
15368
15369 /*
15370 * Calculate the min,max Rice partition orders
15371 */
15372 if(is_fractional_block) {
15373 max_partition_order = 0;
15374 }
15375 else {
15376 max_partition_order = FLAC__format_get_max_rice_partition_order_from_blocksize(encoder->protected_->blocksize);
15377 max_partition_order = std::min(max_partition_order, encoder->protected_->max_residual_partition_order);
15378 }
15379 min_partition_order = std::min(min_partition_order, max_partition_order);
15380
15381 /*
15382 * Setup the frame
15383 */
15384 frame_header.blocksize = encoder->protected_->blocksize;
15385 frame_header.sample_rate = encoder->protected_->sample_rate;
15386 frame_header.channels = encoder->protected_->channels;
15387 frame_header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT; /* the default unless the encoder determines otherwise */
15388 frame_header.bits_per_sample = encoder->protected_->bits_per_sample;
15389 frame_header.number_type = FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER;
15390 frame_header.number.frame_number = encoder->private_->current_frame_number;
15391
15392 /*
15393 * Figure out what channel assignments to try
15394 */
15395 if(encoder->protected_->do_mid_side_stereo) {
15396 if(encoder->protected_->loose_mid_side_stereo) {
15397 if(encoder->private_->loose_mid_side_stereo_frame_count == 0) {
15398 do_independent = true;
15399 do_mid_side = true;
15400 }
15401 else {
15402 do_independent = (encoder->private_->last_channel_assignment == FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT);
15403 do_mid_side = !do_independent;
15404 }
15405 }
15406 else {
15407 do_independent = true;
15408 do_mid_side = true;
15409 }
15410 }
15411 else {
15412 do_independent = true;
15413 do_mid_side = false;
15414 }
15415
15416 CHOC_ASSERT(do_independent || do_mid_side);
15417
15418 /*
15419 * Check for wasted bits; set effective bps for each subframe
15420 */

Callers 1

process_frame_Function · 0.85

Calls 5

get_wasted_bits_Function · 0.85
process_subframe_Function · 0.85
FLAC__frame_add_headerFunction · 0.85
add_subframe_Function · 0.85

Tested by

no test coverage detected