From 8afad6d5743d274e7f3cc741c89d13d41bcdfee1 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Wed, 10 Oct 2018 15:05:36 +0200 Subject: [PATCH] Added DTS audio support to EBML input/output --- src/input/input_ebml.cpp | 17 +++++++++++++++++ src/output/output_ebml.cpp | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/input/input_ebml.cpp b/src/input/input_ebml.cpp index 2e430074..ae5fe267 100644 --- a/src/input/input_ebml.cpp +++ b/src/input/input_ebml.cpp @@ -35,6 +35,7 @@ namespace Mist{ capa["codecs"].append("MP3"); capa["codecs"].append("AC3"); capa["codecs"].append("FLOAT"); + capa["codecs"].append("DTS"); capa["codecs"].append("JSON"); capa["codecs"].append("subtitle"); lastClusterBPos = 0; @@ -235,6 +236,10 @@ namespace Mist{ tmpElem = E.findChild(EBML::EID_CODECPRIVATE); if (tmpElem){init = tmpElem.getValStringUntrimmed();} } + if (codec == "A_DTS"){ + trueCodec = "DTS"; + trueType = "audio"; + } if (codec == "A_PCM/INT/BIG"){ trueCodec = "PCM"; trueType = "audio"; @@ -365,6 +370,12 @@ namespace Mist{ newTime += (1000000 / Trk.rate)/timeScale;//assume ~1000 samples per frame } else if (Trk.codec == "MP3"){ newTime += (1152000 / Trk.rate)/timeScale;//1152 samples per frame + } else if (Trk.codec == "DTS"){ + //Assume 512 samples per frame (DVD default) + //actual amount can be calculated from data, but data + //is not available during header generation... + //See: http://www.stnsoft.com/DVD/dtshdr.html + newTime += (512000 / Trk.rate)/timeScale; }else{ newTime += 1/timeScale; ERROR_MSG("Unknown frame duration for codec %s - timestamps WILL be wrong!", Trk.codec.c_str()); @@ -531,6 +542,12 @@ namespace Mist{ newTime += (1000000 / Trk.rate)/timeScale;//assume ~1000 samples per frame } else if (Trk.codec == "MP3"){ newTime += (1152000 / Trk.rate)/timeScale;//1152 samples per frame + } else if (Trk.codec == "DTS"){ + //Assume 512 samples per frame (DVD default) + //actual amount can be calculated from data, but data + //is not available during header generation... + //See: http://www.stnsoft.com/DVD/dtshdr.html + newTime += (512000 / Trk.rate)/timeScale; }else{ ERROR_MSG("Unknown frame duration for codec %s - timestamps WILL be wrong!", Trk.codec.c_str()); } diff --git a/src/output/output_ebml.cpp b/src/output/output_ebml.cpp index e353202a..4ea52ac4 100644 --- a/src/output/output_ebml.cpp +++ b/src/output/output_ebml.cpp @@ -39,6 +39,7 @@ namespace Mist{ capa["codecs"][0u][1u].append("MP3"); capa["codecs"][0u][1u].append("FLOAT"); capa["codecs"][0u][1u].append("AC3"); + capa["codecs"][0u][1u].append("DTS"); capa["codecs"][0u][2u].append("+JSON"); capa["methods"][0u]["handler"] = "http"; capa["methods"][0u]["type"] = "html5/video/webm"; @@ -58,6 +59,7 @@ namespace Mist{ capa["exceptions"]["codec:MP3"] = blacklistNonChrome; capa["exceptions"]["codec:FLOAT"] = blacklistNonChrome; capa["exceptions"]["codec:AC3"] = blacklistNonChrome; + capa["exceptions"]["codec:DTS"] = blacklistNonChrome; } /// Calculates the size of a Cluster (contents only) and returns it. @@ -134,6 +136,7 @@ namespace Mist{ if (Trk.codec == "ALAW"){return "A_MS/ACM";} if (Trk.codec == "ULAW"){return "A_MS/ACM";} if (Trk.codec == "FLOAT"){return "A_PCM/FLOAT/IEEE";} + if (Trk.codec == "DTS"){return "A_DTS";} if (Trk.codec == "JSON"){return "M_JSON";} return "E_UNKNOWN"; }