{ { "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 } };
+ { "256", 256 }, { "320", 320 }, { "384", 384 } };
int hb_audio_bitrates_count = sizeof( hb_audio_bitrates ) /
sizeof( hb_rate_t );
int hb_audio_bitrates_default = 8; /* 128 kbps */
+static hb_error_handler_t *error_handler = NULL;
+
+hb_mixdown_t hb_audio_mixdowns[] =
+{ { "Mono", "HB_AMIXDOWN_MONO", "mono", HB_AMIXDOWN_MONO },
+ { "Stereo", "HB_AMIXDOWN_STEREO", "stereo", HB_AMIXDOWN_STEREO },
+ { "Dolby Surround", "HB_AMIXDOWN_DOLBY", "dpl1", HB_AMIXDOWN_DOLBY },
+ { "Dolby Pro Logic II", "HB_AMIXDOWN_DOLBYPLII", "dpl2", HB_AMIXDOWN_DOLBYPLII },
+ { "6-channel discrete", "HB_AMIXDOWN_6CH", "6ch", HB_AMIXDOWN_6CH },
+ { "AC-3 Pass-through", "HB_AMIXDOWN_AC3", "ac-3", HB_AMIXDOWN_AC3 },
+ { "Dolby PLII + AC-3", "HB_AMIXDOWN_DOLBYPLII_AC3", "dpl2+ac3", HB_AMIXDOWN_DOLBYPLII_AC3 },
+};
+int hb_audio_mixdowns_count = sizeof( hb_audio_mixdowns ) /
+ sizeof( hb_mixdown_t );
+
+int hb_mixdown_get_mixdown_from_short_name( const char * short_name )
+{
+ int i;
+ for (i = 0; i < hb_audio_mixdowns_count; i++)
+ {
+ if (strcmp(hb_audio_mixdowns[i].short_name, short_name) == 0)
+ {
+ return hb_audio_mixdowns[i].amixdown;
+ }
+ }
+ return 0;
+}
+
+const char * hb_mixdown_get_short_name_from_mixdown( int amixdown )
+{
+ int i;
+ for (i = 0; i < hb_audio_mixdowns_count; i++)
+ {
+ if (hb_audio_mixdowns[i].amixdown == amixdown)
+ {
+ return hb_audio_mixdowns[i].short_name;
+ }
+ }
+ return "";
+}
+
+/**********************************************************************
+ * hb_reduce
+ **********************************************************************
+ * Given a numerator (num) and a denominator (den), reduce them to an
+ * equivalent fraction and store the result in x and y.
+ *********************************************************************/
+void hb_reduce( int *x, int *y, int num, int den )
+{
+ int lower = MIN( num, den );
+ int i;
+ *x = num;
+ *y = den;
+ for( i = lower - 1; i > 1; --i )
+ {
+ if( ( num % i == 0 ) && ( den % i == 0 ) )
+ {
+ *x = num / i;
+ *y = den / i;
+ break;
+ }
+ }
+}
+
/**********************************************************************
* hb_fix_aspect
**********************************************************************
case HB_MUX_MP4:
case HB_MUX_PSP:
case HB_MUX_IPOD:
+ case HB_MUX_MKV:
overhead = 6;
break;
case HB_MUX_AVI:
{
/* Audio data */
int abitrate;
- if( job->acodec & HB_ACODEC_AC3 )
+ if( job->acodec & HB_ACODEC_AC3 ||
+ job->audio_mixdowns[i] == HB_AMIXDOWN_AC3)
{
+ /*
+ * For AC-3 we take the bitrate from the input audio
+ * bitrate as we are simply passing it through.
+ */
audio = hb_list_item( title->list_audio, job->audios[i] );
abitrate = audio->bitrate / 8;
}
else
{
+ /*
+ * Where we are transcoding the audio we use the destination
+ * bitrate.
+ */
abitrate = job->abitrate * 1000 / 8;
}
avail -= length * abitrate;
* in that buffer.
*********************************************************************/
void hb_list_getbytes( hb_list_t * l, uint8_t * dst, int size,
- uint64_t * pts, int * pos )
+ uint64_t * pts, uint64_t * pos )
{
hb_buffer_t * buf;
int copied;
uint8_t has_pts;
/* So we won't have to deal with NULL pointers */
- uint64_t dummy1;
- int dummy2;
+ uint64_t dummy1, dummy2;
+
if( !pts ) pts = &dummy1;
if( !pos ) pos = &dummy2;
* hb_log
**********************************************************************
* If verbose mode is one, print message with timestamp. Messages
- * longer than 80 characters are stripped ;p
+ * longer than 180 characters are stripped ;p
*********************************************************************/
void hb_log( char * log, ... )
{
- char string[82]; /* 80 chars + \n + \0 */
+ char string[362]; /* 360 chars + \n + \0 */
time_t _now;
struct tm * now;
va_list args;
/* Convert the message to a string */
va_start( args, log );
- vsnprintf( string + 11, 69, log, args );
+ vsnprintf( string + 11, 169, log, args );
va_end( args );
/* Add the end of line */
}
/**********************************************************************
+ * hb_error
+ **********************************************************************
+ * Using whatever output is available display this error.
+ *********************************************************************/
+void hb_error( char * log, ... )
+{
+ char string[181]; /* 180 chars + \0 */
+ va_list args;
+
+ /* Convert the message to a string */
+ va_start( args, log );
+ vsnprintf( string, 180, log, args );
+ va_end( args );
+
+ /*
+ * Got the error in a single string, send it off to be dispatched.
+ */
+ if( error_handler )
+ {
+ error_handler( string );
+ } else {
+ hb_log( string );
+ }
+}
+
+void hb_register_error_handler( hb_error_handler_t * handler )
+{
+ error_handler = handler;
+}
+
+/**********************************************************************
* hb_title_init
**********************************************************************
*
void hb_title_close( hb_title_t ** _t )
{
hb_title_t * t = *_t;
+ hb_audio_t * audio;
+ hb_chapter_t * chapter;
+ hb_subtitle_t * subtitle;
+ while( ( audio = hb_list_item( t->list_audio, 0 ) ) )
+ {
+ hb_list_rem( t->list_audio, audio );
+ free( audio );
+ }
hb_list_close( &t->list_audio );
+
+ while( ( chapter = hb_list_item( t->list_chapter, 0 ) ) )
+ {
+ hb_list_rem( t->list_chapter, chapter );
+ free( chapter );
+ }
hb_list_close( &t->list_chapter );
+
+ while( ( subtitle = hb_list_item( t->list_subtitle, 0 ) ) )
+ {
+ hb_list_rem( t->list_subtitle, subtitle );
+ free( subtitle );
+ }
hb_list_close( &t->list_subtitle );
- free( t->job );
free( t );
*_t = NULL;
}
+/**********************************************************************
+ * hb_filter_close
+ **********************************************************************
+ *
+ *********************************************************************/
+void hb_filter_close( hb_filter_object_t ** _f )
+{
+ hb_filter_object_t * f = *_f;
+
+ f->close( f->private_data );
+
+ if( f->name )
+ free( f->name );
+ if( f->settings )
+ free( f->settings );
+
+ free( f );
+ *_f = NULL;
+}
+