Skip to content

Commit

Permalink
Merge pull request #2071 from dbry/master
Browse files Browse the repository at this point in the history
WavPack: various fixes for multichannel & DSD files
  • Loading branch information
JeromeMartinez committed Jun 13, 2024
2 parents 0e18545 + e5d27d8 commit 6fc649f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
33 changes: 27 additions & 6 deletions Source/MediaInfo/Audio/File_Wvpk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void File_Wvpk::Streams_Finish()
int64u BitDepth=dsf?1:(Wvpk_Resolution[(resolution1?1:0)*2+(resolution0?1:0)]);
int64u Duration=Samples*1000/SamplingRate;
int64u CompressedSize=File_Size-TagsSize;
int64u UncompressedSize=Duration*(mono?1:2)*BitDepth*(SamplingRate<<(3*dsf))/8/1000;
int64u UncompressedSize=Duration*(num_channels?num_channels:(mono?1:2))*BitDepth*(SamplingRate<<(3*dsf))/8/1000;
float32 CompressionRatio=((float32)UncompressedSize)/CompressedSize;
Fill(Stream_Audio, 0, Audio_StreamSize, CompressedSize, 3, true);
Fill(Stream_Audio, 0, Audio_Duration, Duration, 10, true);
Expand Down Expand Up @@ -585,8 +585,8 @@ void File_Wvpk::Data_Parse_Fill()
Fill(Stream_Audio, 0, Audio_Codec_Settings, Mode);
if (dsf)
{
Fill(Stream_Audio, 0, Audio_Format_Settings_Mode, "DSF");
Fill(Stream_Audio, 0, Audio_Format_Settings, "DSF");
Fill(Stream_Audio, 0, Audio_Format_Settings_Mode, "DSD");
Fill(Stream_Audio, 0, Audio_Format_Settings, "DSD");
}
if (correction)
Fill(Stream_Audio, 0, Audio_Format_AdditionalFeatures, "Correction");
Expand All @@ -613,7 +613,27 @@ void File_Wvpk::id_07()
void File_Wvpk::id_0D()
{
//Parsing
Get_L1 (num_channels, "num_channels");
if (Size > 7)
{
//No backward compatibility guaranteed, skipping all
Skip_XX(Size, "(Not parsed)");
return;
}
int8u num_chans_low8;
Get_L1 (num_chans_low8, "num_channels");
num_channels = num_chans_low8;
if (Size >= 6)
{
int8u num_chans_high4;
Skip_L1( "num_streams");
BS_Begin();
Skip_S1(4, "reserved");
Get_S1 (4, num_chans_high4, "num_channels (hi)");
BS_End();
num_channels |= (num_chans_high4 << 8);
num_channels++;
Param_Info2(num_channels, " channels");
}
switch (Size)
{
case 1 :
Expand All @@ -633,12 +653,12 @@ void File_Wvpk::id_0D()
}
break;
case 4 :
case 6 :
Get_L3 (channel_mask, "channel_mask");
break;
case 5 :
default:
Get_L4 (channel_mask, "channel_mask");
break;
default : Skip_XX(Size, "unknown");
}
}

Expand All @@ -650,6 +670,7 @@ void File_Wvpk::id_0E()
Get_L1 (Temp, "framerate multiplier");
if (Temp<31)
SamplingRate_Shift=Temp;
Skip_XX(Size-1, "(Not parsed)");
}

//---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Source/MediaInfo/Audio/File_Wvpk.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private :
bool dsf;
int8u SamplingRate_Index;
int8u SamplingRate_Shift;
int8u num_channels;
int16u num_channels;
int32u SamplingRate;
int32u channel_mask;
int32u Size;
Expand Down

0 comments on commit 6fc649f

Please sign in to comment.