Skip to content

Commit

Permalink
fixed: wrong audio channel count if channel info is like "15 objects …
Browse files Browse the repository at this point in the history
…/ 6"
  • Loading branch information
DanCooper committed Feb 9, 2018
1 parent 0f9b806 commit f030b31
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
Expand Up @@ -14,6 +14,7 @@
<Item Name="atmos / truehd / ac-3">truehd_atmos</Item>
<Item Name="atmos / truehd">truehd_atmos</Item>
<Item Name="e-ac-3">eac3</Item>
<Item Name="e-ac-3+atmos">eac3_atmos</Item>
<Item Name="hra / core">dtshd_hra</Item>
<Item Name="ma / core">dtshd_ma</Item>
<Item Name="truehd / ac-3">truehd</Item>
Expand Down
47 changes: 23 additions & 24 deletions EmberAPI/clsAPIMediaInfo.vb
Expand Up @@ -438,6 +438,8 @@ Public Class MediaInfo
tCodec = sProfile
ElseIf sFormat.ToLower.Contains("atmos / truehd") Then
tCodec = sFormat
ElseIf sProfile.ToLower.Contains("e-ac-3+atmos") Then
tCodec = "e-ac-3+atmos"
ElseIf Not String.IsNullOrEmpty(sCodecID) AndAlso Not Integer.TryParse(sCodecID, 0) AndAlso Not sCodecID.ToLower.Contains("a_pcm") AndAlso Not sCodecID.Contains("00001000-0000-0100-8000-00AA00389B71") Then
tCodec = sCodecID
ElseIf Not String.IsNullOrEmpty(sCodecHint) Then
Expand Down Expand Up @@ -995,33 +997,30 @@ Public Class MediaInfo
''' <summary>
''' Convert string "x/y" to single digit number "x" (Audio Channel conversion)
''' </summary>
''' <param name="AudioChannelstring">The channelstring (as string) to clean</param>
''' <returns>cleaned Channelnumber, i.e "8/6" will return as 7 </returns>
''' <param name="channelinfo">The channelstring (as string) to clean</param>
''' <returns>cleaned Channelnumber, i.e "Object Based / 8 / 6" will return a 8 </returns>
''' <remarks>Inputstring "x/y" will return as "x" which is highest number, i.e 8/6 -> 8 (assume: highest number always first!)
''' 2014/01/22 Cocotus - Since this functionality is needed on several places in Ember, I builded new function to avoid duplicate code
'''</remarks>
Public Shared Function FormatAudioChannel(ByVal AudioChannelstring As String) As String
'cocotus 20130303 ChannelInfo fix
'Channel(s)/sNumber might contain: "8 / 6" (7.1) so we must handle backslash and spaces --> XBMC/Ember only supports Number like 2,6,8...
If AudioChannelstring.Contains("/") Then
Dim mystring As String = ""
'use regex to get rid of all letters(if that ever happens just in case) and also remove spaces
mystring = Text.RegularExpressions.Regex.Replace(AudioChannelstring, "[^/.0-9]", "").Trim
'now get channel number
If mystring.Length > 0 Then
' fix for new dolby atmos stream info i.e. "ObjectBased / 8 channels"
mystring = mystring.Replace("/", "")
If Char.IsDigit(mystring(0)) Then
Try
'In case of "x/y" this will return x which is highest number, i.e 8/6 -> 8 (highest number always first!)
AudioChannelstring = CStr(mystring(0))
Catch ex As Exception
End Try
End If
End If
Public Shared Function FormatAudioChannel(ByVal channelinfo As String) As String
'for channel information like "15 objects / 6"
'returns only the number of channels
Dim rMatch = Regex.Match(channelinfo.ToLower, "(\d+) objects \/? (\d+)")
If rMatch.Success Then
Return rMatch.Groups(2).Value
End If
'for channel information like "Object Based / 8 / 6" or "8 / 6" or "8"
'returns the highest number
Dim rMatches = Regex.Matches(channelinfo.ToLower, "\d+")
If rMatches.Count > 0 Then
Dim lstNumber As New List(Of Integer)
For i As Integer = 0 To rMatches.Count - 1
lstNumber.Add(CInt(rMatches(i).Value))
Next
lstNumber.Sort()
lstNumber.Reverse()
Return lstNumber(0).ToString
End If
Return AudioChannelstring
'cocotus end
Return channelinfo
End Function
''' <summary>
''' Converts "Yes" and "No" to boolean
Expand Down
Binary file modified EmberAPI/x64/MediaInfo.dll
Binary file not shown.
Binary file modified EmberAPI/x86/MediaInfo.dll
Binary file not shown.
3 changes: 3 additions & 0 deletions EmberMediaManager/EmberMediaManager.vbproj
Expand Up @@ -799,6 +799,9 @@
<Content Include="Images\Flags\acodec_eac3.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\Flags\acodec_eac3_atmos.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\Flags\acodec_pcm.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f030b31

Please sign in to comment.