mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2025-01-01 15:56:59 +00:00
Improved the timecode calculation for MP3 tracks. If the source file contains the same timecode for consecutive packets then mkvmerge will extrapolate timecodes for all but the first packets in the sequence. Fix for bug 165.
This commit is contained in:
parent
3713fd72e4
commit
5b437cf369
@ -1,3 +1,8 @@
|
||||
2008-09-06 Moritz Bunkus <moritz@bunkus.org>
|
||||
|
||||
* mkvmerge: bug fix: improved the timecode calculation for MP3
|
||||
tracks read from MP4 files. Another part of the fix for bug 165.
|
||||
|
||||
2008-09-03 Moritz Bunkus <moritz@bunkus.org>
|
||||
|
||||
* mkvmerge: bug fix: mkvmerge honors the timecode offsets of all
|
||||
|
@ -35,7 +35,8 @@ mp3_packetizer_c::mp3_packetizer_c(generic_reader_c *_reader,
|
||||
bytes_skipped(0),
|
||||
samples_per_sec(_samples_per_sec), channels(_channels), spf(1152),
|
||||
byte_buffer(128 * 1024),
|
||||
codec_id_set(false), valid_headers_found(source_is_good) {
|
||||
codec_id_set(false), valid_headers_found(source_is_good),
|
||||
previous_timecode(-1), num_packets_with_same_timecode(0) {
|
||||
|
||||
set_track_type(track_audio);
|
||||
set_track_default_duration((int64_t)(1152000000000.0 / samples_per_sec));
|
||||
@ -164,7 +165,21 @@ mp3_packetizer_c::process(packet_cptr packet) {
|
||||
|
||||
byte_buffer.add(packet->data->get(), packet->data->get_size());
|
||||
while ((mp3_packet = get_mp3_packet(&mp3header)) != NULL) {
|
||||
int64_t new_timecode = -1 == packet->timecode ? (int64_t)(1000000000.0 * packetno * spf / samples_per_sec) : packet->timecode;
|
||||
int64_t new_timecode;
|
||||
if (-1 == packet->timecode)
|
||||
new_timecode = (int64_t)(1000000000.0 * packetno * spf / samples_per_sec);
|
||||
else {
|
||||
if ((-1 != previous_timecode) && (packet->timecode == previous_timecode)) {
|
||||
new_timecode = previous_timecode + num_packets_with_same_timecode * 1000000000ll * spf / samples_per_sec;
|
||||
++num_packets_with_same_timecode;
|
||||
} else {
|
||||
new_timecode = packet->timecode;
|
||||
num_packets_with_same_timecode = 0;
|
||||
}
|
||||
|
||||
previous_timecode = packet->timecode;
|
||||
}
|
||||
|
||||
add_packet(new packet_t(new memory_c(mp3_packet, mp3header.framesize, true), new_timecode, (int64_t)(1000000000.0 * spf / samples_per_sec)));
|
||||
packetno++;
|
||||
}
|
||||
|
@ -29,11 +29,10 @@ private:
|
||||
int samples_per_sec, channels, spf;
|
||||
byte_buffer_c byte_buffer;
|
||||
bool codec_id_set, valid_headers_found;
|
||||
int64_t previous_timecode, num_packets_with_same_timecode;
|
||||
|
||||
public:
|
||||
mp3_packetizer_c(generic_reader_c *_reader, int _samples_per_sec,
|
||||
int _channels, bool source_is_good, track_info_c &_ti)
|
||||
throw (error_c);
|
||||
mp3_packetizer_c(generic_reader_c *_reader, int _samples_per_sec, int _channels, bool source_is_good, track_info_c &_ti) throw (error_c);
|
||||
virtual ~mp3_packetizer_c();
|
||||
|
||||
virtual int process(packet_cptr packet);
|
||||
@ -42,8 +41,7 @@ public:
|
||||
virtual const char *get_format_name() {
|
||||
return "MP3";
|
||||
}
|
||||
virtual connection_result_e can_connect_to(generic_packetizer_c *src,
|
||||
string &error_message);
|
||||
virtual connection_result_e can_connect_to(generic_packetizer_c *src, string &error_message);
|
||||
|
||||
private:
|
||||
virtual unsigned char *get_mp3_packet(mp3_header_t *mp3header);
|
||||
|
Loading…
Reference in New Issue
Block a user