-http://download.m0k.org/handbrake/contrib/libmp4v2-r37.tar.gz
+http://download.m0k.org/handbrake/contrib/libmp4v2-r38.tar.gz
audiocfg->in.bitrate = -1;
audiocfg->in.samplerate = -1;
audiocfg->in.channel_layout = 0;
+ audiocfg->in.version = 0;
+ audiocfg->in.mode = 0;
audiocfg->flags.ac3 = 0;
audiocfg->lang.description[0] = 0;
audiocfg->lang.simple[0] = 0;
int track; /* Input track number */
PRIVATE uint32_t codec; /* Input audio codec */
PRIVATE uint32_t codec_param; /* per-codec config info */
+ PRIVATE uint32_t version; /* Bitsream version */
+ PRIVATE uint32_t mode; /* Bitstream mode, codec dependent encoding */
PRIVATE int samplerate; /* Input sample rate (Hz) */
PRIVATE int bitrate; /* Input bitrate (kbps) */
PRIVATE int channel_layout;
int rate;
int rate_base;
int flags;
+ int version;
+ int mode;
union {
struct { // info only valid for video decoders
int width;
int i;
int rate = 0, bitrate = 0, flags = 0;
int old_rate = 0, old_bitrate = 0;
+ uint8_t raw;
memset( info, 0, sizeof(*info) );
old_rate = rate;
old_bitrate = bitrate;
+ raw = b->data[i+5];
}
}
if ( rate == 0 || bitrate == 0 )
return 0;
}
+ /*
+ * bsid | bsmod | acmod | cmixlev | surmixlev | dsurmod | lfeon | dialnorm | compre
+ * 5 3 3 2 2 2 1 5 1
+ * [ byte1 ][ byte2 ][ byte3 ]
+ */
+
+
info->name = "AC-3";
info->rate = rate;
info->rate_base = 1;
info->bitrate = bitrate;
info->flags = flags;
+ info->version = raw >> 3; /* bsid is the first 5 bits */
+ info->mode = raw & 0x7; /* bsmod is the following 3 bits */
+
if ( (flags & A52_CHANNEL_MASK) == A52_DOLBY )
{
info->flags |= AUDIO_F_DOLBY;
Homepage: <http://handbrake.fr/>.
It may be used under the terms of the GNU General Public License. */
-/* libmp4v2 header */
#include "mp4v2/mp4v2.h"
+#include "a52dec/a52.h"
#include "hb.h"
if( audio->config.out.codec == HB_ACODEC_AC3 )
{
+ uint8_t fscod = 0;
+ uint8_t bsid = audio->config.in.version;
+ uint8_t bsmod = audio->config.in.mode;
+ uint8_t acmod = audio->config.flags.ac3 & 0x7;
+ uint8_t lfeon = (audio->config.flags.ac3 & A52_LFE) ? 1 : 0;
+ uint8_t bit_rate_code = 0;
+
+ /*
+ * Rewrite AC3 information into correct format for dac3 atom
+ */
+ switch( audio->config.in.samplerate )
+ {
+ case 48000:
+ fscod = 0;
+ break;
+ case 44100:
+ fscod = 1;
+ break;
+ case 32000:
+ fscod = 2;
+ break;
+ default:
+ /*
+ * Error value, tells decoder to not decode this audio.
+ */
+ fscod = 3;
+ break;
+ }
+
+ switch( audio->config.in.bitrate )
+ {
+ case 32000:
+ bit_rate_code = 0;
+ break;
+ case 40000:
+ bit_rate_code = 1;
+ break;
+ case 48000:
+ bit_rate_code = 2;
+ break;
+ case 56000:
+ bit_rate_code = 3;
+ break;
+ case 64000:
+ bit_rate_code = 4;
+ break;
+ case 80000:
+ bit_rate_code = 5;
+ break;
+ case 96000:
+ bit_rate_code = 6;
+ break;
+ case 112000:
+ bit_rate_code = 7;
+ break;
+ case 128000:
+ bit_rate_code = 8;
+ break;
+ case 160000:
+ bit_rate_code = 9;
+ break;
+ case 192000:
+ bit_rate_code = 10;
+ break;
+ case 224000:
+ bit_rate_code = 11;
+ break;
+ case 256000:
+ bit_rate_code = 12;
+ break;
+ case 320000:
+ bit_rate_code = 13;
+ break;
+ case 384000:
+ bit_rate_code = 14;
+ break;
+ case 448000:
+ bit_rate_code = 15;
+ break;
+ case 512000:
+ bit_rate_code = 16;
+ break;
+ case 576000:
+ bit_rate_code = 17;
+ break;
+ case 640000:
+ bit_rate_code = 18;
+ break;
+ default:
+ hb_error("Unknown AC3 bitrate");
+ bit_rate_code = 0;
+ break;
+ }
+
mux_data->track = MP4AddAC3AudioTrack(
m->file,
- m->samplerate, 1536, MP4_MPEG4_AUDIO_TYPE );
+ m->samplerate,
+ fscod,
+ bsid,
+ bsmod,
+ acmod,
+ lfeon,
+ bit_rate_code);
+
if (audio->config.out.name == NULL) {
MP4SetTrackBytesProperty(
m->file, mux_data->track,
audio->config.in.samplerate = info.rate;
audio->config.in.bitrate = info.bitrate;
audio->config.in.channel_layout = info.channel_layout;
+ audio->config.in.version = info.version;
+ audio->config.in.mode = info.mode;
audio->config.flags.ac3 = info.flags;
// update the audio description string based on the info we found