Skip to content
This repository
Browse code

AE: handle EAC-3 substreams

  • Loading branch information...
commit 4f296f41d91ac767db3338582fcad1c014a075ad 1 parent 7a18169
Rainer Hochecker authored August 30, 2013
26  xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp
@@ -78,6 +78,7 @@ CAEStreamInfo::CAEStreamInfo() :
78 78
   m_dtsBlocks     (0),
79 79
   m_dtsPeriod     (0),
80 80
   m_fsize         (0),
  81
+  m_fsizeMain     (0),
81 82
   m_repeat        (0),
82 83
   m_substreams    (0),
83 84
   m_dataType      (STREAM_TYPE_NULL),
@@ -287,6 +288,12 @@ unsigned int CAEStreamInfo::SyncAC3(uint8_t *data, unsigned int size)
287 288
 {
288 289
   unsigned int skip = 0;
289 290
 
  291
+  // handle substreams
  292
+  if (m_fsizeMain)
  293
+  {
  294
+    data += m_fsizeMain;
  295
+  }
  296
+
290 297
   for (; size - skip > 7; ++skip, ++data)
291 298
   {
292 299
     /* search for an ac3 sync word */
@@ -335,7 +342,14 @@ unsigned int CAEStreamInfo::SyncAC3(uint8_t *data, unsigned int size)
335 342
       m_sampleRate = AC3FSCod[fscod];
336 343
 
337 344
       /* dont do extensive testing if we have not lost sync */
338  
-      if (m_dataType == STREAM_TYPE_AC3 && skip == 0)
  345
+      /* this may be the main stream of EAC3 */
  346
+      if (m_dataType == STREAM_TYPE_EAC3 && skip == 0)
  347
+      {
  348
+        m_fsizeMain = m_fsize;
  349
+        m_fsize = 0;
  350
+        return 0;
  351
+      }
  352
+      else if (m_dataType == STREAM_TYPE_AC3 && skip == 0)
339 353
         return 0;
340 354
 
341 355
       unsigned int crc_size;
@@ -390,6 +404,14 @@ unsigned int CAEStreamInfo::SyncAC3(uint8_t *data, unsigned int size)
390 404
       }
391 405
 
392 406
       m_fsize        = framesize << 1;
  407
+
  408
+      // concatenate substream to independent stream
  409
+      if (strmtyp == 1 && m_fsizeMain)
  410
+      {
  411
+        m_fsize += m_fsizeMain;
  412
+      }
  413
+      m_fsizeMain = 0;
  414
+
393 415
       m_repeat       = MAX_EAC3_BLOCKS / blocks;
394 416
 
395 417
       // sampling rate multiplied with number of channels must equal the value
@@ -407,6 +429,7 @@ unsigned int CAEStreamInfo::SyncAC3(uint8_t *data, unsigned int size)
407 429
       m_syncFunc       = &CAEStreamInfo::SyncAC3;
408 430
       m_dataType       = STREAM_TYPE_EAC3;
409 431
       m_packFunc       = &CAEPackIEC61937::PackEAC3;
  432
+      m_fsizeMain      = 0;
410 433
 
411 434
       CLog::Log(LOGINFO, "CAEStreamInfo::SyncAC3 - E-AC3 stream detected (%d channels, %dHz)", m_channels, m_sampleRate);
412 435
       return skip;
@@ -416,6 +439,7 @@ unsigned int CAEStreamInfo::SyncAC3(uint8_t *data, unsigned int size)
416 439
   /* if we get here, the entire packet is invalid and we have lost sync */
417 440
   CLog::Log(LOGINFO, "CAEStreamInfo::SyncAC3 - AC3 sync lost");
418 441
   m_hasSync = false;
  442
+  m_fsizeMain = 0;
419 443
   return skip;
420 444
 }
421 445
 
1  xbmc/cores/AudioEngine/Utils/AEStreamInfo.h
@@ -87,6 +87,7 @@ class CAEStreamInfo
87 87
   unsigned int              m_dtsBlocks;
88 88
   unsigned int              m_dtsPeriod;        /* used for dtsHD */
89 89
   unsigned int              m_fsize;
  90
+  unsigned int              m_fsizeMain;        /* used for EAC3 substreams */
90 91
   unsigned int              m_repeat;
91 92
   int                       m_substreams;       /* used for TrueHD  */
92 93
   AVCRC                     m_crcTrueHD[1024];  /* TrueHD crc table */

0 notes on commit 4f296f4

Please sign in to comment.
Something went wrong with that request. Please try again.