diff --git a/Source/CLI/Main.cpp b/Source/CLI/Main.cpp index 08439409..ed05bafb 100644 --- a/Source/CLI/Main.cpp +++ b/Source/CLI/Main.cpp @@ -465,6 +465,15 @@ int ParseFile_Uncompressed(parse_info& ParseInfo, size_t Files_Pos) Output.Streams.push_back(Stream); + // Pre-set frame_size so ffmpeg's enc_open() does not set it to nb_samples, + // which the FLAC encoder would reject as an invalid block size + // if the audio stream has fewer samples than FLAC's minimum block size (16). + if (ParseInfo.InputInfo.SampleCount > 0 && ParseInfo.InputInfo.SampleCount < 16) + { + if (Global.OutputOptions.find("frame_size") == Global.OutputOptions.end()) + Global.OutputOptions["frame_size"] = "16"; + } + if (Global.Actions[Action_Coherency]) { // Duration diff --git a/Source/Lib/Compressed/Matroska/Matroska.cpp b/Source/Lib/Compressed/Matroska/Matroska.cpp index e3772f9b..117acaa0 100644 --- a/Source/Lib/Compressed/Matroska/Matroska.cpp +++ b/Source/Lib/Compressed/Matroska/Matroska.cpp @@ -197,10 +197,15 @@ ELEMENT_VOID( 6, Segment_Attachments_AttachedFile_FileData_RawCookedTrack_ ELEMENT_END() ELEMENT_BEGIN(Segment_Cluster) +ELEMENT_CASE( 20, Segment_Cluster_BlockGroup) ELEMENT_VOID( 23, Segment_Cluster_SimpleBlock) ELEMENT_VOID( 67, Segment_Cluster_Timestamp) ELEMENT_END() +ELEMENT_BEGIN(Segment_Cluster_BlockGroup) +ELEMENT_VOID( 21, Segment_Cluster_BlockGroup_Block) +ELEMENT_END() + ELEMENT_BEGIN(Segment_Tracks) ELEMENT_CASE( 2E, Segment_Tracks_TrackEntry) ELEMENT_END() @@ -930,8 +935,26 @@ void matroska::Segment_Cluster() } } +//--------------------------------------------------------------------------- +void matroska::Segment_Cluster_BlockGroup() +{ + IsList = true; +} + +//--------------------------------------------------------------------------- +void matroska::Segment_Cluster_BlockGroup_Block() +{ + ProcessBlock(); +} + //--------------------------------------------------------------------------- void matroska::Segment_Cluster_SimpleBlock() +{ + ProcessBlock(); +} + +//--------------------------------------------------------------------------- +void matroska::ProcessBlock() { if (Levels[Level].Offset_End - Buffer_Offset > 4) { diff --git a/Source/Lib/Compressed/Matroska/Matroska.h b/Source/Lib/Compressed/Matroska/Matroska.h index c112b765..a16f5645 100644 --- a/Source/Lib/Compressed/Matroska/Matroska.h +++ b/Source/Lib/Compressed/Matroska/Matroska.h @@ -146,6 +146,8 @@ class matroska : public input_base MATROSKA_ELEMENT(Segment_Attachments_AttachedFile_FileData_RawCookedTrack_LibraryName); MATROSKA_ELEMENT(Segment_Attachments_AttachedFile_FileData_RawCookedTrack_LibraryVersion); MATROSKA_ELEMENT(Segment_Cluster); + MATROSKA_ELEMENT(Segment_Cluster_BlockGroup); + MATROSKA_ELEMENT(Segment_Cluster_BlockGroup_Block); MATROSKA_ELEMENT(Segment_Cluster_SimpleBlock); MATROSKA_ELEMENT(Segment_Cluster_Timestamp); MATROSKA_ELEMENT(Segment_Tracks); @@ -192,6 +194,7 @@ class matroska : public input_base int16_t Block_Timestamp; //Utils + void ProcessBlock(); void Uncompress(buffer& Buffer); void Segment_Attachments_AttachedFile_FileData_RawCookedxxx_yyy(reversibility::element Element, type Type); void StoreFromCurrentToEndOfElement(buffer& Output);