[Rejected] TSReader.ax fix: better AAC-LATM compatibility (SBTVD) (1 Viewer)

DucaSP

Portal Member
May 26, 2009
16
5
Home Country
Brazil Brazil
Hi Guys,

Basically this is a simple path that will allow you to use other AAC-LATM compatible filters than monogram (i.e.: libfaddwrapper, elecard) and have it working with AAC-LATM audio streams from ISDB-Tb / SBTVD as well.

It changes the header of the audio stream for AAC-LATM streams, without this change, any filter/codec will just play about one second of audio and then stop.

Several people have been testing this change in Brazil succesfuly, and I've also tried playing back a few New Zealand .TS files to make sure that it did not break compatibility with New Zealand AAC-LATM streams, and the audio played back just fine.

This patch was made upon SVN code revision 24337. Most of the idea/work was done by Sergio Fortier and I've just made some minor tweaks/fixes upon his original work/idea.

Attached is the diff file, and also, a compiled TSReader.ax that can be used with the latest SVN build that contains this small change.
 

Attachments

  • AAC LATM Fix for SBTVD.diff
    30.7 KB

morpheus_xx

Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,070
    7,459
    Home Country
    Germany Germany
    I tried your binary reader, but got bad results:

    before: clip played, 1 sec sound then silence.
    after: clip didn't play, also no sound

    tsreader.log looks like:
    Code:
    05-12-2009 12:02:48.438 [f10]-------------- v1.0.8 ----------------
    05-12-2009 12:02:48.439 [f10]CTsReaderFilter::ctor
    05-12-2009 12:02:48.439 [f10]CRTSPClient::Initialize()
    05-12-2009 12:02:48.439 [f10]CRTSPClient::createClient()
    05-12-2009 12:02:48.440 [f10]Slow motion video allowed during zapping
    05-12-2009 12:02:48.440 [f10]Wait for seeking to eof 0
    05-12-2009 12:02:48.440 [f10]SetRelaxedMode
    05-12-2009 12:02:48.440 [f10]Normal discontinuities filtering
    05-12-2009 12:02:48.440 [f10]CALLBACK SET
    05-12-2009 12:02:48.441 [f10]SetRequestAudioChangeCallback SET
    05-12-2009 12:02:48.441 [f10]CTsReaderFilter::Load()
    05-12-2009 12:02:48.442 [f10]OnNewChannel pat version:-1->7
    05-12-2009 12:02:48.442 [f10]demux:flushing
    05-12-2009 12:02:48.442 [f10]demux:set hold audio:1
    05-12-2009 12:02:48.442 [f10]demux:set hold video:1
    05-12-2009 12:02:48.442 [f10]demux:set hold subtitle:1
    05-12-2009 12:02:48.443 [f10]demux:flush audio
    05-12-2009 12:02:48.443 [f10]demux:flush video
    05-12-2009 12:02:48.443 [f10]demux:flush subtitle
    05-12-2009 12:02:48.443 [f10]demux:set hold audio:0
    05-12-2009 12:02:48.443 [f10]demux:set hold video:0
    05-12-2009 12:02:48.443 [f10]demux:set hold subtitle:0
    05-12-2009 12:02:48.444 [f10]New channel found (PAT/PMT/SDT changed)
    05-12-2009 12:02:48.444 [f10] pcr      pid:  300 
    05-12-2009 12:02:48.444 [f10] pmt      pid:  101 
    05-12-2009 12:02:48.444 [f10] video    pid:  111 type: H264
    05-12-2009 12:02:48.444 [f10] audio    pid:  112 language: UNK type: LATM AAC
    05-12-2009 12:02:48.444 [f10] audio    pid:  113 language: UNK type: LATM AAC
    05-12-2009 12:02:48.445 [f10]Setting initial audio index to : 0
    05-12-2009 12:02:48.445 [f10]OnRequestAudioChange()
    05-12-2009 12:02:48.469 [f10]DeMultiplexer: 111 video format changed: res=1920x1080 aspectRatio=16:9 fps=30 isInterlaced=0
    05-12-2009 12:02:48.469 [f10]DeMultiplexer: triggering OnVideoFormatChanged
    05-12-2009 12:02:48.471 [f10]demux:flushing
    05-12-2009 12:02:48.471 [f10]demux:set hold audio:1
    05-12-2009 12:02:48.471 [f10]demux:set hold video:1
    05-12-2009 12:02:48.471 [f10]demux:set hold subtitle:1
    05-12-2009 12:02:48.471 [f10]demux:flush audio
    05-12-2009 12:02:48.471 [f10]demux:flush video
    05-12-2009 12:02:48.472 [f10]demux:flush subtitle
    05-12-2009 12:02:48.472 [f10]demux:set hold audio:0
    05-12-2009 12:02:48.472 [f10]demux:set hold video:0
    05-12-2009 12:02:48.472 [f10]demux:set hold subtitle:0
    05-12-2009 12:02:48.472 [f10]start:798bae4c end:79a8046a 20.632000
    05-12-2009 12:02:48.475 [f10]filt:IID_IStreamBufferSource()
    05-12-2009 12:02:48.476 [f10]vid:CompleteConnect()
    05-12-2009 12:02:48.476 [f10]vid:CompleteConnect() done
    05-12-2009 12:02:48.476 [f10]vid:CompleteConnect() ok
    05-12-2009 12:02:48.547 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.547 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.548 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.548 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.548 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.548 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.548 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.548 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.548 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.548 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.549 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.549 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.549 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.549 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.549 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.549 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.550 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.550 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.550 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.550 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.550 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.550 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.550 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.550 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.550 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.551 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.551 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.551 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.551 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.551 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.551 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.551 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.551 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.551 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.552 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.552 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.552 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.552 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.552 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.552 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.552 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.552 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.552 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.552 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.553 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.553 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.553 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.553 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.553 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.553 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.554 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.554 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.554 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.554 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.554 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.554 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.554 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.555 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.555 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.555 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.555 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.555 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.555 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.555 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.556 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.556 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.556 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.557 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.557 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.557 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.557 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.558 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.559 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.559 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.559 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.559 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.560 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.560 [f10]sub:BreakConnect() ok
    05-12-2009 12:02:48.619 [f10]CTsReaderFilter::Pause() 0 0
    05-12-2009 12:02:48.620 [f10]Clock : 104171711
    05-12-2009 12:02:48.620 [c90]demux:set hold video:0
    05-12-2009 12:02:48.620 [c90]Wait for seeking to eof 0
    05-12-2009 12:02:48.620 [f10]CTsReaderFilter::Pause() - END - state = 1
    05-12-2009 12:02:48.620 [c90]vid:OnThreadStartPlay(0.000000) 1.00 0
    05-12-2009 12:02:48.621 [f10]filt:IID_IMediaSeeking()
    05-12-2009 12:02:48.621 [690]CTsReaderFilter::ThreadProc start()
    05-12-2009 12:02:48.687 [f10]vid seek to 11.000000
    05-12-2009 12:02:48.688 [f10]demux:set hold video:1
    05-12-2009 12:02:48.688 [f10]CTsReaderFilter::--SeekStart()--
    05-12-2009 12:02:48.713 [f10]CTsReaderFilter::Seek-- LiveTv : 0, TimeShifting : 0
    05-12-2009 12:02:48.713 [f10]Wait for seeking to eof 1
    05-12-2009 12:02:48.713 [f10]CTsReaderFilter::  Seek-> 11.000000/20.632000 (1)
    05-12-2009 12:02:48.713 [f10]seek to 11.000000 filepos:14fb14c pid:300
    05-12-2009 12:02:48.714 [f10] got 11.041016 at filepos 150a3a4 diff 0.041016 ( 0, 275a3f8 )
    05-12-2009 12:02:48.714 [f10] stop seek: 11.041016 at 150a3a4 - target: 11.000000, diff: 0.041016
    05-12-2009 12:02:48.716 [f10]CTsReaderFilter::--SeekDone()
    05-12-2009 12:02:48.716 [f10]vid seek done 1  --- 1
     

    DucaSP

    Portal Member
    May 26, 2009
    16
    5
    Home Country
    Brazil Brazil
    Hi Morpheus,

    The idea of this fix is to use either Elecard or Libfaddwrapper as AAC Decoder, altough Monogram works for me (Windows 7 32 bits, installed 1.1 beta and then SVN24102) I know that for other systems it doesn't work decoding LATM ACC-HE with explicity SBR signaling as is used in Brazil even with this fix. This fix basically tells the decoder properly about the AAC audio as LATM AAC, since the original tsreader tells that the format is the same as AAC (uses AACAudioFormat which is not proper for LATM AAC audio, monogram doesn't care about it but other filters does and they won't work unless you have the right format).

    I'm checking with the developer of libfaadwrapper whether it can be distributed freely or not, it is a filter that "wraps" around libfaad2.dll that is part of FFDShow and works very well with LATM AAC-HE with explict SBR signaling, it is a nice free option, libfaadwrapper is open source altough the binaries of it are within a private section of DVBViewer home page only for DVBViewer owners, so, I'm just checking with its (libfaadwrapper developer) if it is ok to compile it by myself and distribute it or not.

    I've tested some samples from New Zealand like this one:

    MEGAUPLOAD - The leading online storage and file delivery service

    And they worked fine in my system, using either monogram or libfaad2wrapper. Can you test in your system, using monogram and the tsreader I've uploaded to make sure it is not breaking the compatibility the actual tsreader has with Monogram for New Zealand broadcasts... ?

    Thanks
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    The tsreader you posted doesn't work here. MediaPortal just hangs, so it definately needs more testing ;)

    EDIT: Logs attached, makes no sense to complain without them :oops:
     

    DucaSP

    Portal Member
    May 26, 2009
    16
    5
    Home Country
    Brazil Brazil
    Thanks pilehave... It is not building a valid graph with monogram and this tsreader, thats why it did not work.

    So it seems that unfortunately this patch will break compatibility with monogram for LATM AAC audio... Found out what is wrong on my system and can tell that it definitively won't work with monogram in LATM AAC, so, it is not an universal solution, back to the drawing board....:oops: Either figure out a way to make it work with both monogram and other filters, or, perhaps create a new filter based on libfaadwrapper2 that can be freely distributed and replace monogram, but this sure is not a simple task since it would require much more than a patch. Since ISDB-Tb uses explicit signaling, monogram is not able to cope with it....

    Back to the drawing board.... :oops: Thanks for the help testing this out guys. :D
     

    DucaSP

    Portal Member
    May 26, 2009
    16
    5
    Home Country
    Brazil Brazil
    Can someone mark this as rejected? I will probably try to figure out why monogram fails after the first second with Brazilian broadcasts and then forward the fix to the monogram developer, this seems to be the best way to handle this issue...

    Thanks!
     

    Users who are viewing this thread

    Top Bottom