diff options
-rw-r--r-- | libhb/audio_remap.c | 110 | ||||
-rw-r--r-- | libhb/audio_remap.h | 60 | ||||
-rw-r--r-- | libhb/encavcodecaudio.c | 59 | ||||
-rw-r--r-- | libhb/encfaac.c | 18 | ||||
-rw-r--r-- | libhb/encvorbis.c | 174 | ||||
-rw-r--r-- | libhb/platform/macosx/encca_aac.c | 28 |
6 files changed, 268 insertions, 181 deletions
diff --git a/libhb/audio_remap.c b/libhb/audio_remap.c index 6d3877d3d..1c9e5d90d 100644 --- a/libhb/audio_remap.c +++ b/libhb/audio_remap.c @@ -97,30 +97,96 @@ hb_chan_map_t hb_aac_chan_map = } }; -int* hb_audio_remap_build_table(uint64_t layout, hb_chan_map_t *map_in, hb_chan_map_t *map_out) +hb_audio_remap_t* hb_audio_remap_init(uint64_t channel_layout, + hb_chan_map_t *map_out, + hb_chan_map_t *map_in) { - int ii, jj, idx, remap_idx, *remap_table; - uint64_t *input_order, *output_order; + hb_audio_remap_t *remap = malloc(sizeof(hb_audio_remap_t)); + if (remap == NULL) + return NULL; + + remap->remap_table = hb_audio_remap_build_table(channel_layout, + map_out, map_in); + if (remap->remap_table == NULL) + { + hb_audio_remap_free(remap); + return NULL; + } + + int ii; + remap->nchannels = av_get_channel_layout_nb_channels(channel_layout); + remap->sample_size = remap->nchannels * sizeof(hb_sample_t); + remap->remap_needed = 0; + for (ii = 0; ii < remap->nchannels; ii++) + { + if (remap->remap_table[ii] != ii) + { + remap->remap_needed = 1; + break; + } + } + + return remap; +} + +void hb_audio_remap_free(hb_audio_remap_t *remap) +{ + if (remap != NULL) + { + if (remap->remap_table != NULL) + { + free(remap->remap_table); + } + free(remap); + } +} - remap_table = calloc(HB_AUDIO_REMAP_MAX_CHANNELS, sizeof(int)); - if (!remap_table) +void hb_audio_remap(hb_audio_remap_t *remap, hb_sample_t *samples, int nsamples) +{ + if (remap != NULL && remap->remap_needed) + { + int ii, jj; + + for (ii = 0; ii < nsamples; ii++) + { + memcpy(remap->tmp, samples, remap->sample_size); + for (jj = 0; jj < remap->nchannels; jj++) + { + samples[jj] = remap->tmp[remap->remap_table[jj]]; + } + samples += remap->nchannels; + } + } +} + +int* hb_audio_remap_build_table(uint64_t channel_layout, + hb_chan_map_t *map_out, + hb_chan_map_t *map_in) +{ + int ii, jj, nchannels, out_chan_idx, remap_idx, *remap_table; + uint64_t *channels_in, *channels_out; + + nchannels = av_get_channel_layout_nb_channels(channel_layout); + remap_table = malloc(nchannels * sizeof(int)); + if (remap_table == NULL) return NULL; - idx = 0; - input_order = map_in->channel_order; - output_order = map_out->channel_order; - for (ii = 0; output_order[ii]; ii++) + out_chan_idx = 0; + channels_in = map_in->channel_order_map; + channels_out = map_out->channel_order_map; + for (ii = 0; channels_out[ii] && out_chan_idx < nchannels; ii++) { - if (layout & output_order[ii]) + if (channel_layout & channels_out[ii]) { remap_idx = 0; - for (jj = 0; input_order[jj]; jj++) + for (jj = 0; channels_in[jj]; jj++) { - if (output_order[ii] == input_order[jj]) + if (channels_out[ii] == channels_in[jj]) { - remap_table[idx++] = remap_idx++; + remap_table[out_chan_idx++] = remap_idx++; + break; } - else if (layout & input_order[jj]) + else if (channel_layout & channels_in[jj]) { remap_idx++; } @@ -130,19 +196,3 @@ int* hb_audio_remap_build_table(uint64_t layout, hb_chan_map_t *map_in, hb_chan_ return remap_table; } - -void hb_audio_remap(int nchannels, int nsamples, hb_sample_t *samples, int *remap_table) -{ - int ii, jj; - hb_sample_t tmp[HB_AUDIO_REMAP_MAX_CHANNELS]; - - for (ii = 0; ii < nsamples; ii++) - { - memcpy(tmp, samples, nchannels * sizeof(hb_sample_t)); - for (jj = 0; jj < nchannels; jj++) - { - samples[jj] = tmp[remap_table[jj]]; - } - samples += nchannels; - } -}
\ No newline at end of file diff --git a/libhb/audio_remap.h b/libhb/audio_remap.h index 32ee3e9cb..d74bb725c 100644 --- a/libhb/audio_remap.h +++ b/libhb/audio_remap.h @@ -9,45 +9,77 @@ /* This file handles the following two scenarios: * - * 1) remapping from liba52/libdca order to libav order - * - this allows downmixing liba52/libdca sources with libavresample + * 1) remapping audio from decoder order to libav order (for downmixing) * - * 2) remapping from libav order to aac/vorbis order - * - this allows encoding audio without libavcodec (faac, ca_aac, libvorbis) + * 2) remapping audio from libav order to encoder order (for encoding) * - * Thus we only need to support: + * We only need to support: * - * a) channels found in liba52/libdca layouts + * a) channels found in our non-libavcodec audio decoders' layouts * b) channels found in HB_AMIXDOWN_* layouts * - * Notes: + * We consider that: * - * Left/Right Surround -> Side Left/Right - * Left/Right Rear Surround -> Back Left/Right */ + * Left/Right Surround == Side Left/Right + * Left/Right Rear Surround == Back Left/Right */ #ifndef AUDIO_REMAP_H #define AUDIO_REMAP_H #include <stdint.h> -// we only need to support the 11 "most common" channels +/* we only need to support the 11 "most common" channels */ #define HB_AUDIO_REMAP_MAX_CHANNELS 11 typedef float hb_sample_t; typedef struct { - uint64_t channel_order[HB_AUDIO_REMAP_MAX_CHANNELS+1]; + int nchannels; + int sample_size; + int remap_needed; + int *remap_table; + hb_sample_t tmp[HB_AUDIO_REMAP_MAX_CHANNELS]; +} hb_audio_remap_t; + +typedef struct +{ + uint64_t channel_order_map[HB_AUDIO_REMAP_MAX_CHANNELS+1]; } hb_chan_map_t; -// used to convert between various channel orders +/* Predefined channel maps for common channel orders. */ extern hb_chan_map_t hb_libav_chan_map; extern hb_chan_map_t hb_liba52_chan_map; extern hb_chan_map_t hb_libdca_chan_map; extern hb_chan_map_t hb_vorbis_chan_map; extern hb_chan_map_t hb_aac_chan_map; -int* hb_audio_remap_build_table(uint64_t layout, hb_chan_map_t *map_in, hb_chan_map_t *map_out); -void hb_audio_remap(int nchannels, int nsamples, hb_sample_t *samples, int *remap_table); +/* Initialize an hb_audio_remap_t to remap audio with the specified channel + * layout, from the input channel order (indicated by map_in) to the output + * channel order (indicated by map_out). + */ +hb_audio_remap_t* hb_audio_remap_init(uint64_t channel_layout, + hb_chan_map_t *map_out, + hb_chan_map_t *map_in); + +/* Free an hb_audio_remap_t. */ +void hb_audio_remap_free(hb_audio_remap_t *remap); + +/* Remap audio between 2 different channel orders, using the settings specified + * in the remap paremeter. Remapping is only done when necessary. + * + * The remap parameter can be NULL (no remapping). + */ +void hb_audio_remap(hb_audio_remap_t *remap, + hb_sample_t *samples, + int nsamples); + +/* Generate a table used to remap audio between 2 different channel orders. + * + * Usage: output_sample[channel_idx] = input_sample[remap_table[channel_idx]] + */ +int* hb_audio_remap_build_table(uint64_t channel_layout, + hb_chan_map_t *map_out, + hb_chan_map_t *map_in); #endif /* AUDIO_REMAP_H */ diff --git a/libhb/encavcodecaudio.c b/libhb/encavcodecaudio.c index 001000b9a..5871f306b 100644 --- a/libhb/encavcodecaudio.c +++ b/libhb/encavcodecaudio.c @@ -24,7 +24,7 @@ struct hb_work_private_s uint8_t * buf; AVAudioResampleContext *avresample; - int *remap_table; + hb_audio_remap_t *remap; }; static int encavcodecaInit( hb_work_object_t *, hb_job_t * ); @@ -64,16 +64,13 @@ static int encavcodecaInit( hb_work_object_t * w, hb_job_t * job ) context->channel_layout = hb_ff_mixdown_xlat(audio->config.out.mixdown, &mode); pv->out_discrete_channels = hb_mixdown_get_discrete_channel_count(audio->config.out.mixdown); - if (pv->out_discrete_channels > 2 && - audio->config.in.channel_map != &hb_libav_chan_map) + // channel remapping + // note: unnecessary once everything is downmixed using libavresample + pv->remap = hb_audio_remap_init(context->channel_layout, &hb_libav_chan_map, + audio->config.in.channel_map); + if (pv->remap == NULL) { - pv->remap_table = hb_audio_remap_build_table(context->channel_layout, - audio->config.in.channel_map, - &hb_libav_chan_map); - } - else - { - pv->remap_table = NULL; + hb_log("encavcodecaInit: hb_audio_remap_init() failed"); } AVDictionary *av_opts = NULL; @@ -198,36 +195,43 @@ static void Finalize( hb_work_object_t * w ) } } -static void encavcodecaClose( hb_work_object_t * w ) +static void encavcodecaClose(hb_work_object_t * w) { hb_work_private_t * pv = w->private_data; - if ( pv ) + if (pv != NULL) { - if( pv->context ) + if (pv->context != NULL) { - Finalize( w ); - hb_deep_log( 2, "encavcodeca: closing libavcodec" ); - if ( pv->context->codec ) - avcodec_flush_buffers( pv->context ); - hb_avcodec_close( pv->context ); + Finalize(w); + hb_deep_log(2, "encavcodeca: closing libavcodec"); + if (pv->context->codec != NULL) + avcodec_flush_buffers(pv->context); + hb_avcodec_close(pv->context); } - if ( pv->buf ) + if (pv->buf != NULL) { - free( pv->buf ); + free(pv->buf); pv->buf = NULL; } - if ( pv->list ) - hb_list_empty( &pv->list ); + if (pv->list != NULL) + { + hb_list_empty(&pv->list); + } if (pv->avresample != NULL) { avresample_free(&pv->avresample); } - free( pv ); + if (pv->remap != NULL) + { + hb_audio_remap_free(pv->remap); + } + + free(pv); w->private_data = NULL; } } @@ -265,12 +269,9 @@ static hb_buffer_t * Encode( hb_work_object_t * w ) } hb_list_getbytes( pv->list, pv->buf, pv->input_samples * sizeof( float ), - &pts, &pos); - if (pv->remap_table != NULL) - { - hb_audio_remap(pv->out_discrete_channels, pv->samples_per_frame, - (hb_sample_t*)pv->buf, pv->remap_table); - } + &pts, &pos); + + hb_audio_remap(pv->remap, (hb_sample_t*)pv->buf, pv->samples_per_frame); // Prepare input frame AVFrame frame; diff --git a/libhb/encfaac.c b/libhb/encfaac.c index 6782605e9..675881e8e 100644 --- a/libhb/encfaac.c +++ b/libhb/encfaac.c @@ -110,20 +110,20 @@ int encfaacInit( hb_work_object_t * w, hb_job_t * job ) cfg->aacObjectType = LOW; cfg->allowMidside = 1; - // LFE, remapping + // channel remapping, LFE uint64_t layout; + int *remap_table; layout = hb_ff_mixdown_xlat(audio->config.out.mixdown, NULL); - cfg->useLfe = !!(layout & AV_CH_LOW_FREQUENCY); - if (pv->out_discrete_channels > 2 && - audio->config.in.channel_map != &hb_aac_chan_map) + remap_table = hb_audio_remap_build_table(layout, &hb_aac_chan_map, + audio->config.in.channel_map); + if (remap_table != NULL) { - int *remap_table; - remap_table = hb_audio_remap_build_table(layout, - audio->config.in.channel_map, - &hb_aac_chan_map); // faac does its own remapping - memcpy(cfg->channel_map, remap_table, pv->out_discrete_channels * sizeof(int)); + memcpy(cfg->channel_map, remap_table, + pv->out_discrete_channels * sizeof(int)); + free(remap_table); } + cfg->useLfe = !!(layout & AV_CH_LOW_FREQUENCY); cfg->useTns = 0; cfg->bitRate = audio->config.out.bitrate * 1000 / pv->out_discrete_channels; /* Per channel */ diff --git a/libhb/encvorbis.c b/libhb/encvorbis.c index da631592c..a5325ef6d 100644 --- a/libhb/encvorbis.c +++ b/libhb/encvorbis.c @@ -29,119 +29,126 @@ hb_work_object_t hb_encvorbis = struct hb_work_private_s { - hb_job_t * job; + uint8_t *buf; + hb_job_t *job; + hb_list_t *list; - vorbis_info vi; - vorbis_comment vc; - vorbis_dsp_state vd; - vorbis_block vb; + vorbis_dsp_state vd; + vorbis_comment vc; + vorbis_block vb; + vorbis_info vi; - unsigned long input_samples; - uint8_t * buf; - uint64_t pts; + unsigned input_samples; + uint64_t pts; + int64_t prev_blocksize; + int out_discrete_channels; - hb_list_t * list; - int out_discrete_channels; - int * remap_table; - int64_t prev_blocksize; + int *remap_table; }; -int encvorbisInit( hb_work_object_t * w, hb_job_t * job ) +int encvorbisInit(hb_work_object_t *w, hb_job_t *job) { - hb_audio_t * audio = w->audio; - int i; - ogg_packet header[3]; - - hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) ); + hb_work_private_t *pv = calloc(1, sizeof(hb_work_private_t)); + hb_audio_t *audio = w->audio; w->private_data = pv; - pv->out_discrete_channels = hb_mixdown_get_discrete_channel_count(audio->config.out.mixdown); + pv->job = job; - pv->job = job; + int i; + ogg_packet header[3]; - hb_log( "encvorbis: opening libvorbis" ); + hb_log("encvorbis: opening libvorbis"); /* init */ - for( i = 0; i < 3; i++ ) + for (i = 0; i < 3; i++) { // Zero vorbis headers so that we don't crash in mk_laceXiph // when vorbis_encode_setup_managed fails. - memset( w->config->vorbis.headers[i], 0, sizeof( ogg_packet ) ); + memset(w->config->vorbis.headers[i], 0, sizeof(ogg_packet)); } - vorbis_info_init( &pv->vi ); + vorbis_info_init(&pv->vi); + + pv->out_discrete_channels = + hb_mixdown_get_discrete_channel_count(audio->config.out.mixdown); - if( audio->config.out.bitrate > 0 ) + if (audio->config.out.bitrate > 0) { /* 28kbps/channel seems to be the minimum for 6ch vorbis. */ int min_bitrate = 28 * pv->out_discrete_channels; - if (pv->out_discrete_channels > 2 && audio->config.out.bitrate < min_bitrate) + if (pv->out_discrete_channels > 2 && + audio->config.out.bitrate < min_bitrate) { - hb_log( "encvorbis: Selected bitrate (%d kbps) too low for %d channel audio.", audio->config.out.bitrate, pv->out_discrete_channels); - hb_log( "encvorbis: Resetting bitrate to %d kbps", min_bitrate); + hb_log("encvorbis: Selected bitrate (%d kbps) too low for %d channel audio", + audio->config.out.bitrate, pv->out_discrete_channels); + hb_log("encvorbis: Resetting bitrate to %d kbps", min_bitrate); /* Naughty! We shouldn't modify the audio from here. */ audio->config.out.bitrate = min_bitrate; } - if( vorbis_encode_setup_managed( &pv->vi, pv->out_discrete_channels, - audio->config.out.samplerate, -1, 1000 * audio->config.out.bitrate, -1 ) ) + if (vorbis_encode_setup_managed(&pv->vi, pv->out_discrete_channels, + audio->config.out.samplerate, -1, + audio->config.out.bitrate * 1000, -1)) { - hb_error( "encvorbis: vorbis_encode_setup_managed failed.\n" ); + hb_error("encvorbis: vorbis_encode_setup_managed() failed"); *job->die = 1; return -1; } } - else if( audio->config.out.quality != HB_INVALID_AUDIO_QUALITY ) + else if (audio->config.out.quality != HB_INVALID_AUDIO_QUALITY) { // map VBR quality to Vorbis API (divide by 10) - if( vorbis_encode_setup_vbr( &pv->vi, pv->out_discrete_channels, - audio->config.out.samplerate, audio->config.out.quality/10 ) ) + if (vorbis_encode_setup_vbr(&pv->vi, pv->out_discrete_channels, + audio->config.out.samplerate, + audio->config.out.quality / 10)) { - hb_error( "encvorbis: vorbis_encode_setup_vbr failed.\n" ); + hb_error("encvorbis: vorbis_encode_setup_vbr() failed"); *job->die = 1; return -1; } } - if( vorbis_encode_ctl( &pv->vi, OV_ECTL_RATEMANAGE2_SET, NULL ) || - vorbis_encode_setup_init( &pv->vi ) ) + if (vorbis_encode_ctl(&pv->vi, OV_ECTL_RATEMANAGE2_SET, NULL) || + vorbis_encode_setup_init(&pv->vi)) { - hb_error( "encvorbis: vorbis_encode_ctl( ratemanage2_set ) OR vorbis_encode_setup_init failed.\n" ); + hb_error("encvorbis: vorbis_encode_ctl(ratemanage2_set) OR vorbis_encode_setup_init() failed"); *job->die = 1; return -1; } /* add a comment */ - vorbis_comment_init( &pv->vc ); - vorbis_comment_add_tag( &pv->vc, "Encoder", "HandBrake"); - vorbis_comment_add_tag( &pv->vc, "LANGUAGE", w->config->vorbis.language); + vorbis_comment_init(&pv->vc); + vorbis_comment_add_tag(&pv->vc, "Encoder", "HandBrake"); + vorbis_comment_add_tag(&pv->vc, "LANGUAGE", w->config->vorbis.language); /* set up the analysis state and auxiliary encoding storage */ - vorbis_analysis_init( &pv->vd, &pv->vi); - vorbis_block_init( &pv->vd, &pv->vb); + vorbis_analysis_init(&pv->vd, &pv->vi); + vorbis_block_init(&pv->vd, &pv->vb); /* get the 3 headers */ - vorbis_analysis_headerout( &pv->vd, &pv->vc, - &header[0], &header[1], &header[2] ); - for( i = 0; i < 3; i++ ) + vorbis_analysis_headerout(&pv->vd, &pv->vc, + &header[0], &header[1], &header[2]); + for (i = 0; i < 3; i++) { - memcpy( w->config->vorbis.headers[i], &header[i], - sizeof( ogg_packet ) ); - memcpy( w->config->vorbis.headers[i] + sizeof( ogg_packet ), - header[i].packet, header[i].bytes ); + memcpy(w->config->vorbis.headers[i], &header[i], sizeof(ogg_packet)); + memcpy(w->config->vorbis.headers[i] + sizeof(ogg_packet), + header[i].packet, header[i].bytes); } pv->input_samples = pv->out_discrete_channels * OGGVORBIS_FRAME_SIZE; audio->config.out.samples_per_frame = OGGVORBIS_FRAME_SIZE; - pv->buf = malloc( pv->input_samples * sizeof( float ) ); + pv->buf = malloc(pv->input_samples * sizeof(float)); pv->list = hb_list_init(); - // remapping - uint64_t layout; - layout = hb_ff_mixdown_xlat(audio->config.out.mixdown, NULL); - pv->remap_table = hb_audio_remap_build_table(layout, - audio->config.in.channel_map, - &hb_vorbis_chan_map); - + // channel remapping + uint64_t layout = hb_ff_mixdown_xlat(audio->config.out.mixdown, NULL); + pv->remap_table = hb_audio_remap_build_table(layout, &hb_vorbis_chan_map, + audio->config.in.channel_map); + if (pv->remap_table == NULL) + { + hb_error("encvorbisInit: hb_audio_remap_build_table() failed"); + *job->die = 1; + return -1; + } return 0; } @@ -151,20 +158,23 @@ int encvorbisInit( hb_work_object_t * w, hb_job_t * job ) *********************************************************************** * **********************************************************************/ -void encvorbisClose( hb_work_object_t * w ) +void encvorbisClose(hb_work_object_t * w) { - hb_work_private_t * pv = w->private_data; + hb_work_private_t *pv = w->private_data; - vorbis_block_clear( &pv->vb ); - vorbis_dsp_clear( &pv->vd ); - vorbis_comment_clear( &pv->vc ); - vorbis_info_clear( &pv->vi ); + vorbis_comment_clear(&pv->vc); + vorbis_block_clear(&pv->vb); + vorbis_info_clear(&pv->vi); + vorbis_dsp_clear(&pv->vd); if (pv->list) - hb_list_empty( &pv->list ); + { + hb_list_empty(&pv->list); + } - free( pv->buf ); - free( pv ); + free(pv->remap_table); + free(pv->buf); + free(pv); w->private_data = NULL; } @@ -213,40 +223,42 @@ static hb_buffer_t * Flush( hb_work_object_t * w ) *********************************************************************** * **********************************************************************/ -static hb_buffer_t * Encode( hb_work_object_t * w ) +static hb_buffer_t* Encode(hb_work_object_t *w) { - hb_work_private_t * pv = w->private_data; - hb_buffer_t * buf; - float ** buffer; + hb_work_private_t *pv = w->private_data; + hb_buffer_t *buf; + float **buffer; int i, j; /* Try to extract more data */ - if( ( buf = Flush( w ) ) ) + if ((buf = Flush(w)) != NULL) { return buf; } - if( hb_list_bytes( pv->list ) < pv->input_samples * sizeof( float ) ) + /* Check if we need more data */ + if (hb_list_bytes(pv->list) < pv->input_samples * sizeof(float)) { return NULL; } /* Process more samples */ - hb_list_getbytes( pv->list, pv->buf, pv->input_samples * sizeof( float ), - &pv->pts, NULL ); - buffer = vorbis_analysis_buffer( &pv->vd, OGGVORBIS_FRAME_SIZE ); - for( i = 0; i < OGGVORBIS_FRAME_SIZE; i++ ) + hb_list_getbytes(pv->list, pv->buf, pv->input_samples * sizeof(float), + &pv->pts, NULL); + buffer = vorbis_analysis_buffer(&pv->vd, OGGVORBIS_FRAME_SIZE); + for (i = 0; i < OGGVORBIS_FRAME_SIZE; i++) { - for( j = 0; j < pv->out_discrete_channels; j++) + for (j = 0; j < pv->out_discrete_channels; j++) { - buffer[j][i] = ((float *) pv->buf)[(pv->out_discrete_channels * i + pv->remap_table[j])]; + buffer[j][i] = ((float*)pv->buf)[(pv->out_discrete_channels * i + + pv->remap_table[j])]; } } - vorbis_analysis_wrote( &pv->vd, OGGVORBIS_FRAME_SIZE ); + vorbis_analysis_wrote(&pv->vd, OGGVORBIS_FRAME_SIZE); /* Try to extract again */ - return Flush( w ); + return Flush(w); } /*********************************************************************** diff --git a/libhb/platform/macosx/encca_aac.c b/libhb/platform/macosx/encca_aac.c index 7839ed930..8ee84276e 100644 --- a/libhb/platform/macosx/encca_aac.c +++ b/libhb/platform/macosx/encca_aac.c @@ -49,7 +49,7 @@ struct hb_work_private_s uint64_t pts, ibytes; Float64 osamplerate; - int *remap_table; + hb_audio_remap_t *remap; }; #define MP4ESDescrTag 0x03 @@ -289,16 +289,12 @@ int encCoreAudioInit(hb_work_object_t *w, hb_job_t *job, enum AAC_MODE mode) audio->config.out.samples_per_frame = pv->isamples; // channel remapping - if (pv->nchannels > 2 && audio->config.in.channel_map != &hb_aac_chan_map) + uint64_t layout = hb_ff_mixdown_xlat(audio->config.out.mixdown, NULL); + pv->remap = hb_audio_remap_init(layout, &hb_aac_chan_map, + audio->config.in.channel_map); + if (pv->remap == NULL) { - uint64_t layout = hb_ff_mixdown_xlat(audio->config.out.mixdown, NULL); - pv->remap_table = hb_audio_remap_build_table(layout, - audio->config.in.channel_map, - &hb_aac_chan_map); - } - else - { - pv->remap_table = NULL; + hb_log("encCoreAudioInit: hb_audio_remap_init() failed"); } // get maximum output size @@ -344,9 +340,9 @@ void encCoreAudioClose(hb_work_object_t *w) { free(pv->buf); } - if (pv->remap_table != NULL) + if (pv->remap != NULL) { - free(pv->remap_table); + hb_audio_remap_free(pv->remap); } hb_list_empty(&pv->list); free(pv); @@ -392,12 +388,8 @@ static OSStatus inInputDataProc(AudioConverterRef converter, UInt32 *npackets, *npackets = buffers->mBuffers[0].mDataByteSize / pv->isamplesiz; pv->ibytes -= buffers->mBuffers[0].mDataByteSize; - if (pv->remap_table != NULL) - { - hb_audio_remap(pv->nchannels, *npackets, - (hb_sample_t*)buffers->mBuffers[0].mData, - pv->remap_table); - } + hb_audio_remap(pv->remap, + (hb_sample_t*)buffers->mBuffers[0].mData, *npackets); return noErr; } |