#include <sys/time.h>
#include "common.h"
+#include "lang.h"
+#include "hb.h"
/**********************************************************************
* Global variables
{ { "32", 32 }, { "40", 40 }, { "48", 48 }, { "56", 56 },
{ "64", 64 }, { "80", 80 }, { "96", 96 }, { "112", 112 },
{ "128", 128 }, { "160", 160 }, { "192", 192 }, { "224", 224 },
- { "256", 256 }, { "320", 320 }, { "384", 384 } };
+ { "256", 256 }, { "320", 320 }, { "384", 384 }, { "448", 448 },
+ { "768", 768 } };
int hb_audio_bitrates_count = sizeof( hb_audio_bitrates ) /
sizeof( hb_rate_t );
int hb_audio_bitrates_default = 8; /* 128 kbps */
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 */
switch( audio->config.out.codec )
{
case HB_ACODEC_FAAC:
+ case HB_ACODEC_CA_AAC:
case HB_ACODEC_VORBIS:
samples_per_frame = 1024;
break;
samples_per_frame = 1152;
break;
case HB_ACODEC_AC3:
+ case HB_ACODEC_DCA:
samples_per_frame = 1536;
break;
default:
avail -= length * audio->config.out.samplerate * overhead / samples_per_frame;
}
+ret:
if( avail < 0 )
{
return 0;
}
hb_list_close( &t->list_subtitle );
+ if( t->metadata )
+ {
+ if( t->metadata->coverart )
+ {
+ free( t->metadata->coverart );
+ }
+ free( t->metadata );
+ }
+
free( t );
*_t = NULL;
}
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->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;
+}