summaryrefslogtreecommitdiffstats
path: root/libhb/common.h
diff options
context:
space:
mode:
authorsaintdev <[email protected]>2008-04-01 21:25:54 +0000
committersaintdev <[email protected]>2008-04-01 21:25:54 +0000
commit20b75da8e1662ec3dcf9d2077215bed74c67ac67 (patch)
tree68df07e0204c50c54e69a41ccdd6ab46eb025191 /libhb/common.h
parentb8111bf8aa06301b736f23f5fe053cfa2d473ba8 (diff)
New internal audio handling.
Each audio track contains it's own settings for codec, bitrate, samplerate, etc. This allows for very complex combinations of audio tracks if desired. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1365 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/common.h')
-rw-r--r--libhb/common.h214
1 files changed, 111 insertions, 103 deletions
diff --git a/libhb/common.h b/libhb/common.h
index 4758d9c8d..1eef164e6 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -39,6 +39,7 @@ typedef struct hb_job_s hb_job_t;
typedef struct hb_title_s hb_title_t;
typedef struct hb_chapter_s hb_chapter_t;
typedef struct hb_audio_s hb_audio_t;
+typedef struct hb_audio_config_s hb_audio_config_t;
typedef struct hb_subtitle_s hb_subtitle_t;
typedef struct hb_state_s hb_state_t;
typedef union hb_esconfig_u hb_esconfig_t;
@@ -53,6 +54,9 @@ typedef struct hb_lock_s hb_lock_t;
#include "ports.h"
#ifdef __LIBHB__
#include "internal.h"
+#define PRIVATE
+#else
+#define PRIVATE const
#endif
hb_list_t * hb_list_init();
@@ -70,6 +74,11 @@ void hb_fix_aspect( hb_job_t * job, int keep );
int hb_calc_bitrate( hb_job_t *, int size );
+hb_audio_t *hb_audio_copy(const hb_audio_t *src);
+void hb_audio_config_init(hb_audio_config_t * audiocfg);
+int hb_audio_add(const hb_job_t * job, const hb_audio_config_t * audiocfg);
+hb_audio_config_t * hb_list_audio_config_item(hb_list_t * list, int i);
+
struct hb_rate_s
{
char * string;
@@ -175,76 +184,8 @@ struct hb_job_s
int areBframes;
int vfr;
- /* Audio tracks:
- audios: Indexes in hb_title_t's audios list, starting from 0.
- -1 indicates the end of the list
- audio_mixdowns: The mixdown to be used for each audio track in audios[] */
-
-/* define some masks, used to extract the various information from the HB_AMIXDOWN_XXXX values */
-#define HB_AMIXDOWN_DCA_FORMAT_MASK 0x00FFF000
-#define HB_AMIXDOWN_A52_FORMAT_MASK 0x00000FF0
-#define HB_AMIXDOWN_DISCRETE_CHANNEL_COUNT_MASK 0x0000000F
-
-/* define the HB_AMIXDOWN_XXXX values */
-
-#define HB_AMIXDOWN_MONO 0x01000001
-// DCA_FORMAT of DCA_MONO = 0 = 0x000
-// A52_FORMAT of A52_MONO = 1 = 0x01
-// discrete channel count of 1
-
-#define HB_AMIXDOWN_STEREO 0x02002022
-// DCA_FORMAT of DCA_STEREO = 2 = 0x002
-// A52_FORMAT of A52_STEREO = 2 = 0x02
-// discrete channel count of 2
-
-#define HB_AMIXDOWN_DOLBY 0x042070A2
-// DCA_FORMAT of DCA_3F1R | DCA_OUT_DPLI = 519 = 0x207
-// A52_FORMAT of A52_DOLBY = 10 = 0x0A
-// discrete channel count of 2
-
-#define HB_AMIXDOWN_DOLBYPLII 0x084094A2
-// DCA_FORMAT of DCA_3F2R | DCA_OUT_DPLII = 1033 = 0x409
-// A52_FORMAT of A52_DOLBY | A52_USE_DPLII = 74 = 0x4A
-// discrete channel count of 2
-
-#define HB_AMIXDOWN_6CH 0x10089176
-// DCA_FORMAT of DCA_3F2R | DCA_LFE = 137 = 0x089
-// A52_FORMAT of A52_3F2R | A52_LFE = 23 = 0x17
-// discrete channel count of 6
-
-#define HB_AMIXDOWN_AC3 0x20000000
-
-#define HB_AMIXDOWN_DOLBYPLII_AC3 0x404094A2
-// DCA_FORMAT of DCA_3F2R | DCA_OUT_DPLII = 1033 = 0x409
-// A52_FORMAT of A52_DOLBY | A52_USE_DPLII = 74 = 0x4A
-// discrete channel count of 2
-
-/* define some macros to extract the various information from the HB_AMIXDOWN_XXXX values */
-#define HB_AMIXDOWN_GET_DCA_FORMAT( a ) ( ( a & HB_AMIXDOWN_DCA_FORMAT_MASK ) >> 12 )
-#define HB_AMIXDOWN_GET_A52_FORMAT( a ) ( ( a & HB_AMIXDOWN_A52_FORMAT_MASK ) >> 4 )
-#define HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT( a ) ( ( a & HB_AMIXDOWN_DISCRETE_CHANNEL_COUNT_MASK ) )
-
- int audios[8];
- int audio_mixdowns[8];
-
- /* Audio settings:
- acodec: output codec
- abitrate: output bitrate (kbps)
- arate: output samplerate (Hz)
- HB_ACODEC_AC3 means pass-through, then abitrate and arate are
- ignored */
-#define HB_ACODEC_MASK 0x00FF00
-#define HB_ACODEC_FAAC 0x000100
-#define HB_ACODEC_LAME 0x000200
-#define HB_ACODEC_VORBIS 0x000400
-#define HB_ACODEC_AC3 0x000800
-#define HB_ACODEC_MPGA 0x001000
-#define HB_ACODEC_LPCM 0x002000
-#define HB_ACODEC_DCA 0x004000
- int acodec;
- int abitrate;
- int arate;
- float dynamic_range_compression;
+ /* List of audio settings. */
+ hb_list_t * list_audio;
/* Subtitle settings:
subtitle: index in hb_title_t's subtitles list, starting
@@ -300,22 +241,49 @@ struct hb_job_s
#endif
};
-struct hb_audio_s
-{
- int id;
- char lang[1024];
- char lang_simple[1024];
- char iso639_2[4];
- int codec;
- int rate;
- int bitrate;
-
- /* ac3flags is only set when the source audio format is HB_ACODEC_AC3 */
- int ac3flags;
+/* Audio starts here */
+/* Audio Codecs */
+#define HB_ACODEC_MASK 0x00FF00
+#define HB_ACODEC_FAAC 0x000100
+#define HB_ACODEC_LAME 0x000200
+#define HB_ACODEC_VORBIS 0x000400
+#define HB_ACODEC_AC3 0x000800
+#define HB_ACODEC_MPGA 0x001000
+#define HB_ACODEC_LPCM 0x002000
+#define HB_ACODEC_DCA 0x004000
- /* dcaflags is only set when the source audio format is HB_ACODEC_DCA */
- int dcaflags;
+/* Audio Mixdown */
+/* define some masks, used to extract the various information from the HB_AMIXDOWN_XXXX values */
+#define HB_AMIXDOWN_DCA_FORMAT_MASK 0x00FFF000
+#define HB_AMIXDOWN_A52_FORMAT_MASK 0x00000FF0
+#define HB_AMIXDOWN_DISCRETE_CHANNEL_COUNT_MASK 0x0000000F
+/* define the HB_AMIXDOWN_XXXX values */
+#define HB_AMIXDOWN_MONO 0x01000001
+// DCA_FORMAT of DCA_MONO = 0 = 0x000
+// A52_FORMAT of A52_MONO = 1 = 0x01
+// discrete channel count of 1
+#define HB_AMIXDOWN_STEREO 0x02002022
+// DCA_FORMAT of DCA_STEREO = 2 = 0x002
+// A52_FORMAT of A52_STEREO = 2 = 0x02
+// discrete channel count of 2
+#define HB_AMIXDOWN_DOLBY 0x042070A2
+// DCA_FORMAT of DCA_3F1R | DCA_OUT_DPLI = 519 = 0x207
+// A52_FORMAT of A52_DOLBY = 10 = 0x0A
+// discrete channel count of 2
+#define HB_AMIXDOWN_DOLBYPLII 0x084094A2
+// DCA_FORMAT of DCA_3F2R | DCA_OUT_DPLII = 1033 = 0x409
+// A52_FORMAT of A52_DOLBY | A52_USE_DPLII = 74 = 0x4A
+// discrete channel count of 2
+#define HB_AMIXDOWN_6CH 0x10089176
+// DCA_FORMAT of DCA_3F2R | DCA_LFE = 137 = 0x089
+// A52_FORMAT of A52_3F2R | A52_LFE = 23 = 0x17
+// discrete channel count of 6
+/* define some macros to extract the various information from the HB_AMIXDOWN_XXXX values */
+#define HB_AMIXDOWN_GET_DCA_FORMAT( a ) ( ( a & HB_AMIXDOWN_DCA_FORMAT_MASK ) >> 12 )
+#define HB_AMIXDOWN_GET_A52_FORMAT( a ) ( ( a & HB_AMIXDOWN_A52_FORMAT_MASK ) >> 4 )
+#define HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT( a ) ( ( a & HB_AMIXDOWN_DISCRETE_CHANNEL_COUNT_MASK ) )
+/* Input Channel Layout */
/* define some masks, used to extract the various information from the HB_AMIXDOWN_XXXX values */
#define HB_INPUT_CH_LAYOUT_DISCRETE_FRONT_MASK 0x00F0000
#define HB_INPUT_CH_LAYOUT_DISCRETE_REAR_MASK 0x000F000
@@ -323,7 +291,6 @@ struct hb_audio_s
#define HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK 0xFFFF0FF
#define HB_INPUT_CH_LAYOUT_ENCODED_FRONT_MASK 0x00000F0
#define HB_INPUT_CH_LAYOUT_ENCODED_REAR_MASK 0x000000F
-
/* define the input channel layouts used to describe the channel layout of this audio */
#define HB_INPUT_CH_LAYOUT_MONO 0x0110010
#define HB_INPUT_CH_LAYOUT_STEREO 0x0220020
@@ -335,7 +302,6 @@ struct hb_audio_s
#define HB_INPUT_CH_LAYOUT_3F2R 0x0832032
#define HB_INPUT_CH_LAYOUT_4F2R 0x0942042
#define HB_INPUT_CH_LAYOUT_HAS_LFE 0x0000100
-
/* define some macros to extract the various information from the HB_AMIXDOWN_XXXX values */
#define HB_INPUT_CH_LAYOUT_GET_DISCRETE_FRONT_COUNT( a ) ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_FRONT_MASK ) >> 16 )
#define HB_INPUT_CH_LAYOUT_GET_DISCRETE_REAR_COUNT( a ) ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_REAR_MASK ) >> 12 )
@@ -344,24 +310,68 @@ struct hb_audio_s
#define HB_INPUT_CH_LAYOUT_GET_ENCODED_FRONT_COUNT( a ) ( ( a & HB_INPUT_CH_LAYOUT_ENCODED_FRONT_MASK ) >> 4 )
#define HB_INPUT_CH_LAYOUT_GET_ENCODED_REAR_COUNT( a ) ( ( a & HB_INPUT_CH_LAYOUT_ENCODED_REAR_MASK ) )
- /* input_channel_layout is the channel layout of this audio */
- /* this is used to provide a common way of describing the source audio */
- int input_channel_layout;
+struct hb_audio_config_s
+{
+ /* Output */
+ struct
+ {
+ int track; /* Output track number */
+ uint32_t codec; /* Output audio codec.
+ * HB_ACODEC_AC3 means pass-through, then bitrate and samplerate
+ * are ignored.
+ */
+ int samplerate; /* Output sample rate (Hz) */
+ int bitrate; /* Output bitrate (kbps) */
+ int mixdown; /* The mixdown format to be used for this audio track (see HB_AMIXDOWN_*) */
+ double dynamic_range_compression; /* Amount of DRC that gets applied to this track */
+ } out;
+
+ /* Input */
+ struct
+ {
+ int track; /* Input track number */
+ PRIVATE uint32_t codec; /* Input audio codec */
+ PRIVATE int samplerate; /* Input sample rate (Hz) */
+ PRIVATE int bitrate; /* Input bitrate (kbps) */
+ PRIVATE int channel_layout;
+ /* channel_layout is the channel layout of this audio this is used to
+ * provide a common way of describing the source audio
+ */
+ } in;
+
+ /* Misc. */
+ union
+ {
+ PRIVATE int ac3; /* flags.ac3 is only set when the source audio format is HB_ACODEC_AC3 */
+ PRIVATE int dca; /* flags.dca is only set when the source audio format is HB_ACODEC_DCA */
+ } flags;
+
+ struct
+ {
+ PRIVATE char description[1024];
+ PRIVATE char simple[1024];
+ PRIVATE char iso639_2[4];
+ } lang;
+};
#ifdef __LIBHB__
- /* Internal data */
- hb_fifo_t * fifo_in; /* AC3/MPEG/LPCM ES */
- hb_fifo_t * fifo_raw; /* Raw audio */
- hb_fifo_t * fifo_sync; /* Resampled, synced raw audio */
- hb_fifo_t * fifo_out; /* MP3/AAC/Vorbis ES */
+struct hb_audio_s
+{
+ int id;
- hb_esconfig_t config;
- hb_mux_data_t * mux_data;
+ hb_audio_config_t config;
- /* amixdown is the mixdown format to be used for this audio track */
- int amixdown;
-#endif
+ struct {
+ hb_fifo_t * fifo_in; /* AC3/MPEG/LPCM ES */
+ hb_fifo_t * fifo_raw; /* Raw audio */
+ hb_fifo_t * fifo_sync; /* Resampled, synced raw audio */
+ hb_fifo_t * fifo_out; /* MP3/AAC/Vorbis ES */
+
+ hb_esconfig_t config;
+ hb_mux_data_t * mux_data;
+ } priv;
};
+#endif
struct hb_chapter_s
{
@@ -506,10 +516,8 @@ struct hb_work_object_s
hb_fifo_t * fifo_out;
hb_esconfig_t * config;
- /* amixdown is the mixdown format to be used if the work object is an audio track */
- int amixdown;
- /* source_acodec is the source audio codec if the work object is an audio track */
- int source_acodec;
+ /* Pointer hb_audio_t so we have access to the info in the audio worker threads. */
+ hb_audio_t *audio;
hb_work_private_t * private_data;