diff options
author | Rodeo <[email protected]> | 2012-07-15 17:37:27 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2012-07-15 17:37:27 +0000 |
commit | 62cbe39e294565f429411d8293aa64c41a9d1b30 (patch) | |
tree | b4d32ca476e93b84c45b5a9dd2e5f3386cc09e3d /libhb/encavcodecaudio.c | |
parent | c171ef516b8df74903e38cf7c797c25303aff8be (diff) |
Change a few more hb_log() calls to hb_error(), and some cosmetics.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4840 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/encavcodecaudio.c')
-rw-r--r-- | libhb/encavcodecaudio.c | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/libhb/encavcodecaudio.c b/libhb/encavcodecaudio.c index 37cb78769..28eb0d9ae 100644 --- a/libhb/encavcodecaudio.c +++ b/libhb/encavcodecaudio.c @@ -41,22 +41,20 @@ hb_work_object_t hb_encavcodeca = encavcodecaClose }; -static int encavcodecaInit( hb_work_object_t * w, hb_job_t * job ) +static int encavcodecaInit(hb_work_object_t *w, hb_job_t *job) { - AVCodec * codec; - AVCodecContext * context; - hb_audio_t * audio = w->audio; + AVCodec *codec; + AVCodecContext *context; + hb_audio_t *audio = w->audio; - hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) ); + hb_work_private_t *pv = calloc(1, sizeof(hb_work_private_t)); w->private_data = pv; - pv->job = job; - codec = avcodec_find_encoder( w->codec_param ); - if( !codec ) + codec = avcodec_find_encoder(w->codec_param); + if (codec == NULL) { - hb_log( "encavcodecaInit: avcodec_find_encoder " - "failed" ); + hb_error("encavcodecaInit: avcodec_find_encoder() failed"); return 1; } context = avcodec_alloc_context3(codec); @@ -78,40 +76,44 @@ static int encavcodecaInit( hb_work_object_t * w, hb_job_t * job ) av_dict_set(&av_opts, "dsur_mode", "on", 0); } - if( audio->config.out.bitrate > 0 ) + if (audio->config.out.bitrate > 0) + { context->bit_rate = audio->config.out.bitrate * 1000; - else if( audio->config.out.quality >= 0 ) + } + else if (audio->config.out.quality >= 0) { context->global_quality = audio->config.out.quality * FF_QP2LAMBDA; context->flags |= CODEC_FLAG_QSCALE; } - if( audio->config.out.compression_level >= 0 ) + if (audio->config.out.compression_level >= 0) + { context->compression_level = audio->config.out.compression_level; + } - // Try to set format to float. Fallback to whatever is supported. - hb_ff_set_sample_fmt( context, codec ); + // Try to set format to float; fall back to whatever is supported. + hb_ff_set_sample_fmt(context, codec); - if( hb_avcodec_open( context, codec, &av_opts, 0 ) ) + if (hb_avcodec_open(context, codec, &av_opts, 0)) { - hb_log( "encavcodecaInit: avcodec_open failed" ); + hb_error("encavcodecaInit: hb_avcodec_open() failed"); return 1; } // avcodec_open populates the opts dictionary with the // things it didn't recognize. AVDictionaryEntry *t = NULL; - while( ( t = av_dict_get( av_opts, "", t, AV_DICT_IGNORE_SUFFIX ) ) ) + while ((t = av_dict_get(av_opts, "", t, AV_DICT_IGNORE_SUFFIX))) { - hb_log( "encavcodecaInit: Unknown avcodec option %s", t->key ); + hb_log("encavcodecaInit: Unknown avcodec option %s", t->key); } - av_dict_free( &av_opts ); + av_dict_free(&av_opts); // channel remapping pv->remap = hb_audio_remap_init(context->channel_layout, &hb_libav_chan_map, audio->config.in.channel_map); if (pv->remap == NULL) { - hb_log("encavcodecaInit: hb_audio_remap_init() failed"); + hb_error("encavcodecaInit: hb_audio_remap_init() failed"); } // sample_fmt conversion @@ -127,22 +129,22 @@ static int encavcodecaInit( hb_work_object_t * w, hb_job_t * job ) } pv->context = context; - - audio->config.out.samples_per_frame = pv->samples_per_frame = context->frame_size; + pv->samples_per_frame = context->frame_size; + audio->config.out.samples_per_frame = pv->samples_per_frame; pv->input_samples = pv->samples_per_frame * pv->out_discrete_channels; // Set a reasonable maximum output size - pv->output_bytes = context->frame_size * - av_get_bytes_per_sample(context->sample_fmt) * - context->channels; + pv->output_bytes = (context->channels * context->frame_size * + av_get_bytes_per_sample(context->sample_fmt)); - pv->buf = malloc( pv->input_samples * sizeof( float ) ); + pv->buf = malloc(pv->input_samples * sizeof(float)); pv->list = hb_list_init(); - if ( context->extradata ) + if (context->extradata) { - memcpy( w->config->extradata.bytes, context->extradata, context->extradata_size ); + memcpy(w->config->extradata.bytes, + context->extradata, context->extradata_size); w->config->extradata.length = context->extradata_size; } |