+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 } };
+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;
+ }
+ }
+}
+