diff --git a/ChangeLog b/ChangeLog index 2acfbcad6..5a861e26d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-02-15 Moritz Bunkus + + * mkvmerge: bug fix: The AC3 packetizer will re-derive the + sampling frequency and the number of channels from the + bitstream. This way obviously invalid information from the source + container like a sampling frequency of 0 Hz will be fixed. + 2014-02-05 Moritz Bunkus * mkvmerge: enhancements: AVI reader: audio chunks with obvious diff --git a/src/output/p_ac3.cpp b/src/output/p_ac3.cpp index 58839b0c0..d0a341c8b 100644 --- a/src/output/p_ac3.cpp +++ b/src/output/p_ac3.cpp @@ -163,17 +163,23 @@ ac3_packetizer_c::adjust_header_values(ac3::frame_c &ac3_header) { if (0 != m_packetno) return; - m_first_ac3_header = ac3_header; + if (m_first_ac3_header.m_sample_rate != ac3_header.m_sample_rate) + set_audio_sampling_freq((float)ac3_header.m_sample_rate); - if (m_first_ac3_header.is_eac3()) + if (m_first_ac3_header.m_channels != ac3_header.m_channels) + set_audio_channels(ac3_header.m_channels); + + if (ac3_header.is_eac3()) set_codec_id(MKV_A_EAC3); - if (1536 != m_first_ac3_header.m_samples) { - m_s2tc.set(1000000000ll * m_first_ac3_header.m_samples, m_first_ac3_header.m_sample_rate); + if ((1536 != ac3_header.m_samples) || (m_first_ac3_header.m_sample_rate != ac3_header.m_sample_rate)) { + m_s2tc.set(1000000000ll * ac3_header.m_samples, ac3_header.m_sample_rate); m_single_packet_duration = 1 * m_s2tc; set_track_default_duration(m_single_packet_duration); } + m_first_ac3_header = ac3_header; + rerender_track_headers(); } diff --git a/tests/results.txt b/tests/results.txt index f58d13e01..751be760c 100644 --- a/tests/results.txt +++ b/tests/results.txt @@ -122,7 +122,7 @@ T_273pgssup:5221af5f55b59427f095737dfa70e12d-5221af5f55b59427f095737dfa70e12d-db T_274h264_in_nalus_in_avi:95df132ed351cb715432aeca9b9f7f94:passed:20100629-090725:0.046335705 T_275srt_mixed_eol_styles:44c2aeed77f2d4b506461f3c469770ab:passed:20100706-090848:0.206637187 T_276h264_without_nalus_in_avi:6d9df8a7261d5964c1e331c1a05f87bb:passed:20100706-224102:0.331406412 -T_277display_dimensions_fixing_aspect_ratio_usage:73cc005a16e9e10ccf0a35a7e5dbbfc8-782d35c5cf1d29e553aa874522490bc7-c981cff9e12162dd270f94727296f7cd:passed:20100718-201627:2.064719998 +T_277display_dimensions_fixing_aspect_ratio_usage:73cc005a16e9e10ccf0a35a7e5dbbfc8-782d35c5cf1d29e553aa874522490bc7-c981cff9e12162dd270f94727296f7cd:failed:20100718-201627:2.064719998 T_278turning_off_compression:a8a5753017e1b72afe45f08537dbed07-a8a5753017e1b72afe45f08537dbed07:passed:20100728-121842:0.662304078 T_279packet_queue_not_empty_ivf:00ca3f89058edd776e06a215ad00c81e:passed:20100805-230439:0.107456716 T_280replace_one_byte_with_ebmlvoid:9cfa2af2712e48f43f35497f4e9bec24:passed:20100824-201249:0.21509374 @@ -267,3 +267,4 @@ T_418ac3_frame_size_0:24f130019cb8781abe644d742c81487a:passed:20131230-233047:4. T_419mov_pcm_sample_size_1_sample_table_empty:e8eed0fe262c9acdf877c011cb96e788:passed:20140101-221519:0.052961521 T_420matroska_attachment_no_fileuid:e4bdf15fe633ad37e6b7860bbb8f7a67-552b6bfab098f531c54131dfc76eadaa-6fe0517dd519d6adf37c0769354b8ed6:passed:20140111-200918:0.092631489 T_421svq3_from_mov:4947c2a51a12097cf2b3d002eff2e9df:passed:20140112-124559:0.195365669 +T_422ac3_rederive_track_parameters_from_bitstream:7cf40379f451c604c8b6fce1f66b52b3:passed:20140215-162358:0.231506136 diff --git a/tests/test-422ac3_rederive_track_parameters_from_bitstream.rb b/tests/test-422ac3_rederive_track_parameters_from_bitstream.rb new file mode 100755 index 000000000..2d1f3c97a --- /dev/null +++ b/tests/test-422ac3_rederive_track_parameters_from_bitstream.rb @@ -0,0 +1,5 @@ +#!/usr/bin/ruby -w + +# T_422ac3_rederive_track_parameters_from_bitstream +describe "mkvmerge / AC3: re-derive track parameters from the bitstream" +test_merge "data/ac3/wrong-sampling-frequency-in-header.mkv", :args => "--no-video"