X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=libhb%2Fcommon.c;h=52ea27f66bdb6ab5707685d1538cc472ddea49d1;hb=033e32de9c380f54c7d1362a3979da205ebc3a29;hp=c8e4e07b01ee6f217a7bc9f37700ce2fead668d4;hpb=d7053a9ae8ba3bb23eea90220ad3231d2a5e45fe;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/libhb/common.c b/libhb/common.c index c8e4e07b..52ea27f6 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -9,6 +9,8 @@ #include #include "common.h" +#include "lang.h" +#include "hb.h" /********************************************************************** * Global variables @@ -122,8 +124,8 @@ void hb_fix_aspect( hb_job_t * job, int keep ) if ( title->height == 0 || title->width == 0 || title->aspect == 0 ) { hb_log( "hb_fix_aspect: incomplete info for title %d: " - "height = %d, width = %d, aspect = %d", - title->height, title->width, title->aspect ); + "height = %d, width = %d, aspect = %.3f", + title->index, title->height, title->width, title->aspect ); return; } @@ -215,9 +217,21 @@ int hb_calc_bitrate( hb_job_t * job, int size ) length += 135000; length /= 90000; + if( size == -1 ) + { + hb_interjob_t * interjob = hb_interjob_get( job->h ); + avail = job->vbitrate * 125 * length; + avail += length * interjob->vrate * overhead / interjob->vrate_base; + } + /* Video overhead */ avail -= length * job->vrate * overhead / job->vrate_base; + if( size == -1 ) + { + goto ret; + } + for( i = 0; i < hb_list_count(job->list_audio); i++ ) { /* Audio data */ @@ -266,6 +280,7 @@ int hb_calc_bitrate( hb_job_t * job, int size ) avail -= length * audio->config.out.samplerate * overhead / samples_per_frame; } +ret: if( avail < 0 ) { return 0; @@ -816,3 +831,72 @@ hb_audio_config_t * hb_list_audio_config_item(hb_list_t * list, int i) return NULL; } + +/********************************************************************** + * hb_subtitle_copy + ********************************************************************** + * + *********************************************************************/ +hb_subtitle_t *hb_subtitle_copy(const hb_subtitle_t *src) +{ + hb_subtitle_t *subtitle = NULL; + + if( src ) + { + subtitle = calloc(1, sizeof(*subtitle)); + memcpy(subtitle, src, sizeof(*subtitle)); + } + return subtitle; +} + +/********************************************************************** + * hb_subtitle_add + ********************************************************************** + * + *********************************************************************/ +int hb_subtitle_add(const hb_job_t * job, const hb_subtitle_config_t * subtitlecfg, int track) +{ + hb_title_t *title = job->title; + hb_subtitle_t *subtitle; + + subtitle = hb_subtitle_copy( hb_list_item( title->list_subtitle, track ) ); + if( subtitle == NULL ) + { + /* We fail! */ + return 0; + } + subtitle->config = *subtitlecfg; + hb_list_add(job->list_subtitle, subtitle); + return 1; +} + +int hb_srt_add( const hb_job_t * job, + const hb_subtitle_config_t * subtitlecfg, + const char *lang ) +{ + hb_subtitle_t *subtitle; + iso639_lang_t *language = NULL; + int retval = 0; + + subtitle = calloc( 1, sizeof( *subtitle ) ); + + subtitle->id = (hb_list_count(job->list_subtitle) << 8) | 0xFF; + subtitle->format = TEXTSUB; + subtitle->source = SRTSUB; + + language = lang_for_code2( lang ); + + if( language ) + { + + strcpy( subtitle->lang, language->eng_name ); + strncpy( subtitle->iso639_2, lang, 4 ); + + subtitle->config = *subtitlecfg; + subtitle->config.dest = PASSTHRUSUB; + + hb_list_add(job->list_subtitle, subtitle); + retval = 1; + } + return retval; +}